Search is not available for this dataset
text
string
meta
dict
module Oscar.Data.Vec.Injectivity where open import Oscar.Data.Equality open import Oscar.Data.Vec Vec-head-inj : ∀ {a} {A : Set a} {x₁ x₂ : A} {N} {xs₁ xs₂ : Vec A N} → x₁ ∷ xs₁ ≡ x₂ ∷ xs₂ → x₁ ≡ x₂ Vec-head-inj refl = refl Vec-tail-inj : ∀ {a} {A : Set a} {x₁ x₂ : A} {N} {xs₁ xs₂ : Vec A N} → x₁ ∷ xs₁ ≡ x₂ ∷ xs₂ → xs₁ ≡ xs₂ Vec-tail-inj refl = refl
{ "alphanum_fraction": 0.6022408964, "avg_line_length": 29.75, "ext": "agda", "hexsha": "08dfd30abba4a47367d0ff41fb1ba8ddd281890f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-2/Oscar/Data/Vec/Injectivity.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-2/Oscar/Data/Vec/Injectivity.agda", "max_line_length": 102, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-2/Oscar/Data/Vec/Injectivity.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 160, "size": 357 }
{-# OPTIONS --without-K --rewriting #-} module old.Sharp where open import Basics open import Flat open import lib.Equivalence2 {- I want sthing like this record ♯ {@♭ l : ULevel} (A : Type l) : Type l where constructor _^♯ field _/♯ :{♭} A open ♯ publ -} -- Following Licata postulate -- Given a type A, ♯ A is a type ♯ : {i : ULevel} → Type i → Type i -- Given an element a : A, we have an element ♯i a : ♯ A ♯i : {i : ULevel} {A : Type i} → A → ♯ A -- To map out of ♯ A into some type ♯ (B a) depending on it, you may just map out of A. ♯-elim : {i j : ULevel} {A : Type i} (B : ♯ A → Type j) → ((a : A) → ♯ (B (♯i a))) → ((a : ♯ A) → ♯ (B a)) -- The resulting map out of ♯ A ``computes'' to the original map out of A on ♯i ♯-elim-β : {i j : ULevel} {A : Type i} {B : ♯ A → Type j} (f : (a : A) → ♯ (B (♯i a))) (a : A) → (♯-elim B f (♯i a)) ↦ (f a) {-# REWRITE ♯-elim-β #-} -- The type of equalities in a codiscrete type are codiscrete ♯path : {i : ULevel} {A : Type i} {x y : ♯ A} → (♯i {A = x == y}) is-an-equiv -- Given a crisp map into ♯ B, we get a cohesive map into it -- This encodes the adjunction between ♭ and ♯ on the level of types. uncrisp : {@♭ i : ULevel} {j : ULevel} {@♭ A : Type i} (B : A → Type j) → ((@♭ a : A) → ♯ (B a)) → (a : A) → ♯ (B a) -- If we uncrispen a function and then apply it to a crisp variable, we get the original result judgementally uncrisp-β : {@♭ i : ULevel} {j : ULevel} {@♭ A : Type i} (B : A → Type j) → (f : (@♭ a : A) → ♯ (B a)) → (@♭ a : A) → (uncrisp B f a) ↦ (f a) {-# REWRITE uncrisp-β #-} -- We can pull crisp elements out of ♯ A ♭♯e : {@♭ i : ULevel} {@♭ A : Type i} → ♯ A ::→ A -- If we take a crisp element of A, put it into ♯ A, and pull it out again, we get where we were judgementally ♭♯β : {@♭ i : ULevel} {@♭ A : Type i} (@♭ a : A) → (♭♯e (♯i a)) ↦ a {-# REWRITE ♭♯β #-} -- If we pull out a crisp element of ♯ A and then put it back in, we get back where we were -- Not sure why this isn't judgemental. ♭♯η : {@♭ i : ULevel} {@♭ A : Type i} (@♭ a : ♯ A) → a == ♯i (♭♯e a) -- We also posulate the half-adjoint needed for this to be a coherent adjunction. ♭♯η-▵ : {@♭ i : ULevel} {@♭ A : Type i} (@♭ a : A) → ♭♯η (♯i a) == refl ♯path-eq : {i : ULevel} {A : Type i} {x y : ♯ A} → (x == y) ≃ (♯ (x == y)) ♯path-eq = ♯i , ♯path ♯-rec : {i j : ULevel} {A : Type i} {B : Type j} → (A → ♯ B) → (♯ A → ♯ B) ♯-rec {B = B} = ♯-elim (λ _ → B) {- Given a family B : (@♭ a : A) → Type j crisply varying over A, we can form the family B' ≡ (λ (@♭ a : A) → ♯ (B a)). According to Shulman, we should be able to then get a cohesive variation B'' : (a : A) → Type j with the property that if (@♭ a : A) , B'' a ≡ B' a Or, shorter, from B : (@♭ a : A) → Type j, we should get C : (a : A) → Type j with the property that for (@♭ a : A), C a ≡ ♯ (B a) The signature of the operation B ↦ C must be ((@♭ a : A) → Type j) → (a : A) → Type j. Unfortunately, this doesn't tell us anything about where its landing -} postulate ♯' : {@♭ @♭ i : ULevel} {Γ : Type i} {j : ULevel} (A : Γ ::→ Type j) → Γ → Type j ♯'-law : {@♭ @♭ i : ULevel} {Γ : Type i} {j : ULevel} (A : Γ ::→ Type j) (@♭ x : Γ) → (♯' A) x ↦ ♯ (A x) {-# REWRITE ♯'-law #-} {- Here, we define let notations for ♯ to approximate the upper and lower ♯s that Shulman uses in his paper. We also define versions of the eliminator and uncrisper that take an implicit family argument, so we can use the let notation without explicitly noting the family. -} syntax ♯-elim B (λ u → t) a = let♯ a :=♯i u in♯ t in-family B syntax uncrisp B (λ u → t) a = let♯ a ↓♯:= u in♯ t in-family B ♯-elim' : {i j : ULevel} {A : Type i} {B : ♯ A → Type j} → ((a : A) → ♯ (B (♯i a))) → (a : ♯ A) → ♯ (B a) ♯-elim' {B = B} f = ♯-elim B f syntax ♯-elim' (λ u → t) a = let♯ a :=♯i u in♯ t uncrisp' : {@♭ i : ULevel} {j : ULevel} {@♭ A : Type i} {B : A → Type j} → (f : (@♭ a : A) → ♯ (B a)) → (a : A) → ♯ (B a) uncrisp' {B = B} f = uncrisp B f syntax uncrisp' (λ u → t) a = let♯ u := a ↓♯in♯ t -- A type A is codiscrete if the counit ♯i : A → ♯ A is an equivalence. _is-codiscrete : {i : ULevel} (A : Type i) → Type i _is-codiscrete {i} A = (♯i {A = A}) is-an-equiv -- To prove a type is an equivalence, it suffices to give a retract of ♯i _is-codiscrete-because_is-retract-by_ : {i : ULevel} (A : Type i) (r : ♯ A → A) (p : (a : A) → r (♯i a) == a) → A is-codiscrete A is-codiscrete-because r is-retract-by p = (♯i {A = A}) is-an-equivalence-because r is-inverse-by (λ a → -- Given an a : ♯ A, (let♯ a :=♯i b in♯ -- We suppose a is ♯i b (♯i (ap ♯i (p b))) -- apply p to b to get r (♯i b) == b, -- then apply ♯i to get ♯i r ♯i b == ♯i b -- then hit it with ♯i to get ♯ (♯i r ♯i b == ♯i b) in-family (λ (b : ♯ A) → ♯i (r b) == b) -- which is ♯ (♯i r a == a) by our hypothesis, ) |> (<– ♯path-eq) -- and we can strip the ♯ becacuse equality types are codiscrete. ) and p -- (λ a → (<– ♯path-eq) ((♯-elim (λ (b : ♯ A) → ♯i (r b) == b) -- (λ b → ♯i (ap ♯i (p b)))) a)) ♯→ : {i j : ULevel} {A : Type i} {B : Type j} (f : A → B) → (♯ A) → (♯ B) ♯→ {A = A} {B = B} f = ♯-rec (♯i ∘ f) -- Of course, ♯ A is codiscrete for any type A ♯-is-codiscrete : {i : ULevel} (A : Type i) → (♯ A) is-codiscrete ♯-is-codiscrete A = (♯ A) is-codiscrete-because (λ (a : ♯ (♯ A)) → let♯ a :=♯i x in♯ x) is-retract-by (λ a → refl) -- This is the actual equivalence A ≃ ♯ A, given that A is codiscrete codisc-eq : {i : ULevel} {A : Type i} (p : A is-codiscrete) → A ≃ (♯ A) codisc-eq = ♯i ,_ -- Theorem 3.7 of Shulman module _ {@♭ i : ULevel} {@♭ A : Type i} where code : (a b : ♯ A) → Type i code a = ♯' {Γ = ♯ A} {!!} {- (let♯ u := a ↓♯in♯ (let♯ v := b ↓♯in♯ (♯i (♯ (u == v))) ) ) -} ♯-identity-eq : (a b : A) → ((♯i a) == (♯i b)) ≃ ♯ (a == b) ♯-identity-eq a b = equiv {!!} fro {!!} {!!} where to : (♯i a) == (♯i b) → ♯ (a == b) to p = {!!} fro : ♯ (a == b) → ♯i a == ♯i b fro p = (let♯ p :=♯i q in♯ ♯i (ap ♯i q) ) |> (<– ♯path-eq) -- Theorem 6.22 of Shulman -- ♭ and ♯ reflect into eachothers categories. ♭♯-eq : {@♭ i : ULevel} {@♭ A : Type i} → ♭ (♯ A) ≃ ♭ A ♭♯-eq {A = A} = equiv to fro to-fro fro-to where to : ♭ (♯ A) → ♭ A to (a ^♭) = (♭♯e a) ^♭ fro : ♭ A → ♭ (♯ A) fro (a ^♭) = (♯i a) ^♭ to-fro : (a : ♭ A) → to (fro a) == a to-fro (a ^♭) = refl fro-to : (a : ♭ (♯ A)) → fro (to a) == a fro-to (a ^♭) = ♭-ap _^♭ (! (♭♯η a)) ♯♭-eq : {@♭ i : ULevel} {@♭ A : Type i} → ♯ (♭ A) ≃ ♯ A ♯♭-eq {A = A} = equiv to fro to-fro fro-to where to : ♯ (♭ A) → ♯ A to = ♯-rec (λ { (a ^♭) → (♯i a)}) fro : ♯ A → ♯ (♭ A) fro = ♯-rec (uncrisp _ (λ (a : A) → ♯i (a ^♭))) to-fro : (a : ♯ A) → to (fro a) == a to-fro = (<– ♯path-eq) ∘ (♯-elim (λ a → to (fro a) == a) (λ a → ♯i refl)) fro-to : (a : ♯ (♭ A)) → fro (to a) == a fro-to = (<– ♯path-eq) ∘ (♯-elim (λ a → fro (to a) == a) (λ { (a ^♭) → ♯i refl })) -- Theorem 6.27 of Shulman ♭♯-adjoint : {@♭ i j : ULevel} {@♭ A : Type i} {@♭ B : A → Type j} → ♭ ((a : ♭ A) → B (♭i a)) ≃ ♭ ((a : A) → ♯ (B a)) ♭♯-adjoint {i} {j} {A} {B} = equiv to fro to-fro fro-to where to : ♭ ((a : ♭ A) → B (♭i a)) → ♭ ((a : A) → ♯ (B a)) to (f ^♭) = (uncrisp B (λ (@♭ a : A) → ♯i (f (a ^♭)))) ^♭ fro : ♭ ((a : A) → ♯ (B a)) → ♭ ((a : ♭ A) → B (♭i a)) fro (f ^♭) = (λ { (a ^♭) → ♭♯e (f a) }) ^♭ to-fro : (f : ♭ ((a : A) → ♯ (B a))) → to (fro f) == f to-fro (f ^♭)= ♭-ap _^♭ {!!} fro-to : (f : ♭ ((a : ♭ A) → B (♭i a))) → fro (to f) == f fro-to (@♭ f ^♭) = ♭-ap _^♭ (λ= (λ a → {!(λ { (a₁ ^♭) → ♭♯e (uncrisp B (λ (a₂ : _) → ♯i (f (a₂ ^♭))) a₁) })!})) has-level-is-codiscrete : {i : ULevel} {A : Type i} {n : ℕ₋₂} → (has-level n A) is-codiscrete has-level-is-codiscrete = {!!} ♯-preserves-level : {i : ULevel} {A : Type i} {n : ℕ₋₂} (p : has-level n A) → has-level n (♯ A) ♯-preserves-level {i} {A} {⟨-2⟩} p = has-level-in (♯i (contr-center p) , (<– ♯path-eq) ∘ (♯-elim (λ a → ♯i (contr-center p) == a) (λ a → ♯i (ap ♯i (contr-path p a))))) ♯-preserves-level {i} {A} {S n} p = has-level-in (λ x y → (<– (codisc-eq has-level-is-codiscrete)) ((♯-elim (λ y → has-level n (x == y)) {!!}) y) ) {- to-crisp : {@♭ i : ULevel} {j : ULevel} {A : ♭ (Type i)} {B : Type j} → (♭i A → B) → (A ♭:→ B) to-crisp {A = (A ^♭)} f = (<– ♭-recursion-eq) (f ∘ ♭i) _is-codiscrete : {@♭ j : ULevel} (B : Type j) → Type (lsucc j) _is-codiscrete {j} B = (A : ♭ (Type j)) → to-crisp {A = A} {B = B} is-an-equiv codisc-eq : {@♭ j : ULevel} {B : Type j} (p : B is-codiscrete) {A : ♭ (Type j)} → (♭i A → B) ≃ (A ♭:→ B) codisc-eq {j} {B} p {A} = (to-crisp {A = A} {B = B}) , (p A) codisc-promote : {@♭ j : ULevel} {B : Type j} (p : B is-codiscrete) {A : ♭ (Type j)} → (A ♭:→ B) → (♭i A → B) codisc-promote p = <– (codisc-eq p) _is-codiscrete-is-a-prop : {@♭ j : ULevel} (B : Type j) → (B is-codiscrete) is-a-prop _is-codiscrete-is-a-prop {j} B = mapping-into-prop-is-a-prop (λ { (A ^♭) → is-equiv-is-prop }) _is-codiscrete₀ : {@♭ j : ULevel} (B : Type j) → Type₀ _is-codiscrete₀ {j} B = (resize₀ ((B is-codiscrete) , (B is-codiscrete-is-a-prop))) holds ⊤-is-codiscrete : ⊤ is-codiscrete ⊤-is-codiscrete = λ { (A ^♭) → to-crisp is-an-equivalence-because (λ _ _ → unit) is-inverse-by (λ f → refl) and (λ f → refl) } {- Π-codisc : {@♭ i : ULevel} {A : Type i} {B : A → Type i} → ((a : A) → (B a) is-codiscrete) → ((a : A) → B a) is-codiscrete Π-codisc {i} {A} {B} f = λ { (T ^♭) → to-crisp is-an-equivalence-because (λ g → λ t a → {!codisc-promote (f a)!}) is-inverse-by {!!} and {!!}} -} {- question : {@♭ i : ULevel} (B : Type i) (r : (A : ♭ (Type i)) → (to-crisp {A = A} {B = B}) is-split-inj) → B is-codiscrete question {i = i} B r = λ { (A ^♭) → to-crisp is-an-equivalence-because fst (r (A ^♭)) is-inverse-by (λ f → {!!}) and snd (r (A ^♭)) } -} {- The idea from this proof is to map out of the suspension =-is-codiscrete : {@♭ i : ULevel} {B : Type i} (p : B is-codiscrete) (x y : B) → (x == y) is-codiscrete =-is-codiscrete {i} {B} p x y = λ { (A ^♭) → to-crisp is-an-equivalence-because {!!} is-inverse-by {!!} and {!!} } -} -}
{ "alphanum_fraction": 0.427907777, "avg_line_length": 34.9069069069, "ext": "agda", "hexsha": "56b2f3d643facdff2517714f34f91ba8b52d4377", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "glangmead/formalization", "max_forks_repo_path": "cohesion/david_jaz_261/old/Sharp.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "glangmead/formalization", "max_issues_repo_path": "cohesion/david_jaz_261/old/Sharp.agda", "max_line_length": 117, "max_stars_count": 6, "max_stars_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "glangmead/formalization", "max_stars_repo_path": "cohesion/david_jaz_261/old/Sharp.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-13T05:51:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-06T17:39:22.000Z", "num_tokens": 4927, "size": 11624 }
{-# OPTIONS --without-K --safe #-} module Definition.Conversion.Decidable where open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Properties open import Definition.Conversion open import Definition.Conversion.Whnf open import Definition.Conversion.Soundness open import Definition.Conversion.Symmetry open import Definition.Conversion.Stability open import Definition.Conversion.Conversion open import Definition.Typed.Consequences.Syntactic open import Definition.Typed.Consequences.Substitution open import Definition.Typed.Consequences.Injectivity open import Definition.Typed.Consequences.Reduction open import Definition.Typed.Consequences.Equality open import Definition.Typed.Consequences.Inequality as IE open import Definition.Typed.Consequences.NeTypeEq open import Definition.Typed.Consequences.SucCong open import Definition.Typed.Consequences.Inversion open import Tools.Nat open import Tools.Product open import Tools.Empty open import Tools.Nullary import Tools.PropositionalEquality as PE -- Algorithmic equality of variables infers propositional equality. strongVarEq : ∀ {m n A Γ} → Γ ⊢ var n ~ var m ↑ A → n PE.≡ m strongVarEq (var-refl x x≡y) = x≡y -- Helper function for decidability of applications. dec~↑-app : ∀ {k k₁ l l₁ F F₁ G G₁ B Γ} → Γ ⊢ k ∷ Π F ▹ G → Γ ⊢ k₁ ∷ Π F₁ ▹ G₁ → Γ ⊢ k ~ k₁ ↓ B → Dec (Γ ⊢ l [conv↑] l₁ ∷ F) → Dec (∃ λ A → Γ ⊢ k ∘ l ~ k₁ ∘ l₁ ↑ A) dec~↑-app k k₁ k~k₁ (yes p) = let whnfA , neK , neL = ne~↓ k~k₁ ⊢A , ⊢k , ⊢l = syntacticEqTerm (soundness~↓ k~k₁) ΠFG₁≡A = neTypeEq neK k ⊢k H , E , A≡ΠHE = Π≡A ΠFG₁≡A whnfA F≡H , G₁≡E = injectivity (PE.subst (λ x → _ ⊢ _ ≡ x) A≡ΠHE ΠFG₁≡A) in yes (E [ _ ] , app-cong (PE.subst (λ x → _ ⊢ _ ~ _ ↓ x) A≡ΠHE k~k₁) (convConvTerm p F≡H)) dec~↑-app k₂ k₃ k~k₁ (no ¬p) = no (λ { (_ , app-cong x x₁) → let whnfA , neK , neL = ne~↓ x ⊢A , ⊢k , ⊢l = syntacticEqTerm (soundness~↓ x) ΠFG≡ΠF₂G₂ = neTypeEq neK k₂ ⊢k F≡F₂ , G≡G₂ = injectivity ΠFG≡ΠF₂G₂ in ¬p (convConvTerm x₁ (sym F≡F₂)) }) -- Helper function for decidability for neutrals of natural number type. decConv↓Term-ℕ-ins : ∀ {t u Γ} → Γ ⊢ t [conv↓] u ∷ ℕ → Γ ⊢ t ~ t ↓ ℕ → Γ ⊢ t ~ u ↓ ℕ decConv↓Term-ℕ-ins (ℕ-ins x) t~t = x decConv↓Term-ℕ-ins (ne-ins x x₁ () x₃) t~t decConv↓Term-ℕ-ins (zero-refl x) ([~] A D whnfB ()) decConv↓Term-ℕ-ins (suc-cong x) ([~] A D whnfB ()) -- Helper function for decidability for neutrals of empty type. decConv↓Term-Empty-ins : ∀ {t u Γ} → Γ ⊢ t [conv↓] u ∷ Empty → Γ ⊢ t ~ t ↓ Empty → Γ ⊢ t ~ u ↓ Empty decConv↓Term-Empty-ins (Empty-ins x) t~t = x decConv↓Term-Empty-ins (ne-ins x x₁ () x₃) t~t -- Helper function for decidability for neutrals of a neutral type. decConv↓Term-ne-ins : ∀ {t u A Γ} → Neutral A → Γ ⊢ t [conv↓] u ∷ A → ∃ λ B → Γ ⊢ t ~ u ↓ B decConv↓Term-ne-ins () (ℕ-ins x) decConv↓Term-ne-ins () (Empty-ins x) decConv↓Term-ne-ins neA (ne-ins x x₁ x₂ x₃) = _ , x₃ decConv↓Term-ne-ins () (univ x x₁ x₂) decConv↓Term-ne-ins () (zero-refl x) decConv↓Term-ne-ins () (suc-cong x) decConv↓Term-ne-ins () (η-eq x₁ x₂ x₃ x₄ x₅) -- Helper function for decidability for impossibility of terms not being equal -- as neutrals when they are equal as terms and the first is a neutral. decConv↓Term-ℕ : ∀ {t u Γ} → Γ ⊢ t [conv↓] u ∷ ℕ → Γ ⊢ t ~ t ↓ ℕ → ¬ (Γ ⊢ t ~ u ↓ ℕ) → ⊥ decConv↓Term-ℕ (ℕ-ins x) t~t ¬u~u = ¬u~u x decConv↓Term-ℕ (ne-ins x x₁ () x₃) t~t ¬u~u decConv↓Term-ℕ (zero-refl x) ([~] A D whnfB ()) ¬u~u decConv↓Term-ℕ (suc-cong x) ([~] A D whnfB ()) ¬u~u -- Helper function for extensional equality of Unit. decConv↓Term-Unit : ∀ {t u Γ} → Γ ⊢ t [conv↓] t ∷ Unit → Γ ⊢ u [conv↓] u ∷ Unit → Dec (Γ ⊢ t [conv↓] u ∷ Unit) decConv↓Term-Unit tConv uConv = let t≡t = soundnessConv↓Term tConv u≡u = soundnessConv↓Term uConv _ , [t] , _ = syntacticEqTerm t≡t _ , [u] , _ = syntacticEqTerm u≡u _ , tWhnf , _ = whnfConv↓Term tConv _ , uWhnf , _ = whnfConv↓Term uConv in yes (η-unit [t] [u] tWhnf uWhnf) mutual -- Decidability of algorithmic equality of neutrals. dec~↑ : ∀ {k l R T Γ} → Γ ⊢ k ~ k ↑ R → Γ ⊢ l ~ l ↑ T → Dec (∃ λ A → Γ ⊢ k ~ l ↑ A) dec~↑ (var-refl {n} x₂ x≡y) (var-refl {m} x₃ x≡y₁) with n ≟ m ... | yes PE.refl = yes (_ , var-refl x₂ x≡y₁) ... | no ¬p = no (λ { (A , k~l) → ¬p (strongVarEq k~l) }) dec~↑ (var-refl x₁ x≡y) (app-cong x₂ x₃) = no (λ { (_ , ()) }) dec~↑ (var-refl x₁ x≡y) (fst-cong x₂) = no (λ { (_ , ()) }) dec~↑ (var-refl x₁ x≡y) (snd-cong x₂) = no (λ { (_ , ()) }) dec~↑ (var-refl x₁ x≡y) (natrec-cong x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑ (var-refl x₁ x≡y) (Emptyrec-cong x₂ x₃) = no (λ { (_ , ()) }) dec~↑ (app-cong x x₁) (app-cong x₂ x₃) with dec~↓ x x₂ ... | yes (A , k~l) = let whnfA , neK , neL = ne~↓ k~l ⊢A , ⊢k , ⊢l = syntacticEqTerm (soundness~↓ k~l) _ , ⊢l₁ , _ = syntacticEqTerm (soundness~↓ x) _ , ⊢l₂ , _ = syntacticEqTerm (soundness~↓ x₂) ΠFG≡A = neTypeEq neK ⊢l₁ ⊢k ΠF′G′≡A = neTypeEq neL ⊢l₂ ⊢l F≡F′ , G≡G′ = injectivity (trans ΠFG≡A (sym ΠF′G′≡A)) in dec~↑-app ⊢l₁ ⊢l₂ k~l (decConv↑TermConv F≡F′ x₁ x₃) ... | no ¬p = no (λ { (_ , app-cong x₄ x₅) → ¬p (_ , x₄) }) dec~↑ (app-cong x₁ x₂) (var-refl x₃ x≡y) = no (λ { (_ , ()) }) dec~↑ (app-cong x x₁) (fst-cong x₂) = no (λ { (_ , ()) }) dec~↑ (app-cong x x₁) (snd-cong x₂) = no (λ { (_ , ()) }) dec~↑ (app-cong x x₁) (natrec-cong x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑ (app-cong x x₁) (Emptyrec-cong x₂ x₃) = no (λ { (_ , ()) }) dec~↑ (fst-cong {k} k~k) (fst-cong {l} l~l) with dec~↓ k~k l~l ... | yes (A , k~l) = let whnfA , neK , neL = ne~↓ k~l ⊢A , ⊢k , ⊢l = syntacticEqTerm (soundness~↓ k~l) _ , ⊢k₁ , _ = syntacticEqTerm (soundness~↓ k~k) ΣFG≡A = neTypeEq neK ⊢k₁ ⊢k F , G , A≡ΣFG = Σ≡A ΣFG≡A whnfA in yes (F , fst-cong (PE.subst (λ x → _ ⊢ _ ~ _ ↓ x) A≡ΣFG k~l)) ... | no ¬p = no (λ { (_ , fst-cong x₂) → ¬p (_ , x₂) }) dec~↑ (fst-cong x) (var-refl x₁ x₂) = no (λ { (_ , ()) }) dec~↑ (fst-cong x) (app-cong x₁ x₂) = no (λ { (_ , ()) }) dec~↑ (fst-cong x) (snd-cong x₁) = no (λ { (_ , ()) }) dec~↑ (fst-cong x) (natrec-cong x₁ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑ (fst-cong x) (Emptyrec-cong x₁ x₂) = no (λ { (_ , ()) }) dec~↑ (snd-cong {k} k~k) (snd-cong {l} l~l) with dec~↓ k~k l~l ... | yes (A , k~l) = let whnfA , neK , neL = ne~↓ k~l ⊢A , ⊢k , ⊢l = syntacticEqTerm (soundness~↓ k~l) _ , ⊢k₁ , _ = syntacticEqTerm (soundness~↓ k~k) ΣFG≡A = neTypeEq neK ⊢k₁ ⊢k F , G , A≡ΣFG = Σ≡A ΣFG≡A whnfA in yes (G [ fst k ] , snd-cong (PE.subst (λ x → _ ⊢ _ ~ _ ↓ x) A≡ΣFG k~l)) ... | no ¬p = no (λ { (_ , snd-cong x₂) → ¬p (_ , x₂) }) dec~↑ (snd-cong x) (var-refl x₁ x₂) = no (λ { (_ , ()) }) dec~↑ (snd-cong x) (app-cong x₁ x₂) = no (λ { (_ , ()) }) dec~↑ (snd-cong x) (fst-cong x₁) = no (λ { (_ , ()) }) dec~↑ (snd-cong x) (natrec-cong x₁ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑ (snd-cong x) (Emptyrec-cong x₁ x₂) = no (λ { (_ , ()) }) dec~↑ (natrec-cong x x₁ x₂ x₃) (natrec-cong x₄ x₅ x₆ x₇) with decConv↑ x x₄ ... | yes p with decConv↑TermConv (substTypeEq (soundnessConv↑ p) (refl (zeroⱼ (wfEqTerm (soundness~↓ x₃))))) x₁ x₅ | decConv↑TermConv (sucCong (soundnessConv↑ p)) x₂ x₆ | dec~↓ x₃ x₇ ... | yes p₁ | yes p₂ | yes (A , k~l) = let whnfA , neK , neL = ne~↓ k~l ⊢A , ⊢k , ⊢l = syntacticEqTerm (soundness~↓ k~l) _ , ⊢l∷ℕ , _ = syntacticEqTerm (soundness~↓ x₃) ⊢ℕ≡A = neTypeEq neK ⊢l∷ℕ ⊢k A≡ℕ = ℕ≡A ⊢ℕ≡A whnfA k~l′ = PE.subst (λ x → _ ⊢ _ ~ _ ↓ x) A≡ℕ k~l in yes (_ , natrec-cong p p₁ p₂ k~l′) ... | yes p₁ | yes p₂ | no ¬p = no (λ { (_ , natrec-cong x₈ x₉ x₁₀ x₁₁) → ¬p (_ , x₁₁) }) ... | yes p₁ | no ¬p | r = no (λ { (_ , natrec-cong x₈ x₉ x₁₀ x₁₁) → ¬p x₁₀ }) ... | no ¬p | w | r = no (λ { (_ , natrec-cong x₈ x₉ x₁₀ x₁₁) → ¬p x₉ }) dec~↑ (natrec-cong x x₁ x₂ x₃) (natrec-cong x₄ x₅ x₆ x₇) | no ¬p = no (λ { (_ , natrec-cong x₈ x₉ x₁₀ x₁₁) → ¬p x₈ }) dec~↑ (natrec-cong _ _ _ _) (var-refl _ _) = no (λ { (_ , ()) }) dec~↑ (natrec-cong _ _ _ _) (fst-cong _) = no (λ { (_ , ()) }) dec~↑ (natrec-cong _ _ _ _) (snd-cong _) = no (λ { (_ , ()) }) dec~↑ (natrec-cong _ _ _ _) (app-cong _ _) = no (λ { (_ , ()) }) dec~↑ (natrec-cong _ _ _ _) (Emptyrec-cong _ _) = no (λ { (_ , ()) }) dec~↑ (Emptyrec-cong x x₁) (Emptyrec-cong x₄ x₅) with decConv↑ x x₄ | dec~↓ x₁ x₅ ... | yes p | yes (A , k~l) = let whnfA , neK , neL = ne~↓ k~l ⊢A , ⊢k , ⊢l = syntacticEqTerm (soundness~↓ k~l) _ , ⊢l∷Empty , _ = syntacticEqTerm (soundness~↓ x₁) ⊢Empty≡A = neTypeEq neK ⊢l∷Empty ⊢k A≡Empty = Empty≡A ⊢Empty≡A whnfA k~l′ = PE.subst (λ x → _ ⊢ _ ~ _ ↓ x) A≡Empty k~l in yes (_ , Emptyrec-cong p k~l′) ... | yes p | no ¬p = no (λ { (_ , Emptyrec-cong a b) → ¬p (_ , b) }) ... | no ¬p | r = no (λ { (_ , Emptyrec-cong a b) → ¬p a }) dec~↑ (Emptyrec-cong _ _) (var-refl _ _) = no (λ { (_ , ()) }) dec~↑ (Emptyrec-cong _ _) (fst-cong _) = no (λ { (_ , ()) }) dec~↑ (Emptyrec-cong _ _) (snd-cong _) = no (λ { (_ , ()) }) dec~↑ (Emptyrec-cong _ _) (app-cong _ _) = no (λ { (_ , ()) }) dec~↑ (Emptyrec-cong _ _) (natrec-cong _ _ _ _) = no (λ { (_ , ()) }) dec~↑′ : ∀ {k l R T Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ k ~ k ↑ R → Δ ⊢ l ~ l ↑ T → Dec (∃ λ A → Γ ⊢ k ~ l ↑ A) dec~↑′ Γ≡Δ k~k l~l = dec~↑ k~k (stability~↑ (symConEq Γ≡Δ) l~l) -- Decidability of algorithmic equality of neutrals with types in WHNF. dec~↓ : ∀ {k l R T Γ} → Γ ⊢ k ~ k ↓ R → Γ ⊢ l ~ l ↓ T → Dec (∃ λ A → Γ ⊢ k ~ l ↓ A) dec~↓ ([~] A D whnfB k~l) ([~] A₁ D₁ whnfB₁ k~l₁) with dec~↑ k~l k~l₁ dec~↓ ([~] A D whnfB k~l) ([~] A₁ D₁ whnfB₁ k~l₁) | yes (B , k~l₂) = let ⊢B , _ , _ = syntacticEqTerm (soundness~↑ k~l₂) C , whnfC , D′ = whNorm ⊢B in yes (C , [~] B (red D′) whnfC k~l₂) dec~↓ ([~] A D whnfB k~l) ([~] A₁ D₁ whnfB₁ k~l₁) | no ¬p = no (λ { (A₂ , [~] A₃ D₂ whnfB₂ k~l₂) → ¬p (A₃ , k~l₂) }) -- Decidability of algorithmic equality of types. decConv↑ : ∀ {A B Γ} → Γ ⊢ A [conv↑] A → Γ ⊢ B [conv↑] B → Dec (Γ ⊢ A [conv↑] B) decConv↑ ([↑] A′ B′ D D′ whnfA′ whnfB′ A′<>B′) ([↑] A″ B″ D₁ D″ whnfA″ whnfB″ A′<>B″) rewrite whrDet* (D , whnfA′) (D′ , whnfB′) | whrDet* (D₁ , whnfA″) (D″ , whnfB″) with decConv↓ A′<>B′ A′<>B″ decConv↑ ([↑] A′ B′ D D′ whnfA′ whnfB′ A′<>B′) ([↑] A″ B″ D₁ D″ whnfA″ whnfB″ A′<>B″) | yes p = yes ([↑] B′ B″ D′ D″ whnfB′ whnfB″ p) decConv↑ ([↑] A′ B′ D D′ whnfA′ whnfB′ A′<>B′) ([↑] A″ B″ D₁ D″ whnfA″ whnfB″ A′<>B″) | no ¬p = no (λ { ([↑] A‴ B‴ D₂ D‴ whnfA‴ whnfB‴ A′<>B‴) → let A‴≡B′ = whrDet* (D₂ , whnfA‴) (D′ , whnfB′) B‴≡B″ = whrDet* (D‴ , whnfB‴) (D″ , whnfB″) in ¬p (PE.subst₂ (λ x y → _ ⊢ x [conv↓] y) A‴≡B′ B‴≡B″ A′<>B‴) }) decConv↑′ : ∀ {A B Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ A [conv↑] A → Δ ⊢ B [conv↑] B → Dec (Γ ⊢ A [conv↑] B) decConv↑′ Γ≡Δ A B = decConv↑ A (stabilityConv↑ (symConEq Γ≡Δ) B) -- Decidability of algorithmic equality of types in WHNF. decConv↓ : ∀ {A B Γ} → Γ ⊢ A [conv↓] A → Γ ⊢ B [conv↓] B → Dec (Γ ⊢ A [conv↓] B) -- True cases decConv↓ (U-refl x) (U-refl x₁) = yes (U-refl x) decConv↓ (ℕ-refl x) (ℕ-refl x₁) = yes (ℕ-refl x) decConv↓ (Empty-refl x) (Empty-refl x₁) = yes (Empty-refl x) decConv↓ (Unit-refl x) (Unit-refl x₁) = yes (Unit-refl x) -- Inspective cases decConv↓ (ne x) (ne x₁) with dec~↓ x x₁ decConv↓ (ne x) (ne x₁) | yes (A , k~l) = let whnfA , neK , neL = ne~↓ k~l ⊢A , ⊢k , _ = syntacticEqTerm (soundness~↓ k~l) _ , ⊢k∷U , _ = syntacticEqTerm (soundness~↓ x) ⊢U≡A = neTypeEq neK ⊢k∷U ⊢k A≡U = U≡A ⊢U≡A k~l′ = PE.subst (λ x → _ ⊢ _ ~ _ ↓ x) A≡U k~l in yes (ne k~l′) decConv↓ (ne x) (ne x₁) | no ¬p = no (λ x₂ → ¬p (U , decConv↓-ne x₂ x)) decConv↓ (Π-cong x x₁ x₂) (Π-cong x₃ x₄ x₅) with decConv↑ x₁ x₄ ... | yes p with decConv↑′ (reflConEq (wf x) ∙ soundnessConv↑ p) x₂ x₅ ... | yes p₁ = yes (Π-cong x p p₁) ... | no ¬p = no (λ { (ne ([~] A D whnfB ())) ; (Π-cong x₆ x₇ x₈) → ¬p x₈ }) decConv↓ (Π-cong x x₁ x₂) (Π-cong x₃ x₄ x₅) | no ¬p = no (λ { (ne ([~] A D whnfB ())) ; (Π-cong x₆ x₇ x₈) → ¬p x₇ }) decConv↓ (Σ-cong x x₁ x₂) (Σ-cong x₃ x₄ x₅) with decConv↑ x₁ x₄ ... | yes p with decConv↑′ (reflConEq (wf x) ∙ soundnessConv↑ p) x₂ x₅ ... | yes p₁ = yes (Σ-cong x p p₁) ... | no ¬p = no (λ { (ne ([~] A D whnfB ())) ; (Σ-cong x₆ x₇ x₈) → ¬p x₈ }) decConv↓ (Σ-cong x x₁ x₂) (Σ-cong x₃ x₄ x₅) | no ¬p = no (λ { (ne ([~] A D whnfB ())) ; (Σ-cong x₆ x₇ x₈) → ¬p x₇ }) -- False cases decConv↓ (U-refl x) (ℕ-refl x₁) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (U-refl x) (Empty-refl x₁) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (U-refl x) (Unit-refl x₁) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (U-refl x) (ne x₁) = no (λ x₂ → let whnfA , neK , neL = ne~↓ x₁ in ⊥-elim (IE.U≢ne neK (soundnessConv↓ x₂))) decConv↓ (U-refl x) (Π-cong x₁ x₂ x₃) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (U-refl x) (Σ-cong x₁ x₂ x₃) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (ℕ-refl x) (U-refl x₁) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (ℕ-refl x) (Empty-refl x₁) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (ℕ-refl x) (Unit-refl x₁) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (ℕ-refl x) (ne x₁) = no (λ x₂ → let whnfA , neK , neL = ne~↓ x₁ in ⊥-elim (IE.ℕ≢ne neK (soundnessConv↓ x₂))) decConv↓ (ℕ-refl x) (Π-cong x₁ x₂ x₃) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (ℕ-refl x) (Σ-cong x₁ x₂ x₃) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Empty-refl x) (U-refl x₁) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Empty-refl x) (ℕ-refl x₁) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Empty-refl x) (Unit-refl x₁) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Empty-refl x) (ne x₁) = no (λ x₂ → let whnfA , neK , neL = ne~↓ x₁ in ⊥-elim (IE.Empty≢neⱼ neK (soundnessConv↓ x₂))) decConv↓ (Empty-refl x) (Π-cong x₁ x₂ x₃) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Empty-refl x) (Σ-cong x₁ x₂ x₃) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Unit-refl x) (U-refl x₁) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Unit-refl x) (ℕ-refl x₁) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Unit-refl x) (Empty-refl x₁) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Unit-refl x) (ne x₁) = no (λ x₂ → let whnfA , neK , neL = ne~↓ x₁ in ⊥-elim (IE.Unit≢neⱼ neK (soundnessConv↓ x₂))) decConv↓ (Unit-refl x) (Π-cong x₁ x₂ x₃) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Unit-refl x) (Σ-cong x₁ x₂ x₃) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (ne x) (U-refl x₁) = no (λ x₂ → let whnfA , neK , neL = ne~↓ x in ⊥-elim (IE.U≢ne neK (sym (soundnessConv↓ x₂)))) decConv↓ (ne x) (ℕ-refl x₁) = no (λ x₂ → let whnfA , neK , neL = ne~↓ x in ⊥-elim (IE.ℕ≢ne neK (sym (soundnessConv↓ x₂)))) decConv↓ (ne x) (Empty-refl x₁) = no (λ x₂ → let whnfA , neK , neL = ne~↓ x in ⊥-elim (IE.Empty≢neⱼ neK (sym (soundnessConv↓ x₂)))) decConv↓ (ne x) (Unit-refl x₁) = no (λ x₂ → let whnfA , neK , neL = ne~↓ x in ⊥-elim (IE.Unit≢neⱼ neK (sym (soundnessConv↓ x₂)))) decConv↓ (ne x) (Π-cong x₁ x₂ x₃) = no (λ x₄ → let whnfA , neK , neL = ne~↓ x in ⊥-elim (IE.Π≢ne neK (sym (soundnessConv↓ x₄)))) decConv↓ (ne x) (Σ-cong x₁ x₂ x₃) = no (λ x₄ → let whnfA , neK , neL = ne~↓ x in ⊥-elim (IE.Σ≢ne neK (sym (soundnessConv↓ x₄)))) decConv↓ (Π-cong x x₁ x₂) (U-refl x₃) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Π-cong x x₁ x₂) (ℕ-refl x₃) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Π-cong x x₁ x₂) (Empty-refl x₃) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Π-cong x x₁ x₂) (Unit-refl x₃) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Π-cong x x₁ x₂) (Σ-cong x₃ x₄ x₅) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Π-cong x x₁ x₂) (ne x₃) = no (λ x₄ → let whnfA , neK , neL = ne~↓ x₃ in ⊥-elim (IE.Π≢ne neK (soundnessConv↓ x₄))) decConv↓ (Σ-cong x x₁ x₂) (U-refl x₃) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Σ-cong x x₁ x₂) (ℕ-refl x₃) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Σ-cong x x₁ x₂) (Empty-refl x₃) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Σ-cong x x₁ x₂) (Unit-refl x₃) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Σ-cong x x₁ x₂) (Π-cong x₃ x₄ x₅) = no (λ { (ne ([~] A D whnfB ())) }) decConv↓ (Σ-cong x x₁ x₂) (ne x₃) = no (λ x₄ → let whnfA , neK , neL = ne~↓ x₃ in ⊥-elim (IE.Σ≢ne neK (soundnessConv↓ x₄))) -- Helper function for decidability of neutral types. decConv↓-ne : ∀ {A B Γ} → Γ ⊢ A [conv↓] B → Γ ⊢ A ~ A ↓ U → Γ ⊢ A ~ B ↓ U decConv↓-ne (U-refl x) A~A = A~A decConv↓-ne (ℕ-refl x) A~A = A~A decConv↓-ne (Empty-refl x) A~A = A~A decConv↓-ne (ne x) A~A = x decConv↓-ne (Π-cong x x₁ x₂) ([~] A D whnfB ()) -- Decidability of algorithmic equality of terms. decConv↑Term : ∀ {t u A Γ} → Γ ⊢ t [conv↑] t ∷ A → Γ ⊢ u [conv↑] u ∷ A → Dec (Γ ⊢ t [conv↑] u ∷ A) decConv↑Term ([↑]ₜ B t′ u′ D d d′ whnfB whnft′ whnfu′ t<>u) ([↑]ₜ B₁ t″ u″ D₁ d₁ d″ whnfB₁ whnft″ whnfu″ t<>u₁) rewrite whrDet* (D , whnfB) (D₁ , whnfB₁) | whrDet*Term (d , whnft′) (d′ , whnfu′) | whrDet*Term (d₁ , whnft″) (d″ , whnfu″) with decConv↓Term t<>u t<>u₁ decConv↑Term ([↑]ₜ B t′ u′ D d d′ whnfB whnft′ whnfu′ t<>u) ([↑]ₜ B₁ t″ u″ D₁ d₁ d″ whnfB₁ whnft″ whnfu″ t<>u₁) | yes p = yes ([↑]ₜ B₁ u′ u″ D₁ d′ d″ whnfB₁ whnfu′ whnfu″ p) decConv↑Term ([↑]ₜ B t′ u′ D d d′ whnfB whnft′ whnfu′ t<>u) ([↑]ₜ B₁ t″ u″ D₁ d₁ d″ whnfB₁ whnft″ whnfu″ t<>u₁) | no ¬p = no (λ { ([↑]ₜ B₂ t‴ u‴ D₂ d₂ d‴ whnfB₂ whnft‴ whnfu‴ t<>u₂) → let B₂≡B₁ = whrDet* (D₂ , whnfB₂) (D₁ , whnfB₁) t‴≡u′ = whrDet*Term (d₂ , whnft‴) (PE.subst (λ x → _ ⊢ _ ⇒* _ ∷ x) (PE.sym B₂≡B₁) d′ , whnfu′) u‴≡u″ = whrDet*Term (d‴ , whnfu‴) (PE.subst (λ x → _ ⊢ _ ⇒* _ ∷ x) (PE.sym B₂≡B₁) d″ , whnfu″) in ¬p (PE.subst₃ (λ x y z → _ ⊢ x [conv↓] y ∷ z) t‴≡u′ u‴≡u″ B₂≡B₁ t<>u₂) }) decConv↑Term′ : ∀ {t u A Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ t [conv↑] t ∷ A → Δ ⊢ u [conv↑] u ∷ A → Dec (Γ ⊢ t [conv↑] u ∷ A) decConv↑Term′ Γ≡Δ t u = decConv↑Term t (stabilityConv↑Term (symConEq Γ≡Δ) u) -- Decidability of algorithmic equality of terms in WHNF. decConv↓Term : ∀ {t u A Γ} → Γ ⊢ t [conv↓] t ∷ A → Γ ⊢ u [conv↓] u ∷ A → Dec (Γ ⊢ t [conv↓] u ∷ A) -- True cases decConv↓Term (zero-refl x) (zero-refl x₁) = yes (zero-refl x) decConv↓Term (Unit-ins t~t) uConv = decConv↓Term-Unit (Unit-ins t~t) uConv decConv↓Term (η-unit [t] _ tUnit _) uConv = decConv↓Term-Unit (η-unit [t] [t] tUnit tUnit) uConv -- Inspective cases decConv↓Term (ℕ-ins x) (ℕ-ins x₁) with dec~↓ x x₁ decConv↓Term (ℕ-ins x) (ℕ-ins x₁) | yes (A , k~l) = let whnfA , neK , neL = ne~↓ k~l ⊢A , ⊢k , ⊢l = syntacticEqTerm (soundness~↓ k~l) _ , ⊢l∷ℕ , _ = syntacticEqTerm (soundness~↓ x) ⊢ℕ≡A = neTypeEq neK ⊢l∷ℕ ⊢k A≡ℕ = ℕ≡A ⊢ℕ≡A whnfA k~l′ = PE.subst (λ x → _ ⊢ _ ~ _ ↓ x) A≡ℕ k~l in yes (ℕ-ins k~l′) decConv↓Term (ℕ-ins x) (ℕ-ins x₁) | no ¬p = no (λ x₂ → ¬p (ℕ , decConv↓Term-ℕ-ins x₂ x)) decConv↓Term (Empty-ins x) (Empty-ins x₁) with dec~↓ x x₁ decConv↓Term (Empty-ins x) (Empty-ins x₁) | yes (A , k~l) = let whnfA , neK , neL = ne~↓ k~l ⊢A , ⊢k , ⊢l = syntacticEqTerm (soundness~↓ k~l) _ , ⊢l∷Empty , _ = syntacticEqTerm (soundness~↓ x) ⊢Empty≡A = neTypeEq neK ⊢l∷Empty ⊢k A≡Empty = Empty≡A ⊢Empty≡A whnfA k~l′ = PE.subst (λ x → _ ⊢ _ ~ _ ↓ x) A≡Empty k~l in yes (Empty-ins k~l′) decConv↓Term (Empty-ins x) (Empty-ins x₁) | no ¬p = no (λ x₂ → ¬p (Empty , decConv↓Term-Empty-ins x₂ x)) decConv↓Term (ne-ins x x₁ x₂ x₃) (ne-ins x₄ x₅ x₆ x₇) with dec~↓ x₃ x₇ decConv↓Term (ne-ins x x₁ x₂ x₃) (ne-ins x₄ x₅ x₆ x₇) | yes (A , k~l) = yes (ne-ins x₁ x₄ x₆ k~l) decConv↓Term (ne-ins x x₁ x₂ x₃) (ne-ins x₄ x₅ x₆ x₇) | no ¬p = no (λ x₈ → ¬p (decConv↓Term-ne-ins x₆ x₈)) decConv↓Term (univ x x₁ x₂) (univ x₃ x₄ x₅) with decConv↓ x₂ x₅ decConv↓Term (univ x x₁ x₂) (univ x₃ x₄ x₅) | yes p = yes (univ x₁ x₃ p) decConv↓Term (univ x x₁ x₂) (univ x₃ x₄ x₅) | no ¬p = no (λ { (ne-ins x₆ x₇ () x₉) ; (univ x₆ x₇ x₈) → ¬p x₈ }) decConv↓Term (suc-cong x) (suc-cong x₁) with decConv↑Term x x₁ decConv↓Term (suc-cong x) (suc-cong x₁) | yes p = yes (suc-cong p) decConv↓Term (suc-cong x) (suc-cong x₁) | no ¬p = no (λ { (ℕ-ins ([~] A D whnfB ())) ; (ne-ins x₂ x₃ () x₅) ; (suc-cong x₂) → ¬p x₂ }) decConv↓Term (Σ-η ⊢t _ tProd _ fstConvT sndConvT) (Σ-η ⊢u _ uProd _ fstConvU sndConvU) with decConv↑Term fstConvT fstConvU ... | yes P with let ⊢F , ⊢G = syntacticΣ (syntacticTerm ⊢t) fstt≡fstu = soundnessConv↑Term P Gfstt≡Gfstu = substTypeEq (refl ⊢G) fstt≡fstu in decConv↑TermConv Gfstt≡Gfstu sndConvT sndConvU ... | yes Q = yes (Σ-η ⊢t ⊢u tProd uProd P Q) ... | no ¬Q = no (λ { (Σ-η _ _ _ _ _ Q) → ¬Q Q } ) decConv↓Term (Σ-η _ _ _ _ _ _) (Σ-η _ _ _ _ _ _) | no ¬P = no (λ { (Σ-η _ _ _ _ P _) → ¬P P } ) decConv↓Term (η-eq x₁ x₂ x₃ x₄ x₅) (η-eq x₇ x₈ x₉ x₁₀ x₁₁) with decConv↑Term x₅ x₁₁ decConv↓Term (η-eq x₁ x₂ x₃ x₄ x₅) (η-eq x₇ x₈ x₉ x₁₀ x₁₁) | yes p = yes (η-eq x₂ x₇ x₄ x₁₀ p) decConv↓Term (η-eq x₁ x₂ x₃ x₄ x₅) (η-eq x₇ x₈ x₉ x₁₀ x₁₁) | no ¬p = no (λ { (ne-ins x₁₂ x₁₃ () x₁₅) ; (η-eq x₁₃ x₁₄ x₁₅ x₁₆ x₁₇) → ¬p x₁₇ }) -- False cases decConv↓Term (ℕ-ins x) (zero-refl x₁) = no (λ x₂ → decConv↓Term-ℕ x₂ x (λ { ([~] A D whnfB ()) })) decConv↓Term (ℕ-ins x) (suc-cong x₁) = no (λ x₂ → decConv↓Term-ℕ x₂ x (λ { ([~] A D whnfB ()) })) decConv↓Term (zero-refl x) (ℕ-ins x₁) = no (λ x₂ → decConv↓Term-ℕ (symConv↓Term′ x₂) x₁ (λ { ([~] A D whnfB ()) })) decConv↓Term (zero-refl x) (suc-cong x₁) = no (λ { (ℕ-ins ([~] A D whnfB ())) ; (ne-ins x₂ x₃ () x₅) }) decConv↓Term (suc-cong x) (ℕ-ins x₁) = no (λ x₂ → decConv↓Term-ℕ (symConv↓Term′ x₂) x₁ (λ { ([~] A D whnfB ()) })) decConv↓Term (suc-cong x) (zero-refl x₁) = no (λ { (ℕ-ins ([~] A D whnfB ())) ; (ne-ins x₂ x₃ () x₅) }) -- Decidability of algorithmic equality of terms of equal types. decConv↑TermConv : ∀ {t u A B Γ} → Γ ⊢ A ≡ B → Γ ⊢ t [conv↑] t ∷ A → Γ ⊢ u [conv↑] u ∷ B → Dec (Γ ⊢ t [conv↑] u ∷ A) decConv↑TermConv A≡B t u = decConv↑Term t (convConvTerm u (sym A≡B))
{ "alphanum_fraction": 0.4943458522, "avg_line_length": 46.3288718929, "ext": "agda", "hexsha": "9f3b26ed0dea97e33089de08cffdf1cc7538e711", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Vtec234/logrel-mltt", "max_forks_repo_path": "Definition/Conversion/Decidable.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Vtec234/logrel-mltt", "max_issues_repo_path": "Definition/Conversion/Decidable.agda", "max_line_length": 82, "max_stars_count": null, "max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Vtec234/logrel-mltt", "max_stars_repo_path": "Definition/Conversion/Decidable.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 11030, "size": 24230 }
module _ where record R : Set₁ where field Type : Set postulate A : Set module M (x : A) (r₁ : R) (y : A) where open R r₁ r₂ : R r₂ = record { Type = A } foo : R.Type r₂ foo = {!!} -- R.Type r₂ bar : R.Type r₁ bar = {!!} -- Type
{ "alphanum_fraction": 0.5076923077, "avg_line_length": 11.8181818182, "ext": "agda", "hexsha": "2d6ce13913bcabcfc6c9d355f10575dc9ce94f8c", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue2210.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue2210.agda", "max_line_length": 39, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue2210.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 106, "size": 260 }
{-# OPTIONS --cubical --safe #-} module Data.Tuple where open import Data.Tuple.Base public
{ "alphanum_fraction": 0.7127659574, "avg_line_length": 15.6666666667, "ext": "agda", "hexsha": "48f3fa43da2c8d66919f9242472613858d490869", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Data/Tuple.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Data/Tuple.agda", "max_line_length": 34, "max_stars_count": 6, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Data/Tuple.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 23, "size": 94 }
open import Relation.Binary using (Rel; Setoid; IsEquivalence) module GGT.Structures {a b ℓ₁ ℓ₂} {G : Set a} -- The underlying group carrier {Ω : Set b} -- The underlying set space (_≈_ : Rel G ℓ₁) -- The underlying group equality (_≋_ : Rel Ω ℓ₂) -- The underlying space equality where open import Level using (_⊔_) open import Algebra.Core open import Algebra.Structures {a} {ℓ₁} {G} using (IsGroup) open import GGT.Definitions record IsAction (· : Opᵣ G Ω) (∙ : Op₂ G) (ε : G) (⁻¹ : Op₁ G) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where field isEquivalence : IsEquivalence _≋_ isGroup : IsGroup _≈_ ∙ ε ⁻¹ actAssoc : ActAssoc _≈_ _≋_ · ∙ actId : ActLeftIdentity _≈_ _≋_ ε · ·-cong : ·-≋-Congruence _≈_ _≋_ · G-ext : ≈-Ext _≈_ _≋_ · setoid : Setoid b ℓ₂ setoid = record { Carrier = Ω; _≈_ = _≋_; isEquivalence = isEquivalence }
{ "alphanum_fraction": 0.589055794, "avg_line_length": 25.1891891892, "ext": "agda", "hexsha": "25fd6560135285a52d92c864259fbeb554e25f10", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "zampino/ggt", "max_forks_repo_path": "src/ggt/Structures.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "zampino/ggt", "max_issues_repo_path": "src/ggt/Structures.agda", "max_line_length": 62, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "zampino/ggt", "max_stars_repo_path": "src/ggt/Structures.agda", "max_stars_repo_stars_event_max_datetime": "2020-11-28T05:48:39.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-17T11:10:00.000Z", "num_tokens": 364, "size": 932 }
------------------------------------------------------------------------ -- Soundness and completeness ------------------------------------------------------------------------ module TotalParserCombinators.Derivative.SoundComplete where open import Category.Monad open import Codata.Musical.Notation open import Data.List import Data.List.Categorical open import Data.Maybe hiding (_>>=_) open import Data.Product open import Level open import Relation.Binary.PropositionalEquality open RawMonad {f = zero} Data.List.Categorical.monad using () renaming (_>>=_ to _>>=′_; _⊛_ to _⊛′_) open import TotalParserCombinators.Derivative.Definition import TotalParserCombinators.InitialBag as I open import TotalParserCombinators.Lib open import TotalParserCombinators.Parser open import TotalParserCombinators.Semantics ------------------------------------------------------------------------ -- Soundness sound : ∀ {Tok R xs x s} {t} (p : Parser Tok R xs) → x ∈ D t p · s → x ∈ p · t ∷ s sound token return = token sound (p₁ ∣ p₂) (∣-left x∈p₁) = ∣-left (sound p₁ x∈p₁) sound (_∣_ {xs₁ = xs₁} p₁ p₂) (∣-right ._ x∈p₂) = ∣-right xs₁ (sound p₂ x∈p₂) sound (f <$> p) (<$> x∈p) = <$> sound p x∈p sound (_⊛_ {fs = nothing} {xs = just _} p₁ p₂) (f∈p₁′ ⊛ x∈p₂) = [ ○ - ◌ ] sound p₁ f∈p₁′ ⊛ x∈p₂ sound (_⊛_ {fs = just _} {xs = just _} p₁ p₂) (∣-left (f∈p₁′ ⊛ x∈p₂)) = [ ○ - ○ ] sound p₁ f∈p₁′ ⊛ x∈p₂ sound (_⊛_ {fs = just fs} {xs = just _} p₁ p₂) (∣-right ._ (f∈ret⋆ ⊛ x∈p₂′)) with Return⋆.sound fs f∈ret⋆ sound (_⊛_ {fs = just fs} {xs = just _} p₁ p₂) (∣-right ._ (f∈ret⋆ ⊛ x∈p₂′)) | (refl , f∈fs) = [ ○ - ○ ] I.sound p₁ f∈fs ⊛ sound p₂ x∈p₂′ sound (_⊛_ {fs = nothing} {xs = nothing} p₁ p₂) (f∈p₁′ ⊛ x∈p₂) = [ ◌ - ◌ ] sound (♭ p₁) f∈p₁′ ⊛ x∈p₂ sound (_⊛_ {fs = just _} {xs = nothing} p₁ p₂) (∣-left (f∈p₁′ ⊛ x∈p₂)) = [ ◌ - ○ ] sound (♭ p₁) f∈p₁′ ⊛ x∈p₂ sound (_⊛_ {fs = just fs} {xs = nothing} p₁ p₂) (∣-right ._ (f∈ret⋆ ⊛ x∈p₂′)) with Return⋆.sound fs f∈ret⋆ sound (_⊛_ {fs = just fs} {xs = nothing} p₁ p₂) (∣-right ._ (f∈ret⋆ ⊛ x∈p₂′)) | (refl , f∈fs) = [ ◌ - ○ ] I.sound (♭ p₁) f∈fs ⊛ sound p₂ x∈p₂′ sound (_>>=_ {xs = nothing} {f = just _} p₁ p₂) (x∈p₁′ >>= y∈p₂x) = [ ○ - ◌ ] sound p₁ x∈p₁′ >>= y∈p₂x sound (_>>=_ {xs = just xs} {f = just _} p₁ p₂) (∣-right ._ (y∈ret⋆ >>= z∈p₂′y)) with Return⋆.sound xs y∈ret⋆ sound (_>>=_ {xs = just xs} {f = just _} p₁ p₂) (∣-right ._ (y∈ret⋆ >>= z∈p₂′y)) | (refl , y∈xs) = [ ○ - ○ ] I.sound p₁ y∈xs >>= sound (p₂ _) z∈p₂′y sound (_>>=_ {xs = just xs} {f = just _} p₁ p₂) (∣-left (x∈p₁′ >>= y∈p₂x)) = [ ○ - ○ ] sound p₁ x∈p₁′ >>= y∈p₂x sound (_>>=_ {xs = nothing} {f = nothing} p₁ p₂) (x∈p₁′ >>= y∈p₂x) = [ ◌ - ◌ ] sound (♭ p₁) x∈p₁′ >>= y∈p₂x sound (_>>=_ {xs = just xs} {f = nothing} p₁ p₂) (∣-right ._ (y∈ret⋆ >>= z∈p₂′y)) with Return⋆.sound xs y∈ret⋆ sound (_>>=_ {xs = just xs} {f = nothing} p₁ p₂) (∣-right ._ (y∈ret⋆ >>= z∈p₂′y)) | (refl , y∈xs) = [ ◌ - ○ ] I.sound (♭ p₁) y∈xs >>= sound (p₂ _) z∈p₂′y sound (_>>=_ {xs = just xs} {f = nothing} p₁ p₂) (∣-left (x∈p₁′ >>= y∈p₂x)) = [ ◌ - ○ ] sound (♭ p₁) x∈p₁′ >>= y∈p₂x sound (nonempty p) x∈p = nonempty (sound p x∈p) sound (cast _ p) x∈p = cast (sound p x∈p) sound (return _) () sound fail () ------------------------------------------------------------------------ -- Completeness mutual complete : ∀ {Tok R xs x s t} {p : Parser Tok R xs} → x ∈ p · t ∷ s → x ∈ D t p · s complete x∈p = complete′ _ x∈p refl complete′ : ∀ {Tok R xs x s s′ t} (p : Parser Tok R xs) → x ∈ p · s′ → s′ ≡ t ∷ s → x ∈ D t p · s complete′ token token refl = return complete′ (p₁ ∣ p₂) (∣-left x∈p₁) refl = ∣-left (complete x∈p₁) complete′ (p₁ ∣ p₂) (∣-right _ x∈p₂) refl = ∣-right (D-bag _ p₁) (complete x∈p₂) complete′ (f <$> p) (<$> x∈p) refl = <$> complete x∈p complete′ (_⊛_ {fs = nothing} {xs = just _} p₁ p₂) (_⊛_ {s₁ = _ ∷ _} f∈p₁ x∈p₂) refl = _⊛_ {fs = ○} {xs = ○} (complete f∈p₁) x∈p₂ complete′ (_⊛_ {fs = just _} {xs = just _} p₁ p₂) (_⊛_ {s₁ = _ ∷ _} f∈p₁ x∈p₂) refl = ∣-left (_⊛_ {fs = ○} {xs = ○} (complete f∈p₁) x∈p₂) complete′ (_⊛_ {fs = just _} {xs = just xs} p₁ p₂) (_⊛_ {s₁ = []} f∈p₁ x∈p₂) refl = ∣-right (D-bag _ p₁ ⊛′ xs) (_⊛_ {fs = ○} {xs = ○} (Return⋆.complete (I.complete f∈p₁)) (complete x∈p₂)) complete′ (_⊛_ {fs = nothing} {xs = nothing} p₁ p₂) (_⊛_ {s₁ = _ ∷ _} f∈p₁ x∈p₂) refl = _⊛_ {fs = ○} {xs = ◌} (complete f∈p₁) x∈p₂ complete′ (_⊛_ {fs = just _} {xs = nothing} p₁ p₂) (_⊛_ {s₁ = _ ∷ _} f∈p₁ x∈p₂) refl = ∣-left (_⊛_ {fs = ○} {xs = ◌} (complete f∈p₁) x∈p₂) complete′ (_⊛_ {fs = just _} {xs = nothing} p₁ p₂) (_⊛_ {s₁ = []} f∈p₁ x∈p₂) refl = ∣-right [] (_⊛_ {fs = ○} {xs = ○} (Return⋆.complete (I.complete f∈p₁)) (complete x∈p₂)) complete′ (_>>=_ {xs = nothing} {f = just _} p₁ p₂) (_>>=_ {s₁ = _ ∷ _} x∈p₁ y∈p₂x) refl = _>>=_ {xs = ○} {f = ○} (complete x∈p₁) y∈p₂x complete′ (_>>=_ {xs = just _} {f = just _} p₁ p₂) (_>>=_ {s₁ = _ ∷ _} x∈p₁ y∈p₂x) refl = ∣-left (_>>=_ {xs = ○} {f = ○} (complete x∈p₁) y∈p₂x) complete′ (_>>=_ {xs = just _} {f = just f} p₁ p₂) (_>>=_ {s₁ = []} x∈p₁ y∈p₂x) refl = ∣-right (D-bag _ p₁ >>=′ f) (_>>=_ {xs = ○} {f = ○} (Return⋆.complete (I.complete x∈p₁)) (complete y∈p₂x)) complete′ (_>>=_ {xs = nothing} {f = nothing} p₁ p₂) (_>>=_ {s₁ = _ ∷ _} x∈p₁ y∈p₂x) refl = _>>=_ {xs = ○} {f = ◌} (complete x∈p₁) y∈p₂x complete′ (_>>=_ {xs = just _} {f = nothing} p₁ p₂) (_>>=_ {s₁ = _ ∷ _} x∈p₁ y∈p₂x) refl = ∣-left (_>>=_ {xs = ○} {f = ◌} (complete x∈p₁) y∈p₂x) complete′ (_>>=_ {xs = just _} {f = nothing} p₁ p₂) (_>>=_ {s₁ = []} x∈p₁ y∈p₂x) refl = ∣-right [] (_>>=_ {xs = ○} {f = ○} (Return⋆.complete (I.complete x∈p₁)) (complete y∈p₂x)) complete′ (nonempty p) (nonempty x∈p) refl = complete x∈p complete′ (cast _ p) (cast x∈p) refl = complete x∈p complete′ (return _) () refl complete′ fail () refl complete′ (_⊛_ {fs = nothing} _ _) (_⊛_ {s₁ = []} f∈p₁ _) _ with I.complete f∈p₁ ... | () complete′ (_>>=_ {xs = nothing} _ _) (_>>=_ {s₁ = []} x∈p₁ _) _ with I.complete x∈p₁ ... | ()
{ "alphanum_fraction": 0.4270732717, "avg_line_length": 58.918699187, "ext": "agda", "hexsha": "dabde40dfe399818dd14c0b6c27735c48346e3fa", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "TotalParserCombinators/Derivative/SoundComplete.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "TotalParserCombinators/Derivative/SoundComplete.agda", "max_line_length": 137, "max_stars_count": 1, "max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/parser-combinators", "max_stars_repo_path": "TotalParserCombinators/Derivative/SoundComplete.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z", "num_tokens": 2998, "size": 7247 }
module _ where id : {A : Set} → A → A id x = x const : {A : Set₁} {B : Set} → A → (B → A) const x = λ _ → x {-# DISPLAY const x y = x #-} infixr 4 _,_ infixr 2 _×_ record Σ (A : Set) (B : A → Set) : Set where constructor _,_ field proj₁ : A proj₂ : B proj₁ open Σ public _×_ : (A B : Set) → Set A × B = Σ A (const B) Σ-map : ∀ {A B : Set} {P : A → Set} {Q : B → Set} → (f : A → B) → (∀ {x} → P x → Q (f x)) → Σ A P → Σ B Q Σ-map f g = λ p → (f (proj₁ p) , g (proj₂ p)) foo : {A B : Set} → A × B → A × B foo = Σ-map id {!!}
{ "alphanum_fraction": 0.4456327986, "avg_line_length": 17, "ext": "agda", "hexsha": "609de0dafd419061710a51ef71ae7a0521e71ce3", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue1873.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue1873.agda", "max_line_length": 51, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue1873.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 254, "size": 561 }
{-# OPTIONS --safe #-} module Cubical.Algebra.CommRing.Instances.UnivariatePoly where open import Cubical.Foundations.Prelude open import Cubical.Algebra.CommRing open import Cubical.Algebra.Polynomials.Univariate.Base open import Cubical.Algebra.Polynomials.Univariate.Properties private variable ℓ : Level UnivariatePoly : (CommRing ℓ) → CommRing ℓ UnivariatePoly R = (PolyMod.Poly R) , str where open CommRingStr --(snd R) str : CommRingStr (PolyMod.Poly R) 0r str = PolyModTheory.0P R 1r str = PolyModTheory.1P R _+_ str = PolyModTheory._Poly+_ R _·_ str = PolyModTheory._Poly*_ R - str = PolyModTheory.Poly- R isCommRing str = makeIsCommRing (PolyMod.isSetPoly R) (PolyModTheory.Poly+Assoc R) (PolyModTheory.Poly+Rid R) (PolyModTheory.Poly+Inverses R) (PolyModTheory.Poly+Comm R) (PolyModTheory.Poly*Associative R) (PolyModTheory.Poly*Rid R) (PolyModTheory.Poly*LDistrPoly+ R) (PolyModTheory.Poly*Commutative R)
{ "alphanum_fraction": 0.5657587549, "avg_line_length": 37.7941176471, "ext": "agda", "hexsha": "227a3fffe974f902edba3ffe9546b418a9e9022c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_path": "Cubical/Algebra/CommRing/Instances/UnivariatePoly.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_path": "Cubical/Algebra/CommRing/Instances/UnivariatePoly.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_path": "Cubical/Algebra/CommRing/Instances/UnivariatePoly.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 315, "size": 1285 }
{- This example used to fail but after the point-free evaluation fix it seems to work #-} module Issue259c where postulate A : Set a : A b : ({x : A} → A) → A C : A → Set d : {x : A} → A d {x} = a e : A e = b (λ {x} → d {x}) F : C e → Set₁ F _ with Set F _ | _ = Set
{ "alphanum_fraction": 0.5283687943, "avg_line_length": 14.1, "ext": "agda", "hexsha": "75bdd2ad1bcd27b9d4043709b9ffb186a95a43b2", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue259c.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue259c.agda", "max_line_length": 68, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue259c.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 114, "size": 282 }
{-# OPTIONS --cubical --safe #-} module Cubical.Data.Unit.Properties where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Nat open import Cubical.Data.Unit.Base isContrUnit : isContr Unit isContrUnit = tt , λ {tt → refl} isPropUnit : isProp Unit isPropUnit _ _ i = tt -- definitionally equal to: isContr→isProp isContrUnit isOfHLevelUnit : (n : ℕ) → isOfHLevel n Unit isOfHLevelUnit n = isContr→isOfHLevel n isContrUnit
{ "alphanum_fraction": 0.7788461538, "avg_line_length": 26, "ext": "agda", "hexsha": "606a88c78a055ba5a7fa8f345e5b648917d71236", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "borsiemir/cubical", "max_forks_repo_path": "Cubical/Data/Unit/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "borsiemir/cubical", "max_issues_repo_path": "Cubical/Data/Unit/Properties.agda", "max_line_length": 76, "max_stars_count": null, "max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "borsiemir/cubical", "max_stars_repo_path": "Cubical/Data/Unit/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 151, "size": 520 }
-- The NO_POSITIVITY_CHECK pragma is not allowed in safe mode. module Issue1614a where {-# NO_POSITIVITY_CHECK #-} data D : Set where lam : (D → D) → D
{ "alphanum_fraction": 0.6987179487, "avg_line_length": 19.5, "ext": "agda", "hexsha": "518b629c0cafaa537e2017fa1a1163d3429c1440", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Issue1614a.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Issue1614a.agda", "max_line_length": 62, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue1614a.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 46, "size": 156 }
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module BottomBottom where open import Common.FOL.FOL postulate bot bot' : ⊥ {-# ATP prove bot bot' #-} {-# ATP prove bot' bot #-} -- $ apia-fot BottomBottom.agda -- Proving the conjecture in /tmp/BottomBottom/8-bot.tptp ... -- Vampire 0.6 (revision 903) proved the conjecture -- Proving the conjecture in /tmp/BottomBottom/8-bot39.tptp ... -- Vampire 0.6 (revision 903) proved the conjecture
{ "alphanum_fraction": 0.6355633803, "avg_line_length": 29.8947368421, "ext": "agda", "hexsha": "6a785fe1afbc3aa914dca95e38aedb3c4ef433fc", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/papers/fossacs-2012/BottomBottom.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/papers/fossacs-2012/BottomBottom.agda", "max_line_length": 63, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/papers/fossacs-2012/BottomBottom.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 150, "size": 568 }
------------------------------------------------------------------------------ -- The gcd is a common divisor ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Program.GCD.Partial.CommonDivisorATP where open import FOTC.Base open import FOTC.Base.PropertiesATP open import FOTC.Data.Nat open import FOTC.Data.Nat.Divisibility.NotBy0 open import FOTC.Data.Nat.Divisibility.NotBy0.PropertiesATP open import FOTC.Data.Nat.Induction.NonAcc.LexicographicATP open import FOTC.Data.Nat.Inequalities open import FOTC.Data.Nat.Inequalities.EliminationPropertiesATP open import FOTC.Data.Nat.Inequalities.PropertiesATP open import FOTC.Data.Nat.PropertiesATP open import FOTC.Program.GCD.Partial.Definitions open import FOTC.Program.GCD.Partial.GCD open import FOTC.Program.GCD.Partial.TotalityATP ------------------------------------------------------------------------------ -- Some cases of the gcd-∣₁. -- We don't prove that -- -- gcd-∣₁ : ... → (gcd m n) ∣ m -- because this proof should be defined mutually recursive with the -- proof -- -- gcd-∣₂ : ... → (gcd m n) ∣ n. -- -- Therefore, instead of proving -- -- gcdCD : ... → CD m n (gcd m n) -- -- using these proofs (i.e. the conjunction of them), we proved it -- using well-founded induction. -- gcd 0 (succ n) ∣ 0. postulate gcd-0S-∣₁ : ∀ {n} → N n → gcd zero (succ₁ n) ∣ zero {-# ATP prove gcd-0S-∣₁ #-} -- gcd (succ₁ m) 0 ∣ succ₁ m. postulate gcd-S0-∣₁ : ∀ {n} → N n → gcd (succ₁ n) zero ∣ succ₁ n {-# ATP prove gcd-S0-∣₁ ∣-refl-S #-} -- gcd (succ₁ m) (succ₁ n) ∣ succ₁ m, when succ₁ m ≯ succ₁ n. postulate gcd-S≯S-∣₁ : ∀ {m n} → N m → N n → (gcd (succ₁ m) (succ₁ n ∸ succ₁ m) ∣ succ₁ m) → succ₁ m ≯ succ₁ n → gcd (succ₁ m) (succ₁ n) ∣ succ₁ m {-# ATP prove gcd-S≯S-∣₁ #-} -- gcd (succ₁ m) (succ₁ n) ∣ succ₁ m when succ₁ m > succ₁ n. {- Proof: 1. gcd (Sm ∸ Sn) Sn | (Sm ∸ Sn) IH 2. gcd (Sm ∸ Sn) Sn | Sn gcd-∣₂ 3. gcd (Sm ∸ Sn) Sn | (Sm ∸ Sn) + Sn m∣n→m∣o→m∣n+o 1,2 4. Sm > Sn Hip 5. gcd (Sm ∸ Sn) Sn | Sm arith-gcd-m>n₂ 3,4 6. gcd Sm Sn = gcd (Sm ∸ Sn) Sn gcd eq. 4 7. gcd Sm Sn | Sm subst 5,6 -} -- For the proof using the ATP we added the helper hypothesis: -- 1. gcd (succ₁ m ∸ succ₁ n) (succ₁ n) ∣ (succ₁ m ∸ succ₁ n) + succ₁ n. -- 2. (succ₁ m ∸ succ₁ n) + succ₁ n ≡ succ₁ m. postulate gcd-S>S-∣₁-ah : ∀ {m n} → N m → N n → (gcd (succ₁ m ∸ succ₁ n) (succ₁ n) ∣ (succ₁ m ∸ succ₁ n)) → (gcd (succ₁ m ∸ succ₁ n) (succ₁ n) ∣ succ₁ n) → succ₁ m > succ₁ n → gcd (succ₁ m ∸ succ₁ n) (succ₁ n) ∣ (succ₁ m ∸ succ₁ n) + succ₁ n → ((succ₁ m ∸ succ₁ n) + succ₁ n ≡ succ₁ m) → gcd (succ₁ m) (succ₁ n) ∣ succ₁ m {-# ATP prove gcd-S>S-∣₁-ah #-} gcd-S>S-∣₁ : ∀ {m n} → N m → N n → (gcd (succ₁ m ∸ succ₁ n) (succ₁ n) ∣ (succ₁ m ∸ succ₁ n)) → (gcd (succ₁ m ∸ succ₁ n) (succ₁ n) ∣ succ₁ n) → succ₁ m > succ₁ n → gcd (succ₁ m) (succ₁ n) ∣ succ₁ m gcd-S>S-∣₁ {m} {n} Nm Nn ih gcd-∣₂ Sm>Sn = gcd-S>S-∣₁-ah Nm Nn ih gcd-∣₂ Sm>Sn (x∣y→x∣z→x∣y+z gcd-Sm-Sn,Sn-N Sm-Sn-N (nsucc Nn) ih gcd-∣₂) (x>y→x∸y+y≡x (nsucc Nm) (nsucc Nn) Sm>Sn) where Sm-Sn-N : N (succ₁ m ∸ succ₁ n) Sm-Sn-N = ∸-N (nsucc Nm) (nsucc Nn) gcd-Sm-Sn,Sn-N : N (gcd (succ₁ m ∸ succ₁ n) (succ₁ n)) gcd-Sm-Sn,Sn-N = gcd-N Sm-Sn-N (nsucc Nn) (λ p → ⊥-elim (S≢0 (∧-proj₂ p))) ------------------------------------------------------------------------------ -- Some case of the gcd-∣₂. -- We don't prove that gcd-∣₂ : ... → gcd m n ∣ n. The reason is -- the same to don't prove gcd-∣₁ : ... → gcd m n ∣ m. -- gcd 0 (succ₁ n) ∣₂ succ₁ n. postulate gcd-0S-∣₂ : ∀ {n} → N n → gcd zero (succ₁ n) ∣ succ₁ n {-# ATP prove gcd-0S-∣₂ ∣-refl-S #-} -- gcd (succ₁ m) 0 ∣ 0. postulate gcd-S0-∣₂ : ∀ {m} → N m → gcd (succ₁ m) zero ∣ zero {-# ATP prove gcd-S0-∣₂ #-} -- gcd (succ₁ m) (succ₁ n) ∣ succ₁ n when succ₁ m ≯ succ₁ n. {- Proof: 1. gcd Sm (Sn ∸ Sm) | (Sn ∸ Sm) IH 2 gcd Sm (Sn ∸ Sm) | Sm gcd-∣₁ 3. gcd Sm (Sn ∸ Sm) | (Sn ∸ Sm) + Sm m∣n→m∣o→m∣n+o 1,2 4. Sm ≯ Sn Hip 5. gcd (Sm ∸ Sn) Sn | Sm arith-gcd-m≤n₂ 3,4 6. gcd Sm Sn = gcd Sm (Sn ∸ Sm) gcd eq. 4 7. gcd Sm Sn | Sn subst 5,6 -} -- For the proof using the ATP we added the helper hypothesis: -- 1. gcd (succ₁ m) (succ₁ n ∸ succ₁ m) ∣ (succ₁ n ∸ succ₁ m) + succ₁ m. -- 2 (succ₁ n ∸ succ₁ m) + succ₁ m ≡ succ₁ n. postulate gcd-S≯S-∣₂-ah : ∀ {m n} → N m → N n → (gcd (succ₁ m) (succ₁ n ∸ succ₁ m) ∣ (succ₁ n ∸ succ₁ m)) → (gcd (succ₁ m) (succ₁ n ∸ succ₁ m) ∣ succ₁ m) → succ₁ m ≯ succ₁ n → (gcd (succ₁ m) (succ₁ n ∸ succ₁ m) ∣ (succ₁ n ∸ succ₁ m) + succ₁ m) → ((succ₁ n ∸ succ₁ m) + succ₁ m ≡ succ₁ n) → gcd (succ₁ m) (succ₁ n) ∣ succ₁ n {-# ATP prove gcd-S≯S-∣₂-ah #-} gcd-S≯S-∣₂ : ∀ {m n} → N m → N n → (gcd (succ₁ m) (succ₁ n ∸ succ₁ m) ∣ (succ₁ n ∸ succ₁ m)) → (gcd (succ₁ m) (succ₁ n ∸ succ₁ m) ∣ succ₁ m) → succ₁ m ≯ succ₁ n → gcd (succ₁ m) (succ₁ n) ∣ succ₁ n gcd-S≯S-∣₂ {m} {n} Nm Nn ih gcd-∣₁ Sm≯Sn = gcd-S≯S-∣₂-ah Nm Nn ih gcd-∣₁ Sm≯Sn (x∣y→x∣z→x∣y+z gcd-Sm,Sn-Sm-N Sn-Sm-N (nsucc Nm) ih gcd-∣₁) (x≤y→y∸x+x≡y (nsucc Nm) (nsucc Nn) (x≯y→x≤y (nsucc Nm) (nsucc Nn) Sm≯Sn)) where Sn-Sm-N : N (succ₁ n ∸ succ₁ m) Sn-Sm-N = ∸-N (nsucc Nn) (nsucc Nm) gcd-Sm,Sn-Sm-N : N (gcd (succ₁ m) (succ₁ n ∸ succ₁ m)) gcd-Sm,Sn-Sm-N = gcd-N (nsucc Nm) (Sn-Sm-N) (λ p → ⊥-elim (S≢0 (∧-proj₁ p))) -- gcd (succ₁ m) (succ₁ n) ∣ succ₁ n when succ₁ m > succ₁ n. postulate gcd-S>S-∣₂ : ∀ {m n} → N m → N n → (gcd (succ₁ m ∸ succ₁ n) (succ₁ n) ∣ succ₁ n) → succ₁ m > succ₁ n → gcd (succ₁ m) (succ₁ n) ∣ succ₁ n {-# ATP prove gcd-S>S-∣₂ #-} ------------------------------------------------------------------------------ -- The gcd is CD. -- We will prove that gcdCD : ... → CD m n (gcd m n). -- The gcd 0 (succ₁ n) is CD. gcd-0S-CD : ∀ {n} → N n → CD zero (succ₁ n) (gcd zero (succ₁ n)) gcd-0S-CD Nn = (gcd-0S-∣₁ Nn , gcd-0S-∣₂ Nn) -- The gcd (succ₁ m) 0 is CD. gcd-S0-CD : ∀ {m} → N m → CD (succ₁ m) zero (gcd (succ₁ m) zero) gcd-S0-CD Nm = (gcd-S0-∣₁ Nm , gcd-S0-∣₂ Nm) -- The gcd (succ₁ m) (succ₁ n) when succ₁ m > succ₁ n is CD. gcd-S>S-CD : ∀ {m n} → N m → N n → (CD (succ₁ m ∸ succ₁ n) (succ₁ n) (gcd (succ₁ m ∸ succ₁ n) (succ₁ n))) → succ₁ m > succ₁ n → CD (succ₁ m) (succ₁ n) (gcd (succ₁ m) (succ₁ n)) gcd-S>S-CD {m} {n} Nm Nn acc Sm>Sn = (gcd-S>S-∣₁ Nm Nn acc-∣₁ acc-∣₂ Sm>Sn , gcd-S>S-∣₂ Nm Nn acc-∣₂ Sm>Sn) where acc-∣₁ : gcd (succ₁ m ∸ succ₁ n) (succ₁ n) ∣ (succ₁ m ∸ succ₁ n) acc-∣₁ = ∧-proj₁ acc acc-∣₂ : gcd (succ₁ m ∸ succ₁ n) (succ₁ n) ∣ succ₁ n acc-∣₂ = ∧-proj₂ acc -- The gcd (succ₁ m) (succ₁ n) when succ₁ m ≯ succ₁ n is CD. gcd-S≯S-CD : ∀ {m n} → N m → N n → (CD (succ₁ m) (succ₁ n ∸ succ₁ m) (gcd (succ₁ m) (succ₁ n ∸ succ₁ m))) → succ₁ m ≯ succ₁ n → CD (succ₁ m) (succ₁ n) (gcd (succ₁ m) (succ₁ n)) gcd-S≯S-CD {m} {n} Nm Nn acc Sm≯Sn = (gcd-S≯S-∣₁ Nm Nn acc-∣₁ Sm≯Sn , gcd-S≯S-∣₂ Nm Nn acc-∣₂ acc-∣₁ Sm≯Sn) where acc-∣₁ : gcd (succ₁ m) (succ₁ n ∸ succ₁ m) ∣ succ₁ m acc-∣₁ = ∧-proj₁ acc acc-∣₂ : gcd (succ₁ m) (succ₁ n ∸ succ₁ m) ∣ (succ₁ n ∸ succ₁ m) acc-∣₂ = ∧-proj₂ acc -- The gcd m n when m > n is CD. gcd-x>y-CD : ∀ {m n} → N m → N n → (∀ {o p} → N o → N p → Lexi o p m n → x≢0≢y o p → CD o p (gcd o p)) → m > n → x≢0≢y m n → CD m n (gcd m n) gcd-x>y-CD nzero Nn _ 0>n _ = ⊥-elim (0>x→⊥ Nn 0>n) gcd-x>y-CD (nsucc Nm) nzero _ _ _ = gcd-S0-CD Nm gcd-x>y-CD (nsucc {m} Nm) (nsucc {n} Nn) ah Sm>Sn _ = gcd-S>S-CD Nm Nn ih Sm>Sn where -- Inductive hypothesis. ih : CD (succ₁ m ∸ succ₁ n) (succ₁ n) (gcd (succ₁ m ∸ succ₁ n) (succ₁ n)) ih = ah {succ₁ m ∸ succ₁ n} {succ₁ n} (∸-N (nsucc Nm) (nsucc Nn)) (nsucc Nn) ([Sx∸Sy,Sy]<[Sx,Sy] Nm Nn) (λ p → ⊥-elim (S≢0 (∧-proj₂ p))) -- The gcd m n when m ≯ n is CD. gcd-x≯y-CD : ∀ {m n} → N m → N n → (∀ {o p} → N o → N p → Lexi o p m n → x≢0≢y o p → CD o p (gcd o p)) → m ≯ n → x≢0≢y m n → CD m n (gcd m n) gcd-x≯y-CD nzero nzero _ _ h = ⊥-elim (h (refl , refl)) gcd-x≯y-CD nzero (nsucc Nn) _ _ _ = gcd-0S-CD Nn gcd-x≯y-CD (nsucc _) nzero _ Sm≯0 _ = ⊥-elim (S≯0→⊥ Sm≯0) gcd-x≯y-CD (nsucc {m} Nm) (nsucc {n} Nn) ah Sm≯Sn _ = gcd-S≯S-CD Nm Nn ih Sm≯Sn where -- Inductive hypothesis. ih : CD (succ₁ m) (succ₁ n ∸ succ₁ m) (gcd (succ₁ m) (succ₁ n ∸ succ₁ m)) ih = ah {succ₁ m} {succ₁ n ∸ succ₁ m} (nsucc Nm) (∸-N (nsucc Nn) (nsucc Nm)) ([Sx,Sy∸Sx]<[Sx,Sy] Nm Nn) (λ p → ⊥-elim (S≢0 (∧-proj₁ p))) -- The gcd is CD. gcdCD : ∀ {m n} → N m → N n → x≢0≢y m n → CD m n (gcd m n) gcdCD = Lexi-wfind A h where A : D → D → Set A i j = x≢0≢y i j → CD i j (gcd i j) h : ∀ {i j} → N i → N j → (∀ {k l} → N k → N l → Lexi k l i j → A k l) → A i j h Ni Nj ah = case (gcd-x>y-CD Ni Nj ah) (gcd-x≯y-CD Ni Nj ah) (x>y∨x≯y Ni Nj)
{ "alphanum_fraction": 0.5020786697, "avg_line_length": 36.0807692308, "ext": "agda", "hexsha": "6ae90633a306f314d1ea8a367e815d8d78750d2a", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Program/GCD/Partial/CommonDivisorATP.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Program/GCD/Partial/CommonDivisorATP.agda", "max_line_length": 79, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Program/GCD/Partial/CommonDivisorATP.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 4140, "size": 9381 }
-- A DSL example in the language Agda: "polynomial types" module TypeDSL where open import Data.Empty open import Data.Unit open import Data.Sum open import Data.Product open import Data.Nat data E : Set1 where Add : E -> E -> E Mul : E -> E -> E Zero : E One : E eval : E -> Set eval (Add x y) = (eval x) ⊎ (eval y) eval (Mul x y) = (eval x) × (eval y) eval Zero = ⊥ eval One = ⊤ two = Add One One three = Add One two test1 : eval One test1 = tt false : eval two false = inj₁ tt true : eval two true = inj₂ tt test3 : eval three test3 = inj₁ tt card : E -> ℕ card (Add x y) = card x + card y card (Mul x y) = card x * card y card Zero = 0 card One = 1 open import Data.Vec as V variable m n : ℕ A B : Set enumAdd : Vec A m -> Vec B n -> Vec (A ⊎ B) (m + n) enumAdd xs ys = V.map inj₁ xs ++ V.map inj₂ ys -- cartesianProduct enumMul : Vec A m → Vec B n → Vec (A × B) (m * n) enumMul xs ys = concat (V.map (\a -> V.map ((a ,_)) ys) xs) enumerate : (t : E) -> Vec (eval t) (card t) enumerate (Add x y) = enumAdd (enumerate x) (enumerate y) enumerate (Mul x y) = enumMul (enumerate x) (enumerate y) enumerate Zero = [] enumerate One = [ tt ] test : Vec (eval three) 3 test = enumerate three -- inj₁ tt ∷ inj₂ (inj₁ tt) ∷ inj₂ (inj₂ tt) ∷ [] -- Exercise: add a constructor for function types to the syntax E
{ "alphanum_fraction": 0.5947105075, "avg_line_length": 21.5230769231, "ext": "agda", "hexsha": "56de41055c9400ccb85a2ae356673800639a6544", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "22c9e02aaeb505baad7a001f179e0d1e1f6e511c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "felixwellen/DSLsofMath", "max_forks_repo_path": "L/01/TypeDSL.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "22c9e02aaeb505baad7a001f179e0d1e1f6e511c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "felixwellen/DSLsofMath", "max_issues_repo_path": "L/01/TypeDSL.agda", "max_line_length": 66, "max_stars_count": null, "max_stars_repo_head_hexsha": "22c9e02aaeb505baad7a001f179e0d1e1f6e511c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "felixwellen/DSLsofMath", "max_stars_repo_path": "L/01/TypeDSL.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 489, "size": 1399 }
module _ where open import Agda.Builtin.List open import Agda.Builtin.Nat hiding (_==_) open import Agda.Builtin.Equality open import Agda.Builtin.Unit open import Agda.Builtin.Bool infix -1 _,_ record _×_ {a} (A B : Set a) : Set a where constructor _,_ field fst : A snd : B open _×_ data Constraint : Set₁ where mkConstraint : {A : Set} (x y : A) → x ≡ y → Constraint infix 0 _==_ pattern _==_ x y = mkConstraint x y refl infixr 5 _++_ _++_ : {A : Set} → List A → List A → List A [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ (xs ++ ys) deepId : {A : Set} → List A → List A deepId [] = [] deepId (x ∷ xs) = x ∷ deepId xs nil : Constraint nil = _ ++ [] == 1 ∷ 2 ∷ [] neutral : List Nat → Constraint neutral ys = _ ++ deepId ys == 1 ∷ 2 ∷ deepId ys spine : (ys zs : List Nat) → Constraint spine ys zs = _ ++ zs == 1 ∷ ys ++ zs N-ary : Nat → Set → Set N-ary zero A = A N-ary (suc n) A = A → N-ary n A foo : N-ary _ Nat foo = λ x y z → x sum : (n : Nat) → Nat → N-ary n Nat sum zero m = m sum (suc n) m = λ p → sum n (m + p) nary-sum : Nat nary-sum = sum _ 1 2 3 4 plus : Nat → Constraint plus n = _ + n == 2 + n plus-lit : Constraint plus-lit = _ + 0 == 3 dont-fail : Nat → Nat → Constraint × Constraint dont-fail n m = let X = _ in X + (m + 0) == n + (m + 0) , X == n -- Harder problems -- data Color : Set where red green blue : Color isRed : Color → Bool isRed red = true isRed green = false isRed blue = false non-unique : Constraint non-unique = isRed _ == true data Maybe (A : Set) : Set where nothing : Maybe A just : A → Maybe A sumJust : Maybe Nat → Nat → Nat sumJust nothing _ = 0 sumJust (just x) n = x + n unknown-head : Nat → Constraint unknown-head n = sumJust _ n == n
{ "alphanum_fraction": 0.5885386819, "avg_line_length": 19.606741573, "ext": "agda", "hexsha": "f01c0ab71bc523590b16e2470f6dcc2d37d35400", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/ImprovedInjectivity.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/ImprovedInjectivity.agda", "max_line_length": 57, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/ImprovedInjectivity.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 644, "size": 1745 }
{-# OPTIONS --prop #-} {-# TERMINATING #-} makeloop : {P : Prop} → P → P makeloop p = makeloop p postulate P : Prop p : P Q : P → Set record X : Set where field f : Q (makeloop p) data Y : Set where f : Q (makeloop p) → Y
{ "alphanum_fraction": 0.55, "avg_line_length": 13.3333333333, "ext": "agda", "hexsha": "c851595eeac833a6fcd4bc155df68b4b32d06bbc", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue4122.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue4122.agda", "max_line_length": 29, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue4122.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 91, "size": 240 }
-- {-# OPTIONS -v reify:80 #-} open import Common.Prelude open import Common.Reflection open import Common.Equality module Issue1345 (A : Set) where -- Andreas, 2016-07-17 -- Also test correct handling of abstract abstract unquoteDecl idNat = define (vArg idNat) (funDef (pi (vArg (def (quote Nat) [])) (abs "" (def (quote Nat) []))) (clause (vArg (var "") ∷ []) (var 0 []) ∷ [])) -- This raised the UselessAbstract error in error. -- Should work. abstract thm : ∀ n → idNat n ≡ n thm n = refl
{ "alphanum_fraction": 0.6285714286, "avg_line_length": 23.8636363636, "ext": "agda", "hexsha": "c7565402e91cef0185d3431ebcb3649ba6bcce28", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-09-15T14:36:15.000Z", "max_forks_repo_forks_event_min_datetime": "2015-09-15T14:36:15.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue1345.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/Succeed/Issue1345.agda", "max_line_length": 74, "max_stars_count": 3, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Succeed/Issue1345.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 163, "size": 525 }
open import Common.Prelude open import TestHarness open import TestBool using ( not; _∧_ ; _↔_ ) module TestNat where _*_ : Nat → Nat → Nat zero * n = zero suc m * n = n + (m * n) {-# COMPILED_JS _*_ function (x) { return function (y) { return x*y; }; } #-} fact : Nat → Nat fact zero = 1 fact (suc x) = suc x * fact x _≟_ : Nat → Nat → Bool zero ≟ zero = true suc x ≟ suc y = x ≟ y x ≟ y = false {-# COMPILED_JS _≟_ function (x) { return function (y) { return x === y; }; } #-} tests : Tests tests _ = ( assert (0 ≟ 0) "0=0" , assert (not (0 ≟ 1)) "0≠1" , assert ((1 + 2) ≟ 3) "1+2=3" , assert ((2 ∸ 1) ≟ 1) "2∸1=1" , assert ((1 ∸ 2) ≟ 0) "1∸2=0" , assert ((2 * 3) ≟ 6) "2+3=6" , assert (fact 0 ≟ 1) "0!=1" , assert (fact 1 ≟ 1) "1!=1" , assert (fact 2 ≟ 2) "2!=2" , assert (fact 3 ≟ 6) "3!=6" , assert (fact 4 ≟ 24) "4!=24" )
{ "alphanum_fraction": 0.4983240223, "avg_line_length": 23.5526315789, "ext": "agda", "hexsha": "b219efefa7723758332d7b065f4c42daa0fb4635", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/js/TestNat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/js/TestNat.agda", "max_line_length": 81, "max_stars_count": 1, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/js/TestNat.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 399, "size": 895 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Some examples showing where the integers and some related -- operations and properties are defined, and how they can be used ------------------------------------------------------------------------ module README.Integer where -- The integers and various arithmetic operations are defined in -- Data.Integer. open import Data.Integer -- The +_ function converts natural numbers into integers. ex₁ : ℤ ex₁ = + 2 -- The -_ function negates an integer. ex₂ : ℤ ex₂ = - + 4 -- Some binary operators are also defined, including addition, -- subtraction and multiplication. ex₃ : ℤ ex₃ = + 1 + + 3 * - + 2 - + 4 -- Propositional equality and some related properties can be found -- in Relation.Binary.PropositionalEquality. open import Relation.Binary.PropositionalEquality as P using (_≡_) ex₄ : ex₃ ≡ - + 9 ex₄ = P.refl -- Data.Integer.Properties contains a number of properties related to -- integers. Algebra defines what a commutative ring is, among other -- things. open import Algebra import Data.Integer.Properties as Integer private module CR = CommutativeRing Integer.commutativeRing ex₅ : ∀ i j → i * j ≡ j * i ex₅ i j = CR.*-comm i j -- The module ≡-Reasoning in Relation.Binary.PropositionalEquality -- provides some combinators for equational reasoning. open P.≡-Reasoning open import Data.Product ex₆ : ∀ i j → i * (j + + 0) ≡ j * i ex₆ i j = begin i * (j + + 0) ≡⟨ P.cong (_*_ i) (proj₂ CR.+-identity j) ⟩ i * j ≡⟨ CR.*-comm i j ⟩ j * i ∎ -- The module RingSolver in Data.Integer.Properties contains a solver -- for integer equalities involving variables, constants, _+_, _*_, -_ -- and _-_. ex₇ : ∀ i j → i * - j - j * i ≡ - + 2 * i * j ex₇ = solve 2 (λ i j → i :* :- j :- j :* i := :- con (+ 2) :* i :* j) P.refl where open Integer.RingSolver
{ "alphanum_fraction": 0.6162610047, "avg_line_length": 27.1971830986, "ext": "agda", "hexsha": "c6e3469ebdc3857b5cc571e471154665e2d9ecc6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/README/Integer.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/README/Integer.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/README/Integer.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 550, "size": 1931 }
-- Issue #80. -- The disjunction data type. data _∨_ (A B : Set) : Set where inj₁ : A → A ∨ B inj₂ : B → A ∨ B -- A different symbol for disjunction. _⊕_ : Set → Set → Set P ⊕ Q = P ∨ Q {-# ATP definition _⊕_ #-} postulate P Q : Set ⊕-comm : P ⊕ Q → Q ⊕ P {-# ATP prove ⊕-comm #-} -- The previous error was: -- $ apia Issue80.agda -- An internal error has occurred. Please report this as a bug. -- Location of the error: src/Apia/Translation/Functions.hs:188 -- The current error is: -- $ apia Issue80.agda -- apia: the translation of ‘IssueXX._⊕_’ failed because it is not a FOL-definition
{ "alphanum_fraction": 0.6320132013, "avg_line_length": 21.6428571429, "ext": "agda", "hexsha": "6ae04408d24c46e97a5bbeaf6d5d2637f1f8d40d", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z", "max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/apia", "max_forks_repo_path": "test/Fail/Errors/Issue80.agda", "max_issues_count": 121, "max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/apia", "max_issues_repo_path": "test/Fail/Errors/Issue80.agda", "max_line_length": 83, "max_stars_count": 10, "max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/apia", "max_stars_repo_path": "test/Fail/Errors/Issue80.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z", "num_tokens": 209, "size": 606 }
-- {-# OPTIONS -v tc.meta:20 #-} module UnifyWithIrrelevantArgument where data _≡_ {A : Set}(a : A) : A -> Set where refl : a ≡ a fail : (A : Set) -> let X : .A -> A X = _ in (x : A) -> X x ≡ x fail A x = refl -- error: X cannot depend on its first argument
{ "alphanum_fraction": 0.5208333333, "avg_line_length": 22.1538461538, "ext": "agda", "hexsha": "6918327e4ed88a92cad46cb230f5511cc9c37bc3", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/UnifyWithIrrelevantArgument.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/UnifyWithIrrelevantArgument.agda", "max_line_length": 47, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/UnifyWithIrrelevantArgument.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 101, "size": 288 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Groups.Definition open import Numbers.Naturals.Definition open import Setoids.Setoids open import Sets.EquivalenceRelations open import Lists.Lists open import Maybe open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) module Groups.Polynomials.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} (G : Group S _+_) where open Setoid S open Equivalence eq open Group G NaivePoly : Set a NaivePoly = List A 0P : NaivePoly 0P = [] polysEqual : NaivePoly → NaivePoly → Set (a ⊔ b) polysEqual [] [] = True' polysEqual [] (x :: b) = (x ∼ 0G) && polysEqual [] b polysEqual (x :: a) [] = (x ∼ 0G) && polysEqual a [] polysEqual (x :: a) (y :: b) = (x ∼ y) && polysEqual a b polysReflexive : {x : NaivePoly} → polysEqual x x polysReflexive {[]} = record {} polysReflexive {x :: y} = reflexive ,, polysReflexive polysSymmetricZero : {x : NaivePoly} → polysEqual [] x → polysEqual x [] polysSymmetricZero {[]} 0=x = record {} polysSymmetricZero {x :: y} (fst ,, snd) = fst ,, polysSymmetricZero snd polysSymmetricZero' : {x : NaivePoly} → polysEqual x [] → polysEqual [] x polysSymmetricZero' {[]} 0=x = record {} polysSymmetricZero' {x :: y} (fst ,, snd) = fst ,, polysSymmetricZero' snd polysSymmetric : {x y : NaivePoly} → polysEqual x y → polysEqual y x polysSymmetric {[]} {y} x=y = polysSymmetricZero x=y polysSymmetric {x :: xs} {[]} x=y = polysSymmetricZero' {x :: xs} x=y polysSymmetric {x :: xs} {y :: ys} (fst ,, snd) = symmetric fst ,, polysSymmetric {xs} {ys} snd polysTransitive : {x y z : NaivePoly} → polysEqual x y → polysEqual y z → polysEqual x z polysTransitive {[]} {[]} {[]} x=y y=z = record {} polysTransitive {[]} {[]} {x :: z} x=y y=z = y=z polysTransitive {[]} {x :: y} {[]} (fst ,, snd) y=z = record {} polysTransitive {[]} {x :: y} {x₁ :: z} (fst ,, snd) (fst2 ,, snd2) = transitive (symmetric fst2) fst ,, polysTransitive snd snd2 polysTransitive {x :: xs} {[]} {[]} x=y y=z = x=y polysTransitive {x :: xs} {[]} {z :: zs} (fst ,, snd) (fst2 ,, snd2) = transitive fst (symmetric fst2) ,, polysTransitive snd snd2 polysTransitive {x :: xs} {y :: ys} {[]} (fst ,, snd) (fst2 ,, snd2) = transitive fst fst2 ,, polysTransitive snd snd2 polysTransitive {x :: xs} {y :: ys} {z :: zs} (fst ,, snd) (fst2 ,, snd2) = transitive fst fst2 ,, polysTransitive snd snd2 naivePolySetoid : Setoid NaivePoly Setoid._∼_ naivePolySetoid = polysEqual Equivalence.reflexive (Setoid.eq naivePolySetoid) = polysReflexive Equivalence.symmetric (Setoid.eq naivePolySetoid) = polysSymmetric Equivalence.transitive (Setoid.eq naivePolySetoid) = polysTransitive polyInjection : A → NaivePoly polyInjection a = a :: [] polyInjectionIsInj : SetoidInjection S naivePolySetoid polyInjection SetoidInjection.wellDefined polyInjectionIsInj x=y = x=y ,, record {} SetoidInjection.injective polyInjectionIsInj {x} {y} (fst ,, snd) = fst -- the zero polynomial has no degree -- all other polynomials have a degree degree : ((x : A) → (x ∼ 0G) || ((x ∼ 0G) → False)) → NaivePoly → Maybe ℕ degree decide [] = no degree decide (x :: poly) with decide x degree decide (x :: poly) | inl x=0 with degree decide poly degree decide (x :: poly) | inl x=0 | no = no degree decide (x :: poly) | inl x=0 | yes deg = yes (succ deg) degree decide (x :: poly) | inr x!=0 with degree decide poly degree decide (x :: poly) | inr x!=0 | no = yes 0 degree decide (x :: poly) | inr x!=0 | yes n = yes (succ n) degreeWellDefined : (decide : ((x : A) → (x ∼ 0G) || ((x ∼ 0G) → False))) {x y : NaivePoly} → polysEqual x y → degree decide x ≡ degree decide y degreeWellDefined decide {[]} {[]} x=y = refl degreeWellDefined decide {[]} {x :: y} (fst ,, snd) with decide x degreeWellDefined decide {[]} {x :: y} (fst ,, snd) | inl x=0 with inspect (degree decide y) degreeWellDefined decide {[]} {x :: y} (fst ,, snd) | inl x=0 | no with≡ pr rewrite pr = refl degreeWellDefined decide {[]} {x :: y} (fst ,, snd) | inl x=0 | yes bad with≡ pr rewrite pr = exFalso (noNotYes (transitivity (degreeWellDefined decide {[]} {y} snd) pr)) degreeWellDefined decide {[]} {x :: y} (fst ,, snd) | inr x!=0 with inspect (degree decide y) degreeWellDefined decide {[]} {x :: y} (fst ,, snd) | inr x!=0 | no with≡ pr rewrite pr = exFalso (x!=0 fst) degreeWellDefined decide {[]} {x :: y} (fst ,, snd) | inr x!=0 | yes deg with≡ pr rewrite pr = exFalso (x!=0 fst) degreeWellDefined decide {x :: xs} {[]} x=y with decide x degreeWellDefined decide {x :: xs} {[]} (fst ,, snd) | inl x=0 with inspect (degree decide xs) degreeWellDefined decide {x :: xs} {[]} (fst ,, snd) | inl x=0 | no with≡ pr rewrite pr = refl degreeWellDefined decide {x :: xs} {[]} (fst ,, snd) | inl x=0 | yes bad with≡ pr rewrite pr = exFalso (noNotYes (transitivity (equalityCommutative (degreeWellDefined decide snd)) pr)) degreeWellDefined decide {x :: xs} {[]} (fst ,, snd) | inr x!=0 = exFalso (x!=0 fst) degreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) with decide x degreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inl x=0 with decide y degreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inl x=0 | inl y=0 with inspect (degree decide ys) degreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inl x=0 | inl y=0 | no with≡ pr rewrite degreeWellDefined decide {xs} {ys} snd | pr = refl degreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inl x=0 | inl y=0 | (yes th) with≡ pr rewrite degreeWellDefined decide {xs} {ys} snd | pr = refl degreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inl x=0 | inr y!=0 = exFalso (y!=0 (transitive (symmetric fst) x=0)) degreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inr x!=0 with decide y degreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inr x!=0 | inl y=0 = exFalso (x!=0 (transitive fst y=0)) degreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inr x!=0 | inr y!=0 with inspect (degree decide ys) degreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inr x!=0 | inr y!=0 | no with≡ pr rewrite degreeWellDefined decide {xs} {ys} snd | pr = refl degreeWellDefined decide {x :: xs} {y :: ys} (fst ,, snd) | inr x!=0 | inr y!=0 | yes x₁ with≡ pr rewrite degreeWellDefined decide {xs} {ys} snd | pr = refl degreeNoImpliesZero : (decide : ((x : A) → (x ∼ 0G) || ((x ∼ 0G) → False))) → (a : NaivePoly) → degree decide a ≡ no → polysEqual a [] degreeNoImpliesZero decide [] not = record {} degreeNoImpliesZero decide (x :: a) not with decide x degreeNoImpliesZero decide (x :: a) not | inl x=0 with inspect (degree decide a) degreeNoImpliesZero decide (x :: a) not | inl x=0 | no with≡ pr rewrite pr = x=0 ,, degreeNoImpliesZero decide a pr degreeNoImpliesZero decide (x :: a) not | inl x=0 | (yes deg) with≡ pr rewrite pr = exFalso (noNotYes (equalityCommutative not)) degreeNoImpliesZero decide (x :: a) not | inr x!=0 with degree decide a degreeNoImpliesZero decide (x :: a) () | inr x!=0 | no degreeNoImpliesZero decide (x :: a) () | inr x!=0 | yes x₁ emptyImpliesDegreeZero : (decide : ((x : A) → (x ∼ 0G) || ((x ∼ 0G) → False))) → (a : NaivePoly) → polysEqual a [] → degree decide a ≡ no emptyImpliesDegreeZero decide [] a=[] = refl emptyImpliesDegreeZero decide (x :: a) (fst ,, snd) with decide x emptyImpliesDegreeZero decide (x :: a) (fst ,, snd) | inl x=0 with inspect (degree decide a) emptyImpliesDegreeZero decide (x :: a) (fst ,, snd) | inl x=0 | no with≡ pr rewrite pr = refl emptyImpliesDegreeZero decide (x :: a) (fst ,, snd) | inl x=0 | (yes deg) with≡ pr rewrite pr = exFalso (noNotYes (transitivity (equalityCommutative (emptyImpliesDegreeZero decide a snd)) pr)) emptyImpliesDegreeZero decide (x :: a) (fst ,, snd) | inr x!=0 = exFalso (x!=0 fst)
{ "alphanum_fraction": 0.6539206821, "avg_line_length": 60.9527559055, "ext": "agda", "hexsha": "64fc0346848ac7979cd485df25e42c8ff357319f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Groups/Polynomials/Definition.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Groups/Polynomials/Definition.agda", "max_line_length": 192, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Groups/Polynomials/Definition.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 2648, "size": 7741 }
------------------------------------------------------------------------ -- The Agda standard library -- -- M-types (the dual of W-types) ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe --sized-types #-} module Codata.M where open import Size open import Level open import Codata.Thunk using (Thunk; force) open import Data.Product hiding (map) open import Data.Container.Core as C hiding (map) data M {s p} (C : Container s p) (i : Size) : Set (s ⊔ p) where inf : ⟦ C ⟧ (Thunk (M C) i) → M C i module _ {s p} {C : Container s p} where head : ∀ {i} → M C i → Shape C head (inf (x , f)) = x tail : (x : M C ∞) → Position C (head x) → M C ∞ tail (inf (x , f)) = λ p → f p .force -- map module _ {s₁ s₂ p₁ p₂} {C₁ : Container s₁ p₁} {C₂ : Container s₂ p₂} (m : C₁ ⇒ C₂) where map : ∀ {i} → M C₁ i → M C₂ i map (inf t) = inf (⟪ m ⟫ (C.map (λ t → λ where .force → map (t .force)) t)) -- unfold module _ {s p ℓ} {C : Container s p} (open Container C) {S : Set ℓ} (alg : S → ⟦ C ⟧ S) where unfold : S → ∀ {i} → M C i unfold seed = let (x , next) = alg seed in inf (x , λ p → λ where .force → unfold (next p))
{ "alphanum_fraction": 0.4873262469, "avg_line_length": 27.7954545455, "ext": "agda", "hexsha": "7f4eefc59fd34fc63d61b4ba510d69d3579e7be2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Codata/M.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Codata/M.agda", "max_line_length": 77, "max_stars_count": 5, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Codata/M.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 403, "size": 1223 }
module builtin where open import Agda.Builtin.IO open import Agda.Builtin.Unit open import Agda.Builtin.String postulate putStrLn : String -> IO ⊤ {-# COMPILE GHC putStrLn = putStrLn . Data.Text.unpack #-} main : IO ⊤ main = putStrLn "hallo"
{ "alphanum_fraction": 0.7357723577, "avg_line_length": 18.9230769231, "ext": "agda", "hexsha": "5648b6f6accc796a1905ba622754bc3d76ee7fd0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "112a706f266941d6ec8cb107d18476f9d7ffbbc6", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "neosimsim/merkdas", "max_forks_repo_path": "agda-coinductive-io/builtin.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "112a706f266941d6ec8cb107d18476f9d7ffbbc6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "neosimsim/merkdas", "max_issues_repo_path": "agda-coinductive-io/builtin.agda", "max_line_length": 58, "max_stars_count": 1, "max_stars_repo_head_hexsha": "112a706f266941d6ec8cb107d18476f9d7ffbbc6", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "neosimsim/merkdas", "max_stars_repo_path": "agda-coinductive-io/builtin.agda", "max_stars_repo_stars_event_max_datetime": "2020-05-26T08:08:13.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-26T08:08:13.000Z", "num_tokens": 63, "size": 246 }
import MJ.Classtable import MJ.Syntax.Untyped as Syntax import MJ.Classtable.Core as Core module MJ.Semantics.Smallstep {c} (Ct : Core.Classtable c)(ℂ : Syntax.Classes Ct) where open import Prelude open import Data.Vec as V hiding (init; _>>=_; _∈_; _[_]=_) open import Data.Vec.All.Properties.Extra as Vec∀++ open import Data.Sum open import Data.String open import Data.List.Most as List open import Data.Maybe as Maybe using (Maybe; just; nothing) open import Relation.Nullary.Decidable open import Data.Star hiding (return; _>>=_) import Data.Vec.All as Vec∀ open Syntax Ct open Core c open Classtable Ct open import MJ.Classtable.Membership Ct open import MJ.Types {-} -- fragment of a typed smallstep semantics; -- this is tedious, because there are so many indices to repeat and keep track of readvar : ∀ {W Γ a} → Var Γ a → Env Γ W → Store W → Val W a readvar v E μ = {!!} data Cont (Γ : Ctx) : Ty c → Ty c → Set where k-iopₗ : ∀ {a} → NativeBinOp → Cont int a → Expr Γ data State : Ty c → Set where exp : ∀ {Γ W a b} → Store W → Env Γ W → Expr Γ a → Cont a b → State b skip : ∀ {Γ W a b} → Store W → Env Γ W → Val W a → Cont a b → State b data _⟶_ {b} : State b → State b → Set where exp-var : ∀ {W Γ a}{μ : Store W}{E : Env Γ W}{x k} → exp μ E (var {a = a} x) k ⟶ skip μ E (readvar x E μ) k iopₗ : ∀ {W Γ a}{μ : Store W}{E : Env Γ W}{x k l r f} → exp μ E (iop f l r) k ⟶ k-iopₗ -} Loc = ℕ data Val : Set where num : ℕ → Val unit : Val null : Val ref : Cid c → Loc → Val default : Ty c → Val default a = {!!} data StoreVal : Set where val : Val → StoreVal Env : ℕ → Set Env = Vec Val Store = List StoreVal data Focus (n : ℕ) : ℕ → Set where stmt : ∀ {o} → Stmt n o → Focus n o continue : Focus n n exp : Expr n → Focus n n val : Val → Focus n n vals : List Val → Focus n n data Cont (n : ℕ) : Set where k-done : Cont n k-iopₗ : NativeBinOp → Cont n → Expr n → Cont n k-iopᵣ : NativeBinOp → Val → Cont n → Cont n k-new : Cid c → Cont n → Cont n k-args : List Val → List (Expr n) → Cont n → Cont n k-get : String → Cont n → Cont n k-call : String → Cont n → Cont n k-asgn : Fin n → Cont n → Cont n k-seq : ∀ {o} → Stmts n o → Cont o → Cont n k-set₁ : String → Expr n → Cont n → Cont n k-set₂ : Val → String → Cont n → Cont n data Config : Set where ⟨_,_,_,_⟩ : ∀ {n o} → Store → Env n → Focus n o → Cont o → Config data _⟶_ : Config → Config → Set where ---- -- expressions ---- num : ∀ {n}{E : Env n}{μ i k} → ⟨ μ , E , exp (num i) , k ⟩ ⟶ ⟨ μ , E , val (num i) , k ⟩ unit : ∀ {n}{E : Env n}{μ k} → ⟨ μ , E , exp unit , k ⟩ ⟶ ⟨ μ , E , val unit , k ⟩ null : ∀ {n}{E : Env n}{μ k} → ⟨ μ , E , exp null , k ⟩ ⟶ ⟨ μ , E , val null , k ⟩ var : ∀ {n}{E : Env n}{μ x k ℓ v} → μ [ ℓ ]= (val v) → ⟨ μ , E , exp (var x) , k ⟩ ⟶ ⟨ μ , E , val v , k ⟩ iopₗ : ∀ {n}{E : Env n}{μ k f l r} → ⟨ μ , E , exp (iop f l r) , k ⟩ ⟶ ⟨ μ , E , exp l , k-iopₗ f k r ⟩ iopᵣ : ∀ {n}{E : Env n}{μ k f v r} → ⟨ μ , E , val v , (k-iopₗ f k r) ⟩ ⟶ ⟨ μ , E , exp r , k-iopᵣ f v k ⟩ iop-red : ∀ {n}{E : Env n}{μ k f vᵣ vₗ} → ⟨ μ , E , val (num vᵣ) , (k-iopᵣ f (num vₗ) k) ⟩ ⟶ ⟨ μ , E , val (num (f vₗ vᵣ)) , k ⟩ new : ∀ {n}{E : Env n}{μ k cid e es} → ⟨ μ , E , exp (new cid (e ∷ es)), k ⟩ ⟶ ⟨ μ , E , exp e , k-args [] es (k-new cid k) ⟩ new-nil : ∀ {n}{E : Env n}{μ k cid} → ⟨ μ , E , exp (new cid []), k ⟩ ⟶ ⟨ μ List.∷ʳ {!!} , E , {!!} , k ⟩ new-red : ∀ {n}{E : Env n}{μ k cid vs} → ⟨ μ , E , vals vs , k-new cid k ⟩ ⟶ ⟨ μ List.∷ʳ {!!} , E , {!!} , k ⟩ args : ∀ {n}{E : Env n}{μ k e es v vs} → ⟨ μ , E , val v , k-args vs (e ∷ es) k ⟩ ⟶ ⟨ μ , E , exp e , k-args (vs List.∷ʳ v) es k ⟩ args-red : ∀ {n}{E : Env n}{μ k v vs} → ⟨ μ , E , val v , k-args vs [] k ⟩ ⟶ ⟨ μ , E , vals (vs List.∷ʳ v) , k ⟩ get : ∀ {n}{E : Env n}{μ k e m} → ⟨ μ , E , exp (get e m) , k ⟩ ⟶ ⟨ μ , E , exp e , k-get m k ⟩ get-red : ∀ {n}{E : Env n}{μ k c o m} → ⟨ μ , E , val (ref c o) , k-get m k ⟩ ⟶ ⟨ μ , E , {!!} , k ⟩ call : ∀ {n}{E : Env n}{μ k e m args} → ⟨ μ , E , exp (call e m args), k ⟩ ⟶ ⟨ μ , E , exp e , k-args [] args (k-call m k) ⟩ call-red : ∀ {n}{E : Env n}{μ k m v vs} → ⟨ μ , E , vals (v ∷ vs) , k-call m k ⟩ ⟶ ⟨ μ , E , {!!} , k ⟩ ---- -- statements ---- next : ∀ {n}{E : Env n}{μ j o}{s : Stmt n j}{st : Stmts j o}{k} → ⟨ μ , E , continue , k-seq (s ◅ st) k ⟩ ⟶ ⟨ μ , E , stmt s , k-seq st k ⟩ loc : ∀ {n}{E : Env n}{μ k a} → ⟨ μ , E , stmt (loc a) , k ⟩ ⟶ ⟨ μ , default a ∷ E , continue , k ⟩ asgn : ∀ {n}{E : Env n}{μ k e x} → ⟨ μ , E , stmt (asgn x e) , k ⟩ ⟶ ⟨ μ , E , exp e , k-asgn x k ⟩ asgn-red : ∀ {n}{E : Env n}{μ k v x} → ⟨ μ , E , val v , k-asgn x k ⟩ ⟶ ⟨ μ , (E V.[ x ]≔ v) , continue , k ⟩ set₁ : ∀ {n}{E : Env n}{μ m k e e'} → ⟨ μ , E , stmt (set e m e') , k ⟩ ⟶ ⟨ μ , E , exp e , k-set₁ m e' k ⟩ set₂ : ∀ {n}{E : Env n}{μ m k v e'} → ⟨ μ , E , val v , k-set₁ m e' k ⟩ ⟶ ⟨ μ , E , exp e' , k-set₂ v m k ⟩ set-red : ∀ {n}{E : Env n}{μ μ' m C k v o O} → maybe-lookup o μ ≡ just O → maybe-write o {!!} μ ≡ just μ' → ⟨ μ , E , val v , k-set₂ (ref C o) m k ⟩ ⟶ ⟨ μ' , E , continue , k ⟩ -- A few useful predicates on configurations Stuck : Config → Set Stuck φ = ¬ ∃ λ φ' → φ ⟶ φ' data Done : Config → Set where done : ∀ {n}{E : Env n}{μ v} → Done ⟨ μ , E , val v , k-done ⟩ -- reflexive, transitive-closure of step _⟶ₖ_ : Config → Config → Set _⟶ₖ_ = Star _⟶_
{ "alphanum_fraction": 0.4935955259, "avg_line_length": 31.8563218391, "ext": "agda", "hexsha": "8ac67f4cd9cff1a72da9a4dfabcc0b4aa7e4cc96", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_path": "src/MJ/Semantics/Smallstep.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_path": "src/MJ/Semantics/Smallstep.agda", "max_line_length": 93, "max_stars_count": 10, "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_path": "src/MJ/Semantics/Smallstep.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "num_tokens": 2383, "size": 5543 }
{-# OPTIONS -WnoMissingDefinitions #-} postulate A : Set B : A → Set variable a : A data D : B a → Set -- Expected: Warning about missing definition -- Not expected: Complaint about generalizable variable
{ "alphanum_fraction": 0.6930232558, "avg_line_length": 15.3571428571, "ext": "agda", "hexsha": "7ba04a2c23f5af4041aa158106f487e1eafaa547", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue3436.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue3436.agda", "max_line_length": 55, "max_stars_count": 2, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue3436.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 56, "size": 215 }
-- Andreas, 2017-01-01, issue 2372, reported by m0davis open import Issue2372Inst f : r → Set₁ f _ = Set -- WAS: No instance of type R was found in scope. -- Should succeed
{ "alphanum_fraction": 0.6949152542, "avg_line_length": 16.0909090909, "ext": "agda", "hexsha": "43c8ba5e0e0c62781c37f10ff73a251f918e410e", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue2372ImportInst.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue2372ImportInst.agda", "max_line_length": 55, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue2372ImportInst.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 59, "size": 177 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Data.Vec.OperationsNat where open import Cubical.Foundations.Prelude open import Cubical.Data.Nat renaming(_+_ to _+n_; _·_ to _·n_) open import Cubical.Data.Vec.Base open import Cubical.Data.Sigma private variable ℓ : Level _+n-vec_ : {m : ℕ} → Vec ℕ m → Vec ℕ m → Vec ℕ m _+n-vec_ {.zero} [] [] = [] _+n-vec_ {.(suc _)} (k ∷ v) (l ∷ v') = (k +n l) ∷ (v +n-vec v') +n-vec-lid : {m : ℕ} → (v : Vec ℕ m) → replicate 0 +n-vec v ≡ v +n-vec-lid {.zero} [] = refl +n-vec-lid {.(suc _)} (k ∷ v) = cong (_∷_ k) (+n-vec-lid v) +n-vec-rid : {m : ℕ} → (v : Vec ℕ m) → v +n-vec replicate 0 ≡ v +n-vec-rid {.zero} [] = refl +n-vec-rid {.(suc _)} (k ∷ v) = cong₂ _∷_ (+-zero k) (+n-vec-rid v) +n-vec-assoc : {m : ℕ} → (v v' v'' : Vec ℕ m) → v +n-vec (v' +n-vec v'') ≡ (v +n-vec v') +n-vec v'' +n-vec-assoc [] [] [] = refl +n-vec-assoc (k ∷ v) (l ∷ v') (p ∷ v'') = cong₂ _∷_ (+-assoc k l p) (+n-vec-assoc v v' v'') +n-vec-comm : {m : ℕ} → (v v' : Vec ℕ m) → v +n-vec v' ≡ v' +n-vec v +n-vec-comm {.zero} [] [] = refl +n-vec-comm {.(suc _)} (k ∷ v) (l ∷ v') = cong₂ _∷_ (+-comm k l) (+n-vec-comm v v') sep-vec : (k l : ℕ) → Vec ℕ (k +n l) → (Vec ℕ k) × (Vec ℕ l ) sep-vec zero l v = [] , v sep-vec (suc k) l (x ∷ v) = (x ∷ fst (sep-vec k l v)) , (snd (sep-vec k l v)) sep-vec-fst : (k l : ℕ) → (v : Vec ℕ k) → (v' : Vec ℕ l) → fst (sep-vec k l (v ++ v')) ≡ v sep-vec-fst zero l [] v' = refl sep-vec-fst (suc k) l (x ∷ v) v' = cong (λ X → x ∷ X) (sep-vec-fst k l v v') sep-vec-snd : (k l : ℕ) → (v : Vec ℕ k) → (v' : Vec ℕ l) → snd (sep-vec k l (v ++ v')) ≡ v' sep-vec-snd zero l [] v' = refl sep-vec-snd (suc k) l (x ∷ v) v' = sep-vec-snd k l v v' sep-vec-id : (k l : ℕ) → (v : Vec ℕ (k +n l)) → fst (sep-vec k l v) ++ snd (sep-vec k l v) ≡ v sep-vec-id zero l v = refl sep-vec-id (suc k) l (x ∷ v) = cong (λ X → x ∷ X) (sep-vec-id k l v) rep-concat : (k l : ℕ) → {B : Type ℓ} → (b : B) → replicate {_} {k} {B} b ++ replicate {_} {l} {B} b ≡ replicate {_} {k +n l} {B} b rep-concat zero l b = refl rep-concat (suc k) l b = cong (λ X → b ∷ X) (rep-concat k l b) +n-vec-concat : (k l : ℕ) → (v w : Vec ℕ k) → (v' w' : Vec ℕ l) → (v +n-vec w) ++ (v' +n-vec w') ≡ (v ++ v') +n-vec (w ++ w') +n-vec-concat zero l [] [] v' w' = refl +n-vec-concat (suc k) l (x ∷ v) (y ∷ w) v' w' = cong (λ X → x +n y ∷ X) (+n-vec-concat k l v w v' w')
{ "alphanum_fraction": 0.4965034965, "avg_line_length": 41.9137931034, "ext": "agda", "hexsha": "59a2f242b5fcfebae54c0ef110956b345a51c167", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_path": "Cubical/Data/Vec/OperationsNat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_path": "Cubical/Data/Vec/OperationsNat.agda", "max_line_length": 101, "max_stars_count": null, "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_path": "Cubical/Data/Vec/OperationsNat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1133, "size": 2431 }
module Type.Dependent.Functions where import Lvl open import Functional.Dependent open import Type open import Type.Dependent open import Syntax.Function module _ {ℓ₁ ℓ₂ ℓ₃} {A : Type{ℓ₁}} {B : A → Type{ℓ₂}} {C : ∀{x} → B(x) → Type{ℓ₃}} where _[Π]-∘_ : (∀{x} → Π(B(x))(C)) → (g : Π(A)(B)) → Π(A)(\x → C(Π.apply g x)) Π.apply (f [Π]-∘ g) x = Π.apply f (Π.apply g x) depCurry : (Π(Σ A B) (C ∘ Σ.right)) → (Π A (a ↦ (Π(B(a)) C))) Π.apply (Π.apply (depCurry f) a) b = Π.apply f (intro a b) depUncurry : (Π A (a ↦ Π(B(a)) C)) → (Π(Σ A B) (C ∘ Σ.right)) Π.apply (depUncurry f) (intro a b) = Π.apply(Π.apply f a) b module _ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} {A₁ : Type{ℓ₁}} {B₁ : A₁ → Type{ℓ₂}} {A₂ : Type{ℓ₃}} {B₂ : A₂ → Type{ℓ₄}} where [Σ]-apply : (x : Σ(A₁)(B₁)) → (l : A₁ → A₂) → (r : B₁(Σ.left x) → B₂(l(Σ.left x))) → Σ(A₂)(B₂) [Σ]-apply x l r = intro(l(Σ.left x))(r(Σ.right x)) [ℰ]-apply : (x : Σ(A₁)(B₁)) → {l : A₁ → A₂} → (r : B₁(Σ.left x) → B₂(l(Σ.left x))) → Σ(A₂)(B₂) [ℰ]-apply x {l} r = [Σ]-apply x l r [Σ]-map : (l : A₁ → A₂) → (∀{a} → B₁(a) → B₂(l(a))) → (Σ(A₁)(B₁) → Σ(A₂)(B₂)) [Σ]-map l r (intro left right) = intro (l left) (r right) [ℰ]-map : ∀{l : A₁ → A₂} → (∀{a} → B₁(a) → B₂(l(a))) → (Σ(A₁)(B₁) → Σ(A₂)(B₂)) [ℰ]-map {l} = [Σ]-map l module _ {ℓ₁ ℓ₂ ℓ₃} {A : Type{ℓ₁}} {B₁ : A → Type{ℓ₂}} {B₂ : A → Type{ℓ₃}} where [Σ]-applyᵣ : (x : Σ(A)(B₁)) → (r : B₁(Σ.left x) → B₂(Σ.left x)) → Σ(A)(B₂) [Σ]-applyᵣ x r = intro(Σ.left x)(r(Σ.right x)) module _ {ℓ₁ ℓ₂ ℓ₃ ℓ₄ ℓ₅ ℓ₆} {A₁ : Type{ℓ₁}} {B₁ : A₁ → Type{ℓ₂}} {A₂ : Type{ℓ₃}} {B₂ : A₂ → Type{ℓ₄}} {A₃ : Type{ℓ₅}} {B₃ : A₃ → Type{ℓ₆}} where [Σ]-apply₂ : (x : Σ(A₁)(B₁)) → (y : Σ(A₂)(B₂)) → (l : A₁ → A₂ → A₃) → (r : B₁(Σ.left x) → B₂(Σ.left y) → B₃(l(Σ.left x)(Σ.left y))) → Σ(A₃)(B₃) [Σ]-apply₂ x y l r = intro(l(Σ.left x)(Σ.left y))(r(Σ.right x)(Σ.right y)) [ℰ]-apply₂ : (x : Σ(A₁)(B₁)) → (y : Σ(A₂)(B₂)) → {l : A₁ → A₂ → A₃} → (r : B₁(Σ.left x) → B₂(Σ.left y) → B₃(l(Σ.left x)(Σ.left y))) → Σ(A₃)(B₃) [ℰ]-apply₂ x y {l} r = [Σ]-apply₂ x y l r [Σ]-map₂ : (l : A₁ → A₂ → A₃) → (∀{a₁}{a₂} → B₁(a₁) → B₂(a₂) → B₃(l a₁ a₂)) → (Σ(A₁)(B₁) → Σ(A₂)(B₂) → Σ(A₃)(B₃)) [Σ]-map₂ l r (intro left₁ right₁) (intro left₂ right₂) = intro (l left₁ left₂) (r right₁ right₂) [ℰ]-map₂ : ∀{l : A₁ → A₂ → A₃} → (∀{a₁}{a₂} → B₁(a₁) → B₂(a₂) → B₃(l a₁ a₂)) → (Σ(A₁)(B₁) → Σ(A₂)(B₂) → Σ(A₃)(B₃)) [ℰ]-map₂ {l} = [Σ]-map₂ l
{ "alphanum_fraction": 0.4587049244, "avg_line_length": 37.9264705882, "ext": "agda", "hexsha": "9bdd7efe40b30f9b93b14196630b6dae0c4183e4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Type/Dependent/Functions.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Type/Dependent/Functions.agda", "max_line_length": 145, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Type/Dependent/Functions.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 1399, "size": 2579 }
{-# OPTIONS --cubical --safe --no-import-sorts --postfix-projections #-} module Cubical.Data.Fin.Recursive.Properties where open import Cubical.Foundations.Equiv open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Prelude open import Cubical.Foundations.Transport open import Cubical.Foundations.Univalence open import Cubical.Functions.Embedding import Cubical.Data.Empty as Empty open Empty hiding (rec; elim) open import Cubical.Data.Nat hiding (elim) open import Cubical.Data.Nat.Order.Recursive open import Cubical.Data.Sigma import Cubical.Data.Sum as Sum open Sum using (_⊎_; _⊎?_; inl; inr) open import Cubical.Data.Fin.Recursive.Base open import Cubical.Relation.Nullary private variable ℓ : Level m n : ℕ A : Type ℓ x y : A isPropFin0 : isProp (Fin 0) isPropFin0 = isProp⊥ isContrFin1 : isContr (Fin 1) isContrFin1 .fst = zero isContrFin1 .snd zero = refl Unit≡Fin1 : Unit ≡ Fin 1 Unit≡Fin1 = ua (const zero , ctr) where fibr : fiber (const zero) zero fibr = tt , refl fibr! : ∀ f → fibr ≡ f fibr! (tt , p) i .fst = tt fibr! (tt , p) i .snd = J (λ{ zero q → refl ≡ q }) refl p i ctr : isEquiv (const zero) ctr .equiv-proof zero .fst = fibr ctr .equiv-proof zero .snd = fibr! module Cover where Cover : FinF A → FinF A → Type _ Cover zero zero = Unit Cover (suc x) (suc y) = x ≡ y Cover _ _ = ⊥ crefl : Cover x x crefl {x = zero} = _ crefl {x = suc x} = refl cover : x ≡ y → Cover x y cover p = transport (λ i → Cover (p i0) (p i)) crefl predp : Path (FinF A) (suc x) (suc y) → x ≡ y predp {x = x} p = transport (λ i → Cover (suc x) (p i)) refl suc-predp-refl : Path (Path (FinF A) (suc x) (suc x)) (λ i → suc (predp (λ _ → suc x) i)) refl suc-predp-refl {x = x} i j = suc (transportRefl (refl {x = x}) i j) suc-retract : (p : Path (FinF A) (suc x) (suc y)) → (λ i → suc (predp p i)) ≡ p suc-retract = J (λ{ (suc m) q → (λ i → suc (predp q i)) ≡ q ; zero _ → ⊥}) suc-predp-refl isEmbedding-suc : isEmbedding {B = FinF A} suc isEmbedding-suc w x = isoToIsEquiv theIso where open Iso theIso : Iso (w ≡ x) (suc w ≡ suc x) theIso .fun = cong suc theIso .inv p = predp p theIso .rightInv = suc-retract theIso .leftInv = J (λ _ q → transport (λ i → w ≡ q i) refl ≡ q) (transportRefl refl) private zK : (p : Path (FinF A) zero zero) → p ≡ refl zK = J (λ{ zero q → q ≡ refl ; one _ → ⊥ }) refl isSetFinF : isSet A → isSet (FinF A) isSetFinF Aset zero zero p = J (λ{ zero q → p ≡ q ; _ _ → ⊥ }) (zK p) isSetFinF Aset (suc x) (suc y) = isOfHLevelRetract 1 Cover.predp (cong suc) Cover.suc-retract (Aset x y) isSetFinF Aset zero (suc _) p = Empty.rec (Cover.cover p) isSetFinF Aset (suc _) zero p = Empty.rec (Cover.cover p) isSetFin : isSet (Fin m) isSetFin {zero} = isProp→isSet isPropFin0 isSetFin {suc m} = isSetFinF isSetFin discreteFin : Discrete (Fin m) discreteFin {suc m} zero zero = yes refl discreteFin {suc m} (suc i) (suc j) with discreteFin i j ... | yes p = yes (cong suc p) ... | no ¬p = no (¬p ∘ Cover.predp) discreteFin {suc m} zero (suc _) = no Cover.cover discreteFin {suc m} (suc _) zero = no Cover.cover inject< : m < n → Fin m → Fin n inject< {suc m} {suc n} _ zero = zero inject< {suc m} {suc n} m<n (suc i) = suc (inject< m<n i) inject≤ : m ≤ n → Fin m → Fin n inject≤ {suc m} {suc n} _ zero = zero inject≤ {suc m} {suc n} m≤n (suc i) = suc (inject≤ m≤n i) any? : {P : Fin m → Type ℓ} → (∀ i → Dec (P i)) → Dec (Σ _ P) any? {zero} P? = no fst any? {suc m} P? with P? zero ⊎? any? (P? ∘ suc) ... | yes (inl p) = yes (zero , p) ... | yes (inr (i , p)) = yes (suc i , p) ... | no k = no λ where (zero , p) → k (inl p) (suc x , p) → k (inr (x , p)) _#_ : Fin m → Fin m → Type₀ _#_ {m = suc m} zero zero = ⊥ _#_ {m = suc m} (suc i) zero = Unit _#_ {m = suc m} zero (suc j) = Unit _#_ {m = suc m} (suc i) (suc j) = i # j #→≢ : ∀{i j : Fin m} → i # j → ¬ i ≡ j #→≢ {suc _} {zero} {suc j} _ = Cover.cover #→≢ {suc _} {suc i} {zero} _ = Cover.cover #→≢ {suc m} {suc i} {suc j} ap p = #→≢ ap (Cover.predp p) ≢→# : ∀{i j : Fin m} → ¬ i ≡ j → i # j ≢→# {suc m} {zero} {zero} ¬p = ¬p refl ≢→# {suc m} {zero} {suc j} _ = _ ≢→# {suc m} {suc i} {zero} _ = _ ≢→# {suc m} {suc i} {suc j} ¬p = ≢→# {m} {i} {j} (¬p ∘ cong suc) #-inject< : ∀{l : m < n} (i j : Fin m) → i # j → inject< {m} {n} l i # inject< l j #-inject< {suc m} {suc n} zero (suc _) _ = _ #-inject< {suc m} {suc n} (suc _) zero _ = _ #-inject< {suc m} {suc n} (suc i) (suc j) a = #-inject< {m} {n} i j a punchOut : (i j : Fin (suc m)) → i # j → Fin m punchOut {suc m} zero (suc j) _ = j punchOut {suc m} (suc i) zero _ = zero punchOut {suc m} (suc i) (suc j) ap = suc (punchOut i j ap) punchOut-inj : ∀{i j k : Fin (suc m)} → (i#j : i # j) (i#k : i # k) → punchOut i j i#j ≡ punchOut i k i#k → j ≡ k punchOut-inj {suc m} {suc i} {zero} {zero} i#j i#k p = refl punchOut-inj {suc m} {zero} {suc j} {suc k} i#j i#k p = cong suc p punchOut-inj {suc m} {suc i} {suc j} {suc k} i#j i#k p = cong suc (punchOut-inj {m} {i} {j} {k} i#j i#k (Cover.predp p)) punchOut-inj {suc m} {suc i} {zero} {suc x} i#j i#k p = Empty.rec (Cover.cover p) punchOut-inj {suc m} {suc i} {suc j} {zero} i#j i#k p = Empty.rec (Cover.cover p) _⊕_ : (m : ℕ) → Fin n → Fin (m + n) zero ⊕ i = i suc m ⊕ i = suc (m ⊕ i) toFin : (n : ℕ) → Fin (suc n) toFin zero = zero toFin (suc n) = suc (toFin n) inject<#toFin : ∀(i : Fin n) → inject< (≤-refl (suc n)) i # toFin n inject<#toFin {suc n} zero = _ inject<#toFin {suc n} (suc i) = inject<#toFin {n} i inject≤#⊕ : ∀(i : Fin m) (j : Fin n) → inject≤ (k≤k+n m) i # (m ⊕ j) inject≤#⊕ {suc m} {suc n} zero j = _ inject≤#⊕ {suc m} {suc n} (suc i) j = inject≤#⊕ i j split : (m : ℕ) → Fin (m + n) → Fin m ⊎ Fin n split zero j = inr j split (suc m) zero = inl zero split (suc m) (suc i) with split m i ... | inl k = inl (suc k) ... | inr j = inr j pigeonhole : m < n → (f : Fin n → Fin m) → Σ[ i ∈ Fin n ] Σ[ j ∈ Fin n ] (i # j) × (f i ≡ f j) pigeonhole {zero} {suc n} m<n f = Empty.rec (f zero) pigeonhole {suc m} {suc n} m<n f with any? (λ i → discreteFin (f zero) (f (suc i))) ... | yes (j , p) = zero , suc j , _ , p ... | no ¬p = let i , j , ap , p = pigeonhole {m} {n} m<n g in suc i , suc j , ap , punchOut-inj {i = f zero} (apart i) (apart j) p where apart : (i : Fin n) → f zero # f (suc i) apart i = ≢→# {suc m} {f zero} (¬p ∘ _,_ i) g : Fin n → Fin m g i = punchOut (f zero) (f (suc i)) (apart i) Fin-inj₀ : m < n → ¬ Fin n ≡ Fin m Fin-inj₀ m<n P with pigeonhole m<n (transport P) ... | i , j , i#j , p = #→≢ i#j i≡j where i≡j : i ≡ j i≡j = transport (λ k → transport⁻Transport P i k ≡ transport⁻Transport P j k) (cong (transport⁻ P) p) Fin-inj : (m n : ℕ) → Fin m ≡ Fin n → m ≡ n Fin-inj m n P with m ≟ n ... | eq p = p ... | lt m<n = Empty.rec (Fin-inj₀ m<n (sym P)) ... | gt n<m = Empty.rec (Fin-inj₀ n<m P) module Isos where open Iso up : Fin m → Fin (m + n) up {m} = inject≤ (k≤k+n m) resplit-identᵣ₀ : ∀ m (i : Fin n) → Sum.⊎Path.Cover (split m (m ⊕ i)) (inr i) resplit-identᵣ₀ zero i = lift refl resplit-identᵣ₀ (suc m) i with split m (m ⊕ i) | resplit-identᵣ₀ m i ... | inr j | p = p resplit-identᵣ : ∀ m (i : Fin n) → split m (m ⊕ i) ≡ inr i resplit-identᵣ m i = Sum.⊎Path.decode _ _ (resplit-identᵣ₀ m i) resplit-identₗ₀ : ∀ m (i : Fin m) → Sum.⊎Path.Cover (split {n} m (up i)) (inl i) resplit-identₗ₀ (suc m) zero = lift refl resplit-identₗ₀ {n} (suc m) (suc i) with split {n} m (up i) | resplit-identₗ₀ {n} m i ... | inl j | lift p = lift (cong suc p) resplit-identₗ : ∀ m (i : Fin m) → split {n} m (up i) ≡ inl i resplit-identₗ m i = Sum.⊎Path.decode _ _ (resplit-identₗ₀ m i) desplit-ident : ∀ m → (i : Fin (m + n)) → Sum.rec up (m ⊕_) (split m i) ≡ i desplit-ident zero i = refl desplit-ident (suc m) zero = refl desplit-ident (suc m) (suc i) with split m i | desplit-ident m i ... | inl j | p = cong suc p ... | inr j | p = cong suc p sumIso : Iso (Fin m ⊎ Fin n) (Fin (m + n)) sumIso {m} .fun = Sum.rec up (m ⊕_) sumIso {m} .inv i = split m i sumIso {m} .rightInv i = desplit-ident m i sumIso {m} .leftInv (inr j) = resplit-identᵣ m j sumIso {m} .leftInv (inl i) = resplit-identₗ m i sum≡ : Fin m ⊎ Fin n ≡ Fin (m + n) sum≡ = isoToPath Isos.sumIso
{ "alphanum_fraction": 0.5683072947, "avg_line_length": 31.8838951311, "ext": "agda", "hexsha": "33ca4eecf231d655b154cb5ed675b2accc48c3a7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Edlyr/cubical", "max_forks_repo_path": "Cubical/Data/Fin/Recursive/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Edlyr/cubical", "max_issues_repo_path": "Cubical/Data/Fin/Recursive/Properties.agda", "max_line_length": 83, "max_stars_count": null, "max_stars_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Edlyr/cubical", "max_stars_repo_path": "Cubical/Data/Fin/Recursive/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3751, "size": 8513 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT module homotopy.EilenbergMacLane1 {i} (G : Group i) where private module G = Group G comp-equiv : ∀ g → G.El ≃ G.El comp-equiv g = equiv (λ x → G.comp x g) (λ x → G.comp x (G.inv g)) (λ x → G.assoc x (G.inv g) g ∙ ap (G.comp x) (G.inv-l g) ∙ G.unit-r x) (λ x → G.assoc x g (G.inv g) ∙ ap (G.comp x) (G.inv-r g) ∙ G.unit-r x) comp-equiv-comp : (g₁ g₂ : G.El) → comp-equiv (G.comp g₁ g₂) == (comp-equiv g₂ ∘e comp-equiv g₁) comp-equiv-comp g₁ g₂ = pair= (λ= (λ x → ! (G.assoc x g₁ g₂))) (prop-has-all-paths-↓ {B = is-equiv}) Ω-group : Group (lsucc i) Ω-group = Ω^S-group 0 ⊙[ (0 -Type i) , (G.El , G.El-level) ] Codes-hom : G →ᴳ Ω-group Codes-hom = group-hom (nType=-out ∘ ua ∘ comp-equiv) pres-comp where abstract pres-comp : ∀ g₁ g₂ → nType=-out {A = G.El , G.El-level} {B = G.El , G.El-level} (ua (comp-equiv (G.comp g₁ g₂))) == nType=-out {A = G.El , G.El-level} {B = G.El , G.El-level} (ua (comp-equiv g₁)) ∙ nType=-out {A = G.El , G.El-level} {B = G.El , G.El-level} (ua (comp-equiv g₂)) pres-comp g₁ g₂ = nType=-out {A = G.El , G.El-level} {B = G.El , G.El-level} (ua (comp-equiv (G.comp g₁ g₂))) =⟨ comp-equiv-comp g₁ g₂ |in-ctx nType=-out ∘ ua ⟩ nType=-out {A = G.El , G.El-level} {B = G.El , G.El-level} (ua (comp-equiv g₂ ∘e comp-equiv g₁)) =⟨ ua-∘e (comp-equiv g₁) (comp-equiv g₂) |in-ctx nType=-out ⟩ nType=-out {A = G.El , G.El-level} {B = G.El , G.El-level} (ua (comp-equiv g₁) ∙ ua (comp-equiv g₂)) =⟨ ! $ nType-∙ {A = G.El , G.El-level} {B = G.El , G.El-level} {C = G.El , G.El-level} (ua (comp-equiv g₁)) (ua (comp-equiv g₂)) ⟩ nType=-out {A = G.El , G.El-level} {B = G.El , G.El-level} (ua (comp-equiv g₁)) ∙ nType=-out {A = G.El , G.El-level} {B = G.El , G.El-level} (ua (comp-equiv g₂)) =∎ module CodesRec = EM₁Level₁Rec {G = G} {C = 0 -Type i} (G.El , G.El-level) Codes-hom Codes : EM₁ G → 0 -Type i Codes = CodesRec.f encode : {x : EM₁ G} → embase == x → fst (Codes x) encode α = transport (fst ∘ Codes) α G.ident abstract transp-Codes-β : ∀ g g' → transport (fst ∘ Codes) (emloop g) g' == G.comp g' g transp-Codes-β g g' = coe (ap (fst ∘ Codes) (emloop g)) g' =⟨ ap (λ v → coe v g') (ap-∘ fst Codes (emloop g)) ⟩ coe (ap fst (ap Codes (emloop g))) g' =⟨ ap (λ v → coe (ap fst v) g') (CodesRec.emloop-β g) ⟩ coe (ap fst (nType=-out (ua (comp-equiv g)))) g' =⟨ ap (λ v → coe v g') (fst=-β (ua (comp-equiv g)) _) ⟩ coe (ua (comp-equiv g)) g' =⟨ coe-β (comp-equiv g) g' ⟩ –> (comp-equiv g) g' =∎ encode-emloop : ∀ g → encode (emloop g) == g encode-emloop g = transport (fst ∘ Codes) (emloop g) G.ident =⟨ transp-Codes-β g G.ident ⟩ G.comp G.ident g =⟨ G.unit-l g ⟩ g =∎ module Decode where private {- transport in path fibration of EM₁ -} transp-PF : embase' G == embase → embase' G == embase → embase' G == embase transp-PF = transport (embase' G ==_) {- transport in Codes -} transp-C : embase' G == embase → G.El → G.El transp-C = transport (fst ∘ Codes) transp-emloop : embase' G == embase → G.El → embase' G == embase transp-emloop p = transp-PF p ∘ emloop emloop-transp : embase' G == embase → G.El → embase' G == embase emloop-transp p = emloop ∘ transp-C p swap-transp-emloop-seq : ∀ g h → transp-emloop (emloop g) h =-= emloop-transp (emloop g) h swap-transp-emloop-seq g h = transp-emloop (emloop g) h =⟪ transp-cst=idf (emloop g) (emloop h) ⟫ emloop h ∙ emloop g =⟪ ! (emloop-comp h g) ⟫ emloop (G.comp h g) =⟪ ap emloop (! (transp-Codes-β g h)) ⟫ emloop-transp (emloop g) h ∎∎ swap-transp-emloop : ∀ g h → transp-emloop (emloop g) h == emloop-transp (emloop g) h swap-transp-emloop g h = ↯ (swap-transp-emloop-seq g h) private decode-emloop-comp : ∀ g₁ g₂ h → swap-transp-emloop (G.comp g₁ g₂) h ◃∙ ap (λ p → emloop (transp-C p h)) (emloop-comp g₁ g₂) ◃∙ ap emloop (transp-∙ (emloop g₁) (emloop g₂) h) ◃∎ =ₛ ap (λ p → transp-PF p (emloop h)) (emloop-comp g₁ g₂) ◃∙ transp-∙ (emloop g₁) (emloop g₂) (emloop h) ◃∙ ap (transp-PF (emloop g₂)) (swap-transp-emloop g₁ h) ◃∙ swap-transp-emloop g₂ (transp-C (emloop g₁) h) ◃∎ decode-emloop-comp g₁ g₂ h = swap-transp-emloop g₁g₂ h ◃∙ ap (λ p → emloop-transp p h) (emloop-comp g₁ g₂) ◃∙ ap emloop (transp-∙ (emloop g₁) (emloop g₂) h) ◃∎ =ₛ₁⟨ 1 & 1 & ap-∘ emloop (λ p → transp-C p h) (emloop-comp g₁ g₂) ⟩ swap-transp-emloop g₁g₂ h ◃∙ ap emloop (ap (λ p → transp-C p h) (emloop-comp g₁ g₂)) ◃∙ ap emloop (transp-∙ (emloop g₁) (emloop g₂) h) ◃∎ =ₛ⟨ 0 & 1 & expand (swap-transp-emloop-seq g₁g₂ h) ⟩ transp-cst=idf (emloop g₁g₂) (emloop h) ◃∙ ! (emloop-comp h g₁g₂) ◃∙ ap emloop (! (transp-Codes-β g₁g₂ h)) ◃∙ ap emloop (ap (λ p → transp-C p h) (emloop-comp g₁ g₂)) ◃∙ ap emloop (transp-∙ (emloop g₁) (emloop g₂) h) ◃∎ =ₛ⟨ 2 & 3 & ap-seq-=ₛ emloop $ =ₛ-in {s = ! (transp-Codes-β g₁g₂ h) ◃∙ ap (λ p → transp-C p h) (emloop-comp g₁ g₂) ◃∙ transp-∙ (emloop g₁) (emloop g₂) h ◃∎} {t = ! (G.assoc h g₁ g₂) ◃∙ ap (λ k → G.comp k g₂) (! (transp-Codes-β g₁ h)) ◃∙ ! (transp-Codes-β g₂ (transp-C (emloop g₁) h)) ◃∎} $ prop-path (has-level-apply G.El-level _ _) _ _ ⟩ transp-cst=idf (emloop g₁g₂) (emloop h) ◃∙ ! (emloop-comp h g₁g₂) ◃∙ ap emloop (! (G.assoc h g₁ g₂)) ◃∙ ap emloop (ap (λ k → G.comp k g₂) (! (transp-Codes-β g₁ h))) ◃∙ ap emloop (! (transp-Codes-β g₂ (transp-C (emloop g₁) h))) ◃∎ =ₛ⟨ 0 & 1 & post-rotate-in {p = _ ◃∎} $ !ₛ $ homotopy-naturality (λ p → transp-PF p (emloop h)) (emloop h ∙_) (λ p → transp-cst=idf p (emloop h)) (emloop-comp g₁ g₂) ⟩ ap (λ p → transp-emloop p h) (emloop-comp g₁ g₂) ◃∙ transp-cst=idf (emloop g₁ ∙ emloop g₂) (emloop h) ◃∙ ! (ap (emloop h ∙_) (emloop-comp g₁ g₂)) ◃∙ ! (emloop-comp h g₁g₂) ◃∙ ap emloop (! (G.assoc h g₁ g₂)) ◃∙ ap emloop (ap (λ k → G.comp k g₂) (! (transp-Codes-β g₁ h))) ◃∙ ap emloop (! (transp-Codes-β g₂ (transp-C (emloop g₁) h))) ◃∎ =ₛ₁⟨ 4 & 1 & ap-! emloop (G.assoc h g₁ g₂) ⟩ ap (λ p → transp-emloop p h) (emloop-comp g₁ g₂) ◃∙ transp-cst=idf (emloop g₁ ∙ emloop g₂) (emloop h) ◃∙ ! (ap (emloop h ∙_) (emloop-comp g₁ g₂)) ◃∙ ! (emloop-comp h g₁g₂) ◃∙ ! (ap emloop (G.assoc h g₁ g₂)) ◃∙ ap emloop (ap (λ k → G.comp k g₂) (! (transp-Codes-β g₁ h))) ◃∙ ap emloop (! (transp-Codes-β g₂ (transp-C (emloop g₁) h))) ◃∎ =ₛ⟨ 2 & 3 & !ₛ (!-=ₛ (emloop-coh' G h g₁ g₂)) ⟩ ap (λ p → transp-emloop p h) (emloop-comp g₁ g₂) ◃∙ transp-cst=idf (emloop g₁ ∙ emloop g₂) (emloop h) ◃∙ ! (∙-assoc (emloop h) (emloop g₁) (emloop g₂)) ◃∙ ! (ap (_∙ emloop g₂) (emloop-comp h g₁)) ◃∙ ! (emloop-comp (G.comp h g₁) g₂) ◃∙ ap emloop (ap (λ k → G.comp k g₂) (! (transp-Codes-β g₁ h))) ◃∙ ap emloop (! (transp-Codes-β g₂ (transp-C (emloop g₁) h))) ◃∎ =ₛ⟨ 1 & 2 & post-rotate'-in {p = _ ◃∙ _ ◃∙ _ ◃∎} $ transp-cst=idf-pentagon (emloop g₁) (emloop g₂) (emloop h) ⟩ ap (λ p → transp-emloop p h) (emloop-comp g₁ g₂) ◃∙ transp-∙ (emloop g₁) (emloop g₂) (emloop h) ◃∙ ap (transp-PF (emloop g₂)) (transp-cst=idf (emloop g₁) (emloop h)) ◃∙ transp-cst=idf (emloop g₂) (emloop h ∙ emloop g₁) ◃∙ ! (ap (_∙ emloop g₂) (emloop-comp h g₁)) ◃∙ ! (emloop-comp (G.comp h g₁) g₂) ◃∙ ap emloop (ap (λ k → G.comp k g₂) (! (transp-Codes-β g₁ h))) ◃∙ ap emloop (! (transp-Codes-β g₂ (transp-C (emloop g₁) h))) ◃∎ =ₛ₁⟨ 6 & 1 & ∘-ap emloop (λ k → G.comp k g₂) (! (transp-Codes-β g₁ h)) ⟩ ap (λ p → transp-emloop p h) (emloop-comp g₁ g₂) ◃∙ transp-∙ (emloop g₁) (emloop g₂) (emloop h) ◃∙ ap (transp-PF (emloop g₂)) (transp-cst=idf (emloop g₁) (emloop h)) ◃∙ transp-cst=idf (emloop g₂) (emloop h ∙ emloop g₁) ◃∙ ! (ap (_∙ emloop g₂) (emloop-comp h g₁)) ◃∙ ! (emloop-comp (G.comp h g₁) g₂) ◃∙ ap (λ k → emloop (G.comp k g₂)) (! (transp-Codes-β g₁ h)) ◃∙ ap emloop (! (transp-Codes-β g₂ (transp-C (emloop g₁) h))) ◃∎ =ₛ⟨ 5 & 2 & !ₛ $ homotopy-naturality (λ k → emloop k ∙ emloop g₂) (λ k → emloop (G.comp k g₂)) (λ k → ! (emloop-comp k g₂)) (! (transp-Codes-β g₁ h)) ⟩ ap (λ p → transp-emloop p h) (emloop-comp g₁ g₂) ◃∙ transp-∙ (emloop g₁) (emloop g₂) (emloop h) ◃∙ ap (transp-PF (emloop g₂)) (transp-cst=idf (emloop g₁) (emloop h)) ◃∙ transp-cst=idf (emloop g₂) (emloop h ∙ emloop g₁) ◃∙ ! (ap (_∙ emloop g₂) (emloop-comp h g₁)) ◃∙ ap (λ k → emloop k ∙ emloop g₂) (! (transp-Codes-β g₁ h)) ◃∙ ! (emloop-comp (transp-C (emloop g₁) h) g₂) ◃∙ ap emloop (! (transp-Codes-β g₂ (transp-C (emloop g₁) h))) ◃∎ =ₛ₁⟨ 4 & 1 & !-ap (_∙ emloop g₂) (emloop-comp h g₁) ⟩ ap (λ p → transp-PF p (emloop h)) (emloop-comp g₁ g₂) ◃∙ transp-∙ (emloop g₁) (emloop g₂) (emloop h) ◃∙ ap (transp-PF (emloop g₂)) (transp-cst=idf (emloop g₁) (emloop h)) ◃∙ transp-cst=idf (emloop g₂) (emloop h ∙ emloop g₁) ◃∙ ap (_∙ emloop g₂) (! (emloop-comp h g₁)) ◃∙ ap (λ k → emloop k ∙ emloop g₂) (! (transp-Codes-β g₁ h)) ◃∙ ! (emloop-comp (transp-C (emloop g₁) h) g₂) ◃∙ ap emloop (! (transp-Codes-β g₂ (transp-C (emloop g₁) h))) ◃∎ =ₛ⟨ 3 & 2 & !ₛ $ homotopy-naturality (transp-PF (emloop g₂)) (_∙ emloop g₂) (transp-cst=idf (emloop g₂)) (! (emloop-comp h g₁)) ⟩ ap (λ p → transp-emloop p h) (emloop-comp g₁ g₂) ◃∙ transp-∙ (emloop g₁) (emloop g₂) (emloop h) ◃∙ ap (transp-PF (emloop g₂)) (transp-cst=idf (emloop g₁) (emloop h)) ◃∙ ap (transp-PF (emloop g₂)) (! (emloop-comp h g₁)) ◃∙ transp-cst=idf (emloop g₂) (emloop (G.comp h g₁)) ◃∙ ap (λ k → emloop k ∙ emloop g₂) (! (transp-Codes-β g₁ h)) ◃∙ ! (emloop-comp (transp-C (emloop g₁) h) g₂) ◃∙ ap emloop (! (transp-Codes-β g₂ (transp-C (emloop g₁) h))) ◃∎ =ₛ₁⟨ 5 & 1 & ap-∘ (_∙ emloop g₂) emloop (! (transp-Codes-β g₁ h)) ⟩ ap (λ p → transp-emloop p h) (emloop-comp g₁ g₂) ◃∙ transp-∙ (emloop g₁) (emloop g₂) (emloop h) ◃∙ ap (transp-PF (emloop g₂)) (transp-cst=idf (emloop g₁) (emloop h)) ◃∙ ap (transp-PF (emloop g₂)) (! (emloop-comp h g₁)) ◃∙ transp-cst=idf (emloop g₂) (emloop (G.comp h g₁)) ◃∙ ap (_∙ emloop g₂) (ap emloop (! (transp-Codes-β g₁ h))) ◃∙ ! (emloop-comp (transp-C (emloop g₁) h) g₂) ◃∙ ap emloop (! (transp-Codes-β g₂ (transp-C (emloop g₁) h))) ◃∎ =ₛ⟨ 4 & 2 & !ₛ $ homotopy-naturality (transp-PF (emloop g₂)) (_∙ emloop g₂) (transp-cst=idf (emloop g₂)) (ap emloop (! (transp-Codes-β g₁ h))) ⟩ ap (λ p → transp-emloop p h) (emloop-comp g₁ g₂) ◃∙ transp-∙ (emloop g₁) (emloop g₂) (emloop h) ◃∙ ap (transp-PF (emloop g₂)) (transp-cst=idf (emloop g₁) (emloop h)) ◃∙ ap (transp-PF (emloop g₂)) (! (emloop-comp h g₁)) ◃∙ ap (transp-PF (emloop g₂)) (ap emloop (! (transp-Codes-β g₁ h))) ◃∙ transp-cst=idf (emloop g₂) (emloop (transp-C (emloop g₁) h)) ◃∙ ! (emloop-comp (transp-C (emloop g₁) h) g₂) ◃∙ ap emloop (! (transp-Codes-β g₂ (transp-C (emloop g₁) h))) ◃∎ =ₛ⟨ 2 & 3 & ∙-ap-seq (transp-PF (emloop g₂)) (swap-transp-emloop-seq g₁ h) ⟩ ap (λ p → transp-emloop p h) (emloop-comp g₁ g₂) ◃∙ transp-∙ (emloop g₁) (emloop g₂) (emloop h) ◃∙ ap (transp-PF (emloop g₂)) (swap-transp-emloop g₁ h) ◃∙ transp-cst=idf (emloop g₂) (emloop (transp-C (emloop g₁) h)) ◃∙ ! (emloop-comp (transp-C (emloop g₁) h) g₂) ◃∙ ap emloop (! (transp-Codes-β g₂ (transp-C (emloop g₁) h))) ◃∎ =ₛ⟨ 3 & 3 & contract ⟩ ap (λ p → transp-emloop p h) (emloop-comp g₁ g₂) ◃∙ transp-∙ (emloop g₁) (emloop g₂) (emloop h) ◃∙ ap (transp-PF (emloop g₂)) (swap-transp-emloop g₁ h) ◃∙ swap-transp-emloop g₂ (transp-C (emloop g₁) h) ◃∎ ∎ₛ where g₁g₂ = G.comp g₁ g₂ decode : {x : EM₁ G} → fst (Codes x) → embase == x decode {x} = Decode.f x where module Decode = EM₁Level₁FunElim {B = fst ∘ Codes} {C = embase' G ==_} emloop swap-transp-emloop decode-emloop-comp open Decode using (decode) decode-encode : ∀ {x} (α : embase' G == x) → decode (encode α) == α decode-encode idp = emloop-ident {G = G} emloop-equiv : G.El ≃ (embase' G == embase) emloop-equiv = equiv emloop encode decode-encode encode-emloop ⊙emloop-equiv : G.⊙El ⊙≃ ⊙Ω (⊙EM₁ G) ⊙emloop-equiv = ≃-to-⊙≃ emloop-equiv emloop-ident abstract instance EM₁-level₁ : {n : ℕ₋₂} → has-level (S (S (S n))) (EM₁ G) EM₁-level₁ {⟨-2⟩} = has-level-in pathspace-is-set where embase-loopspace-is-set : is-set (embase' G == embase) embase-loopspace-is-set = transport is-set (ua emloop-equiv) ⟨⟩ pathspace-is-set : ∀ (x y : EM₁ G) → is-set (x == y) pathspace-is-set = EM₁-prop-elim (EM₁-prop-elim embase-loopspace-is-set) EM₁-level₁ {S n} = raise-level _ EM₁-level₁ Ω¹-EM₁ : Ω^S-group 0 (⊙EM₁ G) ≃ᴳ G Ω¹-EM₁ = ≃-to-≃ᴳ (emloop-equiv ⁻¹) (λ l₁ l₂ → <– (ap-equiv emloop-equiv _ _) $ emloop (encode (l₁ ∙ l₂)) =⟨ decode-encode (l₁ ∙ l₂) ⟩ l₁ ∙ l₂ =⟨ ! $ ap2 _∙_ (decode-encode l₁) (decode-encode l₂) ⟩ emloop (encode l₁) ∙ emloop (encode l₂) =⟨ ! $ emloop-comp (encode l₁) (encode l₂) ⟩ emloop (G.comp (encode l₁) (encode l₂)) =∎) π₁-EM₁ : πS 0 (⊙EM₁ G) ≃ᴳ G π₁-EM₁ = Ω¹-EM₁ ∘eᴳ unTrunc-iso (Ω^S-group-structure 0 (⊙EM₁ G))
{ "alphanum_fraction": 0.4870230989, "avg_line_length": 49.0828025478, "ext": "agda", "hexsha": "5c1d31c88521f8f0713f5e7f6ee652d157ee3eed", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AntoineAllioux/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/EilenbergMacLane1.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "AntoineAllioux/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/EilenbergMacLane1.agda", "max_line_length": 110, "max_stars_count": 294, "max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AntoineAllioux/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/EilenbergMacLane1.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 6251, "size": 15412 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Functor.Algebras where open import Level hiding (lift) open import Categories.Category open import Categories.Functor hiding (_≡_; id; _∘_; equiv; assoc; identityˡ; identityʳ; ∘-resp-≡) open import Categories.Functor.Algebra record F-Algebra-Morphism {o ℓ e} {C : Category o ℓ e} {F : Endofunctor C} (X Y : F-Algebra F) : Set (ℓ ⊔ e) where constructor _,_ open Category C module X = F-Algebra X module Y = F-Algebra Y open Functor F field f : X.A ⇒ Y.A .commutes : f ∘ X.α ≡ Y.α ∘ F₁ f F-Algebras : ∀ {o ℓ e} {C : Category o ℓ e} → Endofunctor C → Category (ℓ ⊔ o) (e ⊔ ℓ) e F-Algebras {C = C} F = record { Obj = Obj′ ; _⇒_ = Hom′ ; _≡_ = _≡′_ ; _∘_ = _∘′_ ; id = id′ ; assoc = assoc ; identityˡ = identityˡ ; identityʳ = identityʳ ; equiv = record { refl = refl ; sym = sym ; trans = trans } ; ∘-resp-≡ = ∘-resp-≡ } where open Category C open Equiv open Functor F Obj′ = F-Algebra F Hom′ : (A B : Obj′) → Set _ Hom′ = F-Algebra-Morphism _≡′_ : ∀ {A B} (f g : Hom′ A B) → Set _ (f , _) ≡′ (g , _) = f ≡ g _∘′_ : ∀ {A B C} → Hom′ B C → Hom′ A B → Hom′ A C _∘′_ {A} {B} {C} (f , pf₁) (g , pf₂) = _,_ {X = A} {C} (f ∘ g) pf -- TODO: find out why the hell I need to provide these implicits where module A = F-Algebra A module B = F-Algebra B module C = F-Algebra C .pf : (f ∘ g) ∘ A.α ≡ C.α ∘ (F₁ (f ∘ g)) pf = begin (f ∘ g) ∘ A.α ↓⟨ assoc ⟩ f ∘ (g ∘ A.α) ↓⟨ ∘-resp-≡ʳ pf₂ ⟩ f ∘ (B.α ∘ F₁ g) ↑⟨ assoc ⟩ (f ∘ B.α) ∘ F₁ g ↓⟨ ∘-resp-≡ˡ pf₁ ⟩ (C.α ∘ F₁ f) ∘ F₁ g ↓⟨ assoc ⟩ C.α ∘ (F₁ f ∘ F₁ g) ↑⟨ ∘-resp-≡ʳ homomorphism ⟩ C.α ∘ (F₁ (f ∘ g)) ∎ where open HomReasoning id′ : ∀ {A} → Hom′ A A id′ {A} = _,_ {X = A} {A} id pf where module A = F-Algebra A .pf : id ∘ A.α ≡ A.α ∘ F₁ id pf = begin id ∘ A.α ↓⟨ identityˡ ⟩ A.α ↑⟨ identityʳ ⟩ A.α ∘ id ↑⟨ ∘-resp-≡ʳ identity ⟩ A.α ∘ F₁ id ∎ where open HomReasoning open import Categories.Object.Initial module Lambek {o ℓ e} {C : Category o ℓ e} {F : Endofunctor C} (I : Initial (F-Algebras F)) where open Category C open Equiv module FA = Category (F-Algebras F) renaming (_∘_ to _∘FA_; _≡_ to _≡FA_) open Functor F import Categories.Morphisms as Morphisms open Morphisms C open Initial I open F-Algebra ⊥ lambek : A ≅ F₀ A lambek = record { f = f′ ; g = g′ ; iso = iso′ } where f′ : A ⇒ F₀ A f′ = F-Algebra-Morphism.f (! {lift ⊥}) g′ : F₀ A ⇒ A g′ = α .iso′ : Iso f′ g′ iso′ = record { isoˡ = isoˡ′ ; isoʳ = begin f′ ∘ g′ ↓⟨ F-Algebra-Morphism.commutes (! {lift ⊥}) ⟩ F₁ g′ ∘ F₁ f′ ↑⟨ homomorphism ⟩ F₁ (g′ ∘ f′) ↓⟨ F-resp-≡ isoˡ′ ⟩ F₁ id ↓⟨ identity ⟩ id ∎ } where open FA hiding (id; module HomReasoning) open HomReasoning isoˡ′ = ⊥-id ((_,_ {C = C} {F} g′ refl) ∘FA !) open Lambek public
{ "alphanum_fraction": 0.4769461078, "avg_line_length": 23.5211267606, "ext": "agda", "hexsha": "ebc0d4d18abc7377c68a7f368b3fc1f41617d478", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Functor/Algebras.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Functor/Algebras.agda", "max_line_length": 132, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Functor/Algebras.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 1369, "size": 3340 }
module Agda.Builtin.TrustMe where open import Agda.Builtin.Equality primitive primTrustMe : ∀ {a} {A : Set a} {x y : A} → x ≡ y
{ "alphanum_fraction": 0.679389313, "avg_line_length": 18.7142857143, "ext": "agda", "hexsha": "1108f9b0157647533cd2e652560ac394679564fd", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/TrustMe.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/TrustMe.agda", "max_line_length": 59, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/TrustMe.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 47, "size": 131 }
module Issue2649-1 where module MyModule (A : Set) (a : A) where foo : A foo = a
{ "alphanum_fraction": 0.6206896552, "avg_line_length": 12.4285714286, "ext": "agda", "hexsha": "be631e543dcf5d5104801dd01e22c5c4663517b1", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/customised/Issue2649-1.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/customised/Issue2649-1.agda", "max_line_length": 39, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/customised/Issue2649-1.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 33, "size": 87 }
module Prelude.Semigroup where open import Prelude.Function open import Prelude.Maybe open import Prelude.List open import Prelude.Semiring open import Prelude.Applicative open import Prelude.Functor open import Prelude.Equality record Semigroup {a} (A : Set a) : Set a where infixr 6 _<>_ field _<>_ : A → A → A open Semigroup {{...}} public {-# DISPLAY Semigroup._<>_ _ a b = a <> b #-} {-# DISPLAY Semigroup._<>_ _ = _<>_ #-} record Semigroup/Laws {a} (A : Set a) : Set a where field {{super}} : Semigroup A semigroup-assoc : (a b c : A) → (a <> b) <> c ≡ a <> (b <> c) open Semigroup/Laws {{...}} public hiding (super) instance SemigroupList : ∀ {a} {A : Set a} → Semigroup (List A) _<>_ {{SemigroupList}} = _++_ SemigroupFun : ∀ {a b} {A : Set a} {B : A → Set b} {{_ : ∀ {x} → Semigroup (B x)}} → Semigroup (∀ x → B x) _<>_ {{SemigroupFun}} f g x = f x <> g x SemigroupMaybe : ∀ {a} {A : Set a} → Semigroup (Maybe A) _<>_ {{SemigroupMaybe}} nothing y = y _<>_ {{SemigroupMaybe}} (just x) _ = just x
{ "alphanum_fraction": 0.6037914692, "avg_line_length": 27.0512820513, "ext": "agda", "hexsha": "b51199989a09bac4a9eaa5ee7ba6568497c4bfe2", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_path": "src/Prelude/Semigroup.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_path": "src/Prelude/Semigroup.agda", "max_line_length": 108, "max_stars_count": 111, "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_path": "src/Prelude/Semigroup.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 360, "size": 1055 }
------------------------------------------------------------------------ -- Comparisons of different kinds of lenses, focusing on the -- definition of composable record setters and getters ------------------------------------------------------------------------ {-# OPTIONS --cubical --safe #-} -- This module uses both dependent and non-dependent lenses, in order -- to illustrate a problem with the non-dependent ones. It also uses -- two kinds of dependent lenses, in order to illustrate a minor -- problem with one of them. module README.Record-getters-and-setters where open import Equality.Propositional.Cubical open import Prelude hiding (_∘_) open import Bijection equality-with-J as Bij using (_↔_; module _↔_) open import Equality.Decision-procedures equality-with-J import Equivalence equality-with-J as Eq open import Function-universe equality-with-J as F hiding (_∘_) import Lens.Dependent import Lens.Non-dependent.Higher equality-with-paths as Higher ------------------------------------------------------------------------ -- Dependent lenses with "remainder types" visible in the type module Dependent₃ where open Lens.Dependent -- Nested records. record R₁ (A : Set) : Set where field f : A → A x : A lemma : ∀ y → f y ≡ y record R₂ : Set₁ where field A : Set r₁ : R₁ A -- Lenses for each of the three fields of R₁. -- The x field is easiest, because it is independent of the others. -- -- (Note that the from function is inferred automatically.) x : {A : Set} → Lens₃ (R₁ A) (∃ λ (f : A → A) → ∀ y → f y ≡ y) (λ _ → A) x = Eq.↔⇒≃ (record { surjection = record { logical-equivalence = record { to = λ r → (R₁.f r , R₁.lemma r) , R₁.x r ; from = _ } ; right-inverse-of = λ _ → refl } ; left-inverse-of = λ _ → refl }) -- The lemma field depends on the f field, so whenever the f field -- is set the lemma field needs to be updated as well. f : {A : Set} → Lens₃ (R₁ A) A (λ _ → ∃ λ (f : A → A) → ∀ y → f y ≡ y) f = Eq.↔⇒≃ (record { surjection = record { logical-equivalence = record { to = λ r → R₁.x r , (R₁.f r , R₁.lemma r) ; from = _ } ; right-inverse-of = λ _ → refl } ; left-inverse-of = λ _ → refl }) -- The lemma field can be updated independently. lemma : {A : Set} → Lens₃ (R₁ A) (A × (A → A)) (λ r → ∀ y → proj₂ r y ≡ y) lemma = Eq.↔⇒≃ (record { surjection = record { logical-equivalence = record { to = λ r → (R₁.x r , R₁.f r) , R₁.lemma r ; from = _ } ; right-inverse-of = λ _ → refl } ; left-inverse-of = λ _ → refl }) -- Note that the type of the last lens may not be quite -- satisfactory: the type of the lens does not guarantee that the -- lemma applies to the input's f field. The following lemma may -- provide some form of consolation: consolation : {A : Set} (r : R₁ A) → ∀ y → R₁.f r y ≡ y consolation = Lens₃.get lemma -- Let us now construct lenses for the same fields, but accessed -- through an R₂ record. -- First we define lenses for the fields of R₂ (note that the A lens -- does not seem to be very useful): A : Lens₃ R₂ ⊤ (λ _ → R₂) A = id₃ r₁ : Lens₃ R₂ Set R₁ r₁ = Eq.↔⇒≃ (record { surjection = record { logical-equivalence = record { to = λ r → R₂.A r , R₂.r₁ r ; from = _ } ; right-inverse-of = λ _ → refl } ; left-inverse-of = λ _ → refl }) -- The lenses for the three R₁ fields can now be defined by -- composition: x₂ : Lens₃ R₂ _ (λ r → proj₁ r) x₂ = x ₃∘₃ r₁ f₂ : Lens₃ R₂ _ (λ r → ∃ λ (f : proj₁ r → proj₁ r) → ∀ y → f y ≡ y) f₂ = f ₃∘₃ r₁ lemma₂ : Lens₃ R₂ _ (λ r → ∀ y → proj₂ (proj₂ r) y ≡ y) lemma₂ = lemma ₃∘₃ r₁ consolation₂ : (r : R₂) → ∀ y → proj₁ (Lens₃.get f₂ r) y ≡ y consolation₂ = Lens₃.get lemma₂ ------------------------------------------------------------------------ -- Dependent lenses without "remainder types" visible in the type module Dependent where open Lens.Dependent open Dependent₃ using (R₁; module R₁; R₂; module R₂) -- Lenses for each of the three fields of R₁. x : {A : Set} → Lens (R₁ A) (λ _ → A) x = Lens₃-to-Lens Dependent₃.x f : {A : Set} → Lens (R₁ A) (λ _ → ∃ λ (f : A → A) → ∀ y → f y ≡ y) f = Lens₃-to-Lens Dependent₃.f lemma : {A : Set} → Lens (R₁ A) (λ r → ∀ y → R₁.f r y ≡ y) lemma = Lens₃-to-Lens Dependent₃.lemma -- Note that the type of lemma is now more satisfactory: the type of -- the lens /does/ guarantee that the lemma applies to the input's f -- field. -- A lens for the r₁ field of R₂. r₁ : Lens R₂ (λ r → R₁ (R₂.A r)) r₁ = Lens₃-to-Lens {-a = # 0-} Dependent₃.r₁ -- Lenses for the fields of R₁, accessed through an R₂ record. Note -- the use of /forward/ composition. x₂ : Lens R₂ (λ r → R₂.A r) x₂ = r₁ ⨾ x f₂ : Lens R₂ (λ r → ∃ λ (f : R₂.A r → R₂.A r) → ∀ y → f y ≡ y) f₂ = r₁ ⨾ f lemma₂ : Lens R₂ (λ r → ∀ y → R₁.f (R₂.r₁ r) y ≡ y) lemma₂ = r₁ ⨾ lemma ------------------------------------------------------------------------ -- Non-dependent lenses module Non-dependent where open Higher open Lens-combinators -- Labels. data Label : Set where ″f″ ″x″ ″lemma″ ″A″ ″r₁″ : Label -- Labels come with decidable equality. Label↔Fin : Label ↔ Fin 5 Label↔Fin = record { surjection = record { logical-equivalence = record { to = to ; from = from } ; right-inverse-of = to∘from } ; left-inverse-of = from∘to } where to : Label → Fin 5 to ″f″ = fzero to ″x″ = fsuc fzero to ″lemma″ = fsuc (fsuc fzero) to ″A″ = fsuc (fsuc (fsuc fzero)) to ″r₁″ = fsuc (fsuc (fsuc (fsuc fzero))) from : Fin 5 → Label from fzero = ″f″ from (fsuc fzero) = ″x″ from (fsuc (fsuc fzero)) = ″lemma″ from (fsuc (fsuc (fsuc fzero))) = ″A″ from (fsuc (fsuc (fsuc (fsuc fzero)))) = ″r₁″ from (fsuc (fsuc (fsuc (fsuc (fsuc ()))))) to∘from : ∀ i → to (from i) ≡ i to∘from fzero = refl to∘from (fsuc fzero) = refl to∘from (fsuc (fsuc fzero)) = refl to∘from (fsuc (fsuc (fsuc fzero))) = refl to∘from (fsuc (fsuc (fsuc (fsuc fzero)))) = refl to∘from (fsuc (fsuc (fsuc (fsuc (fsuc ()))))) from∘to : ∀ ℓ → from (to ℓ) ≡ ℓ from∘to ″f″ = refl from∘to ″x″ = refl from∘to ″lemma″ = refl from∘to ″A″ = refl from∘to ″r₁″ = refl _≟_ : Decidable-equality Label _≟_ = Bij.decidable-equality-respects (inverse Label↔Fin) Fin._≟_ -- Records. open import Records-with-with equality-with-J Label _≟_ -- Nested records (defined using the record language from Record, so -- that we can use manifest fields). R₁ : Set → Signature _ R₁ A = ∅ , ″f″ ∶ (λ _ → A → A) , ″x″ ∶ (λ _ → A) , ″lemma″ ∶ (λ r → ∀ y → (r · ″f″) y ≡ y) R₂ : Signature _ R₂ = ∅ , ″A″ ∶ (λ _ → Set) , ″r₁″ ∶ (λ r → ↑ _ (Record (R₁ (r · ″A″)))) -- Lenses for each of the three fields of R₁. -- The x field is easiest, because it is independent of the others. x : {A : Set} → Lens (Record (R₁ A)) A x {A} = isomorphism-to-lens (Record (R₁ A) ↝⟨ Record↔Recʳ ⟩ (∃ λ (f : A → A) → ∃ λ (x : A) → ∀ y → f y ≡ y) ↝⟨ ∃-comm ⟩ (A × ∃ λ (f : A → A) → ∀ y → f y ≡ y) ↝⟨ ×-comm ⟩□ (∃ λ (f : A → A) → ∀ y → f y ≡ y) × A □) -- The lemma field depends on the f field, so whenever the f field -- is set the lemma field needs to be updated as well. f : {A : Set} → Lens (Record (R₁ A)) (Record (∅ , ″f″ ∶ (λ _ → A → A) , ″lemma″ ∶ (λ r → ∀ x → (r · ″f″) x ≡ x))) f {A} = isomorphism-to-lens (Record (R₁ A) ↝⟨ Record↔Recʳ ⟩ (∃ λ (f : A → A) → ∃ λ (x : A) → ∀ y → f y ≡ y) ↝⟨ ∃-comm ⟩ A × (∃ λ (f : A → A) → ∀ y → f y ≡ y) ↝⟨ F.id ×-cong inverse Record↔Recʳ ⟩□ A × Record _ □) -- The lemma field can be updated independently. Note the use of a -- manifest field in the type of the lens to capture the dependency -- between the two lens parameters. lemma : {A : Set} {f : A → A} → Lens (Record (R₁ A With ″f″ ≔ (λ _ → f))) (∀ x → f x ≡ x) lemma {A} {f} = isomorphism-to-lens (Record (R₁ A With ″f″ ≔ (λ _ → f)) ↝⟨ Record↔Recʳ ⟩□ A × (∀ x → f x ≡ x) □) -- The use of a manifest field is problematic, because the domain of -- the lens is no longer Record (R₁ A). It is easy to convert -- records into the required form, but this conversion is not a -- non-dependent lens (due to the dependency). convert : {A : Set} (r : Record (R₁ A)) → Record (R₁ A With ″f″ ≔ (λ _ → r · ″f″)) convert (rec (rec (rec (_ , f) , x) , lemma)) = rec (rec (_ , x) , lemma) -- Let us now try to construct lenses for the same fields, but -- accessed through an R₂ record. -- First we define a lens for the r₁ field. r₁ : {A : Set} → Lens (Record (R₂ With ″A″ ≔ λ _ → A)) (Record (R₁ A)) r₁ {A} = isomorphism-to-lens (Record (R₂ With ″A″ ≔ λ _ → A) ↝⟨ Record↔Recʳ ⟩ ↑ _ (Record (R₁ A)) ↝⟨ Bij.↑↔ ⟩ Record (R₁ A) ↝⟨ inverse ×-left-identity ⟩ ⊤ × Record (R₁ A) ↝⟨ inverse Bij.↑↔ ×-cong F.id ⟩□ ↑ _ ⊤ × Record (R₁ A) □) -- It is now easy to construct lenses for the embedded x and f -- fields using composition of lenses. x₂ : {A : Set} → Lens (Record (R₂ With ″A″ ≔ λ _ → A)) A x₂ = ⟨ _ , _ ⟩ x ∘ r₁ f₂ : {A : Set} → Lens (Record (R₂ With ″A″ ≔ λ _ → A)) (Record (∅ , ″f″ ∶ (λ _ → A → A) , ″lemma″ ∶ (λ r → ∀ x → (r · ″f″) x ≡ x))) f₂ = ⟨ _ , _ ⟩ f ∘ r₁ -- It is less obvious how to construct the corresponding lens for -- the embedded lemma field. module Lemma-lens (r₁₂ : {A : Set} {r : Record (R₁ A)} → Lens (Record (R₂ With ″A″ ≔ (λ _ → A) With ″r₁″ ≔ (λ _ → lift r))) (Record (R₁ A With ″f″ ≔ (λ _ → r · ″f″)))) where -- To start with, what should the type of the lemma lens be? The -- type used below is an obvious choice. lemma₂ : {A : Set} {r : Record (R₁ A)} → Lens (Record (R₂ With ″A″ ≔ (λ _ → A) With ″r₁″ ≔ (λ _ → lift r))) (∀ x → (r · ″f″) x ≡ x) -- If we can construct a suitable lens r₁₂, with the type -- signature given above, then we can define the lemma lens using -- composition. lemma₂ = ⟨ _ , _ ⟩ lemma ∘ r₁₂ -- However, we cannot define r₁₂. not-r₁₂ : ⊥ not-r₁₂ = no-isomorphism isomorphism where open Lens isomorphisms : ∀ _ _ → _ isomorphisms = λ A r → ⊤ ↝⟨ inverse Bij.↑↔ ⟩ ↑ _ ⊤ ↝⟨ inverse Record↔Recʳ ⟩ Record (R₂ With ″A″ ≔ (λ _ → A) With ″r₁″ ≔ (λ _ → lift r)) ↔⟨ equiv r₁₂ ⟩ R r₁₂ × Record (R₁ A With ″f″ ≔ (λ _ → r · ″f″)) ↝⟨ F.id ×-cong Record↔Recʳ ⟩□ R r₁₂ × A × (∀ y → (r · ″f″) y ≡ y) □ isomorphism : ∃ λ (A : Set₁) → ⊤ ↔ A × Bool isomorphism = _ , (⊤ ↝⟨ isomorphisms Bool r ⟩ R r₁₂ × Bool × (∀ b → b ≡ b) ↝⟨ F.id ×-cong ×-comm ⟩ R r₁₂ × (∀ b → b ≡ b) × Bool ↝⟨ ×-assoc ⟩□ (R r₁₂ × (∀ b → b ≡ b)) × Bool □) where r : Record (R₁ Bool) r = rec (rec (rec (_ , F.id) , true) , λ _ → refl) no-isomorphism : ¬ ∃ λ (A : Set₁) → ⊤ ↔ A × Bool no-isomorphism (A , iso) = Bool.true≢false ( true ≡⟨⟩ proj₂ (a , true) ≡⟨ cong proj₂ $ sym $ right-inverse-of (a , true) ⟩ proj₂ (to (from (a , true))) ≡⟨⟩ proj₂ (to (from (a , false))) ≡⟨ cong proj₂ $ right-inverse-of (a , false) ⟩ proj₂ (a , false) ≡⟨ refl ⟩∎ false ∎) where open _↔_ iso a : A a = proj₁ (to _) -- Conclusion: The use of manifest fields limits the usefulness of -- these lenses, because they do not compose as well as they do for -- non-dependent records. Dependent lenses seem to be more useful.
{ "alphanum_fraction": 0.4936243448, "avg_line_length": 31.9575, "ext": "agda", "hexsha": "3e130041098c2e40fba3fffbecd2c7c4640a2cf4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b7921cc6b52858cd7d8a52c183c7a6544d1a4062", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Saizan/dependent-lenses", "max_forks_repo_path": "README/Record-getters-and-setters.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b7921cc6b52858cd7d8a52c183c7a6544d1a4062", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Saizan/dependent-lenses", "max_issues_repo_path": "README/Record-getters-and-setters.agda", "max_line_length": 91, "max_stars_count": null, "max_stars_repo_head_hexsha": "b7921cc6b52858cd7d8a52c183c7a6544d1a4062", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Saizan/dependent-lenses", "max_stars_repo_path": "README/Record-getters-and-setters.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4434, "size": 12783 }
module Type.Category.ExtensionalFunctionsCategory{ℓ} where open import Data open import Functional open import Function.Equals open import Function.Equals.Proofs open import Logic.Propositional import Relator.Equals as Eq open import Relator.Equals.Proofs.Equiv open import Structure.Category open import Structure.Categorical.Properties open import Type open import Type.Properties.Singleton -- The set category but the equality on the morphisms/functions is pointwise/extensional. typeExtensionalFnCategory : Category{Obj = Type{ℓ}}(_→ᶠ_) ⦃ [⊜]-equiv ⦃ [≡]-equiv ⦄ ⦄ Category._∘_ typeExtensionalFnCategory = _∘_ Category.id typeExtensionalFnCategory = id Category.binaryOperator typeExtensionalFnCategory = [⊜][∘]-binaryOperator Morphism.Associativity.proof (Category.associativity typeExtensionalFnCategory) {x = _} {_} {_} {x = f} {g} {h} = [⊜]-associativity {x = f}{y = g}{z = h} Category.identity typeExtensionalFnCategory = [∧]-intro (Morphism.intro (Dependent.intro Eq.[≡]-intro)) (Morphism.intro (Dependent.intro Eq.[≡]-intro)) typeExtensionalFnCategoryObject : CategoryObject typeExtensionalFnCategoryObject = intro typeExtensionalFnCategory Empty-initialObject : Object.Initial{Obj = Type{ℓ}}(_→ᶠ_) ⦃ [⊜]-equiv ⦃ [≡]-equiv ⦄ ⦄ (Empty) IsUnit.unit Empty-initialObject = empty _⊜_.proof (IsUnit.uniqueness Empty-initialObject {f}) {} Unit-terminalObject : Object.Terminal{Obj = Type{ℓ}}(_→ᶠ_) ⦃ [⊜]-equiv ⦃ [≡]-equiv ⦄ ⦄ (Unit) IsUnit.unit Unit-terminalObject = const <> _⊜_.proof (IsUnit.uniqueness Unit-terminalObject {f}) {_} = Eq.[≡]-intro
{ "alphanum_fraction": 0.7621483376, "avg_line_length": 47.3939393939, "ext": "agda", "hexsha": "82fba45e0a7d8c3b0d17bcd5aa63dc7496256611", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Type/Category/ExtensionalFunctionsCategory.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Type/Category/ExtensionalFunctionsCategory.agda", "max_line_length": 153, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Type/Category/ExtensionalFunctionsCategory.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 474, "size": 1564 }
module Oscar.Data.Vec where open import Data.Vec public open import Oscar.Data.Nat open import Oscar.Data.Equality open import Data.Nat map₂ : ∀ {a b} {A : Set a} {B : Set b} {m n} → ∀ {c} {C : Set c} (f : A → B → C) → Vec A m → Vec B n → Vec C (m * n) map₂ f xs ys = map f xs ⊛* ys open import Data.Fin delete : ∀ {a n} {A : Set a} → Fin (suc n) → Vec A (suc n) → Vec A n delete zero (x ∷ xs) = xs delete {n = zero} (suc ()) _ delete {n = suc n} (suc i) (x ∷ xs) = x ∷ delete i xs open import Function open import Data.Product tabulate⋆ : ∀ {n a} {A : Set a} → (F : Fin n → A) → ∃ λ (v : Vec A n) → ∀ (i : Fin n) → F i ∈ v tabulate⋆ {zero} F = [] , (λ ()) tabulate⋆ {suc n} F = let v , t = tabulate⋆ (F ∘ suc) in F zero ∷ v , (λ { zero → here ; (suc i) → there (t i)})
{ "alphanum_fraction": 0.535, "avg_line_length": 28.5714285714, "ext": "agda", "hexsha": "f9dc32eca4de0ecf39b5ee53b5ee033b7599a5d1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-2/Oscar/Data/Vec.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-2/Oscar/Data/Vec.agda", "max_line_length": 112, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-2/Oscar/Data/Vec.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 326, "size": 800 }
{-# OPTIONS --without-K #-} module PiG where import Level as L open import Data.Empty open import Data.Unit open import Data.Sum open import Data.Product open import Data.Nat open import Function open import Relation.Binary.PropositionalEquality open import Relation.Binary ------------------------------------------------------------------------------ -- Reasoning about paths pathInd : ∀ {u u'} → {A : Set u} → (C : (x y : A) → (x ≡ y) → Set u') → (c : (x : A) → C x x refl) → ((x y : A) (p : x ≡ y) → C x y p) pathInd C c x .x refl = c x trans' : {A : Set} → {x y z : A} → (x ≡ y) → (y ≡ z) → (x ≡ z) trans' {A} {x} {y} {z} p q = pathInd (λ x y p → ((z : A) → (q : y ≡ z) → (x ≡ z))) (pathInd (λ x z q → x ≡ z) (λ _ → refl)) x y p z q ap : {A B : Set} {x y : A} → (f : A → B) → (x ≡ y) → (f x ≡ f y) ap {A} {B} {x} {y} f p = pathInd (λ x y p → f x ≡ f y) (λ x → refl) x y p ap× : {A B : Set} {x y : A} {z w : B} → (x ≡ y) → (z ≡ w) → ((x , z) ≡ (y , w)) ap× {A} {B} {x} {y} {z} {w} p₁ p₂ = pathInd (λ x y p₁ → ((z : B) (w : B) (p₂ : z ≡ w) → ((x , z) ≡ (y , w)))) (λ x → pathInd (λ z w p₂ → ((x , z) ≡ (x , w))) (λ z → refl)) x y p₁ z w p₂ transport : {A : Set} {x y : A} {P : A → Set} → (p : x ≡ y) → P x → P y transport {A} {x} {y} {P} p = pathInd (λ x y p → (P x → P y)) (λ x → id) x y p ------------------------------------------------------------------------------ -- Codes for our types data B : Set where -- no zero because we map types to POINTED SETS ONE : B PLUS : B → B → B TIMES : B → B → B HALF : B -- used to explore fractionals {-- Now let's define groups/groupoids The type 1/2 is modeled by the group { refl , loop } where loop is self-inverse, i.e., loop . loop = refl We always get refl, inverses, and associativity for free. We need to explicitly add the new element 'loop' and the new equation 'loop . loop = refl' --} cut-path : {A : Set} → {x : A} → (f g : ( x ≡ x) → (x ≡ x)) → x ≡ x → Set cut-path f g a = f a ≡ g a record GroupoidVal : Set₁ where constructor •[_,_,_,_,_,_] field ∣_∣ : Set • : ∣_∣ path : • ≡ • -- the additional path (loop) -- truncate : trans' path path ≡ refl -- the equivalence used to truncate -- truncate : (f : • ≡ • → • ≡ •) → (b : • ≡ •) → f b ≡ refl path-rel₁ : • ≡ • → • ≡ • path-rel₂ : • ≡ • → • ≡ • truncate : cut-path path-rel₁ path-rel₂ path open GroupoidVal public -- Example: const-loop : {A : Set} {x : A} → (y : x ≡ x) → x ≡ x const-loop _ = refl postulate iloop : tt ≡ tt itruncate : (f : tt ≡ tt → tt ≡ tt) → cut-path f const-loop iloop -- (trans' iloop iloop) ≡ refl 2loop : {A : Set} → {x : A} → x ≡ x → x ≡ x 2loop x = trans' x x half : GroupoidVal half = •[ ⊤ , tt , iloop , 2loop , const-loop , itruncate 2loop ] -- Interpretations of types ⟦_⟧ : B → GroupoidVal ⟦ ONE ⟧ = •[ ⊤ , tt , refl , id , id , refl ] ⟦ PLUS b₁ b₂ ⟧ with ⟦ b₁ ⟧ | ⟦ b₂ ⟧ ... | •[ B₁ , x₁ , p₁ , f₁ , g₁ , t₁ ] | •[ B₂ , x₂ , p₂ , f₂ , g₂ , t₂ ] = •[ B₁ ⊎ B₂ , inj₁ x₁ , ap inj₁ p₁ , id , id , refl ] ⟦ TIMES b₁ b₂ ⟧ with ⟦ b₁ ⟧ | ⟦ b₂ ⟧ ... | •[ B₁ , x₁ , p₁ , f₁ , g₁ , t₁ ] | •[ B₂ , x₂ , p₂ , f₂ , g₂ , t₂ ] = •[ B₁ × B₂ , (x₁ , x₂) , ap× p₁ p₂ , id , id , refl ] ⟦ HALF ⟧ = half -- Combinators data _⟷_ : B → B → Set₁ where swap× : {b₁ b₂ : B} → TIMES b₁ b₂ ⟷ TIMES b₂ b₁ record GFunctor (G₁ G₂ : GroupoidVal) : Set where field fun : ∣ G₁ ∣ → ∣ G₂ ∣ baseP : fun (• G₁) ≡ (• G₂) -- dependent paths?? isoP : {x y : ∣ G₁ ∣} (p : x ≡ y) → (fun x ≡ fun y) eval : {b₁ b₂ : B} → (b₁ ⟷ b₂) → GFunctor ⟦ b₁ ⟧ ⟦ b₂ ⟧ eval swap× = record { fun = swap; baseP = refl; isoP = λ p → ap swap p } ------------------------------------------------------------------------------ {- Some old scribblings A-2 : Set A-2 = ⊤ postulate S⁰ : Set S¹ : Set record Trunc-1 (A : Set) : Set where field embed : A → Trunc-1 A hub : (r : S⁰ → Trunc-1 A) → Trunc-1 A spoke : (r : S⁰ → Trunc-1 A) → (x : S⁰) → r x ≡ hub r -} -------------------- record 2Groupoid : Set₁ where constructor ²[_,_,_] field obj : Set hom : Rel obj L.zero -- paths (loop) 2path : ∀ {a b} → hom a b → hom a b → Set -- 2paths, i.e. path eqns open 2Groupoid public hom⊤ : Rel ⊤ L.zero hom⊤ = _≡_ 2path⊤ : Rel (hom⊤ tt tt) L.zero 2path⊤ = _≡_ half' : 2Groupoid half' = ²[ ⊤ , hom⊤ , 2path⊤ ]
{ "alphanum_fraction": 0.4434561626, "avg_line_length": 26.2333333333, "ext": "agda", "hexsha": "7e6281c0965cd8b17efa592abbe1101351f9a784", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "PiG.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "PiG.agda", "max_line_length": 79, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "PiG.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 1864, "size": 4722 }
module free-vars where open import cedille-types open import syntax-util open import general-util open import type-util infixr 7 _++ₛ_ _++ₛ_ : stringset → stringset → stringset s₁ ++ₛ s₂ = stringset-insert* s₂ (stringset-strings s₁) stringset-single : string → stringset stringset-single = flip trie-single triv {-# TERMINATING #-} free-vars : ∀ {ed} → ⟦ ed ⟧ → stringset free-vars? : ∀ {ed} → maybe ⟦ ed ⟧ → stringset free-vars-args : args → stringset free-vars-arg : arg → stringset free-vars-cases : cases → stringset free-vars-case : case → stringset free-vars-tk : tpkd → stringset free-vars-tT : tmtp → stringset free-vars-tk = free-vars -tk'_ free-vars-tT = free-vars -tT'_ free-vars? = maybe-else empty-stringset free-vars free-vars {TERM} (App t t') = free-vars t ++ₛ free-vars t' free-vars {TERM} (AppE t tT) = free-vars t ++ₛ free-vars -tT' tT free-vars {TERM} (Beta t t') = free-vars t ++ₛ free-vars t' free-vars {TERM} (Delta b? T t) = free-vars? (fst <$> b?) ++ₛ free-vars? (snd <$> b?) ++ₛ free-vars T ++ₛ free-vars t free-vars {TERM} (Hole pi) = empty-stringset free-vars {TERM} (IotaPair t t' x T) = free-vars t ++ₛ free-vars t' ++ₛ stringset-remove (free-vars T) x free-vars {TERM} (IotaProj t n) = free-vars t free-vars {TERM} (Lam me x tk t) = maybe-else empty-stringset (free-vars-tk) tk ++ₛ stringset-remove (free-vars t) x free-vars {TERM} (LetTm me x T? t t') = free-vars? T? ++ₛ free-vars t ++ₛ stringset-remove (free-vars t') x free-vars {TERM} (LetTp x k T t) = free-vars k ++ₛ free-vars T ++ₛ stringset-remove (free-vars t) x free-vars {TERM} (Phi tₑ t₁ t₂) = free-vars tₑ ++ₛ free-vars t₁ ++ₛ free-vars t₂ free-vars {TERM} (Rho t x T t') = free-vars t ++ₛ stringset-remove (free-vars T) x ++ₛ free-vars t' free-vars {TERM} (Sigma t) = free-vars t free-vars {TERM} (Mu μ t T t~ cs) = free-vars t ++ₛ free-vars? T ++ₛ free-vars-cases cs free-vars {TERM} (Var x) = stringset-single x free-vars {TYPE} (TpAbs me x tk T) = free-vars-tk tk ++ₛ stringset-remove (free-vars T) x free-vars {TYPE} (TpIota x T₁ T₂) = free-vars T₁ ++ₛ stringset-remove (free-vars T₂) x free-vars {TYPE} (TpApp T tT) = free-vars T ++ₛ free-vars -tT' tT free-vars {TYPE} (TpEq t₁ t₂) = free-vars t₁ ++ₛ free-vars t₂ free-vars {TYPE} (TpHole pi) = empty-stringset free-vars {TYPE} (TpLam x tk T) = free-vars-tk tk ++ₛ stringset-remove (free-vars T) x free-vars {TYPE} (TpVar x) = stringset-single x free-vars {KIND} KdStar = empty-stringset free-vars {KIND} (KdHole pi) = empty-stringset free-vars {KIND} (KdAbs x tk k) = free-vars-tk tk ++ₛ stringset-remove (free-vars k) x free-vars-arg (Arg t) = free-vars t free-vars-arg (ArgE tT) = free-vars -tT' tT free-vars-args = foldr (_++ₛ_ ∘ free-vars-arg) empty-stringset free-vars-case (Case x cas t T) = foldr (λ {(CaseArg e x tk) → flip trie-remove x}) (free-vars t) cas free-vars-cases = foldr (_++ₛ_ ∘ free-vars-case) empty-stringset {-# TERMINATING #-} erase : ∀ {ed} → ⟦ ed ⟧ → ⟦ ed ⟧ erase-cases : cases → cases erase-case : case → case erase-args : args → 𝕃 term erase-params : params → 𝕃 var erase-tk : tpkd → tpkd erase-tT : tmtp → tmtp erase-is-mu : is-mu → is-mu erase-is-mu = either-else (λ _ → inj₁ nothing) inj₂ erase-tk = erase -tk_ erase-tT = erase -tT_ erase {TERM} (App t t') = App (erase t) (erase t') erase {TERM} (AppE t T) = erase t erase {TERM} (Beta t t') = erase t' erase {TERM} (Delta b? T t) = id-term erase {TERM} (Hole pi) = Hole pi erase {TERM} (IotaPair t t' x T) = erase t erase {TERM} (IotaProj t n) = erase t erase {TERM} (Lam me x tk t) = if me then erase t else Lam ff x nothing (erase t) erase {TERM} (LetTm me x T? t t') = let t'' = erase t' in if ~ me && stringset-contains (free-vars t'') x then LetTm ff x nothing (erase t) t'' else t'' erase {TERM} (LetTp x k T t) = erase t erase {TERM} (Phi tₑ t₁ t₂) = erase t₂ erase {TERM} (Rho t x T t') = erase t' erase {TERM} (Sigma t) = erase t erase {TERM} (Mu μ t T t~ ms) = Mu (erase-is-mu μ) (erase t) nothing t~ (erase-cases ms) erase {TERM} (Var x) = Var x erase {TYPE} (TpAbs me x tk T) = TpAbs me x (erase-tk tk) (erase T) erase {TYPE} (TpIota x T₁ T₂) = TpIota x (erase T₁) (erase T₂) erase {TYPE} (TpApp T tT) = TpApp (erase T) (erase -tT tT) erase {TYPE} (TpEq t₁ t₂) = TpEq (erase t₁) (erase t₂) erase {TYPE} (TpHole pi) = TpHole pi erase {TYPE} (TpLam x tk T) = TpLam x (erase-tk tk) (erase T) erase {TYPE} (TpVar x) = TpVar x erase {KIND} KdStar = KdStar erase {KIND} (KdHole pi) = KdHole pi erase {KIND} (KdAbs x tk k) = KdAbs x (erase-tk tk) (erase k) erase-case-args : case-args → case-args erase-case-args (CaseArg ff x _ :: cas) = CaseArg ff x nothing :: erase-case-args cas erase-case-args (_ :: cas) = erase-case-args cas erase-case-args [] = [] erase-cases = map erase-case erase-case (Case x cas t T) = Case x (erase-case-args cas) (erase t) T erase-args (Arg t :: as) = erase t :: erase-args as erase-args (_ :: as) = erase-args as erase-args [] = [] erase-arg-keep : arg → arg erase-args-keep : args → args erase-args-keep = map erase-arg-keep erase-arg-keep (Arg t) = Arg (erase t) erase-arg-keep (ArgE tT) = ArgE (erase -tT tT) erase-params (Param ff x (Tkt T) :: ps) = x :: erase-params ps erase-params (_ :: ps) = erase-params ps erase-params [] = [] free-vars-erased : ∀ {ed} → ⟦ ed ⟧ → stringset free-vars-erased = free-vars ∘ erase is-free-in : ∀ {ed} → var → ⟦ ed ⟧ → 𝔹 is-free-in x t = stringset-contains (free-vars t) x are-free-in-h : ∀ {X} → trie X → stringset → 𝔹 are-free-in-h xs fxs = list-any (trie-contains fxs) (map fst (trie-mappings xs)) are-free-in : ∀ {X} {ed} → trie X → ⟦ ed ⟧ → 𝔹 are-free-in xs t = are-free-in-h xs (free-vars t) erase-if : ∀ {ed} → 𝔹 → ⟦ ed ⟧ → ⟦ ed ⟧ erase-if tt = erase erase-if ff = id infix 5 `|_|` `|_|` = erase
{ "alphanum_fraction": 0.6494432846, "avg_line_length": 39.3698630137, "ext": "agda", "hexsha": "512b23e6fb0ab9d02e75882af4918e88ee7d645b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9df4b85b55b57f97466242fdbb499adbd3bca893", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "zmthy/cedille", "max_forks_repo_path": "src/free-vars.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9df4b85b55b57f97466242fdbb499adbd3bca893", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "zmthy/cedille", "max_issues_repo_path": "src/free-vars.agda", "max_line_length": 117, "max_stars_count": null, "max_stars_repo_head_hexsha": "9df4b85b55b57f97466242fdbb499adbd3bca893", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "zmthy/cedille", "max_stars_repo_path": "src/free-vars.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2146, "size": 5748 }
-- Reported and fixed by Andrea Vezzosi. module Issue902 where module M (A : Set) where postulate A : Set F : Set -> Set test : A test = {! let module m = M (F A) in ? !} -- C-c C-r gives let module m = M F A in ? -- instead of let module m = M (F A) in ?
{ "alphanum_fraction": 0.5873605948, "avg_line_length": 17.9333333333, "ext": "agda", "hexsha": "e7b0db7c520cc191f1148dfc88bd59a8ced65097", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/Issue902.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/Issue902.agda", "max_line_length": 45, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue902.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 92, "size": 269 }
-- Andreas, 2013-06-15 reported by Guillaume Brunerie -- {-# OPTIONS -v malonzo.definition:100 #-} module Issue867 where {- The program below gives the following error when trying to compile it (using MAlonzo) $ agda -c Test.agda Checking Test (/tmp/Test.agda). Finished Test. Compiling Test in /tmp/Test.agdai to /tmp/MAlonzo/Code/Test.hs Calling: ghc -O -o /tmp/Test -Werror -i/tmp -main-is MAlonzo.Code.Test /tmp/MAlonzo/Code/Test.hs --make -fwarn-incomplete-patterns -fno-warn-overlapping-patterns [1 of 2] Compiling MAlonzo.RTE ( MAlonzo/RTE.hs, MAlonzo/RTE.o ) [2 of 2] Compiling MAlonzo.Code.Test ( /tmp/MAlonzo/Code/Test.hs, /tmp/MAlonzo/Code/Test.o ) Compilation error: /tmp/MAlonzo/Code/Test.hs:21:35: Not in scope: `d5' Perhaps you meant one of these: `d1' (line 11), `d4' (line 26), `d9' (line 29) -} -- Here is the program module Test where data ℕ : Set where O : ℕ S : ℕ → ℕ {-# BUILTIN NATURAL ℕ #-} postulate IO : ∀ {i} → Set i → Set i return : ∀ {i} {A : Set i} → A → IO A {-# BUILTIN IO IO #-} main : IO ℕ main = return (S 1) {- It’s the first time I try to compile an Agda program, so presumably I’m doing something wrong. But even if I’m doing something wrong, Agda should be the one giving the error, not ghc. -} -- Should work now.
{ "alphanum_fraction": 0.6774691358, "avg_line_length": 27.5744680851, "ext": "agda", "hexsha": "9cbfb417bc2632537c1d2e7be9e12810b03f8ed8", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue867.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue867.agda", "max_line_length": 189, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue867.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 428, "size": 1296 }
{-# OPTIONS --safe #-} module Cubical.Categories.Limits.Pullback where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.HITs.PropositionalTruncation.Base open import Cubical.Data.Sigma open import Cubical.Categories.Category open import Cubical.Categories.Functor open import Cubical.Categories.Instances.Cospan private variable ℓ ℓ' : Level module _ (C : Category ℓ ℓ') where open Category C open Functor record Cospan : Type (ℓ-max ℓ ℓ') where constructor cospan field l m r : ob s₁ : C [ l , m ] s₂ : C [ r , m ] open Cospan isPullback : (cspn : Cospan) → {c : ob} (p₁ : C [ c , cspn .l ]) (p₂ : C [ c , cspn .r ]) (H : p₁ ⋆ cspn .s₁ ≡ p₂ ⋆ cspn .s₂) → Type (ℓ-max ℓ ℓ') isPullback cspn {c} p₁ p₂ H = ∀ {d} (h : C [ d , cspn .l ]) (k : C [ d , cspn .r ]) (H' : h ⋆ cspn .s₁ ≡ k ⋆ cspn .s₂) → ∃![ hk ∈ C [ d , c ] ] (h ≡ hk ⋆ p₁) × (k ≡ hk ⋆ p₂) isPropIsPullback : (cspn : Cospan) → {c : ob} (p₁ : C [ c , cspn .l ]) (p₂ : C [ c , cspn .r ]) (H : p₁ ⋆ cspn .s₁ ≡ p₂ ⋆ cspn .s₂) → isProp (isPullback cspn p₁ p₂ H) isPropIsPullback cspn p₁ p₂ H = isPropImplicitΠ (λ x → isPropΠ3 λ h k H' → isPropIsContr) record Pullback (cspn : Cospan) : Type (ℓ-max ℓ ℓ') where field pbOb : ob pbPr₁ : C [ pbOb , cspn .l ] pbPr₂ : C [ pbOb , cspn .r ] pbCommutes : pbPr₁ ⋆ cspn .s₁ ≡ pbPr₂ ⋆ cspn .s₂ univProp : isPullback cspn pbPr₁ pbPr₂ pbCommutes open Pullback pullbackArrow : {cspn : Cospan} (pb : Pullback cspn) {c : ob} (p₁ : C [ c , cspn .l ]) (p₂ : C [ c , cspn .r ]) (H : p₁ ⋆ cspn .s₁ ≡ p₂ ⋆ cspn .s₂) → C [ c , pb . pbOb ] pullbackArrow pb p₁ p₂ H = pb .univProp p₁ p₂ H .fst .fst pullbackArrowPr₁ : {cspn : Cospan} (pb : Pullback cspn) {c : ob} (p₁ : C [ c , cspn .l ]) (p₂ : C [ c , cspn .r ]) (H : p₁ ⋆ cspn .s₁ ≡ p₂ ⋆ cspn .s₂) → p₁ ≡ pullbackArrow pb p₁ p₂ H ⋆ pbPr₁ pb pullbackArrowPr₁ pb p₁ p₂ H = pb .univProp p₁ p₂ H .fst .snd .fst pullbackArrowPr₂ : {cspn : Cospan} (pb : Pullback cspn) {c : ob} (p₁ : C [ c , cspn .l ]) (p₂ : C [ c , cspn .r ]) (H : p₁ ⋆ cspn .s₁ ≡ p₂ ⋆ cspn .s₂) → p₂ ≡ pullbackArrow pb p₁ p₂ H ⋆ pbPr₂ pb pullbackArrowPr₂ pb p₁ p₂ H = pb .univProp p₁ p₂ H .fst .snd .snd pullbackArrowUnique : {cspn : Cospan} (pb : Pullback cspn) {c : ob} (p₁ : C [ c , cspn .l ]) (p₂ : C [ c , cspn .r ]) (H : p₁ ⋆ cspn .s₁ ≡ p₂ ⋆ cspn .s₂) (pbArrow' : C [ c , pb .pbOb ]) (H₁ : p₁ ≡ pbArrow' ⋆ pbPr₁ pb) (H₂ : p₂ ≡ pbArrow' ⋆ pbPr₂ pb) → pullbackArrow pb p₁ p₂ H ≡ pbArrow' pullbackArrowUnique pb p₁ p₂ H pbArrow' H₁ H₂ = cong fst (pb .univProp p₁ p₂ H .snd (pbArrow' , (H₁ , H₂))) Pullbacks : Type (ℓ-max ℓ ℓ') Pullbacks = (cspn : Cospan) → Pullback cspn hasPullbacks : Type (ℓ-max ℓ ℓ') hasPullbacks = ∥ Pullbacks ∥ -- TODO: finish the following show that this definition of Pullback -- is equivalent to the Cospan limit module _ {C : Category ℓ ℓ'} where open Category C open Functor Cospan→Func : Cospan C → Functor CospanCat C Cospan→Func (cospan l m r f g) .F-ob ⓪ = l Cospan→Func (cospan l m r f g) .F-ob ① = m Cospan→Func (cospan l m r f g) .F-ob ② = r Cospan→Func (cospan l m r f g) .F-hom {⓪} {①} k = f Cospan→Func (cospan l m r f g) .F-hom {②} {①} k = g Cospan→Func (cospan l m r f g) .F-hom {⓪} {⓪} k = id Cospan→Func (cospan l m r f g) .F-hom {①} {①} k = id Cospan→Func (cospan l m r f g) .F-hom {②} {②} k = id Cospan→Func (cospan l m r f g) .F-id {⓪} = refl Cospan→Func (cospan l m r f g) .F-id {①} = refl Cospan→Func (cospan l m r f g) .F-id {②} = refl Cospan→Func (cospan l m r f g) .F-seq {⓪} {⓪} {⓪} φ ψ = sym (⋆IdL _) Cospan→Func (cospan l m r f g) .F-seq {⓪} {⓪} {①} φ ψ = sym (⋆IdL _) Cospan→Func (cospan l m r f g) .F-seq {⓪} {①} {①} φ ψ = sym (⋆IdR _) Cospan→Func (cospan l m r f g) .F-seq {①} {①} {①} φ ψ = sym (⋆IdL _) Cospan→Func (cospan l m r f g) .F-seq {②} {②} {②} φ ψ = sym (⋆IdL _) Cospan→Func (cospan l m r f g) .F-seq {②} {②} {①} φ ψ = sym (⋆IdL _) Cospan→Func (cospan l m r f g) .F-seq {②} {①} {①} φ ψ = sym (⋆IdR _)
{ "alphanum_fraction": 0.5717008099, "avg_line_length": 35.5762711864, "ext": "agda", "hexsha": "47c665c6711c8b3db70765c92a87f8c4f7011df9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lpw25/cubical", "max_forks_repo_path": "Cubical/Categories/Limits/Pullback.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lpw25/cubical", "max_issues_repo_path": "Cubical/Categories/Limits/Pullback.agda", "max_line_length": 74, "max_stars_count": null, "max_stars_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lpw25/cubical", "max_stars_repo_path": "Cubical/Categories/Limits/Pullback.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1974, "size": 4198 }
module Issue1839.B where open import Issue1839.A postulate DontPrintThis : Set {-# DISPLAY DontPrintThis = PrintThis #-}
{ "alphanum_fraction": 0.7480314961, "avg_line_length": 12.7, "ext": "agda", "hexsha": "76f72cc737f3b4e2789a69b5d405e4b7317d1a9d", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue1839/B.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue1839/B.agda", "max_line_length": 41, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue1839/B.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 34, "size": 127 }
-- Andreas, 2019-04-12, issue #3684 -- Report also available record fields in case user gives spurious fields. -- {-# OPTIONS -v tc.record:30 #-} record R : Set₁ where field foo {boo} moo : Set test : (A : Set) → R test A = record { moo = A ; bar = A ; far = A } -- The record type R does not have the fields bar, far but it would -- have the fields foo, boo -- when checking that the expression -- record { moo = A ; bar = A ; far = A } has type R
{ "alphanum_fraction": 0.6231263383, "avg_line_length": 22.2380952381, "ext": "agda", "hexsha": "8381fc3b8d17a9ccf98e976bdfe39de0129a151d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/Issue3684.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/Fail/Issue3684.agda", "max_line_length": 74, "max_stars_count": 2, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Fail/Issue3684.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 146, "size": 467 }
{-# OPTIONS --cubical --safe #-} module Data.List.Relation.Unary where open import Prelude open import Data.List.Base open import Data.Fin open import Relation.Nullary open import Data.Sum private variable p : Level module Inductive◇ where data ◇ {A : Type a} (P : A → Type p) : List A → Type (a ℓ⊔ p) where here : ∀ {x xs} → P x → ◇ P (x ∷ xs) there : ∀ {x xs} → ◇ P xs → ◇ P (x ∷ xs) ◇ : (P : A → Type p) → List A → Type _ ◇ P xs = ∃[ i ] P (xs ! i) ◇! : (P : A → Type p) → List A → Type _ ◇! P xs = isContr (◇ P xs) module Exists {a} {A : Type a} {p} (P : A → Type p) where push : ∀ {x xs} → ◇ P xs → ◇ P (x ∷ xs) push (n , p) = fs n , p pull : ∀ {x xs} → ¬ P x → ◇ P (x ∷ xs) → ◇ P xs pull ¬Px (f0 , p) = ⊥-elim (¬Px p) pull ¬Px (fs n , p) = n , p uncons : ∀ {x xs} → ◇ P (x ∷ xs) → P x ⊎ ◇ P xs uncons (f0 , p) = inl p uncons (fs x , p) = inr (x , p) infixr 5 _++◇_ _◇++_ _++◇_ : ∀ {xs} ys → ◇ P xs → ◇ P (ys ++ xs) [] ++◇ ys = ys (x ∷ xs) ++◇ ys = push (xs ++◇ ys) _◇++_ : ∀ xs → ◇ P xs → ∀ {ys} → ◇ P (xs ++ ys) _◇++_ (x ∷ xs) (f0 , ∃Pxs) = f0 , ∃Pxs _◇++_ (x ∷ xs) (fs n , ∃Pxs) = push (xs ◇++ (n , ∃Pxs)) push! : ∀ {x xs} → ¬ P x → ◇! P xs → ◇! P (x ∷ xs) push! ¬Px x∈!xs .fst = push (x∈!xs .fst) push! ¬Px x∈!xs .snd (f0 , px) = ⊥-elim (¬Px px) push! ¬Px x∈!xs .snd (fs n , y∈xs) i = push (x∈!xs .snd (n , y∈xs) i) pull! : ∀ {x xs} → ¬ P x → ◇! P (x ∷ xs) → ◇! P xs pull! ¬Px ((f0 , px ) , uniq) = ⊥-elim (¬Px px) pull! ¬Px ((fs n , x∈xs ) , uniq) .fst = (n , x∈xs) pull! ¬Px ((fs n , x∈xs ) , uniq) .snd (m , x∈xs′) i = pull ¬Px (uniq (fs m , x∈xs′ ) i) here! : ∀ {x xs} → isContr (P x) → ¬ ◇ P xs → ◇! P (x ∷ xs) here! Px p∉xs .fst = f0 , Px .fst here! Px p∉xs .snd (f0 , p∈xs) i .fst = f0 here! Px p∉xs .snd (f0 , p∈xs) i .snd = Px .snd p∈xs i here! Px p∉xs .snd (fs n , p∈xs) = ⊥-elim (p∉xs (n , p∈xs)) module _ (P? : ∀ x → Dec (P x)) where open import Relation.Nullary.Decidable.Logic ◇? : ∀ xs → Dec (◇ P xs) ◇? [] = no λ () ◇? (x ∷ xs) = ⟦yes ⟦l f0 ,_ ,r push ⟧ ,no uncons ⟧ (P? x || ◇? xs) ◻ : (P : A → Type p) → List A → Type _ ◻ P xs = ∀ i → P (xs ! i) module Forall {a} {A : Type a} {p} (P : A → Type p) where push : ∀ {x xs} → P x → ◻ P xs → ◻ P (x ∷ xs) push Px Pxs f0 = Px push Px Pxs (fs n) = Pxs n uncons : ∀ {x xs} → ◻ P (x ∷ xs) → P x × ◻ P xs uncons Pxs = Pxs f0 , Pxs ∘ fs pull : ∀ {x xs} → ◻ P (x ∷ xs) → ◻ P xs pull = snd ∘ uncons _++◇_ : ∀ xs {ys} → ◻ P (xs ++ ys) → ◻ P ys [] ++◇ xs⊆P = xs⊆P (x ∷ xs) ++◇ xs⊆P = xs ++◇ (xs⊆P ∘ fs) _◇++_ : ∀ xs {ys} → ◻ P (xs ++ ys) → ◻ P xs ([] ◇++ xs⊆P) () ((x ∷ xs) ◇++ xs⊆P) f0 = xs⊆P f0 ((x ∷ xs) ◇++ xs⊆P) (fs n) = (xs ◇++ pull xs⊆P) n both : ∀ xs {ys} → ◻ P xs → ◻ P ys → ◻ P (xs ++ ys) both [] xs⊆P ys⊆P = ys⊆P both (x ∷ xs) xs⊆P ys⊆P f0 = xs⊆P f0 both (x ∷ xs) xs⊆P ys⊆P (fs i) = both xs (pull xs⊆P) ys⊆P i empty : ◻ P [] empty () module _ where open import Relation.Nullary.Decidable.Logic ◻? : (∀ x → Dec (P x)) → ∀ xs → Dec (◻ P xs) ◻? P? [] = yes λ () ◻? P? (x ∷ xs) = ⟦yes uncurry push ,no uncons ⟧ (P? x && ◻? P? xs) module Forall-NotExists {a} {A : Type a} {p} (P : A → Type p) where open import Relation.Nullary.Stable open import Data.Empty.Properties open Forall P ¬P = ¬_ ∘ P module ∃¬ = Exists ¬P ∀⇒¬∃¬ : ∀ xs → ◻ P xs → ¬ (◇ ¬P xs) ∀⇒¬∃¬ (x ∷ xs) xs⊆P (f0 , ∃¬P∈xs) = ∃¬P∈xs(xs⊆P f0) ∀⇒¬∃¬ (x ∷ xs) xs⊆P (fs n , ∃¬P∈xs) = ∀⇒¬∃¬ xs (xs⊆P ∘ fs) (n , ∃¬P∈xs) module _ (stable : ∀ {x} → Stable (P x)) where ¬∃¬⇒∀ : ∀ xs → ¬ (◇ ¬P xs) → ◻ P xs ¬∃¬⇒∀ (x ∷ xs) ¬∃¬P∈xs f0 = stable (¬∃¬P∈xs ∘ (f0 ,_)) ¬∃¬⇒∀ (x ∷ xs) ¬∃¬P∈xs (fs n) = ¬∃¬⇒∀ xs (¬∃¬P∈xs ∘ ∃¬.push) n leftInv′ : ∀ (prop : ∀ {x} → isProp (P x)) xs → (x : ◻ P xs) → ¬∃¬⇒∀ xs (∀⇒¬∃¬ xs x) ≡ x leftInv′ prop [] x i () leftInv′ prop (x ∷ xs) xs⊆P i f0 = prop (stable λ ¬p → ¬p (xs⊆P f0)) (xs⊆P f0) i leftInv′ prop (x ∷ xs) xs⊆P i (fs n) = leftInv′ prop xs (pull xs⊆P) i n ∀⇔¬∃¬ : ∀ (prop : ∀ {x} → isProp (P x)) xs → ◻ P xs ⇔ (¬ ◇ ¬P xs) ∀⇔¬∃¬ _ xs .fun = ∀⇒¬∃¬ xs ∀⇔¬∃¬ _ xs .inv = ¬∃¬⇒∀ xs ∀⇔¬∃¬ p xs .leftInv = leftInv′ p xs ∀⇔¬∃¬ _ xs .rightInv x = isProp¬ _ _ x module Exists-NotForall {a} {A : Type a} {p} (P : A → Type p) where open Exists P ¬P = ¬_ ∘ P module ∀¬ = Forall ¬P ∃⇒¬∀¬ : ∀ xs → ◇ P xs → ¬ ◻ ¬P xs ∃⇒¬∀¬ (x ∷ xs) (f0 , P∈xs) xs⊆P = xs⊆P f0 P∈xs ∃⇒¬∀¬ (x ∷ xs) (fs n , P∈xs) xs⊆P = ∃⇒¬∀¬ xs (n , P∈xs) (xs⊆P ∘ fs) module _ (P? : ∀ x → Dec (P x)) where ¬∀¬⇒∃ : ∀ xs → ¬ ◻ ¬P xs → ◇ P xs ¬∀¬⇒∃ [] ¬xs⊆¬P = ⊥-elim (¬xs⊆¬P λ ()) ¬∀¬⇒∃ (x ∷ xs) ¬xs⊆¬P with P? x ¬∀¬⇒∃ (x ∷ xs) ¬xs⊆¬P | yes p = f0 , p ¬∀¬⇒∃ (x ∷ xs) ¬xs⊆¬P | no ¬p = push (¬∀¬⇒∃ xs (¬xs⊆¬P ∘ ∀¬.push ¬p)) module Congruence {p q} (P : A → Type p) (Q : B → Type q) {f : A → B} (f↑ : ∀ {x} → P x → Q (f x)) where cong-◇ : ∀ xs → ◇ P xs → ◇ Q (map f xs) cong-◇ (x ∷ xs) (f0 , P∈xs) = f0 , f↑ P∈xs cong-◇ (x ∷ xs) (fs n , P∈xs) = Exists.push Q (cong-◇ xs (n , P∈xs)) ◇-concat : ∀ (P : A → Type p) xs → ◇ (◇ P) xs → ◇ P (concat xs) ◇-concat P (x ∷ xs) (f0 , ps) = Exists._◇++_ P x ps ◇-concat P (x ∷ xs) (fs n , ps) = Exists._++◇_ P x (◇-concat P xs (n , ps)) ◻-concat : ∀ (P : A → Type p) xs → ◻ (◻ P) xs → ◻ P (concat xs) ◻-concat P [] xs⊆P () ◻-concat P (x ∷ xs) xs⊆P = Forall.both P x (xs⊆P f0) (◻-concat P xs (xs⊆P ∘ fs)) module Search {A : Type a} where data Result {p} (P : A → Type p) (xs : List A) : Bool → Type (a ℓ⊔ p) where all′ : ◻ P xs → Result P xs true except′ : ◇ (¬_ ∘ P) xs → Result P xs false record Found {p} (P : A → Type p) (xs : List A) : Type (a ℓ⊔ p) where field found? : Bool result : Result P xs found? open Found public pattern all ps = record { found? = true ; result = all′ ps } pattern except ¬p = record { found? = false ; result = except′ ¬p } module _ {p} {P : A → Type p} (P? : ∀ x → Dec (P x)) where search : ∀ xs → Found P xs search [] = all λ () search (x ∷ xs) = search′ x xs (P? x) (search xs) where search′ : ∀ x xs → Dec (P x) → Found P xs → Found P (x ∷ xs) search′ x xs Px Pxs .found? = Px .does and Pxs .found? search′ x xs (no ¬p) Pxs .result = except′ (f0 , ¬p) search′ x xs (yes p) (except ¬p) .result = except′ (Exists.push (¬_ ∘ P) ¬p) search′ x xs (yes p) (all ps) .result = all′ (Forall.push P p ps)
{ "alphanum_fraction": 0.4440195779, "avg_line_length": 34.2303664921, "ext": "agda", "hexsha": "2194e050743f459faff1cd91cb1b9e4836417dee", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Data/List/Relation/Unary.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Data/List/Relation/Unary.agda", "max_line_length": 92, "max_stars_count": 4, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Data/List/Relation/Unary.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z", "max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z", "num_tokens": 3363, "size": 6538 }
module Issue332 where id : {A : Set} → A → A id x = x syntax id x = id x -- This makes parsing id x ambiguous
{ "alphanum_fraction": 0.6120689655, "avg_line_length": 10.5454545455, "ext": "agda", "hexsha": "34c45ea53c53a159b7b0cfc3b6881733a27ee31b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/Issue332.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/Issue332.agda", "max_line_length": 55, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/fail/Issue332.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 36, "size": 116 }
{-# OPTIONS --warning=error --safe --without-K #-} open import LogicalFormulae open import Lists.Lists open import Numbers.Naturals.Semiring open import Numbers.Naturals.Naturals open import Numbers.BinaryNaturals.Definition open import Numbers.BinaryNaturals.Addition open import Semirings.Definition module Numbers.BinaryNaturals.Multiplication where _*Binherit_ : BinNat → BinNat → BinNat a *Binherit b = NToBinNat (binNatToN a *N binNatToN b) _*B_ : BinNat → BinNat → BinNat [] *B b = [] (zero :: a) *B b = zero :: (a *B b) (one :: a) *B b = (zero :: (a *B b)) +B b private contr : {a : _} {A : Set a} {l1 l2 : List A} → {x : A} → l1 ≡ [] → l1 ≡ x :: l2 → False contr {l1 = []} p1 () contr {l1 = x :: l1} () p2 *BEmpty : (a : BinNat) → canonical (a *B []) ≡ [] *BEmpty [] = refl *BEmpty (zero :: a) rewrite *BEmpty a = refl *BEmpty (one :: a) rewrite *BEmpty a = refl canonicalDistributesPlus : (a b : BinNat) → canonical (a +B b) ≡ canonical a +B canonical b canonicalDistributesPlus a b = transitivity ans (+BIsInherited (canonical a) (canonical b) (canonicalIdempotent a) (canonicalIdempotent b)) where ans : canonical (a +B b) ≡ NToBinNat (binNatToN (canonical a) +N binNatToN (canonical b)) ans rewrite binNatToNIsCanonical a | binNatToNIsCanonical b = equalityCommutative (+BIsInherited' a b) incrPullsOut : (a b : BinNat) → incr (a +B b) ≡ (incr a) +B b incrPullsOut [] [] = refl incrPullsOut [] (zero :: b) = refl incrPullsOut [] (one :: b) = refl incrPullsOut (zero :: a) [] = refl incrPullsOut (zero :: a) (zero :: b) = refl incrPullsOut (zero :: a) (one :: b) = refl incrPullsOut (one :: a) [] = refl incrPullsOut (one :: a) (zero :: b) = applyEquality (zero ::_) (incrPullsOut a b) incrPullsOut (one :: a) (one :: b) = applyEquality (one ::_) (incrPullsOut a b) timesZero : (a b : BinNat) → canonical a ≡ [] → canonical (a *B b) ≡ [] timesZero [] b pr = refl timesZero (zero :: a) b pr with inspect (canonical a) timesZero (zero :: a) b pr | [] with≡ prA rewrite prA | timesZero a b prA = refl timesZero (zero :: a) b pr | (a1 :: as) with≡ prA rewrite prA = exFalso (nonEmptyNotEmpty pr) timesZero'' : (a b : BinNat) → canonical (a *B b) ≡ [] → (canonical a ≡ []) || (canonical b ≡ []) timesZero'' [] b pr = inl refl timesZero'' (x :: a) [] pr = inr refl timesZero'' (zero :: as) (zero :: bs) pr with inspect (canonical as) timesZero'' (zero :: as) (zero :: bs) pr | y with≡ x with inspect (canonical bs) timesZero'' (zero :: as) (zero :: bs) pr | [] with≡ prAs | y₁ with≡ prBs rewrite prAs = inl refl timesZero'' (zero :: as) (zero :: bs) pr | (a1 :: a's) with≡ prAs | [] with≡ prBs rewrite prBs = inr refl timesZero'' (zero :: as) (zero :: bs) pr | (a1 :: a's) with≡ prAs | (x :: y) with≡ prBs with inspect (canonical (as *B (zero :: bs))) timesZero'' (zero :: as) (zero :: bs) pr | (a1 :: a's) with≡ prAs | (b1 :: b's) with≡ prBs | [] with≡ pr' with timesZero'' as (zero :: bs) pr' timesZero'' (zero :: as) (zero :: bs) pr | (a1 :: a's) with≡ prAs | (b1 :: b's) with≡ prBs | [] with≡ pr' | inl x rewrite prAs | prBs | pr' | x = exFalso (nonEmptyNotEmpty x) timesZero'' (zero :: as) (zero :: bs) pr | (a1 :: a's) with≡ prAs | (b1 :: b's) with≡ prBs | [] with≡ pr' | inr x rewrite prBs | pr' | x = exFalso (nonEmptyNotEmpty x) timesZero'' (zero :: as) (zero :: bs) pr | (a1 :: a's) with≡ prAs | (b1 :: b's) with≡ prBs | (x :: y) with≡ pr' rewrite prAs | prBs | pr' = exFalso (nonEmptyNotEmpty pr) timesZero'' (zero :: as) (one :: bs) pr with inspect (canonical as) timesZero'' (zero :: as) (one :: bs) pr | [] with≡ x rewrite x = inl refl timesZero'' (zero :: as) (one :: bs) pr | (a1 :: a's) with≡ x with inspect (canonical (as *B (one :: bs))) timesZero'' (zero :: as) (one :: bs) pr | (a1 :: a's) with≡ x | [] with≡ pr' with timesZero'' as (one :: bs) pr' timesZero'' (zero :: as) (one :: bs) pr | (a1 :: a's) with≡ x | [] with≡ pr' | inl pr'' rewrite x | pr' | pr'' = exFalso (nonEmptyNotEmpty pr'') timesZero'' (zero :: as) (one :: bs) pr | (a1 :: a's) with≡ x | (x₁ :: y) with≡ pr' rewrite x | pr' = exFalso (nonEmptyNotEmpty pr) timesZero'' (one :: as) (zero :: bs) pr with inspect (canonical bs) timesZero'' (one :: as) (zero :: bs) pr | [] with≡ x rewrite x = inr refl timesZero'' (one :: as) (zero :: bs) pr | (b1 :: b's) with≡ prB with inspect (canonical ((as *B (zero :: bs)) +B bs)) timesZero'' (one :: as) (zero :: bs) pr | (b1 :: b's) with≡ prB | [] with≡ x rewrite equalityCommutative (+BIsInherited' (as *B (zero :: bs)) bs) = exFalso (nonEmptyNotEmpty (transitivity (equalityCommutative prB) v)) where t : binNatToN (as *B (zero :: bs)) +N binNatToN bs ≡ 0 t = transitivity (equalityCommutative (nToN _)) (applyEquality binNatToN x) u : (binNatToN (as *B (zero :: bs)) ≡ 0) && (binNatToN bs ≡ 0) u = sumZeroImpliesSummandsZero t v : canonical bs ≡ [] v with u ... | fst ,, snd = binNatToNZero bs snd timesZero'' (one :: as) (zero :: bs) pr | (b1 :: b's) with≡ prB | (x₁ :: y) with≡ x rewrite prB | x = exFalso (nonEmptyNotEmpty pr) lemma : {i : Bit} → (a b : BinNat) → canonical a ≡ canonical b → canonical (i :: a) ≡ canonical (i :: b) lemma {zero} a b pr with inspect (canonical a) lemma {zero} a b pr | [] with≡ x rewrite x | equalityCommutative pr = refl lemma {zero} a b pr | (a1 :: as) with≡ x rewrite x | equalityCommutative pr = refl lemma {one} a b pr = applyEquality (one ::_) pr binNatToNDistributesPlus : (a b : BinNat) → binNatToN (a +B b) ≡ binNatToN a +N binNatToN b binNatToNDistributesPlus a b = transitivity (equalityCommutative (binNatToNIsCanonical (a +B b))) (transitivity (applyEquality binNatToN (equalityCommutative (+BIsInherited' a b))) (nToN (binNatToN a +N binNatToN b))) +BAssociative : (a b c : BinNat) → canonical (a +B (b +B c)) ≡ canonical ((a +B b) +B c) +BAssociative a b c rewrite equalityCommutative (+BIsInherited' a (b +B c)) | equalityCommutative (+BIsInherited' (a +B b) c) | binNatToNDistributesPlus a b | binNatToNDistributesPlus b c | equalityCommutative (Semiring.+Associative ℕSemiring (binNatToN a) (binNatToN b) (binNatToN c)) = refl timesOne : (a b : BinNat) → (canonical b) ≡ (one :: []) → canonical (a *B b) ≡ canonical a timesOne [] b pr = refl timesOne (zero :: a) b pr with inspect (canonical (a *B b)) timesOne (zero :: a) b pr | [] with≡ prAB with timesZero'' a b prAB timesOne (zero :: a) b pr | [] with≡ prAB | inl a=0 rewrite a=0 | prAB = refl timesOne (zero :: a) b pr | [] with≡ prAB | inr b=0 = exFalso (nonEmptyNotEmpty (transitivity (equalityCommutative pr) b=0)) timesOne (zero :: a) b pr | (ab1 :: abs) with≡ prAB with inspect (canonical a) timesOne (zero :: a) b pr | (ab1 :: abs) with≡ prAB | [] with≡ x = exFalso (nonEmptyNotEmpty (transitivity (equalityCommutative prAB) (timesZero a b x))) timesOne (zero :: a) b pr | (ab1 :: abs) with≡ prAB | (x₁ :: y) with≡ x rewrite prAB | x | timesOne a b pr = applyEquality (zero ::_) (transitivity (equalityCommutative prAB) x) timesOne (one :: a) (zero :: b) pr with canonical b timesOne (one :: a) (zero :: b) () | [] timesOne (one :: a) (zero :: b) () | x :: bl timesOne (one :: a) (one :: b) pr rewrite canonicalDistributesPlus (a *B (one :: b)) b | ::Inj pr | +BCommutative (canonical (a *B (one :: b))) [] | timesOne a (one :: b) pr = refl timesZero' : (a b : BinNat) → canonical b ≡ [] → canonical (a *B b) ≡ [] timesZero' [] b pr = refl timesZero' (zero :: a) b pr with inspect (canonical (a *B b)) timesZero' (zero :: a) b pr | [] with≡ x rewrite x = refl timesZero' (zero :: a) b pr | (ab1 :: abs) with≡ prAB rewrite prAB = exFalso (nonEmptyNotEmpty (transitivity (equalityCommutative prAB) (timesZero' a b pr))) timesZero' (one :: a) b pr rewrite canonicalDistributesPlus (zero :: (a *B b)) b | pr | +BCommutative (canonical (zero :: (a *B b))) [] = ans where ans : canonical (zero :: (a *B b)) ≡ [] ans with inspect (canonical (a *B b)) ans | [] with≡ x rewrite x = refl ans | (x₁ :: y) with≡ x rewrite x = exFalso (nonEmptyNotEmpty (transitivity (equalityCommutative x) (timesZero' a b pr))) canonicalDistributesTimes : (a b : BinNat) → canonical (a *B b) ≡ canonical ((canonical a) *B (canonical b)) canonicalDistributesTimes [] b = refl canonicalDistributesTimes (zero :: a) b with inspect (canonical a) canonicalDistributesTimes (zero :: a) b | [] with≡ x rewrite timesZero a b x | x = refl canonicalDistributesTimes (zero :: a) b | (a1 :: as) with≡ prA with inspect (canonical b) canonicalDistributesTimes (zero :: a) b | (a1 :: as) with≡ prA | [] with≡ prB rewrite prA | prB = ans where ans : canonical (zero :: (a *B b)) ≡ canonical (zero :: ((a1 :: as) *B [])) ans with inspect (canonical ((a1 :: as) *B [])) ans | [] with≡ x rewrite x | timesZero' a b prB = refl ans | (x₁ :: y) with≡ x = exFalso (nonEmptyNotEmpty (equalityCommutative (transitivity (equalityCommutative (timesZero' (a1 :: as) [] refl)) x))) canonicalDistributesTimes (zero :: a) b | (a1 :: as) with≡ prA | (b1 :: bs) with≡ prB with inspect (canonical (a *B b)) canonicalDistributesTimes (zero :: a) b | (a1 :: as) with≡ prA | (b1 :: bs) with≡ prB | [] with≡ x with timesZero'' a b x canonicalDistributesTimes (zero :: a) b | (a1 :: as) with≡ prA | (b1 :: bs) with≡ prB | [] with≡ x | inl a=0 = exFalso (nonEmptyNotEmpty (transitivity (equalityCommutative prA) a=0)) canonicalDistributesTimes (zero :: a) b | (a1 :: as) with≡ prA | (b1 :: bs) with≡ prB | [] with≡ x | inr b=0 = exFalso (nonEmptyNotEmpty (transitivity (equalityCommutative prB) b=0)) canonicalDistributesTimes (zero :: a) b | (a1 :: as) with≡ prA | (b1 :: bs) with≡ prB | (ab1 :: abs) with≡ x rewrite prA | prB | x = ans where ans : zero :: ab1 :: abs ≡ canonical (zero :: ((a1 :: as) *B (b1 :: bs))) ans rewrite equalityCommutative prA | equalityCommutative prB | equalityCommutative (canonicalDistributesTimes a b) | x = refl canonicalDistributesTimes (one :: a) b = transitivity (canonicalDistributesPlus (zero :: (a *B b)) b) (transitivity (transitivity (applyEquality (_+B canonical b) (transitivity (equalityCommutative (canonicalAscends'' (a *B b))) (transitivity (applyEquality (λ i → canonical (zero :: i)) (canonicalDistributesTimes a b)) (canonicalAscends'' (canonical a *B canonical b))))) (applyEquality (λ i → canonical (zero :: (canonical a *B canonical b)) +B i) (canonicalIdempotent b))) (equalityCommutative (canonicalDistributesPlus (zero :: (canonical a *B canonical b)) (canonical b)))) NToBinNatDistributesPlus : (a b : ℕ) → NToBinNat (a +N b) ≡ NToBinNat a +B NToBinNat b NToBinNatDistributesPlus zero b = refl NToBinNatDistributesPlus (succ a) b with inspect (NToBinNat a) ... | bl with≡ prA with inspect (NToBinNat (a +N b)) ... | q with≡ prAB = transitivity (applyEquality incr (NToBinNatDistributesPlus a b)) (incrPullsOut (NToBinNat a) (NToBinNat b)) timesCommutative : (a b : BinNat) → canonical (a *B b) ≡ canonical (b *B a) timesCommLemma : (a b : BinNat) → canonical (zero :: (b *B a)) ≡ canonical (b *B (zero :: a)) timesCommLemma a b rewrite timesCommutative b (zero :: a) | equalityCommutative (canonicalAscends'' {zero} (b *B a)) | equalityCommutative (canonicalAscends'' {zero} (a *B b)) | timesCommutative b a = refl timesCommutative [] b rewrite timesZero' b [] refl = refl timesCommutative (x :: a) [] rewrite timesZero' (x :: a) [] refl = refl timesCommutative (zero :: as) (zero :: b) rewrite equalityCommutative (canonicalAscends'' {zero} (as *B (zero :: b))) | timesCommutative as (zero :: b) | canonicalAscends'' {zero} (zero :: b *B as) | equalityCommutative (canonicalAscends'' {zero} (b *B (zero :: as))) | timesCommutative b (zero :: as) | canonicalAscends'' {zero} (zero :: (as *B b)) = ans where ans : canonical (zero :: zero :: (b *B as)) ≡ canonical (zero :: zero :: (as *B b)) ans rewrite equalityCommutative (canonicalAscends'' {zero} (zero :: (b *B as))) | equalityCommutative (canonicalAscends'' {zero} (b *B as)) | timesCommutative b as | canonicalAscends'' {zero} (as *B b) | canonicalAscends'' {zero} (zero :: (as *B b)) = refl timesCommutative (zero :: as) (one :: b) = transitivity (equalityCommutative (canonicalAscends'' (as *B (one :: b)))) (transitivity (applyEquality (λ i → canonical (zero :: i)) (timesCommutative as (one :: b))) (transitivity (applyEquality (λ i → canonical (zero :: i)) ans) (canonicalAscends'' ((b *B (zero :: as)) +B as)))) where ans : canonical ((zero :: (b *B as)) +B as) ≡ canonical ((b *B (zero :: as)) +B as) ans rewrite canonicalDistributesPlus (zero :: (b *B as)) as | canonicalDistributesPlus (b *B (zero :: as)) as = applyEquality (_+B canonical as) (timesCommLemma as b) timesCommutative (one :: as) (zero :: bs) = transitivity (equalityCommutative (canonicalAscends'' ((as *B (zero :: bs)) +B bs))) (transitivity (applyEquality (λ i → canonical (zero :: i)) ans) (canonicalAscends'' (bs *B (one :: as)))) where ans : canonical ((as *B (zero :: bs)) +B bs) ≡ canonical (bs *B (one :: as)) ans rewrite timesCommutative bs (one :: as) | canonicalDistributesPlus (as *B (zero :: bs)) bs | canonicalDistributesPlus (zero :: (as *B bs)) bs = applyEquality (_+B canonical bs) (equalityCommutative (timesCommLemma bs as)) timesCommutative (one :: as) (one :: bs) = applyEquality (one ::_) (transitivity (canonicalDistributesPlus (as *B (one :: bs)) bs) (transitivity (transitivity (applyEquality (_+B canonical bs) (timesCommutative as (one :: bs))) (transitivity ans (equalityCommutative (applyEquality (_+B canonical as) (timesCommutative bs (one :: as)))))) (equalityCommutative (canonicalDistributesPlus (bs *B (one :: as)) as)))) where ans : canonical ((zero :: (bs *B as)) +B as) +B canonical bs ≡ canonical ((zero :: (as *B bs)) +B bs) +B canonical as ans rewrite equalityCommutative (canonicalDistributesPlus ((zero :: (bs *B as)) +B as) bs) | equalityCommutative (canonicalDistributesPlus ((zero :: (as *B bs)) +B bs) as) | equalityCommutative (+BAssociative (zero :: (bs *B as)) as bs) | equalityCommutative (+BAssociative (zero :: (as *B bs)) bs as) | canonicalDistributesPlus (zero :: (bs *B as)) (as +B bs) | canonicalDistributesPlus (zero :: (as *B bs)) (bs +B as) | equalityCommutative (canonicalAscends'' {zero} (bs *B as)) | timesCommutative bs as | canonicalAscends'' {zero} (as *B bs) | +BCommutative as bs = refl *BIsInherited : (a b : BinNat) → a *Binherit b ≡ canonical (a *B b) *BIsInherited a b = transitivity (applyEquality NToBinNat t) (transitivity (binToBin (canonical (a *B b))) (equalityCommutative (canonicalIdempotent (a *B b)))) where ans : (a b : BinNat) → binNatToN a *N binNatToN b ≡ binNatToN (a *B b) ans [] b = refl ans (zero :: a) b rewrite equalityCommutative (ans a b) = equalityCommutative (Semiring.*Associative ℕSemiring 2 (binNatToN a) (binNatToN b)) ans (one :: a) b rewrite binNatToNDistributesPlus (zero :: (a *B b)) b | Semiring.commutative ℕSemiring (binNatToN b) ((2 *N (binNatToN a)) *N (binNatToN b)) | equalityCommutative (ans a b) = applyEquality (_+N binNatToN b) (equalityCommutative (Semiring.*Associative ℕSemiring 2 (binNatToN a) (binNatToN b))) t : (binNatToN a *N binNatToN b) ≡ binNatToN (canonical (a *B b)) t = transitivity (ans a b) (equalityCommutative (binNatToNIsCanonical (a *B b)))
{ "alphanum_fraction": 0.6480666973, "avg_line_length": 83.2404371585, "ext": "agda", "hexsha": "df629bb46167d73aa1b55ddffa3f0c080b4f56b1", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Numbers/BinaryNaturals/Multiplication.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Numbers/BinaryNaturals/Multiplication.agda", "max_line_length": 579, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Numbers/BinaryNaturals/Multiplication.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 5289, "size": 15233 }
{-# OPTIONS --warning=error --safe --without-K #-} open import LogicalFormulae open import Lists.Lists open import Numbers.BinaryNaturals.Definition open import Maybe module Numbers.BinaryNaturals.SubtractionGo where go : Bit → BinNat → BinNat → Maybe BinNat go zero [] [] = yes [] go one [] [] = no go zero [] (zero :: b) = go zero [] b go zero [] (one :: b) = no go one [] (x :: b) = no go zero (zero :: a) [] = yes (zero :: a) go one (zero :: a) [] = mapMaybe (one ::_) (go one a []) go zero (zero :: a) (zero :: b) = mapMaybe (zero ::_) (go zero a b) go one (zero :: a) (zero :: b) = mapMaybe (one ::_) (go one a b) go zero (zero :: a) (one :: b) = mapMaybe (one ::_) (go one a b) go one (zero :: a) (one :: b) = mapMaybe (zero ::_) (go one a b) go zero (one :: a) [] = yes (one :: a) go zero (one :: a) (zero :: b) = mapMaybe (one ::_) (go zero a b) go zero (one :: a) (one :: b) = mapMaybe (zero ::_) (go zero a b) go one (one :: a) [] = yes (zero :: a) go one (one :: a) (zero :: b) = mapMaybe (zero ::_) (go zero a b) go one (one :: a) (one :: b) = mapMaybe (one ::_) (go one a b) _-B_ : BinNat → BinNat → Maybe BinNat a -B b = go zero a b goEmpty : (a : BinNat) → go zero a [] ≡ yes a goEmpty [] = refl goEmpty (zero :: a) = refl goEmpty (one :: a) = refl goOneSelf : (a : BinNat) → go one a a ≡ no goOneSelf [] = refl goOneSelf (zero :: a) rewrite goOneSelf a = refl goOneSelf (one :: a) rewrite goOneSelf a = refl goOneEmpty : (b : BinNat) {t : BinNat} → go one [] b ≡ yes t → False goOneEmpty [] {t} () goOneEmpty (x :: b) {t} () goOneEmpty' : (b : BinNat) → go one [] b ≡ no goOneEmpty' b with inspect (go one [] b) goOneEmpty' b | no with≡ x = x goOneEmpty' b | yes x₁ with≡ x = exFalso (goOneEmpty b x) goZeroEmpty : (b : BinNat) {t : BinNat} → go zero [] b ≡ yes t → canonical b ≡ [] goZeroEmpty [] {t} = λ _ → refl goZeroEmpty (zero :: b) {t} pr with inspect (canonical b) goZeroEmpty (zero :: b) {t} pr | [] with≡ pr2 rewrite pr2 = refl goZeroEmpty (zero :: b) {t} pr | (x :: r) with≡ pr2 with goZeroEmpty b pr ... | u = exFalso (nonEmptyNotEmpty (transitivity (equalityCommutative pr2) u)) goZeroEmpty' : (b : BinNat) {t : BinNat} → go zero [] b ≡ yes t → canonical t ≡ [] goZeroEmpty' [] {[]} pr = refl goZeroEmpty' (x :: b) {[]} pr = refl goZeroEmpty' (zero :: b) {x₁ :: t} pr = goZeroEmpty' b pr goZeroIncr : (b : BinNat) → go zero [] (incr b) ≡ no goZeroIncr [] = refl goZeroIncr (zero :: b) = refl goZeroIncr (one :: b) = goZeroIncr b goPreservesCanonicalRightEmpty : (b : BinNat) → go zero [] (canonical b) ≡ go zero [] b goPreservesCanonicalRightEmpty [] = refl goPreservesCanonicalRightEmpty (zero :: b) with inspect (canonical b) goPreservesCanonicalRightEmpty (zero :: b) | [] with≡ x with goPreservesCanonicalRightEmpty b ... | pr2 rewrite x = pr2 goPreservesCanonicalRightEmpty (zero :: b) | (x₁ :: y) with≡ x with goPreservesCanonicalRightEmpty b ... | pr2 rewrite x = pr2 goPreservesCanonicalRightEmpty (one :: b) = refl goZero : (b : BinNat) {t : BinNat} → mapMaybe canonical (go zero [] b) ≡ yes t → t ≡ [] goZero b {[]} pr = refl goZero b {x :: t} pr with inspect (go zero [] b) goZero b {x :: t} pr | no with≡ pr2 rewrite pr2 = exFalso (noNotYes pr) goZero b {x :: t} pr | yes x₁ with≡ pr2 with goZeroEmpty b pr2 ... | u with applyEquality (mapMaybe canonical) (goPreservesCanonicalRightEmpty b) ... | bl rewrite u | pr = exFalso (nonEmptyNotEmpty (equalityCommutative (yesInjective bl)))
{ "alphanum_fraction": 0.6222739168, "avg_line_length": 40.9404761905, "ext": "agda", "hexsha": "aca774331ef2085686c802d7b869334ad1a19937", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Numbers/BinaryNaturals/SubtractionGo.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Numbers/BinaryNaturals/SubtractionGo.agda", "max_line_length": 100, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Numbers/BinaryNaturals/SubtractionGo.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 1213, "size": 3439 }
-- Agda program using the Iowa Agda library open import bool module PROOF-sortPreservesLength (Choice : Set) (choose : Choice → 𝔹) (lchoice : Choice → Choice) (rchoice : Choice → Choice) where open import eq open import nat open import list open import maybe --------------------------------------------------------------------------- -- Translated Curry operations: insert : ℕ → 𝕃 ℕ → 𝕃 ℕ insert x [] = x :: [] insert y (z :: u) = if y ≤ z then y :: (z :: u) else z :: (insert y u) sort : 𝕃 ℕ → 𝕃 ℕ sort [] = [] sort (x :: y) = insert x (sort y) --------------------------------------------------------------------------- insertIncLength : (x : ℕ) → (xs : 𝕃 ℕ) → length (insert x xs) ≡ suc (length xs) insertIncLength x [] = refl insertIncLength x (y :: ys) with (x ≤ y) ... | tt = refl ... | ff rewrite insertIncLength x ys = refl sortPreservesLength : (xs : 𝕃 ℕ) → length (sort xs) ≡ length xs sortPreservesLength [] = refl sortPreservesLength (x :: xs) rewrite insertIncLength x (sort xs) | sortPreservesLength xs = refl ---------------------------------------------------------------------------
{ "alphanum_fraction": 0.5052724077, "avg_line_length": 26.4651162791, "ext": "agda", "hexsha": "1e75a12d9d1821a5bc73ae8844ad46d693e717f6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7905bc4f625a94a725f9f6d8a2de1140bea5e471", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "phlummox/curry-tools", "max_forks_repo_path": "currypp/.cpm/packages/currycheck/examples/withVerification/PROOF-sortPreservesLength.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7905bc4f625a94a725f9f6d8a2de1140bea5e471", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "phlummox/curry-tools", "max_issues_repo_path": "currypp/.cpm/packages/currycheck/examples/withVerification/PROOF-sortPreservesLength.agda", "max_line_length": 75, "max_stars_count": null, "max_stars_repo_head_hexsha": "7905bc4f625a94a725f9f6d8a2de1140bea5e471", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "phlummox/curry-tools", "max_stars_repo_path": "currypp/.cpm/packages/currycheck/examples/withVerification/PROOF-sortPreservesLength.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 299, "size": 1138 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Group.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open import Cubical.Algebra.Group.Base private variable ℓ ℓ' ℓ'' : Level module GroupLemmas (G : Group {ℓ}) where open Group G public abstract simplL : (a : Carrier) {b c : Carrier} → a + b ≡ a + c → b ≡ c simplL a {b} {c} p = b ≡⟨ sym (lid b) ∙ cong (_+ b) (sym (invl a)) ∙ sym (assoc _ _ _) ⟩ - a + (a + b) ≡⟨ cong (- a +_) p ⟩ - a + (a + c) ≡⟨ assoc _ _ _ ∙ cong (_+ c) (invl a) ∙ lid c ⟩ c ∎ simplR : {a b : Carrier} (c : Carrier) → a + c ≡ b + c → a ≡ b simplR {a} {b} c p = a ≡⟨ sym (rid a) ∙ cong (a +_) (sym (invr c)) ∙ assoc _ _ _ ⟩ (a + c) - c ≡⟨ cong (_- c) p ⟩ (b + c) - c ≡⟨ sym (assoc _ _ _) ∙ cong (b +_) (invr c) ∙ rid b ⟩ b ∎ invInvo : (a : Carrier) → - (- a) ≡ a invInvo a = simplL (- a) (invr (- a) ∙ sym (invl a)) invId : - 0g ≡ 0g invId = simplL 0g (invr 0g ∙ sym (lid 0g)) idUniqueL : {e : Carrier} (x : Carrier) → e + x ≡ x → e ≡ 0g idUniqueL {e} x p = simplR x (p ∙ sym (lid _)) idUniqueR : (x : Carrier) {e : Carrier} → x + e ≡ x → e ≡ 0g idUniqueR x {e} p = simplL x (p ∙ sym (rid _)) invUniqueL : {g h : Carrier} → g + h ≡ 0g → g ≡ - h invUniqueL {g} {h} p = simplR h (p ∙ sym (invl h)) invUniqueR : {g h : Carrier} → g + h ≡ 0g → h ≡ - g invUniqueR {g} {h} p = simplL g (p ∙ sym (invr g)) invDistr : (a b : Carrier) → - (a + b) ≡ - b - a invDistr a b = sym (invUniqueR γ) where γ : (a + b) + (- b - a) ≡ 0g γ = (a + b) + (- b - a) ≡⟨ sym (assoc _ _ _) ⟩ a + b + (- b) + (- a) ≡⟨ cong (a +_) (assoc _ _ _ ∙ cong (_+ (- a)) (invr b)) ⟩ a + (0g - a) ≡⟨ cong (a +_) (lid (- a)) ∙ invr a ⟩ 0g ∎ isPropIsGroup : {G : Type ℓ} (0g : G) (_+_ : G → G → G) (-_ : G → G) → isProp (IsGroup 0g _+_ -_) IsGroup.isMonoid (isPropIsGroup 0g _+_ -_ g1 g2 i) = isPropIsMonoid _ _ (IsGroup.isMonoid g1) (IsGroup.isMonoid g2) i IsGroup.inverse (isPropIsGroup 0g _+_ -_ g1 g2 i) = isPropInv (IsGroup.inverse g1) (IsGroup.inverse g2) i where isSetG : isSet _ isSetG = IsSemigroup.is-set (IsMonoid.isSemigroup (IsGroup.isMonoid g1)) isPropInv : isProp ((x : _) → ((x + (- x)) ≡ 0g) × (((- x) + x) ≡ 0g)) isPropInv = isPropΠ λ _ → isProp× (isSetG _ _) (isSetG _ _)
{ "alphanum_fraction": 0.5077622113, "avg_line_length": 33.858974359, "ext": "agda", "hexsha": "6783ed64f60fd1ac08af822adecc1e4111d6ff5f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "knrafto/cubical", "max_forks_repo_path": "Cubical/Algebra/Group/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "knrafto/cubical", "max_issues_repo_path": "Cubical/Algebra/Group/Properties.agda", "max_line_length": 117, "max_stars_count": null, "max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "knrafto/cubical", "max_stars_repo_path": "Cubical/Algebra/Group/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1114, "size": 2641 }
open import Data.Nat.Base open import Relation.Binary.PropositionalEquality open ≡-Reasoning test : 0 ≡ 0 test = begin 0 ≡⟨ {!!} ⟩ 0 ∎ -- WAS: Goal is garbled: -- -- ?0 : (.Relation.Binary.Setoid.preorder (setoid ℕ) -- .Relation.Binary.Preorder.∼ 0) -- 0 -- EXPECTED: Nice goal: -- -- ?0 : 0 ≡ 0
{ "alphanum_fraction": 0.6221498371, "avg_line_length": 14.619047619, "ext": "agda", "hexsha": "c0a867b6a4f6c384cfb7be7dbea2712fecdf50b5", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/lib-interaction/EqReasoning.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/lib-interaction/EqReasoning.agda", "max_line_length": 52, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/lib-interaction/EqReasoning.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 117, "size": 307 }
{-# OPTIONS --type-in-type #-} -- {-# OPTIONS --guardedness-preserving-type-constructors #-} module PatternSynonymsErrorLocation where data _≡_ {A : Set}(a : A) : A -> Set where refl : a ≡ a infixr 2 _,_ record Unit : Set where data Sigma (A : Set)(B : A -> Set) : Set where _,_ : (fst : A) -> B fst -> Sigma A B -- Prod does not communicate guardedness Prod : (A B : Set) -> Set Prod A B = Sigma A \ _ -> B data Empty : Set where data ListTag : Set where nil cons : ListTag {-# TERMINATING #-} List : (A : Set) -> Set List A = Sigma ListTag T where T : ListTag -> Set T nil = Unit T cons = Sigma A \ _ -> List A infix 5 _∷_ pattern [] = nil , _ pattern _∷_ x xs = cons , x , xs -- FAILS: pattern x ∷ xs = cons , x , xs data TyTag : Set where base arr : TyTag {-# TERMINATING #-} Ty : Set Ty = Sigma TyTag T where T : TyTag -> Set T base = Unit T arr = Sigma Ty \ _ -> Ty -- Prod Ty Ty infix 10 _⇒_ pattern ★ = base , _ pattern _⇒_ A B = arr , A , B Context = List Ty data NatTag : Set where zero succ : NatTag Var : (Gamma : Context)(C : Ty) -> Set Var [] C = Empty Var (cons , A , Gamma) C = Sigma NatTag T where T : NatTag -> Set T zero = A ≡ C T succ = Var Gamma C pattern vz = zero , refl pattern vs x = succ , x idVar : (Gamma : Context)(C : Ty)(x : Var Gamma C) -> Var Gamma C idVar [] _ () -- CORRECT: idVar (A ∷ Gamma) C (zero , proof) = zero , proof idVar (A ∷ Gamma) C vz = vz idVar (A ∷ Gamma) C (vs x) = vs (idVar Gamma C x)
{ "alphanum_fraction": 0.5763707572, "avg_line_length": 21.8857142857, "ext": "agda", "hexsha": "b8c3660f3f075f6e5372a4c8fbbe07fefba7b74e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Fail/PatternSynonymsErrorLocation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "test/Fail/PatternSynonymsErrorLocation.agda", "max_line_length": 65, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Fail/PatternSynonymsErrorLocation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 521, "size": 1532 }
record Unit : Set where data Bool : Set where true false : Bool F : Bool -> Set F true = Bool F false = Unit f : (b : Bool) -> F b f true = true f false = record {} -- this should give an error, but only gives yellow test : Bool test = f _ false
{ "alphanum_fraction": 0.6414342629, "avg_line_length": 16.7333333333, "ext": "agda", "hexsha": "edd5ab6c809c3272e1a584b03babf0f418963adb", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/Issue437.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/Issue437.agda", "max_line_length": 51, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue437.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 77, "size": 251 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Group.Morphism where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Algebra.Group.Base open import Cubical.HITs.PropositionalTruncation hiding (map) open import Cubical.Data.Sigma private variable ℓ ℓ' : Level -- The following definition of GroupHom and GroupEquiv are level-wise heterogeneous. -- This allows for example to deduce that G ≡ F from a chain of isomorphisms -- G ≃ H ≃ F, even if H does not lie in the same level as G and F. isGroupHom : (G : Group {ℓ}) (H : Group {ℓ'}) (f : ⟨ G ⟩ → ⟨ H ⟩) → Type _ isGroupHom G H f = (x y : ⟨ G ⟩) → f (x G.+ y) ≡ (f x H.+ f y) where module G = Group G module H = Group H record GroupHom (G : Group {ℓ}) (H : Group {ℓ'}) : Type (ℓ-max ℓ ℓ') where constructor grouphom no-eta-equality field fun : ⟨ G ⟩ → ⟨ H ⟩ isHom : isGroupHom G H fun record GroupEquiv (G : Group {ℓ}) (H : Group {ℓ'}) : Type (ℓ-max ℓ ℓ') where constructor groupequiv no-eta-equality field eq : ⟨ G ⟩ ≃ ⟨ H ⟩ isHom : isGroupHom G H (equivFun eq) hom : GroupHom G H hom = grouphom (equivFun eq) isHom open GroupHom open GroupEquiv η-hom : {G : Group {ℓ}} {H : Group {ℓ'}} → (a : GroupHom G H) → grouphom (fun a) (isHom a) ≡ a fun (η-hom a i) = fun a isHom (η-hom a i) = isHom a η-equiv : {G : Group {ℓ}} {H : Group {ℓ'}} → (a : GroupEquiv G H) → groupequiv (eq a) (isHom a) ≡ a eq (η-equiv a i) = eq a isHom (η-equiv a i) = isHom a ×hom : ∀ {ℓ ℓ' ℓ'' ℓ'''} {A : Group {ℓ}} {B : Group {ℓ'}} {C : Group {ℓ''}} {D : Group {ℓ'''}} → GroupHom A C → GroupHom B D → GroupHom (dirProd A B) (dirProd C D) fun (×hom mf1 mf2) = map-× (fun mf1) (fun mf2) isHom (×hom mf1 mf2) a b = ≡-× (isHom mf1 _ _) (isHom mf2 _ _) open Group isInIm : ∀ {ℓ ℓ'} (G : Group {ℓ}) (H : Group {ℓ'}) → (GroupHom G H) → ⟨ H ⟩ → Type (ℓ-max ℓ ℓ') isInIm G H ϕ h = ∃[ g ∈ ⟨ G ⟩ ] (fun ϕ) g ≡ h isInKer : ∀ {ℓ ℓ'} (G : Group {ℓ}) (H : Group {ℓ'}) → (GroupHom G H) → ⟨ G ⟩ → Type ℓ' isInKer G H ϕ g = (fun ϕ) g ≡ 0g H isSurjective : ∀ {ℓ ℓ'} (G : Group {ℓ}) (H : Group {ℓ'}) → GroupHom G H → Type (ℓ-max ℓ ℓ') isSurjective G H ϕ = (x : ⟨ H ⟩) → isInIm G H ϕ x isInjective : ∀ {ℓ ℓ'} (G : Group {ℓ}) (H : Group {ℓ'}) → GroupHom G H → Type (ℓ-max ℓ ℓ') isInjective G H ϕ = (x : ⟨ G ⟩) → isInKer G H ϕ x → x ≡ 0g G
{ "alphanum_fraction": 0.5815691158, "avg_line_length": 32.5540540541, "ext": "agda", "hexsha": "be2f40684c6a9b8c5d7f12d088ba4833cddb8f7d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "knrafto/cubical", "max_forks_repo_path": "Cubical/Algebra/Group/Morphism.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "knrafto/cubical", "max_issues_repo_path": "Cubical/Algebra/Group/Morphism.agda", "max_line_length": 94, "max_stars_count": null, "max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "knrafto/cubical", "max_stars_repo_path": "Cubical/Algebra/Group/Morphism.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 993, "size": 2409 }
-- Andreas, 2019-03-28, issue #3248, reported by guillaumebrunerie {-# OPTIONS --sized-types --show-implicit #-} -- {-# OPTIONS -v tc:10 #-} -- {-# OPTIONS -v tc.term:20 #-} -- {-# OPTIONS -v tc.conv.size:45 #-} -- {-# OPTIONS -v tc.conv.coerce:45 #-} -- {-# OPTIONS -v tc.term.args.target:45 #-} {-# BUILTIN SIZEUNIV SizeUniv #-} -- SizeUniv : SizeUniv {-# BUILTIN SIZE Size #-} -- Size : SizeUniv {-# BUILTIN SIZELT Size<_ #-} -- Size<_ : ..Size → SizeUniv {-# BUILTIN SIZESUC ↑_ #-} -- ↑_ : Size → Size {-# BUILTIN SIZEINF ∞ #-} -- ∞ : Size {-# BUILTIN SIZEMAX _⊔ˢ_ #-} -- _⊔ˢ_ : Size → Size → Size data D (i : Size) : Set where c : {j : Size< i} → D j → D i f : {i : Size} → D i → D i → D i f (c {j₁} l1) (c {j₂} l2) = c {j = j₁ ⊔ˢ j₂} (f {j₁ ⊔ˢ j₂} l1 l2) -- The problem was that the new "check target first" logic -- e49d1ca276e5adbf2eb9f6cd33926b786cef78f7 -- for checking applications does not work for Size<. -- -- Checking target types first -- inferred = Size -- expected = Size< i -- -- It is not the case that Size <= Size< i, however, coerce succeeds, -- since e.g. j : Size <= Size< i if j : Size< i. -- -- The solution is to switch off the check target first logic -- if the target type of a (possibly empty) application is Size< _.
{ "alphanum_fraction": 0.5701492537, "avg_line_length": 35.2631578947, "ext": "agda", "hexsha": "25019e2377719b6c885547aa16ce4a8ad5849541", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue3248.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue3248.agda", "max_line_length": 69, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue3248.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 482, "size": 1340 }
open import Formalization.PredicateLogic.Signature module Formalization.PredicateLogic.Classical.Semantics (𝔏 : Signature) {ℓₘ} where open Signature(𝔏) import Lvl open import Data.Boolean open import Data.ListSized open import Numeral.Natural open import Type private variable args : ℕ -- Model. -- A model decides which propositional constants that are true or false. -- A model in a signature `s` consists of a domain and interpretations of the function/relation symbols in `s`. -- Also called: Structure. -- Note: A model satisfying `∀{args} → Empty(Prop args)` is called an "Algebraic structure". record Model : Type{ℓₚ Lvl.⊔ ℓₒ Lvl.⊔ Lvl.𝐒(ℓₘ)} where field Domain : Type{ℓₘ} -- The type of objects that quantifications quantifies over and functions/relations maps from. function : Obj(args) → List(Domain)(args) → Domain -- Maps Obj to a n-ary function (n=0 is interpreted as a constant). relation : Prop(args) → List(Domain)(args) → Bool -- Maps Prop to a boolean n-ary relation (n=0 is interpreted as a proposition). open Model public using() renaming (Domain to dom ; function to fn ; relation to rel)
{ "alphanum_fraction": 0.720890411, "avg_line_length": 44.9230769231, "ext": "agda", "hexsha": "c4723b1f46cce238529e07701a0f7756bcd4b105", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Formalization/PredicateLogic/Classical/Semantics.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Formalization/PredicateLogic/Classical/Semantics.agda", "max_line_length": 149, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Formalization/PredicateLogic/Classical/Semantics.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 310, "size": 1168 }
{-# OPTIONS --safe #-} module Cubical.Categories.Instances.Cospan where open import Cubical.Foundations.Prelude open import Cubical.Categories.Category open import Cubical.Data.Unit open import Cubical.Data.Empty open Category data 𝟛 : Type ℓ-zero where ⓪ : 𝟛 ① : 𝟛 ② : 𝟛 CospanCat : Category ℓ-zero ℓ-zero CospanCat .ob = 𝟛 CospanCat .Hom[_,_] ⓪ ① = Unit CospanCat .Hom[_,_] ② ① = Unit CospanCat .Hom[_,_] ⓪ ⓪ = Unit CospanCat .Hom[_,_] ① ① = Unit CospanCat .Hom[_,_] ② ② = Unit CospanCat .Hom[_,_] _ _ = ⊥ CospanCat ._⋆_ {x = ⓪} {⓪} {⓪} f g = tt CospanCat ._⋆_ {x = ①} {①} {①} f g = tt CospanCat ._⋆_ {x = ②} {②} {②} f g = tt CospanCat ._⋆_ {x = ⓪} {①} {①} f g = tt CospanCat ._⋆_ {x = ②} {①} {①} f g = tt CospanCat ._⋆_ {x = ⓪} {⓪} {①} f g = tt CospanCat ._⋆_ {x = ②} {②} {①} f g = tt CospanCat .id {⓪} = tt CospanCat .id {①} = tt CospanCat .id {②} = tt CospanCat .⋆IdL {⓪} {①} _ = refl CospanCat .⋆IdL {②} {①} _ = refl CospanCat .⋆IdL {⓪} {⓪} _ = refl CospanCat .⋆IdL {①} {①} _ = refl CospanCat .⋆IdL {②} {②} _ = refl CospanCat .⋆IdR {⓪} {①} _ = refl CospanCat .⋆IdR {②} {①} _ = refl CospanCat .⋆IdR {⓪} {⓪} _ = refl CospanCat .⋆IdR {①} {①} _ = refl CospanCat .⋆IdR {②} {②} _ = refl CospanCat .⋆Assoc {⓪} {⓪} {⓪} {⓪} _ _ _ = refl CospanCat .⋆Assoc {⓪} {⓪} {⓪} {①} _ _ _ = refl CospanCat .⋆Assoc {⓪} {⓪} {①} {①} _ _ _ = refl CospanCat .⋆Assoc {⓪} {①} {①} {①} _ _ _ = refl CospanCat .⋆Assoc {①} {①} {①} {①} _ _ _ = refl CospanCat .⋆Assoc {②} {②} {②} {②} _ _ _ = refl CospanCat .⋆Assoc {②} {②} {②} {①} _ _ _ = refl CospanCat .⋆Assoc {②} {②} {①} {①} _ _ _ = refl CospanCat .⋆Assoc {②} {①} {①} {①} _ _ _ = refl CospanCat .isSetHom {⓪} {⓪} = isSetUnit CospanCat .isSetHom {⓪} {①} = isSetUnit CospanCat .isSetHom {①} {①} = isSetUnit CospanCat .isSetHom {②} {①} = isSetUnit CospanCat .isSetHom {②} {②} = isSetUnit
{ "alphanum_fraction": 0.6004378763, "avg_line_length": 28.1076923077, "ext": "agda", "hexsha": "0b57f294421e7f1ebfdcd826af907270b6ff629d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "63c770b381039c0132c17d7913f4566b35984701", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mzeuner/cubical", "max_forks_repo_path": "Cubical/Categories/Instances/Cospan.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "63c770b381039c0132c17d7913f4566b35984701", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mzeuner/cubical", "max_issues_repo_path": "Cubical/Categories/Instances/Cospan.agda", "max_line_length": 48, "max_stars_count": null, "max_stars_repo_head_hexsha": "63c770b381039c0132c17d7913f4566b35984701", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mzeuner/cubical", "max_stars_repo_path": "Cubical/Categories/Instances/Cospan.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1055, "size": 1827 }
import Lvl open import Structure.Operator.Vector open import Structure.Setoid open import Type module Structure.Operator.Vector.InfiniteDimensional {ℓᵥ ℓₛ ℓᵥₑ ℓₛₑ} {V : Type{ℓᵥ}} ⦃ equiv-V : Equiv{ℓᵥₑ}(V) ⦄ {S : Type{ℓₛ}} ⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄ {_+ᵥ_ : V → V → V} {_⋅ₛᵥ_ : S → V → V} {_+ₛ_ _⋅ₛ_ : S → S → S} ⦃ vectorSpace : VectorSpace(_+ᵥ_)(_⋅ₛᵥ_)(_+ₛ_)(_⋅ₛ_) ⦄ where open VectorSpace(vectorSpace) open import Data.Tuple using (_⨯_ ; _,_) open import Logic open import Logic.Predicate open import Numeral.CoordinateVector as Vec using () renaming (Vector to Vec) open import Numeral.Finite open import Numeral.Natural open import Sets.ExtensionalPredicateSet as PredSet using (PredSet ; _∈_ ; [∋]-binaryRelator) import Structure.Operator.Vector.FiniteDimensional as FiniteDimensional open import Structure.Operator.Vector.LinearCombination ⦃ vectorSpace = vectorSpace ⦄ open import Syntax.Function private variable ℓ ℓₗ : Lvl.Level private variable n : ℕ InfiniteDimensional = ∀{n} → ∃(vf ↦ FiniteDimensional.Spanning ⦃ vectorSpace = vectorSpace ⦄ {n}(vf)) -- TODO: Not sure if correct -- This states that all finite sequences `vf` of length `n` (in terms of `Vec`) that consists of elements from the set `vs` satisfies `P`. -- This can be used in infinite-dimensional vector spaces to define linear independence, span and basis by: `∃(n ↦ AllFiniteSubsets(n)(P)(vs))` AllFiniteSubsets : (n : ℕ) → (Vec(n)(V) → Stmt{ℓ}) → (PredSet{ℓₗ}(V) → Stmt) AllFiniteSubsets(n) P(vs) = (∀{vf : Vec(n)(V)} ⦃ distinct : Vec.Distinct(vf) ⦄ → (∀{i : 𝕟(n)} → (Vec.proj(vf)(i) ∈ vs)) → P(vf)) LinearlyIndependent : PredSet{ℓₗ}(V) → Stmt LinearlyIndependent(vs) = ∃(n ↦ AllFiniteSubsets(n)(FiniteDimensional.LinearlyIndependent)(vs)) Spanning : PredSet{ℓₗ}(V) → Stmt Spanning(vs) = ∃(n ↦ AllFiniteSubsets(n)(FiniteDimensional.Spanning)(vs)) -- Also called: Hamel basis (TODO: I think) Basis : PredSet{ℓₗ}(V) → Stmt Basis(vs) = ∃(n ↦ AllFiniteSubsets(n)(FiniteDimensional.Basis)(vs))
{ "alphanum_fraction": 0.7057356608, "avg_line_length": 40.9183673469, "ext": "agda", "hexsha": "d30026a145210331f322c746932e59070ff18ab8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Operator/Vector/InfiniteDimensional.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Operator/Vector/InfiniteDimensional.agda", "max_line_length": 143, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Operator/Vector/InfiniteDimensional.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 724, "size": 2005 }
-- Copyright: (c) 2016 Ertugrul Söylemez -- License: BSD3 -- Maintainer: Ertugrul Söylemez <[email protected]> module Algebra.Category.Semigroupoid where open import Core -- A semigroupoid is a set of objects and morphisms between objects -- together with an associative binary function that combines morphisms. record Semigroupoid {c h r} : Set (lsuc (c ⊔ h ⊔ r)) where field Ob : Set c Hom : Ob → Ob → Set h Eq : ∀ {A B} → Equiv {r = r} (Hom A B) _∘_ : ∀ {A B C} → Hom B C → Hom A B → Hom A C infixl 6 _∘_ open module MyEquiv {A} {B} = Equiv (Eq {A} {B}) public field ∘-cong : ∀ {A B C} {f1 f2 : Hom B C} {g1 g2 : Hom A B} → f1 ≈ f2 → g1 ≈ g2 → f1 ∘ g1 ≈ f2 ∘ g2 assoc : ∀ {A B C D} (f : Hom C D) (g : Hom B C) (h : Hom A B) → (f ∘ g) ∘ h ≈ f ∘ (g ∘ h) Epic : ∀ {A B} → (f : Hom A B) → Set _ Epic f = ∀ {C} {g1 g2 : Hom _ C} → g1 ∘ f ≈ g2 ∘ f → g1 ≈ g2 Monic : ∀ {B C} → (f : Hom B C) → Set _ Monic f = ∀ {A} {g1 g2 : Hom A _} → f ∘ g1 ≈ f ∘ g2 → g1 ≈ g2 Unique : ∀ {A B} → (f : Hom A B) → Set _ Unique f = ∀ g → f ≈ g IsProduct : ∀ A B AB → (fst : Hom AB A) (snd : Hom AB B) → Set _ IsProduct A B AB fst snd = ∀ AB' (fst' : Hom AB' A) (snd' : Hom AB' B) → ∃ (λ (u : Hom AB' AB) → Unique u × (fst ∘ u ≈ fst') × (snd ∘ u ≈ snd')) record Product A B : Set (c ⊔ h ⊔ r) where field A×B : Ob cfst : Hom A×B A csnd : Hom A×B B isProduct : IsProduct A B A×B cfst csnd record _bimonic_ A B : Set (c ⊔ h ⊔ r) where field to : Hom A B from : Hom B A to-monic : Monic to from-monic : Monic from -- A semifunctor is a composition-preserving mapping from a semigroupoid -- to another. record Semifunctor {cc ch cr dc dh dr} (C : Semigroupoid {cc} {ch} {cr}) (D : Semigroupoid {dc} {dh} {dr}) : Set (cc ⊔ ch ⊔ cr ⊔ dc ⊔ dh ⊔ dr) where private module C = Semigroupoid C module D = Semigroupoid D field F : C.Ob → D.Ob map : ∀ {A B} → C.Hom A B → D.Hom (F A) (F B) map-cong : ∀ {A B} {f g : C.Hom A B} → f C.≈ g → map f D.≈ map g ∘-preserving : ∀ {A B C} (f : C.Hom B C) (g : C.Hom A B) → map (f C.∘ g) D.≈ map f D.∘ map g
{ "alphanum_fraction": 0.4963251189, "avg_line_length": 25.4175824176, "ext": "agda", "hexsha": "a1e59b957649dc72a3eca7cd7d6ed68c26be4d01", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "d9245e5a8b2e902781736de09bd17e81022f6f13", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "esoeylemez/agda-simple", "max_forks_repo_path": "Algebra/Category/Semigroupoid.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d9245e5a8b2e902781736de09bd17e81022f6f13", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "esoeylemez/agda-simple", "max_issues_repo_path": "Algebra/Category/Semigroupoid.agda", "max_line_length": 75, "max_stars_count": 1, "max_stars_repo_head_hexsha": "d9245e5a8b2e902781736de09bd17e81022f6f13", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "esoeylemez/agda-simple", "max_stars_repo_path": "Algebra/Category/Semigroupoid.agda", "max_stars_repo_stars_event_max_datetime": "2019-10-07T17:36:42.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-07T17:36:42.000Z", "num_tokens": 958, "size": 2313 }
module par-swap.union-confluent where open import par-swap open import par-swap.properties open import par-swap.confluent open import par-swap.dpg open import Data.Nat using (_+_ ; _≤′_ ; _<′_ ; suc ; zero ; ≤′-refl ; ℕ) open import Data.Nat.Properties.Simple using ( +-comm ; +-assoc) open import Data.Nat.Properties using (s≤′s ; z≤′n) open import Data.MoreNatProp using (≤′-trans ; suc≤′⇒≤′) open import Data.Product open import Data.Sum open import Data.Bool open import Data.List using ([] ; [_] ; _∷_ ; List ; _++_) open import Data.Empty open import Induction.Nat using (<-rec) open import Induction.Lexicographic using () open import Induction using () open import Induction.WellFounded using () open import Level using () open import Relation.Binary using (Rel) open import Esterel.Lang open import Esterel.Lang.Properties open import Esterel.Environment as Env open import Esterel.Context open import Esterel.Lang.Binding open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; sym ; subst ; cong ; trans ; module ≡-Reasoning ; cong₂ ; subst₂ ; inspect) open import sn-calculus open import context-properties -- get view, E-views open import binding-preserve using (sn⟶-maintains-binding ; sn⟶*-maintains-binding) open import noetherian using (noetherian ; ∥_∥s) open import sn-calculus-props ∥R-preserves-∥∥s : ∀ {p q} -> p ∥R q -> ∥ q ∥s ≡ ∥ p ∥s ∥R-preserves-∥∥s (∥Rstep{C}{p}{q} d≐C⟦p∥q⟧c) rewrite sym (unplugc d≐C⟦p∥q⟧c) = ∥∥par-sym p q C where ∥∥par-sym : ∀ p q C -> ∥ C ⟦ q ∥ p ⟧c ∥s ≡ ∥ C ⟦ p ∥ q ⟧c ∥s ∥∥par-sym p q [] rewrite +-comm ∥ p ∥s ∥ q ∥s = refl ∥∥par-sym p q (_ ∷ C) with ∥∥par-sym p q C ∥∥par-sym p q (ceval (epar₁ _) ∷ C) | R rewrite R = refl ∥∥par-sym p q (ceval (epar₂ _) ∷ C) | R rewrite R = refl ∥∥par-sym p q (ceval (eseq _) ∷ C) | R rewrite R = refl ∥∥par-sym p q (ceval (eloopˢ _) ∷ C) | R rewrite R = refl ∥∥par-sym p q (ceval (esuspend _) ∷ C) | R rewrite R = refl ∥∥par-sym p q (ceval etrap ∷ C) | R rewrite R = refl ∥∥par-sym p q (csignl _ ∷ C) | R rewrite R = refl ∥∥par-sym p q (cpresent₁ _ _ ∷ C) | R rewrite R = refl ∥∥par-sym p q (cpresent₂ _ _ ∷ C) | R rewrite R = refl ∥∥par-sym p q (cloop ∷ C) | R rewrite R = refl ∥∥par-sym p q (cloopˢ₂ _ ∷ C) | R rewrite R = refl ∥∥par-sym p q (cseq₂ _ ∷ C) | R rewrite R = refl ∥∥par-sym p q (cshared _ _ ∷ C) | R rewrite R = refl ∥∥par-sym p q (cvar _ _ ∷ C) | R rewrite R = refl ∥∥par-sym p q (cif₁ _ _ ∷ C) | R rewrite R = refl ∥∥par-sym p q (cif₂ _ _ ∷ C) | R rewrite R = refl ∥∥par-sym p q (cenv _ _ ∷ C) | R rewrite R = refl ∥R*-preserves-∥∥s : ∀ {p q} -> p ∥R* q -> ∥ q ∥s ≡ ∥ p ∥s ∥R*-preserves-∥∥s ∥R0 = refl ∥R*-preserves-∥∥s (∥Rn p∥Rq p∥R*q) with ∥R*-preserves-∥∥s p∥R*q ... | x rewrite ∥R-preserves-∥∥s p∥Rq = x module LexicographicLE {a b ℓ₁ ℓ₂} {A : Set a} {B : Set b} (RelA : Rel A ℓ₁) (RelB : Rel B ℓ₂) where open import Level open import Relation.Binary open import Induction.WellFounded open import Data.Product open import Function open import Induction open import Relation.Unary data _<_ : Rel (Σ A \ _ → B) (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where left : ∀ {x₁ y₁ x₂ y₂} (x₁<x₂ : RelA x₁ x₂) → (x₁ , y₁) < (x₂ , y₂) right : ∀ {x₁ y₁ x₂ y₂} (y₁<y₂ : RelB y₁ y₂) → (x₁ ≡ x₂ ⊎ RelA x₁ x₂) → (x₁ , y₁) < (x₂ , y₂) mutual accessibleLE : ∀ {x y} → Acc RelA x → WellFounded RelB → Acc _<_ (x , y) accessibleLE accA wfB = acc (accessibleLE′ accA (wfB _) wfB) accessibleLE′ : ∀ {x y} → Acc RelA x → Acc RelB y → WellFounded RelB → WfRec _<_ (Acc _<_) (x , y) accessibleLE′ (acc rsA) _ wfB ._ (left x′<x) = accessibleLE (rsA _ x′<x) wfB accessibleLE′ accA (acc rsB) wfB .(_ , _) (right y′<y (inj₁ refl)) = acc (accessibleLE′ accA (rsB _ y′<y) wfB) accessibleLE′ (acc rsA) (acc rsB) wfB .(_ , _) (right y′<y (inj₂ x′<x)) = acc (accessibleLE′ (rsA _ x′<x) (rsB _ y′<y) wfB) wellFounded : WellFounded RelA → WellFounded RelB → WellFounded _<_ wellFounded wfA wfB p = accessibleLE (wfA (proj₁ p)) wfB module _ where open LexicographicLE _<′_ _<′_ public renaming (_<_ to _<<′_; wellFounded to <<′-wellFounded; left to <<′-left; right to <<′-right) module _ {ℓ} where open Induction.WellFounded.All (<<′-wellFounded Induction.Nat.<′-wellFounded Induction.Nat.<′-wellFounded) ℓ public renaming (wfRec-builder to <<′-rec-builder; wfRec to <<′-rec) {- proof from _On the Power of Simple Diagrams_ by Roberto Di Cosmo, RTA 1996 (lemma 7) -} ∥R*-sn⟶*-commute : CB-COMMUTE _∥R*_ _sn⟶*_ ∥R*-sn⟶*-commute = thm where redlen : ∀ {p q} -> p ∥R* q -> ℕ redlen ∥R0 = zero redlen (∥Rn p∥Rq p∥R*q) = suc (redlen p∥R*q) sharedtype : (ℕ × ℕ) -> Set sharedtype (sizeb , distab) = ∀ {a b c BV FV} -> CorrectBinding a BV FV -> (a∥R*b : a ∥R* b) -> a sn⟶* c -> redlen a∥R*b ≡ distab -> ∥ b ∥s ≡ sizeb -> ∃ \ {d -> b sn⟶* d × c ∥R* d} {- this proof is not working the way that Di Cosmo intended; it uses properties about ∥R* reduction directly -} composing-the-diagram-in-the-hypothesis-down : ∀ {p1 p2 p3 q1 q3} -> p1 sn⟶ p2 -> p2 sn⟶* p3 -> p1 ∥R* q1 -> p3 ∥R* q3 -> (∥ q3 ∥s) <′ (∥ q1 ∥s) composing-the-diagram-in-the-hypothesis-down = thm where thm-no-∥R* : ∀ {p1 p2 p3} -> p1 sn⟶ p2 -> p2 sn⟶* p3 -> ∥ p3 ∥s <′ ∥ p1 ∥s thm-no-∥R* p1sn⟶p2 rrefl = noetherian p1sn⟶p2 thm-no-∥R* {p1}{p2}{p3} p1sn⟶p2 (rstep{q = r} p2sn⟶r rsn⟶*p3) with thm-no-∥R* p2sn⟶r rsn⟶*p3 ... | ∥p3∥s<′∥p2∥s = ≤′-trans {y = ∥ p2 ∥s} ∥p3∥s<′∥p2∥s (suc≤′⇒≤′ ∥ p2 ∥s ∥ p1 ∥s (noetherian p1sn⟶p2)) thm : ∀ {p1 p2 p3 q1 q3} -> p1 sn⟶ p2 -> p2 sn⟶* p3 -> p1 ∥R* q1 -> p3 ∥R* q3 -> (∥ q3 ∥s) <′ (∥ q1 ∥s) thm p1sn⟶p2 p2sn⟶*p3 p1∥R*q1 p3∥R*q3 rewrite ∥R*-preserves-∥∥s p1∥R*q1 | ∥R*-preserves-∥∥s p3∥R*q3 = thm-no-∥R* p1sn⟶p2 p2sn⟶*p3 step : ∀ nm -> (∀ (nm′ : ℕ × ℕ) -> nm′ <<′ nm -> sharedtype nm′) -> sharedtype nm step (sizeb , distab) rec CBa ∥R0 asn⟶*c redlena∥R*b≡distab ∥b∥s≡sizeb = _ , asn⟶*c , ∥R0 step (sizeb , distab) rec CBa a∥R*b rrefl redlena∥R*b≡distab ∥b∥s≡sizeb = _ , rrefl , a∥R*b step (sizeb , distab) rec {a} {b} {c} CBa (∥Rn{q = a″} a∥Ra″ a″∥R*b) (rstep{q = a′} asn⟶a′ a′sn⟶*c) redlena∥R*b≡distab ∥b∥s≡sizeb rewrite sym redlena∥R*b≡distab with sn⟶-maintains-binding CBa asn⟶a′ ... | (_ , CBa′ , _) with DPG a∥Ra″ asn⟶a′ ... | (a‴ , gap) , a″sn⟶gap , gapsn⟶*a‴ , a′∥R*a‴ with rec (sizeb , redlen a″∥R*b) (<<′-right (s≤′s ≤′-refl) (inj₁ refl)) (∥R-maintains-binding CBa a∥Ra″) a″∥R*b (rstep a″sn⟶gap gapsn⟶*a‴) refl ∥b∥s≡sizeb ... | (b′ , bsn⟶*b′ , a‴∥R*b′) rewrite sym ∥b∥s≡sizeb with composing-the-diagram-in-the-hypothesis-down a″sn⟶gap gapsn⟶*a‴ a″∥R*b a‴∥R*b′ ... | ∥b′∥s<′∥b∥s with rec (∥ b′ ∥s , redlen (∥R*-concat a′∥R*a‴ a‴∥R*b′)) (<<′-left ∥b′∥s<′∥b∥s) CBa′ (∥R*-concat a′∥R*a‴ a‴∥R*b′) a′sn⟶*c refl refl ... | ( d , b′sn⟶*d , c∥R*d) = d , sn⟶*+ bsn⟶*b′ b′sn⟶*d , c∥R*d lemma7-commutation : ∀ (nm : ℕ × ℕ) -> sharedtype nm lemma7-commutation = <<′-rec _ step thm : CB-COMMUTE _∥R*_ _sn⟶*_ thm {p}{q}{r} CBp p∥R*q psn⟶*r = lemma7-commutation (∥ q ∥s , redlen p∥R*q) CBp p∥R*q psn⟶*r refl refl ∥R*∪sn⟶*-confluent : CB-CONFLUENT _∥R*∪sn⟶*_ ∥R*∪sn⟶*-confluent = \ { CBp p∥R*∪sn⟶*q p∥R*∪sn⟶*r -> hindley-rosen (redlen p∥R*∪sn⟶*q , redlen p∥R*∪sn⟶*r) CBp p∥R*∪sn⟶*q p∥R*∪sn⟶*r refl refl} where redlen : ∀ {p q} -> p ∥R*∪sn⟶* q -> ℕ redlen (∪∥R* _ r) = suc (redlen r) redlen (∪sn⟶* _ r) = suc (redlen r) redlen ∪refl = zero sharedtype : ℕ × ℕ -> Set sharedtype (n , m) = ∀ {p q r BV FV} -> CorrectBinding p BV FV -> (p∥R*∪sn⟶*q : p ∥R*∪sn⟶* q) -> (p∥R*∪sn⟶*r : p ∥R*∪sn⟶* r) -> n ≡ redlen p∥R*∪sn⟶*q -> m ≡ redlen p∥R*∪sn⟶*r -> ∃ λ {z → (q ∥R*∪sn⟶* z × r ∥R*∪sn⟶* z)} length-lemma : ∀ {a b} (l : a ∥R*∪sn⟶* b) -> suc zero ≡ suc (redlen l) ⊎ suc zero <′ suc (redlen l) length-lemma (∪∥R* p∥R*q l) = inj₂ (s≤′s (s≤′s z≤′n)) length-lemma (∪sn⟶* psn⟶*q l) = inj₂ (s≤′s (s≤′s z≤′n)) length-lemma ∪refl = inj₁ refl step : ∀ nm -> (∀ (nm′ : ℕ × ℕ) -> nm′ <<′ nm -> sharedtype nm′) -> sharedtype nm step (n , m) rec CBp (∪∥R* p∥R*q a) ∪refl n≡ m≡ = _ , ∪refl , ∪∥R* p∥R*q a step (n , m) rec CBp (∪sn⟶* psn⟶*q a) ∪refl n≡ m≡ = _ , ∪refl , ∪sn⟶* psn⟶*q a step (n , m) rec CBp ∪refl (∪∥R* p∥R*q b) n≡ m≡ = _ , ∪∥R* p∥R*q b , ∪refl step (n , m) rec CBp ∪refl (∪sn⟶* psn⟶*q b) n≡ m≡ = _ , ∪sn⟶* psn⟶*q b , ∪refl step (n , m) rec CBp ∪refl ∪refl n≡ m≡ = _ , ∪refl , ∪refl step(n , m) rec {p}{q}{r} CBp (∪∥R* {_}{q₁} p∥R*q₁ q₁∥R*∪sn⟶*q) (∪∥R* {_}{r₁} p∥R*r₁ r₁∥R*∪sn⟶*r) n≡ m≡ rewrite n≡ | m≡ with BVFVcorrect _ _ _ CBp ... | refl , refl with ∥R*-maintains-binding CBp p∥R*q₁ ... | CBq₁ with BVFVcorrect _ _ _ CBq₁ ... | refl , refl with ∥R*-maintains-binding CBp p∥R*r₁ ... | CBr₁ with BVFVcorrect _ _ _ CBr₁ ... | refl , refl with ∥R*-confluent CBp p∥R*q₁ p∥R*r₁ ... | q₁r₁ , q₁∥R*q₁r₁ , r₁∥R*q₁r₁ with rec (suc zero , redlen r₁∥R*∪sn⟶*r) (<<′-right ≤′-refl (length-lemma q₁∥R*∪sn⟶*q)) CBr₁ (∪∥R* r₁∥R*q₁r₁ ∪refl) r₁∥R*∪sn⟶*r refl refl ... | q₁r₁r , q₁r₁∥R*∪sn⟶*q₁r₁r , r∥R*∪sn⟶*q₁r₁r with rec (redlen q₁∥R*∪sn⟶*q , suc (redlen q₁r₁∥R*∪sn⟶*q₁r₁r)) (<<′-left ≤′-refl) CBq₁ q₁∥R*∪sn⟶*q (∪∥R* q₁∥R*q₁r₁ q₁r₁∥R*∪sn⟶*q₁r₁r) refl refl ... | qq₁r₁r , q∥R*∪sn⟶*qq₁r₁r , q₁r₁r∥R*∪sn⟶*qq₁r₁r = qq₁r₁r , q∥R*∪sn⟶*qq₁r₁r , ∥R*∪sn⟶*-concat r∥R*∪sn⟶*q₁r₁r q₁r₁r∥R*∪sn⟶*qq₁r₁r step (n , m) rec {p}{q}{r} CBp (∪∥R*{_}{q₁} p∥R*q₁ q₁∥R*∪sn⟶*q) (∪sn⟶*{_}{r₁} psn⟶*r₁ r₁∥R*∪sn⟶*r) n≡ m≡ rewrite n≡ | m≡ with BVFVcorrect _ _ _ CBp ... | refl , refl with ∥R*-maintains-binding CBp p∥R*q₁ ... | CBq₁ with BVFVcorrect _ _ _ CBq₁ ... | refl , refl with sn⟶*-maintains-binding CBp psn⟶*r₁ ... | (BVr₁ , FVr₁) , CBr₁ with ∥R*-sn⟶*-commute CBp p∥R*q₁ psn⟶*r₁ ... | q₁r₁ , q₁sn⟶*q₁r₁ , r₁∥R*q₁r₁ with rec (suc zero , redlen r₁∥R*∪sn⟶*r) (<<′-right ≤′-refl (length-lemma q₁∥R*∪sn⟶*q)) CBr₁ (∪∥R* r₁∥R*q₁r₁ ∪refl) r₁∥R*∪sn⟶*r refl refl ... | q₁r₁r , q₁r₁∥R*∪sn⟶*q₁r₁r , r∥R*∪sn⟶*q₁r₁r with rec (redlen q₁∥R*∪sn⟶*q , suc (redlen q₁r₁∥R*∪sn⟶*q₁r₁r)) (<<′-left ≤′-refl) CBq₁ q₁∥R*∪sn⟶*q (∪sn⟶* q₁sn⟶*q₁r₁ q₁r₁∥R*∪sn⟶*q₁r₁r) refl refl ... | qq₁r₁r , q∥R*∪sn⟶*qq₁r₁r , q₁r₁r∥R*∪sn⟶*qq₁r₁r = qq₁r₁r , q∥R*∪sn⟶*qq₁r₁r , ∥R*∪sn⟶*-concat r∥R*∪sn⟶*q₁r₁r q₁r₁r∥R*∪sn⟶*qq₁r₁r step (n , m) rec {p}{q}{r} CBp (∪sn⟶*{_}{q₁} psn⟶*q₁ q₁∥R*∪sn⟶*q) (∪∥R*{_}{r₁} p∥R*r₁ r₁∥R*∪sn⟶*r) n≡ m≡ rewrite n≡ | m≡ with BVFVcorrect _ _ _ CBp ... | refl , refl with sn⟶*-maintains-binding CBp psn⟶*q₁ ... | (BVq₁ , FVq₁) , CBq₁ with ∥R*-maintains-binding CBp p∥R*r₁ ... | CBr₁ with BVFVcorrect _ _ _ CBr₁ ... | refl , refl with ∥R*-sn⟶*-commute CBp p∥R*r₁ psn⟶*q₁ ... | r₁q₁ , r₁sn⟶*r₁q₁ , q₁∥R*r₁q₁ with rec (suc zero , redlen r₁∥R*∪sn⟶*r) (<<′-right ≤′-refl (length-lemma q₁∥R*∪sn⟶*q)) CBr₁ (∪sn⟶* r₁sn⟶*r₁q₁ ∪refl) r₁∥R*∪sn⟶*r refl refl ... | r₁q₁r , r₁q₁∥R*∪sn⟶*r₁q₁r , r∥R*∪sn⟶*r₁q₁r with rec (redlen q₁∥R*∪sn⟶*q , suc (redlen r₁q₁∥R*∪sn⟶*r₁q₁r)) (<<′-left ≤′-refl) CBq₁ q₁∥R*∪sn⟶*q (∪∥R* q₁∥R*r₁q₁ r₁q₁∥R*∪sn⟶*r₁q₁r) refl refl ... | qq₁r₁r , q∥R*∪sn⟶*qq₁r₁r , q₁r₁r∥R*∪sn⟶*qq₁r₁r = qq₁r₁r , q∥R*∪sn⟶*qq₁r₁r , ∥R*∪sn⟶*-concat r∥R*∪sn⟶*r₁q₁r q₁r₁r∥R*∪sn⟶*qq₁r₁r step (n , m) rec {p}{q}{r} CBp (∪sn⟶*{_}{q₁} psn⟶*q₁ q₁∥R*∪sn⟶*q) (∪sn⟶*{_}{r₁} psn⟶*r₁ r₁∥R*∪sn⟶*r) n≡ m≡ rewrite n≡ | m≡ with BVFVcorrect _ _ _ CBp ... | refl , refl with sn⟶*-maintains-binding CBp psn⟶*q₁ ... | (BVq₁ , FVq₁) , CBq₁ with sn⟶*-maintains-binding CBp psn⟶*r₁ ... | (BVr₁ , FVr₁) , CBr₁ with sn⟶*-confluent CBp psn⟶*q₁ psn⟶*r₁ ... | q₁r₁ , q₁sn⟶*q₁r₁ , r₁sn⟶*q₁r₁ with rec (suc zero , redlen r₁∥R*∪sn⟶*r) (<<′-right ≤′-refl (length-lemma q₁∥R*∪sn⟶*q)) CBr₁ (∪sn⟶* r₁sn⟶*q₁r₁ ∪refl) r₁∥R*∪sn⟶*r refl refl ... | q₁r₁r , q₁r₁∥R*∪sn⟶*q₁r₁r , r∥R*∪sn⟶*q₁r₁r with rec (redlen q₁∥R*∪sn⟶*q , suc (redlen q₁r₁∥R*∪sn⟶*q₁r₁r)) (<<′-left ≤′-refl) CBq₁ q₁∥R*∪sn⟶*q (∪sn⟶* q₁sn⟶*q₁r₁ q₁r₁∥R*∪sn⟶*q₁r₁r) refl refl ... | qq₁r₁r , q∥R*∪sn⟶*qq₁r₁r , q₁r₁r∥R*∪sn⟶*qq₁r₁r = qq₁r₁r , q∥R*∪sn⟶*qq₁r₁r , ∥R*∪sn⟶*-concat r∥R*∪sn⟶*q₁r₁r q₁r₁r∥R*∪sn⟶*qq₁r₁r hindley-rosen : ∀ (nm : ℕ × ℕ) -> sharedtype nm hindley-rosen = <<′-rec _ step
{ "alphanum_fraction": 0.5252037428, "avg_line_length": 37.3295774648, "ext": "agda", "hexsha": "24a75585cd40a61122086cbe75b10096fd475c0a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_path": "agda/par-swap/union-confluent.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "florence/esterel-calculus", "max_issues_repo_path": "agda/par-swap/union-confluent.agda", "max_line_length": 93, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_path": "agda/par-swap/union-confluent.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "num_tokens": 6813, "size": 13252 }
{-# OPTIONS --without-K --safe #-} module Definition.Conversion.EqRelInstance where open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.Weakening using (_∷_⊆_; wkEq) open import Definition.Conversion open import Definition.Conversion.Reduction open import Definition.Conversion.Universe open import Definition.Conversion.Stability open import Definition.Conversion.Soundness open import Definition.Conversion.Lift open import Definition.Conversion.Conversion open import Definition.Conversion.Symmetry open import Definition.Conversion.Transitivity open import Definition.Conversion.Weakening open import Definition.Typed.EqualityRelation open import Definition.Typed.Consequences.Syntactic open import Definition.Typed.Consequences.Substitution open import Definition.Typed.Consequences.Injectivity open import Definition.Typed.Consequences.Equality open import Definition.Typed.Consequences.Reduction open import Definition.Typed.Consequences.Inversion open import Tools.Nat open import Tools.Product import Tools.PropositionalEquality as PE open import Tools.Function -- Algorithmic equality of neutrals with injected conversion. record _⊢_~_∷_ (Γ : Con Term) (k l A : Term) : Set where inductive constructor ↑ field {B} : Term A≡B : Γ ⊢ A ≡ B k~↑l : Γ ⊢ k ~ l ↑ B -- Properties of algorithmic equality of neutrals with injected conversion. ~-var : ∀ {x A Γ} → Γ ⊢ var x ∷ A → Γ ⊢ var x ~ var x ∷ A ~-var x = let ⊢A = syntacticTerm x in ↑ (refl ⊢A) (var-refl x PE.refl) ~-app : ∀ {f g a b F G Γ} → Γ ⊢ f ~ g ∷ Π F ▹ G → Γ ⊢ a [conv↑] b ∷ F → Γ ⊢ f ∘ a ~ g ∘ b ∷ G [ a ] ~-app (↑ A≡B x) x₁ = let _ , ⊢B = syntacticEq A≡B B′ , whnfB′ , D = whNorm ⊢B ΠFG≡B′ = trans A≡B (subset* (red D)) H , E , B≡ΠHE = Π≡A ΠFG≡B′ whnfB′ F≡H , G≡E = injectivity (PE.subst (λ x → _ ⊢ _ ≡ x) B≡ΠHE ΠFG≡B′) _ , ⊢f , _ = syntacticEqTerm (soundnessConv↑Term x₁) in ↑ (substTypeEq G≡E (refl ⊢f)) (app-cong (PE.subst (λ x → _ ⊢ _ ~ _ ↓ x) B≡ΠHE ([~] _ (red D) whnfB′ x)) (convConvTerm x₁ F≡H)) ~-fst : ∀ {Γ p r F G} → Γ ⊢ p ~ r ∷ Σ F ▹ G → Γ ⊢ fst p ~ fst r ∷ F ~-fst (↑ A≡B p~r) = let _ , ⊢B = syntacticEq A≡B B′ , whnfB′ , D = whNorm ⊢B ΣFG≡B′ = trans A≡B (subset* (red D)) H , E , B≡ΣHE = Σ≡A ΣFG≡B′ whnfB′ F≡H , G≡E = Σ-injectivity (PE.subst (λ x → _ ⊢ _ ≡ x) B≡ΣHE ΣFG≡B′) p~r↓ = PE.subst (λ x → _ ⊢ _ ~ _ ↓ x) B≡ΣHE ([~] _ (red D) whnfB′ p~r) in ↑ F≡H (fst-cong p~r↓) ~-snd : ∀ {Γ p r F G} → Γ ⊢ p ~ r ∷ Σ F ▹ G → Γ ⊢ snd p ~ snd r ∷ G [ fst p ] ~-snd (↑ A≡B p~r) = let ⊢ΣFG , ⊢B = syntacticEq A≡B B′ , whnfB′ , D = whNorm ⊢B ΣFG≡B′ = trans A≡B (subset* (red D)) H , E , B≡ΣHE = Σ≡A ΣFG≡B′ whnfB′ F≡H , G≡E = Σ-injectivity (PE.subst (λ x → _ ⊢ _ ≡ x) B≡ΣHE ΣFG≡B′) p~r↓ = PE.subst (λ x → _ ⊢ _ ~ _ ↓ x) B≡ΣHE ([~] _ (red D) whnfB′ p~r) ⊢F , ⊢G = syntacticΣ ⊢ΣFG _ , ⊢p , _ = syntacticEqTerm (soundness~↑ p~r) ⊢fst = fstⱼ ⊢F ⊢G (conv ⊢p (sym A≡B)) in ↑ (substTypeEq G≡E (refl ⊢fst)) (snd-cong p~r↓) ~-natrec : ∀ {z z′ s s′ n n′ F F′ Γ} → (Γ ∙ ℕ) ⊢ F [conv↑] F′ → Γ ⊢ z [conv↑] z′ ∷ (F [ zero ]) → Γ ⊢ s [conv↑] s′ ∷ (Π ℕ ▹ (F ▹▹ F [ suc (var 0) ]↑)) → Γ ⊢ n ~ n′ ∷ ℕ → Γ ⊢ natrec F z s n ~ natrec F′ z′ s′ n′ ∷ (F [ n ]) ~-natrec x x₁ x₂ (↑ A≡B x₄) = let _ , ⊢B = syntacticEq A≡B B′ , whnfB′ , D = whNorm ⊢B ℕ≡B′ = trans A≡B (subset* (red D)) B≡ℕ = ℕ≡A ℕ≡B′ whnfB′ k~l′ = PE.subst (λ x → _ ⊢ _ ~ _ ↓ x) B≡ℕ ([~] _ (red D) whnfB′ x₄) ⊢F , _ = syntacticEq (soundnessConv↑ x) _ , ⊢n , _ = syntacticEqTerm (soundness~↓ k~l′) in ↑ (refl (substType ⊢F ⊢n)) (natrec-cong x x₁ x₂ k~l′) ~-Emptyrec : ∀ {n n′ F F′ Γ} → Γ ⊢ F [conv↑] F′ → Γ ⊢ n ~ n′ ∷ Empty → Γ ⊢ Emptyrec F n ~ Emptyrec F′ n′ ∷ F ~-Emptyrec x (↑ A≡B x₄) = let _ , ⊢B = syntacticEq A≡B B′ , whnfB′ , D = whNorm ⊢B Empty≡B′ = trans A≡B (subset* (red D)) B≡Empty = Empty≡A Empty≡B′ whnfB′ k~l′ = PE.subst (λ x → _ ⊢ _ ~ _ ↓ x) B≡Empty ([~] _ (red D) whnfB′ x₄) ⊢F , _ = syntacticEq (soundnessConv↑ x) _ , ⊢n , _ = syntacticEqTerm (soundness~↓ k~l′) in ↑ (refl ⊢F) (Emptyrec-cong x k~l′) ~-sym : {k l A : Term} {Γ : Con Term} → Γ ⊢ k ~ l ∷ A → Γ ⊢ l ~ k ∷ A ~-sym (↑ A≡B x) = let ⊢Γ = wfEq A≡B B , A≡B′ , l~k = sym~↑ (reflConEq ⊢Γ) x in ↑ (trans A≡B A≡B′) l~k ~-trans : {k l m A : Term} {Γ : Con Term} → Γ ⊢ k ~ l ∷ A → Γ ⊢ l ~ m ∷ A → Γ ⊢ k ~ m ∷ A ~-trans (↑ x x₁) (↑ x₂ x₃) = let ⊢Γ = wfEq x k~m , _ = trans~↑ x₁ x₃ in ↑ x k~m ~-wk : {k l A : Term} {ρ : Wk} {Γ Δ : Con Term} → ρ ∷ Δ ⊆ Γ → ⊢ Δ → Γ ⊢ k ~ l ∷ A → Δ ⊢ wk ρ k ~ wk ρ l ∷ wk ρ A ~-wk x x₁ (↑ x₂ x₃) = ↑ (wkEq x x₁ x₂) (wk~↑ x x₁ x₃) ~-conv : {k l A B : Term} {Γ : Con Term} → Γ ⊢ k ~ l ∷ A → Γ ⊢ A ≡ B → Γ ⊢ k ~ l ∷ B ~-conv (↑ x x₁) x₂ = ↑ (trans (sym x₂) x) x₁ ~-to-conv : {k l A : Term} {Γ : Con Term} → Γ ⊢ k ~ l ∷ A → Γ ⊢ k [conv↑] l ∷ A ~-to-conv (↑ x x₁) = convConvTerm (lift~toConv↑ x₁) (sym x) -- Algorithmic equality instance of the generic equality relation. instance eqRelInstance : EqRelSet eqRelInstance = record { _⊢_≅_ = _⊢_[conv↑]_; _⊢_≅_∷_ = _⊢_[conv↑]_∷_; _⊢_~_∷_ = _⊢_~_∷_; ~-to-≅ₜ = ~-to-conv; ≅-eq = soundnessConv↑; ≅ₜ-eq = soundnessConv↑Term; ≅-univ = univConv↑; ≅-sym = symConv; ≅ₜ-sym = symConvTerm; ~-sym = ~-sym; ≅-trans = transConv; ≅ₜ-trans = transConvTerm; ~-trans = ~-trans; ≅-conv = convConvTerm; ~-conv = ~-conv; ≅-wk = wkConv↑; ≅ₜ-wk = wkConv↑Term; ~-wk = ~-wk; ≅-red = λ x x₁ x₂ x₃ x₄ → reductionConv↑ x x₁ x₄; ≅ₜ-red = λ x x₁ x₂ x₃ x₄ x₅ x₆ → reductionConv↑Term x x₁ x₂ x₆; ≅-Urefl = liftConv ∘ᶠ U-refl; ≅-ℕrefl = liftConv ∘ᶠ ℕ-refl; ≅ₜ-ℕrefl = λ x → liftConvTerm (univ (ℕⱼ x) (ℕⱼ x) (ℕ-refl x)); ≅-Emptyrefl = liftConv ∘ᶠ Empty-refl; ≅ₜ-Emptyrefl = λ x → liftConvTerm (univ (Emptyⱼ x) (Emptyⱼ x) (Empty-refl x)); ≅-Unitrefl = liftConv ∘ᶠ Unit-refl; ≅ₜ-Unitrefl = λ ⊢Γ → liftConvTerm (univ (Unitⱼ ⊢Γ) (Unitⱼ ⊢Γ) (Unit-refl ⊢Γ)); ≅ₜ-η-unit = λ [e] [e'] → let u , uWhnf , uRed = whNormTerm [e] u' , u'Whnf , u'Red = whNormTerm [e'] [u] = ⊢u-redₜ uRed [u'] = ⊢u-redₜ u'Red in [↑]ₜ Unit u u' (red (idRed:*: (syntacticTerm [e]))) (redₜ uRed) (redₜ u'Red) Unitₙ uWhnf u'Whnf (η-unit [u] [u'] uWhnf u'Whnf); ≅-Π-cong = λ x x₁ x₂ → liftConv (Π-cong x x₁ x₂); ≅ₜ-Π-cong = λ x x₁ x₂ → let _ , F∷U , H∷U = syntacticEqTerm (soundnessConv↑Term x₁) _ , G∷U , E∷U = syntacticEqTerm (soundnessConv↑Term x₂) ⊢Γ = wfTerm F∷U F<>H = univConv↑ x₁ G<>E = univConv↑ x₂ F≡H = soundnessConv↑ F<>H E∷U′ = stabilityTerm (reflConEq ⊢Γ ∙ F≡H) E∷U in liftConvTerm (univ (Πⱼ F∷U ▹ G∷U) (Πⱼ H∷U ▹ E∷U′) (Π-cong x F<>H G<>E)); ≅-Σ-cong = λ x x₁ x₂ → liftConv (Σ-cong x x₁ x₂); ≅ₜ-Σ-cong = λ x x₁ x₂ → let _ , F∷U , H∷U = syntacticEqTerm (soundnessConv↑Term x₁) _ , G∷U , E∷U = syntacticEqTerm (soundnessConv↑Term x₂) ⊢Γ = wfTerm F∷U F<>H = univConv↑ x₁ G<>E = univConv↑ x₂ F≡H = soundnessConv↑ F<>H E∷U′ = stabilityTerm (reflConEq ⊢Γ ∙ F≡H) E∷U in liftConvTerm (univ (Σⱼ F∷U ▹ G∷U) (Σⱼ H∷U ▹ E∷U′) (Σ-cong x F<>H G<>E)); ≅ₜ-zerorefl = liftConvTerm ∘ᶠ zero-refl; ≅-suc-cong = liftConvTerm ∘ᶠ suc-cong; ≅-η-eq = λ x x₁ x₂ x₃ x₄ x₅ → liftConvTerm (η-eq x₁ x₂ x₃ x₄ x₅); ≅-Σ-η = λ x x₁ x₂ x₃ x₄ x₅ x₆ x₇ → (liftConvTerm (Σ-η x₂ x₃ x₄ x₅ x₆ x₇)); ~-var = ~-var; ~-app = ~-app; ~-fst = λ x x₁ x₂ → ~-fst x₂; ~-snd = λ x x₁ x₂ → ~-snd x₂; ~-natrec = ~-natrec; ~-Emptyrec = ~-Emptyrec }
{ "alphanum_fraction": 0.4926665897, "avg_line_length": 37.8122270742, "ext": "agda", "hexsha": "da670516203d42a3d2a5c9d12f7e8aa1077f5d59", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Vtec234/logrel-mltt", "max_forks_repo_path": "Definition/Conversion/EqRelInstance.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Vtec234/logrel-mltt", "max_issues_repo_path": "Definition/Conversion/EqRelInstance.agda", "max_line_length": 85, "max_stars_count": null, "max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Vtec234/logrel-mltt", "max_stars_repo_path": "Definition/Conversion/EqRelInstance.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3731, "size": 8659 }
{-# OPTIONS --safe #-} module Cubical.Categories.DistLatticeSheaf where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Structure open import Cubical.Foundations.Powerset open import Cubical.Data.Sigma open import Cubical.Relation.Binary.Poset open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing open import Cubical.Algebra.Semilattice open import Cubical.Algebra.Lattice open import Cubical.Algebra.DistLattice open import Cubical.Algebra.DistLattice.Basis open import Cubical.Categories.Category open import Cubical.Categories.Functor open import Cubical.Categories.NaturalTransformation open import Cubical.Categories.Limits.Pullback open import Cubical.Categories.Limits.Terminal open import Cubical.Categories.Instances.Functors open import Cubical.Categories.Instances.CommRings open import Cubical.Categories.Instances.Poset open import Cubical.Categories.Instances.Semilattice open import Cubical.Categories.Instances.Lattice open import Cubical.Categories.Instances.DistLattice private variable ℓ ℓ' ℓ'' : Level module _ (L : DistLattice ℓ) (C : Category ℓ' ℓ'') (T : Terminal C) where open Category hiding (_⋆_) open Functor open Order (DistLattice→Lattice L) open DistLatticeStr (snd L) open JoinSemilattice (Lattice→JoinSemilattice (DistLattice→Lattice L)) open MeetSemilattice (Lattice→MeetSemilattice (DistLattice→Lattice L)) using (∧≤RCancel ; ∧≤LCancel) open PosetStr (IndPoset .snd) hiding (_≤_) 𝟙 : ob C 𝟙 = terminalOb C T DLCat : Category ℓ ℓ DLCat = DistLatticeCategory L open Category DLCat -- C-valued presheaves on a distributive lattice DLPreSheaf : Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'') DLPreSheaf = Functor (DLCat ^op) C hom-∨₁ : (x y : L .fst) → DLCat [ x , x ∨l y ] hom-∨₁ = ∨≤RCancel -- TODO: isn't the fixity of the operators a bit weird? hom-∨₂ : (x y : L .fst) → DLCat [ y , x ∨l y ] hom-∨₂ = ∨≤LCancel hom-∧₁ : (x y : L .fst) → DLCat [ x ∧l y , x ] hom-∧₁ _ _ = (≤m→≤j _ _ (∧≤RCancel _ _)) hom-∧₂ : (x y : L .fst) → DLCat [ x ∧l y , y ] hom-∧₂ _ _ = (≤m→≤j _ _ (∧≤LCancel _ _)) {- x ∧ y ----→ y | | | sq | V V x ----→ x ∨ y -} sq : (x y : L .fst) → hom-∧₂ x y ⋆ hom-∨₂ x y ≡ hom-∧₁ x y ⋆ hom-∨₁ x y sq x y = is-prop-valued (x ∧l y) (x ∨l y) (hom-∧₂ x y ⋆ hom-∨₂ x y) (hom-∧₁ x y ⋆ hom-∨₁ x y) {- F(x ∨ y) ----→ F(y) | | | Fsq | V V F(x) ------→ F(x ∧ y) -} Fsq : (F : DLPreSheaf) (x y : L .fst) → F .F-hom (hom-∨₂ x y) ⋆⟨ C ⟩ F .F-hom (hom-∧₂ x y) ≡ F .F-hom (hom-∨₁ x y) ⋆⟨ C ⟩ F .F-hom (hom-∧₁ x y) Fsq F x y = sym (F-seq F (hom-∨₂ x y) (hom-∧₂ x y)) ∙∙ cong (F .F-hom) (sq x y) ∙∙ F-seq F (hom-∨₁ x y) (hom-∧₁ x y) isDLSheaf : (F : DLPreSheaf) → Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'') isDLSheaf F = (F-ob F 0l ≡ 𝟙) × ((x y : L .fst) → isPullback C _ _ _ (Fsq F x y)) -- TODO: might be better to define this as a record DLSheaf : Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'') DLSheaf = Σ[ F ∈ DLPreSheaf ] isDLSheaf F module Lemma1 (L : DistLattice ℓ) (C : Category ℓ' ℓ'') (T : Terminal C) (L' : ℙ (fst L)) (hB : IsBasis L L') where open Category hiding (_⋆_) open Functor open DistLatticeStr (snd L) open IsBasis hB isDLBasisSheaf : (F : DLPreSheaf L C T) → Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'') isDLBasisSheaf F = (F-ob F 0l ≡ 𝟙 L C T) × ((x y : L .fst) → x ∈ L' → y ∈ L' → isPullback C _ _ _ (Fsq L C T F x y)) DLBasisSheaf : Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'') DLBasisSheaf = Σ[ F ∈ DLPreSheaf L C T ] isDLBasisSheaf F -- To prove the statement we probably need that C is: -- 1. univalent -- 2. has finite limits (or pullbacks and a terminal object) -- 3. isGroupoid (C .ob) -- The last point is not strictly necessary, but we have to have some -- control over the hLevel as we want to write F(x) in terms of its -- basis cover which is information hidden under a prop truncation... -- Alternatively we just prove the statement for C = CommRingsCategory -- TODO: is unique existence expressed like this what we want? -- statement : (F' : DLBasisSheaf) -- → ∃![ F ∈ DLSheaf L C T ] ((x : fst L) → (x ∈ L') → CatIso C (F-ob (fst F) x) (F-ob (fst F') x)) -- TODO: if C is univalent the CatIso could be ≡? -- statement (F' , h1 , hPb) = ? -- It might be easier to prove all of these if we use the definition -- in terms of particular limits instead -- Scrap zone: -- -- Sublattices: upstream later -- record isSublattice (L' : ℙ (fst L)) : Type ℓ where -- field -- 1l-closed : 1l ∈ L' -- 0l-closed : 0l ∈ L' -- ∧l-closed : {x y : fst L} → x ∈ L' → y ∈ L' → x ∧l y ∈ L' -- ∨l-closed : {x y : fst L} → x ∈ L' → y ∈ L' → x ∨l y ∈ L' -- open isSublattice -- Sublattice : Type (ℓ-suc ℓ) -- Sublattice = Σ[ L' ∈ ℙ (fst L) ] isSublattice L' -- restrictDLSheaf : DLSheaf → Sublattice → DLSheaf -- F-ob (fst (restrictDLSheaf F (L' , HL'))) x = {!F-ob (fst F) x!} -- Hmm, not nice... -- F-hom (fst (restrictDLSheaf F L')) = {!!} -- F-id (fst (restrictDLSheaf F L')) = {!!} -- F-seq (fst (restrictDLSheaf F L')) = {!!} -- snd (restrictDLSheaf F L') = {!!}
{ "alphanum_fraction": 0.6010558069, "avg_line_length": 33.15, "ext": "agda", "hexsha": "c131a1de043da5f42236642d28b5ee3dd1ac9513", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lpw25/cubical", "max_forks_repo_path": "Cubical/Categories/DistLatticeSheaf.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lpw25/cubical", "max_issues_repo_path": "Cubical/Categories/DistLatticeSheaf.agda", "max_line_length": 161, "max_stars_count": null, "max_stars_repo_head_hexsha": "9f9ad9dad7404c75cf457f81ba5ac269afe1b1a7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lpw25/cubical", "max_stars_repo_path": "Cubical/Categories/DistLatticeSheaf.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2032, "size": 5304 }
open import Prelude module Implicits.Resolution.Scala.Type where open import Implicits.Syntax open import Implicits.Substitutions open import Implicits.Substitutions.Lemmas.Type open import Implicits.Substitutions.Type as TS using () -- predicate on types to limit them to non-rule types -- (as those don't exist in Scala currently) mutual data ScalaSimpleType {ν} : SimpleType ν → Set where tc : (c : ℕ) → ScalaSimpleType (tc c) tvar : (n : Fin ν) → ScalaSimpleType (tvar n) _→'_ : ∀ {a b} → ScalaType a → ScalaType b → ScalaSimpleType (a →' b) data ScalaType {ν} : Type ν → Set where simpl : ∀ {τ} → ScalaSimpleType {ν} τ → ScalaType (simpl τ) ∀' : ∀ {a} → ScalaType a → ScalaType (∀' a) data ScalaRule {ν} : Type ν → Set where idef : ∀ {a b} → ScalaType a → ScalaType b → ScalaRule (a ⇒ b) ival : ∀ {a} → ScalaType a → ScalaRule a ScalaICtx : ∀ {ν} → ICtx ν → Set ScalaICtx Δ = All ScalaRule Δ mutual weaken-scalastype : ∀ {ν} k {a : SimpleType (k N+ ν)} → ScalaSimpleType a → ScalaType (a TS.simple/ (TS.wk TS.↑⋆ k)) weaken-scalastype k (tc c) = simpl (tc c) weaken-scalastype k (tvar n) = Prelude.subst (λ z → ScalaType z) (sym $ var-/-wk-↑⋆ k n) (simpl (tvar (lift k suc n))) weaken-scalastype k (a →' b) = simpl ((weaken-scalatype k a) →' (weaken-scalatype k b)) weaken-scalatype : ∀ {ν} k {a : Type (k N+ ν)} → ScalaType a → ScalaType (a TS./ TS.wk TS.↑⋆ k) weaken-scalatype k (simpl {τ} x) = weaken-scalastype k x weaken-scalatype k (∀' p) = ∀' (weaken-scalatype (suc k) p) weaken-scalarule : ∀ {ν} k {a : Type (k N+ ν)} → ScalaRule a → ScalaRule (a TS./ (TS.wk TS.↑⋆ k)) weaken-scalarule k (idef x y) = idef (weaken-scalatype k x) (weaken-scalatype k y) weaken-scalarule k (ival x) = ival (weaken-scalatype k x) weaken-scalaictx : ∀ {ν} {Δ : ICtx ν} → ScalaICtx Δ → ScalaICtx (ictx-weaken Δ) weaken-scalaictx All.[] = All.[] weaken-scalaictx (px All.∷ ps) = weaken-scalarule zero px All.∷ weaken-scalaictx ps
{ "alphanum_fraction": 0.6387512389, "avg_line_length": 38.8076923077, "ext": "agda", "hexsha": "6753b04df613e9138bd888633c736b5565a8371a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Implicits/Resolution/Scala/Type.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Implicits/Resolution/Scala/Type.agda", "max_line_length": 97, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Implicits/Resolution/Scala/Type.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 714, "size": 2018 }
{- This file contains: - The inductive family 𝕁 can be constructed by iteratively applying pushouts; - The special cases of 𝕁 n for n = 0, 1 and 2; - Connectivity of inclusion maps. Easy, almost direct consequences of the very definition. -} {-# OPTIONS --safe #-} module Cubical.HITs.James.Inductive.PushoutFormula where open import Cubical.Foundations.Prelude open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Function open import Cubical.Foundations.Pointed hiding (pt) open import Cubical.Data.Nat open import Cubical.Algebra.NatSolver.Reflection open import Cubical.Data.Unit open import Cubical.Data.Sigma open import Cubical.HITs.Wedge open import Cubical.HITs.Pushout open import Cubical.HITs.Pushout.PushoutProduct open import Cubical.HITs.SequentialColimit open import Cubical.HITs.James.Inductive.Base renaming (𝕁ames to 𝕁amesContruction ; 𝕁ames∞ to 𝕁ames∞Contruction) open import Cubical.Homotopy.Connected private variable ℓ : Level module _ (X∙@(X , x₀) : Pointed ℓ) where private 𝕁ames = 𝕁amesContruction (X , x₀) 𝕁ames∞ = 𝕁ames∞Contruction (X , x₀) 𝕁amesPush : (n : ℕ) → Type ℓ 𝕁amesPush n = Pushout {A = 𝕁ames n} {B = X × 𝕁ames n} {C = 𝕁ames (1 + n)} (λ xs → x₀ , xs) incl X→𝕁ames1 : X → 𝕁ames 1 X→𝕁ames1 x = x ∷ [] 𝕁ames1→X : 𝕁ames 1 → X 𝕁ames1→X (x ∷ []) = x 𝕁ames1→X (incl []) = x₀ 𝕁ames1→X (unit [] i) = x₀ X→𝕁ames1→X : (x : X) → 𝕁ames1→X (X→𝕁ames1 x) ≡ x X→𝕁ames1→X x = refl 𝕁ames1→X→𝕁ames1 : (xs : 𝕁ames 1) → X→𝕁ames1 (𝕁ames1→X xs) ≡ xs 𝕁ames1→X→𝕁ames1 (x ∷ []) = refl 𝕁ames1→X→𝕁ames1 (incl []) i = unit [] (~ i) 𝕁ames1→X→𝕁ames1 (unit [] i) j = unit [] (i ∨ ~ j) leftMap : {n : ℕ} → 𝕁amesPush n → X × 𝕁ames (1 + n) leftMap (inl (x , xs)) = x , incl xs leftMap (inr ys) = x₀ , ys leftMap (push xs i) = x₀ , incl xs rightMap : {n : ℕ} → 𝕁amesPush n → 𝕁ames (1 + n) rightMap (inl (x , xs)) = x ∷ xs rightMap (inr ys) = ys rightMap (push xs i) = unit xs (~ i) PushMap : {n : ℕ} → Pushout {A = 𝕁amesPush n} leftMap rightMap → 𝕁ames (2 + n) PushMap (inl (x , xs)) = x ∷ xs PushMap (inr ys) = incl ys PushMap (push (inl (x , xs)) i) = incl∷ x xs (~ i) PushMap (push (inr ys) i) = unit ys (~ i) PushMap (push (push xs i) j) = coh xs (~ i) (~ j) PushInv : {n : ℕ} → 𝕁ames (2 + n) → Pushout {A = 𝕁amesPush n} leftMap rightMap PushInv (x ∷ xs) = inl (x , xs) PushInv (incl xs) = inr xs PushInv (incl∷ x xs i) = push (inl (x , xs)) (~ i) PushInv (unit xs i) = push (inr xs) (~ i) PushInv (coh xs i j) = push (push xs (~ i)) (~ j) PushInvMapInv : {n : ℕ}(xs : 𝕁ames (2 + n)) → PushMap (PushInv xs) ≡ xs PushInvMapInv (x ∷ xs) = refl PushInvMapInv (incl xs) = refl PushInvMapInv (incl∷ x xs i) = refl PushInvMapInv (unit xs i) = refl PushInvMapInv (coh xs i j) = refl PushMapInvMap : {n : ℕ}(xs : Pushout {A = 𝕁amesPush n} leftMap rightMap) → PushInv (PushMap xs) ≡ xs PushMapInvMap (inl (x , xs)) = refl PushMapInvMap (inr ys) = refl PushMapInvMap (push (inl (x , xs)) i) = refl PushMapInvMap (push (inr ys) i) = refl PushMapInvMap (push (push xs i) j) = refl -- The special case 𝕁ames 2 P0→X⋁X : 𝕁amesPush 0 → X∙ ⋁ X∙ P0→X⋁X (inl (x , [])) = inl x P0→X⋁X (inr (x ∷ [])) = inr x P0→X⋁X (inr (incl [])) = inr x₀ P0→X⋁X (inr (unit [] i)) = inr x₀ P0→X⋁X (push [] i) = push tt i X⋁X→P0 : X∙ ⋁ X∙ → 𝕁amesPush 0 X⋁X→P0 (inl x) = inl (x , []) X⋁X→P0 (inr x) = inr (x ∷ []) X⋁X→P0 (push tt i) = (push [] ∙ (λ i → inr (unit [] i))) i P0→X⋁X→P0 : (x : 𝕁amesPush 0) → X⋁X→P0 (P0→X⋁X x) ≡ x P0→X⋁X→P0 (inl (x , [])) = refl P0→X⋁X→P0 (inr (x ∷ [])) = refl P0→X⋁X→P0 (inr (incl [])) i = inr (unit [] (~ i)) P0→X⋁X→P0 (inr (unit [] i)) j = inr (unit [] (i ∨ ~ j)) P0→X⋁X→P0 (push [] i) j = hcomp (λ k → λ { (i = i0) → inl (x₀ , []) ; (i = i1) → inr (unit [] (~ j ∧ k)) ; (j = i0) → compPath-filler (push []) (λ i → inr (unit [] i)) k i ; (j = i1) → push [] i }) (push [] i) X⋁X→P0→X⋁X : (x : X∙ ⋁ X∙) → P0→X⋁X (X⋁X→P0 x) ≡ x X⋁X→P0→X⋁X (inl x) = refl X⋁X→P0→X⋁X (inr x) = refl X⋁X→P0→X⋁X (push tt i) j = hcomp (λ k → λ { (i = i0) → inl x₀ ; (i = i1) → inr x₀ ; (j = i0) → P0→X⋁X (compPath-filler (push []) refl k i) ; (j = i1) → push tt i }) (push tt i) P0≃X⋁X : 𝕁amesPush 0 ≃ X∙ ⋁ X∙ P0≃X⋁X = isoToEquiv (iso P0→X⋁X X⋁X→P0 X⋁X→P0→X⋁X P0→X⋁X→P0) -- The type family 𝕁ames can be constructed by iteratively using pushouts 𝕁ames0≃ : 𝕁ames 0 ≃ Unit 𝕁ames0≃ = isoToEquiv (iso (λ { [] → tt }) (λ { tt → [] }) (λ { tt → refl }) (λ { [] → refl })) 𝕁ames1≃ : 𝕁ames 1 ≃ X 𝕁ames1≃ = isoToEquiv (iso 𝕁ames1→X X→𝕁ames1 X→𝕁ames1→X 𝕁ames1→X→𝕁ames1) 𝕁ames2+n≃ : (n : ℕ) → 𝕁ames (2 + n) ≃ Pushout leftMap rightMap 𝕁ames2+n≃ n = isoToEquiv (iso PushInv PushMap PushMapInvMap PushInvMapInv) private left≃ : X × 𝕁ames 1 ≃ X × X left≃ = ≃-× (idEquiv _) 𝕁ames1≃ lComm : (x : 𝕁amesPush 0) → left≃ .fst (leftMap x) ≡ ⋁↪ (P0→X⋁X x) lComm (inl (x , [])) = refl lComm (inr (x ∷ [])) = refl lComm (inr (incl [])) = refl lComm (inr (unit [] i)) = refl lComm (push [] i) = refl rComm : (x : 𝕁amesPush 0) → 𝕁ames1≃ .fst (rightMap x) ≡ fold⋁ (P0→X⋁X x) rComm (inl (x , [])) = refl rComm (inr (x ∷ [])) = refl rComm (inr (incl [])) = refl rComm (inr (unit [] i)) = refl rComm (push [] i) = refl 𝕁ames2≃ : 𝕁ames 2 ≃ Pushout {A = X∙ ⋁ X∙} ⋁↪ fold⋁ 𝕁ames2≃ = compEquiv (𝕁ames2+n≃ 0) (pushoutEquiv _ _ _ _ P0≃X⋁X left≃ 𝕁ames1≃ (funExt lComm) (funExt rComm)) -- The leftMap can be seen as pushout-product private Unit×-≃ : {A : Type ℓ} → A ≃ Unit × A Unit×-≃ = isoToEquiv (invIso lUnit×Iso) pt : Unit → X pt _ = x₀ 𝕁amesPush' : (n : ℕ) → Type ℓ 𝕁amesPush' n = PushProd {X = Unit} {A = X} {Y = 𝕁ames n} {B = 𝕁ames (1 + n)} pt incl leftMap' : {n : ℕ} → 𝕁amesPush' n → X × 𝕁ames (1 + n) leftMap' = pt ×̂ incl 𝕁amesPush→Push' : (n : ℕ) → 𝕁amesPush n → 𝕁amesPush' n 𝕁amesPush→Push' n (inl x) = inr x 𝕁amesPush→Push' n (inr x) = inl (tt , x) 𝕁amesPush→Push' n (push x i) = push (tt , x) (~ i) 𝕁amesPush'→Push : (n : ℕ) → 𝕁amesPush' n → 𝕁amesPush n 𝕁amesPush'→Push n (inl (tt , x)) = inr x 𝕁amesPush'→Push n (inr x) = inl x 𝕁amesPush'→Push n (push (tt , x) i) = push x (~ i) 𝕁amesPush≃ : (n : ℕ) → 𝕁amesPush n ≃ 𝕁amesPush' n 𝕁amesPush≃ n = isoToEquiv (iso (𝕁amesPush→Push' n) (𝕁amesPush'→Push n) (λ { (inl x) → refl ; (inr x) → refl ; (push x i) → refl }) (λ { (inl x) → refl ; (inr x) → refl ; (push x i) → refl })) ≃𝕁ames1 : X ≃ 𝕁ames 1 ≃𝕁ames1 = isoToEquiv (iso X→𝕁ames1 𝕁ames1→X 𝕁ames1→X→𝕁ames1 X→𝕁ames1→X) ≃𝕁ames2+n : (n : ℕ) → Pushout leftMap rightMap ≃ 𝕁ames (2 + n) ≃𝕁ames2+n n = isoToEquiv (iso PushMap PushInv PushInvMapInv PushMapInvMap) -- The connectivity of inclusion private comp1 : (n : ℕ) → leftMap' ∘ 𝕁amesPush≃ n .fst ≡ leftMap comp1 n = funExt (λ { (inl x) → refl ; (inr x) → refl ; (push x i) → refl }) comp2 : (n : ℕ) → ≃𝕁ames2+n n .fst ∘ inr ≡ incl comp2 n = funExt (λ _ → refl) comp3 : ≃𝕁ames1 .fst ∘ pt ∘ 𝕁ames0≃ .fst ≡ incl comp3 i [] = unit [] (~ i) isConnIncl0 : (n : ℕ) → isConnected (1 + n) X → isConnectedFun n (incl {X∙ = X∙} {n = 0}) isConnIncl0 n conn = subst (isConnectedFun _) comp3 (isConnectedComp _ _ _ (isEquiv→isConnected _ (≃𝕁ames1 .snd) _) (isConnectedComp _ _ _ (isConnectedPoint _ conn _) (isEquiv→isConnected _ (𝕁ames0≃ .snd) _))) isConnIncl-ind : (m n k : ℕ) → isConnected (1 + m) X → isConnectedFun n (incl {X∙ = X∙} {n = k}) → isConnectedFun (m + n) (incl {X∙ = X∙} {n = 1 + k}) isConnIncl-ind m n k connX connf = subst (isConnectedFun _) (comp2 _) (isConnectedComp _ _ _ (isEquiv→isConnected _ (≃𝕁ames2+n k .snd) _) (inrConnected _ _ _ (subst (isConnectedFun _) (comp1 _) (isConnectedComp _ _ _ (isConnected×̂ (isConnectedPoint _ connX _) connf) (isEquiv→isConnected _ (𝕁amesPush≃ k .snd) _))))) nat-path : (n m k : ℕ) → (1 + (k + m)) · n ≡ k · n + (1 + m) · n nat-path = solve -- Connectivity results isConnectedIncl : (n : ℕ) → isConnected (1 + n) X → (m : ℕ) → isConnectedFun ((1 + m) · n) (incl {X∙ = X∙} {n = m}) isConnectedIncl n conn 0 = subst (λ d → isConnectedFun d _) (sym (+-zero n)) (isConnIncl0 n conn) isConnectedIncl n conn (suc m) = isConnIncl-ind _ _ _ conn (isConnectedIncl n conn m) isConnectedIncl>n : (n : ℕ) → isConnected (1 + n) X → (m k : ℕ) → isConnectedFun ((1 + m) · n) (incl {X∙ = X∙} {n = k + m}) isConnectedIncl>n n conn m k = isConnectedFunSubtr _ (k · n) _ (subst (λ d → isConnectedFun d (incl {X∙ = X∙} {n = k + m})) (nat-path n m k) (isConnectedIncl n conn (k + m))) private inl∞ : (n : ℕ) → 𝕁ames n → 𝕁ames∞ inl∞ _ = inl isConnectedInl : (n : ℕ) → isConnected (1 + n) X → (m : ℕ) → isConnectedFun ((1 + m) · n) (inl∞ m) isConnectedInl n conn m = isConnectedInl∞ _ _ _ (isConnectedIncl>n _ conn _)
{ "alphanum_fraction": 0.5663678583, "avg_line_length": 34.0404411765, "ext": "agda", "hexsha": "b535067891baa160d41d5acb217ede7c0a68b5a6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/HITs/James/Inductive/PushoutFormula.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/HITs/James/Inductive/PushoutFormula.agda", "max_line_length": 102, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/HITs/James/Inductive/PushoutFormula.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 4277, "size": 9259 }
module InstanceArgumentsBraces where record T' : Set where record T'' : Set where field a : T' testT'' : T'' testT'' = record { a = record {}}
{ "alphanum_fraction": 0.6418918919, "avg_line_length": 14.8, "ext": "agda", "hexsha": "6263ceffedba9acbc6527411bdef2baa8faa542e", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/InstanceArgumentsBraces.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/InstanceArgumentsBraces.agda", "max_line_length": 36, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/InstanceArgumentsBraces.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 44, "size": 148 }
module Prelude where -- Booleans data Bool : Set where tt : Bool ff : Bool _||_ : Bool -> Bool -> Bool tt || y = tt ff || y = y _&&_ : Bool -> Bool -> Bool tt && y = y ff && y = ff if_then_else : {A : Set} -> Bool -> A -> A -> A if tt then x else _ = x if ff then _ else y = y -- Eq "type class" record Eq (A : Set) : Set where field _==_ : A -> A -> Bool open Eq {{...}} public -- Function composition _∘_ : ∀ {x y z : Set} -> (y -> z) -> (x -> y) -> (x -> z) (f ∘ g) x = f (g x) -- Product type data _×_ (A B : Set) : Set where _,_ : A -> B -> A × B uncurry : ∀ {x y z : Set} -> (x -> y -> z) -> (x × y) -> z uncurry f (a , b) = f a b -- Lists data List (A : Set) : Set where [] : List A _::_ : A -> List A -> List A infixr 20 _::_ infixr 15 _++_ [_] : ∀ {A} -> A -> List A [ x ] = x :: [] _++_ : ∀ {A} -> List A -> List A -> List A [] ++ l = l (x :: xs) ++ l = x :: (xs ++ l) foldr : ∀ {A B : Set} -> (A -> B -> B) -> B -> List A -> B foldr f b [] = b foldr f b (x :: xs) = f x (foldr f b xs) map : ∀ {A B} -> (A -> B) -> List A -> List B map f [] = [] map f (x :: xs) = f x :: map f xs zip : ∀ {A B} -> List A -> List B -> List (A × B) zip [] _ = [] zip _ [] = [] zip (x :: xs) (y :: ys) = (x , y) :: zip xs ys -- Bottom type -- data ⊥ : Set where -- ¬ : Set -> Set -- ¬ A = A -> ⊥ -- Decidable propositions and relations: -- Rel : Set -> Set₁ -- Rel a = a -> a -> Set -- data Dec (P : Set) : Set where -- yes : (p : P) → Dec P -- no : (¬p : ¬ P) → Dec P -- Decidable : {a : Set} → Rel a → Set -- Decidable _∼_ = forall x y → Dec (x ∼ y) -- Natural numbers data ℕ : Set where zero : ℕ suc : ℕ -> ℕ
{ "alphanum_fraction": 0.4221218962, "avg_line_length": 20.367816092, "ext": "agda", "hexsha": "ef138dc7eeea1454c37561c0f090113be03ac680", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4af28af701b65b45900bba2d92a526ce44a3be63", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "tuura/selective-theory-agda", "max_forks_repo_path": "src/Prelude.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4af28af701b65b45900bba2d92a526ce44a3be63", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "tuura/selective-theory-agda", "max_issues_repo_path": "src/Prelude.agda", "max_line_length": 59, "max_stars_count": 7, "max_stars_repo_head_hexsha": "4af28af701b65b45900bba2d92a526ce44a3be63", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "tuura/selective-theory-agda", "max_stars_repo_path": "src/Prelude.agda", "max_stars_repo_stars_event_max_datetime": "2020-06-22T12:31:48.000Z", "max_stars_repo_stars_event_min_datetime": "2018-07-11T14:42:19.000Z", "num_tokens": 667, "size": 1772 }
open import OutsideIn.Prelude open import OutsideIn.X module OutsideIn.Inference(x : X) where import OutsideIn.TopLevel as TL import OutsideIn.TypeSchema as TS import OutsideIn.Expressions as E import OutsideIn.Environments as V import OutsideIn.Constraints as C import OutsideIn.Inference.Solver as S import OutsideIn.Inference.Prenexer as P import OutsideIn.Inference.Separator as SP import OutsideIn.Inference.ConstraintGen as CG open S(x) open P(x) open SP(x) open CG(x) open X(x) open TL(x) open TS(x) open E(x) open V(x) open C(x) private module PlusN-m {n} = Monad(PlusN-is-monad {n}) module QC-f = Functor(qconstraint-is-functor) module Ax-f = Functor(axiomscheme-is-functor) module Exp-f {ev}{s} = Functor(expression-is-functor₂ {ev}{s}) module TS-f {x} = Functor(type-schema-is-functor {x}) module Type-m = Monad(type-is-monad) module Type-f = Functor(type-is-functor) open Type-m data _,_►_ {x ev : Set}⦃ eq : Eq x ⦄(Q : AxiomScheme x)(Γ : Environment ev x) : Program ev x → Set where Empty : Q , Γ ► end BindA : ∀ {r}{m}{e : Expression ev (x ⨁ m) r}{prog : Program (Ⓢ ev) x}{τ}{C : Constraint (x ⨁ m) Extended}{Qc}{f}{f′} {C′ : Constraint ((x ⨁ m) ⨁ f) Flat}{r}{C′′ : SeparatedConstraint ((x ⨁ m) ⨁ f) r}{θ : (x ⨁ m) ⨁ f → Type ((x ⨁ m) ⨁ f′)} → TS-f.map (PlusN-m.unit {m}) ∘ Γ ► e ∶ τ ↝ C → C prenex: f , C′ → C′ separate: r , C′′ → let eq′ = PlusN-eq {m} eq in Ax-f.map (PlusN-m.unit {m}) Q , Qc , f solv► C′′ ↝ f′ , ε , θ → Q , ⟨ ∀′ m · Qc ⇒ τ ⟩, Γ ► prog → Q , Γ ► bind₂ m · e ∷ Qc ⇒ τ , prog Bind : ∀{r}{e : Expression ev x r}{prog : Program (Ⓢ ev) x}{C : Constraint (Ⓢ x) Extended}{f}{C′ : Constraint (x ⨁ suc f) Flat} {r′}{C′′ : SeparatedConstraint (x ⨁ suc f) r′}{n}{θ : x ⨁ suc f → Type (x ⨁ n)}{Qr} → TS-f.map (suc) ∘ Γ ► Exp-f.map suc e ∶ unit zero ↝ C → C prenex: f , C′ → C′ separate: r′ , C′′ → Q , ε , suc f solv► C′′ ↝ n , Qr , θ → Q , ⟨ ∀′ n · Qr ⇒ (θ (PlusN-m.unit {f} zero)) ⟩, Γ ► prog → Q , Γ ► bind₁ e , prog go : {ev tv : Set}(Q : AxiomScheme tv)(Γ : Environment ev tv) → (eq : Eq tv) → (p : Program ev tv) → Ⓢ (Q , Γ ► p) go Q Γ eq (end) = suc Empty go {ev}{tv} Q Γ eq (bind₁ e , prog) with genConstraint {ev}{Ⓢ tv} (TS-f.map suc ∘ Γ) (Exp-f.map suc e) (unit zero) ... | C , prf₁ with prenex C ... | f , C′ , prf₂ with separate C′ ... | r , C′′ , prf₃ with solver eq (suc f) Q ε C′′ ... | zero = zero ... | suc (m , Qr , θ , prf₄) with go Q (⟨ ∀′ m · Qr ⇒ (θ (PlusN-m.unit {f} zero)) ⟩, Γ) eq prog ... | zero = zero ... | suc prf₅ = suc (Bind prf₁ prf₂ prf₃ prf₄ prf₅) go Q Γ eq (bind₂ m · e ∷ Qc ⇒ τ , prog) with genConstraint (TS-f.map (PlusN-m.unit {m}) ∘ Γ) e τ ... | C , prf₁ with prenex C ... | f , C′ , prf₂ with separate C′ ... | r , C′′ , prf₃ with solver (PlusN-eq {m} eq) f (Ax-f.map (PlusN-m.unit {m}) Q) Qc C′′ ... | zero = zero ... | suc (f′ , Qr , θ , prf₄) with is-ε Qr ... | no _ = zero ... | yes prf₄′ with go Q (⟨ ∀′ m · Qc ⇒ τ ⟩, Γ) eq prog ... | zero = zero ... | suc prf₅ = let eq′ = PlusN-eq {m} eq in suc (BindA prf₁ prf₂ prf₃ (subst (λ Qr → Ax-f.map (PlusN-m.unit {m}) Q , Qc , f solv► C′′ ↝ f′ , Qr , θ ) prf₄′ prf₄) prf₅)
{ "alphanum_fraction": 0.5229172672, "avg_line_length": 42.3048780488, "ext": "agda", "hexsha": "87344e0290671a8d3445c332f3bb95d74e4ba55e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "liamoc/outside-in", "max_forks_repo_path": "OutsideIn/Inference.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "liamoc/outside-in", "max_issues_repo_path": "OutsideIn/Inference.agda", "max_line_length": 135, "max_stars_count": 2, "max_stars_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "liamoc/outside-in", "max_stars_repo_path": "OutsideIn/Inference.agda", "max_stars_repo_stars_event_max_datetime": "2020-11-19T14:30:07.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-14T05:22:15.000Z", "num_tokens": 1388, "size": 3469 }
postulate T : Set pre : (T → T) → T pre!_ : (T → T) → T _post : T → Set _+_ : T → T → T _>>=_ : T → (T → T) → T infix 5 pre!_ _>>=_ infix 4 _post infixl 3 _+_ -- add parens test-1a : Set test-1a = {!pre λ x → x!} post -- no parens test-1b : Set test-1b = {!pre (λ x → x)!} post -- add parens test-1c : Set test-1c = {!pre! λ x → x!} post -- no parens test-1d : Set test-1d = {!pre! (λ x → x)!} post -- add parens test-1e : T → Set test-1e e = {!e >>= λ x → x!} post -- no parens test-1f : T → Set test-1f e = {!e >>= (λ x → x)!} post -- add parens test-2a : Set test-2a = pre {!λ x → x!} post -- add parens test-2b : Set test-2b = pre! {!λ x → x!} post -- no parens test-3a : T test-3a = pre {!λ x → x!} -- no parens test-3b : T test-3b = pre! {!λ x → x!} -- no parens test-4a : T → T test-4a e = e + {!pre λ x → x!} -- no parens test-4b : T → T test-4b e = e + {!pre! λ x → x!}
{ "alphanum_fraction": 0.5049288061, "avg_line_length": 14.9672131148, "ext": "agda", "hexsha": "f7521c3cae7209c3c9e0f5712341838c6d627898", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/Issue2718.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/Issue2718.agda", "max_line_length": 36, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue2718.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 437, "size": 913 }
{-# OPTIONS --without-K #-} module sets where import sets.bool import sets.empty import sets.fin import sets.nat import sets.int import sets.unit import sets.vec import sets.list open import sets.properties open import sets.finite
{ "alphanum_fraction": 0.7854077253, "avg_line_length": 15.5333333333, "ext": "agda", "hexsha": "5d73650e6664f9eab8717bd050b87449ce9ff81e", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_path": "src/sets.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/sets.agda", "max_line_length": 27, "max_stars_count": 20, "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_path": "src/sets.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "num_tokens": 54, "size": 233 }
------------------------------------------------------------------------ -- Truncation, defined using a kind of Church encoding ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} -- Partly following the HoTT book. open import Equality module H-level.Truncation.Church {reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where open import Prelude open import Logical-equivalence using (_⇔_) open import Bijection eq as Bijection using (_↔_) open Derived-definitions-and-properties eq open import Embedding eq hiding (_∘_) open import Equality.Decidable-UIP eq import Equality.Groupoid eq as EG open import Equivalence eq as Eq using (_≃_; Is-equivalence) import Equivalence.Half-adjoint eq as HA open import Function-universe eq as F hiding (_∘_) open import Groupoid eq open import H-level eq as H-level open import H-level.Closure eq open import Nat eq open import Preimage eq as Preimage using (_⁻¹_) open import Surjection eq using (_↠_; Split-surjective) -- Truncation. ∥_∥ : ∀ {a} → Type a → ℕ → (ℓ : Level) → Type (a ⊔ lsuc ℓ) ∥ A ∥ n ℓ = (P : Type ℓ) → H-level n P → (A → P) → P -- If A is inhabited, then ∥ A ∥ n ℓ is also inhabited. ∣_∣ : ∀ {n ℓ a} {A : Type a} → A → ∥ A ∥ n ℓ ∣ x ∣ = λ _ _ f → f x -- A special case of ∣_∣. ∣_∣₁ : ∀ {ℓ a} {A : Type a} → A → ∥ A ∥ 1 ℓ ∣ x ∣₁ = ∣_∣ {n = 1} x -- The truncation produces types of the right h-level (assuming -- extensionality). truncation-has-correct-h-level : ∀ n {ℓ a} {A : Type a} → Extensionality (a ⊔ lsuc ℓ) (a ⊔ ℓ) → H-level n (∥ A ∥ n ℓ) truncation-has-correct-h-level n {ℓ} {a} ext = Π-closure (lower-extensionality a lzero ext) n λ _ → Π-closure (lower-extensionality (a ⊔ lsuc ℓ) lzero ext) n λ h → Π-closure (lower-extensionality (lsuc ℓ) a ext) n λ _ → h -- Primitive "recursion" for truncated types. rec : ∀ n {a b} {A : Type a} {B : Type b} → H-level n B → (A → B) → ∥ A ∥ n b → B rec _ h f x = x _ h f private -- The function rec computes in the right way. rec-∣∣ : ∀ {n a b} {A : Type a} {B : Type b} (h : H-level n B) (f : A → B) (x : A) → rec _ h f ∣ x ∣ ≡ f x rec-∣∣ _ _ _ = refl _ -- Map function. ∥∥-map : ∀ n {a b ℓ} {A : Type a} {B : Type b} → (A → B) → ∥ A ∥ n ℓ → ∥ B ∥ n ℓ ∥∥-map _ f x = λ P h g → x P h (g ∘ f) -- The truncation operator preserves logical equivalences. ∥∥-cong-⇔ : ∀ {n a b ℓ} {A : Type a} {B : Type b} → A ⇔ B → ∥ A ∥ n ℓ ⇔ ∥ B ∥ n ℓ ∥∥-cong-⇔ A⇔B = record { to = ∥∥-map _ (_⇔_.to A⇔B) ; from = ∥∥-map _ (_⇔_.from A⇔B) } -- The truncation operator preserves bijections (assuming -- extensionality). ∥∥-cong : ∀ {k n a b ℓ} {A : Type a} {B : Type b} → Extensionality (a ⊔ b ⊔ lsuc ℓ) (a ⊔ b ⊔ ℓ) → A ↔[ k ] B → ∥ A ∥ n ℓ ↔[ k ] ∥ B ∥ n ℓ ∥∥-cong {k} {n} {a} {b} {ℓ} ext A↝B = from-bijection (record { surjection = record { logical-equivalence = record { to = ∥∥-map _ (_↔_.to A↔B) ; from = ∥∥-map _ (_↔_.from A↔B) } ; right-inverse-of = lemma (lower-extensionality a a ext) A↔B } ; left-inverse-of = lemma (lower-extensionality b b ext) (inverse A↔B) }) where A↔B = from-isomorphism A↝B lemma : ∀ {c d} {C : Type c} {D : Type d} → Extensionality (d ⊔ lsuc ℓ) (d ⊔ ℓ) → (C↔D : C ↔ D) (∥d∥ : ∥ D ∥ n ℓ) → ∥∥-map _ (_↔_.to C↔D) (∥∥-map _ (_↔_.from C↔D) ∥d∥) ≡ ∥d∥ lemma {d = d} ext C↔D ∥d∥ = apply-ext (lower-extensionality d lzero ext) λ P → apply-ext (lower-extensionality _ lzero ext) λ h → apply-ext (lower-extensionality (lsuc ℓ) d ext) λ g → ∥d∥ P h (g ∘ _↔_.to C↔D ∘ _↔_.from C↔D) ≡⟨ cong (λ f → ∥d∥ P h (g ∘ f)) $ apply-ext (lower-extensionality (lsuc ℓ) ℓ ext) (_↔_.right-inverse-of C↔D) ⟩∎ ∥d∥ P h g ∎ -- The universe level can be decreased (unless it is zero). with-lower-level : ∀ ℓ₁ {ℓ₂ a} n {A : Type a} → ∥ A ∥ n (ℓ₁ ⊔ ℓ₂) → ∥ A ∥ n ℓ₂ with-lower-level ℓ₁ _ x = λ P h f → lower (x (↑ ℓ₁ P) (↑-closure _ h) (lift ∘ f)) private -- The function with-lower-level computes in the right way. with-lower-level-∣∣ : ∀ {ℓ₁ ℓ₂ a n} {A : Type a} (x : A) → with-lower-level ℓ₁ {ℓ₂ = ℓ₂} n ∣ x ∣ ≡ ∣ x ∣ with-lower-level-∣∣ _ = refl _ -- ∥_∥ is downwards closed in the h-level. downwards-closed : ∀ {m n a ℓ} {A : Type a} → n ≤ m → ∥ A ∥ m ℓ → ∥ A ∥ n ℓ downwards-closed n≤m x = λ P h f → x P (H-level.mono n≤m h) f private -- The function downwards-closed computes in the right way. downwards-closed-∣∣ : ∀ {m n a ℓ} {A : Type a} (n≤m : n ≤ m) (x : A) → downwards-closed {ℓ = ℓ} n≤m ∣ x ∣ ≡ ∣ x ∣ downwards-closed-∣∣ _ _ = refl _ -- The function rec can be used to define a kind of dependently typed -- eliminator for the propositional truncation (assuming -- extensionality). prop-elim : ∀ {ℓ a p} {A : Type a} → Extensionality (lsuc ℓ ⊔ a) (ℓ ⊔ a ⊔ p) → (P : ∥ A ∥ 1 ℓ → Type p) → (∀ x → Is-proposition (P x)) → ((x : A) → P ∣ x ∣₁) → ∥ A ∥ 1 (lsuc ℓ ⊔ a ⊔ p) → (x : ∥ A ∥ 1 ℓ) → P x prop-elim {ℓ} {a} {p} ext P P-prop f = rec 1 (Π-closure (lower-extensionality lzero (ℓ ⊔ a) ext) 1 P-prop) (λ x _ → subst P (truncation-has-correct-h-level 1 (lower-extensionality lzero p ext) _ _) (f x)) abstract -- The eliminator gives the right result, up to propositional -- equality, when applied to ∣ x ∣ and ∣ x ∣. prop-elim-∣∣ : ∀ {ℓ a p} {A : Type a} (ext : Extensionality (lsuc ℓ ⊔ a) (ℓ ⊔ a ⊔ p)) (P : ∥ A ∥ 1 ℓ → Type p) (P-prop : ∀ x → Is-proposition (P x)) (f : (x : A) → P ∣ x ∣₁) (x : A) → prop-elim ext P P-prop f ∣ x ∣₁ ∣ x ∣₁ ≡ f x prop-elim-∣∣ _ _ P-prop _ _ = P-prop _ _ _ -- Nested truncations can sometimes be flattened. flatten↠ : ∀ {m n a ℓ} {A : Type a} → Extensionality (a ⊔ lsuc ℓ) (a ⊔ ℓ) → m ≤ n → ∥ ∥ A ∥ m ℓ ∥ n (a ⊔ lsuc ℓ) ↠ ∥ A ∥ m ℓ flatten↠ ext m≤n = record { logical-equivalence = record { to = rec _ (H-level.mono m≤n (truncation-has-correct-h-level _ ext)) F.id ; from = ∣_∣ } ; right-inverse-of = refl } flatten↔ : ∀ {a ℓ} {A : Type a} → Extensionality (lsuc (a ⊔ lsuc ℓ)) (lsuc (a ⊔ lsuc ℓ)) → (∥ ∥ A ∥ 1 ℓ ∥ 1 (a ⊔ lsuc ℓ) → ∥ ∥ A ∥ 1 ℓ ∥ 1 (lsuc (a ⊔ lsuc ℓ))) → ∥ ∥ A ∥ 1 ℓ ∥ 1 (a ⊔ lsuc ℓ) ↔ ∥ A ∥ 1 ℓ flatten↔ ext resize = record { surjection = flatten↠ {m = 1} ext′ ≤-refl ; left-inverse-of = λ x → prop-elim ext (λ x → ∣ rec 1 (H-level.mono (≤-refl {n = 1}) (truncation-has-correct-h-level 1 ext′)) F.id x ∣₁ ≡ x) (λ _ → ⇒≡ 1 $ truncation-has-correct-h-level 1 (lower-extensionality lzero _ ext)) (λ _ → refl _) (resize x) x } where ext′ = lower-extensionality _ _ ext -- Surjectivity. -- -- I'm not quite sure what the universe level of the truncation should -- be, so I've included it as a parameter. Surjective : ∀ {a b} ℓ {A : Type a} {B : Type b} → (A → B) → Type (a ⊔ b ⊔ lsuc ℓ) Surjective ℓ f = ∀ b → ∥ f ⁻¹ b ∥ 1 ℓ -- The property Surjective ℓ f is a proposition (assuming -- extensionality). Surjective-propositional : ∀ {ℓ a b} {A : Type a} {B : Type b} {f : A → B} → Extensionality (a ⊔ b ⊔ lsuc ℓ) (a ⊔ b ⊔ lsuc ℓ) → Is-proposition (Surjective ℓ f) Surjective-propositional {ℓ} {a} ext = Π-closure (lower-extensionality (a ⊔ lsuc ℓ) lzero ext) 1 λ _ → truncation-has-correct-h-level 1 (lower-extensionality lzero (lsuc ℓ) ext) -- Split surjective functions are surjective. Split-surjective→Surjective : ∀ {a b ℓ} {A : Type a} {B : Type b} {f : A → B} → Split-surjective f → Surjective ℓ f Split-surjective→Surjective s = λ b → ∣ s b ∣₁ -- Being both surjective and an embedding is equivalent to being an -- equivalence. -- -- This is Corollary 4.6.4 from the first edition of the HoTT book -- (the proof is perhaps not quite identical). surjective×embedding≃equivalence : ∀ {a b} ℓ {A : Type a} {B : Type b} {f : A → B} → Extensionality (lsuc (a ⊔ b ⊔ ℓ)) (lsuc (a ⊔ b ⊔ ℓ)) → (Surjective (a ⊔ b ⊔ ℓ) f × Is-embedding f) ≃ Is-equivalence f surjective×embedding≃equivalence {a} {b} ℓ {f = f} ext = Eq.⇔→≃ (×-closure 1 (Surjective-propositional ext) (Is-embedding-propositional (lower-extensionality _ _ ext))) (Eq.propositional (lower-extensionality _ _ ext) _) (λ (is-surj , is-emb) → _⇔_.from HA.Is-equivalence⇔Is-equivalence-CP $ λ y → $⟨ is-surj y ⟩ ∥ f ⁻¹ y ∥ 1 (a ⊔ b ⊔ ℓ) ↝⟨ with-lower-level ℓ 1 ⟩ ∥ f ⁻¹ y ∥ 1 (a ⊔ b) ↝⟨ rec 1 (Contractible-propositional (lower-extensionality _ _ ext)) (f ⁻¹ y ↝⟨ propositional⇒inhabited⇒contractible (embedding→⁻¹-propositional is-emb y) ⟩□ Contractible (f ⁻¹ y) □) ⟩□ Contractible (f ⁻¹ y) □) (λ is-eq → (λ y → $⟨ HA.inverse is-eq y , HA.right-inverse-of is-eq y ⟩ f ⁻¹ y ↝⟨ ∣_∣₁ ⟩□ ∥ f ⁻¹ y ∥ 1 (a ⊔ b ⊔ ℓ) □) , ($⟨ is-eq ⟩ Is-equivalence f ↝⟨ Embedding.is-embedding ∘ from-equivalence ∘ Eq.⟨ _ ,_⟩ ⟩□ Is-embedding f □)) -- If the underlying type has a certain h-level, then there is a split -- surjection from corresponding truncations (if they are "big" -- enough) to the type itself. ∥∥↠ : ∀ ℓ {a} {A : Type a} n → H-level n A → ∥ A ∥ n (a ⊔ ℓ) ↠ A ∥∥↠ ℓ _ h = record { logical-equivalence = record { to = rec _ h F.id ∘ with-lower-level ℓ _ ; from = ∣_∣ } ; right-inverse-of = refl } -- If the underlying type is a proposition, then propositional -- truncations of the type are isomorphic to the type itself (if they -- are "big" enough, and assuming extensionality). ∥∥↔ : ∀ ℓ {a} {A : Type a} → Extensionality (lsuc (a ⊔ ℓ)) (a ⊔ ℓ) → Is-proposition A → ∥ A ∥ 1 (a ⊔ ℓ) ↔ A ∥∥↔ ℓ ext A-prop = record { surjection = ∥∥↠ ℓ 1 A-prop ; left-inverse-of = λ _ → truncation-has-correct-h-level 1 ext _ _ } -- A simple isomorphism involving propositional truncation. ∥∥×↔ : ∀ {ℓ a} {A : Type a} → Extensionality (lsuc ℓ ⊔ a) (ℓ ⊔ a) → ∥ A ∥ 1 ℓ × A ↔ A ∥∥×↔ {ℓ} {A = A} ext = ∥ A ∥ 1 ℓ × A ↝⟨ ×-comm ⟩ A × ∥ A ∥ 1 ℓ ↝⟨ (drop-⊤-right λ a → _⇔_.to contractible⇔↔⊤ $ propositional⇒inhabited⇒contractible (truncation-has-correct-h-level 1 ext) ∣ a ∣₁) ⟩□ A □ -- A variant of ∥∥×↔, introduced to ensure that the right-inverse-of -- proof is, by definition, simple (see right-inverse-of-∥∥×≃ below). ∥∥×≃ : ∀ {ℓ a} {A : Type a} → Extensionality (lsuc ℓ ⊔ a) (ℓ ⊔ a) → (∥ A ∥ 1 ℓ × A) ≃ A ∥∥×≃ ext = Eq.↔→≃ proj₂ (λ x → ∣ x ∣₁ , x) refl (λ _ → cong (_, _) (truncation-has-correct-h-level 1 ext _ _)) private right-inverse-of-∥∥×≃ : ∀ {ℓ a} {A : Type a} (ext : Extensionality (lsuc ℓ ⊔ a) (ℓ ⊔ a)) (x : A) → _≃_.right-inverse-of (∥∥×≃ {ℓ = ℓ} ext) x ≡ refl x right-inverse-of-∥∥×≃ _ x = refl (refl x) -- ∥_∥ commutes with _×_ (assuming extensionality and a resizing -- function for the propositional truncation). ∥∥×∥∥↔∥×∥ : ∀ {a b} ℓ {A : Type a} {B : Type b} → Extensionality (lsuc (a ⊔ b ⊔ ℓ)) (a ⊔ b ⊔ ℓ) → (∀ {x} {X : Type x} → ∥ X ∥ 1 (a ⊔ b ⊔ ℓ) → ∥ X ∥ 1 (lsuc (a ⊔ b ⊔ ℓ))) → let ℓ′ = a ⊔ b ⊔ ℓ in (∥ A ∥ 1 ℓ′ × ∥ B ∥ 1 ℓ′) ↔ ∥ A × B ∥ 1 ℓ′ ∥∥×∥∥↔∥×∥ _ ext resize = record { surjection = record { logical-equivalence = record { from = λ p → ∥∥-map 1 proj₁ p , ∥∥-map 1 proj₂ p ; to = λ { (x , y) → rec 1 (truncation-has-correct-h-level 1 ext) (λ x → rec 1 (truncation-has-correct-h-level 1 ext) (λ y → ∣ x , y ∣₁) (resize y)) (resize x) } } ; right-inverse-of = λ _ → truncation-has-correct-h-level 1 ext _ _ } ; left-inverse-of = λ _ → ×-closure 1 (truncation-has-correct-h-level 1 ext) (truncation-has-correct-h-level 1 ext) _ _ } -- If A is merely inhabited (at a certain level), then the -- propositional truncation of A (at the same level) is isomorphic to -- the unit type (assuming extensionality). inhabited⇒∥∥↔⊤ : ∀ {ℓ a} {A : Type a} → Extensionality (lsuc ℓ ⊔ a) (ℓ ⊔ a) → ∥ A ∥ 1 ℓ → ∥ A ∥ 1 ℓ ↔ ⊤ inhabited⇒∥∥↔⊤ ext ∥a∥ = _⇔_.to contractible⇔↔⊤ $ propositional⇒inhabited⇒contractible (truncation-has-correct-h-level 1 ext) ∥a∥ -- If A is not inhabited, then the propositional truncation of A is -- isomorphic to the empty type. not-inhabited⇒∥∥↔⊥ : ∀ {ℓ₁ ℓ₂ a} {A : Type a} → ¬ A → ∥ A ∥ 1 ℓ₁ ↔ ⊥ {ℓ = ℓ₂} not-inhabited⇒∥∥↔⊥ {A = A} = ¬ A ↝⟨ (λ ¬a ∥a∥ → rec 1 ⊥-propositional ¬a (with-lower-level _ 1 ∥a∥)) ⟩ ¬ ∥ A ∥ 1 _ ↝⟨ inverse ∘ Bijection.⊥↔uninhabited ⟩□ ∥ A ∥ 1 _ ↔ ⊥ □ -- The following two results come from "Generalizations of Hedberg's -- Theorem" by Kraus, Escardó, Coquand and Altenkirch. -- Types with constant endofunctions are "h-stable" (meaning that -- "mere inhabitance" implies inhabitance). constant-endofunction⇒h-stable : ∀ {a} {A : Type a} {f : A → A} → Constant f → ∥ A ∥ 1 a → A constant-endofunction⇒h-stable {a} {A} {f} c = ∥ A ∥ 1 a ↝⟨ rec 1 (fixpoint-lemma f c) (λ x → f x , c (f x) x) ⟩ (∃ λ (x : A) → f x ≡ x) ↝⟨ proj₁ ⟩□ A □ -- Having a constant endofunction is logically equivalent to being -- h-stable (assuming extensionality). constant-endofunction⇔h-stable : ∀ {a} {A : Type a} → Extensionality (lsuc a) a → (∃ λ (f : A → A) → Constant f) ⇔ (∥ A ∥ 1 a → A) constant-endofunction⇔h-stable ext = record { to = λ { (_ , c) → constant-endofunction⇒h-stable c } ; from = λ f → f ∘ ∣_∣₁ , λ x y → f ∣ x ∣₁ ≡⟨ cong f $ truncation-has-correct-h-level 1 ext _ _ ⟩∎ f ∣ y ∣₁ ∎ } -- The following three lemmas were communicated to me by Nicolai -- Kraus. (In slightly different form.) They are closely related to -- Lemma 2.1 in his paper "The General Universal Property of the -- Propositional Truncation". -- A variant of ∥∥×≃. drop-∥∥ : ∀ ℓ {a b} {A : Type a} {B : A → Type b} → Extensionality (lsuc (a ⊔ ℓ)) (a ⊔ b ⊔ ℓ) → (∥ A ∥ 1 (a ⊔ ℓ) → ∀ x → B x) ↔ (∀ x → B x) drop-∥∥ ℓ {a} {b} {A} {B} ext = (∥ A ∥ 1 _ → ∀ x → B x) ↝⟨ inverse currying ⟩ ((p : ∥ A ∥ 1 _ × A) → B (proj₂ p)) ↝⟨ Π-cong (lower-extensionality lzero (a ⊔ ℓ) ext) (∥∥×≃ (lower-extensionality lzero b ext)) (λ _ → F.id) ⟩□ (∀ x → B x) □ -- Another variant of ∥∥×≃. push-∥∥ : ∀ ℓ {a b c} {A : Type a} {B : A → Type b} {C : (∀ x → B x) → Type c} → Extensionality (lsuc (a ⊔ ℓ)) (a ⊔ b ⊔ c ⊔ ℓ) → (∥ A ∥ 1 (a ⊔ ℓ) → ∃ λ (f : ∀ x → B x) → C f) ↔ (∃ λ (f : ∀ x → B x) → ∥ A ∥ 1 (a ⊔ ℓ) → C f) push-∥∥ ℓ {a} {b} {c} {A} {B} {C} ext = (∥ A ∥ 1 _ → ∃ λ (f : ∀ x → B x) → C f) ↝⟨ ΠΣ-comm ⟩ (∃ λ (f : ∥ A ∥ 1 _ → ∀ x → B x) → ∀ ∥x∥ → C (f ∥x∥)) ↝⟨ Σ-cong (drop-∥∥ ℓ (lower-extensionality lzero c ext)) (λ f → ∀-cong (lower-extensionality lzero (a ⊔ b ⊔ ℓ) ext) λ ∥x∥ → ≡⇒↝ _ $ cong C $ apply-ext (lower-extensionality _ (a ⊔ c ⊔ ℓ) ext) λ x → f ∥x∥ x ≡⟨ cong (λ ∥x∥ → f ∥x∥ x) $ truncation-has-correct-h-level 1 (lower-extensionality lzero (b ⊔ c) ext) _ _ ⟩ f ∣ x ∣₁ x ≡⟨ sym $ subst-refl _ _ ⟩∎ subst B (refl x) (f ∣ x ∣₁ x) ∎) ⟩□ (∃ λ (f : ∀ x → B x) → ∥ A ∥ 1 _ → C (λ x → f x)) □ -- This is an instance of a variant of Lemma 2.1 from "The General -- Universal Property of the Propositional Truncation" by Kraus. drop-∥∥₃ : ∀ ℓ {a b c d} {A : Type a} {B : A → Type b} {C : A → (∀ x → B x) → Type c} {D : A → (f : ∀ x → B x) → (∀ x → C x f) → Type d} → Extensionality (lsuc (a ⊔ ℓ)) (a ⊔ b ⊔ c ⊔ d ⊔ ℓ) → (∥ A ∥ 1 (a ⊔ ℓ) → ∃ λ (f : ∀ x → B x) → ∃ λ (g : ∀ x → C x f) → ∀ x → D x f g) ↔ (∃ λ (f : ∀ x → B x) → ∃ λ (g : ∀ x → C x f) → ∀ x → D x f g) drop-∥∥₃ ℓ {b = b} {c} {A = A} {B} {C} {D} ext = (∥ A ∥ 1 _ → ∃ λ (f : ∀ x → B x) → ∃ λ (g : ∀ x → C x f) → ∀ x → D x f g) ↝⟨ push-∥∥ ℓ ext ⟩ (∃ λ (f : ∀ x → B x) → ∥ A ∥ 1 _ → ∃ λ (g : ∀ x → C x f) → ∀ x → D x f g) ↝⟨ (∃-cong λ _ → push-∥∥ ℓ (lower-extensionality lzero b ext)) ⟩ (∃ λ (f : ∀ x → B x) → ∃ λ (g : ∀ x → C x f) → ∥ A ∥ 1 _ → ∀ x → D x f g) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → drop-∥∥ ℓ (lower-extensionality lzero (b ⊔ c) ext)) ⟩□ (∃ λ (f : ∀ x → B x) → ∃ λ (g : ∀ x → C x f) → ∀ x → D x f g) □ -- Having a coherently constant function into a groupoid is equivalent -- to having a function from a propositionally truncated type into the -- groupoid (assuming extensionality). This result is Proposition 2.3 -- in "The General Universal Property of the Propositional Truncation" -- by Kraus. Coherently-constant : ∀ {a b} {A : Type a} {B : Type b} → (A → B) → Type (a ⊔ b) Coherently-constant f = ∃ λ (c : Constant f) → ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃ coherently-constant-function≃∥inhabited∥⇒inhabited : ∀ {a b} ℓ {A : Type a} {B : Type b} → Extensionality (lsuc (a ⊔ b ⊔ ℓ)) (a ⊔ b ⊔ ℓ) → H-level 3 B → (∃ λ (f : A → B) → Coherently-constant f) ≃ (∥ A ∥ 1 (a ⊔ b ⊔ ℓ) → B) coherently-constant-function≃∥inhabited∥⇒inhabited {a} {b} ℓ {A} {B} ext B-groupoid = (∃ λ (f : A → B) → Coherently-constant f) ↔⟨ inverse $ drop-∥∥₃ (b ⊔ ℓ) ext ⟩ (∥ A ∥ 1 ℓ′ → ∃ λ (f : A → B) → Coherently-constant f) ↝⟨ ∀-cong (lower-extensionality lzero ℓ ext) (inverse ∘ equivalence₂) ⟩□ (∥ A ∥ 1 ℓ′ → B) □ where ℓ′ = a ⊔ b ⊔ ℓ rearrangement-lemma = λ a₀ → (∃ λ (f₁ : B) → ∃ λ (f : A → B) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∃ λ (c : Constant f) → ∃ λ (d₁ : ∀ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡ c₁ a₁) → ∃ λ (c₂ : f a₀ ≡ f₁) → ∃ λ (d₃ : trans (c a₀ a₀) (c₁ a₀) ≡ c₂) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → (a : A) → trans (c a₀ a) (c₁ a) ≡ c₂) ↝⟨ ∃-comm ⟩ (∃ λ (f : A → B) → ∃ λ (f₁ : B) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∃ λ (c : Constant f) → ∃ λ (d₁ : ∀ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡ c₁ a₁) → ∃ λ (c₂ : f a₀ ≡ f₁) → ∃ λ (d₃ : trans (c a₀ a₀) (c₁ a₀) ≡ c₂) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → (a : A) → trans (c a₀ a) (c₁ a) ≡ c₂) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-comm) ⟩ (∃ λ (f : A → B) → ∃ λ (f₁ : B) → ∃ λ (c : Constant f) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∃ λ (d₁ : ∀ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡ c₁ a₁) → ∃ λ (c₂ : f a₀ ≡ f₁) → ∃ λ (d₃ : trans (c a₀ a₀) (c₁ a₀) ≡ c₂) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → (a : A) → trans (c a₀ a) (c₁ a) ≡ c₂) ↝⟨ (∃-cong λ _ → ∃-comm) ⟩ (∃ λ (f : A → B) → ∃ λ (c : Constant f) → ∃ λ (f₁ : B) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∃ λ (d₁ : ∀ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡ c₁ a₁) → ∃ λ (c₂ : f a₀ ≡ f₁) → ∃ λ (d₃ : trans (c a₀ a₀) (c₁ a₀) ≡ c₂) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → (a : A) → trans (c a₀ a) (c₁ a) ≡ c₂) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-comm) ⟩ (∃ λ (f : A → B) → ∃ λ (c : Constant f) → ∃ λ (f₁ : B) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∃ λ (d₁ : ∀ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡ c₁ a₁) → ∃ λ (c₂ : f a₀ ≡ f₁) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → ∃ λ (d₃ : trans (c a₀ a₀) (c₁ a₀) ≡ c₂) → (a : A) → trans (c a₀ a) (c₁ a) ≡ c₂) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-comm) ⟩ (∃ λ (f : A → B) → ∃ λ (c : Constant f) → ∃ λ (f₁ : B) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∃ λ (d₁ : ∀ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡ c₁ a₁) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → ∃ λ (c₂ : f a₀ ≡ f₁) → ∃ λ (d₃ : trans (c a₀ a₀) (c₁ a₀) ≡ c₂) → (a : A) → trans (c a₀ a) (c₁ a) ≡ c₂) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-comm) ⟩ (∃ λ (f : A → B) → ∃ λ (c : Constant f) → ∃ λ (f₁ : B) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → ∃ λ (d₁ : ∀ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡ c₁ a₁) → ∃ λ (c₂ : f a₀ ≡ f₁) → ∃ λ (d₃ : trans (c a₀ a₀) (c₁ a₀) ≡ c₂) → (a : A) → trans (c a₀ a) (c₁ a) ≡ c₂) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-comm) ⟩ (∃ λ (f : A → B) → ∃ λ (c : Constant f) → ∃ λ (f₁ : B) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∃ λ (d₁ : ∀ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡ c₁ a₁) → ∃ λ (c₂ : f a₀ ≡ f₁) → ∃ λ (d₃ : trans (c a₀ a₀) (c₁ a₀) ≡ c₂) → (a : A) → trans (c a₀ a) (c₁ a) ≡ c₂) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-comm) ⟩ (∃ λ (f : A → B) → ∃ λ (c : Constant f) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → ∃ λ (f₁ : B) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∃ λ (d₁ : ∀ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡ c₁ a₁) → ∃ λ (c₂ : f a₀ ≡ f₁) → ∃ λ (d₃ : trans (c a₀ a₀) (c₁ a₀) ≡ c₂) → (a : A) → trans (c a₀ a) (c₁ a) ≡ c₂) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-comm) ⟩ (∃ λ (f : A → B) → ∃ λ (c : Constant f) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → ∃ λ (f₁ : B) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∃ λ (c₂ : f a₀ ≡ f₁) → ∃ λ (d₁ : ∀ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡ c₁ a₁) → ∃ λ (d₃ : trans (c a₀ a₀) (c₁ a₀) ≡ c₂) → (a : A) → trans (c a₀ a) (c₁ a) ≡ c₂) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-comm) ⟩ (∃ λ (f : A → B) → ∃ λ (c : Constant f) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → ∃ λ (f₁ : B) → ∃ λ (c₂ : f a₀ ≡ f₁) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∃ λ (d₁ : ∀ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡ c₁ a₁) → ∃ λ (d₃ : trans (c a₀ a₀) (c₁ a₀) ≡ c₂) → (a : A) → trans (c a₀ a) (c₁ a) ≡ c₂) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ×-comm) ⟩ (∃ λ (f : A → B) → ∃ λ (c : Constant f) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → ∃ λ (f₁ : B) → ∃ λ (c₂ : f a₀ ≡ f₁) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∃ λ (d₁ : ∀ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡ c₁ a₁) → ∃ λ (d₂ : (a : A) → trans (c a₀ a) (c₁ a) ≡ c₂) → trans (c a₀ a₀) (c₁ a₀) ≡ c₂) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-comm) ⟩□ (∃ λ (f : A → B) → ∃ λ (c : Constant f) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → ∃ λ (f₁ : B) → ∃ λ (c₂ : f a₀ ≡ f₁) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∃ λ (d₂ : (a : A) → trans (c a₀ a) (c₁ a) ≡ c₂) → ∃ λ (d₁ : ∀ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡ c₁ a₁) → trans (c a₀ a₀) (c₁ a₀) ≡ c₂) □ equivalence₁ : A → (B ≃ ∃ λ (f : A → B) → Coherently-constant f) equivalence₁ a₀ = Eq.↔⇒≃ ( B ↝⟨ (inverse $ drop-⊤-right λ _ → _⇔_.to contractible⇔↔⊤ $ Π-closure (lower-extensionality _ (a ⊔ ℓ) ext) 0 λ _ → singleton-contractible _) ⟩ (∃ λ (f₁ : B) → (a : A) → ∃ λ (b : B) → b ≡ f₁) ↝⟨ (∃-cong λ _ → ΠΣ-comm) ⟩ (∃ λ (f₁ : B) → ∃ λ (f : A → B) → (a : A) → f a ≡ f₁) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → inverse $ drop-⊤-right λ _ → _⇔_.to contractible⇔↔⊤ $ Π-closure (lower-extensionality _ ℓ ext) 0 λ _ → Π-closure (lower-extensionality _ (a ⊔ ℓ) ext) 0 λ _ → singleton-contractible _) ⟩ (∃ λ (f₁ : B) → ∃ λ (f : A → B) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∀ a₁ a₂ → ∃ λ (c : f a₁ ≡ f a₂) → c ≡ trans (c₁ a₁) (sym (c₁ a₂))) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∀-cong (lower-extensionality _ ℓ ext) λ _ → ∀-cong (lower-extensionality _ (a ⊔ ℓ) ext) λ _ → ∃-cong λ _ → ≡⇒↝ _ $ sym $ [trans≡]≡[≡trans-symʳ] _ _ _) ⟩ (∃ λ (f₁ : B) → ∃ λ (f : A → B) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∀ a₁ a₂ → ∃ λ (c : f a₁ ≡ f a₂) → trans c (c₁ a₂) ≡ c₁ a₁) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∀-cong (lower-extensionality _ ℓ ext) λ _ → ΠΣ-comm) ⟩ (∃ λ (f₁ : B) → ∃ λ (f : A → B) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∀ a₁ → ∃ λ (c : ∀ a₂ → f a₁ ≡ f a₂) → ∀ a₂ → trans (c a₂) (c₁ a₂) ≡ c₁ a₁) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ΠΣ-comm) ⟩ (∃ λ (f₁ : B) → ∃ λ (f : A → B) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∃ λ (c : Constant f) → ∀ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡ c₁ a₁) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → inverse $ drop-⊤-right λ _ → _⇔_.to contractible⇔↔⊤ $ other-singleton-contractible _) ⟩ (∃ λ (f₁ : B) → ∃ λ (f : A → B) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∃ λ (c : Constant f) → ∃ λ (d₁ : ∀ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡ c₁ a₁) → ∃ λ (c₂ : f a₀ ≡ f₁) → trans (c a₀ a₀) (c₁ a₀) ≡ c₂) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ c₁ → ∃-cong λ c → ∃-cong λ d₁ → ∃-cong λ _ → inverse $ drop-⊤-right λ _ → _⇔_.to contractible⇔↔⊤ $ propositional⇒inhabited⇒contractible (Π-closure (lower-extensionality _ ℓ ext) 1 λ _ → Π-closure (lower-extensionality _ ℓ ext) 1 λ _ → Π-closure (lower-extensionality _ (a ⊔ ℓ) ext) 1 λ _ → B-groupoid) (λ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡⟨ cong₂ trans (≡⇒↝ implication ([trans≡]≡[≡trans-symʳ] _ _ _) (d₁ _ _)) (≡⇒↝ implication ([trans≡]≡[≡trans-symʳ] _ _ _) (d₁ _ _)) ⟩ trans (trans (c₁ a₁) (sym (c₁ a₂))) (trans (c₁ a₂) (sym (c₁ a₃))) ≡⟨ sym $ trans-assoc _ _ _ ⟩ trans (trans (trans (c₁ a₁) (sym (c₁ a₂))) (c₁ a₂)) (sym (c₁ a₃)) ≡⟨ cong (flip trans _) $ trans-[trans-sym]- _ _ ⟩ trans (c₁ a₁) (sym (c₁ a₃)) ≡⟨ sym $ ≡⇒↝ implication ([trans≡]≡[≡trans-symʳ] _ _ _) (d₁ _ _) ⟩∎ c a₁ a₃ ∎)) ⟩ (∃ λ (f₁ : B) → ∃ λ (f : A → B) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∃ λ (c : Constant f) → ∃ λ (d₁ : ∀ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡ c₁ a₁) → ∃ λ (c₂ : f a₀ ≡ f₁) → ∃ λ (d₃ : trans (c a₀ a₀) (c₁ a₀) ≡ c₂) → ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ c₁ → ∃-cong λ c → ∃-cong λ d₁ → ∃-cong λ c₂ → ∃-cong λ d₃ → inverse $ drop-⊤-right λ d → _⇔_.to contractible⇔↔⊤ $ propositional⇒inhabited⇒contractible (Π-closure (lower-extensionality _ (a ⊔ ℓ) ext) 1 λ _ → B-groupoid) (λ a → trans (c a₀ a) (c₁ a) ≡⟨ cong (λ x → trans x _) $ sym $ d _ _ _ ⟩ trans (trans (c a₀ a₀) (c a₀ a)) (c₁ a) ≡⟨ trans-assoc _ _ _ ⟩ trans (c a₀ a₀) (trans (c a₀ a) (c₁ a)) ≡⟨ cong (trans _) $ d₁ _ _ ⟩ trans (c a₀ a₀) (c₁ a₀) ≡⟨ d₃ ⟩∎ c₂ ∎)) ⟩ (∃ λ (f₁ : B) → ∃ λ (f : A → B) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∃ λ (c : Constant f) → ∃ λ (d₁ : ∀ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡ c₁ a₁) → ∃ λ (c₂ : f a₀ ≡ f₁) → ∃ λ (d₃ : trans (c a₀ a₀) (c₁ a₀) ≡ c₂) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → (a : A) → trans (c a₀ a) (c₁ a) ≡ c₂) ↝⟨ rearrangement-lemma a₀ ⟩ (∃ λ (f : A → B) → ∃ λ (c : Constant f) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → ∃ λ (f₁ : B) → ∃ λ (c₂ : f a₀ ≡ f₁) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∃ λ (d₂ : (a : A) → trans (c a₀ a) (c₁ a) ≡ c₂) → ∃ λ (d₁ : ∀ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡ c₁ a₁) → trans (c a₀ a₀) (c₁ a₀) ≡ c₂) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ d₂ → drop-⊤-right λ _ → _⇔_.to contractible⇔↔⊤ $ propositional⇒inhabited⇒contractible (B-groupoid) (d₂ _)) ⟩ (∃ λ (f : A → B) → ∃ λ (c : Constant f) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → ∃ λ (f₁ : B) → ∃ λ (c₂ : f a₀ ≡ f₁) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → ∃ λ (d₂ : (a : A) → trans (c a₀ a) (c₁ a) ≡ c₂) → ∀ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡ c₁ a₁) ↝⟨ (∃-cong λ _ → ∃-cong λ c → ∃-cong λ d → ∃-cong λ _ → ∃-cong λ c₂ → ∃-cong λ c₁ → drop-⊤-right λ d₂ → _⇔_.to contractible⇔↔⊤ $ propositional⇒inhabited⇒contractible (Π-closure (lower-extensionality _ ℓ ext) 1 λ _ → Π-closure (lower-extensionality _ (a ⊔ ℓ) ext) 1 λ _ → B-groupoid) (λ a₁ a₂ → trans (c a₁ a₂) (c₁ a₂) ≡⟨ cong₂ trans (sym $ d _ _ _) (≡⇒↝ implication ([trans≡]≡[≡trans-symˡ] _ _ _) (d₂ _)) ⟩ trans (trans (c a₁ a₀) (c a₀ a₂)) (trans (sym (c a₀ a₂)) c₂) ≡⟨ sym $ trans-assoc _ _ _ ⟩ trans (trans (trans (c a₁ a₀) (c a₀ a₂)) (sym (c a₀ a₂))) c₂ ≡⟨ cong (flip trans _) $ trans-[trans]-sym _ _ ⟩ trans (c a₁ a₀) c₂ ≡⟨ cong (trans _) $ sym $ d₂ _ ⟩ trans (c a₁ a₀) (trans (c a₀ a₁) (c₁ a₁)) ≡⟨ sym $ trans-assoc _ _ _ ⟩ trans (trans (c a₁ a₀) (c a₀ a₁)) (c₁ a₁) ≡⟨ cong (flip trans _) $ d _ _ _ ⟩ trans (c a₁ a₁) (c₁ a₁) ≡⟨ cong (flip trans _) $ Groupoid.idempotent⇒≡id (EG.groupoid _) (d _ _ _) ⟩ trans (refl _) (c₁ a₁) ≡⟨ trans-reflˡ _ ⟩∎ c₁ a₁ ∎)) ⟩ (∃ λ (f : A → B) → ∃ λ (c : Constant f) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → ∃ λ (f₁ : B) → ∃ λ (c₂ : f a₀ ≡ f₁) → ∃ λ (c₁ : (a : A) → f a ≡ f₁) → (a : A) → trans (c a₀ a) (c₁ a) ≡ c₂) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → inverse ΠΣ-comm) ⟩ (∃ λ (f : A → B) → ∃ λ (c : Constant f) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → ∃ λ (f₁ : B) → ∃ λ (c₂ : f a₀ ≡ f₁) → (a : A) → ∃ λ (c₁ : f a ≡ f₁) → trans (c a₀ a) c₁ ≡ c₂) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∀-cong (lower-extensionality _ (a ⊔ ℓ) ext) λ _ → ∃-cong λ _ → ≡⇒↝ _ $ [trans≡]≡[≡trans-symˡ] _ _ _) ⟩ (∃ λ (f : A → B) → ∃ λ (c : Constant f) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → ∃ λ (f₁ : B) → ∃ λ (c₂ : f a₀ ≡ f₁) → (a : A) → ∃ λ (c₁ : f a ≡ f₁) → c₁ ≡ trans (sym (c a₀ a)) c₂) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → drop-⊤-right λ _ → _⇔_.to contractible⇔↔⊤ $ Π-closure (lower-extensionality _ (a ⊔ ℓ) ext) 0 λ _ → singleton-contractible _) ⟩ (∃ λ (f : A → B) → ∃ λ (c : Constant f) → ∃ λ (d : ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) → ∃ λ (f₁ : B) → f a₀ ≡ f₁) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → drop-⊤-right λ _ → _⇔_.to contractible⇔↔⊤ $ other-singleton-contractible _) ⟩□ (∃ λ (f : A → B) → ∃ λ (c : Constant f) → ∀ a₁ a₂ a₃ → trans (c a₁ a₂) (c a₂ a₃) ≡ c a₁ a₃) □) -- An alternative implementation of the forward component of the -- equivalence above (with shorter proofs). to : B → ∃ λ (f : A → B) → Coherently-constant f to b = (λ _ → b) , (λ _ _ → refl b) , (λ _ _ _ → trans-refl-refl) to-is-an-equivalence : A → Is-equivalence to to-is-an-equivalence a₀ = Eq.respects-extensional-equality (λ b → Σ-≡,≡→≡ (refl _) $ Σ-≡,≡→≡ (proj₁ (subst Coherently-constant (refl _) (proj₂ (_≃_.to (equivalence₁ a₀) b))) ≡⟨ cong proj₁ $ subst-refl Coherently-constant _ ⟩ (λ _ _ → trans (refl b) (sym (refl b))) ≡⟨ (apply-ext (lower-extensionality _ ℓ ext) λ _ → apply-ext (lower-extensionality _ (a ⊔ ℓ) ext) λ _ → trans-symʳ _) ⟩∎ (λ _ _ → refl b) ∎) ((Π-closure (lower-extensionality _ ℓ ext) 1 λ _ → Π-closure (lower-extensionality _ ℓ ext) 1 λ _ → Π-closure (lower-extensionality _ (a ⊔ ℓ) ext) 1 λ _ → B-groupoid) _ _)) (_≃_.is-equivalence (equivalence₁ a₀)) -- The forward component of the equivalence above does not depend on -- the value a₀ of type A, so it suffices to assume that A is merely -- inhabited. equivalence₂ : ∥ A ∥ 1 ℓ′ → (B ≃ ∃ λ (f : A → B) → Coherently-constant f) equivalence₂ ∥a∥ = Eq.⟨ to , rec 1 (Eq.propositional (lower-extensionality _ ℓ ext) _) to-is-an-equivalence (with-lower-level ℓ 1 ∥a∥) ⟩ -- Having a constant function into a set is equivalent to having a -- function from a propositionally truncated type into the set -- (assuming extensionality). The statement of this result is that of -- Proposition 2.2 in "The General Universal Property of the -- Propositional Truncation" by Kraus, but it uses a different proof: -- as observed by Kraus this result follows from Proposition 2.3. constant-function≃∥inhabited∥⇒inhabited : ∀ {a b} ℓ {A : Type a} {B : Type b} → Extensionality (lsuc (a ⊔ b ⊔ ℓ)) (a ⊔ b ⊔ ℓ) → Is-set B → (∃ λ (f : A → B) → Constant f) ≃ (∥ A ∥ 1 (a ⊔ b ⊔ ℓ) → B) constant-function≃∥inhabited∥⇒inhabited {a} {b} ℓ {A} {B} ext B-set = (∃ λ (f : A → B) → Constant f) ↔⟨ (∃-cong λ f → inverse $ drop-⊤-right λ c → _⇔_.to contractible⇔↔⊤ $ Π-closure (lower-extensionality _ ℓ ext) 0 λ _ → Π-closure (lower-extensionality _ ℓ ext) 0 λ _ → Π-closure (lower-extensionality _ (a ⊔ ℓ) ext) 0 λ _ → +⇒≡ B-set) ⟩ (∃ λ (f : A → B) → Coherently-constant f) ↝⟨ coherently-constant-function≃∥inhabited∥⇒inhabited ℓ ext (mono₁ 2 B-set) ⟩□ (∥ A ∥ 1 (a ⊔ b ⊔ ℓ) → B) □ private -- One direction of the proposition above computes in the right way. to-constant-function≃∥inhabited∥⇒inhabited : ∀ {a b} ℓ {A : Type a} {B : Type b} (ext : Extensionality (lsuc (a ⊔ b ⊔ ℓ)) (a ⊔ b ⊔ ℓ)) (B-set : Is-set B) (f : ∃ λ (f : A → B) → Constant f) (x : A) → _≃_.to (constant-function≃∥inhabited∥⇒inhabited ℓ ext B-set) f ∣ x ∣₁ ≡ proj₁ f x to-constant-function≃∥inhabited∥⇒inhabited _ _ _ _ _ = refl _ -- The propositional truncation's universal property (defined using -- extensionality). -- -- As observed by Kraus this result follows from Proposition 2.2 in -- his "The General Universal Property of the Propositional -- Truncation". universal-property : ∀ {a b} ℓ {A : Type a} {B : Type b} → Extensionality (lsuc (a ⊔ b ⊔ ℓ)) (a ⊔ b ⊔ ℓ) → Is-proposition B → (∥ A ∥ 1 (a ⊔ b ⊔ ℓ) → B) ≃ (A → B) universal-property {a = a} {b} ℓ {A} {B} ext B-prop = Eq.with-other-function ((∥ A ∥ 1 (a ⊔ b ⊔ ℓ) → B) ↝⟨ inverse $ constant-function≃∥inhabited∥⇒inhabited ℓ ext (mono₁ 1 B-prop) ⟩ (∃ λ (f : A → B) → Constant f) ↔⟨ (drop-⊤-right λ _ → _⇔_.to contractible⇔↔⊤ $ Π-closure (lower-extensionality _ ℓ ext) 0 λ _ → Π-closure (lower-extensionality _ (a ⊔ ℓ) ext) 0 λ _ → +⇒≡ B-prop) ⟩□ (A → B) □) (_∘ ∣_∣₁) (λ f → apply-ext (lower-extensionality _ (a ⊔ ℓ) ext) λ x → subst (const B) (refl x) (f ∣ x ∣₁) ≡⟨ subst-refl _ _ ⟩∎ f ∣ x ∣₁ ∎) private -- The universal property computes in the right way. to-universal-property : ∀ {a b} ℓ {A : Type a} {B : Type b} (ext : Extensionality (lsuc (a ⊔ b ⊔ ℓ)) (a ⊔ b ⊔ ℓ)) (B-prop : Is-proposition B) (f : ∥ A ∥ 1 (a ⊔ b ⊔ ℓ) → B) → _≃_.to (universal-property ℓ ext B-prop) f ≡ f ∘ ∣_∣₁ to-universal-property _ _ _ _ = refl _ from-universal-property : ∀ {a b} ℓ {A : Type a} {B : Type b} (ext : Extensionality (lsuc (a ⊔ b ⊔ ℓ)) (a ⊔ b ⊔ ℓ)) (B-prop : Is-proposition B) (f : A → B) (x : A) → _≃_.from (universal-property ℓ ext B-prop) f ∣ x ∣₁ ≡ f x from-universal-property _ _ _ _ _ = refl _ -- Some properties of an imagined "real" /propositional/ truncation. module Real-propositional-truncation (∥_∥ʳ : ∀ {a} → Type a → Type a) (∣_∣ʳ : ∀ {a} {A : Type a} → A → ∥ A ∥ʳ) (truncation-is-proposition : ∀ {a} {A : Type a} → Is-proposition ∥ A ∥ʳ) (recʳ : ∀ {a b} {A : Type a} {B : Type b} → Is-proposition B → (A → B) → ∥ A ∥ʳ → B) where -- The function recʳ can be used to define a dependently typed -- eliminator (assuming extensionality). elimʳ : ∀ {a p} {A : Type a} → Extensionality a p → (P : ∥ A ∥ʳ → Type p) → (∀ x → Is-proposition (P x)) → ((x : A) → P ∣ x ∣ʳ) → (x : ∥ A ∥ʳ) → P x elimʳ {A = A} ext P P-prop f x = recʳ {A = A} {B = ∀ x → P x} (Π-closure ext 1 P-prop) (λ x _ → subst P (truncation-is-proposition _ _) (f x)) x x -- The eliminator gives the right result, up to propositional -- equality, when applied to ∣ x ∣ʳ. elimʳ-∣∣ʳ : ∀ {a p} {A : Type a} (ext : Extensionality a p) (P : ∥ A ∥ʳ → Type p) (P-prop : ∀ x → Is-proposition (P x)) (f : (x : A) → P ∣ x ∣ʳ) (x : A) → elimʳ ext P P-prop f ∣ x ∣ʳ ≡ f x elimʳ-∣∣ʳ ext P P-prop f x = P-prop _ _ _ -- The "real" propositional truncation is isomorphic to the one -- defined above (assuming extensionality). isomorphic : ∀ {ℓ a} {A : Type a} → Extensionality (lsuc (a ⊔ ℓ)) (a ⊔ ℓ) → ∥ A ∥ʳ ↔ ∥ A ∥ 1 (a ⊔ ℓ) isomorphic {ℓ} ext = record { surjection = record { logical-equivalence = record { to = recʳ (truncation-has-correct-h-level 1 ext) ∣_∣₁ ; from = lower {ℓ = ℓ} ∘ rec 1 (↑-closure 1 truncation-is-proposition) (lift ∘ ∣_∣ʳ) } ; right-inverse-of = λ _ → truncation-has-correct-h-level 1 ext _ _ } ; left-inverse-of = λ _ → truncation-is-proposition _ _ } -- The axiom of choice, in one of the alternative forms given in the -- HoTT book (§3.8). -- -- The HoTT book uses a "real" propositional truncation, rather than -- the defined one used here. Note that I don't know if the universe -- levels used below (b ⊔ ℓ and a ⊔ b ⊔ ℓ) make sense. However, in the -- presence of a "real" propositional truncation (and extensionality) -- they can be dropped (see Real-propositional-truncation.isomorphic). Axiom-of-choice : (a b ℓ : Level) → Type (lsuc (a ⊔ b ⊔ ℓ)) Axiom-of-choice a b ℓ = {A : Type a} {B : A → Type b} → Is-set A → (∀ x → ∥ B x ∥ 1 (b ⊔ ℓ)) → ∥ (∀ x → B x) ∥ 1 (a ⊔ b ⊔ ℓ)
{ "alphanum_fraction": 0.4026660933, "avg_line_length": 45.111542192, "ext": "agda", "hexsha": "38c92d9b004f4b8a015845ffc681fe7da92d73e7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/H-level/Truncation/Church.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/H-level/Truncation/Church.agda", "max_line_length": 146, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/H-level/Truncation/Church.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 17934, "size": 46510 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.types.Truncation open import lib.types.Groupoid open import lib.types.PathSet module lib.groupoids.FundamentalPreGroupoid {i} (A : Type i) where fundamental-pregroupoid : PreGroupoid i i fundamental-pregroupoid = record { El = A ; Arr = _=₀_ {A = A} ; Arr-level = λ _ _ → Trunc-level ; groupoid-struct = record { ident = idp₀ ; inv = !₀ ; comp = _∙₀_ ; unit-l = ∙₀-unit-l ; assoc = ∙₀-assoc ; inv-l = !₀-inv-l } }
{ "alphanum_fraction": 0.6049822064, "avg_line_length": 23.4166666667, "ext": "agda", "hexsha": "4c8e9b01f3cf6961a64c01096d91b0479404414d", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "core/lib/groupoids/FundamentalPreGroupoid.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "core/lib/groupoids/FundamentalPreGroupoid.agda", "max_line_length": 66, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "core/lib/groupoids/FundamentalPreGroupoid.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 180, "size": 562 }
------------------------------------------------------------------------ -- Properties satisfied by total orders ------------------------------------------------------------------------ open import Relation.Binary module Relation.Binary.Props.TotalOrder (t : TotalOrder) where open Relation.Binary.TotalOrder t open import Relation.Binary.Consequences decTotalOrder : Decidable _≈_ → DecTotalOrder decTotalOrder ≟ = record { isDecTotalOrder = record { isTotalOrder = isTotalOrder ; _≟_ = ≟ ; _≤?_ = total+dec⟶dec reflexive antisym total ≟ } }
{ "alphanum_fraction": 0.5219594595, "avg_line_length": 29.6, "ext": "agda", "hexsha": "63c1559181b8ead114feea3cbb156f9ebf7d055e", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Relation/Binary/Props/TotalOrder.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Relation/Binary/Props/TotalOrder.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Relation/Binary/Props/TotalOrder.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 125, "size": 592 }
module Slides where import Background import OpenTheory import OpenTheory2 import ClosedTheory import ClosedTheory2 import ClosedTheory3 import ClosedTheory4
{ "alphanum_fraction": 0.8867924528, "avg_line_length": 15.9, "ext": "agda", "hexsha": "3840c74d3e98adfddca92e1c59fff8e090ac3618", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:31:22.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-02T08:56:15.000Z", "max_forks_repo_head_hexsha": "832383d7adf37aa2364213fb0aeb67e9f61a248f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/generic-elim", "max_forks_repo_path": "slides/Slides.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "832383d7adf37aa2364213fb0aeb67e9f61a248f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/generic-elim", "max_issues_repo_path": "slides/Slides.agda", "max_line_length": 20, "max_stars_count": 11, "max_stars_repo_head_hexsha": "832383d7adf37aa2364213fb0aeb67e9f61a248f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/generic-elim", "max_stars_repo_path": "slides/Slides.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-09T08:46:42.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-02T14:05:20.000Z", "num_tokens": 36, "size": 159 }
{-# OPTIONS --without-K --safe #-} open import Data.Nat using (ℕ) module Categories.Category.Construction.Fin (n : ℕ) where open import Level open import Data.Fin.Properties open import Categories.Category open import Categories.Category.Construction.Thin 0ℓ (≤-poset n) Fin : Category 0ℓ 0ℓ 0ℓ Fin = Thin
{ "alphanum_fraction": 0.7524115756, "avg_line_length": 20.7333333333, "ext": "agda", "hexsha": "7de3eb278f035af308a6b36d6326edc7dce30288", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Category/Construction/Fin.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Category/Construction/Fin.agda", "max_line_length": 64, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Category/Construction/Fin.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 88, "size": 311 }
-- Andreas, 2016-12-09, issue #2331 -- Testcase from Nisse's application open import Common.Size data D (i : Size) : Set where c : (j : Size< i) → D i postulate f : (i : Size) → ((j : Size< i) → D j → Set) → Set module Mutual where mutual test : (i : Size) → D i → Set test i (c j) = f j (helper i j) helper : (i : Size) (j : Size< i) (k : Size< j) → D k → Set helper i j k = test k module Where where test : (i : Size) → D i → Set test i (c j) = f j helper where helper : (k : Size< j) → D k → Set helper k = test k -- While k is an unusable size per se, in combination with the usable size j -- (which comes from a inductive pattern match) -- it should be fine to certify termination.
{ "alphanum_fraction": 0.5893587995, "avg_line_length": 24.4333333333, "ext": "agda", "hexsha": "b256db7ae11f70b8fd1ed96ed2fd8668ee4ccf7d", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/features/Issue2331.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/features/Issue2331.agda", "max_line_length": 76, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/features/Issue2331.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 252, "size": 733 }
------------------------------------------------------------------------ -- The torus, defined as a HIT ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} -- This module is based on the discussion of the torus in the HoTT -- book. -- The module is parametrised by a notion of equality. The higher -- constructors of the HIT defining the torus use path equality, but -- the supplied notion of equality is used for many other things. import Equality.Path as P module Torus {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq hiding (elim) open import Prelude open import Bijection equality-with-J using (_↔_) open import Equality.Path.Isomorphisms eq open import Circle eq as Circle using (𝕊¹; base; loopᴾ) private variable a p : Level A : Type a P : A → Type p ------------------------------------------------------------------------ -- The torus mutual -- The torus. data T² : Type where base hub : T² loop₁ᴾ loop₂ᴾ : base P.≡ base spokeᴾ : (x : 𝕊¹) → rimᴾ x P.≡ hub private -- A synonym used to work around an Agda restriction. base′ = base -- A function used to define the spoke constructor. -- -- Note that this function is defined using Circle.recᴾ, not -- Circle.rec. rimᴾ : 𝕊¹ → T² rimᴾ = Circle.recᴾ base loop₁₂₋₁₋₂ᴾ -- A loop. loop₁₂₋₁₋₂ᴾ : base′ P.≡ base′ loop₁₂₋₁₋₂ᴾ = base P.≡⟨ loop₁ᴾ ⟩ base P.≡⟨ loop₂ᴾ ⟩ base P.≡⟨ P.sym loop₁ᴾ ⟩ base P.≡⟨ P.sym loop₂ᴾ ⟩∎ base ∎ -- The constructors (and loop₁₂₋₁₋₂ᴾ) expressed using _≡_ instead of -- paths. loop₁ : base ≡ base loop₁ = _↔_.from ≡↔≡ loop₁ᴾ loop₂ : base ≡ base loop₂ = _↔_.from ≡↔≡ loop₂ᴾ loop₁₂₋₁₋₂ : base ≡ base loop₁₂₋₁₋₂ = _↔_.from ≡↔≡ loop₁₂₋₁₋₂ᴾ spoke : (x : 𝕊¹) → rimᴾ x ≡ hub spoke = _↔_.from ≡↔≡ ∘ spokeᴾ -- A variant of rimᴾ, defined using Circle.rec and loop₁₂₋₁₋₂. rim : 𝕊¹ → T² rim = Circle.rec base loop₁₂₋₁₋₂ -- The functions rim and rimᴾ are pointwise equal. rim≡rimᴾ : ∀ x → rim x ≡ rimᴾ x rim≡rimᴾ = Circle.elim _ (refl _) (subst (λ x → rim x ≡ rimᴾ x) Circle.loop (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong rim Circle.loop)) (trans (refl _) (cong rimᴾ Circle.loop)) ≡⟨ cong (trans _) $ trans-reflˡ _ ⟩ trans (sym (cong rim Circle.loop)) (cong rimᴾ Circle.loop) ≡⟨ cong₂ (trans ∘ sym) Circle.rec-loop lemma ⟩ trans (sym loop₁₂₋₁₋₂) loop₁₂₋₁₋₂ ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎) where lemma = cong rimᴾ Circle.loop ≡⟨ cong≡cong ⟩ _↔_.from ≡↔≡ (P.cong rimᴾ loopᴾ) ≡⟨⟩ _↔_.from ≡↔≡ loop₁₂₋₁₋₂ᴾ ≡⟨⟩ loop₁₂₋₁₋₂ ∎ ------------------------------------------------------------------------ -- Eliminators expressed using paths -- A dependent eliminator, expressed using paths. record Elimᴾ₀ (P : T² → Type p) : Type p where no-eta-equality field baseʳ : P base loop₁ʳ : P.[ (λ i → P (loop₁ᴾ i)) ] baseʳ ≡ baseʳ loop₂ʳ : P.[ (λ i → P (loop₂ᴾ i)) ] baseʳ ≡ baseʳ -- A dependent path. loop₁₂₋₁₋₂ʳ : P.[ (λ i → P (loop₁₂₋₁₋₂ᴾ i)) ] baseʳ ≡ baseʳ loop₁₂₋₁₋₂ʳ = baseʳ P.≡⟨ loop₁ʳ ⟩[ P ] baseʳ P.≡⟨ loop₂ʳ ⟩[ P ] baseʳ P.≡⟨ P.hsym loop₁ʳ ⟩[ P ] baseʳ P.≡⟨ P.hsym loop₂ʳ ⟩∎h baseʳ ∎ -- A special case of elimᴾ, used in the type of elimᴾ. elimᴾ-rimᴾ : (x : 𝕊¹) → P (rimᴾ x) elimᴾ-rimᴾ = Circle.elimᴾ (P ∘ rimᴾ) baseʳ loop₁₂₋₁₋₂ʳ record Elimᴾ (P : T² → Type p) : Type p where no-eta-equality field elimᴾ₀ : Elimᴾ₀ P open Elimᴾ₀ elimᴾ₀ public field hubʳ : P hub spokeʳ : (x : 𝕊¹) → P.[ (λ i → P (spokeᴾ x i)) ] elimᴾ-rimᴾ x ≡ hubʳ elimᴾ : Elimᴾ P → (x : T²) → P x elimᴾ {P = P} e = helper where module E = Elimᴾ e helper : (x : T²) → P x helper = λ where base → E.baseʳ hub → E.hubʳ (loop₁ᴾ i) → E.loop₁ʳ i (loop₂ᴾ i) → E.loop₂ʳ i (spokeᴾ base i) → E.spokeʳ base i (spokeᴾ (loopᴾ j) i) → E.spokeʳ (loopᴾ j) i -- The special case is a special case. elimᴾ-rimᴾ≡elimᴾ-rimᴾ : (e : Elimᴾ P) (x : 𝕊¹) → elimᴾ e (rimᴾ x) ≡ Elimᴾ.elimᴾ-rimᴾ e x elimᴾ-rimᴾ≡elimᴾ-rimᴾ _ = Circle.elimᴾ _ (refl _) (λ _ → refl _) -- A non-dependent eliminator, expressed using paths. Recᴾ : Type a → Type a Recᴾ A = Elimᴾ (λ _ → A) recᴾ : Recᴾ A → T² → A recᴾ = elimᴾ ------------------------------------------------------------------------ -- Eliminators -- A dependent eliminator. record Elim (P : T² → Type p) : Type p where no-eta-equality field baseʳ : P base loop₁ʳ : subst P loop₁ baseʳ ≡ baseʳ loop₂ʳ : subst P loop₂ baseʳ ≡ baseʳ -- An instance of Elimᴾ₀ P. elimᴾ₀ : Elimᴾ₀ P elimᴾ₀ = λ where .Elimᴾ₀.baseʳ → baseʳ .Elimᴾ₀.loop₁ʳ → subst≡→[]≡ loop₁ʳ .Elimᴾ₀.loop₂ʳ → subst≡→[]≡ loop₂ʳ -- A special case of elim, used in the type of elim. elim-rimᴾ : (x : 𝕊¹) → P (rimᴾ x) elim-rimᴾ = Elimᴾ₀.elimᴾ-rimᴾ elimᴾ₀ field hubʳ : P hub spokeʳ : (x : 𝕊¹) → subst P (spoke x) (elim-rimᴾ x) ≡ hubʳ -- The eliminator. elim : (x : T²) → P x elim = elimᴾ λ where .Elimᴾ.elimᴾ₀ → elimᴾ₀ .Elimᴾ.hubʳ → hubʳ .Elimᴾ.spokeʳ → subst≡→[]≡ ∘ spokeʳ -- The special case is a special case. elim-rimᴾ≡elim-rimᴾ : (x : 𝕊¹) → elim (rimᴾ x) ≡ elim-rimᴾ x elim-rimᴾ≡elim-rimᴾ = elimᴾ-rimᴾ≡elimᴾ-rimᴾ _ -- A variant of spokeʳ with a slightly different type. spokeʳ′ : (x : 𝕊¹) → subst P (spoke x) (elim (rimᴾ x)) ≡ hubʳ spokeʳ′ = Circle.elimᴾ _ (spokeʳ base) (λ i → spokeʳ (loopᴾ i)) -- Computation rules. elim-loop₁ : dcong elim loop₁ ≡ loop₁ʳ elim-loop₁ = dcong-subst≡→[]≡ (refl _) elim-loop₂ : dcong elim loop₂ ≡ loop₂ʳ elim-loop₂ = dcong-subst≡→[]≡ (refl _) elim-spoke : (x : 𝕊¹) → dcong elim (spoke x) ≡ spokeʳ′ x elim-spoke = Circle.elimᴾ _ (dcong-subst≡→[]≡ (refl _)) (λ _ → dcong-subst≡→[]≡ (refl _)) -- A non-dependent eliminator. record Rec (A : Type a) : Type a where no-eta-equality field baseʳ : A loop₁ʳ : baseʳ ≡ baseʳ loop₂ʳ : baseʳ ≡ baseʳ -- An instance of Elimᴾ₀ P. elimᴾ₀ : Elimᴾ₀ (λ _ → A) elimᴾ₀ = λ where .Elimᴾ₀.baseʳ → baseʳ .Elimᴾ₀.loop₁ʳ → _↔_.to ≡↔≡ loop₁ʳ .Elimᴾ₀.loop₂ʳ → _↔_.to ≡↔≡ loop₂ʳ -- A special case of recᴾ, used in the type of rec. rec-rimᴾ : 𝕊¹ → A rec-rimᴾ = Elimᴾ₀.elimᴾ-rimᴾ elimᴾ₀ field hubʳ : A spokeʳ : (x : 𝕊¹) → rec-rimᴾ x ≡ hubʳ -- The eliminator. rec : T² → A rec = recᴾ λ where .Elimᴾ.elimᴾ₀ → elimᴾ₀ .Elimᴾ.hubʳ → hubʳ .Elimᴾ.spokeʳ → _↔_.to ≡↔≡ ∘ spokeʳ -- The special case is a special case. rec-rimᴾ≡rec-rimᴾ : (x : 𝕊¹) → rec (rimᴾ x) ≡ rec-rimᴾ x rec-rimᴾ≡rec-rimᴾ = elimᴾ-rimᴾ≡elimᴾ-rimᴾ _ -- A variant of spokeʳ with a slightly different type. spokeʳ′ : (x : 𝕊¹) → rec (rimᴾ x) ≡ hubʳ spokeʳ′ = Circle.elimᴾ _ (spokeʳ base) (λ i → spokeʳ (loopᴾ i)) -- Computation rules. rec-loop₁ : cong rec loop₁ ≡ loop₁ʳ rec-loop₁ = cong-≡↔≡ (refl _) rec-loop₂ : cong rec loop₂ ≡ loop₂ʳ rec-loop₂ = cong-≡↔≡ (refl _) rec-spoke : (x : 𝕊¹) → cong rec (spoke x) ≡ spokeʳ′ x rec-spoke = Circle.elimᴾ _ (cong-≡↔≡ (refl _)) (λ _ → cong-≡↔≡ (refl _)) ------------------------------------------------------------------------ -- Some lemmas -- The remaining results are not taken from the HoTT book. -- One can express loop₁₂₋₁₋₂ using loop₁ and loop₂. loop₁₂₋₁₋₂≡ : loop₁₂₋₁₋₂ ≡ trans (trans loop₁ loop₂) (sym (trans loop₂ loop₁)) loop₁₂₋₁₋₂≡ = _↔_.from ≡↔≡ loop₁₂₋₁₋₂ᴾ ≡⟨⟩ _↔_.from ≡↔≡ (P.trans loop₁ᴾ (P.trans loop₂ᴾ (P.trans (P.sym loop₁ᴾ) (P.sym loop₂ᴾ)))) ≡⟨ sym trans≡trans ⟩ trans loop₁ (_↔_.from ≡↔≡ (P.trans loop₂ᴾ (P.trans (P.sym loop₁ᴾ) (P.sym loop₂ᴾ)))) ≡⟨ cong (trans _) $ sym trans≡trans ⟩ trans loop₁ (trans loop₂ (_↔_.from ≡↔≡ (P.trans (P.sym loop₁ᴾ) (P.sym loop₂ᴾ)))) ≡⟨ cong (λ eq → trans loop₁ (trans loop₂ eq)) $ sym trans≡trans ⟩ trans loop₁ (trans loop₂ (trans (_↔_.from ≡↔≡ (P.sym loop₁ᴾ)) (_↔_.from ≡↔≡ (P.sym loop₂ᴾ)))) ≡⟨ cong₂ (λ p q → trans loop₁ (trans loop₂ (trans p q))) (sym sym≡sym) (sym sym≡sym) ⟩ trans loop₁ (trans loop₂ (trans (sym loop₁) (sym loop₂))) ≡⟨ sym $ trans-assoc _ _ _ ⟩ trans (trans loop₁ loop₂) (trans (sym loop₁) (sym loop₂)) ≡⟨ cong (trans _) $ sym $ sym-trans _ _ ⟩∎ trans (trans loop₁ loop₂) (sym (trans loop₂ loop₁)) ∎
{ "alphanum_fraction": 0.5428957442, "avg_line_length": 26.833836858, "ext": "agda", "hexsha": "b65ee873f3cdc4fa849d238f4d8f14d81e51bb90", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Torus.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Torus.agda", "max_line_length": 131, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Torus.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 3857, "size": 8882 }
module Builtin.Float where open import Prelude open import Prelude.Equality.Unsafe open import Agda.Builtin.Float open Agda.Builtin.Float public using (Float) natToFloat : Nat → Float natToFloat = primNatToFloat intToFloat : Int → Float intToFloat (pos x) = natToFloat x intToFloat (negsuc x) = primFloatMinus -1.0 (natToFloat x) instance EqFloat : Eq Float _==_ {{EqFloat}} x y with primFloatEquality x y ... | true = yes unsafeEqual ... | false = no unsafeNotEqual data LessFloat (x y : Float) : Set where less-float : primFloatLess x y ≡ true → LessFloat x y instance OrdFloat : Ord Float OrdFloat = defaultOrd cmpFloat where cmpFloat : ∀ x y → Comparison LessFloat x y cmpFloat x y with inspect (primFloatLess x y) ... | true with≡ eq = less (less-float eq) ... | false with≡ _ with inspect (primFloatLess y x) ... | true with≡ eq = greater (less-float eq) ... | false with≡ _ = equal unsafeEqual OrdLawsFloat : Ord/Laws Float Ord/Laws.super OrdLawsFloat = it less-antirefl {{OrdLawsFloat}} (less-float eq) = unsafeNotEqual eq less-trans {{OrdLawsFloat}} (less-float _) (less-float _) = less-float unsafeEqual instance ShowFloat : Show Float ShowFloat = simpleShowInstance primShowFloat instance NumFloat : Number Float Number.Constraint NumFloat _ = ⊤ Number.fromNat NumFloat x = primNatToFloat x SemiringFloat : Semiring Float Semiring.zro SemiringFloat = 0.0 Semiring.one SemiringFloat = 1.0 Semiring._+_ SemiringFloat = primFloatPlus Semiring._*_ SemiringFloat = primFloatTimes SubFloat : Subtractive Float Subtractive._-_ SubFloat = primFloatMinus Subtractive.negate SubFloat = primFloatNegate NegFloat : Negative Float Negative.Constraint NegFloat _ = ⊤ Negative.fromNeg NegFloat x = negate (primNatToFloat x) FracFloat : Fractional Float Fractional.Constraint FracFloat _ _ = ⊤ Fractional._/_ FracFloat x y = primFloatDiv x y floor = primFloor round = primRound ceiling = primCeiling exp = primExp ln = primLog sin = primSin sqrt = primFloatSqrt π : Float π = 3.141592653589793 cos : Float → Float cos x = sin (π / 2.0 - x) tan : Float → Float tan x = sin x / cos x log : Float → Float → Float log base x = ln x / ln base _**_ : Float → Float → Float a ** x = exp (x * ln a) NaN : Float NaN = 0.0 / 0.0 Inf : Float Inf = 1.0 / 0.0 -Inf : Float -Inf = -1.0 / 0.0
{ "alphanum_fraction": 0.6886252046, "avg_line_length": 24.44, "ext": "agda", "hexsha": "fcd80704b336e352ee468021f531cdd735ce8559", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_path": "src/Builtin/Float.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lclem/agda-prelude", "max_issues_repo_path": "src/Builtin/Float.agda", "max_line_length": 87, "max_stars_count": null, "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_path": "src/Builtin/Float.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 777, "size": 2444 }
module Tactic.Monoid.Proofs where open import Prelude open import Structure.Monoid.Laws open import Tactic.Monoid.Exp ⟦_⟧_ : ∀ {a} {A : Set a} {{_ : Monoid A}} → Exp → (Nat → A) → A ⟦ var x ⟧ ρ = ρ x ⟦ ε ⟧ ρ = mempty ⟦ e ⊕ e₁ ⟧ ρ = ⟦ e ⟧ ρ <> ⟦ e₁ ⟧ ρ ⟦_⟧n_ : ∀ {a} {A : Set a} {{_ : Monoid A}} → List Nat → (Nat → A) → A ⟦ xs ⟧n ρ = mconcat (map ρ xs) map/++ : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) (xs ys : List A) → map f (xs ++ ys) ≡ map f xs ++ map f ys map/++ f [] ys = refl map/++ f (x ∷ xs) ys = f x ∷_ $≡ map/++ f xs ys module _ {a} {A : Set a} {{Mon : Monoid A}} {{Laws : MonoidLaws A}} where mconcat/++ : (xs ys : List A) → mconcat (xs ++ ys) ≡ mconcat xs <> mconcat ys mconcat/++ [] ys = sym (idLeft _) mconcat/++ (x ∷ xs) ys = x <>_ $≡ mconcat/++ xs ys ⟨≡⟩ <>assoc x _ _ sound : ∀ e (ρ : Nat → A) → ⟦ e ⟧ ρ ≡ ⟦ flatten e ⟧n ρ sound (var x) ρ = sym (idRight (ρ x)) sound ε ρ = refl sound (e ⊕ e₁) ρ = _<>_ $≡ sound e ρ *≡ sound e₁ ρ ⟨≡⟩ʳ mconcat $≡ map/++ ρ (flatten e) (flatten e₁) ⟨≡⟩ mconcat/++ (map ρ (flatten e)) _ proof : ∀ e e₁ (ρ : Nat → A) → flatten e ≡ flatten e₁ → ⟦ e ⟧ ρ ≡ ⟦ e₁ ⟧ ρ proof e e₁ ρ nfeq = eraseEquality $ sound e ρ ⟨≡⟩ (⟦_⟧n ρ) $≡ nfeq ⟨≡⟩ʳ sound e₁ ρ
{ "alphanum_fraction": 0.4913657771, "avg_line_length": 33.5263157895, "ext": "agda", "hexsha": "84b8ee1323af5716ab11a4f01b540c92a8bf72e8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_path": "src/Tactic/Monoid/Proofs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lclem/agda-prelude", "max_issues_repo_path": "src/Tactic/Monoid/Proofs.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_path": "src/Tactic/Monoid/Proofs.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 596, "size": 1274 }
------------------------------------------------------------------------------ -- Example of a partial function using the Bove-Capretta method ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- From: Ana Bove and Venanzio Capretta. Nested general recursion and -- partiality in type theory. vol 2152 LNCS. 2001. module FOT.FOTC.Program.Min.MinBC-SL where open import Data.Nat renaming ( suc to succ ) open import Relation.Binary.PropositionalEquality ------------------------------------------------------------------------------ data minAcc : (ℕ → ℕ) → Set where minacc0 : (f : ℕ → ℕ) → f 0 ≡ 0 → minAcc f minacc1 : (f : ℕ → ℕ) → f 0 ≢ 0 → minAcc (λ n → f (succ n)) → minAcc f min : (f : ℕ → ℕ) → minAcc f → ℕ min f (minacc0 .f q) = 0 min f (minacc1 .f q h) = succ (min (λ n → f (succ n)) h)
{ "alphanum_fraction": 0.4648166501, "avg_line_length": 37.3703703704, "ext": "agda", "hexsha": "c4bdb3294be4c6d384e9299a424382c8e457b84a", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Program/Min/MinBC-SL.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Program/Min/MinBC-SL.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Program/Min/MinBC-SL.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 258, "size": 1009 }
open import Logic open import Logic.Classical open import Structure.Setoid open import Structure.OrderedField open import Type module Structure.Function.Metric {ℓF ℓₑF ℓ≤} {F : Type{ℓF}} ⦃ equiv-F : Equiv{ℓₑF}(F) ⦄ {_+_}{_⋅_} {_≤_ : _ → _ → Type{ℓ≤}} ⦃ orderedField-F : OrderedField{F = F}(_+_)(_⋅_)(_≤_) ⦄ ⦃ classical : ∀{ℓ}{P : Stmt{ℓ}} → Classical(P) ⦄ where open OrderedField(orderedField-F) import Lvl open import Data.Boolean open import Data.Boolean.Proofs import Data.Either as Either open import Data.Tuple as Tuple using (_⨯_ ; _,_) open import Functional as Fn open import Logic.Propositional open import Logic.Predicate open import Relator.Ordering open import Sets.PredicateSet renaming (_≡_ to _≡ₛ_) open import Structure.Setoid.Uniqueness open import Structure.Function.Ordering open import Structure.Operator.Field open import Structure.Operator.Monoid open import Structure.Operator.Group open import Structure.Operator.Proofs open import Structure.Operator.Properties open import Structure.Operator open import Structure.Relator.Ordering open Structure.Relator.Ordering.Weak.Properties open import Structure.Relator.Properties open import Syntax.Transitivity F₊ = ∃(Positive) module _ where record MetricSpace {ℓₘ ℓₑₘ} {M : Type{ℓₘ}} ⦃ equiv-M : Equiv{ℓₑₘ}(M) ⦄ (d : M → M → F) : Type{ℓF Lvl.⊔ ℓ≤ Lvl.⊔ ℓₘ Lvl.⊔ ℓₑₘ Lvl.⊔ ℓₑF} where field ⦃ distance-binary-operator ⦄ : BinaryOperator(d) self-distance : ∀{x y} → (d(x)(y) ≡ 𝟎) ↔ (x ≡ y) ⦃ distance-commutativity ⦄ : Commutativity(d) triangle-inequality : ∀{x y z} → (d(x)(z) ≤ (d(x)(y) + d(y)(z))) ⦃ non-negativity ⦄ : ∀{x y} → NonNegative(d(x)(y)) {- non-negativity{x}{y} = ([≤]ₗ-of-[+] ( 𝟎 d(x)(x) d(x)(y) + d(y)(x) d(x)(y) + d(x)(y) 2 ⋅ d(x)(y) )) -} distance-to-self : ∀{x} → (d(x)(x) ≡ 𝟎) distance-to-self = [↔]-to-[←] self-distance (reflexivity(_≡_)) Neighborhood : M → F₊ → PredSet(M) Neighborhood(p)([∃]-intro r)(q) = (d(p)(q) < r) Neighborhoods : ∀{ℓ} → M → PredSet(PredSet{ℓ}(M)) Neighborhoods(p)(N) = ∃(r ↦ N ≡ₛ Neighborhood(p)(r)) PuncturedNeighborhood : M → F₊ → PredSet(M) PuncturedNeighborhood(p)([∃]-intro r)(q) = (𝟎 < d(p)(q) < r) LimitPoint : ∀{ℓ} → PredSet{ℓ}(M) → PredSet(M) LimitPoint(E)(p) = ∀{r} → Overlapping(PuncturedNeighborhood(p)(r)) (E) IsolatedPoint : ∀{ℓ} → PredSet{ℓ}(M) → PredSet(M) IsolatedPoint(E)(p) = ∃(r ↦ Disjoint(PuncturedNeighborhood(p)(r)) (E)) Interior : ∀{ℓ} → PredSet{ℓ}(M) → PredSet(M) Interior(E)(p) = ∃(r ↦ Neighborhood(p)(r) ⊆ E) Closed : ∀{ℓ} → PredSet(PredSet{ℓ}(M)) Closed(E) = LimitPoint(E) ⊆ E Open : ∀{ℓ} → PredSet(PredSet{ℓ}(M)) Open(E) = E ⊆ Interior(E) Perfect : ∀{ℓ} → PredSet(PredSet{ℓ}(M)) Perfect(E) = LimitPoint(E) ≡ₛ E Bounded : ∀{ℓ} → PredSet(PredSet{ℓ}(M)) Bounded(E) = ∃(p ↦ ∃(r ↦ E ⊆ Neighborhood(p)(r))) Discrete : ∀{ℓ} → PredSet(PredSet{ℓ}(M)) Discrete(E) = E ⊆ IsolatedPoint(E) Closure : ∀{ℓ} → PredSet{ℓ}(M) → PredSet(M) Closure(E) = E ∪ LimitPoint(E) Dense : ∀{ℓ} → PredSet(PredSet{ℓ}(M)) Dense(E) = ∀{p} → (p ∈ Closure(E)) -- Compact Separated : ∀{ℓ₁ ℓ₂} → PredSet{ℓ₁}(M) → PredSet{ℓ₂}(M) → Stmt Separated(A)(B) = Disjoint(A)(Closure(B)) ∧ Disjoint(Closure(A))(B) Connected : ∀{ℓ} → PredSet{ℓ}(M) → Stmtω Connected(E) = ∀{ℓ₁ ℓ₂}{A : PredSet{ℓ₁}(M)}{B : PredSet{ℓ₂}(M)} → ((A ∪ B) ≡ₛ E) → Separated(A)(B) → ⊥ -- Complete = Sequence.Cauchy ⊆ Sequence.Converging neighborhood-contains-center : ∀{p}{r} → (p ∈ Neighborhood(p)(r)) neighborhood-contains-center {p}{[∃]-intro r ⦃ intro positive-r ⦄} = d(p)(p) 🝖-[ sub₂(_≡_)(_≤_) distance-to-self ]-sub 𝟎 🝖-semiend r 🝖-end-from-[ positive-r ] -- TODO: Not always the case? -- subneighborhood-subradius : ∀{p₁ p₂}{r₁ r₂} → (Neighborhood(p₁)(r₁) ⊆ Neighborhood(p₂)(r₂)) → ([∃]-witness r₁ ≤ [∃]-witness r₂) subneighborhood-radius : ∀{p₁ p₂}{r₁ r₂} → (Neighborhood(p₁)(r₁) ⊆ Neighborhood(p₂)(r₂)) ← (d(p₂)(p₁) ≤ ([∃]-witness r₂ − [∃]-witness r₁)) subneighborhood-radius {p₁} {p₂} {[∃]-intro r₁} {[∃]-intro r₂} p {q} qN₁ = d(p₂)(q) 🝖[ _≤_ ]-[ triangle-inequality ]-sub d(p₂)(p₁) + d(p₁)(q) 🝖[ _<_ ]-[ [<][+]-preserve-subₗ p qN₁ ]-super (r₂ − r₁) + r₁ 🝖[ _≡_ ]-[ {!inverseOperₗ ? ?!} ] -- inverseOperatorᵣ(_+_)(_−_) r₂ 🝖-end {-where r₁r₂ : (r₁ ≤ r₂) -- TODO: This seems to be provable, but not used here r₁r₂ = r₁ 🝖-[ {!!} ] d(p₁)(p₂) + r₁ 🝖-[ {!!} ] r₂ 🝖-end -} subneighborhood-radius-on-same : ∀{p}{r₁ r₂} → (Neighborhood(p)(r₁) ⊆ Neighborhood(p)(r₂)) ← ([∃]-witness r₁ ≤ [∃]-witness r₂) subneighborhood-radius-on-same {p} {[∃]-intro r₁} {[∃]-intro r₂} r₁r₂ {x} xN₁ xN₂ = xN₁ (r₁r₂ 🝖 xN₂) interior-is-subset : ∀{ℓ}{E : PredSet{ℓ}(M)} → Interior(E) ⊆ E interior-is-subset {ℓ} {E} {x} ([∃]-intro ([∃]-intro r ⦃ intro positive-r ⦄) ⦃ N⊆E ⦄) = N⊆E {x} (p ↦ positive-r ( r 🝖[ _≤_ ]-[ p ]-super d(x)(x) 🝖[ _≡_ ]-[ distance-to-self ] 𝟎 🝖[ _≡_ ]-end )) neighborhood-interior-is-self : ∀{p}{r} → (Interior(Neighborhood(p)(r)) ≡ₛ Neighborhood(p)(r)) ∃.witness (Tuple.left (neighborhood-interior-is-self {p} {r}) x) = r ∃.proof (Tuple.left (neighborhood-interior-is-self {p} {r} {x}) Nx) = {!!} Tuple.right (neighborhood-interior-is-self {p} {r}) = {!!} neighborhood-is-open : ∀{p}{r} → Open(Neighborhood(p)(r)) interior-is-largest-subspace : ∀{ℓ₁ ℓ₂}{E : PredSet{ℓ₁}(M)}{Eₛ : PredSet{ℓ₂}(M)} → Open(Eₛ) → (Eₛ ⊆ E) → (Eₛ ⊆ Interior(E)) nested-interior : ∀{ℓ}{E : PredSet{ℓ}(M)} → Interior(Interior(E)) ≡ₛ Interior(E) isolated-limit-eq : ∀{ℓ}{E : PredSet{ℓ}(M)} → (IsolatedPoint(E) ⊆ ∅ {Lvl.𝟎}) ↔ (E ⊆ LimitPoint(E)) interior-closure-eq1 : ∀{ℓ}{E : PredSet{ℓ}(M)} → ((∁ Interior(E)) ≡ₛ Closure(∁ E)) interior-closure-eq2 : ∀{ℓ}{E : PredSet{ℓ}(M)} → (Interior(∁ E) ≡ₛ (∁ Closure(E))) open-closed-eq1 : ∀{ℓ}{E : PredSet{ℓ}(M)} → (Open(E) ↔ Closed(∁ E)) open-closed-eq2 : ∀{ℓ}{E : PredSet{ℓ}(M)} → (Open(∁ E) ↔ Closed(E)) union-is-open : ∀{ℓ₁ ℓ₂}{A : PredSet{ℓ₁}(M)}{B : PredSet{ℓ₂}(M)} → Open(A) → Open(B) → Open(A ∪ B) intersection-is-open : ∀{ℓ₁ ℓ₂}{A : PredSet{ℓ₁}(M)}{B : PredSet{ℓ₂}(M)} → Open(A) → Open(B) → Open(A ∩ B) -- open-subsubspace : ∀{ℓ₁ ℓ₂}{Eₛ : PredSet{ℓ₁}(M)}{E : PredSet{ℓ₂}(M)} → separated-is-disjoint : ∀{ℓ₁ ℓ₂}{A : PredSet{ℓ₁}(M)}{B : PredSet{ℓ₂}(M)} → Separated(A)(B) → Disjoint(A)(B) unionₗ-is-connected : ∀{ℓ₁ ℓ₂}{A : PredSet{ℓ₁}(M)}{B : PredSet{ℓ₂}(M)} → Connected(A ∪ B) → Connected(A) unionᵣ-is-connected : ∀{ℓ₁ ℓ₂}{A : PredSet{ℓ₁}(M)}{B : PredSet{ℓ₂}(M)} → Connected(A ∪ B) → Connected(B) intersection-is-connected : ∀{ℓ₁ ℓ₂}{A : PredSet{ℓ₁}(M)}{B : PredSet{ℓ₂}(M)} → Connected(A) → Connected(B) → Connected(A ∩ B) module Sequence {ℓ} {M : Type{ℓ}} ⦃ equiv-M : Equiv(M) ⦄ (d : M → M → F) where open import Numeral.Natural import Numeral.Natural.Relation.Order as ℕ ConvergesTo : (ℕ → M) → M → Stmt ConvergesTo f(L) = ∃{Obj = F₊ → ℕ}(N ↦ ∀{ε : F₊}{n} → (n ℕ.≥ N(ε)) → (d(f(n))(L) < [∃]-witness ε)) Converging : (ℕ → M) → Stmt Converging(f) = ∃(ConvergesTo(f)) Diverging : (ℕ → M) → Stmt Diverging(f) = ∀{L} → ¬(ConvergesTo f(L)) lim : (f : ℕ → M) → ⦃ Converging(f) ⦄ → M lim(f) ⦃ [∃]-intro L ⦄ = L Cauchy : (ℕ → M) → Stmt Cauchy(f) = ∃{Obj = F₊ → ℕ}(N ↦ ∀{ε : F₊}{a b} → (a ℕ.≥ N(ε)) → (b ℕ.≥ N(ε)) → (d(f(a))(f(b)) < [∃]-witness ε)) Complete : Stmt Complete = Cauchy ⊆ Converging Bounded : (ℕ → M) → Stmt Bounded(f) = ∃(r ↦ ∃(p ↦ ∀{n} → (d(p)(f(n)) < r))) unique-converges-to : ∀{f} → Unique(ConvergesTo(f)) converging-bounded : Converging ⊆ Bounded -- strictly-ordered-sequence-limit : ∀{f g : ℕ → M} → (∀{n} → (f(n) < g(n))) → (lim f < lim g) -- ordered-sequence-limit : ∀{f g : ℕ → M} → (∀{n} → (f(n) ≤ g(n))) → (lim f ≤ lim g) -- limit-point-converging-sequence : ∀{E}{p} → LimitPoint(E)(p) → ∃(f ↦ (ConvergesTo f(p)) ∧ (∀{x} → (f(x) ∈ E))) -- TODO: Apparently, this requires both axiom of choice and excluded middle? At least the (←)-direction? -- continuous-sequence-convergence-composition : (ContinuousOn f(p)) ↔ (∀{g} → (ConvergesTo g(p)) → (ConvergesTo(f ∘ g)(f(p)))) {- module Series where ∑ : (ℕ → M) → ℕ → M ∑ f(𝟎) = 𝟎 ∑ f(𝐒(n)) = (∑ f(n)) + f(𝐒(n)) ∑₂ : (ℕ → M) → (ℕ ⨯ ℕ) → M ∑₂ f(a , b) = ∑ (f ∘ (a +_))(b − a) ConvergesTo : (ℕ → M) → M → Stmt ConvergesTo f(L) = Sequence.ConvergesTo(∑ f)(L) Converging : (ℕ → M) → Stmt Converging(f) = ∃(ConvergesTo(f)) Diverging : (ℕ → M) → Stmt Diverging(f) = ∀{L} → ¬(ConvergesTo f(L)) ConvergesTo : (ℕ → M) → M → Stmt AbsolutelyConvergesTo f(L) = ConvergesTo (‖_‖ ∘ f)(L) AbsolutelyConverging : (ℕ → M) → Stmt AbsolutelyConverging(f) = ∃(AbsolutelyConvergesTo(f)) AbsolutelyDiverging : (ℕ → M) → Stmt AbsolutelyDiverging(f) = ∀{L} → ¬(AbsolutelyConvergesTo f(L)) ConditionallyConverging : (ℕ → M) → Stmt ConditionallyConverging(f) = AbsolutelyDiverging(f) ∧ Converging(f) sequence-of-converging-series-converges-to-0 : Converging(f) → (Sequence.ConvergesTo f(𝟎)) convergence-by-ordering : (∀{n} → f(n) ≤ g(n)) → (Converging(f) ← Converging(g)) divergence-by-ordering : (∀{n} → f(n) ≤ g(n)) → (Diverging(f) → Diverging(g)) convergence-by-quotient : Sequence.Converging(n ↦ f(n) / g(n)) → (Converging(f) ↔ Converging(g)) -} module Analysis {ℓ₁ ℓ₂} {M₁ : Type{ℓ₁}} ⦃ equiv-M₁ : Equiv(M₁) ⦄ (d₁ : M₁ → M₁ → F) ⦃ space₁ : MetricSpace(d₁) ⦄ {M₂ : Type{ℓ₂}} ⦃ equiv-M₂ : Equiv(M₂) ⦄ (d₂ : M₂ → M₂ → F) ⦃ space₂ : MetricSpace(d₂) ⦄ where open MetricSpace Lim : ∀{ℓ}{E : PredSet{ℓ}(M₁)} → ((x : M₁) → ⦃ x ∈ E ⦄ → M₂) → M₁ → M₂ → Stmt Lim {E = E} f(p)(L) = ∃{Obj = F₊ → F₊}(δ ↦ ∀{ε : F₊}{x} → ⦃ ex : x ∈ E ⦄ → (p ∈ PuncturedNeighborhood(space₁)(x)(δ(ε))) → (L ∈ Neighborhood(space₂)(f(x) ⦃ ex ⦄)(ε))) lim : ∀{ℓ}{E : PredSet{ℓ}(M₁)} → (f : (x : M₁) → ⦃ x ∈ E ⦄ → M₂) → (p : M₁) → ⦃ ∃(Lim f(p)) ⦄ → M₂ lim f(p) ⦃ [∃]-intro L ⦄ = L ContinuousOn : ∀{ℓ}{E : PredSet{ℓ}(M₁)} → ((x : M₁) → ⦃ x ∈ E ⦄ → M₂) → (p : M₁) → ⦃ p ∈ E ⦄ → Stmt ContinuousOn f(p) = Lim f(p) (f(p)) Continuous : ∀{ℓ}{E : PredSet{ℓ}(M₁)} → ((x : M₁) → ⦃ x ∈ E ⦄ → M₂) → Stmt Continuous{E = E}(f) = ∀{p} → ⦃ ep : p ∈ E ⦄ → ContinuousOn f(p) ⦃ ep ⦄ -- continuous-mapping-connected : Continuous(f) → Connected(E) → Connected(map f(E))
{ "alphanum_fraction": 0.5517627308, "avg_line_length": 38.1565836299, "ext": "agda", "hexsha": "674ac393a2251b388cde441ecc2f11b3900435e6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Function/Metric.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Function/Metric.agda", "max_line_length": 167, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Function/Metric.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 4566, "size": 10722 }
module Positivity where data Nat : Set where zero : Nat suc : Nat -> Nat data List (A : Set) : Set where [] : List A _::_ : A -> List A -> List A data Tree : Set where node : List Tree -> Tree data Loop (A : Set) : Set where loop : Loop (Loop A) -> Loop A data _×_ (A B : Set) : Set where _,_ : A -> B -> A × B data PList (A : Set) : Set where leaf : A -> PList A succ : PList (A × A) -> PList A data Bush (A : Set) : Set where nil : Bush A cons : A -> Bush (Bush A) -> Bush A F : Set -> Set F A = A data Ok : Set where ok : F Ok -> Ok
{ "alphanum_fraction": 0.5426086957, "avg_line_length": 16.4285714286, "ext": "agda", "hexsha": "040cfa56a89b548ce7f5ee554c2524b71a8f00e3", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Positivity.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Positivity.agda", "max_line_length": 37, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Positivity.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 211, "size": 575 }
module Section10 where open import Section9 public -- 10. Conclusions -- =============== -- -- We have defined a calculus of proof trees for simply typed λ-calculus with explicit substitutions -- and we have proved that this calculus is sound and complete with respect to Kripke -- models. A decision algorithm for convertibility based on the technique of “normalisation by -- evaluation” has also been proven correct. -- -- One application of the results for proof trees is the soundness and completeness for a -- formulation of an implicitly-typed λ-calculus with explicit substitutions. -- -- An important aspect of this work is that it has been carried out on a machine; actually, -- the problem was partly chosen because it seemed possible to do the formalization in a nice -- way using ALF. It is often emphasised that a proof is machine checked, but this is the very -- minimum one can ask of a proof system. Another important aspect is that the system helps -- you to develop your proof, and I feel that ALF is on the right way: this work was not done -- first by pen and paper and then typed into the machine, but was from the very beginning -- carried out in interaction with the system. -- -- NOTE: The above paragraphs apply to Agda, as well. -- -- -- Appendix -- -------- -- -- (…) -- -- -- Acknowledgement -- --------------- -- -- The author wants to thank the editor Olivier Danvy for having had the patience with delays -- and still being supportive. She is also grateful to Bernd Grobauer for help with improving -- the presentation. The comments of the anonymous referees have also been very valuable. -- -- -- References -- ---------- -- -- 1. Abadi, M., Cardelli, L., Curien, P.-L., and Lévy, J.-J. -- Explicit substitutions. -- Journal of Functional Programming, 1(4) (1991) 375–416. -- -- 2. Berger, U. -- Program extraction from normalization proofs. -- In Proceedings of TLCA’93, LNCS, Vol. 664, Springer Verlag, Berlin, 1993, pp. 91–106. -- -- 3. Berger, U. and Schwichtenberg, H. -- An inverse of the evaluation functional for typed λ-calculus. -- In Proceedings of the 6th Annual IEEE Symposium on Logic in Comp. Sci., Amsterdam, 1991, pp. 203–211. -- -- 4. Coquand, Th. -- Pattern matching with dependent types. -- In Proceedings of the 1992 Workshop on Types for Proofs and Programs, B. Nordström, K. Petersson, and -- G. Plotkin (Eds.). Dept. of Comp. Sci. Chalmers Univ. of Technology and Göteborg Univ. -- Available at (…), pp. 66–79. -- -- 5. Coquand, Th. and Dybjer, P. -- Intuitionistic model constructions and normalisation proofs. -- Math. Structures Comp. Sci., 7(1) (1997) 75–94. -- -- 6. Coquand, Th. and Gallier, J. -- A proof of strong normalization for the theory of constructions using a Kripke-like interpretation. -- In Proceedings of the First Workshop in Logical Frameworks, G. Huet and G. Plotkin (Eds.). -- Available at (…), pp. 479–497. -- -- 7. Coquand, Th., Nordström, B., Smith, J., and von Sydow, B. -- Type theory and programming. -- EATCS, 52 (1994) 203–228. -- -- 8. Curien, P.-L. -- An abstract framework for environment machines. -- Theoretical Comp. Sci., 82 (1991) 389–402. -- -- 9. Friedman, H. -- Equality between functionals. -- In Logic Colloquium, Symposium on Logic, held at Boston, 1972–1973, LNCS, Vol. 453, -- Springer-Verlag, Berlin, 1975, pp. 22–37. -- -- 10. Gandy, R.O. -- On the axiom of extensionality—Part I. -- The Journal of symbolic logic, 21 (1956) 36–48. -- -- 11. Kripke S.A. -- Semantical analysis of intuitionistic logic I. -- In Formal Systems and Recursive Functions, J.N. Crossley and M.A.E. Dummet (Eds.). -- North-Holland, Amsterdam, 1965, pp. 92–130. -- -- 12. Magnusson, L. and Nordström, B. -- The ALF proof editor and its proof engine. -- In Types for Proofs and Programs, LNCS, Vol. 806, Springer-Verlag, Berlin, 1994, pp. 213–237. -- -- 13. Martin-Löf, P. -- Substitution calculus. -- Handwritten notes, Göteborg, 1992. -- -- 14. Mitchell, J.C. -- Type systems for programming languages. -- In Handbook of Theoretical Comp. Sci., Volume B: Formal Models and Semantics, J. van Leeuwen (Ed.). -- Elsevier and MIT Press, Amsterdam, 1990, pp. 365–458. -- -- 15. Mitchell, J.C. and Moggi, E. -- Kripke-style models for typed lambda calculus. -- Annals for Pure and Applied Logic, 51 (1991) 99–124. -- -- 16. Nordström, B., Petersson, K., and Smith, J. -- Programming in Martin-Löf’s Type THeory. An Introduction. -- Oxford University Press, Oxford, UK, 1990. -- -- 17. Scott, D.S. -- Relating theories lambda calculus. -- In To H.B. Curry: Essays on Combinatory Logic, Lambda Calculus, and Formalism. -- Academic Press, New York, 1980, pp. 403–450. -- -- 18. Statman, R. -- Logical relation and the typed λ-calculus. -- Information and Control, 65 (1985) 85–97. -- -- 19. Streicher, T. -- Semantics of Type Theory. -- Birkhäuser, Basel, 1991. -- -- 20. Tasistro, A. -- Formulation of Martin-Löf’s theory of types with explicit substitutions. -- Licentiate thesis, Dept. of Comp. Sci. Chalmers Univ. of Technology and Göteborg Univ., 1993.
{ "alphanum_fraction": 0.6761504678, "avg_line_length": 39.9770992366, "ext": "agda", "hexsha": "ee8bb292d1a7eae4a9ba7689e60c596c9931c544", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/coquand", "max_forks_repo_path": "src/Section10.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/coquand", "max_issues_repo_path": "src/Section10.agda", "max_line_length": 108, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/coquand", "max_stars_repo_path": "src/Section10.agda", "max_stars_repo_stars_event_max_datetime": "2017-09-07T12:44:40.000Z", "max_stars_repo_stars_event_min_datetime": "2017-03-27T01:29:58.000Z", "num_tokens": 1494, "size": 5237 }
{-# OPTIONS --cubical-compatible #-} module _ where infix 4 _≡_ data _≡_ {a} {A : Set a} (x : A) : A → Set a where instance refl : x ≡ x {-# BUILTIN EQUALITY _≡_ #-} {-# BUILTIN REFL refl #-} -- This should trigger a warning!
{ "alphanum_fraction": 0.6017316017, "avg_line_length": 23.1, "ext": "agda", "hexsha": "6dba9f1ec2fb607d0b8c3597687e3125e053547a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Succeed/Issue1988.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Succeed/Issue1988.agda", "max_line_length": 60, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Succeed/Issue1988.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 81, "size": 231 }
open import Agda.Primitive open import Agda.Builtin.List open import Agda.Builtin.Equality private variable a p : Level A : Set a P Q : A → Set p data Any {a p} {A : Set a} (P : A → Set p) : List A → Set (a ⊔ p) where here : ∀ {x xs} (px : P x) → Any P (x ∷ xs) there : ∀ {x xs} (pxs : Any P xs) → Any P (x ∷ xs) map : (∀ {x} → P x → Q x) → (∀ {xs} → Any P xs → Any Q xs) map g (here px) = here (g px) map g (there pxs) = there (map g pxs) postulate map-id : ∀ (f : ∀ {x} → P x → P x) → (∀ {x} (p : P x) → f p ≡ p) → ∀ {xs} → (p : Any P xs) → map f p ≡ p
{ "alphanum_fraction": 0.4899665552, "avg_line_length": 27.1818181818, "ext": "agda", "hexsha": "40bffaa3764d0a08a3f2d4352035180db72efb91", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue5147.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue5147.agda", "max_line_length": 71, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue5147.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 255, "size": 598 }
module Avionics.SafetyEnvelopes where open import Data.Bool using (Bool; true; false; _∧_; _∨_) open import Data.List using (List; []; _∷_; any; map; foldl; length) open import Data.List.Relation.Unary.Any as Any using (Any) open import Data.List.Relation.Unary.All as All using (All) open import Data.Maybe using (Maybe; just; nothing; is-just; _>>=_) open import Data.Nat using (ℕ; zero; suc) open import Data.Product using (_×_; proj₁; proj₂) renaming (_,_ to ⟨_,_⟩) open import Function using (_∘_) open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; cong; subst; sym) open import Relation.Unary using (_∈_) open import Relation.Nullary using (yes; no; ¬_) open import Relation.Nullary.Decidable using (fromWitnessFalse) open import Avionics.Real using (ℝ; _+_; _-_; _*_; _÷_; _^_; _<ᵇ_; _≤ᵇ_; _≤_; _<_; _<?_; _≤?_; _≟_; 1/_; 0ℝ; 1ℝ; 2ℝ; 1/2; _^2; √_; fromℕ) --open import Avionics.Product using (_×_; ⟨_,_⟩; proj₁; proj₂) open import Avionics.Probability using (Dist; NormalDist; ND; BiNormalDist) sum : List ℝ → ℝ sum = foldl _+_ 0ℝ inside : NormalDist → ℝ → ℝ → Bool inside nd z x = ((μ - z * σ) <ᵇ x) ∧ (x <ᵇ (μ + z * σ)) where open NormalDist nd using (μ; σ) mahalanobis1 : ℝ → ℝ → ℝ → ℝ mahalanobis1 u v IV = √((u - v) * IV * (u - v)) inside' : NormalDist → ℝ → ℝ → Bool inside' nd z x = mahalanobis1 μ x σ²-¹ <ᵇ z where open NormalDist nd using (μ; σ) σ²-¹ = 1/ (σ * σ) mahalanobis2 : (ℝ × ℝ) → (ℝ × ℝ) → (ℝ × ℝ × ℝ × ℝ) → ℝ --mahalanobis2 u v VI = ... mahalanobis2 ⟨ u₁ , u₂ ⟩ ⟨ v₁ , v₂ ⟩ ⟨ iv₁₁ , ⟨ iv₁₂ , ⟨ iv₂₁ , iv₂₂ ⟩ ⟩ ⟩ = √ ⟨u-v⟩IV⟨u-v⟩' where x₁ = u₁ - v₁ x₂ = u₂ - v₂ ⟨u-v⟩IV⟨u-v⟩' = (x₁ * x₁ * iv₁₁ + x₁ * x₂ * iv₁₂ + x₁ * x₂ * iv₂₁ + x₂ * x₂ * iv₂₂) insideBiv : BiNormalDist → ℝ → (ℝ × ℝ) → Bool insideBiv bnd z x = mahalanobis2 μ x Σ-¹ <ᵇ z where open BiNormalDist bnd using (μ; Σ-¹) FlightState = (ℝ × ℝ) record Model : Set where field -- Flight states SM : List FlightState -- Map from flight states to Normal Distributions fM : List (FlightState × (NormalDist × ℝ)) -- Every flight state must be represented in the map fM .fMisMap₁ : All (λ θ → Any (λ θ,ND → proj₁ θ,ND ≡ θ) fM ) SM .fMisMap₂ : All (λ θ,ND → Any (λ θ → proj₁ θ,ND ≡ θ) SM ) fM .lenSM>0 : length SM ≢ 0 --.lenfM>0 : length fM ≢ 0 -- this is the result of the bijection above and .lenSM>0 z-predictable' : List NormalDist → ℝ → ℝ → ℝ × Bool z-predictable' nds z x = ⟨ x , any (λ nd → inside nd z x) nds ⟩ z-predictable : Model → ℝ → ℝ → ℝ × Bool z-predictable M z x = z-predictable' (map (proj₁ ∘ proj₂) (Model.fM M)) z x -- sample-z-predictable : List NormalDist → ℝ → ℝ → List ℝ → Maybe (ℝ × ℝ × Bool) sample-z-predictable nds zμ zσ [] = nothing sample-z-predictable nds zμ zσ (_ ∷ []) = nothing sample-z-predictable nds zμ zσ xs@(_ ∷ _ ∷ _) = just ⟨ mean , ⟨ var_est , any inside'' nds ⟩ ⟩ where n = fromℕ (length xs) mean = (sum xs ÷ n) var_est = (sum (map (λ{x →(x - mean)^2}) xs) ÷ (n - 1ℝ)) inside'' : NormalDist → Bool inside'' nd = ((μ - zμ * σ) <ᵇ mean) ∧ (mean <ᵇ (μ + zμ * σ)) ∧ (σ^2 - zσ * std[σ^2] <ᵇ var) ∧ (var <ᵇ σ^2 + zσ * std[σ^2]) where open NormalDist nd using (μ; σ) σ^2 = σ ^2 --Var[σ^2] = 2 * (σ^2)^2 / n std[σ^2] = (√ 2ℝ) * (σ^2 ÷ (√ n)) -- Notice that the estimated variance here is computed assuming `μ` -- it's the mean of the distribution. This is so that Cramer-Rao -- lower bound can be applied to it var = (sum (map (λ{x →(x - μ)^2}) xs) ÷ n) nonneg-cf : ℝ → ℝ × Bool nonneg-cf x = ⟨ x , 0ℝ ≤ᵇ x ⟩ data StallClasses : Set where Stall NoStall Uncertain : StallClasses P[stall]f⟨_|stall⟩_ : ℝ → List (ℝ × ℝ × Dist ℝ) → ℝ P[stall]f⟨ x |stall⟩ pbs = sum (map unpack pbs) where unpack : ℝ × ℝ × Dist ℝ → ℝ unpack ⟨ P[θ] , ⟨ P[stall|θ] , dist ⟩ ⟩ = pdf x * P[θ] * P[stall|θ] where open Dist dist using (pdf) f⟨_⟩_ : ℝ → List (ℝ × ℝ × Dist ℝ) → ℝ f⟨ x ⟩ pbs = sum (map unpack pbs) where unpack : ℝ × ℝ × Dist ℝ → ℝ unpack ⟨ P[θ] , ⟨ _ , dist ⟩ ⟩ = pdf x * P[θ] where open Dist dist using (pdf) -- There should be a proof showing that the resulting value will always be in the interval [0,1] P[_|X=_]_ : StallClasses → ℝ → List (ℝ × ℝ × Dist ℝ) → Maybe ℝ P[ Stall |X= x ] pbs with f⟨ x ⟩ pbs ≟ 0ℝ ... | yes _ = nothing ... | no _ = just (((P[stall]f⟨ x |stall⟩ pbs) ÷ (f⟨ x ⟩ pbs))) P[ NoStall |X= x ] pbs with f⟨ x ⟩ pbs ≟ 0ℝ ... | yes _ = nothing ... | no _ = just (1ℝ - ((P[stall]f⟨ x |stall⟩ pbs) ÷ (f⟨ x ⟩ pbs))) P[ Uncertain |X= _ ] _ = nothing postulate -- TODO: Find out how to prove this! -- It probably requires to prove that P[Stall|X=x] + P[NoStall|X=x] ≡ 1 Stall≡1-NoStall : ∀ {x pbs p} → P[ Stall |X= x ] pbs ≡ just p → P[ NoStall |X= x ] pbs ≡ just (1ℝ - p) NoStall≡1-Stall : ∀ {x pbs p} → P[ NoStall |X= x ] pbs ≡ just p → P[ Stall |X= x ] pbs ≡ just (1ℝ - p) -- Main assumptions -- * 0.5 < τ ≤ 1 -- * 0 ≤ p ≤ 1 -- Of course, these assumptions are never explicit in the code. But note -- that, only the first assumption can be broken by an user bad input. The -- second assumption stems for probability theory, yet not proven but -- should be true ≤p→¬≤1-p : ∀ {τ p} -- This first line are the assumptions. From them, the rest should follow → 1/2 < τ → τ ≤ 1ℝ -- 0.5 < τ ≤ 1 → 0ℝ ≤ p → p ≤ 1ℝ -- 0 ≤ p ≤ 1 → τ ≤ p → ¬ τ ≤ (1ℝ - p) ≤1-p→¬≤p : ∀ {τ p} → 1/2 < τ → τ ≤ 1ℝ -- 0.5 < τ ≤ 1 → 0ℝ ≤ p → p ≤ 1ℝ -- 0 ≤ p ≤ 1 → τ ≤ (1ℝ - p) → ¬ τ ≤ p classify'' : List (ℝ × ℝ × Dist ℝ) → ℝ → ℝ → StallClasses classify'' pbs τ x with P[ Stall |X= x ] pbs ... | nothing = Uncertain ... | just p with τ ≤? p | τ ≤? (1ℝ - p) ... | yes _ | no _ = Stall ... | no _ | yes _ = NoStall ... | _ | _ = Uncertain -- the only missing case is `no _ | no _`, `yes _ | yes _` is not possible M→pbs : Model → List (ℝ × ℝ × Dist ℝ) M→pbs M = map convert (Model.fM M) where n = fromℕ (length (Model.fM M)) convert : (ℝ × ℝ) × (NormalDist × ℝ) → ℝ × ℝ × Dist ℝ convert ⟨ _ , ⟨ nd , P[stall|c] ⟩ ⟩ = ⟨ 1/ n , ⟨ P[stall|c] , dist ⟩ ⟩ where open NormalDist nd using (dist) classify : Model → ℝ → ℝ → StallClasses classify M = classify'' (M→pbs M) no-uncertain : StallClasses → Bool no-uncertain Uncertain = false no-uncertain _ = true τ-confident : Model → ℝ → ℝ → Bool τ-confident M τ = no-uncertain ∘ classify M τ safety-envelope : Model → ℝ → ℝ → ℝ → Bool safety-envelope M z τ x = proj₂ (z-predictable M z x) ∧ τ-confident M τ x
{ "alphanum_fraction": 0.5509729887, "avg_line_length": 36.6276595745, "ext": "agda", "hexsha": "38da35db2e60e89063a2df1ba307b8fda0be629f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-09-20T00:36:09.000Z", "max_forks_repo_forks_event_min_datetime": "2020-09-20T00:36:09.000Z", "max_forks_repo_head_hexsha": "bf518286f9d06dc6ea91e111be6ddedb3e2b728f", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "helq/safety-envelopes-sentinels", "max_forks_repo_path": "agda/Avionics/SafetyEnvelopes.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bf518286f9d06dc6ea91e111be6ddedb3e2b728f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "helq/safety-envelopes-sentinels", "max_issues_repo_path": "agda/Avionics/SafetyEnvelopes.agda", "max_line_length": 117, "max_stars_count": null, "max_stars_repo_head_hexsha": "bf518286f9d06dc6ea91e111be6ddedb3e2b728f", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "helq/safety-envelopes-sentinels", "max_stars_repo_path": "agda/Avionics/SafetyEnvelopes.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2684, "size": 6886 }
{-# OPTIONS --without-K #-} open import Base open import Coinduction module CoindEquiv where -- Coinductive equivalences record _∼_ {i j} (A : Set i) (B : Set j) : Set (max i j) where constructor _,_,_ field to : A → B from : B → A eq : ∞ ((a : A) (b : B) → ((to a ≡ b) ∼ (a ≡ from b))) -- Identity id-∼ : ∀ {i} (A : Set i) → A ∼ A id-∼ A = (id A) , (id A) , ♯ (λ a b → id-∼ (a ≡ b)) -- Transitivity trans-∼ : ∀ {i} {A B C : Set i} → A ∼ B → B ∼ C → A ∼ C trans-∼ (to , from , eq) (to' , from' , eq') = ((to' ◯ to) , (from ◯ from') , ♯ (λ a c → trans-∼ (♭ eq' (to a) c) (♭ eq a (from' c))) ) --(λ a c → ♯ trans-∼ (♭ (eq' (to a) c)) (♭ (eq a (from' c))))) -- -- Left unity -- left-unit-∼ : ∀ {i} {A B : Set i} (f : A ∼ B) → trans-∼ (id-∼ A) f ≡ f -- left-unit-∼ f = {!!} postulate !-≡ : ∀ {i} {A : Set i} {u v : A} → (u ≡ v) ≡ (v ≡ u) -- Symmetry is harder sym-∼ : ∀ {i} {A B : Set i} → A ∼ B → B ∼ A sym-∼ (to , from , eq) = (from , to , ♯ (λ b a → let (too , fromo , eqo) = sym-∼ (♭ eq a b) in ((! ◯ (too ◯ !)) , {!!} , {!!}))) --(λ a b → transport (λ u → ∞ (u ∼ (a ≡ to b))) !-≡ (transport (λ u → ∞ ((b ≡ from a) ∼ u)) !-≡ (♯ (sym-∼ (♭ (eq b a))))))) --♯ trans-∼ {!!} (trans-∼ (sym-∼ (♭ (eq b a))) {!!}))) -- Logical equivalence with the usual notion of equivalences ∼-to-≃ : ∀ {i j} {A : Set i} {B : Set j} → (A ∼ B → A ≃ B) ∼-to-≃ (to , from , eq) = (to , iso-is-eq to from (λ b → _∼_.from (♭ eq (from b) b) refl) (λ a → ! (_∼_.to (♭ eq a (to a)) refl))) ≃-to-∼ : ∀ {i j} {A : Set i} {B : Set j} → (A ≃ B → A ∼ B) ≃-to-∼ e = (π₁ e) , (inverse e) , ♯ (λ a b → ≃-to-∼ (equiv-compose (path-to-eq (ap (λ b → e ☆ a ≡ b) (! (inverse-right-inverse e b)))) ((equiv-ap e a (inverse e b))⁻¹))) -- Unfinished attempt to prove that this notion is coherent ∼-eq-raw : ∀ {i j} {A : Set i} {B : Set j} {f f' : A → B} (p : f ≡ f') {g g' : B → A} (q : g ≡ g') {eq : ∞ ((a : A) (b : B) → ((f a ≡ b) ∼ (a ≡ g b)))} {eq' : ∞ ((a : A) (b : B) → ((f' a ≡ b) ∼ (a ≡ g' b)))} (r : transport _ p (transport _ q eq) ≡ eq') → (f , g , eq) ≡ (f' , g' , eq') ∼-eq-raw refl refl refl = refl -- ∼-eq : ∀ {i j} {A : Set i} {B : Set j} -- {f f' : A → B} (p : (a : A) → f a ≡ f' a) -- {g g' : B → A} (q : (b : B) → g b ≡ g' b) -- {eq : (a : A) (b : B) → ∞ ((f a ≡ b) ∼ (a ≡ g b))} -- {eq' : (a : A) (b : B) → ∞ ((f' a ≡ b) ∼ (a ≡ g' b))} -- (r : (a : A) (b : B) → -- transport (λ u → (u ≡ b) ∼ (a ≡ g' b)) (p a) ( -- transport (λ u → (f a ≡ b) ∼ (a ≡ u)) (q b) (♭ (eq a b))) -- ≡ ♭ (eq' a b)) -- → (f , g , eq) ≡ (f' , g' , eq') -- ∼-eq p q r = ∼-eq-raw (funext p) (funext q) -- (funext (λ a → (funext (λ b → {!r a b!})))) -- coherent : ∀ {i j} (A : Set i) (B : Set j) → ((A ≃ B) ≃ (A ∼ B)) -- coherent A B = (≃-to-∼ A B , iso-is-eq _ (∼-to-≃ A B) -- (λ y → ∼-eq (λ a → refl _) -- (λ b → happly (inverse-iso-is-eq (_∼_.to y) (_∼_.from y) _ _) b) -- (λ a b → {!!})) -- (λ e → Σ-eq (refl _) (π₁ (is-equiv-is-prop _ _ _))))
{ "alphanum_fraction": 0.3943476832, "avg_line_length": 36.6626506024, "ext": "agda", "hexsha": "8ac3f2ed28d94ca9047b63de8e4ad3dca3e544c4", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "old/CoindEquiv.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "old/CoindEquiv.agda", "max_line_length": 178, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "old/CoindEquiv.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 1494, "size": 3043 }
{-# OPTIONS --safe #-} module Definition.Typed.Consequences.Substitution where open import Definition.Untyped open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.EqRelInstance open import Definition.Typed.Weakening open import Definition.Typed.Consequences.Syntactic open import Definition.LogicalRelation open import Definition.LogicalRelation.Properties open import Definition.LogicalRelation.Substitution open import Definition.LogicalRelation.Substitution.Irrelevance open import Definition.LogicalRelation.Fundamental open import Tools.Product import Tools.PropositionalEquality as PE -- Well-formed substitution of types. substitution : ∀ {A rA Γ Δ σ} → Γ ⊢ A ^ rA → Δ ⊢ˢ σ ∷ Γ → ⊢ Δ → Δ ⊢ subst σ A ^ rA substitution A σ ⊢Δ = let X = fundamental A [Γ] = proj₁ X [A] = proj₂ X Y = fundamentalSubst (wf A) ⊢Δ σ [Γ]′ = proj₁ Y [σ] = proj₂ Y in escape (proj₁ ([A] ⊢Δ (irrelevanceSubst [Γ]′ [Γ] ⊢Δ ⊢Δ [σ]))) -- Well-formed substitution of type equality. substitutionEq : ∀ {A B rA Γ Δ σ σ′} → Γ ⊢ A ≡ B ^ rA → Δ ⊢ˢ σ ≡ σ′ ∷ Γ → ⊢ Δ → Δ ⊢ subst σ A ≡ subst σ′ B ^ rA substitutionEq A≡B σ ⊢Δ = let X = fundamentalEq A≡B [Γ] = proj₁ X [A] = proj₁ (proj₂ X) [B] = proj₁ (proj₂ (proj₂ X)) [A≡B] = proj₂ (proj₂ (proj₂ X)) Y = fundamentalSubstEq (wfEq A≡B) ⊢Δ σ [Γ]′ = proj₁ Y [σ] = proj₁ (proj₂ Y) [σ′] = proj₁ (proj₂ (proj₂ Y)) [σ≡σ′] = proj₂ (proj₂ (proj₂ Y)) [σ]′ = irrelevanceSubst [Γ]′ [Γ] ⊢Δ ⊢Δ [σ] [σ′]′ = irrelevanceSubst [Γ]′ [Γ] ⊢Δ ⊢Δ [σ′] [σ≡σ′]′ = irrelevanceSubstEq [Γ]′ [Γ] ⊢Δ ⊢Δ [σ] [σ]′ [σ≡σ′] in escapeEq (proj₁ ([A] ⊢Δ [σ]′)) (transEq (proj₁ ([A] ⊢Δ [σ]′)) (proj₁ ([B] ⊢Δ [σ]′)) (proj₁ ([B] ⊢Δ [σ′]′)) ([A≡B] ⊢Δ [σ]′) (proj₂ ([B] ⊢Δ [σ]′) [σ′]′ [σ≡σ′]′)) -- Well-formed substitution of terms. substitutionTerm : ∀ {t A rA Γ Δ σ} → Γ ⊢ t ∷ A ^ rA → Δ ⊢ˢ σ ∷ Γ → ⊢ Δ → Δ ⊢ subst σ t ∷ subst σ A ^ rA substitutionTerm t σ ⊢Δ = let X = fundamentalTerm t [Γ] = proj₁ X [A] = proj₁ (proj₂ X) [t] = proj₂ (proj₂ X) Y = fundamentalSubst (wfTerm t) ⊢Δ σ [Γ]′ = proj₁ Y [σ] = proj₂ Y [σ]′ = irrelevanceSubst [Γ]′ [Γ] ⊢Δ ⊢Δ [σ] in escapeTerm (proj₁ ([A] ⊢Δ [σ]′)) (proj₁ ([t] ⊢Δ [σ]′)) -- Well-formed substitution of term equality. substitutionEqTerm : ∀ {t u A rA Γ Δ σ σ′} → Γ ⊢ t ≡ u ∷ A ^ rA → Δ ⊢ˢ σ ≡ σ′ ∷ Γ → ⊢ Δ → Δ ⊢ subst σ t ≡ subst σ′ u ∷ subst σ A ^ rA substitutionEqTerm t≡u σ≡σ′ ⊢Δ with fundamentalTermEq t≡u substitutionEqTerm t≡u σ≡σ′ ⊢Δ | [Γ] , modelsTermEq [A] [t] [u] [t≡u] = let Y = fundamentalSubstEq (wfEqTerm t≡u) ⊢Δ σ≡σ′ [Γ]′ = proj₁ Y [σ] = proj₁ (proj₂ Y) [σ′] = proj₁ (proj₂ (proj₂ Y)) [σ≡σ′] = proj₂ (proj₂ (proj₂ Y)) [σ]′ = irrelevanceSubst [Γ]′ [Γ] ⊢Δ ⊢Δ [σ] [σ′]′ = irrelevanceSubst [Γ]′ [Γ] ⊢Δ ⊢Δ [σ′] [σ≡σ′]′ = irrelevanceSubstEq [Γ]′ [Γ] ⊢Δ ⊢Δ [σ] [σ]′ [σ≡σ′] in escapeTermEq (proj₁ ([A] ⊢Δ [σ]′)) (transEqTerm (proj₁ ([A] ⊢Δ [σ]′)) ([t≡u] ⊢Δ [σ]′) (proj₂ ([u] ⊢Δ [σ]′) [σ′]′ [σ≡σ′]′)) -- Reflexivity of well-formed substitution. substRefl : ∀ {σ Γ Δ} → Δ ⊢ˢ σ ∷ Γ → Δ ⊢ˢ σ ≡ σ ∷ Γ substRefl id = id substRefl (σ , x) = substRefl σ , genRefl x -- Weakening of well-formed substitution. wkSubst′ : ∀ {ρ σ Γ Δ Δ′} (⊢Γ : ⊢ Γ) (⊢Δ : ⊢ Δ) (⊢Δ′ : ⊢ Δ′) ([ρ] : ρ ∷ Δ′ ⊆ Δ) ([σ] : Δ ⊢ˢ σ ∷ Γ) → Δ′ ⊢ˢ ρ •ₛ σ ∷ Γ wkSubst′ ε ⊢Δ ⊢Δ′ ρ id = id wkSubst′ (_∙_ {Γ} {A} ⊢Γ ⊢A) ⊢Δ ⊢Δ′ ρ (tailσ , headσ) = wkSubst′ ⊢Γ ⊢Δ ⊢Δ′ ρ tailσ , PE.subst (λ x → _ ⊢ _ ∷ x ^ _) (wk-subst A) (wkTerm ρ ⊢Δ′ headσ) -- Weakening of well-formed substitution by one. wk1Subst′ : ∀ {F rF σ Γ Δ} (⊢Γ : ⊢ Γ) (⊢Δ : ⊢ Δ) (⊢F : Δ ⊢ F ^ rF) ([σ] : Δ ⊢ˢ σ ∷ Γ) → (Δ ∙ F ^ rF) ⊢ˢ wk1Subst σ ∷ Γ wk1Subst′ {F} {σ} {Γ} {Δ} ⊢Γ ⊢Δ ⊢F [σ] = wkSubst′ ⊢Γ ⊢Δ (⊢Δ ∙ ⊢F) (step id) [σ] -- Lifting of well-formed substitution. liftSubst′ : ∀ {F rF σ Γ Δ} (⊢Γ : ⊢ Γ) (⊢Δ : ⊢ Δ) (⊢F : Γ ⊢ F ^ rF) ([σ] : Δ ⊢ˢ σ ∷ Γ) → (Δ ∙ subst σ F ^ rF) ⊢ˢ liftSubst σ ∷ Γ ∙ F ^ rF liftSubst′ {F} {rF} {σ} {Γ} {Δ} ⊢Γ ⊢Δ ⊢F [σ] = let ⊢Δ∙F = ⊢Δ ∙ substitution ⊢F [σ] ⊢Δ in wkSubst′ ⊢Γ ⊢Δ ⊢Δ∙F (step id) [σ] , var ⊢Δ∙F (PE.subst (λ x → 0 ∷ x ^ rF ∈ (Δ ∙ subst σ F ^ rF)) (wk-subst F) here) -- Well-formed identity substitution. idSubst′ : ∀ {Γ} (⊢Γ : ⊢ Γ) → Γ ⊢ˢ idSubst ∷ Γ idSubst′ ε = id idSubst′ (_∙_ {Γ} {A} {rA} ⊢Γ ⊢A) = wk1Subst′ ⊢Γ ⊢Γ ⊢A (idSubst′ ⊢Γ) , PE.subst (λ x → Γ ∙ A ^ rA ⊢ _ ∷ x ^ rA) (wk1-tailId A) (var (⊢Γ ∙ ⊢A) here) -- Well-formed substitution composition. substComp′ : ∀ {σ σ′ Γ Δ Δ′} (⊢Γ : ⊢ Γ) (⊢Δ : ⊢ Δ) (⊢Δ′ : ⊢ Δ′) ([σ] : Δ′ ⊢ˢ σ ∷ Δ) ([σ′] : Δ ⊢ˢ σ′ ∷ Γ) → Δ′ ⊢ˢ σ ₛ•ₛ σ′ ∷ Γ substComp′ ε ⊢Δ ⊢Δ′ [σ] id = id substComp′ (_∙_ {Γ} {A} {rA} ⊢Γ ⊢A) ⊢Δ ⊢Δ′ [σ] ([tailσ′] , [headσ′]) = substComp′ ⊢Γ ⊢Δ ⊢Δ′ [σ] [tailσ′] , PE.subst (λ x → _ ⊢ _ ∷ x ^ rA) (substCompEq A) (substitutionTerm [headσ′] [σ] ⊢Δ′) -- Well-formed singleton substitution of terms. singleSubst : ∀ {A t rA Γ} → Γ ⊢ t ∷ A ^ rA → Γ ⊢ˢ sgSubst t ∷ Γ ∙ A ^ rA singleSubst {A} {rA = rA} t = let ⊢Γ = wfTerm t in idSubst′ ⊢Γ , PE.subst (λ x → _ ⊢ _ ∷ x ^ rA) (PE.sym (subst-id A)) t -- Well-formed singleton substitution of term equality. singleSubstEq : ∀ {A t u rA Γ} → Γ ⊢ t ≡ u ∷ A ^ rA → Γ ⊢ˢ sgSubst t ≡ sgSubst u ∷ Γ ∙ A ^ rA singleSubstEq {A} {rA = rA} t = let ⊢Γ = wfEqTerm t in substRefl (idSubst′ ⊢Γ) , PE.subst (λ x → _ ⊢ _ ≡ _ ∷ x ^ rA) (PE.sym (subst-id A)) t -- Well-formed singleton substitution of terms with lifting. singleSubst↑ : ∀ {A t rA Γ} → Γ ∙ A ^ rA ⊢ t ∷ wk1 A ^ rA → Γ ∙ A ^ rA ⊢ˢ consSubst (wk1Subst idSubst) t ∷ Γ ∙ A ^ rA singleSubst↑ {A} {rA = rA} t with wfTerm t ... | ⊢Γ ∙ ⊢A = wk1Subst′ ⊢Γ ⊢Γ ⊢A (idSubst′ ⊢Γ) , PE.subst (λ x → _ ∙ A ^ rA ⊢ _ ∷ x ^ _) (wk1-tailId A) t -- Well-formed singleton substitution of term equality with lifting. singleSubst↑Eq : ∀ {A rA t u Γ} → Γ ∙ A ^ rA ⊢ t ≡ u ∷ wk1 A ^ rA → Γ ∙ A ^ rA ⊢ˢ consSubst (wk1Subst idSubst) t ≡ consSubst (wk1Subst idSubst) u ∷ Γ ∙ A ^ rA singleSubst↑Eq {A} {rA} t with wfEqTerm t ... | ⊢Γ ∙ ⊢A = substRefl (wk1Subst′ ⊢Γ ⊢Γ ⊢A (idSubst′ ⊢Γ)) , PE.subst (λ x → _ ∙ A ^ rA ⊢ _ ≡ _ ∷ x ^ rA) (wk1-tailId A) t -- Helper lemmas for single substitution substType : ∀ {t F rF G rG Γ} → Γ ∙ F ^ rF ⊢ G ^ rG → Γ ⊢ t ∷ F ^ rF → Γ ⊢ G [ t ] ^ rG substType {t} {F} {G} ⊢G ⊢t = let ⊢Γ = wfTerm ⊢t in substitution ⊢G (singleSubst ⊢t) ⊢Γ substTypeEq : ∀ {t u F rF G E rG Γ} → Γ ∙ F ^ rF ⊢ G ≡ E ^ rG → Γ ⊢ t ≡ u ∷ F ^ rF → Γ ⊢ G [ t ] ≡ E [ u ] ^ rG substTypeEq {F = F} ⊢G ⊢t = let ⊢Γ = wfEqTerm ⊢t in substitutionEq ⊢G (singleSubstEq ⊢t) ⊢Γ substTerm : ∀ {F rF G rG t f Γ} → Γ ∙ F ^ rF ⊢ f ∷ G ^ rG → Γ ⊢ t ∷ F ^ rF → Γ ⊢ f [ t ] ∷ G [ t ] ^ rG substTerm {F} {G} {t} {f} ⊢f ⊢t = let ⊢Γ = wfTerm ⊢t in substitutionTerm ⊢f (singleSubst ⊢t) ⊢Γ substTypeΠ : ∀ {t F rF lF lG G rΠ lΠ Γ} → Γ ⊢ Π F ^ rF ° lF ▹ G ° lG ° lΠ ^ [ rΠ , ι lΠ ] → Γ ⊢ t ∷ F ^ [ rF , ι lF ] → Γ ⊢ G [ t ] ^ [ rΠ , ι lG ] substTypeΠ ΠFG t with syntacticΠ ΠFG substTypeΠ ΠFG t | F , G = substType G t subst↑Type : ∀ {t F rF G rG Γ} → Γ ∙ F ^ rF ⊢ G ^ rG → Γ ∙ F ^ rF ⊢ t ∷ wk1 F ^ rF → Γ ∙ F ^ rF ⊢ G [ t ]↑ ^ rG subst↑Type ⊢G ⊢t = substitution ⊢G (singleSubst↑ ⊢t) (wfTerm ⊢t) subst↑TypeEq : ∀ {t u F rF G E rG Γ} → Γ ∙ F ^ rF ⊢ G ≡ E ^ rG → Γ ∙ F ^ rF ⊢ t ≡ u ∷ wk1 F ^ rF → Γ ∙ F ^ rF ⊢ G [ t ]↑ ≡ E [ u ]↑ ^ rG subst↑TypeEq ⊢G ⊢t = substitutionEq ⊢G (singleSubst↑Eq ⊢t) (wfEqTerm ⊢t)
{ "alphanum_fraction": 0.4979012346, "avg_line_length": 39.3203883495, "ext": "agda", "hexsha": "cd58d3e580f253f4f52069473f1ac22e4f96cc16", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/Typed/Consequences/Substitution.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/Typed/Consequences/Substitution.agda", "max_line_length": 117, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/Typed/Consequences/Substitution.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z", "max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z", "num_tokens": 3847, "size": 8100 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Construction.Kleisli where open import Level open import Categories.Category open import Categories.Functor using (Functor; module Functor) open import Categories.NaturalTransformation hiding (id) open import Categories.Monad import Categories.Morphism.Reasoning as MR private variable o ℓ e : Level Kleisli : {𝒞 : Category o ℓ e} → Monad 𝒞 → Category o ℓ e Kleisli {𝒞 = 𝒞} M = record { Obj = Obj ; _⇒_ = λ A B → (A ⇒ F₀ B) ; _≈_ = _≈_ ; _∘_ = λ f g → (μ.η _ ∘ F₁ f) ∘ g ; id = η.η _ ; assoc = assoc′ ; sym-assoc = Equiv.sym assoc′ ; identityˡ = identityˡ′ ; identityʳ = identityʳ′ ; identity² = identity²′ ; equiv = equiv ; ∘-resp-≈ = λ f≈h g≈i → ∘-resp-≈ (∘-resp-≈ʳ (F-resp-≈ f≈h)) g≈i } where module M = Monad M open M using (μ; η; F) open Functor F open Category 𝒞 open HomReasoning open MR 𝒞 -- shorthands to make the proofs nicer F≈ = F-resp-≈ assoc′ : ∀ {A B C D} {f : A ⇒ F₀ B} {g : B ⇒ F₀ C} {h : C ⇒ F₀ D} → (μ.η D ∘ (F₁ ((μ.η D ∘ F₁ h) ∘ g))) ∘ f ≈ (μ.η D ∘ F₁ h) ∘ ((μ.η C ∘ F₁ g) ∘ f) assoc′ {A} {B} {C} {D} {f} {g} {h} = begin (μ.η D ∘ F₁ ((μ.η D ∘ F₁ h) ∘ g)) ∘ f ≈⟨ assoc ⟩ μ.η D ∘ (F₁ ((μ.η D ∘ F₁ h) ∘ g) ∘ f) ≈⟨ refl⟩∘⟨ (F≈ assoc ⟩∘⟨refl ) ⟩ μ.η D ∘ (F₁ (μ.η D ∘ (F₁ h ∘ g)) ∘ f) ≈⟨ refl⟩∘⟨ (homomorphism ⟩∘⟨refl) ⟩ μ.η D ∘ ((F₁ (μ.η D) ∘ F₁ (F₁ h ∘ g)) ∘ f) ≈⟨ refl⟩∘⟨ assoc ○ ⟺ assoc ⟩ (μ.η D ∘ F₁ (μ.η D)) ∘ (F₁ (F₁ h ∘ g) ∘ f) ≈⟨ M.assoc ⟩∘⟨refl ○ assoc ⟩ μ.η D ∘ (μ.η (F₀ D) ∘ (F₁ (F₁ h ∘ g) ∘ f)) ≈˘⟨ refl⟩∘⟨ assoc ⟩ μ.η D ∘ ((μ.η (F₀ D) ∘ F₁ (F₁ h ∘ g)) ∘ f) ≈⟨ refl⟩∘⟨ ( (refl⟩∘⟨ homomorphism) ⟩∘⟨refl) ⟩ μ.η D ∘ ((μ.η (F₀ D) ∘ (F₁ (F₁ h) ∘ F₁ g)) ∘ f) ≈˘⟨ refl⟩∘⟨ (assoc ⟩∘⟨refl) ⟩ μ.η D ∘ (((μ.η (F₀ D) ∘ F₁ (F₁ h)) ∘ F₁ g) ∘ f) ≈⟨ refl⟩∘⟨ ((μ.commute h ⟩∘⟨refl) ⟩∘⟨refl) ⟩ μ.η D ∘ (((F₁ h ∘ μ.η C) ∘ F₁ g) ∘ f) ≈⟨ refl⟩∘⟨ (assoc ⟩∘⟨refl) ⟩ μ.η D ∘ ((F₁ h ∘ (μ.η C ∘ F₁ g)) ∘ f) ≈⟨ refl⟩∘⟨ assoc ○ ⟺ assoc ⟩ (μ.η D ∘ F₁ h) ∘ ((μ.η C ∘ F₁ g) ∘ f) ∎ identityˡ′ : ∀ {A B} {f : A ⇒ F₀ B} → (μ.η B ∘ F₁ (η.η B)) ∘ f ≈ f identityˡ′ {A} {B} {f} = elimˡ M.identityˡ identityʳ′ : ∀ {A B} {f : A ⇒ F₀ B} → (μ.η B ∘ F₁ f) ∘ η.η A ≈ f identityʳ′ {A} {B} {f} = begin (μ.η B ∘ F₁ f) ∘ η.η A ≈⟨ assoc ⟩ μ.η B ∘ (F₁ f ∘ η.η A) ≈˘⟨ refl⟩∘⟨ η.commute f ⟩ μ.η B ∘ (η.η (F₀ B) ∘ f) ≈˘⟨ assoc ⟩ (μ.η B ∘ η.η (F₀ B)) ∘ f ≈⟨ elimˡ M.identityʳ ⟩ f ∎ identity²′ : {A : Obj} → (μ.η A ∘ F₁ (η.η A)) ∘ η.η A ≈ η.η A identity²′ = elimˡ M.identityˡ
{ "alphanum_fraction": 0.4455587393, "avg_line_length": 37.2266666667, "ext": "agda", "hexsha": "11f320ba4ba4b7c2d047581a5af20442f699a6a7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Taneb/agda-categories", "max_forks_repo_path": "Categories/Category/Construction/Kleisli.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Taneb/agda-categories", "max_issues_repo_path": "Categories/Category/Construction/Kleisli.agda", "max_line_length": 103, "max_stars_count": null, "max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Taneb/agda-categories", "max_stars_repo_path": "Categories/Category/Construction/Kleisli.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1478, "size": 2792 }
{-# OPTIONS --rewriting #-} module Examples.Run where open import Agda.Builtin.Equality using (_≡_; refl) open import Agda.Builtin.Bool using (true; false) open import Luau.Syntax using (nil; var; _$_; function_is_end; return; _∙_; done; _⟨_⟩; number; binexp; +; <; val; bool; ~=; string) open import Luau.Run using (run; return) ex1 : (run (function "id" ⟨ var "x" ⟩ is return (var "x") ∙ done end ∙ return (var "id" $ val nil) ∙ done) ≡ return nil _) ex1 = refl ex2 : (run (function "fn" ⟨ var "x" ⟩ is return (val (number 123.0)) ∙ done end ∙ return (var "fn" $ val nil) ∙ done) ≡ return (number 123.0) _) ex2 = refl ex3 : (run (function "fn" ⟨ var "x" ⟩ is return (binexp (val (number 1.0)) + (val (number 2.0))) ∙ done end ∙ return (var "fn" $ val nil) ∙ done) ≡ return (number 3.0) _) ex3 = refl ex4 : (run (function "fn" ⟨ var "x" ⟩ is return (binexp (val (number 1.0)) < (val (number 2.0))) ∙ done end ∙ return (var "fn" $ val nil) ∙ done) ≡ return (bool true) _) ex4 = refl ex5 : (run (function "fn" ⟨ var "x" ⟩ is return (binexp (val (string "foo")) ~= (val (string "bar"))) ∙ done end ∙ return (var "fn" $ val nil) ∙ done) ≡ return (bool true) _) ex5 = refl
{ "alphanum_fraction": 0.6164965986, "avg_line_length": 49, "ext": "agda", "hexsha": "84ebf84e2278ad456ea0ae4d949b0fd0ff1a6094", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "XanderYZZ/luau", "max_forks_repo_path": "prototyping/Examples/Run.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "XanderYZZ/luau", "max_issues_repo_path": "prototyping/Examples/Run.agda", "max_line_length": 174, "max_stars_count": 1, "max_stars_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "TheGreatSageEqualToHeaven/luau", "max_stars_repo_path": "prototyping/Examples/Run.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-05T21:53:03.000Z", "max_stars_repo_stars_event_min_datetime": "2021-12-05T21:53:03.000Z", "num_tokens": 443, "size": 1176 }
------------------------------------------------------------------------------ -- Properties for the bisimilarity relation ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Relation.Binary.Bisimilarity.PropertiesATP where open import FOTC.Base open import FOTC.Base.List open import FOTC.Data.Stream.Type open import FOTC.Relation.Binary.Bisimilarity.Type ------------------------------------------------------------------------------ -- Because a greatest post-fixed point is a fixed-point, the -- bisimilarity relation _≈_ on unbounded lists is also a pre-fixed -- point of the bisimulation functional (see -- FOTC.Relation.Binary.Bisimulation). -- See Issue https://github.com/asr/apia/issues/81 . ≈-inB : D → D → Set ≈-inB xs ys = ∃[ x' ] ∃[ xs' ] ∃[ ys' ] xs ≡ x' ∷ xs' ∧ ys ≡ x' ∷ ys' ∧ xs' ≈ ys' {-# ATP definition ≈-inB #-} ≈-in : ∀ {xs ys} → ∃[ x' ] ∃[ xs' ] ∃[ ys' ] xs ≡ x' ∷ xs' ∧ ys ≡ x' ∷ ys' ∧ xs' ≈ ys' → xs ≈ ys ≈-in h = ≈-coind ≈-inB h' h where postulate h' : ∀ {xs} {ys} → ≈-inB xs ys → ∃[ x' ] ∃[ xs' ] ∃[ ys' ] xs ≡ x' ∷ xs' ∧ ys ≡ x' ∷ ys' ∧ ≈-inB xs' ys' {-# ATP prove h' #-} -- See Issue https://github.com/asr/apia/issues/81 . ≈-reflB : D → D → Set ≈-reflB xs ys = xs ≡ ys ∧ Stream xs {-# ATP definition ≈-reflB #-} ≈-refl : ∀ {xs} → Stream xs → xs ≈ xs ≈-refl {xs} Sxs = ≈-coind ≈-reflB h₁ h₂ where postulate h₁ : ∀ {xs ys} → ≈-reflB xs ys → ∃[ x' ] ∃[ xs' ] ∃[ ys' ] xs ≡ x' ∷ xs' ∧ ys ≡ x' ∷ ys' ∧ ≈-reflB xs' ys' {-# ATP prove h₁ #-} postulate h₂ : ≈-reflB xs xs {-# ATP prove h₂ #-} -- See Issue https://github.com/asr/apia/issues/81 . ≈-symB : D → D → Set ≈-symB xs ys = ys ≈ xs {-# ATP definition ≈-symB #-} ≈-sym : ∀ {xs ys} → xs ≈ ys → ys ≈ xs ≈-sym {xs} {ys} xs≈ys = ≈-coind ≈-symB h₁ h₂ where postulate h₁ : ∀ {ys} {xs} → ≈-symB ys xs → ∃[ y' ] ∃[ ys' ] ∃[ xs' ] ys ≡ y' ∷ ys' ∧ xs ≡ y' ∷ xs' ∧ ≈-symB ys' xs' {-# ATP prove h₁ #-} postulate h₂ : ≈-symB ys xs {-# ATP prove h₂ #-} -- See Issue https://github.com/asr/apia/issues/81 . ≈-transB : D → D → Set ≈-transB xs zs = ∃[ ys ] xs ≈ ys ∧ ys ≈ zs {-# ATP definition ≈-transB #-} ≈-trans : ∀ {xs ys zs} → xs ≈ ys → ys ≈ zs → xs ≈ zs ≈-trans {xs} {ys} {zs} xs≈ys ys≈zs = ≈-coind ≈-transB h₁ h₂ where postulate h₁ : ∀ {as} {cs} → ≈-transB as cs → ∃[ a' ] ∃[ as' ] ∃[ cs' ] as ≡ a' ∷ as' ∧ cs ≡ a' ∷ cs' ∧ ≈-transB as' cs' {-# ATP prove h₁ #-} postulate h₂ : ≈-transB xs zs {-# ATP prove h₂ #-} postulate ∷-injective≈ : ∀ {x xs ys} → x ∷ xs ≈ x ∷ ys → xs ≈ ys {-# ATP prove ∷-injective≈ #-} postulate ∷-rightCong≈ : ∀ {x xs ys} → xs ≈ ys → x ∷ xs ≈ x ∷ ys {-# ATP prove ∷-rightCong≈ ≈-in #-}
{ "alphanum_fraction": 0.4763202726, "avg_line_length": 31.5591397849, "ext": "agda", "hexsha": "c7cdb7ae88d13094ef05e49d5b874faa30dc20d2", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Relation/Binary/Bisimilarity/PropertiesATP.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Relation/Binary/Bisimilarity/PropertiesATP.agda", "max_line_length": 83, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Relation/Binary/Bisimilarity/PropertiesATP.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 1151, "size": 2935 }
open import Data.Nat hiding ( _+_; _*_; _⊔_; zero ) open import Algebra hiding (Zero) open import Level using (Level; _⊔_) open import Data.Product module quad { c ℓ } ( ring : Ring c ℓ ) where open Ring ring data Nat4 : Set where One : Nat4 Suc : Nat4 -> Nat4 variable a b d : Level A : Set a B : Set b C : Set c m n : Nat4 -- Indu:ctive definition of a Quad matrix data Quad ( A : Set a ) : Nat4 → Set a where Zero : Quad A n Scalar : A → Quad A One Mtx : ( nw ne sw se : Quad A n ) → Quad A (Suc n) -- Zero with explicit size zeroQ : ( n : Nat4) → Quad A n zeroQ n = Zero oneQ : ∀ { n } → Quad Carrier n oneQ {One} = Scalar 1# oneQ {Suc n} = Mtx oneQ Zero Zero oneQ -- Equality -- eq-Zero is only valid when m ≡ n data EqQ {A : Set a} (_∼_ : A -> A -> Set d) : (xs : Quad A m) (ys : Quad A n) → Set (a ⊔ d) where eq-Zero : ∀ { n } → EqQ _∼_ (zeroQ n) (zeroQ n) eq-Scalar : { x y : A } ( x∼y : x ∼ y ) → EqQ _∼_ (Scalar x) (Scalar y) eq-Mtx : { nw1 ne1 sw1 se1 : Quad A m } { nw2 ne2 sw2 se2 : Quad A n } ( nw : EqQ _∼_ nw1 nw2 ) ( ne : EqQ _∼_ ne1 ne2 ) ( sw : EqQ _∼_ sw1 sw2 ) ( se : EqQ _∼_ se1 se2 ) → EqQ _∼_ (Mtx nw1 ne1 sw1 se1) (Mtx nw2 ne2 sw2 se2) _=q_ : Quad Carrier n -> Quad Carrier n -> Set ( c ⊔ ℓ) _=q_ = EqQ _≈_ -- Functions mapq : ∀ { A B : Set } → ( A → B ) → Quad A n -> Quad B n mapq f Zero = Zero mapq f (Scalar x) = Scalar (f x) mapq f (Mtx nw ne sw se) = Mtx (mapq f nw) (mapq f ne) (mapq f sw) (mapq f se) -- Addition on Quads _+q_ : ( x y : Quad Carrier n) → Quad Carrier n Zero +q y = y Scalar x +q Zero = Scalar x Scalar x +q Scalar x₁ = Scalar (x + x₁) Mtx x x₁ x₂ x₃ +q Zero = Mtx x x₁ x₂ x₃ Mtx x x₁ x₂ x₃ +q Mtx y y₁ y₂ y₃ = Mtx (x +q y) (x₁ +q y₁) (x₂ +q y₂) (x₃ +q y₃) -- Multiplication data Q' ( A : Set a) : Set a where Mtx' : ( nw ne sw se : A ) → Q' A Q'toQuad : Q' (Quad A n) → Quad A (Suc n) -- Q'toQuad (Mtx' Zero Zero Zero Zero) = Zero Q'toQuad (Mtx' nw ne sw se) = Mtx nw ne sw se zipQ' : ( A → B → C ) → Q' A → Q' B → Q' C zipQ' _op_ (Mtx' nw ne sw se) (Mtx' nw₁ ne₁ sw₁ se₁) = Mtx' (nw op nw₁) (ne op ne₁) (sw op sw₁) (se op se₁) colExchange : Q' A → Q' A colExchange (Mtx' nw ne sw se) = Mtx' ne nw se sw prmDiagSqsh : Q' A → Q' A prmDiagSqsh (Mtx' nw ne sw se) = Mtx' nw se nw se offDiagSqsh : Q' A → Q' A offDiagSqsh (Mtx' nw ne sw se) = Mtx' sw ne sw se _*q_ : ( x y : Quad Carrier n) → Quad Carrier n Zero *q y = Zero Scalar x *q Zero = Zero Scalar x *q Scalar x₁ = Scalar (x * x₁) Mtx x x₁ x₂ x₃ *q Zero = Zero Mtx x x₁ x₂ x₃ *q Mtx y y₁ y₂ y₃ = let X = Mtx' x x₁ x₂ x₃ Y = Mtx' y y₁ y₂ y₃ in Q'toQuad (zipQ' _+q_ (zipQ' _*q_ (colExchange X) (offDiagSqsh Y)) (zipQ' _*q_ X (prmDiagSqsh Y))) -- Example Quad q1 : Quad ℕ (Suc One) q1 = Mtx (Scalar 2) (Scalar 7) Zero Zero q2 : Quad ℕ (Suc (Suc One)) q2 = Mtx q1 q1 Zero (Mtx (Scalar 1) Zero Zero (Scalar 1)) -- Proofs quad-refl : { a : Quad Carrier n } → a =q a quad-refl { n } { Zero } = eq-Zero quad-refl { n } { (Scalar x) } = eq-Scalar refl quad-refl { n } { (Mtx a a₁ a₂ a₃) } = eq-Mtx quad-refl quad-refl quad-refl quad-refl quad-sym : { a b : Quad Carrier n } → a =q b → b =q a quad-sym eq-Zero = eq-Zero quad-sym (eq-Scalar x∼y) = eq-Scalar (sym x∼y) quad-sym (eq-Mtx x x₁ x₂ x₃) = eq-Mtx (quad-sym x) (quad-sym x₁) (quad-sym x₂) (quad-sym x₃) quad-zerol : ∀ { n } ( x : Quad Carrier n ) → ( Zero +q x ) =q x quad-zerol x = quad-refl quad-zeror : ∀ { n } ( x : Quad Carrier n ) → ( x +q Zero ) =q x quad-zeror Zero = quad-refl quad-zeror (Scalar x) = quad-refl quad-zeror (Mtx x x₁ x₂ x₃) = quad-refl -- Need a proof that Zero is left and right +q-identity -- Should be some kind of (quad-zerol, quad-zeror) quad-comm : ( a b : Quad Carrier n ) → ( a +q b) =q ( b +q a ) quad-comm Zero b = quad-sym (quad-zeror b) quad-comm (Scalar x) Zero = quad-refl quad-comm (Scalar x) (Scalar x₁) = eq-Scalar (+-comm x x₁) quad-comm (Mtx a a₁ a₂ a₃) Zero = quad-refl quad-comm (Mtx a a₁ a₂ a₃) (Mtx b b₁ b₂ b₃) = eq-Mtx (quad-comm a b) (quad-comm a₁ b₁) (quad-comm a₂ b₂) (quad-comm a₃ b₃) quad-assoc : ( a b c : Quad Carrier n ) → ((a +q b ) +q c ) =q ( a +q ( b +q c )) quad-assoc Zero b c = quad-refl quad-assoc (Scalar x) Zero c = quad-refl quad-assoc (Scalar x) (Scalar x₁) Zero = quad-refl quad-assoc (Scalar x) (Scalar x₁) (Scalar x₂) = eq-Scalar (+-assoc x x₁ x₂) quad-assoc (Mtx a a₁ a₂ a₃) Zero c = quad-refl quad-assoc (Mtx a a₁ a₂ a₃) (Mtx b b₁ b₂ b₃) Zero = quad-refl quad-assoc (Mtx a a₁ a₂ a₃) (Mtx b b₁ b₂ b₃) (Mtx c c₁ c₂ c₃) = eq-Mtx (quad-assoc a b c ) (quad-assoc a₁ b₁ c₁) (quad-assoc a₂ b₂ c₂) (quad-assoc a₃ b₃ c₃) quad-*-zerol : ( x : Quad Carrier n ) → ( Zero *q x ) =q Zero quad-*-zerol x = eq-Zero quad-*-zeror : ( x : Quad Carrier n ) → ( x *q Zero ) =q Zero quad-*-zeror Zero = eq-Zero quad-*-zeror (Scalar x) = eq-Zero quad-*-zeror (Mtx x x₁ x₂ x₃) = eq-Zero quad-onel : ( x : Quad Carrier n ) → ( oneQ *q x ) =q x quad-onel-lemma : ( x : Quad Carrier n ) → ((oneQ *q x) +q Zero) =q x quad-onel-lemma {One} Zero = eq-Zero quad-onel-lemma {Suc n} Zero = eq-Zero quad-onel-lemma (Scalar x) = eq-Scalar (*-identityˡ x) quad-onel-lemma (Mtx x x₁ x₂ x₃) = eq-Mtx (quad-onel x) (quad-onel-lemma x₁) (quad-onel-lemma x₂) (quad-onel x₃) quad-onel Zero = quad-*-zeror oneQ quad-onel (Scalar x) = eq-Scalar (*-identityˡ x) quad-onel (Mtx x x₁ x₂ x₃) = eq-Mtx (quad-onel x) (quad-onel-lemma x₁) (quad-onel-lemma x₂) (quad-onel x₃)
{ "alphanum_fraction": 0.5581752947, "avg_line_length": 30.6439790576, "ext": "agda", "hexsha": "208af95f451fcfdf17a19b042ccc8e7a336e3a96", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "87c0340515b0965454d9ba240ecc6de84b74ee0a", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "DSLsofMath/BScProj2021", "max_forks_repo_path": "agda/quad.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "87c0340515b0965454d9ba240ecc6de84b74ee0a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "DSLsofMath/BScProj2021", "max_issues_repo_path": "agda/quad.agda", "max_line_length": 114, "max_stars_count": null, "max_stars_repo_head_hexsha": "87c0340515b0965454d9ba240ecc6de84b74ee0a", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "DSLsofMath/BScProj2021", "max_stars_repo_path": "agda/quad.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2366, "size": 5853 }
-- Andreas, 2016-09-20, issue #2196 reported by mechvel -- Test case by Ulf -- {-# OPTIONS -v tc.lhs.dot:40 #-} data _≡_ {a} {A : Set a} (x : A) : A → Set a where refl : x ≡ x record _×_ (A B : Set) : Set where constructor _,_ field fst : A snd : B open _×_ EqP₁ : ∀ {A B} (p q : A × B) → Set EqP₁ (x , y) (z , w) = (x ≡ z) × (y ≡ w) EqP₂ : ∀ {A B} (p q : A × B) → Set EqP₂ p q = (fst p ≡ fst q) × (snd p ≡ snd q) works : {A : Set} (p q : A × A) → EqP₁ p q → Set₁ works (x , y) .(x , y) (refl , refl) = Set test : {A : Set} (p q : A × A) → EqP₂ p q → Set₁ test (x , y) .(x , y) (refl , refl) = Set -- ERROR WAS: -- Failed to infer the value of dotted pattern -- when checking that the pattern .(x , y) has type .A × .A
{ "alphanum_fraction": 0.5114401077, "avg_line_length": 24.7666666667, "ext": "agda", "hexsha": "4ad7613cf7acd003ff4067c2044b0183711d73d0", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue2196.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue2196.agda", "max_line_length": 59, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue2196.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 325, "size": 743 }
{- This file contains: - The first Eilenberg–Mac Lane type as a HIT -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.EilenbergMacLane1.Base where open import Cubical.Foundations.Prelude open import Cubical.Algebra.Group.Base private variable ℓ : Level module _ (G : Group {ℓ}) where open Group G data EM₁ : Type ℓ where embase : EM₁ emloop : Carrier → embase ≡ embase emcomp : (g h : Carrier) → PathP (λ j → embase ≡ emloop h j) (emloop g) (emloop (g + h)) -- emsquash : ∀ (x y : EM₁) (p q : x ≡ y) (r s : p ≡ q) → r ≡ s emsquash : isGroupoid EM₁ {- The comp// constructor fills the square: emloop (g + h) [a]— — — >[c] ‖ ^ ‖ | emloop h ^ ‖ | j | [a]— — — >[b] ∙ — > emloop g i We use this to give another constructor-like construction: -} emloop-comp : (g h : Carrier) → emloop (g + h) ≡ emloop g ∙ emloop h emloop-comp g h i = compPath-unique refl (emloop g) (emloop h) (emloop (g + h) , emcomp g h) (emloop g ∙ emloop h , compPath-filler (emloop g) (emloop h)) i .fst
{ "alphanum_fraction": 0.5555555556, "avg_line_length": 25.8, "ext": "agda", "hexsha": "defded51bbcc0b26c06cf7f61a00f868bcc3d3e6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_path": "Cubical/HITs/EilenbergMacLane1/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Schippmunk/cubical", "max_issues_repo_path": "Cubical/HITs/EilenbergMacLane1/Base.agda", "max_line_length": 74, "max_stars_count": null, "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_path": "Cubical/HITs/EilenbergMacLane1/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 401, "size": 1161 }
{-# OPTIONS --safe #-} module Cubical.Algebra.CommAlgebra.FGIdeal where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Structure open import Cubical.Foundations.Powerset open import Cubical.Data.FinData open import Cubical.Data.Nat open import Cubical.Data.Vec open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.FGIdeal using () renaming (generatedIdeal to generatedIdealCommRing; indInIdeal to ringIncInIdeal; 0FGIdeal to 0FGIdealCommRing) open import Cubical.Algebra.CommAlgebra open import Cubical.Algebra.CommAlgebra.Ideal private variable ℓ : Level R : CommRing ℓ generatedIdeal : {n : ℕ} (A : CommAlgebra R ℓ) → FinVec (fst A) n → IdealsIn A generatedIdeal A = generatedIdealCommRing (CommAlgebra→CommRing A) incInIdeal : {n : ℕ} (A : CommAlgebra R ℓ) (U : FinVec ⟨ A ⟩ n) (i : Fin n) → U i ∈ fst (generatedIdeal A U) incInIdeal A = ringIncInIdeal (CommAlgebra→CommRing A) syntax generatedIdeal A V = ⟨ V ⟩[ A ] module _ {R : CommRing ℓ} (A : CommAlgebra R ℓ) where open CommAlgebraStr (snd A) 0FGIdeal : {n : ℕ} → ⟨ replicateFinVec n 0a ⟩[ A ] ≡ (0Ideal A) 0FGIdeal = 0FGIdealCommRing (CommAlgebra→CommRing A)
{ "alphanum_fraction": 0.7081681205, "avg_line_length": 33.1842105263, "ext": "agda", "hexsha": "e06ed81b11f3a1179beb778046dc6a0c84665109", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Algebra/CommAlgebra/FGIdeal.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Algebra/CommAlgebra/FGIdeal.agda", "max_line_length": 79, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/CommAlgebra/FGIdeal.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 385, "size": 1261 }
{-# OPTIONS --without-K #-} module algebra.monoid.morphism where open import level open import algebra.monoid.core open import algebra.semigroup.morphism open import equality.core open import function.isomorphism open import hott.level open import sum module _ {i}{j} {X : Set i}⦃ sX : IsMonoid X ⦄ {Y : Set j}⦃ sY : IsMonoid Y ⦄ where open IsMonoid ⦃ ... ⦄ record IsMonoidMorphism (f : X → Y) : Set (i ⊔ j) where constructor mk-is-monoid-morphism field sgrp-mor : IsSemigroupMorphism f id-pres : f e ≡ e is-monoid-morphism-struct-iso : (f : X → Y) → IsMonoidMorphism f ≅ (IsSemigroupMorphism f × (f e ≡ e)) is-monoid-morphism-struct-iso f = record { to = λ mor → ( IsMonoidMorphism.sgrp-mor mor , IsMonoidMorphism.id-pres mor ) ; from = λ { (s , i) → mk-is-monoid-morphism s i } ; iso₁ = λ _ → refl ; iso₂ = λ _ → refl } is-monoid-morphism-level : (f : X → Y) → h 1 (IsMonoidMorphism f) is-monoid-morphism-level f = iso-level (sym≅ (is-monoid-morphism-struct-iso f)) (×-level (is-semigroup-morphism-level f) (is-set _ _))
{ "alphanum_fraction": 0.6300884956, "avg_line_length": 30.5405405405, "ext": "agda", "hexsha": "fe76198e28aaba99c55c8df43c9fd283bb919f76", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_path": "src/algebra/monoid/morphism.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/algebra/monoid/morphism.agda", "max_line_length": 67, "max_stars_count": 20, "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_path": "src/algebra/monoid/morphism.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "num_tokens": 381, "size": 1130 }
{- DUARel for the constant unit family -} {-# OPTIONS --no-exact-split --safe #-} module Cubical.Displayed.Unit where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Data.Unit open import Cubical.Displayed.Base open import Cubical.Displayed.Constant private variable ℓA ℓ≅A : Level 𝒮-Unit : UARel Unit ℓ-zero 𝒮-Unit .UARel._≅_ _ _ = Unit 𝒮-Unit .UARel.ua _ _ = invEquiv (isContr→≃Unit (isProp→isContrPath isPropUnit _ _)) 𝒮ᴰ-Unit : {A : Type ℓA} (𝒮-A : UARel A ℓ≅A) → DUARel 𝒮-A (λ _ → Unit) ℓ-zero 𝒮ᴰ-Unit 𝒮-A = 𝒮ᴰ-const 𝒮-A 𝒮-Unit
{ "alphanum_fraction": 0.7245696401, "avg_line_length": 22.8214285714, "ext": "agda", "hexsha": "6d24f8539e3f38c408bdbcd0c944a44d084aa63a", "lang": "Agda", "max_forks_count": 134, "max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z", "max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z", "max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "marcinjangrzybowski/cubical", "max_forks_repo_path": "Cubical/Displayed/Unit.agda", "max_issues_count": 584, "max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z", "max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "marcinjangrzybowski/cubical", "max_issues_repo_path": "Cubical/Displayed/Unit.agda", "max_line_length": 83, "max_stars_count": 301, "max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "marcinjangrzybowski/cubical", "max_stars_repo_path": "Cubical/Displayed/Unit.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z", "num_tokens": 252, "size": 639 }
------------------------------------------------------------------------ -- Compiler correctness ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --sized-types #-} module Lambda.Simplified.Delay-monad.Compiler-correctness where import Equality.Propositional as E open import Prelude open import Prelude.Size open import Monad E.equality-with-J open import Vec.Function E.equality-with-J open import Delay-monad open import Delay-monad.Bisimilarity open import Delay-monad.Monad open import Lambda.Simplified.Compiler open import Lambda.Simplified.Delay-monad.Interpreter open import Lambda.Simplified.Delay-monad.Virtual-machine open import Lambda.Simplified.Syntax open import Lambda.Simplified.Virtual-machine private module C = Closure Code module T = Closure Tm -- Compiler correctness. mutual ⟦⟧-correct : ∀ {i n} t {ρ : T.Env n} {c s} {k : T.Value → Delay (Maybe C.Value) ∞} → (∀ v → [ i ] exec ⟨ c , val (comp-val v) ∷ s , comp-env ρ ⟩ ≈ k v) → [ i ] exec ⟨ comp t c , s , comp-env ρ ⟩ ≈ ⟦ t ⟧ ρ >>= k ⟦⟧-correct (var x) {ρ} {c} {s} {k} hyp = exec ⟨ var x ∷ c , s , comp-env ρ ⟩ ≳⟨⟩ exec ⟨ c , val (comp-val (ρ x)) ∷ s , comp-env ρ ⟩ ≈⟨ hyp (ρ x) ⟩∼ k (ρ x) ∼⟨⟩ ⟦ var x ⟧ ρ >>= k ∎ ⟦⟧-correct (ƛ t) {ρ} {c} {s} {k} hyp = exec ⟨ clo (comp t (ret ∷ [])) ∷ c , s , comp-env ρ ⟩ ≳⟨⟩ exec ⟨ c , val (comp-val (T.ƛ t ρ)) ∷ s , comp-env ρ ⟩ ≈⟨ hyp (T.ƛ t ρ) ⟩∼ k (T.ƛ t ρ) ∼⟨⟩ ⟦ ƛ t ⟧ ρ >>= k ∎ ⟦⟧-correct (t₁ · t₂) {ρ} {c} {s} {k} hyp = exec ⟨ comp t₁ (comp t₂ (app ∷ c)) , s , comp-env ρ ⟩ ≈⟨ (⟦⟧-correct t₁ λ v₁ → ⟦⟧-correct t₂ λ v₂ → ∙-correct v₁ v₂ hyp) ⟩∼ (⟦ t₁ ⟧ ρ >>= λ v₁ → ⟦ t₂ ⟧ ρ >>= λ v₂ → v₁ ∙ v₂ >>= k) ∼⟨ (⟦ t₁ ⟧ ρ ∎) >>=-cong (λ _ → associativity′ (⟦ t₂ ⟧ ρ) _ _) ⟩ (⟦ t₁ ⟧ ρ >>= λ v₁ → (⟦ t₂ ⟧ ρ >>= λ v₂ → v₁ ∙ v₂) >>= k) ∼⟨ associativity′ (⟦ t₁ ⟧ ρ) _ _ ⟩ ⟦ t₁ · t₂ ⟧ ρ >>= k ∎ ∙-correct : ∀ {i n} v₁ v₂ {ρ : T.Env n} {c s} {k : T.Value → Delay (Maybe C.Value) ∞} → (∀ v → [ i ] exec ⟨ c , val (comp-val v) ∷ s , comp-env ρ ⟩ ≈ k v) → [ i ] exec ⟨ app ∷ c , val (comp-val v₂) ∷ val (comp-val v₁) ∷ s , comp-env ρ ⟩ ≈ v₁ ∙ v₂ >>= k ∙-correct (T.ƛ t₁ ρ₁) v₂ {ρ} {c} {s} {k} hyp = exec ⟨ app ∷ c , val (comp-val v₂) ∷ val (comp-val (T.ƛ t₁ ρ₁)) ∷ s , comp-env ρ ⟩ ≈⟨ later (λ { .force → exec ⟨ comp t₁ (ret ∷ []) , ret c (comp-env ρ) ∷ s , cons (comp-val v₂) (comp-env ρ₁) ⟩ ≡⟨ E.cong (λ ρ′ → exec ⟨ comp t₁ (ret ∷ []) , ret c (comp-env ρ) ∷ s , ρ′ ⟩) $ E.sym comp-cons ⟩ exec ⟨ comp t₁ (ret ∷ []) , ret c (comp-env ρ) ∷ s , comp-env (cons v₂ ρ₁) ⟩ ≈⟨ ⟦⟧-correct t₁ (λ v → exec ⟨ ret ∷ [] , val (comp-val v) ∷ ret c (comp-env ρ) ∷ s , comp-env (cons v₂ ρ₁) ⟩ ≳⟨⟩ exec ⟨ c , val (comp-val v) ∷ s , comp-env ρ ⟩ ≈⟨ hyp v ⟩∎ k v ∎) ⟩∼ ⟦ t₁ ⟧ (cons v₂ ρ₁) >>= k ∎ }) ⟩∎ T.ƛ t₁ ρ₁ ∙ v₂ >>= k ∎ -- Note that the equality that is used here is syntactic. correct : ∀ t → exec ⟨ comp t [] , [] , nil ⟩ ≈ ⟦ t ⟧ nil >>= λ v → return (just (comp-val v)) correct t = exec ⟨ comp t [] , [] , nil ⟩ ≡⟨ E.cong (λ ρ → exec ⟨ comp t [] , [] , ρ ⟩) $ E.sym comp-nil ⟩ exec ⟨ comp t [] , [] , comp-env nil ⟩ ≈⟨ ⟦⟧-correct t (λ v → return (just (comp-val v)) ∎) ⟩ (⟦ t ⟧ nil >>= λ v → return (just (comp-val v))) ∎
{ "alphanum_fraction": 0.3820406279, "avg_line_length": 39.3818181818, "ext": "agda", "hexsha": "999f97d6a15fc151c51fb0299ca23c965fd5216b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/partiality-monad", "max_forks_repo_path": "src/Lambda/Simplified/Delay-monad/Compiler-correctness.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/partiality-monad", "max_issues_repo_path": "src/Lambda/Simplified/Delay-monad/Compiler-correctness.agda", "max_line_length": 141, "max_stars_count": 2, "max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/partiality-monad", "max_stars_repo_path": "src/Lambda/Simplified/Delay-monad/Compiler-correctness.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:08.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:59:18.000Z", "num_tokens": 1480, "size": 4332 }
module omega-automaton where open import Level renaming ( suc to succ ; zero to Zero ) open import Data.Nat open import Data.List open import Data.Maybe -- open import Data.Bool using ( Bool ; true ; false ; _∧_ ) renaming ( not to negate ) open import Relation.Binary.PropositionalEquality hiding ( [_] ) open import Relation.Nullary -- using (not_; Dec; yes; no) open import Data.Empty open import logic open import automaton open Automaton ω-run : { Q Σ : Set } → (Ω : Automaton Q Σ ) → (astart : Q ) → ℕ → ( ℕ → Σ ) → Q ω-run Ω x zero s = x ω-run Ω x (suc n) s = δ Ω (ω-run Ω x n s) ( s n ) -- -- accept as Buchi automaton -- record Buchi { Q Σ : Set } (Ω : Automaton Q Σ ) ( S : ℕ → Σ ) : Set where field from : ℕ stay : (x : Q) → (n : ℕ ) → n > from → aend Ω ( ω-run Ω x n S ) ≡ true open Buchi -- after sometimes, always p -- -- not p -- ------------> -- <> [] p * <> [] p -- <----------- -- p -- -- accept as Muller automaton -- record Muller { Q Σ : Set } (Ω : Automaton Q Σ ) ( S : ℕ → Σ ) : Set where field next : (n : ℕ ) → ℕ infinite : (x : Q) → (n : ℕ ) → aend Ω ( ω-run Ω x (n + (next n)) S ) ≡ true -- always sometimes p -- -- not p -- ------------> -- [] <> p * [] <> p -- <----------- -- p data States3 : Set where ts* : States3 ts : States3 transition3 : States3 → Bool → States3 transition3 ts* true = ts* transition3 ts* false = ts transition3 ts true = ts* transition3 ts false = ts mark1 : States3 → Bool mark1 ts* = true mark1 ts = false ωa1 : Automaton States3 Bool ωa1 = record { δ = transition3 ; aend = mark1 } true-seq : ℕ → Bool true-seq _ = true false-seq : ℕ → Bool false-seq _ = false flip-seq : ℕ → Bool flip-seq zero = false flip-seq (suc n) = not ( flip-seq n ) lemma0 : Muller ωa1 flip-seq lemma0 = record { next = λ n → suc (suc n) ; infinite = lemma01 } where lemma01 : (x : States3) (n : ℕ) → aend ωa1 (ω-run ωa1 x (n + suc (suc n)) flip-seq) ≡ true lemma01 = {!!} lemma1 : Buchi ωa1 true-seq lemma1 = record { from = zero ; stay = {!!} } where lem1 : ( n : ℕ ) → n > zero → aend ωa1 (ω-run ωa1 {!!} n true-seq ) ≡ true lem1 zero () lem1 (suc n) (s≤s z≤n) with ω-run ωa1 {!!} n true-seq lem1 (suc n) (s≤s z≤n) | ts* = {!!} lem1 (suc n) (s≤s z≤n) | ts = {!!} ωa2 : Automaton States3 Bool ωa2 = record { δ = transition3 ; aend = λ x → not ( mark1 x ) } flip-dec : (n : ℕ ) → Dec ( flip-seq n ≡ true ) flip-dec n with flip-seq n flip-dec n | false = no λ () flip-dec n | true = yes refl flip-dec1 : (n : ℕ ) → flip-seq (suc n) ≡ ( not ( flip-seq n ) ) flip-dec1 n = let open ≡-Reasoning in flip-seq (suc n ) ≡⟨⟩ ( not ( flip-seq n ) ) ∎ flip-dec2 : (n : ℕ ) → not flip-seq (suc n) ≡ flip-seq n flip-dec2 n = {!!} record flipProperty : Set where field flipP : (n : ℕ) → ω-run ωa2 {!!} {!!} ≡ ω-run ωa2 {!!} {!!} lemma2 : Muller ωa2 flip-seq lemma2 = record { next = next ; infinite = {!!} } where next : ℕ → ℕ next = {!!} infinite' : (n m : ℕ) → n ≥″ m → aend ωa2 {!!} ≡ true → aend ωa2 {!!} ≡ true infinite' = {!!} infinite : (n : ℕ) → aend ωa2 {!!} ≡ true infinite = {!!} lemma3 : Buchi ωa1 false-seq → ⊥ lemma3 = {!!} lemma4 : Muller ωa1 flip-seq → ⊥ lemma4 = {!!}
{ "alphanum_fraction": 0.4888405008, "avg_line_length": 23.5512820513, "ext": "agda", "hexsha": "a4ae5705057e62a2779c9aed04c33525fe1f98aa", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/automaton-in-agda", "max_forks_repo_path": "src/omega-automaton.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "shinji-kono/automaton-in-agda", "max_issues_repo_path": "src/omega-automaton.agda", "max_line_length": 87, "max_stars_count": null, "max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/automaton-in-agda", "max_stars_repo_path": "src/omega-automaton.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1316, "size": 3674 }