Search is not available for this dataset
text
string
meta
dict
module All where data List (A : Set) : Set where [] : List A _::_ : A -> List A -> List A map : {A B : Set} -> (A -> B) -> List A -> List B map f [] = [] map f (x :: xs) = f x :: map f xs _++_ : {A : Set} -> List A -> List A -> List A [] ++ ys = ys (x :: xs) ++ ys = x :: (xs ++ ys) foldr : {A B : Set} -> (A -> B -> B) -> B -> List A -> B foldr f z [] = z foldr f z (x :: xs) = f x (foldr f z xs) data All {A : Set}(P : A -> Set) : List A -> Set where ∅ : All P [] _▹_ : {x : A}{xs : List A} -> P x -> All P xs -> All P (x :: xs) data Some {A : Set}(P : A -> Set) : List A -> Set where hd : {x : A}{xs : List A} -> P x -> Some P (x :: xs) tl : {x : A}{xs : List A} -> Some P xs -> Some P (x :: xs) data _==_ {A : Set}(x : A) : A -> Set where refl : x == x _∈_ : {A : Set} -> A -> List A -> Set x ∈ xs = Some (_==_ x) xs infixr 40 _,_ data _×_ (A : Set)(B : A -> Set) : Set where _,_ : (x : A) -> B x -> A × B _∧_ : (A B : Set) -> Set A ∧ B = A × \_ -> B _!_ : {A : Set}{P : A -> Set}{Q : A -> Set}{xs : List A} -> All P xs -> Some Q xs -> A × (\x -> P x ∧ Q x) ε ! () (p ▹ ps) ! hd q = _ , (p , q) (p ▹ ps) ! tl q = ps ! q
{ "alphanum_fraction": 0.4074387151, "avg_line_length": 25.170212766, "ext": "agda", "hexsha": "3aa6380cd8a390598a25dc9c5463fd1c760b7438", "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": "examples/outdated-and-incorrect/tactics/bool/All.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": "examples/outdated-and-incorrect/tactics/bool/All.agda", "max_line_length": 66, "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": "examples/outdated-and-incorrect/tactics/bool/All.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": 501, "size": 1183 }
------------------------------------------------------------------------------ -- Properties related with the totality of the rose tree type ------------------------------------------------------------------------------ {-# OPTIONS --injective-type-constructors #-} {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Program.Mirror.Tree.TotalityNonTerminationI where open import Common.FOL.Relation.Binary.EqReasoning open import FOTC.Base open import FOTC.Base.List open import FOTC.Data.List open import FOTC.Program.Mirror.Mirror open import FOTC.Program.Mirror.Type open import FOTC.Program.Mirror.Forest.TotalityI open import FOTC.Program.Mirror.Forest.PropertiesI ------------------------------------------------------------------------------ -- Requires --injective-type-constructors -- Peter: To use injectivity of type constructors means asking for -- trouble. The logic behind this is very unclear. node-Forest : ∀ {d ts} → Tree (node d ts) → Forest ts node-Forest {d} (tree .d Fts) = Fts postulate reverse-∷' : ∀ x ys → reverse (x ∷ ys) ≡ reverse ys ++ (x ∷ []) -- The termination checker can not determine that the function mirror-Tree -- defined by -- -- mirror-Tree (tree d (fcons {t} {ts} Tt Fts)) = -- ... mirror-Tree (tree d Fts) ... mirror-Tree Tt ... -- -- is structurally recursive. -- Andreas Abel: The function does not terminate because we are using -- postulates (i.e. D, _∷_, etc). In particular, x is not structurally -- smaller than x ∷ xs. {-# TERMINATING #-} mirror-Tree : ∀ {t} → Tree t → Tree (mirror · t) mirror-Tree (tree d fnil) = subst Tree (sym (mirror-eq d [])) (tree d helper₂) where helper₁ : rev (map mirror []) [] ≡ [] helper₁ = rev (map mirror []) [] ≡⟨ subst (λ x → rev (map mirror []) [] ≡ rev x []) (map-[] mirror) refl ⟩ rev [] [] ≡⟨ rev-[] [] ⟩ [] ∎ helper₂ : Forest (rev (map mirror []) []) helper₂ = subst Forest (sym helper₁) fnil mirror-Tree (tree d (fcons {t} {ts} Tt Fts)) = subst Tree (sym (mirror-eq d (t ∷ ts))) (tree d helper) where h₁ : Tree (node d (reverse (map mirror ts))) h₁ = subst Tree (mirror-eq d ts) (mirror-Tree (tree d Fts)) h₂ : Forest (reverse (map mirror ts)) h₂ = node-Forest h₁ h₃ : Forest ((reverse (map mirror ts)) ++ (mirror · t ∷ [])) h₃ = ++-Forest h₂ (fcons (mirror-Tree Tt) fnil) h₄ : Forest (reverse (mirror · t ∷ map mirror ts)) h₄ = subst Forest (sym (reverse-∷' (mirror · t) (map mirror ts))) h₃ helper : Forest (reverse (map mirror (t ∷ ts))) helper = subst Forest (subst (λ x → reverse x ≡ reverse (map mirror (t ∷ ts))) (map-∷ mirror t ts) refl) h₄
{ "alphanum_fraction": 0.544500846, "avg_line_length": 34.3604651163, "ext": "agda", "hexsha": "0d9c7ff85e13e708ae5e8e13f07ea68c7fc70884", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Program/Mirror/Tree/TotalityNonTerminationI.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Program/Mirror/Tree/TotalityNonTerminationI.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Program/Mirror/Tree/TotalityNonTerminationI.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": 793, "size": 2955 }
module L.Base.Id where -- Reexport definitions open import L.Base.Id.Core public
{ "alphanum_fraction": 0.7804878049, "avg_line_length": 16.4, "ext": "agda", "hexsha": "fd4edc6d23465068a74363c2e97459f33d3fd630", "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": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "borszag/smallib", "max_forks_repo_path": "src/L/Base/Id.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_issues_repo_issues_event_max_datetime": "2020-11-09T16:40:39.000Z", "max_issues_repo_issues_event_min_datetime": "2020-10-19T10:13:16.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "borszag/smallib", "max_issues_repo_path": "src/L/Base/Id.agda", "max_line_length": 33, "max_stars_count": null, "max_stars_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "borszag/smallib", "max_stars_repo_path": "src/L/Base/Id.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 19, "size": 82 }
{-# OPTIONS --cubical #-} module Agda.Builtin.Cubical.Sub where open import Agda.Primitive.Cubical {-# BUILTIN SUB Sub #-} postulate inc : ∀ {ℓ} {A : Set ℓ} {φ} (x : A) → Sub A φ (λ _ → x) {-# BUILTIN SUBIN inc #-} primitive primSubOut : ∀ {ℓ} {A : Set ℓ} {φ : I} {u : Partial φ A} → Sub _ φ u → A
{ "alphanum_fraction": 0.5514018692, "avg_line_length": 21.4, "ext": "agda", "hexsha": "0efc88077473e2e573a86d9ded19a3b0b02297a0", "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": "f77b563d328513138d6c88bf0a3e350a9b91f8ed", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "bennn/agda", "max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/Cubical/Sub.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f77b563d328513138d6c88bf0a3e350a9b91f8ed", "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": "bennn/agda", "max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/Cubical/Sub.agda", "max_line_length": 76, "max_stars_count": null, "max_stars_repo_head_hexsha": "f77b563d328513138d6c88bf0a3e350a9b91f8ed", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "bennn/agda", "max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/Cubical/Sub.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 123, "size": 321 }
{-# OPTIONS --safe #-} module TEST where open import Data.Nat open import Data.Nat.Properties open import Relation.Binary.PropositionalEquality arith-sum : ℕ → ℕ arith-sum zero = zero arith-sum (suc n) = suc n + arith-sum n arith-formula : ℕ → ℕ arith-formula n = ⌊ n * (n + 1) /2⌋ silly : ∀ (n m : ℕ) → ⌊ n + n + m * (m + 1) /2⌋ ≡ n + ⌊ m * (m + 1) /2⌋ silly zero m = refl silly (suc n) m rewrite +-suc n n = cong suc (silly n m) lemma : ∀ (n : ℕ) → ⌊ suc n * (suc n + 1) /2⌋ ≡ suc n + ⌊ n * (n + 1) /2⌋ lemma n rewrite *-comm n (suc n + 1) | +-assoc n 1 (n + (n + 1) * n) | *-comm (n + 1) n | +-comm n (suc (n + n * (n + 1))) | +-assoc n (n * (n + 1)) n | +-comm (n * (n + 1)) n | sym (silly n n) | +-assoc n n (n * (n + 1)) = refl arith-eq : (n : ℕ) -> arith-formula n ≡ arith-sum n arith-eq zero = refl arith-eq (suc n) rewrite lemma n = cong (_+_ (suc n)) (arith-eq n)
{ "alphanum_fraction": 0.5135427952, "avg_line_length": 35.5, "ext": "agda", "hexsha": "401c682e94c65daf36f954dafcf585483ad3bb85", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Brethland/LEARNING-STUFF", "max_forks_repo_path": "Agda/TEST.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "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": "Brethland/LEARNING-STUFF", "max_issues_repo_path": "Agda/TEST.agda", "max_line_length": 142, "max_stars_count": 2, "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Brethland/LEARNING-STUFF", "max_stars_repo_path": "Agda/TEST.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z", "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z", "num_tokens": 397, "size": 923 }
{-# OPTIONS --safe --warning=error --without-K --guardedness #-} open import Setoids.Setoids open import Rings.Definition open import Rings.Orders.Partial.Definition open import Rings.Orders.Total.Definition open import Groups.Definition open import Groups.Lemmas open import Fields.Fields open import Sets.EquivalenceRelations open import Sequences open import Setoids.Orders.Partial.Definition open import Setoids.Orders.Total.Definition open import Functions.Definition open import LogicalFormulae open import Numbers.Naturals.Semiring open import Numbers.Naturals.Order open import Rings.Homomorphisms.Definition module Fields.CauchyCompletion.Ring {m n o : _} {A : Set m} {S : Setoid {m} {n} A} {_+_ : A → A → A} {_*_ : A → A → A} {_<_ : Rel {m} {o} A} {pOrder : SetoidPartialOrder S _<_} {R : Ring S _+_ _*_} {pRing : PartiallyOrderedRing R pOrder} (order : TotallyOrderedRing pRing) (F : Field R) where open Setoid S open SetoidTotalOrder (TotallyOrderedRing.total order) open SetoidPartialOrder pOrder open Equivalence eq open PartiallyOrderedRing pRing open Field F open Group (Ring.additiveGroup R) open import Rings.Orders.Total.Lemmas order open import Rings.Orders.Total.AbsoluteValue order open import Fields.CauchyCompletion.Definition order F open import Fields.CauchyCompletion.Multiplication order F open import Fields.CauchyCompletion.Addition order F open import Fields.CauchyCompletion.Setoid order F open import Fields.CauchyCompletion.Group order F private abstract c*Assoc : {a b c : CauchyCompletion} → Setoid._∼_ cauchyCompletionSetoid (a *C (b *C c)) ((a *C b) *C c) c*Assoc {a} {b} {c} ε 0<e = 0 , ans where ans : {m : ℕ} → 0 <N m → abs (index (CauchyCompletion.elts ((a *C (b *C c)) +C (-C ((a *C b) *C c)))) m) < ε ans {m} 0<m rewrite indexAndApply (CauchyCompletion.elts (a *C (b *C c))) (CauchyCompletion.elts (-C ((a *C b) *C c))) _+_ {m} | indexAndApply (CauchyCompletion.elts a) (apply _*_ (CauchyCompletion.elts b) (CauchyCompletion.elts c)) _*_ {m} | equalityCommutative (mapAndIndex (apply _*_ (apply _*_ (CauchyCompletion.elts a) (CauchyCompletion.elts b)) (CauchyCompletion.elts c)) inverse m) | indexAndApply (CauchyCompletion.elts b) (CauchyCompletion.elts c) _*_ {m} | indexAndApply (apply _*_ (CauchyCompletion.elts a) (CauchyCompletion.elts b)) (CauchyCompletion.elts c) _*_ {m} | indexAndApply (CauchyCompletion.elts a) (CauchyCompletion.elts b) _*_ {m} = <WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq (absWellDefined _ _ (transferToRight'' (Ring.additiveGroup R) (Ring.*Associative R))) (identityOfIndiscernablesRight _∼_ (Equivalence.reflexive eq) absZero))) (Equivalence.reflexive eq) 0<e c*Ident : {a : CauchyCompletion} → Setoid._∼_ cauchyCompletionSetoid (injection (Ring.1R R) *C a) a c*Ident {a} ε 0<e = 0 , ans where ans : {m : ℕ} → 0 <N m → abs (index (apply _+_ (CauchyCompletion.elts (injection (Ring.1R R) *C a)) (map inverse (CauchyCompletion.elts a))) m) < ε ans {m} 0<m rewrite indexAndApply (CauchyCompletion.elts (injection (Ring.1R R) *C a)) (map inverse (CauchyCompletion.elts a)) _+_ {m} | indexAndApply (constSequence (Ring.1R R)) (CauchyCompletion.elts a) _*_ {m} | equalityCommutative (mapAndIndex (CauchyCompletion.elts a) inverse m) | indexAndConst (Ring.1R R) m = <WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq (absWellDefined _ _ (transferToRight'' (Ring.additiveGroup R) (Ring.identIsIdent R))) (identityOfIndiscernablesRight _∼_ (Equivalence.reflexive eq) (absZero)))) (Equivalence.reflexive eq) 0<e *CDistribute : {a b c : CauchyCompletion} → Setoid._∼_ cauchyCompletionSetoid (a *C (b +C c)) ((a *C b) +C (a *C c)) *CDistribute {a} {b} {c} e 0<e = 0 , ans where ans : {m : ℕ} → 0 <N m → abs (index (apply _+_ (CauchyCompletion.elts (a *C (b +C c))) (map inverse (CauchyCompletion.elts ((a *C b) +C (a *C c))))) m) < e ans {m} N<m rewrite indexAndApply (CauchyCompletion.elts (a *C (b +C c))) (map inverse (CauchyCompletion.elts ((a *C b) +C (a *C c)))) _+_ {m} | indexAndApply (CauchyCompletion.elts a) (apply _+_ (CauchyCompletion.elts b) (CauchyCompletion.elts c)) _*_ {m} | equalityCommutative (mapAndIndex (apply _+_ (apply _*_ (CauchyCompletion.elts a) (CauchyCompletion.elts b)) (apply _*_ (CauchyCompletion.elts a) (CauchyCompletion.elts c))) inverse m) | indexAndApply (CauchyCompletion.elts b) (CauchyCompletion.elts c) _+_ {m} | indexAndApply (apply _*_ (CauchyCompletion.elts a) (CauchyCompletion.elts b)) (apply _*_ (CauchyCompletion.elts a) (CauchyCompletion.elts c)) _+_ {m} | indexAndApply (CauchyCompletion.elts a) (CauchyCompletion.elts b) _*_ {m} | indexAndApply (CauchyCompletion.elts a) (CauchyCompletion.elts c) _*_ {m} = <WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq (absWellDefined _ _ (transferToRight'' (Ring.additiveGroup R) (Ring.*DistributesOver+ R))) (absZeroIsZero))) (Equivalence.reflexive eq) 0<e CRing : Ring cauchyCompletionSetoid _+C_ _*C_ Ring.additiveGroup CRing = CGroup Ring.*WellDefined CRing {a} {b} {c} {d} r=t s=u = multiplicationWellDefined {a} {c} {b} {d} r=t s=u Ring.1R CRing = injection (Ring.1R R) Ring.groupIsAbelian CRing {a} {b} = +CCommutative a b Ring.*Associative CRing {a} {b} {c} = c*Assoc {a} {b} {c} Ring.*Commutative CRing {a} {b} = *CCommutative {a} {b} Ring.*DistributesOver+ CRing {a} {b} {c} = *CDistribute {a} {b} {c} Ring.identIsIdent CRing {a} = c*Ident {a} private injectionIsRingHom : (a b : A) → Setoid._∼_ cauchyCompletionSetoid (injection (a * b)) (injection a *C injection b) injectionIsRingHom a b ε 0<e = 0 , ans where ans : {m : ℕ} → 0 <N m → abs (index (apply _+_ (CauchyCompletion.elts (injection (a * b))) (map inverse (CauchyCompletion.elts (injection a *C injection b)))) m) < ε ans {m} 0<m rewrite indexAndApply (constSequence (a * b)) (map inverse (apply _*_ (constSequence a) (constSequence b))) _+_ {m} | indexAndConst (a * b) m | equalityCommutative (mapAndIndex (apply _*_ (constSequence a) (constSequence b)) inverse m) | indexAndApply (constSequence a) (constSequence b) _*_ {m} | indexAndConst a m | indexAndConst b m = <WellDefined (symmetric (transitive (absWellDefined _ _ invRight) absZeroIsZero)) reflexive 0<e CInjectionRingHom : RingHom R CRing injection RingHom.preserves1 CInjectionRingHom = Equivalence.reflexive (Setoid.eq cauchyCompletionSetoid) {injection (Ring.1R R)} RingHom.ringHom CInjectionRingHom {a} {b} = injectionIsRingHom a b RingHom.groupHom CInjectionRingHom = CInjectionGroupHom
{ "alphanum_fraction": 0.7223069881, "avg_line_length": 82.9620253165, "ext": "agda", "hexsha": "aa6208d5bf4995f3caf57229b1d29ab9db9b24c6", "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": "Fields/CauchyCompletion/Ring.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": "Fields/CauchyCompletion/Ring.agda", "max_line_length": 1038, "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": "Fields/CauchyCompletion/Ring.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": 2204, "size": 6554 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Rings.Definition open import Rings.IntegralDomains.Definition open import Setoids.Setoids open import Sets.EquivalenceRelations module Fields.FieldOfFractions.Multiplication {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} {_*_ : A → A → A} {R : Ring S _+_ _*_} (I : IntegralDomain R) where open import Fields.FieldOfFractions.Setoid I fieldOfFractionsTimes : fieldOfFractionsSet → fieldOfFractionsSet → fieldOfFractionsSet fieldOfFractionsTimes (record { num = a ; denom = b ; denomNonzero = b!=0 }) (record { num = c ; denom = d ; denomNonzero = d!=0 }) = record { num = a * c ; denom = b * d ; denomNonzero = ans } where open Setoid S open Ring R ans : ((b * d) ∼ Ring.0R R) → False ans pr with IntegralDomain.intDom I pr ans pr | f = exFalso (d!=0 (f b!=0)) fieldOfFractionsTimesWellDefined : {a b c d : fieldOfFractionsSet} → (Setoid._∼_ fieldOfFractionsSetoid a c) → (Setoid._∼_ fieldOfFractionsSetoid b d) → (Setoid._∼_ fieldOfFractionsSetoid (fieldOfFractionsTimes a b) (fieldOfFractionsTimes c d)) fieldOfFractionsTimesWellDefined {record { num = a ; denom = b }} {record { num = c ; denom = d }} {record { num = e ; denom = f }} {record { num = g ; denom = h }} af=be ch=dg = need where open Setoid S open Equivalence eq need : ((a * c) * (f * h)) ∼ ((b * d) * (e * g)) need = transitive (Ring.*WellDefined R reflexive (Ring.*Commutative R)) (transitive (Ring.*Associative R) (transitive (Ring.*WellDefined R (symmetric (Ring.*Associative R)) reflexive) (transitive (Ring.*WellDefined R (Ring.*WellDefined R reflexive ch=dg) reflexive) (transitive (Ring.*Commutative R) (transitive (Ring.*Associative R) (transitive (Ring.*WellDefined R (Ring.*Commutative R) reflexive) (transitive (Ring.*WellDefined R af=be reflexive) (transitive (Ring.*Associative R) (transitive (Ring.*WellDefined R (transitive (symmetric (Ring.*Associative R)) (transitive (Ring.*WellDefined R reflexive (Ring.*Commutative R)) (Ring.*Associative R))) reflexive) (symmetric (Ring.*Associative R)))))))))))
{ "alphanum_fraction": 0.6950420954, "avg_line_length": 71.2666666667, "ext": "agda", "hexsha": "4bf19d54c99babd440f83b3ac712f847c9096ccb", "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": "Fields/FieldOfFractions/Multiplication.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Fields/FieldOfFractions/Multiplication.agda", "max_line_length": 710, "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": "Fields/FieldOfFractions/Multiplication.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 676, "size": 2138 }
module Structure.Operator.Monoid.Category where open import Data open import Data.Tuple as Tuple using (_,_) open import Functional import Lvl open import Structure.Setoid open import Structure.Category open import Structure.Categorical.Properties open import Structure.Operator.Monoid open import Structure.Operator.Monoid.Homomorphism open import Structure.Operator.Properties using (associativity ; identityₗ ; identityᵣ) open import Structure.Operator open import Type private variable ℓ ℓₑ ℓₗ ℓₗₑ : Lvl.Level private variable T : Type{ℓ} private variable _▫_ : T → T → T module _ ⦃ equiv : Equiv{ℓₑ}(T) ⦄ ⦃ oper : BinaryOperator(_▫_) ⦄ (M : Monoid{T = T}(_▫_)) where -- A monoid as a special case of a category with a single object and morphisms in and out of this object. -- Composition and identity in the category is the binary operator and the identity element from the monoid. monoidCategory : Category{Obj = Unit{Lvl.𝟎}}(const(const(T))) Category._∘_ monoidCategory = (_▫_) Category.id monoidCategory = Monoid.id(M) Category.binaryOperator monoidCategory = oper Category.associativity monoidCategory = Morphism.intro(associativity(_▫_)) Category.identity monoidCategory = Morphism.intro (identityₗ(_▫_)(Monoid.id(M))) , Morphism.intro ((identityᵣ(_▫_)(Monoid.id(M)))) module _ where open import Function.Equals open import Function.Equals.Proofs open import Function.Proofs open import Logic.Predicate open import Logic.Propositional open import Structure.Function.Multi open import Structure.Function open import Structure.Relator.Equivalence open import Structure.Relator.Properties open import Syntax.Function open import Syntax.Transitivity private variable x y z : MonoidObject{ℓₗ}{ℓₗₑ} instance [→ᵐᵒⁿᵒⁱᵈ]-equiv : Equiv(x →ᵐᵒⁿᵒⁱᵈ y) Equiv._≡_ [→ᵐᵒⁿᵒⁱᵈ]-equiv ([∃]-intro F) ([∃]-intro G) = F ⊜ G Reflexivity.proof (Equivalence.reflexivity (Equiv.equivalence [→ᵐᵒⁿᵒⁱᵈ]-equiv)) = reflexivity(_⊜_) Symmetry.proof (Equivalence.symmetry (Equiv.equivalence [→ᵐᵒⁿᵒⁱᵈ]-equiv)) = symmetry(_⊜_) Transitivity.proof (Equivalence.transitivity (Equiv.equivalence [→ᵐᵒⁿᵒⁱᵈ]-equiv)) = transitivity(_⊜_) -- Identity monoid homomorphism. idᵐᵒⁿᵒⁱᵈ : x →ᵐᵒⁿᵒⁱᵈ x ∃.witness idᵐᵒⁿᵒⁱᵈ = id Homomorphism.function (∃.proof idᵐᵒⁿᵒⁱᵈ) = id-function Preserving.proof (Homomorphism.preserve-op (∃.proof idᵐᵒⁿᵒⁱᵈ)) = reflexivity(_≡_) Preserving.proof (Homomorphism.preserve-id (∃.proof idᵐᵒⁿᵒⁱᵈ)) = reflexivity(_≡_) -- Composition of monoid homomorphisms. _∘ᵐᵒⁿᵒⁱᵈ_ : let _ = x in (y →ᵐᵒⁿᵒⁱᵈ z) → (x →ᵐᵒⁿᵒⁱᵈ y) → (x →ᵐᵒⁿᵒⁱᵈ z) ∃.witness (([∃]-intro F) ∘ᵐᵒⁿᵒⁱᵈ ([∃]-intro G)) = F ∘ G Homomorphism.function (∃.proof (([∃]-intro F) ∘ᵐᵒⁿᵒⁱᵈ ([∃]-intro G))) = [∘]-function {f = F}{g = G} Preserving.proof (Homomorphism.preserve-op (∃.proof (_∘ᵐᵒⁿᵒⁱᵈ_ {x = A} {y = B} {z = C} ([∃]-intro F) ([∃]-intro G)))) {x} {y} = (F ∘ G)(x ⦗ MonoidObject._▫_ A ⦘ y) 🝖[ _≡_ ]-[] F(G(x ⦗ MonoidObject._▫_ A ⦘ y)) 🝖[ _≡_ ]-[ congruence₁(F) (preserving₂(G) (MonoidObject._▫_ A) (MonoidObject._▫_ B)) ] F(G(x) ⦗ MonoidObject._▫_ B ⦘ G(y)) 🝖[ _≡_ ]-[ preserving₂(F) (MonoidObject._▫_ B) (MonoidObject._▫_ C) ] F(G(x)) ⦗ MonoidObject._▫_ C ⦘ F(G(y)) 🝖[ _≡_ ]-[] (F ∘ G)(x) ⦗ MonoidObject._▫_ C ⦘ (F ∘ G)(y) 🝖-end Preserving.proof (Homomorphism.preserve-id (∃.proof (_∘ᵐᵒⁿᵒⁱᵈ_ {x = A} {y = B} {z = C} ([∃]-intro F) ([∃]-intro G)))) = (F ∘ G)(MonoidObject.id A) 🝖[ _≡_ ]-[] F(G(MonoidObject.id A)) 🝖[ _≡_ ]-[ congruence₁(F) (preserving₀(G) (MonoidObject.id A) (MonoidObject.id B)) ] F(MonoidObject.id B) 🝖[ _≡_ ]-[ preserving₀(F) (MonoidObject.id B) (MonoidObject.id C) ] MonoidObject.id C 🝖-end -- A category where the objects are monoids themselves and the morphisms are homomorphism between them. instance monoidObjectCategory : Category{Obj = MonoidObject{ℓₗ}{ℓₗₑ}}(_→ᵐᵒⁿᵒⁱᵈ_) Category._∘_ monoidObjectCategory = _∘ᵐᵒⁿᵒⁱᵈ_ Category.id monoidObjectCategory = idᵐᵒⁿᵒⁱᵈ Category.binaryOperator monoidObjectCategory = intro(\p q → [⊜][∘]-binaryOperator-raw p q) Category.associativity monoidObjectCategory = Morphism.intro (reflexivity(_⊜_)) Category.identity monoidObjectCategory = [∧]-intro (Morphism.intro(reflexivity(_⊜_))) (Morphism.intro(reflexivity(_⊜_))) monoidObjectCategoryObject : ∀{ℓₗ ℓₑ} → CategoryObject monoidObjectCategoryObject{ℓₗ}{ℓₑ} = intro(monoidObjectCategory{ℓₗ}{ℓₑ})
{ "alphanum_fraction": 0.6760992599, "avg_line_length": 50.4835164835, "ext": "agda", "hexsha": "65eed4dea7f018e5d23016a7bc171a128754ce29", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Operator/Monoid/Category.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Operator/Monoid/Category.agda", "max_line_length": 138, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Operator/Monoid/Category.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": 1871, "size": 4594 }
------------------------------------------------------------------------------ -- Totality properties respect to OrdList (flatten-OrdList-helper) ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- The termination checker can not determine that the function -- flatten-OrdList-helper is defined by structural recursion because -- we are using postulates. module FOT.FOTC.Program.SortList.Properties.Totality.OrdList.FlattenI where open import Common.FOL.Relation.Binary.EqReasoning open import FOTC.Base open import FOTC.Base.List open import FOTC.Data.Bool open import FOTC.Data.Bool.PropertiesI open import FOTC.Data.Nat.Inequalities open import FOTC.Data.Nat.Inequalities.PropertiesI open import FOTC.Data.Nat.Type open import FOTC.Data.List open import FOTC.Program.SortList.Properties.Totality.BoolI open import FOTC.Program.SortList.Properties.Totality.ListN-I open import FOTC.Program.SortList.Properties.Totality.OrdTreeI open import FOTC.Program.SortList.Properties.MiscellaneousI open import FOTC.Program.SortList.SortList ------------------------------------------------------------------------------ {-# TERMINATING #-} flatten-OrdList-helper : ∀ {t₁ i t₂} → Tree t₁ → N i → Tree t₂ → OrdTree (node t₁ i t₂) → ≤-Lists (flatten t₁) (flatten t₂) flatten-OrdList-helper {t₂ = t₂} tnil Ni Tt₂ OTt = subst (λ t → ≤-Lists t (flatten t₂)) (sym (flatten-nil)) (le-Lists-[] (flatten t₂)) flatten-OrdList-helper (ttip {i₁} Ni₁) _ tnil OTt = le-Lists (flatten (tip i₁)) (flatten nil) ≡⟨ subst₂ (λ x₁ x₂ → le-Lists (flatten (tip i₁)) (flatten nil) ≡ le-Lists x₁ x₂) (flatten-tip i₁) flatten-nil refl ⟩ le-Lists (i₁ ∷ []) [] ≡⟨ le-Lists-∷ i₁ [] [] ⟩ le-ItemList i₁ [] && le-Lists [] [] ≡⟨ subst₂ (λ x₁ x₂ → le-ItemList i₁ [] && le-Lists [] [] ≡ x₁ && x₂) (le-ItemList-[] i₁) (le-Lists-[] []) refl ⟩ true && true ≡⟨ t&&x≡x true ⟩ true ∎ flatten-OrdList-helper {i = i} (ttip {i₁} Ni₁) Ni (ttip {i₂} Ni₂) OTt = le-Lists (flatten (tip i₁)) (flatten (tip i₂)) ≡⟨ subst₂ (λ x₁ x₂ → le-Lists (flatten (tip i₁)) (flatten (tip i₂)) ≡ le-Lists x₁ x₂) (flatten-tip i₁) (flatten-tip i₂) refl ⟩ le-Lists (i₁ ∷ []) (i₂ ∷ []) ≡⟨ le-Lists-∷ i₁ [] (i₂ ∷ []) ⟩ le-ItemList i₁ (i₂ ∷ []) && le-Lists [] (i₂ ∷ []) ≡⟨ subst (λ t → le-ItemList i₁ (i₂ ∷ []) && le-Lists [] (i₂ ∷ []) ≡ t && le-Lists [] (i₂ ∷ [])) (le-ItemList-∷ i₁ i₂ []) refl ⟩ (le i₁ i₂ && le-ItemList i₁ []) && le-Lists [] (i₂ ∷ []) ≡⟨ subst (λ t → (le i₁ i₂ && le-ItemList i₁ []) && le-Lists [] (i₂ ∷ []) ≡ (t && le-ItemList i₁ []) && le-Lists [] (i₂ ∷ [])) lemma refl ⟩ (true && le-ItemList i₁ []) && le-Lists [] (i₂ ∷ []) ≡⟨ subst₂ (λ x₁ x₂ → (true && le-ItemList i₁ []) && le-Lists [] (i₂ ∷ []) ≡ (true && x₁) && x₂) (le-ItemList-[] i₁) (le-Lists-[] (i₂ ∷ [])) refl ⟩ (true && true) && true ≡⟨ &&-assoc btrue btrue btrue ⟩ true && true && true ≡⟨ &&-list₃-all-t btrue btrue btrue (refl , refl , refl) ⟩ true ∎ where helper₁ : Bool (ordTree (tip i₁)) helper₁ = ordTree-Bool (ttip Ni₁) helper₂ : Bool (ordTree (tip i₂)) helper₂ = ordTree-Bool (ttip Ni₂) helper₃ : Bool (le-TreeItem (tip i₁) i) helper₃ = le-TreeItem-Bool (ttip Ni₁) Ni helper₄ : Bool (le-ItemTree i (tip i₂)) helper₄ = le-ItemTree-Bool Ni (ttip Ni₂) helper₅ : ordTree (tip i₁) && ordTree (tip i₂) && le-TreeItem (tip i₁) i && le-ItemTree i (tip i₂) ≡ true helper₅ = trans (sym (ordTree-node (tip i₁) i (tip i₂))) OTt lemma : i₁ ≤ i₂ lemma = ≤-trans Ni₁ Ni Ni₂ i₁≤i i≤i₂ where i₁≤i : i₁ ≤ i i₁≤i = trans (sym (le-TreeItem-tip i₁ i)) (&&-list₄-t₃ helper₁ helper₂ helper₃ helper₄ helper₅) i≤i₂ : i ≤ i₂ i≤i₂ = trans (sym (le-ItemTree-tip i i₂)) (&&-list₄-t₄ helper₁ helper₂ helper₃ helper₄ helper₅) flatten-OrdList-helper {i = i} (ttip {i₁} Ni₁) Ni (tnode {t₂₁} {i₂} {t₂₂} Tt₂₁ Ni₂ Tt₂₂) OTt = le-Lists (flatten (tip i₁)) (flatten (node t₂₁ i₂ t₂₂)) ≡⟨ subst (λ x → le-Lists (flatten (tip i₁)) (flatten (node t₂₁ i₂ t₂₂)) ≡ le-Lists (flatten (tip i₁)) x) (flatten-node t₂₁ i₂ t₂₂) refl ⟩ le-Lists (flatten (tip i₁)) (flatten t₂₁ ++ flatten t₂₂) ≡⟨ xs≤ys→xs≤zs→xs≤ys++zs (flatten-ListN (ttip Ni₁)) (flatten-ListN Tt₂₁) (flatten-ListN Tt₂₂) lemma₁ lemma₂ ⟩ true ∎ where -- Helper terms to get the conjuncts from OTt. helper₁ = ordTree-Bool (ttip Ni₁) helper₂ = ordTree-Bool (tnode Tt₂₁ Ni₂ Tt₂₂) helper₃ = le-TreeItem-Bool (ttip Ni₁) Ni helper₄ = le-ItemTree-Bool Ni (tnode Tt₂₁ Ni₂ Tt₂₂) helper₅ = trans (sym (ordTree-node (tip i₁) i (node t₂₁ i₂ t₂₂))) OTt -- Helper terms to get the conjuncts from the fourth conjunct of OTt. helper₆ = le-ItemTree-Bool Ni Tt₂₁ helper₇ = le-ItemTree-Bool Ni Tt₂₂ helper₈ = trans (sym (le-ItemTree-node i t₂₁ i₂ t₂₂)) (&&-list₄-t₄ helper₁ helper₂ helper₃ helper₄ helper₅) -- Common terms for the lemma₁ and lemma₂. OrdTree-tip-i₁ : OrdTree (tip i₁) OrdTree-tip-i₁ = &&-list₄-t₁ helper₁ helper₂ helper₃ helper₄ helper₅ ≤-TreeItem-tip-i₁-i : ≤-TreeItem (tip i₁) i ≤-TreeItem-tip-i₁-i = &&-list₄-t₃ helper₁ helper₂ helper₃ helper₄ helper₅ lemma₁ : ≤-Lists (flatten (tip i₁)) (flatten t₂₁) lemma₁ = flatten-OrdList-helper (ttip Ni₁) Ni Tt₂₁ OT where OrdTree-t₂₁ : OrdTree t₂₁ OrdTree-t₂₁ = leftSubTree-OrdTree Tt₂₁ Ni₂ Tt₂₂ (&&-list₄-t₂ helper₁ helper₂ helper₃ helper₄ helper₅) ≤-ItemTree-i-t₂₁ : ≤-ItemTree i t₂₁ ≤-ItemTree-i-t₂₁ = &&-list₂-t₁ helper₆ helper₇ helper₈ OT : OrdTree (node (tip i₁) i t₂₁) OT = ordTree (node (tip i₁) i t₂₁) ≡⟨ ordTree-node (tip i₁) i t₂₁ ⟩ ordTree (tip i₁) && ordTree t₂₁ && le-TreeItem (tip i₁) i && le-ItemTree i t₂₁ ≡⟨ subst₄ (λ w x y z → ordTree (tip i₁) && ordTree t₂₁ && le-TreeItem (tip i₁) i && le-ItemTree i t₂₁ ≡ w && x && y && z) OrdTree-tip-i₁ OrdTree-t₂₁ ≤-TreeItem-tip-i₁-i ≤-ItemTree-i-t₂₁ refl ⟩ true && true && true && true ≡⟨ &&-list₄-all-t btrue btrue btrue btrue (refl , refl , refl , refl) ⟩ true ∎ lemma₂ : ≤-Lists (flatten (tip i₁)) (flatten t₂₂) lemma₂ = flatten-OrdList-helper (ttip Ni₁) Ni Tt₂₂ OT where OrdTree-t₂₂ : OrdTree t₂₂ OrdTree-t₂₂ = rightSubTree-OrdTree Tt₂₁ Ni₂ Tt₂₂ (&&-list₄-t₂ helper₁ helper₂ helper₃ helper₄ helper₅) ≤-ItemTree-i-t₂₂ : ≤-ItemTree i t₂₂ ≤-ItemTree-i-t₂₂ = &&-list₂-t₂ helper₆ helper₇ helper₈ OT : OrdTree (node (tip i₁) i t₂₂) OT = ordTree (node (tip i₁) i t₂₂) ≡⟨ ordTree-node (tip i₁) i t₂₂ ⟩ ordTree (tip i₁) && ordTree t₂₂ && le-TreeItem (tip i₁) i && le-ItemTree i t₂₂ ≡⟨ subst₄ (λ w x y z → ordTree (tip i₁) && ordTree t₂₂ && le-TreeItem (tip i₁) i && le-ItemTree i t₂₂ ≡ w && x && y && z) OrdTree-tip-i₁ OrdTree-t₂₂ ≤-TreeItem-tip-i₁-i ≤-ItemTree-i-t₂₂ refl ⟩ true && true && true && true ≡⟨ &&-list₄-all-t btrue btrue btrue btrue (refl , refl , refl , refl) ⟩ true ∎ flatten-OrdList-helper {i = i} (tnode {t₁₁} {i₁} {t₁₂} Tt₁₁ Ni₁ Tt₁₂) Ni tnil OTt = le-Lists (flatten (node t₁₁ i₁ t₁₂)) (flatten nil) ≡⟨ subst (λ x → le-Lists (flatten (node t₁₁ i₁ t₁₂)) (flatten nil) ≡ le-Lists x (flatten nil)) (flatten-node t₁₁ i₁ t₁₂) refl ⟩ le-Lists (flatten t₁₁ ++ flatten t₁₂) (flatten nil) ≡⟨ xs≤zs→ys≤zs→xs++ys≤zs (flatten-ListN Tt₁₁) (flatten-ListN Tt₁₂) (flatten-ListN tnil) lemma₁ lemma₂ ⟩ true ∎ where -- Helper terms to get the conjuncts from OTt. helper₁ = ordTree-Bool (tnode Tt₁₁ Ni₁ Tt₁₂) helper₂ = ordTree-Bool tnil helper₃ = le-TreeItem-Bool (tnode Tt₁₁ Ni₁ Tt₁₂) Ni helper₄ = le-ItemTree-Bool Ni tnil helper₅ = trans (sym (ordTree-node (node t₁₁ i₁ t₁₂) i nil)) OTt -- Helper terms to get the conjuncts from the third conjunct of OTt. helper₆ = le-TreeItem-Bool Tt₁₁ Ni helper₇ = le-TreeItem-Bool Tt₁₂ Ni helper₈ = trans (sym (le-TreeItem-node t₁₁ i₁ t₁₂ i)) (&&-list₄-t₃ helper₁ helper₂ helper₃ helper₄ helper₅) -- Common terms for the lemma₁ and lemma₂. ≤-ItemTree-i-niltree : ≤-ItemTree i nil ≤-ItemTree-i-niltree = &&-list₄-t₄ helper₁ helper₂ helper₃ helper₄ helper₅ lemma₁ : ≤-Lists (flatten t₁₁) (flatten nil) lemma₁ = flatten-OrdList-helper Tt₁₁ Ni tnil OT where OrdTree-t₁₁ : OrdTree t₁₁ OrdTree-t₁₁ = leftSubTree-OrdTree Tt₁₁ Ni₁ Tt₁₂ (&&-list₄-t₁ helper₁ helper₂ helper₃ helper₄ helper₅) ≤-TreeItem-t₁₁-i : ≤-TreeItem t₁₁ i ≤-TreeItem-t₁₁-i = &&-list₂-t₁ helper₆ helper₇ helper₈ OT : OrdTree (node t₁₁ i nil) OT = ordTree (node t₁₁ i nil) ≡⟨ ordTree-node t₁₁ i nil ⟩ ordTree t₁₁ && ordTree nil && le-TreeItem t₁₁ i && le-ItemTree i nil ≡⟨ subst₄ (λ w x y z → ordTree t₁₁ && ordTree nil && le-TreeItem t₁₁ i && le-ItemTree i nil ≡ w && x && y && z) OrdTree-t₁₁ ordTree-nil ≤-TreeItem-t₁₁-i ≤-ItemTree-i-niltree refl ⟩ true && true && true && true ≡⟨ &&-list₄-all-t btrue btrue btrue btrue (refl , refl , refl , refl) ⟩ true ∎ lemma₂ : ≤-Lists (flatten t₁₂) (flatten nil) lemma₂ = flatten-OrdList-helper Tt₁₂ Ni tnil OT where OrdTree-t₁₂ : OrdTree t₁₂ OrdTree-t₁₂ = rightSubTree-OrdTree Tt₁₁ Ni₁ Tt₁₂ (&&-list₄-t₁ helper₁ helper₂ helper₃ helper₄ helper₅) ≤-TreeItem-t₁₂-i : ≤-TreeItem t₁₂ i ≤-TreeItem-t₁₂-i = &&-list₂-t₂ helper₆ helper₇ helper₈ OT : OrdTree (node t₁₂ i nil) OT = ordTree (node t₁₂ i nil) ≡⟨ ordTree-node t₁₂ i nil ⟩ ordTree t₁₂ && ordTree nil && le-TreeItem t₁₂ i && le-ItemTree i nil ≡⟨ subst₄ (λ w x y z → ordTree t₁₂ && ordTree nil && le-TreeItem t₁₂ i && le-ItemTree i nil ≡ w && x && y && z) OrdTree-t₁₂ ordTree-nil ≤-TreeItem-t₁₂-i ≤-ItemTree-i-niltree refl ⟩ true && true && true && true ≡⟨ &&-list₄-all-t btrue btrue btrue btrue (refl , refl , refl , refl) ⟩ true ∎ flatten-OrdList-helper {i = i} (tnode {t₁₁} {i₁} {t₁₂} Tt₁₁ Ni₁ Tt₁₂) Ni (ttip {i₂} Ni₂) OTt = le-Lists (flatten (node t₁₁ i₁ t₁₂)) (flatten (tip i₂)) ≡⟨ subst (λ x → le-Lists (flatten (node t₁₁ i₁ t₁₂)) (flatten (tip i₂)) ≡ le-Lists x (flatten (tip i₂))) (flatten-node t₁₁ i₁ t₁₂) refl ⟩ le-Lists (flatten t₁₁ ++ flatten t₁₂) (flatten (tip i₂)) ≡⟨ xs≤zs→ys≤zs→xs++ys≤zs (flatten-ListN Tt₁₁) (flatten-ListN Tt₁₂) (flatten-ListN (ttip Ni₂)) lemma₁ lemma₂ ⟩ true ∎ where -- Helper terms to get the conjuncts from OTt. helper₁ = ordTree-Bool (tnode Tt₁₁ Ni₁ Tt₁₂) helper₂ = ordTree-Bool (ttip Ni₂) helper₃ = le-TreeItem-Bool (tnode Tt₁₁ Ni₁ Tt₁₂) Ni helper₄ = le-ItemTree-Bool Ni (ttip Ni₂) helper₅ = trans (sym (ordTree-node (node t₁₁ i₁ t₁₂) i (tip i₂))) OTt -- Helper terms to get the conjuncts from the third conjunct of OTt. helper₆ = le-TreeItem-Bool Tt₁₁ Ni helper₇ = le-TreeItem-Bool Tt₁₂ Ni helper₈ = trans (sym (le-TreeItem-node t₁₁ i₁ t₁₂ i)) (&&-list₄-t₃ helper₁ helper₂ helper₃ helper₄ helper₅) -- Common terms for the lemma₁ and lemma₂. OrdTree-tip-i₂ : OrdTree (tip i₂) OrdTree-tip-i₂ = &&-list₄-t₂ helper₁ helper₂ helper₃ helper₄ helper₅ ≤-ItemTree-i-tip-i₂ : ≤-ItemTree i (tip i₂) ≤-ItemTree-i-tip-i₂ = &&-list₄-t₄ helper₁ helper₂ helper₃ helper₄ helper₅ lemma₁ : ≤-Lists (flatten t₁₁) (flatten (tip i₂)) lemma₁ = flatten-OrdList-helper Tt₁₁ Ni (ttip Ni₂) OT where OrdTree-t₁₁ : OrdTree t₁₁ OrdTree-t₁₁ = leftSubTree-OrdTree Tt₁₁ Ni₁ Tt₁₂ (&&-list₄-t₁ helper₁ helper₂ helper₃ helper₄ helper₅) ≤-TreeItem-t₁₁-i : ≤-TreeItem t₁₁ i ≤-TreeItem-t₁₁-i = &&-list₂-t₁ helper₆ helper₇ helper₈ OT : OrdTree (node t₁₁ i (tip i₂)) OT = ordTree (node t₁₁ i (tip i₂)) ≡⟨ ordTree-node t₁₁ i (tip i₂) ⟩ ordTree t₁₁ && ordTree (tip i₂) && le-TreeItem t₁₁ i && le-ItemTree i (tip i₂) ≡⟨ subst₄ (λ w x y z → ordTree t₁₁ && ordTree (tip i₂) && le-TreeItem t₁₁ i && le-ItemTree i (tip i₂) ≡ w && x && y && z) OrdTree-t₁₁ OrdTree-tip-i₂ ≤-TreeItem-t₁₁-i ≤-ItemTree-i-tip-i₂ refl ⟩ true && true && true && true ≡⟨ &&-list₄-all-t btrue btrue btrue btrue (refl , refl , refl , refl) ⟩ true ∎ lemma₂ : ≤-Lists (flatten t₁₂) (flatten (tip i₂)) lemma₂ = flatten-OrdList-helper Tt₁₂ Ni (ttip Ni₂) OT where OrdTree-t₁₂ : OrdTree t₁₂ OrdTree-t₁₂ = rightSubTree-OrdTree Tt₁₁ Ni₁ Tt₁₂ (&&-list₄-t₁ helper₁ helper₂ helper₃ helper₄ helper₅) ≤-TreeItem-t₁₂-i : ≤-TreeItem t₁₂ i ≤-TreeItem-t₁₂-i = &&-list₂-t₂ helper₆ helper₇ helper₈ OT : OrdTree (node t₁₂ i (tip i₂)) OT = ordTree (node t₁₂ i (tip i₂)) ≡⟨ ordTree-node t₁₂ i (tip i₂) ⟩ ordTree t₁₂ && ordTree (tip i₂) && le-TreeItem t₁₂ i && le-ItemTree i (tip i₂) ≡⟨ subst₄ (λ w x y z → ordTree t₁₂ && ordTree (tip i₂) && le-TreeItem t₁₂ i && le-ItemTree i (tip i₂) ≡ w && x && y && z) OrdTree-t₁₂ OrdTree-tip-i₂ ≤-TreeItem-t₁₂-i ≤-ItemTree-i-tip-i₂ refl ⟩ true && true && true && true ≡⟨ &&-list₄-all-t btrue btrue btrue btrue (refl , refl , refl , refl) ⟩ true ∎ flatten-OrdList-helper {i = i} (tnode {t₁₁} {i₁} {t₁₂} Tt₁₁ Ni₁ Tt₁₂) Ni (tnode {t₂₁} {i₂} {t₂₂} Tt₂₁ Ni₂ Tt₂₂) OTt = le-Lists (flatten (node t₁₁ i₁ t₁₂)) (flatten (node t₂₁ i₂ t₂₂)) ≡⟨ subst (λ x → le-Lists (flatten (node t₁₁ i₁ t₁₂)) (flatten (node t₂₁ i₂ t₂₂)) ≡ le-Lists x (flatten (node t₂₁ i₂ t₂₂))) (flatten-node t₁₁ i₁ t₁₂) refl ⟩ le-Lists (flatten t₁₁ ++ flatten t₁₂) (flatten (node t₂₁ i₂ t₂₂)) ≡⟨ xs≤zs→ys≤zs→xs++ys≤zs (flatten-ListN Tt₁₁) (flatten-ListN Tt₁₂) (flatten-ListN (tnode Tt₂₁ Ni₂ Tt₂₂)) lemma₁ lemma₂ ⟩ true ∎ where -- Helper terms to get the conjuncts from OTt. helper₁ = ordTree-Bool (tnode Tt₁₁ Ni₁ Tt₁₂) helper₂ = ordTree-Bool (tnode Tt₂₁ Ni₂ Tt₂₂) helper₃ = le-TreeItem-Bool (tnode Tt₁₁ Ni₁ Tt₁₂) Ni helper₄ = le-ItemTree-Bool Ni (tnode Tt₂₁ Ni₂ Tt₂₂) helper₅ = trans (sym (ordTree-node (node t₁₁ i₁ t₁₂) i (node t₂₁ i₂ t₂₂))) OTt -- Helper terms to get the conjuncts from the third conjunct of OTt. helper₆ = le-TreeItem-Bool Tt₁₁ Ni helper₇ = le-TreeItem-Bool Tt₁₂ Ni helper₈ = trans (sym (le-TreeItem-node t₁₁ i₁ t₁₂ i)) (&&-list₄-t₃ helper₁ helper₂ helper₃ helper₄ helper₅) -- Common terms for the lemma₁ and lemma₂. OrdTree-node-t₂₁-i₂-t₂₂ : OrdTree (node t₂₁ i₂ t₂₂) OrdTree-node-t₂₁-i₂-t₂₂ = &&-list₄-t₂ helper₁ helper₂ helper₃ helper₄ helper₅ ≤-ItemTree-i-node-t₂₁-i₂-t₂₂ : ≤-ItemTree i (node t₂₁ i₂ t₂₂) ≤-ItemTree-i-node-t₂₁-i₂-t₂₂ = &&-list₄-t₄ helper₁ helper₂ helper₃ helper₄ helper₅ lemma₁ : ≤-Lists (flatten t₁₁) (flatten (node t₂₁ i₂ t₂₂)) lemma₁ = flatten-OrdList-helper Tt₁₁ Ni (tnode Tt₂₁ Ni₂ Tt₂₂) OT where OrdTree-t₁₁ : OrdTree t₁₁ OrdTree-t₁₁ = leftSubTree-OrdTree Tt₁₁ Ni₁ Tt₁₂ (&&-list₄-t₁ helper₁ helper₂ helper₃ helper₄ helper₅) ≤-TreeItem-t₁₁-i : ≤-TreeItem t₁₁ i ≤-TreeItem-t₁₁-i = &&-list₂-t₁ helper₆ helper₇ helper₈ OT : OrdTree (node t₁₁ i (node t₂₁ i₂ t₂₂)) OT = ordTree (node t₁₁ i (node t₂₁ i₂ t₂₂)) ≡⟨ ordTree-node t₁₁ i (node t₂₁ i₂ t₂₂) ⟩ ordTree t₁₁ && ordTree (node t₂₁ i₂ t₂₂) && le-TreeItem t₁₁ i && le-ItemTree i (node t₂₁ i₂ t₂₂) ≡⟨ subst₄ (λ w x y z → ordTree t₁₁ && ordTree (node t₂₁ i₂ t₂₂) && le-TreeItem t₁₁ i && le-ItemTree i (node t₂₁ i₂ t₂₂) ≡ w && x && y && z) OrdTree-t₁₁ OrdTree-node-t₂₁-i₂-t₂₂ ≤-TreeItem-t₁₁-i ≤-ItemTree-i-node-t₂₁-i₂-t₂₂ refl ⟩ true && true && true && true ≡⟨ &&-list₄-all-t btrue btrue btrue btrue (refl , refl , refl , refl) ⟩ true ∎ lemma₂ : ≤-Lists (flatten t₁₂) (flatten (node t₂₁ i₂ t₂₂)) lemma₂ = flatten-OrdList-helper Tt₁₂ Ni (tnode Tt₂₁ Ni₂ Tt₂₂) OT where OrdTree-t₁₂ : OrdTree t₁₂ OrdTree-t₁₂ = rightSubTree-OrdTree Tt₁₁ Ni₁ Tt₁₂ (&&-list₄-t₁ helper₁ helper₂ helper₃ helper₄ helper₅) ≤-TreeItem-t₁₂-i : ≤-TreeItem t₁₂ i ≤-TreeItem-t₁₂-i = &&-list₂-t₂ helper₆ helper₇ helper₈ OT : OrdTree (node t₁₂ i (node t₂₁ i₂ t₂₂)) OT = ordTree (node t₁₂ i (node t₂₁ i₂ t₂₂)) ≡⟨ ordTree-node t₁₂ i (node t₂₁ i₂ t₂₂) ⟩ ordTree t₁₂ && ordTree (node t₂₁ i₂ t₂₂) && le-TreeItem t₁₂ i && le-ItemTree i (node t₂₁ i₂ t₂₂) ≡⟨ subst₄ (λ w x y z → ordTree t₁₂ && ordTree (node t₂₁ i₂ t₂₂) && le-TreeItem t₁₂ i && le-ItemTree i (node t₂₁ i₂ t₂₂) ≡ w && x && y && z) OrdTree-t₁₂ OrdTree-node-t₂₁-i₂-t₂₂ ≤-TreeItem-t₁₂-i ≤-ItemTree-i-node-t₂₁-i₂-t₂₂ refl ⟩ true && true && true && true ≡⟨ &&-list₄-all-t btrue btrue btrue btrue (refl , refl , refl , refl) ⟩ true ∎
{ "alphanum_fraction": 0.4770999359, "avg_line_length": 40.5083487941, "ext": "agda", "hexsha": "6bcb783077bad804a3a2ba8e3afe1102156dbf46", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Program/SortList/Properties/Totality/OrdList/FlattenI.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Program/SortList/Properties/Totality/OrdList/FlattenI.agda", "max_line_length": 86, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Program/SortList/Properties/Totality/OrdList/FlattenI.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": 7005, "size": 21834 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Conversion from naturals to universe levels ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Level.Literals where open import Agda.Builtin.Nat renaming (Nat to ℕ) open import Agda.Builtin.FromNat open import Agda.Builtin.Unit open import Level using (Level; 0ℓ) -- Increase a Level by a number of sucs. _ℕ+_ : ℕ → Level → Level zero ℕ+ ℓ = ℓ suc n ℕ+ ℓ = Level.suc (n ℕ+ ℓ) -- Nat-computed Level. infix 10 #_ #_ : ℕ → Level #_ = _ℕ+ 0ℓ -- Literal overloading for levels. Levelℕ : Number Level Levelℕ .Number.Constraint _ = ⊤ Levelℕ .Number.fromNat n = # n
{ "alphanum_fraction": 0.5537634409, "avg_line_length": 21.8823529412, "ext": "agda", "hexsha": "663d62e534f55cbac5d4c6eb8d61da9c1a37b4be", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Level/Literals.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Level/Literals.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Level/Literals.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": 197, "size": 744 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties satisfied by posets ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Relation.Binary.Properties.Poset {p₁ p₂ p₃} (P : Poset p₁ p₂ p₃) where open Poset P renaming (Carrier to A) open import Function using (flip) import Relation.Binary.Construct.NonStrictToStrict _≈_ _≤_ as ToStrict import Relation.Binary.Properties.Preorder preorder as PreorderProperties open import Relation.Nullary using (¬_) private _≉_ : Rel A p₂ x ≉ y = ¬ (x ≈ y) ------------------------------------------------------------------------ -- The _≥_ relation is also a poset. infix 4 _≥_ _≥_ : Rel A p₃ x ≥ y = y ≤ x open PreorderProperties public using () renaming ( invIsPreorder to ≥-isPreorder ; invPreorder to ≥-preorder ) ≥-isPartialOrder : IsPartialOrder _≈_ _≥_ ≥-isPartialOrder = record { isPreorder = PreorderProperties.invIsPreorder ; antisym = flip antisym } ≥-poset : Poset p₁ p₂ p₃ ≥-poset = record { isPartialOrder = ≥-isPartialOrder } open Poset ≥-poset public using () renaming ( refl to ≥-refl ; reflexive to ≥-reflexive ; trans to ≥-trans ; antisym to ≥-antisym ) ------------------------------------------------------------------------ -- Partial orders can be turned into strict partial orders infix 4 _<_ _<_ : Rel A _ _<_ = ToStrict._<_ <-isStrictPartialOrder : IsStrictPartialOrder _≈_ _<_ <-isStrictPartialOrder = ToStrict.<-isStrictPartialOrder isPartialOrder <-strictPartialOrder : StrictPartialOrder _ _ _ <-strictPartialOrder = record { isStrictPartialOrder = <-isStrictPartialOrder } open StrictPartialOrder <-strictPartialOrder public using ( <-resp-≈; <-respʳ-≈; <-respˡ-≈) renaming ( irrefl to <-irrefl ; asym to <-asym ; trans to <-trans ) <⇒≉ : ∀ {x y} → x < y → x ≉ y <⇒≉ = ToStrict.<⇒≉ ≤∧≉⇒< : ∀ {x y} → x ≤ y → x ≉ y → x < y ≤∧≉⇒< = ToStrict.≤∧≉⇒< <⇒≱ : ∀ {x y} → x < y → ¬ (y ≤ x) <⇒≱ = ToStrict.<⇒≱ antisym ≤⇒≯ : ∀ {x y} → x ≤ y → ¬ (y < x) ≤⇒≯ = ToStrict.≤⇒≯ antisym ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 1.2 invIsPartialOrder = ≥-isPartialOrder {-# WARNING_ON_USAGE invIsPartialOrder "Warning: invIsPartialOrder was deprecated in v1.2. Please use ≥-isPartialOrder instead." #-} invPoset = ≥-poset {-# WARNING_ON_USAGE invPoset "Warning: invPoset was deprecated in v1.2. Please use ≥-poset instead." #-} strictPartialOrder = <-strictPartialOrder {-# WARNING_ON_USAGE strictPartialOrder "Warning: strictPartialOrder was deprecated in v1.2. Please use <-strictPartialOrder instead." #-}
{ "alphanum_fraction": 0.5766621438, "avg_line_length": 24.1639344262, "ext": "agda", "hexsha": "9383902ed2c0b58b3d68bad820e6c6bbf3aaee77", "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/Relation/Binary/Properties/Poset.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/Relation/Binary/Properties/Poset.agda", "max_line_length": 73, "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/Relation/Binary/Properties/Poset.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": 896, "size": 2948 }
{-# OPTIONS --cubical --safe #-} module Cubical.Structures.Poset where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Logic open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv hiding (_■) open import Cubical.Foundations.SIP renaming (SNS-≡ to SNS) open import Cubical.Core.Primitives open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.Data.Sigma.Properties -- We will adopt the convention of denoting the level of the carrier -- set by ℓ₀ and the level of the relation result by ℓ₁. private variable ℓ₀ ℓ₁ : Level Order : (ℓ₁ : Level) → Type ℓ₀ → Type (ℓ-max ℓ₀ (ℓ-suc ℓ₁)) Order ℓ₁ A = A → A → hProp ℓ₁ order-iso : (M N : Σ (Type ℓ₀) (Order ℓ₁)) → fst M ≃ fst N → Type (ℓ-max ℓ₀ ℓ₁) order-iso (A , _⊑₀_) (B , _⊑₁_) (f , _) = (x y : A) → [ x ⊑₀ y ⇔ f x ⊑₁ f y ] isSetOrder : (ℓ₁ : Level) (A : Type ℓ₀) → isSet (Order ℓ₁ A) isSetOrder ℓ₁ A = isSetΠ2 λ _ _ → isSetHProp Order-is-SNS : SNS {ℓ₀} (Order ℓ₁) order-iso Order-is-SNS {ℓ₁ = ℓ₁} {X = X} _⊑₀_ _⊑₁_ = f , f-equiv where f : order-iso (X , _⊑₀_) (X , _⊑₁_) (idEquiv X) → _⊑₀_ ≡ _⊑₁_ f i = funExt λ x → funExt λ y → ⇔toPath (fst (i x y)) (snd (i x y)) ⇔-prop : isProp ((x y : X) → [ x ⊑₀ y ⇔ x ⊑₁ y ]) ⇔-prop = isPropΠ2 λ x y → snd (x ⊑₀ y ⇔ x ⊑₁ y) f-equiv : isEquiv f f-equiv = record { equiv-proof = λ eq → (g eq , sec eq) , h eq } where g : (eq : _⊑₀_ ≡ _⊑₁_) → (x y : X) → ([ x ⊑₀ y ] → [ x ⊑₁ y ]) × ([ x ⊑₁ y ] → [ x ⊑₀ y ]) g eq x y = subst (λ { _⊑⋆_ → [ x ⊑⋆ y ] }) eq , subst (λ { _⊑⋆_ → [ x ⊑⋆ y ] }) (sym eq) sec : section f g sec p = isSetOrder _ X _⊑₀_ _⊑₁_ (f (g p)) p h : (p : _⊑₀_ ≡ _⊑₁_) → (fib : fiber f p) → (g p , sec p) ≡ fib h p (i , _) = ΣProp≡ A-prop B-prop where A-prop = λ i′ → isOfHLevelSuc 2 (isSetOrder ℓ₁ X) _⊑₀_ _⊑₁_ (f i′) p B-prop = ⇔-prop (g p) i -- We now write down the axioms for a partial order. isReflexive : {A : Type ℓ₀} → Order ℓ₁ A → hProp (ℓ-max ℓ₀ ℓ₁) isReflexive {A = X} _⊑_ = ((x : X) → [ x ⊑ x ]) , isPropΠ λ x → snd (x ⊑ x) isTransitive : {A : Type ℓ₀} → Order ℓ₁ A → hProp (ℓ-max ℓ₀ ℓ₁) isTransitive {ℓ₀ = ℓ₀} {ℓ₁ = ℓ₁} {A = X} _⊑_ = φ , φ-prop where φ : Type (ℓ-max ℓ₀ ℓ₁) φ = ((x y z : X) → [ x ⊑ y ⇒ y ⊑ z ⇒ x ⊑ z ]) φ-prop : isProp φ φ-prop = isPropΠ3 λ x y z → snd (x ⊑ y ⇒ y ⊑ z ⇒ x ⊑ z) isAntisym : {A : Type ℓ₀} → isSet A → Order ℓ₁ A → hProp (ℓ-max ℓ₀ ℓ₁) isAntisym {ℓ₀ = ℓ₀} {ℓ₁ = ℓ₁} {A = X} A-set _⊑_ = φ , φ-prop where φ : Type (ℓ-max ℓ₀ ℓ₁) φ = ((x y : X) → [ x ⊑ y ] → [ y ⊑ x ] → x ≡ y) φ-prop : isProp φ φ-prop = isPropΠ3 λ x y z → isPropΠ λ _ → A-set x y -- The predicate expressing that a given order satisfies the partial order -- axioms. satPosetAx : (ℓ₁ : Level) (A : Type ℓ₀) → Order ℓ₁ A → hProp (ℓ-max ℓ₀ ℓ₁) satPosetAx {ℓ₀ = ℓ₀} ℓ₁ A _⊑_ = φ , φ-prop where isPartial : isSet A → hProp (ℓ-max ℓ₀ ℓ₁) isPartial A-set = isReflexive _⊑_ ⊓ isTransitive _⊑_ ⊓ isAntisym A-set _⊑_ φ = Σ[ A-set ∈ isSet A ] [ isPartial A-set ] φ-prop = isOfHLevelΣ 1 isPropIsSet (λ x → snd (isPartial x)) -- The poset structure. PosetStr : (ℓ₁ : Level) → Type ℓ₀ → Type (ℓ-max ℓ₀ (ℓ-suc ℓ₁)) PosetStr ℓ₁ = add-to-structure (Order ℓ₁) λ A _⊑_ → [ satPosetAx ℓ₁ A _⊑_ ] PosetStr-set : (ℓ₁ : Level) (A : Type ℓ₀) → isSet (PosetStr ℓ₁ A) PosetStr-set ℓ₁ A = isSetΣ (isSetΠ2 λ _ _ → isSetHProp) λ _⊑_ → isProp→isSet (snd (satPosetAx ℓ₁ A _⊑_)) Poset : (ℓ₀ ℓ₁ : Level) → Type (ℓ-max (ℓ-suc ℓ₀) (ℓ-suc ℓ₁)) Poset ℓ₀ ℓ₁ = TypeWithStr ℓ₀ (PosetStr ℓ₁) -- Some projections for syntactic convenience. -- Carrier set of a poset. ∣_∣ₚ : Poset ℓ₀ ℓ₁ → Type ℓ₀ ∣ X , _ ∣ₚ = X strₚ : (P : Poset ℓ₀ ℓ₁) → PosetStr ℓ₁ ∣ P ∣ₚ strₚ (_ , s) = s rel : (P : Poset ℓ₀ ℓ₁) → ∣ P ∣ₚ → ∣ P ∣ₚ → hProp ℓ₁ rel (_ , _⊑_ , _) = _⊑_ syntax rel P x y = x ⊑[ P ] y ⊑[_]-refl : (P : Poset ℓ₀ ℓ₁) → (x : ∣ P ∣ₚ) → [ x ⊑[ P ] x ] ⊑[_]-refl (_ , _ , _ , ⊑-refl , _) = ⊑-refl ⊑[_]-trans : (P : Poset ℓ₀ ℓ₁) (x y z : ∣ P ∣ₚ) → [ x ⊑[ P ] y ] → [ y ⊑[ P ] z ] → [ x ⊑[ P ] z ] ⊑[_]-trans (_ , _ , _ , _ , ⊑-trans , _) = ⊑-trans ⊑[_]-antisym : (P : Poset ℓ₀ ℓ₁) (x y : ∣ P ∣ₚ) → [ x ⊑[ P ] y ] → [ y ⊑[ P ] x ] → x ≡ y ⊑[_]-antisym (_ , _ , _ , _ , _ , ⊑-antisym) = ⊑-antisym carrier-is-set : (P : Poset ℓ₀ ℓ₁) → isSet ∣ P ∣ₚ carrier-is-set (_ , _ , is-set , _) = is-set module PosetReasoning (P : Poset ℓ₀ ℓ₁) where _⊑⟨_⟩_ : (x : ∣ P ∣ₚ) {y z : ∣ P ∣ₚ} → [ x ⊑[ P ] y ] → [ y ⊑[ P ] z ] → [ x ⊑[ P ] z ] _ ⊑⟨ p ⟩ q = ⊑[ P ]-trans _ _ _ p q _■ : (x : ∣ P ∣ₚ) → [ x ⊑[ P ] x ] _■ = ⊑[ P ]-refl infixr 0 _⊑⟨_⟩_ infix 1 _■ -- Poset univalence. RP-iso-prop : (P Q : Σ (Type ℓ₀) (Order ℓ₁)) → (eqv : fst P ≃ fst Q) → isProp (order-iso P Q eqv) RP-iso-prop (A , _⊑₀_) (B , _⊑₁_) (f , _) = isPropΠ2 λ x y → snd (x ⊑₀ y ⇔ f x ⊑₁ f y) poset-iso : (P Q : Poset ℓ₀ ℓ₁) → ∣ P ∣ₚ ≃ ∣ Q ∣ₚ → Type (ℓ-max ℓ₀ ℓ₁) poset-iso {ℓ₁ = ℓ₁} = add-to-iso order-iso (λ A _⊑_ → [ satPosetAx ℓ₁ A _⊑_ ]) -- We collect poset isomorphisms in the following type. _≃ₚ_ : Poset ℓ₀ ℓ₁ → Poset ℓ₀ ℓ₁ → Type (ℓ-max ℓ₀ ℓ₁) _≃ₚ_ P Q = Σ[ i ∈ (∣ P ∣ₚ ≃ ∣ Q ∣ₚ) ] poset-iso P Q i poset-ax-props : (A : Type ℓ₀) (str : Order ℓ₁ A) → isProp [ satPosetAx ℓ₁ A str ] poset-ax-props {ℓ₁ = ℓ₁} A str = snd (satPosetAx ℓ₁ A str) poset-is-SNS : SNS {ℓ₀} (PosetStr ℓ₁) poset-iso poset-is-SNS {ℓ₁ = ℓ₁} = SNS-PathP→SNS-≡ _ poset-iso (add-axioms-SNS _ poset-ax-props isSNS-PathP) where isSNS-PathP : SNS-PathP (Order ℓ₁) order-iso isSNS-PathP = SNS-≡→SNS-PathP order-iso Order-is-SNS poset-is-SNS-PathP : SNS-PathP {ℓ₀} (PosetStr ℓ₁) poset-iso poset-is-SNS-PathP = SNS-≡→SNS-PathP poset-iso poset-is-SNS poset-SIP : (A : Type ℓ₀) (B : Type ℓ₀) (eqv : A ≃ B) (P : PosetStr ℓ₁ A) (Q : PosetStr ℓ₁ B) → poset-iso (A , P) (B , Q) eqv → (A , P) ≡ (B , Q) poset-SIP {ℓ₁ = ℓ₁} A B eqv P Q i = φ (eqv , i) where φ : (A , P) ≃[ poset-iso ] (B , Q) → (A , P) ≡ (B , Q) φ = equivFun (SIP poset-is-SNS-PathP (A , P) (B , Q)) ≃ₚ→≡ : (P Q : Poset ℓ₀ ℓ₁) → P ≃ₚ Q → P ≡ Q ≃ₚ→≡ (A , A-pos) (B , B-pos) (eqv , i) = poset-SIP A B eqv A-pos B-pos i
{ "alphanum_fraction": 0.5311619167, "avg_line_length": 35.4777777778, "ext": "agda", "hexsha": "3229e7680cb80143a844f41cd133840e3494a5a8", "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": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmester0/cubical", "max_forks_repo_path": "Cubical/Structures/Poset.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "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": "cmester0/cubical", "max_issues_repo_path": "Cubical/Structures/Poset.agda", "max_line_length": 80, "max_stars_count": 1, "max_stars_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmester0/cubical", "max_stars_repo_path": "Cubical/Structures/Poset.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-23T23:52:11.000Z", "max_stars_repo_stars_event_min_datetime": "2020-03-23T23:52:11.000Z", "num_tokens": 3118, "size": 6386 }
-- An ATP axiom must be used with postulates or data constructors. -- This error is detected by TypeChecking.Rules.Decl. module ATPBadAxiom where foo : Set → Set foo A = A {-# ATP axiom foo #-}
{ "alphanum_fraction": 0.7157360406, "avg_line_length": 19.7, "ext": "agda", "hexsha": "ea1ba5611e9af1c4a1739a160d455d9f5e252de2", "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": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "asr/eagda", "max_forks_repo_path": "test/fail/ATPBadAxiom.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "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": "asr/eagda", "max_issues_repo_path": "test/fail/ATPBadAxiom.agda", "max_line_length": 66, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "asr/eagda", "max_stars_repo_path": "test/fail/ATPBadAxiom.agda", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "num_tokens": 51, "size": 197 }
open import Issue623.A
{ "alphanum_fraction": 0.8260869565, "avg_line_length": 11.5, "ext": "agda", "hexsha": "24956bb3f7f721833dd0f7d2501d519f244940ee", "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/Issue623A.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/Issue623A.agda", "max_line_length": 22, "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/Issue623A.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": 6, "size": 23 }
open import FRP.JS.Nat using ( ℕ ) open import FRP.JS.String using ( String ) module FRP.JS.Geolocation.Distance where postulate Distance : Set _m : ℕ → Distance toString : Distance → String {-# COMPILED_JS _m function(x) { return x; } #-} {-# COMPILED_JS toString function(x) { return x.toString(); } #-}
{ "alphanum_fraction": 0.6857142857, "avg_line_length": 24.2307692308, "ext": "agda", "hexsha": "4f7368a593ab1438340d4a04093ca7ffb5c41ddb", "lang": "Agda", "max_forks_count": 7, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z", "max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z", "max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_forks_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_forks_repo_name": "agda/agda-frp-js", "max_forks_repo_path": "src/agda/FRP/JS/Geolocation/Distance.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_issues_repo_name": "agda/agda-frp-js", "max_issues_repo_path": "src/agda/FRP/JS/Geolocation/Distance.agda", "max_line_length": 65, "max_stars_count": 63, "max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_stars_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_stars_repo_name": "agda/agda-frp-js", "max_stars_repo_path": "src/agda/FRP/JS/Geolocation/Distance.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z", "num_tokens": 88, "size": 315 }
-- Using do-notation to implement a type checker for simply-typed -- lambda-calculus. module _ where open import Agda.Builtin.Nat hiding (_==_) open import Agda.Builtin.List open import Agda.Builtin.Equality open import Agda.Builtin.String -- Preliminaries -- --- Decidable equality --- data ⊥ : Set where ¬_ : Set → Set ¬ A = A → ⊥ data Dec (P : Set) : Set where yes : P → Dec P no : ¬ P → Dec P record Eq (A : Set) : Set where field _==_ : (x y : A) → Dec (x ≡ y) open Eq {{...}} --- Functors, Applicatives, and Monads --- record Functor (F : Set → Set) : Set₁ where field fmap : ∀ {A B} → (A → B) → F A → F B open Functor {{...}} record Applicative (F : Set → Set) : Set₁ where field pure : ∀ {A} → A → F A _<*>_ : ∀ {A B} → F (A → B) → F A → F B overlap {{super}} : Functor F open Applicative {{...}} record Monad (M : Set → Set) : Set₁ where field _>>=_ : ∀ {A B} → M A → (A → M B) → M B overlap {{super}} : Applicative M _>>_ : ∀ {A B} → M A → M B → M B m >> m' = m >>= λ _ → m' open Monad {{...}} data Maybe (A : Set) : Set where nothing : Maybe A just : A → Maybe A instance FunctorMaybe : Functor Maybe fmap {{FunctorMaybe}} f nothing = nothing fmap {{FunctorMaybe}} f (just x) = just (f x) ApplicativeMaybe : Applicative Maybe pure {{ApplicativeMaybe}} = just _<*>_ {{ApplicativeMaybe}} nothing _ = nothing _<*>_ {{ApplicativeMaybe}} (just _) nothing = nothing _<*>_ {{ApplicativeMaybe}} (just f) (just x) = just (f x) MonadMaybe : Monad Maybe _>>=_ {{MonadMaybe}} nothing f = nothing _>>=_ {{MonadMaybe}} (just x) f = f x --- List membership --- infix 2 _∈_ data _∈_ {A : Set} (x : A) : List A → Set where zero : ∀ {xs} → x ∈ x ∷ xs suc : ∀ {y xs} → x ∈ xs → x ∈ y ∷ xs rawIndex : ∀ {A} {x : A} {xs} → x ∈ xs → Nat rawIndex zero = zero rawIndex (suc i) = suc (rawIndex i) -- Simply typed λ-calculus -- infixr 7 _=>_ data Type : Set where nat : Type _=>_ : Type → Type → Type --- Decidable equality for Type --- private =>-inj₁ : ∀ {σ₁ σ₂ τ₁ τ₂} → (σ₁ => τ₁) ≡ (σ₂ => τ₂) → σ₁ ≡ σ₂ =>-inj₁ refl = refl =>-inj₂ : ∀ {σ₁ σ₂ τ₁ τ₂} → σ₁ => τ₁ ≡ σ₂ => τ₂ → τ₁ ≡ τ₂ =>-inj₂ refl = refl instance EqType : Eq Type _==_ {{EqType}} nat nat = yes refl _==_ {{EqType}} nat (τ => τ₁) = no λ() _==_ {{EqType}} (σ => σ₁) nat = no λ() _==_ {{EqType}} (σ => σ₁) (τ => τ₁) with σ == τ | σ₁ == τ₁ ... | yes refl | yes refl = yes refl ... | yes refl | no neq = no λ eq → neq (=>-inj₂ eq) ... | no neq | _ = no λ eq → neq (=>-inj₁ eq) --- Raw terms --- data Expr : Set where var : Nat → Expr app : Expr → Expr → Expr lam : Type → Expr → Expr lit : Nat → Expr suc : Expr --- Well-typed terms --- Context = List Type data Term (Γ : Context) : Type → Set where var : ∀ {τ} (x : τ ∈ Γ) → Term Γ τ app : ∀ {σ τ} (s : Term Γ (σ => τ)) (t : Term Γ σ) → Term Γ τ lam : ∀ σ {τ} (t : Term (σ ∷ Γ) τ) → Term Γ (σ => τ) lit : (n : Nat) → Term Γ nat suc : Term Γ (nat => nat) --- Erasing types --- forgetTypes : ∀ {Γ τ} → Term Γ τ → Expr forgetTypes (var x) = var (rawIndex x) forgetTypes (app s t) = app (forgetTypes s) (forgetTypes t) forgetTypes (lam σ t) = lam σ (forgetTypes t) forgetTypes (lit n) = lit n forgetTypes suc = suc --- Type checking --- TC = Maybe typeError : ∀ {A} → TC A typeError = nothing data WellTyped (Γ : Context) (e : Expr) : Set where ok : (σ : Type) (t : Term Γ σ) → forgetTypes t ≡ e → WellTyped Γ e data InScope (Γ : Context) (n : Nat) : Set where ok : (σ : Type) (i : σ ∈ Γ) → rawIndex i ≡ n → InScope Γ n infix 2 _∋_ pattern _∋_ σ x = ok σ x refl lookupVar : ∀ Γ n → TC (InScope Γ n) lookupVar [] n = typeError lookupVar (σ ∷ Γ) zero = pure (σ ∋ zero) lookupVar (σ ∷ Γ) (suc n) = do τ ∋ i ← lookupVar Γ n pure (τ ∋ suc i) -- Correct-by-construction type inference infer : ∀ Γ e → TC (WellTyped Γ e) infer Γ (var x) = do τ ∋ i ← lookupVar Γ x pure (τ ∋ var i) infer Γ (app e e₁) = do σ => τ ∋ s ← infer Γ e where nat ∋ s → typeError σ′ ∋ t ← infer Γ e₁ yes refl ← pure (σ == σ′) where no _ → typeError pure (τ ∋ app s t) infer Γ (lam σ e) = do τ ∋ t ← infer (σ ∷ Γ) e pure (σ => τ ∋ lam σ t) infer Γ (lit x) = pure (nat ∋ lit x) infer Γ suc = pure (nat => nat ∋ suc) -- Check that it works test : infer [] (lam (nat => nat) (lam nat (app (var 1) (var 0)))) ≡ pure ((nat => nat) => nat => nat ∋ lam (nat => nat) (lam nat (app (var (suc zero)) (var zero)))) test = refl
{ "alphanum_fraction": 0.5485575864, "avg_line_length": 25.0883977901, "ext": "agda", "hexsha": "69def6f4adfb17b30ca61b2ec541dc7084bcfa91", "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": "examples/DoNotation.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": "examples/DoNotation.agda", "max_line_length": 74, "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": "examples/DoNotation.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": 1711, "size": 4541 }
{-# OPTIONS --without-K --safe #-} module Data.String.Printf where open import Data.List using (List; []; _∷_; foldr) open import Data.String hiding (show) open import Data.Nat hiding (_≟_) open import Data.Char as Char using (Char) import Level open import Relation.Nullary infixr 6 _%_ record FormatUnit : Set (Level.suc Level.zero) where constructor _%_ field marker : Char {type} : Set conv : type → String open FormatUnit public module Internal where data Formatter : Set (Level.suc Level.zero) where chr : Char → Formatter cnv : (t : Set) → (t → String) → Formatter formatUnitTy : Formatter → Set → Set formatUnitTy (chr _) xs = xs formatUnitTy (cnv t _) xs = t → xs formatTy : List Formatter → Set formatTy = foldr formatUnitTy String toFormat : List FormatUnit → List Char → List Formatter toFormat fs [] = [] toFormat fs ('%' ∷ x ∷ xs) = go fs x xs where go : List FormatUnit → Char → List Char → List Formatter go [] x xs = chr x ∷ toFormat fs xs go (f ∷ fs) x xs with marker f Char.≟ x go (f ∷ _ ) x xs | yes p = cnv _ (conv f) ∷ toFormat fs xs go (f ∷ fs) x xs | no ¬p = go fs x xs toFormat fs (x ∷ xs) = chr x ∷ toFormat fs xs printf : (fs : List FormatUnit) → (xs : String) → formatTy (toFormat fs (toList xs)) printf fs xs = go "" (toFormat fs (toList xs)) where go : String → (xs : List Formatter) → formatTy xs go k [] = k go k (chr x ∷ xs) = go (k ++ fromList (x ∷ [])) xs go k (cnv _ c ∷ xs) = λ x → go (k ++ c x) xs import Data.Nat.Show open import Function standard : List FormatUnit standard = 'i' % Data.Nat.Show.show ∷ 's'% id ∷ [] module Printf (fs : List FormatUnit) where printf : (xs : String) → Internal.formatTy (Internal.toFormat fs (toList xs)) printf = Internal.printf fs
{ "alphanum_fraction": 0.6362631288, "avg_line_length": 30.6610169492, "ext": "agda", "hexsha": "90926007e7cfe455668125de58ecdc1f902e34cd", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-20T07:07:11.000Z", "max_forks_repo_forks_event_min_datetime": "2019-04-16T02:23:16.000Z", "max_forks_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mckeankylej/agda-ring-solver", "max_forks_repo_path": "src/Data/String/Printf.agda", "max_issues_count": 5, "max_issues_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_issues_repo_issues_event_max_datetime": "2022-03-12T01:55:42.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-17T20:48:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mckeankylej/agda-ring-solver", "max_issues_repo_path": "src/Data/String/Printf.agda", "max_line_length": 86, "max_stars_count": 36, "max_stars_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mckeankylej/agda-ring-solver", "max_stars_repo_path": "src/Data/String/Printf.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-15T00:57:55.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-25T16:40:52.000Z", "num_tokens": 573, "size": 1809 }
-- Andreas, 2014-06-27 test case by Ulf -- {-# OPTIONS -v tc.lhs:40 #-} {-# OPTIONS --copatterns #-} record Coind : Set where coinductive field ind : Coind open Coind loop : Set -> Coind ind A loop = ind (loop A) -- WAS: Internal error. -- NOW: Proper error. -- Ill-formed projection pattern ind A -- when checking that the clause ind A loop = ind (loop A) has type -- Set → Coind
{ "alphanum_fraction": 0.6564102564, "avg_line_length": 19.5, "ext": "agda", "hexsha": "72b86abd3fcadb72b1f8b923a8d7facc4a60c23a", "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/Issue1216.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/Issue1216.agda", "max_line_length": 67, "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/Issue1216.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": 390 }
{-# OPTIONS --without-K #-} module function.isomorphism.properties where open import level open import sum open import sets.nat.core open import equality.core open import equality.calculus open import equality.reasoning open import function.core open import function.fibration open import function.overloading open import function.extensionality.core open import function.extensionality.proof open import function.isomorphism.core open import function.isomorphism.coherent open import function.isomorphism.lift open import function.isomorphism.utils open import function.isomorphism.two-out-of-six open import hott.equivalence.core open import hott.equivalence.alternative open import hott.level.core open import hott.loop.core open import sets.unit iso-adjunction : ∀ {i j}{X : Set i}{Y : Set j} → (isom : X ≅ Y)(x : X)(y : Y) → (apply isom x ≡ y) ≅ (x ≡ invert isom y) iso-adjunction {i}{j}{X}{Y} isom x y = family-eq-iso total' (λ { (y , x) q → comm' x y q }) (y , x) where open _≅_ isom open ≅-Reasoning to-we : weak-equiv to to-we = proj₂ (≅⇒≈ isom) total' : (Σ (Y × X) λ { (y , x) → to x ≡ y }) ≅ (Σ (Y × X) λ { (y , x) → x ≡ from y}) total' = Σ-assoc-iso ·≅ ( Σ-ap-iso refl≅ λ y → contr-⊤-iso (to-we y) ·≅ sym≅ (contr-⊤-iso (singl-contr' (from y))) ) ·≅ sym≅ Σ-assoc-iso comm' : (x : X)(y : Y)(p : to x ≡ y) → proj₁ (apply total' ((y , x) , p)) ≡ (y , x) comm' x y q = ap (_,_ y) (sym (ap from q) · iso₁ x) private iso≡-lem : ∀ {i j}{X : Set i}{Y : Set j} → (isom : X ≅ Y) → (x x' : X) → weak-equiv (λ (p : x ≡ x') → ap (invert isom) (ap (apply isom) p)) iso≡-lem {X = X} isom x x' = step₃ where step₁ : ∀ {k}{A : Set k}(a a' : A) → weak-equiv {X = a ≡ a'} {Y = a ≡ a'} (ap (λ x → x)) step₁ a a' = subst weak-equiv (sym (funext ap-id)) (proj₂ (≅⇒≈ refl≅)) step₂ : weak-equiv (λ (p : x ≡ x') → ap (invert isom ∘ apply isom) p) step₂ = subst (λ u → weak-equiv {X = x ≡ x'} (ap u)) (sym (funext (_≅_.iso₁ isom))) (step₁ x x') step₃ = subst weak-equiv (sym (funext λ p → ap-hom (apply isom) (invert isom) p)) step₂ iso≡ : ∀ {i j}{X : Set i}{Y : Set j} → (isom : X ≅ Y) → {x x' : X} → (x ≡ x') ≅ (apply isom x ≡ apply isom x') iso≡ isom {x}{x'} = two-out-of-six.f-iso (ap (apply isom)) (ap (invert isom)) (ap (apply isom)) (iso≡-lem isom x x') (iso≡-lem (sym≅ isom) (apply isom x) (apply isom x')) private abstract Ω-iso' : ∀ {i j}{X : Set i}{Y : Set j}(n : ℕ) → (φ : X ≅ Y)(x : X) → Ω n x ≅ Ω n (apply φ x) Ω-iso' {X = X}{Y = Y} zero φ x = φ Ω-iso' (suc n) φ x = Ω-iso' n (iso≡ φ) refl Ω-iso-β : ∀ {i j}{X : Set i}{Y : Set j}(n : ℕ) → (φ : X ≅ Y)(x : X) → (p : Ω n x) → apply (Ω-iso' n φ x) p ≡ mapΩ n (apply φ) p Ω-iso-β zero φ x p = refl Ω-iso-β (suc n) φ x p = Ω-iso-β n (iso≡ φ) refl p Ω-iso : ∀ {i j}{X : Set i}{Y : Set j}(n : ℕ) → (φ : X ≅ Y)(x : X) → Ω n x ≅ Ω n (apply φ x) Ω-iso n φ x = ≈⇒≅ ( (λ p → mapΩ n (apply φ) p) , subst weak-equiv eq we) where abstract we : weak-equiv (apply (Ω-iso' n φ x)) we = proj₂ (≅⇒≈ (Ω-iso' n φ x)) eq : apply (Ω-iso' n φ x) ≡ mapΩ n (apply φ) eq = funext (Ω-iso-β n φ x) abstract subtype-eq : ∀ {i j k}{A : Set i}{P : A → Set j} → ((x : A) → h 1 (P x)) → {X : Set k} → (isom : X ≅ Σ A P) → {x y : X} → (proj₁ (apply isom x) ≡ proj₁ (apply isom y)) → x ≡ y subtype-eq hP isom p = iso⇒inj isom (unapΣ (p , h1⇒prop (hP _) _ _))
{ "alphanum_fraction": 0.5062087186, "avg_line_length": 32.3504273504, "ext": "agda", "hexsha": "a384e31bbea5d4bf5af497a87cfceb039ce5e7dd", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_path": "src/function/isomorphism/properties.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/function/isomorphism/properties.agda", "max_line_length": 93, "max_stars_count": 20, "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_path": "src/function/isomorphism/properties.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "num_tokens": 1488, "size": 3785 }
------------------------------------------------------------------------------ -- Arithmetic properties (added for the Collatz function example) ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Program.Collatz.Data.Nat.PropertiesI where open import Common.FOL.Relation.Binary.EqReasoning open import FOTC.Base open import FOTC.Base.PropertiesI open import FOTC.Data.Nat open import FOTC.Data.Nat.Inequalities open import FOTC.Data.Nat.Inequalities.PropertiesI open import FOTC.Data.Nat.PropertiesI open import FOTC.Data.Nat.UnaryNumbers open import FOTC.Data.Nat.UnaryNumbers.TotalityI open import FOTC.Program.Collatz.Data.Nat ------------------------------------------------------------------------------ -- Congruence properties divLeftCong : ∀ {m n o} → m ≡ n → div m o ≡ div n o divLeftCong refl = refl divRightCong : ∀ {m n o} → n ≡ o → div m n ≡ div m o divRightCong refl = refl ------------------------------------------------------------------------------ ^-N : ∀ {m n} → N m → N n → N (m ^ n) ^-N {m} Nm nzero = subst N (sym (^-0 m)) (nsucc nzero) ^-N {m} Nm (nsucc {n} Nn) = subst N (sym (^-S m n)) (*-N Nm (^-N Nm Nn)) div-0-x≡0 : ∀ {n} → N n → n ≢ 0' → div 0' n ≡ 0' div-0-x≡0 nzero h = ⊥-elim (h refl) div-0-x≡0 (nsucc {n} Nn) h = div-x<y h (lt-0S n) div-x-x≡1 : ∀ {n} → N n → n ≢ 0' → div n n ≡ 1' div-x-x≡1 {n} Nn h = div n n ≡⟨ div-x≥y h (x≤x Nn) ⟩ succ₁ (div (n ∸ n) n) ≡⟨ succCong (divLeftCong (x∸x≡0 Nn)) ⟩ succ₁ (div 0' n) ≡⟨ succCong (div-0-x≡0 Nn h) ⟩ 1' ∎ div-2x-2≡x : ∀ {n} → N n → div (2' * n) 2' ≡ n div-2x-2≡x nzero = prf where -- See the combined proof. postulate prf : div (2' * zero) 2' ≡ zero div-2x-2≡x (nsucc nzero) = div (2' * 1') 2' ≡⟨ divLeftCong (*-rightIdentity 2-N) ⟩ div 2' 2' ≡⟨ div-x≥y S≢0 (x≤x 2-N) ⟩ succ₁ (div (2' ∸ 2') 2') ≡⟨ succCong (divLeftCong (x∸x≡0 2-N)) ⟩ succ₁ (div zero 2') ≡⟨ succCong (div-x<y S≢0 (lt-0S 1')) ⟩ 1' ∎ div-2x-2≡x (nsucc (nsucc {n} Nn)) = prf where -- See the combined proof. postulate prf : div (2' * (succ₁ (succ₁ n))) 2' ≡ succ₁ (succ₁ n) div-2^[x+1]-2≡2^x : ∀ {n} → N n → div (2' ^ succ₁ n) 2' ≡ 2' ^ n div-2^[x+1]-2≡2^x {n} Nn = div (2' ^ succ₁ n) 2' ≡⟨ divLeftCong (^-S 2' n) ⟩ div (2' * 2' ^ n) 2' ≡⟨ div-2x-2≡x (^-N 2-N Nn) ⟩ 2' ^ n ∎ +∸2 : ∀ {n} → N n → n ≢ zero → n ≢ 1' → n ≡ succ₁ (succ₁ (n ∸ 2')) +∸2 nzero n≢0 _ = ⊥-elim (n≢0 refl) +∸2 (nsucc nzero) _ n≢1 = ⊥-elim (n≢1 refl) +∸2 (nsucc (nsucc {n} Nn)) _ _ = sym prf where prf : succ₁ (succ₁ (succ₁ (succ₁ n) ∸ 2')) ≡ succ₁ (succ₁ n) prf = succ₁ (succ₁ (succ₁ (succ₁ n) ∸ 2')) ≡⟨ succCong (succCong (S∸S (nsucc Nn) (nsucc nzero))) ⟩ succ₁ (succ₁ ((succ₁ n) ∸ 1')) ≡⟨ succCong (succCong (S∸S Nn nzero)) ⟩ succ₁ (succ₁ (n ∸ zero)) ≡⟨ succCong (succCong (∸-x0 n)) ⟩ succ₁ (succ₁ n) ∎ x^1≡x : ∀ {n} → N n → n ^ 1' ≡ n x^1≡x {n} Nn = n ^ 1' ≡⟨ ^-S n 0' ⟩ n * n ^ 0' ≡⟨ *-rightCong (^-0 n) ⟩ n * 1' ≡⟨ *-rightIdentity Nn ⟩ n ∎ 2^x≢0 : ∀ {n} → N n → 2' ^ n ≢ zero 2^x≢0 nzero h = ⊥-elim (0≢S (trans (sym h) (^-0 2'))) 2^x≢0 (nsucc {n} Nn) h = case (λ 2≡0 → ⊥-elim (0≢S (sym 2≡0))) (λ 2^n≡0 → ⊥-elim (2^x≢0 Nn 2^n≡0)) (xy≡0→x≡0∨y≡0 2-N (^-N 2-N Nn) (trans (sym (^-S 2' n)) h)) 2^[x+1]≢1 : ∀ {n} → N n → 2' ^ succ₁ n ≢ 1' 2^[x+1]≢1 {n} Nn h = Sx≢x 1-N (xy≡1→x≡1 2-N (^-N 2-N Nn) (trans (sym (^-S 2' n)) h)) Sx-Even→x-Odd : ∀ {n} → N n → Even (succ₁ n) → Odd n Sx-Even→x-Odd nzero h = ⊥-elim (t≢f (trans₂ (sym h) (even-S zero) odd-0)) Sx-Even→x-Odd (nsucc {n} Nn) h = trans (sym (even-S (succ₁ n))) h Sx-Odd→x-Even : ∀ {n} → N n → Odd (succ₁ n) → Even n Sx-Odd→x-Even nzero _ = even-0 Sx-Odd→x-Even (nsucc {n} Nn) h = trans (sym (odd-S (succ₁ n))) h ∸-Even : ∀ {m n} → N m → N n → Even m → Even n → Even (m ∸ n) ∸-Odd : ∀ {m n} → N m → N n → Odd m → Odd n → Even (m ∸ n) ∸-Even {m} Nm nzero h₁ _ = subst Even (sym (∸-x0 m)) h₁ ∸-Even nzero (nsucc {n} Nn) h₁ _ = subst Even (sym (0∸x (nsucc Nn))) h₁ ∸-Even (nsucc {m} Nm) (nsucc {n} Nn) h₁ h₂ = subst Even (sym (S∸S Nm Nn)) (∸-Odd Nm Nn (Sx-Even→x-Odd Nm h₁) (Sx-Even→x-Odd Nn h₂)) ∸-Odd nzero Nn h₁ _ = ⊥-elim (t≢f (trans (sym h₁) odd-0)) ∸-Odd (nsucc Nm) nzero _ h₂ = ⊥-elim (t≢f (trans (sym h₂) odd-0)) ∸-Odd (nsucc {m} Nm) (nsucc {n} Nn) h₁ h₂ = subst Even (sym (S∸S Nm Nn)) (∸-Even Nm Nn (Sx-Odd→x-Even Nm h₁) (Sx-Odd→x-Even Nn h₂)) x-Even→SSx-Even : ∀ {n} → N n → Even n → Even (succ₁ (succ₁ n)) x-Even→SSx-Even nzero h = even 2' ≡⟨ even-S 1' ⟩ odd 1' ≡⟨ odd-S zero ⟩ even zero ≡⟨ even-0 ⟩ true ∎ x-Even→SSx-Even (nsucc {n} Nn) h = even (succ₁ (succ₁ (succ₁ n))) ≡⟨ even-S (succ₁ (succ₁ n)) ⟩ odd (succ₁ (succ₁ n)) ≡⟨ odd-S (succ₁ n) ⟩ even (succ₁ n) ≡⟨ h ⟩ true ∎ 2-Even : Even 2' 2-Even = x-Even→SSx-Even nzero even-0 x+x-Even : ∀ {n} → N n → Even (n + n) x+x-Even nzero = subst Even (sym (+-rightIdentity nzero)) even-0 x+x-Even (nsucc {n} Nn) = subst Even (sym prf) (x-Even→SSx-Even (+-N Nn Nn) (x+x-Even Nn)) where prf : succ₁ n + succ₁ n ≡ succ₁ (succ₁ (n + n)) prf = succ₁ n + succ₁ n ≡⟨ +-Sx n (succ₁ n) ⟩ succ₁ (n + succ₁ n) ≡⟨ succCong (+-comm Nn (nsucc Nn)) ⟩ succ₁ (succ₁ n + n) ≡⟨ succCong (+-Sx n n) ⟩ succ₁ (succ₁ (n + n)) ∎ 2x-Even : ∀ {n} → N n → Even (2' * n) 2x-Even nzero = subst Even (sym (*-rightZero 2-N)) even-0 2x-Even (nsucc {n} Nn) = subst Even (sym prf) (x-Even→SSx-Even (+-N Nn Nn) (x+x-Even Nn)) where prf : 2' * succ₁ n ≡ succ₁ (succ₁ (n + n)) prf = 2' * succ₁ n ≡⟨ *-Sx 1' (succ₁ n) ⟩ succ₁ n + 1' * succ₁ n ≡⟨ +-Sx n (1' * succ₁ n) ⟩ succ₁ (n + 1' * succ₁ n) ≡⟨ succCong (+-rightCong (*-Sx zero (succ₁ n))) ⟩ succ₁ (n + (succ₁ n + zero * succ₁ n)) ≡⟨ succCong (+-rightCong (+-rightCong (*-leftZero (succ₁ n)))) ⟩ succ₁ (n + (succ₁ n + zero)) ≡⟨ succCong (+-rightCong (+-rightIdentity (nsucc Nn))) ⟩ succ₁ (n + succ₁ n) ≡⟨ succCong (+-comm Nn (nsucc Nn)) ⟩ succ₁ (succ₁ n + n) ≡⟨ succCong (+-Sx n n) ⟩ succ₁ (succ₁ (n + n)) ∎ 2^[x+1]-Even : ∀ {n} → N n → Even (2' ^ succ₁ n) 2^[x+1]-Even {n} Nn = subst Even (sym (^-S 2' n)) (2x-Even (^-N 2-N Nn))
{ "alphanum_fraction": 0.4772592152, "avg_line_length": 34.8601036269, "ext": "agda", "hexsha": "afdf489136c290fbc8b0a53e0624249a9e229e0c", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Program/Collatz/Data/Nat/PropertiesI.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Program/Collatz/Data/Nat/PropertiesI.agda", "max_line_length": 84, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Program/Collatz/Data/Nat/PropertiesI.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": 3082, "size": 6728 }
open import Relation.Binary using (Decidable) open import Relation.Binary.PropositionalEquality using (_≡_ ; _≢_ ; refl ; subst ; subst₂) open import Data.Nat as Nat using (ℕ ; _≤′_ ; _+_) open import Relation.Binary.PropositionalEquality using (sym) import Relation.Unary as U open import Function using (_∘_) open import Relation.Nullary module Data.FiniteMap {Key : Set} (inject : Key → ℕ) (surject : ℕ → Key) (inject-injective : ∀ {k1 k2} → inject k1 ≡ inject k2 → k1 ≡ k2) (surject-inject : ∀ {k} → inject (surject k) ≡ k) where open import utility open import Data.Maybe using (just) open import Data.Empty using (⊥-elim) open import Data.List using (List ; _++_ ; [_] ; [] ; _∷_) open import Data.List.Any using (any ; here ; there ; Any) open import Data.Nat using (ℕ ; zero ; suc) open import Data.Sum using (inj₁ ; inj₂ ; _⊎_) open import Data.Product using (Σ ; Σ-syntax ; ∃ ; proj₁ ; proj₂ ; _×_ ; _,_ ; ∃-syntax ; uncurry ; map) open import Function using (id ; _$_) open import Relation.Nullary using (yes ; no) open import Data.OrderedListMap(Key)(inject) as OMap hiding (insert-mono ; U-mono) open import Data.Bool using (Bool ; true ; false) private nbiject : ∀ {k1 k2} → k1 ≢ k2 → inject k1 ≢ inject k2 nbiject = (_∘ inject-injective) Map : Set → Set Map = LMap keys : ∀{Value} → Map Value → List ℕ keys{Value} l = (Dom' Value l) keys+∈ : ∀{Value} → (l : Map Value) → List (∃[ n ] (n ∈ (Dom' Value l))) keys+∈{Value} l = (Dom'+∈ Value l) inj= : Key → ℕ → Set inj= = _≡_ ∘ inject ∈Dom : ∀{Value} → Key → Map Value → Set ∈Dom{Value} k m = (inject k) ∈ (Dom' Value m) in-inject : ∀ {Value}{x : ℕ} → (l : Map Value) → x ∈ Dom' Value l → ∈Dom (surject x) l in-inject{x = x} l ∈ rewrite surject-inject{x} = ∈ key-map : ∀{Value}{a}{L : Set a} → (l : Map Value) → (f : (k : Key) → (∈Dom k l) → L) → List L key-map{L = L} l f = Data.List.map ((uncurry f) ∘ (map surject (in-inject l))) (keys+∈ l) ∈Check : ∀{Value} → (k : Key) → (m : Map Value) → Relation.Nullary.Dec (∈Dom k m) ∈Check{Value} k m = any (Nat._≟_ (inject k)) (Dom' Value m) lookup : ∀{Value k} → (l : Map Value) → (∈Dom k l) → Value lookup{Value}{k = k} m k∈ = deref Value (inject k) m k∈ update : ∀{Value} → (l : Map Value) → Key → Value → Map Value update{Value} l k v = m-insert Value (just v) (inject k) l -- Union map. For repeated keys, the values from the second map is preferred. union : ∀{Value} → Map Value → Map Value → Map Value union{Value} m1 m2 = (_U_ Value m1 m2) empty : ∀{Value} → Map Value empty = [] [_↦_] : ∀{Value} → (k : Key) → (v : Value) → Map Value [ k ↦ v ] = update empty k v [_↦_,_↦_] : ∀{Value} → (k₁ : Key) → (v₁ : Value) → (k₂ : Key) → (v₂ : Value) → Map Value [ k₁ ↦ v₁ , k₂ ↦ v₂ ] = update [ k₁ ↦ v₁ ] k₂ v₂ keys-1map : ∀{Value} → (k : Key) → (v : Value) → keys [ k ↦ v ] ≡ inject k ∷ [] keys-1map {Value} k v = Dom'-1map Value (inject k) v keys-2map : ∀{Value} → (k₁ : Key) → (v₁ : Value) → (k₂ : Key) → (v₂ : Value) → (keys [ k₁ ↦ v₁ , k₂ ↦ v₂ ] ≡ inject k₁ ∷ [] × k₁ ≡ k₂) ⊎ (keys [ k₁ ↦ v₁ , k₂ ↦ v₂ ] ≡ inject k₁ ∷ inject k₂ ∷ []) ⊎ (keys [ k₁ ↦ v₁ , k₂ ↦ v₂ ] ≡ inject k₂ ∷ inject k₁ ∷ []) keys-2map {Value} k₁ v₁ k₂ v₂ = Data.Sum.map (Data.Product.map id inject-injective) id (Dom'-2map Value (inject k₁) v₁ (inject k₂) v₂) keys-1map-distinct : ∀{Value} → (k1 k2 : Key) → (v1 v2 : Value) → ¬ (k1 ≡ k2) → utility.distinct' (keys [ k1 ↦ v1 ]) (keys [ k2 ↦ v2 ]) keys-1map-distinct k1 k2 v1 v2 neg z k1∈ k2∈ rewrite (keys-1map k1 v1) | (keys-1map k2 v2) with k1∈ | k2∈ ... | here refl | here px = (nbiject neg) px ... | there () | _ ... | here px | there () keys-1map∈ : ∀{Value} → (k1 : Key) → (v1 : Value) → (inject k1) ∈ keys [ k1 ↦ v1 ] keys-1map∈ k v rewrite keys-1map k v = here refl 2map-eq-one : ∀{V} k1 k2 v k1∈ → (lookup{V}{k1} ([ k1 ↦ v , k2 ↦ v ]) k1∈) ≡ v 2map-eq-one {V} k1 k2 = insert-two-eq-one V (inject k1) (inject k2) 2map-eq-two : ∀{V} k1 k2 v k2∈ → (lookup{V}{k2} ([ k1 ↦ v , k2 ↦ v ]) k2∈) ≡ v 2map-eq-two {V} k1 k2 = insert-two-eq-two V (inject k1) (inject k2) -- theorems update-in-keys : ∀{V} m k v → ∈Dom k (update{V} m k v) update-in-keys {V} m k = insert-in-domain V m (inject k) lookup-∈-irr : ∀{Value k m} → (∈1 : ∈Dom k m) → (∈2 : ∈Dom k m) → lookup{Value}{k} m ∈1 ≡ lookup{Value}{k} m ∈2 lookup-∈-irr{Value} ∈1 ∈2 = deref-∈-irr Value ∈1 ∈2 insert-mono : ∀{Value k m k' v} → ∈Dom k m → ∈Dom k (update{Value} m k' v) insert-mono{Value}{k}{m}{k'}{v} i = (OMap.insert-mono Value {m}{inject k}{inject k'}{v} i) U-mono : ∀{Value m m' k} → ∈Dom k m → ∈Dom k (union{Value} m m') U-mono{V}{m}{m'}{k} i = OMap.U-mono V {m}{m'}{inject k} i union-comm : ∀ {Value} → (m1 : Map Value) → (m2 : Map Value) → distinct' (keys m1) (keys m2) → union m1 m2 ≡ union m2 m1 union-comm {Value} m1 m2 keys-m1≠keys-m2 = U-comm Value {m1} {m2} keys-m1≠keys-m2 union-assoc : ∀ {Value} → (m1 m2 m3 : Map Value) → union m1 (union m2 m3) ≡ union (union m1 m2) m3 union-assoc {Value} = U-assoc Value keys-assoc-comm : ∀ {Value} m1 m2 m3 → keys (union {Value} (union {Value} m1 m2) m3) ≡ keys (union {Value} (union {Value} m1 m3) m2) keys-assoc-comm {Value} = Dom'-assoc-comm Value U⁻-m : ∀ {Value m m' n} → ∈Dom n (union {Value} m m') → ∈Dom n m ⊎ ∈Dom n m' U⁻-m {Value} {m} {m'} {n} = U⁻ Value {m} {m'} {inject n} U-∉-irr-get-help-m : ∀{Value m m' k} → (k∈m : ∈Dom k m) → ¬ (∈Dom k m') → (k∈' : ∈Dom k (union {Value} m m'))→ lookup {Value} {k} m k∈m ≡ lookup {Value} {k} (union {Value} m m') k∈' U-∉-irr-get-help-m {Value} = U-∉-irr-get-help Value U-∉-irr-get-m : ∀{Value m m' k} → (k∈m : ∈Dom k m) → ¬ (∈Dom k m') → ∃ λ k∈' → lookup {Value} {k} m k∈m ≡ lookup {Value} {k} (union {Value} m m') k∈' U-∉-irr-get-m {Value} = U-∉-irr-get Value get-U-right-irr-m : ∀ {Value} k m m' → (k∈mUm' : ∈Dom k (union {Value} m m')) → (k∈m' : ∈Dom k m') → lookup {Value} {k} (union {Value} m m') k∈mUm' ≡ lookup {Value} {k} m' k∈m' get-U-right-irr-m {Value} k = deref-U-right-irr Value (inject k) ∈-get-U-irr-m : ∀ {Value} k m m' m'' k∈mUm'' k∈m'Um'' → (k∈m'' : ∈Dom k m'') → lookup {Value} {k} (union {Value} m m'') k∈mUm'' ≡ lookup {Value} {k} (union {Value} m' m'') k∈m'Um'' ∈-get-U-irr-m {Value} k = ∈-deref-U-irr Value (inject k) get-U-both-irr-m : ∀ {Value} k m m' m'' k∈m k∈m' k∈mUm'' k∈m'Um'' → lookup {Value} {k} m k∈m ≡ lookup {Value} {k} m' k∈m' → lookup {Value} {k} (union {Value} m m'') k∈mUm'' ≡ lookup {Value} {k} (union {Value} m' m'') k∈m'Um'' get-U-both-irr-m {Value} k = deref-U-both-irr Value (inject k) putputget : ∀{Value m k k' v v'} → ¬ k ≡ k' → (∈1 : ∈Dom k m) → (∈2 : ∈Dom k (update{Value} m k' v')) → lookup{Value}{k} m ∈1 ≡ v → lookup{Value}{k} (update{Value} m k' v') ∈2 ≡ v putputget{V}{m}{k}{k'}{v}{v'} neq kin1 kin2 eq = putputget-neq V {inject k}{inject k'}{m} (nbiject neq) kin1 kin2 eq putput-overwrite : ∀{Value} m k v v' → (update{Value} (update{Value} m k v) k v') ≡ (update m k v') putput-overwrite {V} m k v v' = putputget-eq V (inject k) m v v' getput-m : ∀ {Value} k m → (∈1 : ∈Dom k m) → m ≡ update {Value} m k (lookup {Value} {k} m ∈1) getput-m {Value} k = getput Value (inject k) putget-m : ∀{Value m k v} → (kin : ∈Dom k (update{Value} m k v)) → (lookup{Value}{k} (update{Value} m k v) kin) ≡ v putget-m {V}{m}{k}{v} kin = putget V kin update-union-union : ∀ {Value} k v m m' → (∈1 : ∈Dom k m) → (∈2 : ∈Dom k m') → union {Value} m m' ≡ union {Value} (update {Value} m k v) m' update-union-union {Value} k = put-U-U Value (inject k) ineq-m : ∀{Value k m} → (k1 : ∈Dom{Value} k m) → (k2 : ∈Dom k m) → k1 ≡ k2 ineq-m {V}{k}{m} k1 k2 = ineq V {inject k}{m} k1 k2 put-comm : ∀{Value m k1 k2 v1 v2} → ¬ k1 ≡ k2 → (update (update{Value} m k1 v1) k2 v2) ≡ (update (update m k2 v2) k1 v1) put-comm{V}{m}{k1}{k2}{v1}{v2} ¬k1≡k2 = insert-comm V {m}{inject k1}{inject k2}{v1}{v2} (nbiject ¬k1≡k2) put-union-comm : ∀ {Value} k v m m' → ¬ (∈Dom k m') → union {Value} (update {Value} m k v) m' ≡ update {Value} (union {Value} m m') k v put-union-comm {Value} k = insert-U-comm Value (inject k) union-=-irr : ∀ {Value} m m' → (keys{Value} m) ≡ (keys{Value} m') → ∀ k k∈ k∈2 → (lookup{Value}{k} (union m m') k∈) ≡ (lookup{Value}{k} m' k∈2) union-=-irr {V} m m' eql k = U-=-irr V m m' eql (inject k) union-single-overwrite : ∀ {V} k v1 v2 → union{V} [ k ↦ v1 ] [ k ↦ v2 ] ≡ [ k ↦ v2 ] union-single-overwrite {V} k v1 v2 = U-single-overwrite V (inject k) v1 v2 update-single-val : ∀ {V} k v k∈ → lookup{V}{k} [ k ↦ v ] k∈ ≡ v update-single-val {V} k v k∈ = set-single-val V (inject k) v k∈ single-val-overwrite : ∀ {V} k v m → (∈Dom{V} k m) → union{V} ([ k ↦ v ]) m ≡ m single-val-overwrite {V} k = overwrite-single-val V (inject k) union-insert-eq : ∀{V} k v m → (update{V} m k v) ≡ (union{V} m [ k ↦ v ]) union-insert-eq {V} k = U-insert-eq V (inject k) update-domain-eq : ∀{V} k v m → (inject k) ∈ keys{V} m → (keys m) ≡ (keys (update{V} m k v)) update-domain-eq {V} k = insert-domain-eq V (inject k) --(OMap.insert-mono Value {m}{inject k}{inject k'}{v} i) keys-2map∈ : ∀{Value} → (k1 : Key) → (v1 : Value) → (k2 : Key) → (v2 : Value) → (∈Dom k1 [ k1 ↦ v1 , k2 ↦ v2 ]) × (∈Dom k2 [ k1 ↦ v1 , k2 ↦ v2 ]) keys-2map∈ {V} k1 v1 k2 v2 = insert-mono (keys-1map∈ k1 v1) , update-in-keys ([ k1 ↦ v1 ]) k2 v2 count : ∀ {V} -> (V -> Bool) -> Map V -> ℕ count {V} p m = ocount V p m change-one-count-goes-down : ∀ {Value} (m : Map Value) -> (p : Value -> Bool) -> (k : Key) -> (k∈ : ∈Dom k m) -> p (lookup m k∈) ≡ true -> (v : Value) -> p v ≡ false -> count p m ≡ suc (count p (update m k v)) change-one-count-goes-down {V} m p k = change-one-ocount-goes-down V m p (inject k) change-nothing-count-stays-same : ∀ {Value} (m : Map Value) -> (p : Value -> Bool) -> (k : Key) -> (k∈ : ∈Dom k m) -> (v : Value) -> p (lookup m k∈) ≡ p v -> count p m ≡ count p (update m k v) change-nothing-count-stays-same {V} m p k = change-nothing-ocount-stays-same V m p (inject k) count-merge≤′sum-count : ∀ {Value} (m1 m2 : Map Value) -> (p : Value -> Bool) -> count p (union m1 m2) ≤′ count p m1 + count p m2 count-merge≤′sum-count {V} m1 m2 p = ocount-merge≤′sum-ocount V m1 m2 p
{ "alphanum_fraction": 0.5558114982, "avg_line_length": 37.75, "ext": "agda", "hexsha": "bc7d3259ce5416d03e2cb9e777a2fc2b6e88aca9", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_path": "agda/Data/FiniteMap.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "florence/esterel-calculus", "max_issues_repo_path": "agda/Data/FiniteMap.agda", "max_line_length": 181, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_path": "agda/Data/FiniteMap.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "num_tokens": 4446, "size": 10419 }
-- {-# OPTIONS --show-implicit --show-irrelevant #-} module Data.QuadTree.LensProofs.Valid-LensGo where open import Haskell.Prelude renaming (zero to Z; suc to S) open import Data.Lens.Lens open import Data.Logic open import Data.QuadTree.InternalAgda open import Agda.Primitive open import Data.Lens.Proofs.LensLaws open import Data.Lens.Proofs.LensPostulates open import Data.Lens.Proofs.LensComposition open import Data.QuadTree.LensProofs.Valid-LensLeaf open import Data.QuadTree.LensProofs.Valid-LensA open import Data.QuadTree.LensProofs.Valid-LensBCD open import Axiom.Extensionality.Propositional open import Data.QuadTree.Implementation.QuadrantLenses open import Data.QuadTree.Implementation.Definition open import Data.QuadTree.Implementation.ValidTypes open import Data.QuadTree.Implementation.SafeFunctions open import Data.QuadTree.Implementation.PublicFunctions open import Data.QuadTree.Implementation.DataLenses {- I spend close to 50 hours on this file, at the time of writing more than the rest of the lens proofs combined. The file still looks horrible and there is very serious code duplication, but I honestly wish to never look at this file again. In order to proof this we need some form of Extensionality Because this is quite a complicated application of Extensionality, I did not proof it from generic Extensionality, but just postulated it seperately. It is needed because Agda eagerly applies implicit arguments at the start of a function, which I don't want it to do This can be used to reverse agda doing that -} postulate FunctorExtensionality : {t : Set} {{eqT : Eq t}} -> {deps : Nat} -> {la lb : Lens (VQuadrant t {S deps}) t} -> ({f : Set -> Set} -> {{ff : Functor f}} -> (la {f} {{ff}} ≡ lb {f} {{ff}})) -> (λ {f} ⦃ ff ⦄ → la {f} {{ff}}) ≡ (λ {f} ⦃ ff ⦄ → lb {f} {{ff}}) ---- Lens laws for go ValidLens-go-ViewSet : {t : Set} {{eqT : Eq t}} -> (loc : Nat × Nat) -> (dep : Nat) -> {ins : IsTrue (isInsidePow loc dep)} -> ViewSet (go {t} loc dep {ins}) ValidLens-go-SetView : {t : Set} {{eqT : Eq t}} -> (loc : Nat × Nat) -> (dep : Nat) -> {ins : IsTrue (isInsidePow loc dep)} -> SetView (go {t} loc dep {ins}) ValidLens-go-SetSet : {t : Set} {{eqT : Eq t}} -> (loc : Nat × Nat) -> (dep : Nat) -> {ins : IsTrue (isInsidePow loc dep)} -> SetSet (go {t} loc dep {ins}) ValidLens-go : {t : Set} {{eqT : Eq t}} -> (loc : Nat × Nat) -> (dep : Nat) -> {IsTrue (isInsidePow loc dep)} -> ValidLens (VQuadrant t {dep}) t ValidLens-go {t} {{eqT}} loc dep {ins} = CValidLens (go loc dep {ins}) (ValidLens-go-ViewSet loc dep {ins}) (ValidLens-go-SetView loc dep {ins}) (ValidLens-go-SetSet loc dep {ins}) ValidLens-go-ViewSet loc Z v cvq@(CVQuadrant (Leaf x) {p}) = refl ValidLens-go-ViewSet {t} (x , y) dep@(S deps) {ins} v cvq@(CVQuadrant qd {p}) = ifc y < mid then (λ {{py}} -> ifc x < mid then (λ {{px}} -> trans (cong -- We need to explicitly provide the x, otherwise agda gets confused {x = λ {f} ⦃ ff ⦄ → go (x , y) (S deps) {ins} {f} {{ff}} } -- We cong over the law, applying the transformation to go (λ (g : Lens (VQuadrant t {dep}) t) -> view g (set g v cvq)) -- Select only the lensA branch (FunctorExtensionality (trans (ifTrue (y < mid) py) (ifTrue (x < mid) px)))) -- Then use the property of composition to proof the law (prop-Composition-ViewSet (ValidLens-LensA) (ValidLens-go (mod x mid , mod y mid) deps {andCombine (modLt x mid {pow_not_zero_cv deps}) (modLt y mid {pow_not_zero_cv deps})}) v cvq) ) else (λ {{px}} -> trans (cong -- We need to explicitly provide the x, otherwise agda gets confused {x = λ {f} ⦃ ff ⦄ → go (x , y) (S deps) {ins} {f} {{ff}} } -- We cong over the law, applying the transformation to go (λ (g : Lens (VQuadrant t {dep}) t) -> view g (set g v cvq)) -- Select only the lensB branch (FunctorExtensionality (trans (ifTrue (y < mid) py) (ifFalse (x < mid) px)))) -- Then use the property of composition to proof the law (prop-Composition-ViewSet (ValidLens-LensB) (ValidLens-go (mod x mid , mod y mid) deps {andCombine (modLt x mid {pow_not_zero_cv deps}) (modLt y mid {pow_not_zero_cv deps})}) v cvq) ) ) else (λ {{py}} -> ifc x < mid then (λ {{px}} -> trans (cong -- We need to explicitly provide the x, otherwise agda gets confused {x = λ {f} ⦃ ff ⦄ → go (x , y) (S deps) {ins} {f} {{ff}} } -- We cong over the law, applying the transformation to go (λ (g : Lens (VQuadrant t {dep}) t) -> view g (set g v cvq)) -- Select only the lensC branch (FunctorExtensionality (trans (ifFalse (y < mid) py) (ifTrue (x < mid) px)))) -- Then use the property of composition to proof the law (prop-Composition-ViewSet (ValidLens-LensC) (ValidLens-go (mod x mid , mod y mid) deps {andCombine (modLt x mid {pow_not_zero_cv deps}) (modLt y mid {pow_not_zero_cv deps})}) v cvq) ) else (λ {{px}} -> trans (cong -- We need to explicitly provide the x, otherwise agda gets confused {x = λ {f} ⦃ ff ⦄ → go (x , y) (S deps) {ins} {f} {{ff}} } -- We cong over the law, applying the transformation to go (λ (g : Lens (VQuadrant t {dep}) t) -> view g (set g v cvq)) -- Select only the lensD branch (FunctorExtensionality (trans (ifFalse (y < mid) py) (ifFalse (x < mid) px)))) -- Then use the property of composition to proof the law (prop-Composition-ViewSet (ValidLens-LensD) (ValidLens-go (mod x mid , mod y mid) deps {andCombine (modLt x mid {pow_not_zero_cv deps}) (modLt y mid {pow_not_zero_cv deps})}) v cvq) ) ) where mid = pow 2 deps ValidLens-go-SetView loc Z cvq@(CVQuadrant (Leaf x) {p}) = refl ValidLens-go-SetView {t} (x , y) dep@(S deps) {ins} cvq@(CVQuadrant qd {p}) = ifc y < mid then (λ {{py}} -> ifc x < mid then (λ {{px}} -> trans (cong -- We need to explicitly provide the x, otherwise agda gets confused {x = λ {f} ⦃ ff ⦄ → go (x , y) (S deps) {ins} {f} {{ff}} } -- We cong over the law, applying the transformation to go (λ (g : Lens (VQuadrant t {dep}) t) -> set g (view g cvq) cvq) -- Select only the lensA branch (FunctorExtensionality (trans (ifTrue (y < mid) py) (ifTrue (x < mid) px)))) -- Then use the property of composition to proof the law (prop-Composition-SetView (ValidLens-LensA) (ValidLens-go (mod x mid , mod y mid) deps {andCombine (modLt x mid {pow_not_zero_cv deps}) (modLt y mid {pow_not_zero_cv deps})}) cvq) ) else (λ {{px}} -> trans (cong -- We need to explicitly provide the x, otherwise agda gets confused {x = λ {f} ⦃ ff ⦄ → go (x , y) (S deps) {ins} {f} {{ff}} } -- We cong over the law, applying the transformation to go (λ (g : Lens (VQuadrant t {dep}) t) -> set g (view g cvq) cvq) -- Select only the lensB branch (FunctorExtensionality (trans (ifTrue (y < mid) py) (ifFalse (x < mid) px)))) -- Then use the property of composition to proof the law (prop-Composition-SetView (ValidLens-LensB) (ValidLens-go (mod x mid , mod y mid) deps {andCombine (modLt x mid {pow_not_zero_cv deps}) (modLt y mid {pow_not_zero_cv deps})}) cvq) ) ) else (λ {{py}} -> ifc x < mid then (λ {{px}} -> trans (cong -- We need to explicitly provide the x, otherwise agda gets confused {x = λ {f} ⦃ ff ⦄ → go (x , y) (S deps) {ins} {f} {{ff}} } -- We cong over the law, applying the transformation to go (λ (g : Lens (VQuadrant t {dep}) t) -> set g (view g cvq) cvq) -- Select only the lensC branch (FunctorExtensionality (trans (ifFalse (y < mid) py) (ifTrue (x < mid) px)))) -- Then use the property of composition to proof the law (prop-Composition-SetView (ValidLens-LensC) (ValidLens-go (mod x mid , mod y mid) deps {andCombine (modLt x mid {pow_not_zero_cv deps}) (modLt y mid {pow_not_zero_cv deps})}) cvq) ) else (λ {{px}} -> trans (cong -- We need to explicitly provide the x, otherwise agda gets confused {x = λ {f} ⦃ ff ⦄ → go (x , y) (S deps) {ins} {f} {{ff}} } -- We cong over the law, applying the transformation to go (λ (g : Lens (VQuadrant t {dep}) t) -> set g (view g cvq) cvq) -- Select only the lensD branch (FunctorExtensionality (trans (ifFalse (y < mid) py) (ifFalse (x < mid) px)))) -- Then use the property of composition to proof the law (prop-Composition-SetView (ValidLens-LensD) (ValidLens-go (mod x mid , mod y mid) deps {andCombine (modLt x mid {pow_not_zero_cv deps}) (modLt y mid {pow_not_zero_cv deps})}) cvq) ) ) where mid = pow 2 deps ValidLens-go-SetSet loc Z v1 v2 cvq@(CVQuadrant (Leaf x) {p}) = refl ValidLens-go-SetSet {t} (x , y) dep@(S deps) {ins} v1 v2 cvq@(CVQuadrant qd {p}) = ifc y < mid then (λ {{py}} -> ifc x < mid then (λ {{px}} -> trans (cong -- We need to explicitly provide the x, otherwise agda gets confused {x = λ {f} ⦃ ff ⦄ → go (x , y) (S deps) {ins} {f} {{ff}} } -- We cong over the law, applying the transformation to go (λ (g : Lens (VQuadrant t {dep}) t) -> set g v2 (set g v1 cvq)) -- Select only the lensA branch (FunctorExtensionality (trans (ifTrue (y < mid) py) (ifTrue (x < mid) px)))) (trans -- Then use the property of composition to proof the law (prop-Composition-SetSet (ValidLens-LensA) (ValidLens-go (mod x mid , mod y mid) deps {modproof}) v1 v2 cvq) -- Finally, cong back over the law, applying the transformation to go (sym $ cong {x = λ {f} ⦃ ff ⦄ → go (x , y) (S deps) {ins} {f} {{ff}}} (λ (g : Lens (VQuadrant t {dep}) t) -> set g v2 cvq) (FunctorExtensionality (trans (ifTrue (y < mid) py) (ifTrue (x < mid) px))))) ) else (λ {{px}} -> trans (cong -- We need to explicitly provide the x, otherwise agda gets confused {x = λ {f} ⦃ ff ⦄ → go (x , y) (S deps) {ins} {f} {{ff}} } -- We cong over the law, applying the transformation to go (λ (g : Lens (VQuadrant t {dep}) t) -> set g v2 (set g v1 cvq)) -- Select only the lensB branch (FunctorExtensionality (trans (ifTrue (y < mid) py) (ifFalse (x < mid) px)))) (trans -- Then use the property of composition to proof the law (prop-Composition-SetSet (ValidLens-LensB) (ValidLens-go (mod x mid , mod y mid) deps {modproof}) v1 v2 cvq) -- Finally, cong back over the law, applying the transformation to go (sym $ cong {x = λ {f} ⦃ ff ⦄ → go (x , y) (S deps) {ins} {f} {{ff}}} (λ (g : Lens (VQuadrant t {dep}) t) -> set g v2 cvq) (FunctorExtensionality (trans (ifTrue (y < mid) py) (ifFalse (x < mid) px))))) ) ) else (λ {{py}} -> ifc x < mid then (λ {{px}} -> trans (cong -- We need to explicitly provide the x, otherwise agda gets confused {x = λ {f} ⦃ ff ⦄ → go (x , y) (S deps) {ins} {f} {{ff}} } -- We cong over the law, applying the transformation to go (λ (g : Lens (VQuadrant t {dep}) t) -> set g v2 (set g v1 cvq)) -- Select only the lensC branch (FunctorExtensionality (trans (ifFalse (y < mid) py) (ifTrue (x < mid) px)))) (trans -- Then use the property of composition to proof the law (prop-Composition-SetSet (ValidLens-LensC) (ValidLens-go (mod x mid , mod y mid) deps {modproof}) v1 v2 cvq) -- Finally, cong back over the law, applying the transformation to go (sym $ cong {x = λ {f} ⦃ ff ⦄ → go (x , y) (S deps) {ins} {f} {{ff}}} (λ (g : Lens (VQuadrant t {dep}) t) -> set g v2 cvq) (FunctorExtensionality (trans (ifFalse (y < mid) py) (ifTrue (x < mid) px))))) ) else (λ {{px}} -> trans (cong -- We need to explicitly provide the x, otherwise agda gets confused {x = λ {f} ⦃ ff ⦄ → go (x , y) (S deps) {ins} {f} {{ff}} } -- We cong over the law, applying the transformation to go (λ (g : Lens (VQuadrant t {dep}) t) -> set g v2 (set g v1 cvq)) -- Select only the lensD branch (FunctorExtensionality (trans (ifFalse (y < mid) py) (ifFalse (x < mid) px)))) (trans -- Then use the property of composition to proof the law (prop-Composition-SetSet (ValidLens-LensD) (ValidLens-go (mod x mid , mod y mid) deps {modproof}) v1 v2 cvq) -- Finally, cong back over the law, applying the transformation to go (sym $ cong {x = λ {f} ⦃ ff ⦄ → go (x , y) (S deps) {ins} {f} {{ff}}} (λ (g : Lens (VQuadrant t {dep}) t) -> set g v2 cvq) (FunctorExtensionality (trans (ifFalse (y < mid) py) (ifFalse (x < mid) px))))) ) ) where mid = pow 2 deps modproof = andCombine (modLt x mid {pow_not_zero_cv deps}) (modLt y mid {pow_not_zero_cv deps})
{ "alphanum_fraction": 0.5327763929, "avg_line_length": 59.372, "ext": "agda", "hexsha": "c671be28e88076a420d56e798f9d671b47dcd0c9", "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": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "JonathanBrouwer/research-project", "max_forks_repo_path": "src/Data/QuadTree/LensProofs/Valid-LensGo.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "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": "JonathanBrouwer/research-project", "max_issues_repo_path": "src/Data/QuadTree/LensProofs/Valid-LensGo.agda", "max_line_length": 197, "max_stars_count": 1, "max_stars_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "JonathanBrouwer/research-project", "max_stars_repo_path": "src/Data/QuadTree/LensProofs/Valid-LensGo.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-25T09:10:20.000Z", "max_stars_repo_stars_event_min_datetime": "2021-05-25T09:10:20.000Z", "num_tokens": 4238, "size": 14843 }
-- open import Data.List -- open import Data.Fin open import Agda.Builtin.Nat public using (Nat; zero; suc) open import Agda.Builtin.List public using (List; []; _∷_) data Fin : Nat → Set where fzero : {n : Nat} → Fin (suc n) fsuc : {n : Nat} (i : Fin n) → Fin (suc n) foldr : ∀ {a b} {A : Set a} {B : Set b} → (A → B → B) → B → List A → B foldr c n [] = n foldr c n (x ∷ xs) = c x (foldr c n xs) length : ∀ {a} {A : Set a} → List A → Nat length = foldr (λ _ → suc) 0 lookup : ∀ {a} {A : Set a} (xs : List A) → Fin (length xs) → A lookup [] () lookup (x ∷ xs) fzero = x lookup (x ∷ xs) (fsuc i) = lookup xs i data ListD {I : Set} (T : I → Set) : List I → Set where nilD : ListD T [] consD : ∀ {x xs} → (elem : T x) → (rest : ListD T xs) → ListD T (x ∷ xs) lookupD : {I : Set} {T : I → Set} {xs : List I} → ListD T xs → (at : Fin (length xs)) → {!lookup ? ?!} lookupD xs at = {!!}
{ "alphanum_fraction": 0.5297356828, "avg_line_length": 28.375, "ext": "agda", "hexsha": "b8af4c121b59982710020ea09e081792d92bca9f", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/Issue3312.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/Issue3312.agda", "max_line_length": 102, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue3312.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": 369, "size": 908 }
------------------------------------------------------------------------ -- A delay monad with the possibility of crashing ------------------------------------------------------------------------ module Lambda.Delay-crash where import Equality.Propositional as E open import Logical-equivalence using (_⇔_) open import Prelude open import Prelude.Size import Conat E.equality-with-J as Conat open import Function-universe E.equality-with-J hiding (_∘_) open import Maybe E.equality-with-J as Maybe hiding (raw-monad) open import Monad E.equality-with-J as M using (Raw-monad; _>>=_) open import Delay-monad open import Delay-monad.Bisimilarity open import Delay-monad.Bisimilarity.Kind import Delay-monad.Monad as DM import Delay-monad.Parallel as DP import Delay-monad.Sequential as DS open import Delay-monad.Termination private variable A B C : Type i : Size f g k x y : A ------------------------------------------------------------------------ -- Types and operations -- The monad. Delay-crash : Type → Size → Type Delay-crash A i = Delay (Maybe A) i -- A raw-monad instance. (This definition is turned into an actual -- instance at the end of this module, to avoid problems with instance -- resolution.) private raw-monad′ : Raw-monad (λ A → Delay-crash A i) raw-monad′ {i = i} = _⇔_.to (M.⇔→raw⇔raw {F = MaybeT (λ A → Delay A i)} (λ _ → record { to = run; from = wrap })) it module DC {i} = Raw-monad (raw-monad′ {i = i}) -- A crashing computation. pattern crash = now nothing private -- A computation that terminates now. pattern return x = now (just x) -- Sequential composition of computations. -- -- Note that if the first argument fails to terminate, and the other -- one crashes, then the computation fails to terminate. However, if -- the first argument crashes, then the computation always crashes. infixl 6 _⊛ˢ_ _⊛ˢ_ : Delay-crash (A → B) i → Delay-crash A i → Delay-crash B i f ⊛ˢ x = f DC.>>= λ f → x DC.>>= λ x → DC.return (f x) -- Parallel composition of computations. -- -- Note that if the first argument fails to terminate, and the other -- one crashes, then the computation fails to terminate. However, if -- the first argument crashes, then the computation always crashes. infixl 6 _⊛ᵖ_ _⊛ᵖ_ : Delay-crash (A → B) i → Delay-crash A i → Delay-crash B i crash ⊛ᵖ _ = crash return f ⊛ᵖ return x = return (f x) return f ⊛ᵖ crash = crash return f ⊛ᵖ later x = later λ { .force → return f ⊛ᵖ x .force } later f ⊛ᵖ later x = later λ { .force → f .force ⊛ᵖ x .force } later f ⊛ᵖ x = later λ { .force → f .force ⊛ᵖ x } ------------------------------------------------------------------------ -- Some properties -- Bind preserves strong and weak bisimilarity and the expansion -- relation. infixl 5 _>>=-cong_ _>>=-cong_ : [ i ] x ⟨ k ⟩ y → (∀ z → [ i ] f z ⟨ k ⟩ g z) → [ i ] x DC.>>= f ⟨ k ⟩ y DC.>>= g p >>=-cong q = p DM.>>=-cong [ (λ _ → run fail ∎) , q ] -- Sequential composition preserves strong and weak bisimilarity and -- the expansion relation. infixl 6 _⊛ˢ-cong_ _⊛ˢ-cong_ : [ i ] f ⟨ k ⟩ g → [ i ] x ⟨ k ⟩ y → [ i ] f ⊛ˢ x ⟨ k ⟩ g ⊛ˢ y p ⊛ˢ-cong q = p >>=-cong λ _ → q >>=-cong λ _ → now -- Parallel composition preserves strong and weak bisimilarity and the -- expansion relation. infixl 6 _⊛ᵖ-cong_ _⊛ᵖ-cong_ : [ i ] f ⟨ k ⟩ g → [ i ] x ⟨ k ⟩ y → [ i ] f ⊛ᵖ x ⟨ k ⟩ g ⊛ᵖ y _⊛ᵖ-cong_ = λ p q → ⊛ᵖ-cong-helper _ _ p _ _ q where crash-lemma : [ i ] f ⟨ other k ⟩ crash → ∀ x → [ i ] f ⊛ᵖ x ⟨ other k ⟩ crash crash-lemma now x = now crash-lemma (laterˡ p) (now x) = laterˡ (crash-lemma p _) crash-lemma (laterˡ p) (later x) = laterˡ (crash-lemma p _) ⊛ᵖ-cong-helper : (f g : Delay-crash (A → B) ∞) → [ i ] f ⟨ k ⟩ g → (x y : Delay-crash A ∞) → [ i ] x ⟨ k ⟩ y → [ i ] f ⊛ᵖ x ⟨ k ⟩ g ⊛ᵖ y ⊛ᵖ-cong-helper crash crash now = λ _ _ _ → now ⊛ᵖ-cong-helper (return f) .(return f) now = λ where (later x) (later y) q → later λ { .force → now ⊛ᵖ-cong later⁻¹ q } crash crash now → now (return x) .(return x) now → now _ _ (laterˡ q) → laterˡ (now ⊛ᵖ-cong q) _ _ (laterʳ q) → laterʳ (now ⊛ᵖ-cong q) ⊛ᵖ-cong-helper (later f) (later g) p = λ where crash crash now → later λ { .force → later⁻¹ p ⊛ᵖ-cong now } (return x) .(return x) now → later λ { .force → later⁻¹ p ⊛ᵖ-cong now } (later x) (later y) q → later λ { .force → later⁻¹ p ⊛ᵖ-cong later⁻¹ q } _ crash (laterˡ q) → later λ { .force → later⁻¹ p ⊛ᵖ-cong q } _ (return y) (laterˡ q) → later λ { .force → later⁻¹ p ⊛ᵖ-cong q } crash _ (laterʳ q) → later λ { .force → later⁻¹ p ⊛ᵖ-cong q } (return x) _ (laterʳ q) → later λ { .force → later⁻¹ p ⊛ᵖ-cong q } ⊛ᵖ-cong-helper _ (return g) (laterˡ p) = λ where crash crash now → laterˡ (p ⊛ᵖ-cong now) (return x) .(return x) now → laterˡ (p ⊛ᵖ-cong now) (later x) (later y) q → later λ { .force → p ⊛ᵖ-cong later⁻¹ q } _ crash (laterˡ q) → laterˡ (p ⊛ᵖ-cong q) _ (return y) (laterˡ q) → laterˡ (p ⊛ᵖ-cong q) crash _ (laterʳ q) → later λ { .force → p ⊛ᵖ-cong q } (return x) _ (laterʳ q) → later λ { .force → p ⊛ᵖ-cong q } ⊛ᵖ-cong-helper (return f) _ (laterʳ p) = λ where crash crash now → laterʳ (p ⊛ᵖ-cong now) (return x) .(return x) now → laterʳ (p ⊛ᵖ-cong now) (later x) (later y) q → later λ { .force → p ⊛ᵖ-cong later⁻¹ q } _ crash (laterˡ q) → later λ { .force → p ⊛ᵖ-cong q } _ (return y) (laterˡ q) → later λ { .force → p ⊛ᵖ-cong q } crash _ (laterʳ q) → laterʳ (p ⊛ᵖ-cong q) (return x) _ (laterʳ q) → laterʳ (p ⊛ᵖ-cong q) ⊛ᵖ-cong-helper _ crash p@(laterˡ _) = λ _ _ _ → crash-lemma p _ ⊛ᵖ-cong-helper crash _ p@(laterʳ _) = λ _ _ _ → symmetric (crash-lemma (symmetric p) _) -- The monad laws. left-identity : ∀ x (f : A → Delay-crash B ∞) → [ ∞ ] DC.return x DC.>>= f ∼ f x left-identity x f = f x ∎ right-identity : (x : Delay-crash A ∞) → [ ∞ ] x DC.>>= DC.return ∼ x right-identity x = x DC.>>= DC.return ∼⟨⟩ x >>= maybe return crash ∼⟨ (x ∎) DM.>>=-cong [ (λ _ → run fail ∎) , (λ x → run (M.return x) ∎) ] ⟩ x >>= M.return ∼⟨ DM.right-identity′ _ ⟩ x ∎ associativity : (x : Delay-crash A ∞) (f : A → Delay-crash B ∞) (g : B → Delay-crash C ∞) → x DC.>>= (λ x → f x DC.>>= g) ∼ x DC.>>= f DC.>>= g associativity x f g = x DC.>>= (λ x → f x DC.>>= g) ∼⟨⟩ x >>= maybe (λ x → f x DC.>>= g) crash ∼⟨ (x ∎) DM.>>=-cong [ (λ _ → run fail ∎) , (λ x → f x DC.>>= g ∎) ] ⟩ x >>= (λ x → maybe f crash x >>= maybe g crash) ∼⟨ DM.associativity′ x _ _ ⟩ x >>= maybe f crash >>= maybe g crash ∼⟨⟩ x DC.>>= f DC.>>= g ∎ -- Use of _⟨$⟩_ does not affect the number of steps in the -- computation. steps-⟨$⟩ : Conat.[ i ] steps (f DC.⟨$⟩ x) ∼ steps x steps-⟨$⟩ {f = f} {x = x} = steps (f DC.⟨$⟩ x) Conat.≡⟨⟩∼ steps (x DC.>>= DC.return ∘ f) Conat.≡⟨⟩∼ steps (x >>= maybe (return ∘ f) crash) Conat.∼⟨ steps-cong ((x ∎) DM.>>=-cong [ (λ _ → run fail ∎) , (λ x → return (f x) ∎) ]) ⟩ steps (x >>= M.return ∘ maybe (just ∘ f) nothing) Conat.∼⟨ DM.steps-⟨$⟩ _ ⟩ steps x Conat.∎∼ -- Sequential composition is an expansion of parallel composition. ⊛ˢ≳⊛ᵖ : [ i ] f ⊛ˢ x ≳ f ⊛ᵖ x ⊛ˢ≳⊛ᵖ {f = return f} {x = return x} = now ⊛ˢ≳⊛ᵖ {f = return f} {x = crash} = now ⊛ˢ≳⊛ᵖ {f = return f} {x = later x} = later λ { .force → ⊛ˢ≳⊛ᵖ } ⊛ˢ≳⊛ᵖ {f = crash} = now ⊛ˢ≳⊛ᵖ {f = later f} {x = now x} = later λ { .force → ⊛ˢ≳⊛ᵖ } ⊛ˢ≳⊛ᵖ {f = later f} {x = later x} = later λ { .force → (f .force DC.>>= λ f → later x DC.>>= λ x → DC.return (f x)) ≳⟨ ((f .force ∎) >>=-cong λ _ → laterˡ (_ ∎)) ⟩ f .force ⊛ˢ x .force ≳⟨ ⊛ˢ≳⊛ᵖ ⟩∼ f .force ⊛ᵖ x .force ∎ } -- The computation crash is a left zero for _⊛ˢ_ and _⊛ᵖ_. crash-⊛ˢ : [ i ] crash ⊛ˢ x ∼ (crash ⦂ Delay-crash B ∞) crash-⊛ˢ = reflexive _ crash-⊛ᵖ : [ i ] crash ⊛ᵖ x ∼ (crash ⦂ Delay-crash B ∞) crash-⊛ᵖ = reflexive _ -- The computation never is a left zero for _⊛ˢ_ and _⊛ᵖ_. never-⊛ˢ : (x : Delay-crash A ∞) → [ i ] never ⊛ˢ x ∼ (never ⦂ Delay-crash B ∞) never-⊛ˢ x = later λ { .force → never-⊛ˢ x } never-⊛ᵖ : (x : Delay-crash A ∞) → [ i ] never ⊛ᵖ x ∼ (never ⦂ Delay-crash B ∞) never-⊛ᵖ (now x) = later λ { .force → never-⊛ᵖ (now x) } never-⊛ᵖ (later x) = later λ { .force → never-⊛ᵖ _ } -- The computation never is a right zero for _⊛ˢ_ and _⊛ᵖ_ if the left -- computation does not crash. ⊛ˢ-never : ¬ f ≈ crash → [ i ] f ⊛ˢ never ∼ never ⊛ˢ-never {f = return _} p = later λ { .force → ⊛ˢ-never p } ⊛ˢ-never {f = later _} p = later λ { .force → ⊛ˢ-never (p ∘ laterˡ) } ⊛ˢ-never {f = crash} p = ⊥-elim (p (_ ∎)) ⊛ᵖ-never : ¬ f ≈ crash → [ i ] f ⊛ᵖ never ∼ never ⊛ᵖ-never {f = return _} p = later λ { .force → ⊛ᵖ-never p } ⊛ᵖ-never {f = later _} p = later λ { .force → ⊛ᵖ-never (p ∘ laterˡ) } ⊛ᵖ-never {f = crash} p = ⊥-elim (p (_ ∎)) -- The computation crash is a right zero for _⊛ˢ_ and _⊛ᵖ_ (up to -- expansion) if the left computation terminates. ⊛ˢ-crash : f ⇓ g → [ i ] f ⊛ˢ crash ≳ crash ⊛ˢ-crash (now {x = nothing}) = now ⊛ˢ-crash (now {x = just _}) = now ⊛ˢ-crash (laterʳ p) = laterˡ (⊛ˢ-crash p) ⊛ᵖ-crash : f ⇓ g → [ i ] f ⊛ᵖ crash ≳ crash ⊛ᵖ-crash (now {x = nothing}) = now ⊛ᵖ-crash (now {x = just _}) = now ⊛ᵖ-crash (laterʳ p) = laterˡ (⊛ᵖ-crash p) -- The _⊛ᵖ_ and _⊛ˢ_ operators are not (kind of) commutative. ¬-⊛ᵖ-comm : ¬ (∀ {f : Delay-crash (A → B) ∞} {x} → f ⊛ᵖ x ≈ flip _$_ DC.⟨$⟩ x ⊛ᵖ f) ¬-⊛ᵖ-comm {A = A} {B = B} = (∀ {f : Delay-crash (A → B) ∞} {x} → f ⊛ᵖ x ≈ flip _$_ DC.⟨$⟩ x ⊛ᵖ f) ↝⟨ (λ hyp → hyp {f = crash} {x = never}) ⟩ crash ≈ flip _$_ DC.⟨$⟩ never ⊛ᵖ crash ↝⟨ flip transitive-∞∼ʳ lemma ⟩ crash ≈ never ↝⟨ now≉never ⟩□ ⊥ □ where lemma : [ i ] flip _$_ DC.⟨$⟩ never ⊛ᵖ crash ∼ never lemma = later λ { .force → lemma } ¬-⊛ˢ-comm : ¬ (∀ {f : Delay-crash (A → B) ∞} {x} → f ⊛ˢ x ≈ flip _$_ DC.⟨$⟩ x ⊛ˢ f) ¬-⊛ˢ-comm {A = A} {B = B} = (∀ {f : Delay-crash (A → B) ∞} {x} → f ⊛ˢ x ≈ flip _$_ DC.⟨$⟩ x ⊛ˢ f) ↝⟨ (λ hyp {f x} → f ⊛ᵖ x ≈⟨ symmetric (≳→ ⊛ˢ≳⊛ᵖ) ⟩ f ⊛ˢ x ≈⟨ hyp {f = f} {x = x} ⟩ flip _$_ DC.⟨$⟩ x ⊛ˢ f ≳⟨ ⊛ˢ≳⊛ᵖ ⟩ flip _$_ DC.⟨$⟩ x ⊛ᵖ f ∎) ⟩ (∀ {f : Delay-crash (A → B) ∞} {x} → f ⊛ᵖ x ≈ flip _$_ DC.⟨$⟩ x ⊛ᵖ f) ↝⟨ ¬-⊛ᵖ-comm ⟩□ ⊥ □ ------------------------------------------------------------------------ -- The instance declaration -- A raw-monad instance. instance raw-monad : Raw-monad (λ A → Delay-crash A i) raw-monad = raw-monad′
{ "alphanum_fraction": 0.4807935838, "avg_line_length": 37.3659305994, "ext": "agda", "hexsha": "66d7a3efd8c88d63caf57d3d176c5f65c933c6dc", "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": "dec8cd2d2851340840de25acb0feb78f7b5ffe96", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/definitional-interpreters", "max_forks_repo_path": "src/Lambda/Delay-crash.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "dec8cd2d2851340840de25acb0feb78f7b5ffe96", "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/definitional-interpreters", "max_issues_repo_path": "src/Lambda/Delay-crash.agda", "max_line_length": 123, "max_stars_count": null, "max_stars_repo_head_hexsha": "dec8cd2d2851340840de25acb0feb78f7b5ffe96", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/definitional-interpreters", "max_stars_repo_path": "src/Lambda/Delay-crash.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4678, "size": 11845 }
module test where open import Data.Sum.Base postulate X : Set a : X b : X p : X → X → Set φ : (x : X) → (p x a ⊎ p x b) example : (x : X) →
{ "alphanum_fraction": 0.475308642, "avg_line_length": 14.7272727273, "ext": "agda", "hexsha": "e26eaea3c089983af6f5e72e98bddb36476b8ffe", "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": "92359922bd401a4fe07c3a9ab5e29b4c6338b69e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lexpk/Proofs-as-Programs-in-Classical-Logic", "max_forks_repo_path": "Experiments/test.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "92359922bd401a4fe07c3a9ab5e29b4c6338b69e", "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": "lexpk/Proofs-as-Programs-in-Classical-Logic", "max_issues_repo_path": "Experiments/test.agda", "max_line_length": 33, "max_stars_count": null, "max_stars_repo_head_hexsha": "92359922bd401a4fe07c3a9ab5e29b4c6338b69e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lexpk/Proofs-as-Programs-in-Classical-Logic", "max_stars_repo_path": "Experiments/test.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 65, "size": 162 }
{-# OPTIONS --cubical --safe --guardedness #-} module Data.PolyP.Currying where open import Prelude hiding (_⟨_⟩_) open import Data.Vec.Iterated open import Data.PolyP.Universe Curriedⁿ : ℕ → Type₁ Curriedⁿ zero = Type Curriedⁿ (suc n) = Type → Curriedⁿ n _~_ : ∀ {n} → (Params n → Type) → Curriedⁿ n _~_ {n = zero} f = f [] _~_ {n = suc n} f A = _~_ {n = n} (f ∘ (A ∷_))
{ "alphanum_fraction": 0.624671916, "avg_line_length": 22.4117647059, "ext": "agda", "hexsha": "9427bb7acf9e9ce95f9603cd3e17f5f5e104dbe0", "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/PolyP/Currying.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/PolyP/Currying.agda", "max_line_length": 46, "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/PolyP/Currying.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": 151, "size": 381 }
{-# OPTIONS --universe-polymorphism #-} open import FRP.JS.Bool using ( Bool ; true ; false ; if_then_else_ ; not ; _∧_ ) module FRP.JS.True where record ⊤ : Set where constructor tt data ⊥ : Set where contradiction : ∀ {α} {A : Set α} → ⊥ → A contradiction () True : Bool → Set True true = ⊤ True false = ⊥ False : Bool → Set False b = True b → ⊥ ∧-intro : ∀ {a b} → True a → True b → True (a ∧ b) ∧-intro {false} () b ∧-intro {true} {false} tt () ∧-intro {true} {true} tt tt = tt ∧-elim₁ : ∀ {a b} → True (a ∧ b) → True a ∧-elim₁ {false} () ∧-elim₁ {true} b = tt ∧-elim₂ : ∀ {a b} → True (a ∧ b) → True b ∧-elim₂ {false} () ∧-elim₂ {true} b = b data Dec (b : Bool) : Set where yes : True b → Dec b no : False b → Dec b {-# COMPILED_JS Dec function(x,v) { if (x) { return v.yes(null); } else { return v.no(null); } } #-} {-# COMPILED_JS yes true #-} {-# COMPILED_JS no false #-} dec : ∀ b → Dec b dec true = yes tt dec false = no contradiction
{ "alphanum_fraction": 0.5630081301, "avg_line_length": 20.5, "ext": "agda", "hexsha": "50206c3d585f49f311cb8baf6c38a81f1b47c9b3", "lang": "Agda", "max_forks_count": 7, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z", "max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z", "max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_forks_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_forks_repo_name": "agda/agda-frp-js", "max_forks_repo_path": "src/agda/FRP/JS/True.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_issues_repo_name": "agda/agda-frp-js", "max_issues_repo_path": "src/agda/FRP/JS/True.agda", "max_line_length": 81, "max_stars_count": 63, "max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_stars_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_stars_repo_name": "agda/agda-frp-js", "max_stars_repo_path": "src/agda/FRP/JS/True.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z", "num_tokens": 375, "size": 984 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Sizes for Agda's sized types ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe --sized-types #-} module Size where open import Agda.Builtin.Size public renaming ( SizeU to SizeUniv ) -- sort SizeUniv using ( Size -- Size : SizeUniv ; Size<_ -- Size<_ : Size → SizeUniv ; ↑_ -- ↑_ : Size → Size ; ∞ ) -- ∞ : Size
{ "alphanum_fraction": 0.3569023569, "avg_line_length": 34.9411764706, "ext": "agda", "hexsha": "8441a4bed79c83b24636a28cc548fbab7e41cd82", "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": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Size.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Size.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Size.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 123, "size": 594 }
{-# OPTIONS --without-K --exact-split --rewriting #-} open import lib.Basics open import lib.types.Truncation open import lib.Function2 open import lib.NType2 open import Graphs.Definition open import Coequalizers.Definition open import Util.Misc module Coequalizers.Misc where module _ {i j : ULevel} {E : Type i} {V : Type j} ⦃ gph : Graph E V ⦄ where inh-coeq-to-vertex : ∥ V / E ∥ → ∥ V ∥ inh-coeq-to-vertex = Trunc-rec (Coeq-rec [_] (λ _ → prop-has-all-paths _ _)) quotient-map-is-surj : is-surj (c[_] :> (V → V / E)) quotient-map-is-surj = Coeq-elim (λ v → ∥ hfiber c[_] v ∥) (λ v → [ v , idp ]) λ _ → prop-has-all-paths-↓
{ "alphanum_fraction": 0.6562986003, "avg_line_length": 30.619047619, "ext": "agda", "hexsha": "a39a563c5574e047d533242934c4f58d7efeaef5", "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": "84be713b8a8e41ea6f01f8ccf7251ebbbd73ad5d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "awswan/nielsenschreier-hott", "max_forks_repo_path": "main/Coequalizers/Misc.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "84be713b8a8e41ea6f01f8ccf7251ebbbd73ad5d", "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": "awswan/nielsenschreier-hott", "max_issues_repo_path": "main/Coequalizers/Misc.agda", "max_line_length": 107, "max_stars_count": null, "max_stars_repo_head_hexsha": "84be713b8a8e41ea6f01f8ccf7251ebbbd73ad5d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "awswan/nielsenschreier-hott", "max_stars_repo_path": "main/Coequalizers/Misc.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 223, "size": 643 }
-- Andreas, 2016-10-09, re issue #2223 -- The front matter or module telescope of the top-level module -- may generate level constraints that live in no module! {-# OPTIONS -v tc.constr.add:45 #-} -- KEEP! open import Common.Level open import Issue2223.Setoids -- import necessary! module _ (S : Setoid lzero lzero) (a : Setoid.Carrier S) (_ : a ⟨ Setoid._≈_ S ⟩ a) where -- PROBLEM WAS: internal error in debug printing. -- Should work now.
{ "alphanum_fraction": 0.7046979866, "avg_line_length": 29.8, "ext": "agda", "hexsha": "812b4164ca7553b5ff9eb0f44a18d69a7d347190", "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/Issue2223-constraints-in-frontmatter.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/Issue2223-constraints-in-frontmatter.agda", "max_line_length": 89, "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/Issue2223-constraints-in-frontmatter.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": 126, "size": 447 }
module objectsInAgdaUnsized where open import Data.Product open import interactiveProgramsAgdaUnsized hiding (main) open import NativeIO open import Data.String.Base record Interface : Set₁ where field Method : Set Result : (m : Method) → Set open Interface public record Object (I : Interface) : Set where coinductive field objectMethod : (m : Method I) → Result I m × Object I open Object public record IOObject (Iᵢₒ : IOInterface) (I : Interface) : Set where coinductive field method : (m : Method I) → IO Iᵢₒ (Result I m × IOObject Iᵢₒ I) open IOObject public data CellMethod A : Set where get : CellMethod A put : A → CellMethod A CellResult : ∀{A} → CellMethod A → Set CellResult {A} get = A CellResult (put _) = Unit cellI : (A : Set) → Interface Method (cellI A) = CellMethod A Result (cellI A) m = CellResult m {- A cell as an Object -} Cell : Set → Set Cell A = Object (cellI A) cell : {A : Set} → A → Cell A objectMethod (cell a) get = a , cell a objectMethod (cell a) (put a') = unit , cell a' {- A cell as an IOObject -} CellC : Set CellC = IOObject ConsoleInterface (cellI String) simpleCell : (s : String) → CellC force (method (simpleCell s) get) = do' (putStrLn ("getting (" ++ s ++ ")")) λ _ → delay (return' (s , simpleCell s)) force (method (simpleCell s) (put x)) = do' (putStrLn ("putting (" ++ x ++ ")")) λ _ → delay (return' (_ , simpleCell x)) {-# TERMINATING #-} program : CellC → IOConsole Unit force (program c₁) = do' getLine λ s → method c₁ (put s) >>= λ{ (_ , c₂) → method c₂ get >>= λ{ (s' , c₃) → do (putStrLn s') λ _ → (program c₃)}} main : NativeIO Unit main = translateIOConsole (program (simpleCell "Start"))
{ "alphanum_fraction": 0.6166574738, "avg_line_length": 24.1733333333, "ext": "agda", "hexsha": "a3076d85b9a601faf54c056a819d0138af002233", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/objectsInAgdaUnsized.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "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": "agda/ooAgda", "max_issues_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/objectsInAgdaUnsized.agda", "max_line_length": 70, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/objectsInAgdaUnsized.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 587, "size": 1813 }
{- This is a rather literal translation of Martin Hötzel-Escardó's structure identity principle into cubical Agda. See https://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html#sns All the needed preliminary results from the lecture notes are stated and proven in this file. It would be interesting to compare the proves with the one in Cubical.Foundations.SIP -} {-# OPTIONS --cubical --safe #-} module Cubical.Experiments.EscardoSIP where open import Cubical.Core.Everything open import Cubical.Foundations.Everything open import Cubical.Foundations.HAEquiv open import Cubical.Data.Sigma.Properties private variable ℓ ℓ' ℓ'' : Level -- We prove several useful equalities and equivalences between Σ-types all the proofs are taken from -- Martin Hötzel-Escardó's lecture notes. -- The next result is just a reformulation of pathSigma≡sigmaPath from Sigma.Properties. Σ-≡-≃ : {X : Type ℓ} {A : X → Type ℓ'} → (σ τ : Σ X A) → ((σ ≡ τ) ≃ (Σ[ p ∈ (σ .fst) ≡ (τ .fst) ] (subst A p (σ .snd) ≡ (τ .snd)))) Σ-≡-≃ {A = A} σ τ = pathToEquiv (pathSigma≡sigmaPath σ τ) -- This cubical proof is much shorter than in HoTT but requires that A, B live in the same universe. Σ-cong : {X : Type ℓ} {A B : X → Type ℓ'} → ((x : X) → (A x ≡ B x)) → (Σ X A ≡ Σ X B) Σ-cong {X = X} p i = Σ[ x ∈ X ] (p x i) -- Two lemmas for the more general formulation using equivalences NatΣ : {X : Type ℓ} {A : X → Type ℓ'} {B : X → Type ℓ''} → ((x : X) → (A x) → (B x)) → (Σ X A) → (Σ X B) NatΣ τ (x , a) = (x , τ x a) Σ-to-PathP : {X : Type ℓ} {A : X → Type ℓ'} {x : X} {a b : A x} → (a ≡ b) → PathP (λ i → Σ X A) (x , a) (x , b) Σ-to-PathP {x = x} p i = (x , p i) Σ-cong-≃ : {X : Type ℓ} {A : X → Type ℓ'} {B : X → Type ℓ''} → ((x : X) → (A x ≃ B x)) → (Σ X A ≃ Σ X B) Σ-cong-≃ {X = X} {A = A} {B = B} φ = isoToEquiv (iso (NatΣ f) (NatΣ g) NatΣ-ε NatΣ-η) where f : (x : X) → (A x) → (B x) f x = equivFun (φ x) g : (x : X) → (B x) → (A x) g x = equivFun (invEquiv (φ x)) η : (x : X) → (a : A x) → (g x) ((f x) a) ≡ a η x = retEq (invEquiv (φ x)) ε : (x : X) → (b : B x) → f x (g x b) ≡ b ε x = secEq (invEquiv (φ x)) NatΣ-η : (w : Σ X A) → NatΣ g (NatΣ f w) ≡ w NatΣ-η (x , a) = (x , g x (f x a)) ≡⟨ Σ-to-PathP (η x a) ⟩ (x , a) ∎ NatΣ-ε : (u : Σ X B) → NatΣ f (NatΣ g u) ≡ u NatΣ-ε (x , b) = (x , f x (g x b)) ≡⟨ Σ-to-PathP (ε x b) ⟩ (x , b) ∎ -- The next result is stated a bit awkwardly but is rather straightforward to prove. Σ-change-of-variable-Iso : {X : Type ℓ} {Y : Type ℓ'} {A : Y → Type ℓ''} (f : X → Y) → (isHAEquiv f) → (Iso (Σ X (A ∘ f)) (Σ Y A)) Σ-change-of-variable-Iso {ℓ = ℓ} {ℓ' = ℓ'} {X = X} {Y = Y} {A = A} f isHAEquivf = iso φ ψ φψ ψφ where g : Y → X g = isHAEquiv.g isHAEquivf ε : (x : X) → (g (f x)) ≡ x ε = isHAEquiv.sec isHAEquivf η : (y : Y) → f (g y) ≡ y η = isHAEquiv.ret isHAEquivf τ : (x : X) → cong f (ε x) ≡ η (f x) τ = isHAEquiv.com isHAEquivf φ : (Σ X (A ∘ f)) → (Σ Y A) φ (x , a) = (f x , a) ψ : (Σ Y A) → (Σ X (A ∘ f)) ψ (y , a) = (g y , subst A (sym (η y)) a) φψ : (z : (Σ Y A)) → φ (ψ z) ≡ z φψ (y , a) = sigmaPath→pathSigma (φ (ψ (y , a))) (y , a) (η y , transportTransport⁻ (λ i → A (η y i)) a) -- last term proves transp (λ i → A (η y i)) i0 (transp (λ i → A (η y (~ i))) i0 a) ≡ a ψφ : (z : (Σ X (A ∘ f))) → ψ (φ z) ≡ z ψφ (x , a) = sigmaPath→pathSigma (ψ (φ (x , a))) (x , a) (ε x , q) where b : A (f (g (f x))) b = (transp (λ i → A (η (f x) (~ i))) i0 a) q : transp (λ i → A (f (ε x i))) i0 (transp (λ i → A (η (f x) (~ i))) i0 a) ≡ a q = transp (λ i → A (f (ε x i))) i0 b ≡⟨ S ⟩ transp (λ i → A (η (f x) i)) i0 b ≡⟨ transportTransport⁻ (λ i → A (η (f x) i)) a ⟩ a ∎ where S : (transp (λ i → A (f (ε x i))) i0 b) ≡ (transp (λ i → A (η (f x) i)) i0 b) S = subst (λ p → (transp (λ i → A (f (ε x i))) i0 b) ≡ (transp (λ i → A (p i)) i0 b)) (τ x) refl -- Using the result above we can prove the following quite useful result. Σ-change-of-variable-≃ : {X : Type ℓ} {Y : Type ℓ'} {A : Y → Type ℓ''} (f : X → Y) → (isEquiv f) → ((Σ X (A ∘ f)) ≃ (Σ Y A)) Σ-change-of-variable-≃ f isEquivf = isoToEquiv (Σ-change-of-variable-Iso f (equiv→HAEquiv (f , isEquivf) .snd)) Σ-assoc-Iso : (X : Type ℓ) (A : X → Type ℓ') (P : Σ X A → Type ℓ'') → (Iso (Σ (Σ X A) P) (Σ[ x ∈ X ] (Σ[ a ∈ A x ] P (x , a)))) Σ-assoc-Iso X A P = iso f g ε η where f : (Σ (Σ X A) P) → (Σ[ x ∈ X ] (Σ[ a ∈ A x ] P (x , a))) f ((x , a) , p) = (x , (a , p)) g : (Σ[ x ∈ X ] (Σ[ a ∈ A x ] P (x , a))) → (Σ (Σ X A) P) g (x , (a , p)) = ((x , a) , p) ε : section f g ε n = refl η : retract f g η m = refl Σ-assoc-≃ : (X : Type ℓ) (A : X → Type ℓ') (P : Σ X A → Type ℓ'') → (Σ (Σ X A) P) ≃ (Σ[ x ∈ X ] (Σ[ a ∈ A x ] P (x , a))) Σ-assoc-≃ X A P = isoToEquiv (Σ-assoc-Iso X A P) -- A structure is a type-family S : Type ℓ → Type ℓ', i.e. for X : Type ℓ and s : S X, the pair (X , s) -- means that X is equipped with a S-structure, which is witnessed by s. -- An S-structure should have a notion of S-homomorphism, or rather S-isomorphism. -- This will be implemented by a function ι -- that gives us for any two types with S-structure (X , s) and (Y , t) a family: -- ι (X , s) (Y , t) : (X ≃ Y) → Type ℓ'' -- Note that for any equivalence (f , e) : X ≃ Y the type ι (X , s) (Y , t) (f , e) need not to be -- a proposition. Indeed this type should correspond to the ways s and t can be identified -- as S-structures. This we call a standard notion of structure. SNS : (S : Type ℓ → Type ℓ') → ((A B : Σ[ X ∈ (Type ℓ) ] (S X)) → ((A .fst) ≃ (B .fst)) → Type ℓ'') → Type (ℓ-max (ℓ-max(ℓ-suc ℓ) ℓ') ℓ'') SNS {ℓ = ℓ} S ι = ∀ {X : (Type ℓ)} (s t : S X) → ((s ≡ t) ≃ ι (X , s) (X , t) (idEquiv X)) -- Escardo's ρ can actually be defined from this: ρ : {S : Type ℓ → Type ℓ'} → {ι : (A B : Σ[ X ∈ (Type ℓ) ] (S X)) → ((A .fst) ≃ (B .fst)) → Type ℓ''} → (SNS S ι) → (A : Σ[ X ∈ (Type ℓ) ] (S X)) → (ι A A (idEquiv (A .fst))) ρ θ A = equivFun (θ (A .snd) (A .snd)) refl -- We introduce the notation a bit differently: _≃[_]_ : {S : Type ℓ → Type ℓ'} → (Σ[ X ∈ (Type ℓ) ] (S X)) → (ι : (A B : Σ[ X ∈ (Type ℓ) ] (S X)) → ((A .fst) ≃ (B .fst)) → Type ℓ'') → (Σ[ X ∈ (Type ℓ) ] (S X)) → (Type (ℓ-max ℓ ℓ'')) A ≃[ ι ] B = Σ[ f ∈ ((A .fst) ≃ (B. fst)) ] (ι A B f) Id→homEq : (S : Type ℓ → Type ℓ') → (ι : (A B : Σ[ X ∈ (Type ℓ) ] (S X)) → ((A .fst) ≃ (B .fst)) → Type ℓ'') → (ρ : (A : Σ[ X ∈ (Type ℓ) ] (S X)) → ι A A (idEquiv (A .fst))) → (A B : Σ[ X ∈ (Type ℓ) ] (S X)) → A ≡ B → (A ≃[ ι ] B) Id→homEq S ι ρ A B p = J (λ y x → A ≃[ ι ] y) (idEquiv (A .fst) , ρ A) p -- Use a PathP version of Escardó's homomorphism-lemma hom-lemma-dep : (S : Type ℓ → Type ℓ') → (ι : (A B : Σ[ X ∈ (Type ℓ) ] (S X)) → ((A .fst) ≃ (B .fst)) → Type ℓ'') → (θ : SNS S ι) → (A B : Σ[ X ∈ (Type ℓ) ] (S X)) → (p : (A .fst) ≡ (B. fst)) → (PathP (λ i → S (p i)) (A .snd) (B .snd)) ≃ (ι A B (pathToEquiv p)) hom-lemma-dep S ι θ A B p = (J P (λ s → γ s) p) (B .snd) where P = (λ y x → (s : S y) → PathP (λ i → S (x i)) (A .snd) s ≃ ι A (y , s) (pathToEquiv x)) γ : (s : S (A .fst)) → ((A .snd) ≡ s) ≃ ι A ((A .fst) , s) (pathToEquiv refl) γ s = subst (λ f → ((A .snd) ≡ s) ≃ ι A ((A .fst) , s) f) (sym pathToEquivRefl) (θ (A. snd) s) -- Define the inverse of Id→homEq directly. ua-lemma : (A B : Type ℓ) (e : A ≃ B) → (pathToEquiv (ua e)) ≡ e ua-lemma A B e = EquivJ (λ b a f → (pathToEquiv (ua f)) ≡ f) (λ x → subst (λ r → pathToEquiv r ≡ idEquiv x) (sym uaIdEquiv) pathToEquivRefl) B A e homEq→Id : (S : Type ℓ → Type ℓ') → (ι : (A B : Σ[ X ∈ (Type ℓ) ] (S X)) → ((A .fst) ≃ (B .fst)) → Type ℓ'') → (θ : SNS S ι) → (A B : Σ[ X ∈ (Type ℓ) ] (S X)) → (A ≃[ ι ] B) → A ≡ B homEq→Id S ι θ A B (f , φ) = ΣPathP (p , q) where p = ua f ψ : ι A B (pathToEquiv p) ψ = subst (λ g → ι A B g) (sym (ua-lemma (A .fst) (B. fst) f)) φ q : PathP (λ i → S (p i)) (A .snd) (B .snd) q = equivFun (invEquiv (hom-lemma-dep S ι θ A B p)) ψ -- Proof of the SIP: SIP : (S : Type ℓ → Type ℓ') → (ι : (A B : Σ[ X ∈ (Type ℓ) ] (S X)) → ((A .fst) ≃ (B .fst)) → Type ℓ'') → (θ : SNS S ι) → (A B : Σ[ X ∈ (Type ℓ) ] (S X)) → ((A ≡ B) ≃ (A ≃[ ι ] B)) SIP S ι θ A B = (A ≡ B) ≃⟨ i ⟩ (Σ[ p ∈ (A .fst) ≡ (B. fst) ] PathP (λ i → S (p i)) (A .snd) (B .snd)) ≃⟨ ii ⟩ (Σ[ p ∈ (A .fst) ≡ (B. fst) ] (ι A B (pathToEquiv p))) ≃⟨ iii ⟩ (A ≃[ ι ] B) ■ where i = invEquiv Σ≡ ii = Σ-cong-≃ (hom-lemma-dep S ι θ A B) iii = Σ-change-of-variable-≃ pathToEquiv (equivIsEquiv univalence) -- A simple example: pointed types pointed-structure : Type ℓ → Type ℓ pointed-structure X = X Pointed-Type : Type (ℓ-suc ℓ) Pointed-Type {ℓ = ℓ} = Σ (Type ℓ) pointed-structure pointed-ι : (A B : Pointed-Type) → (A .fst) ≃ (B. fst) → Type ℓ pointed-ι (X , x) (Y , y) f = (equivFun f) x ≡ y pointed-is-sns : SNS {ℓ = ℓ} pointed-structure pointed-ι pointed-is-sns s t = idEquiv (s ≡ t) pointed-type-sip : (X Y : Type ℓ) (x : X) (y : Y) → (Σ[ f ∈ X ≃ Y ] (f .fst) x ≡ y) ≃ ((X , x) ≡ (Y , y)) pointed-type-sip X Y x y = invEquiv (SIP pointed-structure pointed-ι pointed-is-sns (X , x) (Y , y))
{ "alphanum_fraction": 0.4614465033, "avg_line_length": 38.6076923077, "ext": "agda", "hexsha": "31ffce97f94d24a397def688d6c3007225761a12", "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/Experiments/EscardoSIP.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/Experiments/EscardoSIP.agda", "max_line_length": 115, "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/Experiments/EscardoSIP.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4395, "size": 10038 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.ZCohomology.Base where open import Cubical.Data.Int.Base open import Cubical.Data.Nat.Base open import Cubical.Data.Sigma open import Cubical.Foundations.Pointed.Base open import Cubical.HITs.Nullification.Base open import Cubical.HITs.SetTruncation.Base open import Cubical.HITs.Sn.Base open import Cubical.HITs.S1.Base open import Cubical.HITs.Susp.Base open import Cubical.HITs.Truncation.Base private variable ℓ : Level A : Type ℓ --- Cohomology --- {- EM-spaces Kₙ from Brunerie 2016 -} coHomK : (n : ℕ) → Type₀ coHomK zero = Int coHomK (suc n) = ∥ S₊ (suc n) ∥ (2 + suc n) {- Cohomology -} coHom : (n : ℕ) → Type ℓ → Type ℓ coHom n A = ∥ (A → coHomK n) ∥₂ --- Reduced cohomology --- coHom-pt : (n : ℕ) → coHomK n coHom-pt 0 = 0 coHom-pt 1 = ∣ base ∣ coHom-pt (suc (suc n)) = ∣ north ∣ {- Pointed version of Kₙ -} coHomK-ptd : (n : ℕ) → Pointed (ℓ-zero) coHomK-ptd n = coHomK n , coHom-pt n {- Reduced cohomology -} coHomRed : (n : ℕ) → (A : Pointed ℓ) → Type ℓ coHomRed n A = ∥ A →∙ coHomK-ptd n ∥₂
{ "alphanum_fraction": 0.67063129, "avg_line_length": 23.2553191489, "ext": "agda", "hexsha": "8c75c24576ee58850f4d1fbd62455f1e170a1417", "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": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ayberkt/cubical", "max_forks_repo_path": "Cubical/ZCohomology/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "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": "ayberkt/cubical", "max_issues_repo_path": "Cubical/ZCohomology/Base.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ayberkt/cubical", "max_stars_repo_path": "Cubical/ZCohomology/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 417, "size": 1093 }
module Unsolved-meta-in-postulate where postulate P : _
{ "alphanum_fraction": 0.7894736842, "avg_line_length": 14.25, "ext": "agda", "hexsha": "4db555d4c26d6033f3e007608576d6660cc52f5d", "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/Unsolved-meta-in-postulate.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/Unsolved-meta-in-postulate.agda", "max_line_length": 39, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Unsolved-meta-in-postulate.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": 14, "size": 57 }
{-# OPTIONS --without-K --safe #-} module Data.Bits where open import Level infixr 8 0∷_ 1∷_ data Bits : Type where [] : Bits 0∷_ : Bits → Bits 1∷_ : Bits → Bits
{ "alphanum_fraction": 0.6140350877, "avg_line_length": 14.25, "ext": "agda", "hexsha": "eafdad8628561f70231662ee24622ec5137f0f23", "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/Bits.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/Bits.agda", "max_line_length": 34, "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/Bits.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": 66, "size": 171 }
module RecordPatternMatching where -- Sigma type. record Σ (A : Set) (B : A → Set) : Set where constructor _,_ field proj₁ : A proj₂ : B proj₁ open Σ _×_ : Set → Set → Set A × B = Σ A λ _ → B -- Curry and uncurry with pattern matching. curry : ∀ {A : Set} {B : A → Set} {C : Σ A B → Set} → ((p : Σ A B) → C p) → ((x : A) → (y : B x) → C (x , y)) curry f x y = f (x , y) uncurry : ∀ {A : Set} {B : A → Set} {C : Σ A B → Set} → ((x : A) → (y : B x) → C (x , y)) → ((p : Σ A B) → C p) uncurry f (x , y) = f x y -- We still have η-equality. data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x curry∘uncurry : ∀ {A : Set} {B : A → Set} {C : Σ A B → Set} → (f : (x : A) → (y : B x) → C (x , y)) → (x : A) → (y : B x) → curry {C = C} (uncurry f) x y ≡ f x y curry∘uncurry f x y = refl uncurry∘curry : ∀ {A : Set} {B : A → Set} {C : Σ A B → Set} → (f : (p : Σ A B) → C p) → (p : Σ A B) → uncurry {C = C} (curry f) p ≡ f p uncurry∘curry f p = refl -- Nested pattern matching is also possible. to : {A B C : Set} → A × (B × C) → (A × B) × C to (x , (y , z)) = ((x , y) , z) from : {A B C : Set} → (A × B) × C → A × (B × C) from ((x , y) , z) = (x , (y , z)) from∘to : {A B C : Set} (p : A × (B × C)) → from (to p) ≡ p from∘to p = refl data Bool : Set where true false : Bool data ⊥ : Set where F : Bool → Set F true = Bool F false = ⊥ foo : Σ Bool F → Bool foo (true , b) = b foo (false , ()) bar : ∀ p → F (foo p) → F (foo p) bar (true , true) = λ b → b bar (true , false) = λ () bar (false , ()) baz : (Σ Bool λ _ → Σ Bool λ _ → Bool) → Bool baz (true , (b , c)) = b baz (false , (b , c)) = c lemma : ∀ p → baz (false , p) ≡ proj₂ p lemma p = refl data ℕ : Set where zero : ℕ suc : ℕ → ℕ add : ℕ × ℕ → ℕ add (zero , n) = n add (suc m , n) = suc (add (m , n)) -- The code below used to trigger a bug: in one part of the code B was -- assumed to be reduced to an application of a record type -- constructor. data Unit : Set where unit : Unit B : Set B = Σ Unit λ _ → Unit C : B → Set₁ C (_ , _) = Set -- The code below, which involves a clause with a "swapping -- permutation", also used to trigger a bug. data P : ⊥ → ⊥ → Set where p : (x y : ⊥) → P x y Bar : (x : ⊥) → P x x → P x x → Set₁ Bar .x _ (p x .x) = Set -- Another example which used to trigger a bug: G : (Σ ⊥ λ x → Σ ⊥ λ y → x ≡ y) → Set₁ G (x , (.x , refl)) = Set -- Record patterns containing dot patterns are supported. Foo : (p₁ p₂ : B) → proj₁ p₁ ≡ proj₁ p₂ → Unit Foo (x , y) (.x , y′) refl = unit Foo-eval : (p : B) → Foo p p refl ≡ unit Foo-eval _ = refl -- Record patterns containing dot patterns as well as data type -- patterns are also supported. D : (p₁ p₂ : B) → proj₁ p₁ ≡ proj₁ p₂ → Set₁ D (x , y) (.x , unit) refl = Set
{ "alphanum_fraction": 0.4913733609, "avg_line_length": 22.4651162791, "ext": "agda", "hexsha": "49ede4a75986a9e9c28ed57c905ab9562c31403b", "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": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_path": "test/succeed/RecordPatternMatching.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "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": "np/agda-git-experiment", "max_issues_repo_path": "test/succeed/RecordPatternMatching.agda", "max_line_length": 70, "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/succeed/RecordPatternMatching.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": 1175, "size": 2898 }
module L.Base.Coproduct where -- Reexport definitions open import L.Base.Coproduct.Core public
{ "alphanum_fraction": 0.8125, "avg_line_length": 19.2, "ext": "agda", "hexsha": "bd2c2adccb3d1046832920ff30dc74ad3f4b1452", "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": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "borszag/smallib", "max_forks_repo_path": "src/L/Base/Coproduct.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_issues_repo_issues_event_max_datetime": "2020-11-09T16:40:39.000Z", "max_issues_repo_issues_event_min_datetime": "2020-10-19T10:13:16.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "borszag/smallib", "max_issues_repo_path": "src/L/Base/Coproduct.agda", "max_line_length": 40, "max_stars_count": null, "max_stars_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "borszag/smallib", "max_stars_repo_path": "src/L/Base/Coproduct.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 23, "size": 96 }
module #5 where open import Level open import Data.Product open import Data.Bool open import Relation.Binary.PropositionalEquality {- Exercise 1.5. Show that if we define A + B :≡ ∑(x:2) rec2(U, A, B, x), then we can give a definition of indA+B for which the definitional equalities stated in §1.7 hold. -} rec₂ : ∀{c}{C : Set c} → C → C → Bool → C rec₂ c₀ c₁ true = c₁ rec₂ c₀ c₁ false = c₀ ind₂ : ∀{c}(C : Bool → Set c) → C false → C true → (x : Bool) → C x ind₂ C c₀ c₁ true = c₁ ind₂ C c₀ c₁ false = c₀ _⊎_ : ∀ {i} → Set i → Set i → Set _ A ⊎ B = Σ Bool λ b → if b then A else B module SumTwo {a}{A B : Set a} where inl : A → A ⊎ B inl x = true , x inr : B → A ⊎ B inr y = false , y rec-sum₂ : ∀{a b c}{A : Set a}{B : A → Set b} → (C : Σ A B -> Set c) → (f : (x : A)(y : B x) → C (x , y)) → (s : Σ A B) → C s rec-sum₂ C f (x , y) = f x y ind-sum₂ : ∀{c}(C : A ⊎ B -> Set c) → ((x : A) → C (inl x)) → ((y : B) → C (inr y)) → (u : A ⊎ B) → C u ind-sum₂ C c₁ c₀ u = rec-sum₂ C (ind₂ (λ b → (z : if b then A else B) → C (b , z)) c₀ c₁) u ind-sum₂-β₁ : ∀{c}(C : A ⊎ B -> Set c) → (f : (x : A) → C (inl x)) → (g : (y : B) → C (inr y)) → (x : A) → ind-sum₂ C f g (inl x) ≡ f x ind-sum₂-β₁ C f g x = refl ind-sum₂-β₂ : ∀{c}(C : A ⊎ B -> Set c) → (f : (x : A) → C (inl x)) → (g : (y : B) → C (inr y)) → (x : B) → ind-sum₂ C f g (inr x) ≡ g x ind-sum₂-β₂ C f g x = refl
{ "alphanum_fraction": 0.5046395432, "avg_line_length": 32.5813953488, "ext": "agda", "hexsha": "48f127a289c8e57e6a204896353c298d2daca0d5", "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": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CodaFi/HoTT-Exercises", "max_forks_repo_path": "Chapter1/#5.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "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": "CodaFi/HoTT-Exercises", "max_issues_repo_path": "Chapter1/#5.agda", "max_line_length": 137, "max_stars_count": null, "max_stars_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CodaFi/HoTT-Exercises", "max_stars_repo_path": "Chapter1/#5.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 651, "size": 1401 }
{-# OPTIONS --cubical --safe #-} module Categories.Exponential where open import Prelude hiding (_×_) open import Categories open import Categories.Product module _ {ℓ₁ ℓ₂} (C : Category ℓ₁ ℓ₂) (hasProducts : HasProducts C) where open Category C open HasProducts hasProducts module _ (Y Z : Ob) where record Exponential : Type (ℓ₁ ℓ⊔ ℓ₂) where field obj : Ob eval : C [ obj × Y , Z ] uniq : ∀ (X : Ob) (f : C [ X × Y , Z ]) → ∃![ f~ ] (C [ eval ∘ (f~ |×| Category.Id C) ] ≡ f) HasExponentials : Type (ℓ₁ ℓ⊔ ℓ₂) HasExponentials = ∀ X Y → Exponential X Y
{ "alphanum_fraction": 0.5925324675, "avg_line_length": 26.7826086957, "ext": "agda", "hexsha": "1ddb9166f697a3dc48df4ada1cc77761a36365d2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Categories/Exponential.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Categories/Exponential.agda", "max_line_length": 73, "max_stars_count": 4, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Categories/Exponential.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z", "max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z", "num_tokens": 210, "size": 616 }
------------------------------------------------------------------------ -- Some negative results related to weak bisimilarity and expansion ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} open import Prelude module Delay-monad.Bisimilarity.Negative {a} {A : Type a} where open import Equality.Propositional open import Logical-equivalence using (_⇔_) open import Prelude.Size open import Function-universe equality-with-J hiding (id; _∘_) open import Delay-monad open import Delay-monad.Bisimilarity open import Delay-monad.Termination ------------------------------------------------------------------------ -- Lemmas stating that functions of certain types can be defined iff A -- is uninhabited -- The computation now x is an expansion of -- later (record { force = now x }) for every x : A iff A is -- uninhabited. Now≳later-now = (x : A) → now x ≳ later (record { force = now x }) now≳later-now⇔uninhabited : Now≳later-now ⇔ ¬ A now≳later-now⇔uninhabited = record { to = Now≳later-now ↝⟨ (λ hyp x → case hyp x of λ ()) ⟩□ ¬ A □ ; from = ¬ A ↝⟨ uninhabited→trivial ⟩ (∀ x y → x ≳ y) ↝⟨ (λ hyp _ → hyp _ _) ⟩□ Now≳later-now □ } -- A variant of laterˡ⁻¹ for (fully defined) expansion can be defined -- iff A is uninhabited. Laterˡ⁻¹-≳ = ∀ {x} {y : Delay A ∞} → later x ≳ y → force x ≳ y laterˡ⁻¹-≳⇔uninhabited : Laterˡ⁻¹-≳ ⇔ ¬ A laterˡ⁻¹-≳⇔uninhabited = record { to = Laterˡ⁻¹-≳ ↝⟨ (λ hyp _ → hyp (reflexive _)) ⟩ Now≳later-now ↝⟨ _⇔_.to now≳later-now⇔uninhabited ⟩□ ¬ A □ ; from = ¬ A ↝⟨ uninhabited→trivial ⟩ (∀ x y → x ≳ y) ↝⟨ (λ hyp {_ _} _ → hyp _ _) ⟩□ Laterˡ⁻¹-≳ □ } -- The following variants of transitivity can be proved iff A is -- uninhabited. Transitivity-≈≳≳ = {x y z : Delay A ∞} → x ≈ y → y ≳ z → x ≳ z Transitivity-≳≈≳ = {x y z : Delay A ∞} → x ≳ y → y ≈ z → x ≳ z transitive-≈≳≳⇔uninhabited : Transitivity-≈≳≳ ⇔ ¬ A transitive-≈≳≳⇔uninhabited = record { to = Transitivity-≈≳≳ ↝⟨ (λ trans → trans (laterʳ (reflexive _))) ⟩ Laterˡ⁻¹-≳ ↝⟨ _⇔_.to laterˡ⁻¹-≳⇔uninhabited ⟩□ ¬ A □ ; from = ¬ A ↝⟨ uninhabited→trivial ⟩ (∀ x y → x ≳ y) ↝⟨ (λ hyp {_ _ _} _ _ → hyp _ _) ⟩□ Transitivity-≈≳≳ □ } transitive-≳≈≳⇔uninhabited : Transitivity-≳≈≳ ⇔ ¬ A transitive-≳≈≳⇔uninhabited = record { to = Transitivity-≳≈≳ ↝⟨ (λ trans {_ y} lx≳y → later⁻¹ {y = record { force = y }} (trans lx≳y (laterʳ (reflexive _)))) ⟩ Laterˡ⁻¹-≳ ↝⟨ _⇔_.to laterˡ⁻¹-≳⇔uninhabited ⟩□ ¬ A □ ; from = ¬ A ↝⟨ uninhabited→trivial ⟩ (∀ x y → x ≳ y) ↝⟨ (λ hyp {_ _ _} _ _ → hyp _ _) ⟩□ Transitivity-≳≈≳ □ } ------------------------------------------------------------------------ -- Lemmas stating that certain size-preserving functions can be -- defined iff A is uninhabited -- A variant of laterˡ⁻¹ in which one occurrence of weak bisimilarity -- is replaced by strong bisimilarity, and both arguments are -- specialised, can be made size-preserving iff A is uninhabited. -- -- This lemma is used to prove all other similar results below -- (directly or indirectly), with the exception that an alternative, -- more direct proof is also given for one of the results. Laterˡ⁻¹-∼≈ = ∀ {i} {x : A} → [ i ] later (λ { .force → now x }) ∼ never → [ i ] now x ≈ never size-preserving-laterˡ⁻¹-∼≈⇔uninhabited : Laterˡ⁻¹-∼≈ ⇔ ¬ A size-preserving-laterˡ⁻¹-∼≈⇔uninhabited = record { to = Laterˡ⁻¹-∼≈ ↝⟨ (λ laterˡ⁻¹-∼≈ x → contradiction (laterˡ⁻¹-∼≈ {_}) x ∞) ⟩□ ¬ A □ ; from = ¬ A ↝⟨ uninhabited→trivial ⟩ (∀ x y → x ≈ y) ↝⟨ (λ trivial {_ _} _ → trivial _ _) ⟩□ Laterˡ⁻¹-∼≈ □ } where module _ (laterˡ⁻¹-∼≈ : Laterˡ⁻¹-∼≈) (x : A) where mutual now≈never : ∀ {i} → [ i ] now x ≈ never now≈never = laterˡ⁻¹-∼≈ (later now∼never) now∼never : ∀ {i} → [ i ] now x ∼′ never force now∼never {j = j} = ⊥-elim (contradiction j) contradiction : Size → ⊥ contradiction i = now≉never (now≈never {i = i}) -- A variant of Laterˡ⁻¹-∼≈ which it is sometimes easier to work with. Laterˡ⁻¹-∼≈′ = ∀ {i} {x : A} → [ i ] later (record { force = now x }) ∼ never → [ i ] now x ≈ never size-preserving-laterˡ⁻¹-∼≈′⇔uninhabited : Laterˡ⁻¹-∼≈′ ⇔ ¬ A size-preserving-laterˡ⁻¹-∼≈′⇔uninhabited = Laterˡ⁻¹-∼≈′ ↝⟨ record { to = _∘ transitive-∼ʳ (later λ { .force → now }) ; from = _∘ transitive-∼ʳ (later λ { .force → now }) } ⟩ Laterˡ⁻¹-∼≈ ↝⟨ size-preserving-laterˡ⁻¹-∼≈⇔uninhabited ⟩□ ¬ A □ -- A variant of laterʳ⁻¹ for weak bisimilarity in which one occurrence -- of weak bisimilarity is replaced by strong bisimilarity, and both -- arguments are specialised, can be made size-preserving iff A is -- uninhabited. Laterʳ⁻¹-∼≈ = ∀ {i} {x : A} → [ i ] never ∼ later (record { force = now x }) → [ i ] never ≈ now x size-preserving-laterʳ⁻¹-∼≈⇔uninhabited : Laterʳ⁻¹-∼≈ ⇔ ¬ A size-preserving-laterʳ⁻¹-∼≈⇔uninhabited = Laterʳ⁻¹-∼≈ ↝⟨ record { to = λ laterʳ⁻¹ → symmetric ∘ laterʳ⁻¹ ∘ symmetric ; from = λ laterˡ⁻¹ → symmetric ∘ laterˡ⁻¹ ∘ symmetric } ⟩ Laterˡ⁻¹-∼≈′ ↝⟨ size-preserving-laterˡ⁻¹-∼≈′⇔uninhabited ⟩□ ¬ A □ -- A variant of laterʳ⁻¹ for expansion in which one occurrence of the -- expansion relation is replaced by strong bisimilarity, and both -- arguments are specialised, can be made size-preserving iff A is -- uninhabited. Laterʳ⁻¹-∼≳ = ∀ {i} {x : A} → [ i ] never ∼ later (record { force = now x }) → [ i ] never ≳ now x size-preserving-laterʳ⁻¹-∼≳⇔uninhabited : Laterʳ⁻¹-∼≳ ⇔ ¬ A size-preserving-laterʳ⁻¹-∼≳⇔uninhabited = record { to = Laterʳ⁻¹-∼≳ ↝⟨ ≳→ ∘_ ⟩ Laterʳ⁻¹-∼≈ ↝⟨ _⇔_.to size-preserving-laterʳ⁻¹-∼≈⇔uninhabited ⟩□ ¬ A □ ; from = ¬ A ↝⟨ uninhabited→trivial ⟩ (∀ x y → x ≳ y) ↝⟨ (λ trivial {_ _} _ → trivial _ _) ⟩□ Laterʳ⁻¹-∼≳ □ } -- The function laterˡ⁻¹ can be made size-preserving iff A is -- uninhabited. Laterˡ⁻¹-≈ = ∀ {i x} {y : Delay A ∞} → [ i ] later x ≈ y → [ i ] force x ≈ y size-preserving-laterˡ⁻¹-≈⇔uninhabited : Laterˡ⁻¹-≈ ⇔ ¬ A size-preserving-laterˡ⁻¹-≈⇔uninhabited = record { to = Laterˡ⁻¹-≈ ↝⟨ _∘ ∼→ ⟩ Laterˡ⁻¹-∼≈ ↝⟨ _⇔_.to size-preserving-laterˡ⁻¹-∼≈⇔uninhabited ⟩□ ¬ A □ ; from = ¬ A ↝⟨ uninhabited→trivial ⟩ (∀ x y → x ≈ y) ↝⟨ (λ trivial {_ _ _} _ → trivial _ _) ⟩□ Laterˡ⁻¹-≈ □ } -- The function laterʳ⁻¹ can be made size-preserving for weak -- bisimilarity iff A is uninhabited. Laterʳ⁻¹-≈ = ∀ {i} {x : Delay A ∞} {y} → [ i ] x ≈ later y → [ i ] x ≈ force y size-preserving-laterʳ⁻¹-≈⇔uninhabited : Laterʳ⁻¹-≈ ⇔ ¬ A size-preserving-laterʳ⁻¹-≈⇔uninhabited = Laterʳ⁻¹-≈ ↝⟨ record { to = λ laterʳ⁻¹ → symmetric ∘ laterʳ⁻¹ ∘ symmetric ; from = λ laterˡ⁻¹ → symmetric ∘ laterˡ⁻¹ ∘ symmetric } ⟩ Laterˡ⁻¹-≈ ↝⟨ size-preserving-laterˡ⁻¹-≈⇔uninhabited ⟩□ ¬ A □ -- The function laterʳ⁻¹ can be made size-preserving for expansion iff -- A is uninhabited. Laterʳ⁻¹-≳ = ∀ {i} {x : Delay A ∞} {y} → [ i ] x ≳ later y → [ i ] x ≳ force y size-preserving-laterʳ⁻¹-≳⇔uninhabited : Laterʳ⁻¹-≳ ⇔ ¬ A size-preserving-laterʳ⁻¹-≳⇔uninhabited = record { to = Laterʳ⁻¹-≳ ↝⟨ _∘ ∼→ ⟩ Laterʳ⁻¹-∼≳ ↝⟨ _⇔_.to size-preserving-laterʳ⁻¹-∼≳⇔uninhabited ⟩□ ¬ A □ ; from = ¬ A ↝⟨ uninhabited→trivial ⟩ (∀ x y → x ≳ y) ↝⟨ (λ trivial {_ _ _} _ → trivial _ _) ⟩□ Laterʳ⁻¹-≳ □ } -- A variant of ⇓-respects-≈ in which _≈_ is replaced by _∼_ can be -- made size-preserving in the second argument iff A is uninhabited. ⇓-Respects-∼ʳ = ∀ {i x y} {z : A} → x ⇓ z → [ i ] x ∼ y → Terminates i y z size-preserving-⇓-respects-∼ʳ⇔uninhabited : ⇓-Respects-∼ʳ ⇔ ¬ A size-preserving-⇓-respects-∼ʳ⇔uninhabited = record { to = ⇓-Respects-∼ʳ ↝⟨ (λ resp → resp (laterʳ now)) ⟩ Laterˡ⁻¹-∼≈ ↝⟨ _⇔_.to size-preserving-laterˡ⁻¹-∼≈⇔uninhabited ⟩ ¬ A □ ; from = ¬ A ↝⟨ uninhabited→trivial ⟩ (∀ x y → x ≈ y) ↝⟨ (λ trivial {_ _ _ _} _ _ → trivial _ _) ⟩□ ⇓-Respects-∼ʳ □ } -- The lemma ⇓-respects-≈ can be made size-preserving in the second -- argument iff A is uninhabited. ⇓-Respects-≈ʳ = ∀ {i x y} {z : A} → x ⇓ z → [ i ] x ≈ y → Terminates i y z size-preserving-⇓-respects-≈ʳ⇔uninhabited : ⇓-Respects-≈ʳ ⇔ ¬ A size-preserving-⇓-respects-≈ʳ⇔uninhabited = record { to = ⇓-Respects-≈ʳ ↝⟨ (λ resp x⇓z → resp x⇓z ∘ ∼→) ⟩ ⇓-Respects-∼ʳ ↝⟨ _⇔_.to size-preserving-⇓-respects-∼ʳ⇔uninhabited ⟩□ ¬ A □ ; from = ¬ A ↝⟨ uninhabited→trivial ⟩ (∀ x y → x ≈ y) ↝⟨ (λ trivial {_ _ _ _} _ _ → trivial _ _) ⟩□ ⇓-Respects-≈ʳ □ } -- There is a transitivity-like proof, taking weak bisimilarity and -- strong bisimilarity to weak bisimilarity, that preserves the size -- of the second argument iff A is uninhabited. Transitivity-≈∼ʳ = ∀ {i} {x y z : Delay A ∞} → x ≈ y → [ i ] y ∼ z → [ i ] x ≈ z size-preserving-transitivity-≈∼ʳ⇔uninhabited : Transitivity-≈∼ʳ ⇔ ¬ A size-preserving-transitivity-≈∼ʳ⇔uninhabited = record { to = Transitivity-≈∼ʳ ↝⟨ (λ trans → trans) ⟩ ⇓-Respects-∼ʳ ↝⟨ _⇔_.to size-preserving-⇓-respects-∼ʳ⇔uninhabited ⟩□ ¬ A □ ; from = ¬ A ↝⟨ uninhabited→trivial ⟩ (∀ x y → x ≈ y) ↝⟨ (λ trivial {_ _ _ _} _ _ → trivial _ _) ⟩□ Transitivity-≈∼ʳ □ } -- There is a transitivity-like proof, taking strong bisimilarity and -- weak bisimilarity to weak bisimilarity, that preserves the size of -- the first argument iff A is uninhabited. Transitivity-∼≈ˡ = ∀ {i} {x y z : Delay A ∞} → [ i ] x ∼ y → y ≈ z → [ i ] x ≈ z size-preserving-transitivity-∼≈ˡ⇔uninhabited : Transitivity-∼≈ˡ ⇔ ¬ A size-preserving-transitivity-∼≈ˡ⇔uninhabited = Transitivity-∼≈ˡ ↝⟨ record { to = λ trans {_ _ _ _} p q → symmetric (trans (symmetric q) (symmetric p)) ; from = λ trans {_ _ _ _} p q → symmetric (trans (symmetric q) (symmetric p)) } ⟩ Transitivity-≈∼ʳ ↝⟨ size-preserving-transitivity-≈∼ʳ⇔uninhabited ⟩□ ¬ A □ -- There is a transitivity-like proof, taking strong bisimilarity and -- expansion to expansion, that preserves the size of the first -- argument iff A is uninhabited. Transitivity-∼≳ˡ = ∀ {i} {x y z : Delay A ∞} → [ i ] x ∼ y → y ≳ z → [ i ] x ≳ z size-preserving-transitivity-∼≳ˡ⇔uninhabited : Transitivity-∼≳ˡ ⇔ ¬ A size-preserving-transitivity-∼≳ˡ⇔uninhabited = record { to = Transitivity-∼≳ˡ ↝⟨ (λ trans never∼lnx → trans never∼lnx (laterˡ now)) ⟩ Laterʳ⁻¹-∼≳ ↝⟨ _⇔_.to size-preserving-laterʳ⁻¹-∼≳⇔uninhabited ⟩□ ¬ A □ ; from = ¬ A ↝⟨ uninhabited→trivial ⟩ (∀ x y → x ≳ y) ↝⟨ (λ trivial {_ _ _ _} _ _ → trivial _ _) ⟩□ Transitivity-∼≳ˡ □ } -- There is a transitivity proof for weak bisimilarity that preserves -- the size of the second argument iff A is uninhabited. Transitivity-≈ʳ = ∀ {i} {x y z : Delay A ∞} → x ≈ y → [ i ] y ≈ z → [ i ] x ≈ z size-preserving-transitivity-≈ʳ⇔uninhabited : Transitivity-≈ʳ ⇔ ¬ A size-preserving-transitivity-≈ʳ⇔uninhabited = record { to = Transitivity-≈ʳ ↝⟨ (λ trans → trans) ⟩ ⇓-Respects-≈ʳ ↝⟨ _⇔_.to size-preserving-⇓-respects-≈ʳ⇔uninhabited ⟩□ ¬ A □ ; from = ¬ A ↝⟨ uninhabited→trivial ⟩ (∀ x y → x ≈ y) ↝⟨ (λ trivial {_ _ _ _} _ _ → trivial _ _) ⟩□ Transitivity-≈ʳ □ } -- There is a transitivity proof for weak bisimilarity that preserves -- the size of the first argument iff A is uninhabited. Transitivity-≈ˡ = ∀ {i} {x y z : Delay A ∞} → [ i ] x ≈ y → y ≈ z → [ i ] x ≈ z size-preserving-transitivity-≈ˡ⇔uninhabited : Transitivity-≈ˡ ⇔ ¬ A size-preserving-transitivity-≈ˡ⇔uninhabited = Transitivity-≈ˡ ↝⟨ record { to = λ trans {_ _ _ _} p q → symmetric (trans (symmetric q) (symmetric p)) ; from = λ trans {_ _ _ _} p q → symmetric (trans (symmetric q) (symmetric p)) } ⟩ Transitivity-≈ʳ ↝⟨ size-preserving-transitivity-≈ʳ⇔uninhabited ⟩□ ¬ A □ -- There is a transitivity proof for expansion that preserves the size -- of the first argument iff A is uninhabited. Transitivity-≳ˡ = ∀ {i} {x y z : Delay A ∞} → [ i ] x ≳ y → y ≳ z → [ i ] x ≳ z size-preserving-transitivity-≳ˡ⇔uninhabited : Transitivity-≳ˡ ⇔ ¬ A size-preserving-transitivity-≳ˡ⇔uninhabited = record { to = Transitivity-≳ˡ ↝⟨ _∘ ∼→ ⟩ Transitivity-∼≳ˡ ↝⟨ _⇔_.to size-preserving-transitivity-∼≳ˡ⇔uninhabited ⟩□ ¬ A □ ; from = ¬ A ↝⟨ uninhabited→trivial ⟩ (∀ x y → x ≳ y) ↝⟨ (λ trivial {_ _ _ _} _ _ → trivial _ _) ⟩□ Transitivity-≳ˡ □ } -- There is a fully size-preserving transitivity proof for weak -- bisimilarity iff A is uninhabited. Transitivity-≈ = ∀ {i} {x y z : Delay A ∞} → [ i ] x ≈ y → [ i ] y ≈ z → [ i ] x ≈ z size-preserving-transitivity-≈⇔uninhabited : Transitivity-≈ ⇔ ¬ A size-preserving-transitivity-≈⇔uninhabited = record { to = Transitivity-≈ ↝⟨ (λ trans → trans) ⟩ Transitivity-≈ˡ ↝⟨ _⇔_.to size-preserving-transitivity-≈ˡ⇔uninhabited ⟩ ¬ A □ ; from = ¬ A ↝⟨ uninhabited→trivial ⟩ (∀ x y → x ≈ y) ↝⟨ (λ trivial {_ _ _ _} _ _ → trivial _ _) ⟩□ Transitivity-≈ □ } -- The following two lemmas provide an alternative proof of one -- direction of the previous lemma (with a small change to one of the -- types). -- If there is a transitivity proof for weak bisimilarity that is -- size-preserving in both arguments, then weak bisimilarity is -- trivial. size-preserving-transitivity-≈→trivial : (∀ {i} x {y z : Delay A ∞} → [ i ] x ≈ y → [ i ] y ≈ z → [ i ] x ≈ z) → ∀ {i} (x y : Delay A ∞) → [ i ] x ≈ y size-preserving-transitivity-≈→trivial _≈⟨_⟩ʷ_ x y = (x ≈⟨ laterʳ (x ∎ʷ) ⟩ʷ (later (λ { .force → x }) ≈⟨ later (λ { .force → size-preserving-transitivity-≈→trivial _≈⟨_⟩ʷ_ x y }) ⟩ʷ (later (λ { .force → y }) ≈⟨ laterˡ (y ∎ʷ) ⟩ʷ (y ∎ʷ)))) where _∎ʷ = reflexive -- If there is a transitivity proof for weak bisimilarity that is -- size-preserving in both arguments, then the carrier type A is not -- inhabited. size-preserving-transitivity-≈→uninhabited : (∀ {i} x {y z : Delay A ∞} → [ i ] x ≈ y → [ i ] y ≈ z → [ i ] x ≈ z) → ¬ A size-preserving-transitivity-≈→uninhabited trans x = now≉never (size-preserving-transitivity-≈→trivial trans (now x) never) -- There is a fully size-preserving transitivity proof for expansion -- iff A is uninhabited. Transitivity-≳ = ∀ {i} {x y z : Delay A ∞} → [ i ] x ≳ y → [ i ] y ≳ z → [ i ] x ≳ z size-preserving-transitivity-≳⇔uninhabited : Transitivity-≳ ⇔ ¬ A size-preserving-transitivity-≳⇔uninhabited = record { to = Transitivity-≳ ↝⟨ id ⟩ Transitivity-≳ˡ ↝⟨ _⇔_.to size-preserving-transitivity-≳ˡ⇔uninhabited ⟩□ ¬ A □ ; from = ¬ A ↝⟨ uninhabited→trivial ⟩ (∀ x y → x ≳ y) ↝⟨ (λ trivial {_ _ _ _} _ _ → trivial _ _) ⟩□ Transitivity-≳ □ } -- There is a transitivity-like proof, taking expansion and weak -- bisimilarity to weak bisimilarity, that preserves the size of the -- first argument iff A is uninhabited. Transitivity-≳≈ˡ = ∀ {i} {x y z : Delay A ∞} → [ i ] x ≳ y → y ≈ z → [ i ] x ≈ z size-preserving-transitivity-≳≈ˡ⇔uninhabited : Transitivity-≳≈ˡ ⇔ ¬ A size-preserving-transitivity-≳≈ˡ⇔uninhabited = record { to = Transitivity-≳≈ˡ ↝⟨ _∘ ∼→ ⟩ Transitivity-∼≈ˡ ↝⟨ _⇔_.to size-preserving-transitivity-∼≈ˡ⇔uninhabited ⟩ ¬ A □ ; from = ¬ A ↝⟨ uninhabited→trivial ⟩ (∀ x y → x ≈ y) ↝⟨ (λ trivial {_ _ _ _} _ _ → trivial _ _) ⟩□ Transitivity-≳≈ˡ □ } -- There is a transitivity-like proof, taking expansion and weak -- bisimilarity to weak bisimilarity, that preserves the size of both -- arguments iff A is uninhabited. Transitivity-≳≈ = ∀ {i} {x y z : Delay A ∞} → [ i ] x ≳ y → [ i ] y ≈ z → [ i ] x ≈ z size-preserving-transitivity-≳≈⇔uninhabited : Transitivity-≳≈ ⇔ ¬ A size-preserving-transitivity-≳≈⇔uninhabited = record { to = Transitivity-≳≈ ↝⟨ id ⟩ Transitivity-≳≈ˡ ↝⟨ _⇔_.to size-preserving-transitivity-≳≈ˡ⇔uninhabited ⟩ ¬ A □ ; from = ¬ A ↝⟨ uninhabited→trivial ⟩ (∀ x y → x ≈ y) ↝⟨ (λ trivial {_ _ _ _} _ _ → trivial _ _) ⟩□ Transitivity-≳≈ □ } -- There is a transitivity-like proof, taking weak bisimilarity and -- the converse of expansion to weak bisimilarity, that preserves the -- size of the second argument iff A is uninhabited. Transitivity-≈≲ʳ = ∀ {i} {x y z : Delay A ∞} → x ≈ y → [ i ] y ≲ z → [ i ] x ≈ z size-preserving-transitivity-≈≲ʳ⇔uninhabited : Transitivity-≈≲ʳ ⇔ ¬ A size-preserving-transitivity-≈≲ʳ⇔uninhabited = Transitivity-≈≲ʳ ↝⟨ record { to = λ trans x≳y y≈z → symmetric (trans (symmetric y≈z) x≳y) ; from = λ trans x≈y y≲z → symmetric (trans y≲z (symmetric x≈y)) } ⟩ Transitivity-≳≈ˡ ↝⟨ size-preserving-transitivity-≳≈ˡ⇔uninhabited ⟩□ ¬ A □ -- There is a transitivity-like proof, taking weak bisimilarity and -- the converse of expansion to weak bisimilarity, that preserves the -- size of both arguments iff A is uninhabited. Transitivity-≈≲ = ∀ {i} {x y z : Delay A ∞} → [ i ] x ≈ y → [ i ] y ≲ z → [ i ] x ≈ z size-preserving-transitivity-≈≲⇔uninhabited : Transitivity-≈≲ ⇔ ¬ A size-preserving-transitivity-≈≲⇔uninhabited = Transitivity-≈≲ ↝⟨ record { to = λ trans x≳y y≈z → symmetric (trans (symmetric y≈z) x≳y) ; from = λ trans x≈y y≲z → symmetric (trans y≲z (symmetric x≈y)) } ⟩ Transitivity-≳≈ ↝⟨ size-preserving-transitivity-≳≈⇔uninhabited ⟩□ ¬ A □ -- There is a transitivity-like proof, taking weak bisimilarity and -- expansion to weak bisimilarity, that preserves the size of the -- first argument iff A is uninhabited. Transitivity-≈≳ˡ = ∀ {i} {x y z : Delay A ∞} → [ i ] x ≈ y → y ≳ z → [ i ] x ≈ z size-preserving-transitivity-≈≳ˡ⇔uninhabited : Transitivity-≈≳ˡ ⇔ ¬ A size-preserving-transitivity-≈≳ˡ⇔uninhabited = record { to = Transitivity-≈≳ˡ ↝⟨ (λ trans x≈ly → trans x≈ly (laterˡ (reflexive _))) ⟩ Laterʳ⁻¹-≈ ↝⟨ _⇔_.to size-preserving-laterʳ⁻¹-≈⇔uninhabited ⟩ ¬ A □ ; from = ¬ A ↝⟨ uninhabited→trivial ⟩ (∀ x y → x ≈ y) ↝⟨ (λ trivial {_ _ _ _} _ _ → trivial _ _) ⟩□ Transitivity-≈≳ˡ □ }
{ "alphanum_fraction": 0.5322620889, "avg_line_length": 40.5647773279, "ext": "agda", "hexsha": "1bb585490c7d4bd038a8e9bfe384fb82617ef4d2", "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": "495f9996673d0f1f34ce202902daaa6c39f8925e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/delay-monad", "max_forks_repo_path": "src/Delay-monad/Bisimilarity/Negative.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "495f9996673d0f1f34ce202902daaa6c39f8925e", "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/delay-monad", "max_issues_repo_path": "src/Delay-monad/Bisimilarity/Negative.agda", "max_line_length": 108, "max_stars_count": null, "max_stars_repo_head_hexsha": "495f9996673d0f1f34ce202902daaa6c39f8925e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/delay-monad", "max_stars_repo_path": "src/Delay-monad/Bisimilarity/Negative.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 8001, "size": 20039 }
module CF.Examples.Ex2 where open import Function open import Data.Bool open import Data.Product open import Data.List open import Data.Integer open import Data.String open import Relation.Binary.PropositionalEquality using (refl) open import Relation.Ternary.Core open import Relation.Ternary.Structures open import Relation.Ternary.Structures.Syntax open import Relation.Ternary.Monad.Possibly open import JVM.Contexts open import JVM.Types open import JVM.Transform.Assemble open import JVM.Printer import JVM.Printer.Jasmin as J open import CF.Syntax as Src open import CF.Types open import CF.Contexts.Lexical open import CF.Compile -- int i = 0; -- while(i < 10) { -- i = i + 1 -- } ex₂ : Src.Block void ε ex₂ = Src.num (+ 0) ≔⟨ ∙-idˡ ⟩ Possibly.possibly ∼-all ( Src.while (bop gt (var ∙⟨ ∙-idʳ ⟩ num (+ 10)) ∙⟨ overlaps ∙-idˡ ⟩ Src.block ( Src.asgn (refl ∙⟨ overlaps ∙-idˡ ⟩ bop add (var ∙⟨ ∙-idʳ ⟩ num (+ 1))) ⍮⟨ ∙-idʳ ⟩ emp) )⍮⟨ ∙-idʳ ⟩ emp ) -- Which should compile to: -- -- 0: push 0 -- 1: store 0 -- 2: load 0 -- 3: push 10 -- 4: if_icmplt 7 -- 5: push false // 0 -- 6: goto 8 -- 7: push true // 1 -- 8: if eq 14 // 0 = false -> jump to end -- 9: load 0 -- 10: push 1 -- 11: bop add -- 12: store 0 -- 13: goto 2 -- 14: nop open import IO as IO main = IO.run (putStrLn test) where test = Show.showBytecode $ proj₂ $ exec-extractor $ extract (proj₂ $ compile ex₂) -- Uncomment this instead of the above main to output Jasmin code. -- You can assemble this using Jasmin so that you can run the output with java. -- Disclaimer: the jasmin compiler pass is not verified. -- main = IO.run (putStrLn (J.unlines $ J.Jasmin.out proc)) -- where -- proc = procedure "ex1" (proj₂ $ compile ex₂)
{ "alphanum_fraction": 0.6679931779, "avg_line_length": 24.7746478873, "ext": "agda", "hexsha": "56c74b377b9fa00f7d8a345c6b88c1fa05658183", "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/CF/Examples/Ex2.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/CF/Examples/Ex2.agda", "max_line_length": 90, "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/CF/Examples/Ex2.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": 609, "size": 1759 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use -- Data.List.Relation.Binary.Lex.Core directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Relation.Lex.Core where open import Data.List.Relation.Binary.Lex.Core public
{ "alphanum_fraction": 0.47, "avg_line_length": 30.7692307692, "ext": "agda", "hexsha": "b4a8f1611390ed36a2b0729f511cad8c728e1660", "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": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Lex/Core.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Lex/Core.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Lex/Core.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 63, "size": 400 }
--------------------------------------------------------------------------------- -- Equality data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x {-# BUILTIN EQUALITY _≡_ #-} infix 4 _≡_ ------------------------------------------------------------------------------ -- Equality is an equivalence relation : reflexive, symmetric, and transitive. -- Reflexivity is built-in to the definition of equality. sym : ∀ {A : Set} {x y : A} → x ≡ y ----- → y ≡ x sym refl = refl trans : ∀ {A : Set} {x y z : A} → x ≡ y → y ≡ z ----- → x ≡ z trans refl refl = refl -- Equality satisfies congruence. -- If two terms are equal, they are eual after the same function is applied to both: cong : ∀ {A B : Set} (f : A → B) {x y : A} → x ≡ y --------- → f x ≡ f y cong f refl = refl -- Congruence of 2 arg functions cong₂ : ∀ {A B C : Set} (f : A → B → C) {u x : A} {v y : B} → u ≡ x → v ≡ y ------------- → f u v ≡ f x y cong₂ f refl refl = refl -- Equality is a congruence in the function position of an application. -- If two functions are equal, then applying them to the same term yields equal terms: cong-app : ∀ {A B : Set} {f g : A → B} → f ≡ g --------------------- → ∀ (x : A) → f x ≡ g x cong-app refl x = refl -- Equality satisfies substitution. -- If two values are equal and a predicate holds of the first then it also holds of the second: subst : ∀ {A : Set} {x y : A} (P : A → Set) → x ≡ y --------- → P x → P y subst P refl px = px -- Chains of equations : support equational reasoning module ≡-Reasoning {A : Set} where infix 1 begin_ infixr 2 _≡⟨⟩_ _≡⟨_⟩_ infix 3 _∎ begin_ : ∀ {x y : A} → x ≡ y ----- → x ≡ y begin x≡y = x≡y _≡⟨⟩_ : ∀ (x : A) {y : A} → x ≡ y ----- → x ≡ y x ≡⟨⟩ x≡y = x≡y _≡⟨_⟩_ : ∀ (x : A) {y z : A} → x ≡ y → y ≡ z ----- → x ≡ z x ≡⟨ x≡y ⟩ y≡z = trans x≡y y≡z _∎ : ∀ (x : A) ----- → x ≡ x x ∎ = refl open ≡-Reasoning -- equational proof of transitivity trans′ : ∀ {A : Set} {x y z : A} → x ≡ y → y ≡ z ----- → x ≡ z trans′ {A} {x} {y} {z} x≡y y≡z = begin x ≡⟨ x≡y ⟩ y ≡⟨ y≡z ⟩ z ∎ {- Exercise trans and ≡-Reasoning (practice): TODO Cannot use the definition of trans’ using ≡-Reasoning as the definition for trans. WHY? Hint: look at the definition of _≡⟨_⟩_ -} data ℕ : Set where zero : ℕ suc : ℕ → ℕ _+_ : ℕ → ℕ → ℕ zero + n = n (suc m) + n = suc (m + n) postulate +-identity : ∀ (m : ℕ) → m + zero ≡ m +-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n) +-comm : ∀ (m n : ℕ) → m + n ≡ n + m +-comm m zero = begin m + zero ≡⟨ +-identity m ⟩ m ≡⟨⟩ zero + m ∎ +-comm m (suc n) = begin m + suc n ≡⟨ +-suc m n ⟩ suc (m + n) ≡⟨ cong suc (+-comm m n) ⟩ suc (n + m) ≡⟨⟩ suc n + m ∎ {- Exercise ≤-Reasoning (stretch) TODO The proof of monotonicity from Chapter Relations can be written in a more readable form by using an analogue of our notation for ≡-Reasoning. Define ≤-Reasoning analogously, and use it to write out an alternative proof that addition is monotonic with regard to inequality. Rewrite all of +-monoˡ-≤, +-monoʳ-≤, and +-mono-≤. -} ------------------------------------------------------------------------------ -- Rewriting -- keyword rewrite : followed by evidence of an EQUALITY -- that equality is used to rewrite -- - the type of the goal -- - and of any variable in scope data even : ℕ → Set data odd : ℕ → Set data even where even-zero : even zero even-suc : ∀ {n : ℕ} → odd n ------------ → even (suc n) data odd where odd-suc : ∀ {n : ℕ} → even n ----------- → odd (suc n) even-comm : ∀ (m n : ℕ) → even (m + n) ------------ → even (n + m) even-comm m n ev -- even (n + m) rewrite +-comm n m -- even (m + n) ; ev : even (m + n) = ev -------------------------------------------------- -- Multiple rewrites each separated by a vertical bar. +-comm′ : ∀ (m n : ℕ) → m + n ≡ n + m +-comm′ zero n rewrite +-identity n = refl +-comm′ (suc m) n rewrite +-suc n m | +-comm′ m n = refl -------------------------------------------------- -- rewrite is shorthand for an use of WITH even-comm′ : ∀ (m n : ℕ) → even (m + n) ------------ → even (n + m) even-comm′ m n ev with m + n | +-comm m n ... | .(n + m) | refl = ev {- -------------------------------------------------- DOT pattern, .(n + m). dot followed by an expression. Used when other info forces value matched to be equal to value of expr in dot pattern. -} ------------------------------------------------------------------------------ -- subst (instead of rewrite) even-comm″ : ∀ (m n : ℕ) → even (m + n) ------------ → even (n + m) even-comm″ m n = subst even (+-comm m n) {- ------------------------------------------------------------------------------ Leibniz equality ≡ def is due to Martin Löf (1975). Older form is due to Leibniz (1686). IDENTITY OF INDISCERNIBLES: - two objects are equal IFF they satisfy the same properties Below: define Leibniz equality, and show that two terms satisfy Leibniz equality IFF they satisfy Martin Löf equality. x ≐ y holds if every property P that holds of x also holds of y this def is sufficient to ensure the converse - that every property P that holds of y also holds of x Let x and y be objects of type A. x ≐ y holds if for every predicate P over type A we have that P x implies P y: _] -} _≐_ : ∀ {A : Set} (x y : A) → Set₁ _≐_ {A} x y = ∀ (P : A → Set) → P x → P y {- NOTE: write _≐_ {A} x y (instead of x ≐ y) to provide access to implicit parameter. -------------------------------------------------- FIRST USE OF LEVELS. Cannot assign Set the type Set (Russell’s Paradox and Girard’s Paradox). Set is an abbreviation for Set₀ Since _≐_ def mentions Set on right-hand side, the corresponding signature must use Set₁. Leibniz equality is reflexive (follows by a variant of the identity function) and transitive (by a variant of function composition) -} refl-≐ : ∀ {A : Set} {x : A} → x ≐ x refl-≐ P Px = Px trans-≐ : ∀ {A : Set} {x y z : A} → x ≐ y → y ≐ z ----- → x ≐ z trans-≐ x≐y y≐z P Px = y≐z P (x≐y P Px) -- Symmetry : show that if P x implies P y for all predicates P, -- then the implication holds the other way round as well: sym-≐ : ∀ {A : Set} {x y : A} → x ≐ y ----- → y ≐ x sym-≐ {A} {x} {y} x≐y P = Qy where Q : A → Set Q z = P z → P x Qx : Q x Qx = refl-≐ P Qy : Q y Qy = x≐y Q Qx {- Given x ≐ y, a specific P, construct a proof that P y implies P x. Instantiate the equality with a predicate Q such that Q z holds if P z implies P x. The property Q x is trivial by reflexivity, and hence Q y follows from x ≐ y. But Q y is exactly a proof of what we require, that P y implies P x. show Martin Löf equality implies Leibniz equality, and vice versa. if x ≡ y then need for any P to take evidence of P x to evidence of P y which can be done since equality of x and y implies that any proof of P x is also a proof of P y: -} ≡-implies-≐ : ∀ {A : Set} {x y : A} → x ≡ y ----- → x ≐ y ≡-implies-≐ x≡y P = subst P x≡y -- given that for any P we can take a proof of P x to a proof of P y then show x ≡ y: ≐-implies-≡ : ∀ {A : Set} {x y : A} → x ≐ y ----- → x ≡ y ≐-implies-≡ {A} {x} {y} x≐y = Qy where Q : A → Set Q z = x ≡ z Qx : Q x Qx = refl Qy : Q y Qy = x≐y Q Qx {- proof similar to that for symmetry of Leibniz equality. We take Q to be the predicate that holds of z if x ≡ z. Then Q x is trivial by reflexivity of Martin Löf equality, and hence Q y follows from x ≐ y. But Q y is exactly a proof of what we require, that x ≡ y. (Parts adapted from ≐≃≡: Leibniz Equality is Isomorphic to Martin-Löf Identity, Parametrically, by Andreas Abel, Jesper Cockx, Dominique Devries, Andreas Nuyts, and Philip Wadler, draft, 2017.) ------------------------------------------------------------------------------ Universe polymorphism Not every type belongs to Set. Set₀ : Set₁, Set₁ : Set₂, ... ≡ def at beginning is ok for comparing values of a type that belongs to Set. How to compare two values of a type that belongs to Set ℓ for some arbitrary level ℓ? Via universe polymorphism : definition made with respect to arbitrary level ℓ. To use levels: -} open import Level using (Level; _⊔_) renaming (zero to lzero; suc to lsuc) {- Levels : isomorphic to natural numbers lzero : Level lsuc : Level → Level Set₀, Set₁, Set₂, and so on, are abbreviations for Set lzero Set (lsuc lzero) Set (lsuc (lsuc lzero)) _⊔_ : Level → Level → Level -- given two levels returns the largest equality, symetry, generalised to an arbitrary level: -} data _≡′_ {ℓ : Level} {A : Set ℓ} (x : A) : A → Set ℓ where refl′ : x ≡′ x sym′ : ∀ {ℓ : Level} {A : Set ℓ} {x y : A} → x ≡′ y ------ → y ≡′ x sym′ refl′ = refl′ {- most defs in standard library are generalised to arbitrary levels generalised Leibniz equality: -} _≐′_ : ∀ {ℓ : Level} {A : Set ℓ} (x y : A) → Set (lsuc ℓ) _≐′_ {ℓ} {A} x y = ∀ (P : A → Set ℓ) → P x → P y -- generalized composition _∘_ : ∀ {ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set ℓ₁} {B : Set ℓ₂} {C : Set ℓ₃} → (B → C) → (A → B) → A → C (g ∘ f) x = g (f x) {- Standard library defines _≡⟨_⟩_ as step-≡, which reverses the order of the arguments. defines a syntax macro ((automatically imported with step-≡) i, which recovers original arg order: -}
{ "alphanum_fraction": 0.5364474235, "avg_line_length": 24.2335025381, "ext": "agda", "hexsha": "32a89307bbf8abfb7e107ea72eccb21fdbb6b547", "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/x04equality-hc-2.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/x04equality-hc-2.agda", "max_line_length": 98, "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/x04equality-hc-2.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": 3285, "size": 9548 }
module zfc where open import Level open import Relation.Binary open import Relation.Nullary open import logic record IsZFC {n m : Level } (ZFSet : Set n) (_∋_ : ( A x : ZFSet ) → Set m) (_≈_ : Rel ZFSet m) (∅ : ZFSet) (Select : (X : ZFSet ) → ( ψ : (x : ZFSet ) → Set m ) → ZFSet ) : Set (suc (n ⊔ suc m)) where field -- ∀ X [ ∅ ∉ X → (∃ f : X → ⋃ X ) → ∀ A ∈ X ( f ( A ) ∈ A ) ] choice-func : (X : ZFSet ) → {x : ZFSet } → ¬ ( x ≈ ∅ ) → ( X ∋ x ) → ZFSet choice : (X : ZFSet ) → {A : ZFSet } → ( X∋A : X ∋ A ) → (not : ¬ ( A ≈ ∅ )) → A ∋ choice-func X not X∋A infixr 200 _∈_ infixr 230 _∩_ _∈_ : ( A B : ZFSet ) → Set m A ∈ B = B ∋ A _∩_ : ( A B : ZFSet ) → ZFSet A ∩ B = Select A ( λ x → ( A ∋ x ) ∧ ( B ∋ x ) ) record ZFC {n m : Level } : Set (suc (n ⊔ suc m)) where field ZFSet : Set n _∋_ : ( A x : ZFSet ) → Set m _≈_ : ( A B : ZFSet ) → Set m ∅ : ZFSet Select : (X : ZFSet ) → ( ψ : (x : ZFSet ) → Set m ) → ZFSet isZFC : IsZFC ZFSet _∋_ _≈_ ∅ Select
{ "alphanum_fraction": 0.4455813953, "avg_line_length": 30.7142857143, "ext": "agda", "hexsha": "177382511b696c3b7cf34067639e4111cb5c02cc", "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": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/zf-in-agda", "max_forks_repo_path": "src/zfc.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "shinji-kono/zf-in-agda", "max_issues_repo_path": "src/zfc.agda", "max_line_length": 110, "max_stars_count": 5, "max_stars_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/zf-in-agda", "max_stars_repo_path": "src/zfc.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-10T13:27:48.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-02T13:46:23.000Z", "num_tokens": 504, "size": 1075 }
{-# OPTIONS --without-K --safe #-} {- Properties regarding Morphisms of a category: - Regular Monomorphism - Regular Epimorphism https://ncatlab.org/nlab/show/regular+epimorphism These are defined here rather than in Morphism, as this might cause import cycles (and make the dependency graph very odd). -} open import Categories.Category.Core module Categories.Morphism.Regular {o ℓ e} (𝒞 : Category o ℓ e) where open import Level open import Categories.Morphism 𝒞 open import Categories.Diagram.Equalizer 𝒞 open import Categories.Diagram.Coequalizer 𝒞 open Category 𝒞 private variable A B : Obj f : A ⇒ B record RegularMono (f : A ⇒ B) : Set (o ⊔ ℓ ⊔ e) where field { C } : Obj g : B ⇒ C h : B ⇒ C equalizer : IsEqualizer f h g record RegularEpi (f : A ⇒ B) : Set (o ⊔ ℓ ⊔ e) where field { C } : Obj h : C ⇒ A g : C ⇒ A coequalizer : IsCoequalizer h g f RegularMono⇒Mono : RegularMono f → Mono f RegularMono⇒Mono regular = IsEqualizer⇒Mono equalizer where open RegularMono regular RegularEpi⇒Epi : RegularEpi f → Epi f RegularEpi⇒Epi regular = IsCoequalizer⇒Epi coequalizer where open RegularEpi regular
{ "alphanum_fraction": 0.6899159664, "avg_line_length": 21.6363636364, "ext": "agda", "hexsha": "0dca21cf0a8953b9c27be8eba5a3b8b458418c8f", "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": "8f3c844d929508040dfa21f681fa260056214b73", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "maxsnew/agda-categories", "max_forks_repo_path": "src/Categories/Morphism/Regular.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "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": "maxsnew/agda-categories", "max_issues_repo_path": "src/Categories/Morphism/Regular.agda", "max_line_length": 69, "max_stars_count": null, "max_stars_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "maxsnew/agda-categories", "max_stars_repo_path": "src/Categories/Morphism/Regular.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 388, "size": 1190 }
module Forcing where open import Common.IO open import Common.Unit open import Lib.Vec open import Common.Nat len : {A : Set}{n : Nat} → Vec A n → Nat len {A} .{zero} [] = zero len {A} .{suc n} (_∷_ {n} x xs) = suc n len2 : {A : Set}{n : Nat} → Vec A n → Nat len2 [] = 0 len2 (_∷_ {n} x xs) = suc (len2 {n = n} xs) len3 : {A : Set}{n : Nat} → Vec A n → Nat len3 {n = zero} [] = zero len3 {n = suc n} (_∷_ .{n} x xs) = suc n len4 : {A : Set}{n : Nat} → Vec A n → Nat len4 [] = zero len4 (_∷_ {zero} x xs) = suc zero len4 (_∷_ {suc n} x xs) = suc (suc n) main : IO Unit main = printNat (len l1) ,, printNat (len l2) ,, printNat (len l3) ,, printNat (len2 l1) ,, printNat (len2 l2) ,, printNat (len2 l3) ,, printNat (len3 l1) ,, printNat (len3 l2) ,, printNat (len3 l3) ,, printNat (len4 l1) ,, printNat (len4 l2) ,, printNat (len4 l3) ,, return unit where l1 = "a" ∷ ("b" ∷ ("c" ∷ [])) l2 = 1 ∷ (2 ∷ (3 ∷ (4 ∷ (5 ∷ [])))) l3 : Vec Nat zero l3 = []
{ "alphanum_fraction": 0.486586494, "avg_line_length": 22.5208333333, "ext": "agda", "hexsha": "d9b474f03de332ba72451c8655de6e6cb64c3fe2", "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/Forcing.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/Forcing.agda", "max_line_length": 43, "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/Forcing.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": 456, "size": 1081 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Lists, basic types and operations ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Base where open import Data.Nat.Base as ℕ using (ℕ; zero; suc; _+_; _*_ ; _≤_ ; s≤s) open import Data.Fin using (Fin; zero; suc) open import Data.Sum as Sum using (_⊎_; inj₁; inj₂) open import Data.Bool.Base as Bool using (Bool; false; true; not; _∧_; _∨_; if_then_else_) open import Data.Maybe.Base as Maybe using (Maybe; nothing; just) open import Data.Product as Prod using (_×_; _,_) open import Data.These as These using (These; this; that; these) open import Function using (id; _∘_ ; _∘′_; const; flip) open import Relation.Nullary using (yes; no) open import Relation.Unary using (Pred; Decidable) open import Relation.Unary.Properties using (∁?) ------------------------------------------------------------------------ -- Types open import Agda.Builtin.List public using (List; []; _∷_) ------------------------------------------------------------------------ -- Operations for transforming lists map : ∀ {a b} {A : Set a} {B : Set b} → (A → B) → List A → List B map f [] = [] map f (x ∷ xs) = f x ∷ map f xs mapMaybe : ∀ {a b} {A : Set a} {B : Set b} → (A → Maybe B) → List A → List B mapMaybe p [] = [] mapMaybe p (x ∷ xs) with p x ... | just y = y ∷ mapMaybe p xs ... | nothing = mapMaybe p xs module _ {a} {A : Set a} where infixr 5 _++_ _++_ : List A → List A → List A [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ (xs ++ ys) intersperse : A → List A → List A intersperse x [] = [] intersperse x (y ∷ []) = y ∷ [] intersperse x (y ∷ ys) = y ∷ x ∷ intersperse x ys intercalate : List A → List (List A) → List A intercalate xs [] = [] intercalate xs (ys ∷ []) = ys intercalate xs (ys ∷ yss) = ys ++ xs ++ intercalate xs yss ------------------------------------------------------------------------ -- Aligning and zipping module _ {a b c} {A : Set a} {B : Set b} {C : Set c} where alignWith : (These A B → C) → List A → List B → List C alignWith f [] bs = map (f ∘′ that) bs alignWith f as [] = map (f ∘′ this) as alignWith f (a ∷ as) (b ∷ bs) = f (these a b) ∷ alignWith f as bs zipWith : (A → B → C) → List A → List B → List C zipWith f (x ∷ xs) (y ∷ ys) = f x y ∷ zipWith f xs ys zipWith f _ _ = [] unalignWith : (A → These B C) → List A → List B × List C unalignWith f [] = [] , [] unalignWith f (a ∷ as) with f a ... | this b = Prod.map₁ (b ∷_) (unalignWith f as) ... | that c = Prod.map₂ (c ∷_) (unalignWith f as) ... | these b c = Prod.map (b ∷_) (c ∷_) (unalignWith f as) unzipWith : (A → B × C) → List A → List B × List C unzipWith f [] = [] , [] unzipWith f (xy ∷ xys) = Prod.zip _∷_ _∷_ (f xy) (unzipWith f xys) partitionSumsWith : (A → B ⊎ C) → List A → List B × List C partitionSumsWith f = unalignWith (These.fromSum ∘′ f) module _ {a b} {A : Set a} {B : Set b} where align : List A → List B → List (These A B) align = alignWith id zip : List A → List B → List (A × B) zip = zipWith (_,_) unalign : List (These A B) → List A × List B unalign = unalignWith id unzip : List (A × B) → List A × List B unzip = unzipWith id partitionSums : List (A ⊎ B) → List A × List B partitionSums = partitionSumsWith id ------------------------------------------------------------------------ -- Operations for reducing lists foldr : ∀ {a b} {A : Set a} {B : Set b} → (A → B → B) → B → List A → B foldr c n [] = n foldr c n (x ∷ xs) = c x (foldr c n xs) foldl : ∀ {a b} {A : Set a} {B : Set b} → (A → B → A) → A → List B → A foldl c n [] = n foldl c n (x ∷ xs) = foldl c (c n x) xs concat : ∀ {a} {A : Set a} → List (List A) → List A concat = foldr _++_ [] concatMap : ∀ {a b} {A : Set a} {B : Set b} → (A → List B) → List A → List B concatMap f = concat ∘ map f null : ∀ {a} {A : Set a} → List A → Bool null [] = true null (x ∷ xs) = false and : List Bool → Bool and = foldr _∧_ true or : List Bool → Bool or = foldr _∨_ false any : ∀ {a} {A : Set a} → (A → Bool) → List A → Bool any p = or ∘ map p all : ∀ {a} {A : Set a} → (A → Bool) → List A → Bool all p = and ∘ map p sum : List ℕ → ℕ sum = foldr _+_ 0 product : List ℕ → ℕ product = foldr _*_ 1 length : ∀ {a} {A : Set a} → List A → ℕ length = foldr (const suc) 0 ------------------------------------------------------------------------ -- Operations for constructing lists [_] : ∀ {a} {A : Set a} → A → List A [ x ] = x ∷ [] fromMaybe : ∀ {a} {A : Set a} → Maybe A → List A fromMaybe (just x) = [ x ] fromMaybe nothing = [] replicate : ∀ {a} {A : Set a} → ℕ → A → List A replicate zero x = [] replicate (suc n) x = x ∷ replicate n x inits : ∀ {a} {A : Set a} → List A → List (List A) inits [] = [] ∷ [] inits (x ∷ xs) = [] ∷ map (x ∷_) (inits xs) tails : ∀ {a} {A : Set a} → List A → List (List A) tails [] = [] ∷ [] tails (x ∷ xs) = (x ∷ xs) ∷ tails xs -- Scans scanr : ∀ {a b} {A : Set a} {B : Set b} → (A → B → B) → B → List A → List B scanr f e [] = e ∷ [] scanr f e (x ∷ xs) with scanr f e xs ... | [] = [] -- dead branch ... | y ∷ ys = f x y ∷ y ∷ ys scanl : ∀ {a b} {A : Set a} {B : Set b} → (A → B → A) → A → List B → List A scanl f e [] = e ∷ [] scanl f e (x ∷ xs) = e ∷ scanl f (f e x) xs module _ {a} {A : Set a} where -- Tabulation applyUpTo : (ℕ → A) → ℕ → List A applyUpTo f zero = [] applyUpTo f (suc n) = f zero ∷ applyUpTo (f ∘ suc) n applyDownFrom : (ℕ → A) → ℕ → List A applyDownFrom f zero = [] applyDownFrom f (suc n) = f n ∷ applyDownFrom f n tabulate : ∀ {n} (f : Fin n → A) → List A tabulate {zero} f = [] tabulate {suc n} f = f Fin.zero ∷ tabulate (f ∘ Fin.suc) lookup : ∀ (xs : List A) → Fin (length xs) → A lookup [] () lookup (x ∷ xs) Fin.zero = x lookup (x ∷ xs) (Fin.suc i) = lookup xs i -- Numerical upTo : ℕ → List ℕ upTo = applyUpTo id downFrom : ℕ → List ℕ downFrom = applyDownFrom id allFin : ∀ n → List (Fin n) allFin n = tabulate id -- Other unfold : ∀ {a b} {A : Set a} (B : ℕ → Set b) (f : ∀ {n} → B (suc n) → Maybe (A × B n)) → ∀ {n} → B n → List A unfold B f {n = zero} s = [] unfold B f {n = suc n} s with f s ... | nothing = [] ... | just (x , s') = x ∷ unfold B f s' ------------------------------------------------------------------------ -- Operations for deconstructing lists -- Note that although these combinators can be useful for programming, when -- proving it is often a better idea to manually destruct a list argument: -- each branch of the pattern-matching will have a refined type. module _ {a} {A : Set a} where uncons : List A → Maybe (A × List A) uncons [] = nothing uncons (x ∷ xs) = just (x , xs) head : List A → Maybe A head [] = nothing head (x ∷ _) = just x tail : List A → Maybe (List A) tail [] = nothing tail (_ ∷ xs) = just xs take : ∀ {a} {A : Set a} → ℕ → List A → List A take zero xs = [] take (suc n) [] = [] take (suc n) (x ∷ xs) = x ∷ take n xs drop : ∀ {a} {A : Set a} → ℕ → List A → List A drop zero xs = xs drop (suc n) [] = [] drop (suc n) (x ∷ xs) = drop n xs splitAt : ∀ {a} {A : Set a} → ℕ → List A → (List A × List A) splitAt zero xs = ([] , xs) splitAt (suc n) [] = ([] , []) splitAt (suc n) (x ∷ xs) with splitAt n xs ... | (ys , zs) = (x ∷ ys , zs) takeWhile : ∀ {a p} {A : Set a} {P : Pred A p} → Decidable P → List A → List A takeWhile P? [] = [] takeWhile P? (x ∷ xs) with P? x ... | yes _ = x ∷ takeWhile P? xs ... | no _ = [] dropWhile : ∀ {a p} {A : Set a} {P : Pred A p} → Decidable P → List A → List A dropWhile P? [] = [] dropWhile P? (x ∷ xs) with P? x ... | yes _ = dropWhile P? xs ... | no _ = x ∷ xs filter : ∀ {a p} {A : Set a} {P : Pred A p} → Decidable P → List A → List A filter P? [] = [] filter P? (x ∷ xs) with P? x ... | no _ = filter P? xs ... | yes _ = x ∷ filter P? xs partition : ∀ {a p} {A : Set a} {P : Pred A p} → Decidable P → List A → (List A × List A) partition P? [] = ([] , []) partition P? (x ∷ xs) with P? x | partition P? xs ... | yes _ | (ys , zs) = (x ∷ ys , zs) ... | no _ | (ys , zs) = (ys , x ∷ zs) span : ∀ {a p} {A : Set a} {P : Pred A p} → Decidable P → List A → (List A × List A) span P? [] = ([] , []) span P? (x ∷ xs) with P? x ... | yes _ = Prod.map (x ∷_) id (span P? xs) ... | no _ = ([] , x ∷ xs) break : ∀ {a p} {A : Set a} {P : Pred A p} → Decidable P → List A → (List A × List A) break P? = span (∁? P?) ------------------------------------------------------------------------ -- Actions on single elements module _ {a} {A : Set a} where infixl 5 _[_]%=_ _[_]∷=_ _─_ _[_]%=_ : (xs : List A) → Fin (length xs) → (A → A) → List A [] [ () ]%= f (x ∷ xs) [ zero ]%= f = f x ∷ xs (x ∷ xs) [ suc k ]%= f = x ∷ (xs [ k ]%= f) _[_]∷=_ : (xs : List A) → Fin (length xs) → A → List A xs [ k ]∷= v = xs [ k ]%= const v _─_ : (xs : List A) → Fin (length xs) → List A [] ─ () (x ∷ xs) ─ zero = xs (x ∷ xs) ─ suc k = x ∷ (xs ─ k) ------------------------------------------------------------------------ -- Operations for reversing lists module _ {a} {A : Set a} where reverseAcc : List A → List A → List A reverseAcc = foldl (flip _∷_) reverse : List A → List A reverse = reverseAcc [] -- Snoc. infixl 5 _∷ʳ_ _∷ʳ_ : ∀ {a} {A : Set a} → List A → A → List A xs ∷ʳ x = xs ++ [ x ] -- Backwards initialisation infixl 5 _∷ʳ'_ data InitLast {a} {A : Set a} : List A → Set a where [] : InitLast [] _∷ʳ'_ : (xs : List A) (x : A) → InitLast (xs ∷ʳ x) initLast : ∀ {a} {A : Set a} → (xs : List A) → InitLast xs initLast [] = [] initLast (x ∷ xs) with initLast xs initLast (x ∷ .[]) | [] = [] ∷ʳ' x initLast (x ∷ .(ys ∷ʳ y)) | ys ∷ʳ' y = (x ∷ ys) ∷ʳ' y ------------------------------------------------------------------------ -- DEPRECATED ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- -- Note that the `boolX` functions are not given warnings as they are -- used by other deprecated proofs throughout the library. -- Version 0.15 gfilter = mapMaybe {-# WARNING_ON_USAGE gfilter "Warning: gfilter was deprecated in v0.15. Please use mapMaybe instead." #-} boolFilter : ∀ {a} {A : Set a} → (A → Bool) → List A → List A boolFilter p = mapMaybe (λ x → if p x then just x else nothing) boolPartition : ∀ {a} {A : Set a} → (A → Bool) → List A → (List A × List A) boolPartition p [] = ([] , []) boolPartition p (x ∷ xs) with p x | boolPartition p xs ... | true | (ys , zs) = (x ∷ ys , zs) ... | false | (ys , zs) = (ys , x ∷ zs) -- Version 0.16 boolTakeWhile : ∀ {a} {A : Set a} → (A → Bool) → List A → List A boolTakeWhile p [] = [] boolTakeWhile p (x ∷ xs) with p x ... | true = x ∷ boolTakeWhile p xs ... | false = [] boolDropWhile : ∀ {a} {A : Set a} → (A → Bool) → List A → List A boolDropWhile p [] = [] boolDropWhile p (x ∷ xs) with p x ... | true = boolDropWhile p xs ... | false = x ∷ xs boolSpan : ∀ {a} {A : Set a} → (A → Bool) → List A → (List A × List A) boolSpan p [] = ([] , []) boolSpan p (x ∷ xs) with p x ... | true = Prod.map (x ∷_) id (boolSpan p xs) ... | false = ([] , x ∷ xs) boolBreak : ∀ {a} {A : Set a} → (A → Bool) → List A → (List A × List A) boolBreak p = boolSpan (not ∘ p)
{ "alphanum_fraction": 0.4832682181, "avg_line_length": 29.1435643564, "ext": "agda", "hexsha": "ca5a6665bad3060728b5203b09292ff34f13fb96", "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": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Base.agda", "max_line_length": 76, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4182, "size": 11774 }
-------------------------------------------------------------------------------- -- This is part of Agda Inference Systems {-# OPTIONS --sized-types #-} open import Agda.Builtin.Equality open import Data.Product open import Size open import Codata.Thunk open import Level open import Relation.Unary using (_⊆_) module is-lib.InfSys.SCoinduction {𝓁} where private variable U : Set 𝓁 open import is-lib.InfSys.Base {𝓁} open import is-lib.InfSys.Induction {𝓁} open MetaRule open IS {- Coinductive interpretation -} data SCoInd⟦_⟧ {𝓁c 𝓁p 𝓁n : Level} (is : IS {𝓁c} {𝓁p} {𝓁n} U) : U → Size → Set (𝓁 ⊔ 𝓁c ⊔ 𝓁p ⊔ 𝓁n) where sfold : ∀{u i} → ISF[ is ] (λ u → Thunk (SCoInd⟦ is ⟧ u) i) u → SCoInd⟦ is ⟧ u i {- Coinduction Principle -} scoind[_] : ∀{𝓁c 𝓁p 𝓁n 𝓁'} → (is : IS {𝓁c} {𝓁p} {𝓁n} U) → (S : U → Set 𝓁') → S ⊆ ISF[ is ] S -- S is consistent → S ⊆ λ u → ∀{i} → SCoInd⟦ is ⟧ u i scoind[ is ] S cn Su with cn Su ... | rn , c , refl , pr = sfold (rn , c , refl , λ i → λ where .force → scoind[ is ] S cn (pr i)) {- Apply Rule -} apply-scoind : ∀{𝓁c 𝓁p 𝓁n}{is : IS {𝓁c} {𝓁p} {𝓁n} U} → (rn : is .Names) → RClosed (is .rules rn) (λ u → ∀{i} → SCoInd⟦ is ⟧ u i) apply-scoind {is = is} rn = prefix⇒closed (is .rules rn) {P = λ u → ∀{i} → SCoInd⟦ is ⟧ u i } λ{(c , refl , pr) → sfold (rn , c , refl , λ i → λ where .force → pr i)} {- Postfix - Prefix -} scoind-postfix : ∀{𝓁c 𝓁p 𝓁n}{is : IS {𝓁c} {𝓁p} {𝓁n} U} → (λ u → ∀{i} → SCoInd⟦ is ⟧ u i) ⊆ ISF[ is ] (λ u → ∀{i} → SCoInd⟦ is ⟧ u i) scoind-postfix p-scoind with p-scoind ... | sfold (rn , c , refl , pr) = rn , c , refl , λ i → (pr i) .force scoind-prefix : ∀{𝓁c 𝓁p 𝓁n}{is : IS {𝓁c} {𝓁p} {𝓁n} U} → ISF[ is ] (λ u → ∀{i} → SCoInd⟦ is ⟧ u i) ⊆ λ u → ∀{i} → SCoInd⟦ is ⟧ u i scoind-prefix (rn , c , refl , pr) = apply-scoind rn c pr
{ "alphanum_fraction": 0.5191285866, "avg_line_length": 36.1923076923, "ext": "agda", "hexsha": "2ff8a5d17995a697e9cfc6cdf4b1f0877a4371bc", "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": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "boystrange/FairSubtypingAgda", "max_forks_repo_path": "src/is-lib/InfSys/SCoinduction.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "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": "boystrange/FairSubtypingAgda", "max_issues_repo_path": "src/is-lib/InfSys/SCoinduction.agda", "max_line_length": 142, "max_stars_count": 4, "max_stars_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "boystrange/FairSubtypingAgda", "max_stars_repo_path": "src/is-lib/InfSys/SCoinduction.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-24T14:38:47.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-29T14:32:30.000Z", "num_tokens": 849, "size": 1882 }
{-# OPTIONS --cubical --no-exact-split --safe #-} module Cubical.Structures.Queue where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Foundations.FunExtEquiv open import Cubical.Foundations.Equiv open import Cubical.Foundations.SIP renaming (SNS-PathP to SNS) open import Cubical.Structures.Pointed open import Cubical.Data.Unit open import Cubical.Data.Sum open import Cubical.Data.Prod.Base hiding (_×_) renaming (_×Σ_ to _×_) -- Developing Queues as a standard notion of structure, see -- https://github.com/ecavallo/cubical/blob/queue/Cubical/Experiments/Queue.agda -- for the original development variable ℓ ℓ' : Level -- We start fixing a set A on which we define what it means for a type Q to have -- a Queue structure (wrt. A) module Queues-on (A : Type ℓ) (Aset : isSet A) where -- A Queue structure has three components, the empty Queue, a push function and a pop function -- We first deal with push and pop as separate structures left-action-structure : Type ℓ → Type ℓ left-action-structure X = A → X → X Left-Action : Type (ℓ-suc ℓ) Left-Action = TypeWithStr ℓ left-action-structure left-action-iso : StrIso left-action-structure ℓ left-action-iso (X , l) (Y , m) e = ∀ a x → e .fst (l a x) ≡ m a (e .fst x) Left-Action-is-SNS : SNS {ℓ} left-action-structure left-action-iso Left-Action-is-SNS = SNS-≡→SNS-PathP left-action-iso ((λ _ _ → funExt₂Equiv)) -- Now for the pop-map as a structure -- First, a few preliminary results that we will need later pop-map-forward : {X Y : Type ℓ} → (X → Y) → Unit ⊎ (X × A) → Unit ⊎ (Y × A) pop-map-forward f (inl tt) = inl tt pop-map-forward f (inr (x , a)) = inr (f x , a) pop-map-forward-∘ :{B C D : Type ℓ} (g : C → D) (f : B → C) → ∀ r → pop-map-forward {X = C} g (pop-map-forward f r) ≡ pop-map-forward (λ b → g (f b)) r pop-map-forward-∘ g f (inl tt) = refl pop-map-forward-∘ g f (inr (b , a)) = refl pop-map-lemma : {X : Type ℓ} → idfun (Unit ⊎ (X × A)) ≡ pop-map-forward (idfun X) pop-map-lemma {X = X} = funExt γ where γ : ∀ z → z ≡ pop-map-forward (idfun X) z γ (inl tt) = refl γ (inr xa) = refl pop-structure : Type ℓ → Type ℓ pop-structure X = X → Unit ⊎ (X × A) Pop : Type (ℓ-suc ℓ) Pop = TypeWithStr ℓ pop-structure pop-iso : StrIso pop-structure ℓ pop-iso (X , p) (Y , q) e = ∀ x → pop-map-forward (e .fst) (p x) ≡ q (e .fst x) Pop-is-SNS : SNS {ℓ} pop-structure pop-iso Pop-is-SNS = SNS-≡→SNS-PathP pop-iso (λ p q → (subst (λ f → (∀ x → f (p x) ≡ q x) ≃ (p ≡ q)) pop-map-lemma funExtEquiv)) -- Now we can do Queues: queue-structure : Type ℓ → Type ℓ queue-structure Q = Q × (A → Q → Q) × (Q → Unit ⊎ (Q × A)) Queue : Type (ℓ-suc ℓ) Queue = TypeWithStr ℓ queue-structure queue-iso : StrIso queue-structure ℓ queue-iso (Q₁ , emp₁ , push₁ , pop₁) (Q₂ , emp₂ , push₂ , pop₂) e = (e .fst emp₁ ≡ emp₂) × (∀ a q → e .fst (push₁ a q) ≡ push₂ a (e .fst q)) × (∀ q → pop-map-forward (e .fst) (pop₁ q) ≡ pop₂ (e .fst q)) Queue-is-SNS : SNS {ℓ₁ = ℓ} queue-structure queue-iso Queue-is-SNS = join-SNS pointed-structure pointed-iso pointed-is-SNS (λ X → (left-action-structure X) × (pop-structure X)) (λ B C e → (∀ a q → e .fst (B .snd .fst a q) ≡ C .snd .fst a (e .fst q)) × (∀ q → pop-map-forward (e .fst) (B .snd .snd q) ≡ C .snd .snd (e .fst q))) (join-SNS left-action-structure left-action-iso Left-Action-is-SNS pop-structure pop-iso Pop-is-SNS ) -- Should we add further axioms for Queues? -- Some suggestions: queue-axioms : (Q : Type ℓ) → queue-structure Q → Type ℓ queue-axioms Q (emp , push , pop) = (isSet Q) × (pop emp ≡ inl tt) × ∀ a → pop (push a emp) ≡ inr (emp , a) -- etc.
{ "alphanum_fraction": 0.6006485408, "avg_line_length": 34.5603448276, "ext": "agda", "hexsha": "66dd2cd274127ab713ee9ae1a344ddd916559c70", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "borsiemir/cubical", "max_forks_repo_path": "Cubical/Structures/Queue.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "borsiemir/cubical", "max_issues_repo_path": "Cubical/Structures/Queue.agda", "max_line_length": 121, "max_stars_count": null, "max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "borsiemir/cubical", "max_stars_repo_path": "Cubical/Structures/Queue.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1347, "size": 4009 }
{-# OPTIONS --without-K --safe --no-sized-types --no-guardedness --no-subtyping #-} module Agda.Builtin.String.Properties where open import Agda.Builtin.String open import Agda.Builtin.Equality primitive primStringToListInjective : ∀ a b → primStringToList a ≡ primStringToList b → a ≡ b
{ "alphanum_fraction": 0.7222222222, "avg_line_length": 25.5, "ext": "agda", "hexsha": "b1e33edd5c40899e5887f848d73253d27c1c481c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-09-15T14:36:15.000Z", "max_forks_repo_forks_event_min_datetime": "2015-09-15T14:36:15.000Z", "max_forks_repo_head_hexsha": "57165760eeffdbf2aec92b636cb92075d79ac7a3", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alexarice/agda", "max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/String/Properties.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "57165760eeffdbf2aec92b636cb92075d79ac7a3", "max_issues_repo_issues_event_max_datetime": "2015-09-15T15:49:15.000Z", "max_issues_repo_issues_event_min_datetime": "2015-09-15T15:49:15.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alexarice/agda", "max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/String/Properties.agda", "max_line_length": 85, "max_stars_count": 1, "max_stars_repo_head_hexsha": "57165760eeffdbf2aec92b636cb92075d79ac7a3", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alexarice/agda", "max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/String/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2016-05-20T13:58:52.000Z", "max_stars_repo_stars_event_min_datetime": "2016-05-20T13:58:52.000Z", "num_tokens": 78, "size": 306 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Instance.SimplicialSet where open import Level open import Categories.Category open import Categories.Category.Instance.Simplex open import Categories.Category.Construction.Presheaves SimplicialSet : ∀ o ℓ → Category (suc (o ⊔ ℓ)) (o ⊔ ℓ) (o ⊔ ℓ) SimplicialSet o ℓ = Presheaves {o′ = o} {ℓ′ = ℓ} Δ
{ "alphanum_fraction": 0.7335164835, "avg_line_length": 28, "ext": "agda", "hexsha": "36fc217ea3478f5385158d4331c86af8249080ff", "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/SimplicialSet.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/SimplicialSet.agda", "max_line_length": 62, "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/SimplicialSet.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": 111, "size": 364 }
-- 2010-10-05 Andreas module TerminationRecordPatternCoerce where data Empty : Set where record Unit : Set where constructor unit data Bool : Set where true false : Bool T : Bool -> Set T true = Unit T false = Empty data _==_ {A : Set}(a : A) : A -> Set where refl : a == a subst : forall {A a b} -> a == b -> {P : A -> Set} -> P a -> P b subst refl x = x -- Thorsten suggests on the Agda list thread "Coinductive families" -- to encode lists as records record List (A : Set) : Set where constructor list field isCons : Bool head : T isCons -> A tail : T isCons -> List A open List public -- However, we have to be careful to preserve termination -- in the presence of a lie postulate lie : {b : Bool} -> T b -- if the record constructor list was counted as structural increase -- this function would not be rejected f : {A : Set} -> (b : Bool) -> (l : List A) -> b == isCons l -> Unit f .false (list false h t) refl = unit f .true (list true h t) refl = f (isCons tl) tl refl where tl : List _ tl = t unit {- dot patterns inside of record patterns not supported! f true (list .true h t) refl = f (isCons tl) tl refl where tl : List _ tl = t unit -} -- however, it is almost like the following f' : {A : Set} -> (b : Bool) -> (l : List A) -> b == isCons l -> Unit f' false l p = unit f' true (list b' h t) p = f' (isCons tl) tl refl where tl : List _ tl = t (subst p {T} unit)
{ "alphanum_fraction": 0.6175051688, "avg_line_length": 24.593220339, "ext": "agda", "hexsha": "87be368b1a5aa666f4fef4ce7cbce5ee46c66df2", "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/fail/TerminationRecordPatternCoerce.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/fail/TerminationRecordPatternCoerce.agda", "max_line_length": 69, "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/fail/TerminationRecordPatternCoerce.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 456, "size": 1451 }
{-# OPTIONS --cubical #-} module Multidimensional.Data.Dir where open import Multidimensional.Data.Dir.Base public open import Multidimensional.Data.Dir.Properties public
{ "alphanum_fraction": 0.8092485549, "avg_line_length": 24.7142857143, "ext": "agda", "hexsha": "c078d3440b3caba6ab58349e060d305a99f7095e", "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": "55709dd950e319c4a105ace33ddaf8b955354add", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "wrrnhttn/agda-cubical-multidimensional", "max_forks_repo_path": "Multidimensional/Data/Dir.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "55709dd950e319c4a105ace33ddaf8b955354add", "max_issues_repo_issues_event_max_datetime": "2019-07-02T16:24:01.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-19T20:40:07.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "wrrnhttn/agda-cubical-multidimensional", "max_issues_repo_path": "Multidimensional/Data/Dir.agda", "max_line_length": 55, "max_stars_count": null, "max_stars_repo_head_hexsha": "55709dd950e319c4a105ace33ddaf8b955354add", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wrrnhttn/agda-cubical-multidimensional", "max_stars_repo_path": "Multidimensional/Data/Dir.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 35, "size": 173 }
-- Intuitionistic propositional calculus. -- Kripke-style semantics with exploding abstract worlds. module IPC.Semantics.KripkeExploding where open import IPC.Syntax.Common public -- Intuitionistic Kripke-CPS models, with exploding worlds. record Model : Set₁ where infix 3 _⊪ᵅ_ field World : Set -- Intuitionistic accessibility; preorder. _≤_ : World → World → Set refl≤ : ∀ {w} → w ≤ w trans≤ : ∀ {w w′ w″} → w ≤ w′ → w′ ≤ w″ → w ≤ w″ -- Strong forcing for atomic propositions; monotonic. _⊪ᵅ_ : World → Atom → Set mono⊪ᵅ : ∀ {P w w′} → w ≤ w′ → w ⊪ᵅ P → w′ ⊪ᵅ P -- Exploding. _‼_ : World → Ty → Set open Model {{…}} public -- Strong forcing and forcing, in a particular world of a particular model. module _ {{_ : Model}} where mutual infix 3 _⊪_ _⊪_ : World → Ty → Set w ⊪ α P = w ⊪ᵅ P w ⊪ A ▻ B = ∀ {w′} → w ≤ w′ → w′ ⊩ A → w′ ⊩ B w ⊪ A ∧ B = w ⊩ A × w ⊩ B w ⊪ ⊤ = 𝟙 w ⊪ ⊥ = 𝟘 w ⊪ A ∨ B = w ⊩ A ⊎ w ⊩ B infix 3 _⊩_ _⊩_ : World → Ty → Set w ⊩ A = ∀ {C w′} → w ≤ w′ → (∀ {w″} → w′ ≤ w″ → w″ ⊪ A → w″ ‼ C) → w′ ‼ C infix 3 _⊩⋆_ _⊩⋆_ : World → Cx Ty → Set w ⊩⋆ ∅ = 𝟙 w ⊩⋆ Ξ , A = w ⊩⋆ Ξ × w ⊩ A -- Monotonicity with respect to intuitionistic accessibility. module _ {{_ : Model}} where mutual mono⊪ : ∀ {A w w′} → w ≤ w′ → w ⊪ A → w′ ⊪ A mono⊪ {α P} ξ s = mono⊪ᵅ ξ s mono⊪ {A ▻ B} ξ f = λ ξ′ a → f (trans≤ ξ ξ′) a mono⊪ {A ∧ B} ξ (a , b) = mono⊩ {A} ξ a , mono⊩ {B} ξ b mono⊪ {⊤} ξ ∙ = ∙ mono⊪ {⊥} ξ () mono⊪ {A ∨ B} ξ (ι₁ a) = ι₁ (mono⊩ {A} ξ a) mono⊪ {A ∨ B} ξ (ι₂ b) = ι₂ (mono⊩ {B} ξ b) mono⊩ : ∀ {A w w′} → w ≤ w′ → w ⊩ A → w′ ⊩ A mono⊩ ξ a = λ ξ′ k′ → a (trans≤ ξ ξ′) k′ mono⊩⋆ : ∀ {Ξ w w′} → w ≤ w′ → w ⊩⋆ Ξ → w′ ⊩⋆ Ξ mono⊩⋆ {∅} ξ ∙ = ∙ mono⊩⋆ {Ξ , A} ξ (γ , a) = mono⊩⋆ {Ξ} ξ γ , mono⊩ {A} ξ a -- Additional useful equipment. module _ {{_ : Model}} where _⟪$⟫_ : ∀ {A B w} → w ⊪ A ▻ B → w ⊩ A → w ⊩ B s ⟪$⟫ a = s refl≤ a return : ∀ {A w} → w ⊪ A → w ⊩ A return {A} a = λ ξ k → k refl≤ (mono⊪ {A} ξ a) bind : ∀ {A B w} → w ⊩ A → (∀ {w′} → w ≤ w′ → w′ ⊪ A → w′ ⊩ B) → w ⊩ B bind a k = λ ξ k′ → a ξ (λ ξ′ a′ → k (trans≤ ξ ξ′) a′ refl≤ (λ ξ″ a″ → k′ (trans≤ ξ′ ξ″) a″)) -- Forcing in a particular world of a particular model, for sequents. module _ {{_ : Model}} where infix 3 _⊩_⇒_ _⊩_⇒_ : World → Cx Ty → Ty → Set w ⊩ Γ ⇒ A = w ⊩⋆ Γ → w ⊩ A infix 3 _⊩_⇒⋆_ _⊩_⇒⋆_ : World → Cx Ty → Cx Ty → Set w ⊩ Γ ⇒⋆ Ξ = w ⊩⋆ Γ → w ⊩⋆ Ξ -- Entailment, or forcing in all worlds of all models, for sequents. infix 3 _⊨_ _⊨_ : Cx Ty → Ty → Set₁ Γ ⊨ A = ∀ {{_ : Model}} {w : World} → w ⊩ Γ ⇒ A infix 3 _⊨⋆_ _⊨⋆_ : Cx Ty → Cx Ty → Set₁ Γ ⊨⋆ Ξ = ∀ {{_ : Model}} {w : World} → w ⊩ Γ ⇒⋆ Ξ -- Additional useful equipment, for sequents. module _ {{_ : Model}} where lookup : ∀ {A Γ w} → A ∈ Γ → w ⊩ Γ ⇒ A lookup top (γ , a) = a lookup (pop i) (γ , b) = lookup i γ
{ "alphanum_fraction": 0.4690089493, "avg_line_length": 25.7863247863, "ext": "agda", "hexsha": "e7ae3fe3c73474b78405098d589b64b19c143e35", "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": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/hilbert-gentzen", "max_forks_repo_path": "IPC/Semantics/KripkeExploding.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/hilbert-gentzen", "max_issues_repo_path": "IPC/Semantics/KripkeExploding.agda", "max_line_length": 95, "max_stars_count": 29, "max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/hilbert-gentzen", "max_stars_repo_path": "IPC/Semantics/KripkeExploding.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z", "num_tokens": 1541, "size": 3017 }
module erasure where open import Relation.Binary.PropositionalEquality using (_≡_; refl) open import decidable using (Dec; yes; no; Bool; true; false; ⌊_⌋; _∧_; _×-dec_; _∨_; _⊎-dec_; not; ¬?) -- erasureを使うことで真偽値の論理積とdecidableの論理積が等しくなることの証明 ∧-× : ∀ {A B : Set} (x : Dec A) (y : Dec B) → ⌊ x ⌋ ∧ ⌊ y ⌋ ≡ ⌊ x ×-dec y ⌋ ∧-× (yes a) (yes b) = refl ∧-× (yes a) (no b) = refl ∧-× (no a) (yes b) = refl ∧-× (no a) (no b) = refl -- erasureを使うことで真偽値の論理和とdecidableの論理和が等しくなることの証明 ∨-⊎ : ∀ {A B : Set} (x : Dec A) (y : Dec B) → ⌊ x ⌋ ∨ ⌊ y ⌋ ≡ ⌊ x ⊎-dec y ⌋ ∨-⊎ (yes a) (yes b) = refl ∨-⊎ (yes a) (no b) = refl ∨-⊎ (no a) (yes b) = refl ∨-⊎ (no a) (no b) = refl -- erasureを使うことで真偽値の否定とdecidableの否定が等しくなることの証明 not-¬ : ∀ {A : Set} (x : Dec A) → not ⌊ x ⌋ ≡ ⌊ ¬? x ⌋ not-¬ (yes a) = refl not-¬ (no a) = refl
{ "alphanum_fraction": 0.5452292441, "avg_line_length": 33.625, "ext": "agda", "hexsha": "450a6a2f1c222f7a512e00fb081d40e6dfb71600", "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": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_path": "part1/decidable/erasure.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "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": "akiomik/plfa-solutions", "max_issues_repo_path": "part1/decidable/erasure.agda", "max_line_length": 103, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_path": "part1/decidable/erasure.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "num_tokens": 498, "size": 807 }
open import Issue2229Reexport1 B = A
{ "alphanum_fraction": 0.7894736842, "avg_line_length": 9.5, "ext": "agda", "hexsha": "e90b695f5a6944421d5d0335c07dd13e365d5cb2", "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/Issue2229-1.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue2229-1.agda", "max_line_length": 30, "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/Issue2229-1.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 13, "size": 38 }
{-# OPTIONS --cubical #-} open import Agda.Primitive.Cubical postulate Id : ∀ {ℓ} {A : Set ℓ} → A → A → Set ℓ Path : ∀ {ℓ} {A : Set ℓ} → A → A → Set ℓ PathP : ∀ {ℓ} (A : I → Set ℓ) → A i0 → A i1 → Set ℓ {-# BUILTIN PATH Path #-} {-# BUILTIN PATHP PathP #-} {-# BUILTIN ID Id #-} {-# BUILTIN CONID conid #-} reflPath : ∀ {ℓ} {A : Set ℓ} {x : A} → Path x x reflPath {x = x} = λ i → x reflId : ∀ {ℓ} {A : Set ℓ} {x : A} → Id x x reflId {x = x} = conid i1 reflPath primitive primIdJ : ∀ {ℓ ℓ'} {A : Set ℓ} {x : A} (P : ∀ y → Id x y → Set ℓ') → P x reflId → {y : A} (p : Id x y) → P y p Id-comp-Id : ∀ {ℓ ℓ'} {A : Set ℓ} {x : A} (P : ∀ y → Id x y → Set ℓ') → (b : P x reflId) → Id (primIdJ P b reflId) b Id-comp-Id P b = reflId Id-comp-Path : ∀ {ℓ ℓ'} {A : Set ℓ} {x : A} (P : ∀ y → Id x y → Set ℓ') → (b : P x reflId) → Path (primIdJ P b reflId) b Id-comp-Path P b = λ i → b
{ "alphanum_fraction": 0.4595162986, "avg_line_length": 29.71875, "ext": "agda", "hexsha": "2a26d0a83e1c1a200f2a71afc9c76c1d6d99ae33", "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": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "asr/eagda", "max_forks_repo_path": "test/Succeed/Issue2846.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "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": "asr/eagda", "max_issues_repo_path": "test/Succeed/Issue2846.agda", "max_line_length": 71, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "asr/eagda", "max_stars_repo_path": "test/Succeed/Issue2846.agda", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "num_tokens": 428, "size": 951 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Divisibility and coprimality ------------------------------------------------------------------------ module Data.Integer.Divisibility where open import Function open import Data.Integer open import Data.Integer.Properties import Data.Nat.Divisibility as ℕ import Data.Nat.Coprimality as ℕ open import Level open import Relation.Binary open import Relation.Binary.PropositionalEquality -- Divisibility. infix 4 _∣_ _∣_ : Rel ℤ zero _∣_ = ℕ._∣_ on ∣_∣ -- Coprimality. Coprime : Rel ℤ zero Coprime = ℕ.Coprime on ∣_∣ -- If i divides jk and is coprime to j, then it divides k. coprime-divisor : ∀ i j k → Coprime i j → i ∣ j * k → i ∣ k coprime-divisor i j k c eq = ℕ.coprime-divisor c (subst (ℕ._∣_ ∣ i ∣) (abs-*-commute j k) eq)
{ "alphanum_fraction": 0.5950413223, "avg_line_length": 24.2, "ext": "agda", "hexsha": "bb3b23cfd08eb292aaae526b9ee332288e557c4b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Integer/Divisibility.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Integer/Divisibility.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Integer/Divisibility.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 244, "size": 847 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Closures of a unary relation with respect to a binary one. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Relation.Unary.Closure.Base {a b} {A : Set a} (R : Rel A b) where open import Level open import Relation.Unary using (Pred) ------------------------------------------------------------------------ -- Definitions -- We start with the definition of □ ("box") which is named after the box -- modality in modal logic. `□ T x` states that all the elements one step -- away from `x` with respect to the relation R satisfy `T`. □ : ∀ {t} → Pred A t → Pred A (a ⊔ b ⊔ t) □ T x = ∀ {y} → R x y → T y -- Use cases of □ include: -- * The definition of the accessibility predicate corresponding to R: -- data Acc (x : A) : Set (a ⊔ b) where -- step : □ Acc x → Acc x -- * The characterization of stability under weakening: picking R to be -- `Data.List.Relation.Sublist.Inductive`, `∀ {Γ} → Tm Γ → □ T Γ` -- corresponds to the fact that we have a notion of weakening for `Tm`. -- Closed: whenever we have a value in one context, we can get one in any -- related context. record Closed {t} (T : Pred A t) : Set (a ⊔ b ⊔ t) where field next : ∀ {x} → T x → □ T x ------------------------------------------------------------------------ -- Properties module _ {t} {T : Pred A t} where reindex : Transitive R → ∀ {x y} → R x y → □ T x → □ T y reindex trans x∼y □Tx y∼z = □Tx (trans x∼y y∼z) -- Provided that R is reflexive and Transitive, □ is a comonad map : ∀ {u} {U : Pred A u} {x} → (∀ {x} → T x → U x) → □ T x → □ U x map f □Tx x~y = f (□Tx x~y) extract : Reflexive R → ∀ {x} → □ T x → T x extract refl □Tx = □Tx refl duplicate : Transitive R → ∀ {x} → □ T x → □ (□ T) x duplicate trans □Tx x∼y y∼z = □Tx (trans x∼y y∼z) -- Provided that R is transitive, □ is the Closure operator -- i.e. for any `T`, `□ T` is closed. □-closed : Transitive R → ∀ {t} {T : Pred A t} → Closed (□ T) □-closed trans = record { next = duplicate trans }
{ "alphanum_fraction": 0.5256880734, "avg_line_length": 34.0625, "ext": "agda", "hexsha": "c0f61c294d6eadebb80b15e33f356a3ad11c7354", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Unary/Closure/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Unary/Closure/Base.agda", "max_line_length": 73, "max_stars_count": 5, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Unary/Closure/Base.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": 673, "size": 2180 }
module Base.Prelude.List where open import Size using (Size; ↑_) open import Base.Free using (Free; pure) data List (Shape : Set) (Pos : Shape → Set) (A : Set) : {Size} → Set where cons : ∀ {i : Size} → Free Shape Pos A → Free Shape Pos (List Shape Pos A {i}) → List Shape Pos A {↑ i} nil : List Shape Pos A pattern Cons mx mxs = pure (cons mx mxs) pattern Nil = pure nil
{ "alphanum_fraction": 0.631043257, "avg_line_length": 32.75, "ext": "agda", "hexsha": "6ace5e4b16fa58a8e8d3a7548efad2bd4b3f1108", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-05-14T07:48:41.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-08T11:23:46.000Z", "max_forks_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "FreeProving/free-compiler", "max_forks_repo_path": "base/agda/Base/Prelude/List.agda", "max_issues_count": 120, "max_issues_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9", "max_issues_repo_issues_event_max_datetime": "2020-12-08T07:46:01.000Z", "max_issues_repo_issues_event_min_datetime": "2020-04-09T09:40:39.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "FreeProving/free-compiler", "max_issues_repo_path": "base/agda/Base/Prelude/List.agda", "max_line_length": 105, "max_stars_count": 36, "max_stars_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "FreeProving/free-compiler", "max_stars_repo_path": "base/agda/Base/Prelude/List.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-21T13:38:23.000Z", "max_stars_repo_stars_event_min_datetime": "2020-02-06T11:03:34.000Z", "num_tokens": 118, "size": 393 }
------------------------------------------------------------------------ -- The Agda standard library -- -- The Maybe type and some operations ------------------------------------------------------------------------ -- The definitions in this file are reexported by Data.Maybe. {-# OPTIONS --without-K --safe #-} module Data.Maybe.Base where open import Level open import Data.Bool.Base using (Bool; true; false; not) open import Data.Unit.Base using (⊤) open import Data.These.Base using (These; this; that; these) open import Data.Product as Prod using (_×_; _,_) open import Function.Base open import Relation.Nullary.Reflects open import Relation.Nullary private variable a b c : Level A : Set a B : Set b C : Set c ------------------------------------------------------------------------ -- Definition data Maybe (A : Set a) : Set a where nothing : Maybe A just : (x : A) → Maybe A ------------------------------------------------------------------------ -- Some operations boolToMaybe : Bool → Maybe ⊤ boolToMaybe true = just _ boolToMaybe false = nothing is-just : Maybe A → Bool is-just (just _) = true is-just nothing = false is-nothing : Maybe A → Bool is-nothing = not ∘ is-just decToMaybe : Dec A → Maybe A decToMaybe ( true because [a]) = just (invert [a]) decToMaybe (false because _ ) = nothing -- A dependent eliminator. maybe : ∀ {A : Set a} {B : Maybe A → Set b} → ((x : A) → B (just x)) → B nothing → (x : Maybe A) → B x maybe j n (just x) = j x maybe j n nothing = n -- A non-dependent eliminator. maybe′ : (A → B) → B → Maybe A → B maybe′ = maybe -- A defaulting mechanism fromMaybe : A → Maybe A → A fromMaybe = maybe′ id -- A safe variant of "fromJust". If the value is nothing, then the -- return type is the unit type. module _ {a} {A : Set a} where From-just : Maybe A → Set a From-just (just _) = A From-just nothing = Lift a ⊤ from-just : (x : Maybe A) → From-just x from-just (just x) = x from-just nothing = _ -- Functoriality: map map : (A → B) → Maybe A → Maybe B map f = maybe (just ∘ f) nothing -- Applicative: ap ap : Maybe (A → B) → Maybe A → Maybe B ap nothing = const nothing ap (just f) = map f -- Monad: bind infixl 1 _>>=_ _>>=_ : Maybe A → (A → Maybe B) → Maybe B nothing >>= f = nothing just a >>= f = f a -- Alternative: <∣> _<∣>_ : Maybe A → Maybe A → Maybe A just x <∣> my = just x nothing <∣> my = my ------------------------------------------------------------------------ -- Aligning and zipping alignWith : (These A B → C) → Maybe A → Maybe B → Maybe C alignWith f (just a) (just b) = just (f (these a b)) alignWith f (just a) nothing = just (f (this a)) alignWith f nothing (just b) = just (f (that b)) alignWith f nothing nothing = nothing zipWith : (A → B → C) → Maybe A → Maybe B → Maybe C zipWith f (just a) (just b) = just (f a b) zipWith _ _ _ = nothing align : Maybe A → Maybe B → Maybe (These A B) align = alignWith id zip : Maybe A → Maybe B → Maybe (A × B) zip = zipWith _,_ ------------------------------------------------------------------------ -- Injections. thisM : A → Maybe B → These A B thisM a = maybe′ (these a) (this a) thatM : Maybe A → B → These A B thatM = maybe′ these that
{ "alphanum_fraction": 0.5446182153, "avg_line_length": 23.9779411765, "ext": "agda", "hexsha": "8b16fc86c9b0fb489e90f433feb65372bb660cdb", "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/Maybe/Base.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/Maybe/Base.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/Maybe/Base.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": 929, "size": 3261 }
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.Pushout where open import Cubical.HITs.Pushout.Base public open import Cubical.HITs.Pushout.Properties public
{ "alphanum_fraction": 0.7865853659, "avg_line_length": 27.3333333333, "ext": "agda", "hexsha": "240af15e80abd8e14c233b48fb180362716868c4", "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/HITs/Pushout.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/HITs/Pushout.agda", "max_line_length": 50, "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/HITs/Pushout.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 43, "size": 164 }
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.Hopf where open import Cubical.Core.Glue open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Data.Int open import Cubical.Data.Prod open import Cubical.HITs.S1 open import Cubical.HITs.S2 open import Cubical.HITs.S3 open import Cubical.HITs.Susp open import Cubical.HITs.Join open import Cubical.HITs.Interval renaming ( zero to I0 ; one to I1 ) Border : (x : S¹) → (j : I) → Partial (j ∨ ~ j) (Σ Type₀ (λ T → T ≃ S¹)) Border x j (j = i0) = S¹ , rot x , rotIsEquiv x Border x j (j = i1) = S¹ , idEquiv S¹ -- Hopf fibration using SuspS¹ HopfSuspS¹ : SuspS¹ → Type₀ HopfSuspS¹ north = S¹ HopfSuspS¹ south = S¹ HopfSuspS¹ (merid x j) = Glue S¹ (Border x j) -- Hopf fibration using S² -- TODO : prove that it is equivalent to HopfSuspS¹ HopfS² : S² → Type₀ HopfS² base = S¹ HopfS² (surf i j) = Glue S¹ (λ { (i = i0) → _ , idEquiv S¹ ; (i = i1) → _ , idEquiv S¹ ; (j = i0) → _ , idEquiv S¹ ; (j = i1) → _ , _ , rotIsEquiv (loop i) } ) -- Hopf fibration using more direct definition of the rot equivalence -- TODO : prove that it is equivalent to HopfSuspS¹ HopfS²' : S² → Type₀ HopfS²' base = S¹ HopfS²' (surf i j) = Glue S¹ (λ { (i = i0) → _ , rotLoopEquiv i0 ; (i = i1) → _ , rotLoopEquiv i0 ; (j = i0) → _ , rotLoopEquiv i0 ; (j = i1) → _ , rotLoopEquiv i } ) -- Total space of the fibration TotalHopf : Type₀ TotalHopf = Σ SuspS¹ HopfSuspS¹ -- Forward direction filler-1 : I → (j : I) → (y : S¹) → Glue S¹ (Border y j) → join S¹ S¹ filler-1 i j y x = hfill (λ t → λ { (j = i0) → inl (rotInv-1 x y t) ; (j = i1) → inr x }) (inS (push ((unglue (j ∨ ~ j) x) * inv y) (unglue (j ∨ ~ j) x) j)) i TotalHopf→JoinS¹S¹ : TotalHopf → join S¹ S¹ TotalHopf→JoinS¹S¹ (north , x) = inl x TotalHopf→JoinS¹S¹ (south , x) = inr x TotalHopf→JoinS¹S¹ (merid y j , x) = filler-1 i1 j y x -- Backward direction JoinS¹S¹→TotalHopf : join S¹ S¹ → TotalHopf JoinS¹S¹→TotalHopf (inl x) = (north , x) JoinS¹S¹→TotalHopf (inr x) = (south , x) JoinS¹S¹→TotalHopf (push y x j) = (merid (inv y * x) j , glue (λ { (j = i0) → y ; (j = i1) → x }) (rotInv-2 x y j)) -- Now for the homotopies, we will need to fill squares indexed by x y : S¹ with value in S¹ -- Some will be extremeley tough, but happen to be easy when x = y = base -- therefore, we fill them for x = y = base and then use the connectedness of S¹ × S¹ and -- the discreteness of ΩS¹ to get general fillers. -- To proceed with that strategy, we first need a lemma : -- the sections of the trivial fibration λ (_ : S¹) (_ : S¹) → Int are constant -- this should be generalized to a constant fibration over a connected space with -- discrete fiber fibInt : S¹ → S¹ → Type₀ fibInt _ _ = Int S¹→HSet : (A : Type₀) (p : isSet A) (F : S¹ → A) (x : S¹) → F base ≡ F x S¹→HSet A p F base = refl {x = F base} S¹→HSet A p F (loop i) = f' i where f : PathP (λ i → F base ≡ F (loop i)) refl (cong F loop) f i = λ j → F (loop (i ∧ j)) L : cong F loop ≡ refl L = p (F base) (F base) (f i1) refl f' : PathP (λ i → F base ≡ F (loop i)) (refl {x = F base}) (refl {x = F base}) f' = transport (λ i → PathP (λ j → F base ≡ F (loop j)) refl (L i)) f constant-loop : (F : S¹ → S¹ → Int) → (x y : S¹) → F base base ≡ F x y constant-loop F x y = L0 ∙ L1 where p : isSet (S¹ → Int) p = hLevelPi 2 (λ _ → isSetInt) L : F base ≡ F x L = S¹→HSet (S¹ → Int) p F x L0 : F base base ≡ F x base L0 i = L i base L1 : F x base ≡ F x y L1 = S¹→HSet Int isSetInt (F x) y discretefib : (F : S¹ → S¹ → Type₀) → Type₀ discretefib F = (a : (x y : S¹) → F x y) → (b : (x y : S¹) → F x y) → (a base base ≡ b base base) → (x y : S¹) → a x y ≡ b x y discretefib-fibInt : discretefib fibInt discretefib-fibInt a b h x y i = hcomp (λ t → λ { (i = i0) → constant-loop a x y t ; (i = i1) → constant-loop b x y t }) (h i) -- first homotopy assocFiller-3-aux : I → I → I → I → S¹ assocFiller-3-aux x y j i = hfill (λ t → λ { (i = i0) → rotInv-1 (loop y) (loop (~ y) * loop x) t ; (i = i1) → rotInv-3 (loop y) (loop x) t ; (x = i0) (y = i0) → base ; (x = i0) (y = i1) → base ; (x = i1) (y = i0) → base ; (x = i1) (y = i1) → base }) (inS ((rotInv-2 (loop x) (loop y) i) * (inv (loop (~ y) * loop x)))) j -- assocFiller-3-endpoint is used only in the type of the next function, to specify the -- second endpoint. -- However, I only need the first endpoint, but I cannot specify only one of them as is. -- TODO : use cubical extension types when available to remove assocFiller-3-endpoint assocFiller-3-endpoint : (x : S¹) → (y : S¹) → y ≡ y assocFiller-3-endpoint base base i = base assocFiller-3-endpoint (loop x) base i = assocFiller-3-aux x i0 i1 i assocFiller-3-endpoint base (loop y) i = assocFiller-3-aux i0 y i1 i assocFiller-3-endpoint (loop x) (loop y) i = assocFiller-3-aux x y i1 i assocFiller-3 : (x : S¹) → (y : S¹) → PathP (λ j → rotInv-1 y (inv y * x) j ≡ rotInv-3 y x j) (λ i → ((rotInv-2 x y i) * (inv (inv y * x)))) (assocFiller-3-endpoint x y) assocFiller-3 base base j i = base assocFiller-3 (loop x) base j i = assocFiller-3-aux x i0 j i assocFiller-3 base (loop y) j i = assocFiller-3-aux i0 y j i assocFiller-3 (loop x) (loop y) j i = assocFiller-3-aux x y j i assoc-3 : (_ y : S¹) → basedΩS¹ y assoc-3 x y i = assocFiller-3 x y i1 i fibInt≡fibAssoc-3 : fibInt ≡ (λ _ y → basedΩS¹ y) fibInt≡fibAssoc-3 i = λ x y → basedΩS¹≡Int y (~ i) discretefib-fibAssoc-3 : discretefib (λ _ y → basedΩS¹ y) discretefib-fibAssoc-3 = transp (λ i → discretefib (fibInt≡fibAssoc-3 i)) i0 discretefib-fibInt assocConst-3 : (x y : S¹) → assoc-3 x y ≡ refl assocConst-3 x y = discretefib-fibAssoc-3 assoc-3 (λ _ _ → refl) refl x y assocSquare-3 : I → I → S¹ → S¹ → S¹ assocSquare-3 i j x y = hcomp (λ t → λ { (i = i0) → assocFiller-3 x y j i0 ; (i = i1) → assocFiller-3 x y j i1 ; (j = i0) → assocFiller-3 x y i0 i ; (j = i1) → assocConst-3 x y t i }) (assocFiller-3 x y j i) filler-3 : I → I → S¹ → S¹ → join S¹ S¹ filler-3 i j y x = hcomp (λ t → λ { (i = i0) → filler-1 t j (inv y * x) (glue (λ { (j = i0) → y ; (j = i1) → x }) (rotInv-2 x y j)) ; (i = i1) → push (rotInv-3 y x t) x j ; (j = i0) → inl (assocSquare-3 i t x y) ; (j = i1) → inr x }) (push ((rotInv-2 x y (i ∨ j)) * (inv (inv y * x))) (rotInv-2 x y (i ∨ j)) j) JoinS¹S¹→TotalHopf→JoinS¹S¹ : ∀ x → TotalHopf→JoinS¹S¹ (JoinS¹S¹→TotalHopf x) ≡ x JoinS¹S¹→TotalHopf→JoinS¹S¹ (inl x) i = inl x JoinS¹S¹→TotalHopf→JoinS¹S¹ (inr x) i = inr x JoinS¹S¹→TotalHopf→JoinS¹S¹ (push y x j) i = filler-3 i j y x -- Second homotopy -- This HIT is the total space of the Hopf fibration but the ends of SuspS¹ have not been -- glued together yet — which makes it into a cylinder. -- This allows to write compositions that do not properly match at the endpoints. However, -- I suspect it is unnecessary. TODO : do without PseudoHopf PseudoHopf : Type₀ PseudoHopf = (S¹ × Interval) × S¹ PseudoHopf-π1 : PseudoHopf → S¹ PseudoHopf-π1 ((y , _) , _) = y PseudoHopf-π2 : PseudoHopf → S¹ PseudoHopf-π2 (_ , x) = x assocFiller-4-aux : I → I → I → I → S¹ assocFiller-4-aux x y j i = hfill (λ t → λ { (i = i0) → ((inv (loop y * loop x * loop (~ y))) * (loop y * loop x)) * (rotInv-1 (loop x) (loop y) t) ; (i = i1) → (rotInv-4 (loop y) (loop y * loop x) (~ t)) * loop x ; (x = i0) (y = i0) → base ; (x = i0) (y = i1) → base ; (x = i1) (y = i0) → base ; (x = i1) (y = i1) → base }) (inS (rotInv-2 (loop y * loop x) (loop y * loop x * loop (~ y)) i)) j -- See assocFiller-3-endpoint -- TODO : use cubical extension types when available to remove assocFiller-4-endpoint assocFiller-4-endpoint : (x y : S¹) → basedΩS¹ (((inv (y * x * inv y)) * (y * x)) * x) assocFiller-4-endpoint base base i = base assocFiller-4-endpoint (loop x) base i = assocFiller-4-aux x i0 i1 i assocFiller-4-endpoint base (loop y) i = assocFiller-4-aux i0 y i1 i assocFiller-4-endpoint (loop x) (loop y) i = assocFiller-4-aux x y i1 i assocFiller-4 : (x y : S¹) → PathP (λ j → ((inv (y * x * inv y)) * (y * x)) * (rotInv-1 x y j) ≡ (rotInv-4 y (y * x) (~ j)) * x) (λ i → (rotInv-2 (y * x) (y * x * inv y) i)) (assocFiller-4-endpoint x y) assocFiller-4 base base j i = base assocFiller-4 (loop x) base j i = assocFiller-4-aux x i0 j i assocFiller-4 base (loop y) j i = assocFiller-4-aux i0 y j i assocFiller-4 (loop x) (loop y) j i = assocFiller-4-aux x y j i assoc-4 : (x y : S¹) → basedΩS¹ (((inv (y * x * inv y)) * (y * x)) * x) assoc-4 x y i = assocFiller-4 x y i1 i fibInt≡fibAssoc-4 : fibInt ≡ (λ x y → basedΩS¹ (((inv (y * x * inv y)) * (y * x)) * x)) fibInt≡fibAssoc-4 i = λ x y → basedΩS¹≡Int (((inv (y * x * inv y)) * (y * x)) * x) (~ i) discretefib-fibAssoc-4 : discretefib (λ x y → basedΩS¹ (((inv (y * x * inv y)) * (y * x)) * x)) discretefib-fibAssoc-4 = transp (λ i → discretefib (fibInt≡fibAssoc-4 i)) i0 discretefib-fibInt assocConst-4 : (x y : S¹) → assoc-4 x y ≡ refl assocConst-4 x y = discretefib-fibAssoc-4 assoc-4 (λ _ _ → refl) refl x y assocSquare-4 : I → I → S¹ → S¹ → S¹ assocSquare-4 i j x y = hcomp (λ t → λ { (i = i0) → assocFiller-4 x y j i0 ; (i = i1) → assocFiller-4 x y j i1 ; (j = i0) → assocFiller-4 x y i0 i ; (j = i1) → assocConst-4 x y t i }) (assocFiller-4 x y j i) filler-4-0 : (_ j : I) → (y : S¹) → Glue S¹ (Border y j) → PseudoHopf filler-4-0 i j y x = let x' = unglue (j ∨ ~ j) x in hfill (λ t → λ { (j = i0) → ((inv (y * x * inv y) * (y * x) , I0) , inv (y * x * inv y) * (y * x) * (rotInv-1 x y t)) ; (j = i1) → ((inv (x * inv y) * x , I1) , x) }) (inS ((inv (x' * inv y) * x' , seg j) , rotInv-2 x' (x' * inv y) j)) i filler-4-1 : (_ j : I) → (y : S¹) → Glue S¹ (Border y j) → PseudoHopf filler-4-1 i j y x = let x' = unglue (j ∨ ~ j) x in hfill (λ t → λ { (j = i0) → ((inv (y * x * inv y) * (y * x) , I0) , (rotInv-4 y (y * x) (~ t)) * x) ; (j = i1) → ((inv (x * inv y) * x , I1) , x) }) (inS ((inv (x' * inv y) * x' , seg j) , unglue (j ∨ ~ j) x)) i filler-4-2 : (_ j : I) → (y : S¹) → Glue S¹ (Border y j) → TotalHopf filler-4-2 i j y x = let x' = unglue (j ∨ ~ j) x in hcomp (λ t → λ { (i = i0) → JoinS¹S¹→TotalHopf (filler-1 t j y x) ; (i = i1) → (merid (PseudoHopf-π1 (filler-4-0 t j y x)) j , glue (λ { (j = i0) → rotInv-1 x y t ; (j = i1) → x }) (PseudoHopf-π2 (filler-4-0 t j y x))) ; (j = i0) → (north , rotInv-1 x y t) ; (j = i1) → (south , x) }) (merid (inv (x' * inv y) * x') j , glue (λ { (j = i0) → y * x * inv y ; (j = i1) → x }) (rotInv-2 x' (x' * inv y) j)) filler-4-3 : (_ j : I) → (y : S¹) → Glue S¹ (Border y j) → PseudoHopf filler-4-3 i j y x = let x' = unglue (j ∨ ~ j) x in hcomp (λ t → λ { (i = i0) → filler-4-0 t j y x ; (i = i1) → filler-4-1 t j y x ; (j = i0) → ((inv (y * x * inv y) * (y * x) , I0) , assocSquare-4 i t x y) ; (j = i1) → ((inv (x * inv y) * x , I1) , x) }) ((inv (x' * inv y) * x' , seg j) , rotInv-2 x' (x' * inv y) (i ∨ j)) filler-4-4 : (_ j : I) → (y : S¹) → Glue S¹ (Border y j) → PseudoHopf filler-4-4 i j y x = let x' = unglue (j ∨ ~ j) x in hcomp (λ t → λ { (i = i0) → filler-4-1 t j y x ; (i = i1) → ((y , seg j) , unglue (j ∨ ~ j) x) ; (j = i0) → ((rotInv-4 y (y * x) i , I0) , (rotInv-4 y (y * x) (i ∨ ~ t)) * x) ; (j = i1) → ((rotInv-4 y x i , I1) , x) }) ((rotInv-4 y x' i , seg j) , x') filler-4-5 : (_ j : I) → (y : S¹) → Glue S¹ (Border y j) → TotalHopf filler-4-5 i j y x = hcomp (λ t → λ { (i = i0) → filler-4-2 (~ t) j y x ; (i = i1) → (merid (PseudoHopf-π1 (filler-4-4 t j y x)) j , glue (λ { (j = i0) → x ; (j = i1) → x }) (PseudoHopf-π2 (filler-4-4 t j y x))) ; (j = i0) → (north , x) ; (j = i1) → (south , x) }) (merid (PseudoHopf-π1 (filler-4-3 i j y x)) j , glue (λ { (j = i0) → x ; (j = i1) → x }) (PseudoHopf-π2 (filler-4-3 i j y x))) TotalHopf→JoinS¹S¹→TotalHopf : ∀ x → JoinS¹S¹→TotalHopf (TotalHopf→JoinS¹S¹ x) ≡ x TotalHopf→JoinS¹S¹→TotalHopf (north , x) i = (north , x) TotalHopf→JoinS¹S¹→TotalHopf (south , x) i = (south , x) TotalHopf→JoinS¹S¹→TotalHopf (merid y j , x) i = filler-4-5 i j y x JoinS¹S¹≡TotalHopf : join S¹ S¹ ≡ TotalHopf JoinS¹S¹≡TotalHopf = isoToPath (iso JoinS¹S¹→TotalHopf TotalHopf→JoinS¹S¹ TotalHopf→JoinS¹S¹→TotalHopf JoinS¹S¹→TotalHopf→JoinS¹S¹) S³≡TotalHopf : S³ ≡ TotalHopf S³≡TotalHopf = S³≡joinS¹S¹ ∙ JoinS¹S¹≡TotalHopf
{ "alphanum_fraction": 0.5230315244, "avg_line_length": 42.8827160494, "ext": "agda", "hexsha": "389c5d9288523a6f6e9c8a244ad54f8b6d6ce5be", "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/Hopf.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/Hopf.agda", "max_line_length": 115, "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/Hopf.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5557, "size": 13894 }
-- Partial Agda bindings for the W3C Geolocation API -- http://dev.w3.org/geo/api/spec-source.html -- Not supporting the "read once" API or any of the options yet. open import FRP.JS.Behaviour using ( Beh ; map ) open import FRP.JS.Geolocation.Coords using ( Coords ) open import FRP.JS.Maybe using ( Maybe ) open import FRP.JS.RSet using ( ⟦_⟧ ; ⟨_⟩ ) module FRP.JS.Geolocation where postulate geolocation : ⟦ Beh ⟨ Maybe Coords ⟩ ⟧ {-# COMPILED_JS geolocation require("agda.frp").geolocation #-}
{ "alphanum_fraction": 0.7202380952, "avg_line_length": 31.5, "ext": "agda", "hexsha": "14d178e916e787e6dadd9cc869074151e54239c1", "lang": "Agda", "max_forks_count": 7, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z", "max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z", "max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_forks_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_forks_repo_name": "agda/agda-frp-js", "max_forks_repo_path": "src/agda/FRP/JS/Geolocation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_issues_repo_name": "agda/agda-frp-js", "max_issues_repo_path": "src/agda/FRP/JS/Geolocation.agda", "max_line_length": 64, "max_stars_count": 63, "max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_stars_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_stars_repo_name": "agda/agda-frp-js", "max_stars_repo_path": "src/agda/FRP/JS/Geolocation.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z", "num_tokens": 150, "size": 504 }
module Numeral.Finite.Functions where import Lvl open import Syntax.Number open import Lang.Instance open import Logic.Propositional open import Logic.Predicate open import Numeral.Finite open import Numeral.Finite.Bound open import Numeral.Natural hiding (𝐏) import Numeral.Natural.Function as ℕ import Numeral.Natural.Function.Proofs as ℕ open import Numeral.Natural.Oper -- Maximum function. -- Returns the greatest number. max : ∀{a b} → 𝕟(a) → 𝕟(b) → 𝕟(ℕ.max a b) max 𝟎 𝟎 = 𝟎 max {a}{b} (𝐒(x)) 𝟎 = bound-[≤] (ℕ.max-orderₗ {a}{b}) (𝐒(x)) max {a}{b} 𝟎 (𝐒(y)) = bound-[≤] (ℕ.max-orderᵣ {a}{b}) (𝐒(y)) max (𝐒(x)) (𝐒(y)) = 𝐒(max x y) -- Minimum function. -- Returns the smallest number. min : ∀{a b} → 𝕟(a) → 𝕟(b) → 𝕟(ℕ.min a b) min 𝟎 𝟎 = 𝟎 min (𝐒(_)) 𝟎 = 𝟎 min 𝟎 (𝐒(_)) = 𝟎 min (𝐒(x)) (𝐒(y)) = 𝐒(min x y)
{ "alphanum_fraction": 0.6093928981, "avg_line_length": 29.1, "ext": "agda", "hexsha": "cd4b727778bd627f3651e0c9f13706d461d133ae", "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/Finite/Functions.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Numeral/Finite/Functions.agda", "max_line_length": 65, "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/Finite/Functions.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 371, "size": 873 }
import Lvl open import Structure.Operator.Vector open import Structure.Setoid open import Type module Structure.Operator.Vector.FiniteDimensional {ℓᵥ ℓₛ ℓᵥₑ ℓₛₑ} {V : Type{ℓᵥ}} ⦃ equiv-V : Equiv{ℓᵥₑ}(V) ⦄ {S : Type{ℓₛ}} ⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄ {_+ᵥ_ : V → V → V} {_⋅ₛᵥ_ : S → V → V} {_+ₛ_ _⋅ₛ_ : S → S → S} ⦃ vectorSpace : VectorSpace(_+ᵥ_)(_⋅ₛᵥ_)(_+ₛ_)(_⋅ₛ_) ⦄ where open VectorSpace(vectorSpace) open import Data.Tuple using (_⨯_ ; _,_) open import Functional using (id ; _∘_ ; _∘₂_ ; _$_ ; swap ; _on₂_) open import Function.Equals open import Logic open import Logic.Predicate open import Numeral.CoordinateVector as Vec using () renaming (Vector to Vec) open import Numeral.Finite open import Numeral.Natural open import Sets.ExtensionalPredicateSet as PredSet using (PredSet ; _∈_ ; [∋]-binaryRelator) open import Structure.Function.Domain open import Structure.Operator.Vector.LinearCombination ⦃ vectorSpace = vectorSpace ⦄ open import Syntax.Function private variable n : ℕ -- A sequence of vectors is linearly independent when there is no vector that can be represented as a linear combination by the others. -- Note: Equivalent to: `∀{sf} → (linearCombination(vf)(sf) ≡ 𝟎ᵥ) → (sf ⊜ Vec.fill(𝟎ₛ))`. LinearlyIndependent : Vec(n)(V) → Stmt LinearlyIndependent = Injective ∘ linearCombination -- A sequence of vectors is spanning the vector space when every vector in the vector space can be represented as a linear combination of the set of vectors. Spanning : Vec(n)(V) → Stmt Spanning = Surjective ∘ linearCombination -- A sequence of vectors is a basis when every vector in the vector space can be represented as a unique linear combination of the set of vectors. -- A sequence of vectors is a basis when they span the vector space and is linearly independent. Basis : Vec(n)(V) → Stmt Basis = Bijective ∘ linearCombination -- A finite dimensional vector space is when there are a finite number of vectors that spans the whole space. FiniteDimensional : Stmt FiniteDimensional = ∃(n ↦ ∃(vf ↦ Spanning{n}(vf)))
{ "alphanum_fraction": 0.7395326193, "avg_line_length": 41.08, "ext": "agda", "hexsha": "3b845264657c65f2e349f54def520fc0cdacab28", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Operator/Vector/FiniteDimensional.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Operator/Vector/FiniteDimensional.agda", "max_line_length": 157, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Operator/Vector/FiniteDimensional.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": 645, "size": 2054 }
-- Andreas, 2012-04-20 {-# OPTIONS --show-implicit #-} module SkipParametersInConstructorReification where data Bool : Set where true false : Bool data D (A : Set) : Set where c : {regArg : A} -> D A data P : {A : Set} → D A → Set where p : P (c {regArg = true}) bla : Set bla with c {regArg = true} bla | _ = Bool fail : P (c {regArg = false}) fail = true -- What counts here is the error message! -- -- Bool !=< P {Bool} (c {regArg = false}) of type Set -- -- the parameter argument of c should be skipped, but the -- regular argument should show up
{ "alphanum_fraction": 0.6360424028, "avg_line_length": 20.962962963, "ext": "agda", "hexsha": "6fbceeceafb4bd4b4c354b8e06d3448c1ce8f411", "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/SkipParametersInConstructorReification.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/SkipParametersInConstructorReification.agda", "max_line_length": 57, "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/SkipParametersInConstructorReification.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": 176, "size": 566 }
module BBHeap.Equality {A : Set}(_≤_ : A → A → Set) where open import BBHeap _≤_ open import Bound.Lower A open import Bound.Lower.Order _≤_ data _≈_ {b b' : Bound} : BBHeap b → BBHeap b' → Set where ≈leaf : leaf {b} ≈ leaf {b'} ≈left : {x x' : A}{l r : BBHeap (val x)}{l' r' : BBHeap (val x')} (b≤x : LeB b (val x)) (b'≤x' : LeB b' (val x')) (l⋘r : l ⋘ r) (l'⋘r' : l' ⋘ r') → l ≈ l' → r ≈ r' → left b≤x l⋘r ≈ left b'≤x' l'⋘r' ≈right : {x x' : A}{l r : BBHeap (val x)}{l' r' : BBHeap (val x')} (b≤x : LeB b (val x)) (b'≤x' : LeB b' (val x')) (l⋙r : l ⋙ r) (l'⋙r' : l' ⋙ r') → l ≈ l' → r ≈ r' → right b≤x l⋙r ≈ right b'≤x' l'⋙r'
{ "alphanum_fraction": 0.3455149502, "avg_line_length": 36.12, "ext": "agda", "hexsha": "c8e51970b3b5df3907c447fba933033a9e020641", "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/BBHeap/Equality.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/BBHeap/Equality.agda", "max_line_length": 68, "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/BBHeap/Equality.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": 362, "size": 903 }
-- Plump ordinals as presented by Shulman -- https://homotopytypetheory.org/2014/02/22/surreals-plump-ordinals/ -- -- Implementation based on an implementation of Aczel sets by Andreas Abel. module Ordinal.Shulman where open import Data.Sum using ([_,_]′) open import Induction.WellFounded as WfRec using (Acc ; acc ; WellFounded) open import Level using (Lift ; lift ; lower) open import Relation.Binary using (IsEquivalence) open import Relation.Nullary using (¬_) open import Ordinal.HoTT using (IsOrdinal ; IsExtensional ; _↔_ ; forth ; back) open import Util.Prelude -- Definition of ordinals, equality, orders ------------------------------------------------------------------------ -- Ordinals are infinitely branching well-founded trees. -- The branching type is given at each node. data Ord ℓ : Set (lsuc ℓ) where limSuc : (I : Set ℓ) (els : I → Ord ℓ) → Ord ℓ -- Branching type Br : ∀ {ℓ} (a : Ord ℓ) → Set ℓ Br (limSuc I _) = I -- Elements els : ∀ {ℓ} (a : Ord ℓ) (i : Br a) → Ord ℓ els (limSuc _ f) = f syntax els a i = a ` i lift-Ord : ∀ {a ℓ} → Ord ℓ → Ord (a ⊔ℓ ℓ) lift-Ord {a} (limSuc I f) = limSuc (Lift a I) λ i → lift-Ord {a} (f (lower i)) -- Equality and orders mutual _<_ : ∀ {ℓ} (a b : Ord ℓ) → Set ℓ a < limSuc _ f = ∃[ i ] (a ≤ f i) _≤_ : ∀ {ℓ} (a b : Ord ℓ) → Set ℓ limSuc _ f ≤ b = ∀ i → f i < b _≅_ : ∀ {ℓ} (a b : Ord ℓ) → Set ℓ a ≅ b = (a ≤ b) × (b ≤ a) _≮_ : ∀ {ℓ} (a b : Ord ℓ) → Set ℓ a ≮ b = ¬ (a < b) _≇_ : ∀ {ℓ} (a b : Ord ℓ) → Set ℓ a ≇ b = ¬ (a ≅ b) -- Intro/Elim rules for </≤ (for nicer proofs below) <-intro : ∀ {ℓ} {a b : Ord ℓ} → ∃[ i ] (a ≤ (b ` i)) → a < b <-intro {b = limSuc I f} p = p <-elim : ∀ {ℓ} {a b : Ord ℓ} → a < b → ∃[ i ] (a ≤ (b ` i)) <-elim {b = limSuc I f} p = p ≤-intro : ∀ {ℓ} {a b : Ord ℓ} → (∀ i → (a ` i) < b) → a ≤ b ≤-intro {a = limSuc I f} p = p ≤-elim : ∀ {ℓ} {a b : Ord ℓ} → a ≤ b → (∀ i → (a ` i) < b) ≤-elim {a = limSuc I f} p = p -- Reflexivity ≤-refl : ∀ {ℓ} {a : Ord ℓ} → a ≤ a ≤-refl {a = limSuc _ f} i = i , ≤-refl ≅-refl : ∀ {ℓ} {a : Ord ℓ} → a ≅ a ≅-refl = ≤-refl , ≤-refl -- < implies ≤ <→≤ : ∀ {ℓ} {a b : Ord ℓ} → a < b → a ≤ b <→≤ {ℓ} {limSuc A fa} {limSuc B fb} (i , fa<fb) j = i , <→≤ (fa<fb j) -- Transitivity mutual <-trans-≤ : ∀ {ℓ} {a b c : Ord ℓ} → a < b → b ≤ c → a < c <-trans-≤ {b = limSuc _ f} (i , p) h = ≤-trans-< p (h i) ≤-trans-< : ∀ {ℓ} {a b c : Ord ℓ} → a ≤ b → b < c → a < c ≤-trans-< {c = limSuc _ f} p (i , q) = i , ≤-trans p q ≤-trans : ∀ {ℓ} {a b c : Ord ℓ} → a ≤ b → b ≤ c → a ≤ c ≤-trans {a = limSuc _ f} h q i = <-trans-≤ (h i) q <-trans : ∀ {ℓ} {a b c : Ord ℓ} → a < b → b < c → a < c <-trans {ℓ} {a} {b} {limSuc C fc} a<b (i , b≤fci) = i , <→≤ (<-trans-≤ a<b b≤fci) ≅-trans : ∀ {ℓ} {a b c : Ord ℓ} (d : a ≅ b) (e : b ≅ c) → a ≅ c ≅-trans (p , p′) (q , q′) = ≤-trans p q , ≤-trans q′ p′ -- Symmetry ≅-sym : ∀ {ℓ} {a b : Ord ℓ} (p : a ≅ b) → b ≅ a ≅-sym (p , p′) = p′ , p -- ≅ is an equivalence relation. ≅-equiv : ∀ {ℓ} → IsEquivalence (_≅_ {ℓ}) ≅-equiv = record { refl = ≅-refl ; sym = ≅-sym ; trans = ≅-trans } -- < is 'extensional'. <-ext-≤ : ∀ {ℓ} {a b : Ord ℓ} → (∀ c → c < a → c < b) → a ≤ b <-ext-≤ {a = limSuc I els} p i = p (els i) (i , ≤-refl) <-ext : ∀ {ℓ} → IsExtensional {ℓ} _≅_ _<_ <-ext p = <-ext-≤ (λ c → forth (p c)) , <-ext-≤ (λ c → back (p c)) -- Alternative interpretation of ≤ in terms of < ≤-intro′ : ∀ {ℓ} {b c : Ord ℓ} → (∀ {a} → a < b → a < c) → b ≤ c ≤-intro′ {b = limSuc _ f} cast i = cast (i , ≤-refl) ≤-elim′ : ∀ {ℓ} {b c : Ord ℓ} → b ≤ c → ∀ {a} → a < b → a < c ≤-elim′ b≤c a<b = <-trans-≤ a<b b≤c -- Compatibility of ≤ with ≅ ≤-congˡ : ∀ {ℓ} {a b c : Ord ℓ} → a ≅ b → a ≤ c → b ≤ c ≤-congˡ {ℓ} (a≤b , b≤a) a≤c = ≤-trans b≤a a≤c ≤-congʳ : ∀ {ℓ} {a b c : Ord ℓ} → b ≅ c → a ≤ b → a ≤ c ≤-congʳ (b≤c , c≤b) a≤b = ≤-trans a≤b b≤c -- Compatibility of < with ≅ <-congʳ : ∀ {ℓ} {a b c : Ord ℓ} → b ≅ c → a < b → a < c <-congʳ (b≤c , c≤b) a<b = <-trans-≤ a<b b≤c <-congˡ : ∀ {ℓ} {a b c : Ord ℓ} → a ≅ b → a < c → b < c <-congˡ (a≤b , b≤a) a<c = ≤-trans-< b≤a a<c -- Foundation: a ≤ b implies b ≮ a ≤-found : ∀ {ℓ} {a b : Ord ℓ} → a ≤ b → b ≮ a ≤-found {ℓ} {limSuc A fa} {b} a≤b (i , b≤fai) = ≤-found b≤fai (a≤b i) -- Thus, a ≮ a. <-irr : ∀ {ℓ} {a : Ord ℓ} → a ≮ a <-irr = ≤-found ≤-refl -- Predicates over ordinals (need to respect equality) IsPred : ∀ {ℓ} (P : Ord ℓ → Set ℓ) → Set (lsuc ℓ) IsPred {ℓ} P = {a b : Ord ℓ} → a ≅ b → P a → P b record Pred ℓ : Set (lsuc ℓ) where constructor pred field _!_ : Ord ℓ → Set ℓ resp : IsPred _!_ open Pred -- <-induction. <-acc-≤ : ∀ {ℓ} {a b : Ord ℓ} → a ≤ b → Acc _<_ b → Acc _<_ a <-acc-≤ {ℓ} {limSuc A fa} {b} fai<b (acc rs) = acc λ where x (i , x≤fai) → rs x (≤-trans-< x≤fai (fai<b i)) <-wf : ∀ {ℓ} → WellFounded (_<_ {ℓ}) <-wf (limSuc I f) = acc λ { x (i , x≤fi) → <-acc-≤ x≤fi (<-wf (f i)) } <-ind : ∀ {ℓ ℓ′} (P : Ord ℓ → Set ℓ′) → (∀ a → (∀ b → b < a → P b) → P a) → ∀ a → P a <-ind = WfRec.All.wfRec <-wf _ -- Ordinals are ordinals (in the sense of the HoTT book). isOrdinal : ∀ {ℓ} → IsOrdinal (Ord ℓ) ℓ ℓ isOrdinal = record { _≈_ = _≅_ ; ≈-equiv = ≅-equiv ; _<_ = _<_ ; <-wf = <-wf ; <-ext = <-ext ; <-trans = <-trans } -- Constructions on ordinals ------------------------------------------------------------------------ -- Zero ozero : ∀ {ℓ} → Ord ℓ ozero {ℓ} = limSuc (Lift ℓ ⊥) λ() -- Successor? osuc : ∀ {ℓ} → Ord ℓ → Ord ℓ osuc {ℓ} a = limSuc (Lift ℓ ⊤) λ _ → a -- Lo and behold! osuc-mon-< : ∀ {ℓ} {a b : Ord ℓ} → a < b → osuc a < osuc b osuc-mon-< a<b = _ , λ _ → a<b osuc-mon-≤ : ∀ {ℓ} {a b : Ord ℓ} → a ≤ b → osuc a ≤ osuc b osuc-mon-≤ a≤b _ = _ , a≤b osuc-cong : ∀ {ℓ} {a b : Ord ℓ} → a ≅ b → osuc a ≅ osuc b osuc-cong (a≤b , b≤a) = osuc-mon-≤ a≤b , osuc-mon-≤ b≤a -- Maximum/Supremum _⊔_ : ∀ {ℓ} (a b : Ord ℓ) → Ord ℓ a ⊔ b = limSuc (_ ⊎ _) λ where (inj₁ i) → a ` i (inj₂ j) → b ` j ⊔-introˡ : ∀ {ℓ} a {b c : Ord ℓ} → a < b → a < (b ⊔ c) ⊔-introˡ a {limSuc _ f} (i , e) = inj₁ i , e ⊔-introʳ : ∀ {ℓ} a {b c : Ord ℓ} → a < c → a < (b ⊔ c) ⊔-introʳ a {c = limSuc _ g} (i , e) = inj₂ i , e ⊔-≤-introˡ : ∀ {ℓ} a {b c : Ord ℓ} → a ≤ b → a ≤ (b ⊔ c) ⊔-≤-introˡ a a≤b = ≤-intro λ i → ⊔-introˡ _ (≤-elim a≤b i) ⊔-≤-introˡ′ : ∀ {ℓ} {a : Ord ℓ} b → a ≤ (a ⊔ b) ⊔-≤-introˡ′ b = ⊔-≤-introˡ _ ≤-refl ⊔-≤-introʳ : ∀ {ℓ} a {b c : Ord ℓ} → a ≤ c → a ≤ (b ⊔ c) ⊔-≤-introʳ a a≤c = ≤-intro λ i → ⊔-introʳ _ (≤-elim a≤c i) ⊔-≤-introʳ′ : ∀ {ℓ} a {b : Ord ℓ} → b ≤ (a ⊔ b) ⊔-≤-introʳ′ a = ⊔-≤-introʳ _ ≤-refl ⊔-elim : ∀ {ℓ} {a b c : Ord ℓ} → c < (a ⊔ b) → (c < a) ⊎ (c < b) ⊔-elim {a = limSuc _ f} (inj₁ i , e) = inj₁ (i , e) ⊔-elim {a = limSuc _ _} {b = limSuc _ g} (inj₂ i , e) = inj₂ (i , e) ⊔-case : ∀ {ℓ} {a b c : Ord ℓ} → c < (a ⊔ b) → ∀ {q} {Q : Set q} → (c < a → Q) → (c < b → Q) → Q ⊔-case p left right = [ left , right ]′ (⊔-elim p) ⊔-split : ∀ {ℓ q} {Q : Set q} {a b c : Ord ℓ} → (c < a → Q) → (c < b → Q) → c < (a ⊔ b) → Q ⊔-split left right p = ⊔-case p left right ⊔-mon : ∀ {ℓ} {a a′ b b′ : Ord ℓ} → a ≤ a′ → b ≤ b′ → (a ⊔ b) ≤ (a′ ⊔ b′) ⊔-mon a≤a′ b≤b′ = ≤-intro′ (⊔-split (λ c<a → ⊔-introˡ _ (≤-elim′ a≤a′ c<a)) (λ c<b → ⊔-introʳ _ (≤-elim′ b≤b′ c<b))) ⊔-cong : ∀ {ℓ} {a a′ b b′ : Ord ℓ} → a ≅ a′ → b ≅ b′ → (a ⊔ b) ≅ (a′ ⊔ b′) ⊔-cong (a≤a′ , a′≤a) (b≤b′ , b′≤b) = ⊔-mon a≤a′ b≤b′ , ⊔-mon a′≤a b′≤b ⊔-<→LEM : ∀ {ℓ} → ({α α′ β : Ord ℓ} → α < β → α′ < β → (α ⊔ α′) < β) → (A : Set ℓ) → A ⊎ ¬ A ⊔-<→LEM {ℓ} p A = let α<β : α < β α<β = lift true , ≤-refl α′<β : α′ < β α′<β = lift false , ≤-refl in go (p α<β α′<β) where oone = osuc ozero α = limSuc A λ _ → oone α′ = oone β = limSuc (Lift ℓ Bool) λ { (lift true) → α ; (lift false) → α′ } go : (α ⊔ α′) < β → A ⊎ ¬ A go (lift true , α⊔α′≤α) = inj₁ (proj₁ (α⊔α′≤α (inj₂ _))) go (lift false , α⊔α′≤α′) = inj₂ λ a → lower (proj₁ (proj₂ (α⊔α′≤α′ (inj₁ a)) _)) -- Supremum of a family of ordinals ⨆ᶠ : ∀ {ℓ} {I : Set ℓ} (f : I → Ord ℓ) → Ord ℓ ⨆ᶠ {ℓ} {I} f = limSuc (∃[ i ] Br (f i)) λ { (i , j) → f i ` j } ⨆ᶠ-intro : ∀ {ℓ} {I : Set ℓ} (f : I → Ord ℓ) {c : Ord ℓ} {i : I} → c < f i → c < ⨆ᶠ f ⨆ᶠ-intro f {c} {i} c<fi = let j , c≤ = <-elim c<fi in (i , j) , c≤ ⨆ᶠ-elim : ∀ {ℓ} {I : Set ℓ} (f : I → Ord ℓ) {c : Ord ℓ} → c < ⨆ᶠ f → ∃[ i ] (c < f i) ⨆ᶠ-elim _ ((i , j) , e) = i , <-intro (j , e) ⨆ᶠ-mon : ∀ {ℓ} {I : Set ℓ} {f f′ : I → Ord ℓ} → (∀ i → f i ≤ f′ i) → ⨆ᶠ f ≤ ⨆ᶠ f′ ⨆ᶠ-mon {f = f} {f′} p = ≤-intro′ λ c<⨆ᶠf → let i , q = ⨆ᶠ-elim f c<⨆ᶠf in ⨆ᶠ-intro f′ (≤-elim′ (p i) q) ⨆ᶠ-cong : ∀ {ℓ} {I : Set ℓ} {f f′ : I → Ord ℓ} → (∀ i → f i ≅ f′ i) → ⨆ᶠ f ≅ ⨆ᶠ f′ ⨆ᶠ-cong p = ⨆ᶠ-mon (λ i → proj₁ (p i)) , ⨆ᶠ-mon (λ i → proj₂ (p i)) -- Supremum of all ordinals smaller than some given ordinal ⨆ : ∀ {ℓ} (a : Ord ℓ) → Ord ℓ ⨆ (limSuc _ f) = ⨆ᶠ f ⨆-intro : ∀ {ℓ} {a b : Ord ℓ} → b < a → b ≤ ⨆ a ⨆-intro {a = limSuc A fa} {b = limSuc B fb} (i , b≤fi) = ≤-intro λ j → let k , p = <-elim (b≤fi j) in _ , p ⨆-elim : ∀ {ℓ} {a c : Ord ℓ} → c < ⨆ a → ∃[ b ] ((b < a) × (c < b)) ⨆-elim {a = limSuc _ f} ((i , j) , c≤) = f i , (i , ≤-refl) , <-intro (_ , c≤)
{ "alphanum_fraction": 0.4451830863, "avg_line_length": 27.8905775076, "ext": "agda", "hexsha": "cae23b03ece192d1611ec2bd93492d38997998b7", "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/Ordinal/Shulman.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/Ordinal/Shulman.agda", "max_line_length": 85, "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/Ordinal/Shulman.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": 4843, "size": 9176 }
{-# OPTIONS --safe #-} module Cubical.Algebra.Monoid where open import Cubical.Algebra.Monoid.Base public
{ "alphanum_fraction": 0.7663551402, "avg_line_length": 21.4, "ext": "agda", "hexsha": "856fd42901140e5a58636a83bf5a7d99d71bd51b", "lang": "Agda", "max_forks_count": 134, "max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z", "max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z", "max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "marcinjangrzybowski/cubical", "max_forks_repo_path": "Cubical/Algebra/Monoid.agda", "max_issues_count": 584, "max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z", "max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "marcinjangrzybowski/cubical", "max_issues_repo_path": "Cubical/Algebra/Monoid.agda", "max_line_length": 46, "max_stars_count": 301, "max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "marcinjangrzybowski/cubical", "max_stars_repo_path": "Cubical/Algebra/Monoid.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z", "num_tokens": 25, "size": 107 }
open import Oscar.Prelude module Oscar.Class.Injectivity where module _ where module _ -- Arity=1 {𝔬₁} {𝔒₁ : Ø 𝔬₁} {𝔬₂} (𝔒₂ : 𝔒₁ → Ø 𝔬₂) where 𝓲njection₁ = (x : 𝔒₁) → 𝔒₂ x record 𝓘njection₁ : Ø 𝔬₁ ∙̂ 𝔬₂ where field injection₁ : 𝓲njection₁ open 𝓘njection₁ ⦃ … ⦄ public module _ {ℓ₂} (_∼₂_ : ∀ {x₁ x₂} → 𝔒₂ x₁ → 𝔒₂ x₂ → Ø ℓ₂) {ℓ₁} (_∼₁_ : 𝔒₁ → 𝔒₁ → Ø ℓ₁) where record [𝓘njectivity₁] : Ø₀ where no-eta-equality constructor ∁ module _ ⦃ _ : 𝓘njection₁ ⦄ where 𝓲njectivity₁ = ∀ {x₁ x₂} → injection₁ x₁ ∼₂ injection₁ x₂ → x₁ ∼₁ x₂ record 𝓘njectivity₁ ⦃ _ : [𝓘njectivity₁] ⦄ : Ø 𝔬₁ ∙̂ 𝔬₂ ∙̂ ℓ₁ ∙̂ ℓ₂ where field injectivity₁ : 𝓲njectivity₁ open 𝓘njectivity₁ ⦃ … ⦄ public injectivity₁[_] : ∀ {𝔬₁} {𝔒₁ : Ø 𝔬₁} {𝔬₂} {𝔒₂ : 𝔒₁ → Ø 𝔬₂} {ℓ₂} {_∼₂_ : ∀ {x₁ x₂} → 𝔒₂ x₁ → 𝔒₂ x₂ → Ø ℓ₂} {ℓ₁} (_∼₁_ : 𝔒₁ → 𝔒₁ → Ø ℓ₁) ⦃ _ : 𝓘njection₁ (λ (x : 𝔒₁) → 𝔒₂ x) ⦄ ⦃ _ : [𝓘njectivity₁] (λ (x : 𝔒₁) → 𝔒₂ x) _∼₂_ _∼₁_ ⦄ ⦃ _ : 𝓘njectivity₁ (λ (x : 𝔒₁) → 𝔒₂ x) _∼₂_ _∼₁_ ⦄ → 𝓲njectivity₁ (λ (x : 𝔒₁) → 𝔒₂ x) _∼₂_ _∼₁_ injectivity₁[ _ ] = injectivity₁ module _ -- Arity=2 {𝔬₁} {𝔒₁ : Ø 𝔬₁} {𝔬₂} {𝔒₂ : 𝔒₁ → Ø 𝔬₂} {𝔬₃} (𝔒₃ : ∀ x₁ → 𝔒₂ x₁ → Ø 𝔬₃) where 𝓲njection₂ = ∀ x₁ → (x₂ : 𝔒₂ x₁) → 𝔒₃ _ x₂ record 𝓘njection₂ : Ø 𝔬₁ ∙̂ 𝔬₂ ∙̂ 𝔬₃ where constructor ∁ field injection₂ : 𝓲njection₂ open 𝓘njection₂ ⦃ … ⦄ public module _ -- Fixed=0 {ℓ₃} (_∼₃_ : ∀ {x₁ x₂} {y₁ : 𝔒₂ x₁} {y₂ : 𝔒₂ x₂} → 𝔒₃ _ y₁ → 𝔒₃ _ y₂ → Ø ℓ₃) where module _ -- Var=1 {ℓ₁} (_∼₁_ : 𝔒₁ → 𝔒₁ → Ø ℓ₁) where record [𝓘njectivity₂,₀,₁] : Ø₀ where no-eta-equality constructor ∁ module _ ⦃ _ : 𝓘njection₂ ⦄ where 𝓲njectivity₂,₀,₁ = ∀ {x₁ x₂} {y₁ : 𝔒₂ x₁} {y₂ : 𝔒₂ x₂} → injection₂ _ y₁ ∼₃ injection₂ _ y₂ → x₁ ∼₁ x₂ record 𝓘njectivity₂,₀,₁ ⦃ _ : [𝓘njectivity₂,₀,₁] ⦄ : Ø 𝔬₁ ∙̂ 𝔬₂ ∙̂ 𝔬₃ ∙̂ ℓ₁ ∙̂ ℓ₃ where field injectivity₂,₀,₁ : 𝓲njectivity₂,₀,₁ open 𝓘njectivity₂,₀,₁ ⦃ … ⦄ public module _ -- Var=2 {ℓ₂} (_∼₂_ : ∀ {x₁ x₂} → 𝔒₂ x₁ → 𝔒₂ x₂ → Ø ℓ₂) where record [𝓘njectivity₂,₀,₂] : Ø₀ where no-eta-equality constructor ∁ module _ ⦃ _ : 𝓘njection₂ ⦄ where 𝓲njectivity₂,₀,₂ = ∀ {x₁ x₂ : 𝔒₁} {y₁ : 𝔒₂ x₁} {y₂ : 𝔒₂ x₂} → injection₂ _ y₁ ∼₃ injection₂ _ y₂ → y₁ ∼₂ y₂ record 𝓘njectivity₂,₀,₂ ⦃ _ : [𝓘njectivity₂,₀,₂] ⦄ : Ø 𝔬₁ ∙̂ 𝔬₂ ∙̂ 𝔬₃ ∙̂ ℓ₂ ∙̂ ℓ₃ where field injectivity₂,₀,₂ : 𝓲njectivity₂,₀,₂ open 𝓘njectivity₂,₀,₂ ⦃ … ⦄ public module _ -- Fixed=1 {ℓ₃} (_∼₃_ : ∀ {x} {y₁ y₂ : 𝔒₂ x} → 𝔒₃ _ y₁ → 𝔒₃ _ y₂ → Ø ℓ₃) {ℓ₂} (_∼₂_ : ∀ {x} → 𝔒₂ x → 𝔒₂ x → Ø ℓ₂) where record [𝓘njectivity₂,₁] : Ø₀ where no-eta-equality constructor ∁ module _ ⦃ _ : 𝓘njection₂ ⦄ where 𝓲njectivity₂,₁ = ∀ (x : 𝔒₁) {y₁ y₂ : 𝔒₂ x} → injection₂ _ y₁ ∼₃ injection₂ _ y₂ → y₁ ∼₂ y₂ record 𝓘njectivity₂,₁ ⦃ _ : [𝓘njectivity₂,₁] ⦄ : Ø 𝔬₁ ∙̂ 𝔬₂ ∙̂ 𝔬₃ ∙̂ ℓ₂ ∙̂ ℓ₃ where field injectivity₂,₁ : 𝓲njectivity₂,₁ open 𝓘njectivity₂,₁ ⦃ … ⦄ public injectivity₂,₀,₁[_] : ∀ {𝔬₁} {𝔒₁ : Ø 𝔬₁} {𝔬₂} {𝔒₂ : 𝔒₁ → Ø 𝔬₂} {𝔬₃} {𝔒₃ : ∀ x₁ → 𝔒₂ x₁ → Ø 𝔬₃} {ℓ₃} {_∼₃_ : ∀ {x₁ x₂} {y₁ : 𝔒₂ x₁} {y₂ : 𝔒₂ x₂} → 𝔒₃ _ y₁ → 𝔒₃ _ y₂ → Ø ℓ₃} {ℓ₁} (_∼₁_ : 𝔒₁ → 𝔒₁ → Ø ℓ₁) ⦃ _ : 𝓘njection₂ 𝔒₃ ⦄ ⦃ _ : [𝓘njectivity₂,₀,₁] 𝔒₃ _∼₃_ _∼₁_ ⦄ ⦃ _ : 𝓘njectivity₂,₀,₁ 𝔒₃ _∼₃_ _∼₁_ ⦄ → 𝓲njectivity₂,₀,₁ 𝔒₃ _∼₃_ _∼₁_ injectivity₂,₀,₁[ _ ] = injectivity₂,₀,₁ injectivity₂,₀,₂[_] : ∀ {𝔬₁} {𝔒₁ : Ø 𝔬₁} {𝔬₂} {𝔒₂ : 𝔒₁ → Ø 𝔬₂} {𝔬₃} {𝔒₃ : ∀ x₁ → 𝔒₂ x₁ → Ø 𝔬₃} {ℓ₃} {_∼₃_ : ∀ {x₁ x₂} {y₁ : 𝔒₂ x₁} {y₂ : 𝔒₂ x₂} → 𝔒₃ _ y₁ → 𝔒₃ _ y₂ → Ø ℓ₃} {ℓ₂} (_∼₂_ : ∀ {x₁ x₂} → 𝔒₂ x₁ → 𝔒₂ x₂ → Ø ℓ₂) ⦃ _ : 𝓘njection₂ 𝔒₃ ⦄ ⦃ _ : [𝓘njectivity₂,₀,₂] 𝔒₃ _∼₃_ _∼₂_ ⦄ ⦃ _ : 𝓘njectivity₂,₀,₂ 𝔒₃ _∼₃_ _∼₂_ ⦄ → 𝓲njectivity₂,₀,₂ 𝔒₃ _∼₃_ _∼₂_ injectivity₂,₀,₂[ _ ] = injectivity₂,₀,₂ injectivity₂,₁[_] : ∀ {𝔬₁} {𝔒₁ : Ø 𝔬₁} {𝔬₂} {𝔒₂ : 𝔒₁ → Ø 𝔬₂} {𝔬₃} {𝔒₃ : ∀ x₁ → 𝔒₂ x₁ → Ø 𝔬₃} {ℓ₃} {_∼₃_ : ∀ {x} {y₁ y₂ : 𝔒₂ x} → 𝔒₃ _ y₁ → 𝔒₃ _ y₂ → Ø ℓ₃} {ℓ₂} (_∼₂_ : ∀ {x} → 𝔒₂ x → 𝔒₂ x → Ø ℓ₂) ⦃ _ : [𝓘njectivity₂,₁] 𝔒₃ _∼₃_ _∼₂_ ⦄ ⦃ _ : 𝓘njection₂ 𝔒₃ ⦄ ⦃ _ : 𝓘njectivity₂,₁ 𝔒₃ _∼₃_ _∼₂_ ⦄ → 𝓲njectivity₂,₁ 𝔒₃ _∼₃_ _∼₂_ injectivity₂,₁[ _ ] = injectivity₂,₁ module _ -- Arity=3 {𝔬₁} {𝔒₁ : Ø 𝔬₁} {𝔬₂} {𝔒₂ : 𝔒₁ → Ø 𝔬₂} {𝔬₃} {𝔒₃ : ∀ x₁ → 𝔒₂ x₁ → Ø 𝔬₃} {𝔬₄} (𝔒₄ : ∀ x₁ → (x₂ : 𝔒₂ x₁) → 𝔒₃ _ x₂ → Ø 𝔬₄) where 𝓲njection₃ = ∀ x₁ → (x₂ : 𝔒₂ x₁) → (x₃ : 𝔒₃ _ x₂) → 𝔒₄ _ _ x₃ record 𝓘njection₃ : Ø 𝔬₁ ∙̂ 𝔬₂ ∙̂ 𝔬₃ ∙̂ 𝔬₄ where constructor ∁ field injection₃ : 𝓲njection₃ open 𝓘njection₃ ⦃ … ⦄ public module _ -- Fixed=0 {ℓ₄} (_∼₄_ : ∀ {x₁ x₂} {y₁ : 𝔒₂ x₁} {y₂ : 𝔒₂ x₂} {z₁ : 𝔒₃ _ y₁} {z₂ : 𝔒₃ _ y₂} → 𝔒₄ _ _ z₁ → 𝔒₄ _ _ z₂ → Ø ℓ₄) where module _ -- Var=1 {ℓ₁} (_∼₁_ : 𝔒₁ → 𝔒₁ → Ø ℓ₁) where record [𝓘njectivity₃,₀,₁] : Ø₀ where no-eta-equality constructor ∁ module _ ⦃ _ : 𝓘njection₃ ⦄ where 𝓲njectivity₃,₀,₁ = ∀ {x₁ x₂} {y₁ : 𝔒₂ x₁} {y₂ : 𝔒₂ x₂} {z₁ : 𝔒₃ _ y₁} {z₂ : 𝔒₃ _ y₂} → injection₃ _ _ z₁ ∼₄ injection₃ _ _ z₂ → x₁ ∼₁ x₂ record 𝓘njectivity₃,₀,₁ ⦃ _ : [𝓘njectivity₃,₀,₁] ⦄ : Ø 𝔬₁ ∙̂ 𝔬₂ ∙̂ 𝔬₃ ∙̂ 𝔬₄ ∙̂ ℓ₁ ∙̂ ℓ₄ where field injectivity₃,₀,₁ : 𝓲njectivity₃,₀,₁ open 𝓘njectivity₃,₀,₁ ⦃ … ⦄ public module _ -- Var=2 {ℓ₂} (_∼₂_ : ∀ {x₁ x₂} → 𝔒₂ x₁ → 𝔒₂ x₂ → Ø ℓ₂) where record [𝓘njectivity₃,₀,₂] : Ø₀ where no-eta-equality constructor ∁ module _ ⦃ _ : 𝓘njection₃ ⦄ where 𝓲njectivity₃,₀,₂ = ∀ {x₁ x₂ : 𝔒₁} {y₁ : 𝔒₂ x₁} {y₂ : 𝔒₂ x₂} {z₁ : 𝔒₃ _ y₁} {z₂ : 𝔒₃ _ y₂} → injection₃ _ _ z₁ ∼₄ injection₃ _ _ z₂ → y₁ ∼₂ y₂ record 𝓘njectivity₃,₀,₂ ⦃ _ : [𝓘njectivity₃,₀,₂] ⦄ : Ø 𝔬₁ ∙̂ 𝔬₂ ∙̂ 𝔬₃ ∙̂ ℓ₂ ∙̂ ℓ₄ where field injectivity₃,₀,₂ : 𝓲njectivity₃,₀,₂ open 𝓘njectivity₃,₀,₂ ⦃ … ⦄ public injectivity₃,₀,₁[_] : ∀ {𝔬₁} {𝔒₁ : Ø 𝔬₁} {𝔬₂} {𝔒₂ : 𝔒₁ → Ø 𝔬₂} {𝔬₃} {𝔒₃ : ∀ x₁ → 𝔒₂ x₁ → Ø 𝔬₃} {𝔬₄} {𝔒₄ : ∀ x₁ → (x₂ : 𝔒₂ x₁) → 𝔒₃ _ x₂ → Ø 𝔬₄} {ℓ₄} {_∼₄_ : ∀ {x₁ x₂} {y₁ : 𝔒₂ x₁} {y₂ : 𝔒₂ x₂} {z₁ : 𝔒₃ _ y₁} {z₂ : 𝔒₃ _ y₂} → 𝔒₄ _ _ z₁ → 𝔒₄ _ _ z₂ → Ø ℓ₄} {ℓ₁} (_∼₁_ : 𝔒₁ → 𝔒₁ → Ø ℓ₁) ⦃ _ : [𝓘njectivity₃,₀,₁] 𝔒₄ _∼₄_ _∼₁_ ⦄ ⦃ _ : 𝓘njection₃ 𝔒₄ ⦄ ⦃ _ : 𝓘njectivity₃,₀,₁ 𝔒₄ _∼₄_ _∼₁_ ⦄ → 𝓲njectivity₃,₀,₁ 𝔒₄ _∼₄_ _∼₁_ injectivity₃,₀,₁[ _ ] = injectivity₃,₀,₁ injectivity₃,₀,₂[_] : ∀ {𝔬₁} {𝔒₁ : Ø 𝔬₁} {𝔬₂} {𝔒₂ : 𝔒₁ → Ø 𝔬₂} {𝔬₃} {𝔒₃ : ∀ x₁ → 𝔒₂ x₁ → Ø 𝔬₃} {𝔬₄} {𝔒₄ : ∀ x₁ → (x₂ : 𝔒₂ x₁) → 𝔒₃ _ x₂ → Ø 𝔬₄} {ℓ₄} {_∼₄_ : ∀ {x₁ x₂} {y₁ : 𝔒₂ x₁} {y₂ : 𝔒₂ x₂} {z₁ : 𝔒₃ _ y₁} {z₂ : 𝔒₃ _ y₂} → 𝔒₄ _ _ z₁ → 𝔒₄ _ _ z₂ → Ø ℓ₄} {ℓ₂} (_∼₂_ : ∀ {x₁ x₂} → 𝔒₂ x₁ → 𝔒₂ x₂ → Ø ℓ₂) ⦃ _ : [𝓘njectivity₃,₀,₂] 𝔒₄ _∼₄_ _∼₂_ ⦄ ⦃ _ : 𝓘njection₃ 𝔒₄ ⦄ ⦃ _ : 𝓘njectivity₃,₀,₂ 𝔒₄ _∼₄_ _∼₂_ ⦄ → 𝓲njectivity₃,₀,₂ 𝔒₄ _∼₄_ _∼₂_ injectivity₃,₀,₂[ _ ] = injectivity₃,₀,₂
{ "alphanum_fraction": 0.4990970968, "avg_line_length": 37.6910994764, "ext": "agda", "hexsha": "3ba98474e9572de513f3c65adf91bcaee4a36b54", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Injectivity.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Injectivity.agda", "max_line_length": 151, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Injectivity.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4616, "size": 7199 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Example of a Quotient: ℤ as (ℕ × ℕ / ∼) ------------------------------------------------------------------------ {-# OPTIONS --with-K --safe #-} module Relation.Binary.HeterogeneousEquality.Quotients.Examples where open import Relation.Binary.HeterogeneousEquality.Quotients open import Level using (0ℓ) open import Relation.Binary open import Relation.Binary.HeterogeneousEquality hiding (isEquivalence) import Relation.Binary.PropositionalEquality as ≡ open import Data.Nat open import Data.Nat.Properties open import Data.Product open import Function open ≅-Reasoning ℕ² = ℕ × ℕ _∼_ : ℕ² → ℕ² → Set (x , y) ∼ (x' , y') = x + y' ≅ x' + y infix 10 _∼_ ∼-trans : ∀ {i j k} → i ∼ j → j ∼ k → i ∼ k ∼-trans {x₁ , y₁} {x₂ , y₂} {x₃ , y₃} p q = ≡-to-≅ $ +-cancelˡ-≡ y₂ $ ≅-to-≡ $ begin y₂ + (x₁ + y₃) ≡⟨ ≡.sym (+-assoc y₂ x₁ y₃) ⟩ y₂ + x₁ + y₃ ≡⟨ ≡.cong (_+ y₃) (+-comm y₂ x₁) ⟩ x₁ + y₂ + y₃ ≅⟨ cong (_+ y₃) p ⟩ x₂ + y₁ + y₃ ≡⟨ ≡.cong (_+ y₃) (+-comm x₂ y₁) ⟩ y₁ + x₂ + y₃ ≡⟨ +-assoc y₁ x₂ y₃ ⟩ y₁ + (x₂ + y₃) ≅⟨ cong (y₁ +_) q ⟩ y₁ + (x₃ + y₂) ≡⟨ +-comm y₁ (x₃ + y₂) ⟩ x₃ + y₂ + y₁ ≡⟨ ≡.cong (_+ y₁) (+-comm x₃ y₂) ⟩ y₂ + x₃ + y₁ ≡⟨ +-assoc y₂ x₃ y₁ ⟩ y₂ + (x₃ + y₁) ∎ ∼-isEquivalence : IsEquivalence _∼_ ∼-isEquivalence = record { refl = refl ; sym = sym ; trans = λ {i} {j} {k} → ∼-trans {i} {j} {k} } ℕ²-∼-setoid : Setoid 0ℓ 0ℓ ℕ²-∼-setoid = record { isEquivalence = ∼-isEquivalence } module Integers (quot : Quotients 0ℓ 0ℓ) where Int : Quotient ℕ²-∼-setoid Int = quot _ open Quotient Int renaming (Q to ℤ) _+²_ : ℕ² → ℕ² → ℕ² (x₁ , y₁) +² (x₂ , y₂) = x₁ + x₂ , y₁ + y₂ +²-cong : ∀{a b a' b'} → a ∼ a' → b ∼ b' → a +² b ∼ a' +² b' +²-cong {a₁ , b₁} {c₁ , d₁} {a₂ , b₂} {c₂ , d₂} ab∼cd₁ ab∼cd₂ = begin (a₁ + c₁) + (b₂ + d₂) ≡⟨ ≡.cong (_+ (b₂ + d₂)) (+-comm a₁ c₁) ⟩ (c₁ + a₁) + (b₂ + d₂) ≡⟨ +-assoc c₁ a₁ (b₂ + d₂) ⟩ c₁ + (a₁ + (b₂ + d₂)) ≡⟨ ≡.cong (c₁ +_) (≡.sym (+-assoc a₁ b₂ d₂)) ⟩ c₁ + (a₁ + b₂ + d₂) ≅⟨ cong (λ n → c₁ + (n + d₂)) ab∼cd₁ ⟩ c₁ + (a₂ + b₁ + d₂) ≡⟨ ≡.cong (c₁ +_) (+-assoc a₂ b₁ d₂) ⟩ c₁ + (a₂ + (b₁ + d₂)) ≡⟨ ≡.cong (λ n → c₁ + (a₂ + n)) (+-comm b₁ d₂) ⟩ c₁ + (a₂ + (d₂ + b₁)) ≡⟨ ≡.sym (+-assoc c₁ a₂ (d₂ + b₁)) ⟩ (c₁ + a₂) + (d₂ + b₁) ≡⟨ ≡.cong (_+ (d₂ + b₁)) (+-comm c₁ a₂) ⟩ (a₂ + c₁) + (d₂ + b₁) ≡⟨ +-assoc a₂ c₁ (d₂ + b₁) ⟩ a₂ + (c₁ + (d₂ + b₁)) ≡⟨ ≡.cong (a₂ +_) (≡.sym (+-assoc c₁ d₂ b₁)) ⟩ a₂ + (c₁ + d₂ + b₁) ≅⟨ cong (λ n → a₂ + (n + b₁)) ab∼cd₂ ⟩ a₂ + (c₂ + d₁ + b₁) ≡⟨ ≡.cong (a₂ +_) (+-assoc c₂ d₁ b₁) ⟩ a₂ + (c₂ + (d₁ + b₁)) ≡⟨ ≡.cong (λ n → a₂ + (c₂ + n)) (+-comm d₁ b₁) ⟩ a₂ + (c₂ + (b₁ + d₁)) ≡⟨ ≡.sym (+-assoc a₂ c₂ (b₁ + d₁)) ⟩ (a₂ + c₂) + (b₁ + d₁) ∎ module _ (ext : ∀ {a b} {A : Set a} {B₁ B₂ : A → Set b} {f₁ : ∀ a → B₁ a} {f₂ : ∀ a → B₂ a} → (∀ a → f₁ a ≅ f₂ a) → f₁ ≅ f₂) where _+ℤ_ : ℤ → ℤ → ℤ _+ℤ_ = Properties₂.lift₂ ext Int Int (λ i j → abs (i +² j)) $ λ {a} {b} {c} p p' → compat-abs (+²-cong {a} {b} {c} p p') zero² : ℕ² zero² = 0 , 0 zeroℤ : ℤ zeroℤ = abs zero² +²-identityʳ : (i : ℕ²) → (i +² zero²) ∼ i +²-identityʳ (x , y) = begin (x + 0) + y ≡⟨ ≡.cong (_+ y) (+-identityʳ x) ⟩ x + y ≡⟨ ≡.cong (x +_) (≡.sym (+-identityʳ y)) ⟩ x + (y + 0) ∎ +ℤ-on-abs≅abs-+₂ : ∀ a b → abs a +ℤ abs b ≅ abs (a +² b) +ℤ-on-abs≅abs-+₂ = Properties₂.lift₂-conv ext Int Int _ $ λ {a} {b} {c} p p′ → compat-abs (+²-cong {a} {b} {c} p p′) +ℤ-identityʳ : ∀ i → i +ℤ zeroℤ ≅ i +ℤ-identityʳ = lift _ eq (≅-heterogeneous-irrelevantʳ _ _ ∘ compat-abs) where eq : ∀ a → abs a +ℤ zeroℤ ≅ abs a eq a = begin abs a +ℤ zeroℤ ≡⟨⟩ abs a +ℤ abs zero² ≅⟨ +ℤ-on-abs≅abs-+₂ a zero² ⟩ abs (a +² zero²) ≅⟨ compat-abs (+²-identityʳ a) ⟩ abs a ∎ +²-identityˡ : (i : ℕ²) → (zero² +² i) ∼ i +²-identityˡ i = refl +ℤ-identityˡ : (i : ℤ) → zeroℤ +ℤ i ≅ i +ℤ-identityˡ = lift _ eq (≅-heterogeneous-irrelevantʳ _ _ ∘ compat-abs) where eq : ∀ a → zeroℤ +ℤ abs a ≅ abs a eq a = begin zeroℤ +ℤ abs a ≡⟨⟩ abs zero² +ℤ abs a ≅⟨ +ℤ-on-abs≅abs-+₂ zero² a ⟩ abs (zero² +² a) ≅⟨ compat-abs (+²-identityˡ a) ⟩ abs a ∎ +²-assoc : (i j k : ℕ²) → (i +² j) +² k ∼ i +² (j +² k) +²-assoc (a , b) (c , d) (e , f) = begin ((a + c) + e) + (b + (d + f)) ≡⟨ ≡.cong (_+ (b + (d + f))) (+-assoc a c e) ⟩ (a + (c + e)) + (b + (d + f)) ≡⟨ ≡.cong ((a + (c + e)) +_) (≡.sym (+-assoc b d f)) ⟩ (a + (c + e)) + ((b + d) + f) ∎ +ℤ-assoc : ∀ i j k → (i +ℤ j) +ℤ k ≅ i +ℤ (j +ℤ k) +ℤ-assoc = Properties₃.lift₃ ext Int Int Int eq compat₃ where eq : ∀ i j k → (abs i +ℤ abs j) +ℤ abs k ≅ abs i +ℤ (abs j +ℤ abs k) eq i j k = begin (abs i +ℤ abs j) +ℤ abs k ≅⟨ cong (_+ℤ abs k) (+ℤ-on-abs≅abs-+₂ i j) ⟩ (abs (i +² j) +ℤ abs k) ≅⟨ +ℤ-on-abs≅abs-+₂ (i +² j) k ⟩ abs ((i +² j) +² k) ≅⟨ compat-abs (+²-assoc i j k) ⟩ abs (i +² (j +² k)) ≅⟨ sym (+ℤ-on-abs≅abs-+₂ i (j +² k)) ⟩ (abs i +ℤ abs (j +² k)) ≅⟨ cong (abs i +ℤ_) (sym (+ℤ-on-abs≅abs-+₂ j k)) ⟩ abs i +ℤ (abs j +ℤ abs k) ∎ compat₃ : ∀ {a a′ b b′ c c′} → a ∼ a′ → b ∼ b′ → c ∼ c′ → eq a b c ≅ eq a′ b′ c′ compat₃ p q r = ≅-heterogeneous-irrelevantˡ _ _ $ cong₂ _+ℤ_ (cong₂ _+ℤ_ (compat-abs p) (compat-abs q)) $ compat-abs r
{ "alphanum_fraction": 0.4484837737, "avg_line_length": 37.8456375839, "ext": "agda", "hexsha": "cc9e7421dcc80f35ed1c46942560c321dabba195", "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": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/HeterogeneousEquality/Quotients/Examples.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/HeterogeneousEquality/Quotients/Examples.agda", "max_line_length": 90, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/HeterogeneousEquality/Quotients/Examples.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2846, "size": 5639 }
{-# OPTIONS --cubical --safe --postfix-projections #-} module Data.Fin.Properties where open import Prelude open import Data.Fin.Base import Data.Nat.Properties as ℕ open import Data.Nat.Properties using (+-comm) open import Data.Nat open import Function.Injective open import Agda.Builtin.Nat renaming (_<_ to _<ᵇ_) private variable n m : ℕ suc-natfin : Σ[ m ⦂ ℕ ] × (m ℕ.< n) → Σ[ m ⦂ ℕ ] × (m ℕ.< suc n) suc-natfin (m , p) = suc m , p Fin-to-Nat-lt : Fin n → Σ[ m ⦂ ℕ ] × (m ℕ.< n) Fin-to-Nat-lt {n = suc n} f0 = zero , tt Fin-to-Nat-lt {n = suc n} (fs x) = suc-natfin (Fin-to-Nat-lt x) Fin-from-Nat-lt : ∀ m → m ℕ.< n → Fin n Fin-from-Nat-lt {n = suc n} zero p = f0 Fin-from-Nat-lt {n = suc n} (suc m) p = fs (Fin-from-Nat-lt m p) Fin-Nat-lt-rightInv : ∀ m → (p : m ℕ.< n) → Fin-to-Nat-lt {n = n} (Fin-from-Nat-lt m p) ≡ (m , p) Fin-Nat-lt-rightInv {n = suc n} zero p = refl Fin-Nat-lt-rightInv {n = suc n} (suc m) p = cong (suc-natfin {n = n}) (Fin-Nat-lt-rightInv {n = n} m p) Fin-Nat-lt-leftInv : (x : Fin n) → uncurry Fin-from-Nat-lt (Fin-to-Nat-lt x) ≡ x Fin-Nat-lt-leftInv {n = suc n} f0 = refl Fin-Nat-lt-leftInv {n = suc n} (fs x) = cong fs (Fin-Nat-lt-leftInv x) Fin-Nat-lt : Fin n ⇔ Σ[ m ⦂ ℕ ] × (m ℕ.< n) Fin-Nat-lt .fun = Fin-to-Nat-lt Fin-Nat-lt .inv = uncurry Fin-from-Nat-lt Fin-Nat-lt .rightInv = uncurry Fin-Nat-lt-rightInv Fin-Nat-lt .leftInv = Fin-Nat-lt-leftInv FinToℕ : Fin n → ℕ FinToℕ {n = suc n} f0 = zero FinToℕ {n = suc n} (fs x) = suc (FinToℕ x) FinToℕ-injective : ∀ {k} {m n : Fin k} → FinToℕ m ≡ FinToℕ n → m ≡ n FinToℕ-injective {suc k} {f0} {f0} _ = refl FinToℕ-injective {suc k} {f0} {fs x} p = ⊥-elim (ℕ.znots p) FinToℕ-injective {suc k} {fs m} {f0} p = ⊥-elim (ℕ.snotz p) FinToℕ-injective {suc k} {fs m} {fs x} p = cong fs (FinToℕ-injective (ℕ.injSuc p)) pred : Fin (suc n) → Fin (suc (ℕ.pred n)) pred f0 = f0 pred {n = suc n} (fs m) = m discreteFin : ∀ {k} → Discrete (Fin k) discreteFin {k = suc _} f0 f0 = yes refl discreteFin {k = suc _} f0 (fs fk) = no (ℕ.znots ∘ cong FinToℕ) discreteFin {k = suc _} (fs fj) f0 = no (ℕ.snotz ∘ cong FinToℕ) discreteFin {k = suc _} (fs fj) (fs fk) = iff-dec (cong fs iff cong (λ { f0 → fk ; (fs x) → x})) (discreteFin fj fk) isSetFin : isSet (Fin n) isSetFin = Discrete→isSet discreteFin FinFromℕ : (n m : ℕ) → T (n <ᵇ m) → Fin m FinFromℕ zero (suc m) p = f0 FinFromℕ (suc n) (suc m) p = fs (FinFromℕ n m p)
{ "alphanum_fraction": 0.6092715232, "avg_line_length": 35.0144927536, "ext": "agda", "hexsha": "14aff16bba66fe3f1cd237ce89cfdedac4fa4e36", "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/Fin/Properties.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/Fin/Properties.agda", "max_line_length": 103, "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/Fin/Properties.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": 1071, "size": 2416 }
open import Level open import Relation.Binary.PropositionalEquality import Categories.Category open import Syntax module Renaming where open Equality -- the set of renamings infix 5 _→ʳ_ _→ʳ_ : VShape → VShape → Set γ →ʳ δ = var γ → var δ -- equality of renamings infix 5 _≡ʳ_ _≡ʳ_ : ∀ {γ δ} → (ρ : γ →ʳ δ) → (t : γ →ʳ δ) → Set ρ ≡ʳ σ = ∀ x → ρ x ≡ σ x -- equality is an equivalence relation ≡ʳ-refl : ∀ {γ δ} → {ρ : γ →ʳ δ} → ρ ≡ʳ ρ ≡ʳ-refl x = refl ≡ʳ-sym : ∀ {γ δ} → {ρ τ : γ →ʳ δ} → ρ ≡ʳ τ → τ ≡ʳ ρ ≡ʳ-sym ξ x = sym (ξ x) ≡ʳ-trans : ∀ {γ δ} → {ρ τ χ : γ →ʳ δ} → ρ ≡ʳ τ → τ ≡ʳ χ → ρ ≡ʳ χ ≡ʳ-trans ζ ξ x = trans (ζ x) (ξ x) -- 𝟘 is the weakly initial shape 𝟘-initial : ∀ {γ} → 𝟘 →ʳ γ 𝟘-initial () -- identity renaming 𝟙ʳ : ∀ {γ} → γ →ʳ γ 𝟙ʳ x = x -- composition of renamings infixl 7 _∘ʳ_ _∘ʳ_ : ∀ {γ δ η} → (δ →ʳ η) → (γ →ʳ δ) → (γ →ʳ η) (ρ ∘ʳ τ) x = ρ (τ x) -- join of renamings infix 6 [_,_]ʳ [_,_]ʳ : ∀ {γ δ η} → (γ →ʳ η) → (δ →ʳ η) → (γ ⊕ δ →ʳ η) [ ρ , τ ]ʳ (var-left x) = ρ x [ ρ , τ ]ʳ (var-right y) = τ y -- renaming extension ⇑ʳ : ∀ {γ δ η} → (γ →ʳ δ) → (γ ⊕ η →ʳ δ ⊕ η) ⇑ʳ ρ (var-left x) = var-left (ρ x) ⇑ʳ ρ (var-right y) = var-right y -- extension preserves equality ⇑ʳ-resp-≡ʳ : ∀ {γ δ η} {ρ τ : γ →ʳ δ} → ρ ≡ʳ τ → ⇑ʳ {η = η} ρ ≡ʳ ⇑ʳ τ ⇑ʳ-resp-≡ʳ ξ (var-left x) = cong var-left (ξ x) ⇑ʳ-resp-≡ʳ ξ (var-right y) = refl -- extension respects identity ⇑ʳ-resp-𝟙ʳ : ∀ {γ δ} → ⇑ʳ {η = δ} (𝟙ʳ {γ = γ}) ≡ʳ 𝟙ʳ ⇑ʳ-resp-𝟙ʳ (var-left x) = refl ⇑ʳ-resp-𝟙ʳ (var-right x) = refl -- extension commutes with composition ⇑ʳ-resp-∘ʳ : ∀ {β γ δ η} {ρ : β →ʳ γ} {τ : γ →ʳ δ} → ⇑ʳ {η = η} (τ ∘ʳ ρ) ≡ʳ ⇑ʳ τ ∘ʳ ⇑ʳ ρ ⇑ʳ-resp-∘ʳ (var-left x) = refl ⇑ʳ-resp-∘ʳ (var-right y) = refl module _ {𝕊 : Signature} where open Expression 𝕊 -- the action of a renaming on an expression infixr 6 [_]ʳ_ [_]ʳ_ : ∀ {𝕄} {cl} {γ} {δ} (ρ : γ →ʳ δ) → Expr 𝕄 cl γ → Expr 𝕄 cl δ [ ρ ]ʳ (expr-var x) = expr-var (ρ x) [ ρ ]ʳ (expr-symb S es) = expr-symb S (λ i → [ ⇑ʳ ρ ]ʳ (es i)) [ ρ ]ʳ (expr-meta M ts) = expr-meta M (λ i → [ ρ ]ʳ (ts i)) [ ρ ]ʳ expr-eqty = expr-eqty [ ρ ]ʳ expr-eqtm = expr-eqtm -- the action respects equality of renamings and equality of terms []ʳ-resp-≈ : ∀ {𝕄} {cl} {γ} {δ} (ρ : γ →ʳ δ) {t u : Expr 𝕄 cl γ} → t ≈ u → [ ρ ]ʳ t ≈ [ ρ ]ʳ u []ʳ-resp-≈ ρ (≈-≡ ξ) = ≈-≡ (cong [ ρ ]ʳ_ ξ) []ʳ-resp-≈ ρ (≈-symb ξ) = ≈-symb (λ i → []ʳ-resp-≈ (⇑ʳ ρ) (ξ i)) []ʳ-resp-≈ ρ (≈-meta ξ) = ≈-meta (λ i → []ʳ-resp-≈ ρ (ξ i)) []ʳ-resp-≡ʳ : ∀ {𝕄} {cl} {γ} {δ} {ρ τ : γ →ʳ δ} (t : Expr cl 𝕄 γ) → ρ ≡ʳ τ → [ ρ ]ʳ t ≈ [ τ ]ʳ t []ʳ-resp-≡ʳ (expr-var x) ξ = ≈-≡ (cong expr-var (ξ x)) []ʳ-resp-≡ʳ (expr-symb S es) ξ = ≈-symb (λ i → []ʳ-resp-≡ʳ (es i) (⇑ʳ-resp-≡ʳ ξ)) []ʳ-resp-≡ʳ (expr-meta M ts) ξ = ≈-meta (λ i → []ʳ-resp-≡ʳ (ts i) ξ) []ʳ-resp-≡ʳ expr-eqty ξ = ≈-eqty []ʳ-resp-≡ʳ expr-eqtm ξ = ≈-eqtm -- the action is functorial [𝟙ʳ] : ∀ {cl 𝕄 γ} {t : Expr cl 𝕄 γ} → [ 𝟙ʳ ]ʳ t ≈ t [𝟙ʳ] {t = expr-var x} = ≈-refl [𝟙ʳ] {t = expr-symb S es} = ≈-symb (λ i → ≈-trans ([]ʳ-resp-≡ʳ (es i) ⇑ʳ-resp-𝟙ʳ) [𝟙ʳ]) [𝟙ʳ] {t = expr-meta M ts} = ≈-meta (λ i → [𝟙ʳ]) [𝟙ʳ] {t = expr-eqty} = ≈-eqty [𝟙ʳ] {t = expr-eqtm} = ≈-eqtm [∘ʳ] : ∀ {cl 𝕄} {γ δ η} {ρ : γ →ʳ δ} {τ : δ →ʳ η} (t : Expr cl 𝕄 γ) → [ τ ∘ʳ ρ ]ʳ t ≈ [ τ ]ʳ [ ρ ]ʳ t [∘ʳ] (expr-var x) = ≈-refl [∘ʳ] (expr-symb S es) = ≈-symb (λ i → ≈-trans ([]ʳ-resp-≡ʳ (es i) ⇑ʳ-resp-∘ʳ) ([∘ʳ] (es i))) [∘ʳ] (expr-meta M ts) = ≈-meta (λ i → [∘ʳ] (ts i)) [∘ʳ] expr-eqty = ≈-eqty [∘ʳ] expr-eqtm = ≈-eqtm []ʳ-id : ∀ {cl 𝕄 γ} {ρ : γ →ʳ γ} {t : Expr cl 𝕄 γ} → ρ ≡ʳ 𝟙ʳ → [ ρ ]ʳ t ≈ t []ʳ-id ξ = ≈-trans ([]ʳ-resp-≡ʳ _ ξ) [𝟙ʳ] -- the categorical structure module _ where open Categories.Category Renamings : Category zero zero zero Renamings = record { Obj = VShape ; _⇒_ = _→ʳ_ ; _≈_ = _≡ʳ_ ; id = 𝟙ʳ ; _∘_ = _∘ʳ_ ; assoc = λ _ → refl ; sym-assoc = λ _ → refl ; identityˡ = λ _ → refl ; identityʳ = λ _ → refl ; identity² = λ _ → refl ; equiv = record { refl = ≡ʳ-refl ; sym = ≡ʳ-sym ; trans = ≡ʳ-trans } ; ∘-resp-≈ = λ {_} {_} {_} {ρ} {_} {_} {τ} ζ ξ x → trans (cong ρ (ξ x)) (ζ (τ x)) }
{ "alphanum_fraction": 0.4678522572, "avg_line_length": 28.6666666667, "ext": "agda", "hexsha": "71c6a3569edcc8f5582ff204367f125721ef96d2", "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": "9b634d284a0ec5108c68489575194cd573f38908", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/dependent-type-theory-syntax", "max_forks_repo_path": "src/Renaming.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9b634d284a0ec5108c68489575194cd573f38908", "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": "andrejbauer/dependent-type-theory-syntax", "max_issues_repo_path": "src/Renaming.agda", "max_line_length": 105, "max_stars_count": 7, "max_stars_repo_head_hexsha": "9b634d284a0ec5108c68489575194cd573f38908", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andrejbauer/dependent-type-theory-syntax", "max_stars_repo_path": "src/Renaming.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-14T01:48:00.000Z", "max_stars_repo_stars_event_min_datetime": "2021-05-25T11:14:42.000Z", "num_tokens": 2452, "size": 4386 }
{- Equalizer of functions f g : S X ⇉ T X such that f and g act on relation structures -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Structures.Relational.Equalizer where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.RelationalStructure open import Cubical.Data.Sigma open import Cubical.HITs.SetQuotients open import Cubical.HITs.PropositionalTruncation as Trunc open import Cubical.Relation.Binary.Base private variable ℓ ℓ₁ ℓ₁' ℓ₂ ℓ₂' : Level EqualizerStructure : {S : Type ℓ → Type ℓ₁} {T : Type ℓ → Type ℓ₂} (f g : ∀ X → S X → T X) → Type ℓ → Type (ℓ-max ℓ₁ ℓ₂) EqualizerStructure {S = S} f g X = Σ[ s ∈ S X ] f X s ≡ g X s EqualizerRelStr : {S : Type ℓ → Type ℓ₁} {T : Type ℓ → Type ℓ₂} {f g : ∀ X → S X → T X} → StrRel S ℓ₁' → StrRel T ℓ₂' → StrRel (EqualizerStructure f g) ℓ₁' EqualizerRelStr ρ₁ ρ₂ R (s , _) (s' , _) = ρ₁ R s s' equalizerSuitableRel : {S : Type ℓ → Type ℓ₁} {T : Type ℓ → Type ℓ₂} {f g : ∀ X → S X → T X} {ρ₁ : StrRel S ℓ₁'} {ρ₂ : StrRel T ℓ₂'} (αf : ∀ {X Y} {R : X → Y → Type ℓ} {s s'} → ρ₁ R s s' → ρ₂ R (f X s) (f Y s')) (αg : ∀ {X Y} {R : X → Y → Type ℓ} {s s'} → ρ₁ R s s' → ρ₂ R (g X s) (g Y s')) → SuitableStrRel S ρ₁ → SuitableStrRel T ρ₂ → SuitableStrRel (EqualizerStructure f g) (EqualizerRelStr ρ₁ ρ₂) equalizerSuitableRel {f = f} {g} {ρ₁} {ρ₂} αf αg θ₁ θ₂ .quo (X , s , p) (R , qer) r = ( ((quo₁ .fst .fst , sym step₀ ∙ step₁) , quo₁ .fst .snd) , λ {((s' , _) , r') → Σ≡Prop (λ _ → θ₁ .prop (λ _ _ → squash/ _ _) _ _) (Σ≡Prop (λ _ → θ₂ .set squash/ _ _) (cong fst (quo₁ .snd (s' , r'))))} ) where quo₁ = θ₁ .quo (X , s) (R , qer) r quo₂ = θ₂ .quo (X , f X s) (R , qer) (αf r) step₀ : quo₂ .fst .fst ≡ f (X / R .fst) (quo₁ .fst .fst) step₀ = cong fst (quo₂ .snd (f _ (quo₁ .fst .fst) , αf (quo₁ .fst .snd))) step₁ : quo₂ .fst .fst ≡ g (X / R .fst) (quo₁ .fst .fst) step₁ = cong fst (quo₂ .snd ( g _ (quo₁ .fst .fst) , subst (λ t → ρ₂ (graphRel [_]) t (g _ (quo₁ .fst .fst))) (sym p) (αg (quo₁ .fst .snd)) )) equalizerSuitableRel _ _ θ₁ _ .symmetric R = θ₁ .symmetric R equalizerSuitableRel _ _ θ₁ _ .transitive R R' = θ₁ .transitive R R' equalizerSuitableRel _ _ θ₁ θ₂ .set setX = isSetΣ (θ₁ .set setX) λ _ → isOfHLevelPath 2 (θ₂ .set setX) _ _ equalizerSuitableRel _ _ θ₁ _ .prop propR _ _ = θ₁ .prop propR _ _
{ "alphanum_fraction": 0.5914065667, "avg_line_length": 36.2794117647, "ext": "agda", "hexsha": "d5a14511941c452fd6773d84cba0db08c9578557", "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": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Structures/Relational/Equalizer.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/Structures/Relational/Equalizer.agda", "max_line_length": 96, "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/Structures/Relational/Equalizer.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1053, "size": 2467 }
{-# OPTIONS --warning=error --safe --without-K #-} open import LogicalFormulae open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Functions.Definition open import Setoids.Setoids open import Setoids.Subset open import Graphs.Definition open import Sets.EquivalenceRelations module Graphs.Complement {a b c : _} {V' : Set a} {V : Setoid {a} {b} V'} (G : Graph c V) where open Graph G open Setoid V open Equivalence eq complement : Graph (b ⊔ c) V Graph._<->_ complement x y = ((x <-> y) → False) && ((x ∼ y) → False) Graph.noSelfRelation complement x (pr1 ,, pr2) = pr2 reflexive Graph.symmetric complement (x!-y ,, x!=y) = (λ pr → x!-y (Graph.symmetric G pr)) ,, λ pr → x!=y (Equivalence.symmetric eq pr) Graph.wellDefined complement x=y r=s (x!-r ,, x!=r) = (λ y-s → x!-r (wellDefined (Equivalence.symmetric eq x=y) (Equivalence.symmetric eq r=s) y-s)) ,, λ y=s → x!=r (transitive x=y (transitive y=s (Equivalence.symmetric eq r=s)))
{ "alphanum_fraction": 0.6871741397, "avg_line_length": 43.5909090909, "ext": "agda", "hexsha": "30a1da5a26c251cb00dffa5d8bcbfbd70472354b", "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": "Graphs/Complement.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": "Graphs/Complement.agda", "max_line_length": 229, "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": "Graphs/Complement.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": 305, "size": 959 }
{-# OPTIONS --safe #-} module Cubical.Algebra.Group.Instances.Bool where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Structure open import Cubical.Relation.Nullary open import Cubical.Data.Bool open import Cubical.Data.Empty as ⊥ open import Cubical.Data.Sum hiding (map ; rec) open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Algebra.Monoid open import Cubical.Algebra.Semigroup open GroupStr open IsGroup open IsMonoid open IsSemigroup BoolGroup : Group₀ fst BoolGroup = Bool 1g (snd BoolGroup) = true (snd BoolGroup · false) false = true (snd BoolGroup · false) true = false (snd BoolGroup · true) y = y inv (snd BoolGroup) x = x is-set (isSemigroup (isMonoid (isGroup (snd BoolGroup)))) = isSetBool ·Assoc (isSemigroup (isMonoid (isGroup (snd BoolGroup)))) false false false = refl ·Assoc (isSemigroup (isMonoid (isGroup (snd BoolGroup)))) false false true = refl ·Assoc (isSemigroup (isMonoid (isGroup (snd BoolGroup)))) false true false = refl ·Assoc (isSemigroup (isMonoid (isGroup (snd BoolGroup)))) false true true = refl ·Assoc (isSemigroup (isMonoid (isGroup (snd BoolGroup)))) true false false = refl ·Assoc (isSemigroup (isMonoid (isGroup (snd BoolGroup)))) true false true = refl ·Assoc (isSemigroup (isMonoid (isGroup (snd BoolGroup)))) true true false = refl ·Assoc (isSemigroup (isMonoid (isGroup (snd BoolGroup)))) true true true = refl ·IdR (isMonoid (isGroup (snd BoolGroup))) false = refl ·IdR (isMonoid (isGroup (snd BoolGroup))) true = refl ·IdL (isMonoid (isGroup (snd BoolGroup))) false = refl ·IdL (isMonoid (isGroup (snd BoolGroup))) true = refl ·InvR (isGroup (snd BoolGroup)) false = refl ·InvR (isGroup (snd BoolGroup)) true = refl ·InvL (isGroup (snd BoolGroup)) false = refl ·InvL (isGroup (snd BoolGroup)) true = refl -- Proof that any Group equivalent to Bool as types is also isomorphic to Bool as groups. open GroupStr renaming (·Assoc to ·AssocG) module _ {ℓ : Level} {A : Group ℓ} (e : Iso (fst A) Bool) where private discreteA : Discrete (typ A) discreteA = isoPresDiscrete (invIso e) _≟_ _·A_ = GroupStr._·_ (snd A) -A_ = GroupStr.inv (snd A) IsoABool : Iso Bool (typ A) IsoABool with (Iso.fun e (1g (snd A))) ≟ true ... | yes p = invIso e ... | no p = compIso notIso (invIso e) true→1 : Iso.fun IsoABool true ≡ 1g (snd A) true→1 with (Iso.fun e (1g (snd A))) ≟ true ... | yes p = sym (cong (Iso.inv e) p) ∙ Iso.leftInv e _ ... | no p = sym (cong (Iso.inv e) (¬true→false (Iso.fun e (1g (snd A))) p)) ∙ Iso.leftInv e (1g (snd A)) decA : (x : typ A) → (x ≡ 1g (snd A)) ⊎ (x ≡ Iso.fun IsoABool false) decA x with (Iso.inv IsoABool x) ≟ false | discreteA x (1g (snd A)) ... | yes p | yes q = inl q ... | yes p | no q = inr (sym (Iso.rightInv IsoABool x) ∙ cong (Iso.fun (IsoABool)) p) ... | no p | no q = inr (⊥.rec (q (sym (Iso.rightInv IsoABool x) ∙∙ cong (Iso.fun IsoABool) (¬false→true _ p) ∙∙ true→1))) ... | no p | yes q = inl q ≅Bool : GroupIso BoolGroup A ≅Bool .fst = IsoABool ≅Bool .snd = makeIsGroupHom homHelp where homHelp : _ homHelp false false with discreteA (Iso.fun IsoABool false) (1g (snd A)) | (decA ((Iso.fun IsoABool false) ·A Iso.fun IsoABool false)) ... | yes p | _ = true→1 ∙∙ sym (GroupStr.·IdR (snd A) (1g (snd A))) ∙∙ cong₂ (_·A_) (sym p) (sym p) ... | no p | inl x = true→1 ∙ sym x ... | no p | inr x = true→1 ∙∙ sym (helper _ x) ∙∙ sym x where helper : (x : typ A) → x ·A x ≡ x → x ≡ (1g (snd A)) helper x p = sym (GroupStr.·IdR (snd A) x) ∙∙ cong (x ·A_) (sym ((snd A) .·InvR x)) ∙∙ ·AssocG (snd A) x x (-A x) ∙∙ cong (_·A (-A x)) p ∙∙ (snd A) .·InvR x homHelp false true = sym (GroupStr.·IdR (snd A) _) ∙ cong (Iso.fun IsoABool false ·A_) (sym true→1) homHelp true y = sym (GroupStr.·IdL (snd A) _) ∙ cong (_·A (Iso.fun IsoABool y)) (sym true→1)
{ "alphanum_fraction": 0.6311163895, "avg_line_length": 41.6831683168, "ext": "agda", "hexsha": "57c5847ec68766c394f3d59972450e6dadca26a0", "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/Group/Instances/Bool.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/Group/Instances/Bool.agda", "max_line_length": 108, "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/Group/Instances/Bool.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1427, "size": 4210 }
-- Andreas, 2012-10-30 Sections -- Reported by guillaume.brunerie, Oct 24 2012 module Issue735 where import Common.Level open import Common.Prelude using (Nat; zero; suc) module _ {a} (A : Set a) where data List : Set a where [] : List _∷_ : (x : A) (xs : List) → List module _ {a} {A : Set a} where _++_ : List → List → List [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ (xs ++ ys) -- should not work, we cannot cut a section in two -- correct is: List A test : List Nat test = (5 ∷ []) ++ (3 ∷ [])
{ "alphanum_fraction": 0.5714285714, "avg_line_length": 21, "ext": "agda", "hexsha": "3290eb4305bd878931d63010f7763f1c1c979173", "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/Issue735.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/Issue735.agda", "max_line_length": 50, "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/Issue735.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": 184, "size": 525 }
{-# OPTIONS --without-K #-} open import lib.Basics open import lib.types.Sigma open import lib.types.Pi open import lib.types.Paths open import lib.types.Unit open import lib.types.Empty module lib.Equivalences2 where {- Pre- and post- composition with equivalences are equivalences -} module _ {i j k} {A : Type i} {B : Type j} {C : Type k} {h : A → B} (e : is-equiv h) where pre∘-is-equiv : is-equiv (λ (k : B → C) → k ∘ h) pre∘-is-equiv = is-eq f g f-g g-f where f = λ k → k ∘ h g = λ k → k ∘ is-equiv.g e f-g = λ k → ap (λ q → λ x → k (q x)) (λ= $ is-equiv.g-f e) g-f = λ k → ap (λ q → λ x → k (q x)) (λ= $ is-equiv.f-g e) post∘-is-equiv : is-equiv (λ (k : C → A) → h ∘ k) post∘-is-equiv = is-eq f g f-g g-f where f = λ k → h ∘ k g = λ k → is-equiv.g e ∘ k f-g = λ k → ap (λ q → q ∘ k) (λ= $ is-equiv.f-g e) g-f = λ k → ap (λ q → q ∘ k) (λ= $ is-equiv.g-f e) {- The same thing on the abstraction level of equivalences -} module _ {i j k} {A : Type i} {B : Type j} {C : Type k} (e : A ≃ B) where pre∘-equiv : (B → C) ≃ (A → C) pre∘-equiv = (_ , pre∘-is-equiv (snd e)) post∘-equiv : (C → A) ≃ (C → B) post∘-equiv = (_ , post∘-is-equiv (snd e)) is-contr-map : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) → Type (lmax i j) is-contr-map {A = A} {B = B} f = (y : B) → is-contr (Σ A (λ x → f x == y)) equiv-is-contr-map : ∀ {i j} {A : Type i} {B : Type j} {f : A → B} → (is-equiv f → is-contr-map f) equiv-is-contr-map e y = equiv-preserves-level ((equiv-Σ-fst (λ z → z == y) e) ⁻¹) (pathto-is-contr y) contr-map-is-equiv : ∀ {i j} {A : Type i} {B : Type j} {f : A → B} → (is-contr-map f → is-equiv f) contr-map-is-equiv {f = f} cm = is-eq _ (λ b → fst (fst (cm b))) (λ b → snd (fst (cm b))) (λ a → ap fst (snd (cm (f a)) (a , idp))) fiber=-eqv : ∀ {i j} {A : Type i} {B : Type j} {h : A → B} {y : B} (r s : Σ A (λ x → h x == y)) → (r == s) ≃ Σ (fst r == fst s) (λ γ → ap h γ ∙ snd s == snd r) fiber=-eqv r s = equiv-Σ-snd (λ γ → !-equiv ∘e (↓-app=cst-eqv ⁻¹)) ∘e ((=Σ-eqv r s)⁻¹) module _ {i j} {A : Type i} {B : Type j} where linv : (A → B) → Type (lmax i j) linv f = Σ (B → A) (λ g → (∀ x → g (f x) == x)) rinv : (A → B) → Type (lmax i j) rinv f = Σ (B → A) (λ g → (∀ y → f (g y) == y)) lcoh : (f : A → B) → linv f → Type (lmax i j) lcoh f (g , g-f) = Σ (∀ y → f (g y) == y) (λ f-g → ∀ y → ap g (f-g y) == g-f (g y)) rcoh : (f : A → B) → rinv f → Type (lmax i j) rcoh f (g , f-g) = Σ (∀ x → g (f x) == x) (λ g-f → ∀ x → ap f (g-f x) == f-g (f x)) module _ {i j} {A : Type i} {B : Type j} {f : A → B} (e : is-equiv f) where equiv-linv-is-contr : is-contr (linv f) equiv-linv-is-contr = equiv-preserves-level (equiv-Σ-snd (λ _ → λ=-equiv ⁻¹)) (equiv-is-contr-map (pre∘-is-equiv e) (idf A)) equiv-rinv-is-contr : is-contr (rinv f) equiv-rinv-is-contr = equiv-preserves-level (equiv-Σ-snd (λ _ → λ=-equiv ⁻¹)) (equiv-is-contr-map (post∘-is-equiv e) (idf B)) module _ {i j} {A : Type i} {B : Type j} {f : A → B} where rcoh-eqv : (v : rinv f) → rcoh f v ≃ Π A (λ x → (fst v (f x) , snd v (f x)) == (x , idp {a = f x})) rcoh-eqv v = equiv-Π-r (λ x → ((fiber=-eqv {h = f} _ _)⁻¹) ∘e apply-unit-r x) ∘e choice ⁻¹ where apply-unit-r : ∀ x → Σ _ (λ γ → ap f γ == _) ≃ Σ _ (λ γ → ap f γ ∙ idp == _) apply-unit-r x = equiv-Σ-snd $ λ γ → coe-equiv (ap (λ q → q == snd v (f x)) (! (∙-unit-r _))) lcoh-eqv : (v : linv f) → lcoh f v ≃ Π B (λ y → (f (fst v y) , snd v (fst v y)) == (y , idp)) lcoh-eqv v = equiv-Π-r (λ y → ((fiber=-eqv {h = fst v} _ _)⁻¹) ∘e apply-unit-r y) ∘e choice ⁻¹ where apply-unit-r : ∀ y → Σ _ (λ γ → ap (fst v) γ == _) ≃ Σ _ (λ γ → ap (fst v) γ ∙ idp == _) apply-unit-r y = equiv-Σ-snd $ λ γ → coe-equiv (ap (λ q → q == snd v (fst v y)) (! (∙-unit-r _))) equiv-rcoh-is-contr : ∀ {i j} {A : Type i} {B : Type j} {f : A → B} (e : is-equiv f) → (v : rinv f) → is-contr (rcoh f v) equiv-rcoh-is-contr {f = f} e v = equiv-preserves-level ((rcoh-eqv v)⁻¹) (Π-level (λ x → =-preserves-level -2 (equiv-is-contr-map e (f x)))) rinv-and-rcoh-eqv-is-equiv : ∀ {i j} {A : Type i} {B : Type j} {h : A → B} → Σ (rinv h) (rcoh h) ≃ is-equiv h rinv-and-rcoh-eqv-is-equiv {h = h} = equiv f g (λ _ → idp) (λ _ → idp) where f : Σ (rinv h) (rcoh h) → is-equiv h f s = record {g = fst (fst s); f-g = snd (fst s); g-f = fst (snd s); adj = snd (snd s)} g : is-equiv h → Σ (rinv h) (rcoh h) g t = ((is-equiv.g t , is-equiv.f-g t) , (is-equiv.g-f t , is-equiv.adj t)) is-equiv-is-prop : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) → is-prop (is-equiv f) is-equiv-is-prop _ = inhab-to-contr-is-prop $ λ e → equiv-preserves-level rinv-and-rcoh-eqv-is-equiv (Σ-level (equiv-rinv-is-contr e) (equiv-rcoh-is-contr e)) ∘e-unit-r : ∀ {i} {A B : Type i} (e : A ≃ B) → (e ∘e ide A) == e ∘e-unit-r e = pair= idp (prop-has-all-paths (is-equiv-is-prop (fst e)) _ _) ua-∘e : ∀ {i} {A B : Type i} (e₁ : A ≃ B) {C : Type i} (e₂ : B ≃ C) → ua (e₂ ∘e e₁) == ua e₁ ∙ ua e₂ ua-∘e = equiv-induction (λ {A} {B} e₁ → ∀ {C} → ∀ (e₂ : B ≃ C) → ua (e₂ ∘e e₁) == ua e₁ ∙ ua e₂) (λ A → λ e₂ → ap ua (∘e-unit-r e₂) ∙ ap (λ w → (w ∙ ua e₂)) (! (ua-η idp))) {- Type former equivalences involving Empty may require λ=. -} module _ {j} {B : Empty → Type j} where Σ₁-Empty : Σ Empty B ≃ Empty Σ₁-Empty = equiv (⊥-rec ∘ fst) ⊥-rec ⊥-elim (⊥-rec ∘ fst) Π₁-Empty : Π Empty B ≃ Unit Π₁-Empty = equiv (cst tt) (cst ⊥-elim) (λ _ → contr-has-all-paths Unit-is-contr _ _) (λ _ → λ= ⊥-elim) Σ₂-Empty : ∀ {i} {A : Type i} → Σ A (λ _ → Empty) ≃ Empty Σ₂-Empty = equiv (⊥-rec ∘ snd) ⊥-rec ⊥-elim (⊥-rec ∘ snd)
{ "alphanum_fraction": 0.4878793016, "avg_line_length": 39.0662251656, "ext": "agda", "hexsha": "dadb217628eafc0d749d1a76b4a7eaa4459e3827", "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": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_path": "core/lib/Equivalences2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "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": "cmknapp/HoTT-Agda", "max_issues_repo_path": "core/lib/Equivalences2.agda", "max_line_length": 104, "max_stars_count": null, "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_path": "core/lib/Equivalences2.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2543, "size": 5899 }
open import Agda.Builtin.Coinduction open import Agda.Builtin.Nat open import Agda.Builtin.List open import Agda.Builtin.Equality data Colist (A : Set) : Set where [] : Colist A _∷_ : A → ∞ (Colist A) → Colist A from : Nat → Colist Nat from n = let sn = suc n in n ∷ ♯ (from sn) take : {A : Set} → Nat → Colist A → List A take zero xs = [] take (suc n) [] = [] take (suc n) (x ∷ xs) = x ∷ take n (♭ xs) check : take 3 (from 5) ≡ 5 ∷ 6 ∷ 7 ∷ [] check = refl
{ "alphanum_fraction": 0.6012793177, "avg_line_length": 22.3333333333, "ext": "agda", "hexsha": "99935dd0d5c1232fb3df9b32c58cf9c0f4e555a5", "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/Succeed/Issue140.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/Succeed/Issue140.agda", "max_line_length": 42, "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/Succeed/Issue140.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": 186, "size": 469 }
module Issue308a where data D : Set where d : D → D syntax d x = d d x f : D → D f x = d d x
{ "alphanum_fraction": 0.5612244898, "avg_line_length": 9.8, "ext": "agda", "hexsha": "a63e5840e921e644f0224d22efb69402d12a6a82", "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/Issue308a.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/Issue308a.agda", "max_line_length": 22, "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/Issue308a.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": 98 }
{- A counterexample from Section 5.1 of Andreas Abel's dissertation [1], showing that the types of recursive functions must be (semi-)continuous, i.e. `loop` below should be disallowed. In the example, `loop` is not used as-is, but rather the size involved is instantiated to the infinite size in order to pass in `plus2`. The conditions on ω-instantiating from John Hughes' paper [2] is essentially a stricter condition than Abel's semi-continuity on where size variables may appear in the type. [1] A Polymorphic Lambda-Calculus with Sized Higher-Order Types [2] Proving the Correctness of Reactive Systems using Sized Types -} data Size : Set where ∘ : Size ↑_ : Size → Size data Nat : Size → Set where zero : ∀ {s} → Nat (↑ s) succ : ∀ {s} → Nat s → Nat (↑ s) data NatInf : Set where ⟦_⟧ : ∀ {s} → Nat s → NatInf zero∘ : Nat (↑ ∘) zero∘ = zero {∘} shift : ∀ {s} → (NatInf → Nat (↑ (↑ s))) → NatInf → Nat (↑ s) shift f ⟦ n ⟧ with f ⟦ succ n ⟧ ... | zero = zero ... | succ m = m plus2 : NatInf → NatInf plus2 ⟦ n ⟧ = ⟦ succ (succ n) ⟧ loop : ∀ {s} → Nat s → (NatInf → Nat (↑ s)) → NatInf loop _ f with f ⟦ zero∘ ⟧ ... | zero = ⟦ zero∘ ⟧ ... | succ zero = ⟦ zero∘ ⟧ ... | succ (succ k) = loop k (shift f) {- Interpreting Nat^∞ as a size-paired natural, we need to somehow derive an infinity-instantiated version (`loopInf`) using `loop`, but we cannot produce a `NatInf → Nat (↑ s)` out of `NatInf → NatInf`: doing so amounts to proving `∃s. Nat s → ∀s. Nat s`. -} -- loop cannot be instantiated with an infinite size postulate loopInf : NatInf → (NatInf → NatInf) → NatInf uhoh : NatInf uhoh = loopInf ⟦ zero∘ ⟧ plus2
{ "alphanum_fraction": 0.635391924, "avg_line_length": 30.0714285714, "ext": "agda", "hexsha": "101f2d65360cc65c0e445e87bb5b037c4510928a", "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": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "ionathanch/msc-thesis", "max_forks_repo_path": "code/SizeLoop.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "ionathanch/msc-thesis", "max_issues_repo_path": "code/SizeLoop.agda", "max_line_length": 74, "max_stars_count": null, "max_stars_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "ionathanch/msc-thesis", "max_stars_repo_path": "code/SizeLoop.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 559, "size": 1684 }
module Esterel.Lang.CanFunction.Properties where {- Basic properties of the Can function and utilities used in the reasoning, such as Can does not look at shared variables and sequential variables; Can can only output free variables; Can will capture free emit S and s ⇐ e (and more). -} open import Esterel.Lang.CanFunction.Base hiding ([_↦_]) public {- The equivalent "goodness" of can w.r.t. the rmerge reduction. Specifically, here are the main lemmas: can-irr : ∀ {BV} {FV} θ₁ θ₂ q → CorrectBinding q BV FV → (distinct' (proj₁ FV) (proj₁ (Dom θ₂))) → Can q θ₁ ≡ Can q (θ₁ ← θ₂) can-irr θ₁ θ₂ q cbq FV≠Domθ₂ canθₛ-mergeˡ : ∀ {E θ' r p BV FV} sigs θ → CorrectBinding p BV FV → p ≐ E ⟦ ρ θ' · r ⟧e → ∀ S' → Signal.unwrap S' ∉ SigMap.keys (Env.sig θ') → Signal.unwrap S' ∈ Canθₛ (SigMap.union sigs (Env.sig θ')) 0 (E ⟦ r ⟧e) θ → Signal.unwrap S' ∈ Canθₛ sigs 0 p θ canθₛ-mergeʳ : ∀ sigs θ' r θ → distinct' (proj₁ (Dom θ)) (SigMap.keys sigs) → ∀ S' → Signal.unwrap S' ∈ Canθₛ (SigMap.union sigs (Env.sig θ')) 0 r θ → Signal.unwrap S' ∈ Canθₛ (Env.sig θ') 0 r θ These lemma says that when updating or extending the environent, if the program does not refer to the updated variables, then the Can function will not change and the Canθ function will have some sort of monotonicity. -} open import Esterel.Lang.CanFunction.MergePotentialRuleCan public open import Esterel.Lang.CanFunction.MergePotentialRuleTheta public {- The subset "goodness" of can w.r.t. other ρθ-reductions. For each of the 7 non-merge ρθ-reductions, there are two corresponding Can subset lemmas. -} open import Esterel.Lang.CanFunction.NonMergePotentialRules public {- The compatible closure context C⟦_⟧c respects the monotonicity of the potential function. For example, Can is monotonic w.r.t. to _sn⟶₁_, hence also _sn⟶_ by the lemmas in this file. -} open import Esterel.Lang.CanFunction.Plug public open import utility open import Esterel.Lang using (Term ; emit ; _⇐_) open import Esterel.Context using (_≐_⟦_⟧e) open import Esterel.Environment as Env using (Env ; Θ ; _←_ ; Dom ; module SigMap ; module ShrMap ; module VarMap) open import Esterel.Lang.CanFunction open import Esterel.Variable.Signal as Signal using (Signal ; _ₛ) open import Esterel.Variable.Shared as SharedVar using (SharedVar ; _ₛₕ) open import Esterel.Variable.Sequential as SeqVar using (SeqVar) open import Function using (_∘_) open import Relation.Nullary using (¬_)
{ "alphanum_fraction": 0.7154213037, "avg_line_length": 33.1052631579, "ext": "agda", "hexsha": "4cf9d102c91c14df4634eed17b6b34ad9a898ea2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_path": "agda/Esterel/Lang/CanFunction/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "florence/esterel-calculus", "max_issues_repo_path": "agda/Esterel/Lang/CanFunction/Properties.agda", "max_line_length": 84, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_path": "agda/Esterel/Lang/CanFunction/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "num_tokens": 814, "size": 2516 }
module io-test2 where open import io open import list open import string open import unit main : IO ⊤ main = getArgs >>= cont where cont : 𝕃 string → IO ⊤ cont [] = return triv cont (x :: xs) = (readFiniteFile x) >>= putStr
{ "alphanum_fraction": 0.5740740741, "avg_line_length": 19.2857142857, "ext": "agda", "hexsha": "d91124839405b0797ae1fac4d37a8287b36e2304", "lang": "Agda", "max_forks_count": 17, "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rfindler/ial", "max_forks_repo_path": "io-test2.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rfindler/ial", "max_issues_repo_path": "io-test2.agda", "max_line_length": 62, "max_stars_count": 29, "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rfindler/ial", "max_stars_repo_path": "io-test2.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "num_tokens": 74, "size": 270 }
{-# OPTIONS --warning=error --safe --without-K #-} open import LogicalFormulae open import Semirings.Definition module Semirings.Solver {a : _} {A : Set a} {Zero One : A} {_+_ : A → A → A} {_*_ : A → A → A} (S : Semiring Zero One _+_ _*_) (comm : (a b : A) → a * b ≡ b * a) where open Semiring S -- You can see how to use the solver in LectureNotes/NumbersAndSets/Lecture1.agda. data Expr : Set a where const : A → Expr zero : Expr succ : Expr → Expr plus : Expr → Expr → Expr times : Expr → Expr → Expr -- TODO: do this in distinct phases. (Work out what those phases are.) -- Expose those phases to the user so that they can choose which tactics to use. -- Phases: -- * In any expression which is all sums, extract all consts out to the front -- * In any expression which is all sums, extract all the succs to the front eval : Expr → A eval (const k) = k eval zero = Zero eval (succ e) = One + (eval e) eval (plus x y) = (eval x) + (eval y) eval (times x y) = (eval x) * (eval y) simplePlus : Expr → Expr → Expr simplePlus (const x) (const y) = plus (const x) (const y) simplePlus (const x) zero = const x simplePlus (const x) (succ b) = succ (plus (const x) b) simplePlus (const x) (plus a b) = plus (const x) (plus a b) simplePlus (const x) (times a b) = plus (const x) (times a b) simplePlus zero b = b simplePlus (succ a) (const x) = succ (plus (const x) a) simplePlus (succ a) zero = succ a simplePlus (succ a) (succ b) = succ (succ (plus a b)) simplePlus (succ a) (plus b c) = succ (plus a (plus b c)) simplePlus (succ a) (times b c) = succ (plus a (times b c)) simplePlus (plus a b) (const x) = plus (const x) (plus a b) simplePlus (plus a b) zero = plus a b simplePlus (plus a b) (succ c) = succ (plus a (plus b c)) simplePlus (plus a b) (plus c d) = plus a (plus b (plus c d)) simplePlus (plus a b) (times c d) = plus a (plus b (times c d)) simplePlus (times a b) (const x) = plus (const x) (times a b) simplePlus (times a b) zero = times a b simplePlus (times a b) (succ c) = succ (plus (times a b) c) simplePlus (times a b) (plus c d) = plus (times a b) (plus c d) simplePlus (times a b) (times c d) = plus (times a b) (times c d) private lemma : (a b c : A) → a + (b + c) ≡ b + (a + c) lemma a b c rewrite commutative a (b + c) | equalityCommutative (+Associative b c a) = applyEquality (b +_) (commutative _ _) simplePlusIsPlus : (a b : Expr) → eval (simplePlus a b) ≡ eval (plus a b) simplePlusIsPlus (const x) (const x₁) = refl simplePlusIsPlus (const x) zero rewrite Semiring.sumZeroRight S x = refl simplePlusIsPlus (const x) (succ b) = lemma One x (eval b) simplePlusIsPlus (const x) (plus b c) = refl simplePlusIsPlus (const x) (times b c) = refl simplePlusIsPlus zero b = equalityCommutative (sumZeroLeft (eval b)) simplePlusIsPlus (succ a) (const x) rewrite lemma One x (eval a) = commutative x _ simplePlusIsPlus (succ a) zero = equalityCommutative (sumZeroRight _) simplePlusIsPlus (succ a) (succ b) rewrite lemma (One + eval a) One (eval b) = applyEquality (One +_) (+Associative One _ _) simplePlusIsPlus (succ a) (plus b c) = +Associative _ _ _ simplePlusIsPlus (succ a) (times b c) = +Associative _ _ _ simplePlusIsPlus (plus a b) (const x) = commutative x _ simplePlusIsPlus (plus a b) zero = equalityCommutative (sumZeroRight _) simplePlusIsPlus (plus a b) (succ c) rewrite lemma (eval a + eval b) One (eval c) = applyEquality (One +_) (+Associative _ _ _) simplePlusIsPlus (plus a b) (plus c d) = +Associative (eval a) _ _ simplePlusIsPlus (plus a b) (times c d) = +Associative _ _ _ simplePlusIsPlus (times a b) (const x) = commutative x _ simplePlusIsPlus (times a b) zero = equalityCommutative (sumZeroRight _) simplePlusIsPlus (times a b) (succ c) rewrite lemma One (eval a * eval b) (eval c) = refl simplePlusIsPlus (times a b) (plus c d) = refl simplePlusIsPlus (times a b) (times c d) = refl simplify : Expr → Expr simplify (const k) = const k simplify zero = zero simplify (succ e) = succ (simplify e) simplify (plus (const k) (const x)) = simplePlus (const k) (const x) simplify (plus (const k) zero) = simplify (const k) simplify (plus (const k) (succ expr)) = succ (simplify (plus (const k) expr)) simplify (plus (const k) (plus x y)) = simplePlus (const k) (simplify (plus x y)) simplify (plus (const k) (times x y)) = simplePlus (const k) (simplify (times x y)) simplify (plus zero expr2) = simplify expr2 simplify (plus (succ expr1) expr2) = succ (simplify (plus expr1 expr2)) simplify (plus (plus expr1 expr3) zero) = simplify (plus expr1 expr3) simplify (plus (plus expr1 expr3) (const k)) = simplePlus (const k) (simplify (plus expr1 expr3)) simplify (plus (plus expr1 expr3) (succ expr2)) = succ (simplePlus (simplify (plus expr1 expr3)) (simplify expr2)) simplify (plus (plus expr1 expr3) (plus expr2 expr4)) = simplePlus (simplify (plus expr1 expr3)) (simplify (plus expr2 expr4)) simplify (plus (plus expr1 expr3) (times expr2 expr4)) = simplePlus (simplify (plus expr1 expr3)) (simplify (times expr2 expr4)) simplify (plus (times expr1 expr3) (const k)) = simplePlus (const k) (simplify (times expr1 expr3)) simplify (plus (times expr1 expr3) zero) = times (simplify expr1) (simplify expr3) simplify (plus (times expr1 expr3) (succ expr2)) = succ (simplePlus (simplify (times expr1 expr3)) (simplify expr2)) simplify (plus (times expr1 expr3) (plus expr2 expr4)) = simplePlus (simplify (times expr1 expr3)) (simplify (plus expr2 expr4)) simplify (plus (times expr1 expr3) (times expr2 expr4)) = simplePlus (simplify (times expr1 expr3)) (simplify (times expr2 expr4)) simplify (times (const k) (const x)) = times (const k) (const x) simplify (times (const k) zero) = zero simplify (times (const k) (succ zero)) = const k simplify (times (const k) (succ (const y))) = simplePlus (const k) (times (const k) (const y)) simplify (times (const k) (succ (plus a b))) = simplePlus (const k) (simplify (times (const k) (plus a b))) simplify (times (const k) (succ (times a b))) = simplePlus (const k) (simplify (times (const k) (times a b))) simplify (times (const k) (succ (succ x))) = simplePlus (const k) (simplify (times (const k) (succ x))) simplify (times (const k) (plus expr2 expr3)) = simplePlus (simplify (times (const k) (expr2))) (simplify (times (const k) expr3)) simplify (times (const k) (times expr2 expr3)) = times (const k) (simplify (times expr2 expr3)) simplify (times zero expr2) = zero simplify (times (succ zero) expr2) = simplify expr2 simplify (times (succ (succ expr1)) expr2) = simplePlus (simplify expr2) (simplify (times (succ expr1) expr2)) simplify (times (succ (plus expr1 expr3)) (const k)) = times (const k) (simplify (succ (plus expr1 expr3))) simplify (times (succ (plus expr1 expr3)) zero) = zero simplify (times (succ (plus expr1 expr3)) (succ expr2)) = succ (simplePlus (simplify (times expr1 expr2)) (simplePlus (simplify (times expr3 expr2)) (simplePlus expr2 (simplify (plus expr1 expr3))))) simplify (times (succ (plus expr1 expr3)) (plus expr2 expr4)) = times (simplify (succ (plus expr1 expr3))) (simplify (plus expr2 expr4)) simplify (times (succ (plus expr1 expr3)) (times expr2 expr4)) = times (simplify (succ (plus expr1 expr3))) (simplify (times expr2 expr4)) simplify (times (succ (const k)) (const x)) = simplePlus (const x) (times (const k) (const x)) simplify (times (succ (const k)) zero) = zero simplify (times (succ (const k)) (succ (const x))) = succ (simplePlus (const k) (simplePlus (const x) (simplify (times (const k) (const x))))) simplify (times (succ (const k)) (succ zero)) = succ (const k) simplify (times (succ (const k)) (succ (succ expr2))) = succ (simplePlus (const k) (simplePlus (simplify (succ expr2)) (simplify (times (const k) (succ (expr2)))))) simplify (times (succ (const k)) (succ (plus expr2 expr3))) = succ (simplePlus (const k) (simplePlus (simplify (plus expr2 expr3)) (simplify (times (const k) (plus expr2 expr3))))) simplify (times (succ (const k)) (succ (times expr2 expr3))) = succ (simplePlus (const k) (simplePlus (simplify (times expr2 expr3)) (simplify (times (const k) (times expr2 expr3))))) simplify (times (succ (const k)) (plus expr2 expr3)) = simplePlus (simplify (plus expr2 expr3)) (simplify (times (const k) (plus expr2 expr3))) simplify (times (succ (const k)) (times expr2 expr3)) = simplePlus (simplify (times expr2 expr3)) (simplify (times (const k) (times expr2 expr3))) simplify (times (succ (times expr1 expr3)) (const x)) = times (const x) (simplify (succ (times expr1 expr3))) simplify (times (succ (times expr1 expr3)) zero) = zero simplify (times (succ (times expr1 expr3)) (succ expr2)) = succ (simplePlus (simplify expr2) (plus (simplify (times expr1 expr3)) (simplify (times (times expr1 expr3) expr2)))) simplify (times (succ (times expr1 expr3)) (plus expr2 expr4)) = simplePlus (simplify (plus expr2 expr4)) (simplify (times (times expr1 expr3) (plus expr2 expr4))) simplify (times (succ (times expr1 expr3)) (times expr2 expr4)) = simplePlus (simplify (times expr2 expr4)) (simplify (times (times expr1 expr3) (times expr2 expr4))) simplify (times (plus expr1 expr3) zero) = zero simplify (times (plus expr1 expr3) (succ expr2)) = simplePlus (simplify (plus expr1 expr3)) (simplify (times (plus expr1 expr3) expr2)) simplify (times (plus expr1 expr3) (const x)) = times (const x) (simplify (plus expr1 expr3)) simplify (times (plus expr1 expr3) (plus expr2 expr4)) = simplePlus (simplify (times expr1 expr2)) (simplePlus (simplify (times expr3 expr2)) (simplePlus (simplify (times expr1 expr4)) (simplify (times expr3 expr4)))) simplify (times (plus expr1 expr3) (times expr2 expr4)) = simplePlus (simplify (times expr1 (times expr2 expr4))) (simplify (times expr3 (times expr2 expr4))) simplify (times (times expr1 expr3) zero) = zero simplify (times (times expr1 expr3) (succ expr2)) = simplePlus (simplify (times expr1 expr3)) (simplify (times (times expr1 expr3) expr2)) simplify (times (times expr1 expr3) (plus expr2 expr4)) = simplePlus (simplify (times (times expr1 expr3) expr2)) (simplify (times (times expr1 expr3) expr4)) simplify (times (times expr1 expr3) (times expr2 expr4)) = times (simplify expr1) (simplify (times expr3 (times expr2 expr4))) simplify (times (times expr1 expr3) (const x)) = times (simplify (times expr1 expr3)) (const x) equalPlus : {a b c d : A} → (a ≡ c) → (b ≡ d) → (a + b) ≡ (c + d) equalPlus refl refl = refl equalTimes : {a b c d : A} → (a ≡ c) → (b ≡ d) → (a * b) ≡ (c * d) equalTimes refl refl = refl otherDist : {a b c : A} → (a * b) + (c * b) ≡ (a + c) * b otherDist = transitivity (equalPlus (comm _ _) (comm _ _)) (transitivity (equalityCommutative (+DistributesOver* _ _ _)) (comm _ _)) simplifyPreserves : (a : Expr) → eval (simplify a) ≡ eval a simplifyPreserves (const x) = refl simplifyPreserves zero = refl simplifyPreserves (succ a) = applyEquality (One +_) (simplifyPreserves a) simplifyPreserves (plus (const x) (const y)) = refl simplifyPreserves (plus (const x) zero) = equalityCommutative (sumZeroRight x) simplifyPreserves (plus (const x) (succ b)) = transitivity (transitivity (applyEquality (One +_) (transitivity (simplifyPreserves (plus (const x) b)) (commutative x (eval b)))) (+Associative One (eval b) x)) (commutative (One + eval b) x) simplifyPreserves (plus (const x) (plus b c)) = transitivity (simplePlusIsPlus (const x) (simplify (plus b c))) (applyEquality (x +_) (simplifyPreserves (plus b c))) simplifyPreserves (plus (const x) (times b c)) = transitivity (simplePlusIsPlus (const x) (simplify (times b c))) (applyEquality (x +_) (simplifyPreserves (times b c))) simplifyPreserves (plus zero a) = transitivity (simplifyPreserves a) (equalityCommutative (sumZeroLeft (eval a))) simplifyPreserves (plus (succ a) b) = transitivity (applyEquality (One +_) (simplifyPreserves (plus a b))) (+Associative One (eval a) (eval b)) simplifyPreserves (plus (plus a b) (const x)) = transitivity (simplePlusIsPlus (const x) (simplify (plus a b))) (transitivity (commutative x (eval (simplify (plus a b)))) (applyEquality (_+ x) (simplifyPreserves (plus a b)))) simplifyPreserves (plus (plus a b) zero) = transitivity (simplifyPreserves (plus a b)) (equalityCommutative (sumZeroRight _)) simplifyPreserves (plus (plus a b) (succ c)) = transitivity (applyEquality (One +_) (simplePlusIsPlus (simplify (plus a b)) (simplify c))) (transitivity (+Associative One _ _) (transitivity (applyEquality (_+ eval (simplify c)) (commutative One _)) (transitivity (equalityCommutative (+Associative _ _ _)) (transitivity (applyEquality (_+ (One + eval (simplify c))) (simplifyPreserves (plus a b))) (applyEquality (λ i → (eval a + eval b) + (One + i)) (simplifyPreserves c)))))) simplifyPreserves (plus (plus a b) (plus c d)) = transitivity (simplePlusIsPlus (simplify (plus a b)) (simplify (plus c d))) (transitivity (applyEquality (_+ eval (simplify (plus c d))) (simplifyPreserves (plus a b))) (applyEquality ((eval a + eval b) +_) (simplifyPreserves (plus c d)))) simplifyPreserves (plus (plus a b) (times c d)) = transitivity (simplePlusIsPlus (simplify (plus a b)) (simplify (times c d))) (transitivity (applyEquality (_+ eval (simplify (times c d))) (simplifyPreserves (plus a b))) (applyEquality ((eval a + eval b) +_) (simplifyPreserves (times c d)))) simplifyPreserves (plus (times a b) (const x)) = transitivity (simplePlusIsPlus (const x) (simplify (times a b))) (transitivity (commutative x _) (applyEquality (_+ x) (simplifyPreserves (times a b)))) simplifyPreserves (plus (times a b) zero) = transitivity (transitivity (applyEquality (_* eval (simplify b)) (simplifyPreserves a)) (applyEquality ((eval a) *_) (simplifyPreserves b))) (equalityCommutative (sumZeroRight _)) simplifyPreserves (plus (times a b) (succ c)) = transitivity (transitivity (applyEquality (One +_) (transitivity (simplePlusIsPlus (simplify (times a b)) (simplify c)) (transitivity (transitivity (applyEquality (eval (simplify (times a b)) +_) (simplifyPreserves c)) (applyEquality (_+ eval c) (simplifyPreserves (times a b)))) (commutative _ (eval c))))) (+Associative One (eval c) _)) (commutative _ (eval a * eval b)) simplifyPreserves (plus (times a b) (plus c d)) = transitivity (simplePlusIsPlus (simplify (times a b)) (simplify (plus c d))) (transitivity (applyEquality (_+ eval (simplify (plus c d))) (simplifyPreserves (times a b))) (applyEquality ((eval a * eval b) +_) (simplifyPreserves (plus c d)))) simplifyPreserves (plus (times a b) (times c d)) = transitivity (simplePlusIsPlus (simplify (times a b)) (simplify (times c d))) (transitivity (applyEquality (_+ eval (simplify (times c d))) (simplifyPreserves (times a b))) (applyEquality ((eval a * eval b) +_) (simplifyPreserves (times c d)))) simplifyPreserves (times (const x) (const y)) = refl simplifyPreserves (times (const x) zero) = equalityCommutative (productZeroRight x) simplifyPreserves (times (const x) (succ (const y))) = transitivity (applyEquality (_+ (x * y)) (equalityCommutative (productOneRight _))) (equalityCommutative (+DistributesOver* x One y)) simplifyPreserves (times (const x) (succ zero)) = equalityCommutative (transitivity (applyEquality (x *_) (sumZeroRight One)) (productOneRight x)) simplifyPreserves (times (const x) (succ (succ b))) = transitivity (simplePlusIsPlus (const x) (simplify (times (const x) (succ b)))) (transitivity (equalPlus (equalityCommutative (productOneRight _)) (simplifyPreserves (times (const x) (succ b)))) (equalityCommutative (+DistributesOver* x One _))) simplifyPreserves (times (const x) (succ (plus b c))) = transitivity (simplePlusIsPlus (const x) (simplePlus (simplify (times (const x) b)) (simplify (times (const x) c)))) (transitivity (equalPlus (equalityCommutative (productOneRight _)) (transitivity (simplePlusIsPlus (simplify (times (const x) b)) (simplify (times (const x) c))) (transitivity (equalPlus (simplifyPreserves (times (const x) b)) (simplifyPreserves (times (const x) c))) (equalityCommutative (+DistributesOver* x (eval b) (eval c)))))) (equalityCommutative (+DistributesOver* x One _))) simplifyPreserves (times (const x) (succ (times b c))) = transitivity (equalPlus (equalityCommutative (productOneRight x)) (applyEquality (x *_) (simplifyPreserves (times b c)))) (equalityCommutative (+DistributesOver* x One _)) simplifyPreserves (times (const x) (plus b c)) = transitivity (simplePlusIsPlus (simplify (times (const x) b)) (simplify (times (const x) c))) (transitivity (transitivity (applyEquality (eval (simplify (times (const x) b)) +_) (simplifyPreserves (times (const x) c))) (applyEquality (_+ (x * eval c)) (simplifyPreserves (times (const x) b)))) (equalityCommutative (+DistributesOver* x (eval b) (eval c)))) simplifyPreserves (times (const x) (times b c)) = applyEquality (x *_) (simplifyPreserves (times b c)) simplifyPreserves (times zero b) = equalityCommutative (productZeroLeft (eval b)) simplifyPreserves (times (succ (const x)) (const y)) = transitivity (transitivity (equalPlus (equalityCommutative (productOneRight y)) (comm x y)) (equalityCommutative (+DistributesOver* y One x))) (comm y _) simplifyPreserves (times (succ (const x)) zero) = equalityCommutative (productZeroRight _) simplifyPreserves (times (succ (const x)) (succ (const y))) = transitivity (transitivity (transitivity (+Associative One x _) (applyEquality ((One + x) +_) (transitivity (equalPlus (equalityCommutative (productOneRight y)) (comm x y)) (equalityCommutative (+DistributesOver* y One x))))) (equalPlus (equalityCommutative (productOneRight (One + x))) (comm _ _))) (equalityCommutative (+DistributesOver* _ _ _)) simplifyPreserves (times (succ (const x)) (succ zero)) = equalityCommutative (transitivity (applyEquality ((One + x) *_) (sumZeroRight One)) (productOneRight _)) simplifyPreserves (times (succ (const x)) (succ (succ b))) = transitivity (applyEquality (One +_) (simplePlusIsPlus (const x) (simplePlus (succ (simplify b)) (simplify (times (const x) (succ b)))))) (transitivity (applyEquality (λ i → One + (x + i)) (simplePlusIsPlus (succ (simplify b)) (simplify (times (const x) (succ b))))) (transitivity (applyEquality (λ i → One + (x + ((One + i) + eval (simplify (times (const x) (succ b)))))) (simplifyPreserves b)) (transitivity (applyEquality (λ i → One + (x + ((One + eval b) + i))) (simplifyPreserves (times (const x) (succ b)))) (transitivity (transitivity (+Associative One x _) (equalPlus (equalityCommutative (productOneRight _)) (transitivity (transitivity (transitivity (applyEquality ((One + eval b) +_) (+DistributesOver* x One (eval b))) (transitivity (transitivity (equalityCommutative (+Associative One (eval b) _)) (transitivity (applyEquality (One +_) (transitivity (+Associative (eval b) _ _) (transitivity (equalPlus (transitivity (commutative _ _) (equalPlus (productOneRight x) (equalityCommutative (productOneRight _)))) (comm x _)) (equalityCommutative (+Associative x _ _))))) (+Associative One x _))) (applyEquality ((One + x) +_) (equalityCommutative (+DistributesOver* (eval b) One x))))) (equalPlus (equalityCommutative (productOneRight _)) (comm (eval b) _))) (equalityCommutative (+DistributesOver* (One + x) One _))))) (equalityCommutative (+DistributesOver* (One + x) One _)))))) simplifyPreserves (times (succ (const x)) (succ (plus b c))) = transitivity (transitivity (transitivity (applyEquality (One +_) (simplePlusIsPlus (const x) (simplePlus (simplify (plus b c)) (simplePlus (simplify (times (const x) b)) (simplify (times (const x) c)))))) (transitivity (+Associative One x _) (applyEquality ((One + x) +_) (transitivity (simplePlusIsPlus (simplify (plus b c)) (simplePlus (simplify (times (const x) b)) (simplify (times (const x) c)))) (transitivity (equalPlus (simplifyPreserves (plus b c)) (simplePlusIsPlus (simplify (times (const x) b)) (simplify (times (const x) c)))) (transitivity (transitivity (transitivity (transitivity (equalityCommutative (+Associative _ _ _ )) (transitivity (applyEquality (eval b +_) (transitivity (applyEquality (eval c +_) (equalPlus (simplifyPreserves (times (const x) b)) (simplifyPreserves (times (const x) c)))) (transitivity (+Associative (eval c) _ _) (transitivity (applyEquality (_+ (x * eval c)) (commutative _ _)) (equalityCommutative (+Associative _ _ _)))))) (+Associative _ _ _))) (equalPlus (equalPlus (equalityCommutative (productOneRight (eval b))) (comm _ _)) (equalPlus (equalityCommutative (productOneRight (eval c))) (comm x _)))) (equalPlus (equalityCommutative (+DistributesOver* (eval b) One x)) (equalityCommutative (+DistributesOver* (eval c) One x)))) (equalPlus (comm _ _) (comm _ _)))))))) (equalPlus (equalityCommutative (productOneRight _)) (equalityCommutative (+DistributesOver* (One + x) _ _)))) (equalityCommutative (+DistributesOver* (One + x) _ _)) simplifyPreserves (times (succ (const x)) (succ (times b c))) = transitivity (transitivity (applyEquality (One +_) (simplePlusIsPlus (const x) (simplePlus (simplify (times b c)) (times (const x) (simplify (times b c)))))) (transitivity (+Associative One x _) (equalPlus (equalityCommutative (productOneRight _)) (transitivity (simplePlusIsPlus (simplify (times b c)) (times (const x) (simplify (times b c)))) (transitivity (transitivity (equalPlus (transitivity (simplifyPreserves (times b c)) (equalityCommutative (productOneRight _))) (transitivity (comm _ _) (applyEquality (_* x) (simplifyPreserves (times b c))))) (equalityCommutative (+DistributesOver* _ One x))) (comm _ _)))))) (equalityCommutative (+DistributesOver* _ _ _)) simplifyPreserves (times (succ (const x)) (plus b c)) = transitivity (simplePlusIsPlus (simplify (plus b c)) (simplePlus (simplify (times (const x) b)) (simplify (times (const x) c)))) (transitivity (transitivity (equalPlus (transitivity (simplifyPreserves (plus b c)) (equalityCommutative (productOneRight _))) (transitivity (simplePlusIsPlus (simplify (times (const x) b)) (simplify (times (const x) c))) (transitivity (transitivity (equalPlus (simplifyPreserves (times (const x) b)) (simplifyPreserves (times (const x) c))) (equalityCommutative (+DistributesOver* x _ _))) (comm x _)))) (equalityCommutative (+DistributesOver* _ One x))) (comm _ _)) simplifyPreserves (times (succ (const x)) (times b c)) = transitivity (simplePlusIsPlus (simplify (times b c)) (times (const x) (simplify (times b c)))) (transitivity (transitivity (equalPlus (transitivity (simplifyPreserves (times b c)) (equalityCommutative (productOneRight _))) (transitivity (comm x _) (applyEquality (_* x) (simplifyPreserves (times b c))))) (equalityCommutative (+DistributesOver* _ One x))) (comm _ _)) simplifyPreserves (times (succ zero) b) = transitivity (simplifyPreserves b) (transitivity (equalityCommutative (productOneLeft (eval b))) (applyEquality (_* eval b) (equalityCommutative (sumZeroRight One)))) simplifyPreserves (times (succ (succ a)) b) = transitivity (simplePlusIsPlus (simplify b) (simplify (times (succ a) b))) (transitivity (equalPlus (simplifyPreserves b) (simplifyPreserves (times (succ a) b))) (transitivity (transitivity (equalPlus (equalityCommutative (productOneRight _)) (comm _ _)) (equalityCommutative (+DistributesOver* (eval b) One _))) (comm (eval b) _))) simplifyPreserves (times (succ (plus a b)) (const x)) = transitivity (comm x _) (applyEquality (λ i → (One + i) * x) (simplifyPreserves (plus a b))) simplifyPreserves (times (succ (plus a b)) zero) = equalityCommutative (productZeroRight _) simplifyPreserves (times (succ (plus a b)) (succ c)) = transitivity (transitivity (transitivity (applyEquality (One +_) (transitivity (simplePlusIsPlus (simplify (times a c)) (simplePlus (simplify (times b c)) (simplePlus c (simplify (plus a b))))) (transitivity (transitivity (equalPlus (simplifyPreserves (times a c)) (simplePlusIsPlus (simplify (times b c)) (simplePlus c (simplify (plus a b))))) (transitivity (+Associative _ _ _) (transitivity (transitivity (equalPlus (transitivity (equalPlus (comm _ _) (transitivity (simplifyPreserves (times b c)) (comm _ _))) (equalityCommutative (+DistributesOver* _ _ _))) (transitivity (simplePlusIsPlus c (simplify (plus a b))) (transitivity (commutative _ _) (equalPlus (simplifyPreserves (plus a b)) (equalityCommutative (productOneRight _)))))) (commutative _ _)) (equalityCommutative (+Associative _ _ _))))) (applyEquality ((eval a + eval b) +_) (equalityCommutative (+DistributesOver* _ One _)))))) (+Associative One _ _)) (equalPlus (equalityCommutative (productOneRight _)) (comm _ _))) (equalityCommutative (+DistributesOver* _ _ _)) simplifyPreserves (times (succ (plus a b)) (plus c d)) = equalTimes (applyEquality (One +_) (simplifyPreserves (plus a b))) (simplifyPreserves (plus c d)) simplifyPreserves (times (succ (plus a b)) (times c d)) = equalTimes (applyEquality (One +_) (simplifyPreserves (plus a b))) (simplifyPreserves (times c d)) simplifyPreserves (times (succ (times a b)) (const x)) = transitivity (comm x _) (applyEquality (λ i → (One + i) * x) (simplifyPreserves (times a b))) simplifyPreserves (times (succ (times a b)) zero) = equalityCommutative (productZeroRight _) simplifyPreserves (times (succ (times a b)) (succ c)) = transitivity (transitivity (transitivity (applyEquality (One +_) (transitivity (simplePlusIsPlus (simplify c) (plus (simplify (times a b)) (simplify (times (times a b) c)))) (transitivity (transitivity (transitivity (equalPlus (transitivity (simplifyPreserves c) (equalityCommutative (productOneRight _))) (transitivity (commutative _ _) (equalPlus (transitivity (simplifyPreserves (times (times a b) c)) (comm _ _)) (simplifyPreserves (times a b))))) (+Associative _ _ _)) (applyEquality (_+ (eval a * eval b)) (equalityCommutative (+DistributesOver* _ One _)))) (commutative _ _)))) (+Associative One _ _)) (equalPlus (equalityCommutative (productOneRight _)) (comm _ _))) (equalityCommutative (+DistributesOver* _ One _)) simplifyPreserves (times (succ (times a b)) (plus c d)) = transitivity (simplePlusIsPlus (simplify (plus c d)) (simplePlus (simplify (times (times a b) c)) (simplify (times (times a b) d)))) (transitivity (equalPlus (simplifyPreserves (plus c d)) (simplePlusIsPlus (simplify (times (times a b) c)) (simplify (times (times a b) d)))) (transitivity (transitivity (equalPlus (equalityCommutative (productOneRight _)) (transitivity (transitivity (equalPlus (simplifyPreserves (times (times a b) c)) (simplifyPreserves (times (times a b) d))) (equalityCommutative (+DistributesOver* _ _ _))) (comm _ _))) (equalityCommutative (+DistributesOver* _ One _))) (comm _ _))) simplifyPreserves (times (succ (times a b)) (times c d)) = transitivity (simplePlusIsPlus (simplify (times c d)) (times (simplify a) (simplify (times b (times c d))))) (transitivity (equalPlus (simplifyPreserves (times c d)) (equalTimes (simplifyPreserves a) (simplifyPreserves (times b (times c d))))) (transitivity (transitivity (equalPlus (equalityCommutative (productOneRight _)) (transitivity (*Associative (eval a) _ _) (comm _ _))) (equalityCommutative (+DistributesOver* _ One _))) (comm _ _))) simplifyPreserves (times (plus a b) (const x)) = transitivity (comm x _) (applyEquality (_* x) (simplifyPreserves (plus a b))) simplifyPreserves (times (plus a b) zero) = equalityCommutative (productZeroRight _) simplifyPreserves (times (plus a b) (succ c)) = transitivity (simplePlusIsPlus (simplify (plus a b)) (simplify (times (plus a b) c))) (transitivity (applyEquality ((eval (simplify (plus a b))) +_) (simplifyPreserves (times (plus a b) c))) (transitivity (applyEquality (_+ ((eval a + eval b) * eval c)) (simplifyPreserves (plus a b))) (transitivity (equalPlus (equalityCommutative (productOneRight _)) refl) (equalityCommutative (+DistributesOver* _ One (eval c)))))) simplifyPreserves (times (plus a b) (plus c d)) = transitivity (simplePlusIsPlus (simplify (times a c)) (simplePlus (simplify (times b c)) (simplePlus (simplify (times a d)) (simplify (times b d))))) (transitivity (transitivity (transitivity (transitivity (equalPlus (transitivity (simplifyPreserves (times a c)) (comm _ _)) (transitivity (simplePlusIsPlus (simplify (times b c)) (simplePlus (simplify (times a d)) (simplify (times b d)))) (equalPlus (transitivity (simplifyPreserves (times b c)) (comm _ _)) (transitivity (simplePlusIsPlus (simplify (times a d)) (simplify (times b d))) (equalPlus (transitivity (simplifyPreserves (times a d)) (comm _ _)) (transitivity (simplifyPreserves (times b d)) (comm _ _))))))) (+Associative _ _ _)) (equalPlus (equalityCommutative (+DistributesOver* (eval c) (eval a) _)) (equalityCommutative (+DistributesOver* (eval d) (eval a) _)))) (equalPlus (comm (eval c) _) (comm (eval d) _))) (equalityCommutative (+DistributesOver* _ (eval c) (eval d)))) simplifyPreserves (times (plus a b) (times c d)) = transitivity (simplePlusIsPlus (simplify (times a (times c d))) (simplify (times b (times c d)))) (transitivity (equalPlus (simplifyPreserves (times a (times c d))) (simplifyPreserves (times b (times c d)))) (transitivity (equalPlus (comm (eval a) _) (comm (eval b) _)) (transitivity (equalityCommutative (+DistributesOver* _ (eval a) (eval b))) (comm _ _)))) simplifyPreserves (times (times a b) (const x)) = applyEquality (_* x) (simplifyPreserves (times a b)) simplifyPreserves (times (times a b) zero) = equalityCommutative (productZeroRight _) simplifyPreserves (times (times a b) (succ c)) = transitivity (simplePlusIsPlus (simplify (times a b)) (simplify (times (times a b) c))) (transitivity (equalPlus (simplifyPreserves (times a b)) (simplifyPreserves (times (times a b) c))) (transitivity (applyEquality (_+ ((eval a * eval b) * eval c)) (equalityCommutative (productOneRight _))) (equalityCommutative (+DistributesOver* _ One (eval c))))) simplifyPreserves (times (times a b) (plus c d)) = transitivity (simplePlusIsPlus (simplify (times (times a b) c)) (simplify (times (times a b) d))) (transitivity (equalPlus (simplifyPreserves (times (times a b) c)) (simplifyPreserves (times (times a b) d))) (equalityCommutative (+DistributesOver* _ _ _))) simplifyPreserves (times (times a b) (times c d)) = transitivity (equalTimes (simplifyPreserves a) (simplifyPreserves (times b (times c d)))) (*Associative (eval a) (eval b) _) from_to_by_ : (x y : Expr) (pr : eval (simplify x) ≡ eval (simplify y)) → eval x ≡ eval y from a to b by pr = transitivity (equalityCommutative (simplifyPreserves a)) (transitivity pr (simplifyPreserves b))
{ "alphanum_fraction": 0.7157773005, "avg_line_length": 138.196347032, "ext": "agda", "hexsha": "f244c3a4c8e40f78a12ff55ba9105479c0d28b5f", "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": "Semirings/Solver.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": "Semirings/Solver.agda", "max_line_length": 1546, "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": "Semirings/Solver.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": 9376, "size": 30265 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Homogeneously-indexed binary relations ------------------------------------------------------------------------ -- This file contains some core definitions which are reexported by -- Relation.Binary.Indexed.Homogeneous {-# OPTIONS --without-K --safe #-} module Relation.Binary.Indexed.Homogeneous.Core where open import Level using (Level; _⊔_) open import Data.Product using (_×_) open import Relation.Binary as B using (REL; Rel) open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl) import Relation.Binary.Indexed.Heterogeneous as I open import Relation.Unary.Indexed using (IPred) ------------------------------------------------------------------------ -- Homegeneously indexed binary relations -- Heterogeneous types IREL : ∀ {i a b} {I : Set i} → (I → Set a) → (I → Set b) → (ℓ : Level) → Set _ IREL A B ℓ = ∀ {i} → REL (A i) (B i) ℓ -- Homogeneous types IRel : ∀ {i a} {I : Set i} → (I → Set a) → (ℓ : Level) → Set _ IRel A = IREL A A ------------------------------------------------------------------------ -- Simple properties module _ {i a} {I : Set i} (A : I → Set a) where syntax Implies A _∼₁_ _∼₂_ = _∼₁_ ⇒[ A ] _∼₂_ Implies : ∀ {ℓ₁ ℓ₂} → IRel A ℓ₁ → IRel A ℓ₂ → Set _ Implies _∼₁_ _∼₂_ = ∀ {i} → _∼₁_ B.⇒ (_∼₂_ {i}) Reflexive : ∀ {ℓ} → IRel A ℓ → Set _ Reflexive _∼_ = ∀ {i} → B.Reflexive (_∼_ {i}) Symmetric : ∀ {ℓ} → IRel A ℓ → Set _ Symmetric _∼_ = ∀ {i} → B.Symmetric (_∼_ {i}) Transitive : ∀ {ℓ} → IRel A ℓ → Set _ Transitive _∼_ = ∀ {i} → B.Transitive (_∼_ {i}) Antisymmetric : ∀ {ℓ₁ ℓ₂} → IRel A ℓ₁ → IRel A ℓ₂ → Set _ Antisymmetric _≈_ _∼_ = ∀ {i} → B.Antisymmetric _≈_ (_∼_ {i}) Decidable : ∀ {ℓ} → IRel A ℓ → Set _ Decidable _∼_ = ∀ {i} → B.Decidable (_∼_ {i}) Respects : ∀ {ℓ₁ ℓ₂} → IPred A ℓ₁ → IRel A ℓ₂ → Set _ Respects P _∼_ = ∀ {i} {x y : A i} → x ∼ y → P x → P y Respectsˡ : ∀ {ℓ₁ ℓ₂} → IRel A ℓ₁ → IRel A ℓ₂ → Set _ Respectsˡ P _∼_ = ∀ {i} {x y z : A i} → x ∼ y → P x z → P y z Respectsʳ : ∀ {ℓ₁ ℓ₂} → IRel A ℓ₁ → IRel A ℓ₂ → Set _ Respectsʳ P _∼_ = ∀ {i} {x y z : A i} → x ∼ y → P z x → P z y Respects₂ : ∀ {ℓ₁ ℓ₂} → IRel A ℓ₁ → IRel A ℓ₂ → Set _ Respects₂ P _∼_ = (Respectsʳ P _∼_) × (Respectsˡ P _∼_) ------------------------------------------------------------------------ -- Conversion between homogeneous and heterogeneously indexed relations module _ {i a b} {I : Set i} {A : I → Set a} {B : I → Set b} where OverPath : ∀ {ℓ} → IREL A B ℓ → ∀ {i j} → i ≡ j → REL (A i) (B j) ℓ OverPath _∼_ refl = _∼_ toHetIndexed : ∀ {ℓ} → IREL A B ℓ → I.IREL A B (i ⊔ ℓ) toHetIndexed _∼_ {i} {j} x y = (p : i ≡ j) → OverPath _∼_ p x y fromHetIndexed : ∀ {ℓ} → I.IREL A B ℓ → IREL A B ℓ fromHetIndexed _∼_ = _∼_ ------------------------------------------------------------------------ -- Lifting to non-indexed binary relations module _ {i a} {I : Set i} (A : I → Set a) where Lift : ∀ {ℓ} → IRel A ℓ → Rel (∀ i → A i) _ Lift _∼_ x y = ∀ i → x i ∼ y i
{ "alphanum_fraction": 0.5001616554, "avg_line_length": 33.6195652174, "ext": "agda", "hexsha": "7a2f91e1f09eca553985bc545a6e58dae953de6a", "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": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Indexed/Homogeneous/Core.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Indexed/Homogeneous/Core.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Indexed/Homogeneous/Core.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1156, "size": 3093 }
{-# OPTIONS --allow-unsolved-metas #-} open import Oscar.Class open import Oscar.Class.Hmap open import Oscar.Class.Leftunit open import Oscar.Class.Reflexivity open import Oscar.Class.Smap open import Oscar.Class.Symmetry open import Oscar.Class.Transextensionality open import Oscar.Class.Transitivity open import Oscar.Class.Transleftidentity open import Oscar.Data.Substitunction open import Oscar.Data.Term open import Oscar.Prelude module Test.ProblemWithDerivation-4 where postulate A : Set B : Set _~A~_ : A → A → Set _~B~_ : B → B → Set s1 : A → B f1 : ∀ {x y} → x ~A~ y → s1 x ~B~ s1 y instance 𝓢urjectivity1 : Smap.class _~A~_ _~B~_ s1 s1 𝓢urjectivity1 .⋆ _ _ = f1 -- Oscar.Class.Hmap.Transleftidentity instance -HmapFromTransleftidentitySymmetry : ∀ {𝔵} {𝔛 : Ø 𝔵} {𝔞} {𝔄 : 𝔛 → Ø 𝔞} {𝔟} {𝔅 : 𝔛 → Ø 𝔟} (let _∼_ = Arrow 𝔄 𝔅) {ℓ̇} {_∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ̇} {transitivity : Transitivity.type _∼_} {reflexivity : Reflexivity.type _∼_} {ℓ} ⦃ _ : Transleftidentity.class _∼_ _∼̇_ reflexivity transitivity ⦄ ⦃ _ : ∀ {x y} → Symmetry.class (_∼̇_ {x} {y}) ⦄ → ∀ {m n} → Hmap.class (λ (f : m ∼ n) (P : LeftExtensionṖroperty ℓ _∼_ _∼̇_ m) → π₀ (π₀ P) f) (λ f P → π₀ (π₀ P) (transitivity f reflexivity)) -HmapFromTransleftidentitySymmetry .⋆ _ (_ , P₁) = P₁ $ symmetry transleftidentity test-before : ∀ {x y} → x ~A~ y → s1 x ~B~ s1 y test-before = smap postulate XX : Set BB : XX → Set CC : XX → Set EQ : ∀ {x y} → Arrow BB BB x y → Arrow BB BB x y → Set instance postulate -transleftidentity : Transleftidentity.class (Arrow BB BB) EQ magic magic -symmetry : ∀ {x y} → Symmetry.class (EQ {x} {y}) test-after : ∀ {x y} → x ~A~ y → s1 x ~B~ s1 y test-after = smap -- FIXME this was yellow when we used Symmetry instead of Sym. why?
{ "alphanum_fraction": 0.6325981711, "avg_line_length": 28.1666666667, "ext": "agda", "hexsha": "e0a538aef859383dc0f8ba8ba8ff27641c2ec2b7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Test/ProblemWithDerivation-4.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Test/ProblemWithDerivation-4.agda", "max_line_length": 88, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Test/ProblemWithDerivation-4.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 721, "size": 1859 }
open import FRP.JS.Nat using ( ℕ ; suc ; _+_ ; _≟_ ) open import FRP.JS.RSet open import FRP.JS.Time using ( Time ; epoch ) open import FRP.JS.Delay using ( _ms ) open import FRP.JS.Behaviour open import FRP.JS.Event using ( ∅ ) open import FRP.JS.Bool using ( Bool ; not ; true ) open import FRP.JS.QUnit using ( TestSuite ; ok◇ ; test ; _,_ ; ε ) module FRP.JS.Test.Behaviour where infixr 2 _≟*_ _≟*_ : ⟦ Beh ⟨ ℕ ⟩ ⇒ Beh ⟨ ℕ ⟩ ⇒ Beh ⟨ Bool ⟩ ⟧ _≟*_ = map2 _≟_ tests : TestSuite tests = ( test "≟*" ( ok◇ "[ 1 ] ≟* [ 1 ]" ([ 1 ] ≟* [ 1 ]) , ok◇ "[ 1 ] ≟* [ 0 ]" (not* ([ 1 ] ≟* [ 0 ])) , ok◇ "[ 0 ] ≟* [ 1 ]" (not* ([ 0 ] ≟* [ 1 ])) ) , test "map" ( ok◇ "map suc [ 0 ] ≟* [ 1 ]" (map suc [ 0 ] ≟* [ 1 ]) , ok◇ "map suc [ 1 ] ≟* [ 1 ]" (not* (map suc [ 1 ] ≟* [ 1 ])) ) , test "join" ( ok◇ "join (map [ suc ] [ 0 ] ) ≟* [ 1 ]" (join (map (λ n → [ suc n ]) [ 0 ]) ≟* [ 1 ]) , ok◇ "join (map [ suc ] [ 1 ]) ≟* [ 1 ]" (not* (join (map (λ n → [ suc n ]) [ 1 ]) ≟* [ 1 ])) ) , test "hold" ( ok◇ "hold 1 ∅ ≟* [ 1 ]" (hold 1 ∅ ≟* [ 1 ]) , ok◇ "hold 0 ∅ ≟* [ 1 ]" (not* (hold 0 ∅ ≟* [ 1 ])) ) )
{ "alphanum_fraction": 0.4422907489, "avg_line_length": 35.46875, "ext": "agda", "hexsha": "01c56fd06d27ece1492f1862e68c58b11c8d76cc", "lang": "Agda", "max_forks_count": 7, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z", "max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z", "max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_forks_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_forks_repo_name": "agda/agda-frp-js", "max_forks_repo_path": "test/agda/FRP/JS/Test/Behaviour.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_issues_repo_name": "agda/agda-frp-js", "max_issues_repo_path": "test/agda/FRP/JS/Test/Behaviour.agda", "max_line_length": 100, "max_stars_count": 63, "max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_stars_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_stars_repo_name": "agda/agda-frp-js", "max_stars_repo_path": "test/agda/FRP/JS/Test/Behaviour.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z", "num_tokens": 545, "size": 1135 }
-- Andreas, 2016-07-17 issue 2101 -- It should be possible to place a single function with a where block -- inside `abstract`. -- This will work if type signatures inside a where-block -- are considered private, since in private type signatures, -- abstract definitions are transparent. -- (Unlike in public type signatures.) record Wrap (A : Set) : Set where field unwrap : A postulate P : ∀{A : Set} → A → Set module AbstractPrivate (A : Set) where abstract B : Set B = Wrap A postulate b : B private -- this makes abstract defs transparent in type signatures postulate test : P (Wrap.unwrap b) -- should succeed abstract unnamedWhere : (A : Set) → Set unnamedWhere A = A where -- the following definitions are private! B : Set B = Wrap A postulate b : B test : P (Wrap.unwrap b) -- should succeed namedWherePrivate : (A : Set) → Set namedWherePrivate A = A module MP where B : Set B = Wrap A private postulate b : B test : P (Wrap.unwrap b) -- should succeed namedWhere : (A : Set) → Set namedWhere A = A module M where -- the definitions in this module are not private! B : Set B = Wrap A postulate b : B test : P (Wrap.unwrap b) -- should fail! access = M.b -- should be in scope outside : ∀ {A} → M.B A → A outside = Wrap.unwrap -- should fail and does so --
{ "alphanum_fraction": 0.6209059233, "avg_line_length": 20.7971014493, "ext": "agda", "hexsha": "1cb0bbbb20fa027665048e9436f70e0c00f77c4a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-09-15T14:36:15.000Z", "max_forks_repo_forks_event_min_datetime": "2015-09-15T14:36:15.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/Issue2101.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/Issue2101.agda", "max_line_length": 70, "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/Issue2101.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": 398, "size": 1435 }
-- WARNING: This file was generated automatically by Vehicle -- and should not be modified manually! -- Metadata -- - Agda version: 2.6.2 -- - AISEC version: 0.1.0.1 -- - Time generated: ??? {-# OPTIONS --allow-exec #-} open import Vehicle open import Data.Unit open import Data.Empty open import Data.Product open import Data.Nat as ℕ using (ℕ) open import Data.Fin as Fin using (Fin; #_) open import Data.List open import Data.List.Relation.Unary.All as List open import Relation.Binary.PropositionalEquality module simple-let-temp-output where abstract e1 : let x = ⊤ in let y = ⊥ in x × y e1 = checkSpecification record { proofCache = "/home/matthew/Code/AISEC/vehicle/proofcache.vclp" } abstract e2 : let y = # 1 in y Fin.≥ # 2 e2 = checkSpecification record { proofCache = "/home/matthew/Code/AISEC/vehicle/proofcache.vclp" } e3 : ℕ e3 = let y = 1 ℕ.+ 1 in y lamLet : ℕ → ℕ lamLet x = let y = x in y abstract forallLet : ∀ (x : Fin 2) → let y = x in y ≡ # 1 forallLet = checkSpecification record { proofCache = "/home/matthew/Code/AISEC/vehicle/proofcache.vclp" } abstract letForall : let y = # 1 in ∀ (x : Fin 2) → y ≡ x letForall = checkSpecification record { proofCache = "/home/matthew/Code/AISEC/vehicle/proofcache.vclp" } abstract forallInLet : List.All (λ (x : Fin 2) → let y = x in y ≡ # 1) (# 1 ∷ []) forallInLet = checkSpecification record { proofCache = "/home/matthew/Code/AISEC/vehicle/proofcache.vclp" } abstract letForallIn : let y = # 1 in List.All (λ (x : Fin 2) → y ≡ x) (# 1 ∷ []) letForallIn = checkSpecification record { proofCache = "/home/matthew/Code/AISEC/vehicle/proofcache.vclp" }
{ "alphanum_fraction": 0.6633547633, "avg_line_length": 27.5967741935, "ext": "agda", "hexsha": "b125ce091413355ffd5471f19f2db3ff5ad0e5c2", "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": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "vehicle-lang/vehicle", "max_forks_repo_path": "test/Test/Compile/Golden/simple-let/simple-let-output.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_issues_repo_issues_event_max_datetime": "2022-03-31T20:49:39.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-07T14:09:13.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "vehicle-lang/vehicle", "max_issues_repo_path": "test/Test/Compile/Golden/simple-let/simple-let-output.agda", "max_line_length": 74, "max_stars_count": 9, "max_stars_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "vehicle-lang/vehicle", "max_stars_repo_path": "test/Test/Compile/Golden/simple-let/simple-let-output.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-17T18:51:05.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-10T12:56:42.000Z", "num_tokens": 565, "size": 1711 }
module Test where open import Data.List open import Data.List.Instance open import Data.Nat open import Category.FAM f : List ℕ → List ℕ f = fmap suc
{ "alphanum_fraction": 0.7631578947, "avg_line_length": 15.2, "ext": "agda", "hexsha": "2567388fa8fdedff1db6210c5ac623601c01d251", "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": "e5e562e4cde2face1f3f5b6d0486c8c56a47b435", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/FAM", "max_forks_repo_path": "test/Test.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e5e562e4cde2face1f3f5b6d0486c8c56a47b435", "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/FAM", "max_issues_repo_path": "test/Test.agda", "max_line_length": 30, "max_stars_count": null, "max_stars_repo_head_hexsha": "e5e562e4cde2face1f3f5b6d0486c8c56a47b435", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/FAM", "max_stars_repo_path": "test/Test.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 40, "size": 152 }
------------------------------------------------------------------------ -- Simple queues, implemented in the usual way using two lists -- (following Hood and Melville) ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality module Queue.Simple {c⁺} (eq : ∀ {a p} → Equality-with-J a p c⁺) where open Derived-definitions-and-properties eq open import Prelude open import Bijection eq using (_↔_) open import Equality.Decision-procedures eq open import List eq as L hiding (map) open import Surjection eq using (_↠_) private variable a : Level A B : Type a x : A f : A → B xs ys : List A ------------------------------------------------------------------------ -- Invariant -- The queue invariant: if the first list is empty, then the second -- list is empty. Invariant : {A : Type a} → List A → List A → Type a Invariant (_ ∷ _) _ = ↑ _ ⊤ Invariant [] [] = ↑ _ ⊤ Invariant [] (_ ∷ _) = ⊥ -- The invariant is propositional. Invariant-propositional : Is-proposition (Invariant xs ys) Invariant-propositional {xs = []} {ys = []} _ _ = refl _ Invariant-propositional {xs = _ ∷ _} _ _ = refl _ -- Some lemmas related to the invariant. -[] : Invariant xs [] -[] {xs = []} = _ -[] {xs = _ ∷ _} = _ map-map : Invariant xs ys → Invariant (L.map f xs) (L.map f ys) map-map {xs = _ ∷ _} _ = _ map-map {xs = []} {ys = []} _ = _ ------------------------------------------------------------------------ -- Queues -- Queues. -- -- Note that the invariant is erased. record Queue (A : Type a) : Type a where constructor ⟨_,_⟩ field front rear : List A @0 {invariant} : Invariant front rear open Queue public -- A variant of ⟨_,_⟩ with three explicit arguments. pattern ⟨_,_⟩[_] f r i = record { front = f ; rear = r ; invariant = i } ------------------------------------------------------------------------ -- Conversion functions -- Converts queues to lists. to-List : Queue A → List A to-List q = front q ++ reverse (rear q) -- Converts lists to queues. from-List : List A → Queue A from-List xs = ⟨ xs , [] ⟩[ -[] ] -- The function from-List is a right inverse of to-List. to-List-from-List : to-List (from-List xs) ≡ xs to-List-from-List {xs = xs} = xs ++ [] ≡⟨ ++-right-identity _ ⟩∎ xs ∎ -- If the carrier type is inhabited, then the function from-List is -- not, in general, a left inverse of to-List. ¬-from-List-to-List : A → ¬ ((q : Queue A) → from-List (to-List q) ≡ q) ¬-from-List-to-List {A = A} x hyp = not-equal equal where counter-example : Queue A counter-example = ⟨ x ∷ [] , x ∷ [] ⟩ not-equal : from-List (to-List counter-example) ≢ counter-example not-equal eq = List.[]≢∷ (cong rear eq) equal : from-List (to-List counter-example) ≡ counter-example equal = hyp counter-example ------------------------------------------------------------------------ -- The representation is not unique -- If the carrier type is inhabited, then two queues representing the -- same list are not necessarily equal. representation-not-unique : A → ¬ ({q₁ q₂ : Queue A} → to-List q₁ ≡ to-List q₂ → q₁ ≡ q₂) representation-not-unique x hyp = ¬-from-List-to-List x λ q → hyp ( to-List (from-List (to-List q)) ≡⟨ to-List-from-List ⟩∎ to-List q ∎) -- If the carrier type is inhabited, then the type -- ∃ λ (q : Queue A) → to-List q ≡ xs is not, in general, a -- proposition. ¬-Σ-Queue-propositional : A → ¬ ({xs : List A} → Is-proposition (∃ λ (q : Queue A) → to-List q ≡ xs)) ¬-Σ-Queue-propositional x hyp = representation-not-unique x λ {q₁ q₂} eq → cong proj₁ ( q₁ , eq ≡⟨ hyp _ _ ⟩∎ q₂ , refl _ ∎) ------------------------------------------------------------------------ -- Queue operations -- Enqueues an element. enqueue : A → Queue A → Queue A enqueue x ⟨ [] , rear ⟩ = ⟨ x ∷ [] , rear ⟩ enqueue x ⟨ front@(_ ∷ _) , rear ⟩ = ⟨ front , x ∷ rear ⟩ to-List-enqueue : ∀ q → to-List (enqueue x q) ≡ to-List q ++ x ∷ [] to-List-enqueue ⟨ [] , [] ⟩ = refl _ to-List-enqueue {x = x} ⟨ front@(_ ∷ _) , rear ⟩ = front ++ reverse (x ∷ rear) ≡⟨ cong (front ++_) $ reverse-∷ rear ⟩ front ++ reverse rear ++ x ∷ [] ≡⟨ ++-associative front _ _ ⟩∎ (front ++ reverse rear) ++ x ∷ [] ∎ -- Dequeues an element, if possible. dequeue : Queue A → Maybe (A × Queue A) dequeue ⟨ [] , [] ⟩ = nothing dequeue ⟨ x ∷ [] , rear ⟩ = just (x , ⟨ reverse rear , [] ⟩[ -[] ]) dequeue ⟨ x ∷ front@(_ ∷ _) , rear ⟩ = just (x , ⟨ front , rear ⟩) to-List-dequeue : {A : Type a} (q : Queue A) → ⊎-map id (Σ-map id to-List) (dequeue q) ≡ _↔_.to List↔Maybe[×List] (to-List q) to-List-dequeue ⟨ [] , [] ⟩ = refl _ to-List-dequeue ⟨ x ∷ [] , rear ⟩ = cong (just ∘ (x ,_)) ( reverse rear ++ [] ≡⟨ ++-right-identity _ ⟩∎ reverse rear ∎) to-List-dequeue ⟨ _ ∷ _ ∷ _ , _ ⟩ = refl _ -- The "inverse" of the dequeue operation. dequeue⁻¹ : Maybe (A × Queue A) → Queue A dequeue⁻¹ nothing = ⟨ [] , [] ⟩ dequeue⁻¹ (just (x , ⟨ front , rear ⟩)) = ⟨ x ∷ front , rear ⟩ to-List-dequeue⁻¹ : (x : Maybe (A × Queue A)) → to-List (dequeue⁻¹ x) ≡ _↔_.from List↔Maybe[×List] (⊎-map id (Σ-map id to-List) x) to-List-dequeue⁻¹ nothing = refl _ to-List-dequeue⁻¹ (just _) = refl _ -- A map function. map : (A → B) → Queue A → Queue B map f ⟨ front , rear ⟩[ inv ] = ⟨ L.map f front , L.map f rear ⟩[ map-map inv ] to-List-map : ∀ q → to-List (map f q) ≡ L.map f (to-List q) to-List-map {f = f} ⟨ front , rear ⟩ = L.map f front ++ reverse (L.map f rear) ≡⟨ cong (L.map f front ++_) $ sym $ map-reverse rear ⟩ L.map f front ++ L.map f (reverse rear) ≡⟨ sym $ map-++ _ front _ ⟩∎ L.map f (front ++ reverse rear) ∎
{ "alphanum_fraction": 0.5224738087, "avg_line_length": 28.8682926829, "ext": "agda", "hexsha": "8f188a903e658617fcb5290dfdd81b6c266d2ca3", "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/Queue/Simple.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/Queue/Simple.agda", "max_line_length": 97, "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/Queue/Simple.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": 1889, "size": 5918 }
{-# OPTIONS --cubical --safe #-} module Algebra.Construct.Free.Semilattice.Relation.Unary.All.Map where open import Prelude hiding (⊥; ⊤) open import Algebra.Construct.Free.Semilattice.Eliminators open import Algebra.Construct.Free.Semilattice.Definition open import Cubical.Foundations.HLevels open import Data.Empty.UniversePolymorphic open import HITs.PropositionalTruncation.Sugar open import HITs.PropositionalTruncation.Properties open import HITs.PropositionalTruncation open import Data.Unit.UniversePolymorphic open import Algebra.Construct.Free.Semilattice.Relation.Unary.All.Def private variable p : Level map-◻ : ∀ {p} {P : A → Type p} → (∀ x → P x) → ∀ xs → ◻ P xs map-◻ {A = A} {P = P} = λ f → ∥ map-◻′ f ∥⇓ where map-◻′ : (∀ x → P x) → xs ∈𝒦 A ⇒∥ ◻ P xs ∥ ∥ map-◻′ f ∥-prop {xs} = isProp-◻ {P = P} {xs = xs} ∥ map-◻′ f ∥[] = tt ∥ map-◻′ f ∥ x ∷ xs ⟨ Pxs ⟩ = ∣ f x ∣ , Pxs
{ "alphanum_fraction": 0.6810631229, "avg_line_length": 34.7307692308, "ext": "agda", "hexsha": "a61d783d09c8f052ad62640e267ab6f1d4657dda", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Algebra/Construct/Free/Semilattice/Relation/Unary/All/Map.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Algebra/Construct/Free/Semilattice/Relation/Unary/All/Map.agda", "max_line_length": 70, "max_stars_count": 6, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Algebra/Construct/Free/Semilattice/Relation/Unary/All/Map.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": 335, "size": 903 }
module LC.Reasoning where open import LC.Base open import LC.Reduction open import Relation.Binary.Construct.Closure.ReflexiveTransitive open import Relation.Binary.Construct.Closure.ReflexiveTransitive.Properties using (preorder) open import Relation.Binary.Reasoning.Preorder (preorder _β→_) open import Relation.Binary.Reasoning.Preorder (preorder _β→_) using (begin_; step-≡; _∎; _≡⟨⟩_) public infixr 2 _→*⟨_⟩_ _→*⟨_⟩_ : ∀ (x : Term) {y z} → x β→* y → y IsRelatedTo z → x IsRelatedTo z x →*⟨ P ⟩ y = x ∼⟨ P ⟩ y infixr 2 _→⟨_⟩_ _→⟨_⟩_ : ∀ (x : Term) {y z} → x β→ y → y IsRelatedTo z → x IsRelatedTo z x →⟨ P ⟩ y = x ∼⟨ return P ⟩ y infixr 2 _→⟨⟩_ _→⟨⟩_ : ∀ (x : Term) {y} → x IsRelatedTo y → x IsRelatedTo y x →⟨⟩ y = x ∼⟨ ε ⟩ y
{ "alphanum_fraction": 0.6657645467, "avg_line_length": 33.5909090909, "ext": "agda", "hexsha": "b9a8c0b077a06750dabaac850cde34d4a99059a8", "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": "0c9a6e79c23192b28ddb07315b200a94ee900ca6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/bidirectional", "max_forks_repo_path": "LC/Reasoning.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6", "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/bidirectional", "max_issues_repo_path": "LC/Reasoning.agda", "max_line_length": 103, "max_stars_count": 2, "max_stars_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/bidirectional", "max_stars_repo_path": "LC/Reasoning.agda", "max_stars_repo_stars_event_max_datetime": "2020-08-25T14:05:01.000Z", "max_stars_repo_stars_event_min_datetime": "2020-08-25T07:34:40.000Z", "num_tokens": 300, "size": 739 }
------------------------------------------------------------------------ -- INCREMENTAL λ-CALCULUS -- -- Machine-checked formalization of the theoretical results presented -- in the paper: -- -- Yufei Cai, Paolo G. Giarrusso, Tillmann Rendel, Klaus Ostermann. -- A Theory of Changes for Higher-Order Languages: -- Incrementalizing λ-Calculi by Static Differentiation. -- To appear at PLDI, ACM 2014. -- -- We claim that this formalization -- -- (1) proves every lemma and theorem in Sec. 2 and 3 of the paper, -- (2) formally specifies the interface between our incrementalization -- framework and potential plugins, and -- (3) shows that the plugin interface can be instantiated. -- -- The first claim is the main reason for a machine-checked -- proof: We want to be sure that we got the proofs right. -- -- The second claim is about reusability and applicability: Only -- a clearly defined interface allows other researchers to -- provide plugins for our framework. -- -- The third claim is to show that the plugin interface is -- consistent: An inconsistent plugin interface would allow to -- prove arbitrary results in the framework. ------------------------------------------------------------------------ module README where -- We know two good ways to read this code base. You can either -- use Emacs with agda2-mode to interact with the source files, -- or you can use a web browser to view the pretty-printed and -- hyperlinked source files. For Agda power users, we also -- include basic setup information for your own machine. -- IF YOU WANT TO USE A BROWSER -- ============================ -- -- Start with *HTML* version of this readme. On the AEC -- submission website (online or inside the VM), follow the link -- "view the Agda code in their browser" to the file -- agda/README.html. -- -- The source code is syntax highlighted and hyperlinked. You can -- click on module names to open the corresponding files, or you -- can click on identifiers to jump to their definition. In -- general, a Agda file with name `Foo/Bar/Baz.agda` contains a -- module `Foo.Bar.Baz` and is shown in an HTML file -- `Foo.Bar.Baz.html`. -- -- Note that we also include the HTML files generated for our -- transitive dependencies from the Agda standard library. This -- allows you to follow hyperlinks to the Agda standard -- library. It is the default behavior of `agda --html` which we -- used to generate the HTML. -- -- To get started, continue below on "Where to start reading?". -- IF YOU WANT TO USE EMACS -- ======================== -- -- Open this file in Emacs with agda2-mode installed. See below -- for which Agda version you need to install. On the VM image, -- everything is setup for you and you can just open this file in -- Emacs. -- -- C-c C-l Load code. Type checks and syntax highlights. Use -- this if the code is not syntax highlighted, or -- after you changed something that you want to type -- check. -- -- M-. Jump to definition of identifier at the point. -- M-* Jump back. -- -- Note that README.agda imports Everything.agda which imports -- every Agda file in our formalization. So if README.agda type -- checks successfully, everything does. If you want to type -- check everything from scratch, delete the *.agdai files to -- disable separate compilation. You can use "find . -name -- '*.agdai' | xargs rm" to do that. -- -- More information on the Agda mode is available on the Agda wiki: -- -- http://wiki.portal.chalmers.se/agda/pmwiki.php?n=Main.QuickGuideToEditingTypeCheckingAndCompilingAgdaCode -- http://wiki.portal.chalmers.se/agda/pmwiki.php?n=Docs.EmacsModeKeyCombinations -- -- To get started, continue below on "Where to start reading?". -- IF YOU WANT TO USE YOUR OWN SETUP -- ================================= -- -- To typecheck this formalization, you need to install the appropriate version -- of Agda (2.4.0.*), the Agda standard library (version 0.8), generate -- Everything.agda with the attached Haskell helper, and finally run Agda on -- this file. -- -- Given a Unix-like environment (including Cygwin), running the ./agdaCheck.sh -- script and following instructions given on output will eventually generate -- Everything.agda and proceed to type check everything on command line. -- -- If you're not an Agda power user, it is probably easier to use -- the VM image or look at the pretty-printed and hyperlinked -- HTML files, see above. -- WHERE TO START READING? -- ======================= -- -- modules.pdf -- The graph of dependencies between Agda modules. -- Good if you want to get a broad overview. -- -- README.agda -- This file. A coarse-grained introduction to the Agda -- formalization. Good if you want to begin at the beginning -- and understand the structure of our code. -- -- PLDI14-List-of-Theorems.agda -- Pointers to the Agda formalizations of all theorems, lemmas -- or definitions in the PLDI paper. Good if you want to read -- the paper and the Agda code side by side. -- -- Here is an import of this file, so you can jump to it -- directly (use M-. in Emacs or click the module name in the -- Browser): import PLDI14-List-of-Theorems -- Everything.agda -- Imports every Agda module in our formalization. Good if you -- want to make sure you don't miss anything. -- -- Again, here's is an import of this file so you can navigate -- there: import Everything -- (This import is also important to ensure that if we typecheck -- README.agda, we also typecheck every other file of our -- formalization). -- THE AGDA CODE -- ============= -- -- The formalization has four parts: -- -- 1. A formalization of change structures. This lives in -- Base.Change.Algebra. (What we call "change structure" in the -- paper, we call "change algebra" in the Agda code. We changed -- the name when writing the paper, and never got around to -- updating the name in the Agda code). -- -- 2. Incrementalization framework for first-class functions, -- with extension points for plugging in data types and their -- incrementalization. This lives in the Parametric.* -- hierarchy. -- -- 3. An example plugin that provides integers and bags -- with negative multiplicity. This lives in the Nehemiah.* -- hierarchy. (For some reason, we choose to call this -- particular incarnation of the plugin Nehemiah). -- -- 4. Other material that is unrelated to the framework/plugin -- distinction. This is all other files. -- FORMALIZATION OF CHANGE STRUCTURES -- ================================== -- -- Section 2 of the paper, and Base.Change.Algebra in Agda. import Base.Change.Algebra -- INCREMENTALIZATION FRAMEWORK -- ============================ -- -- Section 3 of the paper, and Parametric.* hierarchy in Agda. -- -- The extension points are implemented as module parameters. See -- detailed explanation in Parametric.Syntax.Type and -- Parametric.Syntax.Term. Some extension points are for types, -- some for values, and some for proof fragments. In Agda, these -- three kinds of entities are unified anyway, so we can encode -- all of them as module parameters. -- -- Every module in the Parametric.* hierarchy adds at least one -- extension point, so the module hierarchy of a plugin will -- typically mirror the Parametric.* hierarchy, defining the -- values for these extension points. -- -- Firstly, we have the syntax of types and terms, the erased -- change structure for function types and incrementalization as -- a term-to-term transformation. The contents of these modules -- formalizes Sec. 3.1 and 3.2 of the paper, except for the -- second and third line of Figure 3, which is formalized further -- below. import Parametric.Syntax.Type -- syntax of types import Parametric.Syntax.Term -- syntax of terms import Parametric.Change.Type -- simply-typed changes import Parametric.Change.Derive -- incrementalization -- Secondly, we define the usual denotational semantics of the -- simply-typed lambda calculus in terms of total functions, and -- the change semantics in terms of a change structure on total -- functions. The contents of these modules formalize Sec. 3.3, -- 3.4 and 3.5 of the paper. import Parametric.Denotation.Value -- standard values import Parametric.Denotation.Evaluation -- standard evaluation import Parametric.Change.Validity -- dependently-typed changes import Parametric.Change.Specification -- change evaluation -- Thirdly, we define terms that operate on simply-typed changes, -- and connect them to their values. The concents of these -- modules formalize the second and third line of Figure 3, as -- well as the semantics of these lines. import Parametric.Change.Term -- terms that operate on simply-typed changes import Parametric.Change.Value -- the values of these terms import Parametric.Change.Evaluation -- connecting the terms and their values -- Finally, we prove correctness by connecting the (syntactic) -- incrementalization to the (semantic) change evaluation by a -- logical relation, and a proof that the values of terms -- produced by the incrementalization transformation are related -- to the change values of the original terms. The contents of -- these modules formalize Sec. 3.6. import Parametric.Change.Implementation -- logical relation import Parametric.Change.Correctness -- main correctness proof -- EXAMPLE PLUGIN -- ============== -- -- Sec. 3.7 in the paper, and the Nehemiah.* hierarchy in Agda. -- -- The module structure of the plugin follows the structure of -- the Parametric.* hierarchy. For example, the extension point -- defined in Parametric.Syntax.Term is instantiated in -- Nehemiah.Syntax.Term. -- -- As discussed in Sec. 3.7 of the paper, the point of this -- plugin is not to speed up any real programs, but to show "that -- the interface for proof plugins can be implemented". As a -- first step towards proving correctness of the more complicated -- plugin with integers, bags and finite maps we implement in -- Scala, we choose to define plugin with integers and bags in -- Agda. Instead of implementing bags (with negative -- multiplicities, like in the paper) in Agda, though, we -- postulate that a group of such bags exist. Note that integer -- bags with integer multiplicities are actually the free group -- given a singleton operation `Integer -> Bag`, so this should -- be easy to formalize in principle. -- Before we start with the plugin, we postulate an abstract data -- type for integer bags. import Postulate.Bag-Nehemiah -- Firstly, we extend the syntax of types and terms, the erased -- change structure for function types, and incrementalization as -- a term-to-term transformation to account for the data types of -- the Nehemiah language. The contents of these modules -- instantiate the extension points in Sec. 3.1 and 3.2 of the -- paper, except for the second and third line of Figure 3, which -- is instantiated further below. import Nehemiah.Syntax.Type import Nehemiah.Syntax.Term import Nehemiah.Change.Type import Nehemiah.Change.Derive -- Secondly, we extend the usual denotational semantics and the -- change semantics to account for the data types of the Nehemiah -- language. The contents of these modules instantiate the -- extension points in Sec. 3.3, 3.4 and 3.5 of the paper. import Nehemiah.Denotation.Value import Nehemiah.Denotation.Evaluation import Nehemiah.Change.Validity -- Thirdly, we extend the terms that operate on simply-typed -- changes, and the connection to their values to account for the -- data types of the Nehemiah language. The concents of these -- modules instantiate the extension points in the second and -- third line of Figure 3. import Nehemiah.Change.Term import Nehemiah.Change.Value import Nehemiah.Change.Evaluation -- Finally, we extend the logical relation and the main -- correctness proof to account for the data types in the -- Nehemiah language. The contents of these modules instantiate -- the extension points defined in Sec. 3.6. import Nehemiah.Change.Implementation import Nehemiah.Change.Correctness -- OTHER MATERIAL -- ============== -- -- We postulate extensionality of Agda functions. This postulate -- is well known to be compatible with Agda's type theory. import Postulate.Extensionality -- For historical reasons, we reexport Data.List.All from the -- standard library under the name DependentList. import Base.Data.DependentList -- This module supports overloading the ⟦_⟧ notation based on -- Agda's instance arguments. import Base.Denotation.Notation -- These modules implement contexts including typed de Bruijn -- indices to represent bound variables, sets of bound variables, -- and environments. These modules are parametric in the set of -- types (that are stored in contexts) and the set of values -- (that are stored in environments). So these modules are even -- more parametric than the Parametric.* hierarchy. import Base.Syntax.Context import Base.Syntax.Vars import Base.Denotation.Environment -- This module contains some helper definitions to merge a -- context of values and a context of changes. import Base.Change.Context
{ "alphanum_fraction": 0.7258810155, "avg_line_length": 37.7, "ext": "agda", "hexsha": "c3936a923ef68be32a4a82752614ad597298d192", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_path": "README.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_path": "README.agda", "max_line_length": 108, "max_stars_count": 10, "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_path": "README.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "num_tokens": 3050, "size": 13195 }
data Nat : Set where zero : Nat suc : Nat → Nat data Id (A : Set) : Set where mkId : A → Id A data Monad (M : Set → Set) : Set where postulate return : ∀ {M} {{Mon : Monad M}} {A} → A → M A _>>=_ : ∀ {M} {{Mon : Monad M}} {A B} → M A → (A → M B) → M B State : (S A : Set) → Set instance MonadState : ∀ {S} → Monad (State S) MonadId : Monad Id -- Yields -- _M Nat == State Nat Nat, -- which inert improvement solves by -- _M x := State (_S x) (_A x) -- with _S Nat == Nat -- _A Nat == Nat -- This allows instance search to pick the right instance. rz : State Nat Nat rz = return zero postulate StateT : (S : Set) (M : Set → Set) (A : Set) → Set instance MonadStateT : ∀ {S M} → Monad M → Monad (StateT S M) stateT₁ : ∀ {M} {{Mon : Monad M}} → StateT Nat M Nat stateT₁ = return zero stateT₂ : ∀ {M} {{Mon : Monad M}} → StateT Nat M Nat stateT₂ = return zero >>= λ n → return (suc n) postulate _<$_ : ∀ {A B M} {{Mon : Monad M}} → A → M B → M A record ⊤ : Set where constructor tt foo : Id ⊤ foo = _ <$ return zero
{ "alphanum_fraction": 0.5538033395, "avg_line_length": 21.56, "ext": "agda", "hexsha": "789cea76f4ee8fac84c71e047113de72a4e03f93", "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/Succeed/ImproveInertRHS.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/Succeed/ImproveInertRHS.agda", "max_line_length": 64, "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/Succeed/ImproveInertRHS.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": 392, "size": 1078 }
------------------------------------------------------------------------ -- Simple recognisers ------------------------------------------------------------------------ open import Relation.Binary open import Relation.Binary.PropositionalEquality hiding ([_]) -- The recognisers are parametrised on the alphabet. module TotalRecognisers.Simple (Tok : Set) (_≟_ : Decidable (_≡_ {A = Tok})) -- The tokens must come with decidable equality. where open import Algebra open import Codata.Musical.Notation open import Data.Bool hiding (_≟_) import Data.Bool.Properties as Bool private module BoolCS = CommutativeSemiring Bool.∧-∨-commutativeSemiring open import Function open import Data.List open import Data.Product open import Relation.Nullary ------------------------------------------------------------------------ -- Recogniser combinators infixl 10 _·_ infixl 5 _∣_ mutual -- The index is true if the corresponding language contains the -- empty string (is nullable). data P : Bool → Set where fail : P false empty : P true tok : Tok → P false _∣_ : ∀ {n₁ n₂} → P n₁ → P n₂ → P (n₁ ∨ n₂) _·_ : ∀ {n₁ n₂} → P n₁ → ∞⟨ not n₁ ⟩P n₂ → P (n₁ ∧ n₂) -- Coinductive if the index is true. ∞⟨_⟩P : Bool → Bool → Set ∞⟨ true ⟩P n = ∞ (P n) ∞⟨ false ⟩P n = P n ------------------------------------------------------------------------ -- Conditional coinduction helpers delayed? : ∀ {b n} → ∞⟨ b ⟩P n → Bool delayed? {b = b} _ = b ♭? : ∀ {b n} → ∞⟨ b ⟩P n → P n ♭? {true} x = ♭ x ♭? {false} x = x ♯? : ∀ {b n} → P n → ∞⟨ b ⟩P n ♯? {true} x = ♯ x ♯? {false} x = x -- A lemma. ♭?♯? : ∀ b {n} {p : P n} → ♭? {b} (♯? p) ≡ p ♭?♯? true = refl ♭?♯? false = refl ------------------------------------------------------------------------ -- Semantics -- The semantics is defined inductively: s ∈ p iff the string s is -- contained in the language defined by p. infix 4 _∈_ data _∈_ : ∀ {n} → List Tok → P n → Set where empty : [] ∈ empty tok : ∀ {t} → [ t ] ∈ tok t ∣-left : ∀ {s n₁ n₂} {p₁ : P n₁} {p₂ : P n₂} → s ∈ p₁ → s ∈ p₁ ∣ p₂ ∣-right : ∀ {s n₁ n₂} {p₁ : P n₁} {p₂ : P n₂} → s ∈ p₂ → s ∈ p₁ ∣ p₂ _·_ : ∀ {s₁ s₂ n₁ n₂} {p₁ : P n₁} {p₂ : ∞⟨ not n₁ ⟩P n₂} → s₁ ∈ p₁ → s₂ ∈ ♭? p₂ → s₁ ++ s₂ ∈ p₁ · p₂ -- A lemma. cast : ∀ {n} {p p′ : P n} {s} → p ≡ p′ → s ∈ p → s ∈ p′ cast refl s∈ = s∈ ------------------------------------------------------------------------ -- Nullability -- The nullability index is correct. ⇒ : ∀ {n} {p : P n} → [] ∈ p → n ≡ true ⇒ pr = ⇒′ pr refl where ⇒′ : ∀ {n s} {p : P n} → s ∈ p → s ≡ [] → n ≡ true ⇒′ empty refl = refl ⇒′ tok () ⇒′ (∣-left pr₁) refl with ⇒ pr₁ ⇒′ (∣-left pr₁) refl | refl = refl ⇒′ (∣-right pr₂) refl with ⇒ pr₂ ⇒′ (∣-right {n₁ = n₁} pr₂) refl | refl = proj₂ BoolCS.zero n₁ ⇒′ (_·_ {[]} pr₁ pr₂) refl = cong₂ _∧_ (⇒ pr₁) (⇒ pr₂) ⇒′ (_·_ {_ ∷ _} pr₁ pr₂) () ⇐ : ∀ {n} (p : P n) → n ≡ true → [] ∈ p ⇐ fail () ⇐ empty refl = empty ⇐ (tok t) () ⇐ (_∣_ {true} p₁ p₂) refl = ∣-left (⇐ p₁ refl) ⇐ (_∣_ {false} {true} p₁ p₂) refl = ∣-right {p₁ = p₁} (⇐ p₂ refl) ⇐ (_∣_ {false} {false} p₁ p₂) () ⇐ (_·_ {true} p₁ p₂) refl = ⇐ p₁ refl · ⇐ p₂ refl ⇐ (_·_ {false} p₁ p₂) () -- We can decide if the empty string belongs to a given language. nullable? : ∀ {n} (p : P n) → Dec ([] ∈ p) nullable? {true} p = yes (⇐ p refl) nullable? {false} p = no helper where helper : ¬ [] ∈ p helper []∈p with ⇒ []∈p ... | () ------------------------------------------------------------------------ -- Derivative -- D-nullable and D are placed in a mutual block to ensure that the -- underscores in the definition of D-nullable can be solved by -- constraints introduced in the body of D. The functions are not -- actually mutually recursive. mutual -- The index of the derivative. The right-hand sides (excluding -- t′ ≟ t and delayed? p₂) are inferable, but included here so that -- they can easily be inspected. D-nullable : ∀ {n} → Tok → P n → Bool D-nullable t fail = false D-nullable t empty = false D-nullable t (tok t′) with t′ ≟ t D-nullable t (tok t′) | yes t′≡t = true D-nullable t (tok t′) | no t′≢t = false D-nullable t (p₁ ∣ p₂) = D-nullable t p₁ ∨ D-nullable t p₂ D-nullable t (p₁ · p₂) with delayed? p₂ D-nullable t (p₁ · p₂) | true = D-nullable t p₁ ∧ _ D-nullable t (p₁ · p₂) | false = D-nullable t p₁ ∧ _ ∨ D-nullable t p₂ -- D t p is the "derivative" of p with respect to t. It is specified -- by the equivalence s ∈ D t p ⇔ t ∷ s ∈ p (proved below). D : ∀ {n} (t : Tok) (p : P n) → P (D-nullable t p) D t fail = fail D t empty = fail D t (tok t′) with t′ ≟ t D t (tok t′) | yes t′≡t = empty D t (tok t′) | no t′≢t = fail D t (p₁ ∣ p₂) = D t p₁ ∣ D t p₂ D t (p₁ · p₂) with delayed? p₂ D t (p₁ · p₂) | true = D t p₁ · ♯? (♭ p₂) D t (p₁ · p₂) | false = D t p₁ · ♯? p₂ ∣ D t p₂ -- D is correct. D-sound : ∀ {s n} {t} {p : P n} → s ∈ D t p → t ∷ s ∈ p D-sound s∈ = D-sound′ _ _ s∈ where D-sound′ : ∀ {s n} t (p : P n) → s ∈ D t p → t ∷ s ∈ p D-sound′ t fail () D-sound′ t empty () D-sound′ t (tok t′) _ with t′ ≟ t D-sound′ t (tok .t) empty | yes refl = tok D-sound′ t (tok t′) () | no t′≢t D-sound′ t (p₁ ∣ p₂) (∣-left ∈₁) = ∣-left (D-sound′ t p₁ ∈₁) D-sound′ t (p₁ ∣ p₂) (∣-right ∈₂) = ∣-right {p₁ = p₁} (D-sound′ t p₂ ∈₂) D-sound′ t (_·_ {true} p₁ p₂) (∣-left (∈₁ · ∈₂)) = D-sound′ t p₁ ∈₁ · cast (♭?♯? (not (D-nullable t p₁))) ∈₂ D-sound′ t (_·_ {true} p₁ p₂) (∣-right ∈₂) = ⇐ p₁ refl · D-sound′ t p₂ ∈₂ D-sound′ t (_·_ {false} p₁ p₂) (∈₁ · ∈₂) = D-sound′ t p₁ ∈₁ · cast (♭?♯? (not (D-nullable t p₁))) ∈₂ D-complete : ∀ {s n} {t} {p : P n} → t ∷ s ∈ p → s ∈ D t p D-complete {t = t} t∷s∈ = D-complete′ _ t∷s∈ refl where D-complete′ : ∀ {s s′ n} (p : P n) → s′ ∈ p → s′ ≡ t ∷ s → s ∈ D t p D-complete′ fail () refl D-complete′ empty () refl D-complete′ (tok t′) _ refl with t′ ≟ t D-complete′ (tok .t) tok refl | yes refl = empty D-complete′ {[]} (tok .t) tok refl | no t′≢t with t′≢t refl D-complete′ {[]} (tok .t) tok refl | no t′≢t | () D-complete′ (p₁ ∣ p₂) (∣-left ∈₁) refl = ∣-left (D-complete ∈₁) D-complete′ (p₁ ∣ p₂) (∣-right ∈₂) refl = ∣-right {p₁ = D t p₁} (D-complete ∈₂) D-complete′ (_·_ {true} p₁ p₂) (_·_ {[]} ∈₁ ∈₂) refl = ∣-right {p₁ = D t p₁ · _} (D-complete ∈₂) D-complete′ (_·_ {true} p₁ p₂) (_·_ {._ ∷ _} ∈₁ ∈₂) refl = ∣-left (D-complete ∈₁ · cast (sym (♭?♯? (not (D-nullable t p₁)))) ∈₂) D-complete′ (_·_ {false} p₁ p₂) (_·_ {[]} ∈₁ ∈₂) refl with ⇒ ∈₁ D-complete′ (_·_ {false} p₁ p₂) (_·_ {[]} ∈₁ ∈₂) refl | () D-complete′ (_·_ {false} p₁ p₂) (_·_ {._ ∷ _} ∈₁ ∈₂) refl = D-complete ∈₁ · cast (sym (♭?♯? (not (D-nullable t p₁)))) ∈₂ ------------------------------------------------------------------------ -- _∈_ is decidable -- _∈?_ runs a recogniser. Note that the result is yes or no plus a -- /proof/ verifying that the answer is correct. infix 4 _∈?_ _∈?_ : ∀ {n} (s : List Tok) (p : P n) → Dec (s ∈ p) [] ∈? p = nullable? p t ∷ s ∈? p with s ∈? D t p t ∷ s ∈? p | yes s∈Dtp = yes (D-sound s∈Dtp) t ∷ s ∈? p | no s∉Dtp = no (s∉Dtp ∘ D-complete)
{ "alphanum_fraction": 0.4570912376, "avg_line_length": 35.3835616438, "ext": "agda", "hexsha": "4702e310fa5cb8c39c0677f9903496c507859b49", "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": "TotalRecognisers/Simple.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "TotalRecognisers/Simple.agda", "max_line_length": 131, "max_stars_count": 1, "max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/parser-combinators", "max_stars_repo_path": "TotalRecognisers/Simple.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z", "num_tokens": 3040, "size": 7749 }
-- Andreas, 2011-09-11 module Issue392 where import Common.Irrelevance -- Create an non-irrelevant record R1 (at least one field relevant). record R1 : Set1 where field .f1 : Set f1' : Set {- This creates a module with an relevant record parameter module R1 (r : R1) where .f1 : Set -- = R1.f1 r f1' : Set -} -- Create an irrelevant instance f2 of R1. record R2 : Set2 where field .f2 : R1 f3 : Set -- This should not succeed. open R1 f2 public {- identifier f2 is declared irrelevant, so it cannot be used here when checking that the expression f2 has type R1 -}
{ "alphanum_fraction": 0.6732673267, "avg_line_length": 19.5483870968, "ext": "agda", "hexsha": "84302e873482ddd0467d7ebae35d8dcaf2c72478", "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": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Fail/Issue392.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "test/Fail/Issue392.agda", "max_line_length": 68, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Fail/Issue392.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": 192, "size": 606 }
module Generic.Lib.Equality.Heteroindexed where open import Data.Product open import Generic.Lib.Equality.Propositional data [_]_≅_ {ι α} {I : Set ι} {i} (A : I -> Set α) (x : A i) : ∀ {j} -> A j -> Set where irefl : [ A ] x ≅ x inds : ∀ {ι α} {I : Set ι} {A : I -> Set α} {i j} {x : A i} {y : A j} -> [ A ] x ≅ y -> i ≡ j inds irefl = refl homo : ∀ {ι α} {I : Set ι} {A : I -> Set α} {i} {x y : A i} -> [ A ] x ≅ y -> x ≡ y homo irefl = refl inds-homo : ∀ {ι α} {I : Set ι} {A : Set α} {i j : I} {x y : A} -> [_]_≅_ {i = i} (λ _ -> A) x {j} y -> i ≡ j × x ≡ y inds-homo irefl = refl , refl
{ "alphanum_fraction": 0.4717285945, "avg_line_length": 29.4761904762, "ext": "agda", "hexsha": "4cb3ac0e3b9477d9daceb65a2bf3c2f637649977", "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/Equality/Heteroindexed.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/Equality/Heteroindexed.agda", "max_line_length": 88, "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/Equality/Heteroindexed.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": 278, "size": 619 }
module IndentedCheckingMessages where import A.M Foo : Set Foo = Foo
{ "alphanum_fraction": 0.7746478873, "avg_line_length": 10.1428571429, "ext": "agda", "hexsha": "dcb6e3331b852ada164f61679cbde3736594f220", "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/IndentedCheckingMessages.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/IndentedCheckingMessages.agda", "max_line_length": 37, "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/IndentedCheckingMessages.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": 19, "size": 71 }