Search is not available for this dataset
text
string
meta
dict
------------------------------------------------------------------------ -- The Agda standard library -- -- Reflection utilities for Fin ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Fin.Reflection where open import Data.Nat.Base as ℕ hiding (module ℕ) open import Data.Fin.Base as Fin hiding (module Fin) open import Data.List.Base open import Reflection.Term open import Reflection.Argument ------------------------------------------------------------------------ -- Term toTerm : ∀ {n} → Fin n → Term toTerm zero = con (quote Fin.zero) (1 ⋯⟅∷⟆ []) toTerm (suc i) = con (quote Fin.suc) (1 ⋯⟅∷⟆ toTerm i ⟨∷⟩ [])
{ "alphanum_fraction": 0.4640804598, "avg_line_length": 30.2608695652, "ext": "agda", "hexsha": "d9c70fe0a6ef70097d686f3610709d739f559bc4", "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": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/Fin/Reflection.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "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": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Fin/Reflection.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Fin/Reflection.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": 151, "size": 696 }
module algebra where open import Relation.Binary.PropositionalEquality open ≡-Reasoning -- Goals are written as normalised data ℕ : Set where zero : ℕ suc : ℕ → ℕ _+_ : ℕ → ℕ → ℕ zero + y = y suc x + y = suc (x + y) record Semigroup (a : Set) : Set where field _⊛_ : a → a → a assoc : ∀ a b c → (a ⊛ b) ⊛ c ≡ a ⊛ (b ⊛ c) record Monoid (a : Set) : Set where field semigroup : Semigroup a open Semigroup semigroup field e : a idl : ∀ a → e ⊛ a ≡ a idr : ∀ a → a ⊛ e ≡ a record Group (a : Set) : Set where field monoid : Monoid a open Monoid monoid open Semigroup semigroup field -- TODO [aerben] fix this invl : ∀ a ∃ b → a ⊛ b ≡ e invr : ∀ a ∃ b → b ⊛ a ≡ e record AbelianGroup (a : Set) : Set where field group : Group a open Group group open Monoid monoid open Semigroup semigroup field commutative : ∀ a b → a ⊛ b ≡ b ⊛ a record CommutativeSemigroup (a : Set) : Set where field _⊛_ : a → a → a associative : ∀ a b c → (a ⊛ b) ⊛ c ≡ a ⊛ (b ⊛ c) commutative : ∀ a b → a ⊛ b ≡ b ⊛ a plusAssociative : ∀ a b c -> (a + b) + c ≡ a + (b + c) -- Goal: (b + c) ≡ (b + c) -- Follows from reflexivity plusAssociative zero b c = refl -- Goal: suc ((a + b) + c) ≡ suc (a + (b + c)) -- Inductive step -- Follows from induction assumption and congruence plusAssociative (suc a) b c = begin suc ((a + b) + c) ≡⟨ cong suc (plusAssociative a b c) ⟩ suc (a + (b + c)) ∎ plusCommutativeLemma : ∀ a b -> a + suc b ≡ suc (a + b) -- Goal: suc b ≡ suc b -- Follows from reflexivity plusCommutativeLemma zero b = refl -- Goal: suc (a + suc b) ≡ suc (suc (a + b)) -- Inductive step -- Follows from induction assumption and congruence plusCommutativeLemma (suc a) b = begin suc (a + suc b) ≡⟨ cong suc (plusCommutativeLemma a b) ⟩ suc (suc (a + b)) ∎ plusCommutative : ∀ a b -> a + b ≡ b + a -- Goal: zero ≡ zero -- Follows from reflexivity plusCommutative zero zero = refl -- Goal: suc (a + zero) ≡ suc a -- One-sided inductive step -- Follows from induction assumption and congruence plusCommutative (suc a) zero = begin suc (a + zero) ≡⟨ cong suc (plusCommutative a zero) ⟩ suc a ∎ -- Goal: suc b ≡ suc (b + zero) -- One-sided inductive step -- Follows from induction assumption and congruence plusCommutative zero (suc b) = begin suc b ≡⟨ cong suc (plusCommutative zero b) ⟩ suc (b + zero) ∎ -- plusCommutative (suc a) (suc b) rewrite plusCommutativeAux a b | plusCommutativeAux b a = cong suc (cong suc (plusCommutative a b)) -- Goal: suc (a + suc b) ≡ suc (b + suc a) plusCommutative (suc a) (suc b) = begin suc (a + suc b) ≡⟨ cong suc (plusCommutativeLemma a b) ⟩ suc (suc (a + b)) ≡⟨ cong suc (cong suc (plusCommutative a b)) ⟩ suc (suc (b + a)) -- Need to invoke symmetry since definitional equivalence does not guarantee it ≡⟨ cong suc (sym (plusCommutativeLemma b a)) ⟩ suc (b + suc a) ∎ plusSemigroup : CommutativeSemigroup ℕ plusSemigroup = record { _⊛_ = _+_ ; associative = plusAssociative ; commutative = plusCommutative }
{ "alphanum_fraction": 0.6097717776, "avg_line_length": 24.888, "ext": "agda", "hexsha": "9133b1ecb3050de975ed0fa480f450b0e9a63191", "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": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "aronerben/agda-playground", "max_forks_repo_path": "experiments/algebra.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "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": "aronerben/agda-playground", "max_issues_repo_path": "experiments/algebra.agda", "max_line_length": 134, "max_stars_count": null, "max_stars_repo_head_hexsha": "64a00f1f97f053d246d5b9deab090e75d923fe8f", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "aronerben/agda-playground", "max_stars_repo_path": "experiments/algebra.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1164, "size": 3111 }
open import Type open import Structure.Relator open import Structure.Setoid renaming (_≡_ to _≡ₑ_) module Structure.Sets.ZFC.Oper {ℓₛ ℓₗ ℓₑ} {S : Type{ℓₛ}} ⦃ equiv : Equiv{ℓₑ}(S) ⦄ (_∈_ : S → S → Type{ℓₗ}) ⦃ [∈]-binaryRelator : BinaryRelator(_∈_) ⦄ where open import Functional using (id ; _∘₂_) open import Functional.Dependent using (_∘_) import Lvl open import Logic.Predicate open import Logic.Propositional open import Logic.Propositional.Theorems open import Structure.Function open import Structure.Operator open import Structure.Relator.Properties open import Structure.Relator.Proofs renaming ([≡]-binaryRelator to [≡ₑ]-binaryRelator) open import Structure.Sets.ZFC(_∈_) ⦃ [∈]-binaryRelator ⦄ import Structure.Sets.Names open import Syntax.Function open import Syntax.Implication open Structure.Sets.Names.From-[∈] (_∈_) open Structure.Sets.Names.Relations (_∈_) open Structure.Sets.Names.One (_∈_) open Structure.Sets.Names.Two (_∈_)(_∈_) open Structure.Sets.Names.TwoDifferent (_∈_)(_∈_) open Structure.Sets.Names.TwoSame (_∈_)(_∈_) open Structure.Sets.Names.Three (_∈_)(_∈_)(_∈_) open Structure.Sets.Names.ThreeNestedTwoDifferent (_∈_) open Structure.Sets.Names.ThreeTwoNested (_∈_)(_∈_)(_∈_) open import Structure.Sets.Quantifiers(_∈_) open import Structure.Sets.Quantifiers.Proofs(_∈_) ⦃ [∈]-binaryRelator ⦄ private variable ℓ : Lvl.Level private variable A B C D E N a b c d e x y z As : S private variable P : S → Type{ℓ} module _ ⦃ zfc : ZFC ⦄ where open ZFC(zfc) infixl 3001 _∩_ infixl 3002 _⨯_ _∖_ -- Intersection operator. -- Constructs a set which consists of elements which are in both LHS and RHS. _∩_ : S → S → S a ∩ b = filter(_∈ b) ⦃ binary-unaryRelatorᵣ ⦄ a -- "Without"-operator. -- Constructs a set which consists of elements which are in LHS, but not RHS. _∖_ : S → S → S a ∖ b = filter(_∉ b) ⦃ [¬]-unaryRelator ⦃ rel-P = binary-unaryRelatorᵣ ⦄ ⦄ a -- Intersection over arbitrary sets. -- Constructs a set which consists of elements which are in all of the specified sets. ⋂ : S → S ⋂(As) = filter(a ↦ (∀ₛ(As) (a ∈_))) ⦃ [∀]-unaryRelator ⦃ rel-P = [→]-unaryRelator ⦃ rel-Q = binary-unaryRelatorᵣ ⦄ ⦄ ⦄ (⋃(As)) -- Tuple value. -- An ordered pair of values. _,_ : S → S → S (a , b) = pair(singleton a) (pair a b) -- Set product (Set of tuples) (Cartesian product). _⨯_ : S → S → S A ⨯ B = filter(t ↦ ∃ₛ(A)(a ↦ ∃ₛ(B)(b ↦ t ≡ₑ (a , b)))) ⦃ [∃ₛ]-unaryRelator ⦃ rel-P = [∃ₛ]-unaryRelator ⦃ rel-P = binary-unaryRelatorᵣ ⦃ rel-P = [≡ₑ]-binaryRelator ⦄ ⦄ ⦄ ⦄ (℘(℘(A ∪ B))) identityPair : S → S identityPair(D) = filter(xy ↦ ∃(a ↦ xy ≡ₑ (a , a))) ⦃ [∃]-unaryRelator ⦃ rel-P = binary-unaryRelatorᵣ ⦃ rel-P = [≡ₑ]-binaryRelator ⦄ ⦄ ⦄ (D ⨯ D) -- Quotient set. -- The set of equivalence classes. _/_ : S → (_▫_ : S → S → Type{ℓ}) ⦃ rel : BinaryRelator(_▫_) ⦄ → S (a / (_▫_)) ⦃ rel ⦄ = filter(aₛ ↦ ∀ₛ(aₛ)(x ↦ ∀ₛ(aₛ)(x ▫_))) ⦃ binary-unaryRelatorᵣ ⦃ rel-P = [∀ₛ]-binaryRelator {P = \x A _ → ∀ₛ(A) (x ▫_)} ⦃ rel-P = [∀ₛ]-binaryRelator ⦃ rel-P = const-binaryRelator ⦄ ⦄ ⦄ {∅} ⦄ (℘(a)) -- Equivalence class. -- The set of elements which are equivalent to the specified one. [_of_,_] : S → S → (_▫_ : S → S → Type{ℓ}) ⦃ rel : BinaryRelator(_▫_) ⦄ → S [ x of a , (_▫_) ] = filter(x ▫_) ⦃ binary-unaryRelatorₗ ⦄ a -- The unmap of a set. -- The set of elements in the domain X when applied to a function gives an element in Y. -- Or: The inverse image of the function on the set. -- Or: The pre-image of the function on the set. -- Note: -- The domain is neccessary because a class function's domain is not neccesarily a set. -- For example: `const(x): Domain → Domain` for any (x: Domain) is a class function for which its domain is not a set. -- This is because const is defined for all objects in `Domain`, so if a set would have to have all objects in `Domain`, it has to be the universal set, but there is no universal set. unmap : S → (f : S → S) ⦃ func : Function(f) ⦄ → S → S unmap(X) f(Y) = filter(x ↦ f(x) ∈ Y) ⦃ [∘]-unaryRelator {P = _∈ Y} ⦃ binary-unaryRelatorᵣ ⦄ ⦄ X [∩]-inclusion : IntersectMembership(_∩_) [∩]-inclusion {A = A}{B = B}{x = x} = (x ∈ (A ∩ B)) ⇔-[] x ∈ filter(_∈ B) ⦃ _ ⦄ A ⇔-[ restricted-comprehension ⦃ _ ⦄ ] (x ∈ A) ∧ (x ∈ B) ⇔-end [∖]-inclusion : WithoutMembership(_∖_) [∖]-inclusion {A = A}{B = B}{x = x} = (x ∈ (A ∖ B)) ⇔-[] x ∈ filter(_∉ B) ⦃ _ ⦄ A ⇔-[ restricted-comprehension ⦃ _ ⦄ ] (x ∈ A) ∧ (x ∉ B) ⇔-end intersection : BigIntersectionMembershipWithEmpty(⋂) intersection {A = A}{x = x} = (x ∈ filter(a ↦ ∀ₛ(A)(a ∈_)) ⦃ _ ⦄ (⋃ A)) ⇔-[ restricted-comprehension ⦃ _ ⦄ ] (x ∈ ⋃ A) ∧ ∀ₛ(A)(x ∈_) ⇔-[ [∧]-map-[↔] union [↔]-reflexivity ] ∃(a ↦ (a ∈ A) ∧ (x ∈ a)) ∧ ∀ₛ(A)(x ∈_) ⇔-end [⨯]-inclusion : (x ∈ (A ⨯ B)) ↔ ∃ₛ(A)(a ↦ ∃ₛ(B)(b ↦ x ≡ₑ (a , b))) [⨯]-inclusion {x = x}{A = A}{B = B} = (x ∈ (A ⨯ B)) ⇔-[] x ∈ filter(t ↦ ∃ₛ(A)(a ↦ ∃ₛ(B)(b ↦ t ≡ₑ (a , b)))) ⦃ _ ⦄ (℘(℘(A ∪ B))) ⇔-[ restricted-comprehension ⦃ _ ⦄ ] (x ∈ ℘(℘(A ∪ B))) ∧ ∃ₛ(A)(a ↦ ∃ₛ(B)(b ↦ (x ≡ₑ (a , b)))) ⇔-[ [↔]-intro (p ↦ [∧]-intro (l p) p) [∧]-elimᵣ ] ∃ₛ(A)(a ↦ ∃ₛ(B)(b ↦ x ≡ₑ (a , b))) ⇔-end where tuple-superset : (a ∈ A) → (b ∈ B) → ((a , b) ⊆ ℘(A ∪ B)) tuple-superset pa pb = pair-superset ([↔]-to-[←] power (singleton-superset ([↔]-to-[←] [∪]-inclusion ([∨]-introₗ pa)) )) ([↔]-to-[←] power (pair-superset ([↔]-to-[←] union ([∃]-intro A ⦃ [∧]-intro pair-contains-left pa ⦄)) ([↔]-to-[←] union ([∃]-intro B ⦃ [∧]-intro pair-contains-right pb ⦄)) )) l = ∃ₛ(A)(a ↦ ∃ₛ(B)(b ↦ x ≡ₑ (a , b))) ⇒-[ [∃]-map-proof ([∧]-map id ([∃]-map-proof ([∧]-map id ([↔]-to-[→] set-extensionality)))) ] ∃ₛ(A)(a ↦ ∃ₛ(B)(b ↦ x ≡ (a , b))) ⇒-[ [∃]-map-proof ([∧]-map id ([∃]-map-proof ([∧]-map id (sub₂(_≡_)(_⊆_))))) ] ∃ₛ(A)(a ↦ ∃ₛ(B)(b ↦ x ⊆ (a , b))) ⇒-[] ∃ₛ(A)(a ↦ ∃ₛ(B)(b ↦ x ⊆ pair(singleton a) (pair a b))) ⇒-[ (\([∃]-intro _ ⦃ [∧]-intro pa ([∃]-intro _ ⦃ [∧]-intro pb sub ⦄) ⦄) {y} → transitivity(_⊆_) sub (tuple-superset pa pb) {y}) ] x ⊆ ℘(A ∪ B) ⇒-[ [↔]-to-[←] power ] x ∈ ℘(℘(A ∪ B)) ⇒-end instance ⋂-function : Function(⋂) Function.congruence ⋂-function {x = As}{y = Bs} AsBs = filter-function ⦃ _ ⦄ ⦃ _ ⦄ p (congruence₁(⋃) AsBs) where p : ∀{x} → (∀{A} → (A ∈ As) → (x ∈ A)) ↔ (∀{B} → (B ∈ Bs) → (x ∈ B)) p = [↔]-intro (_∘ (substitute₂ᵣ(_∈_) AsBs)) (_∘ (substitute₂ᵣ(_∈_) (symmetry(_≡ₑ_) AsBs))) instance ∪-operator : BinaryOperator(_∪_) BinaryOperator.congruence ∪-operator = congruence₁(⋃) ∘₂ congruence₂(pair) instance ∩-operator : BinaryOperator(_∩_) BinaryOperator.congruence ∩-operator xy1 xy2 = filter-function ⦃ _ ⦄ ⦃ _ ⦄ ([↔]-to-[→] set-extensionality xy2) xy1 instance ∖-operator : BinaryOperator(_∖_) BinaryOperator.congruence ∖-operator xy1 xy2 = filter-function ⦃ _ ⦄ ⦃ _ ⦄ ([¬]-unaryOperator ([↔]-to-[→] set-extensionality xy2)) xy1 instance [,]-operator : BinaryOperator(_,_) BinaryOperator.congruence [,]-operator xy1 xy2 = congruence₂(pair) (congruence₁(singleton) xy1) (congruence₂(pair) xy1 xy2)
{ "alphanum_fraction": 0.5368884287, "avg_line_length": 48.8987341772, "ext": "agda", "hexsha": "84fdff1dcbce19b8c6e51c5ccce104a7538b61cb", "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/Sets/ZFC/Oper.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/Sets/ZFC/Oper.agda", "max_line_length": 219, "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/Sets/ZFC/Oper.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": 3104, "size": 7726 }
module ListMember where open import Prelude data Member {A : Set} (x : A) : List A -> Set where here : {xs : List A} -> Member x (cons x xs) there : forall {y} -> {xs : List A} -> Member x xs -> Member x (cons y xs) empty-no-member' : forall {A} -> {x : A} -> Member x nil -> Empty empty-no-member' p = {!!} empty-no-member : forall {A} -> {x : A} -> Not (Member x nil) empty-no-member = is-absurd empty-no-member' neither-here-nor-there' : forall {A} -> {x y : A} {ys : List A} -> (x == y -> Empty) -> (Member x ys -> Empty) -> Member x (cons y ys) -> Empty neither-here-nor-there' not-here not-there member = {!!} neither-here-nor-there : forall {A} -> {x y : A} {ys : List A} -> Not (x == y) -> Not (Member x ys) -> Not (Member x (cons y ys)) neither-here-nor-there (is-absurd not-here) (is-absurd not-there) = is-absurd (neither-here-nor-there' not-here not-there) member : forall {A} -> ((x y : A) -> Dec (x == y)) -> (v : A) -> (vs : List A) -> Dec (Member v vs) member eq? x nil = no empty-no-member member eq? x (cons y ys) with eq? x y member eq? x (cons y ys) | yes p = {!!} member eq? x (cons y ys) | no pf with member eq? x ys member eq? x (cons y ys) | no pf | member = {!!}
{ "alphanum_fraction": 0.58882402, "avg_line_length": 44.4074074074, "ext": "agda", "hexsha": "4e35fd84d204159bae2f6cc8b924311e27314951", "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": "baf979ef78b5ec0f4783240b03f9547490bc5d42", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "carlostome/martin", "max_forks_repo_path": "data/test-files/ListMember.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "baf979ef78b5ec0f4783240b03f9547490bc5d42", "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": "carlostome/martin", "max_issues_repo_path": "data/test-files/ListMember.agda", "max_line_length": 143, "max_stars_count": null, "max_stars_repo_head_hexsha": "baf979ef78b5ec0f4783240b03f9547490bc5d42", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "carlostome/martin", "max_stars_repo_path": "data/test-files/ListMember.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 418, "size": 1199 }
-- We ban termination pragmas inside `where` clauses. module Issue1137 where postulate A : Set a : A foo : A foo = bar where {-# TERMINATING #-} bar : A bar = bar
{ "alphanum_fraction": 0.6292134831, "avg_line_length": 11.8666666667, "ext": "agda", "hexsha": "8e40c98f5fb26b54a358c18177144972899709b9", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.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/Issue1137.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/Fail/Issue1137.agda", "max_line_length": 53, "max_stars_count": 3, "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/Issue1137.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": 58, "size": 178 }
{-# OPTIONS --without-K --safe #-} module Categories.Diagram.Coend.Properties where open import Categories.Category.Core using (Category) open import Categories.Category.Product import Categories.Category.Construction.Cowedges as Cowedges open import Categories.Category.Construction.Functors open import Categories.Category.Equivalence open import Categories.Category.Equivalence.Preserves open import Categories.Diagram.Coend open import Categories.Diagram.Colimit open import Categories.Diagram.Cowedge open import Categories.Diagram.Cowedge.Properties open import Categories.Functor using (Functor) open import Categories.Functor.Bifunctor using (Bifunctor) open import Categories.Functor.Instance.Twisted import Categories.Morphism as M open import Categories.NaturalTransformation hiding (id) open import Categories.NaturalTransformation.Dinatural open import Categories.Object.Initial as Initial import Categories.Morphism.Reasoning as MR open import Level open import Data.Product using (Σ; _,_) open import Function using (_$_) module _ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (F : Bifunctor (Category.op C) C D) where open Cowedges F -- Being a Coend is the same as being an Initial object in the category of Cowedges Coend⇒Initial : Coend F → Initial Cowedges Coend⇒Initial c = record { ⊥ = cowedge ; ⊥-is-initial = record { ! = λ {A} → record { u = factor A ; commute = universal } ; !-unique = λ {A} f → unique {A} (Cowedge-Morphism.commute f) } } where open Coend c Initial⇒Coend : Initial Cowedges → Coend F Initial⇒Coend i = record { cowedge = ⊥ ; factor = λ W → u {W₂ = W} ! ; universal = commute ! ; unique = λ {_} {g} x → !-unique (record { u = g ; commute = x }) } where open Initial.Initial i open Cowedge-Morphism private variable o ℓ e : Level C D E : Category o ℓ e module _ (F : Functor E (Functors (Product (Category.op C) C) D)) where private module C = Category C module D = Category D module E = Category E module NT = NaturalTransformation open D open HomReasoning open MR D open Functor F open Coend hiding (E) open NT using (η) CoendF : (∀ X → Coend (F₀ X)) → Functor E D CoendF coend = record { F₀ = λ X → Coend.E (coend X) ; F₁ = F₁′ ; identity = λ {A} → unique (coend A) (id-comm-sym ○ ∘-resp-≈ʳ (⟺ identity)) ; homomorphism = λ {A B C} {f g} → unique (coend A) $ λ {Z} → begin (F₁′ g ∘ F₁′ f) ∘ dinatural.α (coend A) Z ≈⟨ pullʳ (universal (coend A)) ⟩ (F₁′ g ∘ (dinatural.α (coend B) Z ∘ η (F₁ f) (Z , Z) ) ) ≈⟨ pullˡ (universal (coend B)) ⟩ ((dinatural.α (coend C) Z ∘ η (F₁ g) (Z , Z)) ∘ η (F₁ f) (Z , Z)) ≈˘⟨ pushʳ homomorphism ⟩ dinatural.α (coend C) Z ∘ η (F₁ (g E.∘ f)) (Z , Z) ∎ ; F-resp-≈ = λ {A B f g} eq → unique (coend A) $ λ {Z} → begin F₁′ g ∘ dinatural.α (coend A) Z ≈⟨ universal (coend A) ⟩ dinatural.α (coend B) Z ∘ η (F₁ g) (Z , Z) ≈˘⟨ refl⟩∘⟨ F-resp-≈ eq ⟩ dinatural.α (coend B) Z ∘ η (F₁ f) (Z , Z) ∎ } where F₁′ : ∀ {X Y} → X E.⇒ Y → Coend.E (coend X) ⇒ Coend.E (coend Y) F₁′ {X} {Y} f = factor (coend X) $ record { E = Coend.E (coend Y) ; dinatural = dinatural (coend Y) ∘> F₁ f } -- A Natural Transformation between two functors induces an arrow between the -- (object part of) the respective coends. module _ {P Q : Functor (Product (Category.op C) C) D} (P⇒Q : NaturalTransformation P Q) where open Coend renaming (E to coend) open Category D coend-η : {cp : Coend P} {cq : Coend Q} → coend cp ⇒ coend cq coend-η {cp} {cq} = factor cp ((record { E = Coend.E cq ; dinatural = dtHelper record { α = λ c → dinatural.α cq c ∘ η (c , c) ; commute = λ {C} {C′} f → begin id ∘ (αq C ∘ η (C , C)) ∘ P.₁ (f , C.id) ≈⟨ pushʳ assoc ⟩ (id ∘ αq C) ∘ (η (C , C) ∘ P.₁ (f , C.id)) ≈⟨ refl⟩∘⟨ nt.commute (f , C.id) ⟩ (id ∘ αq C) ∘ (Q.₁ (f , C.id) ∘ η (C′ , C)) ≈⟨ pullˡ assoc ⟩ (id ∘ αq C ∘ Q.₁ (f , C.id)) ∘ η (C′ , C) ≈⟨ αq-comm f ⟩∘⟨refl ⟩ (id ∘ αq C′ ∘ Q.₁ (C.id , f)) ∘ η (C′ , C) ≈⟨ pushˡ sym-assoc ⟩ (id ∘ αq C′) ∘ Q.₁ (C.id , f) ∘ η (C′ , C) ≈⟨ refl⟩∘⟨ nt.sym-commute (C.id , f) ⟩ (id ∘ αq C′) ∘ η (C′ , C′) ∘ P.₁ (C.id , f) ≈⟨ pullʳ sym-assoc ⟩ id ∘ (αq C′ ∘ η (C′ , C′)) ∘ P.₁ (C.id , f) ∎ } })) where module nt = NaturalTransformation P⇒Q open nt using (η) open HomReasoning module C = Category C module P = Functor P module Q = Functor Q open DinaturalTransformation (dinatural cp) renaming (α to αp; commute to αp-comm) open DinaturalTransformation (dinatural cq) renaming (α to αq; commute to αq-comm) open Cowedge open MR D module _ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (F : Bifunctor (Category.op C) C D) where private Eq = CoconesTwist≅Cowedges F module O = M D open M (Cowedges.Cowedges F) open Functor open StrongEquivalence Eq renaming (F to F⇒) -- Coends and Colimits are equivalent, in the category Cowedge F Coend-as-Colimit : (coend : Coend F) → (cl : Colimit (Twist′ C D F)) → Coend.cowedge coend ≅ F₀ F⇒ (Colimit.initial.⊥ cl) Coend-as-Colimit coend cl = Initial.up-to-iso (Cowedges.Cowedges F) (Coend⇒Initial F coend) (pres-Initial Eq initial) where open Colimit cl -- Which then induces that the objects, in D, are also equivalent. Coend-as-Colimit-on-Obj : (coend : Coend F) → (cl : Colimit (Twist′ C D F)) → Coend.E coend O.≅ Colimit.coapex cl Coend-as-Colimit-on-Obj coend cl = record { from = Cowedge-Morphism.u (M._≅_.from X≅Y) ; to = Cowedge-Morphism.u (M._≅_.to X≅Y) ; iso = record { isoˡ = M._≅_.isoˡ X≅Y ; isoʳ = M._≅_.isoʳ X≅Y } } where X≅Y = Coend-as-Colimit coend cl open Category D
{ "alphanum_fraction": 0.592092257, "avg_line_length": 38.1761006289, "ext": "agda", "hexsha": "397ad41ce2041452a91be7be93f037d82355eaac", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Diagram/Coend/Properties.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Diagram/Coend/Properties.agda", "max_line_length": 123, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Diagram/Coend/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 2237, "size": 6070 }
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} -- {-# OPTIONS --without-K #-} -- No accepted! module K-FOTC where postulate D : Set data _≡_ (x : D) : D → Set where refl : x ≡ x K : (x : D)(P : x ≡ x → Set) → P refl → (p : x ≡ x) → P p K x P pr refl = pr
{ "alphanum_fraction": 0.4791086351, "avg_line_length": 23.9333333333, "ext": "agda", "hexsha": "65b9ae9baf01a9f7d376b6bab1dc9e9e41993616", "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/k-axiom/K-FOTC.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/k-axiom/K-FOTC.agda", "max_line_length": 62, "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/k-axiom/K-FOTC.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": 117, "size": 359 }
{-# OPTIONS --without-K #-} module Model.Type.Core where open import Cats.Category open import Relation.Binary using (IsEquivalence) open import Model.RGraph as RG using (RGraph) open import Util.HoTT.Equiv open import Util.HoTT.FunctionalExtensionality open import Util.HoTT.HLevel open import Util.HoTT.Homotopy open import Util.HoTT.Univalence open import Util.Prelude hiding (id) renaming (_∘_ to _∘F_) open import Util.Relation.Binary.LogicalEquivalence using ( _↔_ ; forth ; back ; ↔-reflexive ) open import Util.Relation.Binary.PropositionalEquality using ( Σ-≡⁺ ; Σ-≡⁻ ; cast ; subst-subst ; subst-sym-subst ; subst-subst-sym ) open Category._≅_ public open RG._⇒_ infixr 0 _⇒_ infix 4 _≈_ _≈⟦Type⟧_ infixr 9 _∘_ private variable Δ Γ Ψ : RGraph -- This is an RGraph-indexed family of RGraphs. record ⟦Type⟧ (Δ : RGraph) : Set₁ where no-eta-equality field ObjHSet : Δ .RG.Obj → HSet 0ℓ private module M₀ δ = HLevel (ObjHSet δ) module M₁ {δ} = HLevel (ObjHSet δ) open M₀ public using () renaming ( type to Obj ) open M₁ public using () renaming ( level to Obj-IsSet ) field eqHProp : ∀ {δ δ′} → Δ .RG.eq δ δ′ → Obj δ → Obj δ′ → HProp 0ℓ private module M₂ {δ δ′} (δ≈δ′ : Δ .RG.eq δ δ′) x y = HLevel (eqHProp δ≈δ′ x y) module M₃ {δ δ′} {δ≈δ′ : Δ .RG.eq δ δ′} {x y} = HLevel (eqHProp δ≈δ′ x y) open M₂ public using () renaming ( type to eq ) open M₃ public using () renaming ( level to eq-IsProp ) field eq-refl : ∀ {δ} (x : Obj δ) → eq (Δ .RG.eq-refl δ) x x open ⟦Type⟧ public private variable T U V W : ⟦Type⟧ Δ open RGraph transportEq : ∀ (T : ⟦Type⟧ Δ) {δ γ} {δ≈γ₀ δ≈γ₁ : Δ .eq δ γ} {x y} → T .eq δ≈γ₀ x y → T .eq δ≈γ₁ x y transportEq {Δ} T = subst (λ p → T .eq p _ _) (Δ .eq-IsProp _ _) transportObj : ∀ (T : ⟦Type⟧ Δ) {δ γ} → δ ≡ γ → T .Obj δ → T .Obj γ transportObj T = subst (T .Obj) abstract transportObj-resp : ∀ (T : ⟦Type⟧ Δ) {δ γ} → (δ≡γ₀ δ≡γ₁ : δ ≡ γ) → ∀ {x y} → x ≡ y → transportObj T δ≡γ₀ x ≡ transportObj T δ≡γ₁ y transportObj-resp {Δ} T refl δ≡γ₁ x≡y rewrite Δ .Obj-IsSet δ≡γ₁ refl = x≡y transportObj-resp-eq : ∀ (T : ⟦Type⟧ Δ) {δ₀ γ₀ δ₁ γ₁} → (δ₀≡γ₀ : δ₀ ≡ γ₀) (δ₁≡γ₁ : δ₁ ≡ γ₁) → ∀ {x y} {δ₀≈δ₁ : Δ .eq δ₀ δ₁} {γ₀≈γ₁ : Δ .eq γ₀ γ₁} → T .eq δ₀≈δ₁ x y → T .eq γ₀≈γ₁ (transportObj T δ₀≡γ₀ x) (transportObj T δ₁≡γ₁ y) transportObj-resp-eq {Δ} T refl refl {δ₀≈δ₁ = δ₀≈δ₁} {γ₀≈γ₁} x≈y = transportEq T x≈y abstract transportObj∘transportObj : ∀ (T : ⟦Type⟧ Δ) {δ δ′ δ″} → (p : δ ≡ δ′) (q : δ′ ≡ δ″) {x : T .Obj δ} → transportObj T q (transportObj T p x) ≡ transportObj T (trans p q) x transportObj∘transportObj T p q = subst-subst p transportObj-refl : ∀ (T : ⟦Type⟧ Δ) {δ} → (p : δ ≡ δ) {x : T .Obj δ} → transportObj T p x ≡ x transportObj-refl {Δ} T p rewrite Δ .Obj-IsSet p refl = refl record _⇒_ (T U : ⟦Type⟧ Δ) : Set where no-eta-equality field fobj : ∀ {δ} → Obj T δ → Obj U δ feq : ∀ {δ δ′} (δ≈δ′ : Δ .RG.eq δ δ′) {x y} → eq T δ≈δ′ x y → eq U δ≈δ′ (fobj x) (fobj y) open _⇒_ public record _≈_ (f g : T ⇒ U) : Set where no-eta-equality constructor ≈⁺ field ≈⁻ : ∀ δ (x : Obj T δ) → f .fobj x ≡ g .fobj x open _≈_ public ≈-isEquivalence : (T U : ⟦Type⟧ Δ) → IsEquivalence (_≈_ {T = T} {U}) ≈-isEquivalence T U = record { refl = ≈⁺ λ γ x → refl ; sym = λ f≈g → ≈⁺ λ γ x → sym (f≈g .≈⁻ γ x) ; trans = λ f≈g g≈h → ≈⁺ λ γ x → trans (f≈g .≈⁻ γ x) (g≈h .≈⁻ γ x) } ⇒Canon : (T U : ⟦Type⟧ Δ) → Set ⇒Canon {Δ} T U = Σ[ fobj ∈ (∀ {δ} → T .Obj δ → U .Obj δ) ] (∀ {δ δ′} (δ≈δ′ : Δ .RG.eq δ δ′) {x y} → T .eq δ≈δ′ x y → U .eq δ≈δ′ (fobj x) (fobj y)) ⇒≅⇒Canon : (T ⇒ U) ≅ ⇒Canon T U ⇒≅⇒Canon = record { forth = λ f → f .fobj , f .feq ; isIso = record { back = λ f → record { fobj = f .proj₁ ; feq = f .proj₂ } ; back∘forth = λ where record { fobj = fo ; feq = fe } → refl ; forth∘back = λ x → refl } } ⇒Canon-IsSet : (T U : ⟦Type⟧ Δ) → IsSet (⇒Canon T U) ⇒Canon-IsSet T U = Σ-IsSet (∀∙-IsSet λ δ → →-IsSet (U .Obj-IsSet)) (λ _ → ∀∙-IsSet λ δ → ∀∙-IsSet λ δ′ → ∀-IsSet λ δ≈δ′ → ∀∙-IsSet λ x → ∀∙-IsSet λ y → →-IsSet (IsProp→IsSet (U .eq-IsProp))) ⇒-IsSet : IsSet (T ⇒ U) ⇒-IsSet {T = T} {U} = ≅-pres-IsOfHLevel 2 (≅-sym ⇒≅⇒Canon) (⇒Canon-IsSet T U) ≈→≡Canon : {f g : T ⇒ U} → f ≈ g → ⇒≅⇒Canon .forth f ≡ ⇒≅⇒Canon .forth g ≈→≡Canon {U = U} f≈g = Σ-≡⁺ ( (funext∙ (funext (λ x → f≈g .≈⁻ _ x))) , funext∙ (funext∙ (funext λ a → funext∙ (funext∙ (funext λ eq → U .eq-IsProp _ _)))) ) ≈→≡ : {f g : T ⇒ U} → f ≈ g → f ≡ g ≈→≡ f≈g = ≅-Injective ⇒≅⇒Canon (≈→≡Canon f≈g) private open module M₀ {Δ} {T U : ⟦Type⟧ Δ} = IsEquivalence (≈-isEquivalence T U) public using () renaming ( refl to ≈-refl ; sym to ≈-sym ; trans to ≈-trans ; reflexive to ≈-reflexive ) id : {T : ⟦Type⟧ Δ} → T ⇒ T id = record { fobj = λ x → x ; feq = λ γ≈γ′ x → x } _∘_ : {T U V : ⟦Type⟧ Δ} → U ⇒ V → T ⇒ U → T ⇒ V _∘_ {Γ} f g = record { fobj = f .fobj ∘F g .fobj ; feq = λ γ≈γ′ → f .feq γ≈γ′ ∘F g .feq γ≈γ′ } ⟦Types⟧ : RGraph → Category (lsuc 0ℓ) 0ℓ 0ℓ ⟦Types⟧ Δ = record { Obj = ⟦Type⟧ Δ ; _⇒_ = _⇒_ ; _≈_ = _≈_ ; id = id ; _∘_ = _∘_ ; equiv = ≈-isEquivalence _ _ ; ∘-resp = λ {Δ Γ Ψ f g h i} f≈g h≈i → ≈⁺ λ γ x → trans (f≈g .≈⁻ γ (h .fobj x)) (cong (g .fobj) (h≈i .≈⁻ γ x)) ; id-r = ≈⁺ λ γ x → refl ; id-l = ≈⁺ λ γ x → refl ; assoc = ≈⁺ λ γ x → refl } module ⟦Types⟧ {Γ} = Category (⟦Types⟧ Γ) _≈⟦Type⟧_ : (T U : ⟦Type⟧ Δ) → Set₁ _≈⟦Type⟧_ = ⟦Types⟧._≅_ private open module M₁ {Δ} = ⟦Types⟧.≅ {Δ} public using () renaming ( refl to ≈⟦Type⟧-refl ; sym to ≈⟦Type⟧-sym ; trans to ≈⟦Type⟧-trans ; reflexive to ≈⟦Type⟧-reflexive ) module ≅-Reasoning = ⟦Types⟧.≅-Reasoning module ≈-Reasoning = ⟦Types⟧.≈-Reasoning ⟦Type⟧Canon : RGraph → Set₁ ⟦Type⟧Canon Δ = Σ[ ObjHSet ∈ (Δ .Obj → HSet 0ℓ) ] Σ[ eq ∈ (∀ {δ δ′} (δ≈δ′ : Δ .eq δ δ′) → (x : ObjHSet δ .type) (y : ObjHSet δ′ .type) → HProp 0ℓ) ] (∀ {δ} (x : ObjHSet δ .type) → eq (Δ .eq-refl δ) x x .type) ⟦Type⟧≅⟦Type⟧Canon : ∀ {Δ} → ⟦Type⟧ Δ ≅ ⟦Type⟧Canon Δ ⟦Type⟧≅⟦Type⟧Canon {Δ} = record { forth = λ T → T .ObjHSet , T .eqHProp , T .eq-refl ; isIso = record { back = λ T → record { ObjHSet = T .proj₁ ; eqHProp = T .proj₂ .proj₁ ; eq-refl = T .proj₂ .proj₂ } ; back∘forth = λ where record { ObjHSet = x ; eqHProp = y ; eq-refl = z } → refl ; forth∘back = λ x → refl } } proj₁∘subst : ∀ {α β γ} {A : Set α} (B : A → Set β) (C : ∀ a → B a → Set γ) → ∀ {a a′} (p : a ≡ a′) (x : Σ (B a) (C a)) → proj₁ (subst (λ a → Σ (B a) (C a)) p x) ≡ subst B p (proj₁ x) proj₁∘subst B C refl x = refl ≈⟦Type⟧→≡Canon : T ≈⟦Type⟧ U → ⟦Type⟧≅⟦Type⟧Canon .forth T ≡ ⟦Type⟧≅⟦Type⟧Canon .forth U ≈⟦Type⟧→≡Canon {Δ} {T} {U} T≈U = Σ-≡⁺ (T≡U , Σ-≡⁺ (T≈≡U≈ , funext∙ (funext (λ x → U .eq-IsProp _ _)))) where T≅U : ∀ δ → T .Obj δ ≅ U .Obj δ T≅U δ = record { forth = T≈U .forth .fobj ; isIso = record { back = T≈U .back .fobj ; back∘forth = λ x → T≈U .back-forth .≈⁻ _ _ ; forth∘back = λ x → T≈U .forth-back .≈⁻ _ _ } } T≡U : T .ObjHSet ≡ U .ObjHSet T≡U = funext λ δ → HLevel-≡⁺ _ _ (≅→≡ (T≅U δ)) -- "HoTT makes everything so much nicer", they said. "It's all automatic", -- they said. abstract subst-type : ∀ {α n} (A B : HLevel n α) → (p : A .type ≡ B .type) → (x : A .type) → subst type (HLevel-≡⁺ A B p) x ≡ cast p x subst-type A B refl x with IsOfHLevel-IsProp _ (A .level) (B .level) ... | refl = refl -- I believe this equation would be definitional in Cubical TT. subst-T≡U : ∀ {δ} x → subst (λ T → T δ .type) T≡U x ≡ T≈U .forth .fobj x subst-T≡U {δ} x = trans (subst-funext (λ δ T → T .type) _ x) (trans (subst-type (T .ObjHSet δ) (U .ObjHSet δ) (≅→≡ (T≅U δ)) x) (cast-≅→≡ (T≅U δ))) go : (Δ : Set) (T U : Δ → HSet 0ℓ) (eqΔ : Δ → Δ → Set) → (eqT : ∀ δ δ′ → eqΔ δ δ′ → T δ .type → T δ′ .type → HProp 0ℓ) → (eqU : ∀ δ δ′ → eqΔ δ δ′ → U δ .type → U δ′ .type → HProp 0ℓ) → (T≡U : T ≡ U) → (∀ δ δ′ (δ≈δ′ : eqΔ δ δ′) (x : T δ .type) (y : T δ′ .type) → eqT _ _ δ≈δ′ x y .type ↔ eqU _ _ δ≈δ′ (subst (λ T → T δ .type) T≡U x) (subst (λ T → T δ′ .type) T≡U y) .type) → _≡_ {A = ∀ {δ δ′} → eqΔ δ δ′ → U δ .type → U δ′ .type → HProp 0ℓ} (subst (λ T → ∀ {δ δ′} → eqΔ δ δ′ → T δ .type → T δ′ .type → HProp 0ℓ) T≡U (λ {δ δ′} → eqT δ δ′)) (λ {δ δ′} → eqU δ δ′) go Δ T U eqΔ eqT eqU refl eq = funext∙ λ {δ} → funext∙ λ {δ′} → funext λ δ≈δ′ → funext λ x → funext λ y → HProp-≡⁺ _ _ (eq δ δ′ δ≈δ′ x y) T≈≡U≈ : _ T≈≡U≈ = trans (proj₁∘subst (λ T → ∀ {δ δ′} → Δ .eq δ δ′ → T δ .type → T δ′ .type → HProp 0ℓ) (λ T eq → ∀ {δ} (x : T δ .type) → eq (Δ .eq-refl δ) x x .type) T≡U ((λ {δ δ′} → T .eqHProp {δ} {δ′}), (λ {δ} x → T .eq-refl {δ} x))) (go (Δ .Obj) (T .ObjHSet) (U .ObjHSet) (Δ .eq) (λ δ δ′ → T .eqHProp {δ} {δ′}) (λ δ δ′ → U .eqHProp {δ} {δ′}) T≡U λ δ δ′ δ≈δ′ x y → record { forth = λ x≈y → subst₂ (λ x y → U .eq δ≈δ′ x y) (sym (subst-T≡U x)) (sym (subst-T≡U y)) (T≈U .forth .feq δ≈δ′ x≈y) ; back = λ x≈y → subst₂ (λ x y → T .eq δ≈δ′ x y) (trans (cong (T≈U .back .fobj) (subst-T≡U x)) (T≈U .back-forth .≈⁻ δ x)) (trans (cong (T≈U .back .fobj) (subst-T≡U y)) (T≈U .back-forth .≈⁻ δ′ y)) (T≈U .back .feq δ≈δ′ x≈y) }) ≈⟦Type⟧→≡ : T ≈⟦Type⟧ U → T ≡ U ≈⟦Type⟧→≡ T≈U = ≅-Injective ⟦Type⟧≅⟦Type⟧Canon (≈⟦Type⟧→≡Canon T≈U) subT : ∀ {Δ Ω} → Δ RG.⇒ Ω → ⟦Type⟧ Ω → ⟦Type⟧ Δ subT {Γ} {Ω} f T = record { ObjHSet = T .ObjHSet ∘F f .fobj ; eqHProp = T .eqHProp ∘F f .feq ; eq-refl = λ x → subst (λ p → T .eq p x x) (Ω .eq-IsProp _ _) (T .eq-refl x) } subt : ∀ {Δ Ω} (f : Δ RG.⇒ Ω) {T U : ⟦Type⟧ Ω} → T ⇒ U → subT f T ⇒ subT f U subt f g = record { fobj = g .fobj ; feq = λ γ≈γ′ → g .feq (f .feq γ≈γ′) } subt-∘ : ∀ {Δ Ω} (f : Δ RG.⇒ Ω) {T U V : ⟦Type⟧ Ω} → (g : U ⇒ V) (h : T ⇒ U) → subt f (g ∘ h) ≈ subt f g ∘ subt f h subt-∘ f g h = ≈⁺ λ δ γ → refl subT∘subT : ∀ {Δ Γ Ψ} → {f : Δ RG.⇒ Ψ} {g : Γ RG.⇒ Δ} {T : ⟦Type⟧ Ψ} → subT g (subT f T) ≈⟦Type⟧ subT (f RG.∘ g) T subT∘subT = record { forth = record { fobj = λ x → x ; feq = λ _ x → x } ; back = record { fobj = λ x → x ; feq = λ _ x → x } ; back-forth = ≈⁺ λ γ x → refl ; forth-back = ≈⁺ λ γ x → refl } castObj : {T U : ⟦Type⟧ Δ} → T ≡ U → ∀ {δ} → Obj T δ → Obj U δ castObj p {δ} = subst (λ T → Obj T δ) p ≡→≈⟦Type⟧ : {T U : ⟦Type⟧ Δ} → T ≡ U → T ≈⟦Type⟧ U ≡→≈⟦Type⟧ {Δ} {T} {U} T≡U = record { forth = record { fobj = λ {δ} → castObj T≡U ; feq = λ δ≈δ′ x≈y → go T≡U x≈y } ; back = record { fobj = λ {δ} → castObj (sym T≡U) ; feq = λ δ≈δ′ x≈y → go (sym T≡U) x≈y } ; back-forth = ≈⁺ λ δ x → subst-sym-subst T≡U ; forth-back = ≈⁺ λ δ x → subst-subst-sym T≡U } where go : {T U : ⟦Type⟧ Δ} (p : T ≡ U) → ∀ {δ δ′} {δ≈δ′ : Δ .eq δ δ′} {x y} → eq T δ≈δ′ x y → eq U δ≈δ′ (castObj p x) (castObj p y) go refl x≈y = x≈y
{ "alphanum_fraction": 0.4819380243, "avg_line_length": 27.7482185273, "ext": "agda", "hexsha": "75a0b364eab749db278d35f67fa8b46a5e5651b7", "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": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JLimperg/msc-thesis-code", "max_forks_repo_path": "src/Model/Type/Core.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "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": "JLimperg/msc-thesis-code", "max_issues_repo_path": "src/Model/Type/Core.agda", "max_line_length": 82, "max_stars_count": 5, "max_stars_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JLimperg/msc-thesis-code", "max_stars_repo_path": "src/Model/Type/Core.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-26T06:37:31.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-13T21:31:17.000Z", "num_tokens": 5657, "size": 11682 }
module Structure.Relator.Function.Proofs where import Lvl open import Logic open import Logic.Propositional open import Logic.Predicate open import Functional open import Structure.Relator.Function open import Structure.Setoid open import Structure.Setoid.Uniqueness open import Structure.Relator.Properties open import Structure.Relator open import Type private variable ℓ₁ ℓ₂ ℓ₃ ℓₗ ℓₒ ℓₒ₁ ℓₒ₂ ℓₒ₃ ℓₒ₄ ℓₑ ℓₑ₁ ℓₑ₂ ℓₑ₃ ℓₑ₄ : Lvl.Level module _ {A : Type{ℓₒ₁}}{B : Type{ℓₒ₁ Lvl.⊔ ℓₒ₂}} ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ (φ : A → B → Stmt{ℓₗ}) ⦃ totality : Total(φ)⦄ ⦃ func : Function(φ)⦄ ⦃ _ : ∀{x} → UnaryRelator(φ(x)) ⦄ where -- There is a function for a binary relation that is total and function-like. relation-function-existence : ∃(f ↦ ∀{x}{y} → (f(x) ≡ y) ↔ φ(x)(y)) relation-function-existence = [∃]-intro(f) ⦃ \{x y} → proof{x}{y} ⦄ where -- The function f : A → B f(x) = [∃]-witness(total(φ){x}) -- Proof that the function returns the value that the binary relation defines the element from Y that an element from X is associated with. proof : ∀{x}{y} → (f(x) ≡ y) ↔ φ(x)(y) proof{x}{y} = [↔]-intro l r where r : (f(x) ≡ y) → φ(x)(y) r(fxy) = substitute₁(φ(x)) fxy ([∃]-proof(total(φ){x})) l : (f(x) ≡ y) ← φ(x)(y) l(φxy) = [∃!]-existence-eq-any(totalFunction(φ)) φxy -- Constructing a total function from a a binary operation with conditions. relation-function : A → B relation-function = [∃]-witness(relation-function-existence) module _ {A : Type{ℓₒ₁}} {B : Type{ℓₒ₂}} ⦃ _ : Equiv{ℓₑ₂}(B) ⦄ {f : A → B} where -- A function is total -- ∀{x} → ∃(y ↦ f(x) ≡ y) Function-totality : Total(x ↦ y ↦ f(x) ≡ y) Total.proof(Function-totality) {x} = [∃]-intro(f(x)) ⦃ reflexivity(_≡_) ⦄ module _ {X : Type{ℓₒ₁}} {Y : X → Type{ℓₒ₂}} {φ : (x : X) → Y(x) → Stmt{ℓₗ}} where -- Every binary predicate that have its first argument defined for all values -- have at least one choice function that can determine the second argument from the first. -- Proposition: ∀(X: Type)∀(Y: Type)∀(φ: X → Y → Stmt). (∀(x: X)∃(y: Y). φ(x)(y)) → (∃(choice: X → Y)∀(x: X). φ(x)(choice(x))) -- ∀(x: X)∃(y: Y). φ(x)(y) means that the predicate φ holds for every x and some y (which may depend on x). In other words: it associates every element in X with a subset of Y, a function (X → ℘(Y)). -- ∃(choice: X → Y)∀(x: X). φ(x)(choice(x)) means that there is a function that picks out a particular y. -- Note: This proposition can be recognised as one equivalent variant of "Axiom of Choice" from set theory when formulated in classical logic. -- Note: This is similar to what one does in the process of "Skolemization" for an existentially quantified formula in logic. dependent-function-predicate-choice : (∀{x : X} → ∃{Obj = Y(x)}(y ↦ φ(x)(y))) → ∃{Obj = (x : X) → Y(x)}(choice ↦ ∀{x : X} → φ(x)(choice(x))) dependent-function-predicate-choice(function) = [∃]-intro(x ↦ [∃]-witness(function{x})) ⦃ \{x} → [∃]-proof(function{x}) ⦄ module _ {X : Type{ℓₒ₁}} {Y : Type{ℓₒ₂}} {φ : X → Y → Stmt{ℓₗ}} where function-predicate-choice : (∀{x} → ∃(y ↦ φ(x)(y))) → ∃{Obj = X → Y}(choice ↦ ∀{x} → φ(x)(choice(x))) function-predicate-choice = dependent-function-predicate-choice {- module _ {ℓₗ₁ ℓₗ₂ ℓₒ} {X : Type{ℓₒ}} {P : (X → Stmt{ℓₗ₁}) → Stmt{ℓₗ₂}} where standard-choice : (∀{Q : X → Stmt{ℓₗ₁}} → P(Q) → (∃ P)) → ∃{Obj = (X → Stmt{ℓₗ₁}) → X}(f ↦ ∀{Q : X → Stmt{ℓₗ₁}} → P(Q) → Q(f(Q))) standard-choice ep = [∃]-intro (choice) ⦃ \{x} → proof{x} ⦄ where choice : (X → Stmt{ℓₗ₁}) → X choice(R) = [∃]-witness(ep{R} (pr)) proof : ∀{Q : X → Stmt{ℓₗ₁}} → P(Q) → Q(choice(Q)) proof{Q} pq = [∃]-proof(surjective{x}) -}
{ "alphanum_fraction": 0.6131386861, "avg_line_length": 53.6086956522, "ext": "agda", "hexsha": "bc66e29df500caf3ac4174096195e70d31446d81", "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/Relator/Function/Proofs.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/Relator/Function/Proofs.agda", "max_line_length": 203, "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/Relator/Function/Proofs.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": 1454, "size": 3699 }
module List.Order.Bounded.Properties {A : Set} (_≤_ : A → A → Set) (trans≤ : {x y z : A} → x ≤ y → y ≤ z → x ≤ z) where open import Bound.Total A open import Bound.Total.Order _≤_ open import Bound.Total.Order.Properties _≤_ trans≤ open import Data.List open import List.Order.Bounded _≤_ open import List.Sorted _≤_ lemma-sorted++ : {x : A}{xs ys : List A} → xs ≤* (val x) → (val x) *≤ ys → Sorted xs → Sorted ys → Sorted (xs ++ (x ∷ ys)) lemma-sorted++ {x = x} lenx genx _ _ = singls x lemma-sorted++ lenx (gecx u≤y _) _ sys = conss (lemma-LeB≤ u≤y) sys lemma-sorted++ (lecx x≤u xs≤*u) u*≤ys (singls x) sys = conss (lemma-LeB≤ x≤u) (lemma-sorted++ xs≤*u u*≤ys nils sys) lemma-sorted++ (lecx x≤u xs≤*u) u*≤ys (conss x≤z sxs) sys = conss x≤z (lemma-sorted++ xs≤*u u*≤ys sxs sys) lemma-++≤* : {t : Bound}{x : A}{xs ys : List A} → LeB (val x) t → xs ≤* (val x) → ys ≤* t → (xs ++ (x ∷ ys)) ≤* t lemma-++≤* u≤t lenx ys≤*t = lecx u≤t ys≤*t lemma-++≤* u≤t (lecx x≤u xs≤*u) ys≤*u = lecx (transLeB x≤u u≤t) (lemma-++≤* u≤t xs≤*u ys≤*u) lemma-*≤ : {b : Bound}{x : A}{xs : List A} → LeB b (val x) → (val x) *≤ xs → b *≤ xs lemma-*≤ _ genx = genx lemma-*≤ b≤u (gecx u≤x u*≤xs) = gecx (transLeB b≤u u≤x) (lemma-*≤ b≤u u*≤xs) lemma-++*≤ : {b : Bound}{x : A}{xs ys : List A} → LeB b (val x) → b *≤ xs → (val x) *≤ ys → b *≤ (xs ++ (x ∷ ys)) lemma-++*≤ b≤u genx u*≤ys = gecx b≤u (lemma-*≤ b≤u u*≤ys) lemma-++*≤ b≤u (gecx b≤x b*≤xs) u*≤ys = gecx b≤x (lemma-++*≤ b≤u b*≤xs u*≤ys)
{ "alphanum_fraction": 0.540397351, "avg_line_length": 52.0689655172, "ext": "agda", "hexsha": "5aacdd88f68bdd9ae07d1da0a3d3d1944e17c4a9", "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": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/List/Order/Bounded/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "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": "bgbianchi/sorting", "max_issues_repo_path": "agda/List/Order/Bounded/Properties.agda", "max_line_length": 122, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/List/Order/Bounded/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 743, "size": 1510 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Support.PropositionalEquality where open import Function using (flip; id) open import Relation.Binary.PropositionalEquality public using () renaming (_≡_ to _≣_; refl to ≣-refl; trans to ≣-trans; sym to ≣-sym; cong to ≣-cong; cong₂ to ≣-cong₂; subst to ≣-subst; subst₂ to ≣-subst₂; isEquivalence to ≣-isEquivalence; setoid to ≣-setoid) module ≣-reasoning = Relation.Binary.PropositionalEquality.≡-Reasoning renaming (_≡⟨_⟩_ to _≣⟨_⟩_) ≣-app : ∀ {a} {A : Set a} {b} {B : A → Set b} {f g : (x : A) → B x} → f ≣ g → (x : A) → f x ≣ g x ≣-app {f = f} {g} = flip (λ x → ≣-cong (flip id x)) ≣-appʰ : ∀ {a} {A : Set a} {b} {B : A → Set b} {f g : ∀ {x} → B x} → (λ {x} → f) ≣ g → ∀ {x} → f {x} ≣ g {x} ≣-appʰ {f = f} {g} = λ pf {x} → ≣-cong (λ h → h {x}) pf ≣-subst₂-breakdown-lr : ∀ {a} {A : Set a} {b} {B : Set b} {ℓ} (f : A → B → Set ℓ) {a₁ a₂ : A} (a₁≣a₂ : a₁ ≣ a₂) {b₁ b₂ : B} (b₁≣b₂ : b₁ ≣ b₂) (x : f a₁ b₁) → ≣-subst₂ f a₁≣a₂ b₁≣b₂ x ≣ ≣-subst (f a₂) b₁≣b₂ (≣-subst (λ y → f y b₁) a₁≣a₂ x) ≣-subst₂-breakdown-lr f ≣-refl ≣-refl x = ≣-refl ≣-subst₂-breakdown-rl : ∀ {a} {A : Set a} {b} {B : Set b} {ℓ} (f : A → B → Set ℓ) {a₁ a₂ : A} (a₁≣a₂ : a₁ ≣ a₂) {b₁ b₂ : B} (b₁≣b₂ : b₁ ≣ b₂) (x : f a₁ b₁) → ≣-subst₂ f a₁≣a₂ b₁≣b₂ x ≣ ≣-subst (λ y → f y b₂) a₁≣a₂ (≣-subst (f a₁) b₁≣b₂ x) ≣-subst₂-breakdown-rl f ≣-refl ≣-refl x = ≣-refl ≣-subst-trans : ∀ {a} {A : Set a} {ℓ} (f : A → Set ℓ) {a₁ a₂ a₃ : A} (a₁≣a₂ : a₁ ≣ a₂) (a₂≣a₃ : a₂ ≣ a₃) (x : f a₁) → ≣-subst f (≣-trans a₁≣a₂ a₂≣a₃) x ≣ ≣-subst f a₂≣a₃ (≣-subst f a₁≣a₂ x) ≣-subst-trans f ≣-refl ≣-refl x = ≣-refl ≣-cong₂₊ : ∀ {a b c r} {A : Set a} {B : Set b} {C : A → B → Set c} {R : Set r} (f : (x : A) → (u : B) → .(z : C x u) → R) {x y : A} {u v : B} .(z : C x u) → (x≣y : x ≣ y) (u≣v : u ≣ v) → f x u z ≣ f y v (≣-subst₂ C x≣y u≣v z) ≣-cong₂₊ f z ≣-refl ≣-refl = ≣-refl
{ "alphanum_fraction": 0.5172413793, "avg_line_length": 72.5, "ext": "agda", "hexsha": "9664ec97928788b3428d3197b364db835a8f8e10", "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/Support/PropositionalEquality.agda", "max_issues_count": 91, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2022-03-21T04:17:18.000Z", "max_issues_repo_issues_event_min_datetime": "2019-11-11T15:41:26.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Support/PropositionalEquality.agda", "max_line_length": 261, "max_stars_count": 98, "max_stars_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ajnavarro/language-dataset", "max_stars_repo_path": "data/github.com/copumpkin/categories/36f4181d751e2ecb54db219911d8c69afe8ba892/Categories/Support/PropositionalEquality.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": 1048, "size": 1885 }
module StronglyRigidOccurrence where data Nat : Set where zero : Nat suc : Nat -> Nat data _≡_ {A : Set}(a : A) : A -> Set where refl : a ≡ a test : let X : Nat; X = _ in X ≡ suc X test = refl -- this gives an error in the occurs checker
{ "alphanum_fraction": 0.6234817814, "avg_line_length": 20.5833333333, "ext": "agda", "hexsha": "666a8157a8a1235bab2aa23a2ef242f698f192b3", "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": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/agda-kanso", "max_forks_repo_path": "test/fail/StronglyRigidOccurrence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "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": "asr/agda-kanso", "max_issues_repo_path": "test/fail/StronglyRigidOccurrence.agda", "max_line_length": 44, "max_stars_count": null, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/fail/StronglyRigidOccurrence.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 86, "size": 247 }
module Open2 where data ⊤ : Set where tt : ⊤ data ⊤' (x : ⊤) : Set where tt : ⊤' x record R : Set where field x : ⊤ y : ⊤ record S : Set₁ where field x : R open R x public renaming (x to y; y to z) postulate s : S open S s using (y) postulate p : ⊤' y
{ "alphanum_fraction": 0.4322033898, "avg_line_length": 6.4363636364, "ext": "agda", "hexsha": "7cb2347f541a78bb17c0a2c5f11421015de94b5b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-01T16:38:14.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-01T16:38:14.000Z", "max_forks_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "msuperdock/agda-unused", "max_forks_repo_path": "data/declaration/Open2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "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": "msuperdock/agda-unused", "max_issues_repo_path": "data/declaration/Open2.agda", "max_line_length": 29, "max_stars_count": 6, "max_stars_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "msuperdock/agda-unused", "max_stars_repo_path": "data/declaration/Open2.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-01T16:38:05.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-29T09:38:43.000Z", "num_tokens": 151, "size": 354 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.Cogroup open import cohomology.Theory -- H^n is a group homomorphism when the domain is (Susp X -> Y). module cohomology.Cogroup {i} (CT : CohomologyTheory i) (n : ℤ) {X : Ptd i} (cogroup-struct : CogroupStructure X) (Y : Ptd i) where open CohomologyTheory CT open import cohomology.Wedge CT open CogroupStructure cogroup-struct open import cohomology.CoHSpace CT n co-h-struct private module dom = GroupStructure (cogroup⊙→-group-structure cogroup-struct Y) module codom = Group (hom-group (C n Y) (C-abgroup n X)) C-fmap-preserves-comp : preserves-comp dom.comp codom.comp (C-fmap n) C-fmap-preserves-comp f g = group-hom= $ λ= λ y → CEl-fmap n (dom.comp f g) y =⟨ C-fmap-∘ n (⊙Wedge-rec f g) ⊙coμ y ⟩ CEl-fmap n ⊙coμ (CEl-fmap n (⊙Wedge-rec f g) y) =⟨ C-fmap-coμ (CEl-fmap n (⊙Wedge-rec f g) y) ⟩ Group.comp (C n X) (CEl-fmap n ⊙winl (CEl-fmap n (⊙Wedge-rec f g) y)) (CEl-fmap n ⊙winr (CEl-fmap n (⊙Wedge-rec f g) y)) =⟨ ap2 (Group.comp (C n X)) ( ∘-CEl-fmap n ⊙winl (⊙Wedge-rec f g) y ∙ ap (λ f → CEl-fmap n f y) (⊙WedgeRec.⊙winl-β f g)) ( ∘-CEl-fmap n ⊙winr (⊙Wedge-rec f g) y ∙ ap (λ f → CEl-fmap n f y) (⊙WedgeRec.⊙winr-β f g)) ⟩ Group.comp (C n X) (CEl-fmap n f y) (CEl-fmap n g y) =∎
{ "alphanum_fraction": 0.6088825215, "avg_line_length": 38.7777777778, "ext": "agda", "hexsha": "ea5c767da888e8a7d875b0ded3cf164760a8b344", "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": "theorems/cohomology/Cogroup.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": "theorems/cohomology/Cogroup.agda", "max_line_length": 76, "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": "theorems/cohomology/Cogroup.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": 575, "size": 1396 }
------------------------------------------------------------------------------ -- Definition of mutual inductive predicates ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --without-K #-} {-# OPTIONS --no-universe-polymorphism #-} module FOTC.MutualInductivePredicates where open import FOTC.Base ------------------------------------------------------------------------------ -- Using mutual inductive predicates data Even : D → Set data Odd : D → Set data Even where ezero : Even zero esucc : ∀ {n} → Odd n → Even (succ₁ n) data Odd where osucc : ∀ {n} → Even n → Odd (succ₁ n) -- Non-mutual induction principles Even-ind : (A : D → Set) → A zero → (∀ {n} → Odd n → A (succ₁ n)) → ∀ {n} → Even n → A n Even-ind A A0 h ezero = A0 Even-ind A A0 h (esucc On) = h On Odd-ind : (A : D → Set) → (∀ {n} → Even n → A (succ₁ n)) → ∀ {n} → Odd n → A n Odd-ind A h (osucc En) = h En -- Mutual induction principles (from Coq) Even-mutual-ind : (A B : D → Set) → A zero → (∀ {n} → Odd n → B n → A (succ₁ n)) → (∀ {n} → Even n → A n → B (succ₁ n)) → ∀ {n} → Even n → A n Odd-mutual-ind : (A B : D → Set) → A zero → (∀ {n} → Odd n → B n → A (succ₁ n)) → (∀ {n} → Even n → A n → B (succ₁ n)) → ∀ {n} → Odd n → B n Even-mutual-ind A B A0 h₁ h₂ ezero = A0 Even-mutual-ind A B A0 h₁ h₂ (esucc On) = h₁ On (Odd-mutual-ind A B A0 h₁ h₂ On) Odd-mutual-ind A B A0 h₁ h₂ (osucc En) = h₂ En (Even-mutual-ind A B A0 h₁ h₂ En) module DisjointSum where -- Using a single inductive predicate on D × D (see -- Blanchette (2013)). _+_ : Set → Set → Set _+_ = _∨_ data EvenOdd : D + D → Set where eozero : EvenOdd (inj₁ zero) eoodd : {n : D} → EvenOdd (inj₁ n) → EvenOdd (inj₂ (succ₁ n)) eoeven : {n : D} → EvenOdd (inj₂ n) → EvenOdd (inj₁ (succ₁ n)) -- Induction principle EvenOdd-ind : (A : D + D → Set) → A (inj₁ zero) → ({n : D} → A (inj₁ n) → A (inj₂ (succ₁ n))) → ({n : D} → A (inj₂ n) → A (inj₁ (succ₁ n))) → {n : D + D} → EvenOdd n → A n EvenOdd-ind A A0 h₁ h₂ eozero = A0 EvenOdd-ind A A0 h₁ h₂ (eoodd EOn) = h₁ (EvenOdd-ind A A0 h₁ h₂ EOn) EvenOdd-ind A A0 h₁ h₂ (eoeven EOn) = h₂ (EvenOdd-ind A A0 h₁ h₂ EOn) ------------------------------------------------------------------------- -- From the single inductive predicate to the mutual inductive predicates -- Even and Odd from EvenOdd. Even' : D → Set Even' n = EvenOdd (inj₁ n) Odd' : D → Set Odd' n = EvenOdd (inj₂ n) -- From Even/Odd to Even'/Odd' Even→Even' : ∀ {n} → Even n → Even' n Odd→Odd' : ∀ {n} → Odd n → Odd' n Even→Even' ezero = eozero Even→Even' (esucc On) = eoeven (Odd→Odd' On) Odd→Odd' (osucc En) = eoodd (Even→Even' En) -- From Even'/Odd' to Even/Odd Even'→Even : ∀ {n} → Even' n → Even n Odd'→Odd : ∀ {n} → Odd' n → Odd n -- Requires K. Even'→Even eozero = ezero Even'→Even (eoeven h) = esucc (Odd'→Odd h) Odd'→Odd (eoodd h) = osucc (Even'→Even h) -- TODO (03 December 2012). From EvenOdd-ind to Even-mutual-ind and -- Odd-mutual-ind. module FunctionSpace where -- Using a single inductive predicate on D → D data EvenOdd : D → D → Set where eozero : EvenOdd zero (succ₁ zero) eoodd : ∀ {m n} → EvenOdd m n → EvenOdd m (succ₁ m) eoeven : ∀ {m n} → EvenOdd m n → EvenOdd (succ₁ n) n -- Even and Odd from EvenOdd. -- Even' : D → Set -- Even' n = EvenOdd zero (succ₁ zero) ∨ EvenOdd (succ₁ n) n -- Odd' : D → Set -- Odd' n = EvenOdd n (succ₁ n) -- -- From Even/Odd to Even'/Odd' -- Even→Even' : ∀ {n} → Even n → Even' n -- Odd→Odd' : ∀ {n} → Odd n → Odd' n -- Even→Even' ezero = inj₁ eozero -- Even→Even' (esucc On) = inj₂ (eoeven (Odd→Odd' On)) -- Odd→Odd' (osucc En) = eoodd {!!} -- -- From Even'/Odd' to Even/Odd -- Even'→Even : ∀ {n} → Even' n → Even n -- Odd'→Odd : ∀ {n} → Odd' n → Odd n -- Even'→Even (inj₁ x) = {!!} -- Even'→Even (inj₂ x) = {!!} -- Odd'→Odd h = {!!} ------------------------------------------------------------------------------ -- References -- -- Blanchette, Jasmin Christian (2013). Relational analysis of -- (co)inductive predicates, (co)algebraic datatypes, and -- (co)recursive functions. Software Quality Journal 21.1, -- pp. 101–126.
{ "alphanum_fraction": 0.494942832, "avg_line_length": 29.3419354839, "ext": "agda", "hexsha": "7bea8ec45c4a19e13615cfa7c6165256f5573458", "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/thesis/report/FOTC/MutualInductivePredicates.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/thesis/report/FOTC/MutualInductivePredicates.agda", "max_line_length": 80, "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/thesis/report/FOTC/MutualInductivePredicates.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": 1595, "size": 4548 }
{-# OPTIONS --rewriting #-} module RewritingNat where open import Common.Equality {-# BUILTIN REWRITE _≡_ #-} data Nat : Set where zero : Nat suc : Nat → Nat _+_ : Nat → Nat → Nat zero + n = n (suc m) + n = suc (m + n) plus0T : Set plus0T = ∀{x} → (x + zero) ≡ x plusSucT : Set plusSucT = ∀{x y} → (x + (suc y)) ≡ suc (x + y) postulate plus0p : plus0T {-# REWRITE plus0p #-} plusSucp : plusSucT {-# REWRITE plusSucp #-} plus0 : plus0T plus0 = refl data Vec (A : Set) : Nat → Set where [] : Vec A zero _∷_ : ∀ {n} (x : A) (xs : Vec A n) → Vec A (suc n) reverseAcc : ∀{A n m} → Vec A n → Vec A m → Vec A (n + m) reverseAcc [] acc = acc reverseAcc (x ∷ xs) acc = reverseAcc xs (x ∷ acc)
{ "alphanum_fraction": 0.5646067416, "avg_line_length": 17.3658536585, "ext": "agda", "hexsha": "69ee32dfbbcaf12c56df267c218099b782a593e9", "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/Succeed/RewritingNat.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/Succeed/RewritingNat.agda", "max_line_length": 57, "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/Succeed/RewritingNat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 281, "size": 712 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Properties.MaybeEmb {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Typed open import Definition.LogicalRelation open import Tools.Nat private variable n : Nat Γ : Con Term n -- Any level can be embedded into the highest level. maybeEmb : ∀ {l A} → Γ ⊩⟨ l ⟩ A → Γ ⊩⟨ ¹ ⟩ A maybeEmb {l = ⁰} [A] = emb 0<1 [A] maybeEmb {l = ¹} [A] = [A] -- The lowest level can be embedded in any level. maybeEmb′ : ∀ {l A} → Γ ⊩⟨ ⁰ ⟩ A → Γ ⊩⟨ l ⟩ A maybeEmb′ {l = ⁰} [A] = [A] maybeEmb′ {l = ¹} [A] = emb 0<1 [A]
{ "alphanum_fraction": 0.6097222222, "avg_line_length": 22.5, "ext": "agda", "hexsha": "d84484aa772cb9954ee31935888ffcc1255d7daa", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-11-27T15:58:33.000Z", "max_forks_repo_forks_event_min_datetime": "2017-10-18T14:18:20.000Z", "max_forks_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "fhlkfy/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Properties/MaybeEmb.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391", "max_issues_repo_issues_event_max_datetime": "2021-02-22T10:37:24.000Z", "max_issues_repo_issues_event_min_datetime": "2017-06-22T12:49:23.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "fhlkfy/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Properties/MaybeEmb.agda", "max_line_length": 80, "max_stars_count": 30, "max_stars_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "fhlkfy/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Properties/MaybeEmb.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:01:07.000Z", "max_stars_repo_stars_event_min_datetime": "2017-05-20T03:05:21.000Z", "num_tokens": 247, "size": 720 }
module Prelude.Product where record _×_ (A B : Set) : Set where constructor _,_ field fst : A snd : B open _×_ public
{ "alphanum_fraction": 0.6363636364, "avg_line_length": 13.2, "ext": "agda", "hexsha": "f6ecd5978340b191160f8885642ae0eaa840271d", "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": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_path": "test/epic/Prelude/Product.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "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/agda", "max_issues_repo_path": "test/epic/Prelude/Product.agda", "max_line_length": 34, "max_stars_count": null, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/epic/Prelude/Product.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 42, "size": 132 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Categories.Sets where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Categories.Category open Precategory module _ ℓ where SET : Precategory (ℓ-suc ℓ) ℓ SET .ob = Σ (Type ℓ) isSet SET .Hom[_,_] (A , _) (B , _) = A → B SET .id _ = λ x → x SET ._⋆_ f g = λ x → g (f x) SET .⋆IdL f = refl SET .⋆IdR f = refl SET .⋆Assoc f g h = refl module _ {ℓ} where isSetExpIdeal : {A B : Type ℓ} → isSet B → isSet (A → B) isSetExpIdeal B/set = isSetΠ λ _ → B/set isSetLift : {A : Type ℓ} → isSet A → isSet (Lift {ℓ} {ℓ-suc ℓ} A) isSetLift = isOfHLevelLift 2 instance SET-category : isCategory (SET ℓ) SET-category .isSetHom {_} {B , B/set} = isSetExpIdeal B/set
{ "alphanum_fraction": 0.6381660471, "avg_line_length": 26.0322580645, "ext": "agda", "hexsha": "8122141882cbb8ee36c9a0007791a18c0662be2b", "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": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "apabepa10/cubical", "max_forks_repo_path": "Cubical/Categories/Sets.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "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": "apabepa10/cubical", "max_issues_repo_path": "Cubical/Categories/Sets.agda", "max_line_length": 67, "max_stars_count": null, "max_stars_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "apabepa10/cubical", "max_stars_repo_path": "Cubical/Categories/Sets.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 318, "size": 807 }
-- 2014-03-06 Andreas, Reported by Fabien Renaud -- This is a larger example for the termination checker, to test performance. -- In 2014-02-X, it exhausted the heap. -- 2013-03-17 -- The termination checker now rejects this code instead of crashing. -- I do not know whether it is supposed to terminate. -- {-# OPTIONS -v term.matrices:40 #-} module Issue1075 where open import Common.Prelude renaming (Nat to ℕ) hiding (map; length) open import Common.Product open import Common.Sum open import Common.Equality [_] : {A : Set} → A → List A [ x ] = x ∷ [] map : {A B : Set} → (A → B) → List A → List B map f [] = [] map f (x ∷ xs) = f x ∷ map f xs foldr : ∀ {A B : Set} → (A → B → B) → B → List A → B foldr c n [] = n foldr c n (x ∷ xs) = c x (foldr c n xs) length : ∀ {A} → List A → ℕ length = foldr (λ _ → suc) 0 postulate _∈_ : {A : Set} → A → List A → Set _⊆_ : {A : Set} → List A → List A → Set data All {A : Set} (P : A → Set) : List A → Set where [] : All P [] _∷_ : ∀ {x xs} (px : P x) (pxs : All P xs) → All P (x ∷ xs) _⋐_ : ∀{A} (P Q : A → Set) → Set P ⋐ Q = ∀{x} → P x → Q x map-all : ∀ {A : Set} {P : A → Set} {Q : A → Set} → P ⋐ Q → All P ⋐ All Q map-all g [] = [] map-all g (px ∷ pxs) = g px ∷ map-all g pxs -- Propositions and polarity data Polarity : Set where ⁺ : Polarity ⁻ : Polarity data Type : Polarity → Set where a : (Q : String) (⁼ : Polarity) → Type ⁼ -- ↓ : (A : Type ⁻) → Type ⁺ ⊥⁺ : Type ⁺ _∨_ : (A B : Type ⁺) → Type ⁺ ⊤⁺ : Type ⁺ _∧⁺_ : (A B : Type ⁺) → Type ⁺ -- ↑ : (A : Type ⁺) → Type ⁻ _⊃_ : (A : Type ⁺) (B : Type ⁻) → Type ⁻ ⊤⁻ : Type ⁻ _∧⁻_ : (A B : Type ⁻) → Type ⁻ -- Judgmental infrastructure data Conc : Set where Inv : (A : Type ⁻) → Conc True : (A : Type ⁺) → Conc Susp : (A : Type ⁻) → Conc stable : Conc → Set stable (Inv A) = ⊥ stable (True A) = ⊤ stable (Susp A) = ⊤ suspnormal : Conc → Set suspnormal (Inv A) = ⊤ suspnormal (True A) = ⊤ suspnormal (Susp (a Q .⁻)) = ⊤ suspnormal (Susp (↑ A)) = ⊥ suspnormal (Susp (A ⊃ A₁)) = ⊥ suspnormal (Susp ⊤⁻) = ⊥ suspnormal (Susp (A ∧⁻ A₁)) = ⊥ suspstable : Conc -> Set suspstable U = stable U × suspnormal U data Hyp : Set where HSusp : (A : Type ⁺) → Hyp Pers : (A : Type ⁻) → Hyp Ctx = List Hyp hsusp-inj : ∀{x y} → HSusp x ≡ HSusp y → x ≡ y hsusp-inj refl = refl {- Suspension normality: all suspended propositions are atomic -} suspnormalΓ : Ctx → Set suspnormalΓ Γ = ∀{A} → HSusp A {-Membership-≡.-}∈ Γ → ∃ λ Q → A ≡ (a Q ⁺) postulate conssusp : ∀{Γ Q} → suspnormalΓ Γ → suspnormalΓ ((HSusp (a Q ⁺)) ∷ Γ) conspers : ∀{Γ A} → suspnormalΓ Γ → suspnormalΓ ((Pers A) ∷ Γ) fromctx : ∀{A B Γ} (Γ' : Ctx) → B ∈ (Γ' ++ A ∷ Γ) → (A ≡ B) ⊎ (B ∈ (Γ' ++ Γ)) fromctxGen : ∀{A} {Γ : Ctx} → (Γ' : Ctx) → (L : Ctx) → A ∈ (Γ' ++ L ++ Γ) → (A ∈ L) ⊎ (A ∈ (Γ' ++ Γ)) -- Sequent calculus data SeqForm : Set where Rfoc : (A : Type ⁺) → SeqForm Left : (L : List (Type ⁺) ⊎ Type ⁻) (U : Conc) → SeqForm suspnormalF : SeqForm → Set suspnormalF (Rfoc A) = ⊤ suspnormalF (Left L U) = suspnormal U data Exp (Γ : Ctx) : SeqForm → Set Value : (Γ : Ctx) → Type ⁺ → Set Value Γ A = Exp Γ (Rfoc A) Term : (Γ : Ctx) → List (Type ⁺) → Conc → Set Term Γ Ω U = Exp Γ (Left (inj₁ Ω) U) Spine : (Γ : Ctx) (A : Type ⁻) (U : Conc) → Set Spine Γ A U = Exp Γ (Left (inj₂ A) U) data Exp Γ where -- Values id⁺ : ∀{A} (v : HSusp A ∈ Γ) → Value Γ A ↓R : ∀{A} (N : Term Γ [] (Inv A)) → Value Γ (↓ A) ∨R₁ : ∀{A B} (V : Value Γ A) → Value Γ (A ∨ B) ∨R₂ : ∀{A B} (V : Value Γ B) → Value Γ (A ∨ B) ⊤⁺R : Value Γ ⊤⁺ ∧⁺R : ∀{A B} (V₁ : Value Γ A) (V₂ : Value Γ B) → Value Γ (A ∧⁺ B) -- Terms focR : ∀{A} (V : Value Γ A) → Term Γ [] (True A) focL : ∀{A U} (pf : stable U) (x : Pers A ∈ Γ) (Sp : Spine Γ A U) → Term Γ [] U η⁺ : ∀{Q Ω U} (N : Term (HSusp (a Q ⁺) ∷ Γ) Ω U) → Term Γ (a Q ⁺ ∷ Ω) U ↓L : ∀{A Ω U} (N : Term (Pers A ∷ Γ) Ω U) → Term Γ (↓ A ∷ Ω) U ⊥L : ∀{U Ω} → Term Γ (⊥⁺ ∷ Ω) U ∨L : ∀{A B Ω U} (N₁ : Term Γ (A ∷ Ω) U) (N₂ : Term Γ (B ∷ Ω) U) → Term Γ ((A ∨ B) ∷ Ω) U ⊤⁺L : ∀{U Ω} (N : Term Γ Ω U) → Term Γ (⊤⁺ ∷ Ω) U ∧⁺L : ∀{U Ω A B} (N : Term Γ (A ∷ B ∷ Ω) U) → Term Γ ((A ∧⁺ B) ∷ Ω) U η⁻ : ∀{Q} (N : Term Γ [] (Susp (a Q ⁻))) → Term Γ [] (Inv (a Q ⁻)) ↑R : ∀{A} (N : Term Γ [] (True A)) → Term Γ [] (Inv (↑ A)) ⊃R : ∀{A B} (N : Term Γ [ A ] (Inv B)) → Term Γ [] (Inv (A ⊃ B)) ⊤⁻R : Term Γ [] (Inv ⊤⁻) ∧⁻R : ∀{A B} (N₁ : Term Γ [] (Inv A)) (N₂ : Term Γ [] (Inv B)) → Term Γ [] (Inv (A ∧⁻ B)) -- Spines id⁻ : ∀{A} → Spine Γ A (Susp A) ↑L : ∀{A U} (N : Term Γ [ A ] U) → Spine Γ (↑ A) U ⊃L : ∀{A B U} (V : Value Γ A) (Sp : Spine Γ B U) → Spine Γ (A ⊃ B) U ∧⁻L₁ : ∀{A B U} (Sp : Spine Γ A U) → Spine Γ (A ∧⁻ B) U ∧⁻L₂ : ∀{A B U} (Sp : Spine Γ B U) → Spine Γ (A ∧⁻ B) U -- Weakening postulate sub-cons-congr : ∀{A : Set} {x : A} {xs ys : List A} → xs ⊆ ys → (x ∷ xs) ⊆ (x ∷ ys) sub-wkex : ∀{A : Set} {x y : A} {xs ys : List A} → (x ∷ xs) ⊆ (x ∷ y ∷ xs) sub-cntr : ∀{A : Set} {x : A} → (xs : List A) → x ∈ xs → (x ∷ xs) ⊆ xs wk : ∀{Γ Γ' Form} → Γ ⊆ Γ' → Exp Γ Form → Exp Γ' Form wken : ∀{Γ A Form} → Exp Γ Form → Exp (A ∷ Γ) Form wken-all-rfoc : ∀{Γ' Γ xs B} → All (λ A → Exp (Γ' ++ Γ) (Rfoc A)) xs → All (λ A → Exp (B ∷ (Γ' ++ Γ)) (Rfoc A)) xs wken-all-rfoc [] = [] wken-all-rfoc (px ∷ All) = map-all (\x → wken x) (px ∷ All) wken-all-inv : ∀{Γ' Γ Ω xs B} → All (λ A → Exp (Γ' ++ Γ) (Left (inj₁ Ω) (Inv A))) xs → All (λ A → Exp (B ∷ (Γ' ++ Γ)) (Left (inj₁ Ω) (Inv A))) xs wken-all-inv [] = [] wken-all-inv (px ∷ All) = map-all (\x → wken x) (px ∷ All) postulate wkex : ∀{Γ A B Form} → Exp (A ∷ Γ) Form → Exp (A ∷ B ∷ Γ) Form wkex2 : ∀{Γ A B C Form} → Exp (A ∷ B ∷ Γ) Form → Exp (A ∷ B ∷ C ∷ Γ) Form cntr : ∀{A Form} → (Γ : Ctx) → A ∈ Γ → Exp (A ∷ Γ) Form → Exp Γ Form cntr Γ In Exp = wk (sub-cntr Γ In) Exp postulate exch-cons : ∀{Γ Γ' LA C x} → Term (x ∷ Γ ++ Γ') LA C → Term (Γ ++ x ∷ Γ') LA C subst⁺ : ∀{Γ Form} → (Γ' : Ctx) → (LAi : List (Type ⁺)) → All (\x → Value (Γ' ++ Γ) x) LAi → Exp (Γ' ++ map (\x → HSusp x) (LAi) ++ Γ) Form → Exp (Γ' ++ Γ) Form subst⁻ : ∀{Γ A L U} → stable U → Exp Γ (Left L (Susp A)) → Spine Γ A U → Exp Γ (Left L U) cut⁺ : ∀{U Γ Ω} → suspnormalΓ Γ → suspnormal U → (LAi : List (Type ⁺)) → All (\x → Value Γ x) LAi → Term Γ (LAi ++ Ω) U → Term Γ Ω U cut⁻ : ∀{U Γ N} → suspnormalΓ Γ → suspstable U → (LA : List (Type ⁻)) → (length LA ≡ suc N) → All (\x → Term Γ [] (Inv x)) LA → All (\x → Spine Γ x U) LA → Term Γ [] U rsubst+ : ∀{Ω Γ Form} (Γ' : Ctx) → suspnormalΓ (Γ' ++ Γ) → suspnormal Form → (LA+ : List (Type ⁺)) → (LA- : List (Type ⁻)) → All (\x → Term (Γ' ++ Γ) [] (Inv x)) LA- → All (\x → Value Γ x) LA+ → Term (Γ' ++ (map (\x → Pers x) LA-) ++ Γ) (LA+ ++ Ω) Form → Term (Γ' ++ Γ) Ω Form postulate rsubst-v : ∀{Γ Form} (Γ' : Ctx) → suspnormalΓ (Γ' ++ Γ) → suspnormalF Form → (LA- : List (Type ⁻)) → All (\x → Term (Γ' ++ Γ) [] (Inv x)) LA- → Exp (Γ' ++ (map (\x → Pers x) LA-) ++ Γ) Form → Exp (Γ' ++ Γ) Form -- {-# NO_TERMINATION_CHECK #-} --rsubst : ∀{Γ Form A} (Γ' : Ctx) -- → suspnormalΓ (Γ' ++ Γ) -- → suspnormalF Form -- → Term (Γ' ++ Γ) [] (Inv A) -- → Exp (Γ' ++ (Pers A) ∷ Γ) Form -- → Exp (Γ' ++ Γ) Form lsubst : ∀{Γ U L A} → suspnormalΓ Γ → suspstable U → Exp Γ (Left L (True A)) → Term Γ [ A ] U → Exp Γ (Left L U) -- -- Positive principal substitution cut⁺ pfΓ pf [] Values T = T cut⁺ pfΓ pf (z ∷ LA) ((id⁺ v) ∷ Values) N with (pfΓ v) cut⁺ pfΓ pf (.(a A ⁺) ∷ LA) (id⁺ v ∷ Values) (η⁺ N) | A , refl = subst⁺ [] (a A ⁺ ∷ []) (id⁺ v ∷ []) (cut⁺ (conssusp pfΓ) pf LA (wken-all-rfoc {[]} Values) N) cut⁺ {U} {Γ} {Ω} pfΓ pf (.(↓ A) ∷ LA) (↓R N ∷ Values) (↓L {A} N') = rsubst+ [] pfΓ pf LA (A ∷ []) (N ∷ []) Values N' -- rsubst+ [] pfΓ pf N (cut⁺ (conspers pfΓ) pf LA (wken-all-rfoc {[]} Values) N₁) cut⁺ pfΓ pf (.(A ∨ B) ∷ LA) (∨R₁ V ∷ Values) (∨L {A} {B} N₁ N₂) = cut⁺ pfΓ pf (A ∷ LA) (V ∷ Values) N₁ cut⁺ pfΓ pf (.(A ∨ B) ∷ LA) (∨R₂ V ∷ Values) (∨L {A} {B} N₁ N₂) = cut⁺ pfΓ pf (B ∷ LA) (V ∷ Values) N₂ cut⁺ pfΓ pf (.⊤⁺ ∷ LA) (px ∷ Values) (⊤⁺L N) = cut⁺ pfΓ pf LA Values N cut⁺ pfΓ pf ((A ∧⁺ B) ∷ LA) (∧⁺R V₁ V₂ ∷ Values) (∧⁺L N) = cut⁺ pfΓ pf (B ∷ LA) (V₂ ∷ Values) (cut⁺ pfΓ pf ((A ∷ [])) (V₁ ∷ []) N) -- -- Negative principle substitution cut⁻ pfΓ pf [] () LExp LExp' cut⁻ pfΓ pf (_ ∷ LA) LL (focL () x Sp ∷ LExp) (px₁ ∷ LExp') cut⁻ pfΓ pf (a Q .⁻ ∷ LA) LL (η⁻ N₁ ∷ LExp) (id⁻ ∷ LExp') = N₁ cut⁻ pfΓ (proj₁ , ()) (⊤⁻ ∷ LA) LL (⊤⁻R ∷ LExp) (id⁻ ∷ LExp') cut⁻ pfΓ (proj₁ , ()) (↑ x ∷ LA) LL (↑R N₁ ∷ LExp) (id⁻ ∷ LExp') cut⁻ pfΓ (proj₁ , ()) ((x ⊃ x₁) ∷ LA) LL (⊃R N₁ ∷ LExp) (id⁻ ∷ LExp') cut⁻ pfΓ (proj₁ , ()) ((x ∧⁻ x₁) ∷ LA) LL (∧⁻R N₁ N₂ ∷ LExp) (id⁻ ∷ LExp') cut⁻ pfΓ pf (↑ x ∷ LA) LL (↑R N₁ ∷ LExp) (↑L N₂ ∷ LExp') = lsubst pfΓ pf N₁ N₂ cut⁻ pfΓ pf ((x ⊃ x₁) ∷ LA) refl (⊃R N₁ ∷ LExp) (⊃L V Sp ∷ LExp') = cut⁻ pfΓ pf (x₁ ∷ LA) refl ((cut⁺ pfΓ _ (x ∷ []) (V ∷ []) N₁) ∷ LExp) (Sp ∷ LExp') cut⁻ pfΓ pf ((x ∧⁻ x₁) ∷ LA) refl (∧⁻R N₁ N₂ ∷ LExp) (∧⁻L₁ Sp ∷ LExp') = cut⁻ pfΓ pf (x ∷ LA) refl (N₁ ∷ LExp) (Sp ∷ LExp') cut⁻ pfΓ pf ((x ∧⁻ x₁) ∷ LA) LL (∧⁻R N₁ N₂ ∷ LExp) (∧⁻L₂ Sp ∷ LExp') = cut⁻ pfΓ pf (x₁ ∷ LA) refl (N₂ ∷ LExp) (Sp ∷ LExp') -- helper : ∀{Γ LA- A} → -- All (λ x₂ → Exp (Γ) (Left (inj₁ []) (Inv x₂))) LA- -- → Any (_≡_ (Pers A)) (map Pers LA-) -- → All (λ x₂ → Exp (Γ) (Left (inj₁ []) (Inv x₂))) (A ∷ []) -- helper [] () -- helper (px ∷ L) (here refl) = px ∷ [] -- helper (px ∷ L) (there In) = helper L In rsubst+ Γ' pfΓ pf [] LA- LT [] (focR V) = focR (rsubst-v Γ' pfΓ _ LA- LT V ) rsubst+ Γ' pfΓ pf [] LA- LT [] (focL pf₁ x Sp) with fromctxGen Γ' (map Pers LA-) x rsubst+ Γ' pfΓ pf [] LA- LT [] (focL {A} pf₁ x Sp) | inj₁ x₁ = cut⁻ pfΓ (pf₁ , pf) (A ∷ []) refl {!(helper LT x₁)!} ((rsubst-v Γ' pfΓ pf LA- LT Sp) ∷ []) rsubst+ Γ' pfΓ pf [] LA- LT [] (focL pf₁ x Sp) | inj₂ y = focL pf₁ y (rsubst-v Γ' pfΓ pf LA- LT Sp ) rsubst+ Γ' pfΓ pf [] LA- LT [] (η⁺ N) = η⁺ (rsubst-v (_ ∷ Γ' ) (conssusp pfΓ) pf LA- (wken-all-inv {[]} LT) N ) rsubst+ Γ' pfΓ pf [] LA- LT [] (↓L N) = ↓L (rsubst-v (_ ∷ Γ' ) (conspers pfΓ) pf LA- (wken-all-inv {[]} LT) N ) rsubst+ Γ' pfΓ pf [] LA- LT [] ⊥L = ⊥L rsubst+ Γ' pfΓ pf [] LA- LT [] (∨L N₁ N₂) = ∨L (rsubst+ Γ' pfΓ pf [] LA- LT [] N₁) (rsubst+ Γ' pfΓ pf [] LA- LT [] N₂) rsubst+ Γ' pfΓ pf [] LA- LT [] (⊤⁺L N) = ⊤⁺L (rsubst+ Γ' pfΓ pf [] LA- LT [] N ) rsubst+ Γ' pfΓ pf [] LA- LT [] (∧⁺L N) = ∧⁺L (rsubst+ Γ' pfΓ pf [] LA- LT [] N) rsubst+ Γ' pfΓ pf [] LA- LT [] (η⁻ N) = η⁻ (rsubst+ Γ' pfΓ pf [] LA- LT [] N) rsubst+ Γ' pfΓ pf [] LA- LT [] (↑R N) = ↑R (rsubst+ Γ' pfΓ pf [] LA- LT [] N) rsubst+ Γ' pfΓ pf [] LA- LT [] (⊃R N) = ⊃R (rsubst+ Γ' pfΓ pf [] LA- LT [] N) rsubst+ Γ' pfΓ pf [] LA- LT [] ⊤⁻R = ⊤⁻R rsubst+ Γ' pfΓ pf [] LA- LT [] (∧⁻R N₁ N₂) = ∧⁻R (rsubst+ Γ' pfΓ pf [] LA- LT [] N₁) (rsubst+ Γ' pfΓ pf [] LA- LT [] N₂) -- rsubst+ Γ' pfΓ pf (↓ x ∷ LA+) LA- LT (id⁺ v ∷ Values) (↓L N) with (pfΓ (++ʳ Γ' v)) -- ... | proj₁ , () -- ------------ -- -- Part which requires a list for negative types -- rsubst+ {Ω} {Γ} Γ' pfΓ pf (a Q .⁺ ∷ LA+) LA- LT (id⁺ v ∷ Values) (η⁺ N) = -- rsubst+ Γ' pfΓ pf LA+ LA- (LT ) Values -- (cntr (Γ' ++ map Pers LA- ++ Γ) (++ʳ Γ' (++ʳ (map Pers LA-) v) ) N) -- rsubst+ {Ω} {Γ} Γ' pfΓ pf (↓ x ∷ LA+) LA- LT (↓R N ∷ Values) (↓L N₁) = -- rsubst+ Γ' pfΓ pf LA+ (x ∷ LA-) ((wk (λ x₂ → ++ʳ Γ' x₂) N) ∷ LT) Values (exch-cons {Γ'} {map Pers LA- ++ Γ} N₁) -------------- -- rsubst+ Γ' pfΓ pf (⊥⁺ ∷ LA+) LA- LT (id⁺ v ∷ Values) ⊥L with (pfΓ (++ʳ Γ' v)) -- ... | proj₁ , () -- rsubst+ Γ' pfΓ pf (x ∨ x₁ ∷ LA+) LA- LT (id⁺ v ∷ Values) (∨L N₁ N₂) with (pfΓ (++ʳ Γ' v)) -- ... | proj₁ , () rsubst+ Γ' pfΓ pf ((x ∨ x₁) ∷ LA+) LA- LT (∨R₁ V ∷ Values) (∨L N₁ N₂) = rsubst+ Γ' pfΓ pf (x ∷ LA+) LA- LT (V ∷ Values) N₁ rsubst+ Γ' pfΓ pf ((x ∨ x₁) ∷ LA+) LA- LT (∨R₂ V ∷ Values) (∨L N₁ N₂) = rsubst+ Γ' pfΓ pf (x₁ ∷ LA+) LA- LT (V ∷ Values) N₂ rsubst+ Γ' pfΓ pf (⊤⁺ ∷ LA+) LA- LT (_ ∷ Values) (⊤⁺L N) = rsubst+ Γ' pfΓ pf LA+ LA- LT Values N -- rsubst+ Γ' pfΓ pf (x ∧⁺ x₁ ∷ LA+) LA- LT (id⁺ v ∷ Values) (∧⁺L N) with (pfΓ (++ʳ Γ' v)) -- ... | proj₁ , () rsubst+ Γ' pfΓ pf ((x ∧⁺ x₁) ∷ LA+) LA- LT (∧⁺R V₁ V₂ ∷ Values) (∧⁺L N) = rsubst+ Γ' pfΓ pf (x ∷ x₁ ∷ LA+) LA- LT (V₁ ∷ V₂ ∷ Values) N rsubst+ {_} {_} {_} _ _ _ _ _ _ _ _ = ? -- -- -- Substitution out of terms lsubst pfΓ pf (focR {A} V) N = cut⁺ pfΓ (proj₂ pf) (A ∷ []) (V ∷ []) N lsubst pfΓ pf (focL pf' x Sp) N = focL (proj₁ pf) x (lsubst pfΓ pf Sp N) lsubst pfΓ pf (η⁺ M) N = η⁺ (lsubst (conssusp pfΓ) pf M (wken N)) lsubst pfΓ pf (↓L M) N = ↓L (lsubst (conspers pfΓ) pf M (wken N)) lsubst pfΓ pf ⊥L M = ⊥L lsubst pfΓ pf (∨L M₁ M₂) N = ∨L (lsubst pfΓ pf M₁ N) (lsubst pfΓ pf M₂ N) lsubst pfΓ pf (⊤⁺L M) N = ⊤⁺L (lsubst pfΓ pf M N) lsubst pfΓ pf (∧⁺L M) N = ∧⁺L (lsubst pfΓ pf M N) -- Substitution of of spines lsubst pfΓ pf (↑L M) N = ↑L (lsubst pfΓ pf M N) lsubst pfΓ pf (⊃L V Sp) N = ⊃L V (lsubst pfΓ pf Sp N) lsubst pfΓ pf (∧⁻L₁ Sp) N = ∧⁻L₁ (lsubst pfΓ pf Sp N) lsubst pfΓ pf (∧⁻L₂ Sp) N = ∧⁻L₂ (lsubst pfΓ pf Sp N)
{ "alphanum_fraction": 0.476130091, "avg_line_length": 30.2618510158, "ext": "agda", "hexsha": "978155c4d2bbc483dbcf77963844e1cb036d5126", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/bugs/Issue1075.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "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": "alhassy/agda", "max_issues_repo_path": "test/bugs/Issue1075.agda", "max_line_length": 228, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/bugs/Issue1075.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": 6595, "size": 13406 }
module Category.Choice where open import Data.Sum using (_⊎_) open import Agda.Primitive using (Level; _⊔_; lsuc) open import Category.Profunctor record ChoiceImp {a b : Level} (p : Set a → Set a → Set b) : Set (lsuc (a ⊔ b)) where field isProfunctor : ProfunctorImp p left' : ∀ {x y z : Set a} → p x y → p (x ⊎ z) (y ⊎ z) right' : ∀ {x y z : Set a} → p x y → p (z ⊎ x) (z ⊎ y) module Choice {a b : Level} {p : Set a → Set a → Set b} (isChoice : ChoiceImp p) where left : ∀ {x y z : Set a} → p x y → p (x ⊎ z) (y ⊎ z) left = ChoiceImp.left' isChoice right : ∀ {x y z : Set a} → p x y → p (z ⊎ x) (z ⊎ y) right = ChoiceImp.right' isChoice open Profunctor (ChoiceImp.isProfunctor isChoice)
{ "alphanum_fraction": 0.593006993, "avg_line_length": 37.6315789474, "ext": "agda", "hexsha": "caaf1c1bd4254b5e81211138b3701e583db1b3c0", "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": "308afeeaa905870dbf1a995fa82e8825dfaf2d74", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "crisoagf/agda-optics", "max_forks_repo_path": "src/Category/Choice.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "308afeeaa905870dbf1a995fa82e8825dfaf2d74", "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": "crisoagf/agda-optics", "max_issues_repo_path": "src/Category/Choice.agda", "max_line_length": 86, "max_stars_count": null, "max_stars_repo_head_hexsha": "308afeeaa905870dbf1a995fa82e8825dfaf2d74", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "crisoagf/agda-optics", "max_stars_repo_path": "src/Category/Choice.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 277, "size": 715 }
open import Common.Prelude open import Common.Equality open import Common.Product test : (p : Bool × Bool) → proj₁ p ≡ true → Set test _ e = {!e!} -- WAS: -- Splitting on e gives -- test r refl = ? -- proj₁ r != true of type Bool -- when checking that the pattern refl has type proj₁ r ≡ true
{ "alphanum_fraction": 0.6722972973, "avg_line_length": 21.1428571429, "ext": "agda", "hexsha": "4271397365d816a4dfdafcab06336f7d245f21fd", "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/interaction/Issue635c.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/interaction/Issue635c.agda", "max_line_length": 62, "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/interaction/Issue635c.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 87, "size": 296 }
module Category.Strong where open import Data.Product using (_×_) open import Agda.Primitive using (Level; _⊔_; lsuc) open import Category.Profunctor record StrongImp {a b : Level} (p : Set a → Set a → Set b) : Set (lsuc (a ⊔ b)) where field isProfunctor : ProfunctorImp p first' : ∀ {x y z : Set a} → p x y → p (x × z) (y × z) second' : ∀ {x y z : Set a} → p x y → p (z × x) (z × y) module Strong {a b : Level} {p : Set a → Set a → Set b} (isStrong : StrongImp p) where first : ∀ {x y z : Set a} → p x y → p (x × z) (y × z) first = StrongImp.first' isStrong second : ∀ {x y z : Set a} → p x y → p (z × x) (z × y) second = StrongImp.second' isStrong open Profunctor (StrongImp.isProfunctor isStrong)
{ "alphanum_fraction": 0.5997248968, "avg_line_length": 38.2631578947, "ext": "agda", "hexsha": "b7807da286b42fa0d13d8bef97ce0b8af6e067d9", "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": "308afeeaa905870dbf1a995fa82e8825dfaf2d74", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "crisoagf/agda-optics", "max_forks_repo_path": "src/Category/Strong.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "308afeeaa905870dbf1a995fa82e8825dfaf2d74", "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": "crisoagf/agda-optics", "max_issues_repo_path": "src/Category/Strong.agda", "max_line_length": 86, "max_stars_count": null, "max_stars_repo_head_hexsha": "308afeeaa905870dbf1a995fa82e8825dfaf2d74", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "crisoagf/agda-optics", "max_stars_repo_path": "src/Category/Strong.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 267, "size": 727 }
module Bee2.Crypto.Bign where open import Data.ByteString open import Data.ByteVec open import Data.Bool using (Bool) open import Data.Nat using (ℕ) open import Data.Product using (_,_) open import Agda.Builtin.TrustMe using (primTrustMe) import Bee2.Crypto.Defs open Bee2.Crypto.Defs open Bee2.Crypto.Defs using (Hash) public {-# FOREIGN GHC import qualified Bee2.Crypto.Bign #-} {-# FOREIGN GHC import qualified Data.ByteString #-} postulate -- bignstd128-pri [32] → belt-hash [32] → bign-sig [48] primBignSign2 : ByteString Strict → ByteString Strict → ByteString Strict -- bignstd128-pri [32] → bignstd128-pub [64] primBignCalcPubkey : ByteString Strict → ByteString Strict -- bignstd128-pub [64] → belt-hash [32] → bign-sig [48] → Bool primBignVerify : ByteString Strict → ByteString Strict → ByteString Strict → Bool {-# COMPILE GHC primBignSign2 = ( \pri hash -> Bee2.Crypto.Bign.bignSign2'bs 128 pri Bee2.Crypto.Belt.hbelt_oid hash ) #-} {-# COMPILE GHC primBignCalcPubkey = ( \pri -> Bee2.Crypto.Bign.bignCalcPubkey'bs 128 pri ) #-} {-# COMPILE GHC primBignVerify = ( \pub hash sig -> Bee2.Crypto.Bign.bignVerify'bs 128 pub Bee2.Crypto.Belt.hbelt_oid hash sig ) #-} Pri = ByteVec {Strict} 32 Pub = ByteVec {Strict} 64 -- TODO: add IsValid Sig = ByteVec {Strict} 48 bignSign2 : Pri → Hash → Sig bignSign2 (pri , _) (hash , _) = primBignSign2 pri hash , primTrustMe bignCalcPubkey : Pri → Pub bignCalcPubkey (pri , _) = primBignCalcPubkey pri , primTrustMe bignVerify : Pub → Hash → Sig → Bool bignVerify (pub , _) (hash , _) (sig , _) = primBignVerify pub hash sig
{ "alphanum_fraction": 0.7177419355, "avg_line_length": 36.6363636364, "ext": "agda", "hexsha": "8146794f93e93b2a817161e253d812b2de7f680b", "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": "22682afc8d488e3812307e104785d2b8dc8b9d4a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "semenov-vladyslav/bee2-agda", "max_forks_repo_path": "src/Bee2/Crypto/Bign.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "22682afc8d488e3812307e104785d2b8dc8b9d4a", "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": "semenov-vladyslav/bee2-agda", "max_issues_repo_path": "src/Bee2/Crypto/Bign.agda", "max_line_length": 103, "max_stars_count": null, "max_stars_repo_head_hexsha": "22682afc8d488e3812307e104785d2b8dc8b9d4a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "semenov-vladyslav/bee2-agda", "max_stars_repo_path": "src/Bee2/Crypto/Bign.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 495, "size": 1612 }
------------------------------------------------------------------------ -- A partial order ------------------------------------------------------------------------ {-# OPTIONS --cubical --sized-types #-} open import Prelude hiding (⊥; module W) module Partiality-monad.Coinductive.Partial-order {a} {A : Type a} where open import Equality.Propositional.Cubical open import Logical-equivalence using (_⇔_) open import Prelude.Size open import Bijection equality-with-J using (_↔_) open import Equality.Path.Isomorphisms.Univalence equality-with-paths open import H-level equality-with-J open import H-level.Closure equality-with-J open import H-level.Truncation.Propositional equality-with-paths as Trunc open import Quotient equality-with-paths as Quotient open import Univalence-axiom equality-with-J open import Delay-monad open import Delay-monad.Bisimilarity as B using (_≈_) import Delay-monad.Partial-order as PO open import Partiality-monad.Coinductive -- An ordering relation. LE : A ⊥ → A ⊥ → Proposition a LE x y = Quotient.rec (λ where .[]ʳ x → LE″ x y .[]-respects-relationʳ → left-lemma″-∥∥ y .is-setʳ → is-set) x where LE′ : Delay A ∞ → Delay A ∞ → Proposition a LE′ x y = ∥ x PO.⊑ y ∥ , truncation-is-proposition abstract is-set : Is-set (∃ λ (A : Type a) → Is-proposition A) is-set = Is-set-∃-Is-proposition ext prop-ext right-lemma : ∀ {x y z} → x ≈ y → LE′ z x ≡ LE′ z y right-lemma x≈y = _↔_.to (⇔↔≡″ ext prop-ext) (record { to = ∥∥-map (flip PO.transitive-⊑≈ x≈y) ; from = ∥∥-map (flip PO.transitive-⊑≈ (B.symmetric x≈y)) }) right-lemma-∥∥ : ∀ {x y z} → ∥ x ≈ y ∥ → LE′ z x ≡ LE′ z y right-lemma-∥∥ = Trunc.rec is-set right-lemma LE″ : Delay A ∞ → A ⊥ → Proposition a LE″ x y = Quotient.rec (λ where .[]ʳ → LE′ x .[]-respects-relationʳ → right-lemma-∥∥ .is-setʳ → is-set) y abstract left-lemma : ∀ {x y z} → x ≈ y → LE′ x z ≡ LE′ y z left-lemma x≈y = _↔_.to (⇔↔≡″ ext prop-ext) (record { to = ∥∥-map (PO.transitive-≈⊑ (B.symmetric x≈y)) ; from = ∥∥-map (PO.transitive-≈⊑ x≈y) }) left-lemma″ : ∀ {x y} z → x ≈ y → LE″ x z ≡ LE″ y z left-lemma″ {x} {y} z x≈y = Quotient.elim-prop {P = λ z → LE″ x z ≡ LE″ y z} (λ where .[]ʳ _ → left-lemma x≈y .is-propositionʳ _ → Is-set-∃-Is-proposition ext prop-ext) z left-lemma″-∥∥ : ∀ {x y} z → ∥ x ≈ y ∥ → LE″ x z ≡ LE″ y z left-lemma″-∥∥ z = Trunc.rec is-set (left-lemma″ z) infix 4 _⊑_ _⊑_ : A ⊥ → A ⊥ → Type a x ⊑ y = proj₁ (LE x y) -- _⊑_ is propositional. ⊑-propositional : ∀ x y → Is-proposition (x ⊑ y) ⊑-propositional x y = proj₂ (LE x y) -- _⊑_ is reflexive. reflexive : ∀ x → x ⊑ x reflexive = Quotient.elim-prop λ where .[]ʳ x → ∣ PO.reflexive x ∣ .is-propositionʳ x → ⊑-propositional [ x ] [ x ] -- _⊑_ is antisymmetric. antisymmetric : ∀ x y → x ⊑ y → y ⊑ x → x ≡ y antisymmetric = Quotient.elim-prop λ where .[]ʳ x → Quotient.elim-prop (λ where .[]ʳ y ∥x⊑y∥ ∥y⊑x∥ → []-respects-relation $ Trunc.rec truncation-is-proposition (λ x⊑y → ∥∥-map (PO.antisymmetric x⊑y) ∥y⊑x∥) ∥x⊑y∥ .is-propositionʳ _ → Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → ⊥-is-set) .is-propositionʳ _ → Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → ⊥-is-set -- _⊑_ is transitive. transitive : ∀ x y z → x ⊑ y → y ⊑ z → x ⊑ z transitive = Quotient.elim-prop λ where .[]ʳ x → Quotient.elim-prop λ where .[]ʳ y → Quotient.elim-prop λ where .[]ʳ z ∥x⊑y∥ → Trunc.rec truncation-is-proposition (λ y⊑z → ∥∥-map (λ x⊑y → PO.transitive x⊑y y⊑z) ∥x⊑y∥) .is-propositionʳ _ → Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → ⊑-propositional [ _ ] [ _ ] .is-propositionʳ _ → Π-closure ext 1 λ z → Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → ⊑-propositional [ _ ] z .is-propositionʳ _ → Π-closure ext 1 λ _ → Π-closure ext 1 λ z → Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → ⊑-propositional [ _ ] z
{ "alphanum_fraction": 0.5238741797, "avg_line_length": 29.0723684211, "ext": "agda", "hexsha": "edf5a2bc773e63efa1d5a8e4ceaf942982401982", "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/Partiality-monad/Coinductive/Partial-order.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/Partiality-monad/Coinductive/Partial-order.agda", "max_line_length": 72, "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/Partiality-monad/Coinductive/Partial-order.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": 1665, "size": 4419 }
module SystemF.Substitutions.Lemmas where open import Prelude hiding (module Fin; id) open import SystemF.WellTyped open import SystemF.Substitutions open import Data.Fin as Fin using () open import Data.Fin.Substitution open import Data.Fin.Substitution.Lemmas open import Data.Vec hiding ([_]) open import Extensions.Substitution open import Extensions.Vec open import Data.Vec.Properties import Category.Applicative.Indexed as Applicative open Applicative.Morphism using (op-<$>) module TypeLemmas where open TypeSubst using (module Lifted; module TypeApp) open import Data.Fin.Substitution.Lemmas open import Data.Fin.Substitution.Lemmas public using (module VarLemmas) open import Data.Star using (Star; ε; _◅_) typeLemmas : TermLemmas Type typeLemmas = record { termSubst = TypeSubst.typeSubst; app-var = refl ; /✶-↑✶ = Lemma./✶-↑✶ } where module Lemma {T₁ T₂} {lift₁ : Lift T₁ Type} {lift₂ : Lift T₂ Type} where open Lifted lift₁ using () renaming (_↑✶_ to _↑✶₁_; _/✶_ to _/✶₁_) open Lifted lift₂ using () renaming (_↑✶_ to _↑✶₂_; _/✶_ to _/✶₂_) /✶-↑✶ : ∀ {m n} (σs₁ : Subs T₁ m n) (σs₂ : Subs T₂ m n) → (∀ k x → tvar x /✶₁ σs₁ ↑✶₁ k ≡ tvar x /✶₂ σs₂ ↑✶₂ k) → ∀ k t → t /✶₁ σs₁ ↑✶₁ k ≡ t /✶₂ σs₂ ↑✶₂ k /✶-↑✶ ρs₁ ρs₂ hyp k (tvar x) = hyp k x /✶-↑✶ ρs₁ ρs₂ hyp k (tc c) = begin (tc c) /✶₁ ρs₁ ↑✶₁ k ≡⟨ TypeApp.tc-/✶-↑✶ _ k ρs₁ ⟩ (tc c) ≡⟨ sym $ TypeApp.tc-/✶-↑✶ _ k ρs₂ ⟩ (tc c) /✶₂ ρs₂ ↑✶₂ k ∎ /✶-↑✶ ρs₁ ρs₂ hyp k (a ⟶ b) = begin (a ⟶ b) /✶₁ ρs₁ ↑✶₁ k ≡⟨ TypeApp.⟶-/✶-↑✶ _ k ρs₁ ⟩ (a /✶₁ ρs₁ ↑✶₁ k) ⟶ (b /✶₁ ρs₁ ↑✶₁ k) ≡⟨ cong₂ _⟶_ (/✶-↑✶ ρs₁ ρs₂ hyp k a) (/✶-↑✶ ρs₁ ρs₂ hyp k b) ⟩ (a /✶₂ ρs₂ ↑✶₂ k) ⟶ (b /✶₂ ρs₂ ↑✶₂ k) ≡⟨ sym (TypeApp.⟶-/✶-↑✶ _ k ρs₂) ⟩ (a ⟶ b) /✶₂ ρs₂ ↑✶₂ k ∎ /✶-↑✶ ρs₁ ρs₂ hyp k (a →' b) = begin (a →' b) /✶₁ ρs₁ ↑✶₁ k ≡⟨ TypeApp.→'-/✶-↑✶ _ k ρs₁ ⟩ (a /✶₁ ρs₁ ↑✶₁ k) →' (b /✶₁ ρs₁ ↑✶₁ k) ≡⟨ cong₂ _→'_ (/✶-↑✶ ρs₁ ρs₂ hyp k a) (/✶-↑✶ ρs₁ ρs₂ hyp k b) ⟩ (a /✶₂ ρs₂ ↑✶₂ k) →' (b /✶₂ ρs₂ ↑✶₂ k) ≡⟨ sym (TypeApp.→'-/✶-↑✶ _ k ρs₂) ⟩ (a →' b) /✶₂ ρs₂ ↑✶₂ k ∎ /✶-↑✶ ρs₁ ρs₂ hyp k (∀' a) = begin (∀' a) /✶₁ ρs₁ ↑✶₁ k ≡⟨ TypeApp.∀'-/✶-↑✶ _ k ρs₁ ⟩ ∀' (a /✶₁ ρs₁ ↑✶₁ (1 + k)) ≡⟨ cong ∀' (/✶-↑✶ ρs₁ ρs₂ hyp (1 + k) a) ⟩ ∀' (a /✶₂ ρs₂ ↑✶₂ (1 + k)) ≡⟨ sym (TypeApp.∀'-/✶-↑✶ _ k ρs₂) ⟩ (∀' a) /✶₂ ρs₂ ↑✶₂ k ∎ module tpl = TermLemmas typeLemmas -- The above lemma /✶-↑✶ specialized to single substitutions /-↑⋆ : ∀ {T₁ T₂} {lift₁ : Lift T₁ Type} {lift₂ : Lift T₂ Type} → let open Lifted lift₁ using () renaming (_↑⋆_ to _↑⋆₁_; _/_ to _/₁_) open Lifted lift₂ using () renaming (_↑⋆_ to _↑⋆₂_; _/_ to _/₂_) in ∀ {n k} (ρ₁ : Sub T₁ n k) (ρ₂ : Sub T₂ n k) → (∀ i x → tvar x /₁ ρ₁ ↑⋆₁ i ≡ tvar x /₂ ρ₂ ↑⋆₂ i) → ∀ i a → a /₁ ρ₁ ↑⋆₁ i ≡ a /₂ ρ₂ ↑⋆₂ i /-↑⋆ ρ₁ ρ₂ hyp i a = tpl./✶-↑✶ (ρ₁ ◅ ε) (ρ₂ ◅ ε) hyp i a open AdditionalLemmas typeLemmas public open tpl public /Var-/ : ∀ {ν μ} (t : Type ν) (s : Sub Fin ν μ) → t /Var s ≡ t / (map tvar s) /Var-/ (tc c) s = refl /Var-/ (tvar n) s = lookup⋆map s tvar n /Var-/ (a →' b) s = cong₂ _→'_ (/Var-/ a s) (/Var-/ b s) /Var-/ (a ⟶ b) s = cong₂ _⟶_ (/Var-/ a s) (/Var-/ b s) /Var-/ (∀' t) s = begin ∀' (t /Var (s Var.↑)) ≡⟨ cong ∀' $ /Var-/ t (s Var.↑) ⟩ ∀' (t / (map tvar $ s Var.↑)) ≡⟨ cong (λ u → ∀' (t / u)) (map-var-↑ refl) ⟩ ∀' t / (map tvar s) ∎ a-/Var-varwk↑-/-sub0≡a : ∀ {n} (a : Type (suc n)) → (a /Var Var.wk Var.↑) / sub (tvar zero) ≡ a a-/Var-varwk↑-/-sub0≡a a = begin (a /Var Var.wk Var.↑) / (sub $ tvar zero) ≡⟨ cong (λ u → u / (sub $ tvar zero)) (/Var-/ a $ Var.wk Var.↑) ⟩ (a / (map tvar $ Var.wk Var.↑)) / sub (tvar zero) ≡⟨ cong (λ u → (a / u) / (sub $ tvar zero)) (map-var-↑ map-var-varwk≡wk) ⟩ (a / wk ↑) / (sub $ tvar zero) ≡⟨ a/wk↑/sub0≡a a ⟩ a ∎ -- Lemmas about type substitutions in terms. module TermTypeLemmas where open TermTypeSubst public private module T = TypeLemmas private module TS = TypeSubst private module V = VarLemmas /-↑⋆ : ∀ {T₁ T₂} {lift₁ : Lift T₁ Type} {lift₂ : Lift T₂ Type} → let open TS.Lifted lift₁ using () renaming (_↑⋆_ to _↑⋆₁_; _/_ to _/tp₁_) open Lifted lift₁ using () renaming (_/_ to _/₁_) open TS.Lifted lift₂ using () renaming (_↑⋆_ to _↑⋆₂_; _/_ to _/tp₂_) open Lifted lift₂ using () renaming (_/_ to _/₂_) in ∀ {n k} (ρ₁ : Sub T₁ n k) (ρ₂ : Sub T₂ n k) → (∀ i x → tvar x /tp₁ ρ₁ ↑⋆₁ i ≡ tvar x /tp₂ ρ₂ ↑⋆₂ i) → ∀ i {m} (t : Term (i + n) m) → t /₁ ρ₁ ↑⋆₁ i ≡ t /₂ ρ₂ ↑⋆₂ i /-↑⋆ ρ₁ ρ₂ hyp i (var x) = refl /-↑⋆ ρ₁ ρ₂ hyp i (Λ t) = cong Λ (/-↑⋆ ρ₁ ρ₂ hyp (1 + i) t) /-↑⋆ ρ₁ ρ₂ hyp i (λ' a t) = cong₂ λ' (T./-↑⋆ ρ₁ ρ₂ hyp i a) (/-↑⋆ ρ₁ ρ₂ hyp i t) /-↑⋆ ρ₁ ρ₂ hyp i (t [ b ]) = cong₂ _[_] (/-↑⋆ ρ₁ ρ₂ hyp i t) (T./-↑⋆ ρ₁ ρ₂ hyp i b) /-↑⋆ ρ₁ ρ₂ hyp i (s · t) = cong₂ _·_ (/-↑⋆ ρ₁ ρ₂ hyp i s) (/-↑⋆ ρ₁ ρ₂ hyp i t) /-wk : ∀ {m n} (t : Term m n) → t / TypeSubst.wk ≡ weaken t /-wk t = /-↑⋆ TypeSubst.wk VarSubst.wk (λ k x → begin tvar x T./ T.wk T.↑⋆ k ≡⟨ T.var-/-wk-↑⋆ k x ⟩ tvar (Fin.lift k suc x) ≡⟨ cong tvar (sym (V.var-/-wk-↑⋆ k x)) ⟩ tvar (lookup x (V.wk V.↑⋆ k)) ≡⟨ refl ⟩ tvar x TS./Var V.wk V.↑⋆ k ∎) 0 t module CtxLemmas where open CtxSubst public private module Tp = TypeLemmas private module Var = VarSubst -- Term variable substitution (renaming) commutes with type -- substitution. /Var-/ : ∀ {m ν n l} (ρ : Sub Fin m n) (Γ : Ctx ν n) (σ : Sub Type ν l) → (ρ /Var Γ) / σ ≡ ρ /Var (Γ / σ) /Var-/ ρ Γ σ = begin (ρ /Var Γ) / σ ≡⟨ sym (map-∘ _ _ ρ) ⟩ map (λ x → (lookup x Γ) Tp./ σ) ρ ≡⟨ map-cong (λ x → sym (Tp.lookup-⊙ x)) ρ ⟩ map (λ x → lookup x (Γ / σ)) ρ ∎ -- Term variable substitution (renaming) commutes with weakening of -- typing contexts with an additional type variable. /Var-weaken : ∀ {m n k} (ρ : Sub Fin m k) (Γ : Ctx n k) → weaken (ρ /Var Γ) ≡ ρ /Var (weaken Γ) /Var-weaken ρ Γ = begin (ρ /Var Γ) / Tp.wk ≡⟨ /Var-/ ρ Γ Tp.wk ⟩ ρ /Var (weaken Γ) ∎ -- Term variable substitution (renaming) commutes with term variable -- lookup in typing context. /Var-lookup : ∀ {m n k} (x : Fin m) (ρ : Sub Fin m k) (Γ : Ctx n k) → lookup x (ρ /Var Γ) ≡ lookup (lookup x ρ) Γ /Var-lookup x ρ Γ = op-<$> (lookup-morphism x) _ _ -- Term variable substitution (renaming) commutes with weakening of -- typing contexts with an additional term variable. /Var-∷ : ∀ {m n k} (a : Type n) (ρ : Sub Fin m k) (Γ : Ctx n k) → a ∷ (ρ /Var Γ) ≡ (ρ Var.↑) /Var (a ∷ Γ) /Var-∷ a [] Γ = refl /Var-∷ a (x ∷ ρ) Γ = cong (_∷_ a) (cong (_∷_ (lookup x Γ)) (begin map (λ x → lookup x Γ) ρ ≡⟨ refl ⟩ map (λ x → lookup (suc x) (a ∷ Γ)) ρ ≡⟨ map-∘ _ _ ρ ⟩ map (λ x → lookup x (a ∷ Γ)) (map suc ρ) ∎)) -- Invariants of term variable substitution (renaming) idVar-/Var : ∀ {m n} (Γ : Ctx n m) → Γ ≡ (Var.id /Var Γ) wkVar-/Var-∷ : ∀ {m n} (Γ : Ctx n m) (a : Type n) → Γ ≡ (Var.wk /Var (a ∷ Γ)) idVar-/Var [] = refl idVar-/Var (a ∷ Γ) = cong (_∷_ a) (wkVar-/Var-∷ Γ a) wkVar-/Var-∷ Γ a = begin Γ ≡⟨ idVar-/Var Γ ⟩ Var.id /Var Γ ≡⟨ map-∘ _ _ VarSubst.id ⟩ Var.wk /Var (a ∷ Γ) ∎ ctx-weaken-sub-vanishes : ∀ {ν n} {Γ : Ctx ν n} {a} → (ctx-weaken Γ) ctx/ (Tp.sub a) ≡ Γ ctx-weaken-sub-vanishes {Γ = Γ} {a} = begin (Γ ctx/ Tp.wk) ctx/ (Tp.sub a) ≡⟨ sym $ map-∘ (λ s → s tp/tp Tp.sub a) (λ s → s tp/tp Tp.wk) Γ ⟩ (map (λ s → s tp/tp Tp.wk tp/tp (Tp.sub a)) Γ) ≡⟨ map-cong (TypeLemmas.wk-sub-vanishes) Γ ⟩ (map (λ s → s) Γ) ≡⟨ map-id Γ ⟩ Γ ∎ private ⊢subst : ∀ {m n} {Γ₁ Γ₂ : Ctx n m} {t₁ t₂ : Term n m} {a₁ a₂ : Type n} → Γ₁ ≡ Γ₂ → t₁ ≡ t₂ → a₁ ≡ a₂ → Γ₁ ⊢ t₁ ∈ a₁ → Γ₂ ⊢ t₂ ∈ a₂ ⊢subst refl refl refl hyp = hyp ⊢substCtx : ∀ {m n} {Γ₁ Γ₂ : Ctx n m} {t : Term n m} {a : Type n} → Γ₁ ≡ Γ₂ → Γ₁ ⊢ t ∈ a → Γ₂ ⊢ t ∈ a ⊢substCtx refl hyp = hyp ⊢substTp : ∀ {m n} {Γ : Ctx n m} {t : Term n m} {a₁ a₂ : Type n} → a₁ ≡ a₂ → Γ ⊢ t ∈ a₁ → Γ ⊢ t ∈ a₂ ⊢substTp refl hyp = hyp module WtTypeLemmas where open TypeLemmas hiding (_/_; var; weaken) private module Tp = TypeLemmas module TmTp = TermTypeLemmas module C = CtxLemmas infixl 8 _/_ -- Type substitutions lifted to well-typed terms _/_ : ∀ {m n k} {Γ : Ctx n m} {t : Term n m} {a : Type n} → Γ ⊢ t ∈ a → (σ : Sub Type n k) → Γ C./ σ ⊢ t TmTp./ σ ∈ a Tp./ σ var x / σ = ⊢substTp (lookup-⊙ x) (var x) _/_ {Γ = Γ} (Λ ⊢t) σ = Λ (⊢substCtx eq (⊢t / σ ↑)) where eq : (ctx-weaken Γ) C./ (σ Tp.↑) ≡ ctx-weaken (Γ C./ σ) eq = begin (map (λ s → s tp/tp Tp.wk) Γ) C./ (σ Tp.↑) ≡⟨ cong (λ a → a C./ (σ Tp.↑)) (map-cong (λ a → Tp./-wk {t = a}) Γ) ⟩ (map Tp.weaken Γ) ⊙ (σ Tp.↑) ≡⟨ sym $ map-weaken-⊙ Γ σ ⟩ map Tp.weaken (Γ ⊙ σ) ≡⟨ (map-cong (λ a → sym $ Tp./-wk {t = a}) (Γ ⊙ σ)) ⟩ ctx-weaken (Γ C./ σ) ∎ λ' a ⊢t / σ = λ' (a Tp./ σ) (⊢t / σ) _[_] {a = a} ⊢t b / σ = ⊢substTp (sym (sub-commutes a)) ((⊢t / σ) [ b Tp./ σ ]) ⊢s · ⊢t / σ = (⊢s / σ) · (⊢t / σ) -- Weakening of terms with additional type variables lifted to -- well-typed terms. weaken : ∀ {m n} {Γ : Ctx n m} {t : Term n m} {a : Type n} → Γ ⊢ t ∈ a → ctx-weaken Γ ⊢ TmTp.weaken t ∈ Tp.weaken a weaken {t = t} {a = a} ⊢t = ⊢subst refl (TmTp./-wk t) (/-wk {t = a}) (⊢t / wk) -- Weakening of terms with additional type variables lifted to -- collections of well-typed terms. weakenAll : ∀ {m n k} {Γ : Ctx n m} {ts : Vec (Term n m) k} {as : Vec (Type n) k} → Γ ⊢ⁿ ts ∈ as → ctx-weaken Γ ⊢ⁿ map TmTp.weaken ts ∈ map Tp.weaken as weakenAll {ts = []} {[]} [] = [] weakenAll {ts = _ ∷ _} {_ ∷ _} (⊢t ∷ ⊢ts) = weaken ⊢t ∷ weakenAll ⊢ts -- Shorthand for single-variable type substitutions in well-typed -- terms. _[/_] : ∀ {m n} {Γ : Ctx (1 + n) m} {t a} → Γ ⊢ t ∈ a → (b : Type n) → Γ C./ sub b ⊢ t TmTp./ sub b ∈ a Tp./ sub b ⊢t [/ b ] = ⊢t / sub b tm[/tp]-preserves : ∀ {ν n} {Γ : Ctx ν n} {t τ} → Γ ⊢ Λ t ∈ ∀' τ → ∀ a → Γ ⊢ (t tm[/tp a ]) ∈ τ tp[/tp a ] tm[/tp]-preserves {Γ = Γ} {t} {τ} (Λ p) a = ctx-subst C.ctx-weaken-sub-vanishes (p / (Tp.sub a)) where ctx-subst = Prelude.subst (λ c → c ⊢ t tm[/tp a ] ∈ τ tp[/tp a ]) module WtTermLemmas where private module Tp = TypeLemmas module TmTp = TermTypeLemmas module TmTm = TermTermSubst module Var = VarSubst module C = CtxLemmas TmSub = TmTm.TermSub Term infix 4 _⇒_⊢_ -- Well-typed term substitutions are collections of well-typed terms. _⇒_⊢_ : ∀ {ν m k} → Ctx ν m → Ctx ν k → TmSub ν m k → Set Γ ⇒ Δ ⊢ ρ = Δ ⊢ⁿ ρ ∈ Γ infixl 8 _/_ _/Var_ infix 10 _↑ -- Application of term variable substitutions (renaming) lifted to -- well-typed terms. _/Var_ : ∀ {m n k} {Γ : Ctx n k} {t : Term n m} {a : Type n} (ρ : Sub Fin m k) → ρ C./Var Γ ⊢ t ∈ a → Γ ⊢ t TmTm./Var ρ ∈ a _/Var_ {Γ = Γ} ρ (var x) = ⊢substTp (sym (C./Var-lookup x ρ Γ)) (var (lookup x ρ)) _/Var_ {Γ = Γ} ρ (Λ ⊢t) = Λ (ρ /Var ⊢substCtx (C./Var-weaken ρ Γ) ⊢t) _/Var_ {Γ = Γ} ρ (λ' a ⊢t) = λ' a (ρ Var.↑ /Var ⊢substCtx (C./Var-∷ a ρ Γ) ⊢t) ρ /Var (⊢t [ b ]) = (ρ /Var ⊢t) [ b ] ρ /Var (⊢s · ⊢t) = (ρ /Var ⊢s) · (ρ /Var ⊢t) -- Weakening of terms with additional term variables lifted to -- well-typed terms. weaken : ∀ {m n} {Γ : Ctx n m} {t : Term n m} {a b : Type n} → Γ ⊢ t ∈ a → b ∷ Γ ⊢ TmTm.weaken t ∈ a weaken {Γ = Γ} {b = b} ⊢t = Var.wk /Var ⊢substCtx (C.wkVar-/Var-∷ Γ b) ⊢t -- Weakening of terms with additional term variables lifted to -- collections of well-typed terms. weakenAll : ∀ {m n k} {Γ : Ctx n m} {ts : Vec (Term n m) k} {as : Vec (Type n) k} {b : Type n} → Γ ⊢ⁿ ts ∈ as → (b ∷ Γ) ⊢ⁿ map TmTm.weaken ts ∈ as weakenAll {ts = []} {[]} [] = [] weakenAll {ts = _ ∷ _} {_ ∷ _} (⊢t ∷ ⊢ts) = weaken ⊢t ∷ weakenAll ⊢ts -- Lifting of well-typed term substitutions. _↑ : ∀ {m n k} {Γ : Ctx n m} {Δ : Ctx n k} {ρ b} → Γ ⇒ Δ ⊢ ρ → b ∷ Γ ⇒ b ∷ Δ ⊢ ρ TmTm.↑ ⊢ρ ↑ = var zero ∷ weakenAll ⊢ρ -- The well-typed identity substitution. id : ∀ {m n} {Γ : Ctx n m} → Γ ⇒ Γ ⊢ TmTm.id id {zero} {Γ = []} = [] id {suc m} {Γ = a ∷ Γ} = id ↑ -- Well-typed weakening (as a substitution). wk : ∀ {m n} {Γ : Ctx n m} {a} → Γ ⇒ a ∷ Γ ⊢ TmTm.wk wk = weakenAll id -- A well-typed substitution which only replaces the first variable. sub : ∀ {m n} {Γ : Ctx n m} {t a} → Γ ⊢ t ∈ a → a ∷ Γ ⇒ Γ ⊢ TmTm.sub t sub ⊢t = ⊢t ∷ id -- Application of term substitutions lifted to well-typed terms _/_ : ∀ {m n k} {Γ : Ctx n m} {Δ : Ctx n k} {t a ρ} → Γ ⊢ t ∈ a → Γ ⇒ Δ ⊢ ρ → Δ ⊢ t TmTm./ ρ ∈ a var x / ⊢ρ = lookup-⊢ x ⊢ρ _/_ {Γ = Γ} {Δ = Δ} {ρ = ρ} (Λ ⊢t) ⊢ρ = Λ (⊢t / weaken-⊢p) where weaken-⊢p : ctx-weaken Γ ⇒ ctx-weaken Δ ⊢ map TmTp.weaken ρ weaken-⊢p = (Prelude.subst (λ G → G ⇒ ctx-weaken Δ ⊢ map TmTp.weaken ρ) Tp.map-weaken (WtTypeLemmas.weakenAll ⊢ρ)) λ' a ⊢t / ⊢ρ = λ' a (⊢t / ⊢ρ ↑) (⊢t [ a ]) / ⊢ρ = (⊢t / ⊢ρ) [ a ] (⊢s · ⊢t) / ⊢ρ = (⊢s / ⊢ρ) · (⊢t / ⊢ρ) -- Shorthand for well-typed single-variable term substitutions. _[/_] : ∀ {m n} {Γ : Ctx n m} {s t a b} → b ∷ Γ ⊢ s ∈ a → Γ ⊢ t ∈ b → Γ ⊢ s TmTm./ TmTm.sub t ∈ a ⊢s [/ ⊢t ] = ⊢s / sub ⊢t tm[/tm]-preserves : ∀ {ν n} {Γ : Ctx ν n} {t u a b} → b ∷ Γ ⊢ t ∈ a → Γ ⊢ u ∈ b → Γ ⊢ (t tm[/tm u ]) ∈ a tm[/tm]-preserves ⊢s ⊢t = ⊢s / sub ⊢t open WtTypeLemmas public using () renaming (weaken to ⊢tp-weaken) open WtTermLemmas public using () renaming (_/_ to _⊢/tp_; _[/_] to _⊢[/_]; weaken to ⊢weaken)
{ "alphanum_fraction": 0.4894447154, "avg_line_length": 40.0921787709, "ext": "agda", "hexsha": "403e16c29e1f52e50bfef8450d4641931b19b22a", "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/SystemF/Substitutions/Lemmas.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/SystemF/Substitutions/Lemmas.agda", "max_line_length": 108, "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/SystemF/Substitutions/Lemmas.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": 6753, "size": 14353 }
module Issue802b where data I : Set where i : I f : I → I f i = i mutual data P : I → Set where p : (x : I) → Q x x → P (f x) Q : I → I → Set Q i = P g : (x y : I) → Q x y → P y g i _ q = q data R : (x : I) → P x → Set where r : (x : I) (q : Q x x) → R _ (g x _ q) → R (f x) (p x q)
{ "alphanum_fraction": 0.4243421053, "avg_line_length": 13.8181818182, "ext": "agda", "hexsha": "82a2b03226f277316fc8a2f96e7905e598c1c5c5", "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/Issue802b.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/Issue802b.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/Issue802b.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": 146, "size": 304 }
{-# OPTIONS --without-K --safe #-} module Categories.Adjoint where -- Adjoints open import Level open import Data.Product using (_,_; _×_) open import Function using (_$_) renaming (_∘_ to _∙_) open import Function.Equality using (Π; _⟶_) import Function.Inverse as FI open import Relation.Binary using (Rel; IsEquivalence; Setoid) -- be explicit in imports to 'see' where the information comes from open import Categories.Category using (Category) open import Categories.Category.Product using (Product; _⁂_) open import Categories.Category.Instance.Setoids open import Categories.Morphism open import Categories.Functor using (Functor; _∘F_) renaming (id to idF) open import Categories.Functor.Bifunctor using (Bifunctor) open import Categories.Functor.Hom using (Hom[_][-,-]) open import Categories.Functor.Construction.LiftSetoids open import Categories.NaturalTransformation using (NaturalTransformation; ntHelper; _∘ₕ_; _∘ᵥ_; _∘ˡ_; _∘ʳ_) renaming (id to idN) open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism; unitorˡ; unitorʳ; associator; _≃_) import Categories.Morphism.Reasoning as MR private variable o o′ o″ ℓ ℓ′ ℓ″ e e′ e″ : Level C D E : Category o ℓ e record Adjoint (L : Functor C D) (R : Functor D C) : Set (levelOfTerm L ⊔ levelOfTerm R) where private module C = Category C module D = Category D module L = Functor L module R = Functor R field unit : NaturalTransformation idF (R ∘F L) counit : NaturalTransformation (L ∘F R) idF module unit = NaturalTransformation unit module counit = NaturalTransformation counit field zig : ∀ {A : C.Obj} → counit.η (L.F₀ A) D.∘ L.F₁ (unit.η A) D.≈ D.id zag : ∀ {B : D.Obj} → R.F₁ (counit.η B) C.∘ unit.η (R.F₀ B) C.≈ C.id private variable A : C.Obj B : D.Obj Ladjunct : L.F₀ A D.⇒ B → A C.⇒ R.F₀ B Ladjunct f = R.F₁ f C.∘ unit.η _ Radjunct : A C.⇒ R.F₀ B → L.F₀ A D.⇒ B Radjunct f = counit.η _ D.∘ L.F₁ f RLadjunct≈id : ∀ {f : L.F₀ A D.⇒ B} → Radjunct (Ladjunct f) D.≈ f RLadjunct≈id {f = f} = begin Radjunct (Ladjunct f) ≈⟨ refl⟩∘⟨ L.homomorphism ⟩ counit.η _ D.∘ L.F₁ (R.F₁ f) D.∘ L.F₁ (unit.η _) ≈⟨ pullˡ (counit.commute f) ⟩ (f D.∘ counit.η _) D.∘ L.F₁ (unit.η _) ≈⟨ pullʳ zig ⟩ f D.∘ D.id ≈⟨ D.identityʳ ⟩ f ∎ where open D.HomReasoning open MR D LRadjunct≈id : ∀ {f : A C.⇒ R.F₀ B} → Ladjunct (Radjunct f) C.≈ f LRadjunct≈id {f = f} = begin Ladjunct (Radjunct f) ≈⟨ R.homomorphism ⟩∘⟨refl ⟩ (R.F₁ (counit.η _) C.∘ R.F₁ (L.F₁ f)) C.∘ unit.η _ ≈˘⟨ pushʳ (unit.commute f) ⟩ R.F₁ (counit.η _) C.∘ unit.η _ C.∘ f ≈⟨ pullˡ zag ⟩ C.id C.∘ f ≈⟨ C.identityˡ ⟩ f ∎ where open C.HomReasoning open MR C Hom[L-,-] : Bifunctor C.op D (Setoids _ _) Hom[L-,-] = Hom[ D ][-,-] ∘F (L.op ⁂ idF) Hom[-,R-] : Bifunctor C.op D (Setoids _ _) Hom[-,R-] = Hom[ C ][-,-] ∘F (idF ⁂ R) module Hom[L-,-] = Functor Hom[L-,-] module Hom[-,R-] = Functor Hom[-,R-] -- Inverse is more 'categorical' than bijection defined via injection/surjection Hom-inverse : ∀ A B → FI.Inverse (Hom[L-,-].F₀ (A , B)) (Hom[-,R-].F₀ (A , B)) Hom-inverse A B = record { to = record { _⟨$⟩_ = Ladjunct {A} {B} ; cong = C.∘-resp-≈ˡ ∙ R.F-resp-≈ } ; from = record { _⟨$⟩_ = Radjunct {A} {B} ; cong = D.∘-resp-≈ʳ ∙ L.F-resp-≈ } ; inverse-of = record { left-inverse-of = λ _ → RLadjunct≈id ; right-inverse-of = λ _ → LRadjunct≈id } } module Hom-inverse {A} {B} = FI.Inverse (Hom-inverse A B) op : Adjoint R.op L.op op = record { unit = counit.op ; counit = unit.op ; zig = zag ; zag = zig } -- naturality condition on the two hom functors. -- these conditions are separated out because a complication due to the -- universe level in Agda. module _ where open C open HomReasoning open MR C Ladjunct-comm : ∀ {X Y A B} {h i : L.F₀ X D.⇒ Y} {f : A ⇒ X} {g : Y D.⇒ B} → h D.≈ i → R.F₁ (g D.∘ h D.∘ L.F₁ f) ∘ unit.η A ≈ R.F₁ g ∘ (R.F₁ i ∘ unit.η X) ∘ f Ladjunct-comm {X} {Y} {A} {B} {h} {i} {f} {g} eq = begin R.F₁ (g D.∘ h D.∘ L.F₁ f) ∘ unit.η A ≈⟨ R.homomorphism ⟩∘⟨refl ⟩ (R.F₁ g ∘ R.F₁ (h D.∘ L.F₁ f)) ∘ unit.η A ≈⟨ (refl⟩∘⟨ R.homomorphism) ⟩∘⟨refl ⟩ (R.F₁ g ∘ R.F₁ h ∘ R.F₁ (L.F₁ f)) ∘ unit.η A ≈⟨ pullʳ assoc ⟩ R.F₁ g ∘ R.F₁ h ∘ R.F₁ (L.F₁ f) ∘ unit.η A ≈˘⟨ refl⟩∘⟨ ⟺ (R.F-resp-≈ eq) ⟩∘⟨ unit.commute f ⟩ R.F₁ g ∘ R.F₁ i ∘ unit.η X ∘ f ≈˘⟨ refl⟩∘⟨ assoc ⟩ R.F₁ g ∘ (R.F₁ i ∘ unit.η X) ∘ f ∎ Ladjunct-comm′ : ∀ {X A B} {f : A ⇒ X} {g : L.F₀ X D.⇒ B} → Ladjunct (g D.∘ L.F₁ f) ≈ Ladjunct g ∘ f Ladjunct-comm′ = ∘-resp-≈ˡ R.homomorphism ○ (pullʳ (⟺ (unit.commute _))) ○ ⟺ assoc Ladjunct-resp-≈ : ∀ {A B} {f g : L.F₀ A D.⇒ B} → f D.≈ g → Ladjunct f ≈ Ladjunct g Ladjunct-resp-≈ eq = ∘-resp-≈ˡ (R.F-resp-≈ eq) module _ where open D open HomReasoning open MR D Radjunct-comm : ∀ {X Y A B} {h i : X C.⇒ R.F₀ Y} {f : A C.⇒ X} {g : Y ⇒ B} → h C.≈ i → counit.η B ∘ L.F₁ (R.F₁ g C.∘ h C.∘ f) ≈ g ∘ (counit.η Y ∘ L.F₁ i) ∘ L.F₁ f Radjunct-comm {X} {Y} {A} {B} {h} {i} {f} {g} eq = begin counit.η B ∘ L.F₁ (R.F₁ g C.∘ h C.∘ f) ≈⟨ refl⟩∘⟨ L.homomorphism ⟩ counit.η B ∘ L.F₁ (R.F₁ g) ∘ L.F₁ (h C.∘ f) ≈⟨ pullˡ (counit.commute g) ⟩ (g ∘ counit.η Y) ∘ L.F₁ (h C.∘ f) ≈⟨ refl⟩∘⟨ L.homomorphism ⟩ (g ∘ counit.η Y) ∘ L.F₁ h ∘ L.F₁ f ≈⟨ refl ⟩∘⟨ L.F-resp-≈ eq ⟩∘⟨ refl ⟩ (g ∘ counit.η Y) ∘ L.F₁ i ∘ L.F₁ f ≈⟨ pullʳ (⟺ assoc) ⟩ g ∘ (counit.η Y ∘ L.F₁ i) ∘ L.F₁ f ∎ Radjunct-comm′ : ∀ {Y A B} {f : A C.⇒ R.F₀ Y} {g : Y ⇒ B} → Radjunct (R.F₁ g C.∘ f) ≈ g ∘ Radjunct f Radjunct-comm′ = ∘-resp-≈ʳ L.homomorphism ○ pullˡ (counit.commute _) ○ assoc Radjunct-resp-≈ : ∀ {A B} {f g : A C.⇒ R.F₀ B} → f C.≈ g → Radjunct f ≈ Radjunct g Radjunct-resp-≈ eq = ∘-resp-≈ʳ (L.F-resp-≈ eq) -- a complication: the two hom functors do not live in the same Setoids, -- so they need to be mapped to the same Setoids first before establishing -- natural isomorphism! module _ where private levelℓ : Category o ℓ e → Level levelℓ {ℓ = ℓ} _ = ℓ levele : Category o ℓ e → Level levele {e = e} _ = e Hom[L-,-]′ : Bifunctor C.op D (Setoids _ _) Hom[L-,-]′ = LiftSetoids (levelℓ C) (levele C) ∘F Hom[ D ][-,-] ∘F (L.op ⁂ idF) Hom[-,R-]′ : Bifunctor C.op D (Setoids _ _) Hom[-,R-]′ = LiftSetoids (levelℓ D) (levele D) ∘F Hom[ C ][-,-] ∘F (idF ⁂ R) Hom-NI : NaturalIsomorphism Hom[L-,-]′ Hom[-,R-]′ Hom-NI = record { F⇒G = ntHelper record { η = λ _ → record { _⟨$⟩_ = λ f → lift (Ladjunct (lower f)) ; cong = λ eq → lift (Ladjunct-resp-≈ (lower eq)) } ; commute = λ _ eq → lift $ Ladjunct-comm (lower eq) } ; F⇐G = ntHelper record { η = λ _ → record { _⟨$⟩_ = λ f → lift (Radjunct (lower f)) ; cong = λ eq → lift (Radjunct-resp-≈ (lower eq)) } ; commute = λ _ eq → lift $ Radjunct-comm (lower eq) } ; iso = λ X → record { isoˡ = λ eq → let open D.HomReasoning in lift (RLadjunct≈id ○ lower eq) ; isoʳ = λ eq → let open C.HomReasoning in lift (LRadjunct≈id ○ lower eq) } } module Hom-NI = NaturalIsomorphism Hom-NI infix 5 _⊣_ _⊣_ = Adjoint -- a special case of the natural isomorphism in which homsets in C and D have the same -- universe level. therefore there is no need to lift Setoids to the saem level. -- this is helpful when combining with Yoneda lemma. module _ {C : Category o ℓ e} {D : Category o′ ℓ e} {L : Functor C D} {R : Functor D C} where private module C = Category C module D = Category D module L = Functor L module R = Functor R module _ (adjoint : L ⊣ R) where open Adjoint adjoint -- in this case, the hom functors are naturally isomorphism directly Hom-NI′ : NaturalIsomorphism Hom[L-,-] Hom[-,R-] Hom-NI′ = record { F⇒G = ntHelper record { η = λ _ → Hom-inverse.to ; commute = λ _ eq → Ladjunct-comm eq } ; F⇐G = ntHelper record { η = λ _ → Hom-inverse.from ; commute = λ _ eq → Radjunct-comm eq } ; iso = λ _ → record { isoˡ = λ eq → let open D.HomReasoning in RLadjunct≈id ○ eq ; isoʳ = λ eq → let open C.HomReasoning in LRadjunct≈id ○ eq } } -- now goes from natural isomorphism back to adjoint. -- for simplicity, just construct the case in which homsetoids of C and D -- are compatible. private Hom[L-,-] : Bifunctor C.op D (Setoids _ _) Hom[L-,-] = Hom[ D ][-,-] ∘F (L.op ⁂ idF) Hom[-,R-] : Bifunctor C.op D (Setoids _ _) Hom[-,R-] = Hom[ C ][-,-] ∘F (idF ⁂ R) module _ (Hni : NaturalIsomorphism Hom[L-,-] Hom[-,R-]) where open NaturalIsomorphism Hni open NaturalTransformation open Functor open Π private unitη : ∀ X → F₀ Hom[L-,-] (X , L.F₀ X) ⟶ F₀ Hom[-,R-] (X , L.F₀ X) unitη X = ⇒.η (X , L.F₀ X) unit : NaturalTransformation idF (R ∘F L) unit = ntHelper record { η = λ X → unitη X ⟨$⟩ D.id ; commute = λ {X} {Y} f → begin (unitη Y ⟨$⟩ D.id) ∘ f ≈⟨ introˡ R.identity ⟩ R.F₁ D.id ∘ (unitη Y ⟨$⟩ D.id) ∘ f ≈˘⟨ ⇒.commute (f , D.id) D.Equiv.refl ⟩ ⇒.η (X , L.F₀ Y) ⟨$⟩ (D.id D.∘ D.id D.∘ L.F₁ f) ≈⟨ cong (⇒.η (X , L.F₀ Y)) (D.Equiv.trans D.identityˡ D.identityˡ) ⟩ ⇒.η (X , L.F₀ Y) ⟨$⟩ L.F₁ f ≈⟨ cong (⇒.η (X , L.F₀ Y)) (MR.introʳ D (MR.elimʳ D L.identity)) ⟩ ⇒.η (X , L.F₀ Y) ⟨$⟩ (L.F₁ f D.∘ D.id D.∘ L.F₁ id) ≈⟨ ⇒.commute (C.id , L.F₁ f) D.Equiv.refl ⟩ R.F₁ (L.F₁ f) ∘ (unitη X ⟨$⟩ D.id) ∘ id ≈⟨ refl⟩∘⟨ identityʳ ⟩ R.F₁ (L.F₁ f) ∘ (unitη X ⟨$⟩ D.id) ∎ } where open C open HomReasoning open MR C counitη : ∀ X → F₀ Hom[-,R-] (R.F₀ X , X) ⟶ F₀ Hom[L-,-] (R.F₀ X , X) counitη X = ⇐.η (R.F₀ X , X) counit : NaturalTransformation (L ∘F R) idF counit = ntHelper record { η = λ X → counitη X ⟨$⟩ C.id ; commute = λ {X} {Y} f → begin (counitη Y ⟨$⟩ C.id) ∘ L.F₁ (R.F₁ f) ≈˘⟨ identityˡ ⟩ id ∘ (counitη Y ⟨$⟩ C.id) ∘ L.F₁ (R.F₁ f) ≈˘⟨ ⇐.commute (R.F₁ f , D.id) C.Equiv.refl ⟩ ⇐.η (R.F₀ X , Y) ⟨$⟩ (R.F₁ id C.∘ C.id C.∘ R.F₁ f) ≈⟨ cong (⇐.η (R.F₀ X , Y)) (C.Equiv.trans (MR.elimˡ C R.identity) C.identityˡ) ⟩ ⇐.η (R.F₀ X , Y) ⟨$⟩ R.F₁ f ≈⟨ cong (⇐.η (R.F₀ X , Y)) (MR.introʳ C C.identityˡ) ⟩ ⇐.η (R.F₀ X , Y) ⟨$⟩ (R.F₁ f C.∘ C.id C.∘ C.id) ≈⟨ ⇐.commute (C.id , f) C.Equiv.refl ⟩ f ∘ (counitη X ⟨$⟩ C.id) ∘ L.F₁ C.id ≈⟨ refl⟩∘⟨ elimʳ L.identity ⟩ f ∘ (counitη X ⟨$⟩ C.id) ∎ } where open D open HomReasoning open MR D Hom-NI⇒Adjoint : L ⊣ R Hom-NI⇒Adjoint = record { unit = unit ; counit = counit ; zig = λ {A} → let open D open HomReasoning open MR D in begin η counit (L.F₀ A) ∘ L.F₁ (η unit A) ≈˘⟨ identityˡ ⟩ id ∘ η counit (L.F₀ A) ∘ L.F₁ (η unit A) ≈˘⟨ ⇐.commute (η unit A , id) C.Equiv.refl ⟩ ⇐.η (A , L.F₀ A) ⟨$⟩ (R.F₁ id C.∘ C.id C.∘ η unit A) ≈⟨ cong (⇐.η (A , L.F₀ A)) (C.Equiv.trans (MR.elimˡ C R.identity) C.identityˡ) ⟩ ⇐.η (A , L.F₀ A) ⟨$⟩ η unit A ≈⟨ isoˡ refl ⟩ id ∎ ; zag = λ {B} → let open C open HomReasoning open MR C in begin R.F₁ (η counit B) ∘ η unit (R.F₀ B) ≈˘⟨ refl⟩∘⟨ identityʳ ⟩ R.F₁ (η counit B) ∘ η unit (R.F₀ B) ∘ id ≈˘⟨ ⇒.commute (id , η counit B) D.Equiv.refl ⟩ ⇒.η (R.F₀ B , B) ⟨$⟩ (η counit B D.∘ D.id D.∘ L.F₁ id) ≈⟨ cong (⇒.η (R.F₀ B , B)) (MR.elimʳ D (MR.elimʳ D L.identity)) ⟩ ⇒.η (R.F₀ B , B) ⟨$⟩ η counit B ≈⟨ isoʳ refl ⟩ id ∎ } where module i {X} = Iso (iso X) open i -- the general case from isomorphic Hom setoids to adjoint functors module _ {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {L : Functor C D} {R : Functor D C} where private module C = Category C module D = Category D module L = Functor L module R = Functor R open Functor open Π Hom[L-,-] : Bifunctor C.op D (Setoids _ _) Hom[L-,-] = LiftSetoids ℓ e ∘F Hom[ D ][-,-] ∘F (L.op ⁂ idF) Hom[-,R-] : Bifunctor C.op D (Setoids _ _) Hom[-,R-] = LiftSetoids ℓ′ e′ ∘F Hom[ C ][-,-] ∘F (idF ⁂ R) module _ (Hni : Hom[L-,-] ≃ Hom[-,R-]) where open NaturalIsomorphism Hni private unitη : ∀ X → F₀ Hom[L-,-] (X , L.F₀ X) ⟶ F₀ Hom[-,R-] (X , L.F₀ X) unitη X = ⇒.η (X , L.F₀ X) unit : NaturalTransformation idF (R ∘F L) unit = ntHelper record { η = λ X → lower (unitη X ⟨$⟩ lift D.id) ; commute = λ {X Y} f → begin lower (unitη Y ⟨$⟩ lift D.id) ∘ f ≈⟨ introˡ R.identity ⟩ R.F₁ D.id ∘ lower (unitη Y ⟨$⟩ lift D.id) ∘ f ≈˘⟨ lower (⇒.commute (f , D.id) (lift D.Equiv.refl)) ⟩ lower (⇒.η (X , L.F₀ Y) ⟨$⟩ lift (D.id D.∘ D.id D.∘ L.F₁ f)) ≈⟨ lower (cong (⇒.η (X , L.F₀ Y)) (lift (D.Equiv.trans D.identityˡ D.identityˡ))) ⟩ lower (⇒.η (X , L.F₀ Y) ⟨$⟩ lift (L.F₁ f)) ≈⟨ lower (cong (⇒.η (X , L.F₀ Y)) (lift (MR.introʳ D (MR.elimʳ D L.identity)))) ⟩ lower (⇒.η (X , L.F₀ Y) ⟨$⟩ lift (L.F₁ f D.∘ D.id D.∘ L.F₁ id)) ≈⟨ lower (⇒.commute (C.id , L.F₁ f) (lift D.Equiv.refl)) ⟩ R.F₁ (L.F₁ f) ∘ lower (⇒.η (X , L.F₀ X) ⟨$⟩ lift D.id) ∘ id ≈⟨ refl⟩∘⟨ identityʳ ⟩ F₁ (R ∘F L) f ∘ lower (unitη X ⟨$⟩ lift D.id) ∎ } where open C open HomReasoning open MR C counitη : ∀ X → F₀ Hom[-,R-] (R.F₀ X , X) ⟶ F₀ Hom[L-,-] (R.F₀ X , X) counitη X = ⇐.η (R.F₀ X , X) counit : NaturalTransformation (L ∘F R) idF counit = ntHelper record { η = λ X → lower (counitη X ⟨$⟩ lift C.id) ; commute = λ {X} {Y} f → begin lower (⇐.η (R.F₀ Y , Y) ⟨$⟩ lift C.id) ∘ L.F₁ (R.F₁ f) ≈˘⟨ identityˡ ⟩ id ∘ lower (⇐.η (R.F₀ Y , Y) ⟨$⟩ lift C.id) ∘ L.F₁ (R.F₁ f) ≈˘⟨ lower (⇐.commute (R.F₁ f , D.id) (lift C.Equiv.refl)) ⟩ lower (⇐.η (R.F₀ X , Y) ⟨$⟩ lift (R.F₁ id C.∘ C.id C.∘ R.F₁ f)) ≈⟨ lower (cong (⇐.η (R.F₀ X , Y)) (lift (C.Equiv.trans (MR.elimˡ C R.identity) C.identityˡ))) ⟩ lower (⇐.η (R.F₀ X , Y) ⟨$⟩ lift (R.F₁ f)) ≈⟨ lower (cong (⇐.η (R.F₀ X , Y)) (lift (MR.introʳ C C.identityˡ))) ⟩ lower (⇐.η (R.F₀ X , Y) ⟨$⟩ lift (R.F₁ f C.∘ C.id C.∘ C.id)) ≈⟨ lower (⇐.commute (C.id , f) (lift C.Equiv.refl)) ⟩ f ∘ lower (⇐.η (R.F₀ X , X) ⟨$⟩ lift C.id) ∘ L.F₁ C.id ≈⟨ refl⟩∘⟨ elimʳ L.identity ⟩ f ∘ lower (⇐.η (R.F₀ X , X) ⟨$⟩ lift C.id) ∎ } where open D open HomReasoning open MR D Hom-NI′⇒Adjoint : L ⊣ R Hom-NI′⇒Adjoint = record { unit = unit ; counit = counit ; zig = λ {A} → let open D open HomReasoning open MR D in begin lower (counitη (L.F₀ A) ⟨$⟩ lift C.id) ∘ L.F₁ (η unit A) ≈˘⟨ identityˡ ⟩ id ∘ lower (counitη (L.F₀ A) ⟨$⟩ lift C.id) ∘ L.F₁ (η unit A) ≈˘⟨ lower (⇐.commute (η unit A , id) (lift C.Equiv.refl)) ⟩ lower (⇐.η (A , L.F₀ A) ⟨$⟩ lift (R.F₁ id C.∘ C.id C.∘ lower (⇒.η (A , L.F₀ A) ⟨$⟩ lift id))) ≈⟨ lower (cong (⇐.η (A , L.F₀ A)) (lift (C.Equiv.trans (MR.elimˡ C R.identity) C.identityˡ))) ⟩ lower (⇐.η (A , L.F₀ A) ⟨$⟩ (⇒.η (A , L.F₀ A) ⟨$⟩ lift id)) ≈⟨ lower (isoˡ (lift refl)) ⟩ id ∎ ; zag = λ {B} → let open C open HomReasoning open MR C in begin R.F₁ (lower (⇐.η (R.F₀ B , B) ⟨$⟩ lift id)) ∘ lower (⇒.η (R.F₀ B , L.F₀ (R.F₀ B)) ⟨$⟩ lift D.id) ≈˘⟨ refl⟩∘⟨ identityʳ ⟩ R.F₁ (lower (⇐.η (R.F₀ B , B) ⟨$⟩ lift id)) ∘ lower (⇒.η (R.F₀ B , L.F₀ (R.F₀ B)) ⟨$⟩ lift D.id) ∘ id ≈˘⟨ lower (⇒.commute (id , η counit B) (lift D.Equiv.refl)) ⟩ lower (⇒.η (R.F₀ B , B) ⟨$⟩ lift (lower (⇐.η (R.F₀ B , B) ⟨$⟩ lift id) D.∘ D.id D.∘ L.F₁ id)) ≈⟨ lower (cong (⇒.η (R.F₀ B , B)) (lift (MR.elimʳ D (MR.elimʳ D L.identity)))) ⟩ lower (⇒.η (R.F₀ B , B) ⟨$⟩ lift (lower (⇐.η (R.F₀ B , B) ⟨$⟩ lift id))) ≈⟨ lower (isoʳ (lift refl)) ⟩ id ∎ } where open NaturalTransformation module _ {X} where open Iso (iso X) public ⊣-id : idF {C = C} ⊣ idF {C = C} ⊣-id {C = C} = record { unit = F⇐G unitorˡ ; counit = F⇒G unitorʳ ; zig = identityˡ ; zag = identityʳ } where open Category C open NaturalIsomorphism -- Adjoints compose; we can't be sloppy, so associators and unitors must be inserted. -- Use single letters in pairs, so L & M on the left, and R & S on the right _∘⊣_ : {L : Functor C D} {R : Functor D C} {M : Functor D E} {S : Functor E D} → L ⊣ R → M ⊣ S → (M ∘F L) ⊣ (R ∘F S) _∘⊣_ {C = C} {D = D} {E = E} {L = L} {R} {M} {S} LR MS = record { unit = ((F⇐G (associator _ S R) ∘ᵥ R ∘ˡ (F⇒G (associator L M S))) ∘ᵥ (R ∘ˡ (MSη′ ∘ʳ L)) ∘ᵥ (R ∘ˡ (F⇐G unitorˡ))) ∘ᵥ LRη′ ; counit = MSε′ ∘ᵥ (((F⇒G (unitorʳ {F = M}) ∘ʳ S) ∘ᵥ ((M ∘ˡ LRε′) ∘ʳ S)) ∘ᵥ (F⇒G (associator R L M) ∘ʳ S) ) ∘ᵥ F⇐G (associator S R (M ∘F L) ) ; zig = λ {A} → zig′ {A} ; zag = λ {B} → zag′ {B} } where open Functor open NaturalTransformation open NaturalIsomorphism module LR = Adjoint LR renaming (unit to LRη′; counit to LRε′) module MS = Adjoint MS renaming (unit to MSη′; counit to MSε′) module LRη = NaturalTransformation (Adjoint.unit LR) renaming (η to ηLR) module MSη = NaturalTransformation (Adjoint.unit MS) renaming (η to ηMS) module LRε = NaturalTransformation (Adjoint.counit LR) renaming (η to εLR) module MSε = NaturalTransformation (Adjoint.counit MS) renaming (η to εMS) module C = Category C module D = Category D module E = Category E module L = Functor L renaming (F₀ to L₀; F₁ to L₁) module M = Functor M renaming (F₀ to M₀; F₁ to M₁) module R = Functor R renaming (F₀ to R₀; F₁ to R₁) module S = Functor S renaming (F₀ to S₀; F₁ to S₁) open LR; open MS; open LRη; open LRε; open MSε; open MSη; open L; open M; open R; open S zig′ : {A : C.Obj} → (εMS (M₀ (L₀ A)) E.∘ ((E.id E.∘ M₁ (εLR (S₀ (M₀ (L₀ A))))) E.∘ E.id) E.∘ E.id) E.∘ M₁ (L₁ (((C.id C.∘ R₁ D.id) C.∘ R₁ (ηMS (L₀ A)) C.∘ R₁ D.id) C.∘ ηLR A)) E.≈ E.id -- use "inverted" format here, where rules are out-dented zig′ {A} = begin (εMS (M₀ (L₀ A)) E.∘ ((E.id E.∘ M₁ (εLR (S₀ (M₀ (L₀ A))))) E.∘ E.id) E.∘ E.id) E.∘ M₁ (L₁ (((C.id C.∘ R₁ D.id) C.∘ R₁ (ηMS (L₀ A)) C.∘ R₁ D.id) C.∘ ηLR A)) ≈⟨ ( refl⟩∘⟨ (E.identityʳ ○ E.identityʳ ○ E.identityˡ)) ⟩∘⟨refl ⟩ -- get rid of those pesky E.id (εMS (M₀ (L₀ A)) E.∘ M₁ (εLR (S₀ (M₀ (L₀ A))))) E.∘ M₁ (L₁ (((C.id C.∘ R₁ D.id) C.∘ R₁ (ηMS (L₀ A)) C.∘ R₁ D.id) C.∘ ηLR A)) ≈⟨ E.assoc ○ E.∘-resp-≈ʳ (⟺ M.homomorphism) ⟩ εMS (M₀ (L₀ A)) E.∘ M₁ (εLR (S₀ (M₀ (L₀ A))) D.∘ L₁ (((C.id C.∘ R₁ D.id) C.∘ R₁ (ηMS (L₀ A)) C.∘ R₁ D.id) C.∘ ηLR A)) -- below: get rid of lots of pesky id. Nasty bit of nested equational reasoning, but nothing deep ≈⟨ refl⟩∘⟨ M.F-resp-≈ (D.∘-resp-≈ʳ (L.F-resp-≈ (C.∘-resp-≈ˡ (C.∘-resp-≈ C.identityˡ (C.∘-resp-≈ʳ R.identity) C.HomReasoning.○ let _⊚_ = C.HomReasoning._○_ in C.∘-resp-≈ R.identity C.identityʳ ⊚ C.identityˡ)))) ⟩ εMS (M₀ (L₀ A)) E.∘ M₁ (εLR (S₀ (M₀ (L₀ A))) D.∘ L₁ ((R₁ (ηMS (L₀ A))) C.∘ ηLR A)) ≈⟨ refl⟩∘⟨ M.F-resp-≈ (D.∘-resp-≈ʳ L.homomorphism) ⟩ εMS (M₀ (L₀ A)) E.∘ M₁ (εLR (S₀ (M₀ (L₀ A))) D.∘ L₁ (R₁ (ηMS (L₀ A))) D.∘ L₁ (ηLR A)) ≈˘⟨ refl⟩∘⟨ M.F-resp-≈ D.assoc ⟩ εMS (M₀ (L₀ A)) E.∘ M₁ ((εLR (S₀ (M₀ (L₀ A))) D.∘ L₁ (R₁ (ηMS (L₀ A)))) D.∘ L₁ (ηLR A)) ≈⟨ refl⟩∘⟨ M.F-resp-≈ (D.∘-resp-≈ˡ (LRε.commute _)) ⟩ εMS (M₀ (L₀ A)) E.∘ M₁ ( (_ D.∘ εLR _) D.∘ L₁ (ηLR A)) ≈⟨ refl⟩∘⟨ M.homomorphism ⟩ εMS (M₀ (L₀ A)) E.∘ M₁ (_ D.∘ εLR _) E.∘ M₁ (L₁ (ηLR A)) ≈⟨ refl⟩∘⟨ ( M.homomorphism ⟩∘⟨refl ) ⟩ εMS (M₀ (L₀ A)) E.∘ (M₁ (ηMS (L₀ A)) E.∘ M₁ (εLR _)) E.∘ M₁ (L₁ (ηLR A)) ≈˘⟨ E.assoc ○ E.∘-resp-≈ʳ (⟺ E.assoc) ⟩ (εMS (M₀ (L₀ A)) E.∘ M₁ (ηMS (L₀ A))) E.∘ (M₁ (εLR _) E.∘ M₁ (L₁ (ηLR A))) ≈⟨ MS.zig ⟩∘⟨refl ⟩ E.id E.∘ (M₁ (εLR _) E.∘ M₁ (L₁ (ηLR A))) ≈⟨ E.identityˡ ⟩ M₁ (εLR _) E.∘ M₁ (L₁ (ηLR A)) ≈˘⟨ M.homomorphism ⟩ M₁ (εLR _ D.∘ L₁ (ηLR A)) ≈⟨ M.F-resp-≈ LR.zig ○ M.identity ⟩ E.id ∎ where open E.HomReasoning zag′ : {B : E.Obj} → R₁ (S₁ (εMS B E.∘ ((E.id E.∘ M₁ (εLR (S₀ B))) E.∘ E.id) E.∘ E.id)) C.∘ ((C.id C.∘ R₁ D.id) C.∘ R₁ (ηMS (L₀ (R₀ (S₀ B)))) C.∘ R₁ D.id) C.∘ ηLR (R₀ (S₀ B)) C.≈ C.id zag′ {B} = let _⊚_ = E.HomReasoning._○_ in begin R₁ (S₁ (εMS B E.∘ ((E.id E.∘ M₁ (εLR (S₀ B))) E.∘ E.id) E.∘ E.id)) C.∘ ((C.id C.∘ R₁ D.id) C.∘ R₁ (ηMS (L₀ (R₀ (S₀ B)))) C.∘ R₁ D.id) C.∘ ηLR (R₀ (S₀ B)) -- get rid of all those id ≈⟨ R.F-resp-≈ (S.F-resp-≈ (E.∘-resp-≈ʳ (E.identityʳ ⊚ (E.identityʳ ⊚ E.identityˡ)))) ⟩∘⟨ C.∘-resp-≈ˡ (C.∘-resp-≈ C.identityˡ (C.∘-resp-≈ʳ R.identity) ○ C.∘-resp-≈ R.identity C.identityʳ ○ C.identityˡ) ⟩ R₁ (S₁ (εMS B E.∘ M₁ (εLR (S₀ B)))) C.∘ R₁ (ηMS (L₀ (R₀ (S₀ B)))) C.∘ ηLR (R₀ (S₀ B)) ≈˘⟨ C.assoc ⟩ (R₁ (S₁ (εMS B E.∘ M₁ (εLR (S₀ B)))) C.∘ R₁ (ηMS (L₀ (R₀ (S₀ B))))) C.∘ ηLR (R₀ (S₀ B)) ≈˘⟨ R.homomorphism ⟩∘⟨refl ⟩ R₁ (S₁ (εMS B E.∘ M₁ (εLR (S₀ B))) D.∘ ηMS (L₀ (R₀ (S₀ B)))) C.∘ ηLR (R₀ (S₀ B)) ≈⟨ R.F-resp-≈ (D.∘-resp-≈ˡ S.homomorphism) ⟩∘⟨refl ⟩ R₁ ((S₁ (εMS B) D.∘ (S₁ (M₁ (εLR (S₀ B))))) D.∘ ηMS (L₀ (R₀ (S₀ B)))) C.∘ ηLR (R₀ (S₀ B)) ≈⟨ R.F-resp-≈ D.assoc ⟩∘⟨refl ⟩ R₁ (S₁ (εMS B) D.∘ S₁ (M₁ (εLR (S₀ B))) D.∘ ηMS (L₀ (R₀ (S₀ B)))) C.∘ ηLR (R₀ (S₀ B)) ≈⟨ R.F-resp-≈ (D.∘-resp-≈ʳ (D.HomReasoning.⟺ (MSη.commute (εLR (S₀ B))))) ⟩∘⟨refl ⟩ R₁ (S₁ (εMS B) D.∘ ηMS (S₀ B) D.∘ εLR (S₀ B)) C.∘ ηLR (R₀ (S₀ B)) ≈˘⟨ R.F-resp-≈ D.assoc ⟩∘⟨refl ⟩ R₁ ((S₁ (εMS B) D.∘ ηMS (S₀ B)) D.∘ εLR (S₀ B)) C.∘ ηLR (R₀ (S₀ B)) ≈⟨ R.F-resp-≈ (D.∘-resp-≈ˡ MS.zag) ⟩∘⟨refl ⟩ R₁ (D.id D.∘ εLR (S₀ B)) C.∘ ηLR (R₀ (S₀ B)) ≈⟨ C.∘-resp-≈ˡ (R.F-resp-≈ D.identityˡ) ⟩ R₁ (εLR (S₀ B)) C.∘ ηLR (R₀ (S₀ B)) ≈⟨ LR.zag ⟩ C.id ∎ where open C.HomReasoning
{ "alphanum_fraction": 0.4841941976, "avg_line_length": 43.2101449275, "ext": "agda", "hexsha": "ebf3758cc2490bdc5eea1af014c8bf95ae653886", "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/Adjoint.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/Adjoint.agda", "max_line_length": 141, "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/Adjoint.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 10578, "size": 23852 }
module src.Data.Zipper where open import Agda.Builtin.Equality open import Data.Nat open import Data.Nat.Properties open import Induction.WellFounded open import Haskell.Prelude open import Relation.Binary.PropositionalEquality -- language extensions {-# FOREIGN AGDA2HS {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE ViewPatterns #-} #-} -- imports {-# FOREIGN AGDA2HS import Control.Arrow (first) import Control.Comonad import Control.Lens hiding ((<.>)) import Control.Monad import Data.Foldable import Data.Functor.Apply import Data.Functor.Extend import Data.Function import Data.List (unfoldr) import Data.List.NonEmpty (NonEmpty ((:|))) import Data.Semigroup.Foldable import GHC.Generics #-} record Zipper (a : Set) : Set where constructor MkZipper field prefix : List a focus : a suffix : List a {-# COMPILE AGDA2HS Zipper #-} open Zipper public {-# FOREIGN AGDA2HS deriving instance Show a => Show (Zipper a) deriving instance Eq a => Eq (Zipper a) deriving instance Generic a => Generic (Zipper a) deriving instance Functor Zipper deriving instance Foldable Zipper deriving instance Traversable Zipper makeLenses ''Zipper #-} {-# TERMINATING #-} repeat : a → List a repeat x = x ∷ repeat x instance isFunctorZipper : Functor Zipper isFunctorZipper .fmap k record { prefix = p ; focus = f ; suffix = s } = record { prefix = map k p ; focus = k f ; suffix = map k s } isApplicativeZipper : Applicative Zipper isApplicativeZipper .pure a = record { prefix = repeat a ; focus = a ; suffix = repeat a } isApplicativeZipper ._<*>_ record { prefix = p1 ; focus = f1 ; suffix = s1 } record { prefix = p2 ; focus = f2 ; suffix = s2 } = record { prefix = zipWith id p1 p2 ; focus = f1 f2 ; suffix = zipWith id s1 s2 } {-# COMPILE AGDA2HS isApplicativeZipper #-} isFoldableZipper : Foldable Zipper isFoldableZipper .foldMap k record { prefix = p ; focus = f ; suffix = s } = foldMap k p <> k f <> foldMap k s isTraversableZipper : Traversable Zipper isTraversableZipper .traverse k record { prefix = p ; focus = f ; suffix = s } = ⦇ MkZipper (traverse k p) (k f) (traverse k s) ⦈ isSemigroupZipper : ∀ {a : Set} → ⦃ Semigroup a ⦄ → Semigroup (Zipper a) isSemigroupZipper ._<>_ record { prefix = p1 ; focus = f1 ; suffix = s1 } record { prefix = p2 ; focus = f2 ; suffix = s2 } = record { prefix = zipWith (_<>_) p1 p2 ; focus = f1 <> f2 ; suffix = zipWith (_<>_) s1 s2 } {-# COMPILE AGDA2HS isSemigroupZipper #-} {-# FOREIGN AGDA2HS -- | Many of these instances are from Tony Morris's package, list-zipper instance Apply Zipper where MkZipper l1 x1 r1 <.> MkZipper l2 x2 r2 = MkZipper (zipWith id l1 l2) (x1 x2) (zipWith id r1 r2) instance Foldable1 Zipper where foldMap1 f (MkZipper [] x []) = f x foldMap1 f (MkZipper [] x (rh : rt)) = f x <> foldMap1 f (rh :| rt) foldMap1 f (MkZipper (lh : lt) x []) = foldMap1 f (lh :| lt) <> f x foldMap1 f (MkZipper (lh : lt) x (rh : rt)) = foldMap1 f (lh :| lt) <> f x <> foldMap1 f (rh :| rt) instance Traversable1 Zipper where traverse1 f (MkZipper [] x []) = (\x' -> MkZipper [] x' []) <$> f x traverse1 f (MkZipper (lh : lt) x []) = (\l' x' -> MkZipper (toList l') x' []) <$> traverse1 f (lh :| lt) <.> f x traverse1 f (MkZipper [] x (rh : rt)) = (\x' r' -> MkZipper [] x' (toList r')) <$> f x <.> traverse1 f (rh :| rt) traverse1 f (MkZipper (lh : lt) x (rh : rt)) = (\l' x' r' -> MkZipper (toList l') x' (toList r')) <$> traverse1 f (lh :| lt) <.> f x <.> traverse1 f (rh :| rt) instance Extend Zipper where duplicated z = let dup x = (x, x) unf f = unfoldr (fmap dup . f) z in MkZipper (unf left) z (unf right) instance Comonad Zipper where duplicate = duplicated extract (MkZipper _ x _) = x #-} left : ∀ {a : Set} → Zipper a → Maybe (Zipper a) left record { prefix = [] ; focus = f ; suffix = s } = Nothing left record { prefix = x ∷ p ; focus = f ; suffix = s } = Just record { prefix = p ; focus = x ; suffix = f ∷ s } {-# COMPILE AGDA2HS left #-} right : ∀ {a : Set} → Zipper a → Maybe (Zipper a) right record { prefix = p ; focus = f ; suffix = [] } = Nothing right record { prefix = p ; focus = f ; suffix = x ∷ s } = Just record { prefix = f ∷ p ; focus = x ; suffix = s } {-# COMPILE AGDA2HS right #-} left-right : ∀ {a : Set} (z r : Zipper a) → right z ≡ Just r → left r ≡ Just z left-right record { prefix = p ; focus = f ; suffix = (x ∷ s) } .(record { prefix = f ∷ p ; focus = x ; suffix = s }) refl = refl right-left : ∀ {a : Set} (z r : Zipper a) → left z ≡ Just r → right r ≡ Just z right-left record { prefix = (x ∷ p) ; focus = f ; suffix = s } .(record { prefix = p ; focus = x ; suffix = f ∷ s }) refl = refl fromList : List a → Maybe (Zipper a) fromList [] = Nothing fromList (x ∷ xs) = Just record { prefix = [] ; focus = x ; suffix = xs } {-# COMPILE AGDA2HS fromList #-} unzipper : Zipper a → List a unzipper record { prefix = p ; focus = f ; suffix = s } = reverse p ++ f ∷ s {-# COMPILE AGDA2HS unzipper #-} overlay : Zipper a → List a → Maybe (Zipper a) overlay record { prefix = p ; focus = _ ; suffix = [] } [] = Nothing overlay record { prefix = xs ; focus = _ ; suffix = (z ∷ zs) } [] = Just record { prefix = xs ; focus = z ; suffix = zs } overlay record { prefix = xs ; focus = _ ; suffix = zs } (w ∷ ws) = Just record { prefix = xs ; focus = w ; suffix = ws ++ zs } {-# COMPILE AGDA2HS overlay #-} record MonadPlus (m : Set → Set) : Set₁ where field mzero : m a mplus : m a → m a → m a overlap ⦃ super ⦄ : Monad m open MonadPlus ⦃ ... ⦄ public {-# COMPILE AGDA2HS MonadPlus existing-class #-} instance isListMonadPlus : MonadPlus List isListMonadPlus = record { mzero = [] ; mplus = _++_ } zipper : ⦃ MonadPlus f ⦄ → (a → Bool) → List a → f (Zipper a) zipper f xs = case break f xs of λ where (ys , z ∷ zs) → return record { prefix = reverse ys ; focus = z ; suffix = zs } _ → mzero {-# COMPILE AGDA2HS zipper #-} spanM : ⦃ Monad m ⦄ → ⦃ MonadPlus f ⦄ → (a → m Bool) → List a → m (f a × List a) spanM _ [] = return (mzero , []) spanM {m} {f} {a} {{M}} p (x ∷ xs) = do true <- p x where false → return (mzero , x ∷ xs) (ys , zs) <- spanM {m} {f} {a} {{M}} p xs return (mplus (return x) ys , zs) {-# COMPILE AGDA2HS spanM #-} infixr 1 _>=>_ _>=>_ : ⦃ Monad m ⦄ → (a → m b) → (b → m c) → a → m c f >=> g = λ x → f x >>= g infixr 1 _<=<_ _<=<_ : ⦃ Monad m ⦄ → (b → m c) → (a → m b) → a → m c f <=< g = g >=> f breakM : ⦃ Monad m ⦄ → ⦃ MonadPlus f ⦄ → (a → m Bool) → List a → m (f a × List a) breakM p = spanM $ return ∘ not <=< p {-# COMPILE AGDA2HS breakM #-} zipperM : {a : Set} → {m : Set → Set} → {f : Set → Set} → ⦃ Monad m ⦄ → ⦃ MonadPlus f ⦄ → (a → m Bool) → List a → m (f (Zipper a)) zipperM {a} {_} {f} {{M}} k xs = breakM {{M}} {{isListMonadPlus}} k xs <&> λ where (ys , z ∷ zs) → return record { prefix = reverse ys ; focus = z ; suffix = zs } _ → mzero {-# COMPILE AGDA2HS zipperM #-} Traversal' : Set → Set → Set₁ Traversal' s a = ∀ {f : Set → Set} → ⦃ Applicative f ⦄ → (a → f a) → (s → f s) items : Traversal' (Zipper a) a items k z = ⦇ MkZipper (reverse <$> traverse k (reverse (prefix z))) (k (focus z)) (traverse k (suffix z)) ⦈ {-# COMPILE AGDA2HS items #-} scanPreState : {s : Set} → (a → s → (b × s)) → s → List a → List (b × s) scanPreState f _ [] = [] scanPreState f s (x ∷ xs) = case f x s of λ where (b , s') → (b , s) ∷ scanPreState f s' xs {-# COMPILE AGDA2HS scanPreState #-} forward : {A : Set} → Zipper A → List A forward z = focus z ∷ suffix z measure : {A : Set}(f : A → ℕ) → Zipper A → ℕ measure f z = sum (map (suc ∘ f) (forward z)) just-inj : {A : Set} {x y : A} → Just x ≡ Just y → x ≡ y just-inj refl = refl suffix-forward : {A : Set} {z z' : Zipper A} → right z ≡ Just z' → suffix z ≡ forward z' suffix-forward {z = MkZipper prefix₁ focus₁ (x ∷ suffix₁)} H rewrite sym (just-inj H) = refl measure-right-< : {A : Set} (m : A → ℕ) {z z' : Zipper A} → right z ≡ Just z' → measure m z' Data.Nat.< measure m z measure-right-< m {z} {z'} H rewrite suffix-forward H = s≤s (m≤n+m _ _) record ZipperMono (A : Set)(m : A → ℕ) : Set where constructor zippermono field func : Zipper A → Zipper A mono : ∀ z → measure m z ≡ measure m (func z) open import Induction.WellFounded open import Data.Nat.Induction -- This version of survey shows that it terminates, but only if the function -- passed is monotonic with respect to a measure on its input and output. survey′ : {a : Set} (m : a → ℕ) → ZipperMono a m -> List a -> List a survey′ {a} m (zippermono f mono) = maybe [] (λ z → go z (<-wellFounded _)) ∘ fromList where go : (z : Zipper a) → Acc Data.Nat._<_ (measure m z) → List a go z (acc rs) with f z | inspect f z ...| z' | [ eq ] with right z' | inspect right z' ...| Nothing | _ = unzipper z' ...| Just z'' | [ eq' ] = go z'' (rs (measure m z'') (≤-trans (measure-right-< m eq') (≤-reflexive (trans (cong (measure m) (sym eq)) (sym (mono z)))))) {-# TERMINATING #-} survey : {a : Set} → (Zipper a -> Zipper a) -> List a -> List a survey {a} f = maybe [] go ∘ fromList where go : Zipper a → List a go z = let z' = f z in maybe (unzipper z') go (right z') {-# COMPILE AGDA2HS survey #-} {-# TERMINATING #-} surveyM : {a : Set} → {m : Set → Set} → ⦃ Monad m ⦄ → (Zipper a → m (Zipper a)) → List a → m (List a) surveyM {a} {m} f = maybe (return []) go ∘ fromList where go : Zipper a → m (List a) go z = do z' <- f z maybe (return (unzipper z')) go (right z') {-# COMPILE AGDA2HS surveyM #-} first : (a → b) → (a × c) → (b × c) first f (a , c) = (f a , c) mapUntils : (List a → List a) → (a → Maybe (List a × b)) → List a → Maybe (List a × b) mapUntils rev k [] = Nothing mapUntils rev k (x ∷ xs) = case k x of λ where (Just (xs' , b)) → Just (rev xs' ++ xs , b) Nothing → first (λ xs → x ∷ xs) <$> mapUntils rev k xs {-# COMPILE AGDA2HS mapUntils #-} -- | Given a zipper list, attempt to locate an element first in the prefix, -- then in the suffix, and allow for a transformation of that sub-zipper -- list within the parent list, plus the generation of some datum. mapLeftThenRightUntils : Zipper a → (Bool → a → Maybe (List a × b)) → Maybe (Zipper a × b) mapLeftThenRightUntils {a} {b} z f = case mapUntils reverse (f true) (prefix z) of λ where (Just (p' , b)) → Just (record z { prefix = p' } , b) Nothing → case mapUntils id (f false) (suffix z) of λ where (Just (s' , b)) → Just (record z { suffix = s' } , b) Nothing → Nothing {-# COMPILE AGDA2HS mapLeftThenRightUntils #-}
{ "alphanum_fraction": 0.5864370096, "avg_line_length": 31.8649425287, "ext": "agda", "hexsha": "4a000c29bdf0ed56b5a24e2b2d47cbd0d348fd20", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-08-02T11:08:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-07-30T23:28:25.000Z", "max_forks_repo_head_hexsha": "a8aa37e779f7c541a02cdb3f323b3a3393339bdf", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "jwiegley/trade-journal", "max_forks_repo_path": "src/Data/Zipper.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "a8aa37e779f7c541a02cdb3f323b3a3393339bdf", "max_issues_repo_issues_event_max_datetime": "2021-09-30T11:25:26.000Z", "max_issues_repo_issues_event_min_datetime": "2021-07-30T23:29:35.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "jwiegley/trade-journal", "max_issues_repo_path": "src/Data/Zipper.agda", "max_line_length": 86, "max_stars_count": 6, "max_stars_repo_head_hexsha": "a8aa37e779f7c541a02cdb3f323b3a3393339bdf", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "jwiegley/trade-journal", "max_stars_repo_path": "src/Data/Zipper.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-07T16:50:33.000Z", "max_stars_repo_stars_event_min_datetime": "2021-08-19T19:35:51.000Z", "num_tokens": 3851, "size": 11089 }
module x09-747Decidable-hc where -- Library import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; cong; refl; sym) -- added sym open Eq.≡-Reasoning open import Data.Nat using (ℕ; zero; suc; _≤_; z≤n; s≤s) open import Data.Product using (_×_; proj₁; proj₂) renaming (_,_ to ⟨_,_⟩) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Relation.Nullary using (¬_) open import Relation.Nullary.Negation using () renaming (contradiction to ¬¬-intro) open import Data.Unit using (⊤; tt) open import Data.Empty using (⊥; ⊥-elim) -- Copied from 747Isomorphism. record _⇔_ (A B : Set) : Set where field to : A → B from : B → A open _⇔_ -- Copied from 747Relations. infix 4 _<_ data _<_ : ℕ → ℕ → Set where z<s : ∀ {n : ℕ} ------------ → zero < suc n s<s : ∀ {m n : ℕ} → m < n ------------- → suc m < suc n -- examples proving inequalities and their negations 2≤4 : 2 ≤ 4 2≤4 = s≤s (s≤s z≤n) ¬4≤2 : ¬ (4 ≤ 2) ¬4≤2 = λ { (s≤s (s≤s ())) } -- Bool values (computation) data Bool : Set where true : Bool false : Bool -- Boolean comparison function infix 4 _≤ᵇ_ _≤ᵇ_ : ℕ → ℕ → Bool zero ≤ᵇ zero = true zero ≤ᵇ suc n = true suc m ≤ᵇ zero = false suc m ≤ᵇ suc n = m ≤ᵇ n -- PLFA steps through these computations using equational reasoning. _ : (2 ≤ᵇ 4) ≡ true _ = refl _ : (4 ≤ᵇ 2) ≡ false _ = refl -- Relating evidence and computation. -- Boolean types (evidence) T : Bool → Set T true = ⊤ T false = ⊥ T→≡ : ∀ (b : Bool) → T b → b ≡ true T→≡ true tt = refl ≡→T : ∀ {b : Bool} → b ≡ true → T b ≡→T refl = tt ≤ᵇ→≤ : ∀ (m n : ℕ) → T (m ≤ᵇ n) → m ≤ n ≤ᵇ→≤ zero zero t = z≤n ≤ᵇ→≤ zero (suc n) t = z≤n ≤ᵇ→≤ (suc m) (suc n) t = s≤s (≤ᵇ→≤ m n t) ≤→≤ᵇ : ∀ {m n : ℕ} → m ≤ n → T (m ≤ᵇ n) ≤→≤ᵇ {zero} {zero} z≤n = tt ≤→≤ᵇ {zero} {suc n} z≤n = tt ≤→≤ᵇ (s≤s m≤n) = ≤→≤ᵇ m≤n -- computation and evidence data Dec (A : Set) : Set where yes : A → Dec A no : ¬ A → Dec A inv-s≤s : ∀ {m n : ℕ} → suc m ≤ suc n ------------- → m ≤ n inv-s≤s (s≤s m≤n) = m≤n -- helpers for defining _≤?_ (use these so examples will normalize) ¬s≤z : ∀ {m : ℕ} → ¬ (suc m ≤ zero) ¬s≤z = λ () ¬s≤s : ∀ {m n : ℕ} → ¬ (m ≤ n) → ¬ (suc m ≤ suc n) ¬s≤s {zero} {zero} ¬m≤n = λ sucm≤sucn → ¬m≤n z≤n ¬s≤s {zero} {suc n} ¬m≤n = λ sucm≤sucn → ¬m≤n z≤n ¬s≤s {suc m} {zero} ¬m≤n = λ { (s≤s sucm≤sucn) → ¬m≤n sucm≤sucn } ¬s≤s {suc m} {suc n} ¬m≤n = λ { (s≤s sucm≤sucn) → ¬m≤n (s≤s (inv-s≤s sucm≤sucn)) } -- Decidable ≤. _≤?_ : ∀ (m n : ℕ) → Dec (m ≤ n) zero ≤? zero = yes z≤n zero ≤? suc n = yes z≤n suc m ≤? zero = no (λ ()) suc m ≤? suc n with m ≤? n ... | yes m≤n = yes (s≤s m≤n) ... | no ¬m≤n = no (¬s≤s ¬m≤n) -- can also evaluate the LHS of these tests via C-c C-n _ : 2 ≤? 4 ≡ yes (s≤s (s≤s z≤n)) _ = refl _ : 4 ≤? 2 ≡ no (¬s≤s (¬s≤s ¬s≤z)) _ = refl -- 747/PLFA exercise: DecLT (3 point) -- Decidable strict equality. -- You will need these helper functions as we did above. ¬z<z : ¬ (zero < zero) ¬z<z = λ () ¬s<s : ∀ {m n : ℕ} → ¬ (m < n) → ¬ (suc m < suc n) ¬s<s ¬m<n = λ { (s<s sucm<sucn) → ¬m<n sucm<sucn } ¬s<z : ∀ {n : ℕ} → ¬ (suc n < zero) ¬s<z = λ () _<?_ : ∀ (m n : ℕ) → Dec (m < n) zero <? zero = no (λ ()) zero <? suc n = yes z<s suc m <? zero = no (λ ()) suc m <? suc n with m <? n ... | yes m<n = yes (s<s m<n) ... | no ¬m<n = no (¬s<s ¬m<n) _ : 2 <? 4 ≡ yes (s<s (s<s (z<s))) _ = refl _ : 4 <? 2 ≡ no (¬s<s (¬s<s ¬s<z)) _ = refl _ : 3 <? 3 ≡ no (¬s<s (¬s<s (¬s<s ¬z<z))) _ = refl -- 747/PLFA exercise: DecNatEq (3 points) -- Decidable equality for natural numbers. _≡ℕ?_ : ∀ (m n : ℕ) → Dec (m ≡ n) zero ≡ℕ? zero = yes refl zero ≡ℕ? suc n = no (λ ()) suc m ≡ℕ? zero = no (λ ()) suc m ≡ℕ? suc n with m ≡ℕ? n ... | yes m≡n = yes (cong suc m≡n) ... | no ¬m≡n = no λ { refl → ¬m≡n refl } -- reusing ≤ᵇ and proofs of equivalence with ≤ to decide ≤ _≤?′_ : ∀ (m n : ℕ) → Dec (m ≤ n) m ≤?′ n with m ≤ᵇ n | ≤ᵇ→≤ m n | ≤→≤ᵇ {m} {n} ... | true | ⊤→m≤n | _ = yes (⊤→m≤n tt) ... | false | _ | m≤n→⊥ = no (λ m≤n → m≤n→⊥ m≤n) -- extract Bool value from Dec (aka "isYes") ⌊_⌋ : ∀ {A : Set} → Dec A → Bool ⌊ yes x ⌋ = true ⌊ no x ⌋ = false _≤ᵇ′_ : ℕ → ℕ → Bool m ≤ᵇ′ n = ⌊ m ≤? n ⌋ -- If D is Dec A, then T ⌊ D ⌋ is inhabited exactly when A is inhabited. toWitness : ∀ {A : Set} {D : Dec A} → T ⌊ D ⌋ → A toWitness {_} {yes a} t = a fromWitness : ∀ {A : Set} {D : Dec A} → A → T ⌊ D ⌋ fromWitness {_} {yes _} _ = tt fromWitness {_} {no ¬A} a = ¬A a -- handle "no" witnesses isNo : ∀ {A : Set} → Dec A → Bool isNo (yes _) = false isNo (no _) = true toWitnessFalse : ∀ {A : Set} {D : Dec A} → T (isNo D) → ¬ A toWitnessFalse {_} {no ¬A} _ = ¬A fromWitnessFalse : ∀ {A : Set} {D : Dec A} → ¬ A → T (isNo D) fromWitnessFalse {_} {yes A } ¬A = ¬A A fromWitnessFalse {A} {no ¬A'} ¬A = tt -- Agda standard library definitions for use of these. True : ∀ {A : Set} → (D : Dec A) → Set True Q = T ⌊ Q ⌋ False : ∀ {A : Set} → (D : Dec A) → Set False Q = T (isNo Q) -- concrete examples ≤ᵇ′→≤ : ∀ {m n : ℕ} → T (m ≤ᵇ′ n) → m ≤ n ≤ᵇ′→≤ = toWitness ≤→≤ᵇ′ : ∀ {m n : ℕ} → m ≤ n → T (m ≤ᵇ′ n) ≤→≤ᵇ′ = fromWitness -- BEST PRACTICE : use Decidables instead of Booleans. -- Logical connectives for Decidables. infixr 6 _∧_ _∧_ : Bool → Bool → Bool true ∧ true = true true ∧ false = false false ∧ _ = false infixr 6 _×-dec_ _×-dec_ : ∀ {A B : Set} → Dec A → Dec B → Dec (A × B) yes A ×-dec yes B = yes ⟨ A , B ⟩ yes _ ×-dec no ¬B = no (λ A×B → ¬B (proj₂ A×B)) no ¬A ×-dec yes B = no (λ A×B → ¬A (proj₁ A×B)) no _ ×-dec no ¬B = no (λ A×B → ¬B (proj₂ A×B)) infixr 5 _∨_ _∨_ : Bool → Bool → Bool true ∨ _ = true false ∨ r = r infixr 5 _⊎-dec_ _⊎-dec_ : ∀ {A B : Set} → Dec A → Dec B → Dec (A ⊎ B) yes A ⊎-dec yes _ = yes (inj₁ A) yes A ⊎-dec no _ = yes (inj₁ A) no _ ⊎-dec yes B = yes (inj₂ B) no ¬A ⊎-dec no ¬B = no (λ { (inj₁ A) → ¬A A ; (inj₂ B) → ¬B B } ) not : Bool → Bool not true = false not false = true ¬? : ∀ {A : Set} → Dec A → Dec (¬ A) ¬? (yes A) = no (λ ¬A → ¬A A) ¬? (no ¬A) = yes ¬A -- Boolean version of implication _⊃_ : Bool → Bool → Bool true ⊃ true = true true ⊃ false = false false ⊃ _ = true _→-dec_ : ∀ {A B : Set} → Dec A → Dec B → Dec (A → B) _ →-dec yes B = yes (λ _ → B) no ¬A →-dec _ = yes (λ A → ⊥-elim (¬A A)) yes A →-dec no ¬B = no (λ A→B → ¬B (A→B A)) -- 747/PLFA exercise: ErasBoolDec (3 points) -- Erasure relates boolean and decidable operations. ∧-× : ∀ {A B : Set} (x : Dec A) (y : Dec B) → ⌊ x ⌋ ∧ ⌊ y ⌋ ≡ ⌊ x ×-dec y ⌋ ∧-× (no _) (no _) = refl ∧-× (no _) (yes _) = refl ∧-× (yes _) (no _) = refl ∧-× (yes _) (yes _) = refl -- true ≡ true ∨-× : ∀ {A B : Set} (x : Dec A) (y : Dec B) → ⌊ x ⌋ ∨ ⌊ y ⌋ ≡ ⌊ x ⊎-dec y ⌋ ∨-× (no _) (no _) = refl ∨-× (no _) (yes _) = refl ∨-× (yes _) (no _) = refl ∨-× (yes _) (yes _) = refl not-¬ : ∀ {A : Set} (x : Dec A) → not ⌊ x ⌋ ≡ ⌊ ¬? x ⌋ not-¬ (yes _) = refl not-¬ (no _) = refl -- 747/PLFA exercise: iff-erasure. _iff_ : Bool → Bool → Bool true iff true = true false iff false = true true iff false = false false iff true = false _⇔-dec_ : ∀ {A B : Set} → Dec A → Dec B → Dec (A ⇔ B) yes A ⇔-dec yes B = yes (record { to = λ _ → B ; from = λ _ → A }) yes A ⇔-dec no ¬B = no (λ A⇔B → ¬B (to A⇔B A)) no ¬A ⇔-dec yes B = no (λ A⇔B → ¬A (from A⇔B B)) no ¬A ⇔-dec no ¬B = yes (record { to = λ A → ⊥-elim (¬A A) ; from = λ B → ⊥-elim (¬B B) }) iff-⇔ : ∀ {A B : Set} (x : Dec A) (y : Dec B) → ⌊ x ⌋ iff ⌊ y ⌋ ≡ ⌊ x ⇔-dec y ⌋ iff-⇔ (yes _) (yes _) = refl iff-⇔ (yes _) (no _) = refl iff-⇔ (no _) (yes _) = refl iff-⇔ (no ¬A) (no ¬B) = refl -- proof by reflection (i.g., get Agda to construct proofs at compile time) -- guarded version of monus minus : (m n : ℕ) (n≤m : n ≤ m) → ℕ minus m zero _ = m minus (suc m) (suc n) (s≤s m≤n) = minus m n m≤n -- but must provide proofs _ : minus 5 3 (s≤s (s≤s (s≤s z≤n))) ≡ 2 _ = refl -- Agda will fill in an implicit record type if it can fill in all fields. -- Since ⊤ is defined as a record type with no fields... -- then Agda will compute a value of type True (n ≤? m). _-_ : (m n : ℕ) {n≤m : True (n ≤? m)} → ℕ _-_ m n {n≤m} = minus m n (toWitness n≤m) -- then proofs no longer needed _ : 5 - 3 ≡ 2 _ = refl -- Use above to get Agda to compute parts of proofs that would be annoying for us to provide.
{ "alphanum_fraction": 0.5016474465, "avg_line_length": 25.2166172107, "ext": "agda", "hexsha": "e2b214c39f5495c2cc1cf1fe5fc4e93fa43d802c", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x09-747Decidable-hc.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x09-747Decidable-hc.agda", "max_line_length": 93, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x09-747Decidable-hc.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "num_tokens": 3982, "size": 8498 }
module Numeral.Natural.Function where open import Numeral.Natural open import Numeral.Natural.Oper -- Maximum function -- Returns the greatest number max : ℕ → ℕ → ℕ max 𝟎 𝟎 = 𝟎 max (𝐒(a)) 𝟎 = 𝐒(a) max 𝟎 (𝐒(b)) = 𝐒(b) max (𝐒(a)) (𝐒(b)) = 𝐒(max a b) -- Minimum function -- Returns the smallest number min : ℕ → ℕ → ℕ min 𝟎 𝟎 = 𝟎 min (𝐒(_)) 𝟎 = 𝟎 min 𝟎 (𝐒(_)) = 𝟎 min (𝐒(a)) (𝐒(b)) = 𝐒(min a b) -- min a b = (a + b) −₀ max(a)(b) -- min and max as binary operators infixl 100 _[max]_ _[min]_ _[max]_ = max _[min]_ = min -- Fibonacci numbers fib : ℕ → ℕ fib(𝟎) = 𝟎 fib(𝐒(𝟎)) = 𝐒(𝟎) fib(𝐒(𝐒(n))) = fib(n) + fib(𝐒(n)) arithmetic-sequence : ℕ → ℕ → (ℕ → ℕ) arithmetic-sequence init diff 𝟎 = init arithmetic-sequence init diff (𝐒(n)) = diff + arithmetic-sequence init diff n geometric-sequence : ℕ → ℕ → (ℕ → ℕ) geometric-sequence init diff 𝟎 = init geometric-sequence init diff (𝐒(n)) = diff ⋅ arithmetic-sequence init diff n
{ "alphanum_fraction": 0.5949238579, "avg_line_length": 24.0243902439, "ext": "agda", "hexsha": "ea4ecb15ee24d7d9a619ac46f18eee8e5063139c", "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": "Numeral/Natural/Function.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": "Numeral/Natural/Function.agda", "max_line_length": 77, "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": "Numeral/Natural/Function.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": 432, "size": 985 }
module BuildingBlock where open import Data.Nat -------------------------------------------------------------------------------- -- Binomial Tree -- NodeList C n : list of C indexed from 0 to n data NodeList (C : ℕ → Set) : ℕ → Set where Nil : C 0 → NodeList C 0 Cons : ∀ {n} → C (suc n) → NodeList C n → NodeList C (suc n) data BinomialTree (A : Set) : ℕ → Set where Leaf : A → BinomialTree A 0 Node : ∀ {n} → A → NodeList (BinomialTree A) n → BinomialTree A (suc n) -- examples private ein : BinomialTree ℕ 0 ein = Leaf 0 zwei : BinomialTree ℕ 1 zwei = Node 1 (Nil (Leaf 0)) fier' : BinomialTree ℕ 2 fier' = Node 0 (Cons (Node 1 (Nil (Leaf 2))) (Nil (Leaf 3))) -------------------------------------------------------------------------------- -- Pennants data CompleteBinaryTree (A : Set) : ℕ → Set where Leaf : A → CompleteBinaryTree A 0 Node : ∀ {n} → A → CompleteBinaryTree A n → CompleteBinaryTree A n → CompleteBinaryTree A (suc n) data Pennants (A : Set) : ℕ → Set where Leaf : A → Pennants A 0 Node : ∀ {n} → A → CompleteBinaryTree A n → Pennants A n -- examples private zweiP : Pennants ℕ 2 zweiP = Node 0 (Node 1 (Node 2 (Leaf 3) (Leaf 4)) (Node 5 (Leaf 6) (Leaf 7)))
{ "alphanum_fraction": 0.4446666667, "avg_line_length": 25.8620689655, "ext": "agda", "hexsha": "85e98cd81175d3d16c3fff3e903877b23a00af5d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_path": "legacy/BuildingBlock.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "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": "banacorn/numeral", "max_issues_repo_path": "legacy/BuildingBlock.agda", "max_line_length": 80, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_path": "legacy/BuildingBlock.agda", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "num_tokens": 415, "size": 1500 }
-- Andreas, 2018-09-12, issue #3167 -- -- If --no-prop, then Set0 is the least sort and sort constraints -- s <= Set0 should be solved by s = Set0. {-# OPTIONS --no-prop #-} -- (A : Set) can be inferred if Set0 is the bottom universe data Wrap A : Set where wrap : A → Wrap A -- Should succeed with --no-prop
{ "alphanum_fraction": 0.6444444444, "avg_line_length": 22.5, "ext": "agda", "hexsha": "5f70cf21b08184a918146673a9d13784d2a0b15a", "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/Issue3167.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/Issue3167.agda", "max_line_length": 65, "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/Issue3167.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": 94, "size": 315 }
{-# OPTIONS --without-K #-} module Equivalences where open import Level open import Data.Empty open import Data.Sum renaming (map to _⊎→_) open import Data.Product renaming (map to _×→_) open import Function renaming (_∘_ to _○_) open import SimpleHoTT infix 4 _∼_ -- homotopy between two functions infix 4 _≃_ -- type of equivalences infix 2 _∎≃ -- equational reasoning for equivalences infixr 2 _≃⟨_⟩_ -- equational reasoning for equivalences -- Equivalences _∼_ : ∀ {ℓ ℓ'} → {A : Set ℓ} {P : A → Set ℓ'} → (f g : (x : A) → P x) → Set (ℓ ⊔ ℓ') _∼_ {ℓ} {ℓ'} {A} {P} f g = (x : A) → f x ≡ g x -- Lemma 2.4.2 refl∼ : {A B : Set} {f : A → B} → (f ∼ f) refl∼ {A} {B} {f} x = refl (f x) sym∼ : {A B : Set} {f g : A → B} → (f ∼ g) → (g ∼ f) sym∼ H x = ! (H x) trans∼ : {A B : Set} {f g h : A → B} → (f ∼ g) → (g ∼ h) → (f ∼ h) trans∼ H G x = H x ∘ G x -- record qinv {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B) : Set (ℓ ⊔ ℓ') where constructor mkqinv field g : B → A α : (f ○ g) ∼ id β : (g ○ f) ∼ id idqinv : ∀ {ℓ} → {A : Set ℓ} → qinv {ℓ} {ℓ} {A} {A} id idqinv = record { g = id ; α = λ b → refl b ; β = λ a → refl a } record isequiv {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B) : Set (ℓ ⊔ ℓ') where constructor mkisequiv field g : B → A α : (f ○ g) ∼ id h : B → A β : (h ○ f) ∼ id equiv₁ : ∀ {ℓ ℓ'} → {A : Set ℓ} {B : Set ℓ'} {f : A → B} → qinv f → isequiv f equiv₁ (mkqinv qg qα qβ) = mkisequiv qg qα qg qβ equiv₂ : ∀ {ℓ ℓ'} → {A : Set ℓ} {B : Set ℓ'} {f : A → B} → isequiv f → qinv f equiv₂ {f = f} (mkisequiv ig iα ih iβ) = record { g = ig ; α = iα ; β = λ x → ig (f x) ≡⟨ ! (iβ (ig (f x))) ⟩ ih (f (ig (f x))) ≡⟨ ap ih (iα (f x)) ⟩ ih (f x) ≡⟨ iβ x ⟩ x ∎ } _≃_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Set (ℓ ⊔ ℓ') A ≃ B = Σ (A → B) isequiv id≃ : ∀ {ℓ} {A : Set ℓ} → A ≃ A id≃ = (id , equiv₁ idqinv) sym≃ : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} → (A ≃ B) → B ≃ A sym≃ (A→B , equiv) with equiv₂ equiv ... | mkqinv g α β = g , equiv₁ (mkqinv A→B β α) trans≃ : {A B C : Set} → A ≃ B → B ≃ C → A ≃ C trans≃ (f , feq) (g , geq) with equiv₂ feq | equiv₂ geq ... | mkqinv ff fα fβ | mkqinv gg gα gβ = (g ○ f , equiv₁ (mkqinv (ff ○ gg) (λ c → g (f (ff (gg c))) ≡⟨ ap g (fα (gg c)) ⟩ g (gg c) ≡⟨ gα c ⟩ c ∎) (λ a → ff (gg (g (f a))) ≡⟨ ap ff (gβ (f a)) ⟩ ff (f a) ≡⟨ fβ a ⟩ a ∎))) -- equivalences are injective _⋆_ : {A B : Set} → (A ≃ B) → (x : A) → B (f , _) ⋆ x = f x inj≃ : {A B : Set} → (eq : A ≃ B) → (x y : A) → (eq ⋆ x ≡ eq ⋆ y → x ≡ y) inj≃ (f , mkisequiv g α h β) x y p = ! (β x) ∘ (ap h p ∘ β y) -- equivalences for coproducts (Sec. 2.12) codeqinv : {A B : Set} {a₀ : A} {x : A ⊎ B} → qinv (encode a₀ x) codeqinv {A} {B} {a₀} {x} = record { g = decode a₀ x ; α = indCP (λ x → (c : code a₀ x) → encode a₀ x (decode a₀ x c) ≡ c) (λ a c → encode a₀ (inj₁ a) (decode a₀ (inj₁ a) c) ≡⟨ bydef ⟩ encode a₀ (inj₁ a) (ap inj₁ c) ≡⟨ bydef ⟩ transport (code a₀) (ap inj₁ c) (refl a₀) ≡⟨ ! (transport-f inj₁ (code a₀) c (refl a₀)) ⟩ transport (λ a → code {A} {B} a₀ (inj₁ a)) c (refl a₀) ≡⟨ bydef ⟩ transport (λ a → a₀ ≡ a) c (refl a₀) ≡⟨ transportIdR c (refl a₀) ⟩ (refl a₀) ∘ c ≡⟨ ! (unitTransL c) ⟩ c ∎) (λ b ()) x ; β = λ p → basedPathInd (inj₁ a₀) (λ x p → decode a₀ x (encode a₀ x p) ≡ p) (decode a₀ (inj₁ a₀) (encode {A} {B} a₀ (inj₁ a₀) (refl (inj₁ a₀))) ≡⟨ bydef ⟩ (decode a₀ (inj₁ a₀) (transport (code {A} {B} a₀) (refl (inj₁ a₀)) (refl a₀))) ≡⟨ bydef ⟩ (decode a₀ (inj₁ a₀) (refl a₀)) ≡⟨ bydef ⟩ (ap inj₁ (refl a₀)) ≡⟨ bydef ⟩ refl (inj₁ a₀) ∎) x p } thm2-12-5 : {A B : Set} → (a₀ : A) → (x : A ⊎ B) → (inj₁ a₀ ≡ x) ≃ code a₀ x thm2-12-5 {A} {B} a₀ x = (encode a₀ x , equiv₁ codeqinv) inj₁₁path : {A B : Set} → (a₁ a₂ : A) → (inj₁ {A = A} {B = B} a₁ ≡ inj₁ a₂) ≃ (a₁ ≡ a₂) inj₁₁path a₁ a₂ = thm2-12-5 a₁ (inj₁ a₂) inj₁₂path : {A B : Set} → (a : A) (b : B) → (inj₁ a ≡ inj₂ b) ≃ ⊥ inj₁₂path a b = thm2-12-5 a (inj₂ b) -- Abbreviations for equivalence compositions _≃⟨_⟩_ : (A : Set) {B C : Set} → (A ≃ B) → (B ≃ C) → (A ≃ C) _ ≃⟨ p ⟩ q = trans≃ p q _∎≃ : {ℓ : Level} {A : Set ℓ} → A ≃ A _∎≃ {ℓ} {A} = id≃ {ℓ} {A}
{ "alphanum_fraction": 0.4018580747, "avg_line_length": 30.2934131737, "ext": "agda", "hexsha": "0bc05fafd5bac1a9749467899e1b1683c6cdf6cb", "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": "Univalence/OldUnivalence/Equivalences.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": "Univalence/OldUnivalence/Equivalences.agda", "max_line_length": 77, "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": "Univalence/OldUnivalence/Equivalences.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": 2238, "size": 5059 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.S1 where open import Cubical.HITs.S1.Base public open import Cubical.HITs.S1.Properties public
{ "alphanum_fraction": 0.7604790419, "avg_line_length": 27.8333333333, "ext": "agda", "hexsha": "cd8faec7538520e1d0f9a5acab3b60151154544f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/HITs/S1.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/HITs/S1.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/HITs/S1.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 48, "size": 167 }
module Prelude.List.Relations.Any where open import Agda.Primitive open import Prelude.Nat open import Prelude.List.Base open import Prelude.Equality open import Prelude.List.Relations.All data Any {a b} {A : Set a} (P : A → Set b) : List A → Set (a ⊔ b) where zero : ∀ {x xs} (p : P x) → Any P (x ∷ xs) suc : ∀ {x xs} (i : Any P xs) → Any P (x ∷ xs) pattern zero! = zero refl infix 3 _∈_ _∈_ : ∀ {a} {A : Set a} → A → List A → Set a x ∈ xs = Any (_≡_ x) xs module _ {a b} {A : Set a} {P : A → Set b} where -- Delete deleteIx : ∀ xs → Any P xs → List A deleteIx (_ ∷ xs) (zero _) = xs deleteIx (x ∷ xs) (suc i) = x ∷ deleteIx xs i deleteAllIx : ∀ {c} {Q : A → Set c} {xs} → All Q xs → (i : Any P xs) → All Q (deleteIx xs i) deleteAllIx (q ∷ qs) (zero _) = qs deleteAllIx (q ∷ qs) (suc i) = q ∷ deleteAllIx qs i forgetAny : ∀ {a p} {A : Set a} {P : A → Set p} {xs : List A} → Any P xs → Nat forgetAny (zero _) = zero forgetAny (suc i) = suc (forgetAny i)
{ "alphanum_fraction": 0.5753286148, "avg_line_length": 26.0263157895, "ext": "agda", "hexsha": "d1a531840ac57fc693c8a91e5abb3f9f07309db1", "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": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "t-more/agda-prelude", "max_forks_repo_path": "src/Prelude/List/Relations/Any.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "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": "t-more/agda-prelude", "max_issues_repo_path": "src/Prelude/List/Relations/Any.agda", "max_line_length": 94, "max_stars_count": null, "max_stars_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "t-more/agda-prelude", "max_stars_repo_path": "src/Prelude/List/Relations/Any.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 393, "size": 989 }
------------------------------------------------------------------------ -- Homotopy groups of pointed types ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} import Equality.Path as P module Pointed-type.Homotopy-group {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq open import Logical-equivalence using (_⇔_) open import Prelude open import Equality.Groupoid equality-with-J open import Equality.Path.Isomorphisms eq open import Equivalence equality-with-J as Eq using (_≃_) open import Function-universe equality-with-J open import Group equality-with-J as G using (Group; Abelian; _≃ᴳ_) open import H-level equality-with-J open import H-level.Closure equality-with-J open import H-level.Truncation eq as T open import Pointed-type equality-with-J as PT using (Pointed-type; _≃ᴮ_; Ω; Ω[_]) private variable a p q : Level P : Pointed-type p n : ℕ -- Homotopy-group-[1+ n ] P is the (1+n)-th homotopy group of the -- pointed type P. -- -- This definition is taken from the HoTT book. Homotopy-group-[1+_] : ℕ → Pointed-type a → Group a Homotopy-group-[1+ n ] P = λ where .Group.Carrier → Carrier .Group.Carrier-is-set → Carrier-is-set .Group._∘_ → _∘′_ .Group.id → id′ .Group._⁻¹ → _⁻¹ .Group.left-identity → left-identity .Group.right-identity → right-identity .Group.assoc → assoc .Group.left-inverse → left-inverse .Group.right-inverse → right-inverse where Carrier = ∥ proj₁ (Ω[ 1 + n ] P) ∥[1+ 1 ] _∘′_ = ∥∥-zip trans id′ = ∣ refl _ ∣ _⁻¹ = ∥∥-map sym abstract Carrier-is-set : Is-set Carrier Carrier-is-set = truncation-has-correct-h-level 1 left-identity : (x : Carrier) → (id′ ∘′ x) ≡ x left-identity = T.elim λ where .T.∣∣ʳ _ → cong ∣_∣ $ trans-reflˡ _ .T.h-levelʳ _ → mono₁ 2 $ truncation-has-correct-h-level 1 right-identity : (x : Carrier) → (x ∘′ id′) ≡ x right-identity = T.elim λ where .T.∣∣ʳ _ → cong ∣_∣ $ trans-reflʳ _ .T.h-levelʳ _ → mono₁ 2 $ truncation-has-correct-h-level 1 assoc : (x y z : Carrier) → (x ∘′ (y ∘′ z)) ≡ ((x ∘′ y) ∘′ z) assoc = T.elim λ where .T.h-levelʳ _ → Π-closure ext 2 λ _ → Π-closure ext 2 λ _ → mono₁ 2 $ truncation-has-correct-h-level 1 .T.∣∣ʳ _ → T.elim λ where .T.h-levelʳ _ → Π-closure ext 2 λ _ → mono₁ 2 $ truncation-has-correct-h-level 1 .T.∣∣ʳ _ → T.elim λ where .T.h-levelʳ _ → mono₁ 2 $ truncation-has-correct-h-level 1 .T.∣∣ʳ _ → cong ∣_∣ $ sym $ trans-assoc _ _ _ left-inverse : (x : Carrier) → ((x ⁻¹) ∘′ x) ≡ id′ left-inverse = T.elim λ where .T.∣∣ʳ _ → cong ∣_∣ $ trans-symˡ _ .T.h-levelʳ _ → mono₁ 2 $ truncation-has-correct-h-level 1 right-inverse : (x : Carrier) → (x ∘′ (x ⁻¹)) ≡ id′ right-inverse = T.elim λ where .T.∣∣ʳ _ → cong ∣_∣ $ trans-symʳ _ .T.h-levelʳ _ → mono₁ 2 $ truncation-has-correct-h-level 1 -- The fundamental group of a pointed type. -- -- This definition is taken from the HoTT book. Fundamental-group : Pointed-type a → Group a Fundamental-group = Homotopy-group-[1+ 0 ] -- The n-th homotopy group of a pointed type is abelian when n is at -- least two. -- -- (This result is stated in the HoTT book.) abelian : ∀ n → Abelian (Homotopy-group-[1+ suc n ] P) abelian n = T.elim λ where .T.h-levelʳ _ → Π-closure ext 2 λ _ → mono₁ 2 $ truncation-has-correct-h-level 1 .T.∣∣ʳ p → T.elim λ where .T.h-levelʳ _ → mono₁ 2 $ truncation-has-correct-h-level 1 .T.∣∣ʳ q → cong ∣_∣ $ Ω[2+n]-commutative n p q -- If there is a based equivalence between P and Q, then their -- homotopy groups are isomorphic. ≃ᴮ→≃ᴳ : ∀ (P : Pointed-type p) (Q : Pointed-type q) n → P ≃ᴮ Q → Homotopy-group-[1+ n ] P ≃ᴳ Homotopy-group-[1+ n ] Q ≃ᴮ→≃ᴳ P Q n P≃Q = λ where .G.Homomorphic.related → ∥∥-cong (proj₁ (PT.Ω[ suc n ]-cong-≃ᴮ P≃Q)) .G.Homomorphic.homomorphic → T.elim λ where .T.h-levelʳ _ → Π-closure ext 2 λ _ → mono₁ 2 $ truncation-has-correct-h-level 1 .T.∣∣ʳ _ → T.elim λ where .T.h-levelʳ _ → mono₁ 2 $ truncation-has-correct-h-level 1 .T.∣∣ʳ _ → cong ∣_∣ (PT.Ω[1+ n ]-cong-≃ᴮ-trans P≃Q) -- Homotopy-group-[1+ n ] commutes with PT._×_/G._×_. Homotopy-group-[1+_]-× : ∀ n (P : Pointed-type p) (Q : Pointed-type q) → Homotopy-group-[1+ n ] (P PT.× Q) ≃ᴳ (Homotopy-group-[1+ n ] P G.× Homotopy-group-[1+ n ] Q) Homotopy-group-[1+ n ]-× P Q = λ where .G.Homomorphic.related → ∥ proj₁ (Ω[ 1 + n ] (P PT.× Q)) ∥[1+ 1 ] ↝⟨ T.∥∥-cong (proj₁ PT.Ω[ 1 + n ]-×) ⟩ ∥ proj₁ (Ω[ 1 + n ] P) × proj₁ (Ω[ 1 + n ] Q) ∥[1+ 1 ] ↝⟨ inverse T.∥∥×∥∥≃∥×∥ ⟩□ ∥ proj₁ (Ω[ 1 + n ] P) ∥[1+ 1 ] × ∥ proj₁ (Ω[ 1 + n ] Q) ∥[1+ 1 ] □ .G.Homomorphic.homomorphic → T.elim λ where .T.h-levelʳ _ → Π-closure ext 2 λ _ → s .T.∣∣ʳ p → T.elim λ where .T.h-levelʳ _ → s .T.∣∣ʳ q → Σ-map ∣_∣ ∣_∣ (_≃_.to (proj₁ PT.Ω[ 1 + n ]-×) (trans p q)) ≡⟨ cong (Σ-map ∣_∣ ∣_∣) PT.Ω[1+ n ]-×-trans ⟩∎ (Σ-map ∣_∣ ∣_∣ $ Σ-zip trans trans (_≃_.to (proj₁ PT.Ω[ 1 + n ]-×) p) (_≃_.to (proj₁ PT.Ω[ 1 + n ]-×) q)) ∎ where s = mono₁ 2 $ ×-closure 2 (truncation-has-correct-h-level 1) (truncation-has-correct-h-level 1) -- Homotopy-group-[1+ n ]′ P s is the (1+n)-th homotopy group of the -- pointed type P. -- -- The definition does not use set truncation. Instead a certain loop -- space is required to be a set. Homotopy-group-[1+_]′ : ∀ n (P : Pointed-type a) → Is-set (proj₁ (Ω[ 1 + n ] P)) → Group a Homotopy-group-[1+ n ]′ P s = λ where .Group.Carrier → Carrier .Group.Carrier-is-set → Carrier-is-set .Group._∘_ → _∘′_ .Group.id → id′ .Group._⁻¹ → _⁻¹ .Group.left-identity → left-identity .Group.right-identity → right-identity .Group.assoc → assoc .Group.left-inverse → left-inverse .Group.right-inverse → right-inverse where Carrier = proj₁ (Ω[ 1 + n ] P) _∘′_ = trans id′ = refl _ _⁻¹ = sym abstract Carrier-is-set : Is-set Carrier Carrier-is-set = s left-identity : (x : Carrier) → (id′ ∘′ x) ≡ x left-identity _ = trans-reflˡ _ right-identity : (x : Carrier) → (x ∘′ id′) ≡ x right-identity _ = trans-reflʳ _ assoc : (x y z : Carrier) → (x ∘′ (y ∘′ z)) ≡ ((x ∘′ y) ∘′ z) assoc _ _ _ = sym $ trans-assoc _ _ _ left-inverse : (x : Carrier) → ((x ⁻¹) ∘′ x) ≡ id′ left-inverse _ = trans-symˡ _ right-inverse : (x : Carrier) → (x ∘′ (x ⁻¹)) ≡ id′ right-inverse _ = trans-symʳ _ -- The fundamental group of a pointed type. -- -- The definition does not use set truncation. Instead a certain loop -- space is required to be a set. Fundamental-group′ : (P : Pointed-type a) → Is-set (proj₁ (Ω P)) → Group a Fundamental-group′ = Homotopy-group-[1+ 0 ]′ -- Homotopy-group-[1+ n ]′ P s is isomorphic to -- Homotopy-group-[1+ n ] P. Homotopy-group-[1+]′≃ᴳHomotopy-group-[1+] : {s : Is-set (proj₁ (Ω[ 1 + n ] P))} → Homotopy-group-[1+ n ]′ P s ≃ᴳ Homotopy-group-[1+ n ] P Homotopy-group-[1+]′≃ᴳHomotopy-group-[1+] {s = s} = λ where .G.Homomorphic.related → inverse $ Eq.↔⇒≃ $ _⇔_.to T.+⇔∥∥↔ (λ {_ _} → s) .G.Homomorphic.homomorphic p q → ∣ trans p q ∣ ≡⟨⟩ ∣ trans p q ∣ ∎
{ "alphanum_fraction": 0.5495717623, "avg_line_length": 34.4017857143, "ext": "agda", "hexsha": "ec19c616e0c3f193d4fd7368662db61bbf541586", "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/Pointed-type/Homotopy-group.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/Pointed-type/Homotopy-group.agda", "max_line_length": 116, "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/Pointed-type/Homotopy-group.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": 2999, "size": 7706 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Sets.EquivalenceRelations open import Setoids.Setoids open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) module Groups.Definition where record Group {lvl1 lvl2} {A : Set lvl1} (S : Setoid {lvl1} {lvl2} A) (_·_ : A → A → A) : Set (lsuc lvl1 ⊔ lvl2) where open Setoid S field +WellDefined : {m n x y : A} → (m ∼ x) → (n ∼ y) → (m · n) ∼ (x · y) 0G : A inverse : A → A +Associative : {a b c : A} → (a · (b · c)) ∼ (a · b) · c identRight : {a : A} → (a · 0G) ∼ a identLeft : {a : A} → (0G · a) ∼ a invLeft : {a : A} → (inverse a) · a ∼ 0G invRight : {a : A} → a · (inverse a) ∼ 0G +Associative' : {a b c : A} → ((a · b) · c) ∼ (a · (b · c)) +Associative' = Equivalence.symmetric (Setoid.eq S) +Associative +WellDefinedLeft : {m x n : A} → (m ∼ n) → (m · x) ∼ (n · x) +WellDefinedLeft m=n = +WellDefined m=n (Equivalence.reflexive (Setoid.eq S)) +WellDefinedRight : {m x y : A} → (x ∼ y) → (m · x) ∼ (m · y) +WellDefinedRight x=y = +WellDefined (Equivalence.reflexive (Setoid.eq S)) x=y
{ "alphanum_fraction": 0.5570652174, "avg_line_length": 42.4615384615, "ext": "agda", "hexsha": "a999bcf5d98e8da36e463f835a78d7d9416b796b", "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/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/Definition.agda", "max_line_length": 117, "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/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": 456, "size": 1104 }
-- Andreas, 2017-01-19, issue #2412, raised by bixuanzju -- Agda should not insert hidden lambdas of possibly empty size types open import Agda.Builtin.Size data Nat i : Set where zero : Nat i suc : {j : Size< i} (n : Nat j) → Nat i recNat : (P : (i : Size) (n : Nat i) → Set) → (fz : ∀{i} → P i zero) → (fs : ∀{i}{j : Size< i} (n : Nat j) → P j n → P i (suc n)) → ∀{i} (n : Nat i) → P i n recNat P fz fs zero = fz recNat P fz fs (suc n) = fs n (recNat P fz fs n) -- This should pass. -- Agda should not insert the λ {j : Size< i} → fs in the recursive call to recNat.
{ "alphanum_fraction": 0.5863247863, "avg_line_length": 29.25, "ext": "agda", "hexsha": "ec5f5e635a58b9287bb724638f7c0ed35e063805", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.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/Issue2412.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/Issue2412.agda", "max_line_length": 83, "max_stars_count": 3, "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/Issue2412.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": 226, "size": 585 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Relation.Nullary.Decidable where open import Cubical.Core.Everything open import Cubical.Data.Empty using (⊥) private variable ℓ : Level -- Negation infix 3 ¬_ ¬_ : Type ℓ → Type ℓ ¬ A = A → ⊥ -- Decidable types (inspired by standard library) data Dec (P : Type ℓ) : Type ℓ where yes : ( p : P) → Dec P no : (¬p : ¬ P) → Dec P data IsYes {P : Type ℓ} : Dec P → Type ℓ where isYes : ∀ {x} → IsYes (yes x) Discrete : Type ℓ → Type ℓ Discrete A = ∀ x y → Dec (Path A x y)
{ "alphanum_fraction": 0.6211849192, "avg_line_length": 20.6296296296, "ext": "agda", "hexsha": "ea4ae71fae164356fc80821ccae6101ec7489227", "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": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Relation/Nullary/Decidable.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "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": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Relation/Nullary/Decidable.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Relation/Nullary/Decidable.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 200, "size": 557 }
module Generic.Lib.Data.Pow where open import Generic.Lib.Intro open import Generic.Lib.Data.Nat open import Generic.Lib.Data.Product infixl 6 _^_ _^_ : ∀ {α} -> Set α -> ℕ -> Set α A ^ 0 = ⊤ A ^ suc n = A × A ^ n elimPow : ∀ {n α} {A : Set α} {b : ∀ {n} -> A ^ n -> Level} -> (B : ∀ {n} -> (xs : A ^ n) -> Set (b xs)) -> (∀ {n} {xs : A ^ n} x -> B xs -> B (x , xs)) -> B tt -> (xs : A ^ n) -> B xs elimPow {0} B f z tt = z elimPow {suc n} B f z (x , xs) = f x (elimPow B f z xs) foldPow : ∀ {n α β} {A : Set α} -> (B : ℕ -> Set β) -> (∀ {n} -> A -> B n -> B (suc n)) -> B 0 -> A ^ n -> B n foldPow B f z xs = elimPow (λ {n} _ -> B n) (λ x y -> f x y) z xs foldPow₁ : ∀ {n α} {A : Set α} -> (A -> A -> A) -> A ^ suc n -> A foldPow₁ {0} f (x , []) = x foldPow₁ {suc n} f (x , xs) = f x (foldPow₁ f xs) mapPow : ∀ {n α β} {A : Set α} {B : Set β} -> (A -> B) -> A ^ n -> B ^ n mapPow f = foldPow (_ ^_) (_,_ ∘ f) tt replicatePow : ∀ {α} {A : Set α} n -> A -> A ^ n replicatePow 0 x = tt replicatePow (suc n) x = x , replicatePow n x
{ "alphanum_fraction": 0.4459459459, "avg_line_length": 30.8333333333, "ext": "agda", "hexsha": "ada7dd48895f352f0cbbac51a74e9b35eba45820", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2021-01-27T12:57:09.000Z", "max_forks_repo_forks_event_min_datetime": "2017-07-17T07:23:39.000Z", "max_forks_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "turion/Generic", "max_forks_repo_path": "src/Generic/Lib/Data/Pow.agda", "max_issues_count": 9, "max_issues_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_issues_repo_issues_event_max_datetime": "2022-01-04T15:43:14.000Z", "max_issues_repo_issues_event_min_datetime": "2017-04-06T18:58:09.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "turion/Generic", "max_issues_repo_path": "src/Generic/Lib/Data/Pow.agda", "max_line_length": 86, "max_stars_count": 30, "max_stars_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "turion/Generic", "max_stars_repo_path": "src/Generic/Lib/Data/Pow.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T10:19:38.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-19T21:10:54.000Z", "num_tokens": 468, "size": 1110 }
module Holes.Test.General where open import Holes.Prelude open PropEq using (_≡_; refl; cong; sym; trans) open import Holes.Term using (⌞_⌟) open import Holes.Cong.Propositional private +-zero : ∀ x → x + 0 ≡ x +-zero zero = refl +-zero (suc x) = cong suc (+-zero x) +-suc : ∀ x y → suc (x + y) ≡ x + suc y +-suc zero y = refl +-suc (suc x) y = cong suc (+-suc x y) +-comm : ∀ x y → x + y ≡ y + x +-comm zero y = sym (+-zero y) +-comm (suc x) y = trans (cong suc (+-comm x y)) (+-suc y x) data Fin : ℕ → Set where zero : ∀ {n} → Fin (suc n) suc : ∀ {n} → Fin n → Fin (suc n) -- Expressions with free variables test1 : ∀ x y z → ⌞ x + y ⌟ + z ≡ (y + x) + z test1 x y z = cong! (+-comm x y) -- NOTE: This works, but if you replace `y` by `_` in the above, there are -- unsolved metas! test1′ : ∀ x y z → x + y + z ≡ y + x + z test1′ x y z = cong (λ h → h + z) (+-comm x _) -- Multiple holes test2 : ∀ x y z → x + ⌞ y + z ⌟ * ⌞ y + z ⌟ + y * z ≡ x + (z + y) * (z + y) + y * z test2 x y z = cong! (+-comm y z) -- Picking out one instance of a group of identical sub-expressions test3 : ∀ x y z → x + ⌞ y + z ⌟ * (y + z) + y * z ≡ x + (z + y) * (y + z) + y * z test3 x y z = cong! (+-comm y z) -- Automatic symmetry test4 : ∀ x y z → x + ⌞ y + z ⌟ * (y + z) + y * z ≡ x + (z + y) * (y + z) + y * z test4 x y z = cong! (+-comm z y) -- No hole on the LHS ⇒ hole around everything (notice automatic symmetry application) test5 : ∀ x y → x + y ≡ y + x test5 x y = cong! (+-comm y x) -- Works in Π types test6 : ∀ x y → (Fin ⌞ x + y ⌟ → ℕ) ≡ (Fin ⌞ y + x ⌟ → ℕ) test6 x y = cong! (+-comm x y) -- Constructors on the path test7 : ∀ x y → ℕ.suc ⌞ x + y ⌟ ≡ suc (y + x) test7 x y = cong! (+-comm x y) -- -- Fails with a nice error message when holes contain different terms -- fail1 : ∀ x y z → y ≡ x → ⌞ x ⌟ + ⌞ y ⌟ + z ≡ x + x + z -- fail1 x y z eq = cong! eq -- -- This is only provable in the presence of functional extensionality, so the -- -- macro should obviously fail here. It would be nice if the error message -- -- were improved though. -- fail2 : ∀ (x y : ℕ) → (λ (f : ℕ → ℕ) → ⌞ f x + f y ⌟) ≡ (λ f → f y + f x) -- fail2 x y = cong! (+-comm _ _)
{ "alphanum_fraction": 0.5312642629, "avg_line_length": 32.2205882353, "ext": "agda", "hexsha": "fd9b082e0f91e02e72240ee7557f367a4a9c3313", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-02-02T18:57:17.000Z", "max_forks_repo_forks_event_min_datetime": "2017-01-27T14:57:39.000Z", "max_forks_repo_head_hexsha": "b5537c29e69febd7e89580398fac38d619aab3b4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bch29/agda-holes", "max_forks_repo_path": "src/Holes/Test/General.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "b5537c29e69febd7e89580398fac38d619aab3b4", "max_issues_repo_issues_event_max_datetime": "2020-08-31T20:58:33.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-16T10:47:58.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bch29/agda-holes", "max_issues_repo_path": "src/Holes/Test/General.agda", "max_line_length": 86, "max_stars_count": 24, "max_stars_repo_head_hexsha": "b5537c29e69febd7e89580398fac38d619aab3b4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bch29/agda-holes", "max_stars_repo_path": "src/Holes/Test/General.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-03T15:02:41.000Z", "max_stars_repo_stars_event_min_datetime": "2017-01-28T10:56:46.000Z", "num_tokens": 898, "size": 2191 }
open import Data.Sum using ( _⊎_ ) open import FRP.LTL.RSet.Core using ( RSet ) module FRP.LTL.RSet.Sum where infixr 2 _∨_ _∨_ : RSet → RSet → RSet (A ∨ B) t = A t ⊎ B t
{ "alphanum_fraction": 0.6379310345, "avg_line_length": 15.8181818182, "ext": "agda", "hexsha": "be4dca48f018ab075b5526e807ea18bab06f7293", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z", "max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-frp-ltl", "max_forks_repo_path": "src/FRP/LTL/RSet/Sum.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-frp-ltl", "max_issues_repo_path": "src/FRP/LTL/RSet/Sum.agda", "max_line_length": 44, "max_stars_count": 21, "max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-frp-ltl", "max_stars_repo_path": "src/FRP/LTL/RSet/Sum.agda", "max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z", "num_tokens": 73, "size": 174 }
module Generics.Mu.Conversion where
{ "alphanum_fraction": 0.8611111111, "avg_line_length": 18, "ext": "agda", "hexsha": "2ee133b4ac50973972be1f78b4a3a31291d02746", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-01-14T10:35:16.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-08T08:32:42.000Z", "max_forks_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "flupe/generics", "max_forks_repo_path": "src/Generics/Mu/Conversion.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_issues_repo_issues_event_max_datetime": "2022-01-14T10:48:30.000Z", "max_issues_repo_issues_event_min_datetime": "2021-09-13T07:33:50.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "flupe/generics", "max_issues_repo_path": "src/Generics/Mu/Conversion.agda", "max_line_length": 35, "max_stars_count": 11, "max_stars_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "flupe/generics", "max_stars_repo_path": "src/Generics/Mu/Conversion.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T09:35:17.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-08T15:10:20.000Z", "num_tokens": 9, "size": 36 }
module ASN1.Untyped where open import Data.Word8 using (Word8; _and_; _or_; _==_) renaming (primWord8fromNat to to𝕎; primWord8toNat to from𝕎) open import Data.ByteString using (ByteString; Strict; empty; pack; fromChunks; toStrict) open import Data.ByteString.Utf8 using (packStrict) open import Data.Bool using (Bool; true; false) open import Data.Nat using (ℕ; _+_; _*_) open import Data.List using (List; []; _∷_; concatMap) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Data.Product using (_×_; _,_) open import Data.String using (String) open import Relation.Nullary using (Dec; yes; no) open import ASN1.Util -- only short (8-bit) tags are supported Tag = Word8 -- length can be arbitrary big; TODO: restrict to Int64? Len = ℕ data Value : Set data AST : Set data Value where prim : (octets : ByteString Strict) → Value constr : (vs : List AST) → Value data AST where tlv : (t : Tag) → (v : Value) → AST private constructed-flag : Word8 constructed-flag = to𝕎 0x20 context-specific-flag : Word8 context-specific-flag = to𝕎 0x80 constructed : Tag → Tag constructed = _or constructed-flag is-constructed : Tag → Bool is-constructed t = (t and constructed-flag) == constructed-flag context-specific : Tag → Tag context-specific = _or context-specific-flag is-context-specific : Tag → Bool is-context-specific t = (t and context-specific-flag) == context-specific-flag universal : ℕ universal = 0 tag : ℕ → Tag tag = to𝕎 OID = List ℕ -- basic asn.1 types module _ where EXPLICIT : Tag → AST → AST EXPLICIT t v = tlv (context-specific t) (constr (v ∷ [])) IMPLICIT : Tag → AST → AST IMPLICIT t (tlv _ vs) = tlv t vs NULL : AST NULL = tlv (tag 5) (prim empty) BOOLEAN : Bool → AST BOOLEAN b = tlv (tag 1) (prim (pack (bv b ∷ []))) where bv : Bool → Word8 bv b with b ... | true = to𝕎 0xff ... | false = to𝕎 0 INTEGER : ℕ → AST INTEGER n = tlv (to𝕎 2) (prim (pack (base256 n))) SEQUENCE : List AST → AST SEQUENCE vs = tlv (tag 16) (constr vs) SET : List AST → AST SET vs = tlv (tag 17) (constr vs) BIT-STRING : ℕ → ByteString Strict → AST BIT-STRING unused os = tlv (tag 3) (prim (toStrict (fromChunks ((pack (to𝕎 unused ∷ [])) ∷ os ∷ [])))) OCTET-STRING : ByteString Strict → AST OCTET-STRING os = tlv (tag 4) (prim os) OBJECT-IDENTIFIER : OID → AST OBJECT-IDENTIFIER oid = tlv (to𝕎 6) (prim (pack (packOID oid))) where packOID : List ℕ → List Word8 packOID [] = [] -- invalid oid packOID (n ∷ []) = to𝕎 n ∷ [] -- invalid oid packOID (n ∷ n′ ∷ ns) = concatMap base128 ((40 * n + n′) ∷ ns) where UTF8String : String → AST UTF8String s = tlv (to𝕎 12) (prim (packStrict s)) GeneralizedTime : String → AST GeneralizedTime yyyymmddhhz = tlv (to𝕎 24) (prim (packStrict yyyymmddhhz))
{ "alphanum_fraction": 0.6642984014, "avg_line_length": 26.0648148148, "ext": "agda", "hexsha": "f4f013c8b7a1a13a772b9f30037fe95c8ac58807", "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": "bbbeb679fa2c55a12f0cb345ad920c999c3f8fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "semenov-vladyslav/asn1-agda", "max_forks_repo_path": "src/ASN1/Untyped.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bbbeb679fa2c55a12f0cb345ad920c999c3f8fa8", "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": "semenov-vladyslav/asn1-agda", "max_issues_repo_path": "src/ASN1/Untyped.agda", "max_line_length": 115, "max_stars_count": null, "max_stars_repo_head_hexsha": "bbbeb679fa2c55a12f0cb345ad920c999c3f8fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "semenov-vladyslav/asn1-agda", "max_stars_repo_path": "src/ASN1/Untyped.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 931, "size": 2815 }
{- This second-order signature was created from the following second-order syntax description: $sig_string -} module ${syn_name}.Signature where open import SOAS.Context $type_decl $derived_ty_ops open import SOAS.Syntax.Signature $type public open import SOAS.Syntax.Build $type public -- Operator symbols data ${sig}ₒ : Set where $operator_decl -- Term signature ${sig}:Sig : Signature ${sig}ₒ ${sig}:Sig = sig λ { $sig_decl } open Signature ${sig}:Sig public
{ "alphanum_fraction": 0.7415966387, "avg_line_length": 17, "ext": "agda", "hexsha": "0b1eb9d01bcab29d59583a06eed7ddb31502a2a0", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "gen/templates/Signature.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "gen/templates/Signature.agda", "max_line_length": 91, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "gen/templates/Signature.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 124, "size": 476 }
module List.Permutation.Alternative.Correctness (A : Set) where open import Data.List open import List.Permutation.Alternative A renaming (_∼_ to _∼′_) open import List.Permutation.Base A open import List.Permutation.Base.Equivalence A lemma-∼′-∼ : {xs ys : List A} → xs ∼′ ys → xs ∼ ys lemma-∼′-∼ ∼refl = refl∼ lemma-∼′-∼ (∼trans xs∼′ys ys∼′zs) = trans∼ (lemma-∼′-∼ xs∼′ys) (lemma-∼′-∼ ys∼′zs) lemma-∼′-∼ (∼head x xs∼′ys) = ∼x /head /head (lemma-∼′-∼ xs∼′ys) lemma-∼′-∼ (∼swap xyxs∼′ys) = trans∼ (∼x /head (/tail /head) refl∼) (lemma-∼′-∼ xyxs∼′ys)
{ "alphanum_fraction": 0.6292947559, "avg_line_length": 42.5384615385, "ext": "agda", "hexsha": "a70230aa3aac5f670e7f5e883137d66486b0a82e", "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": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/List/Permutation/Alternative/Correctness.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "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": "bgbianchi/sorting", "max_issues_repo_path": "agda/List/Permutation/Alternative/Correctness.agda", "max_line_length": 89, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/List/Permutation/Alternative/Correctness.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 259, "size": 553 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT module homotopy.PushoutSplit where -- g h -- D --> B --> C K = A ⊔^D B / (f,g) d₁ = A <- D -> B -- f| | | L = K ⊔^B C / (right,h) d₂ = K <- B -> C -- v v v d = A <- D -> C -- A --> K --> L -- module PushoutRSplit {i j k l} {A : Type i} {B : Type j} {C : Type k} {D : Type l} (f : D → A) (g : D → B) (h : B → C) where private d₁ : Span d₁ = span A B D f g d₂ : Span d₂ = span (Pushout d₁) C B right h d : Span d = span A C D f (h ∘ g) split-span-map : SpanMap d d₂ split-span-map = span-map left (idf C) g (comm-sqr λ a → glue a) (comm-sqr λ _ → idp) module Split = PushoutFmap split-span-map split : Pushout d → Pushout d₂ split = Split.f inner-span-map : SpanMap d₁ d inner-span-map = span-map (idf A) h (idf D) (comm-sqr λ _ → idp) (comm-sqr λ _ → idp) module Inner = PushoutFmap inner-span-map inner : Pushout d₁ → Pushout d inner = Inner.f module Merge = PushoutRec {d = d₂} {D = Pushout d} inner right (λ _ → idp) merge : Pushout d₂ → Pushout d merge = Merge.f private square-extend-tr : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ b : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (q : a₁₀ == b) → Square p₀₋ p₋₀ p₋₁ p₁₋ → Square p₀₋ (p₋₀ ∙ q) p₋₁ (! q ∙' p₁₋) square-extend-tr idp ids = ids split-inner : (k : Pushout d₁) → split (inner k) == left k split-inner = Pushout-elim (λ a → idp) (λ b → ! (glue b)) (λ d → ↓-='-from-square $ (ap-∘ split inner (glue d) ∙ ap (ap split) (Inner.glue-β d) ∙ Split.glue-β d) ∙v⊡ square-extend-tr (glue (g d)) vid-square) abstract split-merge : (l : Pushout d₂) → split (merge l) == l split-merge = Pushout-elim split-inner (λ c → idp) (λ b → ↓-∘=idf-from-square split merge $ ap (ap split) (Merge.glue-β b) ∙v⊡ bl-square (glue b)) merge-split : (l : Pushout d) → merge (split l) == l merge-split = Pushout-elim (λ a → idp) (λ c → idp) (λ d → ↓-∘=idf-in' merge split $ ap merge (ap split (glue d)) =⟨ ap (ap merge) (Split.glue-β d) ⟩ ap merge (ap left (glue d) ∙ glue (g d)) =⟨ ap-∙ merge (ap left (glue d)) (glue (g d)) ⟩ ap merge (ap left (glue d)) ∙ ap merge (glue (g d)) =⟨ ap2 _∙_ (∘-ap merge left (glue d)) (Merge.glue-β (g d)) ⟩ ap inner (glue d) ∙ idp =⟨ ∙-unit-r _ ⟩ ap inner (glue d) =⟨ Inner.glue-β d ⟩ glue d ∎) split-equiv : Pushout d ≃ Pushout d₂ split-equiv = equiv split merge split-merge merge-split {- two-pushouts-left : lift ∘ left == left ∘ left [ (λ E → (A → E)) ↓ two-pushouts ] two-pushouts-left = codomain-over-equiv _ _ two-pushouts-right : lift ∘ right == right [ (λ E → (D → E)) ↓ two-pushouts ] two-pushouts-right = codomain-over-equiv _ _ two-pushouts-inner : lift ∘ inner == left [ (λ E → (Pushout d₁ → E)) ↓ two-pushouts ] two-pushouts-inner = codomain-over-equiv _ _ ▹ λ= split-inner -} rsplit-equiv = PushoutRSplit.split-equiv -- h -- D --> C K = A ⊔^D C / (f,h) d₁ = A <- D -> C -- f| | L = B ⊔^A K / (g,left) d₂ = B <- A -> K -- v v d = B <- D -> C -- A --> K -- g| | -- v v -- B --> L module PushoutLSplit {i j k l} {A : Type i} {B : Type j} {C : Type k} {D : Type l} (f : D → A) (g : A → B) (h : D → C) where private d₁ : Span d₁ = span A C D f h d₂ : Span d₂ = span B (Pushout d₁) A g left d : Span d = span B C D (g ∘ f) h split-span-map : SpanMap d d₂ split-span-map = span-map (idf B) right f (comm-sqr λ _ → idp) (comm-sqr λ d → ! (glue d)) module Split = PushoutFmap split-span-map split : Pushout d → Pushout d₂ split = Split.f inner-span-map : SpanMap d₁ d inner-span-map = span-map g (idf C) (idf D) (comm-sqr λ _ → idp) (comm-sqr λ _ → idp) module Inner = PushoutFmap inner-span-map inner : Pushout d₁ → Pushout d inner = Inner.f module Merge = PushoutRec {d = d₂} {D = Pushout d} left inner (λ _ → idp) merge : Pushout d₂ → Pushout d merge = Merge.f private square-extend-tl : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ b : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} (q : b == a₀₀) → Square p₀₋ p₋₀ p₋₁ p₁₋ → Square (q ∙' p₀₋) (q ∙' p₋₀) p₋₁ p₁₋ square-extend-tl idp ids = ids split-inner : (k : Pushout d₁) → split (inner k) == right k split-inner = Pushout-elim (λ a → glue a) (λ c → idp) (λ d → ↓-='-from-square $ (ap-∘ split inner (glue d) ∙ ap (ap split) (Inner.glue-β d) ∙ Split.glue-β d ∙ ap (λ p → glue (f d) ∙' ap right p) (!-! (glue d))) ∙v⊡ square-extend-tl (glue (f d)) vid-square) abstract split-merge : (l : Pushout d₂) → split (merge l) == l split-merge = Pushout-elim (λ b → idp) split-inner (λ a → ↓-∘=idf-from-square split merge $ ap (ap split) (Merge.glue-β a) ∙v⊡ br-square (glue a)) merge-split : (l : Pushout d) → merge (split l) == l merge-split = Pushout-elim (λ b → idp) (λ c → idp) (λ d → ↓-∘=idf-in' merge split $ ap merge (ap split (glue d)) =⟨ ap (ap merge) (Split.glue-β d) ⟩ ap merge (glue (f d) ∙' ap right (! (! (glue d)))) =⟨ ap-∙' merge (glue (f d)) (ap right (! (! (glue d)))) ⟩ ap merge (glue (f d)) ∙' ap merge (ap right (! (! (glue d)))) =⟨ ap2 _∙'_ (Merge.glue-β (f d)) (∘-ap merge right (! (! (glue d)))) ⟩ idp ∙' ap inner (! (! (glue d))) =⟨ ∙'-unit-l _ ⟩ ap inner (! (! (glue d))) =⟨ ap (ap inner) (!-! (glue d)) ⟩ ap inner (glue d) =⟨ Inner.glue-β d ⟩ glue d ∎) split-equiv : Pushout d ≃ Pushout d₂ split-equiv = equiv split merge split-merge merge-split lsplit-equiv = PushoutLSplit.split-equiv {- TODO Update this part -- g h -- Y --> Z --> W K = X ⊔^Y Y / (f,g) ps₁ = X <- Y -> Z -- f| | | L = Z ⊔^Z W / (left,h) ps₂ = K <- Z -> W -- v v v ps = X <- Y -> W -- X --> K --> L -- module TwoPushoutsPtd {i j k l} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} {W : Ptd l} (f : Y ⊙→ X) (g : Y ⊙→ Z) (h : Z ⊙→ W) where private ps₁ = ⊙span X Z Y f g ps₂ = ⊙span (⊙Pushout ps₁) W Z (⊙right ps₁) h ps = ⊙span X W Y f (h ⊙∘ g) open TwoPushoutsEquiv (fst f) (fst g) (fst h) two-pushouts-ptd : ⊙Lift {j = lmax l (lmax k (lmax j i))} (⊙Pushout ps) == ⊙Pushout ps₂ two-pushouts-ptd = ⊙ua (two-pushouts-equiv ∘e lift-equiv) idp two-pushouts-⊙left : ⊙lift ⊙∘ ⊙left ps == ⊙left ps₂ ⊙∘ ⊙left ps₁ [ (λ V → X ⊙→ V) ↓ two-pushouts-ptd ] two-pushouts-⊙left = codomain-over-⊙equiv _ _ _ two-pushouts-⊙right : ⊙lift ⊙∘ ⊙right ps == ⊙right ps₂ [ (λ V → W ⊙→ V) ↓ two-pushouts-ptd ] two-pushouts-⊙right = codomain-over-⊙equiv _ _ _ ▹ pair= idp (lemma f g h) where lemma : {X : Ptd i} {Y : Ptd j} {Z : Ptd k} {W : Ptd l} (f : Y ⊙→ X) (g : Y ⊙→ Z) (h : Z ⊙→ W) → ap (TwoPushoutsEquiv.split (fst f) (fst g) (fst h) ∘ lower {j = lmax l (lmax k (lmax j i))}) (snd (⊙lift ⊙∘ ⊙right (⊙span X W Y f (h ⊙∘ g)))) ∙ idp == ap right (! (snd h)) ∙ ! (glue (pt Z)) ∙' ap left (snd (⊙right (⊙span X Z Y f g))) lemma {Y = Y} (f , idp) (g , idp) (h , idp) = ap (2P.split ∘ lower) (ap lift (! (glue (pt Y))) ∙ idp) ∙ idp =⟨ ∙-unit-r _ ⟩ ap (2P.split ∘ lower) (ap lift (! (glue (pt Y))) ∙ idp) =⟨ ∙-unit-r _ |in-ctx (ap (2P.split ∘ lower)) ⟩ ap (2P.split ∘ lower) (ap lift (! (glue (pt Y)))) =⟨ ∘-ap (2P.split ∘ lower) lift _ ⟩ ap 2P.split (! (glue (pt Y))) =⟨ ap-! 2P.split (glue (pt Y)) ⟩ ! (ap 2P.split (glue (pt Y))) =⟨ 2P.Split.glue-β (pt Y) |in-ctx ! ⟩ ! (ap left (glue (pt Y)) ∙ glue (g (pt Y))) =⟨ !-∙ (ap left (glue (pt Y))) (glue (g (pt Y))) ⟩ ! (glue (g (pt Y))) ∙ ! (ap left (glue (pt Y))) =⟨ !-ap left (glue (pt Y)) |in-ctx (λ w → ! (glue (g (pt Y))) ∙ w) ⟩ ! (glue (g (pt Y))) ∙ ap left (! (glue (pt Y))) =⟨ ∙=∙' (! (glue (g (pt Y)))) (ap left (! (glue (pt Y)))) ⟩ ! (glue (g (pt Y))) ∙' ap left (! (glue (pt Y))) ∎ where module 2P = TwoPushoutsEquiv f g h two-pushouts-⊙inner : ⊙lift ⊙∘ (inner , idp) == ⊙left ps₂ [ (λ V → ⊙Pushout ps₁ ⊙→ V) ↓ two-pushouts-ptd ] two-pushouts-⊙inner = codomain-over-⊙equiv _ _ _ ▹ ⊙λ= split-inner idp -} {- open TwoPushoutsEquiv using () renaming (split-equiv to vsplit-pushouts-equiv) -- two-pushouts; two-pushouts-left; two-pushouts-right; two-pushouts-inner open TwoPushoutsPtd using (two-pushouts-ptd; two-pushouts-⊙left; two-pushouts-⊙right; two-pushouts-⊙inner) -}
{ "alphanum_fraction": 0.4919762585, "avg_line_length": 32.0352112676, "ext": "agda", "hexsha": "22328209efeebad14a270a06b810de5cb386d949", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/PushoutSplit.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "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": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/PushoutSplit.agda", "max_line_length": 92, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/PushoutSplit.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3693, "size": 9098 }
-- Copyright: (c) 2016 Ertugrul Söylemez -- License: BSD3 -- Maintainer: Ertugrul Söylemez <[email protected]> module Algebra.Group.Group where open import Algebra.Category open import Algebra.Group.Monoid open import Algebra.Group.Semigroup open import Core -- A group is a monoid where every element has an inverse. record IsGroup {a r} (S : Semigroup {a} {r}) : Set (a ⊔ r) where open Semigroup S field isMonoid : IsMonoid S open IsMonoid isMonoid field iso : ∀ x → Iso x inv : A → A inv x = Iso.inv (iso x) field inv-cong : ∀ {x y} → x ≈ y → inv x ≈ inv y groupoid : Groupoid groupoid = record { category = category; iso = iso; inv-cong = inv-cong } open Groupoid groupoid public using (inv-invol) record Group {a r} : Set (lsuc (a ⊔ r)) where field semigroup : Semigroup {a} {r} open Semigroup semigroup public field isGroup : IsGroup semigroup open IsGroup isGroup public monoid : Monoid monoid = record { semigroup = semigroup; isMonoid = isMonoid } -- A group morphism is a function that maps the elements of one group to -- another while preserving the compositional structure, the identity -- and all inverses. record GroupMorphism {ga gr ha hr} (G : Group {ga} {gr}) (H : Group {ha} {hr}) : Set (ga ⊔ gr ⊔ ha ⊔ hr) where private module G = Group G module H = Group H field monoidMorphism : MonoidMorphism G.monoid H.monoid open MonoidMorphism monoidMorphism public field inv-preserving : ∀ x → map (G.inv x) H.≈ H.inv (map x)
{ "alphanum_fraction": 0.6453018046, "avg_line_length": 21.7162162162, "ext": "agda", "hexsha": "a1f090286614174154855fa705bab23fc19b63c9", "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/Group/Group.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/Group/Group.agda", "max_line_length": 72, "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/Group/Group.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": 495, "size": 1607 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.GradedRing.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Algebra.Monoid open import Cubical.Algebra.AbGroup open import Cubical.Algebra.Ring open import Cubical.Algebra.GradedRing.DirectSumHIT private variable ℓ ℓ' : Level open AbGroupStr open GradedRing-⊕HIT-index open GradedRing-⊕HIT-⋆ ----------------------------------------------------------------------------- -- Definition record IsGradedRing (R : Ring (ℓ-max ℓ ℓ')) (IdM : Monoid ℓ) (G : (k : (fst IdM)) → Type ℓ') (Gstr : (k : fst IdM) → AbGroupStr (G k)) (1⋆ : G (MonoidStr.ε (snd IdM))) (_⋆_ : {k l : fst IdM} → G k → G l → G (MonoidStr._·_ (snd IdM) k l)) : Type (ℓ-max ℓ ℓ') where constructor isgradedring private Idx = fst IdM open MonoidStr (snd IdM) field 0-⋆ : {k l : Idx} → (b : G l) → (0g (Gstr k)) ⋆ b ≡ 0g (Gstr (k · l)) ⋆-0 : {k l : Idx} → (a : G k) → a ⋆ (0g (Gstr l)) ≡ 0g (Gstr (k · l)) ⋆Assoc : {k l m : Idx} → (a : G k) → (b : G l) → (c : G m) → ((k · (l · m)) , (a ⋆ (b ⋆ c))) ≡ (((k · l) · m) , ((a ⋆ b) ⋆ c)) ⋆IdR : {k : Idx} → (a : G k) → ( k · ε , a ⋆ 1⋆ ) ≡ (k , a) ⋆IdL : {l : Idx} → (b : G l) → ( ε · l , 1⋆ ⋆ b ) ≡ (l , b) ⋆DistR+ : {k l : Idx} → (a : G k) → (b c : G l) → a ⋆ ((Gstr l) ._+_ b c) ≡ Gstr (k · l) ._+_ (a ⋆ b) (a ⋆ c) ⋆DistL+ : {k l : Idx} → (a b : G k) → (c : G l) → ((Gstr k) ._+_ a b) ⋆ c ≡ Gstr (k · l) ._+_ (a ⋆ c) (b ⋆ c) equivRing : RingEquiv R (⊕HITgradedRing-Ring IdM G Gstr 1⋆ _⋆_ 0-⋆ ⋆-0 ⋆Assoc ⋆IdR ⋆IdL ⋆DistR+ ⋆DistL+) record GradedRingStr (R : Ring (ℓ-max ℓ ℓ')) : Type (ℓ-suc (ℓ-max ℓ ℓ')) where constructor gradedringstr field IdM : Monoid ℓ G : (k : (fst IdM)) → Type ℓ' Gstr : (k : fst IdM) → AbGroupStr (G k) 1⋆ : G (MonoidStr.ε (snd IdM)) _⋆_ : {k l : fst IdM} → G k → G l → G (MonoidStr._·_ (snd IdM) k l) isGradedRing : IsGradedRing R IdM G Gstr 1⋆ _⋆_ open IsGradedRing isGradedRing public GradedRing : ∀ ℓ ℓ' → Type (ℓ-suc (ℓ-max ℓ ℓ')) GradedRing ℓ ℓ' = Σ[ R ∈ Ring (ℓ-max ℓ ℓ') ] GradedRingStr R ----------------------------------------------------------------------------- -- make open MonoidStr makeIsGradedRing : {R : Ring (ℓ-max ℓ ℓ')} {IdM : Monoid ℓ} {G : (k : (fst IdM)) → Type ℓ'} {Gstr : (k : fst IdM) → AbGroupStr (G k)} {1⋆ : G (ε (snd IdM))} {_⋆_ : {k l : fst IdM} → G k → G l → G (_·_ (snd IdM) k l)} (0-⋆ : {k l : fst IdM} (b : G l) → (0g (Gstr k) ⋆ b) ≡ 0g (Gstr ((snd IdM MonoidStr.· k) l))) (⋆-0 : {k l : fst IdM} (a : G k) → (a ⋆ 0g (Gstr l)) ≡ 0g (Gstr ((snd IdM MonoidStr.· k) l))) (⋆Assoc : {k l m : fst IdM} (a : G k) (b : G l) (c : G m) → (((snd IdM ._·_ k) ((snd IdM ._·_ l) m) , (a ⋆ (b ⋆ c)))) ≡ ((snd IdM ._·_ ((snd IdM ._·_ k) l) m) , ((a ⋆ b) ⋆ c))) (⋆IdR : {k : fst IdM} → (a : G k) → ( snd IdM ._·_ k (snd IdM .ε) , a ⋆ 1⋆ ) ≡ (k , a)) (⋆IdL : {l : fst IdM} → (b : G l) → ( snd IdM ._·_ (snd IdM .ε) l , 1⋆ ⋆ b ) ≡ (l , b)) (⋆DistR+ : {k l : fst IdM} → (a : G k) → (b c : G l) → a ⋆ ((Gstr l) ._+_ b c) ≡ Gstr (snd IdM ._·_ k l) ._+_ (a ⋆ b) (a ⋆ c)) (⋆DistL+ : {k l : fst IdM} → (a b : G k) → (c : G l) → ((Gstr k) ._+_ a b) ⋆ c ≡ Gstr (snd IdM ._·_ k l) ._+_ (a ⋆ c) (b ⋆ c)) (equivRing : RingEquiv R (⊕HITgradedRing-Ring IdM G Gstr 1⋆ _⋆_ 0-⋆ ⋆-0 ⋆Assoc ⋆IdR ⋆IdL ⋆DistR+ ⋆DistL+)) → IsGradedRing R IdM G Gstr 1⋆ _⋆_ makeIsGradedRing 0-⋆ ⋆-0 ⋆Assoc ⋆IdR ⋆IdL ⋆DistR+ ⋆DistL+ equivRing = isgradedring 0-⋆ ⋆-0 ⋆Assoc ⋆IdR ⋆IdL ⋆DistR+ ⋆DistL+ equivRing makeGradedRing : (R : Ring (ℓ-max ℓ ℓ')) (IdM : Monoid ℓ) (G : (k : (fst IdM)) → Type ℓ') (Gstr : (k : fst IdM) → AbGroupStr (G k)) (1⋆ : G (ε (snd IdM))) (_⋆_ : {k l : fst IdM} → G k → G l → G (_·_ (snd IdM) k l)) (0-⋆ : {k l : fst IdM} (b : G l) → (0g (Gstr k) ⋆ b) ≡ 0g (Gstr ((snd IdM MonoidStr.· k) l))) (⋆-0 : {k l : fst IdM} (a : G k) → (a ⋆ 0g (Gstr l)) ≡ 0g (Gstr ((snd IdM MonoidStr.· k) l))) (⋆Assoc : {k l m : fst IdM} (a : G k) (b : G l) (c : G m) → (((snd IdM ._·_ k) ((snd IdM ._·_ l) m) , (a ⋆ (b ⋆ c)))) ≡ ((snd IdM ._·_ ((snd IdM ._·_ k) l) m) , ((a ⋆ b) ⋆ c))) (⋆IdR : {k : fst IdM} → (a : G k) → (snd IdM ._·_ k (snd IdM .ε) , a ⋆ 1⋆ ) ≡ (k , a)) (⋆IdL : {l : fst IdM} → (b : G l) → (snd IdM ._·_ (snd IdM .ε) l , 1⋆ ⋆ b ) ≡ (l , b)) (⋆DistR+ : {k l : fst IdM} → (a : G k) → (b c : G l) → a ⋆ ((Gstr l) ._+_ b c) ≡ Gstr (snd IdM ._·_ k l) ._+_ (a ⋆ b) (a ⋆ c)) (⋆DistL+ : {k l : fst IdM} → (a b : G k) → (c : G l) → ((Gstr k) ._+_ a b) ⋆ c ≡ Gstr (snd IdM ._·_ k l) ._+_ (a ⋆ c) (b ⋆ c)) (equivRing : RingEquiv R (⊕HITgradedRing-Ring IdM G Gstr 1⋆ _⋆_ 0-⋆ ⋆-0 ⋆Assoc ⋆IdR ⋆IdL ⋆DistR+ ⋆DistL+)) → GradedRing ℓ ℓ' fst (makeGradedRing R IdM G Gstr 1⋆ _⋆_ 0-⋆ ⋆-0 ⋆Assoc ⋆IdR ⋆IdL ⋆DistR+ ⋆DistL+ equivRing) = R GradedRingStr.IdM (snd (makeGradedRing R IdM G Gstr 1⋆ _⋆_ 0-⋆ ⋆-0 ⋆Assoc ⋆IdR ⋆IdL ⋆DistR+ ⋆DistL+ equivRing)) = IdM GradedRingStr.G (snd (makeGradedRing R IdM G Gstr 1⋆ _⋆_ 0-⋆ ⋆-0 ⋆Assoc ⋆IdR ⋆IdL ⋆DistR+ ⋆DistL+ equivRing)) = G GradedRingStr.Gstr (snd (makeGradedRing R IdM G Gstr 1⋆ _⋆_ 0-⋆ ⋆-0 ⋆Assoc ⋆IdR ⋆IdL ⋆DistR+ ⋆DistL+ equivRing)) = Gstr GradedRingStr.1⋆ (snd (makeGradedRing R IdM G Gstr 1⋆ _⋆_ 0-⋆ ⋆-0 ⋆Assoc ⋆IdR ⋆IdL ⋆DistR+ ⋆DistL+ equivRing)) = 1⋆ GradedRingStr._⋆_ (snd (makeGradedRing R IdM G Gstr 1⋆ _⋆_ 0-⋆ ⋆-0 ⋆Assoc ⋆IdR ⋆IdL ⋆DistR+ ⋆DistL+ equivRing)) = _⋆_ GradedRingStr.isGradedRing (snd (makeGradedRing R IdM G Gstr 1⋆ _⋆_ 0-⋆ ⋆-0 ⋆Assoc ⋆IdR ⋆IdL ⋆DistR+ ⋆DistL+ equivRing)) = makeIsGradedRing 0-⋆ ⋆-0 ⋆Assoc ⋆IdR ⋆IdL ⋆DistR+ ⋆DistL+ equivRing makeGradedRingSelf : (IdM : Monoid ℓ) (G : (k : (fst IdM)) → Type ℓ') (Gstr : (k : fst IdM) → AbGroupStr (G k)) (1⋆ : G (ε (snd IdM))) (_⋆_ : {k l : fst IdM} → G k → G l → G (_·_ (snd IdM) k l)) (0-⋆ : {k l : fst IdM} (b : G l) → (0g (Gstr k) ⋆ b) ≡ 0g (Gstr ((snd IdM MonoidStr.· k) l))) (⋆-0 : {k l : fst IdM} (a : G k) → (a ⋆ 0g (Gstr l)) ≡ 0g (Gstr ((snd IdM MonoidStr.· k) l))) (⋆Assoc : {k l m : fst IdM} (a : G k) (b : G l) (c : G m) → _≡_ {A = Σ[ k ∈ fst IdM ] G k} (((snd IdM ._·_ k) ((snd IdM ._·_ l) m) , (a ⋆ (b ⋆ c)))) ((snd IdM ._·_ ((snd IdM ._·_ k) l) m) , ((a ⋆ b) ⋆ c))) (⋆IdR : {k : fst IdM} → (a : G k) → _≡_ {A = Σ[ k ∈ fst IdM ] G k} ( snd IdM ._·_ k (snd IdM .ε) , a ⋆ 1⋆ ) (k , a)) (⋆IdL : {l : fst IdM} → (b : G l) → _≡_ {A = Σ[ k ∈ fst IdM ] G k} ( snd IdM ._·_ (snd IdM .ε) l , 1⋆ ⋆ b ) (l , b)) (⋆DistR+ : {k l : fst IdM} → (a : G k) → (b c : G l) → a ⋆ ((Gstr l) ._+_ b c) ≡ Gstr (snd IdM ._·_ k l) ._+_ (a ⋆ b) (a ⋆ c)) (⋆DistL+ : {k l : fst IdM} → (a b : G k) → (c : G l) → ((Gstr k) ._+_ a b) ⋆ c ≡ Gstr (snd IdM ._·_ k l) ._+_ (a ⋆ c) (b ⋆ c)) → GradedRing ℓ ℓ' makeGradedRingSelf IdM G Gstr 1⋆ _⋆_ 0-⋆ ⋆-0 ⋆Assoc ⋆IdR ⋆IdL ⋆DistR+ ⋆DistL+ = makeGradedRing (⊕HITgradedRing-Ring IdM G Gstr 1⋆ _⋆_ 0-⋆ ⋆-0 ⋆Assoc ⋆IdR ⋆IdL ⋆DistR+ ⋆DistL+) IdM G Gstr 1⋆ _⋆_ 0-⋆ ⋆-0 ⋆Assoc ⋆IdR ⋆IdL ⋆DistR+ ⋆DistL+ ((idEquiv _) , (makeIsRingHom refl (λ _ _ → refl) (λ _ _ → refl)))
{ "alphanum_fraction": 0.4123365351, "avg_line_length": 55.391025641, "ext": "agda", "hexsha": "9385d9b109cb36d7c7734950464808fd88a85190", "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/GradedRing/Base.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/GradedRing/Base.agda", "max_line_length": 122, "max_stars_count": null, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/GradedRing/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3974, "size": 8641 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Unbundled.Properties where -- The Obj-unbundled Category is equivalent (as a type) to the -- usual kind. Quite straightforward and because of η, the proofs are just refl. open import Data.Product using (Σ; _,_) open import Level open import Function using (_↔_; mk↔′) open import Relation.Binary.PropositionalEquality using (refl) open import Categories.Category.Core using (Category) open import Categories.Category.Unbundled renaming (Category to Unb-Cat) private variable o ℓ e : Level unpack : Category o ℓ e → Σ (Set o) (λ Obj → Unb-Cat Obj ℓ e) unpack C = C.Obj , record { C } where module C = Category C unpack′ : (C : Category o ℓ e) → Unb-Cat (Category.Obj C) ℓ e unpack′ C = record { C } where module C = Category C pack : Σ (Set o) (λ Obj → Unb-Cat Obj ℓ e) → Category o ℓ e pack (o , uc) = record { Obj = o; UC } where module UC = Unb-Cat uc pack′ : {Obj : Set o} → Unb-Cat Obj ℓ e → Category o ℓ e pack′ {Obj = o} uc = record { Obj = o; UC } where module UC = Unb-Cat uc equiv : (Category o ℓ e) ↔ (Σ (Set o) (λ Obj → Unb-Cat Obj ℓ e)) equiv = mk↔′ unpack pack (λ _ → refl) λ _ → refl
{ "alphanum_fraction": 0.6703204047, "avg_line_length": 32.0540540541, "ext": "agda", "hexsha": "563f8cf512632c2f769a449d697ae848573523cd", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Category/Unbundled/Properties.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Category/Unbundled/Properties.agda", "max_line_length": 80, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Category/Unbundled/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 380, "size": 1186 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Instance.PartialFunctions where -- Category of (Agda) Sets, and partial functions (modelled using Maybe). -- Note that unlike for basic categories, this is named after the morphisms instead of the objects. open import Data.Maybe using (Maybe; nothing; just; _>>=_; maybe) open import Level open import Relation.Binary using (Setoid) open import Relation.Binary.PropositionalEquality as ≡ using (_≗_; refl) open import Categories.Category private variable o : Level A B C D : Set o f g h : A → Maybe B _∘′_ : (B → Maybe C) → (A → Maybe B) → A → Maybe C f ∘′ g = λ a → g a >>= f ∘′-assoc : {h : C → Maybe D} {g : B → Maybe C} {f : A → Maybe B} → (h ∘′ g) ∘′ f ≗ h ∘′ (g ∘′ f) ∘′-assoc {h = h} {g} {f} a with f a ... | nothing = refl ... | just b = refl idˡ : {A B : Set o} {f : A → Maybe B} → just ∘′ f ≗ f idˡ {f = f} a = maybe {B = λ b → (b >>= just) ≡.≡ b} (λ x → refl) refl (f a) resp : {A B C : Set o} {f h : B → Maybe C} {g i : A → Maybe B} → f ≗ h → g ≗ i → (f ∘′ g) ≗ (h ∘′ i) resp {f = f} {h} {g} {i} f≡h g≡i a with g a | i a | g≡i a ... | just x | just .x | refl = f≡h x ... | just x | nothing | () ... | nothing | just x | () ... | nothing | nothing | _ = refl PartialFunctions : ∀ o → Category (suc o) o o PartialFunctions o = record { Obj = Set o ; _⇒_ = λ a b → a → Maybe b ; _≈_ = _≗_ ; id = just ; _∘_ = _∘′_ ; assoc = λ {_} {_} {_} {_} {f} {g} {h} → ∘′-assoc {h = h} {g} {f} ; sym-assoc = λ {_} {_} {_} {_} {f} {g} {h} a → ≡.sym (∘′-assoc {h = h} {g} {f} a) ; identityˡ = idˡ ; identityʳ = λ _ → refl ; identity² = idˡ ; equiv = λ {A} {B} → Setoid.isEquivalence (≡._→-setoid_ A (Maybe B)) ; ∘-resp-≈ = resp }
{ "alphanum_fraction": 0.5279819107, "avg_line_length": 32.1636363636, "ext": "agda", "hexsha": "6820b2bec5e46e947f5b15ff94fd23ef8254f470", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Category/Instance/PartialFunctions.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Category/Instance/PartialFunctions.agda", "max_line_length": 99, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Category/Instance/PartialFunctions.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 725, "size": 1769 }
-- Andreas, 2013-02-27 module Issue385 where import Common.Level open import Common.Equality loop : ∀ {A}{x : A} → x ≡ x loop = loop bad : Set bad rewrite loop = ? -- this used to loop, but should no longer, instead: -- Cannot rewrite by equation of type {A : Set _3} {x : A} → x ≡ x -- when checking that the clause bad rewrite loop = ? has type Set
{ "alphanum_fraction": 0.6704225352, "avg_line_length": 22.1875, "ext": "agda", "hexsha": "8939fa043a5436a87d1ead383319d75c7222f412", "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/fail/Issue385.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/Issue385.agda", "max_line_length": 66, "max_stars_count": 1, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/fail/Issue385.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": 108, "size": 355 }
module Data.List.Functions.Positional where import Lvl open import Data.List open import Data.Option open import Type private variable ℓ : Lvl.Level private variable T : Type{ℓ} -- A singleton list. A list with only a single element. -- Example: -- singleton(a) = [a] singleton : T → List(T) singleton elem = elem ⊰ ∅ -- The list without its first element (if there is one). -- Example: -- tail [] = [] -- tail [a] = [] -- tail [a,b] = [b] -- tail [a,b,c] = [b,c] tail : List(T) → List(T) tail ∅ = ∅ tail (_ ⊰ l) = l -- The first element of the list (head) first : List(T) → Option(T) first ∅ = Option.None first (x ⊰ _) = Option.Some(x) -- The last element of the list last : List(T) → Option(T) last ∅ = Option.None last (x ⊰ ∅) = Option.Some(x) last (_ ⊰ y ⊰ l) = last (y ⊰ l) -- TODO: Function equivalent to (foldₗ (const Option.Some) Option.None)? Prove if correct
{ "alphanum_fraction": 0.6084598698, "avg_line_length": 24.2631578947, "ext": "agda", "hexsha": "308d193c8e388e6ad4344b7c435e89173a983188", "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": "Data/List/Functions/Positional.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": "Data/List/Functions/Positional.agda", "max_line_length": 89, "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": "Data/List/Functions/Positional.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": 286, "size": 922 }
{-# OPTIONS --without-K #-} module hott.level.sets where open import level open import decidable open import sum open import equality.core open import equality.calculus open import equality.reasoning open import function.core open import function.extensionality.proof open import sets.empty open import sets.unit open import hott.level.core -- ⊤ is contractible ⊤-contr : contr ⊤ ⊤-contr = tt , λ { tt → refl } -- ⊥ is propositional ⊥-prop : h 1 ⊥ ⊥-prop x _ = ⊥-elim x ⊥-initial : ∀ {i} {A : Set i} → contr (⊥ → A) ⊥-initial = (λ ()) , (λ f → funext λ ()) -- Hedberg's theorem hedberg : ∀ {i} {A : Set i} → ((x y : A) → Dec (x ≡ y)) → h 2 A hedberg {A = A} dec x y = prop⇒h1 ≡-prop where open ≡-Reasoning canonical : {x y : A} → x ≡ y → x ≡ y canonical {x} {y} p with dec x y ... | yes q = q ... | no _ = p canonical-const : {x y : A} → (p q : x ≡ y) → canonical p ≡ canonical q canonical-const {x} {y} p q with dec x y ... | yes _ = refl ... | no f = ⊥-elim (f p) canonical-inv : {x y : A}(p : x ≡ y) → canonical p · sym (canonical refl) ≡ p canonical-inv refl = left-inverse (canonical refl) ≡-prop : {x y : A}(p q : x ≡ y) → p ≡ q ≡-prop p q = begin p ≡⟨ sym (canonical-inv p) ⟩ canonical p · sym (canonical refl) ≡⟨ ap (λ z → z · sym (canonical refl)) (canonical-const p q) ⟩ canonical q · sym (canonical refl) ≡⟨ canonical-inv q ⟩ q ∎ -- Bool is a set private module BoolSet where open import sets.bool bool-set : h 2 Bool bool-set = hedberg _≟_ open BoolSet public -- Nat is a set private module NatSet where open import sets.nat.core nat-set : h 2 ℕ nat-set = hedberg _≟_ open NatSet public -- Fin is a set private module FinSet where open import sets.fin.core fin-set : ∀ n → h 2 (Fin n) fin-set n = hedberg _≟_ open FinSet public
{ "alphanum_fraction": 0.5611835507, "avg_line_length": 23.1860465116, "ext": "agda", "hexsha": "aac92346c3084147aa0f3530e838bd14ef1215e8", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z", "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "HoTT/M-types", "max_forks_repo_path": "hott/level/sets.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_issues_repo_issues_event_max_datetime": "2015-02-11T15:20:34.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-11T11:14:59.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "HoTT/M-types", "max_issues_repo_path": "hott/level/sets.agda", "max_line_length": 58, "max_stars_count": 27, "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_path": "hott/level/sets.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "num_tokens": 676, "size": 1994 }
import Lvl open import Type module Data.List.Relation.Sublist.Proofs {ℓ} {T : Type{ℓ}} where open import Data.Boolean import Data.Either as Either open import Data.List as List open import Data.List.Functions as List hiding (skip) open import Data.List.Proofs open import Data.List.Relation.Sublist open import Data.Tuple as Tuple using (_,_) open import Functional open import Logic.Propositional open import Logic.Predicate open import Numeral.Natural open import Numeral.Natural.Inductions open import Numeral.Natural.Relation.Order open import Numeral.Natural.Relation.Order.Proofs open import Relator.Equals open import Relator.Equals.Proofs open import Structure.Relator.Ordering open import Structure.Relator.Ordering.Proofs open import Structure.Relator.Properties private variable ℓ₂ : Lvl.Level private variable T₂ : Type{ℓ₂} private variable a x y : T private variable l l₁ l₂ l₃ : List(T) private variable n : ℕ [⊑]-reflexivity : (l ⊑ l) [⊑]-reflexivity {∅} = empty [⊑]-reflexivity {a ⊰ l} = use([⊑]-reflexivity{l}) [⊑]-prepend : (l ⊑ x ⊰ l) [⊑]-prepend {∅} = skip empty [⊑]-prepend {x ⊰ l} = skip [⊑]-reflexivity [⊑]-without-[⊰] : ((x ⊰ l₁) ⊑ (y ⊰ l₂)) → (l₁ ⊑ l₂) [⊑]-without-[⊰] (use p) = p [⊑]-without-[⊰] (skip(use p)) = skip p [⊑]-without-[⊰] {x = x}{y = y} (skip(skip p)) = skip([⊑]-without-[⊰] {x = x}{y = y} (skip p)) [⊑]-transitivity : (l₁ ⊑ l₂) → (l₂ ⊑ l₃) → (l₁ ⊑ l₃) [⊑]-transitivity empty empty = empty [⊑]-transitivity empty (skip l₂l₃) = skip l₂l₃ [⊑]-transitivity (use l₁l₂) (use l₂l₃) = use([⊑]-transitivity l₁l₂ l₂l₃) [⊑]-transitivity (use l₁l₂) (skip l₂l₃) = skip([⊑]-transitivity (use l₁l₂) l₂l₃) [⊑]-transitivity (skip l₁l₂) (use l₂l₃) = skip([⊑]-transitivity l₁l₂ l₂l₃) [⊑]-transitivity (skip l₁l₂) (skip l₂l₃) = skip([⊑]-transitivity (skip l₁l₂) l₂l₃) [⊑]-not-prepend : ¬((x ⊰ l) ⊑ l) [⊑]-not-prepend {x} {x ⊰ l₂} (use p) = [⊑]-not-prepend {x}{l₂} p [⊑]-not-prepend {x} {y ⊰ _} (skip p) = [⊑]-not-prepend([⊑]-without-[⊰] {y = y} (skip p)) [⊑]-antisymmetry : (l₂ ⊑ l₁) → (l₁ ⊑ l₂) → (l₁ ≡ l₂) [⊑]-antisymmetry {∅} {∅} l r = [≡]-intro [⊑]-antisymmetry {y ⊰ l₂} {.y ⊰ l₁} (use l) r = [≡]-with(y ⊰_) ([⊑]-antisymmetry l ([⊑]-without-[⊰] r)) [⊑]-antisymmetry {y ⊰ l₂} {.y ⊰ l₁} (skip l) (use r) = [≡]-with(y ⊰_) ([⊑]-antisymmetry ([⊑]-without-[⊰] {y = y} (skip l)) r) [⊑]-antisymmetry {y ⊰ l₂} {x ⊰ l₁} (skip l) (skip r) = [⊥]-elim ([⊑]-not-prepend ([⊑]-transitivity (skip r) l)) [⊑]-minimum : (∅ ⊑ l) [⊑]-minimum {∅} = empty [⊑]-minimum {a ⊰ l} = skip([⊑]-minimum{l}) [⊑]ᵣ-of-[++]ₗ : (l₁ ⊑ (l₂ ++ l₁)) [⊑]ᵣ-of-[++]ₗ {l₁}{∅} = [⊑]-reflexivity [⊑]ᵣ-of-[++]ₗ {l₁}{a ⊰ l₂} = skip{x = a}([⊑]ᵣ-of-[++]ₗ {l₁}{l₂}) [⊑]ᵣ-of-[++]ᵣ : (l₁ ⊑ (l₁ ++ l₂)) [⊑]ᵣ-of-[++]ᵣ {∅} {l₂} = [⊑]-minimum [⊑]ᵣ-of-[++]ᵣ {a ⊰ l₁}{l₂} = use([⊑]ᵣ-of-[++]ᵣ{l₁}{l₂}) [⊑]-tail : (tail l ⊑ l) [⊑]-tail {∅} = empty [⊑]-tail {a ⊰ l} = skip [⊑]-reflexivity [⊑]-map : ∀{f : T → T₂} → (l₁ ⊑ l₂) → (map f(l₁) ⊑ map f(l₂)) [⊑]-map empty = empty [⊑]-map (use p) = use ([⊑]-map p) [⊑]-map (skip p) = skip ([⊑]-map p) [⊑]-filter : ∀{f} → (filter f(l) ⊑ l) [⊑]-filter {∅} = empty [⊑]-filter {x ⊰ l} {f} with f(x) ... | 𝑇 = use ([⊑]-filter {l}) ... | 𝐹 = skip ([⊑]-filter {l}) [⊑]-separate₂ : let (l₁ , l₂) = separate₂(l) in (l₁ ⊑ l) ∧ (l₂ ⊑ l) Tuple.left ([⊑]-separate₂ {∅}) = empty Tuple.left ([⊑]-separate₂ {x ⊰ ∅}) = [⊑]-reflexivity Tuple.left ([⊑]-separate₂ {x ⊰ y ⊰ l}) = use (skip (Tuple.left [⊑]-separate₂)) Tuple.right ([⊑]-separate₂ {∅}) = empty Tuple.right ([⊑]-separate₂ {x ⊰ ∅}) = skip [⊑]-reflexivity Tuple.right ([⊑]-separate₂ {x ⊰ y ⊰ l}) = skip (use (Tuple.right [⊑]-separate₂)) [⊑]-postpend : (l ⊑ postpend a l) [⊑]-postpend {∅} = skip empty [⊑]-postpend {x ⊰ l} = use [⊑]-postpend [⊑]-withoutIndex : (withoutIndex n l ⊑ l) [⊑]-withoutIndex {𝟎} {∅} = empty [⊑]-withoutIndex {𝐒 n} {∅} = empty [⊑]-withoutIndex {𝟎} {x ⊰ l} = skip [⊑]-reflexivity [⊑]-withoutIndex {𝐒 n} {x ⊰ l} = use [⊑]-withoutIndex [⊑]-initial : (initial n l ⊑ l) [⊑]-initial {𝟎} {∅} = empty [⊑]-initial {𝐒 n} {∅} = empty [⊑]-initial {𝟎} {x ⊰ l} = [⊑]-minimum [⊑]-initial {𝐒 n} {x ⊰ l} = use [⊑]-initial [⊑]-skip : (List.skip n l ⊑ l) [⊑]-skip {𝟎} {∅} = empty [⊑]-skip {𝐒 n} {∅} = empty [⊑]-skip {𝟎} {x ⊰ l} = [⊑]-reflexivity [⊑]-skip {𝐒 n} {x ⊰ l} = skip [⊑]-skip [⊑]-empty : (l ⊑ ∅) → (l ≡ ∅) [⊑]-empty {∅} _ = [≡]-intro [⊑]-empty {_ ⊰ _} () [⊑]-length : (l₁ ⊑ l₂) → (length(l₁) ≤ length(l₂)) [⊑]-length empty = [≤]-minimum [⊑]-length (use p) = [≤]-with-[𝐒] ⦃ [⊑]-length p ⦄ [⊑]-length (skip p) = [≤]-predecessor ([≤]-with-[𝐒] ⦃ [⊑]-length p ⦄) [⊏]-without-[⊰] : ((x ⊰ l₁) ⊏ (y ⊰ l₂)) → (l₁ ⊏ l₂) [⊏]-without-[⊰] (use p) = p [⊏]-without-[⊰] (skip (use p)) = skip p [⊏]-without-[⊰] {x = x}{y = y} (skip (skip p)) = skip ([⊑]-without-[⊰] {x = x}{y = y} (skip p)) [⊏]-irreflexivity : ¬(l ⊏ l) [⊏]-irreflexivity {∅} () [⊏]-irreflexivity {x ⊰ l} p = [⊏]-irreflexivity {l} ([⊏]-without-[⊰] p) [⊏]-to-[⊑] : (l₁ ⊏ l₂) → (l₁ ⊑ l₂) [⊏]-to-[⊑] (use p) = use ([⊏]-to-[⊑] p) [⊏]-to-[⊑] (skip p) = skip p [⊏]-skip-[⊰] : (l₁ ⊏ l₂) → (l₁ ⊏ (x ⊰ l₂)) [⊏]-skip-[⊰] (use p) = skip ([⊏]-to-[⊑] (use p)) [⊏]-skip-[⊰] (skip x) = skip (skip x) [⊏]-transitivity : (l₁ ⊏ l₂) → (l₂ ⊏ l₃) → (l₁ ⊏ l₃) [⊏]-transitivity p (skip (skip q)) = skip(skip([⊑]-transitivity ([⊏]-to-[⊑] p) q)) [⊏]-transitivity (use p) (use q) = use ([⊏]-transitivity p q) [⊏]-transitivity (use p) (skip (use q)) = skip (use ([⊑]-transitivity ([⊏]-to-[⊑] p) q)) [⊏]-transitivity (skip p) (use q) = skip([⊑]-transitivity p ([⊏]-to-[⊑] q)) [⊏]-transitivity (skip p) (skip (use q)) = skip(skip([⊑]-transitivity p q)) [⊏]-asymmetry : (l₂ ⊏ l₁) → (l₁ ⊏ l₂) → ⊥ [⊏]-asymmetry p q = [⊏]-irreflexivity([⊏]-transitivity p q) [⊏]-minimum : (l ≡ ∅) ∨ (∅ ⊏ l) [⊏]-minimum {∅} = [∨]-introₗ [≡]-intro [⊏]-minimum {x ⊰ l} = [∨]-introᵣ (skip [⊑]-minimum) [⊏]-emptyₗ : (∅ ⊏ (x ⊰ l)) [⊏]-emptyₗ {l = ∅} = skip empty [⊏]-emptyₗ {l = x ⊰ l} = skip ([⊏]-to-[⊑] ([⊏]-emptyₗ {l = l})) [⊏]-emptyᵣ : ¬(l ⊏ ∅) [⊏]-emptyᵣ () [⊏]-length : (l₁ ⊏ l₂) → (length(l₁) < length(l₂)) [⊏]-length (use p) = [≤]-with-[𝐒] ⦃ [⊏]-length p ⦄ [⊏]-length (skip p) = [≤]-with-[𝐒] ⦃ [⊑]-length p ⦄ [⊏]-prepend : (l ⊏ x ⊰ l) [⊏]-prepend = skip [⊑]-reflexivity [⊏]-postpend : (l ⊏ postpend x l) [⊏]-postpend {∅} = skip empty [⊏]-postpend {a ⊰ l} = use ([⊏]-postpend {l}) [⊏]-map : ∀{f : T → T₂} → (l₁ ⊏ l₂) → (map f(l₁) ⊏ map f(l₂)) [⊏]-map (use p) = use ([⊏]-map p) [⊏]-map (skip p) = skip ([⊑]-map p) [⊏]-tail : (∅ ⊏ l) → (tail l ⊏ l) [⊏]-tail (skip _) = skip [⊑]-reflexivity [⊏]-initial : (n < length(l)) → (initial n l ⊏ l) [⊏]-initial {𝟎} {x ⊰ l} p = [⊏]-emptyₗ [⊏]-initial {𝐒 n} {x ⊰ l} p = use ([⊏]-initial {n} ([≤]-without-[𝐒] p)) [⊏]-skip : (𝟎 < n) → (n < length(l)) → (List.skip n l ⊏ l) [⊏]-skip {𝐒 n} {x ⊰ l} p q = skip [⊑]-skip [⊏]-withoutIndex : (n < length(l)) → (withoutIndex n l ⊏ l) [⊏]-withoutIndex {𝟎} {x ⊰ l} p = [⊏]-prepend [⊏]-withoutIndex {𝐒 n} {x ⊰ l} p = use ([⊏]-withoutIndex ([≤]-without-[𝐒] p)) [⊏]-separate₂ : let (l₁ , l₂) = separate₂(l) in (2 ≤ length(l)) → ((l₁ ⊏ l) ∧ (l₂ ⊏ l)) [⊏]-separate₂ {x ⊰ ∅} (succ()) Tuple.left ([⊏]-separate₂ {x ⊰ y ⊰ l} (succ (succ min))) = use (skip (Tuple.left [⊑]-separate₂)) Tuple.right ([⊏]-separate₂ {x ⊰ y ⊰ l} (succ (succ min))) = skip (use (Tuple.right [⊑]-separate₂)) [⊏]ᵣ-of-[++]ₗ : (∅ ⊏ l₂) → (l₁ ⊏ (l₂ ++ l₁)) [⊏]ᵣ-of-[++]ₗ {a ⊰ l₂} {l₁} (skip p) = skip([⊑]ᵣ-of-[++]ₗ {l₁}{l₂}) [⊏]ᵣ-of-[++]ᵣ : (∅ ⊏ l₂) → (l₁ ⊏ (l₁ ++ l₂)) [⊏]ᵣ-of-[++]ᵣ {a ⊰ l₂} {∅} (skip p) = skip p [⊏]ᵣ-of-[++]ᵣ {a ⊰ l₂} {b ⊰ l₁} (skip p) = use ([⊏]ᵣ-of-[++]ᵣ {a ⊰ l₂} {l₁} (skip p)) [⊑][⊏]-transitivity-like : (l₁ ⊑ l₂) → (l₂ ⊏ l₃) → (l₁ ⊏ l₃) [⊑][⊏]-transitivity-like p (skip q) = skip([⊑]-transitivity p q) [⊑][⊏]-transitivity-like (use p) (use q) = use ([⊑][⊏]-transitivity-like p q) [⊑][⊏]-transitivity-like (skip p) (use q) = [⊏]-skip-[⊰] ([⊑][⊏]-transitivity-like p q) instance [⊏][<]-on-length-sub : (_⊏_ {T = T}) ⊆₂ ((_<_) on₂ length) [⊏][<]-on-length-sub = intro [⊏]-length module _ where open Structure.Relator.Ordering.Strict.Properties instance [<]-on-length-well-founded : WellFounded((_<_) on₂ (length {T = T})) [<]-on-length-well-founded = wellfounded-image-by-trans instance [⊏]-well-founded : WellFounded(_⊏_ {T = T}) [⊏]-well-founded = accessibleₗ-sub₂ ⦃ [⊏][<]-on-length-sub ⦄ [⊑]-to-[⊏] : (l₁ ⊑ l₂) → ((l₁ ⊏ l₂) ∨ (length(l₁) ≡ length(l₂))) [⊑]-to-[⊏] empty = [∨]-introᵣ [≡]-intro [⊑]-to-[⊏] (use p) = Either.map use ([≡]-with(𝐒)) ([⊑]-to-[⊏] p) [⊑]-to-[⊏] (skip p) = [∨]-introₗ (skip p)
{ "alphanum_fraction": 0.5049269453, "avg_line_length": 37.7307692308, "ext": "agda", "hexsha": "0c58bb83436282c0ce213dcba92177d94235a8e4", "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": "Data/List/Relation/Sublist/Proofs.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": "Data/List/Relation/Sublist/Proofs.agda", "max_line_length": 126, "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": "Data/List/Relation/Sublist/Proofs.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": 4559, "size": 8829 }
------------------------------------------------------------------------ -- Pointed types and loop spaces ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} -- Partly following the HoTT book. open import Equality module Pointed-type {reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where open Derived-definitions-and-properties eq open import Logical-equivalence using (_⇔_) open import Prelude as P hiding (_×_) open import Bijection eq as B using (_↔_) open import Equivalence eq as E using (_≃_) open import Function-universe eq as F hiding (id; _∘_) open import H-level eq open import Surjection eq using (_↠_) open import Univalence-axiom eq private variable a b ℓ : Level A B : Type a x y : A p q : x ≡ y k : Kind ------------------------------------------------------------------------ -- The definition of pointed types -- Pointed types. Pointed-type : ∀ ℓ → Type (lsuc ℓ) Pointed-type a = ∃ λ (A : Type a) → A ------------------------------------------------------------------------ -- Based maps -- Based maps (generalised to several kinds of underlying -- "functions"). infix 4 _↝[_]ᴮ_ _→ᴮ_ _≃ᴮ_ _↝[_]ᴮ_ : Pointed-type a → Kind → Pointed-type b → Type (a ⊔ b) (A , x) ↝[ k ]ᴮ (B , y) = ∃ λ (f : A ↝[ k ] B) → to-implication f x ≡ y -- Based maps. _→ᴮ_ : Pointed-type a → Pointed-type b → Type (a ⊔ b) _→ᴮ_ = _↝[ implication ]ᴮ_ -- Based equivalences. _≃ᴮ_ : Pointed-type a → Pointed-type b → Type (a ⊔ b) _≃ᴮ_ = _↝[ equivalence ]ᴮ_ private variable P P₁ P₂ Q Q₁ Q₂ R : Pointed-type a P→Q : P →ᴮ Q P≃Q : P ≃ᴮ Q -- Based equivalences can be converted to based maps. ≃ᴮ→→ᴮ : P ≃ᴮ Q → P →ᴮ Q ≃ᴮ→→ᴮ = Σ-map _≃_.to id -- Based equivalences are equivalent to equalities (assuming -- univalence). ≃ᴮ≃≡ : {P Q : Pointed-type a} → Univalence a → (P ≃ᴮ Q) ≃ (P ≡ Q) ≃ᴮ≃≡ {P = A , x} {Q = B , y} univ = (∃ λ (A≃B : A ≃ B) → _≃_.to A≃B x ≡ y) ↝⟨ (inverse $ Σ-cong (≡≃≃ univ) λ A≃B → ≡⇒≃ $ cong (_≡ _) $ subst-id-in-terms-of-≡⇒↝ equivalence) ⟩ (∃ λ (A≡B : A ≡ B) → subst id A≡B x ≡ y) ↔⟨ B.Σ-≡,≡↔≡ ⟩□ (A , x) ≡ (B , y) □ -- _↝[ k ]ᴮ_ is reflexive. ↝ᴮ-refl : P ↝[ k ]ᴮ P ↝ᴮ-refl {k = k} = F.id , cong (_$ _) (to-implication-id k) -- _↝[ k ]ᴮ_ is transitive. ↝ᴮ-trans : P ↝[ k ]ᴮ Q → Q ↝[ k ]ᴮ R → P ↝[ k ]ᴮ R ↝ᴮ-trans {P = _ , x} {k = k} {Q = _ , y} {R = _ , z} (A↝B , p) (B↝C , q) = B↝C F.∘ A↝B , (to-implication (B↝C F.∘ A↝B) x ≡⟨ cong (_$ _) $ to-implication-∘ k ⟩ to-implication B↝C (to-implication A↝B x) ≡⟨ cong (to-implication B↝C) p ⟩ to-implication B↝C y ≡⟨ q ⟩∎ z ∎) -- _≃ᴮ_ is symmetric. ≃ᴮ-sym : P ≃ᴮ Q → Q ≃ᴮ P ≃ᴮ-sym (A≃B , p) = inverse A≃B , _≃_.to-from A≃B p -- "Equational" reasoning combinators. infix -1 _□ᴮ finallyᴮ infixr -2 stepᴮ -- For an explanation of why stepᴮ is defined in this way, see -- Equality.step-≡. stepᴮ : (P : Pointed-type a) {Q : Pointed-type b} → Q ↝[ k ]ᴮ R → P ↝[ k ]ᴮ Q → P ↝[ k ]ᴮ R stepᴮ _ = flip ↝ᴮ-trans syntax stepᴮ P Q↝R P↝Q = P ↝ᴮ⟨ P↝Q ⟩ Q↝R finallyᴮ : (P : Pointed-type a) (Q : Pointed-type b) → P ↝[ k ]ᴮ Q → P ↝[ k ]ᴮ Q finallyᴮ _ _ P↝Q = P↝Q syntax finallyᴮ P Q P↝Q = P ↝ᴮ⟨ P↝Q ⟩□ Q □ _□ᴮ : (P : Pointed-type a) → P ↝[ k ]ᴮ P _ □ᴮ = ↝ᴮ-refl -- There is a split surjection from based maps from -- (Maybe A , nothing) to functions. Maybe→ᴮ↠→ : (Maybe A , nothing) →ᴮ (B , x) ↠ (A → B) Maybe→ᴮ↠→ {A = A} {B = B} {x = x} = record { logical-equivalence = record { to = (Maybe A , nothing) →ᴮ (B , x) ↝⟨ proj₁ ⟩ (Maybe A → B) ↝⟨ _∘ inj₂ ⟩□ (A → B) □ ; from = λ f → [ (λ _ → x) , f ] , refl x } ; right-inverse-of = refl } -- Based maps from (Maybe A , nothing) are isomorphic to functions -- (assuming extensionality). Maybe→ᴮ↔→ : ∀ {A : Type a} {B : Type b} {x} → (Maybe A , nothing) →ᴮ (B , x) ↝[ a ∣ b ] (A → B) Maybe→ᴮ↔→ {A = A} {B} {x} = generalise-ext? (_↠_.logical-equivalence Maybe→ᴮ↠→) (λ ext → refl , (λ (f , eq) → Σ-≡,≡→≡ (apply-ext (E.good-ext ext) [ (λ _ → x ≡⟨ sym eq ⟩∎ f nothing ∎) , (λ _ → refl _) ]) (subst (λ f → f nothing ≡ x) (apply-ext (E.good-ext ext) [ (λ _ → sym eq) , (λ _ → refl _) ]) (refl x) ≡⟨ E.subst-good-ext ext _ _ ⟩ subst (_≡ x) (sym eq) (refl x) ≡⟨ subst-trans _ ⟩ trans eq (refl x) ≡⟨ trans-reflʳ _ ⟩∎ eq ∎))) -- A corollary. Bool→ᴮ↔ : ∀ {A : Type a} {x} → (Bool , true) →ᴮ (A , x) ↝[ lzero ∣ a ] A Bool→ᴮ↔ {A = A} {x = x} ext = (Bool , true) →ᴮ (A , x) ↝⟨ Maybe→ᴮ↔→ ext ⟩ (⊤ → A) ↔⟨ Π-left-identity ⟩□ A □ ------------------------------------------------------------------------ -- Loop spaces -- The loop space of a pointed type. Ω : Pointed-type ℓ → Pointed-type ℓ Ω (A , x) = (x ≡ x) , refl x -- Iterated loop spaces. -- -- The HoTT book uses Ω[ n ] ∘ Ω rather than Ω ∘ Ω[ n ]. I prefer -- the following definition, because with the other definition the -- type of Equality.Groupoid.Ω[2+n]-commutative would not be -- well-formed. (See also Ω∘Ω[]≡Ω[]∘Ω.) Ω[_] : ℕ → Pointed-type ℓ → Pointed-type ℓ Ω[ zero ] = id Ω[ suc n ] = Ω ∘ Ω[ n ] -- A rearrangement lemma for Ω and Ω[_]. Ω∘Ω[]≡Ω[]∘Ω : ∀ n → Ω (Ω[ n ] P) ≡ Ω[ n ] (Ω P) Ω∘Ω[]≡Ω[]∘Ω {P = P} zero = Ω P ∎ Ω∘Ω[]≡Ω[]∘Ω {P = P} (suc n) = Ω (Ω[ suc n ] P) ≡⟨⟩ Ω (Ω (Ω[ n ] P)) ≡⟨ cong Ω $ Ω∘Ω[]≡Ω[]∘Ω n ⟩ Ω (Ω[ n ] (Ω P)) ≡⟨⟩ Ω[ suc n ] (Ω P) ∎ -- Ω preserves based maps. Ω-cong-→ᴮ : P →ᴮ Q → Ω P →ᴮ Ω Q Ω-cong-→ᴮ {P = A , x} {Q = B , y} (to , to≡) = (x ≡ x ↝⟨ cong to ⟩ to x ≡ to x ↔⟨ ≡⇒≃ $ cong₂ _≡_ to≡ to≡ ⟩□ y ≡ y □) , (≡⇒→ (cong₂ _≡_ to≡ to≡) (cong to (refl x)) ≡⟨ cong (≡⇒→ (cong₂ _≡_ to≡ to≡)) $ cong-refl _ ⟩ ≡⇒→ (cong₂ _≡_ to≡ to≡) (refl (to x)) ≡⟨ elim¹ (λ to≡ → ≡⇒→ (cong₂ _≡_ to≡ to≡) (refl (to x)) ≡ refl _) ( ≡⇒→ (cong₂ _≡_ (refl _) (refl _)) (refl _) ≡⟨ cong (λ eq → ≡⇒→ eq (refl _)) $ cong₂-refl _≡_ ⟩ ≡⇒→ (refl _) (refl _) ≡⟨ cong (λ eq → _≃_.to eq (refl _)) ≡⇒↝-refl ⟩∎ refl _ ∎) _ ⟩∎ refl y ∎) -- Ω preserves based equivalences. Ω-cong-≃ᴮ : P ≃ᴮ Q → Ω P ≃ᴮ Ω Q Ω-cong-≃ᴮ {P = A , x} {Q = B , y} (A≃B , to≡) = (x ≡ x ↝⟨ inverse $ E.≃-≡ A≃B ⟩ _≃_.to A≃B x ≡ _≃_.to A≃B x ↝⟨ ≡⇒↝ _ $ cong₂ _≡_ to≡ to≡ ⟩□ y ≡ y □) , proj₂ (Ω-cong-→ᴮ (_≃_.to A≃B , to≡)) -- Ω[ n ] preserves based maps. Ω[_]-cong-→ᴮ : ∀ n → P →ᴮ Q → Ω[ n ] P →ᴮ Ω[ n ] Q Ω[ zero ]-cong-→ᴮ A→B = A→B Ω[ suc n ]-cong-→ᴮ A→B = Ω-cong-→ᴮ (Ω[ n ]-cong-→ᴮ A→B) -- Ω[ n ] preserves based equivalences. Ω[_]-cong-≃ᴮ : ∀ n → P ≃ᴮ Q → Ω[ n ] P ≃ᴮ Ω[ n ] Q Ω[ zero ]-cong-≃ᴮ A≃B = A≃B Ω[ suc n ]-cong-≃ᴮ A≃B = Ω-cong-≃ᴮ (Ω[ n ]-cong-≃ᴮ A≃B) -- ≃ᴮ→→ᴮ commutes with Ω-cong-≃ᴮ/Ω-cong-→ᴮ. ≃ᴮ→→ᴮ-Ω-cong-≃ᴮ : (P≃Q : P ≃ᴮ Q) → ≃ᴮ→→ᴮ (Ω-cong-≃ᴮ P≃Q) ≡ Ω-cong-→ᴮ (≃ᴮ→→ᴮ P≃Q) ≃ᴮ→→ᴮ-Ω-cong-≃ᴮ _ = refl _ -- ≃ᴮ→→ᴮ commutes with Ω[ n ]-cong-≃ᴮ/Ω[ n ]-cong-→ᴮ. ≃ᴮ→→ᴮ-Ω[_]-cong-≃ᴮ : ∀ n → ≃ᴮ→→ᴮ (Ω[ n ]-cong-≃ᴮ P≃Q) ≡ Ω[ n ]-cong-→ᴮ (≃ᴮ→→ᴮ P≃Q) ≃ᴮ→→ᴮ-Ω[_]-cong-≃ᴮ {P≃Q = P≃Q} = λ where zero → refl _ (suc n) → ≃ᴮ→→ᴮ (Ω-cong-≃ᴮ (Ω[ n ]-cong-≃ᴮ P≃Q)) ≡⟨⟩ Ω-cong-→ᴮ (≃ᴮ→→ᴮ (Ω[ n ]-cong-≃ᴮ P≃Q)) ≡⟨ cong Ω-cong-→ᴮ ≃ᴮ→→ᴮ-Ω[ n ]-cong-≃ᴮ ⟩ Ω-cong-→ᴮ (Ω[ n ]-cong-→ᴮ (≃ᴮ→→ᴮ P≃Q)) ∎ -- A lemma relating Ω-cong-→ᴮ and ↝ᴮ-refl. proj₁-Ω-cong-→ᴮ-↝ᴮ-refl : proj₁ (Ω-cong-→ᴮ ↝ᴮ-refl) p ≡ p proj₁-Ω-cong-→ᴮ-↝ᴮ-refl {p = p} = ≡⇒→ (cong₂ _≡_ (cong (_$ _) (refl _)) (cong (_$ _) (refl _))) (cong id p) ≡⟨ cong₂ ≡⇒→ (trans (cong₂ (cong₂ _≡_) (cong-refl _) (cong-refl _)) $ cong₂-refl _≡_) (sym $ cong-id _) ⟩ ≡⇒→ (refl _) p ≡⟨ cong (_$ _) ≡⇒→-refl ⟩∎ p ∎ -- A lemma relating Ω-cong-≃ᴮ and ↝ᴮ-refl. proj₁-Ω-cong-≃ᴮ-↝ᴮ-refl : _≃_.to (proj₁ (Ω-cong-≃ᴮ ↝ᴮ-refl)) p ≡ p proj₁-Ω-cong-≃ᴮ-↝ᴮ-refl = proj₁-Ω-cong-→ᴮ-↝ᴮ-refl -- A lemma relating Ω-cong-→ᴮ and trans. Ω-cong-→ᴮ-trans : proj₁ (Ω-cong-→ᴮ P→Q) (trans p q) ≡ trans (proj₁ (Ω-cong-→ᴮ P→Q) p) (proj₁ (Ω-cong-→ᴮ P→Q) q) Ω-cong-→ᴮ-trans {P→Q = to , to≡} {p = p} {q = q} = ≡⇒→ (cong₂ _≡_ to≡ to≡) (cong to (trans p q)) ≡⟨ cong (≡⇒→ (cong₂ _≡_ to≡ to≡)) $ cong-trans _ _ _ ⟩ ≡⇒→ (cong₂ _≡_ to≡ to≡) (trans (cong to p) (cong to q)) ≡⟨ lemma _ ⟩ trans (trans (sym to≡) (trans (cong to p) (cong to q))) to≡ ≡⟨ trans (cong (flip trans _) $ sym $ trans-assoc _ _ _) $ trans-assoc _ _ _ ⟩ trans (trans (sym to≡) (cong to p)) (trans (cong to q) to≡) ≡⟨ cong (trans _) $ sym $ trans--[trans-sym] _ _ ⟩ trans (trans (sym to≡) (cong to p)) (trans to≡ (trans (sym to≡) (trans (cong to q) to≡))) ≡⟨ trans (cong (trans _) $ cong (trans _) $ sym $ trans-assoc _ _ _) $ sym $ trans-assoc _ _ _ ⟩ trans (trans (trans (sym to≡) (cong to p)) to≡) (trans (trans (sym to≡) (cong to q)) to≡) ≡⟨ sym $ cong₂ trans (lemma _) (lemma _) ⟩∎ trans (≡⇒→ (cong₂ _≡_ to≡ to≡) (cong to p)) (≡⇒→ (cong₂ _≡_ to≡ to≡) (cong to q)) ∎ where lemma = λ p → ≡⇒→ (cong₂ _≡_ to≡ to≡) p ≡⟨⟩ ≡⇒→ (trans (cong (_≡ _) to≡) (cong (_ ≡_) to≡)) p ≡⟨ cong (_$ p) $ ≡⇒↝-trans equivalence ⟩ ≡⇒→ (cong (_ ≡_) to≡) (≡⇒→ (cong (_≡ _) to≡) p) ≡⟨ sym $ subst-in-terms-of-≡⇒↝ equivalence _ _ _ ⟩ subst (_ ≡_) to≡ (≡⇒→ (cong (_≡ _) to≡) p) ≡⟨ sym trans-subst ⟩ trans (≡⇒→ (cong (_≡ _) to≡) p) to≡ ≡⟨ cong (flip trans _) $ sym $ subst-in-terms-of-≡⇒↝ equivalence _ _ _ ⟩ trans (subst (_≡ _) to≡ p) to≡ ≡⟨ cong (flip trans _) subst-trans-sym ⟩∎ trans (trans (sym to≡) p) to≡ ∎ -- A lemma relating Ω-cong-≃ᴮ and trans. Ω-cong-≃ᴮ-trans : (P≃Q : P ≃ᴮ Q) → _≃_.to (proj₁ (Ω-cong-≃ᴮ P≃Q)) (trans p q) ≡ trans (_≃_.to (proj₁ (Ω-cong-≃ᴮ P≃Q)) p) (_≃_.to (proj₁ (Ω-cong-≃ᴮ P≃Q)) q) Ω-cong-≃ᴮ-trans _ = Ω-cong-→ᴮ-trans -- A lemma relating Ω[_]-cong-→ᴮ and trans. Ω[1+_]-cong-→ᴮ-trans : ∀ n {p q} → proj₁ (Ω[ 1 + n ]-cong-→ᴮ P→Q) (trans p q) ≡ trans (proj₁ (Ω[ 1 + n ]-cong-→ᴮ P→Q) p) (proj₁ (Ω[ 1 + n ]-cong-→ᴮ P→Q) q) Ω[1+ _ ]-cong-→ᴮ-trans = Ω-cong-→ᴮ-trans -- A lemma relating Ω[_]-cong-≃ᴮ and trans. Ω[1+_]-cong-≃ᴮ-trans : ∀ n {p q} (P≃Q : P ≃ᴮ Q) → _≃_.to (proj₁ (Ω[ 1 + n ]-cong-≃ᴮ P≃Q)) (trans p q) ≡ trans (_≃_.to (proj₁ (Ω[ 1 + n ]-cong-≃ᴮ P≃Q)) p) (_≃_.to (proj₁ (Ω[ 1 + n ]-cong-≃ᴮ P≃Q)) q) Ω[1+ n ]-cong-≃ᴮ-trans P≃Q = Ω-cong-≃ᴮ-trans (Ω[ n ]-cong-≃ᴮ P≃Q) -- A has h-level 1 + n iff the iterated loop space Ω[ n ] (A , x) is -- contractible for every x : A. +⇔∀contractible-Ω[] : ∀ n → H-level (1 + n) A ⇔ ((x : A) → Contractible (proj₁ $ Ω[ n ] (A , x))) +⇔∀contractible-Ω[] {A = A} zero = Is-proposition A ↝⟨ record { to = propositional⇒inhabited⇒contractible ; from = [inhabited⇒contractible]⇒propositional } ⟩□ (A → Contractible A) □ +⇔∀contractible-Ω[] {A = A} (suc zero) = Is-set A ↝⟨ 2+⇔∀1+≡ 0 ⟩ ((x : A) → Is-proposition (x ≡ x)) ↝⟨ (∀-cong _ λ x → record { to = flip propositional⇒inhabited⇒contractible (refl x) ; from = mono₁ 0 }) ⟩□ ((x : A) → Contractible (x ≡ x)) □ +⇔∀contractible-Ω[] {A = A} (suc (suc n)) = H-level (3 + n) A ↝⟨ 2+⇔∀1+≡ (1 + n) ⟩ ((x : A) → H-level (2 + n) (x ≡ x)) ↝⟨ (∀-cong _ λ _ → +⇔∀contractible-Ω[] (suc n)) ⟩ ((x : A) (p : x ≡ x) → Contractible (proj₁ $ Ω[ 1 + n ] ((x ≡ x) , p))) ↝⟨ (∀-cong _ λ _ → ∀-cong _ λ _ → H-level-cong _ _ $ proj₁ $ Ω[ 1 + n ]-cong-≃ᴮ $ lemma _) ⟩ ((x : A) → x ≡ x → Contractible (proj₁ $ Ω[ 1 + n ] (Ω (A , x)))) ↝⟨ (∀-cong _ λ x → _↠_.logical-equivalence $ inhabited→↠ (refl x)) ⟩ ((x : A) → Contractible (proj₁ $ Ω[ 1 + n ] (Ω (A , x)))) ↝⟨ (∀-cong _ λ _ → ≡⇒↝ _ $ cong (Contractible ∘ proj₁) $ sym $ Ω∘Ω[]≡Ω[]∘Ω (1 + n)) ⟩□ ((x : A) → Contractible (proj₁ $ Ω[ 2 + n ] (A , x))) □ where lemma : (p : x ≡ x) → ((x ≡ x) , p) ≃ᴮ Ω (A , x) lemma p = E.↔⇒≃ (inverse $ flip-trans-isomorphism p) , (trans p (sym p) ≡⟨ trans-symʳ _ ⟩∎ refl _ ∎) ------------------------------------------------------------------------ -- Products -- The product of two pointed types. infixr 2 _×_ _×_ : Pointed-type a → Pointed-type b → Pointed-type (a ⊔ b) (A , x) × (B , y) = (A P.× B) , (x , y) -- The first projection. proj₁ᴾ : (P × Q) →ᴮ P proj₁ᴾ = proj₁ , refl _ -- The second projection. proj₂ᴾ : (P × Q) →ᴮ Q proj₂ᴾ = proj₂ , refl _ -- The operator _×_ preserves based maps and equivalences. infixr 2 _×-cong-→ᴮ_ _×-cong-≃ᴮ_ _×-cong-→ᴮ_ : P₁ →ᴮ P₂ → Q₁ →ᴮ Q₂ → (P₁ × Q₁) →ᴮ (P₂ × Q₂) (f₁ , eq₁) ×-cong-→ᴮ (f₂ , eq₂) = (f₁ ×-cong f₂) , cong₂ _,_ eq₁ eq₂ _×-cong-≃ᴮ_ : P₁ ≃ᴮ P₂ → Q₁ ≃ᴮ Q₂ → (P₁ × Q₁) ≃ᴮ (P₂ × Q₂) (f₁ , eq₁) ×-cong-≃ᴮ (f₂ , eq₂) = (f₁ ×-cong f₂) , cong₂ _,_ eq₁ eq₂ -- Ω commutes with _×_. Ω-× : Ω (P × Q) ≃ᴮ (Ω P × Ω Q) Ω-× {P = A , x} {Q = B , y} = ((x , y) ≡ (x , y) ↝⟨ E.↔⇒≃ (inverse ≡×≡↔≡) ⟩□ x ≡ x P.× y ≡ y □) , ((cong proj₁ (refl (x , y)) , cong proj₂ (refl (x , y))) ≡⟨ cong₂ _,_ (cong-refl _) (cong-refl _) ⟩∎ (refl x , refl y) ∎) -- Ω[ n ] commutes with _×_. Ω[_]-× : ∀ n → Ω[ n ] (P × Q) ≃ᴮ (Ω[ n ] P × Ω[ n ] Q) Ω[_]-× {P = P} {Q = Q} = λ where zero → P × Q □ᴮ (suc n) → Ω (Ω[ n ] (P × Q)) ↝ᴮ⟨ Ω-cong-≃ᴮ Ω[ n ]-× ⟩ Ω (Ω[ n ] P × Ω[ n ] Q) ↝ᴮ⟨ Ω-× ⟩□ Ω (Ω[ n ] P) × Ω (Ω[ n ] Q) □ -- A lemma relating Ω[ 1 ]-× and Ω-×. Ω[1]-× : _≃_.to (proj₁ Ω[ 1 ]-×) p ≡ _≃_.to (proj₁ Ω-×) p Ω[1]-× {p = p} = _≃_.to (proj₁ Ω[ 1 ]-×) p ≡⟨⟩ _≃_.to (proj₁ Ω-×) (_≃_.to (proj₁ (Ω-cong-≃ᴮ ↝ᴮ-refl)) p) ≡⟨ cong (_≃_.to (proj₁ Ω-×)) proj₁-Ω-cong-≃ᴮ-↝ᴮ-refl ⟩∎ _≃_.to (proj₁ Ω-×) p ∎ -- A lemma relating Ω-× and trans. Ω-×-trans : _≃_.to (proj₁ Ω-×) (trans p q) ≡ Σ-zip trans trans (_≃_.to (proj₁ Ω-×) p) (_≃_.to (proj₁ Ω-×) q) Ω-×-trans {p = p} {q = q} = _≃_.to (proj₁ Ω-×) (trans p q) ≡⟨⟩ ( cong proj₁ (trans p q) , cong proj₂ (trans p q) ) ≡⟨ cong₂ _,_ (cong-trans _ _ _) (cong-trans _ _ _) ⟩ ( trans (cong proj₁ p) (cong proj₁ q) , trans (cong proj₂ p) (cong proj₂ q) ) ≡⟨⟩ Σ-zip trans trans (_≃_.to (proj₁ Ω-×) p) (_≃_.to (proj₁ Ω-×) q) ∎ -- A lemma relating Ω[_]-× and trans. Ω[1+_]-×-trans : ∀ n {p q : proj₁ (Ω[ suc n ] (P × Q))} → _≃_.to (proj₁ Ω[ suc n ]-×) (trans p q) ≡ Σ-zip trans trans (_≃_.to (proj₁ Ω[ suc n ]-×) p) (_≃_.to (proj₁ Ω[ suc n ]-×) q) Ω[1+ n ]-×-trans {p = p} {q = q} = _≃_.to (proj₁ Ω-×) (_≃_.to (proj₁ (Ω-cong-≃ᴮ Ω[ n ]-×)) (trans p q)) ≡⟨ cong (_≃_.to (proj₁ Ω-×)) $ Ω-cong-≃ᴮ-trans Ω[ n ]-× ⟩ _≃_.to (proj₁ Ω-×) (trans (_≃_.to (proj₁ (Ω-cong-≃ᴮ Ω[ n ]-×)) p) (_≃_.to (proj₁ (Ω-cong-≃ᴮ Ω[ n ]-×)) q)) ≡⟨ Ω-×-trans ⟩∎ Σ-zip trans trans (_≃_.to (proj₁ Ω-×) (_≃_.to (proj₁ (Ω-cong-≃ᴮ Ω[ n ]-×)) p)) (_≃_.to (proj₁ Ω-×) (_≃_.to (proj₁ (Ω-cong-≃ᴮ Ω[ n ]-×)) q)) ∎
{ "alphanum_fraction": 0.4085598612, "avg_line_length": 33.7037037037, "ext": "agda", "hexsha": "b60c9ec329a75956d725274afc3d3a00360a85fd", "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/Pointed-type.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/Pointed-type.agda", "max_line_length": 137, "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/Pointed-type.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": 8134, "size": 17290 }
------------------------------------------------------------------------ -- Parser indices ------------------------------------------------------------------------ module RecursiveDescent.Index where open import Data.Bool open import Data.Product.Record open import Relation.Nullary open import Relation.Binary open import Relation.Binary.PropositionalEquality open import Data.Function ------------------------------------------------------------------------ -- Indices to the parser type -- Does the parser accept empty strings? Empty : Set Empty = Bool -- The proper left corners of the parser, represented as a tree. See -- the definition of RecursiveDescent.(Coi|I)nductive.Internal.Parser. data Corners : Set where leaf : Corners step : Corners -> Corners node : Corners -> Corners -> Corners Index : Set Index = Empty × Corners -- The parser type signature. The second argument is the result type. ParserType : Set1 ParserType = Index -> Set -> Set ParserType₁ : Set2 ParserType₁ = Index -> Set -> Set1 ------------------------------------------------------------------------ -- Operations on indices infixr 50 _·I_ infixr 40 _∣I_ 0I : Index 0I = (false , leaf) 1I : Index 1I = (true , leaf) _∣I_ : Index -> Index -> Index i₁ ∣I i₂ = (proj₁ i₁ ∨ proj₁ i₂ , node (proj₂ i₁) (proj₂ i₂)) _·I_ : Index -> Index -> Index i₁ ·I i₂ = ( proj₁ i₁ ∧ proj₁ i₂ , (if proj₁ i₁ then node (proj₂ i₁) (proj₂ i₂) else step (proj₂ i₁)) ) ------------------------------------------------------------------------ -- Testing indices for equality infix 15 _Index-≟_ _Corners-≟_ private drop-step : forall {c₁ c₂} -> step c₁ ≡ step c₂ -> c₁ ≡ c₂ drop-step refl = refl drop-node₁ : forall {c₁ c₂ c₃ c₄} -> node c₁ c₂ ≡ node c₃ c₄ -> c₁ ≡ c₃ drop-node₁ refl = refl drop-node₂ : forall {c₁ c₂ c₃ c₄} -> node c₁ c₂ ≡ node c₃ c₄ -> c₂ ≡ c₄ drop-node₂ refl = refl _Corners-≟_ : Decidable {Corners} _≡_ leaf Corners-≟ leaf = yes refl step c₁ Corners-≟ step c₂ with c₁ Corners-≟ c₂ step c₁ Corners-≟ step .c₁ | yes refl = yes refl step c₁ Corners-≟ step c₂ | no ¬c₁≡c₂ = no (¬c₁≡c₂ ∘ drop-step) node c₁ c₂ Corners-≟ node c₃ c₄ with c₁ Corners-≟ c₃ | c₂ Corners-≟ c₄ node c₁ c₂ Corners-≟ node .c₁ .c₂ | yes refl | yes refl = yes refl node c₁ c₂ Corners-≟ node c₃ c₄ | no ¬c₁≡c₂ | _ = no (¬c₁≡c₂ ∘ drop-node₁) node c₁ c₂ Corners-≟ node c₃ c₄ | _ | no ¬c₁≡c₂ = no (¬c₁≡c₂ ∘ drop-node₂) leaf Corners-≟ step _ = no \() leaf Corners-≟ node _ _ = no \() step _ Corners-≟ leaf = no \() step _ Corners-≟ node _ _ = no \() node _ _ Corners-≟ leaf = no \() node _ _ Corners-≟ step _ = no \() _Index-≟_ : Decidable {Index} _≡_ i₁ Index-≟ i₂ with proj₁ i₁ ≟ proj₁ i₂ | proj₂ i₁ Corners-≟ proj₂ i₂ ... | yes e₁≡e₂ | yes c₁≡c₂ = yes (cong₂ (_,_) e₁≡e₂ c₁≡c₂) ... | no ¬e₁≡e₂ | _ = no (¬e₁≡e₂ ∘ cong proj₁) ... | _ | no ¬c₁≡c₂ = no (¬c₁≡c₂ ∘ cong proj₂)
{ "alphanum_fraction": 0.5322997416, "avg_line_length": 30.3529411765, "ext": "agda", "hexsha": "2c5988d58da2151ec60fe433779ee8852f59a8f3", "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": "misc/RecursiveDescent/Index.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": "2018-01-24T16:39:37.000Z", "max_issues_repo_issues_event_min_datetime": "2018-01-22T22:21:41.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "misc/RecursiveDescent/Index.agda", "max_line_length": 86, "max_stars_count": 7, "max_stars_repo_head_hexsha": "b396d35cc2cb7e8aea50b982429ee385f001aa88", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yurrriq/parser-combinators", "max_stars_repo_path": "misc/RecursiveDescent/Index.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-22T05:35:31.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-13T05:23:14.000Z", "num_tokens": 1044, "size": 3096 }
{-# OPTIONS --rewriting --without-K #-} open import Agda.Primitive open import Prelude open import GSeTT.Syntax open import GSeTT.Rules {- Decidability of type cheking for the type theory for globular sets -} module GSeTT.Dec-Type-Checking where dec-⊢C : ∀ Γ → dec (Γ ⊢C) dec-⊢T : ∀ Γ A → dec (Γ ⊢T A) dec-⊢t : ∀ Γ A t → dec (Γ ⊢t t # A) dec-⊢S : ∀ Δ Γ γ → dec (Δ ⊢S γ > Γ) private Γ+⊢→Γ⊢ : ∀ {Γ x A} → (Γ :: (x , A)) ⊢C → Γ ⊢C Γ+⊢→Γ⊢ (cc Γ⊢ _ idp) = Γ⊢ Γ+⊢→x=l : ∀ {Γ x A} → (Γ :: (x , A)) ⊢C → x == length Γ Γ+⊢→x=l (cc _ _ idp) = idp Γ+⊢→Γ⊢A : ∀ {Γ x A} → (Γ :: (x , A)) ⊢C → Γ ⊢T A Γ+⊢→Γ⊢A (cc _ Γ⊢A _) = Γ⊢A Γ⊢t⇒u→Γ⊢A : ∀ {Γ A t u} → Γ ⊢T ⇒ A t u → Γ ⊢T A Γ⊢t⇒u→Γ⊢A (ar Γ⊢t:A Γ⊢u:A) = Γ⊢t:A→Γ⊢A Γ⊢t:A Γ⊢t⇒u→Γ⊢t : ∀ {Γ A t u} → Γ ⊢T ⇒ A t u → Γ ⊢t t # A Γ⊢t⇒u→Γ⊢t (ar Γ⊢t:A Γ⊢u:A) = Γ⊢t:A Γ⊢t⇒u→Γ⊢u : ∀ {Γ A t u} → Γ ⊢T ⇒ A t u → Γ ⊢t u # A Γ⊢t⇒u→Γ⊢u (ar Γ⊢t:A Γ⊢u:A) = Γ⊢u:A Γ⊢x:A→x∈Γ : ∀ {Γ x A} → Γ ⊢t Var x # A → x # A ∈ Γ Γ⊢x:A→x∈Γ (var _ x∈Γ) = x∈Γ Δ⊢<>:Γ→Γ=nil : ∀ {Δ Γ} → Δ ⊢S nil > Γ → Γ == nil Δ⊢<>:Γ→Γ=nil (es _) = idp Δ⊢γ:⊘→γ=nil : ∀ {Δ γ} → Δ ⊢S γ > nil → γ == nil Δ⊢γ:⊘→γ=nil (es _) = idp Δ⊢γ+:Γ+→x=y : ∀ {Δ Γ x A γ y t} → Δ ⊢S (γ :: (y , t)) > (Γ :: (x , A)) → x == y Δ⊢γ+:Γ+→x=y (sc _ _ _ idp) = idp Δ⊢γ+:Γ+→Δ⊢t : ∀ {Δ Γ x A γ y t} → Δ ⊢S (γ :: (y , t)) > (Γ :: (x , A)) → Δ ⊢t t # (A [ γ ]Pre-Ty) Δ⊢γ+:Γ+→Δ⊢t (sc _ _ Δ⊢t idp) = Δ⊢t Δ⊢γ+:Γ+→Δ⊢γ : ∀ {Δ Γ x A γ y t} → Δ ⊢S (γ :: (y , t)) > (Γ :: (x , A)) → Δ ⊢S γ > Γ Δ⊢γ+:Γ+→Δ⊢γ (sc Δ⊢γ:Γ _ _ idp) = Δ⊢γ:Γ eqdec-Ty : eqdec Pre-Ty eqdec-Tm : eqdec Pre-Tm eqdec-Ty ∗ ∗ = inl idp eqdec-Ty ∗ (⇒ _ _ _) = inr λ{()} eqdec-Ty (⇒ _ _ _) ∗ = inr λ{()} eqdec-Ty (⇒ A t u) (⇒ B t' u') with eqdec-Ty A B | eqdec-Tm t t' | eqdec-Tm u u' ... | inl idp | inl idp | inl idp = inl idp ... | inl idp | inl idp | inr u≠u' = inr λ p → u≠u' (snd (=⇒ p)) ... | inl idp | inr t≠t' | _ = inr λ p → t≠t' (snd (fst (=⇒ p))) ... | inr A≠B | _ | _ = inr λ p → A≠B (fst (fst (=⇒ p))) eqdec-Tm (Var x) (Var y) with eqdecℕ x y ... | inl idp = inl idp ... | inr x≠y = inr λ p → x≠y (=Var p) dec-∈ : ∀ Γ x A → dec (x # A ∈ Γ) dec-∈ nil x A = inr λ x → x dec-∈ (Γ :: (y , B)) x A with (eqdecℕ y x) | (eqdec-Ty B A) ... | inl idp | inl idp = inl (inr (idp , idp)) ... | inl idp | inr B≠A with dec-∈ Γ x A ... | inl x∈Γ = inl (inl x∈Γ) ... | inr x∉Γ = inr λ {(inl x∈Γ) → x∉Γ x∈Γ ; (inr (_ , A=B)) → B≠A (A=B ^)} dec-∈ (Γ :: (y , B)) x A | inr y≠x | _ with dec-∈ Γ x A ... | inl x∈Γ = inl (inl x∈Γ) ... | inr x∉Γ = inr λ{ (inl x∈Γ) → x∉Γ x∈Γ ; (inr (x=y , _)) → y≠x (x=y ^)} dec-⊢C nil = inl ec dec-⊢C (Γ :: (x , A)) with dec-⊢C Γ | eqdecℕ x (length Γ) | dec-⊢T Γ A ... | inl Γ⊢ | inl idp | inl Γ⊢A = inl (cc Γ⊢ Γ⊢A idp) ... | inl _ | inl idp | inr Γ⊬A = inr λ Γ+⊢ → Γ⊬A (Γ+⊢→Γ⊢A Γ+⊢) ... | inl Γ⊢ | inr n≠l | _ = inr λ Γ+⊢ → n≠l (Γ+⊢→x=l Γ+⊢) ... | inr Γ⊬ | _ | _ = inr λ Γ+⊢ → Γ⊬ (Γ+⊢→Γ⊢ Γ+⊢) dec-⊢T Γ ∗ with dec-⊢C Γ ... | inl Γ⊢ = inl (ob Γ⊢) ... | inr Γ⊬ = inr λ Γ⊢* → Γ⊬ (Γ⊢A→Γ⊢ Γ⊢*) dec-⊢T Γ (⇒ A t u) with dec-⊢t Γ A t | dec-⊢t Γ A u ... | inl Γ⊢t:A | inl Γ⊢u:A = inl (ar Γ⊢t:A Γ⊢u:A) ... | inl _ | inr Γ⊬u:A = inr λ Γ⊢t⇒u → Γ⊬u:A (Γ⊢t⇒u→Γ⊢u Γ⊢t⇒u) ... | inr Γ⊬t:A | _ = inr λ Γ⊢t⇒u → Γ⊬t:A (Γ⊢t⇒u→Γ⊢t Γ⊢t⇒u) dec-⊢t Γ A (Var x) with dec-⊢C Γ | dec-∈ Γ x A ... | inl Γ⊢ | inl x∈Γ = inl (var Γ⊢ x∈Γ) ... | inl _ | inr x∉Γ = inr λ Γ⊢x:A → x∉Γ (Γ⊢x:A→x∈Γ Γ⊢x:A) ... | inr Γ⊬ | _ = inr λ Γ⊢x:A → Γ⊬ (Γ⊢t:A→Γ⊢ Γ⊢x:A) dec-⊢S Δ nil nil with dec-⊢C Δ ... | inl Δ⊢ = inl (es Δ⊢) ... | inr Δ⊬ = inr λ Δ⊢<>:⊘ → Δ⊬ (Δ⊢γ:Γ→Δ⊢ Δ⊢<>:⊘) dec-⊢S Δ (Γ :: _) nil = inr λ Δ⊢<>:Γ → cons≠nil (Δ⊢<>:Γ→Γ=nil Δ⊢<>:Γ) dec-⊢S Δ nil (γ :: a) = inr λ Δ⊢γ:⊘ → cons≠nil (Δ⊢γ:⊘→γ=nil Δ⊢γ:⊘) dec-⊢S Δ (Γ :: (x , A)) (γ :: (y , t)) with dec-⊢S Δ Γ γ | dec-⊢C (Γ :: (x , A)) | dec-⊢t Δ (A [ γ ]Pre-Ty) t | eqdecℕ x y ... | inl Δ⊢γ:Γ | inl Γ+⊢ | inl Δ⊢t | inl idp = inl (sc Δ⊢γ:Γ Γ+⊢ Δ⊢t idp) ... | inl _ | inl _ | inl _ | inr x≠y = inr λ Δ⊢γ+:Γ+ → x≠y (Δ⊢γ+:Γ+→x=y Δ⊢γ+:Γ+) ... | inl _ | inl _ | inr Δ⊬t | _ = inr λ Δ⊢γ+:Γ+ → Δ⊬t (Δ⊢γ+:Γ+→Δ⊢t Δ⊢γ+:Γ+) ... | inl _ | inr Γ+⊬ | _ | _ = inr λ Δ⊢γ+:Γ+ → Γ+⊬ (Δ⊢γ:Γ→Γ⊢ Δ⊢γ+:Γ+) ... | inr Δ⊬γ | _ | _ | _ = inr λ Δ⊢γ+:Γ+ → Δ⊬γ (Δ⊢γ+:Γ+→Δ⊢γ Δ⊢γ+:Γ+)
{ "alphanum_fraction": 0.3117850953, "avg_line_length": 51.981981982, "ext": "agda", "hexsha": "522047ed567b63da5df3fa8f97311b93b30ee859", "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": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thibautbenjamin/catt-formalization", "max_forks_repo_path": "GSeTT/Dec-Type-Checking.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "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": "thibautbenjamin/catt-formalization", "max_issues_repo_path": "GSeTT/Dec-Type-Checking.agda", "max_line_length": 168, "max_stars_count": null, "max_stars_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thibautbenjamin/catt-formalization", "max_stars_repo_path": "GSeTT/Dec-Type-Checking.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3048, "size": 5770 }
{-# OPTIONS --without-K --safe #-} -- here we define the structure version of a cartesian category module Categories.Category.Cartesian.Structure where open import Level open import Categories.Category open import Categories.Category.Cartesian open import Categories.Category.Monoidal record CartesianCategory o ℓ e : Set (suc (o ⊔ ℓ ⊔ e)) where field U : Category o ℓ e -- U for underlying cartesian : Cartesian U module U = Category U module cartesian = Cartesian cartesian open U public open cartesian public monoidalCategory : MonoidalCategory o ℓ e monoidalCategory = record { U = U ; monoidal = monoidal }
{ "alphanum_fraction": 0.7130044843, "avg_line_length": 23.8928571429, "ext": "agda", "hexsha": "acf4eb1f902106c8d6c027f237e9606a65e16ffc", "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": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-categories", "max_forks_repo_path": "src/Categories/Category/Cartesian/Structure.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "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": "bblfish/agda-categories", "max_issues_repo_path": "src/Categories/Category/Cartesian/Structure.agda", "max_line_length": 63, "max_stars_count": 5, "max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bblfish/agda-categories", "max_stars_repo_path": "src/Categories/Category/Cartesian/Structure.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": 161, "size": 669 }
module ClashingModuleImport where X = TODO--I-haven't-fully-understood-this-one
{ "alphanum_fraction": 0.8024691358, "avg_line_length": 20.25, "ext": "agda", "hexsha": "52abbf0a3954df8b86bbb3346ce596121de683bd", "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/fail/ClashingModuleImport.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/ClashingModuleImport.agda", "max_line_length": 45, "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/ClashingModuleImport.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": 22, "size": 81 }
------------------------------------------------------------------------ -- Full β-reduction in Fω with interval kinds ------------------------------------------------------------------------ {-# OPTIONS --safe --without-K #-} module FOmegaInt.Reduction.Full where open import Data.Fin using (suc; zero) open import Data.Fin.Substitution open import Data.Fin.Substitution.ExtraLemmas open import Data.List using ([]; _∷_) open import Data.Sum using ([_,_]) open import Data.Product using (_,_; ∃; _×_) open import Function using (flip; _∘_) open import Relation.Binary using (Setoid; Preorder) import Relation.Binary.Construct.Closure.Equivalence as EqClos open import Relation.Binary.Construct.Closure.ReflexiveTransitive using (ε; _◅_; gmap) import Relation.Binary.Construct.Closure.Symmetric as SymClos open import Relation.Binary.PropositionalEquality as P using (_≡_; refl) open import Relation.Binary.Reduction import Function.Equivalence as Equiv open import FOmegaInt.Syntax open Syntax open Substitution using (_[_]; weaken) ---------------------------------------------------------------------- -- Full β-reduction and equality relations infixl 9 _·₁_ _·₂_ _⊡₁_ _⊡₂_ infixr 7 _⇒₁_ _⇒₂_ infix 6 _⋯₁_ _⋯₂_ infix 5 _→β_ _Kd→β_ mutual -- The compatible closure of a binary term relation. data Compat (_∼_ : TRel Term) {n} : Term n → Term n → Set where ⌈_⌉ : ∀ {a₁ a₂} → a₁ ∼ a₂ → Compat _∼_ a₁ a₂ Π₁ : ∀ {k₁ k₂} → KdCompat _∼_ k₁ k₂ → ∀ a → Compat _∼_ (Π k₁ a) (Π k₂ a) Π₂ : ∀ {a₁ a₂} k → Compat _∼_ a₁ a₂ → Compat _∼_ (Π k a₁) (Π k a₂) _⇒₁_ : ∀ {a₁ a₂} → Compat _∼_ a₁ a₂ → ∀ b → Compat _∼_ (a₁ ⇒ b) (a₂ ⇒ b) _⇒₂_ : ∀ {b₁ b₂} a → Compat _∼_ b₁ b₂ → Compat _∼_ (a ⇒ b₁) (a ⇒ b₂) Λ₁ : ∀ {k₁ k₂} → KdCompat _∼_ k₁ k₂ → ∀ a → Compat _∼_ (Λ k₁ a) (Λ k₂ a) Λ₂ : ∀ {a₁ a₂} k → Compat _∼_ a₁ a₂ → Compat _∼_ (Λ k a₁) (Λ k a₂) ƛ₁ : ∀ {a₁ a₂} → Compat _∼_ a₁ a₂ → ∀ b → Compat _∼_ (ƛ a₁ b) (ƛ a₂ b) ƛ₂ : ∀ {b₁ b₂} a → Compat _∼_ b₁ b₂ → Compat _∼_ (ƛ a b₁) (ƛ a b₂) _·₁_ : ∀ {a₁ a₂} → Compat _∼_ a₁ a₂ → ∀ b → Compat _∼_ (a₁ · b) (a₂ · b) _·₂_ : ∀ {b₁ b₂} a → Compat _∼_ b₁ b₂ → Compat _∼_ (a · b₁) (a · b₂) _⊡₁_ : ∀ {a₁ a₂} → Compat _∼_ a₁ a₂ → ∀ b → Compat _∼_ (a₁ ⊡ b) (a₂ ⊡ b) _⊡₂_ : ∀ {b₁ b₂} a → Compat _∼_ b₁ b₂ → Compat _∼_ (a ⊡ b₁) (a ⊡ b₂) data KdCompat (_∼_ : TRel Term) {n} : Kind Term n → Kind Term n → Set where _⋯₁_ : ∀ {a₁ a₂} → Compat _∼_ a₁ a₂ → ∀ b → KdCompat _∼_ (a₁ ⋯ b) (a₂ ⋯ b) _⋯₂_ : ∀ {b₁ b₂} a → Compat _∼_ b₁ b₂ → KdCompat _∼_ (a ⋯ b₁) (a ⋯ b₂) Π₁ : ∀ {j₁ j₂} → KdCompat _∼_ j₁ j₂ → ∀ b → KdCompat _∼_ (Π j₁ b) (Π j₂ b) Π₂ : ∀ {k₁ k₂} k → KdCompat _∼_ k₁ k₂ → KdCompat _∼_ (Π k k₁) (Π k k₂) -- β-contraction. data BetaCont {n} : Term n → Term n → Set where cont-Tp· : ∀ k a b → BetaCont ((Λ k a) · b) (a [ b ]) cont-Tm· : ∀ a b c → BetaCont ((ƛ a b) · c) (b [ c ]) cont-⊡ : ∀ k a b → BetaCont ((Λ k a) ⊡ b) (a [ b ]) -- One-step β-reduction. _→β_ : TRel Term _→β_ = Compat BetaCont _Kd→β_ : TRel (Kind Term) _Kd→β_ = KdCompat BetaCont -- Full β-reduction and equality. β-reduction : Reduction Term β-reduction = record { _→1_ = _→β_ } β-reductionKind : Reduction (Kind Term) β-reductionKind = record { _→1_ = _Kd→β_ } open Reduction β-reduction public hiding (_→1_) renaming (_→*_ to _→β*_; _↔_ to _≡β_) open Reduction β-reductionKind public hiding (_→1_) renaming (_→*_ to _Kd→β*_; _↔_ to _Kd≡β_) ---------------------------------------------------------------------- -- Simple properties of the β-reductions/equalities -- Inclusions. →β⇒→β* = →1⇒→* β-reduction →β*⇒≡β = →*⇒↔ β-reduction →β⇒≡β = →1⇒↔ β-reduction -- Reduction is a preorders. →β*-preorder = →*-preorder β-reduction Kd→β*-preorder = →*-preorder β-reductionKind -- Preorder reasoning for reduction. module →β*-Reasoning = →*-Reasoning β-reduction module Kd→β*-Reasoning = →*-Reasoning β-reductionKind -- Raw terms and kinds together with β-equality form setoids. ≡β-setoid = ↔-setoid β-reduction Kd≡β-setoid = ↔-setoid β-reductionKind -- Equational reasoning for the equality. module ≡β-Reasoning = ↔-Reasoning β-reduction module Kd≡β-Reasoning = ↔-Reasoning β-reductionKind -- Multistep and equality congruence lemmas. module CongLemmas (_∼_ : TRel Term) where private reduction : Reduction Term reduction = record { _→1_ = Compat _∼_ } reductionKd : Reduction (Kind Term) reductionKd = record { _→1_ = KdCompat _∼_ } module O {n} = Preorder (→*-preorder reduction n) module S {n} = Setoid (↔-setoid reduction n) module OK {n} = Preorder (→*-preorder reductionKd n) module SK {n} = Setoid (↔-setoid reductionKd n) open Reduction reduction open Reduction reductionKd using () renaming (_→*_ to _Kd→*_; _↔_ to _Kd↔_) -- A Congruence lemma for _⌞∙⌟_. →1-⌞∙⌟₁ : ∀ {n} {a₁ a₂ : Term n} → a₁ →1 a₂ → ∀ bs → a₁ ⌞∙⌟ bs →1 a₂ ⌞∙⌟ bs →1-⌞∙⌟₁ a₁∼a₂ [] = a₁∼a₂ →1-⌞∙⌟₁ a₁∼a₂ (b ∷ bs) = →1-⌞∙⌟₁ (a₁∼a₂ ·₁ b) bs -- Multistep congruence lemmas for transitive closures. →*-Π : ∀ {n} {k₁ k₂ : Kind Term n} {a₁ a₂} → k₁ Kd→* k₂ → a₁ →* a₂ → Π k₁ a₁ →* Π k₂ a₂ →*-Π {a₁ = a₁} k₁→*k₂ a₁→*a₂ = O.trans (gmap (flip Π a₁) (λ j→k → Π₁ j→k a₁) k₁→*k₂) (gmap (Π _) (Π₂ _) a₁→*a₂) →*-⇒ : ∀ {n} {a₁ a₂ : Term n} {b₁ b₂} → a₁ →* a₂ → b₁ →* b₂ → a₁ ⇒ b₁ →* a₂ ⇒ b₂ →*-⇒ {b₁ = b₁} a₁→*a₂ b₁→*b₂ = O.trans (gmap (_⇒ b₁) (_⇒₁ b₁) a₁→*a₂) (gmap (_ ⇒_) (_ ⇒₂_) b₁→*b₂) →*-Λ : ∀ {n} {k₁ k₂ : Kind Term n} {a₁ a₂} → k₁ Kd→* k₂ → a₁ →* a₂ → Λ k₁ a₁ →* Λ k₂ a₂ →*-Λ {a₁ = a₁} k₁→*k₂ a₁→*a₂ = O.trans (gmap (flip Λ a₁) (λ j→k → Λ₁ j→k a₁) k₁→*k₂) (gmap (Λ _) (Λ₂ _) a₁→*a₂) →*-ƛ : ∀ {n} {a₁ a₂ : Term n} {b₁ b₂} → a₁ →* a₂ → b₁ →* b₂ → ƛ a₁ b₁ →* ƛ a₂ b₂ →*-ƛ {b₁ = b₁} a₁→*a₂ b₁→*b₂ = O.trans (gmap (flip ƛ b₁) (flip ƛ₁ b₁) a₁→*a₂) (gmap (ƛ _) (ƛ₂ _) b₁→*b₂) →*-· : ∀ {n} {a₁ a₂ : Term n} {b₁ b₂} → a₁ →* a₂ → b₁ →* b₂ → a₁ · b₁ →* a₂ · b₂ →*-· {b₁ = b₁} a₁→*a₂ b₁→*b₂ = O.trans (gmap (_· b₁) (_·₁ b₁) a₁→*a₂) (gmap (_ ·_) (_ ·₂_) b₁→*b₂) →*-⊡ : ∀ {n} {a₁ a₂ : Term n} {b₁ b₂} → a₁ →* a₂ → b₁ →* b₂ → a₁ ⊡ b₁ →* a₂ ⊡ b₂ →*-⊡ {b₁ = b₁} a₁→*a₂ b₁→*b₂ = O.trans (gmap (_⊡ b₁) (_⊡₁ b₁) a₁→*a₂) (gmap (_ ⊡_) (_ ⊡₂_) b₁→*b₂) Kd→*-⋯ : ∀ {n} {a₁ a₂ : Term n} {b₁ b₂} → a₁ →* a₂ → b₁ →* b₂ → a₁ ⋯ b₁ Kd→* a₂ ⋯ b₂ Kd→*-⋯ {b₁ = b₁} a₁→*a₂ b₁→*b₂ = OK.trans (gmap (_⋯ b₁) (_⋯₁ b₁) a₁→*a₂) (gmap (_ ⋯_) (_ ⋯₂_) b₁→*b₂) Kd→*-Π : ∀ {n} {j₁ j₂ : Kind Term n} {k₁ k₂} → j₁ Kd→* j₂ → k₁ Kd→* k₂ → Π j₁ k₁ Kd→* Π j₂ k₂ Kd→*-Π {k₁ = k₁} j₁→*j₂ k₁→*k₂ = OK.trans (gmap (flip Π k₁) (λ j→k → Π₁ j→k k₁) j₁→*j₂) (gmap (Π _) (Π₂ _) k₁→*k₂) →*-⌞∙⌟₁ : ∀ {n} {a₁ a₂ : Term n} → a₁ →* a₂ → ∀ bs → a₁ ⌞∙⌟ bs →* a₂ ⌞∙⌟ bs →*-⌞∙⌟₁ a₁→*a₂ bs = gmap (_⌞∙⌟ bs) (flip →1-⌞∙⌟₁ bs) a₁→*a₂ -- Congruence lemmas for equivalences closures. ↔-Π : ∀ {n} {k₁ k₂ : Kind Term n} {a₁ a₂} → k₁ Kd↔ k₂ → a₁ ↔ a₂ → Π k₁ a₁ ↔ Π k₂ a₂ ↔-Π {a₁ = a₁} k₁↔k₂ a₁↔a₂ = S.trans (EqClos.gmap (flip Π a₁) (λ j→k → Π₁ j→k a₁) k₁↔k₂) (EqClos.gmap (Π _) (Π₂ _) a₁↔a₂) ↔-⇒ : ∀ {n} {a₁ a₂ : Term n} {b₁ b₂} → a₁ ↔ a₂ → b₁ ↔ b₂ → a₁ ⇒ b₁ ↔ a₂ ⇒ b₂ ↔-⇒ {b₁ = b₁} a₁↔a₂ b₁↔b₂ = S.trans (EqClos.gmap (_⇒ b₁) (_⇒₁ b₁) a₁↔a₂) (EqClos.gmap (_ ⇒_) (_ ⇒₂_) b₁↔b₂) ↔-Λ : ∀ {n} {k₁ k₂ : Kind Term n} {a₁ a₂} → k₁ Kd↔ k₂ → a₁ ↔ a₂ → Λ k₁ a₁ ↔ Λ k₂ a₂ ↔-Λ {a₁ = a₁} k₁↔k₂ a₁↔a₂ = S.trans (EqClos.gmap (flip Λ a₁) (λ j→k → Λ₁ j→k a₁) k₁↔k₂) (EqClos.gmap (Λ _) (Λ₂ _) a₁↔a₂) ↔-ƛ : ∀ {n} {a₁ a₂ : Term n} {b₁ b₂} → a₁ ↔ a₂ → b₁ ↔ b₂ → ƛ a₁ b₁ ↔ ƛ a₂ b₂ ↔-ƛ {b₁ = b₁} a₁↔a₂ b₁↔b₂ = S.trans (EqClos.gmap (flip ƛ b₁) (flip ƛ₁ b₁) a₁↔a₂) (EqClos.gmap (ƛ _) (ƛ₂ _) b₁↔b₂) ↔-· : ∀ {n} {a₁ a₂ : Term n} {b₁ b₂} → a₁ ↔ a₂ → b₁ ↔ b₂ → a₁ · b₁ ↔ a₂ · b₂ ↔-· {b₁ = b₁} a₁↔a₂ b₁↔b₂ = S.trans (EqClos.gmap (_· b₁) (_·₁ b₁) a₁↔a₂) (EqClos.gmap (_ ·_) (_ ·₂_) b₁↔b₂) ↔-⊡ : ∀ {n} {a₁ a₂ : Term n} {b₁ b₂} → a₁ ↔ a₂ → b₁ ↔ b₂ → a₁ ⊡ b₁ ↔ a₂ ⊡ b₂ ↔-⊡ {b₁ = b₁} a₁↔a₂ b₁↔b₂ = S.trans (EqClos.gmap (_⊡ b₁) (_⊡₁ b₁) a₁↔a₂) (EqClos.gmap (_ ⊡_) (_ ⊡₂_) b₁↔b₂) Kd↔-⋯ : ∀ {n} {a₁ a₂ : Term n} {b₁ b₂} → a₁ ↔ a₂ → b₁ ↔ b₂ → a₁ ⋯ b₁ Kd↔ a₂ ⋯ b₂ Kd↔-⋯ {b₁ = b₁} a₁↔a₂ b₁↔b₂ = SK.trans (EqClos.gmap (_⋯ b₁) (_⋯₁ b₁) a₁↔a₂) (EqClos.gmap (_ ⋯_) (_ ⋯₂_) b₁↔b₂) Kd↔-Π : ∀ {n} {j₁ j₂ : Kind Term n} {k₁ k₂} → j₁ Kd↔ j₂ → k₁ Kd↔ k₂ → Π j₁ k₁ Kd↔ Π j₂ k₂ Kd↔-Π {k₁ = k₁} j₁↔j₂ k₁↔k₂ = SK.trans (EqClos.gmap (flip Π k₁) (λ j→k → Π₁ j→k k₁) j₁↔j₂) (EqClos.gmap (Π _) (Π₂ _) k₁↔k₂) ↔-⌞∙⌟₁ : ∀ {n} {a₁ a₂ : Term n} → a₁ ↔ a₂ → ∀ bs → a₁ ⌞∙⌟ bs ↔ a₂ ⌞∙⌟ bs ↔-⌞∙⌟₁ a₁↔a₂ bs = EqClos.gmap (_⌞∙⌟ bs) (flip →1-⌞∙⌟₁ bs) a₁↔a₂ open CongLemmas BetaCont public renaming ( →1-⌞∙⌟₁ to →β-⌞∙⌟₁ ; →*-Π to →β*-Π ; →*-⇒ to →β*-⇒ ; →*-Λ to →β*-Λ ; →*-ƛ to →β*-ƛ ; →*-· to →β*-· ; →*-⊡ to →β*-⊡ ; Kd→*-⋯ to Kd→β*-⋯ ; Kd→*-Π to Kd→β*-Π ; →*-⌞∙⌟₁ to →β*-⌞∙⌟₁ ; ↔-Π to ≡β-Π ; ↔-⇒ to ≡β-⇒ ; ↔-Λ to ≡β-Λ ; ↔-ƛ to ≡β-ƛ ; ↔-· to ≡β-· ; ↔-⊡ to ≡β-⊡ ; Kd↔-⋯ to Kd≡β-⋯ ; Kd↔-Π to Kd≡β-Π ; ↔-⌞∙⌟₁ to ≡β-⌞∙⌟₁ )
{ "alphanum_fraction": 0.4968480773, "avg_line_length": 35.5149253731, "ext": "agda", "hexsha": "c925abaa1c16ef9d5e19b16a1e19826ddbdb9fc2", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-05-14T10:25:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-05-13T22:29:48.000Z", "max_forks_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Blaisorblade/f-omega-int-agda", "max_forks_repo_path": "src/FOmegaInt/Reduction/Full.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_issues_repo_issues_event_max_datetime": "2021-05-14T08:54:39.000Z", "max_issues_repo_issues_event_min_datetime": "2021-05-14T08:09:40.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Blaisorblade/f-omega-int-agda", "max_issues_repo_path": "src/FOmegaInt/Reduction/Full.agda", "max_line_length": 80, "max_stars_count": 12, "max_stars_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Blaisorblade/f-omega-int-agda", "max_stars_repo_path": "src/FOmegaInt/Reduction/Full.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-27T05:53:06.000Z", "max_stars_repo_stars_event_min_datetime": "2017-06-13T16:05:35.000Z", "num_tokens": 4941, "size": 9518 }
{-# OPTIONS --cubical --safe #-} module Cubical.Data.Prod.Base where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function -- If × is defined using Σ then transp/hcomp will be compute -- "negatively", that is, they won't reduce unless we project out the -- first of second component. This is not always what we want so the -- default implementation is done using a datatype which computes -- positively. private variable ℓ ℓ' : Level data _×_ (A : Type ℓ) (B : Type ℓ') : Type (ℓ-max ℓ ℓ') where _,_ : A → B → A × B infixr 5 _×_ proj₁ : {A : Type ℓ} {B : Type ℓ'} → A × B → A proj₁ (x , _) = x proj₂ : {A : Type ℓ} {B : Type ℓ'} → A × B → B proj₂ (_ , x) = x -- We still export the version using Σ _×Σ_ : (A : Type ℓ) (B : Type ℓ') → Type (ℓ-max ℓ ℓ') A ×Σ B = Σ A (λ _ → B) infixr 5 _×Σ_ private variable A : Type ℓ B C : A → Type ℓ intro-× : (∀ a → B a) → (∀ a → C a) → ∀ a → B a × C a intro-× f g a = f a , g a map-× : {B : Type ℓ} {D : B → Type ℓ'} → (∀ a → C a) → (∀ b → D b) → (x : A × B) → C (proj₁ x) × D (proj₂ x) map-× f g = intro-× (f ∘ proj₁) (g ∘ proj₂)
{ "alphanum_fraction": 0.5799828914, "avg_line_length": 24.3541666667, "ext": "agda", "hexsha": "be96b0072e931b42e33bf6086cff753679e8ce85", "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": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/Data/Prod/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "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": "limemloh/cubical", "max_issues_repo_path": "Cubical/Data/Prod/Base.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/Data/Prod/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 456, "size": 1169 }
{-# OPTIONS --safe --no-qualified-instances #-} -- Bytecode; i.e., instruction sequences; -- agnostic about the exact instructions, but opiniated about labels open import Data.List hiding (concat) module JVM.Syntax.Bytecode {ℓ} (T : Set ℓ) (I : T → T → List T → Set ℓ) where open import Level open import Function using (_∘_) open import Data.Unit open import Relation.Unary hiding (_∈_; Empty) open import Relation.Binary.PropositionalEquality open import Relation.Ternary.Data.ReflexiveTransitive as Star open import Relation.Ternary.Core open import Relation.Ternary.Structures open import Relation.Ternary.Structures.Syntax open import Relation.Ternary.Data.Bigplus open import Relation.Ternary.Data.IndexedMonoid open import Data.Sum open import Data.Product open import JVM.Model T open import JVM.Syntax.Labeling T data Code : T → T → Pred Intf ℓ where labeled : ∀ {τ₁ τ₂} → ∀[ Up (Labeling τ₁) ✴ Down (I τ₁ τ₂) ⇒ Code τ₁ τ₂ ] instr : ∀ {τ₁ τ₂} → ∀[ Down (I τ₁ τ₂) ⇒ Code τ₁ τ₂ ] getInstr : ∀ {τ₁ τ₂} → ∀[ Code τ₁ τ₂ ⇒ Down (I τ₁ τ₂) ✴ Code τ₁ τ₂ ] getInstr c@(labeled (l ∙⟨ σ ⟩ i@(↓ _))) = let (i ∙⟨ σ ⟩ l∙i) = ✴-swap (✴-assocₗ (l ∙⟨ σ ⟩ copy i)) in i ∙⟨ σ ⟩ labeled l∙i getInstr (instr i@(↓ _)) = i ∙⟨ ∙-copy i ⟩ (instr i) module _ where open Disjoint using (bags; bags-isMonoid; bags-isSemigroup; bags-isCommutative; empty-unique) label : ∀ {τ₁ τ₂} → ∀[ Up (Labeling τ₁) ⇒ Code τ₁ τ₂ ─✴ Code τ₁ τ₂ ] label l ⟨ σ ⟩ instr i = labeled (l ∙⟨ σ ⟩ i) label l ⟨ σ ⟩ labeled (l₂∙i) with ✴-assocₗ (l ∙⟨ σ ⟩ l₂∙i) ... | l₁∙l₂ ∙⟨ σ′ ⟩ i with upMap (↑ (✴-curry (arrow concat))) ⟨ ∙-idˡ ⟩ zipUp l₁∙l₂ ... | ls = labeled (ls ∙⟨ σ′ ⟩ i) ⟪_↝_⟫ : T → T → Pred Intf ℓ ⟪ τ₁ ↝ τ₂ ⟫ = Star Code τ₁ τ₂ ⟪_↝_⟫+ : T → T → Pred Intf ℓ ⟪ τ₁ ↝ τ₂ ⟫+ = Plus Code τ₁ τ₂ ⟪_↜_⟫ : T → T → Pred Intf ℓ ⟪ τ₂ ↜ τ₁ ⟫ = Star (flip Code) τ₁ τ₂ where open import Function using (flip) module _ (nop : ∀ {τ} → I τ τ []) where label-start : ∀ {τ₁ τ₂} → ∀[ Up (Labeling τ₁) ⇒ ⟪ τ₁ ↝ τ₂ ⟫ ─✴ ⟪ τ₁ ↝ τ₂ ⟫ ] label-start l ⟨ σ ⟩ nil = labeled (l ∙⟨ σ ⟩ ↓ nop) ▹⟨ ∙-idʳ ⟩ nil label-start l ⟨ σ ⟩ (i ▹⟨ σ₂ ⟩ is) = let _ , σ₃ , σ₄ = ∙-assocₗ σ σ₂ in (label l ⟨ σ₃ ⟩ i) ▹⟨ σ₄ ⟩ is
{ "alphanum_fraction": 0.6154891304, "avg_line_length": 35.0476190476, "ext": "agda", "hexsha": "7016b24ea32f20845ebebba870a222e8507cd5a1", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ajrouvoet/jvm.agda", "max_forks_repo_path": "src/JVM/Syntax/Bytecode.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "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": "ajrouvoet/jvm.agda", "max_issues_repo_path": "src/JVM/Syntax/Bytecode.agda", "max_line_length": 95, "max_stars_count": 6, "max_stars_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ajrouvoet/jvm.agda", "max_stars_repo_path": "src/JVM/Syntax/Bytecode.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-28T21:49:08.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T14:07:17.000Z", "num_tokens": 911, "size": 2208 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.Colimit where open import Cubical.HITs.Colimit.Base public open import Cubical.HITs.Colimit.Examples public
{ "alphanum_fraction": 0.7777777778, "avg_line_length": 30, "ext": "agda", "hexsha": "65d71f2060e0671cefcc9fb7f12fb6502634e095", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/HITs/Colimit.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/HITs/Colimit.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/HITs/Colimit.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 49, "size": 180 }
{-# OPTIONS --without-K --safe #-} module Cats.Category.Presheaves.Facts.Exponential where open import Data.Product using (_,_) open import Relation.Binary using (Setoid) open import Cats.Category open import Cats.Category.Fun using (Fun ; ≈-intro ; ≈-elim) open import Cats.Category.Presheaves using (Presheaves) open import Cats.Category.Setoids as Setoids using (≈-intro ; ≈-elim) open import Cats.Functor using (Functor) open import Cats.Trans using (Trans ; component ; natural) import Cats.Category.Fun.Facts.Product as Product import Cats.Category.Setoids.Facts open Functor open HasBinaryProducts {{...}} open Setoids._⇒_ module _ {l} {ℂ : Category l l l} where private module ℂ = Category ℂ open Category (Presheaves ℂ l l) module $ (F : Obj) {x : Category.Obj ℂ} = Setoid (fobj F x) -- Could replace this with transposeBifunctor₂ HomF, but that would introduce -- even more redundant compositions with the identity. y : ℂ.Obj → Obj y d = record { fobj = λ c → ℂ.Hom c d ; fmap = λ f → record { arr = (ℂ._∘ f) ; resp = ℂ.∘-resp-l } ; fmap-resp = λ eq₁ → ≈-intro λ eq₂ → ℂ.∘-resp eq₂ eq₁ ; fmap-id = ≈-intro λ eq → ℂ.≈.trans ℂ.id-r eq ; fmap-∘ = ≈-intro λ eq → ℂ.≈.trans ℂ.assoc (ℂ.∘-resp-l eq) } _↝_ : (F G : Obj) → Obj F ↝ G = record { fobj = λ d → Hom (y d × F) G ; fmap = λ {d} {d′} f → record { arr = λ α → record { component = λ d → record { arr = λ where (g , c) → arr (component α d) (f ℂ.∘ g , c) ; resp = λ where (eq₁ , eq₂) → resp (component α d) (ℂ.∘-resp-r eq₁ , eq₂) } ; natural = λ {e} {e′} {g} → ≈-intro λ where {h , c} {h′ , c′} (h≈h′ , c≈c′) → $.trans G (resp (component α e′) (ℂ.unassoc , $.refl F)) (≈-elim (natural α) (ℂ.∘-resp-r h≈h′ , c≈c′)) } ; resp = λ α≈β → ≈-intro (≈-intro λ where (f≈g , h≈i) → ≈-elim (≈-elim α≈β) (ℂ.∘-resp-r f≈g , h≈i)) } ; fmap-resp = λ f≈g → ≈-intro λ α≈β → ≈-intro (≈-intro λ where (c≈d , h≈i) → ≈-elim (≈-elim α≈β) ((ℂ.∘-resp f≈g c≈d) , h≈i)) ; fmap-id = ≈-intro λ α≈β → ≈-intro (≈-intro λ where (c≈d , h≈i) → ≈-elim (≈-elim α≈β) ((ℂ.≈.trans ℂ.id-l c≈d) , h≈i)) ; fmap-∘ = ≈-intro λ α≈β → ≈-intro (≈-intro λ where (c≈d , h≈i) → ≈-elim (≈-elim α≈β) ((ℂ.≈.trans ℂ.unassoc (ℂ.∘-resp-r c≈d)) , h≈i)) } Eval : ∀ F G → F ↝ G × F ⇒ G Eval F G = record { component = λ c → record { arr = λ where (α , x) → arr (component α c) (ℂ.id , x) ; resp = λ where (α≈β , f≈g) → ≈-elim (≈-elim α≈β) (ℂ.≈.refl , f≈g) } ; natural = λ {c} {d} → ≈-intro λ where {α , f} {β , g} (α≈β , f≈g) → $.trans G (≈-elim (≈-elim α≈β) (ℂ.≈.trans ℂ.id-r (ℂ.≈.sym ℂ.id-l) , resp (fmap F _) f≈g)) (≈-elim (natural β) (ℂ.≈.refl , $.refl F)) } Curry : ∀ E F G → E × F ⇒ G → E ⇒ F ↝ G Curry E F G α = record { component = λ d → record { arr = λ x → record { component = λ c → record { arr = λ where (f , y) → arr (component α c) (arr (fmap E f) x , y) ; resp = λ where (c≈d , x≈y) → resp (component α c) (≈-elim (fmap-resp E c≈d) ($.refl E) , x≈y) } ; natural = ≈-intro λ where (f≈g , x≈y) → $.trans G (resp (component α _) (($.sym E (≈-elim (fmap-∘ E) ($.refl E))) , ($.refl F))) (≈-elim (natural α) (≈-elim (fmap-resp E f≈g) ($.refl E) , x≈y)) } ; resp = λ x≈y → ≈-intro (≈-intro λ where (f≈g , c≈d) → resp (component α _) ((≈-elim (fmap-resp E f≈g) x≈y) , c≈d)) } ; natural = ≈-intro λ x≈y → ≈-intro (≈-intro λ where (f≈g , c≈d) → resp (component α _) ( $.trans E (≈-elim (fmap-∘ E) x≈y) (≈-elim (fmap-resp E (ℂ.∘-resp-r f≈g)) ($.refl E)) , c≈d )) } instance hasExponentials : HasExponentials (Presheaves ℂ l l) hasExponentials = record { hasBinaryProducts = Product.hasBinaryProducts ; _↝′_ = λ F G → record { Cᴮ = F ↝ G ; eval = Eval F G ; curry′ = λ {E} α → record { arr = Curry E F G α ; prop = ≈-intro (≈-intro λ where (x≈y , u≈v) → resp (component α _) (≈-elim (fmap-id E) x≈y , u≈v)) ; unique = λ {α} α≈ → ≈-intro (≈-intro (λ x≈y → ≈-intro (≈-intro (λ where (f≈g , u≈v) → $.trans G (≈-elim (≈-elim (≈.sym α≈)) (≈-elim (fmap-resp E f≈g) ($.refl E) , u≈v)) ($.trans G (≈-elim (≈-elim (≈-elim (natural α) x≈y)) (ℂ.≈.refl , ($.refl F))) (resp (component (arr (component α _) _) _) (ℂ.id-r , ($.refl F)))))))) } } }
{ "alphanum_fraction": 0.4726899384, "avg_line_length": 35.2898550725, "ext": "agda", "hexsha": "3d4b4dfc4a4de3253c756cdef2b4deaee7f96ee1", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-18T15:35:07.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-18T15:35:07.000Z", "max_forks_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JLimperg/cats", "max_forks_repo_path": "Cats/Category/Presheaves/Facts/Exponential.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "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": "JLimperg/cats", "max_issues_repo_path": "Cats/Category/Presheaves/Facts/Exponential.agda", "max_line_length": 89, "max_stars_count": 24, "max_stars_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JLimperg/cats", "max_stars_repo_path": "Cats/Category/Presheaves/Facts/Exponential.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-06T05:00:46.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-03T15:18:57.000Z", "num_tokens": 1984, "size": 4870 }
{-# OPTIONS --copatterns --sized-types #-} module SDE where open import Size open import Function open import Data.Product as Prod renaming (Σ to ⨿) open import Data.Sum as Sum open import Streams -- | Signatures record Sig : Set₁ where field ∥_∥ : Set ar : ∥_∥ → Set open Sig public -- | Extension of signature Σ, on objects ⟪_⟫ : Sig → Set → Set ⟪ Σ ⟫ X = ⨿ ∥ Σ ∥ λ f → (ar Σ f → X) -- | Extension of signature Σ, on morphisms ⟪_⟫₁ : (Σ : Sig) {A B : Set} → (A → B) → ⟪ Σ ⟫ A → ⟪ Σ ⟫ B ⟪_⟫₁ Σ f (s , α) = (s , f ∘ α) -- | Terms over a given signature together with some basic operations. module Terms (Σ : Sig) where -- | Terms built from the signature Σ with variables in V. data T (V : Set) : Set where sup : ⟪ Σ ⟫ (T V) ⊎ V → T V -- | Recursion on terms. rec : ∀{V X} → (f : ⟪ Σ ⟫ X ⊎ V → X) → T V → X rec f (sup (inj₁ (s , α))) = f (inj₁ (s , λ i → rec f (α i))) rec f (sup (inj₂ y)) = f (inj₂ y) -- | Functor T, on morphisms T₁ : ∀ {V W} → (V → W) → T V → T W T₁ f = rec (sup ∘ Sum.map id f) -- | Injection of variables into terms. η : ∀{V} → V → T V η = sup ∘ inj₂ -- | Interpretation of SDEs that use the given signature and set of variables. module SDE-Impl (Σ : Sig) (X : Set) where open Terms Σ -- | Variables for streams and their derivatives. V : Set V = X ⊎ X -- | An SDE consists of an assignment of outputs and terms for -- each symbol in the signature. Note that both output and the -- terms may depend on the outputs of the arguments of the corresponding -- symbol. SDE : Set → Set SDE A = (f : ∥ Σ ∥) → ((ar Σ f → A) → A) × ((ar Σ f → A) → T V) -- | Interpretation of terms over the symbols defined by the given SDE -- as streams. ⟦_⟧₁ : ∀ {A} → SDE A → ((f : ∥ Σ ∥) → ar Σ f → X) → T V → ∀{i} → (X → Stream {i} A) → ∀ {j : Size< i} → Stream {j} A -- | Interpretation of symbols defined by the given SDE as streams. ⟦_⟧ : ∀ {A} → SDE A → ((f : ∥ Σ ∥) → ar Σ f → X) → (f : ∥ Σ ∥) → ∀{i} → (X → Stream {i} A) → Stream {i} A hd (⟦ E ⟧ vars f vals) = f-out (hd ∘ vals ∘ vars f) where f-out = proj₁ (E f) tl (⟦ E ⟧ vars f vals) = ⟦ E ⟧₁ vars (f-step (hd ∘ vals ∘ vars f)) vals where f-step = proj₂ (E f) -- Interpret terms by induction. This map is assumed to be called from the -- tail case of ⟦_⟧. -- For a symbol, we just use its interpretation but on the tails of the -- argument streams ⟦ E ⟧₁ vars (sup (inj₁ (f , α))) vals = ⟦ E ⟧ vars f (λ x → tl (vals x)) -- A variable is just interpreted by its valuation. ⟦ E ⟧₁ vars (sup (inj₂ (inj₁ x))) vals = vals x -- A variable denoting a derivative is interpreted by the derivative of -- the corresponding stream. ⟦ E ⟧₁ vars (sup (inj₂ (inj₂ x))) vals = tl (vals x)
{ "alphanum_fraction": 0.5707598127, "avg_line_length": 31.9195402299, "ext": "agda", "hexsha": "f9b1022720721fdc1e7f7effa8d16bb9236de6af", "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": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hbasold/Sandbox", "max_forks_repo_path": "Streams/SDE.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "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": "hbasold/Sandbox", "max_issues_repo_path": "Streams/SDE.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hbasold/Sandbox", "max_stars_repo_path": "Streams/SDE.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1054, "size": 2777 }
-- Andreas, 2021-12-31, issue #5712, reported by Trebor-Huang -- {-# OPTIONS -v tc.cover.cover:10 #-} open import Agda.Builtin.Reflection open import Agda.Builtin.Unit nothing : Term → TC ⊤ nothing hole = returnTC _ record Foo : Set1 where field A : Set @(tactic nothing) foo : A → A open Foo F : Foo F .A = ⊤ F .foo n = _ -- Should succeed. -- There was an internal error, because the coverage checker did -- not expand the last clause due to the presence of a tactic (#5358). -- However, in this case, there is a user argument that forces the -- expansion. This is now recognized by the coverage checker.
{ "alphanum_fraction": 0.6894904459, "avg_line_length": 24.1538461538, "ext": "agda", "hexsha": "8a7544a67cbf80efc3970c0cb8841125e9560ed5", "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": "b5b3b1657556f720a7310cb7744edb1fac71eaf4", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "Seanpm2001-Agda-lang/agda", "max_forks_repo_path": "test/Succeed/Issue5712.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4", "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": "Seanpm2001-Agda-lang/agda", "max_issues_repo_path": "test/Succeed/Issue5712.agda", "max_line_length": 70, "max_stars_count": 1, "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/Issue5712.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:25:14.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:25:14.000Z", "num_tokens": 176, "size": 628 }
{-# OPTIONS --without-K --safe #-} module Fragment.Examples.CSemigroup.Arith.Base where open import Fragment.Examples.Semigroup.Arith.Base public open import Data.Nat.Properties using (*-isCommutativeSemigroup; +-isCommutativeSemigroup) +-csemigroup = csemigroup→model +-isCommutativeSemigroup *-csemigroup = csemigroup→model *-isCommutativeSemigroup
{ "alphanum_fraction": 0.8005617978, "avg_line_length": 32.3636363636, "ext": "agda", "hexsha": "51a197053d0f8581efd3cf8a7fd63d3e5b680832", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z", "max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z", "max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "yallop/agda-fragment", "max_forks_repo_path": "src/Fragment/Examples/CSemigroup/Arith/Base.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z", "max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "yallop/agda-fragment", "max_issues_repo_path": "src/Fragment/Examples/CSemigroup/Arith/Base.agda", "max_line_length": 60, "max_stars_count": 18, "max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yallop/agda-fragment", "max_stars_repo_path": "src/Fragment/Examples/CSemigroup/Arith/Base.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z", "num_tokens": 96, "size": 356 }
module Functor where import Logic.Identity as Id import Category import Logic.ChainReasoning open Category open Poly-Cat private module Fun where data Functor (ℂ ⅅ : Cat) : Set1 where functor : (F : Obj ℂ -> Obj ⅅ) (map : {A B : Obj ℂ} -> A ─→ B -> F A ─→ F B) (mapId : {A : Obj ℂ} -> map (id {A = A}) == id) (mapCompose : {A B C : Obj ℂ}{f : B ─→ C}{g : A ─→ B} -> map (f ∘ g) == map f ∘ map g ) -> Functor ℂ ⅅ open Fun public module Projections where Map : {ℂ ⅅ : Cat} -> Functor ℂ ⅅ -> Obj ℂ -> Obj ⅅ Map (functor F _ _ _) = F map : {ℂ ⅅ : Cat}(F : Functor ℂ ⅅ) {A B : Obj ℂ} -> A ─→ B -> Map F A ─→ Map F B map (functor _ m _ _) = m mapId : {ℂ ⅅ : Cat}(F : Functor ℂ ⅅ) {A : Obj ℂ} -> map F id == id {A = Map F A} mapId (functor _ _ i _) = i mapCompose : {ℂ ⅅ : Cat}(F : Functor ℂ ⅅ) {A B C : Obj ℂ}{f : B ─→ C}{g : A ─→ B} -> map F (f ∘ g) == map F f ∘ map F g mapCompose (functor _ _ _ c) = c module Functor {ℂ ⅅ : Cat}(F : Functor ℂ ⅅ) where module P = Projections Map : Obj ℂ -> Obj ⅅ Map = P.Map F map : {A B : Obj ℂ} -> A ─→ B -> Map A ─→ Map B map = P.map F mapId : {A : Obj ℂ} -> map id == id {A = Map A} mapId = P.mapId F mapCompose : {A B C : Obj ℂ}{f : B ─→ C}{g : A ─→ B} -> map (f ∘ g) == map f ∘ map g mapCompose = P.mapCompose F module Functors where Id : {ℂ : Cat} -> Functor ℂ ℂ Id = functor (\A -> A) (\f -> f) (\{A} -> refl) (\{A}{B}{C}{f}{g} -> refl) _○_ : {ℂ ℚ ℝ : Cat} -> Functor ℚ ℝ -> Functor ℂ ℚ -> Functor ℂ ℝ _○_ {ℂ}{ℚ}{ℝ} F G = functor FG m mid mcomp where module F = Functor F module G = Functor G FG : Obj ℂ -> Obj ℝ FG A = F.Map (G.Map A) m : {A B : Obj ℂ} -> A ─→ B -> FG A ─→ FG B m f = F.map (G.map f) mid : {A : Obj ℂ} -> m (id {A = A}) == id mid = chain> F.map (G.map id) === F.map id by ? -- cong F.map G.mapId === id by F.mapId where open module Chain = Logic.ChainReasoning.Mono.Homogenous _==_ (\f -> refl) (\f g h -> trans) mcomp : {A B C : Obj ℂ}{f : B ─→ C}{g : A ─→ B} -> m (f ∘ g) == m f ∘ m g mcomp {f = f}{g = g} = chain> F.map (G.map (f ∘ g)) === F.map (G.map f ∘ G.map g) by ? -- cong F.map G.mapCompose === F.map (G.map f) ∘ F.map (G.map g) by F.mapCompose where open module Chain = Logic.ChainReasoning.Mono.Homogenous _==_ (\f -> refl) (\f g h -> trans)
{ "alphanum_fraction": 0.4809372518, "avg_line_length": 25.4343434343, "ext": "agda", "hexsha": "0abc281c4c34f4981cd5ffae74781648f1d74502", "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": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/cat/Functor.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "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/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/cat/Functor.agda", "max_line_length": 76, "max_stars_count": null, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "examples/outdated-and-incorrect/cat/Functor.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1026, "size": 2518 }
module Examples where open import Data.Maybe using (just ; nothing) open import Data.Nat using (ℕ ; zero ; suc ; _+_ ; ⌈_/2⌉) open import Data.Nat.Properties using (cancel-+-left) import Algebra.Structures open import Data.List using (List ; length) renaming ([] to []L ; _∷_ to _∷L_) open import Data.Vec using (Vec ; [] ; _∷_ ; reverse ; _++_ ; tail ; take ; drop ; map) open import Function using (id) import Relation.Binary open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; cong) open import Structures using (Shaped) import GetTypes import FreeTheorems import BFF open GetTypes.PartialVecVec using (Get) open FreeTheorems.PartialVecVec using (assume-get) open BFF.PartialVecBFF using (bff) ℕ-decSetoid = Relation.Binary.DecTotalOrder.Eq.decSetoid Data.Nat.decTotalOrder reverse' : Get reverse' = assume-get id id reverse double' : Get double' = assume-get id g f where g : ℕ → ℕ g zero = zero g (suc n) = suc (suc (g n)) f : {A : Set} {n : ℕ} → Vec A n → Vec A (g n) f [] = [] f (x ∷ v) = x ∷ x ∷ f v double'' : Get double'' = assume-get id _ (λ v → v ++ v) tail' : Get tail' = assume-get suc id tail tail-example : bff ℕ-decSetoid tail' 2 (8 ∷ 5 ∷ []) (3 ∷ 1 ∷ []) ≡ just (just 8 ∷ just 3 ∷ just 1 ∷ []) tail-example = refl take' : ℕ → Get take' n = assume-get (_+_ n) _ (take n) drop' : ℕ → Get drop' n = assume-get (_+_ n) _ (drop n) sieve' : Get sieve' = assume-get id _ f where f : {A : Set} {n : ℕ} → Vec A n → Vec A ⌈ n /2⌉ f [] = [] f (x ∷ []) = x ∷ [] f (x ∷ _ ∷ xs) = x ∷ f xs sieve-example : bff ℕ-decSetoid sieve' 4 (0 ∷ 2 ∷ []) (1 ∷ 3 ∷ []) ≡ just (just 1 ∷ just 2 ∷ just 3 ∷ nothing ∷ []) sieve-example = refl intersperse-len : ℕ → ℕ intersperse-len zero = zero intersperse-len (suc zero) = suc zero intersperse-len (suc (suc n)) = suc (suc (intersperse-len (suc n))) intersperse : {A : Set} {n : ℕ} → A → Vec A n → Vec A (intersperse-len n) intersperse s [] = [] intersperse s (x ∷ []) = x ∷ [] intersperse s (x ∷ y ∷ v) = x ∷ s ∷ intersperse s (y ∷ v) intersperse' : Get intersperse' = assume-get suc intersperse-len f where f : {A : Set} {n : ℕ} → Vec A (suc n) → Vec A (intersperse-len n) f (s ∷ v) = intersperse s v intersperse-neg-example : bff ℕ-decSetoid intersperse' 3 (0 ∷ []) (1 ∷ 2 ∷ 3 ∷ 4 ∷ 5 ∷ []) ≡ nothing intersperse-neg-example = refl intersperse-pos-example : bff ℕ-decSetoid intersperse' 3 (0 ∷ []) (1 ∷ 2 ∷ 3 ∷ 2 ∷ 5 ∷ []) ≡ just (map just (2 ∷ 1 ∷ 3 ∷ 5 ∷ [])) intersperse-pos-example = refl data PairVec (α : Set) (β : Set) : List α → Set where []P : PairVec α β []L _,_∷P_ : (x : α) → β → {l : List α} → PairVec α β l → PairVec α β (x ∷L l) PairVecFirstShaped : (α : Set) → Shaped (List α) (PairVec α) PairVecFirstShaped α = record { arity = length ; content = content ; fill = fill ; isShaped = record { content-fill = content-fill ; fill-content = fill-content } } where content : {β : Set} {s : List α} → PairVec α β s → Vec β (length s) content []P = [] content (a , b ∷P p) = b ∷ content p fill : {β : Set} → (s : List α) → Vec β (length s) → PairVec α β s fill []L v = []P fill (a ∷L s) (b ∷ v) = a , b ∷P fill s v content-fill : {β : Set} {s : List α} → (p : PairVec α β s) → fill s (content p) ≡ p content-fill []P = refl content-fill (a , b ∷P p) = cong (_,_∷P_ a b) (content-fill p) fill-content : {β : Set} → (s : List α) → (v : Vec β (length s)) → content (fill s v) ≡ v fill-content []L [] = refl fill-content (a ∷L s) (b ∷ v) = cong (_∷_ b) (fill-content s v)
{ "alphanum_fraction": 0.5640203154, "avg_line_length": 34.0090909091, "ext": "agda", "hexsha": "cfe9432b12ce17d3a36ce03ea8b218921e94fa6a", "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": "a5abbd177f032523d1d9d3fa4b9137aefe88dee0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jvoigtlaender/bidiragda", "max_forks_repo_path": "Examples.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a5abbd177f032523d1d9d3fa4b9137aefe88dee0", "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": "jvoigtlaender/bidiragda", "max_issues_repo_path": "Examples.agda", "max_line_length": 129, "max_stars_count": null, "max_stars_repo_head_hexsha": "a5abbd177f032523d1d9d3fa4b9137aefe88dee0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jvoigtlaender/bidiragda", "max_stars_repo_path": "Examples.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1356, "size": 3741 }
module STLC.Coquand.Convertibility where open import STLC.Coquand.Substitution public -------------------------------------------------------------------------------- -- Convertibility infix 3 _∼_ data _∼_ : ∀ {Γ A} → Γ ⊢ A → Γ ⊢ A → Set where refl∼ : ∀ {Γ A} → {M : Γ ⊢ A} → M ∼ M _⁻¹∼ : ∀ {Γ A} → {M₁ M₂ : Γ ⊢ A} → (p : M₁ ∼ M₂) → M₂ ∼ M₁ _⦙∼_ : ∀ {Γ A} → {M₁ M₂ M₃ : Γ ⊢ A} → (p : M₁ ∼ M₂) (q : M₂ ∼ M₃) → M₁ ∼ M₃ ƛ∼ : ∀ {Γ A B} → {M₁ M₂ : Γ , A ⊢ B} → (p : M₁ ∼ M₂) → ƛ M₁ ∼ ƛ M₂ _∙∼_ : ∀ {Γ A B} → {M₁ M₂ : Γ ⊢ A ⇒ B} {N₁ N₂ : Γ ⊢ A} → (p : M₁ ∼ M₂) (q : N₁ ∼ N₂) → M₁ ∙ N₁ ∼ M₂ ∙ N₂ red⇒ : ∀ {Γ Ξ A B} → (σ : Γ ⊢⋆ Ξ) (M : Ξ , A ⊢ B) (N : Γ ⊢ A) → sub σ (ƛ M) ∙ N ∼ sub (σ , N) M exp⇒ : ∀ {Γ A B} → (M : Γ ⊢ A ⇒ B) → M ∼ ƛ (wk M ∙ 0) ≡→∼ : ∀ {Γ A} → {M₁ M₂ : Γ ⊢ A} → M₁ ≡ M₂ → M₁ ∼ M₂ ≡→∼ refl = refl∼ instance per∼ : ∀ {Γ A} → PER (Γ ⊢ A) _∼_ per∼ = record { _⁻¹ = _⁻¹∼ ; _⦙_ = _⦙∼_ } -------------------------------------------------------------------------------- renred⇒ : ∀ {Γ Γ′ Ξ A B} → {η : Γ′ ∋⋆ Γ} → (σ : Γ ⊢⋆ Ξ) (M : Ξ , A ⊢ B) (N : Γ ⊢ A) → ren η (sub σ (ƛ M) ∙ N) ∼ ren η (sub (σ , N) M) renred⇒ {η = η} σ M N = ƛ∼ (≡→∼ (sublift◑ η σ M ⁻¹)) ∙∼ refl∼ ⦙ red⇒ (η ◑ σ) M (ren η N) ⦙ ≡→∼ ( (λ σ′ → sub σ′ M) & ((⌊ η ⌋ ● σ ,_) & ⌊sub⌋ η N ⁻¹) ⦙ sub◑ η (σ , N) M ) renexp⇒𝓋 : ∀ {Γ Γ′ A B} → {η : Γ′ ∋⋆ Γ} → (i : Γ ∋ A ⇒ B) → ren η (𝓋 i) ∼ ren η (ƛ (wk (𝓋 i) ∙ 0)) renexp⇒𝓋 {η = η} i = exp⇒ (𝓋 (getᵣ η i)) ⦙ ƛ∼ (≡→∼ (𝓋 & ( get○ (wkᵣ idᵣ) η i ⁻¹ ⦙ (λ η′ → getᵣ η′ i) & ( wklid○ η ⦙ liftwkrid○ η ⁻¹ ) ⦙ get○ (liftᵣ η) (wkᵣ idᵣ) i )) ∙∼ refl∼) renexp⇒ƛ : ∀ {Γ Γ′ A B} → {η : Γ′ ∋⋆ Γ} → (M : Γ , A ⊢ B) → ren η (ƛ M) ∼ ren η (ƛ (wk (ƛ M) ∙ 0)) renexp⇒ƛ {η = η} M = exp⇒ (ƛ (ren (liftᵣ η) M)) ⦙ ƛ∼ (ƛ∼ (≡→∼ ( renlift○ (wkᵣ idᵣ) η M ⁻¹ ⦙ (λ η′ → ren η′ M) & (liftᵣ & ( wklid○ η ⦙ wkrid○ η ⁻¹ ⦙ zap○ (wkᵣ η) idᵣ 0 ⁻¹ )) ⦙ renlift○ (liftᵣ η) (wkᵣ idᵣ) M )) ∙∼ refl∼) renexp⇒∙ : ∀ {Γ Γ′ A B C} → {η : Γ′ ∋⋆ Γ} → (M : Γ ⊢ A ⇒ B ⇒ C) (N : Γ ⊢ A) → ren η (M ∙ N) ∼ ren η (ƛ (wk (M ∙ N) ∙ 0)) renexp⇒∙ {η = η} M N = exp⇒ (ren η M ∙ ren η N) ⦙ ƛ∼ ((≡→∼ ( ren○ (wkᵣ idᵣ) η M ⁻¹ ⦙ (λ η′ → ren η′ M) & ( wklid○ η ⦙ wkrid○ η ⁻¹ ⦙ wk○ η idᵣ ⁻¹ ) ⦙ renliftwk○ η idᵣ M ) ∙∼ ≡→∼ ( ren○ (wkᵣ idᵣ) η N ⁻¹ ⦙ (λ η′ → ren η′ N) & ( wklid○ η ⦙ wkrid○ η ⁻¹ ⦙ wk○ η idᵣ ⁻¹ ) ⦙ renliftwk○ η idᵣ N )) ∙∼ refl∼) ren∼ : ∀ {Γ Γ′ A} → {η : Γ′ ∋⋆ Γ} {M₁ M₂ : Γ ⊢ A} → M₁ ∼ M₂ → ren η M₁ ∼ ren η M₂ ren∼ refl∼ = refl∼ ren∼ (p ⁻¹∼) = ren∼ p ⁻¹ ren∼ (p ⦙∼ q) = ren∼ p ⦙ ren∼ q ren∼ (ƛ∼ p) = ƛ∼ (ren∼ p) ren∼ (p ∙∼ q) = ren∼ p ∙∼ ren∼ q ren∼ (red⇒ σ M N) = renred⇒ σ M N ren∼ (exp⇒ (𝓋 i)) = renexp⇒𝓋 i ren∼ (exp⇒ (ƛ M)) = renexp⇒ƛ M ren∼ (exp⇒ (M ∙ N)) = renexp⇒∙ M N -------------------------------------------------------------------------------- subred⇒ : ∀ {Γ Ξ Φ A B} → {σ₁ : Γ ⊢⋆ Ξ} → (σ₂ : Ξ ⊢⋆ Φ) (M : Φ , A ⊢ B) (N : Ξ ⊢ A) → sub σ₁ (sub σ₂ (ƛ M) ∙ N) ∼ sub σ₁ (sub (σ₂ , N) M) subred⇒ {σ₁ = σ₁} σ₂ M N = ƛ∼ (≡→∼ (sublift● σ₁ σ₂ M ⁻¹)) ∙∼ refl∼ ⦙ red⇒ (σ₁ ● σ₂) M (sub σ₁ N) ⦙ ≡→∼ (sub● σ₁ (σ₂ , N) M) subexp⇒𝓋 : ∀ {Γ Ξ A B} → {σ : Γ ⊢⋆ Ξ} → (i : Ξ ∋ A ⇒ B) → sub σ (𝓋 i) ∼ sub σ (ƛ (wk (𝓋 i) ∙ 0)) subexp⇒𝓋 {σ = σ} i = exp⇒ (getₛ σ i) ⦙ ƛ∼ (≡→∼ ( natgetₛ σ i ⁻¹ ⦙ (λ σ′ → getₛ σ′ i) & liftwkrid◐ σ ⁻¹ ⦙ get◐ (liftₛ σ) (wkᵣ idᵣ) i ) ∙∼ refl∼) subexp⇒ƛ : ∀ {Γ Ξ A B} → {σ : Γ ⊢⋆ Ξ} → (M : Ξ , A ⊢ B) → sub σ (ƛ M) ∼ sub σ (ƛ (wk (ƛ M) ∙ 0)) subexp⇒ƛ {σ = σ} M = ƛ∼ ( ≡→∼ ( (λ σ′ → sub σ′ M) & ((_, 0) & ( rid◐ (wkₛ σ) ⁻¹ ⦙ zap◐ (wkₛ σ) idᵣ 0 ⁻¹ ⦙ zap◐ (liftₛ σ) (wkᵣ idᵣ) 0 ⁻¹ )) ⦙ sub◐ (liftₛ σ , 0) (liftᵣ (wkᵣ idᵣ)) M ) ⦙ red⇒ (liftₛ σ) (ren (liftᵣ (wkᵣ idᵣ)) M) 0 ⁻¹ ) subexp⇒∙ : ∀ {Γ Ξ A B C} → {σ : Γ ⊢⋆ Ξ} → (M : Ξ ⊢ A ⇒ B ⇒ C) (N : Ξ ⊢ A) → sub σ (M ∙ N) ∼ sub σ (ƛ (wk (M ∙ N) ∙ 0)) subexp⇒∙ {σ = σ} M N = exp⇒ (sub σ M ∙ sub σ N) ⦙ ƛ∼ ((≡→∼ ( sub◑ (wkᵣ idᵣ) σ M ⁻¹ ⦙ (λ σ′ → sub σ′ M) & ( wklid◑ σ ⦙ wkrid◐ σ ⁻¹ ⦙ wk◐ σ idᵣ ⁻¹ ) ⦙ subliftwk◐ σ idᵣ M ) ∙∼ ≡→∼ ( sub◑ (wkᵣ idᵣ) σ N ⁻¹ ⦙ (λ σ′ → sub σ′ N) & ( wklid◑ σ ⦙ wkrid◐ σ ⁻¹ ⦙ wk◐ σ idᵣ ⁻¹ ) ⦙ subliftwk◐ σ idᵣ N )) ∙∼ refl∼) sub∼ : ∀ {Γ Ξ A} → {σ : Γ ⊢⋆ Ξ} {M₁ M₂ : Ξ ⊢ A} → M₁ ∼ M₂ → sub σ M₁ ∼ sub σ M₂ sub∼ refl∼ = refl∼ sub∼ (p ⁻¹∼) = sub∼ p ⁻¹ sub∼ (p ⦙∼ q) = sub∼ p ⦙ sub∼ q sub∼ (ƛ∼ p) = ƛ∼ (sub∼ p) sub∼ (p ∙∼ q) = sub∼ p ∙∼ sub∼ q sub∼ (red⇒ σ M N) = subred⇒ σ M N sub∼ (exp⇒ (𝓋 i)) = subexp⇒𝓋 i sub∼ (exp⇒ (ƛ M)) = subexp⇒ƛ M sub∼ (exp⇒ (M ∙ N)) = subexp⇒∙ M N -------------------------------------------------------------------------------- -- Convertibility of substitutions infix 3 _∼⋆_ data _∼⋆_ : ∀ {Γ Ξ} → Γ ⊢⋆ Ξ → Γ ⊢⋆ Ξ → Set where ∅ : ∀ {Γ} → ∅ {Γ} ∼⋆ ∅ _,_ : ∀ {Γ Ξ A} → {σ₁ σ₂ : Γ ⊢⋆ Ξ} {M₁ M₂ : Γ ⊢ A} → (χ : σ₁ ∼⋆ σ₂) (p : M₁ ∼ M₂) → σ₁ , M₁ ∼⋆ σ₂ , M₂ refl∼⋆ : ∀ {Γ Ξ} → {σ : Γ ⊢⋆ Ξ} → σ ∼⋆ σ refl∼⋆ {σ = ∅} = ∅ refl∼⋆ {σ = σ , M} = refl∼⋆ , refl∼ _⁻¹∼⋆ : ∀ {Γ Ξ} → {σ₁ σ₂ : Γ ⊢⋆ Ξ} → σ₁ ∼⋆ σ₂ → σ₂ ∼⋆ σ₁ ∅ ⁻¹∼⋆ = ∅ (χ , p) ⁻¹∼⋆ = χ ⁻¹∼⋆ , p ⁻¹ _⦙∼⋆_ : ∀ {Γ Ξ} → {σ₁ σ₂ σ₃ : Γ ⊢⋆ Ξ} → σ₁ ∼⋆ σ₂ → σ₂ ∼⋆ σ₃ → σ₁ ∼⋆ σ₃ ∅ ⦙∼⋆ ∅ = ∅ (χ₁ , p) ⦙∼⋆ (χ₂ , q) = (χ₁ ⦙∼⋆ χ₂) , (p ⦙ q) ≡→∼⋆ : ∀ {Γ Ξ} → {σ₁ σ₂ : Γ ⊢⋆ Ξ} → σ₁ ≡ σ₂ → σ₁ ∼⋆ σ₂ ≡→∼⋆ refl = refl∼⋆ instance per∼⋆ : ∀ {Γ Ξ} → PER (Γ ⊢⋆ Ξ) _∼⋆_ per∼⋆ = record { _⁻¹ = _⁻¹∼⋆ ; _⦙_ = _⦙∼⋆_ } wk∼⋆ : ∀ {A Γ Ξ} → {σ₁ σ₂ : Γ ⊢⋆ Ξ} → σ₁ ∼⋆ σ₂ → wkₛ {A} σ₁ ∼⋆ wkₛ σ₂ wk∼⋆ ∅ = ∅ wk∼⋆ (χ , p) = wk∼⋆ χ , ren∼ p lift∼⋆ : ∀ {A Γ Ξ} → {σ₁ σ₂ : Γ ⊢⋆ Ξ} → σ₁ ∼⋆ σ₂ → liftₛ {A} σ₁ ∼⋆ liftₛ σ₂ lift∼⋆ ∅ = ∅ , refl∼ lift∼⋆ (χ , p) = wk∼⋆ χ , ren∼ p , refl∼ -- NOTE: Needs getₛ σ₁ i ∼ getₛ σ₂ i -- ◐∼⋆ : ∀ {Γ Ξ Ξ′} → {σ₁ σ₂ : Γ ⊢⋆ Ξ′} {η : Ξ′ ∋⋆ Ξ} -- → σ₁ ∼⋆ σ₂ → σ₁ ◐ η ∼⋆ σ₂ ◐ η -- ◐∼⋆ {η = ∅} χ = ∅ -- ◐∼⋆ {η = [ η , i ]} χ = [ ◐∼⋆ χ , {!!} ] ◑∼⋆ : ∀ {Γ Γ′ Ξ} → {η : Γ′ ∋⋆ Γ} {σ₁ σ₂ : Γ ⊢⋆ Ξ} → σ₁ ∼⋆ σ₂ → η ◑ σ₁ ∼⋆ η ◑ σ₂ ◑∼⋆ ∅ = ∅ ◑∼⋆ (χ , p) = ◑∼⋆ χ , sub∼ p -- NOTE: Needs a more general sub∼ -- ●∼⋆ : ∀ {Γ Ξ Φ} → {σ₁ σ₂ : Γ ⊢⋆ Ξ} {τ₁ τ₂ : Ξ ⊢⋆ Φ} -- → σ₁ ∼⋆ σ₂ → τ₁ ∼⋆ τ₂ -- → σ₁ ● τ₁ ∼⋆ σ₂ ● τ₂ -- ●∼⋆ χ₁ ∅ = ∅ -- ●∼⋆ χ₁ [ χ₂ , p ] = [ ●∼⋆ χ₁ χ₂ , {!!} ] --------------------------------------------------------------------------------
{ "alphanum_fraction": 0.2271073693, "avg_line_length": 34.4838709677, "ext": "agda", "hexsha": "f5f5fe8729b569eec2893fee2bf31c6b93aecbe1", "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": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/coquand-kovacs", "max_forks_repo_path": "src/STLC/Coquand/Convertibility.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "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-kovacs", "max_issues_repo_path": "src/STLC/Coquand/Convertibility.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/coquand-kovacs", "max_stars_repo_path": "src/STLC/Coquand/Convertibility.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4435, "size": 9621 }
{-# OPTIONS --cubical --safe #-} module Data.Bag where open import Prelude open import Algebra open import Path.Reasoning infixr 5 _∷_ data ⟅_⟆ (A : Type a) : Type a where [] : ⟅ A ⟆ _∷_ : A → ⟅ A ⟆ → ⟅ A ⟆ com : ∀ x y xs → x ∷ y ∷ xs ≡ y ∷ x ∷ xs trunc : isSet ⟅ A ⟆ record Elim {a ℓ} (A : Type a) (P : ⟅ A ⟆ → Type ℓ) : Type (a ℓ⊔ ℓ) where constructor elim field ⟅_⟆-set : ∀ {xs} → isSet (P xs) ⟅_⟆[] : P [] ⟅_⟆_∷_⟨_⟩ : ∀ x xs → P xs → P (x ∷ xs) private z = ⟅_⟆[]; f = ⟅_⟆_∷_⟨_⟩ field ⟅_⟆-com : (∀ x y xs pxs → PathP (λ i → P (com x y xs i)) (f x (y ∷ xs) (f y xs pxs)) (f y (x ∷ xs) (f x xs pxs))) ⟅_⟆⇓ : (xs : ⟅ A ⟆) → P xs ⟅ [] ⟆⇓ = z ⟅ x ∷ xs ⟆⇓ = f x xs ⟅ xs ⟆⇓ ⟅ com x y xs i ⟆⇓ = ⟅_⟆-com x y xs ⟅ xs ⟆⇓ i ⟅ trunc xs ys x y i j ⟆⇓ = isOfHLevel→isOfHLevelDep 2 (λ xs → ⟅_⟆-set {xs}) ⟅ xs ⟆⇓ ⟅ ys ⟆⇓ (cong ⟅_⟆⇓ x) (cong ⟅_⟆⇓ y) (trunc xs ys x y) i j open Elim infixr 0 elim-syntax elim-syntax : ∀ {a ℓ} → (A : Type a) → (⟅ A ⟆ → Type ℓ) → Type (a ℓ⊔ ℓ) elim-syntax = Elim syntax elim-syntax A (λ xs → Pxs) = xs ⦂⟅ A ⟆→ Pxs record ElimProp {a ℓ} (A : Type a) (P : ⟅ A ⟆ → Type ℓ) : Type (a ℓ⊔ ℓ) where constructor elim-prop field ⟦_⟧-prop : ∀ {xs} → isProp (P xs) ⟦_⟧[] : P [] ⟦_⟧_∷_⟨_⟩ : ∀ x xs → P xs → P (x ∷ xs) private z = ⟦_⟧[]; f = ⟦_⟧_∷_⟨_⟩ ⟦_⟧⇑ = elim (isProp→isSet ⟦_⟧-prop) z f (λ x y xs pxs → toPathP (⟦_⟧-prop (transp (λ i → P (com x y xs i)) i0 (f x (y ∷ xs) (f y xs pxs))) (f y (x ∷ xs) (f x xs pxs)))) ⟦_⟧⇓ = ⟅ ⟦_⟧⇑ ⟆⇓ open ElimProp infixr 0 elim-prop-syntax elim-prop-syntax : ∀ {a ℓ} → (A : Type a) → (⟅ A ⟆ → Type ℓ) → Type (a ℓ⊔ ℓ) elim-prop-syntax = ElimProp syntax elim-prop-syntax A (λ xs → Pxs) = xs ⦂⟅ A ⟆→∥ Pxs ∥ record [⟅_⟆→_] {a b} (A : Type a) (B : Type b) : Type (a ℓ⊔ b) where constructor rec field [_]-set : isSet B [_]_∷_ : A → B → B [_][] : B private f = [_]_∷_; z = [_][] field [_]-com : ∀ x y xs → f x (f y xs) ≡ f y (f x xs) [_]⇑ = elim [_]-set z (λ x _ → f x) (λ x y _ → [_]-com x y) [_]↓ = ⟅ [_]⇑ ⟆⇓ open [⟅_⟆→_] infixr 5 _∪_ _∪_ : ⟅ A ⟆ → ⟅ A ⟆ → ⟅ A ⟆ _∪_ = λ xs ys → [ ys ∪′ ]↓ xs where _∪′ : ⟅ A ⟆ → [⟅ A ⟆→ ⟅ A ⟆ ] [ ys ∪′ ]-set = trunc [ ys ∪′ ] x ∷ xs = x ∷ xs [ ys ∪′ ][] = ys [ ys ∪′ ]-com = com ∪-assoc : (xs ys zs : ⟅ A ⟆) → (xs ∪ ys) ∪ zs ≡ xs ∪ (ys ∪ zs) ∪-assoc = λ xs ys zs → ⟦ ∪-assoc′ ys zs ⟧⇓ xs where ∪-assoc′ : ∀ ys zs → xs ⦂⟅ A ⟆→∥ (xs ∪ ys) ∪ zs ≡ xs ∪ (ys ∪ zs) ∥ ⟦ ∪-assoc′ ys zs ⟧-prop = trunc _ _ ⟦ ∪-assoc′ ys zs ⟧[] = refl ⟦ ∪-assoc′ ys zs ⟧ x ∷ xs ⟨ P ⟩ = cong (x ∷_) P ∪-cons : ∀ (x : A) xs ys → (x ∷ xs) ∪ ys ≡ xs ∪ (x ∷ ys) ∪-cons = λ x xs ys → ⟦ ∪-cons′ x ys ⟧⇓ xs where ∪-cons′ : ∀ x ys → xs ⦂⟅ A ⟆→∥ (x ∷ xs) ∪ ys ≡ xs ∪ (x ∷ ys) ∥ ⟦ ∪-cons′ x ys ⟧-prop = trunc _ _ ⟦ ∪-cons′ x ys ⟧[] = refl ⟦ ∪-cons′ x ys ⟧ y ∷ xs ⟨ P ⟩ = cong (_∪ ys) (com x y xs) ; cong (y ∷_) P ∪-idʳ : (xs : ⟅ A ⟆) → xs ∪ [] ≡ xs ∪-idʳ = ⟦ ∪-idʳ′ ⟧⇓ where ∪-idʳ′ : xs ⦂⟅ A ⟆→∥ xs ∪ [] ≡ xs ∥ ⟦ ∪-idʳ′ ⟧-prop = trunc _ _ ⟦ ∪-idʳ′ ⟧[] = refl ⟦ ∪-idʳ′ ⟧ x ∷ xs ⟨ P ⟩ = cong (x ∷_) P ∪-comm : (xs ys : ⟅ A ⟆) → xs ∪ ys ≡ ys ∪ xs ∪-comm {A = A} = λ xs ys → ⟦ ∪-comm′ ys ⟧⇓ xs where ∪-comm′ : (ys : ⟅ A ⟆) → xs ⦂⟅ A ⟆→∥ xs ∪ ys ≡ ys ∪ xs ∥ ⟦ ∪-comm′ ys ⟧-prop = trunc _ _ ⟦ ∪-comm′ ys ⟧[] = sym (∪-idʳ ys) ⟦ ∪-comm′ ys ⟧ x ∷ xs ⟨ P ⟩ = (x ∷ xs) ∪ ys ≡⟨ cong (x ∷_) P ⟩ (x ∷ ys) ∪ xs ≡⟨ ∪-cons x ys xs ⟩ ys ∪ x ∷ xs ∎ ⟅⟆-commutative-monoid : ∀ {a} (A : Type a) → CommutativeMonoid _ Monoid.𝑆 (CommutativeMonoid.monoid (⟅⟆-commutative-monoid A)) = ⟅ A ⟆ Monoid._∙_ (CommutativeMonoid.monoid (⟅⟆-commutative-monoid A)) = _∪_ Monoid.ε (CommutativeMonoid.monoid (⟅⟆-commutative-monoid A)) = [] Monoid.assoc (CommutativeMonoid.monoid (⟅⟆-commutative-monoid A)) = ∪-assoc Monoid.ε∙ (CommutativeMonoid.monoid (⟅⟆-commutative-monoid A)) _ = refl Monoid.∙ε (CommutativeMonoid.monoid (⟅⟆-commutative-monoid A)) = ∪-idʳ CommutativeMonoid.comm (⟅⟆-commutative-monoid A) = ∪-comm module _ {ℓ} (mon : CommutativeMonoid ℓ) (sIsSet : isSet (CommutativeMonoid.𝑆 mon)) where open CommutativeMonoid mon ⟦_⟧ : (A → 𝑆) → ⟅ A ⟆ → 𝑆 ⟦_⟧ = λ h → [ ⟦ h ⟧′ ]↓ where ⟦_⟧′ : (A → 𝑆) → [⟅ A ⟆→ 𝑆 ] [ ⟦ h ⟧′ ] x ∷ xs = h x ∙ xs [ ⟦ h ⟧′ ][] = ε [ ⟦ h ⟧′ ]-com x y xs = h x ∙ (h y ∙ xs) ≡˘⟨ assoc _ _ _ ⟩ (h x ∙ h y) ∙ xs ≡⟨ cong (_∙ xs) (comm _ _) ⟩ (h y ∙ h x) ∙ xs ≡⟨ assoc _ _ _ ⟩ h y ∙ (h x ∙ xs) ∎ [ ⟦ h ⟧′ ]-set = sIsSet record ⟦_≡_⟧ {a b} {A : Type a} {B : Type b} (h : ⟅ A ⟆ → B) (xf : [⟅ A ⟆→ B ]) : Type (a ℓ⊔ b) where constructor elim-univ field ⟦_≡⟧_∷_ : ∀ x xs → h (x ∷ xs) ≡ [ xf ] x ∷ h xs ⟦_≡⟧[] : h [] ≡ [ xf ][] ⟦_≡⟧⇓ : ∀ xs → h xs ≡ [ xf ]↓ xs ⟦_≡⟧⇓ = ⟦ ≡⇓′ ⟧⇓ where ≡⇓′ : xs ⦂⟅ A ⟆→∥ h xs ≡ [ xf ]↓ xs ∥ ⟦ ≡⇓′ ⟧-prop = [ xf ]-set _ _ ⟦ ≡⇓′ ⟧[] = ⟦_≡⟧[] ⟦ ≡⇓′ ⟧ x ∷ xs ⟨ P ⟩ = ⟦_≡⟧_∷_ x _ ; cong ([ xf ] x ∷_) P open ⟦_≡_⟧ record ⟦_⊚_≡_⟧ {a b c} {A : Type a} {B : Type b} {C : Type c} (h : B → C) (xf : [⟅ A ⟆→ B ]) (yf : [⟅ A ⟆→ C ]) : Type (a ℓ⊔ b ℓ⊔ c) where constructor elim-fuse field ⟦_∘≡⟧_∷_ : ∀ x xs → h ([ xf ] x ∷ xs) ≡ [ yf ] x ∷ h xs ⟦_∘≡⟧[] : h [ xf ][] ≡ [ yf ][] ⟦_∘≡⟧⇓ : ∀ xs → h ([ xf ]↓ xs) ≡ [ yf ]↓ xs ⟦_∘≡⟧⇓ = ⟦ ≡⇓′ ⟧⇓ where ≡⇓′ : xs ⦂⟅ A ⟆→∥ h ([ xf ]↓ xs) ≡ [ yf ]↓ xs ∥ ⟦ ≡⇓′ ⟧-prop = [ yf ]-set _ _ ⟦ ≡⇓′ ⟧[] = ⟦_∘≡⟧[] ⟦ ≡⇓′ ⟧ x ∷ xs ⟨ P ⟩ = ⟦_∘≡⟧_∷_ x _ ; cong ([ yf ] x ∷_) P open ⟦_⊚_≡_⟧ map-alg : (A → B) → [⟅ A ⟆→ ⟅ B ⟆ ] [ map-alg f ]-set = trunc [ map-alg f ][] = [] [ map-alg f ] x ∷ xs = f x ∷ xs [ map-alg f ]-com x y = com (f x) (f y) map : (A → B) → ⟅ A ⟆ → ⟅ B ⟆ map f = [ map-alg f ]↓ [_]∘_ : [⟅ B ⟆→ C ] → (A → B) → [⟅ A ⟆→ C ] [ [ g ]∘ f ]-set = [ g ]-set [ [ g ]∘ f ][] = [ g ][] [ [ g ]∘ f ] x ∷ xs = [ g ] f x ∷ xs [ [ g ]∘ f ]-com x y = [ g ]-com (f x) (f y) map-fuse : ∀ (g : [⟅ B ⟆→ C ]) (f : A → B) → [ g ]↓ ∘ map f ≡ [ [ g ]∘ f ]↓ map-fuse g f = funExt ⟦ map-fuse′ g f ∘≡⟧⇓ where map-fuse′ : (g : [⟅ B ⟆→ C ]) (f : A → B) → ⟦ [ g ]↓ ⊚ map-alg f ≡ [ g ]∘ f ⟧ ⟦ map-fuse′ g f ∘≡⟧ x ∷ xs = refl ⟦ map-fuse′ g f ∘≡⟧[] = refl bind : ⟅ A ⟆ → (A → ⟅ B ⟆) → ⟅ B ⟆ bind xs f = ⟦ ⟅⟆-commutative-monoid _ ⟧ trunc f xs
{ "alphanum_fraction": 0.4050325906, "avg_line_length": 28.807860262, "ext": "agda", "hexsha": "a015af22a24cda271156fbe021a59b96d211d334", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Data/Bag.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "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/agda-playground", "max_issues_repo_path": "Data/Bag.agda", "max_line_length": 89, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Data/Bag.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": 3657, "size": 6597 }
record R (A : Set) : Set₁ where field P : A → Set p : (x : A) → P x module M (r : (A : Set) → R A) where open module R′ {A : Set} = R (r A) public postulate r : (A : Set) → R A A : Set open M r internal-error : (x : A) → P x internal-error x = p
{ "alphanum_fraction": 0.5074626866, "avg_line_length": 14.1052631579, "ext": "agda", "hexsha": "5f4601858c418325356bf4907665f0ea8d242180", "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/Issue2057.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/Issue2057.agda", "max_line_length": 43, "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/Issue2057.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": 111, "size": 268 }
-- Andreas, 2017-08-23, issue #2714 -- Make sure we produce a warning about missing main function -- even though we import a module with --no-main. open import Issue2712
{ "alphanum_fraction": 0.738372093, "avg_line_length": 24.5714285714, "ext": "agda", "hexsha": "afc197d8da5bbd79affe2e75f1ffcfa7b53eae51", "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/Compiler/simple/Issue2714.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/Compiler/simple/Issue2714.agda", "max_line_length": 61, "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/Compiler/simple/Issue2714.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": 172 }
module _ where open import Common.Prelude case_of_ : {A B : Set} → A → (A → B) → B case x of f = f x {-# INLINE case_of_ #-} patlam : Nat → Nat patlam zero = zero patlam (suc n) = case n of λ { zero → zero ; (suc m) → m + patlam n } static : {A : Set} → A → A static x = x {-# STATIC static #-} -- The static here will make the compiler get to the pattern lambda in the body of patlam -- before compiling patlam. If we're not careful this might make the pattern lambda not -- inline in the body of patlam. foo : Nat → Nat foo n = static (patlam (suc n)) main : IO Unit main = printNat (foo 5)
{ "alphanum_fraction": 0.6366612111, "avg_line_length": 20.3666666667, "ext": "agda", "hexsha": "c6b4c228ede4d2abc6dbe7171700a5bedff8625c", "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/Compiler/simple/StaticPatternLambda.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/Compiler/simple/StaticPatternLambda.agda", "max_line_length": 89, "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/Compiler/simple/StaticPatternLambda.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": 197, "size": 611 }
import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; sym; cong; cong₂; cong-app) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎) open import Function using (_∘_) open import Data.Nat using (ℕ; zero; suc) open import Data.Fin hiding (_+_; #_) open import DeBruijn postulate extensionality : ∀ {A B : Set} {f g : A → B} → (∀ (x : A) → f x ≡ g x) ----------------------- → f ≡ g ⟪_⟫ : ∀ {n m} → Subst n m → Term n → Term m ⟪ σ ⟫ = subst σ ids : ∀ {n} → Subst n n ids x = # x ↑ : ∀ {n} → Subst n (suc n) ↑ x = # (suc x) infix 6 _•_ _•_ : ∀ {n m} → Term m → Subst n m → Subst (suc n) m (M • σ) zero = M (M • σ) (suc x) = σ x infixr 5 _⨟_ _⨟_ : ∀ {n k m} → Subst n k → Subst k m → Subst n m σ ⨟ τ = ⟪ τ ⟫ ∘ σ ren : ∀ {n m} → Rename n m → Subst n m ren ρ = ids ∘ ρ sub-head : ∀ {n m} {M : Term m} {σ : Subst n m} → ⟪ M • σ ⟫ (# zero) ≡ M sub-head = refl sub-tail : ∀ {n m} {M : Term m} {σ : Subst n m} → (↑ ⨟ M • σ) ≡ σ sub-tail = extensionality λ x → refl sub-idL : ∀ {n m} {σ : Subst n m} → ids ⨟ σ ≡ σ sub-idL = extensionality λ x → refl sub-dist : ∀ {n m k} {σ : Subst n m} {τ : Subst m k} {M : Term m} → ((M • σ) ⨟ τ) ≡ ((subst τ M) • (σ ⨟ τ)) sub-dist {n}{m}{k}{σ}{τ}{M} = extensionality λ x → lemma {x = x} where lemma : ∀ {x : Fin (suc n)} → ((M • σ) ⨟ τ) x ≡ ((subst τ M) • (σ ⨟ τ)) x lemma {x = zero} = refl lemma {x = suc x} = refl cong-ext : ∀ {n m}{ρ ρ′ : Rename n m} → (ρ ≡ ρ′) --------------------------------- → ext ρ ≡ ext ρ′ cong-ext{n}{m}{ρ}{ρ′} rr = extensionality λ x → lemma {x} where lemma : ∀ {x : Fin (suc n)} → ext ρ x ≡ ext ρ′ x lemma {zero} = refl lemma {suc y} = cong suc (cong-app rr y) cong-rename : ∀ {n m}{ρ ρ′ : Rename n m}{M M′ : Term n} → ρ ≡ ρ′ → M ≡ M′ ------------------------ → rename ρ M ≡ rename ρ′ M cong-rename {M = # x} rr refl = cong #_ (cong-app rr x) cong-rename {ρ = ρ} {ρ′ = ρ′} {M = ƛ N} rr refl = cong ƛ_ (cong-rename {ρ = ext ρ}{ρ′ = ext ρ′}{M = N} (cong-ext rr) refl) cong-rename {M = L · M} rr refl = cong₂ _·_ (cong-rename rr refl) (cong-rename rr refl) cong-exts : ∀ {n m}{σ σ′ : Subst n m} → σ ≡ σ′ ---------------- → exts σ ≡ exts σ′ cong-exts{n}{m}{σ}{σ′} ss = extensionality λ x → lemma {x} where lemma : ∀ {x} → exts σ x ≡ exts σ′ x lemma {zero} = refl lemma {suc x} = cong (rename suc) (cong-app (ss) x) cong-sub : ∀ {n m}{σ σ′ : Subst n m}{M M′ : Term n} → σ ≡ σ′ → M ≡ M′ ----------------------- → subst σ M ≡ subst σ′ M′ cong-sub {n}{m}{σ}{σ′}{# x} ss refl = cong-app ss x cong-sub {n}{m}{σ}{σ′}{ƛ M} ss refl = cong ƛ_ (cong-sub {σ = exts σ}{σ′ = exts σ′} {M = M} (cong-exts ss) refl) cong-sub {n}{m}{σ}{σ′}{L · M} ss refl = cong₂ _·_ (cong-sub {M = L} ss refl) (cong-sub {M = M} ss refl) cong-sub-zero : ∀ {n} {M M′ : Term n} → M ≡ M′ ---------------------------- → subst-zero M ≡ subst-zero M′ cong-sub-zero {n}{M}{M′} mm′ = extensionality λ x → cong (λ z → subst-zero z x) mm′ cong-cons : ∀ {n m}{M N : Term m}{σ τ : Subst n m} → M ≡ N → σ ≡ τ ----------------- → (M • σ) ≡ (N • τ) cong-cons{n}{m}{M}{N}{σ}{τ} refl st = extensionality lemma where lemma : (x : Fin (suc n)) → (M • σ) x ≡ (M • τ) x lemma zero = refl lemma (suc x) = cong-app st x cong-seq : ∀ {n m k}{σ σ′ : Subst n m}{τ τ′ : Subst m k} → (σ ≡ σ′) → (τ ≡ τ′) → (σ ⨟ τ) ≡ (σ′ ⨟ τ′) cong-seq {n}{m}{k}{σ}{σ′}{τ}{τ′} ss′ tt′ = extensionality lemma where lemma : (x : Fin n) → (σ ⨟ τ) x ≡ (σ′ ⨟ τ′) x lemma x = begin (σ ⨟ τ) x ≡⟨⟩ subst τ (σ x) ≡⟨ cong (subst τ) (cong-app ss′ x) ⟩ subst τ (σ′ x) ≡⟨ cong-sub{M = σ′ x} tt′ refl ⟩ subst τ′ (σ′ x) ≡⟨⟩ (σ′ ⨟ τ′) x ∎ ren-ext : ∀ {n m} {ρ : Rename n m} → ren (ext ρ) ≡ exts (ren ρ) ren-ext {n}{m}{ρ} = extensionality λ x → lemma {x = x} where lemma : ∀ {x : Fin (suc n)} → (ren (ext ρ)) x ≡ exts (ren ρ) x lemma {x = zero} = refl lemma {x = suc x} = refl rename-subst-ren : ∀ {n m} {ρ : Rename n m} {M : Term n} → rename ρ M ≡ ⟪ ren ρ ⟫ M rename-subst-ren {M = # x} = refl rename-subst-ren {n}{ρ = ρ}{M = ƛ N} = begin rename ρ (ƛ N) ≡⟨⟩ ƛ rename (ext ρ) N ≡⟨ cong ƛ_ (rename-subst-ren {ρ = ext ρ}{M = N}) ⟩ ƛ ⟪ ren (ext ρ) ⟫ N ≡⟨ cong ƛ_ (cong-sub{M = N} ren-ext refl) ⟩ ƛ ⟪ exts (ren ρ) ⟫ N ≡⟨⟩ ⟪ ren ρ ⟫ (ƛ N) ∎ rename-subst-ren {M = L · M} = cong₂ _·_ rename-subst-ren rename-subst-ren exts-cons-shift : ∀ {n m} {σ : Subst n m} → exts σ ≡ (# zero • (σ ⨟ ↑)) exts-cons-shift = extensionality λ x → lemma{x = x} where lemma : ∀ {n m} {σ : Subst n m} {x : Fin (suc n)} → exts σ x ≡ (# zero • (σ ⨟ ↑)) x lemma {x = zero} = refl lemma {x = suc y} = rename-subst-ren subst-zero-cons-ids : ∀ {n}{M : Term n} → subst-zero M ≡ (M • ids) subst-zero-cons-ids = extensionality λ x → lemma {x = x} where lemma : ∀ {n}{M : Term n}{x : Fin (suc n)} → subst-zero M x ≡ (M • ids) x lemma {x = zero} = refl lemma {x = suc x} = refl exts-ids : ∀ {n} → exts ids ≡ ids {suc n} exts-ids {n} = extensionality lemma where lemma : (x : Fin (suc n)) → exts ids x ≡ ids x lemma zero = refl lemma (suc x) = refl sub-id : ∀ {n} {M : Term n} → ⟪ ids ⟫ M ≡ M sub-id {M = # x} = refl sub-id {M = ƛ N} = begin ⟪ ids ⟫ (ƛ N) ≡⟨⟩ ƛ ⟪ exts ids ⟫ N ≡⟨ cong ƛ_ (cong-sub{M = N} exts-ids refl) ⟩ ƛ ⟪ ids ⟫ N ≡⟨ cong ƛ_ sub-id ⟩ ƛ N ∎ sub-id {M = L · M} = cong₂ _·_ sub-id sub-id sub-idR : ∀ {n m} {σ : Subst n m} → (σ ⨟ ids) ≡ σ sub-idR {n}{σ = σ} = begin σ ⨟ ids ≡⟨⟩ ⟪ ids ⟫ ∘ σ ≡⟨ extensionality (λ x → sub-id) ⟩ σ ∎ compose-ext : ∀ {n m k}{ρ : Rename m k} {ρ′ : Rename n m} → ((ext ρ) ∘ (ext ρ′)) ≡ ext (ρ ∘ ρ′) compose-ext = extensionality λ x → lemma {x = x} where lemma : ∀ {n m k}{ρ : Rename m k} {ρ′ : Rename n m} {x : Fin (suc n)} → ((ext ρ) ∘ (ext ρ′)) x ≡ ext (ρ ∘ ρ′) x lemma {x = zero} = refl lemma {x = suc x} = refl compose-rename : ∀ {n m k}{M : Term n}{ρ : Rename m k}{ρ′ : Rename n m} → rename ρ (rename ρ′ M) ≡ rename (ρ ∘ ρ′) M compose-rename {M = # x} = refl compose-rename {n}{m}{k}{ƛ N}{ρ}{ρ′} = cong ƛ_ G where G : rename (ext ρ) (rename (ext ρ′) N) ≡ rename (ext (ρ ∘ ρ′)) N G = begin rename (ext ρ) (rename (ext ρ′) N) ≡⟨ compose-rename{ρ = ext ρ}{ρ′ = ext ρ′} ⟩ rename ((ext ρ) ∘ (ext ρ′)) N ≡⟨ cong-rename compose-ext refl ⟩ rename (ext (ρ ∘ ρ′)) N ∎ compose-rename {M = L · M} = cong₂ _·_ compose-rename compose-rename commute-subst-rename : ∀ {n m}{M : Term n}{σ : Subst n m} {ρ : ∀ {n} → Rename n (suc n)} → (∀ {x : Fin n} → exts σ (ρ x) ≡ rename ρ (σ x)) → subst (exts σ) (rename ρ M) ≡ rename ρ (subst σ M) commute-subst-rename {M = # x} r = r commute-subst-rename{n}{m}{ƛ N}{σ}{ρ} r = cong ƛ_ (commute-subst-rename{suc n}{suc m}{N} {exts σ}{ρ = ρ′} (λ {x} → H {x})) where ρ′ : ∀ {n} → Rename n (suc n) ρ′ {zero} = λ () ρ′ {suc n} = ext ρ H : {x : Fin (suc n)} → exts (exts σ) (ext ρ x) ≡ rename (ext ρ) (exts σ x) H {zero} = refl H {suc y} = begin exts (exts σ) (ext ρ (suc y)) ≡⟨⟩ rename suc (exts σ (ρ y)) ≡⟨ cong (rename suc) r ⟩ rename suc (rename ρ (σ y)) ≡⟨ compose-rename ⟩ rename (suc ∘ ρ) (σ y) ≡⟨ cong-rename refl refl ⟩ rename ((ext ρ) ∘ suc) (σ y) ≡⟨ sym compose-rename ⟩ rename (ext ρ) (rename suc (σ y)) ≡⟨⟩ rename (ext ρ) (exts σ (suc y)) ∎ commute-subst-rename {M = L · M}{ρ = ρ} r = cong₂ _·_ (commute-subst-rename{M = L}{ρ = ρ} r) (commute-subst-rename{M = M}{ρ = ρ} r) exts-seq : ∀ {n m m′} {σ₁ : Subst n m} {σ₂ : Subst m m′} → (exts σ₁ ⨟ exts σ₂) ≡ exts (σ₁ ⨟ σ₂) exts-seq = extensionality λ x → lemma {x = x} where lemma : ∀ {n m m′}{x : Fin (suc n)} {σ₁ : Subst n m}{σ₂ : Subst m m′} → (exts σ₁ ⨟ exts σ₂) x ≡ exts (σ₁ ⨟ σ₂) x lemma {x = zero} = refl lemma {x = suc x}{σ₁}{σ₂} = begin (exts σ₁ ⨟ exts σ₂) (suc x) ≡⟨⟩ ⟪ exts σ₂ ⟫ (rename suc (σ₁ x)) ≡⟨ commute-subst-rename{M = σ₁ x}{σ = σ₂}{ρ = suc} refl ⟩ rename suc (⟪ σ₂ ⟫ (σ₁ x)) ≡⟨⟩ rename suc ((σ₁ ⨟ σ₂) x) ∎ sub-sub : ∀ {n m k}{M : Term n} {σ₁ : Subst n m}{σ₂ : Subst m k} → ⟪ σ₂ ⟫ (⟪ σ₁ ⟫ M) ≡ ⟪ σ₁ ⨟ σ₂ ⟫ M sub-sub {M = # x} = refl sub-sub {n}{m}{k}{ƛ N}{σ₁}{σ₂} = begin ⟪ σ₂ ⟫ (⟪ σ₁ ⟫ (ƛ N)) ≡⟨⟩ ƛ ⟪ exts σ₂ ⟫ (⟪ exts σ₁ ⟫ N) ≡⟨ cong ƛ_ (sub-sub{M = N}{σ₁ = exts σ₁}{σ₂ = exts σ₂}) ⟩ ƛ ⟪ exts σ₁ ⨟ exts σ₂ ⟫ N ≡⟨ cong ƛ_ (cong-sub{M = N} exts-seq refl) ⟩ ƛ ⟪ exts ( σ₁ ⨟ σ₂) ⟫ N ∎ sub-sub {M = L · M} = cong₂ _·_ (sub-sub{M = L}) (sub-sub{M = M}) rename-subst : ∀ {n m m′}{M : Term n}{ρ : Rename n m}{σ : Subst m m′} → ⟪ σ ⟫ (rename ρ M) ≡ ⟪ σ ∘ ρ ⟫ M rename-subst {n}{m}{m′}{M}{ρ}{σ} = begin ⟪ σ ⟫ (rename ρ M) ≡⟨ cong ⟪ σ ⟫ (rename-subst-ren{M = M}) ⟩ ⟪ σ ⟫ (⟪ ren ρ ⟫ M) ≡⟨ sub-sub{M = M} ⟩ ⟪ ren ρ ⨟ σ ⟫ M ≡⟨⟩ ⟪ σ ∘ ρ ⟫ M ∎ sub-assoc : ∀ {n m k Ψ} {σ : Subst n m} {τ : Subst m k} {θ : Subst k Ψ} → (σ ⨟ τ) ⨟ θ ≡ (σ ⨟ τ ⨟ θ) sub-assoc {n}{m}{k}{Ψ}{σ}{τ}{θ} = extensionality λ x → lemma{x = x} where lemma : ∀ {x : Fin n} → ((σ ⨟ τ) ⨟ θ) x ≡ (σ ⨟ τ ⨟ θ) x lemma {x} = begin ((σ ⨟ τ) ⨟ θ) x ≡⟨⟩ ⟪ θ ⟫ (⟪ τ ⟫ (σ x)) ≡⟨ sub-sub{M = σ x} ⟩ ⟪ τ ⨟ θ ⟫ (σ x) ≡⟨⟩ (σ ⨟ τ ⨟ θ) x ∎ subst-zero-exts-cons : ∀ {n m}{σ : Subst n m}{M : Term m} → exts σ ⨟ subst-zero M ≡ (M • σ) subst-zero-exts-cons {n}{m}{σ}{M} = begin exts σ ⨟ subst-zero M ≡⟨ cong-seq exts-cons-shift subst-zero-cons-ids ⟩ (# zero • (σ ⨟ ↑)) ⨟ (M • ids) ≡⟨ sub-dist ⟩ (⟪ M • ids ⟫ (# zero)) • ((σ ⨟ ↑) ⨟ (M • ids)) ≡⟨ cong-cons (sub-head{σ = ids}) refl ⟩ M • ((σ ⨟ ↑) ⨟ (M • ids)) ≡⟨ cong-cons refl (sub-assoc{σ = σ}) ⟩ M • (σ ⨟ (↑ ⨟ (M • ids))) ≡⟨ cong-cons refl (cong-seq{σ = σ} refl (sub-tail{M = M}{σ = ids})) ⟩ M • (σ ⨟ ids) ≡⟨ cong-cons refl (sub-idR{σ = σ}) ⟩ M • σ ∎ subst-commute : ∀ {n m} {N : Term (suc n)} {M : Term n} {σ : Subst n m} → ⟪ exts σ ⟫ N [ ⟪ σ ⟫ M ] ≡ ⟪ σ ⟫ (N [ M ]) subst-commute {n}{m}{N}{M}{σ} = begin ⟪ exts σ ⟫ N [ ⟪ σ ⟫ M ] ≡⟨⟩ ⟪ subst-zero (⟪ σ ⟫ M) ⟫ (⟪ exts σ ⟫ N) ≡⟨ cong-sub {M = ⟪ exts σ ⟫ N} subst-zero-cons-ids refl ⟩ ⟪ ⟪ σ ⟫ M • ids ⟫ (⟪ exts σ ⟫ N) ≡⟨ sub-sub {M = N} ⟩ ⟪ (exts σ) ⨟ ((⟪ σ ⟫ M) • ids) ⟫ N ≡⟨ cong-sub {M = N} (cong-seq exts-cons-shift refl) refl ⟩ ⟪ (# zero • (σ ⨟ ↑)) ⨟ (⟪ σ ⟫ M • ids) ⟫ N ≡⟨ cong-sub {M = N} (sub-dist {M = # zero}) refl ⟩ ⟪ ⟪ ⟪ σ ⟫ M • ids ⟫ (# zero) • ((σ ⨟ ↑) ⨟ (⟪ σ ⟫ M • ids)) ⟫ N ≡⟨⟩ ⟪ ⟪ σ ⟫ M • ((σ ⨟ ↑) ⨟ (⟪ σ ⟫ M • ids)) ⟫ N ≡⟨ cong-sub {M = N} (cong-cons refl (sub-assoc {σ = σ})) refl ⟩ ⟪ ⟪ σ ⟫ M • (σ ⨟ ↑ ⨟ ⟪ σ ⟫ M • ids) ⟫ N ≡⟨ cong-sub {M = N} refl refl ⟩ ⟪ ⟪ σ ⟫ M • (σ ⨟ ids) ⟫ N ≡⟨ cong-sub {M = N} (cong-cons refl (sub-idR {σ = σ})) refl ⟩ ⟪ ⟪ σ ⟫ M • σ ⟫ N ≡⟨ cong-sub {M = N} (cong-cons refl (sub-idL {σ = σ})) refl ⟩ ⟪ ⟪ σ ⟫ M • (ids ⨟ σ) ⟫ N ≡⟨ cong-sub {M = N} (sym sub-dist) refl ⟩ ⟪ M • ids ⨟ σ ⟫ N ≡⟨ sym (sub-sub {M = N}) ⟩ ⟪ σ ⟫ (⟪ M • ids ⟫ N) ≡⟨ cong ⟪ σ ⟫ (sym (cong-sub {M = N} subst-zero-cons-ids refl)) ⟩ ⟪ σ ⟫ (N [ M ]) ∎ rename-subst-commute : ∀ {n m} {N : Term (suc n)} {M : Term n} {ρ : Rename n m } → (rename (ext ρ) N) [ rename ρ M ] ≡ rename ρ (N [ M ]) rename-subst-commute {n}{m}{N}{M}{ρ} = begin (rename (ext ρ) N) [ rename ρ M ] ≡⟨ cong-sub (cong-sub-zero (rename-subst-ren {M = M})) (rename-subst-ren {M = N}) ⟩ (⟪ ren (ext ρ) ⟫ N) [ ⟪ ren ρ ⟫ M ] ≡⟨ cong-sub refl (cong-sub {M = N} ren-ext refl) ⟩ (⟪ exts (ren ρ) ⟫ N) [ ⟪ ren ρ ⟫ M ] ≡⟨ subst-commute {N = N} ⟩ subst (ren ρ) (N [ M ]) ≡⟨ sym (rename-subst-ren) ⟩ rename ρ (N [ M ]) ∎ infix 8 _〔_〕 _〔_〕 : ∀ {n} → Term (suc (suc n)) → Term n → Term (suc n) _〔_〕 N M = subst (exts (subst-zero M)) N substitution-lemma : ∀ {n} {M : Term (suc (suc n))} {N : Term (suc n)} {L : Term n} → M [ N ] [ L ] ≡ (M 〔 L 〕) [ (N [ L ]) ] substitution-lemma {M = M}{N = N}{L = L} = sym (subst-commute {N = M}{M = N}{σ = subst-zero L})
{ "alphanum_fraction": 0.4497333439, "avg_line_length": 29.9832935561, "ext": "agda", "hexsha": "643072c65c8d38e0dc6d8d14da454c55b6777b25", "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": "2fa17f7738cc7da967375be928137adc4be38696", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "iwilare/church-rosser", "max_forks_repo_path": "Substitution.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2fa17f7738cc7da967375be928137adc4be38696", "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": "iwilare/church-rosser", "max_issues_repo_path": "Substitution.agda", "max_line_length": 85, "max_stars_count": 5, "max_stars_repo_head_hexsha": "2fa17f7738cc7da967375be928137adc4be38696", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "iwilare/church-rosser", "max_stars_repo_path": "Substitution.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-22T01:43:09.000Z", "max_stars_repo_stars_event_min_datetime": "2020-06-02T07:27:54.000Z", "num_tokens": 5931, "size": 12563 }
module Category.Functor.Either where open import Agda.Primitive using (_⊔_) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Category.Functor using (RawFunctor ; module RawFunctor ) open import Category.Applicative using (RawApplicative; module RawApplicative) open import Function using (_∘_) Either : ∀ {l₁ l₂} (A : Set l₁) (B : Set l₂) → Set (l₁ ⊔ l₂) Either = _⊎_ eitherFunctor : ∀ {l₁ l₂} {A : Set l₁} → RawFunctor (Either {l₁} {l₂} A) eitherFunctor = record { _<$>_ = λ f → λ { (inj₁ z) → inj₁ z ; (inj₂ a) → inj₂ (f a) } } eitherApplicative : ∀ {l₁} {A : Set l₁} → RawApplicative (Either {l₁} {l₁} A) eitherApplicative = record { pure = inj₂ ; _⊛_ = λ { (inj₁ a) → λ _ → inj₁ a ; (inj₂ f) → λ { (inj₁ a) → inj₁ a ; (inj₂ b) → inj₂ (f b) } } }
{ "alphanum_fraction": 0.6291560102, "avg_line_length": 35.5454545455, "ext": "agda", "hexsha": "76b1c3ae681c9167786930e133f5f21bd6e1bf5a", "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": "308afeeaa905870dbf1a995fa82e8825dfaf2d74", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "crisoagf/agda-optics", "max_forks_repo_path": "src/Category/Functor/Either.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "308afeeaa905870dbf1a995fa82e8825dfaf2d74", "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": "crisoagf/agda-optics", "max_issues_repo_path": "src/Category/Functor/Either.agda", "max_line_length": 100, "max_stars_count": null, "max_stars_repo_head_hexsha": "308afeeaa905870dbf1a995fa82e8825dfaf2d74", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "crisoagf/agda-optics", "max_stars_repo_path": "src/Category/Functor/Either.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 306, "size": 782 }
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.FiniteMultiset.Base where open import Cubical.Foundations.Prelude open import Cubical.HITs.SetTruncation open import Cubical.Foundations.HLevels private variable A : Type₀ infixr 5 _∷_ data FMSet (A : Type₀) : Type₀ where [] : FMSet A _∷_ : (x : A) → (xs : FMSet A) → FMSet A comm : ∀ x y xs → x ∷ y ∷ xs ≡ y ∷ x ∷ xs trunc : isSet (FMSet A) pattern [_] x = x ∷ [] module FMSetElim {ℓ} {B : FMSet A → Type ℓ} ([]* : B []) (_∷*_ : (x : A) {xs : FMSet A} → B xs → B (x ∷ xs)) (comm* : (x y : A) {xs : FMSet A} (b : B xs) → PathP (λ i → B (comm x y xs i)) (x ∷* (y ∷* b)) (y ∷* (x ∷* b))) (trunc* : (xs : FMSet A) → isSet (B xs)) where f : (xs : FMSet A) → B xs f [] = []* f (x ∷ xs) = x ∷* f xs f (comm x y xs i) = comm* x y (f xs) i f (trunc xs zs p q i j) = isOfHLevel→isOfHLevelDep {n = 2} trunc* (f xs) (f zs) (cong f p) (cong f q) (trunc xs zs p q) i j module FMSetElimProp {ℓ} {B : FMSet A → Type ℓ} (BProp : {xs : FMSet A} → isProp (B xs)) ([]* : B []) (_∷*_ : (x : A) {xs : FMSet A} → B xs → B (x ∷ xs)) where f : (xs : FMSet A) → B xs f = FMSetElim.f []* _∷*_ (λ x y {xs} b → toPathP (BProp (transp (λ i → B (comm x y xs i)) i0 (x ∷* (y ∷* b))) (y ∷* (x ∷* b)))) (λ xs → isProp→isSet BProp) module FMSetRec {ℓ} {B : Type ℓ} (BType : isSet B) ([]* : B) (_∷*_ : A → B → B) (comm* : (x y : A) (b : B) → x ∷* (y ∷* b) ≡ y ∷* (x ∷* b)) where f : FMSet A → B f = FMSetElim.f []* (λ x b → x ∷* b) (λ x y b → comm* x y b) (λ _ → BType)
{ "alphanum_fraction": 0.4921334172, "avg_line_length": 31.78, "ext": "agda", "hexsha": "617fb7a89ddd27c5a54e75a0a2c8d991e6dadd59", "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": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cj-xu/cubical", "max_forks_repo_path": "Cubical/HITs/FiniteMultiset/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "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": "cj-xu/cubical", "max_issues_repo_path": "Cubical/HITs/FiniteMultiset/Base.agda", "max_line_length": 102, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cj-xu/cubical", "max_stars_repo_path": "Cubical/HITs/FiniteMultiset/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 728, "size": 1589 }
-- Σ type (also used as existential) and -- cartesian product (also used as conjunction). {-# OPTIONS --without-K --safe #-} module Tools.Product where open import Agda.Primitive open import Agda.Builtin.Sigma public using (Σ; _,_) open import Agda.Builtin.Sigma using (fst; snd) infixr 2 _×_ -- Dependent pair type (aka dependent sum, Σ type). private variable ℓ₁ ℓ₂ ℓ₃ : Level proj₁ : ∀ {A : Set ℓ₁} {B : A → Set ℓ₂} → Σ A B → A proj₁ = fst proj₂ : ∀ {A : Set ℓ₁} {B : A → Set ℓ₂} → (S : Σ A B) → B (fst S) proj₂ = snd -- Existential quantification. ∃ : {A : Set ℓ₁} → (A → Set ℓ₂) → Set (ℓ₁ ⊔ ℓ₂) ∃ = Σ _ ∃₂ : {A : Set ℓ₁} {B : A → Set ℓ₂} (C : (x : A) → B x → Set ℓ₃) → Set (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃) ∃₂ C = ∃ λ a → ∃ λ b → C a b -- Cartesian product. _×_ : (A : Set ℓ₁) (B : Set ℓ₂) → Set (ℓ₁ ⊔ ℓ₂) A × B = Σ A (λ x → B)
{ "alphanum_fraction": 0.5678571429, "avg_line_length": 21.5384615385, "ext": "agda", "hexsha": "34de47eb49a40fca6baad10e6640577a5c8f439a", "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": "Tools/Product.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": "Tools/Product.agda", "max_line_length": 65, "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": "Tools/Product.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 360, "size": 840 }
-- When defining types by recursion it is sometimes difficult to infer implicit -- arguments. This module illustrates the problem and shows how to get around -- it for the example of vectors of a given length. module DataByRecursion where data Nat : Set where zero : Nat suc : Nat -> Nat data Nil : Set where nil' : Nil data Cons (A As : Set) : Set where _::'_ : A -> As -> Cons A As mutual Vec' : Set -> Nat -> Set Vec' A zero = Nil Vec' A (suc n) = Cons A (Vec A n) data Vec (A : Set)(n : Nat) : Set where vec : Vec' A n -> Vec A n nil : {A : Set} -> Vec A zero nil = vec nil' _::_ : {A : Set}{n : Nat} -> A -> Vec A n -> Vec A (suc n) x :: xs = vec (x ::' xs) map : {n : Nat}{A B : Set} -> (A -> B) -> Vec A n -> Vec B n map {zero} f (vec nil') = nil map {suc n} f (vec (x ::' xs)) = f x :: map f xs
{ "alphanum_fraction": 0.5680473373, "avg_line_length": 23.4722222222, "ext": "agda", "hexsha": "8e210e0b3f214476c644ae7c3774a73d71bb9c35", "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": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_path": "tests/beyond/DataByRecursion.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "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": "andrejtokarcik/agda-semantics", "max_issues_repo_path": "tests/beyond/DataByRecursion.agda", "max_line_length": 79, "max_stars_count": 3, "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_path": "tests/beyond/DataByRecursion.agda", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "num_tokens": 291, "size": 845 }
module FSC where -- focused sequent calculus {- open import Relation.Binary.PropositionalEquality open import Data.Nat hiding (_>_) -} open import StdLibStuff open import Syntax data FSC-Ctx (n : ℕ) : Ctx n → Set where ε : FSC-Ctx n ε _∷_ : {Γ : Ctx n} → (t : Type n) → FSC-Ctx n Γ → FSC-Ctx n (t ∷ Γ) _∷h_ : {Γ : Ctx n} → Form Γ $o → FSC-Ctx n Γ → FSC-Ctx n Γ data HVar {n : ℕ} : {Γ-t : Ctx n} → FSC-Ctx n Γ-t → Set where zero : {Γ-t : Ctx n} {h : Form Γ-t $o} {Γ : FSC-Ctx n Γ-t} → HVar (h ∷h Γ) succ : {Γ-t : Ctx n} {h : Form Γ-t $o} {Γ : FSC-Ctx n Γ-t} → HVar Γ → HVar (h ∷h Γ) skip : {Γ-t : Ctx n} {t : Type n} {Γ : FSC-Ctx n Γ-t} → HVar Γ → HVar (t ∷ Γ) lookup-hyp : {n : ℕ} {Γ-t : Ctx n} (Γ : FSC-Ctx n Γ-t) → HVar Γ → Form Γ-t $o lookup-hyp .(h ∷h Γ) (zero {._} {h} {Γ}) = h lookup-hyp .(h ∷h Γ) (succ {._} {h} {Γ} x) = lookup-hyp Γ x lookup-hyp .(t ∷ Γ) (skip {Γ-t} {t} {Γ} x) = weak (lookup-hyp Γ x) mutual data _⊢_ {n : ℕ} {Γ-t : Ctx n} (Γ : FSC-Ctx n Γ-t) : Form Γ-t $o → Set where ||-I-l : {F G : Form Γ-t $o} → Γ ⊢ F → Γ ⊢ (F || G) ||-I-r : {F G : Form Γ-t $o} → Γ ⊢ G → Γ ⊢ (F || G) &-I : {F G : Form Γ-t $o} → Γ ⊢ F → Γ ⊢ G → Γ ⊢ (F & G) ?-I : {t : Type n} {F : Form (t ∷ Γ-t) $o} (G : Form Γ-t t) → Γ ⊢ sub G F → Γ ⊢ (?[ t ] F) ?'-I : {t : Type n} {F : Form Γ-t (t > $o)} (G : Form Γ-t t) → Γ ⊢ (F · G) → Γ ⊢ (?'[ t ] F) =>-I : {F G : Form Γ-t $o} → (F ∷h Γ) ⊢ G → Γ ⊢ (F => G) ~-I : {F : Form Γ-t $o} → (F ∷h Γ) ⊢ $false → Γ ⊢ (~ F) !-I : {t : Type n} {F : Form (t ∷ Γ-t) $o} → (t ∷ Γ) ⊢ F → Γ ⊢ (![ t ] F) !'-I : {t : Type n} {F : Form Γ-t (t > $o)} → (t ∷ Γ) ⊢ (weak F · ($ this {refl})) → Γ ⊢ (!'[ t ] F) $true-I : Γ ⊢ $true ==-I : {t : Type n} {F G : Form Γ-t t} → Γ ⊢ t ∋ F == G → Γ ⊢ (F == G) -- compute eq elim : {F : Form Γ-t $o} → (x : HVar Γ) → Γ , lookup-hyp Γ x ⊢ F → Γ ⊢ F ac : {t : Type n} {F : Form Γ-t $o} → Γ , (![ t > $o ] ((?[ t ] ($ (next this) {refl} · $ this {refl})) => ($ this {refl} · (ι t ($ (next this) {refl} · $ this {refl}))))) ⊢ F → Γ ⊢ F ac' : {t : Type n} {F : Form Γ-t $o} → Γ , (![ t > $o ] ((?'[ t ] ($ this {refl})) => ($ this {refl} · (ι' t ($ this {refl}))))) ⊢ F → Γ ⊢ F raa : {F : Form Γ-t $o} → Γ ⊢ (~ (~ F)) → Γ ⊢ F reduce : {t u : Type n} {F : Form Γ-t u → Form Γ-t $o} {G : Form (t ∷ Γ-t) u} {H : Form Γ-t t} → Γ ⊢ (F (sub H G)) → Γ ⊢ (F ((^[ t ] G) · H)) data _,_⊢_ {n : ℕ} {Γ-t : Ctx n} (Γ : FSC-Ctx n Γ-t) : Form Γ-t $o → Form Γ-t $o → Set where use : {F G : Form Γ-t $o} → Γ ⊢ $o ∋ G ↔ F → Γ , F ⊢ G $false-E : {H : Form Γ-t $o} → Γ , $false ⊢ H ~-E : {F H : Form Γ-t $o} → Γ ⊢ F → Γ , ~ F ⊢ H ||-E : {F G H : Form Γ-t $o} → Γ ⊢ (F => H) → Γ ⊢ (G => H) → Γ , F || G ⊢ H &-E-l : {F G H : Form Γ-t $o} → Γ , F ⊢ H → Γ , F & G ⊢ H &-E-r : {F G H : Form Γ-t $o} → Γ , G ⊢ H → Γ , F & G ⊢ H ?-E : {t : Type n} {F : Form (t ∷ Γ-t) $o} {H : Form Γ-t $o} → Γ , sub (ι t F) F ⊢ H → Γ , ?[ t ] F ⊢ H ?'-E : {t : Type n} {F : Form Γ-t (t > $o)} {H : Form Γ-t $o} → Γ , (F · ι' t F) ⊢ H → Γ , ?'[ t ] F ⊢ H =>-E : {F G H : Form Γ-t $o} → Γ ⊢ F → Γ , G ⊢ H → Γ , F => G ⊢ H !-E : {t : Type n} {F : Form (t ∷ Γ-t) $o} {H : Form Γ-t $o} (G : Form Γ-t t) → Γ , sub G F ⊢ H → Γ , ![ t ] F ⊢ H !'-E : {t : Type n} {F : Form Γ-t (t > $o)} {H : Form Γ-t $o} (G : Form Γ-t t) → Γ , (F · G) ⊢ H → Γ , !'[ t ] F ⊢ H r-bool-ext : {F G H : Form Γ-t $o} → Γ , ((F => G) & (G => F)) ⊢ H → Γ , F == G ⊢ H -- compute eq r-fun-ext : {t u : Type n} {F G : Form Γ-t (t > u)} {H : Form Γ-t $o} (I : Form Γ-t t) → Γ , (F · I) == (G · I) ⊢ H → Γ , F == G ⊢ H -- compute eq reduce : {t u : Type n} {F : Form Γ-t u → Form Γ-t $o} {G : Form (t ∷ Γ-t) u} {H : Form Γ-t t} {I : Form Γ-t $o} → Γ , (F (sub H G)) ⊢ I → Γ , (F ((^[ t ] G) · H)) ⊢ I data _⊢_∋_==_ {n : ℕ} {Γ-t : Ctx n} (Γ : FSC-Ctx n Γ-t) : (t : Type n) (F G : Form Γ-t t) → Set where simp : {t : Type n} {F G : Form Γ-t t} → Γ ⊢ t ∋ F ↔ G → Γ ⊢ t ∋ F == G step : {t : Type n} {F G : Form Γ-t t} (F' G' : Form Γ-t t) → (x : HVar Γ) → Γ , lookup-hyp Γ x ⊢ F' == G' → Γ ⊢ t ∋ F ↔ F' → Γ ⊢ t ∋ G' == G → Γ ⊢ t ∋ F == G bool-ext : {F G : Form Γ-t $o} → Γ ⊢ ((F => G) & (G => F)) → Γ ⊢ $o ∋ F == G fun-ext : {t u : Type n} {F G : Form Γ-t (t > u)} → (t ∷ Γ) ⊢ u ∋ ((weak F) · $ this {refl}) == ((weak G) · $ this {refl}) → Γ ⊢ (t > u) ∋ F == G data _⊢_∋_↔_ {n : ℕ} {Γ-t : Ctx n} (Γ : FSC-Ctx n Γ-t) : (t : Type n) → Form Γ-t t → Form Γ-t t → Set where head-var : (t : Type n) (x : Var Γ-t) (p : lookup-Var Γ-t x ≡ t) → Γ ⊢ t ∋ $ x {p} ↔ $ x {p} head-const : (t : Type n) (c : Form Γ-t t) → Γ ⊢ t ∋ c ↔ c head-app : (t₁ t₂ : Type n) (F₁ F₂ : Form Γ-t (t₁ > t₂)) (G₁ G₂ : Form Γ-t t₁) → Γ ⊢ (t₁ > t₂) ∋ F₁ == F₂ → Γ ⊢ t₁ ∋ G₁ == G₂ → Γ ⊢ t₂ ∋ (F₁ · G₁) ↔ (F₂ · G₂) head-lam : (t₁ t₂ : Type n) (F₁ F₂ : Form (t₁ ∷ Γ-t) t₂) → (t₁ ∷ Γ) ⊢ t₂ ∋ F₁ == F₂ → Γ ⊢ (t₁ > t₂) ∋ (lam t₁ F₁) ↔ (lam t₁ F₂) head-lam-eta-left : (t₁ t₂ : Type n) (F₁ : Form Γ-t (t₁ > t₂)) (F₂ : Form (t₁ ∷ Γ-t) t₂) → (t₁ ∷ Γ) ⊢ t₂ ∋ (weak F₁ · $ this {refl}) == F₂ → Γ ⊢ (t₁ > t₂) ∋ F₁ ↔ lam t₁ F₂ head-lam-eta-right : (t₁ t₂ : Type n) (F₁ : Form Γ-t (t₁ > t₂)) (F₂ : Form (t₁ ∷ Γ-t) t₂) → (t₁ ∷ Γ) ⊢ t₂ ∋ F₂ == (weak F₁ · $ this {refl}) → Γ ⊢ (t₁ > t₂) ∋ lam t₁ F₂ ↔ F₁ reduce-l : {t u v : Type n} {F₁ : Form Γ-t v → Form Γ-t t} {G : Form (u ∷ Γ-t) v} {H : Form Γ-t u} {F₂ : Form Γ-t t} → Γ ⊢ t ∋ (F₁ (sub H G)) ↔ F₂ → Γ ⊢ t ∋ (F₁ ((^[ u ] G) · H)) ↔ F₂ reduce-r : {t u v : Type n} {F₂ : Form Γ-t v → Form Γ-t t} {G : Form (u ∷ Γ-t) v} {H : Form Γ-t u} {F₁ : Form Γ-t t} → Γ ⊢ t ∋ F₁ ↔ (F₂ (sub H G)) → Γ ⊢ t ∋ F₁ ↔ (F₂ ((^[ u ] G) · H)) data _,_⊢_==_ {n : ℕ} {Γ-t : Ctx n} {t : Type n} (Γ : FSC-Ctx n Γ-t) : Form Γ-t $o → Form Γ-t t → Form Γ-t t → Set where use : {F G : Form Γ-t t} → Γ , F == G ⊢ F == G use' : {F G : Form Γ-t t} {H : Form Γ-t $o} → headNorm 2 (F == G) ≡ headNorm 2 H → Γ , H ⊢ F == G use-sym : {F G : Form Γ-t t} → Γ , F == G ⊢ G == F -- compute eq &-E-l : {F G : Form Γ-t $o} {H₁ H₂ : Form Γ-t t} → Γ , F ⊢ H₁ == H₂ → Γ , F & G ⊢ H₁ == H₂ &-E-r : {F G : Form Γ-t $o} {H₁ H₂ : Form Γ-t t} → Γ , G ⊢ H₁ == H₂ → Γ , F & G ⊢ H₁ == H₂ ?-E : {u : Type n} {F : Form (u ∷ Γ-t) $o} {H₁ H₂ : Form Γ-t t} → Γ , sub (ι u F) F ⊢ H₁ == H₂ → Γ , ?[ u ] F ⊢ H₁ == H₂ ?'-E : {u : Type n} {F : Form Γ-t (u > $o)} {H₁ H₂ : Form Γ-t t} → Γ , (F · ι' u F) ⊢ H₁ == H₂ → Γ , ?'[ u ] F ⊢ H₁ == H₂ =>-E : {F G : Form Γ-t $o} {H₁ H₂ : Form Γ-t t} → Γ ⊢ F → Γ , G ⊢ H₁ == H₂ → Γ , F => G ⊢ H₁ == H₂ !-E : {u : Type n} {F : Form (u ∷ Γ-t) $o} {H₁ H₂ : Form Γ-t t} (G : Form Γ-t u) → Γ , sub G F ⊢ H₁ == H₂ → Γ , ![ u ] F ⊢ H₁ == H₂ !'-E : {u : Type n} {F : Form Γ-t (u > $o)} {H₁ H₂ : Form Γ-t t} (G : Form Γ-t u) → Γ , (F · G) ⊢ H₁ == H₂ → Γ , !'[ u ] F ⊢ H₁ == H₂ r-bool-ext : {F G : Form Γ-t $o} {H I : Form Γ-t t} → Γ , ((F => G) & (G => F)) ⊢ H == I → Γ , F == G ⊢ H == I -- compute eq r-fun-ext : {u v : Type n} {F G : Form Γ-t (u > v)} {H I : Form Γ-t t} (J : Form Γ-t u) → Γ , (F · J) == (G · J) ⊢ H == I → Γ , F == G ⊢ H == I -- compute eq reduce : {u v : Type n} {F : Form Γ-t v → Form Γ-t $o} {G : Form (u ∷ Γ-t) v} {H : Form Γ-t u} {I₁ I₂ : Form Γ-t t} → Γ , (F (sub H G)) ⊢ I₁ == I₂ → Γ , (F ((^[ u ] G) · H)) ⊢ I₁ == I₂
{ "alphanum_fraction": 0.3841830065, "avg_line_length": 33.7004405286, "ext": "agda", "hexsha": "6e49668de809bb477e7fec8157db6971eaef7c78", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-01-15T11:51:19.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-17T20:28:10.000Z", "max_forks_repo_head_hexsha": "032efd5f42e4b56d436ac8e0c3c0f5127b8dc1f7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "frelindb/agsyHOL", "max_forks_repo_path": "soundness/FSC.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "032efd5f42e4b56d436ac8e0c3c0f5127b8dc1f7", "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": "frelindb/agsyHOL", "max_issues_repo_path": "soundness/FSC.agda", "max_line_length": 142, "max_stars_count": 17, "max_stars_repo_head_hexsha": "032efd5f42e4b56d436ac8e0c3c0f5127b8dc1f7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "frelindb/agsyHOL", "max_stars_repo_path": "soundness/FSC.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-19T20:53:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-04T14:38:28.000Z", "num_tokens": 3978, "size": 7650 }
-- Andreas, 2016-09-20, issue #2197 reported by m0davis {-# OPTIONS --allow-unsolved-metas #-} -- {-# OPTIONS -v tc.pos:20 -v tc.meta.eta:20 #-} record R : Set where inductive field foo : R bar : R bar = {!!} -- This used to loop due to infinite eta-expansion. -- Should check now.
{ "alphanum_fraction": 0.62, "avg_line_length": 16.6666666667, "ext": "agda", "hexsha": "8e950ff45d39c7e4d493308f77ea10ba9acd7b28", "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/Issue2197.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/Issue2197.agda", "max_line_length": 55, "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/Issue2197.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": 96, "size": 300 }
module Common.Issue481ParametrizedModule (A : Set1) where id : A → A id x = x postulate Bla : Set
{ "alphanum_fraction": 0.6960784314, "avg_line_length": 12.75, "ext": "agda", "hexsha": "db77e96ee07f30e7960ffb3bae63fc8a8018331d", "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/Common/Issue481ParametrizedModule.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/Common/Issue481ParametrizedModule.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/Common/Issue481ParametrizedModule.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": 37, "size": 102 }
test = forall _⦇_ → Set
{ "alphanum_fraction": 0.625, "avg_line_length": 12, "ext": "agda", "hexsha": "e83c6016fa3d34c4dfd4d320bff5be6cb4a0cc80", "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/InvalidNamePartIdiom.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/InvalidNamePartIdiom.agda", "max_line_length": 23, "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/InvalidNamePartIdiom.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": 11, "size": 24 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics module lib.types.Sigma where -- pointed [Σ] ⊙Σ : ∀ {i j} (X : Ptd i) → (de⊙ X → Ptd j) → Ptd (lmax i j) ⊙Σ ⊙[ A , a₀ ] Y = ⊙[ Σ A (de⊙ ∘ Y) , (a₀ , pt (Y a₀)) ] -- Cartesian product _×_ : ∀ {i j} (A : Type i) (B : Type j) → Type (lmax i j) A × B = Σ A (λ _ → B) _⊙×_ : ∀ {i j} → Ptd i → Ptd j → Ptd (lmax i j) X ⊙× Y = ⊙Σ X (λ _ → Y) infixr 80 _×_ _⊙×_ -- XXX Do we really need two versions of [⊙fst]? ⊙fstᵈ : ∀ {i j} {X : Ptd i} (Y : de⊙ X → Ptd j) → ⊙Σ X Y ⊙→ X ⊙fstᵈ Y = fst , idp ⊙fst : ∀ {i j} {X : Ptd i} {Y : Ptd j} → X ⊙× Y ⊙→ X ⊙fst = ⊙fstᵈ _ ⊙snd : ∀ {i j} {X : Ptd i} {Y : Ptd j} → X ⊙× Y ⊙→ Y ⊙snd = (snd , idp) fanout : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} → (A → B) → (A → C) → (A → B × C) fanout f g x = f x , g x ⊙fanout-pt : ∀ {i j} {A : Type i} {B : Type j} {a₀ a₁ : A} (p : a₀ == a₁) {b₀ b₁ : B} (q : b₀ == b₁) → (a₀ , b₀) == (a₁ , b₁) :> A × B ⊙fanout-pt = pair×= ⊙fanout : ∀ {i j k} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} → X ⊙→ Y → X ⊙→ Z → X ⊙→ Y ⊙× Z ⊙fanout (f , fpt) (g , gpt) = fanout f g , ⊙fanout-pt fpt gpt diag : ∀ {i} {A : Type i} → (A → A × A) diag a = a , a ⊙diag : ∀ {i} {X : Ptd i} → X ⊙→ X ⊙× X ⊙diag = ((λ x → (x , x)) , idp) ⊙×-inl : ∀ {i j} (X : Ptd i) (Y : Ptd j) → X ⊙→ X ⊙× Y ⊙×-inl X Y = (λ x → x , pt Y) , idp ⊙×-inr : ∀ {i j} (X : Ptd i) (Y : Ptd j) → Y ⊙→ X ⊙× Y ⊙×-inr X Y = (λ y → pt X , y) , idp ⊙fst-fanout : ∀ {i j k} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} (f : X ⊙→ Y) (g : X ⊙→ Z) → ⊙fst ⊙∘ ⊙fanout f g == f ⊙fst-fanout (f , idp) (g , idp) = idp ⊙snd-fanout : ∀ {i j k} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} (f : X ⊙→ Y) (g : X ⊙→ Z) → ⊙snd ⊙∘ ⊙fanout f g == g ⊙snd-fanout (f , idp) (g , idp) = idp ⊙fanout-pre∘ : ∀ {i j k l} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} {W : Ptd l} (f : Y ⊙→ Z) (g : Y ⊙→ W) (h : X ⊙→ Y) → ⊙fanout f g ⊙∘ h == ⊙fanout (f ⊙∘ h) (g ⊙∘ h) ⊙fanout-pre∘ (f , idp) (g , idp) (h , idp) = idp module _ {i j} {A : Type i} {B : A → Type j} where pair : (a : A) (b : B a) → Σ A B pair a b = (a , b) -- pair= has already been defined fst= : {ab a'b' : Σ A B} (p : ab == a'b') → (fst ab == fst a'b') fst= = ap fst snd= : {ab a'b' : Σ A B} (p : ab == a'b') → (snd ab == snd a'b' [ B ↓ fst= p ]) snd= {._} {_} idp = idp fst=-β : {a a' : A} (p : a == a') {b : B a} {b' : B a'} (q : b == b' [ B ↓ p ]) → fst= (pair= p q) == p fst=-β idp idp = idp snd=-β : {a a' : A} (p : a == a') {b : B a} {b' : B a'} (q : b == b' [ B ↓ p ]) → snd= (pair= p q) == q [ (λ v → b == b' [ B ↓ v ]) ↓ fst=-β p q ] snd=-β idp idp = idp pair=-η : {ab a'b' : Σ A B} (p : ab == a'b') → p == pair= (fst= p) (snd= p) pair=-η {._} {_} idp = idp pair== : {a a' : A} {p p' : a == a'} (α : p == p') {b : B a} {b' : B a'} {q : b == b' [ B ↓ p ]} {q' : b == b' [ B ↓ p' ]} (β : q == q' [ (λ u → b == b' [ B ↓ u ]) ↓ α ]) → pair= p q == pair= p' q' pair== idp idp = idp module _ {i j} {A : Type i} {B : Type j} where fst×= : {ab a'b' : A × B} (p : ab == a'b') → (fst ab == fst a'b') fst×= = ap fst snd×= : {ab a'b' : A × B} (p : ab == a'b') → (snd ab == snd a'b') snd×= = ap snd fst×=-β : {a a' : A} (p : a == a') {b b' : B} (q : b == b') → fst×= (pair×= p q) == p fst×=-β idp idp = idp snd×=-β : {a a' : A} (p : a == a') {b b' : B} (q : b == b') → snd×= (pair×= p q) == q snd×=-β idp idp = idp pair×=-η : {ab a'b' : A × B} (p : ab == a'b') → p == pair×= (fst×= p) (snd×= p) pair×=-η {._} {_} idp = idp module _ {i j} {A : Type i} {B : A → Type j} where =Σ : (x y : Σ A B) → Type (lmax i j) =Σ (a , b) (a' , b') = Σ (a == a') (λ p → b == b' [ B ↓ p ]) =Σ-econv : (x y : Σ A B) → (=Σ x y) ≃ (x == y) =Σ-econv x y = equiv (λ pq → pair= (fst pq) (snd pq)) (λ p → fst= p , snd= p) (λ p → ! (pair=-η p)) (λ pq → pair= (fst=-β (fst pq) (snd pq)) (snd=-β (fst pq) (snd pq))) =Σ-conv : (x y : Σ A B) → (=Σ x y) == (x == y) =Σ-conv x y = ua (=Σ-econv x y) Σ= : ∀ {i j} {A A' : Type i} (p : A == A') {B : A → Type j} {B' : A' → Type j} (q : B == B' [ (λ X → (X → Type j)) ↓ p ]) → Σ A B == Σ A' B' Σ= idp idp = idp instance Σ-level : ∀ {i j} {n : ℕ₋₂} {A : Type i} {P : A → Type j} → has-level n A → ((x : A) → has-level n (P x)) → has-level n (Σ A P) Σ-level {n = ⟨-2⟩} p q = has-level-in ((contr-center p , (contr-center (q (contr-center p)))) , lemma) where abstract lemma = λ y → pair= (contr-path p _) (from-transp! _ _ (contr-path (q _) _)) Σ-level {n = S n} p q = has-level-in lemma where abstract lemma = λ x y → equiv-preserves-level (=Σ-econv x y) {{Σ-level (has-level-apply p _ _) (λ _ → equiv-preserves-level ((to-transp-equiv _ _)⁻¹) {{has-level-apply (q _) _ _}})}} ×-level : ∀ {i j} {n : ℕ₋₂} {A : Type i} {B : Type j} → (has-level n A → has-level n B → has-level n (A × B)) ×-level pA pB = Σ-level pA (λ x → pB) -- Equivalences in a Σ-type Σ-fmap-l : ∀ {i j k} {A : Type i} {B : Type j} (P : B → Type k) → (f : A → B) → (Σ A (P ∘ f) → Σ B P) Σ-fmap-l P f (a , r) = (f a , r) ×-fmap-l : ∀ {i₀ i₁ j} {A₀ : Type i₀} {A₁ : Type i₁} (B : Type j) → (f : A₀ → A₁) → (A₀ × B → A₁ × B) ×-fmap-l B = Σ-fmap-l (λ _ → B) Σ-isemap-l : ∀ {i j k} {A : Type i} {B : Type j} (P : B → Type k) {h : A → B} → is-equiv h → is-equiv (Σ-fmap-l P h) Σ-isemap-l {A = A} {B = B} P {h} e = is-eq _ g f-g g-f where f = Σ-fmap-l P h g : Σ B P → Σ A (P ∘ h) g (b , s) = (is-equiv.g e b , transport P (! (is-equiv.f-g e b)) s) f-g : ∀ y → f (g y) == y f-g (b , s) = pair= (is-equiv.f-g e b) (transp-↓ P (is-equiv.f-g e b) s) g-f : ∀ x → g (f x) == x g-f (a , r) = pair= (is-equiv.g-f e a) (transport (λ q → transport P (! q) r == r [ P ∘ h ↓ is-equiv.g-f e a ]) (is-equiv.adj e a) (transp-ap-↓ P h (is-equiv.g-f e a) r)) ×-isemap-l : ∀ {i₀ i₁ j} {A₀ : Type i₀} {A₁ : Type i₁} (B : Type j) {h : A₀ → A₁} → is-equiv h → is-equiv (×-fmap-l B h) ×-isemap-l B = Σ-isemap-l (λ _ → B) Σ-emap-l : ∀ {i j k} {A : Type i} {B : Type j} (P : B → Type k) → (e : A ≃ B) → (Σ A (P ∘ –> e) ≃ Σ B P) Σ-emap-l P (f , e) = _ , Σ-isemap-l P e ×-emap-l : ∀ {i₀ i₁ j} {A₀ : Type i₀} {A₁ : Type i₁} (B : Type j) → (e : A₀ ≃ A₁) → (A₀ × B ≃ A₁ × B) ×-emap-l B = Σ-emap-l (λ _ → B) Σ-fmap-r : ∀ {i j k} {A : Type i} {B : A → Type j} {C : A → Type k} → (∀ x → B x → C x) → (Σ A B → Σ A C) Σ-fmap-r h (a , b) = (a , h a b) ×-fmap-r : ∀ {i j₀ j₁} (A : Type i) {B₀ : Type j₀} {B₁ : Type j₁} → (h : B₀ → B₁) → (A × B₀ → A × B₁) ×-fmap-r A h = Σ-fmap-r (λ _ → h) Σ-isemap-r : ∀ {i j k} {A : Type i} {B : A → Type j} {C : A → Type k} {h : ∀ x → B x → C x} → (∀ x → is-equiv (h x)) → is-equiv (Σ-fmap-r h) Σ-isemap-r {A = A} {B = B} {C = C} {h} k = is-eq _ g f-g g-f where f = Σ-fmap-r h g : Σ A C → Σ A B g (a , c) = (a , is-equiv.g (k a) c) f-g : ∀ p → f (g p) == p f-g (a , c) = pair= idp (is-equiv.f-g (k a) c) g-f : ∀ p → g (f p) == p g-f (a , b) = pair= idp (is-equiv.g-f (k a) b) ×-isemap-r : ∀ {i j₀ j₁} (A : Type i) {B₀ : Type j₀} {B₁ : Type j₁} → {h : B₀ → B₁} → is-equiv h → is-equiv (×-fmap-r A h) ×-isemap-r A e = Σ-isemap-r (λ _ → e) Σ-emap-r : ∀ {i j k} {A : Type i} {B : A → Type j} {C : A → Type k} → (∀ x → B x ≃ C x) → (Σ A B ≃ Σ A C) Σ-emap-r k = _ , Σ-isemap-r (λ x → snd (k x)) ×-emap-r : ∀ {i j₀ j₁} (A : Type i) {B₀ : Type j₀} {B₁ : Type j₁} → (e : B₀ ≃ B₁) → (A × B₀ ≃ A × B₁) ×-emap-r A e = Σ-emap-r (λ _ → e) hfiber-Σ-fmap-r : ∀ {i j k} {A : Type i} {B : A → Type j} {C : A → Type k} → (h : ∀ x → B x → C x) → {a : A} → (c : C a) → hfiber (Σ-fmap-r h) (a , c) ≃ hfiber (h a) c hfiber-Σ-fmap-r h {a} c = equiv to from to-from from-to where to : hfiber (Σ-fmap-r h) (a , c) → hfiber (h a) c to ((_ , b) , idp) = b , idp from : hfiber (h a) c → hfiber (Σ-fmap-r h) (a , c) from (b , idp) = (a , b) , idp abstract to-from : (x : hfiber (h a) c) → to (from x) == x to-from (b , idp) = idp from-to : (x : hfiber (Σ-fmap-r h) (a , c)) → from (to x) == x from-to ((_ , b) , idp) = idp {- -- 2016/08/20 favonia: no one is using the following two functions. -- Two ways of simultaneously applying equivalences in each component. module _ {i₀ i₁ j₀ j₁} {A₀ : Type i₀} {A₁ : Type i₁} {B₀ : A₀ → Type j₀} {B₁ : A₁ → Type j₁} where Σ-emap : (u : A₀ ≃ A₁) (v : ∀ a → B₀ (<– u a) ≃ B₁ a) → Σ A₀ B₀ ≃ Σ A₁ B₁ Σ-emap u v = Σ A₀ B₀ ≃⟨ Σ-emap-l _ (u ⁻¹) ⁻¹ ⟩ Σ A₁ (B₀ ∘ <– u) ≃⟨ Σ-emap-r v ⟩ Σ A₁ B₁ ≃∎ Σ-emap' : (u : A₀ ≃ A₁) (v : ∀ a → B₀ a ≃ B₁ (–> u a)) → Σ A₀ B₀ ≃ Σ A₁ B₁ Σ-emap' u v = Σ A₀ B₀ ≃⟨ Σ-emap-r v ⟩ Σ A₀ (B₁ ∘ –> u) ≃⟨ Σ-emap-l _ u ⟩ Σ A₁ B₁ ≃∎ -} ×-fmap : ∀ {i₀ i₁ j₀ j₁} {A₀ : Type i₀} {A₁ : Type i₁} {B₀ : Type j₀} {B₁ : Type j₁} → (h : A₀ → A₁) (k : B₀ → B₁) → (A₀ × B₀ → A₁ × B₁) ×-fmap u v = ×-fmap-r _ v ∘ ×-fmap-l _ u ⊙×-fmap : ∀ {i i' j j'} {X : Ptd i} {X' : Ptd i'} {Y : Ptd j} {Y' : Ptd j'} → X ⊙→ X' → Y ⊙→ Y' → X ⊙× Y ⊙→ X' ⊙× Y' ⊙×-fmap (f , fpt) (g , gpt) = ×-fmap f g , pair×= fpt gpt ×-isemap : ∀ {i₀ i₁ j₀ j₁} {A₀ : Type i₀} {A₁ : Type i₁} {B₀ : Type j₀} {B₁ : Type j₁} {h : A₀ → A₁} {k : B₀ → B₁} → is-equiv h → is-equiv k → is-equiv (×-fmap h k) ×-isemap eh ek = ×-isemap-r _ ek ∘ise ×-isemap-l _ eh ×-emap : ∀ {i₀ i₁ j₀ j₁} {A₀ : Type i₀} {A₁ : Type i₁} {B₀ : Type j₀} {B₁ : Type j₁} → (u : A₀ ≃ A₁) (v : B₀ ≃ B₁) → (A₀ × B₀ ≃ A₁ × B₁) ×-emap u v = ×-emap-r _ v ∘e ×-emap-l _ u ⊙×-emap : ∀ {i i' j j'} {X : Ptd i} {X' : Ptd i'} {Y : Ptd j} {Y' : Ptd j'} → X ⊙≃ X' → Y ⊙≃ Y' → X ⊙× Y ⊙≃ X' ⊙× Y' ⊙×-emap (F , F-ise) (G , G-ise) = ⊙×-fmap F G , ×-isemap F-ise G-ise -- Implementation of [_∙'_] on Σ Σ-∙' : ∀ {i j} {A : Type i} {B : A → Type j} {x y z : A} {p : x == y} {p' : y == z} {u : B x} {v : B y} {w : B z} (q : u == v [ B ↓ p ]) (r : v == w [ B ↓ p' ]) → (pair= p q ∙' pair= p' r) == pair= (p ∙' p') (q ∙'ᵈ r) Σ-∙' {p = idp} {p' = idp} q idp = idp -- Implementation of [_∙_] on Σ Σ-∙ : ∀ {i j} {A : Type i} {B : A → Type j} {x y z : A} {p : x == y} {p' : y == z} {u : B x} {v : B y} {w : B z} (q : u == v [ B ↓ p ]) (r : v == w [ B ↓ p' ]) → (pair= p q ∙ pair= p' r) == pair= (p ∙ p') (q ∙ᵈ r) Σ-∙ {p = idp} {p' = idp} idp r = idp -- Implementation of [!] on Σ Σ-! : ∀ {i j} {A : Type i} {B : A → Type j} {x y : A} {p : x == y} {u : B x} {v : B y} (q : u == v [ B ↓ p ]) → ! (pair= p q) == pair= (! p) (!ᵈ q) Σ-! {p = idp} idp = idp -- Implementation of [_∙'_] on × ×-∙' : ∀ {i j} {A : Type i} {B : Type j} {x y z : A} (p : x == y) (p' : y == z) {u v w : B} (q : u == v) (q' : v == w) → (pair×= p q ∙' pair×= p' q') == pair×= (p ∙' p') (q ∙' q') ×-∙' idp idp q idp = idp -- Implementation of [_∙_] on × ×-∙ : ∀ {i j} {A : Type i} {B : Type j} {x y z : A} (p : x == y) (p' : y == z) {u v w : B} (q : u == v) (q' : v == w) → (pair×= p q ∙ pair×= p' q') == pair×= (p ∙ p') (q ∙ q') ×-∙ idp idp idp r = idp -- Implementation of [!] on × ×-! : ∀ {i j} {A : Type i} {B : Type j} {x y : A} (p : x == y) {u v : B} (q : u == v) → ! (pair×= p q) == pair×= (! p) (! q) ×-! idp idp = idp -- Special case of [ap-,] ap-cst,id : ∀ {i j} {A : Type i} (B : A → Type j) {a : A} {x y : B a} (p : x == y) → ap (λ x → _,_ {B = B} a x) p == pair= idp p ap-cst,id B idp = idp -- hfiber fst == B module _ {i j} {A : Type i} {B : A → Type j} where private to : ∀ a → hfiber (fst :> (Σ A B → A)) a → B a to a ((.a , b) , idp) = b from : ∀ (a : A) → B a → hfiber (fst :> (Σ A B → A)) a from a b = (a , b) , idp to-from : ∀ (a : A) (b : B a) → to a (from a b) == b to-from a b = idp from-to : ∀ a b′ → from a (to a b′) == b′ from-to a ((.a , b) , idp) = idp hfiber-fst : ∀ a → hfiber (fst :> (Σ A B → A)) a ≃ B a hfiber-fst a = to a , is-eq (to a) (from a) (to-from a) (from-to a) {- Dependent paths in a Σ-type -} module _ {i j k} {A : Type i} {B : A → Type j} {C : (a : A) → B a → Type k} where ↓-Σ-in : {x x' : A} {p : x == x'} {r : B x} {r' : B x'} {s : C x r} {s' : C x' r'} (q : r == r' [ B ↓ p ]) → s == s' [ uncurry C ↓ pair= p q ] → (r , s) == (r' , s') [ (λ x → Σ (B x) (C x)) ↓ p ] ↓-Σ-in {p = idp} idp t = pair= idp t ↓-Σ-fst : {x x' : A} {p : x == x'} {r : B x} {r' : B x'} {s : C x r} {s' : C x' r'} → (r , s) == (r' , s') [ (λ x → Σ (B x) (C x)) ↓ p ] → r == r' [ B ↓ p ] ↓-Σ-fst {p = idp} u = fst= u ↓-Σ-snd : {x x' : A} {p : x == x'} {r : B x} {r' : B x'} {s : C x r} {s' : C x' r'} → (u : (r , s) == (r' , s') [ (λ x → Σ (B x) (C x)) ↓ p ]) → s == s' [ uncurry C ↓ pair= p (↓-Σ-fst u) ] ↓-Σ-snd {p = idp} idp = idp ↓-Σ-β-fst : {x x' : A} {p : x == x'} {r : B x} {r' : B x'} {s : C x r} {s' : C x' r'} (q : r == r' [ B ↓ p ]) (t : s == s' [ uncurry C ↓ pair= p q ]) → ↓-Σ-fst (↓-Σ-in q t) == q ↓-Σ-β-fst {p = idp} idp idp = idp ↓-Σ-β-snd : {x x' : A} {p : x == x'} {r : B x} {r' : B x'} {s : C x r} {s' : C x' r'} (q : r == r' [ B ↓ p ]) (t : s == s' [ uncurry C ↓ pair= p q ]) → ↓-Σ-snd (↓-Σ-in q t) == t [ (λ q' → s == s' [ uncurry C ↓ pair= p q' ]) ↓ ↓-Σ-β-fst q t ] ↓-Σ-β-snd {p = idp} idp idp = idp ↓-Σ-η : {x x' : A} {p : x == x'} {r : B x} {r' : B x'} {s : C x r} {s' : C x' r'} (u : (r , s) == (r' , s') [ (λ x → Σ (B x) (C x)) ↓ p ]) → ↓-Σ-in (↓-Σ-fst u) (↓-Σ-snd u) == u ↓-Σ-η {p = idp} idp = idp {- Dependent paths in a ×-type -} module _ {i j k} {A : Type i} {B : A → Type j} {C : A → Type k} where ↓-×-in : {x x' : A} {p : x == x'} {r : B x} {r' : B x'} {s : C x} {s' : C x'} → r == r' [ B ↓ p ] → s == s' [ C ↓ p ] → (r , s) == (r' , s') [ (λ x → B x × C x) ↓ p ] ↓-×-in {p = idp} q t = pair×= q t {- Dependent paths over a ×-type -} module _ {i j k} {A : Type i} {B : Type j} (C : A → B → Type k) where ↓-over-×-in : {x x' : A} {p : x == x'} {y y' : B} {q : y == y'} {u : C x y} {v : C x' y} {w : C x' y'} → u == v [ (λ a → C a y) ↓ p ] → v == w [ (λ b → C x' b) ↓ q ] → u == w [ uncurry C ↓ pair×= p q ] ↓-over-×-in {p = idp} {q = idp} idp idp = idp ↓-over-×-in' : {x x' : A} {p : x == x'} {y y' : B} {q : y == y'} {u : C x y} {v : C x y'} {w : C x' y'} → u == v [ (λ b → C x b) ↓ q ] → v == w [ (λ a → C a y') ↓ p ] → u == w [ uncurry C ↓ pair×= p q ] ↓-over-×-in' {p = idp} {q = idp} idp idp = idp module _ where -- An orphan lemma. ↓-cst×app-in : ∀ {i j k} {A : Type i} {B : Type j} {C : A → B → Type k} {a₁ a₂ : A} (p : a₁ == a₂) {b₁ b₂ : B} (q : b₁ == b₂) {c₁ : C a₁ b₁}{c₂ : C a₂ b₂} → c₁ == c₂ [ uncurry C ↓ pair×= p q ] → (b₁ , c₁) == (b₂ , c₂) [ (λ x → Σ B (C x)) ↓ p ] ↓-cst×app-in idp idp idp = idp {- pair= and pair×= where one argument is reflexivity -} pair=-idp-l : ∀ {i j} {A : Type i} {B : A → Type j} (a : A) {b₁ b₂ : B a} (q : b₁ == b₂) → pair= {B = B} idp q == ap (λ y → (a , y)) q pair=-idp-l _ idp = idp pair×=-idp-l : ∀ {i j} {A : Type i} {B : Type j} (a : A) {b₁ b₂ : B} (q : b₁ == b₂) → pair×= idp q == ap (λ y → (a , y)) q pair×=-idp-l _ idp = idp pair×=-idp-r : ∀ {i j} {A : Type i} {B : Type j} {a₁ a₂ : A} (p : a₁ == a₂) (b : B) → pair×= p idp == ap (λ x → (x , b)) p pair×=-idp-r idp _ = idp pair×=-split-l : ∀ {i j} {A : Type i} {B : Type j} {a₁ a₂ : A} (p : a₁ == a₂) {b₁ b₂ : B} (q : b₁ == b₂) → pair×= p q == ap (λ a → (a , b₁)) p ∙ ap (λ b → (a₂ , b)) q pair×=-split-l idp idp = idp pair×=-split-r : ∀ {i j} {A : Type i} {B : Type j} {a₁ a₂ : A} (p : a₁ == a₂) {b₁ b₂ : B} (q : b₁ == b₂) → pair×= p q == ap (λ b → (a₁ , b)) q ∙ ap (λ a → (a , b₂)) p pair×=-split-r idp idp = idp -- Commutativity of products and derivatives. module _ {i j} {A : Type i} {B : Type j} where ×-comm : Σ A (λ _ → B) ≃ Σ B (λ _ → A) ×-comm = equiv (λ {(a , b) → (b , a)}) (λ {(b , a) → (a , b)}) (λ _ → idp) (λ _ → idp) module _ {i j k} {A : Type i} {B : A → Type j} {C : A → Type k} where Σ₂-×-comm : Σ (Σ A B) (λ ab → C (fst ab)) ≃ Σ (Σ A C) (λ ac → B (fst ac)) Σ₂-×-comm = Σ-assoc ⁻¹ ∘e Σ-emap-r (λ a → ×-comm) ∘e Σ-assoc module _ {i j k} {A : Type i} {B : Type j} {C : A → B → Type k} where Σ₁-×-comm : Σ A (λ a → Σ B (λ b → C a b)) ≃ Σ B (λ b → Σ A (λ a → C a b)) Σ₁-×-comm = Σ-assoc ∘e Σ-emap-l _ ×-comm ∘e Σ-assoc ⁻¹
{ "alphanum_fraction": 0.4013011264, "avg_line_length": 34.730125523, "ext": "agda", "hexsha": "180929a2edc3c6af1d200720aff6ad5b8ff80b54", "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": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "core/lib/types/Sigma.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "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": "timjb/HoTT-Agda", "max_issues_repo_path": "core/lib/types/Sigma.agda", "max_line_length": 104, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "core/lib/types/Sigma.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 8463, "size": 16601 }
{-# OPTIONS --prop --without-K --rewriting #-} -- The basic CBPV metalanguage, extended with parallelism. open import Calf.CostMonoid module Calf.ParMetalanguage (parCostMonoid : ParCostMonoid) where open ParCostMonoid parCostMonoid open import Calf.Prelude open import Calf.Metalanguage open import Calf.Step costMonoid open import Calf.Types.Eq open import Calf.Types.Bounded costMonoid open import Data.Product open import Relation.Binary.PropositionalEquality postulate _&_ : {A₁ A₂ : tp pos} → cmp (F A₁) → cmp (F A₂) → cmp (F (Σ++ A₁ (λ _ → A₂))) &/join : ∀ {A₁ A₂} {v₁ v₂ p₁ p₂} → step (F A₁) p₁ (ret v₁) & step (F A₂) p₂ (ret v₂) ≡ step (F (Σ++ A₁ λ _ → A₂)) (p₁ ⊗ p₂) (ret (v₁ , v₂)) {-# REWRITE &/join #-} &/join/𝟘 : ∀ {A₁ A₂} {v₁ v₂} → ret v₁ & ret v₂ ≡ step (F (Σ++ A₁ λ _ → A₂)) (𝟘 ⊗ 𝟘) (ret (v₁ , v₂)) &/join/𝟘 = &/join {p₁ = 𝟘} {p₂ = 𝟘} {-# REWRITE &/join/𝟘 #-} bind/& : ∀ {A₁ A₂} {X} {v₁ v₂ f} (p₁ p₂ : ℂ) → bind {Σ++ A₁ λ _ → A₂} X (step (F A₁) p₁ (ret v₁) & step (F A₂) p₂ (ret v₂)) f ≡ step X (p₁ ⊗ p₂) (f (v₁ , v₂)) bind/& _ _ = refl bound/par : {A₁ A₂ : tp pos} {e₁ : cmp (F A₁)} {e₂ : cmp (F A₂)} {c₁ c₂ : ℂ} → IsBounded A₁ e₁ c₁ → IsBounded A₂ e₂ c₂ → IsBounded (Σ++ A₁ λ _ → A₂) (e₁ & e₂) (c₁ ⊗ c₂) bound/par (⇓ a₁ withCost p₁' [ h-bounded₁ , h-≡₁ ]) (⇓ a₂ withCost p₂' [ h-bounded₂ , h-≡₂ ]) with eq/ref h-≡₁ | eq/ref h-≡₂ ... | refl | refl = ⇓ (a₁ , a₂) withCost (p₁' ⊗ p₂') [ (λ u → ⊗-mono-≤ (h-bounded₁ u) (h-bounded₂ u)) , (ret (eq/intro refl)) ]
{ "alphanum_fraction": 0.5881962865, "avg_line_length": 35.0697674419, "ext": "agda", "hexsha": "f03ee0ccbc00fdde8462d0c732dfe0f75ac71e55", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z", "max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "jonsterling/agda-calf", "max_forks_repo_path": "src/Calf/ParMetalanguage.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "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": "jonsterling/agda-calf", "max_issues_repo_path": "src/Calf/ParMetalanguage.agda", "max_line_length": 127, "max_stars_count": 29, "max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "jonsterling/agda-calf", "max_stars_repo_path": "src/Calf/ParMetalanguage.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z", "num_tokens": 699, "size": 1508 }
{-# OPTIONS --warning=error --safe --without-K #-} open import LogicalFormulae open import Lists.Lists open import Numbers.BinaryNaturals.Definition open import Maybe open import Numbers.BinaryNaturals.SubtractionGo module Numbers.BinaryNaturals.SubtractionGoPreservesCanonicalRight where goPreservesCanonicalRightZero : (a b : BinNat) → mapMaybe canonical (go zero a b) ≡ mapMaybe canonical (go zero a (canonical b)) goPreservesCanonicalRightOne : (a b : BinNat) → mapMaybe canonical (go one a b) ≡ mapMaybe canonical (go one a (canonical b)) goPreservesCanonicalRightZero [] [] = refl goPreservesCanonicalRightZero [] (zero :: b) with inspect (go zero [] b) goPreservesCanonicalRightZero [] (zero :: b) | no with≡ pr with inspect (canonical b) goPreservesCanonicalRightZero [] (zero :: b) | no with≡ pr | [] with≡ pr2 rewrite pr | pr2 = exFalso (noNotYes (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr)) (transitivity (goPreservesCanonicalRightZero [] b) (transitivity (applyEquality (λ i → mapMaybe canonical (go zero [] i)) pr2) refl)))) goPreservesCanonicalRightZero [] (zero :: b) | no with≡ pr | (x :: y) with≡ pr2 with inspect (go zero [] (x :: y)) goPreservesCanonicalRightZero [] (zero :: b) | no with≡ pr | (x :: y) with≡ pr2 | no with≡ pr3 rewrite pr | pr2 | pr3 = refl goPreservesCanonicalRightZero [] (zero :: b) | no with≡ pr | (x :: y) with≡ pr2 | yes z with≡ pr3 rewrite pr | pr2 | pr3 | equalityCommutative pr2 = exFalso (noNotYes (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr)) (transitivity (goPreservesCanonicalRightZero [] b) (applyEquality (mapMaybe canonical) pr3)))) goPreservesCanonicalRightZero [] (zero :: b) | yes r with≡ pr with inspect (canonical b) goPreservesCanonicalRightZero [] (zero :: b) | yes r with≡ pr | [] with≡ pr2 rewrite pr | pr2 = applyEquality yes (goZeroEmpty' b pr) goPreservesCanonicalRightZero [] (zero :: b) | yes r with≡ pr | (x :: xs) with≡ pr2 with inspect (go zero [] (x :: xs)) goPreservesCanonicalRightZero [] (zero :: b) | yes r with≡ pr | (x :: xs) with≡ pr2 | no with≡ pr3 rewrite pr | pr2 | pr3 = exFalso (noNotYes (transitivity (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr3)) (transitivity (applyEquality (λ i → mapMaybe canonical (go zero [] i)) (equalityCommutative pr2)) (equalityCommutative (goPreservesCanonicalRightZero [] b)))) (applyEquality (mapMaybe canonical) pr))) goPreservesCanonicalRightZero [] (zero :: b) | yes r with≡ pr | (x :: xs) with≡ pr2 | yes x₁ with≡ pr3 rewrite pr | pr2 | pr3 = transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr)) (transitivity (transitivity (goPreservesCanonicalRightZero [] b) (applyEquality (λ i → mapMaybe canonical (go zero [] i)) pr2)) (applyEquality (mapMaybe canonical) pr3)) goPreservesCanonicalRightZero [] (one :: b) = refl goPreservesCanonicalRightZero (zero :: a) [] = refl goPreservesCanonicalRightZero (one :: a) [] = refl goPreservesCanonicalRightZero (zero :: a) (zero :: b) with inspect (canonical b) goPreservesCanonicalRightZero (zero :: a) (zero :: b) | [] with≡ pr1 with inspect (go zero a b) goPreservesCanonicalRightZero (zero :: a) (zero :: b) | [] with≡ pr1 | no with≡ pr2 = exFalso (noNotYes (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr2)) (transitivity (goPreservesCanonicalRightZero a b) (transitivity (applyEquality (λ i → mapMaybe canonical (go zero a i)) pr1) (applyEquality (mapMaybe canonical) (goEmpty a)))))) goPreservesCanonicalRightZero (zero :: a) (zero :: b) | [] with≡ pr1 | yes y with≡ pr2 rewrite pr1 | pr2 = applyEquality yes v where t : canonical y ≡ canonical a t = yesInjective (transitivity (applyEquality (mapMaybe canonical) (equalityCommutative pr2)) (transitivity (goPreservesCanonicalRightZero a b) (transitivity (applyEquality (λ i → mapMaybe canonical (go zero a i)) pr1) (applyEquality (mapMaybe canonical) (goEmpty a))))) v : canonical (zero :: y) ≡ canonical (zero :: a) v with inspect (canonical y) v | [] with≡ pr4 rewrite pr4 | (transitivity (equalityCommutative t) pr4) = refl v | (x :: r) with≡ pr4 rewrite pr4 | transitivity (equalityCommutative t) pr4 = refl goPreservesCanonicalRightZero (zero :: a) (zero :: b) | (r :: rs) with≡ pr1 with inspect (go zero a b) goPreservesCanonicalRightZero (zero :: a) (zero :: b) | (r :: rs) with≡ pr1 | no with≡ pr2 with inspect (go zero a (r :: rs)) goPreservesCanonicalRightZero (zero :: a) (zero :: b) | (r :: rs) with≡ pr1 | no with≡ pr2 | no with≡ pr3 rewrite pr1 | pr2 | pr3 = refl goPreservesCanonicalRightZero (zero :: a) (zero :: b) | (r :: rs) with≡ pr1 | no with≡ pr2 | yes z with≡ pr3 rewrite pr1 | pr2 | pr3 = exFalso (noNotYes (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr2)) (transitivity (transitivity (goPreservesCanonicalRightZero a b) (applyEquality (λ i → mapMaybe canonical (go zero a i)) pr1)) (applyEquality (mapMaybe canonical) pr3)))) goPreservesCanonicalRightZero (zero :: a) (zero :: b) | (r :: rs) with≡ pr1 | yes y with≡ pr2 with inspect (go zero a (r :: rs)) goPreservesCanonicalRightZero (zero :: a) (zero :: b) | (r :: rs) with≡ pr1 | yes y with≡ pr2 | no with≡ pr3 rewrite pr1 | pr2 | pr3 = exFalso (noNotYes (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr3)) (transitivity (transitivity (applyEquality (λ i → mapMaybe canonical (go zero a i)) (equalityCommutative pr1)) (equalityCommutative (goPreservesCanonicalRightZero a b))) (applyEquality (mapMaybe canonical) pr2)))) goPreservesCanonicalRightZero (zero :: a) (zero :: b) | (r :: rs) with≡ pr1 | yes y with≡ pr2 | yes z with≡ pr3 rewrite pr1 | pr2 | pr3 = applyEquality yes v where t : canonical y ≡ canonical z t = yesInjective (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr2)) (transitivity (goPreservesCanonicalRightZero a b) (transitivity (applyEquality (λ i → mapMaybe canonical (go zero a i)) pr1) (applyEquality (mapMaybe canonical) pr3)))) v : canonical (zero :: y) ≡ canonical (zero :: z) v with inspect (canonical y) v | [] with≡ pr4 rewrite pr4 | (transitivity (equalityCommutative t) pr4) = refl v | (x :: r) with≡ pr4 rewrite pr4 | transitivity (equalityCommutative t) pr4 = refl goPreservesCanonicalRightZero (zero :: a) (one :: b) with inspect (go one a b) goPreservesCanonicalRightZero (zero :: a) (one :: b) | no with≡ x with inspect (go one a (canonical b)) goPreservesCanonicalRightZero (zero :: a) (one :: b) | no with≡ pr | no with≡ pr2 rewrite pr | pr2 = refl goPreservesCanonicalRightZero (zero :: a) (one :: b) | no with≡ pr | yes x with≡ pr2 rewrite pr | pr2 = exFalso (noNotYes (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr)) (transitivity (goPreservesCanonicalRightOne a b) (applyEquality (mapMaybe canonical) pr2)))) goPreservesCanonicalRightZero (zero :: a) (one :: b) | yes r with≡ pr1 with inspect (go one a (canonical b)) goPreservesCanonicalRightZero (zero :: a) (one :: b) | yes r with≡ pr1 | no with≡ pr2 rewrite pr1 | pr2 = exFalso (noNotYes (transitivity (applyEquality (mapMaybe canonical) (equalityCommutative pr2)) (transitivity (equalityCommutative (goPreservesCanonicalRightOne a b)) (applyEquality (mapMaybe canonical) pr1)))) goPreservesCanonicalRightZero (zero :: a) (one :: b) | yes r with≡ pr1 | yes s with≡ pr2 rewrite pr1 | pr2 = applyEquality (λ i → yes (one :: i)) (yesInjective (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr1)) (transitivity (goPreservesCanonicalRightOne a b) (applyEquality (mapMaybe canonical) pr2)))) goPreservesCanonicalRightZero (one :: a) (zero :: b) with inspect (go zero a b) goPreservesCanonicalRightZero (one :: a) (zero :: b) | no with≡ pr1 with inspect (canonical b) goPreservesCanonicalRightZero (one :: a) (zero :: b) | no with≡ pr1 | [] with≡ pr2 rewrite pr1 | pr2 = exFalso (noNotYes (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr1)) (transitivity (goPreservesCanonicalRightZero a b) (transitivity (applyEquality (λ i → mapMaybe canonical (go zero a i)) pr2) (applyEquality (mapMaybe canonical) (goEmpty a)))))) goPreservesCanonicalRightZero (one :: a) (zero :: b) | no with≡ pr1 | (x :: y) with≡ pr2 with inspect (go zero a (x :: y)) goPreservesCanonicalRightZero (one :: a) (zero :: b) | no with≡ pr1 | (x :: y) with≡ pr2 | no with≡ pr3 rewrite pr1 | pr2 | pr3 = refl goPreservesCanonicalRightZero (one :: a) (zero :: b) | no with≡ pr1 | (x :: y) with≡ pr2 | yes z with≡ pr3 rewrite pr1 | pr2 | pr3 = exFalso (noNotYes (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr1)) (transitivity (goPreservesCanonicalRightZero a b) (transitivity (applyEquality (λ i → mapMaybe canonical (go zero a i)) pr2) (applyEquality (mapMaybe canonical) pr3))))) goPreservesCanonicalRightZero (one :: a) (zero :: b) | yes x with≡ pr1 with inspect (canonical b) goPreservesCanonicalRightZero (one :: a) (zero :: b) | yes x with≡ pr1 | [] with≡ pr2 rewrite pr1 | pr2 = applyEquality (λ i → yes (one :: i)) (yesInjective (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr1)) (transitivity (goPreservesCanonicalRightZero a b) (transitivity (applyEquality (λ i → mapMaybe canonical (go zero a i)) pr2) (applyEquality (mapMaybe canonical) (goEmpty a)))))) goPreservesCanonicalRightZero (one :: a) (zero :: b) | yes x with≡ pr1 | (r :: rs) with≡ pr2 with inspect (go zero a (r :: rs)) goPreservesCanonicalRightZero (one :: a) (zero :: b) | yes x with≡ pr1 | (r :: rs) with≡ pr2 | no with≡ pr3 rewrite pr1 | pr2 | pr3 = exFalso (noNotYes (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr3)) (transitivity (transitivity (applyEquality (λ i → mapMaybe canonical (go zero a i)) (equalityCommutative pr2)) (equalityCommutative (goPreservesCanonicalRightZero a b))) (applyEquality (mapMaybe canonical) pr1)))) goPreservesCanonicalRightZero (one :: a) (zero :: b) | yes x with≡ pr1 | (r :: rs) with≡ pr2 | yes y with≡ pr3 rewrite pr1 | pr2 | pr3 = applyEquality (λ i → yes (one :: i)) (yesInjective (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr1)) (transitivity (transitivity (goPreservesCanonicalRightZero a b) (applyEquality (λ i → mapMaybe canonical (go zero a i)) pr2)) (applyEquality (mapMaybe canonical) pr3)))) goPreservesCanonicalRightZero (one :: a) (one :: b) with inspect (go zero a b) goPreservesCanonicalRightZero (one :: a) (one :: b) | no with≡ pr1 with inspect (go zero a (canonical b)) goPreservesCanonicalRightZero (one :: a) (one :: b) | no with≡ pr1 | no with≡ x rewrite pr1 | x = refl goPreservesCanonicalRightZero (one :: a) (one :: b) | no with≡ pr1 | yes x₁ with≡ x rewrite pr1 | x = exFalso (noNotYes (transitivity (applyEquality (mapMaybe canonical) (equalityCommutative pr1)) (transitivity (goPreservesCanonicalRightZero a b) (applyEquality (mapMaybe canonical) x)))) goPreservesCanonicalRightZero (one :: a) (one :: b) | yes x with≡ pr1 with inspect (go zero a (canonical b)) goPreservesCanonicalRightZero (one :: a) (one :: b) | yes x with≡ pr1 | no with≡ pr2 rewrite pr1 | pr2 = exFalso (noNotYes (transitivity (applyEquality (mapMaybe canonical) (equalityCommutative pr2)) (transitivity (equalityCommutative (goPreservesCanonicalRightZero a b)) (applyEquality (mapMaybe canonical) pr1)))) goPreservesCanonicalRightZero (one :: a) (one :: b) | yes x with≡ pr1 | yes y with≡ pr2 rewrite pr1 | pr2 = applyEquality yes v where t : canonical x ≡ canonical y t = yesInjective (transitivity (transitivity (applyEquality (mapMaybe canonical) (equalityCommutative pr1)) (goPreservesCanonicalRightZero a b)) (applyEquality (mapMaybe canonical) pr2)) v : canonical (zero :: x) ≡ canonical (zero :: y) v with inspect (canonical x) v | [] with≡ pr4 rewrite pr4 | (transitivity (equalityCommutative t) pr4) = refl v | (x :: r) with≡ pr4 rewrite pr4 | transitivity (equalityCommutative t) pr4 = refl goPreservesCanonicalRightOne a [] = refl goPreservesCanonicalRightOne [] (zero :: b) rewrite goOneEmpty' (canonical (zero :: b)) = refl goPreservesCanonicalRightOne (zero :: a) (zero :: b) with inspect (go one a b) goPreservesCanonicalRightOne (zero :: a) (zero :: b) | no with≡ pr1 with inspect (canonical b) goPreservesCanonicalRightOne (zero :: a) (zero :: b) | no with≡ pr1 | [] with≡ pr2 with inspect (go one a []) goPreservesCanonicalRightOne (zero :: a) (zero :: b) | no with≡ pr1 | [] with≡ pr2 | no with≡ pr3 rewrite pr1 | pr2 | pr3 = refl goPreservesCanonicalRightOne (zero :: a) (zero :: b) | no with≡ pr1 | [] with≡ pr2 | yes y with≡ pr3 rewrite pr1 | pr2 | pr3 = exFalso (noNotYes (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr1)) (transitivity (transitivity (goPreservesCanonicalRightOne a b) (transitivity (applyEquality (λ i → mapMaybe canonical (go one a i)) pr2) refl)) (applyEquality (mapMaybe canonical) pr3)))) goPreservesCanonicalRightOne (zero :: a) (zero :: b) | no with≡ pr1 | (x :: y) with≡ pr2 with inspect (go one a (x :: y)) goPreservesCanonicalRightOne (zero :: a) (zero :: b) | no with≡ pr1 | (x :: y) with≡ pr2 | no with≡ pr3 rewrite pr1 | pr2 | pr3 = refl goPreservesCanonicalRightOne (zero :: a) (zero :: b) | no with≡ pr1 | (x :: y) with≡ pr2 | yes z with≡ pr3 rewrite pr1 | pr2 | pr3 = exFalso (noNotYes (transitivity (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr1)) (transitivity (goPreservesCanonicalRightOne a b) (applyEquality (λ i → mapMaybe canonical (go one a i)) pr2))) (applyEquality (mapMaybe canonical) pr3))) goPreservesCanonicalRightOne (zero :: a) (zero :: b) | yes y with≡ pr1 with inspect (canonical b) goPreservesCanonicalRightOne (zero :: a) (zero :: b) | yes y with≡ pr1 | [] with≡ pr2 with inspect (go one a []) goPreservesCanonicalRightOne (zero :: a) (zero :: b) | yes y with≡ pr1 | [] with≡ pr2 | no with≡ pr3 rewrite pr1 | pr2 | pr3 = exFalso (noNotYes (transitivity (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr3)) (transitivity (applyEquality (λ i → mapMaybe canonical (go one a i)) (equalityCommutative pr2)) (equalityCommutative (goPreservesCanonicalRightOne a b)))) (applyEquality (mapMaybe canonical) pr1))) goPreservesCanonicalRightOne (zero :: a) (zero :: b) | yes y with≡ pr1 | [] with≡ pr2 | yes z with≡ pr3 rewrite pr1 | pr2 | pr3 = applyEquality (λ i → yes (one :: i)) (yesInjective (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr1)) (transitivity (transitivity (goPreservesCanonicalRightOne a b) (applyEquality (λ i → mapMaybe canonical (go one a i)) pr2)) (applyEquality (mapMaybe canonical) pr3)))) goPreservesCanonicalRightOne (zero :: a) (zero :: b) | yes y with≡ pr1 | (r :: rs) with≡ pr2 with inspect (go one a (r :: rs)) goPreservesCanonicalRightOne (zero :: a) (zero :: b) | yes y with≡ pr1 | (r :: rs) with≡ pr2 | no with≡ pr3 rewrite pr1 | pr2 | pr3 = exFalso (noNotYes (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr3)) (transitivity (applyEquality (λ i → mapMaybe canonical (go one a i)) (equalityCommutative pr2)) (transitivity (equalityCommutative (goPreservesCanonicalRightOne a b)) (applyEquality (mapMaybe canonical) pr1))))) goPreservesCanonicalRightOne (zero :: a) (zero :: b) | yes y with≡ pr1 | (r :: rs) with≡ pr2 | yes z with≡ pr3 rewrite pr1 | pr2 | pr3 = applyEquality (λ i → yes (one :: i)) (yesInjective (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr1)) (transitivity (transitivity (goPreservesCanonicalRightOne a b) (applyEquality (λ i → mapMaybe canonical (go one a i)) pr2)) (applyEquality (mapMaybe canonical) pr3)))) goPreservesCanonicalRightOne (one :: a) (zero :: b) with inspect (go zero a b) goPreservesCanonicalRightOne (one :: a) (zero :: b) | no with≡ pr1 with inspect (canonical b) goPreservesCanonicalRightOne (one :: a) (zero :: b) | no with≡ pr1 | [] with≡ pr2 rewrite pr1 | pr2 = exFalso (noNotYes (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr1)) (transitivity (goPreservesCanonicalRightZero a b) (transitivity (applyEquality (λ i → mapMaybe canonical (go zero a i)) pr2) (applyEquality (mapMaybe canonical) (goEmpty a)))))) goPreservesCanonicalRightOne (one :: a) (zero :: b) | no with≡ pr1 | (r :: rs) with≡ pr2 with inspect (go zero a (r :: rs)) goPreservesCanonicalRightOne (one :: a) (zero :: b) | no with≡ pr1 | (r :: rs) with≡ pr2 | no with≡ pr3 rewrite pr1 | pr2 | pr3 = refl goPreservesCanonicalRightOne (one :: a) (zero :: b) | no with≡ pr1 | (r :: rs) with≡ pr2 | yes y with≡ pr3 rewrite pr1 | pr2 | pr3 = exFalso (noNotYes (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr1)) (transitivity (transitivity (goPreservesCanonicalRightZero a b) (applyEquality (λ i → mapMaybe canonical (go zero a i)) pr2)) (applyEquality (mapMaybe canonical) pr3)))) goPreservesCanonicalRightOne (one :: a) (zero :: b) | yes y with≡ pr1 with inspect (canonical b) goPreservesCanonicalRightOne (one :: a) (zero :: b) | yes y with≡ pr1 | [] with≡ pr2 rewrite pr1 | pr2 = applyEquality yes v where t : canonical y ≡ canonical a t = yesInjective (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr1)) (transitivity (goPreservesCanonicalRightZero a b) (transitivity (applyEquality (λ i → mapMaybe canonical (go zero a i)) pr2) (applyEquality (mapMaybe canonical) (goEmpty a))))) v : canonical (zero :: y) ≡ canonical (zero :: a) v with inspect (canonical y) v | [] with≡ pr4 rewrite pr4 | (transitivity (equalityCommutative t) pr4) = refl v | (x :: r) with≡ pr4 rewrite pr4 | transitivity (equalityCommutative t) pr4 = refl goPreservesCanonicalRightOne (one :: a) (zero :: b) | yes y with≡ pr1 | (r :: rs) with≡ pr2 with inspect (go zero a (r :: rs)) goPreservesCanonicalRightOne (one :: a) (zero :: b) | yes y with≡ pr1 | (r :: rs) with≡ pr2 | no with≡ pr3 rewrite pr1 | pr2 | pr3 = exFalso (noNotYes (transitivity (equalityCommutative (transitivity (transitivity (goPreservesCanonicalRightZero a b) (applyEquality (λ i → mapMaybe canonical (go zero a i)) pr2)) (applyEquality (mapMaybe canonical) pr3))) (applyEquality (mapMaybe canonical) pr1))) goPreservesCanonicalRightOne (one :: a) (zero :: b) | yes y with≡ pr1 | (r :: rs) with≡ pr2 | yes z with≡ pr3 rewrite pr1 | pr2 | pr3 = applyEquality yes v where t : canonical y ≡ canonical z t = yesInjective (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr1)) (transitivity (goPreservesCanonicalRightZero a b) (transitivity (applyEquality (λ i → mapMaybe canonical (go zero a i)) pr2) (applyEquality (mapMaybe canonical) pr3)))) v : canonical (zero :: y) ≡ canonical (zero :: z) v with inspect (canonical y) v | [] with≡ pr4 rewrite pr4 | (transitivity (equalityCommutative t) pr4) = refl v | (x :: r) with≡ pr4 rewrite pr4 | transitivity (equalityCommutative t) pr4 = refl goPreservesCanonicalRightOne [] (one :: b) = refl goPreservesCanonicalRightOne (zero :: a) (one :: b) with inspect (go one a b) goPreservesCanonicalRightOne (zero :: a) (one :: b) | no with≡ pr1 with inspect (go one a (canonical b)) goPreservesCanonicalRightOne (zero :: a) (one :: b) | no with≡ pr1 | no with≡ pr2 rewrite pr1 | pr2 = refl goPreservesCanonicalRightOne (zero :: a) (one :: b) | no with≡ pr1 | yes y with≡ pr2 rewrite pr1 | pr2 = exFalso (noNotYes (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr1)) (transitivity (goPreservesCanonicalRightOne a b) (applyEquality (mapMaybe canonical) pr2)))) goPreservesCanonicalRightOne (zero :: a) (one :: b) | yes y with≡ pr1 with inspect (go one a (canonical b)) goPreservesCanonicalRightOne (zero :: a) (one :: b) | yes y with≡ pr1 | no with≡ pr2 rewrite pr1 | pr2 = exFalso (noNotYes (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr2)) (transitivity (equalityCommutative (goPreservesCanonicalRightOne a b)) (applyEquality (mapMaybe canonical) pr1)))) goPreservesCanonicalRightOne (zero :: a) (one :: b) | yes y with≡ pr1 | yes z with≡ pr2 rewrite pr1 | pr2 = applyEquality yes v where t : canonical y ≡ canonical z t = yesInjective (transitivity (transitivity (applyEquality (mapMaybe canonical) (equalityCommutative pr1)) (goPreservesCanonicalRightOne a b)) (applyEquality (mapMaybe canonical) pr2)) v : canonical (zero :: y) ≡ canonical (zero :: z) v with inspect (canonical y) v | [] with≡ pr4 rewrite pr4 | (transitivity (equalityCommutative t) pr4) = refl v | (x :: r) with≡ pr4 rewrite pr4 | transitivity (equalityCommutative t) pr4 = refl goPreservesCanonicalRightOne (one :: a) (one :: b) with inspect (go one a b) goPreservesCanonicalRightOne (one :: a) (one :: b) | no with≡ pr1 with inspect (go one a (canonical b)) goPreservesCanonicalRightOne (one :: a) (one :: b) | no with≡ pr1 | no with≡ pr2 rewrite pr1 | pr2 = refl goPreservesCanonicalRightOne (one :: a) (one :: b) | no with≡ pr1 | yes y with≡ pr2 rewrite pr1 | pr2 = exFalso (noNotYes (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr1)) (transitivity (goPreservesCanonicalRightOne a b) (applyEquality (mapMaybe canonical) pr2)))) goPreservesCanonicalRightOne (one :: a) (one :: b) | yes y with≡ pr1 with inspect (go one a (canonical b)) goPreservesCanonicalRightOne (one :: a) (one :: b) | yes y with≡ pr1 | yes z with≡ pr2 rewrite pr1 | pr2 = applyEquality (λ i → yes (one :: i)) (yesInjective (transitivity (transitivity (applyEquality (mapMaybe canonical) (equalityCommutative pr1)) (goPreservesCanonicalRightOne a b) ) (applyEquality (mapMaybe canonical) pr2))) goPreservesCanonicalRightOne (one :: a) (one :: b) | yes y with≡ pr1 | no with≡ pr2 rewrite pr1 | pr2 = exFalso (noNotYes (transitivity (equalityCommutative (applyEquality (mapMaybe canonical) pr2)) (transitivity (equalityCommutative (goPreservesCanonicalRightOne a b)) (applyEquality (mapMaybe canonical) pr1)))) goPreservesCanonicalRight : (state : Bit) → (a b : BinNat) → mapMaybe canonical (go state a b) ≡ mapMaybe canonical (go state a (canonical b)) goPreservesCanonicalRight zero = goPreservesCanonicalRightZero goPreservesCanonicalRight one = goPreservesCanonicalRightOne
{ "alphanum_fraction": 0.7200812274, "avg_line_length": 142.9677419355, "ext": "agda", "hexsha": "7f369380e99600bdcdcffec49daf5603b554f2e9", "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/SubtractionGoPreservesCanonicalRight.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/SubtractionGoPreservesCanonicalRight.agda", "max_line_length": 443, "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/SubtractionGoPreservesCanonicalRight.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": 6849, "size": 22160 }
open import Nat open import Prelude open import core open import contexts module htype-decidable where lemma-l : ∀{t1 t2 t4} → t1 ==> t2 == t1 ==> t4 → t2 == t4 lemma-l refl = refl lemma-r : ∀{t1 t2 t3} → t1 ==> t2 == t3 ==> t2 → t1 == t3 lemma-r refl = refl lemma-b : ∀{t1 t2 t3 t4} → t1 ==> t2 == t3 ==> t4 → t1 == t3 lemma-b refl = refl htype-dec : (t1 t2 : htyp) → t1 == t2 + (t1 == t2 → ⊥) htype-dec b b = Inl refl htype-dec b ⦇-⦈ = Inr (λ ()) htype-dec b (t2 ==> t3) = Inr (λ ()) htype-dec ⦇-⦈ b = Inr (λ ()) htype-dec ⦇-⦈ ⦇-⦈ = Inl refl htype-dec ⦇-⦈ (t2 ==> t3) = Inr (λ ()) htype-dec (t1 ==> t2) b = Inr (λ ()) htype-dec (t1 ==> t2) ⦇-⦈ = Inr (λ ()) htype-dec (t1 ==> t2) (t3 ==> t4) with htype-dec t1 t3 | htype-dec t2 t4 htype-dec (t1 ==> t2) (.t1 ==> .t2) | Inl refl | Inl refl = Inl refl htype-dec (t1 ==> t2) (.t1 ==> t4) | Inl refl | Inr x₁ = Inr (λ x → x₁ (lemma-l x)) htype-dec (t1 ==> t2) (t3 ==> .t2) | Inr x | Inl refl = Inr (λ x₁ → x (lemma-r x₁)) htype-dec (t1 ==> t2) (t3 ==> t4) | Inr x | Inr x₁ = Inr (λ x₂ → x (lemma-b x₂)) -- if an arrow is disequal, it disagrees in the first or second argument ne-factor : ∀{τ1 τ2 τ3 τ4} → (τ1 ==> τ2) ≠ (τ3 ==> τ4) → (τ1 ≠ τ3) + (τ2 ≠ τ4) ne-factor {τ1} {τ2} {τ3} {τ4} ne with htype-dec τ1 τ3 | htype-dec τ2 τ4 ne-factor ne | Inl refl | Inl refl = Inl (λ x → ne refl) ne-factor ne | Inl x | Inr x₁ = Inr x₁ ne-factor ne | Inr x | Inl x₁ = Inl x ne-factor ne | Inr x | Inr x₁ = Inl x
{ "alphanum_fraction": 0.5233706386, "avg_line_length": 39.9736842105, "ext": "agda", "hexsha": "374ea88a99c03ac8ec0e809a3bf10ea11051f33a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-09-13T18:20:02.000Z", "max_forks_repo_forks_event_min_datetime": "2019-09-13T18:20:02.000Z", "max_forks_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_forks_repo_path": "htype-decidable.agda", "max_issues_count": 54, "max_issues_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_issues_repo_issues_event_max_datetime": "2018-11-29T16:32:40.000Z", "max_issues_repo_issues_event_min_datetime": "2017-06-29T20:53:34.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_issues_repo_path": "htype-decidable.agda", "max_line_length": 89, "max_stars_count": 16, "max_stars_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_stars_repo_path": "htype-decidable.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-19T02:50:23.000Z", "max_stars_repo_stars_event_min_datetime": "2018-03-12T14:32:03.000Z", "num_tokens": 724, "size": 1519 }
open import Agda.Builtin.Nat -- Matching against negative numbers lit : Nat → Nat lit -20 = 0 -- Error thrown here lit _ = 1
{ "alphanum_fraction": 0.6846153846, "avg_line_length": 16.25, "ext": "agda", "hexsha": "32eb727b88aaa60b69102a2c8e4944ef15558b05", "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/Issue2365a.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/Issue2365a.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/Fail/Issue2365a.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": 40, "size": 130 }
------------------------------------------------------------------------ -- The two coinductive definitions of weak bisimilarity are pointwise -- logically equivalent ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} open import Labelled-transition-system module Bisimilarity.Weak.Equivalent {ℓ} {lts : LTS ℓ} where open import Equality.Propositional open import Logical-equivalence using (_⇔_) open import Prelude import Bisimilarity.Weak lts as Std import Bisimilarity.Weak.Alternative lts as Alt import Bisimilarity.Weak.Alternative.Equational-reasoning-instances import Bisimilarity.Weak.Equational-reasoning-instances open import Equational-reasoning open LTS lts mutual -- The alternative definition of weak bisimilarity can be converted -- to the standard one, in a size-preserving way. alternative⇒ : ∀ {i p q} → Alt.[ i ] p ≈ q → Std.[ i ] p ≈ q alternative⇒ {i} p≈q = Std.⟨ lr p≈q , Σ-map id (Σ-map id symmetric) ∘ lr (symmetric p≈q) ⟩ where lr : ∀ {p p′ q μ} → Alt.[ i ] p ≈ q → p [ μ ]⟶ p′ → ∃ λ q′ → q [ μ ]⇒̂ q′ × Std.[ i ] p′ ≈′ q′ lr p≈q p⟶p′ = Σ-map id (Σ-map id alternative⇒′) (Alt.left-to-right p≈q (⟶→⇒̂ p⟶p′)) alternative⇒′ : ∀ {i p q} → Alt.[ i ] p ≈′ q → Std.[ i ] p ≈′ q Std.force (alternative⇒′ p≈′q) = alternative⇒ (Alt.force p≈′q) mutual -- One can also convert in the other direction. Note that this -- conversion is not guaranteed to be size-preserving. For at least -- one LTS it cannot (in general) be size-preserving, see -- Bisimilarity.Weak.Delay-monad.size-preserving-⇒alternative⇔uninhabited. ⇒alternative : ∀ {i p q} → p Std.≈ q → Alt.[ i ] p ≈ q ⇒alternative {i} p≈q = Alt.⟨ lr p≈q , Σ-map id (Σ-map id symmetric) ∘ lr (symmetric p≈q) ⟩ where lr : ∀ {p p′ q μ} → p Std.≈ q → p [ μ ]⇒̂ p′ → ∃ λ q′ → q [ μ ]⇒̂ q′ × Alt.[ i ] p′ ≈′ q′ lr p≈q p⇒̂p′ = Σ-map id (Σ-map id ⇒alternative′) (Std.weak-is-weak⇒̂ p≈q p⇒̂p′) ⇒alternative′ : ∀ {i p q} → p Std.≈ q → Alt.[ i ] p ≈′ q Alt.force (⇒alternative′ p≈q) = ⇒alternative p≈q -- The two definitions of weak bisimilarity are logically equivalent. alternative⇔ : ∀ {p q} → p Alt.≈ q ⇔ p Std.≈ q alternative⇔ = record { to = alternative⇒ ; from = ⇒alternative } -- TODO: I don't know if the two definitions of weak bisimilarity are -- isomorphic.
{ "alphanum_fraction": 0.5777233782, "avg_line_length": 31.8311688312, "ext": "agda", "hexsha": "2c8bbaa8436146d758738b3788cf282e9eb658f0", "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": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/up-to", "max_forks_repo_path": "src/Bisimilarity/Weak/Equivalent.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "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/up-to", "max_issues_repo_path": "src/Bisimilarity/Weak/Equivalent.agda", "max_line_length": 76, "max_stars_count": null, "max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/up-to", "max_stars_repo_path": "src/Bisimilarity/Weak/Equivalent.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 865, "size": 2451 }
------------------------------------------------------------------------ -- Monads ------------------------------------------------------------------------ -- Note that currently the monad laws are not included here. module Category.Monad where open import Data.Function open import Category.Monad.Indexed open import Data.Unit RawMonad : (Set → Set) → Set₁ RawMonad M = RawIMonad {⊤} (λ _ _ → M) RawMonadZero : (Set → Set) → Set₁ RawMonadZero M = RawIMonadZero {⊤} (λ _ _ → M) RawMonadPlus : (Set → Set) → Set₁ RawMonadPlus M = RawIMonadPlus {⊤} (λ _ _ → M) module RawMonad {M : Set → Set} (Mon : RawMonad M) where open RawIMonad Mon public module RawMonadZero {M : Set → Set} (Mon : RawMonadZero M) where open RawIMonadZero Mon public module RawMonadPlus {M : Set → Set} (Mon : RawMonadPlus M) where open RawIMonadPlus Mon public
{ "alphanum_fraction": 0.5844155844, "avg_line_length": 28.2333333333, "ext": "agda", "hexsha": "72ddf28e93e0bc4d2c49afb7f3e075fabe2f3128", "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/Category/Monad.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/Category/Monad.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/Category/Monad.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": 235, "size": 847 }
{-# OPTIONS --copatterns #-} -- {-# OPTIONS -v interaction.give:20 -v tc.cc:60 -v reify.clause:60 -v tc.section.check:10 -v tc:90 #-} -- {-# OPTIONS -v tc.lhs:20 #-} module Issue937 where open import Common.Equality data Nat : Set where zero : Nat suc : Nat → Nat record Σ (A : Set) (B : A → Set) : Set where constructor _,_ field proj₁ : A proj₂ : B proj₁ open Σ public data _≤_ : Nat → Nat → Set where z≤n : ∀ {n} → zero ≤ n s≤s : ∀ {m n} (m≤n : m ≤ n) → suc m ≤ suc n _<_ : Nat → Nat → Set m < n = suc m ≤ n ex : Σ Nat (λ n → zero < n) proj₁ ex = suc zero proj₂ ex = s≤s z≤n module _ (A : Set) where ex'' : Σ Nat (λ n → zero < n) proj₁ ex'' = suc zero proj₂ ex'' = s≤s z≤n test : ex'' Nat ≡ (suc zero , s≤s z≤n) test = refl
{ "alphanum_fraction": 0.5447570332, "avg_line_length": 20.0512820513, "ext": "agda", "hexsha": "df51a812afc788d77152c7daac1f461fedca6dce", "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/Issue937.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/Issue937.agda", "max_line_length": 104, "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/Issue937.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": 315, "size": 782 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.Polynomials.Multivariate.Equiv-Polyn-nPoly where open import Cubical.Foundations.Everything open import Cubical.Data.Nat renaming (_+_ to _+n_; _·_ to _·n_) open import Cubical.Data.Vec open import Cubical.Data.Sigma open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing open import Cubical.Algebra.Polynomials.Univariate.Base open import Cubical.Algebra.CommRing.Instances.UnivariatePoly open import Cubical.Algebra.Polynomials.Multivariate.Base open import Cubical.Algebra.Polynomials.Multivariate.Properties open import Cubical.Algebra.CommRing.Instances.MultivariatePoly open import Cubical.Algebra.Polynomials.Multivariate.Equiv.Poly0-A open import Cubical.Algebra.Polynomials.Multivariate.Equiv.Poly1-Poly open import Cubical.Algebra.Polynomials.Multivariate.Equiv.Comp-Poly open import Cubical.Algebra.Polynomials.Multivariate.Equiv.Induced-Poly open Nth-Poly-structure open CommRingEquivs renaming (compCommRingEquiv to _∘-ecr_ ; invCommRingEquiv to inv-ecr) private variable ℓ : Level ----------------------------------------------------------------------------- -- Definition nPoly : (A' : CommRing ℓ) → (n : ℕ) → CommRing ℓ nPoly A' zero = A' nPoly A' (suc n) = UnivariatePoly (nPoly A' n) Equiv-Polyn-nPoly : (A' : CommRing ℓ) → (n : ℕ) → CommRingEquiv (PolyCommRing A' n) (nPoly A' n) Equiv-Polyn-nPoly A' zero = CRE-Poly0-A A' Equiv-Polyn-nPoly A' (suc n) = inv-ecr _ _ (CRE-PolyN∘M-PolyN+M A' 1 n) ∘-ecr (lift-equiv-poly _ _ (Equiv-Polyn-nPoly A' n) 1 ∘-ecr CRE-Poly1-Poly: (nPoly A' n))
{ "alphanum_fraction": 0.7138590203, "avg_line_length": 38.0454545455, "ext": "agda", "hexsha": "c2494268aaa55e9a118e5c241ec000a9eab2b9e6", "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/Polynomials/Multivariate/Equiv-Polyn-nPoly.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/Polynomials/Multivariate/Equiv-Polyn-nPoly.agda", "max_line_length": 96, "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/Polynomials/Multivariate/Equiv-Polyn-nPoly.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 494, "size": 1674 }
import cedille-options open import general-util module toplevel-state (options : cedille-options.options) {mF : Set → Set} {{_ : monad mF}} where open import lib open import cedille-types open import classify options {mF} open import ctxt open import constants open import conversion open import rename open import spans options {mF} open import syntax-util open import to-string options open import string-format open import subst import cws-types record include-elt : Set where field ast : maybe start cwst : maybe cws-types.start deps : 𝕃 string {- dependencies -} import-to-dep : trie string {- map import strings in the file to their full paths -} ss : spans ⊎ string {- spans in string form (read from disk) -} err : 𝔹 -- is ss reporting an error need-to-add-symbols-to-context : 𝔹 do-type-check : 𝔹 inv : do-type-check imp need-to-add-symbols-to-context ≡ tt last-parse-time : maybe UTC cede-up-to-date : 𝔹 rkt-up-to-date : 𝔹 blank-include-elt : include-elt blank-include-elt = record { ast = nothing ; cwst = nothing; deps = [] ; import-to-dep = empty-trie ; ss = inj₂ "" ; err = ff ; need-to-add-symbols-to-context = tt ; do-type-check = tt ; inv = refl ; last-parse-time = nothing; cede-up-to-date = ff ; rkt-up-to-date = ff } -- the dependencies should pair import strings found in the file with the full paths to those imported files new-include-elt : filepath → (dependencies : 𝕃 (string × string)) → (ast : start) → cws-types.start → maybe UTC → include-elt new-include-elt filename deps x y time = record { ast = just x ; cwst = just y ; deps = map snd deps ; import-to-dep = trie-fill empty-trie deps ; ss = inj₂ "" ; err = ff ; need-to-add-symbols-to-context = tt ; do-type-check = tt ; inv = refl ; last-parse-time = time ; cede-up-to-date = ff ; rkt-up-to-date = ff } error-include-elt : string → include-elt error-include-elt err = record blank-include-elt { ss = inj₂ (global-error-string err) ; err = tt } error-span-include-elt : string → string → posinfo → include-elt error-span-include-elt err errSpan pos = record blank-include-elt { ss = inj₁ (add-span (span.mk-span err pos (posinfo-plus pos 1) [] (just errSpan) ) empty-spans ) ; err = tt } set-do-type-check-include-elt : include-elt → 𝔹 → include-elt set-do-type-check-include-elt ie b = record ie { need-to-add-symbols-to-context = (b || include-elt.need-to-add-symbols-to-context ie) ; do-type-check = b ; inv = lem b } where lem : (b : 𝔹) → b imp (b || include-elt.need-to-add-symbols-to-context ie) ≡ tt lem tt = refl lem ff = refl set-need-to-add-symbols-to-context-include-elt : include-elt → 𝔹 → include-elt set-need-to-add-symbols-to-context-include-elt ie b = record ie { need-to-add-symbols-to-context = b ; do-type-check = b && include-elt.do-type-check ie ; inv = lem b } where lem : ∀(b : 𝔹){b' : 𝔹} → b && b' imp b ≡ tt lem tt {tt} = refl lem tt {ff} = refl lem ff {tt} = refl lem ff {ff} = refl set-spans-include-elt : include-elt → spans → include-elt set-spans-include-elt ie ss = record ie { ss = inj₁ ss ; err = spans-have-error ss } set-last-parse-time-include-elt : include-elt → UTC → include-elt set-last-parse-time-include-elt ie time = record ie { last-parse-time = just time } set-cede-file-up-to-date-include-elt : include-elt → 𝔹 → include-elt set-cede-file-up-to-date-include-elt ie up-to-date = record ie { cede-up-to-date = up-to-date } set-rkt-file-up-to-date-include-elt : include-elt → 𝔹 → include-elt set-rkt-file-up-to-date-include-elt ie up-to-date = record ie { rkt-up-to-date = up-to-date } set-spans-string-include-elt : include-elt → (err : 𝔹) → string → include-elt set-spans-string-include-elt ie err ss = record ie { ss = inj₂ ss ; err = err } record toplevel-state : Set where constructor mk-toplevel-state field include-path : 𝕃 string × stringset files-with-updated-spans : 𝕃 string is : trie include-elt {- keeps track of files we have parsed and/or processed -} Γ : ctxt new-toplevel-state : (include-path : 𝕃 string × stringset) → toplevel-state new-toplevel-state ip = record { include-path = ip ; files-with-updated-spans = [] ; is = empty-trie ; Γ = new-ctxt "[nofile]" "[nomod]" } toplevel-state-lookup-occurrences : var → toplevel-state → 𝕃 (var × posinfo × string) toplevel-state-lookup-occurrences symb (mk-toplevel-state _ _ _ Γ) = ctxt-lookup-occurrences Γ symb get-include-elt-if : toplevel-state → filepath → maybe include-elt get-include-elt-if s filename = trie-lookup (toplevel-state.is s) filename -- get an include-elt assuming it will be there get-include-elt : toplevel-state → filepath → include-elt get-include-elt s filename with get-include-elt-if s filename get-include-elt s filename | nothing = blank-include-elt {- should not happen -} get-include-elt s filename | just ie = ie set-include-elt : toplevel-state → filepath → include-elt → toplevel-state set-include-elt s f ie = record s { is = trie-insert (toplevel-state.is s) f ie } set-include-path : toplevel-state → 𝕃 string × stringset → toplevel-state set-include-path s ip = record s { include-path = ip } get-do-type-check : toplevel-state → string → 𝔹 get-do-type-check s filename = include-elt.do-type-check (get-include-elt s filename) include-elt-spans-to-rope : include-elt → rope include-elt-spans-to-rope ie with (include-elt.ss ie) include-elt-spans-to-rope ie | inj₁ ss = spans-to-rope ss include-elt-spans-to-rope ie | inj₂ ss = [[ ss ]] include-elt-to-string : include-elt → string include-elt-to-string ie = " deps: " ^ (𝕃-to-string (λ x → x) "," (include-elt.deps ie)) ^ -- ast ", ast: " ^ maybe-else "not parsed" (λ ast → "parsed") (include-elt.ast ie) ^ ", " ^ " import-to-dep: " ^ (trie-to-string "," (format "filename: %s") (include-elt.import-to-dep ie)) ^ -- spans " err: " ^ (𝔹-to-string (include-elt.err ie)) ^ ", need-to-add-symbols-to-context: " ^ (𝔹-to-string (include-elt.need-to-add-symbols-to-context ie)) ^ ", do-type-check: " ^ (𝔹-to-string (include-elt.do-type-check ie)) ^ ", last-parse-time: " ^ (maybe-else "" utcToString (include-elt.last-parse-time ie)) params-to-string'' : params → string params-to-string'' ParamsNil = "" -- TODO print erased vs non-erased? params-to-string'' (ParamsCons (Decl pi pi' me v t-k pi'') pms) = "{var: " ^ v ^ ", tk: " ^ rope-to-string (tk-to-string empty-ctxt t-k) ^ "}" ^ ", " ^ (params-to-string'' pms) defParams-to-string : defParams → string defParams-to-string (just pms) = params-to-string'' pms defParams-to-string nothing = "" -- TODO also print modname? syms-to-string : trie (string × 𝕃 string) → string syms-to-string = trie-to-string ", " (λ l → "{" ^ (𝕃-to-string (λ s → s) ", " (snd l)) ^ "}") ctxt-info-to-string : ctxt-info → string ctxt-info-to-string (term-decl tp) = "term-decl: {type: " ^ rope-to-string (to-string empty-ctxt tp) ^ "}" ctxt-info-to-string (term-def dp opac t tp) = "term-def: {defParams: {" ^ (defParams-to-string dp) ^ "}, opacity: " ^ (opacity-to-string opac) ^ ", term: " ^ rope-to-string (to-string empty-ctxt t) ^ ", type: " ^ rope-to-string (to-string empty-ctxt tp) ^ "}" ctxt-info-to-string (term-udef dp opac t) = "term-udef: {defParams: {" ^ (defParams-to-string dp) ^ "}, opacity: " ^ (opacity-to-string opac) ^ ", term: " ^ rope-to-string (to-string empty-ctxt t) ^ "}" ctxt-info-to-string (type-decl k) = "type-decl: {kind: " ^ rope-to-string (to-string empty-ctxt k) ^ "}" ctxt-info-to-string (type-def dp opac tp k) = "type-def: {defParams: {" ^ (defParams-to-string dp) ^ "}, opacity: " ^ (opacity-to-string opac) ^ ", tp: " ^ rope-to-string (to-string empty-ctxt tp) ^ ", kind: " ^ rope-to-string (to-string empty-ctxt k) ^ "}" ctxt-info-to-string (kind-def pms k) = "kind-def: {pms: " ^ (params-to-string'' pms) ^ "kind: " ^ rope-to-string (to-string empty-ctxt k) ^ "}" ctxt-info-to-string (rename-def v) = "rename-def: {var: " ^ v ^ "}" ctxt-info-to-string (var-decl) = "var-decl" ctxt-info-to-string (const-def _) = "const-def" ctxt-info-to-string (datatype-def _ _) = "datatype-def" sym-info-to-string : sym-info → string sym-info-to-string (ci , (fn , pi)) = "{ctxt-info: " ^ (ctxt-info-to-string ci) ^ ", location: {filename: " ^ fn ^ ", posinfo: " ^ pi ^ "}}" sym-infos-to-string : trie sym-info → string sym-infos-to-string = trie-to-string ", " sym-info-to-string occ-to-string : var × posinfo × string → string occ-to-string (v , pi , s) = "var: " ^ v ^ ", posinfo: " ^ pi ^ ", string: " ^ s sym-occs-to-string : trie (𝕃 (var × posinfo × string)) → string sym-occs-to-string = trie-to-string ", " (λ l → "{" ^ (𝕃-to-string occ-to-string ", " l) ^ "}") qualif-to-string : qualif-info → string qualif-to-string (x , as) = x ^ rope-to-string (fst (args-to-string as {TERM} [[]] 0 [] (new-ctxt "" "") nothing neither)) mod-info-to-string : mod-info → string mod-info-to-string (fn , mn , pms , q) = "filename: " ^ fn ^ ", modname: " ^ mn ^ ", pms: {" ^ (params-to-string'' pms) ^ "}" ^ ", qualif: {" ^ (trie-to-string ", " qualif-to-string q) ^ "}" ctxt-to-string : ctxt → string ctxt-to-string (mk-ctxt mi (ss , mn-fn) is os d) = "mod-info: {" ^ (mod-info-to-string mi) ^ "}, syms: {" ^ (syms-to-string ss) ^ "}, i: {" ^ (sym-infos-to-string is) ^ "}, sym-occs: {" ^ (sym-occs-to-string os) ^ "}" toplevel-state-to-string : toplevel-state → string toplevel-state-to-string (mk-toplevel-state include-path files is context) = "\ninclude-path: {\n" ^ (𝕃-to-string (λ x → x) "\n" (fst include-path)) ^ "\n}\nis: {" ^ (trie-to-string "\n" include-elt-to-string is) ^ "\n}\nΓ: {" ^ (ctxt-to-string context) ^ "}" -- check if a variable is being redefined, and if so return the first given state; otherwise the second (in the monad) check-redefined : posinfo → var → toplevel-state → spanM toplevel-state → spanM toplevel-state check-redefined pi x s c = get-ctxt (λ Γ → if ctxt-binds-var Γ x then (spanM-add (redefined-var-span Γ pi x) ≫span spanMr s) else c) import-as : var → optAs → var import-as v NoOptAs = v import-as v (SomeOptAs pi pfx) = pfx # v error-in-import-string = "There is an error in the imported file" -- Traverse all imports, returning an error if we encounter the same file twice {-# TERMINATING #-} check-cyclic-imports : (original current : filepath) → stringset → (path : 𝕃 string) → toplevel-state → err-m check-cyclic-imports fnₒ fn fs path s with stringset-contains fs fn ...| ff = foldr (λ fnᵢ x → x maybe-or check-cyclic-imports fnₒ fnᵢ (stringset-insert fs fn) (fn :: path) s) nothing (include-elt.deps (get-include-elt s fn)) ...| tt with fnₒ =string fn ...| tt = just (foldr (λ fnᵢ x → x ^ " → " ^ fnᵢ) ("Cyclic dependencies (" ^ fn) path ^ " → " ^ fn ^ ")") ...| ff = just error-in-import-string scope-t : Set → Set scope-t X = filepath → string → optAs → params → args → X → toplevel-state → toplevel-state × err-m infixl 0 _≫=scope_ _≫=scope_ : toplevel-state × err-m → (toplevel-state → toplevel-state × err-m) → toplevel-state × err-m _≫=scope_ (ts , err) f with f ts ...| ts' , err' = ts' , err maybe-or err' {-# TERMINATING #-} scope-file : toplevel-state → (original imported : filepath) → optAs → args → toplevel-state × err-m scope-file' : scope-t ⊤ scope-cmds : scope-t cmds scope-cmd : scope-t cmd scope-var : scope-t var scope-file ts fnₒ fnᵢ oa as with check-cyclic-imports fnₒ fnᵢ (trie-single fnₒ triv) [] ts ...| just e = ts , just e ...| nothing = scope-file' fnₒ fnᵢ oa ParamsNil as triv ts scope-file' fnₒ fn oa psₒ as triv s with get-include-elt s fn ...| ie with include-elt.err ie | include-elt.ast ie ...| e | nothing = s , (maybe-if e) ≫maybe just error-in-import-string ...| e | just (File pi0 is pi1 pi2 mn ps cs pi3) = (s , (maybe-if e) ≫maybe just error-in-import-string) ≫=scope scope-cmds fn mn oa ps as (imps-to-cmds is) ≫=scope scope-cmds fn mn oa ps as cs scope-cmds fn mn oa ps as (CmdsNext c cs) s = scope-cmd fn mn oa ps as c s ≫=scope scope-cmds fn mn oa ps as cs scope-cmds fn mn oa ps as CmdsStart s = s , nothing scope-cmd fn mn oa ps as (ImportCmd (Import pi NotPublic pi' ifn oa' as' pi'')) s = s , nothing scope-cmd fn mn oa psₒ asₒ (ImportCmd (Import pi IsPublic pi' ifn oa' asᵢ' pi'')) s = let ifn' = trie-lookup-else ifn (include-elt.import-to-dep (get-include-elt s fn)) ifn in scope-file' fn ifn' oa psₒ asᵢ triv s -- ^ oa' should be NoOptAs, so we can use oa ^ where merged : trie (maybe arg) → params → args → trie (maybe arg) merged σ (ParamsCons (Decl _ _ me x atk _) ps) (ArgsCons a as) = merged (trie-insert σ x $ just a) ps as merged σ (ParamsCons (Decl _ _ me x atk _) ps) ArgsNil = merged (trie-insert σ x nothing) ps ArgsNil merged σ _ _ = σ arg-var : arg → maybe var arg-var (TermArg me (Var pi x)) = just x arg-var (TypeArg (TpVar pi x)) = just x arg-var _ = nothing σ = merged empty-trie psₒ asₒ reorder : args → args reorder (ArgsCons a as) = maybe-else' (arg-var a ≫=maybe trie-lookup σ) (ArgsCons a $ reorder as) λ ma → maybe-else' ma ArgsNil λ a → ArgsCons a $ reorder as reorder ArgsNil = ArgsNil asᵢ = reorder $ qualif-args (toplevel-state.Γ s) asᵢ' scope-cmd fn mn oa ps as (DefKind _ v _ _ _) = scope-var fn mn oa ps as v scope-cmd fn mn oa ps as (DefTermOrType _ (DefTerm _ v _ _) _) = scope-var fn mn oa ps as v scope-cmd fn mn oa ps as (DefTermOrType _ (DefType _ v _ _) _) = scope-var fn mn oa ps as v scope-cmd fn mn oa ps as (DefDatatype (Datatype _ _ v _ _ _ _) _) = scope-var fn mn oa ps as v scope-var _ mn oa ps as v s with import-as v oa | s ...| v' | mk-toplevel-state ip fns is (mk-ctxt (mn' , fn , pms , q) ss sis os d) = mk-toplevel-state ip fns is (mk-ctxt (mn' , fn , pms , trie-insert q v' (mn # v , as)) ss sis os d) , flip maybe-map (trie-lookup q v') (uncurry λ v'' as' → "Multiple definitions of variable " ^ v' ^ " as " ^ v'' ^ " and " ^ (mn # v) ^ (if (mn # v =string v'') then " (perhaps it was already imported?)" else ""))
{ "alphanum_fraction": 0.6362816511, "avg_line_length": 49.7068965517, "ext": "agda", "hexsha": "3e36f220c6ba5e2ee61f1ddfa9c2e9d695c76baa", "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": "acf691e37210607d028f4b19f98ec26c4353bfb5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "xoltar/cedille", "max_forks_repo_path": "src/toplevel-state.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5", "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": "xoltar/cedille", "max_issues_repo_path": "src/toplevel-state.agda", "max_line_length": 259, "max_stars_count": null, "max_stars_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "xoltar/cedille", "max_stars_repo_path": "src/toplevel-state.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4486, "size": 14415 }
module nodcap.NF.Typing where open import Data.Nat as ℕ using (ℕ; suc; zero) open import Data.Pos as ℕ⁺ using (ℕ⁺; suc; _+_) open import Data.Environment open import Data.List as L using (List; []; _∷_; _++_) open import Data.List.Any as LA using (Any; here; there) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Relation.Binary.PropositionalEquality as P using (_≡_) open import nodcap.Base open import nodcap.Typing as FF using (⊢_) -- Typing Rules. infix 1 ⊢ⁿᶠ_ data ⊢ⁿᶠ_ : Environment → Set where send : {Γ Δ : Environment} {A B : Type} → ⊢ⁿᶠ A ∷ Γ → ⊢ⁿᶠ B ∷ Δ → ------------------- ⊢ⁿᶠ A ⊗ B ∷ Γ ++ Δ recv : {Γ : Environment} {A B : Type} → ⊢ⁿᶠ A ∷ B ∷ Γ → ------------- ⊢ⁿᶠ A ⅋ B ∷ Γ sel₁ : {Γ : Environment} {A B : Type} → ⊢ⁿᶠ A ∷ Γ → ----------- ⊢ⁿᶠ A ⊕ B ∷ Γ sel₂ : {Γ : Environment} {A B : Type} → ⊢ⁿᶠ B ∷ Γ → ----------- ⊢ⁿᶠ A ⊕ B ∷ Γ case : {Γ : Environment} {A B : Type} → ⊢ⁿᶠ A ∷ Γ → ⊢ⁿᶠ B ∷ Γ → ------------------- ⊢ⁿᶠ A & B ∷ Γ halt : -------- ⊢ⁿᶠ 𝟏 ∷ [] wait : {Γ : Environment} → ⊢ⁿᶠ Γ → ------- ⊢ⁿᶠ ⊥ ∷ Γ loop : {Γ : Environment} → ------- ⊢ⁿᶠ ⊤ ∷ Γ mk?₁ : {Γ : Environment} {A : Type} → ⊢ⁿᶠ A ∷ Γ → --------------------- ⊢ⁿᶠ ?[ 1 ] A ∷ Γ mk!₁ : {Γ : Environment} {A : Type} → ⊢ⁿᶠ A ∷ Γ → --------------------- ⊢ⁿᶠ ![ 1 ] A ∷ Γ cont : {Γ : Environment} {A : Type} {m n : ℕ⁺} → ⊢ⁿᶠ ?[ m ] A ∷ ?[ n ] A ∷ Γ → ------------------------------ ⊢ⁿᶠ ?[ m + n ] A ∷ Γ pool : {Γ Δ : Environment} {A : Type} {m n : ℕ⁺} → ⊢ⁿᶠ ![ m ] A ∷ Γ → ⊢ⁿᶠ ![ n ] A ∷ Δ → ------------------------------------- ⊢ⁿᶠ ![ m + n ] A ∷ Γ ++ Δ exch : {Γ Δ : Environment} → Γ ∼[ bag ] Δ → ⊢ⁿᶠ Γ → -------------------- ⊢ⁿᶠ Δ fromNF : {Γ : Environment} → ⊢ⁿᶠ Γ → ⊢ Γ fromNF (send x y) = FF.send (fromNF x) (fromNF y) fromNF (recv x) = FF.recv (fromNF x) fromNF (sel₁ x) = FF.sel₁ (fromNF x) fromNF (sel₂ x) = FF.sel₂ (fromNF x) fromNF (case x y) = FF.case (fromNF x) (fromNF y) fromNF halt = FF.halt fromNF (wait x) = FF.wait (fromNF x) fromNF loop = FF.loop fromNF (mk?₁ x) = FF.mk?₁ (fromNF x) fromNF (mk!₁ x) = FF.mk!₁ (fromNF x) fromNF (cont x) = FF.cont (fromNF x) fromNF (pool x y) = FF.pool (fromNF x) (fromNF y) fromNF (exch x y) = FF.exch x (fromNF y) -- -} -- -} -- -} -- -} -- -}
{ "alphanum_fraction": 0.4325820482, "avg_line_length": 21.8017241379, "ext": "agda", "hexsha": "7d40b95801054a17b7348d60452431aabb4c50e8", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-09-05T08:58:13.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-05T08:58:13.000Z", "max_forks_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "pepijnkokke/nodcap", "max_forks_repo_path": "src/cpnd1/nodcap/NF/Typing.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2", "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": "pepijnkokke/nodcap", "max_issues_repo_path": "src/cpnd1/nodcap/NF/Typing.agda", "max_line_length": 66, "max_stars_count": 4, "max_stars_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wenkokke/nodcap", "max_stars_repo_path": "src/cpnd1/nodcap/NF/Typing.agda", "max_stars_repo_stars_event_max_datetime": "2019-09-24T20:16:35.000Z", "max_stars_repo_stars_event_min_datetime": "2018-09-05T08:58:11.000Z", "num_tokens": 1077, "size": 2529 }
-- {-# OPTIONS -v tc.check.app:70 #-} -- {-# OPTIONS -v tc.proj.amb:30 #-} record S : Set₁ where field X : Set record T : Set₁ where field X : Set open S open T ok : S → Set ok s = X s test : S → Set test s = s .X -- Error WAS: -- Cannot resolve overloaded projection X because it is not applied to -- a visible argument -- when inferring the type of .X -- Should succeed.
{ "alphanum_fraction": 0.6302083333, "avg_line_length": 15.36, "ext": "agda", "hexsha": "969feaf1baca8c1f679d18ebc8257b5874c7f316", "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/Issue2136.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/Issue2136.agda", "max_line_length": 70, "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/Issue2136.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": 118, "size": 384 }
open import Data.Nat open import Data.Vec using ( Vec ; [] ; _∷_ ) module OpenTheory2 where ---------------------------------------------------------------------- data _∈_ {A : Set} : A → {n : ℕ} → Vec A n → Set where here : {n : ℕ} {x : A} {xs : Vec A n} → x ∈ (x ∷ xs) there : {n : ℕ} {x y : A} {xs : Vec A n} (p : x ∈ xs) → x ∈ (y ∷ xs) ----------------------------------------------------------------------
{ "alphanum_fraction": 0.3245823389, "avg_line_length": 34.9166666667, "ext": "agda", "hexsha": "c9a800d1d54208d6ecc2f20d6081a58d545bb47e", "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/OpenTheory2.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/OpenTheory2.agda", "max_line_length": 70, "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/OpenTheory2.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": 124, "size": 419 }
------------------------------------------------------------------------------ -- Properties of the inequalities ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.Nat.Inequalities.PropertiesATP where open import FOTC.Base open import FOTC.Data.Nat open import FOTC.Data.Nat.Inequalities open import FOTC.Data.Nat.Inequalities.EliminationPropertiesATP open import FOTC.Data.Nat.PropertiesATP ------------------------------------------------------------------------------ -- N.B. The elimination properties are in the module -- FOTC.Data.Nat.Inequalities.EliminationProperties. 0≯x : ∀ {n} → N n → zero ≯ n 0≯x nzero = prf where postulate prf : zero ≯ zero {-# ATP prove prf #-} 0≯x (nsucc {n} Nn) = prf where postulate prf : zero ≯ succ₁ n {-# ATP prove prf #-} 0≮x→x≡0 : ∀ {n} → N n → zero ≮ n → n ≡ zero 0≮x→x≡0 nzero h = refl 0≮x→x≡0 (nsucc {n} Nn) h = prf where postulate prf : succ₁ n ≡ zero {-# ATP prove prf #-} x≮x : ∀ {n} → N n → n ≮ n x≮x nzero = prf where postulate prf : zero ≮ zero {-# ATP prove prf #-} x≮x (nsucc {n} Nn) = prf (x≮x Nn) where postulate prf : n ≮ n → succ₁ n ≮ succ₁ n {-# ATP prove prf #-} Sx≰0 : ∀ {n} → N n → succ₁ n ≰ zero Sx≰0 nzero = prf where postulate prf : succ₁ zero ≰ zero {-# ATP prove prf #-} Sx≰0 (nsucc {n} Nn) = prf where postulate prf : succ₁ (succ₁ n) ≰ zero {-# ATP prove prf #-} x<Sx : ∀ {n} → N n → n < succ₁ n x<Sx nzero = lt-0S zero x<Sx (nsucc {n} Nn) = prf (x<Sx Nn) where postulate prf : n < succ₁ n → succ₁ n < succ₁ (succ₁ n) {-# ATP prove prf #-} postulate x<y→Sx<Sy : ∀ {m n} → m < n → succ₁ m < succ₁ n {-# ATP prove x<y→Sx<Sy #-} postulate Sx<Sy→x<y : ∀ {m n} → succ₁ m < succ₁ n → m < n {-# ATP prove Sx<Sy→x<y #-} x<y→x<Sy : ∀ {m n} → N m → N n → m < n → m < succ₁ n x<y→x<Sy {m} Nm nzero h = prf where postulate prf : m < succ₁ zero {-# ATP prove prf x<0→⊥ #-} x<y→x<Sy nzero (nsucc {n} Nn) _ = lt-0S (succ₁ n) x<y→x<Sy (nsucc {m} Nm) (nsucc {n} Nn) h = prf (x<y→x<Sy Nm Nn m<n) where postulate m<n : m < n {-# ATP prove m<n #-} postulate prf : m < succ₁ n → succ₁ m < succ₁ (succ₁ n) {-# ATP prove prf #-} x≤x : ∀ {n} → N n → n ≤ n x≤x nzero = lt-0S zero x≤x (nsucc {n} Nn) = prf (x≤x Nn) where postulate prf : n ≤ n → succ₁ n ≤ succ₁ n {-# ATP prove prf #-} postulate 2*SSx≥2 : ∀ {n} → N n → succ₁ (succ₁ zero) * succ₁ (succ₁ n) ≥ succ₁ (succ₁ zero) {-# ATP prove 2*SSx≥2 #-} postulate x≤y→Sx≤Sy : ∀ {m n} → m ≤ n → succ₁ m ≤ succ₁ n {-# ATP prove x≤y→Sx≤Sy #-} postulate Sx≤Sy→x≤y : ∀ {m n} → succ₁ m ≤ succ₁ n → m ≤ n {-# ATP prove Sx≤Sy→x≤y #-} postulate Sx≤y→x≤y : ∀ {m n} → N m → N n → succ₁ m ≤ n → m ≤ n {-# ATP prove Sx≤y→x≤y x<y→x<Sy #-} postulate x≰y→Sx≰Sy : ∀ m n → m ≰ n → succ₁ m ≰ succ₁ n {-# ATP prove x≰y→Sx≰Sy #-} x>y→y<x : ∀ {m n} → N m → N n → m > n → n < m x>y→y<x {n = n} nzero Nn h = prf where postulate prf : n < zero {-# ATP prove prf #-} x>y→y<x (nsucc {m} Nm) nzero _ = lt-0S m x>y→y<x (nsucc {m} Nm) (nsucc {n} Nn) h = prf (x>y→y<x Nm Nn m>n) where postulate m>n : m > n {-# ATP prove m>n #-} postulate prf : n < m → succ₁ n < succ₁ m {-# ATP prove prf #-} x≥y→x≮y : ∀ {m n} → N m → N n → m ≥ n → m ≮ n x≥y→x≮y nzero nzero h = prf where postulate prf : zero ≮ zero {-# ATP prove prf #-} x≥y→x≮y nzero (nsucc {n} Nn) h = prf where postulate prf : zero ≮ succ₁ n {-# ATP prove prf 0≥S→⊥ #-} x≥y→x≮y (nsucc {m} Nm) nzero _ = lt-S0 m x≥y→x≮y (nsucc {m} Nm) (nsucc {n} Nn) h = prf (x≥y→x≮y Nm Nn m≥n) where postulate m≥n : m ≥ n {-# ATP prove m≥n #-} postulate prf : m ≮ n → succ₁ m ≮ succ₁ n {-# ATP prove prf #-} x≮y→x≥y : ∀ {m n} → N m → N n → m ≮ n → m ≥ n x≮y→x≥y nzero nzero h = prf where postulate prf : zero ≥ zero {-# ATP prove prf #-} x≮y→x≥y nzero (nsucc {n} Nn) h = prf where postulate prf : zero ≥ succ₁ n {-# ATP prove prf #-} x≮y→x≥y (nsucc {m} Nm) nzero _ = lt-0S (succ₁ m) x≮y→x≥y (nsucc {m} Nm) (nsucc {n} Nn) h = prf (x≮y→x≥y Nm Nn m≮n) where postulate m≮n : m ≮ n {-# ATP prove m≮n #-} postulate prf : m ≥ n → succ₁ m ≥ succ₁ n {-# ATP prove prf #-} x>y→x≰y : ∀ {m n} → N m → N n → m > n → m ≰ n x>y→x≰y {n = n} nzero Nn h = prf where postulate prf : zero ≰ n {-# ATP prove prf 0>x→⊥ #-} x>y→x≰y (nsucc {m} Nm) nzero h = prf where postulate prf : succ₁ m ≰ zero {-# ATP prove prf Sx≰0 #-} x>y→x≰y (nsucc {m} Nm) (nsucc {n} Nn) h = prf (x>y→x≰y Nm Nn m>n) where postulate m>n : m > n {-# ATP prove m>n #-} postulate prf : m ≰ n → succ₁ m ≰ succ₁ n {-# ATP prove prf #-} x>y∨x≤y : ∀ {m n} → N m → N n → m > n ∨ m ≤ n x>y∨x≤y {n = n} nzero Nn = prf where postulate prf : zero > n ∨ zero ≤ n {-# ATP prove prf #-} x>y∨x≤y (nsucc {m} Nm) nzero = prf where postulate prf : succ₁ m > zero ∨ succ₁ m ≤ zero {-# ATP prove prf #-} x>y∨x≤y (nsucc {m} Nm) (nsucc {n} Nn) = prf (x>y∨x≤y Nm Nn) where postulate prf : m > n ∨ m ≤ n → succ₁ m > succ₁ n ∨ succ₁ m ≤ succ₁ n {-# ATP prove prf #-} x<y∨x≥y : ∀ {m n} → N m → N n → m < n ∨ m ≥ n x<y∨x≥y Nm Nn = x>y∨x≤y Nn Nm x<y∨x≮y : ∀ {m n} → N m → N n → m < n ∨ m ≮ n x<y∨x≮y nzero nzero = prf where postulate prf : zero < zero ∨ zero ≮ zero {-# ATP prove prf #-} x<y∨x≮y nzero (nsucc {n} Nn) = prf where postulate prf : zero < succ₁ n ∨ zero ≮ succ₁ n {-# ATP prove prf #-} x<y∨x≮y (nsucc {m} Nm) nzero = prf where postulate prf : succ₁ m < zero ∨ succ₁ m ≮ zero {-# ATP prove prf #-} x<y∨x≮y (nsucc {m} Nm) (nsucc {n} Nn) = prf (x<y∨x≮y Nm Nn) where postulate prf : m < n ∨ m ≮ n → succ₁ m < succ₁ n ∨ succ₁ m ≮ succ₁ n {-# ATP prove prf #-} x≤y∨x≰y : ∀ {m n} → N m → N n → m ≤ n ∨ m ≰ n x≤y∨x≰y {n = n} nzero Nn = prf where postulate prf : zero ≤ n ∨ zero ≰ n {-# ATP prove prf #-} x≤y∨x≰y (nsucc {m} Nm) nzero = prf where postulate prf : succ₁ m ≤ zero ∨ succ₁ m ≰ zero {-# ATP prove prf Sx≰0 #-} x≤y∨x≰y (nsucc {m} Nm) (nsucc {n} Nn) = prf (x≤y∨x≰y Nm Nn) where postulate prf : m ≤ n ∨ m ≰ n → succ₁ m ≤ succ₁ n ∨ succ₁ m ≰ succ₁ n {-# ATP prove prf #-} postulate x≡y→x≤y : ∀ {m n} → N m → N n → m ≡ n → m ≤ n {-# ATP prove x≡y→x≤y x≤x #-} x<y→x≤y : ∀ {m n} → N m → N n → m < n → m ≤ n x<y→x≤y {m} Nm nzero h = prf where postulate prf : m ≤ zero {-# ATP prove prf x<0→⊥ #-} x<y→x≤y nzero (nsucc {n} Nn) _ = lt-0S (succ₁ n) x<y→x≤y (nsucc {m} Nm) (nsucc {n} Nn) h = prf (x<y→x≤y Nm Nn m<n) where postulate m<n : m < n {-# ATP prove m<n #-} postulate prf : m ≤ n → succ₁ m ≤ succ₁ n {-# ATP prove prf #-} x<Sy→x≤y : ∀ {m n} → N m → N n → m < succ₁ n → m ≤ n x<Sy→x≤y {n = n} nzero Nn _ = lt-0S n x<Sy→x≤y (nsucc Nm) Nn Sm<Sn = Sm<Sn x≤y→x<Sy : ∀ {m n} → N m → N n → m ≤ n → m < succ₁ n x≤y→x<Sy {n = n} nzero Nn _ = lt-0S n x≤y→x<Sy (nsucc Nm) Nn Sm≤n = Sm≤n x≤Sx : ∀ {m} → N m → m ≤ succ₁ m x≤Sx nzero = lt-0S (succ₁ zero) x≤Sx (nsucc {m} Nm) = prf (x≤Sx Nm) where postulate prf : m ≤ succ₁ m → succ₁ m ≤ succ₁ (succ₁ m) {-# ATP prove prf #-} x<y→Sx≤y : ∀ {m n} → N m → N n → m < n → succ₁ m ≤ n x<y→Sx≤y {m} Nm nzero h = prf where postulate prf : succ₁ m ≤ zero {-# ATP prove prf x<0→⊥ #-} x<y→Sx≤y nzero (nsucc {n} Nn) h = prf where postulate prf : succ₁ zero ≤ succ₁ n {-# ATP prove prf x<0→⊥ #-} x<y→Sx≤y (nsucc {m} Nm) (nsucc {n} Nn) h = prf where postulate prf : succ₁ (succ₁ m) ≤ succ₁ n {-# ATP prove prf #-} Sx≤y→x<y : ∀ {m n} → N m → N n → succ₁ m ≤ n → m < n Sx≤y→x<y {m} Nm nzero h = prf where postulate prf : m < zero {-# ATP prove prf S≤0→⊥ #-} Sx≤y→x<y nzero (nsucc {n} Nn) _ = lt-0S n Sx≤y→x<y (nsucc {m} Nm) (nsucc {n} Nn) h = prf (Sx≤y→x<y Nm Nn Sm≤n) where postulate Sm≤n : succ₁ m ≤ n {-# ATP prove Sm≤n #-} postulate prf : m < n → succ₁ m < succ₁ n {-# ATP prove prf #-} x≤y→x≯y : ∀ {m n} → N m → N n → m ≤ n → m ≯ n x≤y→x≯y nzero nzero h = prf where postulate prf : zero ≯ zero {-# ATP prove prf #-} x≤y→x≯y nzero (nsucc {n} Nn) h = prf where postulate prf : zero ≯ succ₁ n {-# ATP prove prf #-} x≤y→x≯y (nsucc {m} Nm) nzero h = prf where postulate prf : succ₁ m ≯ zero {-# ATP prove prf S≤0→⊥ #-} x≤y→x≯y (nsucc {m} Nm) (nsucc {n} Nn) h = prf (x≤y→x≯y Nm Nn m≤n) where postulate m≤n : m ≤ n {-# ATP prove m≤n #-} postulate prf : m ≯ n → succ₁ m ≯ succ₁ n {-# ATP prove prf #-} x≯y→x≤y : ∀ {m n} → N m → N n → m ≯ n → m ≤ n x≯y→x≤y {n = n} nzero Nn _ = lt-0S n x≯y→x≤y (nsucc {m} Nm) nzero h = prf where postulate prf : succ₁ m ≤ zero {-# ATP prove prf #-} x≯y→x≤y (nsucc {m} Nm) (nsucc {n} Nn) h = prf (x≯y→x≤y Nm Nn m≯n) where postulate m≯n : m ≯ n {-# ATP prove m≯n #-} postulate prf : m ≤ n → succ₁ m ≤ succ₁ n {-# ATP prove prf #-} Sx≯y→x≯y : ∀ {m n} → N m → N n → succ₁ m ≯ n → m ≯ n Sx≯y→x≯y nzero nzero h = prf where postulate prf : zero ≯ zero {-# ATP prove prf #-} Sx≯y→x≯y nzero (nsucc {n} Nn) h = prf where postulate prf : zero ≯ succ₁ n {-# ATP prove prf #-} Sx≯y→x≯y (nsucc {m} Nm) nzero h = prf where postulate prf : succ₁ m ≯ zero {-# ATP prove prf #-} Sx≯y→x≯y (nsucc {m} Nm) (nsucc {n} Nn) h = prf (Sx≯y→x≯y Nm Nn Sm≯n) where postulate Sm≯n : succ₁ m ≯ n {-# ATP prove Sm≯n #-} postulate prf : m ≯ n → succ₁ m ≯ succ₁ n {-# ATP prove prf #-} x>y∨x≯y : ∀ {m n} → N m → N n → m > n ∨ m ≯ n x>y∨x≯y {n = n} nzero Nn = prf where postulate prf : zero > n ∨ zero ≯ n {-# ATP prove prf 0≯x #-} x>y∨x≯y (nsucc {m} Nm) nzero = prf where postulate prf : succ₁ m > zero ∨ succ₁ m ≯ zero {-# ATP prove prf #-} x>y∨x≯y (nsucc {m} Nm) (nsucc {n} Nn) = prf (x>y∨x≯y Nm Nn) where postulate prf : m > n ∨ m ≯ n → succ₁ m > succ₁ n ∨ succ₁ m ≯ succ₁ n {-# ATP prove prf #-} <-trans : ∀ {m n o} → N m → N n → N o → m < n → n < o → m < o <-trans {o = o} nzero nzero No h₁ h₂ = prf where postulate prf : zero < o {-# ATP prove prf #-} <-trans nzero (nsucc Nn) nzero h₁ h₂ = prf where postulate prf : zero < zero {-# ATP prove prf #-} <-trans nzero (nsucc Nn) (nsucc {o} No) _ _ = lt-0S o <-trans (nsucc {m} Nm) Nn nzero h₁ h₂ = prf where postulate prf : succ₁ m < zero {-# ATP prove prf x<0→⊥ #-} <-trans (nsucc {m} Nm) nzero (nsucc {o} No) h₁ h₂ = prf where postulate prf : succ₁ m < succ₁ o {-# ATP prove prf #-} <-trans (nsucc {m} Nm) (nsucc {n} Nn) (nsucc {o} No) h₁ h₂ = prf (<-trans Nm Nn No m<n n<o) where postulate m<n : m < n {-# ATP prove m<n #-} postulate n<o : n < o {-# ATP prove n<o #-} postulate prf : m < o → succ₁ m < succ₁ o {-# ATP prove prf #-} ≤-trans : ∀ {m n o} → N m → N n → N o → m ≤ n → n ≤ o → m ≤ o ≤-trans {o = o} nzero Nn No _ _ = lt-0S o ≤-trans {o = o} (nsucc {m} Nm) nzero No h₁ h₂ = prf where postulate prf : succ₁ m ≤ o {-# ATP prove prf S≤0→⊥ #-} ≤-trans (nsucc {m} Nm) (nsucc Nn) nzero h₁ h₂ = prf where postulate prf : succ₁ m ≤ zero {-# ATP prove prf S≤0→⊥ #-} ≤-trans (nsucc {m} Nm) (nsucc {n} Nn) (nsucc {o} No) h₁ h₂ = prf (≤-trans Nm Nn No m≤n n≤o) where postulate m≤n : m ≤ n {-# ATP prove m≤n #-} postulate n≤o : n ≤ o {-# ATP prove n≤o #-} postulate prf : m ≤ o → succ₁ m ≤ succ₁ o {-# ATP prove prf #-} pred-≤ : ∀ {n} → N n → pred₁ n ≤ n pred-≤ nzero = prf where postulate prf : pred₁ zero ≤ zero {-# ATP prove prf #-} pred-≤ (nsucc {n} Nn) = prf where postulate prf : pred₁ (succ₁ n) ≤ succ₁ n {-# ATP prove prf <-trans x<Sx #-} x≤x+y : ∀ {m n} → N m → N n → m ≤ m + n x≤x+y {n = n} nzero Nn = lt-0S (zero + n) x≤x+y {n = n} (nsucc {m} Nm) Nn = prf (x≤x+y Nm Nn) where postulate prf : m ≤ m + n → succ₁ m ≤ succ₁ m + n {-# ATP prove prf #-} x<x+Sy : ∀ {m n} → N m → N n → m < m + succ₁ n x<x+Sy {n = n} nzero Nn = prf0 where postulate prf0 : zero < zero + succ₁ n {-# ATP prove prf0 #-} x<x+Sy {n = n} (nsucc {m} Nm) Nn = prfS (x<x+Sy Nm Nn) where postulate prfS : m < m + succ₁ n → succ₁ m < succ₁ m + succ₁ n {-# ATP prove prfS #-} k+x<k+y→x<y : ∀ {m n k} → N m → N n → N k → k + m < k + n → m < n k+x<k+y→x<y {m} {n} Nm Nn nzero h = prf0 where postulate prf0 : m < n {-# ATP prove prf0 #-} k+x<k+y→x<y {m} {n} Nm Nn (nsucc {k} Nk) h = k+x<k+y→x<y Nm Nn Nk prfS where postulate prfS : k + m < k + n {-# ATP prove prfS #-} postulate x+k<y+k→x<y : ∀ {m n k} → N m → N n → N k → m + k < n + k → m < n {-# ATP prove x+k<y+k→x<y k+x<k+y→x<y +-comm #-} x≤y→k+x≤k+y : ∀ {m n k} → N m → N n → N k → m ≤ n → k + m ≤ k + n x≤y→k+x≤k+y {m} {n} Nm Nn nzero h = prf0 where postulate prf0 : zero + m ≤ zero + n {-# ATP prove prf0 #-} x≤y→k+x≤k+y {m} {n} Nm Nn (nsucc {k} Nk) h = prfS (x≤y→k+x≤k+y Nm Nn Nk h) where postulate prfS : k + m ≤ k + n → succ₁ k + m ≤ succ₁ k + n {-# ATP prove prfS #-} postulate x≤y→x+k≤y+k : ∀ {m n k} → N m → N n → N k → m ≤ n → m + k ≤ n + k {-# ATP prove x≤y→x+k≤y+k x≤y→k+x≤k+y +-comm #-} x<y→Sx∸y≡0 : ∀ {m n} → N m → N n → m < n → succ₁ m ∸ n ≡ zero x<y→Sx∸y≡0 {m} Nm nzero h = prfx0 where postulate prfx0 : succ₁ m ∸ zero ≡ zero {-# ATP prove prfx0 x<0→⊥ #-} x<y→Sx∸y≡0 nzero (nsucc {n} Nn) h = prf0S where postulate prf0S : succ₁ zero ∸ succ₁ n ≡ zero {-# ATP prove prf0S S∸S 0∸x #-} x<y→Sx∸y≡0 (nsucc {m} Nm) (nsucc {n} Nn) h = prfSS (x<y→Sx∸y≡0 Nm Nn m<n) where postulate m<n : m < n {-# ATP prove m<n #-} postulate prfSS : succ₁ m ∸ n ≡ zero → succ₁ (succ₁ m) ∸ succ₁ n ≡ zero {-# ATP prove prfSS S∸S #-} postulate x≤y→x∸y≡0 : ∀ {m n} → N m → N n → m ≤ n → m ∸ n ≡ zero {-# ATP prove x≤y→x∸y≡0 x<y→Sx∸y≡0 S∸S #-} x<y→0<y∸x : ∀ {m n} → N m → N n → m < n → zero < n ∸ m x<y→0<y∸x {m} Nm nzero h = prfx0 where postulate prfx0 : zero < zero ∸ m {-# ATP prove prfx0 x<0→⊥ #-} x<y→0<y∸x nzero (nsucc {n} Nn) h = prf0S where postulate prf0S : zero < succ₁ n ∸ zero {-# ATP prove prf0S #-} x<y→0<y∸x (nsucc {m} Nm) (nsucc {n} Nn) h = prfSS (x<y→0<y∸x Nm Nn m<n) where postulate m<n : m < n {-# ATP prove m<n #-} postulate prfSS : zero < n ∸ m → zero < succ₁ n ∸ succ₁ m {-# ATP prove prfSS S∸S #-} 0<x∸y→0<Sx∸y : ∀ {m n} → N m → N n → zero < m ∸ n → zero < succ₁ m ∸ n 0<x∸y→0<Sx∸y {m} Nm nzero h = prfx0 where postulate prfx0 : zero < succ₁ m ∸ zero {-# ATP prove prfx0 #-} 0<x∸y→0<Sx∸y nzero (nsucc {n} Nn) h = prf0S where postulate prf0S : zero < succ₁ zero ∸ succ₁ n {-# ATP prove prf0S 0∸x x<0→⊥ #-} 0<x∸y→0<Sx∸y (nsucc {m} Nm) (nsucc {n} Nn) h = prfSS (0<x∸y→0<Sx∸y Nm Nn 0<m-n) where postulate 0<m-n : zero < m ∸ n {-# ATP prove 0<m-n S∸S #-} postulate prfSS : zero < succ₁ m ∸ n → zero < succ₁ (succ₁ m) ∸ succ₁ n {-# ATP prove prfSS <-trans S∸S #-} x∸y<Sx : ∀ {m n} → N m → N n → m ∸ n < succ₁ m x∸y<Sx {m} Nm nzero = prf where postulate prf : m ∸ zero < succ₁ m {-# ATP prove prf x<Sx #-} x∸y<Sx nzero (nsucc {n} Nn) = prf where postulate prf : zero ∸ succ₁ n < succ₁ zero {-# ATP prove prf 0∸x #-} x∸y<Sx (nsucc {m} Nm) (nsucc {n} Nn) = prf (x∸y<Sx Nm Nn) where postulate prf : m ∸ n < succ₁ m → succ₁ m ∸ succ₁ n < succ₁ (succ₁ m) {-# ATP prove prf <-trans ∸-N x<Sx S∸S #-} postulate Sx∸Sy<Sx : ∀ {m n} → N m → N n → succ₁ m ∸ succ₁ n < succ₁ m {-# ATP prove Sx∸Sy<Sx x∸y<Sx S∸S #-} x<x∸y→⊥ : ∀ {m n} → N m → N n → ¬ (m < m ∸ n) x<x∸y→⊥ {m} Nm nzero h = prf where postulate prf : ⊥ {-# ATP prove prf x<x→⊥ #-} x<x∸y→⊥ nzero (nsucc Nn) h = prf where postulate prf : ⊥ {-# ATP prove prf x<x→⊥ 0∸x #-} x<x∸y→⊥ (nsucc Nm) (nsucc Nn) h = prf where postulate prf : ⊥ {-# ATP prove prf ∸-N x<y→y<x→⊥ x∸y<Sx S∸S #-} postulate x∸Sy≤x∸y : ∀ {m n} → N m → N n → m ∸ succ₁ n ≤ m ∸ n {-# ATP prove x∸Sy≤x∸y pred-≤ ∸-N #-} x>y→x∸y+y≡x : ∀ {m n} → N m → N n → m > n → (m ∸ n) + n ≡ m x>y→x∸y+y≡x {n = n} nzero Nn h = prf where postulate prf : zero ∸ n + n ≡ zero {-# ATP prove prf 0>x→⊥ #-} x>y→x∸y+y≡x (nsucc {m} Nm) nzero h = prf where postulate prf : (succ₁ m ∸ zero) + zero ≡ succ₁ m {-# ATP prove prf +-rightIdentity ∸-N #-} x>y→x∸y+y≡x (nsucc {m} Nm) (nsucc {n} Nn) h = prf (x>y→x∸y+y≡x Nm Nn m>n) where postulate m>n : m > n {-# ATP prove m>n #-} postulate prf : (m ∸ n) + n ≡ m → (succ₁ m ∸ succ₁ n) + succ₁ n ≡ succ₁ m {-# ATP prove prf +-comm ∸-N S∸S #-} x≤y→y∸x+x≡y : ∀ {m n} → N m → N n → m ≤ n → (n ∸ m) + m ≡ n x≤y→y∸x+x≡y {n = n} nzero Nn h = prf where postulate prf : (n ∸ zero) + zero ≡ n {-# ATP prove prf +-rightIdentity ∸-N #-} x≤y→y∸x+x≡y (nsucc {m} Nm) nzero h = prf where postulate prf : (zero ∸ succ₁ m) + succ₁ m ≡ zero {-# ATP prove prf S≤0→⊥ #-} x≤y→y∸x+x≡y (nsucc {m} Nm) (nsucc {n} Nn) h = prf (x≤y→y∸x+x≡y Nm Nn m≤n) where postulate m≤n : m ≤ n {-# ATP prove m≤n #-} postulate prf : (n ∸ m) + m ≡ n → (succ₁ n ∸ succ₁ m) + succ₁ m ≡ succ₁ n {-# ATP prove prf +-comm ∸-N S∸S #-} x<Sy→x<y∨x≡y : ∀ {m n} → N m → N n → m < succ₁ n → m < n ∨ m ≡ n x<Sy→x<y∨x≡y nzero nzero h = inj₂ refl x<Sy→x<y∨x≡y nzero (nsucc {n} Nn) h = inj₁ (lt-0S n) x<Sy→x<y∨x≡y (nsucc {m} Nm) nzero h = prf where postulate prf : succ₁ m < zero ∨ succ₁ m ≡ zero {-# ATP prove prf x<0→⊥ #-} x<Sy→x<y∨x≡y (nsucc {m} Nm) (nsucc {n} Nn) h = prf (x<Sy→x<y∨x≡y Nm Nn m<Sn) where postulate m<Sn : m < succ₁ n {-# ATP prove m<Sn #-} postulate prf : m < n ∨ m ≡ n → succ₁ m < succ₁ n ∨ succ₁ m ≡ succ₁ n {-# ATP prove prf #-} x≤y→x<y∨x≡y : ∀ {m n} → N m → N n → m ≤ n → m < n ∨ m ≡ n x≤y→x<y∨x≡y = x<Sy→x<y∨x≡y postulate x<y→y≡z→x<z : ∀ {m n o} → m < n → n ≡ o → m < o {-# ATP prove x<y→y≡z→x<z #-} postulate x≡y→y<z→x<z : ∀ {m n o} → m ≡ n → n < o → m < o {-# ATP prove x≡y→y<z→x<z #-} x≯Sy→x≯y∨x≡Sy : ∀ {m n} → N m → N n → m ≯ succ₁ n → m ≯ n ∨ m ≡ succ₁ n x≯Sy→x≯y∨x≡Sy nzero nzero h = prf where postulate prf : zero ≯ zero ∨ zero ≡ succ₁ zero {-# ATP prove prf #-} x≯Sy→x≯y∨x≡Sy nzero (nsucc {n} Nn) h = prf where postulate prf : zero ≯ succ₁ n ∨ zero ≡ succ₁ (succ₁ n) {-# ATP prove prf #-} x≯Sy→x≯y∨x≡Sy (nsucc {m} Nm) nzero h = prf where postulate prf : succ₁ m ≯ zero ∨ succ₁ m ≡ succ₁ zero {-# ATP prove prf 0≮x→x≡0 #-} x≯Sy→x≯y∨x≡Sy (nsucc {m} Nm) (nsucc {n} Nn) h = prf (x≯Sy→x≯y∨x≡Sy Nm Nn m≯Sn) where postulate m≯Sn : m ≯ succ₁ n {-# ATP prove m≯Sn #-} postulate prf : m ≯ n ∨ m ≡ succ₁ n → succ₁ m ≯ succ₁ n ∨ succ₁ m ≡ succ₁ (succ₁ n) {-# ATP prove prf #-} x≥y→y>0→x∸y<x : ∀ {m n} → N m → N n → m ≥ n → n > zero → m ∸ n < m x≥y→y>0→x∸y<x {m} Nm nzero h₁ h₂ = prf where postulate prf : m ∸ zero < m {-# ATP prove prf x∸y<Sx 0∸x S∸S #-} x≥y→y>0→x∸y<x nzero (nsucc {n} Nn) h₁ h₂ = prf where postulate prf : zero ∸ succ₁ n < zero {-# ATP prove prf 0∸x S≤0→⊥ #-} x≥y→y>0→x∸y<x (nsucc {m} Nm) (nsucc {n} Nn) h₁ h₂ = prf where postulate prf : succ₁ m ∸ succ₁ n < succ₁ m {-# ATP prove prf x∸y<Sx 0∸x S∸S #-} x<y→y≤z→x<z : ∀ {m n o} → N m → N n → N o → m < n → n ≤ o → m < o x<y→y≤z→x<z {o = o} nzero nzero No h₁ h₂ = prf where postulate prf : zero < o {-# ATP prove prf 0<0→⊥ #-} x<y→y≤z→x<z nzero (nsucc Nn) nzero h₁ h₂ = prf where postulate prf : zero < zero {-# ATP prove prf S≤0→⊥ #-} x<y→y≤z→x<z nzero (nsucc Nn) (nsucc {o} No) h₁ h₂ = prf where postulate prf : zero < succ₁ o {-# ATP prove prf #-} x<y→y≤z→x<z {o = o} (nsucc {m} Nm) nzero No h₁ h₂ = prf where postulate prf : succ₁ m < o {-# ATP prove prf #-} x<y→y≤z→x<z (nsucc {m} Nm) (nsucc Nn) nzero h₁ h₂ = prf where postulate prf : succ₁ m < zero {-# ATP prove prf S≤0→⊥ #-} x<y→y≤z→x<z (nsucc {m} Nm) (nsucc {n} Nn) (nsucc {o} No) h₁ h₂ = prf (x<y→y≤z→x<z Nm Nn No m<n n≤o) where postulate m<n : m < n {-# ATP prove m<n #-} postulate n≤o : n ≤ o {-# ATP prove n≤o #-} postulate prf : m < o → succ₁ m < succ₁ o {-# ATP prove prf #-} x≤y+x∸y : ∀ {m n} → N m → N n → m ≤ n + (m ∸ n) x≤y+x∸y {n = n} nzero Nn = prf0 where postulate prf0 : zero ≤ n + (zero ∸ n) {-# ATP prove prf0 +-N #-} x≤y+x∸y (nsucc {m} Nm) nzero = prfx0 where postulate prfx0 : succ₁ m ≤ zero + (succ₁ m ∸ zero) {-# ATP prove prfx0 x<Sx #-} x≤y+x∸y (nsucc {m} Nm) (nsucc {n} Nn) = prfSS (x≤y+x∸y Nm Nn) where postulate prfSS : m ≤ n + (m ∸ n) → succ₁ m ≤ succ₁ n + (succ₁ m ∸ succ₁ n) {-# ATP prove prfSS x≤y→Sx≤Sy ≤-trans +-N ∸-N S∸S #-} x∸y<x∸z→Sx∸y<Sx∸z : ∀ {m n o} → N m → N n → N o → m ∸ n < m ∸ o → succ₁ m ∸ n < succ₁ m ∸ o x∸y<x∸z→Sx∸y<Sx∸z {n = n} {o} nzero Nn No h = prf where postulate prf : succ₁ zero ∸ n < succ₁ zero ∸ o {-# ATP prove prf 0∸x #-} x∸y<x∸z→Sx∸y<Sx∸z {o = o} (nsucc {m} Nm) nzero No h = prf where postulate prf : succ₁ (succ₁ m) ∸ zero < succ₁ (succ₁ m) ∸ o {-# ATP prove prf x<x∸y→⊥ #-} x∸y<x∸z→Sx∸y<Sx∸z (nsucc {m} Nm) (nsucc {n} Nn) nzero h = prf where postulate prf : succ₁ (succ₁ m) ∸ succ₁ n < succ₁ (succ₁ m) ∸ zero {-# ATP prove prf Sx∸Sy<Sx #-} x∸y<x∸z→Sx∸y<Sx∸z (nsucc {m} Nm) (nsucc {n} Nn) (nsucc {o} No) h = prf (x∸y<x∸z→Sx∸y<Sx∸z Nm Nn No) where postulate prf : (m ∸ n < m ∸ o → succ₁ m ∸ n < succ₁ m ∸ o) → succ₁ (succ₁ m) ∸ succ₁ n < succ₁ (succ₁ m) ∸ succ₁ o {-# ATP prove prf S∸S #-} ------------------------------------------------------------------------------ -- Properties about the lexicographical order postulate xy<00→⊥ : ∀ {m n} → N m → N n → ¬ (Lexi m n zero zero) {-# ATP prove xy<00→⊥ x<0→⊥ #-} postulate 0Sx<00→⊥ : ∀ {m} → ¬ (Lexi zero (succ₁ m) zero zero) {-# ATP prove 0Sx<00→⊥ #-} postulate Sxy₁<0y₂→⊥ : ∀ {m n₁ n₂} → ¬ (Lexi (succ₁ m) n₁ zero n₂) {-# ATP prove Sxy₁<0y₂→⊥ #-} postulate x₁y<x₂0→x₁<x₂ : ∀ {m₁ n} → N n → ∀ {m₂} → Lexi m₁ n m₂ zero → m₁ < m₂ {-# ATP prove x₁y<x₂0→x₁<x₂ x<0→⊥ #-} postulate xy₁<0y₂→x≡0∧y₁<y₂ : ∀ {m} → N m → ∀ {n₁ n₂} → Lexi m n₁ zero n₂ → m ≡ zero ∧ n₁ < n₂ {-# ATP prove xy₁<0y₂→x≡0∧y₁<y₂ x<0→⊥ #-} [Sx∸Sy,Sy]<[Sx,Sy] : ∀ {m n} → N m → N n → Lexi (succ₁ m ∸ succ₁ n) (succ₁ n) (succ₁ m) (succ₁ n) [Sx∸Sy,Sy]<[Sx,Sy] {m} {n} Nm Nn = prf where postulate prf : Lexi (succ₁ m ∸ succ₁ n) (succ₁ n) (succ₁ m) (succ₁ n) {-# ATP prove prf x∸y<Sx S∸S #-} [Sx,Sy∸Sx]<[Sx,Sy] : ∀ {m n} → N m → N n → Lexi (succ₁ m) (succ₁ n ∸ succ₁ m) (succ₁ m) (succ₁ n) [Sx,Sy∸Sx]<[Sx,Sy] {m} {n} Nm Nn = prf where postulate prf : Lexi (succ₁ m) (succ₁ n ∸ succ₁ m) (succ₁ m) (succ₁ n) {-# ATP prove prf x∸y<Sx S∸S #-}
{ "alphanum_fraction": 0.5066142764, "avg_line_length": 35.1303680982, "ext": "agda", "hexsha": "5ccdb2e60da9b7108e4e89f63665926439d97ef8", "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/Data/Nat/Inequalities/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/Data/Nat/Inequalities/PropertiesATP.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/Data/Nat/Inequalities/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": 11110, "size": 22905 }
-- Like Leftovers.Examples, but more meant to stress-test the library -- than to be clear/readable module Leftovers.Tests where open import Leftovers.Leftovers open import Leftovers.ByRefl open import Level open import Reflection open import Data.Nat open import Relation.Binary.PropositionalEquality open import Data.Unit open import Data.List --Make sure findLeftovers works with data Foo : Set(Level.suc Level.zero) where Bar : Set → ℕ → ((n : ℕ) → n ≡ n + 0) → Foo makePair : Term → TC ⊤ makePair = λ goal → do hole1 <- newMeta (quoteTerm Set) hole2 <- newMeta (quoteTerm ℕ) hole3 <- newMeta (quoteTerm ((n : ℕ) → n ≡ n + 0)) body <- extendContext (vArg (quoteTerm ℕ)) do tyHole ← newMeta (quoteTerm Set) newHole ← newMeta tyHole return (def (quote sym) (vArg newHole ∷ [])) unify hole3 (lam visible (abs "arg" body)) unify hole2 (quoteTerm 4) unify goal (con (quote Bar) (vArg hole1 ∷ vArg hole2 ∷ vArg hole3 ∷ [])) p0 : ∀ n → n + 0 ≡ n p0 zero = refl p0 (suc n) rewrite p0 n = refl f : Foo f = by makePair andAlso p0 ℕ
{ "alphanum_fraction": 0.6491540516, "avg_line_length": 23.3958333333, "ext": "agda", "hexsha": "186b012a0fa5ce0f52ea64e0e6c6235e62b3cd53", "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": "01b60b405009feaada181af175f019ceb89e42b2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "JoeyEremondi/AgdaLeftovers", "max_forks_repo_path": "src/Leftovers/Tests.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "01b60b405009feaada181af175f019ceb89e42b2", "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": "JoeyEremondi/AgdaLeftovers", "max_issues_repo_path": "src/Leftovers/Tests.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "01b60b405009feaada181af175f019ceb89e42b2", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "JoeyEremondi/AgdaLeftovers", "max_stars_repo_path": "src/Leftovers/Tests.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 355, "size": 1123 }