Search is not available for this dataset
text
string
meta
dict
-- There was a bug where constructors of private datatypes were -- not made private. module Issue484 where module A where private data Foo : Set where foo : Foo foo′ = A.foo
{ "alphanum_fraction": 0.7081081081, "avg_line_length": 16.8181818182, "ext": "agda", "hexsha": "59c0bbb56927e6daeb82b1e35d535bcbbeec499e", "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/Issue484.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/Issue484.agda", "max_line_length": 63, "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/Issue484.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": 47, "size": 185 }
module Issue422 where data Bool : Set where true false : Bool data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x foo : Bool → Bool → Bool foo true b = b foo n true = true foo false b = false good : foo false true ≡ true good = refl data Nat : Set where zero : Nat suc : Nat → Nat data T : Set where t₁ : Nat → T t₂ : Nat → Nat → T t₃ : Nat → Nat → Nat → T bar : Nat → Nat → Nat → T bar x zero z = t₂ x z bar x y (suc z) = t₃ x y z bar x (suc y) zero = t₂ x y postulate a b c : Nat eqn₁ : bar a zero c ≡ t₂ a c eqn₁ = refl eqn₂ : bar a (suc b) (suc c) ≡ t₃ a (suc b) c eqn₂ = refl eqn₃ : bar a (suc b) zero ≡ t₂ a b eqn₃ = refl
{ "alphanum_fraction": 0.5499276411, "avg_line_length": 16.0697674419, "ext": "agda", "hexsha": "56d6dda428e7660be7e2755afff94430811516c4", "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/Issue422.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/Issue422.agda", "max_line_length": 45, "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/Issue422.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": 296, "size": 691 }
module Data.QuadTree.Implementation.Foldable where open import Haskell.Prelude renaming (zero to Z; suc to S) open import Data.Logic open import Data.QuadTree.Implementation.Definition open import Data.QuadTree.Implementation.ValidTypes open import Data.QuadTree.Implementation.QuadrantLenses open import Data.QuadTree.Implementation.SafeFunctions open import Data.QuadTree.Implementation.PropDepthRelation {-# FOREIGN AGDA2HS {-# LANGUAGE Safe #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE Rank2Types #-} import Data.Nat import Data.Lens.Lens import Data.Logic import Data.QuadTree.Implementation.Definition import Data.QuadTree.Implementation.ValidTypes import Data.QuadTree.Implementation.QuadrantLenses #-} record FoldableEq (t : (y : Set) -> {{ eqT : Eq y }} -> Set) : Set₁ where field foldMapₑ : {a b : Set} -> {{ eqA : Eq a }} {{ eqB : Eq b }} -> {{ monB : Monoid b }} → (a → b) → t a → b lengthₑ : {{eqA : Eq a}} -> t a → Nat lengthₑ = foldMapₑ ⦃ monB = MonoidSum ⦄ (const 1) open FoldableEq public {-# COMPILE AGDA2HS FoldableEq class #-} data Region : Set where -- point 1: x, point 1: y, point 2: x, point 2: y RegionC : (p1 : Nat × Nat) (p2 : Nat × Nat) -> Region {-# COMPILE AGDA2HS Region #-} data Tile (t : Set) : Set where TileC : t -> Region -> Tile t {-# COMPILE AGDA2HS Tile #-} instance tileFunctor : Functor Tile tileFunctor .fmap f (TileC v r) = TileC (f v) r tilesQd : {t : Set} {{eqT : Eq t}} (dep : Nat) -> VQuadrant t {dep} -> (reg : Region) -> List (Tile t) tilesQd dep (CVQuadrant (Leaf v)) reg = TileC v reg ∷ [] tilesQd {t} (dep @ (S deps)) (CVQuadrant (Node a b c d) {p}) reg@(RegionC (x1 , y1) (x2 , y2)) = let mid = pow 2 deps sA : List (Tile t) sA = tilesQd deps (CVQuadrant a {aSub a b c d p}) (RegionC (x1 , y1) (min x2 (mid + x1) , min y2 (mid + y1))) sB : List (Tile t) sB = tilesQd deps (CVQuadrant b {bSub a b c d p}) (RegionC (min x2 (mid + x1) , y1) (x2 , min y2 (mid + y1)) ) sC : List (Tile t) sC = tilesQd deps (CVQuadrant c {cSub a b c d p}) (RegionC (x1 , min y2 (mid + y1)) (min x2 (mid + x1) , y2) ) sD : List (Tile t) sD = tilesQd deps (CVQuadrant d {dSub a b c d p}) (RegionC (min x2 (mid + x1) , min y2 (mid + y1)) (x2 , y2) ) in sA ++ sB ++ sC ++ sD {-# COMPILE AGDA2HS tilesQd #-} tilesQt : {t : Set} {{eqT : Eq t}} (dep : Nat) -> VQuadTree t {dep} -> List (Tile t) tilesQt dep (CVQuadTree (Wrapper wh qd) {p1} {p2}) = tilesQd dep (CVQuadrant qd {p1}) (RegionC (0 , 0) wh) {-# COMPILE AGDA2HS tilesQt #-} replicateₙ : {t : Set} -> Nat -> t -> List t replicateₙ Z v = [] replicateₙ (S n) v = v ∷ replicateₙ n v {-# COMPILE AGDA2HS replicateₙ #-} expand : {t : Set} -> Tile t -> List t expand (TileC v (RegionC (lx , ly) (ux , uy))) = replicateₙ (dx * dy) v where dx = diff ux lx dy = diff uy ly {-# COMPILE AGDA2HS expand #-} quadtreeFoldable : (dep : Nat) -> FoldableEq (λ y -> VQuadTree y {dep}) quadtreeFoldable dep .foldMapₑ f t = foldMap f $ concat $ map expand (tilesQt dep t)
{ "alphanum_fraction": 0.5986245702, "avg_line_length": 35.9438202247, "ext": "agda", "hexsha": "2a19ed2b66bee19e5c06f41de307429650bf4db5", "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/Implementation/Foldable.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/Implementation/Foldable.agda", "max_line_length": 106, "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/Implementation/Foldable.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": 1114, "size": 3199 }
postulate C : Set anything : C record I : Set where constructor c field {f} : C data Wrap : (i : I) → Set where wrap : ∀ {i} → Wrap i works : ∀ {j} → Wrap j → C works {c {._}} (wrap {c {x}}) = anything fails : ∀ {j} → Wrap j → C fails {c {._}} (wrap {c}) = anything -- Failed to infer the value of dotted pattern -- when checking that the pattern ._ has type C fails' : ∀ {j} → Wrap j → C fails' .{c {_}} (wrap {c}) = anything works2 : ∀ {j} → Wrap j → C works2 {c} (wrap {c {._}}) = anything fails2 : ∀ {j} → Wrap j → C fails2 {c {._}} (wrap {c}) = anything
{ "alphanum_fraction": 0.5507745267, "avg_line_length": 19.3666666667, "ext": "agda", "hexsha": "0f85727e24a16327909130c532364d5846c4978b", "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/Issue1608.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/Issue1608.agda", "max_line_length": 47, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue1608.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": 217, "size": 581 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties of operations on the Stream type ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe --sized-types #-} module Codata.Stream.Properties where open import Level using (Level) open import Size open import Codata.Thunk as Thunk using (Thunk; force) open import Codata.Stream open import Codata.Stream.Bisimilarity open import Data.Nat.Base open import Data.Nat.GeneralisedArithmetic using (fold; fold-pull) open import Data.List.Base as List using ([]; _∷_) open import Data.List.NonEmpty as List⁺ using (List⁺; _∷_) import Data.List.Relation.Binary.Equality.Propositional as Eq open import Data.Product as Prod using (_,_) open import Data.Vec.Base as Vec using (_∷_) open import Function open import Relation.Binary.PropositionalEquality as P using (_≡_; _≢_) private variable a b c : Level A : Set a B : Set b C : Set c i : Size ------------------------------------------------------------------------ -- repeat lookup-repeat-identity : (n : ℕ) (a : A) → lookup n (repeat a) ≡ a lookup-repeat-identity zero a = P.refl lookup-repeat-identity (suc n) a = lookup-repeat-identity n a take-repeat-identity : (n : ℕ) (a : A) → take n (repeat a) ≡ Vec.replicate a take-repeat-identity zero a = P.refl take-repeat-identity (suc n) a = P.cong (a Vec.∷_) (take-repeat-identity n a) splitAt-repeat-identity : (n : ℕ) (a : A) → splitAt n (repeat a) ≡ (Vec.replicate a , repeat a) splitAt-repeat-identity zero a = P.refl splitAt-repeat-identity (suc n) a = P.cong (Prod.map₁ (a ∷_)) (splitAt-repeat-identity n a) replicate-repeat : ∀ {i} (n : ℕ) (a : A) → i ⊢ List.replicate n a ++ repeat a ≈ repeat a replicate-repeat zero a = refl replicate-repeat (suc n) a = P.refl ∷ λ where .force → replicate-repeat n a cycle-replicate : ∀ {i} (n : ℕ) (n≢0 : n ≢ 0) (a : A) → i ⊢ cycle (List⁺.replicate n n≢0 a) ≈ repeat a cycle-replicate {i} n n≢0 a = let as = List⁺.replicate n n≢0 a in begin cycle as ≡⟨⟩ as ⁺++ _ ≈⟨ ⁺++⁺ Eq.≋-refl (λ where .force → cycle-replicate n n≢0 a) ⟩ as ⁺++ (λ where .force → repeat a) ≈⟨ P.refl ∷ (λ where .force → replicate-repeat (pred n) a) ⟩ repeat a ∎ where open ≈-Reasoning module _ {a b} {A : Set a} {B : Set b} where map-repeat : ∀ (f : A → B) a {i} → i ⊢ map f (repeat a) ≈ repeat (f a) map-repeat f a = P.refl ∷ λ where .force → map-repeat f a ap-repeat : ∀ (f : A → B) a {i} → i ⊢ ap (repeat f) (repeat a) ≈ repeat (f a) ap-repeat f a = P.refl ∷ λ where .force → ap-repeat f a ap-repeatˡ : ∀ (f : A → B) as {i} → i ⊢ ap (repeat f) as ≈ map f as ap-repeatˡ f (a ∷ as) = P.refl ∷ λ where .force → ap-repeatˡ f (as .force) ap-repeatʳ : ∀ (fs : Stream (A → B) ∞) (a : A) {i} → i ⊢ ap fs (repeat a) ≈ map (_$ a) fs ap-repeatʳ (f ∷ fs) a = P.refl ∷ λ where .force → ap-repeatʳ (fs .force) a map-++ : ∀ {i} (f : A → B) as xs → i ⊢ map f (as ++ xs) ≈ List.map f as ++ map f xs map-++ f [] xs = refl map-++ f (a ∷ as) xs = P.refl ∷ λ where .force → map-++ f as xs map-⁺++ : ∀ {i} (f : A → B) as xs → i ⊢ map f (as ⁺++ xs) ≈ List⁺.map f as ⁺++ Thunk.map (map f) xs map-⁺++ f (a ∷ as) xs = P.refl ∷ (λ where .force → map-++ f as (xs .force)) map-cycle : ∀ {i} (f : A → B) as → i ⊢ map f (cycle as) ≈ cycle (List⁺.map f as) map-cycle f as = begin map f (cycle as) ≈⟨ map-⁺++ f as _ ⟩ List⁺.map f as ⁺++ _ ≈⟨ ⁺++⁺ Eq.≋-refl (λ where .force → map-cycle f as) ⟩ cycle (List⁺.map f as) ∎ where open ≈-Reasoning ------------------------------------------------------------------------ -- Functor laws map-identity : ∀ (as : Stream A ∞) → i ⊢ map id as ≈ as map-identity (a ∷ as) = P.refl ∷ λ where .force → map-identity (as .force) map-map-fusion : ∀ (f : A → B) (g : B → C) as → i ⊢ map g (map f as) ≈ map (g ∘ f) as map-map-fusion f g (a ∷ as) = P.refl ∷ λ where .force → map-map-fusion f g (as .force) ------------------------------------------------------------------------ -- splitAt splitAt-map : ∀ n (f : A → B) xs → splitAt n (map f xs) ≡ Prod.map (Vec.map f) (map f) (splitAt n xs) splitAt-map zero f xs = P.refl splitAt-map (suc n) f (x ∷ xs) = P.cong (Prod.map₁ (f x Vec.∷_)) (splitAt-map n f (xs .force)) ------------------------------------------------------------------------ -- iterate lookup-iterate-identity : ∀ n f (a : A) → lookup n (iterate f a) ≡ fold a f n lookup-iterate-identity zero f a = P.refl lookup-iterate-identity (suc n) f a = begin lookup (suc n) (iterate f a) ≡⟨⟩ lookup n (iterate f (f a)) ≡⟨ lookup-iterate-identity n f (f a) ⟩ fold (f a) f n ≡⟨ fold-pull (const ∘′ f) (f a) P.refl (λ _ → P.refl) n ⟩ f (fold a f n) ≡⟨⟩ fold a f (suc n) ∎ where open P.≡-Reasoning ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 1.1 repeat-ap-identity = ap-repeatˡ {-# WARNING_ON_USAGE repeat-ap-identity "Warning: repeat-ap-identity was deprecated in v1.1. Please use ap-repeatˡ instead." #-} ap-repeat-identity = ap-repeatʳ {-# WARNING_ON_USAGE ap-repeat-identity "Warning: ap-repeat-identity was deprecated in v1.1. Please use ap-repeatʳ instead." #-} ap-repeat-commute = ap-repeat {-# WARNING_ON_USAGE ap-repeat-commute "Warning: ap-repeat-commute was deprecated in v1.1. Please use ap-repeat instead." #-} map-repeat-commute = map-repeat {-# WARNING_ON_USAGE map-repeat-commute "Warning: map-repeat-commute was deprecated in v1.1. Please use map-repeat instead." #-}
{ "alphanum_fraction": 0.5480293465, "avg_line_length": 38.5592105263, "ext": "agda", "hexsha": "1b94cd54a0bc9f85a20115a32c533b9a5a286c3c", "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/Codata/Stream/Properties.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/Codata/Stream/Properties.agda", "max_line_length": 102, "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/Codata/Stream/Properties.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": 1934, "size": 5861 }
-- {-# OPTIONS -v tc.meta:100 #-} -- Andreas, 2011-09-21 (fix by Ulf) module Issue458b where data _≡_ {A : Set}(a : A) : A -> Set where refl : a ≡ a data Nat : Set where zero : Nat suc : Nat -> Nat data Pair (A B : Set) : Set where pair : A -> B -> Pair A B fst : {A B : Set} -> Pair A B -> A fst (pair a b) = a overzeal : let X : Nat -> Nat -> Nat X = _ Y : Pair Nat Nat -> Nat Y = _ in {C : Set} -> (({x y : Nat} -> X x x ≡ Y (pair x y)) -> ({z : Pair Nat Nat} -> Y z ≡ fst z) -> ({x y : Nat} -> X x y ≡ x) -> C) -> C overzeal k = k refl refl refl -- This should succeed. -- However, before Ulf's fix the first constraint would lead to -- a pruning of y from Y, since X does not depend on y -- This lost the solution Y = fst. {- ERROR was: Cannot instantiate the metavariable _59 to (fst .z) since it contains the variable .z which is not in scope of the metavariable when checking that the expression refl has type (_59 ≡ fst .z) -}
{ "alphanum_fraction": 0.5238970588, "avg_line_length": 30.2222222222, "ext": "agda", "hexsha": "edc266ed0854c41b8113f2d7aec2224f7b334dfc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/Issue458b.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/Issue458b.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/Issue458b.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": 338, "size": 1088 }
open import Data.Bool module GUIgeneric.GUIModelExample where open import GUIgeneric.Prelude renaming (inj₁ to secondButton; inj₂ to firstButton; WxColor to Color) hiding (IOInterfaceˢ) open import GUIgeneric.GUIDefinitions renaming (add to add'; add' to add; ComponentEls to Frame) open import GUIgeneric.GUI open import GUIgeneric.GUIExampleLib open import StateSizedIO.writingOOsUsingIOVers4ReaderMethods open import StateSizedIO.Base open import GUIgeneric.GUIExample using (oneBtnGUI ; propOneBtn ; obj1Btn; twoBtnGUI ; propTwoBtn ; obj2Btn ) open import GUIgeneric.GUIModel open import Data.Sum open IOInterfaceˢ public private postulate btn : FFIButton private postulate fr : FFIFrame state1Btn : ModelGuiState state1Btn = state oneBtnGUI propOneBtn (obj1Btn {∞}) notStarted state2Btn : ModelGuiState state2Btn = state twoBtnGUI propTwoBtn (obj2Btn {∞}) notStarted corstate1BtnNext1∀ : (m : ModelGuiState) → (state1Btn -gui->¹ m) → m ≡ state2Btn corstate1BtnNext1∀ m (step _) = refl corstate1BtnNext∃ : state1Btn -gui->¹ state2Btn corstate1BtnNext∃ = step (btn , fr) corstate1BtnNext∀ : (m : ModelGuiState) → (state2Btn -gui->¹ m) → (m ≡ state2Btn ⊎ m ≡ state1Btn ) corstate1BtnNext∀ m (step (inj₁ _)) = inj₁ refl corstate1BtnNext∀ m (step (inj₂ _)) = inj₂ refl corstate2BtnNext∃1 : state2Btn -gui->¹ state2Btn corstate2BtnNext∃1 = step (inj₁ (btn , (btn , fr)) ) corstate2BtnNext∃2 : state2Btn -gui->¹ state1Btn corstate2BtnNext∃2 = step (inj₂ (btn , (btn , fr)) )
{ "alphanum_fraction": 0.7007343941, "avg_line_length": 32.68, "ext": "agda", "hexsha": "0a8655b1c378096b614fe15427fa402f88e18ac6", "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": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "stephanadls/state-dependent-gui", "max_forks_repo_path": "examples/GUIgeneric/GUIModelExample.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "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": "stephanadls/state-dependent-gui", "max_issues_repo_path": "examples/GUIgeneric/GUIModelExample.agda", "max_line_length": 123, "max_stars_count": 2, "max_stars_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "stephanadls/state-dependent-gui", "max_stars_repo_path": "examples/GUIgeneric/GUIModelExample.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-31T17:20:59.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T15:37:39.000Z", "num_tokens": 522, "size": 1634 }
open import Common.Level postulate ℓ : Level f : (l : Level) (A : Set l) → Set ℓ f ℓ A = A -- Expected error: -- ℓ != ℓ of type Level -- (because one is a variable and one a defined identifier) -- when checking that the expression A has type Set ℓ -- Jesper, 2018-12-10, New error: -- A != Issue998a.A of type Set -- when checking that the expression d A has type D Issue998a.A
{ "alphanum_fraction": 0.6744791667, "avg_line_length": 22.5882352941, "ext": "agda", "hexsha": "a76b77aa52d83fde0fd90a7577180c6ee13d9d19", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "hborum/agda", "max_forks_repo_path": "test/Fail/Issue998d.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "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": "hborum/agda", "max_issues_repo_path": "test/Fail/Issue998d.agda", "max_line_length": 63, "max_stars_count": null, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Fail/Issue998d.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 121, "size": 384 }
open import Agda.Builtin.Nat variable {n} : Nat data Vec (A : Set) : Nat → Set where [] : Vec A 0 _∷_ : A → Vec A n → Vec A (suc n) cons : ∀ {m A} → A → Vec A m → Vec A (suc m) cons = _∷_ module _ (A : Set) where data Vec' : Nat → Set where [] : Vec' 0 _∷_ : A → Vec' n → Vec' (suc n) cons' : ∀ {m A} → A → Vec' A m → Vec' A (suc m) cons' = _∷_
{ "alphanum_fraction": 0.5, "avg_line_length": 19.2631578947, "ext": "agda", "hexsha": "196c50a0c92252037d743d7b8c031a7399ad4499", "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/Issue3108.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/Issue3108.agda", "max_line_length": 47, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue3108.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": 162, "size": 366 }
-- Andreas, 2014-06-12 -- No inversion on one clause functions with record patterns only! {-# OPTIONS -v tc.inj:40 #-} -- KEEP! module _ where open import Common.Product -- No inverse should be created for swap by -- checkInjectivity, since we are dealing with a record constructor. swap : ∀{A B} → A × B → B × A swap (a , b) = b , a -- The internal representation is -- -- swap p = (snd p, fst p) -- -- so trying to use injectivity is pointless here. -- The expected output should mention that injectivity for swap is pointless. -- ... -- Injectivity of ConstructorHeadedPointlessForRecordPatterns.swap would be pointless. -- Crash after typechecking swap. KEEP! CRASH : Set CRASH = Set
{ "alphanum_fraction": 0.7048710602, "avg_line_length": 24.9285714286, "ext": "agda", "hexsha": "816b756f7892f29187a1e5f8dd20e7e71fb9b628", "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/ConstructorHeadedPointlessForRecordPatterns.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/ConstructorHeadedPointlessForRecordPatterns.agda", "max_line_length": 86, "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/ConstructorHeadedPointlessForRecordPatterns.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": 181, "size": 698 }
-- Andreas, 2015-06-29 polarity handling is broken -- See also issue 1592 -- {-# OPTIONS -v tc.polarity:20 -v tc.proj.like:100 #-} -- {-# OPTIONS -v tc.conv.elim:25 --show-implicit #-} open import Common.Size open import Common.Prelude data D : Size → Set where c : ∀ i → D (↑ i) record Type (a : Bool) : Set1 where constructor mkType field type : Set open Type Opp : Set → Set Opp X = X → ⊥ -- projection-like contravariant function which does not unfold abstract Contra : ∀ a (T : Type a) → Set Contra a (mkType A) = Opp A -- Subtyping is broken for projection(-like) things. -- This is exploitable as Contra true (mkType X) does not reduce to Opp X here. cast : ∀{i} → Contra true (mkType (D i)) → Contra true (mkType (D (↑ i))) cast x = x -- Here it, does reduce. abstract loop : ∀{i} → D i → ⊥ loop (c i) = cast loop (c i) absurd : ⊥ absurd = loop (c ∞)
{ "alphanum_fraction": 0.6391402715, "avg_line_length": 23.2631578947, "ext": "agda", "hexsha": "2642b9665f932a7686dd448e2a422ce29c17ca7c", "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/PolarityProjectionLike.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/PolarityProjectionLike.agda", "max_line_length": 81, "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/PolarityProjectionLike.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": 293, "size": 884 }
module Issue564 where open import Agda.Primitive using (Level) renaming (lzero to zero) postulate A : Level → Set module M ℓ where postulate a : A ℓ postulate P : A zero → Set open M zero p : P a p = {!!}
{ "alphanum_fraction": 0.668202765, "avg_line_length": 12.0555555556, "ext": "agda", "hexsha": "c5eb248ef0ce077c8bb33c1be48058bf71500831", "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/Issue564.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/Issue564.agda", "max_line_length": 65, "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/Issue564.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": 71, "size": 217 }
module LevelConstraints where open import Common.Level postulate a b : Level OfLvl : ∀ ℓ → Set ℓ → Set SameLvl : ∀ {ℓ} → Set ℓ → Set ℓ → Set -- Here we get two constraints by themselves unsolveable constraints: -- _18 ⊔ a = _18 (solved by _18 := a ⊔ ℓ, for any ℓ) -- a ⊔ _18 = a (solved by _18 := a or _18 := 0) -- By looking at both constraints together we can find the unique solution -- _18 := a bar : (A : Set _)(B : Set a) → SameLvl A (A → B) → SameLvl B (A → B)
{ "alphanum_fraction": 0.5893909627, "avg_line_length": 31.8125, "ext": "agda", "hexsha": "7df701c5463ced146a97467b7f390a0092d697eb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/LevelConstraints.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/LevelConstraints.agda", "max_line_length": 76, "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/LevelConstraints.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": 187, "size": 509 }
open import Data.Boolean open import Type module Data.List.Sorting.QuickSort {ℓ} {T : Type{ℓ}} (_≤?_ : T → T → Bool) where import Lvl open import Data.List open import Data.List.Functions as List using (_++_) import Data.List.Functions.Multi as List open import Data.Tuple import Numeral.Finite.Conversions as 𝕟 open import Functional using (_∘_) {-# TERMINATING #-} quickSort : List(T) → List(T) quickSort ∅ = ∅ quickSort (x ⊰ l) with (less , great) ← List.separateBy(left 𝕟.bool ∘ (x ≤?_)) l = quickSort(less) ++ (x ⊰ quickSort(great)) module Proofs where
{ "alphanum_fraction": 0.6797274276, "avg_line_length": 26.6818181818, "ext": "agda", "hexsha": "15abe3ff2641176739ab6f7cd39fd861e5ced506", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Data/List/Sorting/QuickSort.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Data/List/Sorting/QuickSort.agda", "max_line_length": 80, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Data/List/Sorting/QuickSort.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": 183, "size": 587 }
module Luau.Syntax where open import Luau.Var using (Var) open import Luau.Addr using (Addr) infixr 5 _∙_ data Block : Set data Stat : Set data Expr : Set data Block where _∙_ : Stat → Block → Block done : Block data Stat where function_⟨_⟩_end : Var → Var → Block → Stat local_←_ : Var → Expr → Stat return : Expr → Stat data Expr where nil : Expr var : Var → Expr addr : Addr → Expr _$_ : Expr → Expr → Expr function⟨_⟩_end : Var → Block → Expr block_is_end : Var → Block → Expr
{ "alphanum_fraction": 0.6561886051, "avg_line_length": 18.1785714286, "ext": "agda", "hexsha": "3fe05bc89e623d96a1d59a16a5258c100c2aacd8", "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": "5187e64f88953f34785ffe58acd0610ee5041f5f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "FreakingBarbarians/luau", "max_forks_repo_path": "prototyping/Luau/Syntax.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f", "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": "FreakingBarbarians/luau", "max_issues_repo_path": "prototyping/Luau/Syntax.agda", "max_line_length": 45, "max_stars_count": 1, "max_stars_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "FreakingBarbarians/luau", "max_stars_repo_path": "prototyping/Luau/Syntax.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-11T21:30:17.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-11T21:30:17.000Z", "num_tokens": 169, "size": 509 }
{-# OPTIONS --safe --no-qualified-instances #-} open import Data.List hiding (concat) module JVM.Syntax.Labeling {ℓ} (T : Set ℓ) where open import Relation.Unary hiding (_∈_; Empty) open import Relation.Ternary.Core open import Relation.Ternary.Data.Bigplus open import Data.Sum open import Data.Product open import JVM.Model T Labeling : T → Pred (List T) _ Labeling = λ τ → Bigplus (One τ) where open Disjoint
{ "alphanum_fraction": 0.7363420428, "avg_line_length": 23.3888888889, "ext": "agda", "hexsha": "c36ffaf854daa662f8ec92d3f60d4134681e9e22", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ajrouvoet/jvm.agda", "max_forks_repo_path": "src/JVM/Syntax/Labeling.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "ajrouvoet/jvm.agda", "max_issues_repo_path": "src/JVM/Syntax/Labeling.agda", "max_line_length": 48, "max_stars_count": 6, "max_stars_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ajrouvoet/jvm.agda", "max_stars_repo_path": "src/JVM/Syntax/Labeling.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": 113, "size": 421 }
module Issue778M (Param : Set) where data Nat : Set where zero : Nat suc : Nat -> Nat pred : Nat → Nat pred = λ { zero → zero; (suc n) → n } where aux = zero
{ "alphanum_fraction": 0.5892857143, "avg_line_length": 14, "ext": "agda", "hexsha": "fbe1fa6256d5540430ced8a90c0175fbe559e1a4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/Issue778M.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/Issue778M.agda", "max_line_length": 37, "max_stars_count": 1, "max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "np/agda-git-experiment", "max_stars_repo_path": "test/succeed/Issue778M.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": 57, "size": 168 }
------------------------------------------------------------------------------ -- Agda-Prop Library. -- Syntax Experiment definitions. ------------------------------------------------------------------------------ open import Data.Nat using ( ℕ ) module Data.PropFormula.SyntaxExperiment ( n : ℕ ) where ------------------------------------------------------------------------------ open import Data.Bool using (false; true) open import Data.PropFormula.Syntax n open import Data.PropFormula.Views n open import Data.PropFormula.Dec n open import Data.PropFormula.Properties n open import Data.List public open import Function using (_∘_) open import Relation.Binary.PropositionalEquality using (_≡_) ------------------------------------------------------------------------------ data _⊢∧_ : Ctxt → List PropFormula → Set where empty-intro : ∀ {Γ} → Γ ⊢∧ [] ∷-intro : ∀ {Γ} {φ} {L} → Γ ⊢ φ → Γ ⊢∧ L → Γ ⊢∧ (φ ∷ L) ∷-proj₁ : ∀ {Γ} {φ} {L} → Γ ⊢∧ (φ ∷ L) → Γ ⊢ φ ∷-proj₁ (∷-intro Γ⊢φ _) = Γ⊢φ ∷-proj₂ : ∀ {Γ} {φ} {L} → Γ ⊢∧ (φ ∷ L) → Γ ⊢∧ L ∷-proj₂ (∷-intro _ Γ⊢∧L) = Γ⊢∧L intro-thm : ∀ {Γ} {φ} → Γ ⊢ φ → Γ ⊢∧ [ φ ] intro-thm {Γ} {φ} Γ⊢φ = ∷-intro Γ⊢φ empty-intro ++-intro : ∀ {Γ} {L₁ L₂} → Γ ⊢∧ L₁ → Γ ⊢∧ L₂ → Γ ⊢∧ (L₁ ++ L₂) ++-intro empty-intro th2 = th2 ++-intro (∷-intro x th1) th2 = ∷-intro x (++-intro th1 th2) toList : PropFormula → List PropFormula toList φ with conj-view φ toList .(φ₁ ∧ φ₂) | conj φ₁ φ₂ = toList φ₁ ++ toList φ₂ toList φ | other .φ = [ φ ] ⊢-to-⊢∧ : ∀ {Γ} {φ} → Γ ⊢ φ → Γ ⊢∧ toList φ ⊢-to-⊢∧ {_} {φ} Γ⊢φ with conj-view φ ... | conj φ₁ φ₂ = ++-intro (⊢-to-⊢∧ (∧-proj₁ Γ⊢φ)) (⊢-to-⊢∧ (∧-proj₂ Γ⊢φ)) ... | other .φ = ∷-intro Γ⊢φ empty-intro toProp : List PropFormula → PropFormula toProp [] = ⊤ toProp (φ ∷ []) = φ toProp (φ ∷ L) = φ ∧ toProp L ⊢∧-to-⊢ : ∀ {Γ} {L} → Γ ⊢∧ L → Γ ⊢ toProp L ⊢∧-to-⊢ {_} {[]} _ = ⊤-intro ⊢∧-to-⊢ {_} {_ ∷ []} Γ⊢∧L = ∷-proj₁ Γ⊢∧L ⊢∧-to-⊢ {_} {x ∷ _ ∷ _} (∷-intro Γ⊢φ Γ⊢∧L) = ∧-intro Γ⊢φ (⊢∧-to-⊢ Γ⊢∧L) right-assoc-∧ : PropFormula → PropFormula right-assoc-∧ = toProp ∘ toList right-assoc-∧-lem : ∀ {Γ} {φ} → Γ ⊢ φ → Γ ⊢ right-assoc-∧ φ right-assoc-∧-lem = ⊢∧-to-⊢ ∘ ⊢-to-⊢∧ find-conjunct : List PropFormula → PropFormula → PropFormula find-conjunct [] x = ⊤ find-conjunct (x ∷ xs) y with ⌊ eq x y ⌋ ... | false = find-conjunct xs y ... | true = x find-conjunct-thm : ∀ {Γ} {L} → (ψ : PropFormula) → Γ ⊢∧ L → Γ ⊢ find-conjunct L ψ find-conjunct-thm {_} {[]} ψ Γ⊢∧L = ⊤-intro find-conjunct-thm {_} {x ∷ L} ψ Γ⊢∧L with ⌊ eq x ψ ⌋ find-conjunct-thm {_} {x ∷ L} ψ Γ⊢∧L | false with Γ⊢∧L find-conjunct-thm {_} {x ∷ L} ψ Γ⊢∧L | false | ∷-intro x₁ w = find-conjunct-thm ψ w find-conjunct-thm {_} {x ∷ L} ψ Γ⊢∧L | true = ∷-proj₁ Γ⊢∧L conjunct-thm : ∀ {Γ} {φ} → (ψ : PropFormula) → Γ ⊢ φ → Γ ⊢ find-conjunct (toList φ) ψ conjunct-thm {_} ψ Γ⊢φ = find-conjunct-thm ψ (⊢-to-⊢∧ Γ⊢φ) {- toWeak : (Γ : List PropFormula) (ψ : PropFormula) → List PropFormula toWeak t f = t , f , f strip : ∀ {Γ} {φ} → (ψ : PropFormula) → Γ ⊢ φ → (toWeak Γ ψ) ⊢ φ strip ψ Γ⊢φ = (weaken ψ (weaken ψ Γ⊢φ)) -- Bag Equivalance -- open import Data.Fin using (Fin; suc; zero; #_) -- open import Data.List using (length) -- infixl 3 _↔_ -- record _↔_(A B : Set) : Set where -- field -- to : A → B -- from : B → A -- from-to : ∀ x → from (to x) ≡ x -- to-from : ∀ x → to (from x) ≡ x -- lookup : (xs : List PropFormula) → Fin (length xs) → PropFormula -- lookup [] () -- lookup (x ∷ xs) zero = x -- lookup (x ∷ xs) (suc n) = lookup xs n -- record _≈Bag_(xs ys : List PropFormula) : Set where -- field -- bijection : Fin (length xs) ↔ Fin (length ys) -- related : ∀ i → lookup xs i ≡ lookup ys (_↔_.to bijection i) -- data _+_ (A B : Set) : Set where -- left : A → A + B -- right : B → A + B -- Any : (Prop → Set) → List PropFormula → Set -- Any P [] = ⊥₂ -- Any P (x ∷ xs) = P x + Any P xs -- infix 4 _∈₂_ -- _∈₂_ : PropFormula → List PropFormula → Set -- x ∈₂ xs = Any (λ y → x ≡ y) xs -- _≈Bag₂_ : List PropFormula → List PropFormula → Set -- xs ≈Bag₂ ys = ∀ x → x ∈₂ xs ↔ x ∈₂ ys -}
{ "alphanum_fraction": 0.4853078358, "avg_line_length": 25.9878787879, "ext": "agda", "hexsha": "2c14ba75daf2d4a2074a0b122430b24a0c387c7e", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2017-12-01T17:01:25.000Z", "max_forks_repo_forks_event_min_datetime": "2017-03-30T16:41:56.000Z", "max_forks_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jonaprieto/agda-prop", "max_forks_repo_path": "src/Data/PropFormula/ExperimentalSyntax.agda", "max_issues_count": 18, "max_issues_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_issues_repo_issues_event_max_datetime": "2017-12-18T16:34:21.000Z", "max_issues_repo_issues_event_min_datetime": "2017-03-08T14:33:10.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "jonaprieto/agda-prop", "max_issues_repo_path": "src/Data/PropFormula/ExperimentalSyntax.agda", "max_line_length": 85, "max_stars_count": 13, "max_stars_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jonaprieto/agda-prop", "max_stars_repo_path": "src/Data/PropFormula/ExperimentalSyntax.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T03:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2017-05-01T16:45:41.000Z", "num_tokens": 1852, "size": 4288 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Examples of printing list and vec-based tables ------------------------------------------------------------------------ {-# OPTIONS --safe --without-K #-} module README.Text.Tabular where open import Function.Base open import Relation.Binary.PropositionalEquality open import Data.List.Base open import Data.String.Base open import Data.Vec.Base open import Text.Tabular.Base import Text.Tabular.List as Tabularˡ import Text.Tabular.Vec as Tabularᵛ ------------------------------------------------------------------------ -- VEC -- -- If you have a matrix of strings, you simply need to: -- * pick a configuration (see below) -- * pick an alignment for each column -- * pass the matrix -- -- The display function will then pad each string on the left, right, -- or both to respect the alignment constraints. -- It will return a list of strings corresponding to each line in the -- table. You may then: --- * use Data.String.Base's unlines to produce a String -- * use Text.Pretty's text and vcat to produce a Doc (i.e. indentable!) ------------------------------------------------------------------------ _ : unlines (Tabularᵛ.display unicode (Right ∷ Left ∷ Center ∷ []) ( ("foo" ∷ "bar" ∷ "baz" ∷ []) ∷ ("1" ∷ "2" ∷ "3" ∷ []) ∷ ("6" ∷ "5" ∷ "4" ∷ []) ∷ [])) ≡ "┌───┬───┬───┐ \ \│foo│bar│baz│ \ \├───┼───┼───┤ \ \│ 1│2 │ 3 │ \ \├───┼───┼───┤ \ \│ 6│5 │ 4 │ \ \└───┴───┴───┘" _ = refl ------------------------------------------------------------------------ -- CONFIG -- -- Configurations allow you to change the way the table is displayed. ------------------------------------------------------------------------ -- We will use the same example throughout foobar : Vec (Vec String 2) 3 foobar = ("foo" ∷ "bar" ∷ []) ∷ ("1" ∷ "2" ∷ []) ∷ ("4" ∷ "3" ∷ []) ∷ [] ------------------------------------------------------------------------ -- Basic configurations: unicode, ascii, whitespace -- unicode _ : unlines (Tabularᵛ.display unicode (Right ∷ Left ∷ []) foobar) ≡ "┌───┬───┐ \ \│foo│bar│ \ \├───┼───┤ \ \│ 1│2 │ \ \├───┼───┤ \ \│ 4│3 │ \ \└───┴───┘" _ = refl -- ascii _ : unlines (Tabularᵛ.display ascii (Right ∷ Left ∷ []) foobar) ≡ "+-------+ \ \|foo|bar| \ \|---+---| \ \| 1|2 | \ \|---+---| \ \| 4|3 | \ \+-------+" _ = refl -- whitespace _ : unlines (Tabularᵛ.display whitespace (Right ∷ Left ∷ []) foobar) ≡ "foo bar \ \ 1 2 \ \ 4 3 " _ = refl ------------------------------------------------------------------------ -- Modifiers: altering existing configurations -- In these examples we will be using unicode as the base configuration. -- However these modifiers apply to all configurations (and can even be -- combined) -- compact: drop the horizontal line between each row _ : unlines (Tabularᵛ.display (compact unicode) (Right ∷ Left ∷ []) foobar) ≡ "┌───┬───┐ \ \│foo│bar│ \ \│ 1│2 │ \ \│ 4│3 │ \ \└───┴───┘" _ = refl -- noBorder: drop the outside borders _ : unlines (Tabularᵛ.display (noBorder unicode) (Right ∷ Left ∷ []) foobar) ≡ "foo│bar \ \───┼─── \ \ 1│2 \ \───┼─── \ \ 4│3 " _ = refl -- addSpace : add whitespace space inside cells _ : unlines (Tabularᵛ.display (addSpace unicode) (Right ∷ Left ∷ []) foobar) ≡ "┌─────┬─────┐ \ \│ foo │ bar │ \ \├─────┼─────┤ \ \│ 1 │ 2 │ \ \├─────┼─────┤ \ \│ 4 │ 3 │ \ \└─────┴─────┘" _ = refl -- compact together with addSpace _ : unlines (Tabularᵛ.display (compact (addSpace unicode)) (Right ∷ Left ∷ []) foobar) ≡ "┌─────┬─────┐ \ \│ foo │ bar │ \ \│ 1 │ 2 │ \ \│ 4 │ 3 │ \ \└─────┴─────┘" _ = refl ------------------------------------------------------------------------ -- LIST -- -- Same thing as for vectors except that if the list of lists is not -- rectangular, it is padded with empty strings to make it so. If there -- are not enough alignment directives, we arbitrarily pick Left. ------------------------------------------------------------------------ _ : unlines (Tabularˡ.display unicode (Center ∷ Right ∷ []) ( ("foo" ∷ "bar" ∷ []) ∷ ("partial" ∷ "rows" ∷ "are" ∷ "ok" ∷ []) ∷ ("3" ∷ "2" ∷ "1" ∷ "..." ∷ "surprise!" ∷ []) ∷ [])) ≡ "┌───────┬────┬───┬───┬─────────┐ \ \│ foo │ bar│ │ │ │ \ \├───────┼────┼───┼───┼─────────┤ \ \│partial│rows│are│ok │ │ \ \├───────┼────┼───┼───┼─────────┤ \ \│ 3 │ 2│1 │...│surprise!│ \ \└───────┴────┴───┴───┴─────────┘" _ = refl ------------------------------------------------------------------------ -- LIST (UNSAFE) -- -- If you know *for sure* that your data is already perfectly rectangular -- i.e. all the rows of the list of lists have the same length -- in each column, all the strings have the same width -- then you can use the unsafeDisplay function defined Text.Tabular.Base. -- -- This is what gets used internally by `Text.Tabular.Vec` and -- `Text.Tabular.List` once the potentially unsafe data has been -- processed. ------------------------------------------------------------------------ _ : unlines (unsafeDisplay (compact unicode) ( ("foo" ∷ "bar" ∷ []) ∷ (" 1" ∷ " 2" ∷ []) ∷ (" 4" ∷ " 3" ∷ []) ∷ [])) ≡ "┌───┬───┐ \ \│foo│bar│ \ \│ 1│ 2│ \ \│ 4│ 3│ \ \└───┴───┘" _ = refl
{ "alphanum_fraction": 0.4158328945, "avg_line_length": 26.7464788732, "ext": "agda", "hexsha": "edb0768f06f2da5d43973894b2ea64e7b22cb87f", "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/README/Text/Tabular.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/README/Text/Tabular.agda", "max_line_length": 74, "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/README/Text/Tabular.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": 1845, "size": 5697 }
{-# OPTIONS --without-K --safe #-} module Data.Vec.Iterated where open import Data.Unit.UniversePolymorphic open import Level open import Data.Nat.Base open import Function private variable n m : ℕ mutual Vec : Type a → ℕ → Type a Vec A zero = Vec⁰ Vec A (suc n) = Vec⁺ A n record Vec⁰ {a} : Type a where eta-equality constructor [] infixr 5 _∷_ record Vec⁺ {a} (A : Type a) (n : ℕ) : Type a where eta-equality inductive constructor _∷_ field head : A tail : Vec A n open Vec⁺ public foldr : ∀ {p} (P : ℕ → Type p) → (∀ {n} → A → P n → P (suc n)) → P zero → Vec A n → P n foldr {n = zero} P f b _ = b foldr {n = suc n} P f b (x ∷ xs) = f x (foldr P f b xs) foldl : ∀ {p} (P : ℕ → Type p) → (∀ {n} → A → P n → P (suc n)) → P zero → Vec A n → P n foldl {n = zero } P f b _ = b foldl {n = suc n} P f b (x ∷ xs) = foldl (P ∘ suc) f (f x b) xs foldlN : ∀ {p} (P : ℕ → Type p) → (∀ {n} → A → P (suc n) → P n) → P n → Vec A n → P zero foldlN P f b xs = foldr (λ n → P n → P zero) (λ x k xs → k (f x xs)) id xs b module _ (f : A → B → B) (e : B) where foldr′ : Vec A n → B foldr′ {n = zero } xs = e foldr′ {n = suc n} (x ∷ xs) = f x (foldr′ xs) foldl′ : (A → B → B) → B → Vec A n → B foldl′ {n = zero} f b xs = b foldl′ {n = suc n} f b (x ∷ xs) = foldl′ f (f x b) xs -- vecFromList : (xs : List A) → Vec A (length xs) -- vecFromList List.[] = [] -- vecFromList (x List.∷ xs) = x ∷ vecFromList xs -- vecToList : Vec A n → List A -- vecToList = foldr′ List._∷_ List.[] open import Data.Fin.Indexed infixl 4 lookup lookup : Fin n → Vec A n → A lookup f0 = head lookup (fs i) xs = lookup i (tail xs) syntax lookup i xs = xs [ i ] infixl 4 replace replace : Fin n → A → Vec A n → Vec A n replace f0 x xs .head = x replace f0 x xs .tail = xs .tail replace (fs i) x xs .head = xs .head replace (fs i) x xs .tail = replace i x (xs .tail) syntax replace i x xs = xs [ i ]≔ x
{ "alphanum_fraction": 0.5228821811, "avg_line_length": 23.6091954023, "ext": "agda", "hexsha": "0d57c9422e7a15f5d563e0211aa00bb06827b162", "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/Vec/Iterated.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/Vec/Iterated.agda", "max_line_length": 76, "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/Vec/Iterated.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": 815, "size": 2054 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Dependent product combinators for propositional equality -- preserving functions ------------------------------------------------------------------------ {-# OPTIONS --with-K --safe #-} module Data.Product.Function.Dependent.Propositional.WithK where open import Data.Product open import Data.Product.Function.Dependent.Setoid open import Data.Product.Relation.Binary.Pointwise.Dependent open import Data.Product.Relation.Binary.Pointwise.Dependent.WithK open import Function.Equality using (_⟨$⟩_) open import Function.Injection as Inj using (_↣_; module Injection) open import Function.Inverse as Inv using (_↔_; module Inverse) import Relation.Binary.HeterogeneousEquality as H ------------------------------------------------------------------------ -- Combinator for Injection module _ {a₁ a₂} {A₁ : Set a₁} {A₂ : Set a₂} {b₁ b₂} {B₁ : A₁ → Set b₁} {B₂ : A₂ → Set b₂} where ↣ : ∀ (A₁↣A₂ : A₁ ↣ A₂) → (∀ {x} → B₁ x ↣ B₂ (Injection.to A₁↣A₂ ⟨$⟩ x)) → Σ A₁ B₁ ↣ Σ A₂ B₂ ↣ A₁↣A₂ B₁↣B₂ = Inverse.injection Pointwise-≡↔≡ ⟨∘⟩ injection (H.indexedSetoid B₂) A₁↣A₂ (Inverse.injection (H.≡↔≅ B₂) ⟨∘⟩ B₁↣B₂ ⟨∘⟩ Inverse.injection (Inv.sym (H.≡↔≅ B₁))) ⟨∘⟩ Inverse.injection (Inv.sym Pointwise-≡↔≡) where open Inj using () renaming (_∘_ to _⟨∘⟩_)
{ "alphanum_fraction": 0.5678144765, "avg_line_length": 36.4871794872, "ext": "agda", "hexsha": "0b3838e12fd78adcab5f30797e826f529601ec05", "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/Data/Product/Function/Dependent/Propositional/WithK.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/Product/Function/Dependent/Propositional/WithK.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/Data/Product/Function/Dependent/Propositional/WithK.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": 430, "size": 1423 }
open import Data.List open import Data.Unit open import Relation.Unary hiding (_∈_) open import Relation.Unary.PredicateTransformer using (Pt) open import Relation.Ternary.Separation open import Relation.Ternary.Separation.Construct.Market open import Relation.Ternary.Separation.Monad open import Relation.Ternary.Separation.Morphisms module Relation.Ternary.Separation.Monad.State.Heap {ℓ} -- value types {T : Set ℓ} -- stored values (V : T → Pred (List T) ℓ) where open import Level hiding (Lift) open import Function using (_∘_; case_of_) import Relation.Binary.HeterogeneousEquality as HEq open import Relation.Unary.PredicateTransformer hiding (_⊔_; [_]) open import Relation.Binary.PropositionalEquality using (refl; _≡_) open import Relation.Ternary.Separation.Construct.Product open import Relation.Ternary.Separation.Construct.List T open import Relation.Ternary.Separation.Morphisms open import Relation.Ternary.Separation.Monad open import Relation.Ternary.Separation.Allstar open import Data.Product open import Data.List.Relation.Ternary.Interleaving.Propositional as I module HeapOps -- inner monad (M : Pt (Market (List T)) ℓ) {{monad : Monads.Monad ⊤ ℓ (λ _ _ → M) }} where Cells : Pred (List T × List T) ℓ Cells (Σ , Φ) = Allstar V Σ Φ open import Relation.Ternary.Separation.Monad.State open StateTransformer M public open Monads using (str) open Monads.Monad {{...}} -- Creating a reference to a new cell, filled with a given value. -- Note that in the market monoid this is pure! -- Because we get a reference that consumes the freshly created resource. newref : ∀ {a} → ∀[ V a ⇒ StateT M Cells (Just a) ] app (newref v) (lift st σ₁) (offerᵣ σ₂) = let _ , τ₁ , τ₂ = ⊎-assoc (⊎-comm σ₂) σ₁ in return ( inj refl ×⟨ offerᵣ ⊎-∙ ⟩ lift (cons (v ×⟨ τ₂ ⟩ st)) (⊎-∙ₗ τ₁)) -- A linear read on a store: you lose the reference. -- This is pure, because with the reference being lost, the cell is destroyed: no resources leak. read : ∀ {a} → ∀[ Just a ⇒ StateT M Cells (V a) ] app (read refl) (lift st σ₁) (offerᵣ σ₂) with ⊎-assoc σ₂ σ₁ ... | _ , σ₃ , σ₄ with repartition σ₃ st ... | cons (v ×⟨ σ₅ ⟩ nil) ×⟨ σ₆ ⟩ st' with ⊎-id⁻ʳ σ₅ | ⊎-assoc (⊎-comm σ₆) (⊎-comm σ₄) ... | refl | _ , τ₁ , τ₂ = return (inj v ×⟨ offerᵣ τ₂ ⟩ lift st' (⊎-comm τ₁)) -- Writing into a cell, returning the current contents write : ∀ {a b} → ∀[ Just b ✴ (V a) ⇒ StateT M Cells (Just a ✴ V b) ] app (write (refl ×⟨ σ₁ ⟩ v)) (lift st σ₂) (offerᵣ σ₃) with ⊎-assoc (⊎-comm σ₁) σ₃ -- first we reassociate the arguments in the order that we want to piece it back together ... | _ , τ₁ , τ₂ with ⊎-assoc (⊎-comm τ₁) σ₂ ... | _ , τ₃ , τ₄ with ⊎-assoc τ₂ τ₃ ... | _ , τ₅ , τ₆ -- then we reorganize the store internally to take out the unit value with repartition τ₅ st ... | cons (vb ×⟨ σ₅ ⟩ nil) ×⟨ σ₆ ⟩ st' rewrite ⊎-id⁻ʳ σ₅ = let _ , κ₁ , κ₂ = ⊎-unassoc τ₄ (⊎-comm σ₆) _ , κ₃ , κ₄ = ⊎-assoc κ₂ (⊎-comm τ₆) in return ( inj (refl ×⟨ consˡ ⊎-idˡ ⟩ vb) ×⟨ offerᵣ (consˡ κ₄) ⟩ lift (cons (v ×⟨ κ₁ ⟩ st')) (⊎-∙ₗ (⊎-comm κ₃))) -- A linear (strong) update on the store update! : ∀ {a b} → ∀[ Just a ⇒ (V a ─✴ StateT M Cells (V b)) ─✴ StateT M Cells (Just b) ] app (update! ptr) f σ = do a ×⟨ σ₁ ⟩ f ← read ptr &⟨ σ ⟩ f b ← app f a (⊎-comm σ₁) newref b
{ "alphanum_fraction": 0.643442623, "avg_line_length": 37.5384615385, "ext": "agda", "hexsha": "227a5b13dd7f25afe79aca4e4402cc7814faef67", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2020-05-23T00:34:36.000Z", "max_forks_repo_forks_event_min_datetime": "2020-01-30T14:15:14.000Z", "max_forks_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "laMudri/linear.agda", "max_forks_repo_path": "src/Relation/Ternary/Separation/Monad/State/Heap.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0", "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": "laMudri/linear.agda", "max_issues_repo_path": "src/Relation/Ternary/Separation/Monad/State/Heap.agda", "max_line_length": 99, "max_stars_count": 34, "max_stars_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "laMudri/linear.agda", "max_stars_repo_path": "src/Relation/Ternary/Separation/Monad/State/Heap.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-03T15:22:33.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-20T13:57:50.000Z", "num_tokens": 1263, "size": 3416 }
module STLC.Type.Context where open import STLC.Type as Type using (Type) open Type.Substitution using () renaming (_⊙_ to _⊙τ_; _/_ to _/τ_; wk to wk-τ) open import Data.Nat using (ℕ; _+_) open import Data.Fin using (Fin; zero; suc) open import Data.Fin.Substitution open import Data.Vec using (Vec; []; _∷_; map; lookup) open import Data.Vec.Properties using (map-∘; map-cong; lookup-map) open import Relation.Binary.PropositionalEquality as Eq using (refl; _≡_; sym; cong) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎) -- -------------------------------------------------------------------- -- Typing Contexts -- -------------------------------------------------------------------- -- A typing context Γ is the mapping from free term variables to -- types. A context Γ m n maps m term variables to tyhpes containing -- n type variables. Ctxt : ℕ -> ℕ -> Set Ctxt m n = Vec (Type n) m -- -------------------------------------------------------------------- module Substitution where infixl 8 _/_ _/Var_ -- Type substitutions lifted to typing contexts _/_ : ∀ { m n p } -> Ctxt m n -> Sub Type n p -> Ctxt m p Γ / ρ = Γ ⊙τ ρ -- Weakening of typing contexts weaken : ∀ { m n } -> Ctxt m n -> Ctxt m (1 + n) weaken Γ = map Type.Substitution.weaken Γ -- Term variable substitution _/Var_ : ∀ { m n p } -> Sub Fin m n -> Ctxt n p -> Ctxt m p θ /Var Γ = map (lookup Γ) θ module Lemmas where open Substitution private module Lemmas-τ = Type.Lemmas -- /Var and / commute /Var-/-comm : ∀ { m n p q } (Γ : Ctxt p n) (θ : Sub Fin m p) (ρ : Sub Type n q) -> (θ /Var Γ) / ρ ≡ θ /Var (Γ / ρ) /Var-/-comm Γ θ ρ = begin (θ /Var Γ) / ρ ≡⟨ sym (map-∘ _ _ θ) ⟩ map (λ x -> (lookup Γ x) /τ ρ) θ ≡⟨ map-cong (λ x → sym (Lemmas-τ.lookup-⊙ x {ρ₁ = Γ})) θ ⟩ map (λ x -> lookup (Γ / ρ) x) θ ∎ -- /Var and weaken commute /Var-weaken-comm : ∀ { m n p } (θ : Sub Fin m p) (Γ : Ctxt p n) -> weaken (θ /Var Γ) ≡ θ /Var (weaken Γ) /Var-weaken-comm θ Γ = begin weaken (θ /Var Γ) ≡⟨ Lemmas-τ.map-weaken ⟩ (θ /Var Γ) / wk-τ ≡⟨ /Var-/-comm Γ θ wk-τ ⟩ θ /Var (Γ / wk-τ) ≡⟨ sym (cong (λ Γ -> θ /Var Γ) (Lemmas-τ.map-weaken {ρ = Γ})) ⟩ θ /Var (weaken Γ) ∎ -- /Var and lookup commute /Var-lookup-comm : ∀ { m n p } (x : Fin m) (θ : Sub Fin m p) (Γ : Ctxt p n) -> lookup (θ /Var Γ) x ≡ lookup Γ (lookup θ x) /Var-lookup-comm x θ Γ = begin lookup (θ /Var Γ) x ≡⟨⟩ lookup (map (lookup Γ) θ) x ≡⟨ lookup-map x (lookup Γ) θ ⟩ lookup Γ (lookup θ x) ∎ /Var-∷-comm : ∀ { m n p } (τ : Type n) (θ : Sub Fin m p) (Γ : Ctxt p n) -> τ ∷ (θ /Var Γ) ≡ (θ VarSubst.↑) /Var (τ ∷ Γ) /Var-∷-comm τ [] Γ = refl /Var-∷-comm τ (x ∷ θ) Γ = begin τ ∷ ((x ∷ θ) /Var Γ) ≡⟨⟩ τ ∷ (lookup Γ x) ∷ (θ /Var Γ) ≡⟨ cong (λ Γ' -> τ ∷ (lookup Γ x) ∷ Γ') lemma ⟩ τ ∷ (lookup Γ x) ∷ map (lookup (τ ∷ Γ)) (map suc θ) ≡⟨⟩ map (lookup (τ ∷ Γ)) (zero ∷ suc x ∷ map suc θ) ≡⟨⟩ ((x ∷ θ) VarSubst.↑) /Var (τ ∷ Γ) ∎ where lemma = begin θ /Var Γ ≡⟨⟩ map (lookup Γ) θ ≡⟨⟩ map (λ x -> lookup (τ ∷ Γ) (suc x)) θ ≡⟨ map-∘ _ _ θ ⟩ map (lookup (τ ∷ Γ)) (map suc θ) ∎ -- invariant on renaming of id /Var-id-inv : ∀ { m n } (Γ : Ctxt m n) -> Γ ≡ (VarSubst.id /Var Γ) /Var-id-inv [] = refl /Var-id-inv (τ ∷ Γ) = begin τ ∷ Γ ≡⟨ cong (λ Γ -> τ ∷ Γ) (/Var-id-inv Γ) ⟩ τ ∷ (VarSubst.id /Var Γ) ≡⟨ /Var-∷-comm τ VarSubst.id Γ ⟩ (VarSubst.id VarSubst.↑) /Var (τ ∷ Γ) ≡⟨⟩ VarSubst.id /Var (τ ∷ Γ) ∎ -- invariant on adding additional types, also known as the weakening lemma /Var-wk-inv : ∀ { m n } (Γ : Ctxt m n) -> (τ : Type n) -> Γ ≡ (VarSubst.wk /Var (τ ∷ Γ)) /Var-wk-inv Γ τ = begin Γ ≡⟨ /Var-id-inv Γ ⟩ VarSubst.id /Var Γ ≡⟨ map-∘ _ _ VarSubst.id ⟩ VarSubst.wk /Var (τ ∷ Γ) ∎
{ "alphanum_fraction": 0.4865598027, "avg_line_length": 27.9655172414, "ext": "agda", "hexsha": "4051d660e9b2cc07a56122db3a2e0bd3959cbccc", "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": "aeb2be63381d891fabe5317e3c27553deb6bca6d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "johnyob/agda-types", "max_forks_repo_path": "src/STLC/Type/Context.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aeb2be63381d891fabe5317e3c27553deb6bca6d", "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": "johnyob/agda-types", "max_issues_repo_path": "src/STLC/Type/Context.agda", "max_line_length": 90, "max_stars_count": null, "max_stars_repo_head_hexsha": "aeb2be63381d891fabe5317e3c27553deb6bca6d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "johnyob/agda-types", "max_stars_repo_path": "src/STLC/Type/Context.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1626, "size": 4055 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.Polynomials.Multivariate.EquivCarac.An[Am[X]]-Anm[X] where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.HLevels open import Cubical.Data.Nat using (ℕ) renaming (_+_ to _+n_) open import Cubical.Data.Vec open import Cubical.Data.Vec.OperationsNat open import Cubical.Data.Sigma open import Cubical.Algebra.DirectSum.DirectSumHIT.Base open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.Instances.Polynomials.MultivariatePoly private variable ℓ ℓ' : Level module Comp-Poly-nm (Acr@(A , Astr) : CommRing ℓ) (n m : ℕ) where private PAm = PolyCommRing Acr m PAn+m = PolyCommRing Acr (n +n m) PAmn = PolyCommRing (PolyCommRing Acr m) n open CommRingStr ----------------------------------------------------------------------------- -- direct sens PAmn→PAn+m-base : (v : Vec ℕ n) → Poly Acr m → Poly Acr (n +n m) PAmn→PAn+m-base v = DS-Rec-Set.f _ _ _ _ trunc (0r (snd PAn+m)) (λ v' a → base (v ++ v') a) (_+_ (snd PAn+m)) (+Assoc (snd PAn+m)) (+IdR (snd PAn+m)) (+Comm (snd PAn+m)) (λ v' → base-neutral (v ++ v')) (λ v' a b → base-add (v ++ v') a b) PAmn→PAn+m : Poly (PolyCommRing Acr m) n → Poly Acr (n +n m) PAmn→PAn+m = DS-Rec-Set.f _ _ _ _ trunc (0r (snd PAn+m)) PAmn→PAn+m-base (_+_ (snd PAn+m)) (+Assoc (snd PAn+m)) (+IdR (snd PAn+m)) (+Comm (snd PAn+m)) (λ _ → refl) λ _ _ _ → refl ----------------------------------------------------------------------------- -- Converse sens PAn+m→PAmn : Poly Acr (n +n m) → Poly (PolyCommRing Acr m) n PAn+m→PAmn = DS-Rec-Set.f _ _ _ _ trunc (0r (snd PAmn)) (λ v a → base (fst (sep-vec n m v)) (base (snd (sep-vec n m v)) a)) (_+_ (snd PAmn)) (+Assoc (snd PAmn)) (+IdR (snd PAmn)) (+Comm (snd PAmn)) (λ v → (cong (base (fst (sep-vec n m v))) (base-neutral _)) ∙ (base-neutral _)) λ v a b → base-add _ _ _ ∙ cong (base (fst (sep-vec n m v))) (base-add _ _ _) ----------------------------------------------------------------------------- -- Section e-sect : (P : Poly Acr (n +n m)) → PAmn→PAn+m (PAn+m→PAmn P) ≡ P e-sect = DS-Ind-Prop.f _ _ _ _ (λ _ → trunc _ _) refl (λ v a → cong (λ X → base X a) (sep-vec-id n m v)) (λ {U V} ind-U ind-V → cong₂ (_+_ (snd PAn+m)) ind-U ind-V) ----------------------------------------------------------------------------- -- Retraction e-retr : (P : Poly (PolyCommRing Acr m) n) → PAn+m→PAmn (PAmn→PAn+m P) ≡ P e-retr = DS-Ind-Prop.f _ _ _ _ (λ _ → trunc _ _) refl (λ v → DS-Ind-Prop.f _ _ _ _ (λ _ → trunc _ _) (sym (base-neutral _)) (λ v' a → cong₂ base (sep-vec-fst n m v v') (cong (λ X → base X a) (sep-vec-snd n m v v'))) λ {U V} ind-U ind-V → (cong₂ (_+_ (snd PAmn)) ind-U ind-V) ∙ (base-add _ _ _)) (λ {U V} ind-U ind-V → cong₂ (_+_ (snd PAmn)) ind-U ind-V) ----------------------------------------------------------------------------- -- Morphism of ring PAmn→PAn+m-pres1 : PAmn→PAn+m (1r (snd PAmn)) ≡ 1r (snd PAn+m) PAmn→PAn+m-pres1 = cong (λ X → base X (1r Astr)) (rep-concat n m 0 ) PAmn→PAn+m-pres+ : (P Q : Poly (PolyCommRing Acr m) n) → PAmn→PAn+m (snd PAmn ._+_ P Q) ≡ snd PAn+m ._+_ (PAmn→PAn+m P) (PAmn→PAn+m Q) PAmn→PAn+m-pres+ = λ _ _ → refl PAmn→PAn+m-pres· : (P Q : Poly (PolyCommRing Acr m) n) → PAmn→PAn+m ( snd PAmn ._·_ P Q) ≡ snd PAn+m ._·_ (PAmn→PAn+m P) (PAmn→PAn+m Q) PAmn→PAn+m-pres· = DS-Ind-Prop.f _ _ _ _ (λ _ → isPropΠ (λ _ → trunc _ _)) (λ Q → refl) (λ v → DS-Ind-Prop.f _ _ _ _ (λ _ → isPropΠ (λ _ → trunc _ _)) (λ Q → cong (λ X → PAmn→PAn+m (snd PAmn ._·_ X Q)) (base-neutral v)) (λ v' a → DS-Ind-Prop.f _ _ _ _ (λ _ → trunc _ _) refl (λ w → DS-Ind-Prop.f _ _ _ _ (λ _ → trunc _ _) refl (λ w' b → cong (λ X → base X (Astr ._·_ a b)) (+n-vec-concat _ _ _ _ _ _)) λ {U V} ind-U ind-V → cong (λ X → PAmn→PAn+m (snd PAmn ._·_ (base v (base v' a)) X)) (sym (base-add _ _ _)) ∙ cong₂ (snd PAn+m ._+_) ind-U ind-V ∙ sym (cong (λ X → snd PAn+m ._·_ (PAmn→PAn+m (base v (base v' a))) (PAmn→PAn+m X)) (base-add _ _ _))) λ {U V} ind-U ind-V → cong₂ (snd PAn+m ._+_) ind-U ind-V) λ {U V} ind-U ind-V Q → cong (λ X → PAmn→PAn+m (snd PAmn ._·_ X Q)) (sym (base-add _ _ _)) ∙ cong₂ (snd PAn+m ._+_) (ind-U Q) (ind-V Q) ∙ sym (cong (λ X → snd PAn+m ._·_ (PAmn→PAn+m X) (PAmn→PAn+m Q)) (base-add _ _ _))) λ {U V} ind-U ind-V Q → cong₂ (_+_ (snd PAn+m)) (ind-U Q) (ind-V Q) ----------------------------------------------------------------------------- -- Ring Equivalence module _ (A' : CommRing ℓ) (n m : ℕ) where open Comp-Poly-nm A' n m CRE-PolyN∘M-PolyN+M : CommRingEquiv (PolyCommRing (PolyCommRing A' m) n) (PolyCommRing A' (n +n m)) fst CRE-PolyN∘M-PolyN+M = isoToEquiv is where is : Iso _ _ Iso.fun is = PAmn→PAn+m Iso.inv is = PAn+m→PAmn Iso.rightInv is = e-sect Iso.leftInv is = e-retr snd CRE-PolyN∘M-PolyN+M = makeIsRingHom PAmn→PAn+m-pres1 PAmn→PAn+m-pres+ PAmn→PAn+m-pres·
{ "alphanum_fraction": 0.4469463794, "avg_line_length": 41.9931972789, "ext": "agda", "hexsha": "e18e8cff82ba520c725a3d3bce74c9f5355eb99e", "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/Polynomials/Multivariate/EquivCarac/An[Am[X]]-Anm[X].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/Polynomials/Multivariate/EquivCarac/An[Am[X]]-Anm[X].agda", "max_line_length": 121, "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/Polynomials/Multivariate/EquivCarac/An[Am[X]]-Anm[X].agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2017, "size": 6173 }
module Foundation where infix -65536 ℞_ ℞_ : ∀ ℓ → Set _ ℞_ ℓ = Set ℓ id : ∀ {ℓ} {A : ℞ ℓ} → A → A id x = x Op₀ : ∀ {ℓ} → ℞ ℓ → ℞ ℓ Op₀ = id Op₁ : ∀ {a} → ℞ a → ℞ a Op₁ A = A → Op₀ A Op₂ : ∀ {a} (A : ℞ a) → ℞ a Op₂ A = A → Op₁ A record ♩Op₀ {a} (A : ℞ a) : ℞ a where field 𝟘 : Op₀ A record ♩Op₁ {a} (A : ℞ a) : ℞ a where infixr 65536 ¡_ field ¡_ : Op₁ A record ♩Op₂ {a} (A : ℞ a) : ℞ a where infixl 0 _∙_ field _∙_ : Op₂ A open ♩Op₀ ⦃ … ⦄ public open ♩Op₁ ⦃ … ⦄ public open ♩Op₂ ⦃ … ⦄ public instance Set₀♩Op₀=Level : ♩Op₀ Set₀ Set₀♩Op₀=Level = record { 𝟘 = Level } where open import Agda.Primitive instance Set₀♩Op₀=Nat : ♩Op₀ _ ♩Op₀.𝟘 Set₀♩Op₀=Nat = Nat where open import Agda.Builtin.Nat instance Nat♩Op₁=successor : ♩Op₁ 𝟘 ♩Op₁.¡_ Nat♩Op₁=successor = suc where open import Agda.Builtin.Nat instance zero♩Op₀Nat : ♩Op₀ 𝟘 ♩Op₀.𝟘 zero♩Op₀Nat = zero where open import Agda.Builtin.Nat instance Level♩Op₀ : ♩Op₀ 𝟘 ♩Op₀.𝟘 Level♩Op₀ = lzero where open import Agda.Primitive instance Level♩Op₁ : ♩Op₁ _ ♩Op₁.¡_ Level♩Op₁ = lsuc where open import Agda.Primitive instance Level♩Op₂ : ♩Op₂ 𝟘 ♩Op₂._∙_ Level♩Op₂ = _⊔_ where open import Agda.Primitive _℞_ : ∀ {a} (A : ℞ a) → ∀ ℓ → ℞ _ _℞_ A ℓ = A → ℞ ℓ _₂℞_ : ∀ {a} (A : ℞ a) → ∀ ℓ → ℞ _ _₂℞_ A ℓ = A → A ℞ ℓ record IsReflexive {a} {A : ℞ a} {ℓ} (_∼_ : A ₂℞ ℓ) : ℞ a ∙ ℓ where field reflexive : ∀ {x} → x ∼ x open IsReflexive ⦃ … ⦄ record IsSymmetric {a} {A : ℞ a} {ℓ} (_∼_ : A ₂℞ ℓ) : ℞ a ∙ ℓ where field symmetric : ∀ {x} {y} → x ∼ y → y ∼ x open IsSymmetric ⦃ … ⦄ record IsTransitive {a} {A : ℞ a} {ℓ} (_∼_ : A ₂℞ ℓ) : ℞ a ∙ ℓ where field transitive : ∀ {x} {y} {z} → x ∼ y → y ∼ z → x ∼ z open IsTransitive ⦃ … ⦄ record IsEquivalence {a} {A : ℞ a} {ℓ} (_≈_ : A ₂℞ ℓ) : ℞ a ∙ ℓ where field overlap ⦃ reflexive ⦄ : IsReflexive _≈_ overlap ⦃ symmetric ⦄ : IsSymmetric _≈_ overlap ⦃ transitive ⦄ : IsTransitive _≈_ open IsEquivalence ⦃ … ⦄ open import Agda.Primitive record Equivalence {a} (A : ℞ a) ℓ : ℞ (a ∙ ¡ ℓ) where infix 4 _≈_ field _≈_ : A ₂℞ ℓ isEquivalence : IsEquivalence _≈_ open Equivalence ⦃ … ⦄ record IsAssociative {a} {A : ℞ a} (_∘_ : Op₂ A) {ℓ} (_≈_ : A ₂℞ ℓ) : ℞ a ∙ ¡ ℓ where field associative : ∀ x y z → (x ∘ (y ∘ z)) ≈ ((x ∘ y) ∘ z) open IsAssociative ⦃ … ⦄ import Relation.Binary.Core as R record ⟦_Preserves₂_⟶_⟶_⟧ {a b c ℓ₁ ℓ₂ ℓ₃} {A : ℞ a} {B : ℞ b} {C : ℞ c} (_+_ : A → B → C) (P : R.Rel A ℓ₁) (Q : R.Rel B ℓ₂) (R : R.Rel C ℓ₃) : ℞ a ∙ b ∙ ℓ₁ ∙ ℓ₂ ∙ ℓ₃ where field _⟶_ : ∀ {x y u v} → P x y → Q u v → R (x + u) (y + v) open ⟦_Preserves₂_⟶_⟶_⟧ ⦃ … ⦄ record Cong₂ a b c (P : ∀ {x} {X : Set x} → X → X → Set (a ∙ x)) : ℞ ¡ a ∙ ¡ b ∙ ¡ c where field cong₂ : {A : ℞ a} {B : ℞ b} {C : ℞ c} (_+_ : A → B → C) → ∀ {x y u v} → P x y → P u v → P (x + u) (y + v) open Cong₂ ⦃ … ⦄ open import Prelude.Function using (_∘_; _∘′_) open import Level --instance Cong₂≡ : ∀ {a b c} → Cong₂ a b c (λ x₁ x₂ → Lift (x₁ R.≡ x₂)) -- R._≡_ --Cong₂≡ = {!!} --Cong₂.cong₂ Cong₂≡ _+_ R.refl R.refl = R.refl record Semigroup {a} (A : ℞ a) ℓ : ℞ a ∙ ¡ ℓ where field _⁀_ : Op₂ A overlap ⦃ equivalence ⦄ : Equivalence A ℓ ⦃ isAssociative ⦄ : IsAssociative _⁀_ _≈_ ⦃ ∙-cong ⦄ : ⟦ _⁀_ Preserves₂ _≈_ ⟶ _≈_ ⟶ _≈_ ⟧ open Semigroup ⦃ … ⦄ record IdentityElement {a} (A : ℞ a) : ℞ a where field ε : A open IdentityElement ⦃ … ⦄ record IsLeftIdentity {a} {A : ℞ a} ℓ (ε : A) (_∘_ : Op₂ A) : ℞ ¡ ℓ ∙ a where field overlap ⦃ equivalence ⦄ : Equivalence A ℓ left-identity : ∀ x → ε ∘ x ≈ x open IsLeftIdentity ⦃ … ⦄ record IsRightIdentity {a} {A : ℞ a} ℓ (ε : A) (_∘_ : Op₂ A) : ℞ ¡ ℓ ∙ a where field overlap ⦃ equivalence ⦄ : Equivalence A ℓ right-identity : ∀ x → x ∘ ε ≈ x open IsRightIdentity ⦃ … ⦄ record IsIdentity {a} {A : ℞ a} ℓ (ε : A) (_∘_ : Op₂ A) : ℞ ¡ ℓ ∙ a where field ⦃ isLeftIdentity ⦄ : IsLeftIdentity ℓ ε _∘_ ⦃ isRightIdentity ⦄ : IsRightIdentity ℓ ε _∘_ open IsIdentity ⦃ … ⦄ record IsMonoid {a} (A : ℞ a) (ε : A) ℓ : ℞ a ∙ ¡ ℓ where field ⦃ semigroup ⦄ : Semigroup A ℓ ⦃ isIdentity ⦄ : IsIdentity ℓ ε _⁀_ open IsMonoid ⦃ … ⦄ record Monoid {a} (A : ℞ a) ℓ : ℞ a ∙ ¡ ℓ where field ⦃ identityElement ⦄ : IdentityElement A ⦃ isMonoid ⦄ : IsMonoid A ε ℓ open Monoid ⦃ … ⦄ foo : (A : Set) ⦃ _ : Monoid A Level.zero ⦄ → (x : A) → (x ⁀ ε) ≈ x foo A ⦃ m ⦄ x₁ = right-identity {zero} {{!!}} {{!!}} {{!!}} {{!!}} ⦃ isRightIdentity {{!!}} {{!!}} {{!!}} {{!!}} {{!!}} ⦄ x₁
{ "alphanum_fraction": 0.5346077785, "avg_line_length": 25.0054945055, "ext": "agda", "hexsha": "2719ba1294e2b5eb6bc31d4a6dc2303c29a8c838", "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-1/Foundation.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-1/Foundation.agda", "max_line_length": 126, "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-1/Foundation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2285, "size": 4551 }
{-# OPTIONS --without-K --safe #-} module Dodo.Nullary.Unique where -- Stdlib imports import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_) open import Level using (Level) -- # Definitions Unique : ∀ {a : Level} (A : Set a) → Set _ Unique A = ∀ (x y : A) → x ≡ y
{ "alphanum_fraction": 0.6561403509, "avg_line_length": 19, "ext": "agda", "hexsha": "28421984db128b172b9fad95eee3a73a45cee5d7", "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": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "sourcedennis/agda-dodo", "max_forks_repo_path": "src/Dodo/Nullary/Unique.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "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": "sourcedennis/agda-dodo", "max_issues_repo_path": "src/Dodo/Nullary/Unique.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "sourcedennis/agda-dodo", "max_stars_repo_path": "src/Dodo/Nullary/Unique.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 82, "size": 285 }
{- This second-order term syntax was created from the following second-order syntax description: $sig_string -} module ${syn_name}.Syntax where open import SOAS.Common open import SOAS.Context open import SOAS.Variable open import SOAS.Families.Core open import SOAS.Construction.Structure open import SOAS.ContextMaps.Inductive open import SOAS.Metatheory.Syntax open import ${syn_name}.Signature private variable Γ Δ Π : Ctx $ty_vars : $type 𝔛 : Familyₛ -- Inductive term declaration module ${sig}:Terms (𝔛 : Familyₛ) where data ${sig} : Familyₛ where var : ℐ ⇾̣ ${sig} mvar : 𝔛 $fst_ty_var Π → Sub ${sig} Π Γ → ${sig} $fst_ty_var Γ $syn_constructors $op_fixity open import SOAS.Metatheory.MetaAlgebra ⅀F 𝔛 ${sig}ᵃ : MetaAlg ${sig} ${sig}ᵃ = record { 𝑎𝑙𝑔 = λ where $alg_patterns ; 𝑣𝑎𝑟 = var ; 𝑚𝑣𝑎𝑟 = λ 𝔪 mε → mvar 𝔪 (tabulate mε) } module ${sig}ᵃ = MetaAlg ${sig}ᵃ module _ {𝒜 : Familyₛ}(𝒜ᵃ : MetaAlg 𝒜) where open MetaAlg 𝒜ᵃ 𝕤𝕖𝕞 : ${sig} ⇾̣ 𝒜 𝕊 : Sub ${sig} Π Γ → Π ~[ 𝒜 ]↝ Γ 𝕊 (t ◂ σ) new = 𝕤𝕖𝕞 t 𝕊 (t ◂ σ) (old v) = 𝕊 σ v 𝕤𝕖𝕞 (mvar 𝔪 mε) = 𝑚𝑣𝑎𝑟 𝔪 (𝕊 mε) 𝕤𝕖𝕞 (var v) = 𝑣𝑎𝑟 v $sem_patterns 𝕤𝕖𝕞ᵃ⇒ : MetaAlg⇒ ${sig}ᵃ 𝒜ᵃ 𝕤𝕖𝕞 𝕤𝕖𝕞ᵃ⇒ = record { ⟨𝑎𝑙𝑔⟩ = λ{ {t = t} → ⟨𝑎𝑙𝑔⟩ t } ; ⟨𝑣𝑎𝑟⟩ = refl ; ⟨𝑚𝑣𝑎𝑟⟩ = λ{ {𝔪 = 𝔪}{mε} → cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-tab mε)) } } where open ≡-Reasoning ⟨𝑎𝑙𝑔⟩ : (t : ⅀ ${sig} $fst_ty_var Γ) → 𝕤𝕖𝕞 (${sig}ᵃ.𝑎𝑙𝑔 t) ≡ 𝑎𝑙𝑔 (⅀₁ 𝕤𝕖𝕞 t) $alg_hom_patterns 𝕊-tab : (mε : Π ~[ ${sig} ]↝ Γ)(v : ℐ α Π) → 𝕊 (tabulate mε) v ≡ 𝕤𝕖𝕞 (mε v) 𝕊-tab mε new = refl 𝕊-tab mε (old v) = 𝕊-tab (mε ∘ old) v module _ (g : ${sig} ⇾̣ 𝒜)(gᵃ⇒ : MetaAlg⇒ ${sig}ᵃ 𝒜ᵃ g) where open MetaAlg⇒ gᵃ⇒ 𝕤𝕖𝕞! : (t : ${sig} $fst_ty_var Γ) → 𝕤𝕖𝕞 t ≡ g t 𝕊-ix : (mε : Sub ${sig} Π Γ)(v : ℐ $fst_ty_var Π) → 𝕊 mε v ≡ g (index mε v) 𝕊-ix (x ◂ mε) new = 𝕤𝕖𝕞! x 𝕊-ix (x ◂ mε) (old v) = 𝕊-ix mε v 𝕤𝕖𝕞! (mvar 𝔪 mε) rewrite cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-ix mε)) = trans (sym ⟨𝑚𝑣𝑎𝑟⟩) (cong (g ∘ mvar 𝔪) (tab∘ix≈id mε)) 𝕤𝕖𝕞! (var v) = sym ⟨𝑣𝑎𝑟⟩ $alg_unique_patterns -- Syntax instance for the signature ${sig}:Syn : Syntax ${sig}:Syn = record { ⅀F = ⅀F ; ⅀:CS = ⅀:CompatStr ; mvarᵢ = ${sig}:Terms.mvar ; 𝕋:Init = λ 𝔛 → let open ${sig}:Terms 𝔛 in record { ⊥ = ${sig} ⋉ ${sig}ᵃ ; ⊥-is-initial = record { ! = λ{ {𝒜 ⋉ 𝒜ᵃ} → 𝕤𝕖𝕞 𝒜ᵃ ⋉ 𝕤𝕖𝕞ᵃ⇒ 𝒜ᵃ } ; !-unique = λ{ {𝒜 ⋉ 𝒜ᵃ} (f ⋉ fᵃ⇒) {x = t} → 𝕤𝕖𝕞! 𝒜ᵃ f fᵃ⇒ t } } } } -- Instantiation of the syntax and metatheory open Syntax ${sig}:Syn public open ${sig}:Terms public open import SOAS.Families.Build public open import SOAS.Syntax.Shorthands ${sig}ᵃ public open import SOAS.Metatheory ${sig}:Syn public $derived_tm_ops
{ "alphanum_fraction": 0.5698384201, "avg_line_length": 25.5504587156, "ext": "agda", "hexsha": "3618fefced8346abf8907a433e845ca7ee9d46fa", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "gen/templates/Syntax.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "gen/templates/Syntax.agda", "max_line_length": 93, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "gen/templates/Syntax.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 1559, "size": 2785 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Substitution.Introductions.Prod {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped as U hiding (wk) open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.Weakening as T hiding (wk; wkTerm; wkEqTerm) open import Definition.Typed.RedSteps open import Definition.LogicalRelation open import Definition.LogicalRelation.ShapeView open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.Weakening open import Definition.LogicalRelation.Properties open import Definition.LogicalRelation.Application open import Definition.LogicalRelation.Substitution open import Definition.LogicalRelation.Substitution.Properties open import Definition.LogicalRelation.Substitution.Reflexivity open import Definition.LogicalRelation.Substitution.Introductions.Pi open import Definition.LogicalRelation.Substitution.Introductions.SingleSubst open import Tools.Product import Tools.PropositionalEquality as PE prod′ : ∀ {F G t u Γ l l′ l″} ([F] : Γ ⊩⟨ l ⟩ F) ([t] : Γ ⊩⟨ l ⟩ t ∷ F / [F]) ([Gt] : Γ ⊩⟨ l″ ⟩ G [ t ]) ([u] : Γ ⊩⟨ l″ ⟩ u ∷ G [ t ] / [Gt]) ([ΣFG] : Γ ⊩⟨ l′ ⟩B⟨ BΣ ⟩ Σ F ▹ G) → Γ ⊩⟨ l′ ⟩ prod t u ∷ Σ F ▹ G / B-intr BΣ [ΣFG] prod′ {F} {G} {t} {u} {Γ} {l} {l′} {l″} [F] [t] [Gt] [u] [ΣFG]@(noemb (Bᵣ F₁ G₁ D ⊢F ⊢G A≡A [F]₁ [G]₁ G-ext)) with B-PE-injectivity BΣ (whnfRed* (red D) Σₙ) ... | PE.refl , PE.refl = let ⊢t = escapeTerm [F] [t] ⊢u = escapeTerm [Gt] [u] ⊢Γ = wf ⊢F fst⇒t : Γ ⊢ fst (prod t u) ⇒ t ∷ F fst⇒t = Σ-β₁ ⊢F ⊢G ⊢t ⊢u [fstprod] , [fstprod≡t] = redSubstTerm fst⇒t [F] [t] [fstprod]′ = (irrelevanceTerm′ (PE.sym (wk-id F)) [F] ([F]₁ id ⊢Γ) [fstprod]) wkLiftIdEq = PE.cong (λ x → x [ fst (prod t u ) ]) (wk-lift-id G) [Gfst] = [G]₁ id ⊢Γ [fstprod]′ [Gfst]′ = irrelevance′ wkLiftIdEq [Gfst] [t]′ = irrelevanceTerm′ (PE.sym (wk-id F)) [F] ([F]₁ id ⊢Γ) [t] [fstprod≡t]′ = irrelevanceEqTerm′ (PE.sym (wk-id F)) [F] ([F]₁ id ⊢Γ) [fstprod≡t] [Gfst≡Gt] = irrelevanceEq″ wkLiftIdEq (PE.cong (λ x → x [ t ]) (wk-lift-id G)) [Gfst] [Gfst]′ (G-ext id ⊢Γ [fstprod]′ [t]′ [fstprod≡t]′) [u]′ = convTerm₂ [Gfst]′ [Gt] [Gfst≡Gt] [u] snd⇒u : Γ ⊢ snd (prod t u) ⇒ u ∷ G [ fst (prod t u) ] snd⇒u = Σ-β₂ ⊢F ⊢G ⊢t ⊢u [sndprod] , [sndprod≡u] = redSubstTerm snd⇒u [Gfst]′ [u]′ ⊢prod = prodⱼ ⊢F ⊢G ⊢t ⊢u [fstRefl] = transEqTerm [F] [fstprod≡t] (symEqTerm [F] [fstprod≡t]) [sndRefl] = transEqTerm [Gfst]′ [sndprod≡u] (symEqTerm [Gfst]′ [sndprod≡u]) in Σₜ (prod t u) (idRedTerm:*: ⊢prod) prodₙ (≅-Σ-η ⊢F ⊢G ⊢prod ⊢prod prodₙ prodₙ (escapeTermEq [F] [fstRefl]) (escapeTermEq [Gfst]′ [sndRefl])) [fstprod]′ (irrelevanceTerm′ (PE.sym wkLiftIdEq) [Gfst]′ [Gfst] [sndprod]) prod′ {F} {G} {t} {u} {Γ} {l} {l′} [F] [t] [Gt] [u] [ΣFG]@(emb 0<1 x) = prod′ [F] [t] [Gt] [u] x prod″ : ∀ {F G t u Γ l l′} ([F] : Γ ⊩⟨ l ⟩ F) ([t] : Γ ⊩⟨ l ⟩ t ∷ F / [F]) ([Gt] : Γ ⊩⟨ l ⟩ G [ t ]) ([u] : Γ ⊩⟨ l ⟩ u ∷ G [ t ] / [Gt]) ([ΣFG] : Γ ⊩⟨ l′ ⟩ Σ F ▹ G) → Γ ⊩⟨ l′ ⟩ prod t u ∷ Σ F ▹ G / [ΣFG] prod″ [F] [t] [Gt] [u] [ΣFG] = let [prod] = prod′ [F] [t] [Gt] [u] (B-elim BΣ [ΣFG]) in irrelevanceTerm (B-intr BΣ (B-elim BΣ [ΣFG])) [ΣFG] [prod] prod-cong′ : ∀ {F G t t′ u u′ Γ l l′} ([F] : Γ ⊩⟨ l ⟩ F) ([t] : Γ ⊩⟨ l ⟩ t ∷ F / [F]) ([t′] : Γ ⊩⟨ l ⟩ t′ ∷ F / [F]) ([t≡t′] : Γ ⊩⟨ l ⟩ t ≡ t′ ∷ F / [F]) ([Gt] : Γ ⊩⟨ l ⟩ G [ t ]) ([u] : Γ ⊩⟨ l ⟩ u ∷ G [ t ] / [Gt]) ([u′] : Γ ⊩⟨ l ⟩ u′ ∷ G [ t ] / [Gt]) ([u≡u′] : Γ ⊩⟨ l ⟩ u ≡ u′ ∷ G [ t ] / [Gt]) ([ΣFG] : Γ ⊩⟨ l′ ⟩B⟨ BΣ ⟩ Σ F ▹ G) → Γ ⊩⟨ l′ ⟩ prod t u ≡ prod t′ u′ ∷ Σ F ▹ G / B-intr BΣ [ΣFG] prod-cong′ {F} {G} {t} {t′} {u} {u′} {Γ} {l} {l′} [F] [t] [t′] [t≡t′] [Gt] [u] [u′] [u≡u′] [ΣFG]@(noemb (Bᵣ F₁ G₁ D ⊢F ⊢G A≡A [F]₁ [G]₁ G-ext)) with B-PE-injectivity BΣ (whnfRed* (red D) Σₙ) ... | PE.refl , PE.refl = let [prod] = prod′ [F] [t] [Gt] [u] [ΣFG] ⊢Γ = wf ⊢F wk[F] = [F]₁ id ⊢Γ wk[t] = irrelevanceTerm′ (PE.sym (wk-id F)) [F] wk[F] [t] wk[t′] = irrelevanceTerm′ (PE.sym (wk-id F)) [F] wk[F] [t′] wk[t≡t′] = irrelevanceEqTerm′ (PE.sym (wk-id F)) [F] wk[F] [t≡t′] wk[Gt] = [G]₁ id ⊢Γ wk[t] wk[Gt′] = [G]₁ id ⊢Γ wk[t′] wk[Gt≡Gt′] = G-ext id ⊢Γ wk[t] wk[t′] wk[t≡t′] [Gt′] = irrelevance′ (PE.cong (λ x → x [ t′ ]) (wk-lift-id G)) wk[Gt′] [Gt≡Gt′] = irrelevanceEq″ (PE.cong (λ x → x [ t ]) (wk-lift-id G)) (PE.cong (λ x → x [ t′ ]) (wk-lift-id G)) wk[Gt] [Gt] wk[Gt≡Gt′] [u′]Gt′ = convTerm₁ [Gt] [Gt′] [Gt≡Gt′] [u′] [prod′] = prod′ [F] [t′] [Gt′] [u′]Gt′ [ΣFG] ⊢t = escapeTerm [F] [t] ⊢t′ = escapeTerm [F] [t′] ⊢u = escapeTerm [Gt] [u] ⊢u′ = escapeTerm [Gt′] [u′]Gt′ fst⇒t = Σ-β₁ ⊢F ⊢G ⊢t ⊢u [fst] , [fst≡t] = redSubstTerm fst⇒t [F] [t] fst⇒t′ = Σ-β₁ ⊢F ⊢G ⊢t′ ⊢u′ [fst′] , [fst≡t′] = redSubstTerm fst⇒t′ [F] [t′] wk[fst≡t] = irrelevanceEqTerm′ (PE.sym (wk-id F)) [F] wk[F] [fst≡t] wk[fst≡t′] = irrelevanceEqTerm′ (PE.sym (wk-id F)) [F] wk[F] [fst≡t′] wk[fst] = irrelevanceTerm′ (PE.sym (wk-id F)) [F] wk[F] [fst] wk[fst′] = irrelevanceTerm′ (PE.sym (wk-id F)) [F] wk[F] [fst′] -- fst t ≡ fst t′ ∷ F [fst≡fst′] = transEqTerm [F] [fst≡t] (transEqTerm [F] [t≡t′] (symEqTerm [F] [fst≡t′])) wk[fst≡fst′] = irrelevanceEqTerm′ (PE.sym (wk-id F)) [F] wk[F] [fst≡fst′] -- snd (prod t u) ≡ u ∷ G [ fst (prod t u) ] wkLiftIdEq = PE.cong (λ x → x [ fst (prod t u ) ]) (wk-lift-id G) wk[Gfst] = [G]₁ id ⊢Γ wk[fst] [Gfst] = irrelevance′ wkLiftIdEq wk[Gfst] [Gfst≡Gt] = irrelevanceEq″ wkLiftIdEq (PE.cong (λ x → x [ t ]) (wk-lift-id G)) wk[Gfst] [Gfst] (G-ext id ⊢Γ wk[fst] wk[t] wk[fst≡t]) [u]fst = convTerm₂ [Gfst] [Gt] [Gfst≡Gt] [u] snd⇒u = Σ-β₂ ⊢F ⊢G ⊢t ⊢u [snd] , [snd≡u] = redSubstTerm snd⇒u [Gfst] [u]fst -- u ≡ u′ ∷ G [ fst (prod t u) ] [u≡u′]Gfst = convEqTerm₂ [Gfst] [Gt] [Gfst≡Gt] [u≡u′] -- u′ ≡ snd (prod t′ u′) ∷ G [ fst (prod t u) ] wkLiftIdEq′ = PE.cong (λ x → x [ fst (prod t′ u′) ]) (wk-lift-id G) wk[Gfst′] = [G]₁ id ⊢Γ wk[fst′] [Gfst′] = irrelevance′ wkLiftIdEq′ wk[Gfst′] [Gfst′≡Gt′] = irrelevanceEq″ wkLiftIdEq′ (PE.cong (λ x → x [ t′ ]) (wk-lift-id G)) wk[Gfst′] [Gfst′] (G-ext id ⊢Γ wk[fst′] wk[t′] wk[fst≡t′]) snd⇒u′ = Σ-β₂ ⊢F ⊢G ⊢t′ ⊢u′ [u′]Gfst′ = convTerm₂ [Gfst′] [Gt′] [Gfst′≡Gt′] [u′]Gt′ [snd≡u′]Gfst′ = proj₂ (redSubstTerm snd⇒u′ [Gfst′] [u′]Gfst′) [Gfst≡Gfst′] = irrelevanceEq″ wkLiftIdEq wkLiftIdEq′ wk[Gfst] [Gfst] (G-ext id ⊢Γ wk[fst] wk[fst′] wk[fst≡fst′]) [snd≡u′]Gfst = convEqTerm₂ [Gfst] [Gfst′] [Gfst≡Gfst′] [snd≡u′]Gfst′ [snd≡snd′] = transEqTerm [Gfst] [snd≡u] (transEqTerm [Gfst] [u≡u′]Gfst (symEqTerm [Gfst] [snd≡u′]Gfst)) wk[snd≡snd′] = irrelevanceEqTerm′ (PE.cong (λ x → x [ fst (prod t u) ]) (PE.sym (wk-lift-id G))) [Gfst] wk[Gfst] [snd≡snd′] ⊢prod = escapeTerm (B-intr BΣ [ΣFG]) [prod] ⊢prod′ = escapeTerm (B-intr BΣ [ΣFG]) [prod′] in Σₜ₌ (prod t u) (prod t′ u′) (idRedTerm:*: ⊢prod) (idRedTerm:*: ⊢prod′) prodₙ prodₙ (≅-Σ-η ⊢F ⊢G ⊢prod ⊢prod′ prodₙ prodₙ (escapeTermEq [F] [fst≡fst′]) (escapeTermEq [Gfst] [snd≡snd′])) [prod] [prod′] wk[fst] wk[fst′] wk[fst≡fst′] wk[snd≡snd′] prod-cong′ [F] [t] [t′] [t≡t′] [Gt] [u] [u′] [u≡u′] (emb 0<1 x) = prod-cong′ [F] [t] [t′] [t≡t′] [Gt] [u] [u′] [u≡u′] x prod-cong″ : ∀ {F G t t′ u u′ Γ l l′} ([F] : Γ ⊩⟨ l ⟩ F) ([t] : Γ ⊩⟨ l ⟩ t ∷ F / [F]) ([t′] : Γ ⊩⟨ l ⟩ t′ ∷ F / [F]) ([t≡t′] : Γ ⊩⟨ l ⟩ t ≡ t′ ∷ F / [F]) ([Gt] : Γ ⊩⟨ l ⟩ G [ t ]) ([u] : Γ ⊩⟨ l ⟩ u ∷ G [ t ] / [Gt]) ([u′] : Γ ⊩⟨ l ⟩ u′ ∷ G [ t ] / [Gt]) ([u≡u′] : Γ ⊩⟨ l ⟩ u ≡ u′ ∷ G [ t ] / [Gt]) ([ΣFG] : Γ ⊩⟨ l′ ⟩ Σ F ▹ G) → Γ ⊩⟨ l′ ⟩ prod t u ≡ prod t′ u′ ∷ Σ F ▹ G / [ΣFG] prod-cong″ [F] [t] [t′] [t≡t′] [Gt] [u] [u′] [u≡u′] [ΣFG] = let [prod≡] = prod-cong′ [F] [t] [t′] [t≡t′] [Gt] [u] [u′] [u≡u′] (B-elim BΣ [ΣFG]) in irrelevanceEqTerm (B-intr BΣ (B-elim BΣ [ΣFG])) [ΣFG] [prod≡] prod-congᵛ : ∀ {F G t t′ u u′ Γ l} ([Γ] : ⊩ᵛ Γ) ([F] : Γ ⊩ᵛ⟨ l ⟩ F / [Γ]) ([G] : Γ ∙ F ⊩ᵛ⟨ l ⟩ G / [Γ] ∙ [F]) ([t] : Γ ⊩ᵛ⟨ l ⟩ t ∷ F / [Γ] / [F]) ([t′] : Γ ⊩ᵛ⟨ l ⟩ t′ ∷ F / [Γ] / [F]) ([t≡t′] : Γ ⊩ᵛ⟨ l ⟩ t ≡ t′ ∷ F / [Γ] / [F]) ([u] : Γ ⊩ᵛ⟨ l ⟩ u ∷ G [ t ] / [Γ] / substS {F} {G} [Γ] [F] [G] [t]) ([u′] : Γ ⊩ᵛ⟨ l ⟩ u′ ∷ G [ t′ ] / [Γ] / substS {F} {G} [Γ] [F] [G] [t′]) ([u≡u′] : Γ ⊩ᵛ⟨ l ⟩ u ≡ u′ ∷ G [ t ] / [Γ] / substS {F} {G} [Γ] [F] [G] [t]) → Γ ⊩ᵛ⟨ l ⟩ prod t u ≡ prod t′ u′ ∷ Σ F ▹ G / [Γ] / Σᵛ {F} {G} [Γ] [F] [G] prod-congᵛ {F} {G} {t} {t′} {u} {u′} {Γ} [Γ] [F] [G] [t] [t′] [t≡t′] [u] [u′] [u≡u′] {Δ} {σ} ⊢Δ [σ] = let ⊩σF = proj₁ ([F] ⊢Δ [σ]) ⊩σt = proj₁ ([t] ⊢Δ [σ]) ⊩σt′ = proj₁ ([t′] ⊢Δ [σ]) σt≡σt′ = [t≡t′] ⊢Δ [σ] [Gt] = substS {F} {G} [Γ] [F] [G] [t] ⊩σGt₁ = proj₁ ([Gt] ⊢Δ [σ]) ⊩σGt = irrelevance′ (singleSubstLift G t) ⊩σGt₁ ⊩σu = irrelevanceTerm′ (singleSubstLift G t) ⊩σGt₁ ⊩σGt (proj₁ ([u] ⊢Δ [σ])) [Gt≡Gt′] = substSEq {F = F} {F′ = F} {G = G} {G′ = G} {t = t} {t′ = t′} [Γ] [F] [F] (reflᵛ {A = F} [Γ] [F]) [G] [G] (reflᵛ {A = G} {Γ = Γ ∙ F} ([Γ] ∙ [F]) [G]) [t] [t′] [t≡t′] σGt≡σGt′ = [Gt≡Gt′] ⊢Δ [σ] ⊩σGt′ = proj₁ (substS {F} {G} [Γ] [F] [G] [t′] ⊢Δ [σ]) ⊩σu′₂ = proj₁ ([u′] ⊢Δ [σ]) ⊩σu′₁ = convTerm₂ ⊩σGt₁ ⊩σGt′ σGt≡σGt′ ⊩σu′₂ ⊩σu′ = irrelevanceTerm′ (singleSubstLift G t) ⊩σGt₁ ⊩σGt ⊩σu′₁ σu≡σu′ = irrelevanceEqTerm′ (singleSubstLift G t) ⊩σGt₁ ⊩σGt ([u≡u′] ⊢Δ [σ]) ⊩σΣFG = proj₁ (Σᵛ {F} {G} [Γ] [F] [G] ⊢Δ [σ]) in prod-cong″ ⊩σF ⊩σt ⊩σt′ σt≡σt′ ⊩σGt ⊩σu ⊩σu′ σu≡σu′ ⊩σΣFG prodᵛ : ∀ {F G t u Γ l} ([Γ] : ⊩ᵛ Γ) ([F] : Γ ⊩ᵛ⟨ l ⟩ F / [Γ]) ([G] : Γ ∙ F ⊩ᵛ⟨ l ⟩ G / [Γ] ∙ [F]) ([t] : Γ ⊩ᵛ⟨ l ⟩ t ∷ F / [Γ] / [F]) ([u] : Γ ⊩ᵛ⟨ l ⟩ u ∷ G [ t ] / [Γ] / substS {F} {G} [Γ] [F] [G] [t]) → Γ ⊩ᵛ⟨ l ⟩ prod t u ∷ Σ F ▹ G / [Γ] / Σᵛ {F} {G} [Γ] [F] [G] prodᵛ {F} {G} {t} {u} {Γ} {l} [Γ] [F] [G] [t] [u] {Δ = Δ} {σ = σ} ⊢Δ [σ] = let [Gt] = substS {F} {G} [Γ] [F] [G] [t] [ΣFG] = Σᵛ {F} {G} [Γ] [F] [G] ⊩σF = proj₁ ([F] ⊢Δ [σ]) ⊢σF = escape ⊩σF ⊩σt = proj₁ ([t] ⊢Δ [σ]) ⊩σGt′ : Δ ⊩⟨ l ⟩ subst σ (G [ t ]) ⊩σGt′ = proj₁ ([Gt] ⊢Δ [σ]) ⊩σGt : Δ ⊩⟨ l ⟩ subst (liftSubst σ) G [ subst σ t ] ⊩σGt = irrelevance′ (singleSubstLift G t) ⊩σGt′ ⊩σu′ = proj₁ ([u] ⊢Δ [σ]) ⊩σu : Δ ⊩⟨ l ⟩ subst σ u ∷ subst (liftSubst σ) G [ subst σ t ] / ⊩σGt ⊩σu = irrelevanceTerm′ (singleSubstLift G t) ⊩σGt′ ⊩σGt ⊩σu′ ⊩σΣFG = proj₁ ([ΣFG] ⊢Δ [σ]) in prod″ ⊩σF ⊩σt ⊩σGt ⊩σu ⊩σΣFG , (λ {σ′} [σ′] [σ≡σ′] → let ⊩σ′F = proj₁ ([F] ⊢Δ [σ′]) σF≡σ′F = proj₂ ([F] ⊢Δ [σ]) [σ′] [σ≡σ′] ⊩σ′t = proj₁ ([t] ⊢Δ [σ′]) ⊩σ′t = convTerm₂ ⊩σF ⊩σ′F σF≡σ′F ⊩σ′t σt≡σ′t = proj₂ ([t] ⊢Δ [σ]) [σ′] [σ≡σ′] ⊩σ′Gt′ = proj₁ ([Gt] ⊢Δ [σ′]) ⊩σ′Gt = irrelevance′ (singleSubstLift G t) ⊩σ′Gt′ σGt≡σ′Gt = proj₂ ([Gt] ⊢Δ [σ]) [σ′] [σ≡σ′] ⊩σ′u″ = proj₁ ([u] ⊢Δ [σ′]) ⊩σ′u′ = convTerm₂ ⊩σGt′ ⊩σ′Gt′ σGt≡σ′Gt ⊩σ′u″ ⊩σ′u = irrelevanceTerm′ (singleSubstLift G t) ⊩σGt′ ⊩σGt ⊩σ′u′ σu≡σ′u : Δ ⊩⟨ l ⟩ subst σ u ≡ subst σ′ u ∷ subst (liftSubst σ) G [ subst σ t ] / ⊩σGt σu≡σ′u = irrelevanceEqTerm′ (singleSubstLift G t) ⊩σGt′ ⊩σGt (proj₂ ([u] ⊢Δ [σ]) [σ′] [σ≡σ′]) in prod-cong″ ⊩σF ⊩σt ⊩σ′t σt≡σ′t ⊩σGt ⊩σu ⊩σ′u σu≡σ′u ⊩σΣFG)
{ "alphanum_fraction": 0.4019947962, "avg_line_length": 41.9272727273, "ext": "agda", "hexsha": "2d15d7cfd1e6a89c848930a69a12cddfaa126d08", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Vtec234/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Prod.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Vtec234/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Prod.agda", "max_line_length": 105, "max_stars_count": null, "max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Vtec234/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Prod.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6493, "size": 13836 }
{-# OPTIONS --safe --sized-types #-} module Issue3517.S where open import Agda.Builtin.Size public
{ "alphanum_fraction": 0.7227722772, "avg_line_length": 16.8333333333, "ext": "agda", "hexsha": "0797eef8e6de2884e91316598a58ebb37dd34112", "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/Issue3517/S.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/Issue3517/S.agda", "max_line_length": 36, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue3517/S.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": 25, "size": 101 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Monoidal.Helpers where open import Data.Nat using (_+_) open import Function using (flip) open import Categories.Category import Categories.Functor open import Categories.Bifunctor hiding (identityˡ; identityʳ; assoc) renaming (id to idF; _≡_ to _≡F_; _∘_ to _∘F_) open import Categories.NaturalIsomorphism open import Categories.NaturalTransformation using (_∘₀_; _∘₁_; _∘ˡ_; _∘ʳ_; NaturalTransformation) renaming (_≡_ to _≡ⁿ_; id to idⁿ) module MonoidalHelperFunctors {o ℓ e} (C : Category o ℓ e) (—⊗— : Bifunctor C C C) (id : Category.Obj C) where private module C = Category C open C hiding (id; identityˡ; identityʳ) import Categories.Power.NaturalTransformation private module PowNat = Categories.Power.NaturalTransformation C open PowNat private module ⊗ = Functor —⊗— renaming (F₀ to ⊗₀; F₁ to ⊗₁; F-resp-≡ to ⊗-resp-≡) open ⊗ infix 2 _⊗_ _⊗_ : ∀ {n m} (F : Powerendo n) (G : Powerendo m) → Powerendo (n + m) _⊗_ = reduce —⊗— _⊗₂_ : ∀ {m} (F G : Powerendo m) → Powerendo m _⊗₂_ = overlaps {C} —⊗— -- reduce (flip-bifunctor {C = C} {C} —⊗—) id↑ : Powerendo 0 id↑ = nullary id x : Powerendo 1 x = unary (idF {C = C}) id⊗x : Powerendo 1 id⊗x = id↑ ⊗ x x⊗id : Powerendo 1 x⊗id = x ⊗ id↑ x⊗y : Powerendo 2 x⊗y = binary —⊗— y⊗x : Powerendo 2 y⊗x = binary (flip-bifunctor {C = C} {C} —⊗—) [x⊗y]⊗z : Powerendo 3 [x⊗y]⊗z = x⊗y ⊗ x x⊗[y⊗z] : Powerendo 3 x⊗[y⊗z] = x ⊗ x⊗y [y⊗z]⊗x : Powerendo 3 [y⊗z]⊗x = (select 1 ⊗₂ select 2) ⊗₂ select 0 [y⊗x]⊗z : Powerendo 3 [y⊗x]⊗z = (select 1 ⊗₂ select 0) ⊗₂ select 2 y⊗[x⊗z] : Powerendo 3 y⊗[x⊗z] = select 1 ⊗₂ (select 0 ⊗₂ select 2) y⊗[z⊗x] : Powerendo 3 y⊗[z⊗x] = select 1 ⊗₂ (select 2 ⊗₂ select 0) z⊗[x⊗y] : Powerendo 3 z⊗[x⊗y] = select 2 ⊗₂ (select 0 ⊗₂ select 1) x⊗[z⊗y] : Powerendo 3 x⊗[z⊗y] = select 0 ⊗₂ (select 2 ⊗₂ select 1) [x⊗z]⊗y : Powerendo 3 [x⊗z]⊗y = (select 0 ⊗₂ select 2) ⊗₂ select 1 [z⊗x]⊗y : Powerendo 3 [z⊗x]⊗y = (select 2 ⊗₂ select 0) ⊗₂ select 1 [x⊗id]⊗y : Powerendo 2 [x⊗id]⊗y = x⊗id ⊗ x x⊗[id⊗y] : Powerendo 2 x⊗[id⊗y] = x ⊗ id⊗x [[x⊗y]⊗z]⊗w : Powerendo 4 [[x⊗y]⊗z]⊗w = [x⊗y]⊗z ⊗ x [x⊗y]⊗[z⊗w] : Powerendo 4 [x⊗y]⊗[z⊗w] = x⊗y ⊗ x⊗y x⊗[y⊗[z⊗w]] : Powerendo 4 x⊗[y⊗[z⊗w]] = x ⊗ x⊗[y⊗z] x⊗[[y⊗z]⊗w] : Powerendo 4 x⊗[[y⊗z]⊗w] = x ⊗ [x⊗y]⊗z [x⊗[y⊗z]]⊗w : Powerendo 4 [x⊗[y⊗z]]⊗w = x⊗[y⊗z] ⊗ x infix 2 _⊗ⁿ_ _⊗ⁿ_ : ∀ {n} {F F′ : Powerendo n} (φ : NaturalTransformation F F′) {m} {G G′ : Powerendo m} (γ : NaturalTransformation G G′) → NaturalTransformation (F ⊗ G) (F′ ⊗ G′) _⊗ⁿ_ = reduceN —⊗— infix 2 _⊗ⁿ′_ _⊗ⁿ′_ : ∀ {n} {F F′ : Powerendo n} (φ : NaturalTransformation F F′) {G G′ : Powerendo n} (γ : NaturalTransformation G G′) → NaturalTransformation (F ⊗₂ G) (F′ ⊗₂ G′) _⊗ⁿ′_ = overlapN —⊗— id₂ : NaturalTransformation x x id₂ = idⁿ id3 : {F : Powerendo 3} → NaturalTransformation F F id3 = idⁿ module Coherence (identityˡ : NaturalIsomorphism id⊗x x) (identityʳ : NaturalIsomorphism x⊗id x) (assoc : NaturalIsomorphism [x⊗y]⊗z x⊗[y⊗z]) where open NaturalIsomorphism identityˡ using () renaming (F⇒G to υˡ) open NaturalIsomorphism identityʳ using () renaming (F⇒G to υʳ) open NaturalIsomorphism assoc using () renaming (F⇒G to α) α-over : ∀ {n₁ n₂ n₃} (F₁ : Powerendo n₁) (F₂ : Powerendo n₂) (F₃ : Powerendo n₃) → NaturalTransformation ((F₁ ⊗ F₂) ⊗ F₃) (reduce2ʳ —⊗— F₁ F₂ F₃) α-over F₁ F₂ F₃ = α ∘ʳ ((hyp F₁ ∥ hyp F₂) ∥ hyp F₃) TriangleLeftSide : NaturalTransformation [x⊗id]⊗y x⊗y TriangleLeftSide = υʳ ⊗ⁿ id₂ TriangleTopSide : NaturalTransformation [x⊗id]⊗y x⊗[id⊗y] TriangleTopSide = α-over x id↑ x TriangleRightSide : NaturalTransformation x⊗[id⊗y] x⊗y TriangleRightSide = id₂ ⊗ⁿ υˡ PentagonNWSide : NaturalTransformation [[x⊗y]⊗z]⊗w [x⊗y]⊗[z⊗w] PentagonNWSide = α-over x⊗y x x PentagonNESide : NaturalTransformation [x⊗y]⊗[z⊗w] x⊗[y⊗[z⊗w]] PentagonNESide = α-over x x x⊗y PentagonSWSide : NaturalTransformation [[x⊗y]⊗z]⊗w [x⊗[y⊗z]]⊗w PentagonSWSide = α ⊗ⁿ id₂ PentagonSSide : NaturalTransformation [x⊗[y⊗z]]⊗w x⊗[[y⊗z]⊗w] PentagonSSide = α-over x x⊗y x PentagonSESide : NaturalTransformation x⊗[[y⊗z]⊗w] x⊗[y⊗[z⊗w]] PentagonSESide = id₂ ⊗ⁿ α
{ "alphanum_fraction": 0.6028207461, "avg_line_length": 26.3233532934, "ext": "agda", "hexsha": "25cd25176b686a8509c5729caa4ac7fee7ae4a05", "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": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Monoidal/Helpers.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "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": "p-pavel/categories", "max_issues_repo_path": "Categories/Monoidal/Helpers.agda", "max_line_length": 168, "max_stars_count": 1, "max_stars_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "p-pavel/categories", "max_stars_repo_path": "Categories/Monoidal/Helpers.agda", "max_stars_repo_stars_event_max_datetime": "2018-12-29T21:51:57.000Z", "max_stars_repo_stars_event_min_datetime": "2018-12-29T21:51:57.000Z", "num_tokens": 2272, "size": 4396 }
{-# OPTIONS --prop --allow-unsolved-metas #-} postulate A : Set P : A → Prop a : A c : P a Q : Prop x : Q x = _ where b : A b = a d : P b d = c
{ "alphanum_fraction": 0.4606060606, "avg_line_length": 9.7058823529, "ext": "agda", "hexsha": "21050c3085cd46965965f74b57c7b22f0a118a45", "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/Issue3618.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/Issue3618.agda", "max_line_length": 45, "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/Issue3618.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": 73, "size": 165 }
module WellScopedTermsModel where open import Library open import WellScopedTerms open import RMonads open import RMonads.REM open import Categories.Sets _<<_ : ∀{n}{X : Set} → (Fin n → X) → X → Fin (suc n) → X (f << x) zero = x (f << x) (suc i) = f i record LambdaModel : Set₁ where field S : Set Env = λ n → Fin n → S field eval : ∀{n} → Env n → Tm n → S ap : S → S → S lawvar : ∀{n}{i : Fin n}{γ : Env n} → eval γ (var i) ≅ γ i lawapp : ∀{n}{t u : Tm n}{γ : Env n} → eval γ (app t u) ≅ ap (eval γ t) (eval γ u) lawlam : ∀{n}{t : Tm (suc n)}{γ : Env n}{s : S} → ap (eval γ (lam t)) s ≅ eval (γ << s) t lawext : ∀{f g : S} → ((a : S) → ap f a ≅ ap g a) → f ≅ g module Model (l : LambdaModel) where open LambdaModel l wk<< : ∀{m n}(α : Ren m n)(β : Env n) (v : S) → (y : Fin (suc m)) → ((β ∘ α) << v) y ≅ (β << v) (wk α y) wk<< α β v zero = refl wk<< α β v (suc i) = refl reneval : ∀{m n}(α : Ren m n)(β : Env n) (t : Tm m) → eval (β ∘ α) t ≅ (eval β ∘ ren α) t reneval α β (var i) = proof eval (β ∘ α) (var i) ≅⟨ lawvar ⟩ β (α i) ≅⟨ sym lawvar ⟩ eval β (var (α i)) ∎ reneval α β (lam t) = lawext λ a → proof ap (eval (β ∘ α) (lam t)) a ≅⟨ lawlam ⟩ eval ((β ∘ α) << a) t ≅⟨ cong (λ (f : Env _) → eval f t) (ext (wk<< α β a)) ⟩ eval ((β << a) ∘ wk α) t ≅⟨ reneval (wk α) (β << a) t ⟩ eval (β << a) (ren (wk α) t) ≅⟨ sym lawlam ⟩ ap (eval β (lam (ren (wk α) t))) a ∎ reneval α β (app t u) = proof eval (β ∘ α) (app t u) ≅⟨ lawapp ⟩ ap (eval (β ∘ α) t) (eval (β ∘ α) u) ≅⟨ cong₂ ap (reneval α β t) (reneval α β u) ⟩ ap (eval β (ren α t)) (eval β (ren α u)) ≅⟨ sym lawapp ⟩ eval β (app (ren α t) (ren α u)) ∎ lift<< : ∀{m n}(γ : Sub m n)(α : Env n) (a : S)(i : Fin (suc m)) → ((eval α ∘ γ ) << a) i ≅ (eval (α << a) ∘ lift γ) i lift<< γ α a zero = proof a ≅⟨ sym lawvar ⟩ eval (α << a) (var zero) ∎ lift<< γ α a (suc i) = proof eval α (γ i) ≡⟨⟩ eval ((α << a) ∘ suc) (γ i) ≅⟨ reneval suc (α << a) (γ i) ⟩ eval (α << a) (ren suc (γ i)) ∎ subeval : ∀{m n}(t : Tm m)(γ : Sub m n)(α : Env n) → eval (eval α ∘ γ) t ≅ (eval α ∘ sub γ) t subeval (var i) γ α = proof eval (eval α ∘ γ) (var i) ≅⟨ lawvar ⟩ eval α (γ i) ∎ subeval (lam t) γ α = lawext λ a → proof ap (eval (eval α ∘ γ) (lam t)) a ≅⟨ lawlam ⟩ eval ((eval α ∘ γ) << a) t ≅⟨ cong (λ (f : Env _) → eval f t) (ext (lift<< γ α a)) ⟩ eval (eval (α << a) ∘ lift γ) t ≅⟨ subeval t (lift γ) (α << a) ⟩ eval (α << a) (sub (lift γ) t) ≅⟨ sym lawlam ⟩ ap (eval α (lam (sub (lift γ) t))) a ∎ subeval (app t u) γ α = proof eval (eval α ∘ γ) (app t u) ≅⟨ lawapp ⟩ ap (eval (eval α ∘ γ) t) (eval (eval α ∘ γ) u) ≅⟨ cong₂ ap (subeval t γ α) (subeval u γ α) ⟩ ap (eval α (sub γ t)) (eval α (sub γ u)) ≅⟨ sym lawapp ⟩ eval α (app (sub γ t) (sub γ u)) ∎ TmRAlg : RAlg TmRMonad TmRAlg = record{ acar = S; astr = eval; alaw1 = ext λ _ → sym lawvar; alaw2 = ext λ t → subeval t _ _} module VEnv where open import Delay open import Size mutual Env : ℕ → Set Env n = Fin n → Val data Val : Set where clo : ∀{n} → Env n → Tm (suc n) → Val -- the RAlg is expecting a env containing 'values' here the values -- evaluator takes an env of undelayed values and makes a delayed -- values. mutual ev : ∀{i n} → Env n → Tm n → Delay Val i ev γ (var x) = now (γ x) ev γ (lam t) = now (clo γ t) ev γ (app t u) = ev γ t >>= λ f → ev γ u >>= λ v → f $$ v _∞$$_ : ∀{i} → Val → Val → ∞Delay Val i force (clo γ t ∞$$ v) = ev (γ << v) t _$$_ : ∀{i} → Val → Val → Delay Val i f $$ v = later (f ∞$$ v) module FusedVals where open import Size mutual data Env (i : Size) : (n : ℕ) → Set where ε : Env i zero _,_ : ∀ {n} (ρ : Env i n) (v : Val i) → Env i (suc n) data Val (i : Size) : Set where lam : forall {n} (t : Tm (suc n)) (ρ : Env i n) → Val i later : (v∞ : ∞Val i) → Val i record ∞Val (i : Size) : Set where coinductive constructor ∞val field vforce : {j : Size< i} → Val j open ∞Val lookup : ∀{i n} -> Env i n -> Fin n -> Val i lookup (ρ , v) zero = v lookup (ρ , v) (suc i) = lookup ρ i tabulate : ∀{i n} -> (Fin n -> Val i) -> Env i n tabulate {n = zero} f = ε tabulate {n = suc n} f = (tabulate {n = n} (f ∘ suc)) , f zero mutual ev : ∀{i n} -> Env i n -> Tm n -> Val i ev ρ (var x) = lookup ρ x ev ρ (lam t) = lam t ρ ev ρ (app t u) = ev ρ t $$ ev ρ u _$$_ : ∀{i} → Val i → Val i → Val i f $$ v = later (f ∞$$ v) _∞$$_ : ∀{i} → Val i → Val i → ∞Val i vforce (lam t ρ ∞$$ v) = ev (ρ , v) t vforce (later p ∞$$ v) = later (vforce p ∞$$ v) {- FRAlg : ∀ {i} -> RAlg TmRMonad FRAlg {i} = ralg (Val i) (ev ∘ tabulate) {!!} {!!} -}
{ "alphanum_fraction": 0.4452873127, "avg_line_length": 26.4974874372, "ext": "agda", "hexsha": "51782875136185c20ba23533438822bef87ef0e7", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_forks_event_min_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jmchapman/Relative-Monads", "max_forks_repo_path": "WellScopedTermsModel.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_issues_repo_issues_event_max_datetime": "2019-05-29T09:50:26.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:12:33.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "jmchapman/Relative-Monads", "max_issues_repo_path": "WellScopedTermsModel.agda", "max_line_length": 68, "max_stars_count": 21, "max_stars_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jmchapman/Relative-Monads", "max_stars_repo_path": "WellScopedTermsModel.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T18:02:18.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-30T01:25:12.000Z", "num_tokens": 2262, "size": 5273 }
open import Signature -- | In this module, we construct the free monad and the free completely -- iterative monad over a signature Σ (see Aczel, Adamek, Milius and Velebil). -- The first assigns to a set V of variables the set TV of finite terms over Σ -- (that is, finite trees labelled with symbols in f ∈ ∥Σ∥ and ar(f) branching). -- The second extends this to also allow for infinite trees, the set of those -- is then denoted by T∞(V). -- Categorically, T(V) is the initial (Σ + V)-algebra, whereas T∞(V) is the -- final (Σ + V)-coalgebra. module Terms (Σ : Sig) where open import Function open import Data.Empty open import Data.Unit hiding (_≤_) open import Data.Product as Prod renaming (Σ to ⨿) open import Data.Nat as Nat open import Data.Sum as Sum open import Relation.Binary.PropositionalEquality hiding ([_]) open ≡-Reasoning open import Relation.Binary hiding (_⇒_) open import Relation.Unary hiding (_⇒_) import Streams as Str open import Streams hiding (corec) -- | Natural transformations Nat : (Set → Set) → (Set → Set) → Set₁ Nat F G = ∀{X} → F X → G X Id : Set → Set Id = id least : {X : Set} (_⊑_ : Rel X _) (P : X → Set) → X → Set least _⊑_ P x = (P x) × (∀ {y} → P y → x ⊑ y) least-unique : {X : Set} {_⊑_ : Rel X _} → (IsTotalOrder _≡_ _⊑_) → {P : X → Set} → (x y : X) → least _⊑_ P x → least _⊑_ P y → x ≡ y least-unique isTO x y (p , l₁) (q , l₂) with IsTotalOrder.total isTO x y least-unique isTO x y (p , l₁) (q , l₂) | inj₁ x⊑y = IsTotalOrder.antisym isTO x⊑y (l₂ p) least-unique isTO x y (p , l₁) (q , l₂) | inj₂ y⊑x = IsTotalOrder.antisym isTO (l₁ q) y⊑x infixr 1 _⇒_ _⇒_ = Nat data T (V : Set) : Set where sup : ⟪ Σ ⟫ (T V) ⊎ V → T V rec : ∀{V X} → (f : ⟪ Σ ⟫ X ⊎ V → X) → T V → X rec f (sup (inj₁ (s , α))) = f (inj₁ (s , λ i → rec f (α i))) rec f (sup (inj₂ y)) = f (inj₂ y) rec-hom : ∀{V X} → (f : ⟪ Σ ⟫ X ⊎ V → X) (u : ⟪ Σ ⟫ (T V) ⊎ V) → rec f (sup u) ≡ f (Sum.map (⟪ Σ ⟫₁ (rec f)) id u) rec-hom f (inj₁ (s , α)) = cong (λ u → f (inj₁ (s , u))) refl rec-hom f (inj₂ v) = refl -- | Functor T, on morphisms T₁ : ∀ {V W} → (V → W) → T V → T W T₁ f = rec (sup ∘ Sum.map id f) η : Id ⇒ T η = sup ∘ inj₂ μ : T ∘ T ⇒ T μ {V} = rec f where f : ⟪ Σ ⟫ (T V) ⊎ T V → T V f = [ sup ∘ inj₁ , id ] -- | First monad law postulate unitᵣ : ∀{V} {t : T V} → μ (T₁ η t) ≡ t {- unitᵣ {V} {t} = begin μ (T₁ η t) ≡⟨ {!!} ⟩ t ∎ -} -- | T is free over Σ with inclusion ι : ⟪ Σ ⟫ ⇒ T ι = sup ∘ inj₁ ∘ ⟪ Σ ⟫₁ η postulate T₁-top-sym : ∀{V W} (f : V → W) (s : ∥ Σ ∥) (α : ar Σ s → T V) → T₁ f (μ (ι (s , α))) ≡ μ (ι (s , T₁ f ∘ α)) -- T₁-top-sym = {!!} -- | Kleisli morphsims for T∞ V Subst : Set → Set → Set Subst V W = V → T W infixr 9 _•_ -- | Kleisli composition _•_ : ∀ {U V W} → Subst V W → Subst U V → Subst U W τ • σ = μ ∘ T₁ τ ∘ σ -- | Application of substitutions to infinite terms app : ∀ {V W} → Subst V W → T V → T W app σ = μ ∘ T₁ σ infixl 1 _≡ₛ_ _≡ₛ_ : ∀{V W} → Rel (Subst V W) _ σ ≡ₛ τ = ∀ {v} → σ v ≡ τ v -- | Order on subsitutions _⊑_ : ∀{V W} → Rel (Subst V W) _ σ₁ ⊑ σ₂ = ∃ λ σ → σ • σ₁ ≡ₛ σ₂ matches : ∀{V W} → T V → T W → Subst V W → Set matches t s σ = app σ t ≡ s -- | Most general matcher mgm : ∀{V W} → T V → T W → Subst V W → Set mgm t s = least _⊑_ (matches t s) η-mgm : ∀{V} (t : T V) → mgm t t η η-mgm {V} t = m , min t where m : matches t t η m = begin app η t ≡⟨ refl ⟩ μ (T₁ η t) ≡⟨ unitᵣ ⟩ t ∎ min : {σ : Subst V V} (t : T V) → matches t t σ → η ⊑ σ min {σ} t m with app σ t min {σ} (sup (inj₁ y)) refl | sup (inj₁ .y) = σ , refl min (sup (inj₁ x)) () | sup (inj₂ w) min (sup (inj₂ v)) () | sup (inj₁ y) min {σ} (sup (inj₂ v)) refl | sup (inj₂ .v) = σ , refl unifies : ∀{V W} → T V → T V → Subst V W → Set unifies t s σ = app σ t ≡ app σ s -- | Most general unifier mgu : ∀{V W} → T V → T V → Subst V W → Set mgu t s = least _⊑_ (unifies t s) -- | Free variables fv : ∀{V} → T V → Pred V _ fv (sup (inj₁ (s , α))) v = ⨿ (Sig.ar Σ s) λ i → (fv (α i) v) fv (sup (inj₂ v₁)) v = v₁ ≡ v isCons : ∀{V} → Pred (T V) _ isCons (sup (inj₁ x)) = ⊤ isCons (sup (inj₂ y)) = ⊥ isVar : ∀{V} → Pred (T V) _ isVar (sup (inj₁ x)) = ⊥ isVar (sup (inj₂ y)) = ⊤ record T∞ (V : Set) : Set where coinductive field out : ⟪ Σ ⟫ (T∞ V) ⊎ V open T∞ public sum-lift : {A B : Set} (R₁ : A → A → Set) (R₂ : B → B → Set) (x y : A ⊎ B) → Set sum-lift R₁ R₂ (inj₁ x) (inj₁ y) = R₁ x y sum-lift R₁ R₂ (inj₁ x) (inj₂ y) = ⊥ sum-lift R₁ R₂ (inj₂ x) (inj₁ y) = ⊥ sum-lift R₁ R₂ (inj₂ x) (inj₂ y) = R₂ x y ~-data : ∀{V} (R : T∞ V → T∞ V → Set) (u w : ⟪ Σ ⟫ (T∞ V) ⊎ V) → Set ~-data R = sum-lift (sig-lift R) _≡_ record _~_ {V : Set} (t s : T∞ V) : Set where coinductive field out~ : ~-data _~_ (out t) (out s) open _~_ public corec : ∀{V X} → (f : X → ⟪ Σ ⟫ X ⊎ V) → X → T∞ V out (corec f x) with f x ... | inj₁ (s , α) = inj₁ (s , (λ i → corec f (α i))) ... | inj₂ v = inj₂ v prim-corec : ∀{V X} → (f : X → ⟪ Σ ⟫ X ⊎ V ⊎ T∞ V) → X → T∞ V out (prim-corec {V} {X} f x) with f x ... | inj₁ (s , α) = inj₁ (s , (λ i → prim-corec f (α i))) ... | inj₂ (inj₁ v) = inj₂ v ... | inj₂ (inj₂ t) = out t sup∞ : ∀{V} → ⟪ Σ ⟫ (T∞ V) ⊎ V → T∞ V out (sup∞ (inj₁ u)) = inj₁ u out (sup∞ (inj₂ v)) = inj₂ v -- | Functor T∞, on morphisms T∞₁ : ∀ {V W} → (V → W) → T∞ V → T∞ W T∞₁ f = corec (Sum.map id f ∘ out) η∞ : Id ⇒ T∞ η∞ = sup∞ ∘ inj₂ μ∞ : T∞ ∘ T∞ ⇒ T∞ μ∞ {V} = corec f where g : T∞ V → ⟪ Σ ⟫ (T∞ (T∞ V)) ⊎ V g = Sum.map (⟪ Σ ⟫₁ η∞) id ∘ out f : T∞ (T∞ V) → ⟪ Σ ⟫ (T∞ (T∞ V)) ⊎ V f = [ inj₁ , g ] ∘ out ι∞ : ⟪ Σ ⟫ ⇒ T∞ ι∞ {V} = g ∘ inj₁ where g : ⟪ Σ ⟫ V ⊎ T∞ V → T∞ V g = prim-corec [ inj₁ ∘ ⟪ Σ ⟫₁ (inj₂ ∘ η∞) , inj₂ ∘ inj₂ ] -- | T is a submonad of T∞ χ : T ⇒ T∞ χ = rec sup∞ -- | Kleisli morphsims for T∞ V Subst∞ : Set → Set → Set Subst∞ V W = V → T∞ W infixl 1 _≡ₛ∞_ _≡ₛ∞_ : ∀{V W} → Rel (Subst∞ V W) _ σ ≡ₛ∞ τ = ∀ {v} → σ v ~ τ v infixr 9 _•∞_ -- | Kleisli composition _•∞_ : ∀ {U V W} → Subst∞ V W → Subst∞ U V → Subst∞ U W τ •∞ σ = μ∞ ∘ T∞₁ τ ∘ σ -- | Application of substitutions to infinite terms app∞ : ∀ {V W} → Subst∞ V W → T∞ V → T∞ W app∞ σ = μ∞ ∘ T∞₁ σ isVar∞ : ∀{V} → Pred (T∞ V) _ isVar∞ t with out t isVar∞ t | inj₁ x = ⊥ isVar∞ t | inj₂ v = ⊤ varNowOrLater : ∀{V} → (T∞ V → Pred V _) → T∞ V → Pred V _ varNowOrLater R t v with out t ... | inj₁ (f , α) = ∃ (λ i → R (α i) v) ... | inj₂ v₁ = v ≡ v₁ record fv∞ {V : Set} (t : T∞ V) (v : V) : Set where coinductive field isFv∞ : varNowOrLater fv∞ t v root-matches : ∀{V} → T V → ∥ Σ ∥ → Set root-matches (sup (inj₁ (g , _))) f = g ≡ f root-matches (sup (inj₂ y)) f = ⊥ record RootsMatch {V : Set} (s : Stream (T V)) (f : ∥ Σ ∥) : Set where coinductive field hd-match : root-matches (hd s) f tl-match : RootsMatch (tl s) f open RootsMatch -- | Nasty hack: assume that RootsMatch is propositional postulate RootsMatch-unique : ∀{V} {s : Stream (T V)} {f : ∥ Σ ∥} (p q : RootsMatch s f) → p ≡ q split : {V : Set} (s : Stream (T V)) (f : ∥ Σ ∥) → RootsMatch s f → ar Σ f → Stream (T V) hd (split s f p i) with hd s | hd-match p hd (split s f p i) | sup (inj₁ (.f , α)) | refl = α i hd (split s f p i) | sup (inj₂ y) | () tl (split s f p i) = split (tl s) f (tl-match p) i root-matches∞ : ∀{V} → T∞ V → ∥ Σ ∥ → Set root-matches∞ t f with out t root-matches∞ t f | inj₁ (g , _) = f ≡ g root-matches∞ t f | inj₂ v = ⊥ split∞ : {V : Set} → (t : T∞ V) (f : ∥ Σ ∥) → root-matches∞ t f → ar Σ f → T∞ V split∞ t f p i with out t split∞ t f refl i | inj₁ (.f , α) = α i split∞ t f () i | inj₂ y data AnyRootMatch {V : Set} (s : Stream (T V)) (f : ∥ Σ ∥) : Stream (T V) → Set where match-hd : root-matches (hd s) f → AnyRootMatch s f s match-tl : AnyRootMatch (tl s) f (tl s) → AnyRootMatch s f (tl s) first-root-match : ∀{V} → Stream (T V) → ∥ Σ ∥ → ℕ → Set first-root-match s f = least _≤_ (λ k → root-matches (s at k) f) conv-branch : {V : Set} (R : Stream (T V) → T∞ V → Set) → Stream (T V) → T∞ V → T V → ⟪ Σ ⟫ (T∞ V) ⊎ V → Set conv-branch R s t (sup (inj₁ (f , α))) (inj₁ (g , β)) = ⨿ (f ≡ g) λ p → ⨿ (RootsMatch (tl s) f) λ q → ∀ i → R (split (tl s) f q i) (β (subst (ar Σ) p i)) conv-branch R s t (sup (inj₁ (f , α))) (inj₂ v) = ⊥ conv-branch R s t (sup (inj₂ v)) (inj₁ (f , α)) = ∃ λ s' → AnyRootMatch s f s' × R s' t conv-branch R s t (sup (inj₂ v)) (inj₂ w) = v ≡ w × R (tl s) t -- | A sequence s of finite terms converges to a possibly infinite term, -- if for all i, sᵢ₊₁ = sᵢ[σ] for some substitution σ : V → T V and t = sᵢ[τ] -- for some τ : V → T∞ V. -- Note that this coincides with convergence in the prefix metric. record _→∞_ {V : Set} (s : Stream (T V)) (t : T∞ V) : Set where coinductive field conv-out : conv-branch _→∞_ s t (hd s) (out t) open _→∞_ public {- unique-conv : ∀{V} (s : Stream (T V)) (t₁ t₂ : T∞ V) → s →∞ t₁ → s →∞ t₂ → t₁ ~ t₂ -} ProperlyRefining : ∀{V} → T V → Pred (Subst V V) _ ProperlyRefining t σ = ∀ v → v ∈ fv t → isCons (σ v) record ProperlyRefiningSeq {V : Set} (t : T V) : Set where coinductive field hd-ref : Subst V V hd-is-ref : hd-ref ∈ ProperlyRefining t tl-ref : ProperlyRefiningSeq (app hd-ref t) open ProperlyRefiningSeq public {- refining-on-subterms : ∀{V f α} (t : T V) → t ≡ sup (inj₁ (f , α)) → ProperlyRefiningSeq t → (i : ar Σ f) → ProperlyRefiningSeq (α i) hd-ref (refining-on-subterms ._ refl p i) = hd-ref p hd-is-ref (refining-on-subterms ._ refl p i) = {!!} tl-ref (refining-on-subterms ._ refl p i) = {!!} -- refining-on-subterms {!!} {!!} {!!} {!!} -- | A non-trivial substitution is a substitution σ, such that, for all v ∈ V -- we have that either σ(v) is a non-trivial term or if it is a variable w, then -- w = v. -- This allows us to stop substituting the first time we hit a variable. NonTrivSubst : Set → Set NonTrivSubst V = ⨿ (Subst V V) λ σ → (∀ v → isVar (σ v) → σ v ≡ η v) term-seq-from-subst-seq : ∀{V} (t : T V) → ProperlyRefiningSeq t → Stream (T V) hd (term-seq-from-subst-seq t Δ) = t tl (term-seq-from-subst-seq t Δ) = term-seq-from-subst-seq (app (hd-ref Δ) t) (tl-ref Δ) var-app-lem : ∀{V} → (σ : Subst V V) → ∀ v → app σ (η v) ≡ σ v var-app-lem = {!!} ∞term-from-subst-seq : ∀{V} (t : T V) → ProperlyRefiningSeq t → T∞ V out (∞term-from-subst-seq {V} (sup (inj₁ (f , α))) Δ) = inj₁ (f , β) where β : ar Σ f → T∞ V β i = ∞term-from-subst-seq (α i) (refining-on-subterms (sup (inj₁ (f , α))) refl Δ i) out (∞term-from-subst-seq {V} (sup (inj₂ v)) Δ) = {!!} -- with fv (sup (inj₂ v)) v | hd-ref Δ v | hd-is-ref Δ v refl where g : ∀{σ} → σ ∈ ProperlyRefining (sup (inj₂ v)) → ⟪ Σ ⟫ (T∞ V) g {σ} p with σ v | p v refl g p | sup (inj₁ (f , α)) | tt = f , β where β : ar Σ f → T∞ V β i = ∞term-from-subst-seq (α i) (refining-on-subterms (sup (inj₁ (f , α))) refl {!!} i) g p | sup (inj₂ w) | () -} {- out (∞term-from-subst-seq {V} (sup (inj₂ v)) Δ) | p | sup (inj₁ (f , α)) | tt = inj₁ (f , β {!refl!}) where foo : hd-ref Δ v ≡ sup (inj₁ (f , α)) → app (hd-ref Δ) (sup (inj₂ v)) ≡ sup (inj₁ (f , α)) foo p = begin app (hd-ref Δ) (sup (inj₂ v)) ≡⟨ {!!} ⟩ hd-ref Δ v ≡⟨ {!refl!} ⟩ sup (inj₁ (f , α)) ∎ β : hd-ref Δ v ≡ sup (inj₁ (f , α)) → ar Σ f → T∞ V β p i = ∞term-from-subst-seq (α i) (refining-on-subterms (sup (inj₁ (f , α))) refl (subst ProperlyRefiningSeq {!!} (tl-ref Δ)) i) -- (app (hd-ref Δ) (η v)) (var-app-lem {!!} v) out (∞term-from-subst-seq (sup (inj₂ v)) Δ) | p | sup (inj₂ y) | () -} {- ∞term-from-subst-seq : ∀{V} → Stream (NonTrivSubst V) → T V → T∞ V out (∞term-from-subst-seq Δ (sup (inj₁ (s , α)))) = inj₁ (s , (λ i → ∞term-from-subst-seq Δ (α i))) out (∞term-from-subst-seq Δ (sup (inj₂ v))) with proj₁ (hd Δ) v | proj₂ (hd Δ) v ... | sup (inj₁ (s , α)) | f = inj₁ (s , (λ i → ∞term-from-subst-seq (tl Δ) (α i))) ... | sup (inj₂ v₁) | f with f tt out (∞term-from-subst-seq Δ (sup (inj₂ v))) | sup (inj₂ .v) | f | refl = inj₂ v -} {- ∞term-from-subst-seq-converges : ∀{V} → (Δ : Stream (NonTrivSubst V)) → (t : T V) → term-seq-from-subst-seq Δ t →∞ ∞term-from-subst-seq Δ t -}
{ "alphanum_fraction": 0.5102525532, "avg_line_length": 29.7900943396, "ext": "agda", "hexsha": "4d0a72b9091f9b5703fc6f7922d01707015af67f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hbasold/Sandbox", "max_forks_repo_path": "LP/Terms.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hbasold/Sandbox", "max_issues_repo_path": "LP/Terms.agda", "max_line_length": 95, "max_stars_count": null, "max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hbasold/Sandbox", "max_stars_repo_path": "LP/Terms.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5647, "size": 12631 }
open import Prelude open import Data.Maybe using (Maybe; just; nothing) open import Data.String renaming (_++_ to _++s_) open import RW.Language.RTerm open import RW.Language.RTermUtils open import RW.Language.FinTerm open import RW.Language.Instantiation -- Strategy Module. -- -- Here we'll provide a modular approach to implementing both -- unification and abstraction-guessing strategies based -- on the head of both terms. module RW.Strategy where -- The complexity annotations might require -- a slight notational introduction. -- -- If a variable name overlaps one in the corresponding type signature, -- this is intentional. -- -- Sₜ is defined by (S t). -- #Fvₜ is defined by length (Fv t). -- Both measures are defined at RW.Language.RTermUtils. -- open import RW.Utils.Monads using (module Monad) open import RW.Utils.Error open Monad {{...}} open IsError {{...}} ------------------------- -- Error Layer ------------------------- -- Strategy related errors data StratErr : Set where Nothing : StratErr NoUnification : StratErr NoUStrat : StratErr NoTStrat : RTermName → RTermName → StratErr Custom : String → StratErr instance IsError-StratErr : IsError StratErr IsError-StratErr = record { showError = showErr } where showErr : StratErr → String showErr Nothing = "Nothing; Internal msg passing flag." showErr NoUnification = "No unification could be performed." showErr NoUStrat = "No suitable unification strategy found." showErr (NoTStrat g a) = "No suitable term stragety found.\n" ++s showRTermName g ++s ", " ++s showRTermName a showErr (Custom msg) = "[!] " Data.String.++ msg ------------------------- -- Strategy Pipeline -- -- Whenever we want to perform a rewrite, we'll have a goal and an action to perform on a "subgoal" -- This subgoal has to figured out by us, which we denote by g□. -- Afterwards, we need to somehow apply our action. -- Let's encapsulate everything we need in a record record RWData : Set where constructor rw-data field goal : RBinApp ⊥ actℕ : ℕ act : RBinApp (Fin actℕ) ctx : List (RTerm ⊥) goal-name : RTermName goal-name = p1 goal goal-1 : RTerm ⊥ goal-1 = p1 (p2 goal) goal-2 : RTerm ⊥ goal-2 = p2 (p2 goal) act-name : RTermName act-name = p1 act open RWData -- We might need a few transformations here and there. data Trs : Set where Symmetry : Trs -- Unification data record UData : Set where constructor u-data field -- We should have an abstraction available, □ : RTerm Unit -- A substitution σ : RSubst -- Our action and a few transformations that might need to be applied. trs : List Trs ------------------------- -- Unification Strategy Layer ------------------------- private μ : ∀{a}{A : Set a} → Maybe (Maybe A) → Maybe A μ (just x) = x μ nothing = nothing -- Alternatives infixr 4 _<|>_ _<|>_ : ∀{a b}{A : Set a}{B E : Set b} ⦃ isErr : IsError E ⦄ → (A → Err E B) → (A → Err E B) → A → Err E B (f <|> g) a with f a ...| i1 _ = g a ...| i2b = i2b try-all : ∀{a b}{A : Set a}{B E : Set b} ⦃ isErr : IsError E ⦄ → (A → Err E B) → E → List A → Err E B try-all f e [] = i1 e try-all f e (a ∷ as) with f a ...| i1 _ = try-all f e as ...| i2 r = return r -- Basic unification strategy -- -- g□ ← g₁ ∩↑ g₂ ∈ O(min(Sg₁, Sg₂)) -- t1 ← g□ -↓ g₁ ∈ O(# Fv g□) -- u1 ← inst ty1 t1 ∈ O(ty1n² + (Sty1 + 1) × ty1n + Sty1) -- t2 ← g□ -↓ g₂ ∈ O(# Fv g□) -- u2 ← inst ty2 t2 ∈ O(ty2n² + (Sty2 + 1) × ty2n + Sty2) -- -- Summing everything up and symplifying a bit, we get: -- (Note that S ty = S t₁ + S t₂ + 1) -- -- min(Sg₁, Sg₂) + 2 #(Fv g□) + t₁² + t₂² + Sty₁ ty₁ + Sty2 ty₂ -- + t₁ + t₂ + ST - 1 -- -- Yet, g□, ideally is our context, with one hole, since -- we are doing one rewrite at a time. Therefore #Fv g□ = 1. -- Prunning out this constant we get: -- -- min(Sg₁, Sg₂) + t₁² + t₂² + Sty₁ ty₁ + Sty2 ty₂ + t₁ + t₂ + ST -- -- wlog, let us assume that t₁ ≥ t₂ and Sty1 ≥ Sty2. -- So, -- 2t₁² + 2S₁t₁ + 2t₁ + 2S₁ -- ≥ t₁² + t₂² + Sty₁ ty₁ + Sty2 ty₂ + t₁ + t₂ + ST -- -- Also ignoring min(Sg₁, Sg₂), since it can be seen as a constant, -- Our basic unification strategy is somewhere around: -- -- basic ∈ O(2t(t + S + 1) + 2S), for t = max(t₁ , t₂) -- and S = max(St₁ , St₂) -- -- Which was expected! Our RTermUtils functions are linear in some of -- the parameters that appeared here, and instantiation was the -- only quadratic one, on the number of free variables to instantiate. -- basic : RWData → Err StratErr UData basic (rw-data (hdₓ , g1 , g2) zero (hdₐ , ty1 , ty2) _ ) = let g□ = g1 ∩↑ g2 in i2 (u-data (⊥2UnitCast g□) [] []) basic (rw-data (hdₓ , g1 , g2) tn (hdₐ , ty1 , ty2) _ ) = let g□ = g1 ∩↑ g2 u1 = (g□ -↓ g1) >>= (inst ty1) u2 = (g□ -↓ g2) >>= (inst ty2) σ = μ ((_++ₓ_ <$> u1) <*> u2) in maybe (λ s → i2 (u-data (⊥2UnitCast g□) s [])) (i1 NoUnification) (σ >>= X2RSubst) -- Unification over the symmetric action type. basic-sym : RWData → Err StratErr UData basic-sym (rw-data (hdₓ , g1 , g2) tn (hdₐ , ty1 , ty2) _ ) = let g□ = g1 ∩↑ g2 u1 = (g□ -↓ g1) >>= (inst ty2) u2 = (g□ -↓ g2) >>= (inst ty1) σ = μ ((_++ₓ_ <$> u1) <*> u2) in maybe (λ s → i2 (u-data (⊥2UnitCast g□) s (Symmetry ∷ []))) (i1 NoUnification) (σ >>= X2RSubst) -- Runs the unification strategies we know about -- in the given target terms. runUStrats : RWData → Err StratErr UData runUStrats = basic <|> basic-sym ------------------------- -- Term Strategy Layer ------------------------- -- The Term Guessing Strategy should be plugged right after -- a unification has been succesfuly performed. -- -- Given the head of both our goal and action we -- should be able to guess a term that 'bridges' them. -- record TStrat : Set where field when : RTermName → RTermName → Bool how : Name → UData → Err StratErr (RTerm ⊥) -- For now, we'll use a naive list to implement a TStrat -- database. TStratDB : Set TStratDB = List TStrat -- Utility to run a list of TStrat's. -- Not only returns the resulting term, but also the selected TStrat. runTStrats : TStratDB → RWData → Name → UData → Err StratErr (RTerm ⊥) runTStrats [] rw = λ _ _ → i1 (NoTStrat (goal-name rw) (act-name rw)) runTStrats (s ∷ ss) rw with TStrat.when s (goal-name rw) (act-name rw) ...| false = runTStrats ss rw ...| true = TStrat.how s -- From a name and a substitution create an application. makeApp : Name → RSubst → RTerm ⊥ makeApp act σ = rapp (rdef act) (map p2 σ)
{ "alphanum_fraction": 0.5639518612, "avg_line_length": 32.334841629, "ext": "agda", "hexsha": "0f00ca9c0b9ca8706f5717df1a1d8f92686dc70f", "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": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "VictorCMiraldo/agda-rw", "max_forks_repo_path": "RW/Strategy.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_issues_repo_issues_event_max_datetime": "2015-05-28T14:48:03.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-06T15:03:33.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "VictorCMiraldo/agda-rw", "max_issues_repo_path": "RW/Strategy.agda", "max_line_length": 102, "max_stars_count": 16, "max_stars_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "VictorCMiraldo/agda-rw", "max_stars_repo_path": "RW/Strategy.agda", "max_stars_repo_stars_event_max_datetime": "2019-10-24T17:38:20.000Z", "max_stars_repo_stars_event_min_datetime": "2015-02-09T15:43:38.000Z", "num_tokens": 2405, "size": 7146 }
------------------------------------------------------------------------------ -- Foo module ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module Foo where postulate foo : Set
{ "alphanum_fraction": 0.3072916667, "avg_line_length": 29.5384615385, "ext": "agda", "hexsha": "dfb94dd87badab311fd37147053d85fde37ab24c", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z", "max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/apia", "max_forks_repo_path": "test/Succeed/NonConjectures/Foo.agda", "max_issues_count": 121, "max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/apia", "max_issues_repo_path": "test/Succeed/NonConjectures/Foo.agda", "max_line_length": 78, "max_stars_count": 10, "max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/apia", "max_stars_repo_path": "test/Succeed/NonConjectures/Foo.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z", "num_tokens": 50, "size": 384 }
------------------------------------------------------------------------ -- Sizes for Agda's sized types ------------------------------------------------------------------------ module Size where postulate Size : Set ↑_ : Size → Size ∞ : Size {-# BUILTIN SIZE Size #-} {-# BUILTIN SIZESUC ↑_ #-} {-# BUILTIN SIZEINF ∞ #-}
{ "alphanum_fraction": 0.3226744186, "avg_line_length": 22.9333333333, "ext": "agda", "hexsha": "4cb481b6d0e10ab868f2a464d754b70fc78e8826", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Size.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Size.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Size.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 67, "size": 344 }
open import IO main = run (putStr "Hello, World!")
{ "alphanum_fraction": 0.6730769231, "avg_line_length": 13, "ext": "agda", "hexsha": "dfb384c7c5c00683e724b58d5f4114727818be4d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-05-10T13:28:32.000Z", "max_forks_repo_forks_event_min_datetime": "2021-05-10T13:28:32.000Z", "max_forks_repo_head_hexsha": "5434416e6b0468a4c06ff7575540f186c38fc58d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Andaraz/hello-world", "max_forks_repo_path": "agda.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "5434416e6b0468a4c06ff7575540f186c38fc58d", "max_issues_repo_issues_event_max_datetime": "2021-03-28T09:19:58.000Z", "max_issues_repo_issues_event_min_datetime": "2021-03-28T09:19:07.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Andaraz/hello-world", "max_issues_repo_path": "agda.agda", "max_line_length": 35, "max_stars_count": 3, "max_stars_repo_head_hexsha": "5434416e6b0468a4c06ff7575540f186c38fc58d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Andaraz/hello-world", "max_stars_repo_path": "agda.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-24T03:20:51.000Z", "max_stars_repo_stars_event_min_datetime": "2021-03-23T13:03:38.000Z", "num_tokens": 15, "size": 52 }
{-# OPTIONS --safe #-} module Mod where open import Data.Fin open import Data.Nat as ℕ using (ℕ; zero; suc; z≤n; s≤s) open import Relation.Binary.PropositionalEquality open import Function private variable k : ℕ last : Fin (suc k) last {k = zero} = zero last {k = suc _} = suc last negate : Fin k -> Fin k negate zero = zero negate (suc zero) = last negate (suc (suc n)) = inject₁ (negate (suc n)) subt : Fin k -> Fin k -> Fin k subt n zero = n subt zero (suc m) = negate (suc m) subt (suc n) (suc m) with (compare n m) ...| less _ _ = suc (subt n m) ...| _ = inject₁ (subt n m) add : Fin k -> Fin k -> Fin k add n m = subt n (negate m) multAux : ∀{n} → ℕ → (Fin n → Fin n) → Fin n → Fin n multAux zero _ x = x multAux (suc n) f x = multAux n f (f x) mult : Fin k -> Fin k -> Fin k mult zero m = zero mult (suc n) m = multAux (toℕ n) (add m) zero zer : Fin 5 zer = zero one : Fin 5 one = suc zero two : Fin 5 two = suc (suc zero) three : Fin 5 three = suc (suc (suc zero)) four : Fin 5 four = suc (suc (suc (suc zero)))
{ "alphanum_fraction": 0.6149369544, "avg_line_length": 21.0408163265, "ext": "agda", "hexsha": "6ec124d5df04db871970d00ac8c8f2f46aeb620f", "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/Mod.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/Mod.agda", "max_line_length": 52, "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/Mod.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": 396, "size": 1031 }
module BasicIS4.Metatheory.Hilbert-BasicKripkeOno where open import BasicIS4.Syntax.Hilbert public open import BasicIS4.Semantics.BasicKripkeOno public -- Soundness with respect to all models, or evaluation. eval : ∀ {A Γ} → Γ ⊢ A → Γ ⊨ A eval (var i) γ = lookup i γ eval (app {A} {B} t u) γ = _⟪$⟫_ {A} {B} (eval t γ) (eval u γ) eval ci γ = K I eval (ck {A} {B}) γ = K (⟪K⟫ {A} {B}) eval (cs {A} {B} {C}) γ = K (⟪S⟫′ {A} {B} {C}) eval (box t) γ = λ ζ → eval t ∙ eval (cdist {A} {B}) γ = K (_⟪D⟫′_ {A} {B}) eval (cup {A}) γ = K (⟪↑⟫ {A}) eval (cdown {A}) γ = K (⟪↓⟫ {A}) eval (cpair {A} {B}) γ = K (_⟪,⟫′_ {A} {B}) eval cfst γ = K π₁ eval csnd γ = K π₂ eval unit γ = ∙ -- TODO: Correctness of evaluation with respect to conversion.
{ "alphanum_fraction": 0.5107655502, "avg_line_length": 32.1538461538, "ext": "agda", "hexsha": "7590fb526611292f1be2f16160ffa8912c0d6a3e", "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": "BasicIS4/Metatheory/Hilbert-BasicKripkeOno.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": "BasicIS4/Metatheory/Hilbert-BasicKripkeOno.agda", "max_line_length": 62, "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": "BasicIS4/Metatheory/Hilbert-BasicKripkeOno.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": 343, "size": 836 }
-- Andreas, 2017-10-09, issue #2576 -- Duplicate definition should be reported as such, -- not as "Missing type signature." data ⊥ : Set where data ⊥ where -- Error was: Missing type signature for ⊥ -- Expected error: Duplicate definition
{ "alphanum_fraction": 0.7190082645, "avg_line_length": 22, "ext": "agda", "hexsha": "547b77ce8de1475cf2f810158b27f97a176d3fa0", "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/Fail/Issue2576.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/Fail/Issue2576.agda", "max_line_length": 51, "max_stars_count": 1, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Fail/Issue2576.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": 63, "size": 242 }
{-# OPTIONS --cubical --no-import-sorts #-} module Number.Prettyprint where open import Cubical.Data.Sigma.Base open import Number.Postulates open import Number.Base [ℕ] = Number (isNat , anyPositivityᵒʳ) [ℕ⁺⁻] = Number (isNat , isNonzeroᵒʳ ) [ℕ₀⁺] = Number (isNat , isNonnegativeᵒʳ) [ℕ⁺] = Number (isNat , isPositiveᵒʳ ) [ℕ₀⁻] = Number (isNat , isNonpositiveᵒʳ) [ℤ] = Number (isInt , anyPositivityᵒʳ) [ℤ⁺⁻] = Number (isInt , isNonzeroᵒʳ ) [ℤ₀⁺] = Number (isInt , isNonnegativeᵒʳ) [ℤ⁺] = Number (isInt , isPositiveᵒʳ ) [ℤ⁻] = Number (isInt , isNegativeᵒʳ ) [ℤ₀⁻] = Number (isInt , isNonpositiveᵒʳ) [ℚ] = Number (isRat , anyPositivityᵒʳ) [ℚ⁺⁻] = Number (isRat , isNonzeroᵒʳ ) [ℚ₀⁺] = Number (isRat , isNonnegativeᵒʳ) [ℚ⁺] = Number (isRat , isPositiveᵒʳ ) [ℚ⁻] = Number (isRat , isNegativeᵒʳ ) [ℚ₀⁻] = Number (isRat , isNonpositiveᵒʳ) [ℝ] = Number (isReal , anyPositivityᵒʳ) [ℝ⁺⁻] = Number (isReal , isNonzeroᵒʳ ) [ℝ₀⁺] = Number (isReal , isNonnegativeᵒʳ) [ℝ⁺] = Number (isReal , isPositiveᵒʳ ) [ℝ⁻] = Number (isReal , isNegativeᵒʳ ) [ℝ₀⁻] = Number (isReal , isNonpositiveᵒʳ) [ℂ] = Number (isComplex , anyPositivityᶠ ) [ℂ⁺⁻] = Number (isComplex , isNonzeroᶠ ) {-# DISPLAY Number (isNat , anyPositivityᵒʳ) = [ℕ] #-} {-# DISPLAY Number (isNat , isNonzeroᵒʳ ) = [ℕ⁺⁻] #-} {-# DISPLAY Number (isNat , isNonnegativeᵒʳ) = [ℕ₀⁺] #-} {-# DISPLAY Number (isNat , isPositiveᵒʳ ) = [ℕ⁺] #-} {-# DISPLAY Number (isNat , isNonpositiveᵒʳ) = [ℕ₀⁻] #-} {-# DISPLAY Number (isInt , anyPositivityᵒʳ) = [ℤ] #-} {-# DISPLAY Number (isInt , isNonzeroᵒʳ ) = [ℤ⁺⁻] #-} {-# DISPLAY Number (isInt , isNonnegativeᵒʳ) = [ℤ₀⁺] #-} {-# DISPLAY Number (isInt , isPositiveᵒʳ ) = [ℤ⁺] #-} {-# DISPLAY Number (isInt , isNegativeᵒʳ ) = [ℤ⁻] #-} {-# DISPLAY Number (isInt , isNonpositiveᵒʳ) = [ℤ₀⁻] #-} {-# DISPLAY Number (isRat , anyPositivityᵒʳ) = [ℚ] #-} {-# DISPLAY Number (isRat , isNonzeroᵒʳ ) = [ℚ⁺⁻] #-} {-# DISPLAY Number (isRat , isNonnegativeᵒʳ) = [ℚ₀⁺] #-} {-# DISPLAY Number (isRat , isPositiveᵒʳ ) = [ℚ⁺] #-} {-# DISPLAY Number (isRat , isNegativeᵒʳ ) = [ℚ⁻] #-} {-# DISPLAY Number (isRat , isNonpositiveᵒʳ) = [ℚ₀⁻] #-} {-# DISPLAY Number (isReal , anyPositivityᵒʳ) = [ℝ] #-} {-# DISPLAY Number (isReal , isNonzeroᵒʳ ) = [ℝ⁺⁻] #-} {-# DISPLAY Number (isReal , isNonnegativeᵒʳ) = [ℝ₀⁺] #-} {-# DISPLAY Number (isReal , isPositiveᵒʳ ) = [ℝ⁺] #-} {-# DISPLAY Number (isReal , isNegativeᵒʳ ) = [ℝ⁻] #-} {-# DISPLAY Number (isReal , isNonpositiveᵒʳ) = [ℝ₀⁻] #-} {-# DISPLAY Number (isComplex , anyPositivityᶠ ) = [ℂ] #-} {-# DISPLAY Number (isComplex , isNonzeroᶠ ) = [ℂ⁺⁻] #-}
{ "alphanum_fraction": 0.5723404255, "avg_line_length": 47, "ext": "agda", "hexsha": "b479f76692af1992081c49271a55f616c3585551", "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": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "agda/Number/Prettyprint.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "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": "mchristianl/synthetic-reals", "max_issues_repo_path": "agda/Number/Prettyprint.agda", "max_line_length": 60, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "agda/Number/Prettyprint.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 1264, "size": 2820 }
module Categories.Functor.Coalgebra where
{ "alphanum_fraction": 0.880952381, "avg_line_length": 21, "ext": "agda", "hexsha": "b5c373f7769ed19bc9472b867946ec9dafbe4c64", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Functor/Coalgebra.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Functor/Coalgebra.agda", "max_line_length": 41, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Functor/Coalgebra.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 10, "size": 42 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Functions.Definition open import LogicalFormulae open import Numbers.Naturals.Definition open import Sets.FinSet.Definition open import Sets.FinSet.Lemmas module Sets.Cardinality.Finite.Lemmas where finsetInjectIntoℕ : {n : ℕ} → Injection (toNat {n}) finsetInjectIntoℕ {zero} {()} finsetInjectIntoℕ {succ n} = ans where ans : {n : ℕ} → {x y : FinSet (succ n)} → (toNat x ≡ toNat y) → x ≡ y ans {zero} {fzero} {fzero} _ = refl ans {zero} {fzero} {fsucc ()} ans {zero} {fsucc ()} {y} ans {succ n} {fzero} {fzero} pr = refl ans {succ n} {fzero} {fsucc y} () ans {succ n} {fsucc x} {fzero} () ans {succ n} {fsucc x} {fsucc y} pr with succInjective pr ... | pr' = applyEquality fsucc (ans {n} {x} {y} pr')
{ "alphanum_fraction": 0.6385093168, "avg_line_length": 33.5416666667, "ext": "agda", "hexsha": "e734dc7070a272880b05f77c9a19771f5f72fdc1", "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": "Sets/Cardinality/Finite/Lemmas.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": "Sets/Cardinality/Finite/Lemmas.agda", "max_line_length": 73, "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": "Sets/Cardinality/Finite/Lemmas.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": 286, "size": 805 }
open import Prelude open import Data.List.Properties open import Data.List.Any hiding (map) open import Data.List.All as All hiding (map; lookup) open import Data.Vec open import Extensions.Vec module Implicits.Resolution.Deterministic.Semantics where open import Implicits.Syntax open import Implicits.Resolution.Deterministic.Resolution open import Implicits.Substitutions open import Implicits.Substitutions.Lemmas open import Implicits.Semantics open import Implicits.Semantics.Lemmas open import Extensions.ListFirst open import SystemF.Everything as F using () module DerivationSemantics where ⟦_,_⟧r : ∀ {ν n} {K : Ktx ν n} {a} → (proj₂ K) ⊢ᵣ a → K# K → ∃ λ t → ⟦ proj₁ K ⟧ctx→ F.⊢ t ∈ ⟦ a ⟧tp→ ⟦_,_⟧r {K = K} (r-simp {ρ = r} r∈Δ r↓τ) m with ∈⟶index (All.lookup m (proj₁ $ first⟶∈ r∈Δ)) ⟦_,_⟧r {K = K} (r-simp {ρ = r} r∈Δ r↓τ) m | i , lookup-i≡r = ⟦ subst (λ u → _ F.⊢ F.var i ∈ u) eq (F.var i) , r↓τ , m ⟧r↓ where eq = begin lookup i ⟦ proj₁ K ⟧ctx→ ≡⟨ sym $ lookup-⟦⟧ctx→ (proj₁ K) i ⟩ ⟦ lookup i (proj₁ K) ⟧tp→ ≡⟨ cong ⟦_⟧tp→ lookup-i≡r ⟩ ⟦ r ⟧tp→ ∎ ⟦_,_,_⟧r↓ : ∀ {ν n} {K : Ktx ν n} {a ta τ} → ⟦ proj₁ K ⟧ctx→ F.⊢ ta ∈ ⟦ a ⟧tp→ → (proj₂ K) ⊢ a ↓ τ → K# K → ∃ λ tτ → ⟦ proj₁ K ⟧ctx→ F.⊢ tτ ∈ ⟦ simpl τ ⟧tp→ ⟦ ⊢ta , i-simp τ , m ⟧r↓ = , ⊢ta ⟦ ⊢ta , i-iabs {ρ₁ = a} ⊢ᵣa b↓τ , m ⟧r↓ = , (proj₂ ⟦ ⊢ta F.· (proj₂ ⟦ ⊢ᵣa , m ⟧r) , b↓τ , m ⟧r↓) ⟦ ⊢ta , i-tabs {ρ = a} b p , m ⟧r↓ = ⟦ subst (λ u → _ F.⊢ _ ∈ u) (sym $ ⟦a/sub⟧tp→ a b) (⊢ta F.[ ⟦ b ⟧tp→ ]) , p , m ⟧r↓ ⟦ r-iabs a {ρ₂ = b} ⊢b , m ⟧r = , F.λ' ⟦ a ⟧tp→ (proj₂ ⟦ ⊢b , #ivar a m ⟧r) ⟦_,_⟧r {K = K} (r-tabs {ρ = r} p) m with ⟦ p , #tvar m ⟧r ⟦_,_⟧r {K = K} (r-tabs {ρ = r} p) m | _ , x = , F.Λ (subst (λ u → u F.⊢ _ ∈ ⟦ r ⟧tp→) (⟦weaken⟧ctx→ (proj₁ K)) x) open Semantics _⊢ᵣ_ DerivationSemantics.⟦_,_⟧r public
{ "alphanum_fraction": 0.5325077399, "avg_line_length": 38, "ext": "agda", "hexsha": "86917ab1dea4f2703a6ba2b4f84bb229f454e8e6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Implicits/Resolution/Deterministic/Semantics.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Implicits/Resolution/Deterministic/Semantics.agda", "max_line_length": 93, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Implicits/Resolution/Deterministic/Semantics.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 907, "size": 1938 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Properties.Reflexivity {{eqrel : EqRelSet}} where open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Weakening open import Definition.Typed.Properties open import Definition.LogicalRelation open import Tools.Product import Tools.PropositionalEquality as PE -- Reflexivity of reducible types. reflEq : ∀ {l Γ A} ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ A ≡ A / [A] reflEq (Uᵣ′ l′ l< ⊢Γ) = PE.refl reflEq (ℕᵣ D) = red D reflEq (Emptyᵣ D) = red D reflEq (Unitᵣ D) = red D reflEq (ne′ K [ ⊢A , ⊢B , D ] neK K≡K) = ne₌ _ [ ⊢A , ⊢B , D ] neK K≡K reflEq (Bᵣ′ W F G [ ⊢A , ⊢B , D ] ⊢F ⊢G A≡A [F] [G] G-ext) = B₌ _ _ D A≡A (λ ρ ⊢Δ → reflEq ([F] ρ ⊢Δ)) (λ ρ ⊢Δ [a] → reflEq ([G] ρ ⊢Δ [a])) reflEq (emb 0<1 [A]) = reflEq [A] reflNatural-prop : ∀ {Γ n} → Natural-prop Γ n → [Natural]-prop Γ n n reflNatural-prop (sucᵣ (ℕₜ n d t≡t prop)) = sucᵣ (ℕₜ₌ n n d d t≡t (reflNatural-prop prop)) reflNatural-prop zeroᵣ = zeroᵣ reflNatural-prop (ne (neNfₜ neK ⊢k k≡k)) = ne (neNfₜ₌ neK neK k≡k) reflEmpty-prop : ∀ {Γ n} → Empty-prop Γ n → [Empty]-prop Γ n n reflEmpty-prop (ne (neNfₜ neK ⊢k k≡k)) = ne (neNfₜ₌ neK neK k≡k) -- Reflexivity of reducible terms. reflEqTerm : ∀ {l Γ A t} ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ t ∷ A / [A] → Γ ⊩⟨ l ⟩ t ≡ t ∷ A / [A] reflEqTerm (Uᵣ′ ⁰ 0<1 ⊢Γ) (Uₜ A d typeA A≡A [A]) = Uₜ₌ A A d d typeA typeA A≡A [A] [A] (reflEq [A]) reflEqTerm (ℕᵣ D) (ℕₜ n [ ⊢t , ⊢u , d ] t≡t prop) = ℕₜ₌ n n [ ⊢t , ⊢u , d ] [ ⊢t , ⊢u , d ] t≡t (reflNatural-prop prop) reflEqTerm (Emptyᵣ D) (Emptyₜ n [ ⊢t , ⊢u , d ] t≡t prop) = Emptyₜ₌ n n [ ⊢t , ⊢u , d ] [ ⊢t , ⊢u , d ] t≡t (reflEmpty-prop prop) reflEqTerm (Unitᵣ D) (Unitₜ n [ ⊢t , ⊢u , d ] prop) = Unitₜ₌ ⊢t ⊢t reflEqTerm (ne′ K D neK K≡K) (neₜ k d (neNfₜ neK₁ ⊢k k≡k)) = neₜ₌ k k d d (neNfₜ₌ neK₁ neK₁ k≡k) reflEqTerm (Bᵣ′ BΠ F G D ⊢F ⊢G A≡A [F] [G] G-ext) [t]@(Πₜ f d funcF f≡f [f] [f]₁) = Πₜ₌ f f d d funcF funcF f≡f [t] [t] (λ ρ ⊢Δ [a] → [f] ρ ⊢Δ [a] [a] (reflEqTerm ([F] ρ ⊢Δ) [a])) reflEqTerm (Bᵣ′ BΣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) [t]@(Σₜ p d pProd p≅p [fst] [snd]) = Σₜ₌ p p d d pProd pProd p≅p [t] [t] [fst] [fst] (reflEqTerm ([F] id (wf ⊢F)) [fst]) (reflEqTerm ([G] id (wf ⊢F) [fst]) [snd]) reflEqTerm (emb 0<1 [A]) t = reflEqTerm [A] t
{ "alphanum_fraction": 0.5453451043, "avg_line_length": 36.115942029, "ext": "agda", "hexsha": "7be4112b7a131f0a87ce1dea7e8cf88dded35ded", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Vtec234/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Properties/Reflexivity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Vtec234/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Properties/Reflexivity.agda", "max_line_length": 86, "max_stars_count": null, "max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Vtec234/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Properties/Reflexivity.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1268, "size": 2492 }
open import Agda.Primitive using (_⊔_) import Categories.Category as Category import Categories.Category.Cartesian as Cartesian import SingleSorted.Interpretation as Interpretation open import SingleSorted.AlgebraicTheory open import SingleSorted.Substitution import SingleSorted.Power as Power module SingleSorted.Model {o ℓ e ℓt} {Σ : Signature} (T : Theory ℓt Σ) {𝒞 : Category.Category o ℓ e} (cartesian-𝒞 : Cartesian.Cartesian 𝒞) where -- Model of a theory record Model (I : Interpretation.Interpretation Σ cartesian-𝒞) : Set (ℓt ⊔ o ⊔ ℓ ⊔ e) where open Theory T open Category.Category 𝒞 open Interpretation.Interpretation I open HomReasoning field model-eq : ∀ (ε : ax) → interp-term (ax-lhs ε) ≈ interp-term (ax-rhs ε) -- Soundness of semantics module _ where open Power.Powered interp-pow -- first we show that substitution preserves validity model-resp-[]s : ∀ {Γ Δ} {u v : Term Γ} {σ : Δ ⇒s Γ} → interp-term u ≈ interp-term v → interp-term (u [ σ ]s) ≈ interp-term (v [ σ ]s) model-resp-[]s {u = u} {v = v} {σ = σ} ξ = begin interp-term (u [ σ ]s) ≈⟨ interp-[]s {t = u} ⟩ (interp-term u ∘ interp-subst σ) ≈⟨ ξ ⟩∘⟨refl ⟩ (interp-term v ∘ interp-subst σ) ≈˘⟨ interp-[]s {t = v} ⟩ interp-term (v [ σ ]s) ∎ -- the soundness statement model-⊢-≈ : ∀ {Γ} {s t : Term Γ} → Γ ⊢ s ≈ t → interp-term s ≈ interp-term t model-⊢-≈ eq-refl = Equiv.refl model-⊢-≈ (eq-symm ξ) = ⟺ (model-⊢-≈ ξ) model-⊢-≈ (eq-tran ξ θ) = (model-⊢-≈ ξ) ○ (model-⊢-≈ θ) model-⊢-≈ (eq-congr ξ) = ∘-resp-≈ʳ (unique (λ i → project ○ model-⊢-≈ (eq-symm (ξ i)))) model-⊢-≈ (eq-axiom ε σ) = model-resp-[]s {u = ax-lhs ε} {v = ax-rhs ε} (model-eq ε) -- Every theory has the trivial model, whose carrier is the terminal object Trivial : Model (Interpretation.Trivial Σ cartesian-𝒞) Trivial = let open Cartesian.Cartesian cartesian-𝒞 in record { model-eq = λ ε → !-unique₂ }
{ "alphanum_fraction": 0.5946205572, "avg_line_length": 37.1785714286, "ext": "agda", "hexsha": "b1195dfc604b72518474d8fa2d95c9931eef2f34", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z", "max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z", "max_forks_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/formaltt", "max_forks_repo_path": "src/SingleSorted/Model.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejbauer/formaltt", "max_issues_repo_path": "src/SingleSorted/Model.agda", "max_line_length": 102, "max_stars_count": 21, "max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cilinder/formaltt", "max_stars_repo_path": "src/SingleSorted/Model.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-19T15:50:08.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-16T14:07:06.000Z", "num_tokens": 755, "size": 2082 }
module exampleEquivalenceLambdaNotations2 where postulate A : Set g : A -> A g = \x -> x g' : A -> A g' a = a postulate P : (A -> A) -> Set f : P g -> P g' f x = x
{ "alphanum_fraction": 0.5470588235, "avg_line_length": 10.625, "ext": "agda", "hexsha": "60b76d455aa239c9826467bceff6b495deace199", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_path": "tests/covered/exampleEquivalenceLambdaNotations2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejtokarcik/agda-semantics", "max_issues_repo_path": "tests/covered/exampleEquivalenceLambdaNotations2.agda", "max_line_length": 47, "max_stars_count": 3, "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_path": "tests/covered/exampleEquivalenceLambdaNotations2.agda", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "num_tokens": 67, "size": 170 }
{-# OPTIONS --safe #-} module Cubical.Data.Graph where open import Cubical.Data.Graph.Base public open import Cubical.Data.Graph.Examples public open import Cubical.Data.Graph.Path public
{ "alphanum_fraction": 0.7936507937, "avg_line_length": 27, "ext": "agda", "hexsha": "6a54d76f29cddc20a5409b785f6d1db327669958", "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/Data/Graph.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/Data/Graph.agda", "max_line_length": 46, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Data/Graph.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 40, "size": 189 }
module Human.Int where open import Human.Nat open import Human.String infix 8 pos data Int : Set where pos : (n : Nat) → Int negsuc : (n : Nat) → Int {-# BUILTIN INTEGER Int #-} {-# BUILTIN INTEGERPOS pos #-} {-# BUILTIN INTEGERNEGSUC negsuc #-} primitive primShowInteger : Int → String
{ "alphanum_fraction": 0.6401273885, "avg_line_length": 18.4705882353, "ext": "agda", "hexsha": "bdfd9420072b12ca083b7b3235b6974bb26a26d0", "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": "b509eb4c4014605facfb4ee5c807cd07753d4477", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MaisaMilena/JuiceMaker", "max_forks_repo_path": "src/Human/Int.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477", "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": "MaisaMilena/JuiceMaker", "max_issues_repo_path": "src/Human/Int.agda", "max_line_length": 40, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MaisaMilena/JuiceMaker", "max_stars_repo_path": "src/Human/Int.agda", "max_stars_repo_stars_event_max_datetime": "2020-11-28T05:46:27.000Z", "max_stars_repo_stars_event_min_datetime": "2019-03-29T17:35:20.000Z", "num_tokens": 90, "size": 314 }
module Data.Product.Instance where open import Class.Equality open import Class.Monoid open import Class.Show open import Data.Product open import Data.Product.Properties open import Data.String.Instance open import Relation.Nullary open import Relation.Binary.PropositionalEquality instance Product-Eq : ∀ {A B} {{_ : Eq A}} {{_ : Eq B}} -> Eq (A × B) Product-Eq {A} {B} = record { _≟_ = ≡-dec _≟_ _≟_ } Product-Monoid : ∀ {a} {A B : Set a} -> {{_ : Monoid A}} -> {{_ : Monoid B}} -> Monoid (A × B) Product-Monoid = record { mzero = mzero , mzero ; _+_ = λ { (x1 , x2) (y1 , y2) -> (x1 + y1) , (x2 + y2) } } Product-Show : ∀ {a} {A B : Set a} {{_ : Show A}} {{_ : Show B}} -> Show (A × B) Product-Show = record { show = λ { (a , b) -> "(" + show a + ", " + show b + ")" } }
{ "alphanum_fraction": 0.5844806008, "avg_line_length": 34.7391304348, "ext": "agda", "hexsha": "85c4ed16eea1beb0d1d3ff23402778f44c9b9cab", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_path": "stdlib-exts/Data/Product/Instance.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_path": "stdlib-exts/Data/Product/Instance.agda", "max_line_length": 96, "max_stars_count": 35, "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_path": "stdlib-exts/Data/Product/Instance.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "num_tokens": 282, "size": 799 }
{-# OPTIONS --without-K --exact-split #-} module polynomial-rings where import rings open rings public {- We state the universal property of the polynomial ring R[x]. -} precomp-universal-property-polynomial-Ring : {l1 l2 l3 : Level} (R : Ring l1) (S : Ring l2) (T : Ring l3) (f : hom-Ring R S) (s : type-Ring S) → hom-Ring S T → (hom-Ring R T) × (type-Ring T) precomp-universal-property-polynomial-Ring R S T f s g = pair (comp-hom-Ring R S T g f) (map-hom-Ring S T g s) universal-property-polynomial-Ring : (l : Level) {l1 l2 : Level} (R : Ring l1) (S : Ring l2) (f : hom-Ring R S) (s : type-Ring S) → UU (lsuc l ⊔ l1 ⊔ l2) universal-property-polynomial-Ring l R S f s = (T : Ring l) → is-equiv (precomp-universal-property-polynomial-Ring R S T f s)
{ "alphanum_fraction": 0.6507115136, "avg_line_length": 33.6086956522, "ext": "agda", "hexsha": "91287b104a667e38346c626e5cf65b51adb654cd", "lang": "Agda", "max_forks_count": 30, "max_forks_repo_forks_event_max_datetime": "2022-03-16T00:33:50.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-26T09:08:57.000Z", "max_forks_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_forks_repo_path": "Agda/polynomial-rings.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_issues_repo_issues_event_max_datetime": "2020-10-16T15:27:01.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-18T04:16:04.000Z", "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_issues_repo_path": "Agda/polynomial-rings.agda", "max_line_length": 66, "max_stars_count": 333, "max_stars_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_stars_repo_path": "Agda/polynomial-rings.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:50:15.000Z", "max_stars_repo_stars_event_min_datetime": "2018-09-26T08:33:30.000Z", "num_tokens": 270, "size": 773 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Ring.Kernel where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Structure open import Cubical.Foundations.HLevels open import Cubical.Foundations.Powerset open import Cubical.Algebra.Ring.Base open import Cubical.Algebra.Ring.Properties open import Cubical.Algebra.Ring.Ideal private variable ℓ : Level module _ {{R S : Ring {ℓ}}} (f′ : RingHom R S) where open RingHom f′ open HomTheory f′ open RingStr ⦃...⦄ open isIdeal open Theory private instance _ = R _ = S _ = snd R _ = snd S kernel : ⟨ R ⟩ → hProp ℓ kernel x = (f x ≡ 0r) , isSetRing S _ _ kernelIsIdeal : isIdeal R kernel +-closed kernelIsIdeal = λ fx≡0 fy≡0 → f (_ + _) ≡⟨ isHom+ _ _ ⟩ f _ + f _ ≡⟨ cong (λ u → u + f _) fx≡0 ⟩ 0r + f _ ≡⟨ cong (λ u → 0r + u) fy≡0 ⟩ 0r + 0r ≡⟨ 0-idempotent S ⟩ 0r ∎ -closed kernelIsIdeal = λ fx≡0 → f (- _) ≡⟨ -commutesWithHom _ ⟩ - f _ ≡⟨ cong -_ fx≡0 ⟩ - 0r ≡⟨ 0-selfinverse S ⟩ 0r ∎ 0r-closed kernelIsIdeal = f 0r ≡⟨ homPres0 ⟩ 0r ∎ ·-closedLeft kernelIsIdeal = λ r fx≡0 → f (r · _) ≡⟨ isHom· _ _ ⟩ f r · f (_) ≡⟨ cong (λ u → f r · u) fx≡0 ⟩ f r · 0r ≡⟨ 0-rightNullifies S _ ⟩ 0r ∎ ·-closedRight kernelIsIdeal = λ r fx≡0 → f (_ · r) ≡⟨ isHom· _ _ ⟩ f _ · f r ≡⟨ cong (λ u → u · f r) fx≡0 ⟩ 0r · f r ≡⟨ 0-leftNullifies S _ ⟩ 0r ∎
{ "alphanum_fraction": 0.5465187924, "avg_line_length": 28.4736842105, "ext": "agda", "hexsha": "a146f89ccc858025434b05890c50382f0b9766e6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_path": "Cubical/Algebra/Ring/Kernel.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "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": "Schippmunk/cubical", "max_issues_repo_path": "Cubical/Algebra/Ring/Kernel.agda", "max_line_length": 59, "max_stars_count": null, "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_path": "Cubical/Algebra/Ring/Kernel.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 658, "size": 1623 }
module BBHeap {A : Set}(_≤_ : A → A → Set) where open import BHeap _≤_ hiding (forget ; # ; flatten) open import Bound.Lower A open import Bound.Lower.Order _≤_ open import BTree {A} hiding (flatten) open import Data.Nat open import Data.List mutual data BBHeap : Bound → Set where leaf : {b : Bound} → BBHeap b left : {b : Bound}{x : A}{l r : BBHeap (val x)} → LeB b (val x) → l ⋘ r → BBHeap b right : {b : Bound}{x : A}{l r : BBHeap (val x)} → LeB b (val x) → l ⋙ r → BBHeap b data _≃_ : {b b' : Bound} → BBHeap b → BBHeap b' → Set where ≃lf : {b b' : Bound} → leaf {b} ≃ leaf {b'} ≃nd : {b b' : Bound}{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 ≃ r → l' ≃ r' → l ≃ l' → (left b≤x l⋘r) ≃ (left b'≤x' l'⋘r') data _⋘_ : {b b' : Bound} → BBHeap b → BBHeap b' → Set where lf⋘ : {b b' : Bound} → leaf {b} ⋘ leaf {b'} ll⋘ : {b b' : Bound}{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'≃r' : l' ≃ r') → r ≃ l' → (left b≤x l⋘r) ⋘ (left b'≤x' l'⋘r') lr⋘ : {b b' : Bound}{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'≃r' : l' ≃ r') → l ⋗ l' → (right b≤x l⋙r) ⋘ (left b'≤x' l'⋘r') data _⋙_ : {b b' : Bound} → BBHeap b → BBHeap b' → Set where ⋙lf : {b b' : Bound}{x : A} → (b≤x : LeB b (val x)) → (left b≤x lf⋘) ⋙ leaf {b'} ⋙rl : {b b' : Bound}{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'⋘r' : l' ⋘ r') → l ⋗ r' → (left b≤x l⋘r) ⋙ (left b'≤x' l'⋘r') ⋙rr : {b b' : Bound}{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'⋙r' : l' ⋙ r') → l ≃ l' → (left b≤x l⋘r) ⋙ (right b'≤x' l'⋙r') data _⋗_ : {b b' : Bound} → BBHeap b → BBHeap b' → Set where ⋗lf : {b b' : Bound}{x : A} → (b≤x : LeB b (val x)) → (left b≤x lf⋘) ⋗ (leaf {b'}) ⋗nd : {b b' : Bound}{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 ≃ r → l' ≃ r' → l ⋗ l' → (left b≤x l⋘r) ⋗ (left b'≤x' l'⋘r') # : {b : Bound} → BBHeap b → ℕ # leaf = zero # (left {l = l} {r = r} _ _) = suc (# l + # r) # (right {l = l} {r = r} _ _) = suc (# l + # r) relax : {b : Bound}(h : BBHeap b) → BHeap b relax leaf = lf relax (left {l = l} {r = r} b≤x _) = nd b≤x (relax l) (relax r) relax (right {l = l} {r = r} b≤x _) = nd b≤x (relax l) (relax r) forget : {b : Bound}(h : BBHeap b) → BTree forget leaf = leaf forget (left {x = x} {l = l} {r = r} _ _) = node x (forget l) (forget r) forget (right {x = x} {l = l} {r = r} _ _) = node x (forget l) (forget r) flatten : {b : Bound} → BBHeap b → List A flatten leaf = [] flatten (left {x = x} {l = l} {r = r} _ _) = x ∷ flatten l ++ flatten r flatten (right {x = x} {l = l} {r = r} _ _) = x ∷ flatten l ++ flatten r
{ "alphanum_fraction": 0.344203761, "avg_line_length": 38.1909090909, "ext": "agda", "hexsha": "65a3372e09b90d5a4e875297bec5dc541c49656d", "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.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.agda", "max_line_length": 81, "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.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": 1758, "size": 4201 }
-- broken since the clocks are not supposed to be freely instantiable open import guarded-recursion.prelude renaming (O to zero; S to suc) open Coe module guarded-recursion.clocks (Clk : Type) (▹ : ∀ {a} → Clk → Set a → Set a) (▹′ : ∀ {a} κ → ▹ κ (Set a) → Set a) --▹′ κ A = ▹ κ A (next : ∀ {κ a} {A : Set a} → A → ▹ κ A) (▹′-rule : ∀ {κ a} {A : Set a} → ▹′ κ (next A) ≡ ▹ κ A) -- (▹′-rule : ∀ {a} {A : Set a} → ▹′ ∘ next ≡ ▹_ {A}) (fix : ∀ {κ a} {A : Set a} → (▹ κ A → A) → A) (fix-rule : ∀ {κ a} {A : Set a} {f : ▹ κ A → A} → fix f ≡ f (next (fix f))) (_⊛_ : ∀ {κ a b} {A : Set a} {B : Set b} → ▹ κ (A → B) → ▹ κ A → ▹ κ B) (fix-uniq : ∀ {κ a} {A : Set a} (u : A) (f : ▹ κ A → A) → u ≡ f (next u) → u ≡ fix f) (next⊛next : ∀ {κ a b} {A : Set a} {B : Set b} (f : A → B) (x : A) → next f ⊛ next x ≡ next {κ} (f x)) where roll▹′ : ∀ {κ a} {A : Set a} → ▹ κ A → ▹′ κ (next A) roll▹′ = coe! ▹′-rule un▹′ : ∀ {κ a} {A : Set a} → ▹′ κ (next A) → ▹ κ A un▹′ = coe ▹′-rule ▹Fix : ∀ {a} → Clk → Set a → Set a ▹Fix κ X = (▹ κ X → X) → X ▹Endo : ∀ {a} → Clk → Set a → Set a ▹Endo κ X = ▹ κ X → X μ : ∀ {a} → Fix (Set a) μ F = ∀ {κ} → fix (F ∘ ▹′ κ) un : ∀ {κ a f} → fix {κ} {A = Set a} f → f (next (fix f)) un = coe fix-rule {- unμ : ∀ {κ a} f → μ {a} f → f (▹ κ (μ f)) unμ {κ} {a} f x rewrite sym (▹′-rule {κ} {A = μ f}) = {!un {κ} x!} -} roll : ∀ {κ a f} → f (next (fix f)) → fix {κ} {A = Set a} f roll = coe! fix-rule {- μ-rule : ∀ {κ a} f → μ {a} f ≡ f (▹ κ (μ f)) μ-rule f = {!trans fix-rule (cong f (▹′-rule {A = μ f}))!} -} {- rollμ : ∀ {a} f → (∀ {κ} → f (▹ κ (μ f))) → μ {a} f rollμ f x {κ} = {!roll (x {κ})!} -- rollμ f = subst id (sym (μ-rule f)) -} un₁ : ∀ {κ a b} {A : Set a} {f x} → fix {κ} {A = A → Set b} f x → f (next (fix f)) x un₁ = coe₁ fix-rule roll₁ : ∀ {κ a b} {A : Set a} {f x} → f (next (fix f)) x → fix {κ} {A = A → Set b} f x roll₁ = coe₁! fix-rule un₂ : ∀ {κ a b} {A : Set a} {B : Set b} {c f x y} → fix {κ} {A = A → B → Set c} f x y → f (next (fix f)) x y un₂ = coe₂ fix-rule roll₂ : ∀ {κ a b} {A : Set a} {B : Set b} {c f x y} → f (next (fix f)) x y → fix {κ} {A = A → B → Set c} f x y roll₂ = coe₂! fix-rule map▹ : ∀ {κ a b} {A : Set a} {B : Set b} → (A → B) → ▹ κ A → ▹ κ B map▹ f ▹x = next f ⊛ ▹x _⊛′_ : ∀ {κ a b} {A : Set a} {B : A → Set b} → ▹ κ ((x : A) → B x) → (x : A) → ▹ κ (B x) ▹f ⊛′ x = map▹ (λ f → f x) ▹f module SimpleStream where F : Type → Type → Type F A X = A × X S : Type → Type S A = μ (F A) {- data IsStream (s : S A) : Type where -- cons : ∀ x xs → IsStream xs → IsStream (cons x xs) cons : ∀ x xs → (▹ IsStream) ⊛ next xs → IsStream (cons x xs) cons : ∀ x xs → ▹ (IsStream xs) → IsStream (cons x xs) -} μ₁F' : ∀ {κ a} {A : Set a} → ((A → ▹ κ Type) → A → Type) → (▹ κ (A → Type) → A → Type) μ₁F' F self = F (λ x → (self ⊛ next x)) μ₁F : ∀ {κ a} {A : Set a} → ((A → Type) → A → Type) → (▹ κ (A → Type) → A → Type) μ₁F F self = F (λ x → ▹′ _ (self ⊛ next x)) -- μ₁ : Fix (Endo Type) μ₁ : ∀ {a} {A : Set a} → ((A → Type) → A → Type) → A → Type μ₁ F x = ∀ {κ} → fix (μ₁F {κ} F) x module μId where μid : Type μid = μ id {- μid-rule : μid ≡ (∀ {κ} → ▹ κ μid) μid-rule = {!trans fix-rule (▹′-rule {A = μ id})!} -} {- ω : μid ω = fix (rollμ id) -}
{ "alphanum_fraction": 0.3926499033, "avg_line_length": 29.6639344262, "ext": "agda", "hexsha": "97ce1938ce3008ea1ba22494756d4db627e39d5c", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-11-16T16:21:54.000Z", "max_forks_repo_forks_event_min_datetime": "2015-08-19T12:37:53.000Z", "max_forks_repo_head_hexsha": "9fba7d89d8b27e9bb08c27df802608b5fff769e0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "np/guarded-recursion", "max_forks_repo_path": "guarded-recursion/clocks.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9fba7d89d8b27e9bb08c27df802608b5fff769e0", "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": "np/guarded-recursion", "max_issues_repo_path": "guarded-recursion/clocks.agda", "max_line_length": 114, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9fba7d89d8b27e9bb08c27df802608b5fff769e0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "np/guarded-recursion", "max_stars_repo_path": "guarded-recursion/clocks.agda", "max_stars_repo_stars_event_max_datetime": "2016-12-06T23:04:56.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-06T23:04:56.000Z", "num_tokens": 1682, "size": 3619 }
{-# OPTIONS --safe --cubical #-} module Relation.Binary where open import Level open import Relation.Nullary open import Path as ≡ hiding (sym; refl) open import Data.Sum open import Function open import Data.Bool as Bool using (Bool; true; false; T; bool) open import Relation.Nullary.Decidable open import Relation.Nullary.Discrete module _ (_~_ : A → A → Type b) where Reflexive : Type _ Reflexive = ∀ {x} → x ~ x Transitive : Type _ Transitive = ∀ {x y z} → x ~ y → y ~ z → x ~ z Symmetric : Type _ Symmetric = ∀ {x y} → x ~ y → y ~ x Decidable : Type _ Decidable = ∀ x y → Dec (x ~ y) Antisymmetric : Type _ Antisymmetric = ∀ {x y} → x ~ y → y ~ x → x ≡ y Total : Type _ Total = ∀ x y → (x ~ y) ⊎ (y ~ x) data Tri {a r₁ r₂ r₃} {A : Type a} (R₁ : A → A → Type r₁) (R₂ : A → A → Type r₂) (R₃ : A → A → Type r₃) (x y : A) : Type (a ℓ⊔ r₁ ℓ⊔ r₂ ℓ⊔ r₃) where lt : (x<y : R₁ x y) → Tri R₁ R₂ R₃ x y eq : (x≡y : R₂ x y) → Tri R₁ R₂ R₃ x y gt : (x>y : R₃ x y) → Tri R₁ R₂ R₃ x y record PartialOrder {ℓ₁} (𝑆 : Type ℓ₁) ℓ₂ : Type (ℓ₁ ℓ⊔ ℓsuc ℓ₂) where infix 4 _≤_ field _≤_ : 𝑆 → 𝑆 → Type ℓ₂ refl : Reflexive _≤_ antisym : Antisymmetric _≤_ trans : Transitive _≤_ record TotalOrder {ℓ₁} (𝑆 : Type ℓ₁) ℓ₂ : Type (ℓ₁ ℓ⊔ ℓsuc ℓ₂) where field partialOrder : PartialOrder 𝑆 ℓ₂ open PartialOrder partialOrder public infix 4 _≤ᵇ_ _≤?_ field _≤?_ : Total _≤_ _≤ᵇ_ : 𝑆 → 𝑆 → Bool x ≤ᵇ y = is-l (x ≤? y) open import Data.Unit open import Data.Empty open import Data.Sigma total⇒discrete : Discrete 𝑆 total⇒discrete x y with x ≤? y | inspect (x ≤?_) y | y ≤? x | inspect (y ≤?_) x total⇒discrete x y | inl x₁ | 〖 xy 〗 | inl x₂ | 〖 yx 〗 = yes (antisym x₁ x₂) total⇒discrete x y | inr x₁ | 〖 xy 〗 | inr x₂ | 〖 yx 〗 = yes (antisym x₂ x₁) total⇒discrete x y | inl x₁ | 〖 xy 〗 | inr x₂ | 〖 yx 〗 = no (λ p → subst (bool ⊥ ⊤) (cong is-l (≡.sym xy) ; cong₂ _≤ᵇ_ p (≡.sym p) ; cong is-l yx) tt) total⇒discrete x y | inr x₁ | 〖 xy 〗 | inl x₂ | 〖 yx 〗 = no (λ p → subst (bool ⊤ ⊥) (cong is-l (≡.sym xy) ; cong₂ _≤ᵇ_ p (≡.sym p) ; cong is-l yx) tt) infix 4 _<_ _<_ : 𝑆 → 𝑆 → Type (ℓ₁ ℓ⊔ ℓ₂) x < y = (x ≢ y) × (x ≤ y) Ordering : 𝑆 → 𝑆 → Type (ℓ₁ ℓ⊔ ℓ₂) Ordering = Tri _<_ _≡_ (flip _<_) compare : ∀ x y → Ordering x y compare x y with x ≤? y | inspect (x ≤?_) y | y ≤? x | inspect (y ≤?_) x compare x y | inl x₁ | 〖 xy 〗 | inl x₂ | 〖 yx 〗 = eq (antisym x₁ x₂) compare x y | inr x₁ | 〖 xy 〗 | inr x₂ | 〖 yx 〗 = eq (antisym x₂ x₁) compare x y | inl x₁ | 〖 xy 〗 | inr x₂ | 〖 yx 〗 = lt ((λ p → subst (bool ⊥ ⊤) (cong is-l (≡.sym xy) ; cong₂ _≤ᵇ_ p (≡.sym p) ; cong is-l yx) tt) , x₁) compare x y | inr x₁ | 〖 xy 〗 | inl x₂ | 〖 yx 〗 = gt ((λ p → subst (bool ⊤ ⊥) (cong is-l (≡.sym xy) ; cong₂ _≤ᵇ_ (≡.sym p) p ; cong is-l yx) tt) , x₁) record Equivalence {ℓ₁} (𝑆 : Type ℓ₁) ℓ₂ : Type (ℓ₁ ℓ⊔ ℓsuc ℓ₂) where infix 4 _≋_ field _≋_ : 𝑆 → 𝑆 → Type ℓ₂ sym : ∀ {x y} → x ≋ y → y ≋ x refl : ∀ {x} → x ≋ x trans : ∀ {x y z} → x ≋ y → y ≋ z → x ≋ z ≡-equivalence : ∀ {a} {A : Set a} → Equivalence A a ≡-equivalence = record { _≋_ = _≡_ ; sym = ≡.sym ; refl = ≡.refl ; trans = _;_ }
{ "alphanum_fraction": 0.5446595878, "avg_line_length": 32.3434343434, "ext": "agda", "hexsha": "e3513a868da4ecebcb37b1b8b2b14971bb9fc987", "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/Relation/Binary.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/Relation/Binary.agda", "max_line_length": 152, "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/Relation/Binary.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": 1586, "size": 3202 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.RingSolver.HornerForms where open import Cubical.Foundations.Prelude open import Cubical.Data.Nat using (ℕ) open import Cubical.Data.FinData open import Cubical.Data.Vec open import Cubical.Data.Bool using (Bool; true; false; if_then_else_) open import Cubical.Algebra.RingSolver.RawRing open import Cubical.Algebra.RingSolver.AlmostRing renaming (⟨_⟩ to ⟨_⟩ᵣ) private variable ℓ : Level {- This defines the type of multivariate Polynomials over the RawRing R. The construction is based on the algebraic fact R[X₀][X₁]⋯[Xₙ] ≅ R[X₀,⋯,Xₙ] BUT: Contrary to algebraic convetions, we will give 'Xₙ' the lowest index in the definition of 'Variable' below. So if 'Variable n R k' is identified with 'Xₖ', then the RawRing we construct should rather be denoted with R[Xₙ][Xₙ₋₁]⋯[X₀] or, to be precise about the evaluation order: (⋯((R[Xₙ])[Xₙ₋₁])⋯)[X₀] -} data IteratedHornerForms (R : RawRing {ℓ}) : ℕ → Type ℓ where const : ⟨ R ⟩ → IteratedHornerForms R ℕ.zero 0H : {n : ℕ} → IteratedHornerForms R (ℕ.suc n) _·X+_ : {n : ℕ} → IteratedHornerForms R (ℕ.suc n) → IteratedHornerForms R n → IteratedHornerForms R (ℕ.suc n) eval : {R : RawRing {ℓ}} (n : ℕ) (P : IteratedHornerForms R n) → Vec ⟨ R ⟩ n → ⟨ R ⟩ eval ℕ.zero (const r) [] = r eval {R = R} .(ℕ.suc _) 0H (_ ∷ _) = RawRing.0r R eval {R = R} (ℕ.suc n) (P ·X+ Q) (x ∷ xs) = let open RawRing R in (eval (ℕ.suc n) P (x ∷ xs)) · x + eval n Q xs module IteratedHornerOperations (R : RawRing {ℓ}) where open RawRing R private 1H' : (n : ℕ) → IteratedHornerForms R n 1H' ℕ.zero = const 1r 1H' (ℕ.suc n) = 0H ·X+ 1H' n 0H' : (n : ℕ) → IteratedHornerForms R n 0H' ℕ.zero = const 0r 0H' (ℕ.suc n) = 0H 1ₕ : {n : ℕ} → IteratedHornerForms R n 1ₕ {n = n} = 1H' n 0ₕ : {n : ℕ} → IteratedHornerForms R n 0ₕ {n = n} = 0H' n X : (n : ℕ) (k : Fin n) → IteratedHornerForms R n X (ℕ.suc m) zero = 1ₕ ·X+ 0ₕ X (ℕ.suc m) (suc k) = 0ₕ ·X+ X m k _+ₕ_ : {n : ℕ} → IteratedHornerForms R n → IteratedHornerForms R n → IteratedHornerForms R n (const r) +ₕ (const s) = const (r + s) 0H +ₕ Q = Q (P ·X+ r) +ₕ 0H = P ·X+ r (P ·X+ r) +ₕ (Q ·X+ s) = (P +ₕ Q) ·X+ (r +ₕ s) -ₕ : {n : ℕ} → IteratedHornerForms R n → IteratedHornerForms R n -ₕ (const x) = const (- x) -ₕ 0H = 0H -ₕ (P ·X+ Q) = (-ₕ P) ·X+ (-ₕ Q) isZero : {n : ℕ} → IteratedHornerForms R (ℕ.suc n) → Bool isZero 0H = true isZero (P ·X+ P₁) = false _⋆_ : {n : ℕ} → IteratedHornerForms R n → IteratedHornerForms R (ℕ.suc n) → IteratedHornerForms R (ℕ.suc n) _·ₕ_ : {n : ℕ} → IteratedHornerForms R n → IteratedHornerForms R n → IteratedHornerForms R n r ⋆ 0H = 0H r ⋆ (P ·X+ Q) = (r ⋆ P) ·X+ (r ·ₕ Q) const x ·ₕ const y = const (x · y) 0H ·ₕ Q = 0H (P ·X+ Q) ·ₕ S = let z = (P ·ₕ S) in if (isZero z) then (Q ⋆ S) else (z ·X+ 0ₕ) +ₕ (Q ⋆ S) asRawRing : (n : ℕ) → RawRing {ℓ} RawRing.Carrier (asRawRing n) = IteratedHornerForms R n RawRing.0r (asRawRing n) = 0ₕ RawRing.1r (asRawRing n) = 1ₕ RawRing._+_ (asRawRing n) = _+ₕ_ RawRing._·_ (asRawRing n) = _·ₕ_ RawRing.- (asRawRing n) = -ₕ Variable : (n : ℕ) (R : RawRing {ℓ}) (k : Fin n) → IteratedHornerForms R n Variable n R k = IteratedHornerOperations.X R n k Constant : (n : ℕ) (R : RawRing {ℓ}) (r : ⟨ R ⟩) → IteratedHornerForms R n Constant ℕ.zero R r = const r Constant (ℕ.suc n) R r = IteratedHornerOperations.0ₕ R ·X+ Constant n R r
{ "alphanum_fraction": 0.5934399118, "avg_line_length": 30.487394958, "ext": "agda", "hexsha": "5b8d89ff04e0cae1954e95e7f18042b00ea8f32e", "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/Algebra/RingSolver/HornerForms.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "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": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Algebra/RingSolver/HornerForms.agda", "max_line_length": 77, "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/Algebra/RingSolver/HornerForms.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1568, "size": 3628 }
open import Agda.Builtin.Nat postulate Pos : Set data FVec : (n : Nat) → Set₁ where FNil : FVec 0 FCons : ∀ {n} → (Pos → Set) → FVec (suc n) pre : ∀ {m n} → FVec m → FVec (suc n) → Pos → Set pre FNil (FCons x) = x pre (FCons x) _ = x data proofAG : ∀ {n} → FVec n → Set where []AG : proofAG FNil postulate preAG : ∀ m n (v : FVec m) (v' : FVec (suc n)) → proofAG v → proofAG v' → ∀ p → pre v v' p m n : Nat v : FVec m v' : FVec (suc n) p : Pos preAG₁ : pre v v' p preAG₁ = preAG 0 n FNil _ []AG {!!} p -- Refine gives internal error instead of 'Cannot refine' or -- 'No introduction forms found'. postulate Constrain : (A B : Set) → (A → B) → Set syntax Constrain A B (λ x → y) = x ∈ A => y ∈ B preAG₂ : (let X : FVec (suc n) X = _) → x ∈ pre FNil X p => x ∈ pre v v' p → proofAG X → Set preAG₂ _ p = {!p!} -- Splitting on p causes the same internal error.
{ "alphanum_fraction": 0.5332629356, "avg_line_length": 24.9210526316, "ext": "agda", "hexsha": "972a8645a15a350843a629e019f4cf4d9f417d22", "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/Issue2560.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/Issue2560.agda", "max_line_length": 62, "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/Issue2560.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": 372, "size": 947 }
{-# OPTIONS --without-K #-} open import Type hiding (★) open import Function open import Relation.Binary.PropositionalEquality open import Explore.Core open import Explore.Properties -- Explore ℓ is not an endo functor because of universe levels module Explore.Monad {a} ℓ where M = Explore {a} ℓ module _ {A : ★ a} where return : A → M A return = point-explore mzero : M A mzero = empty-explore mplus : M A → M A → M A mplus = merge-explore module _ {p} where return-ind : ∀ x → ExploreInd p (return x) return-ind = point-explore-ind mzero-ind : ExploreInd p mzero mzero-ind = empty-explore-ind mplus-ind : ∀ {e₀ e₁ : M A} → ExploreInd p e₀ → ExploreInd p e₁ → ExploreInd p (merge-explore e₀ e₁) mplus-ind Pe₀ Pe₁ P Pε _P∙_ Pf = (Pe₀ P Pε _P∙_ Pf) P∙ (Pe₁ P Pε _P∙_ Pf) module _ {A B : ★ a} where infixl 1 _>>=_ _>>=-ind_ _>>=_ : M A → (A → M B) → M B (expᴬ >>= expᴮ) ε _∙_ f = expᴬ ε _∙_ λ x → expᴮ x ε _∙_ f _>>=-ind_ : ∀ {p} {expᴬ : M A} → ExploreInd p expᴬ → {expᴮ : A → M B} → (∀ x → ExploreInd p (expᴮ x)) → ExploreInd p (expᴬ >>= expᴮ) _>>=-ind_ {expᴬ} Pᴬ {expᴮ} Pᴮ P Pz _P∙_ Pf = Pᴬ (λ e → P (e >>= expᴮ)) Pz _P∙_ λ x → Pᴮ x P Pz _P∙_ Pf map : (A → B) → M A → M B map f e = e >>= return ∘ f map-ind : ∀ {p} (f : A → B) {expᴬ : M A} → ExploreInd p expᴬ → ExploreInd p (map f expᴬ) map-ind f Pᴬ = Pᴬ >>=-ind return-ind ∘ f private {- This law is for free: map f e = e >>= return ∘ f -} map' : (A → B) → M A → M B map' f exp ε _∙_ g = exp ε _∙_ (g ∘ f) map'≡map : map' ≡ map map'≡map = refl -- universe issues... -- join : M (M A) → M A module _ {A B C : ★ a} (m : M A) (f : A → M B) (g : B → M C) where infix 0 _≡e_ _≡e_ = λ {A} → _≡_ {A = M A} left-identity : f ≡ (λ x → return x >>= f) left-identity = refl right-identity : m ≡e m >>= return right-identity = refl associativity : m >>= (λ x → f x >>= g) ≡e (m >>= f) >>= g associativity = refl
{ "alphanum_fraction": 0.5127373784, "avg_line_length": 27.6794871795, "ext": "agda", "hexsha": "406433361d0b03ff1a1e733fbbb8da3f403a4e22", "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": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "crypto-agda/explore", "max_forks_repo_path": "lib/Explore/Monad.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "crypto-agda/explore", "max_issues_repo_path": "lib/Explore/Monad.agda", "max_line_length": 92, "max_stars_count": 2, "max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "crypto-agda/explore", "max_stars_repo_path": "lib/Explore/Monad.agda", "max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z", "num_tokens": 847, "size": 2159 }
-- Occurs when different mixfix operators use similar names. module Issue147a where postulate X : Set f : X -> X f_ : X -> X bad : X -> X bad x = f x
{ "alphanum_fraction": 0.6211180124, "avg_line_length": 13.4166666667, "ext": "agda", "hexsha": "b1f29a8695d4284cbc49ab5bea473a1199815a44", "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/Issue147a.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/Issue147a.agda", "max_line_length": 60, "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/Issue147a.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": 55, "size": 161 }
module ExtendedLambdaCase where data Bool : Set where true false : Bool data Void : Set where foo : Bool -> Bool -> Bool -> Bool foo = λ { x → λ { y z → {!!} } } module parameterised {A : Set}(B : A -> Set) where data Bar : (Bool -> Bool) -> Set where baz : (t : Void) -> Bar λ { x → {!!} } -- with hidden argument data Bar' : (Bool -> Bool) -> Set where baz' : {t : Void} -> Bar' λ { x' → {!!} } baz : Bool -> {w : Bool} -> Bool baz = λ { z {w} → {!!} }
{ "alphanum_fraction": 0.5135699374, "avg_line_length": 20.8260869565, "ext": "agda", "hexsha": "6c599dbe16962e7a3da52ed89a44aeabccff570d", "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": "4383a3d20328a6c43689161496cee8eb479aca08", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dagit/agda", "max_forks_repo_path": "test/interaction/ExtendedLambdaCase.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "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": "dagit/agda", "max_issues_repo_path": "test/interaction/ExtendedLambdaCase.agda", "max_line_length": 50, "max_stars_count": 1, "max_stars_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dagit/agda", "max_stars_repo_path": "test/interaction/ExtendedLambdaCase.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T07:26:06.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T07:26:06.000Z", "num_tokens": 159, "size": 479 }
module Oscar.Data.Term.Substitution.Core {𝔣} (FunctionName : Set 𝔣) where open import Oscar.Data.Term.Core FunctionName open import Oscar.Data.Term.Substitution.Core.bootstrap FunctionName public hiding (_◃Term_; _◃VecTerm_) open import Oscar.Data.Nat.Core open import Oscar.Data.Fin.Core open import Oscar.Data.Vec.Core open import Oscar.Data.Equality.Core open import Oscar.Data.Product.Core open import Oscar.Function open import Oscar.Level ⊸-Property : {ℓ : Level} → ℕ → Set (lsuc ℓ ⊔ 𝔣) ⊸-Property {ℓ} m = ∀ {n} → m ⊸ n → Set ℓ _≐_ : {m n : ℕ} → m ⊸ n → m ⊸ n → Set 𝔣 f ≐ g = ∀ x → f x ≡ g x ⊸-Extensional : {ℓ : Level} {m : ℕ} → ⊸-Property {ℓ} m → Set (ℓ ⊔ 𝔣) ⊸-Extensional P = ∀ {m f g} → f ≐ g → P {m} f → P g ⊸-ExtentionalProperty : {ℓ : Level} → ℕ → Set (lsuc ℓ ⊔ 𝔣) ⊸-ExtentionalProperty {ℓ} m = Σ (⊸-Property {ℓ} m) ⊸-Extensional
{ "alphanum_fraction": 0.6595995289, "avg_line_length": 33.96, "ext": "agda", "hexsha": "2f0be843553a02d4f246095c24489a5a0f433539", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-2/Oscar/Data/Term/Core.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-2/Oscar/Data/Term/Core.agda", "max_line_length": 104, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-2/Oscar/Data/Term/Core.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 332, "size": 849 }
module Impure.LFRef.Readme where open import Impure.LFRef.Syntax open import Impure.LFRef.Welltyped open import Impure.LFRef.Eval open import Impure.LFRef.Properties.Soundness open import Impure.LFRef.Properties.Confluence
{ "alphanum_fraction": 0.8526785714, "avg_line_length": 28, "ext": "agda", "hexsha": "53537de25e8180b2277fd4bca93d5d71952cb4f1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Impure/LFRef/Readme.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Impure/LFRef/Readme.agda", "max_line_length": 46, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Impure/LFRef/Readme.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 62, "size": 224 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Union of two binary relations ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Relation.Binary.Construct.Union where open import Data.Product open import Data.Sum.Base as Sum open import Function using (_∘_) open import Level using (Level; _⊔_) open import Relation.Binary open import Relation.Nullary using (yes; no) open import Relation.Nullary.Sum using (_⊎-dec_) private variable a b ℓ ℓ₁ ℓ₂ ℓ₃ : Level A : Set a B : Set b ------------------------------------------------------------------------ -- Definition _∪_ : ∀ {A : Set a} {B : Set b} → REL A B ℓ₁ → REL A B ℓ₂ → REL A B (ℓ₁ ⊔ ℓ₂) L ∪ R = λ i j → L i j ⊎ R i j ------------------------------------------------------------------------ -- Properties module _ (L : Rel A ℓ) (R : Rel A ℓ) where reflexive : Reflexive L ⊎ Reflexive R → Reflexive (L ∪ R) reflexive (inj₁ L-refl) = inj₁ L-refl reflexive (inj₂ R-refl) = inj₂ R-refl total : Total L ⊎ Total R → Total (L ∪ R) total (inj₁ L-total) x y = [ inj₁ ∘ inj₁ , inj₂ ∘ inj₁ ] (L-total x y) total (inj₂ R-total) x y = [ inj₁ ∘ inj₂ , inj₂ ∘ inj₂ ] (R-total x y) min : ∀ {⊤} → Minimum L ⊤ ⊎ Minimum R ⊤ → Minimum (L ∪ R) ⊤ min = [ inj₁ ∘_ , inj₂ ∘_ ] max : ∀ {⊥} → Maximum L ⊥ ⊎ Maximum R ⊥ → Maximum (L ∪ R) ⊥ max = [ inj₁ ∘_ , inj₂ ∘_ ] module _ {L : Rel A ℓ} {R : Rel A ℓ} where symmetric : Symmetric L → Symmetric R → Symmetric (L ∪ R) symmetric L-sym R-sym = [ inj₁ ∘ L-sym , inj₂ ∘ R-sym ] respects : ∀ {p} {P : A → Set p} → P Respects L → P Respects R → P Respects (L ∪ R) respects resp-L resp-R = [ resp-L , resp-R ] module _ {≈ : Rel A ℓ₁} (L : REL A B ℓ₂) (R : REL A B ℓ₃) where respˡ : L Respectsˡ ≈ → R Respectsˡ ≈ → (L ∪ R) Respectsˡ ≈ respˡ Lˡ Rˡ x≈y = Sum.map (Lˡ x≈y) (Rˡ x≈y) module _ {≈ : Rel B ℓ₁} (L : REL A B ℓ₂) (R : REL A B ℓ₃) where respʳ : L Respectsʳ ≈ → R Respectsʳ ≈ → (L ∪ R) Respectsʳ ≈ respʳ Lʳ Rʳ x≈y = Sum.map (Lʳ x≈y) (Rʳ x≈y) module _ {≈ : Rel A ℓ₁} {L : Rel A ℓ₂} {R : Rel A ℓ₃} where resp₂ : L Respects₂ ≈ → R Respects₂ ≈ → (L ∪ R) Respects₂ ≈ resp₂ (Lʳ , Lˡ) (Rʳ , Rˡ) = respʳ L R Lʳ Rʳ , respˡ L R Lˡ Rˡ module _ (≈ : REL A B ℓ₁) (L : REL A B ℓ₂) (R : REL A B ℓ₃) where implies : (≈ ⇒ L) ⊎ (≈ ⇒ R) → ≈ ⇒ (L ∪ R) implies = [ inj₁ ∘_ , inj₂ ∘_ ] irreflexive : Irreflexive ≈ L → Irreflexive ≈ R → Irreflexive ≈ (L ∪ R) irreflexive L-irrefl R-irrefl x≈y = [ L-irrefl x≈y , R-irrefl x≈y ] module _ {L : REL A B ℓ₁} {R : REL A B ℓ₂} where decidable : Decidable L → Decidable R → Decidable (L ∪ R) decidable L? R? x y = L? x y ⊎-dec R? x y
{ "alphanum_fraction": 0.51447178, "avg_line_length": 31.7701149425, "ext": "agda", "hexsha": "69de2da6340a945e1506ffea653f20c844ee3a7f", "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/Construct/Union.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/Construct/Union.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/Construct/Union.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": 1119, "size": 2764 }
-- We define the localisation of a commutative ring -- at a multiplicatively closed subset and show that it -- has a commutative ring structure. {-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.CommRing.Localisation.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.HLevels open import Cubical.Foundations.Powerset open import Cubical.Foundations.Transport open import Cubical.Functions.FunExtEquiv import Cubical.Data.Empty as ⊥ open import Cubical.Data.Bool open import Cubical.Data.Nat renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_ ; +-comm to +ℕ-comm ; +-assoc to +ℕ-assoc ; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm) open import Cubical.Data.Vec open import Cubical.Data.Sigma.Base open import Cubical.Data.Sigma.Properties open import Cubical.Data.FinData open import Cubical.Relation.Nullary open import Cubical.Relation.Binary open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing open import Cubical.Algebra.RingSolver.ReflectionSolving open import Cubical.HITs.SetQuotients as SQ open import Cubical.HITs.PropositionalTruncation as PT open Iso private variable ℓ ℓ' : Level A : Type ℓ -- A multiplicatively closed subset is assumed to contain 1 record isMultClosedSubset (R' : CommRing ℓ) (S' : ℙ (fst R')) : Type ℓ where constructor multclosedsubset field containsOne : (R' .snd .CommRingStr.1r) ∈ S' multClosed : ∀ {s t} → s ∈ S' → t ∈ S' → ((snd R') .CommRingStr._·_ s t) ∈ S' module Loc (R' : CommRing ℓ) (S' : ℙ (fst R')) (SMultClosedSubset : isMultClosedSubset R' S') where open isMultClosedSubset private R = fst R' open CommRingStr (snd R') open RingTheory (CommRing→Ring R') open CommRingTheory R' S = Σ[ s ∈ R ] (s ∈ S') -- We define the localisation of R by S by quotienting by the following relation: _≈_ : R × S → R × S → Type ℓ (r₁ , s₁) ≈ (r₂ , s₂) = Σ[ s ∈ S ] (fst s · r₁ · fst s₂ ≡ fst s · r₂ · fst s₁) S⁻¹R = (R × S) / _≈_ -- now define addition for S⁻¹R open BinaryRelation locRefl : isRefl _≈_ locRefl _ = (1r , SMultClosedSubset .containsOne) , refl locSym : isSym _≈_ locSym (r , s , s∈S') (r' , s' , s'∈S') (u , p) = u , sym p locTrans : isTrans _≈_ locTrans (r , s , s∈S') (r' , s' , s'∈S') (r'' , s'' , s''∈S') ((u , u∈S') , p) ((v , v∈S') , q) = ((u · v · s') , SMultClosedSubset .multClosed (SMultClosedSubset .multClosed u∈S' v∈S') s'∈S') , path where eq1 : (r s r' s' r'' s'' u v : R) → u · v · s' · r · s'' ≡ u · r · s' · v · s'' eq1 = solve R' eq2 : (r s r' s' r'' s'' u v : R) → u · r' · s · v · s'' ≡ u · s · (v · r' · s'') eq2 = solve R' eq3 : (r s r' s' r'' s'' u v : R) → u · s · (v · r'' · s') ≡ u · v · s' · r'' · s eq3 = solve R' path : u · v · s' · r · s'' ≡ u · v · s' · r'' · s path = u · v · s' · r · s'' ≡⟨ eq1 r s r' s' r'' s'' u v ⟩ -- not just ≡⟨ solve R' ⟩ u · r · s' · v · s'' ≡⟨ cong (λ x → x · v · s'') p ⟩ u · r' · s · v · s'' ≡⟨ eq2 r s r' s' r'' s'' u v ⟩ u · s · (v · r' · s'') ≡⟨ cong (u · s ·_) q ⟩ u · s · (v · r'' · s') ≡⟨ eq3 r s r' s' r'' s'' u v ⟩ u · v · s' · r'' · s ∎ locIsEquivRel : isEquivRel _≈_ isEquivRel.reflexive locIsEquivRel = locRefl isEquivRel.symmetric locIsEquivRel = locSym isEquivRel.transitive locIsEquivRel = locTrans _+ₗ_ : S⁻¹R → S⁻¹R → S⁻¹R _+ₗ_ = setQuotSymmBinOp locRefl locTrans _+ₚ_ (λ a b → subst (λ x → (a +ₚ b) ≈ x) (+ₚ-symm a b) (locRefl (a +ₚ b))) θ where _+ₚ_ : R × S → R × S → R × S (r₁ , s₁ , s₁∈S) +ₚ (r₂ , s₂ , s₂∈S) = (r₁ · s₂ + r₂ · s₁) , (s₁ · s₂) , SMultClosedSubset .multClosed s₁∈S s₂∈S +ₚ-symm : (a b : R × S) → (a +ₚ b) ≡ (b +ₚ a) +ₚ-symm (r₁ , s₁ , s₁∈S) (r₂ , s₂ , s₂∈S) = ΣPathP (+Comm _ _ , Σ≡Prop (λ x → S' x .snd) (·-comm _ _)) θ : (a a' b : R × S) → a ≈ a' → (a +ₚ b) ≈ (a' +ₚ b) θ (r₁ , s₁ , s₁∈S) (r'₁ , s'₁ , s'₁∈S) (r₂ , s₂ , s₂∈S) ((s , s∈S) , p) = (s , s∈S) , path where eq1 : (r₁ s₁ r'₁ s'₁ s'₁ r₂ s₂ s : R) → s · (r₁ · s₂ + r₂ · s₁) · (s'₁ · s₂) ≡ s · r₁ · s'₁ · s₂ · s₂ + s · r₂ · s₁ · s'₁ · s₂ eq1 = solve R' eq2 : (r₁ s₁ r'₁ s'₁ s'₁ r₂ s₂ s : R) → s · r'₁ · s₁ · s₂ · s₂ + s · r₂ · s₁ · s'₁ · s₂ ≡ s · (r'₁ · s₂ + r₂ · s'₁) · (s₁ · s₂) eq2 = solve R' path : s · (r₁ · s₂ + r₂ · s₁) · (s'₁ · s₂) ≡ s · (r'₁ · s₂ + r₂ · s'₁) · (s₁ · s₂) path = s · (r₁ · s₂ + r₂ · s₁) · (s'₁ · s₂) ≡⟨ eq1 r₁ s₁ r'₁ s'₁ s'₁ r₂ s₂ s ⟩ s · r₁ · s'₁ · s₂ · s₂ + s · r₂ · s₁ · s'₁ · s₂ ≡⟨ cong (λ x → x · s₂ · s₂ + s · r₂ · s₁ · s'₁ · s₂) p ⟩ s · r'₁ · s₁ · s₂ · s₂ + s · r₂ · s₁ · s'₁ · s₂ ≡⟨ eq2 r₁ s₁ r'₁ s'₁ s'₁ r₂ s₂ s ⟩ s · (r'₁ · s₂ + r₂ · s'₁) · (s₁ · s₂) ∎ -- check group-laws for addition +ₗ-assoc : (x y z : S⁻¹R) → x +ₗ (y +ₗ z) ≡ (x +ₗ y) +ₗ z +ₗ-assoc = SQ.elimProp3 (λ _ _ _ → squash/ _ _) +ₗ-assoc[] where +ₗ-assoc[] : (a b c : R × S) → [ a ] +ₗ ([ b ] +ₗ [ c ]) ≡ ([ a ] +ₗ [ b ]) +ₗ [ c ] +ₗ-assoc[] (r , s , s∈S) (r' , s' , s'∈S) (r'' , s'' , s''∈S) = cong [_] (ΣPathP ((path r s r' s' r'' s'') , Σ≡Prop (λ x → ∈-isProp S' x) (·Assoc _ _ _))) where path : (r s r' s' r'' s'' : R) → r · (s' · s'') + (r' · s'' + r'' · s') · s ≡ (r · s' + r' · s) · s'' + r'' · (s · s') path = solve R' 0ₗ : S⁻¹R 0ₗ = [ 0r , 1r , SMultClosedSubset .containsOne ] +ₗ-rid : (x : S⁻¹R) → x +ₗ 0ₗ ≡ x +ₗ-rid = SQ.elimProp (λ _ → squash/ _ _) +ₗ-rid[] where +ₗ-rid[] : (a : R × S) → [ a ] +ₗ 0ₗ ≡ [ a ] +ₗ-rid[] (r , s , s∈S) = path where eq1 : (r s : R) → r · 1r + 0r · s ≡ r eq1 = solve R' path : [ r · 1r + 0r · s , s · 1r , SMultClosedSubset .multClosed s∈S (SMultClosedSubset .containsOne) ] ≡ [ r , s , s∈S ] path = cong [_] (ΣPathP (eq1 r s , Σ≡Prop (λ x → ∈-isProp S' x) (·Rid _))) -ₗ_ : S⁻¹R → S⁻¹R -ₗ_ = SQ.rec squash/ -ₗ[] -ₗWellDef where -ₗ[] : R × S → S⁻¹R -ₗ[] (r , s) = [ - r , s ] -ₗWellDef : (a b : R × S) → a ≈ b → -ₗ[] a ≡ -ₗ[] b -ₗWellDef (r , s , _) (r' , s' , _) ((u , u∈S) , p) = eq/ _ _ ((u , u∈S) , path) where eq1 : (u r s' : R) → u · - r · s' ≡ - (u · r · s') eq1 = solve R' eq2 : (u r' s : R) → - (u · r' · s) ≡ u · - r' · s eq2 = solve R' path : u · - r · s' ≡ u · - r' · s path = eq1 u r s' ∙∙ cong -_ p ∙∙ eq2 u r' s +ₗ-rinv : (x : S⁻¹R) → x +ₗ (-ₗ x) ≡ 0ₗ +ₗ-rinv = SQ.elimProp (λ _ → squash/ _ _) +ₗ-rinv[] where +ₗ-rinv[] : (a : R × S) → ([ a ] +ₗ (-ₗ [ a ])) ≡ 0ₗ +ₗ-rinv[] (r , s , s∈S) = eq/ _ _ ((1r , SMultClosedSubset .containsOne) , path r s) where path : (r s : R) → 1r · (r · s + - r · s) · 1r ≡ 1r · 0r · (s · s) path = solve R' +ₗ-comm : (x y : S⁻¹R) → x +ₗ y ≡ y +ₗ x +ₗ-comm = SQ.elimProp2 (λ _ _ → squash/ _ _) +ₗ-comm[] where +ₗ-comm[] : (a b : R × S) → ([ a ] +ₗ [ b ]) ≡ ([ b ] +ₗ [ a ]) +ₗ-comm[] (r , s , s∈S) (r' , s' , s'∈S) = cong [_] (ΣPathP ((+Comm _ _) , Σ≡Prop (λ x → ∈-isProp S' x) (·-comm _ _))) -- Now for multiplication _·ₗ_ : S⁻¹R → S⁻¹R → S⁻¹R _·ₗ_ = setQuotSymmBinOp locRefl locTrans _·ₚ_ (λ a b → subst (λ x → (a ·ₚ b) ≈ x) (·ₚ-symm a b) (locRefl (a ·ₚ b))) θ where _·ₚ_ : R × S → R × S → R × S (r₁ , s₁ , s₁∈S) ·ₚ (r₂ , s₂ , s₂∈S) = (r₁ · r₂) , ((s₁ · s₂) , SMultClosedSubset .multClosed s₁∈S s₂∈S) ·ₚ-symm : (a b : R × S) → (a ·ₚ b) ≡ (b ·ₚ a) ·ₚ-symm (r₁ , s₁ , s₁∈S) (r₂ , s₂ , s₂∈S) = ΣPathP (·-comm _ _ , Σ≡Prop (λ x → S' x .snd) (·-comm _ _)) θ : (a a' b : R × S) → a ≈ a' → (a ·ₚ b) ≈ (a' ·ₚ b) θ (r₁ , s₁ , s₁∈S) (r'₁ , s'₁ , s'₁∈S) (r₂ , s₂ , s₂∈S) ((s , s∈S) , p) = (s , s∈S) , path where eq1 : (r₁ s₁ r'₁ s'₁ r₂ s₂ s : R) → s · (r₁ · r₂) · (s'₁ · s₂) ≡ s · r₁ · s'₁ · r₂ · s₂ eq1 = solve R' eq2 : (r₁ s₁ r'₁ s'₁ r₂ s₂ s : R) → s · r'₁ · s₁ · r₂ · s₂ ≡ s · (r'₁ · r₂) · (s₁ · s₂) eq2 = solve R' path : s · (r₁ · r₂) · (s'₁ · s₂) ≡ s · (r'₁ · r₂) · (s₁ · s₂) path = eq1 r₁ s₁ r'₁ s'₁ r₂ s₂ s ∙∙ cong (λ x → x · r₂ · s₂) p ∙∙ eq2 r₁ s₁ r'₁ s'₁ r₂ s₂ s -- checking laws for multiplication 1ₗ : S⁻¹R 1ₗ = [ 1r , 1r , SMultClosedSubset .containsOne ] ·ₗ-assoc : (x y z : S⁻¹R) → x ·ₗ (y ·ₗ z) ≡ (x ·ₗ y) ·ₗ z ·ₗ-assoc = SQ.elimProp3 (λ _ _ _ → squash/ _ _) ·ₗ-assoc[] where ·ₗ-assoc[] : (a b c : R × S) → [ a ] ·ₗ ([ b ] ·ₗ [ c ]) ≡ ([ a ] ·ₗ [ b ]) ·ₗ [ c ] ·ₗ-assoc[] (r , s , s∈S) (r' , s' , s'∈S) (r'' , s'' , s''∈S) = cong [_] (ΣPathP ((·Assoc _ _ _) , Σ≡Prop (λ x → ∈-isProp S' x) (·Assoc _ _ _))) ·ₗ-rid : (x : S⁻¹R) → x ·ₗ 1ₗ ≡ x ·ₗ-rid = SQ.elimProp (λ _ → squash/ _ _) ·ₗ-rid[] where ·ₗ-rid[] : (a : R × S) → ([ a ] ·ₗ 1ₗ) ≡ [ a ] ·ₗ-rid[] (r , s , s∈S) = cong [_] (ΣPathP ((·Rid _) , Σ≡Prop (λ x → ∈-isProp S' x) (·Rid _))) ·ₗ-rdist-+ₗ : (x y z : S⁻¹R) → x ·ₗ (y +ₗ z) ≡ (x ·ₗ y) +ₗ (x ·ₗ z) ·ₗ-rdist-+ₗ = SQ.elimProp3 (λ _ _ _ → squash/ _ _) ·ₗ-rdist-+ₗ[] where ·ₗ-rdist-+ₗ[] : (a b c : R × S) → [ a ] ·ₗ ([ b ] +ₗ [ c ]) ≡ ([ a ] ·ₗ [ b ]) +ₗ ([ a ] ·ₗ [ c ]) ·ₗ-rdist-+ₗ[] (r , s , s∈S) (r' , s' , s'∈S) (r'' , s'' , s''∈S) = eq/ _ _ ((1r , (SMultClosedSubset .containsOne)) , path r s r' s' r'' s'') where -- could be shortened even further path : (r s r' s' r'' s'' : R) → 1r · (r · (r' · s'' + r'' · s')) · (s · s' · (s · s'')) ≡ 1r · (r · r' · (s · s'') + r · r'' · (s · s')) · (s · (s' · s'')) path = solve R' ·ₗ-comm : (x y : S⁻¹R) → x ·ₗ y ≡ y ·ₗ x ·ₗ-comm = SQ.elimProp2 (λ _ _ → squash/ _ _) ·ₗ-comm[] where ·ₗ-comm[] : (a b : R × S) → [ a ] ·ₗ [ b ] ≡ [ b ] ·ₗ [ a ] ·ₗ-comm[] (r , s , s∈S) (r' , s' , s'∈S) = cong [_] (ΣPathP ((·-comm _ _) , Σ≡Prop (λ x → ∈-isProp S' x) (·-comm _ _))) -- Commutative ring structure on S⁻¹R S⁻¹RAsCommRing : CommRing ℓ S⁻¹RAsCommRing = S⁻¹R , S⁻¹RCommRingStr where open CommRingStr S⁻¹RCommRingStr : CommRingStr S⁻¹R 0r S⁻¹RCommRingStr = 0ₗ 1r S⁻¹RCommRingStr = 1ₗ _+_ S⁻¹RCommRingStr = _+ₗ_ _·_ S⁻¹RCommRingStr = _·ₗ_ - S⁻¹RCommRingStr = -ₗ_ isCommRing S⁻¹RCommRingStr = makeIsCommRing squash/ +ₗ-assoc +ₗ-rid +ₗ-rinv +ₗ-comm ·ₗ-assoc ·ₗ-rid ·ₗ-rdist-+ₗ ·ₗ-comm
{ "alphanum_fraction": 0.476584022, "avg_line_length": 36.4256055363, "ext": "agda", "hexsha": "1166b75a0e5544ba4fc9fb7a52f1574a44743059", "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": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dolio/cubical", "max_forks_repo_path": "Cubical/Algebra/CommRing/Localisation/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "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": "dolio/cubical", "max_issues_repo_path": "Cubical/Algebra/CommRing/Localisation/Base.agda", "max_line_length": 101, "max_stars_count": null, "max_stars_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dolio/cubical", "max_stars_repo_path": "Cubical/Algebra/CommRing/Localisation/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5094, "size": 10527 }
{-# OPTIONS --safe #-} module Cubical.Algebra.Polynomials.UnivariateHIT.Base where open import Cubical.Algebra.CommRing.Instances.Polynomials.UnivariatePolyHIT public {- The Univariate Functional Polynomials over a CommRing A is a CommRing. The base type is define using an HIT. This definition enables to defined a direct sum indexed by ℕ. Thus base type and the AbGroup part of the CommRing is define an instance of the more general Direct Sum one which can be found here : -} open import Cubical.Algebra.DirectSum.DirectSumHIT.Base {- On this definition of the Direct Sum, it is possible to raise a Graded Ring structure. Then complete it to be a CommRing. Those version of the polynomials are hence a instance of this graded ring structure. see : for the details of the constructions -} open import Cubical.Algebra.GradedRing.DirectSumHIT
{ "alphanum_fraction": 0.7969483568, "avg_line_length": 30.4285714286, "ext": "agda", "hexsha": "68072a0a8eb67619d028d218643451b52ab30824", "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/Polynomials/UnivariateHIT/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Algebra/Polynomials/UnivariateHIT/Base.agda", "max_line_length": 86, "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/Polynomials/UnivariateHIT/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 198, "size": 852 }
-- Andreas, 2019-11-07, issue #4169 report and testcase by nad. -- Extra coercions needed when erased versions of functions are used. open import Agda.Builtin.Unit open import Common.IO data D : Set where c : D F : D → Set → Set F c A = A → A f : (d : D) (A : Set) → F d A → A → A -- 14 f c A g = g f′ : (d : D) (A : Set) (P : Set → Set) -- 30 (g : (A : Set) → F d (P A)) → P A → P A f′ d A P g = f d (P A) (g A) module _ (id : (A : Set) → (A → A) → A → A) (G : Set → Set) where postulate g : (A : Set) → G A → G A g′ : (A : Set) → G A → G A g′ A s = g A s g″ : (A : Set) → G A → G A g″ A = id (G A) (f′ c A G g′) main : IO ⊤ main = return _
{ "alphanum_fraction": 0.4860499266, "avg_line_length": 20.0294117647, "ext": "agda", "hexsha": "077982464e4c4dddd5c06507a633defdec0be90e", "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/Compiler/simple/Issue4169.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/Compiler/simple/Issue4169.agda", "max_line_length": 69, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Compiler/simple/Issue4169.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": 292, "size": 681 }
------------------------------------------------------------------------ -- H-levels ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} -- Partly based on Voevodsky's work on so-called univalent -- foundations. open import Equality module H-level {reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where open Derived-definitions-and-properties eq open import Logical-equivalence hiding (id; _∘_) open import Nat eq open import Prelude open import Surjection eq hiding (id; _∘_) private variable a ℓ : Level m n : ℕ A B : Type a ------------------------------------------------------------------------ -- H-levels -- H-levels ("homotopy levels"). H-level : ℕ → Type ℓ → Type ℓ H-level zero A = Contractible A H-level (suc zero) A = Is-proposition A H-level (suc (suc n)) A = {x y : A} → H-level (suc n) (x ≡ y) private -- Note that H-level 2 is a synonym for Is-set. H-level-2≡Is-set : H-level 2 A ≡ Is-set A H-level-2≡Is-set = refl _ -- For-iterated-equality n P A means that P holds for (equalities -- over)^n A. For-iterated-equality : ℕ → (Type ℓ → Type ℓ) → (Type ℓ → Type ℓ) For-iterated-equality zero P A = P A For-iterated-equality (suc n) P A = (x y : A) → For-iterated-equality n P (x ≡ y) -- An alternative definition of h-levels. -- -- In some cases this definition, with only two cases, is easier to -- use. In other cases the definition above, which is less complicated -- for positive h-levels, is easier to use. H-level′ : ℕ → Type ℓ → Type ℓ H-level′ = flip For-iterated-equality Contractible -- Propositions are propositional types. Proposition : (ℓ : Level) → Type (lsuc ℓ) Proposition _ = ∃ Is-proposition -- Types that are sets. Set : (ℓ : Level) → Type (lsuc ℓ) Set _ = ∃ Is-set -- The underlying type. ⌞_⌟ : Set ℓ → Type ℓ ⌞ A ⌟ = proj₁ A ------------------------------------------------------------------------ -- General properties -- H-level′ is upwards closed in its first argument. mono₁′ : ∀ n → H-level′ n A → H-level′ (1 + n) A mono₁′ (suc n) h x y = mono₁′ n (h x y) mono₁′ {A = A} zero h x y = trivial x y , irr where trivial : (x y : A) → x ≡ y trivial x y = x ≡⟨ sym $ proj₂ h x ⟩ proj₁ h ≡⟨ proj₂ h y ⟩∎ y ∎ irr : (x≡y : x ≡ y) → trivial x y ≡ x≡y irr = elim (λ {x y} x≡y → trivial x y ≡ x≡y) (λ x → trans-symˡ (proj₂ h x)) -- H-level and H-level′ are pointwise logically equivalent. H-level⇔H-level′ : H-level n A ⇔ H-level′ n A H-level⇔H-level′ = record { to = to _; from = from _ } where to : ∀ n → H-level n A → H-level′ n A to zero h = h to (suc zero) h = λ x → mono₁′ 0 (x , h x) x to (suc (suc n)) h = λ x y → to (suc n) h from : ∀ n → H-level′ n A → H-level n A from zero h = h from (suc zero) h x y = proj₁ (h x y) from (suc (suc n)) h {x = x} {y = y} = from (suc n) (h x y) -- If A has h-level 1 + n, then the types of equality proofs between -- elements of type A have h-level n. +⇒≡ : {x y : A} → H-level (suc n) A → H-level n (x ≡ y) +⇒≡ h = _⇔_.from H-level⇔H-level′ $ _⇔_.to H-level⇔H-level′ h _ _ -- H-level is upwards closed in its first argument. mono₁ : ∀ n → H-level n A → H-level (1 + n) A mono₁ n = _⇔_.from H-level⇔H-level′ ∘ mono₁′ n ∘ _⇔_.to H-level⇔H-level′ abstract mono : m ≤ n → H-level m A → H-level n A mono (≤-refl′ eq) = subst (λ n → H-level n _) eq mono (≤-step′ m≤n eq) = subst (λ n → H-level n _) eq ∘ mono₁ _ ∘ mono m≤n -- If A has h-level n, then the types of equality proofs between -- elements of type A also have h-level n. ⇒≡ : {x y : A} → ∀ n → H-level n A → H-level n (x ≡ y) ⇒≡ _ = +⇒≡ ∘ mono₁ _ -- If something is contractible given the assumption that it is -- inhabited, then it is propositional. [inhabited⇒contractible]⇒propositional : (A → Contractible A) → Is-proposition A [inhabited⇒contractible]⇒propositional h x = mono₁ 0 (h x) x -- If something has h-level (1 + n) given the assumption that it is -- inhabited, then it has h-level (1 + n). [inhabited⇒+]⇒+ : ∀ n → (A → H-level (1 + n) A) → H-level (1 + n) A [inhabited⇒+]⇒+ n h = _⇔_.from H-level⇔H-level′ λ x → _⇔_.to H-level⇔H-level′ (h x) x -- An alternative characterisation of sets and higher h-levels. -- -- This is Theorem 7.2.7 from the HoTT book. 2+⇔∀1+≡ : ∀ n → H-level (2 + n) A ⇔ ((x : A) → H-level (1 + n) (x ≡ x)) 2+⇔∀1+≡ n = record { to = λ h _ → h ; from = λ h → [inhabited⇒+]⇒+ _ (elim (λ {x y} _ → H-level (1 + n) (x ≡ y)) h) } -- If a propositional type is inhabited, then it is contractible. propositional⇒inhabited⇒contractible : Is-proposition A → A → Contractible A propositional⇒inhabited⇒contractible p x = (x , p x) -- H-level′ n respects (split) surjections. respects-surjection′ : A ↠ B → ∀ n → H-level′ n A → H-level′ n B respects-surjection′ A↠B zero (x , irr) = (to x , irr′) where open _↠_ A↠B irr′ : ∀ y → to x ≡ y irr′ = λ y → to x ≡⟨ cong to (irr (from y)) ⟩ to (from y) ≡⟨ right-inverse-of y ⟩∎ y ∎ respects-surjection′ A↠B (suc n) h = λ x y → respects-surjection′ (↠-≡ A↠B) n (h (from x) (from y)) where open _↠_ A↠B -- H-level n respects (split) surjections. respects-surjection : A ↠ B → ∀ n → H-level n A → H-level n B respects-surjection A↠B n = _⇔_.from H-level⇔H-level′ ∘ respects-surjection′ A↠B n ∘ _⇔_.to H-level⇔H-level′
{ "alphanum_fraction": 0.5556559451, "avg_line_length": 28.0913705584, "ext": "agda", "hexsha": "0c6188078c53910b5cc02b16b5a4247d19619f2c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/H-level.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/H-level.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/H-level.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": 2050, "size": 5534 }
-- define ⋁ and ⋀ as the bigOps of a Ring when interpreted -- as an additive/multiplicative monoid {-# OPTIONS --safe #-} module Cubical.Algebra.DistLattice.BigOps where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.Transport open import Cubical.Foundations.SIP open import Cubical.Data.Sigma open import Cubical.Data.Nat using (ℕ ; zero ; suc) open import Cubical.Data.FinData open import Cubical.Data.Bool open import Cubical.Structures.Axioms open import Cubical.Structures.Auto open import Cubical.Structures.Macro open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open import Cubical.Algebra.Monoid.BigOp open import Cubical.Algebra.CommMonoid open import Cubical.Algebra.Semilattice open import Cubical.Algebra.Lattice open import Cubical.Algebra.DistLattice open import Cubical.Relation.Binary.Poset private variable ℓ : Level module KroneckerDelta (L' : DistLattice ℓ) where private L = fst L' open DistLatticeStr (snd L') δ : {n : ℕ} (i j : Fin n) → L δ i j = if i == j then 1l else 0l module Join (L' : DistLattice ℓ) where private L = fst L' open DistLatticeStr (snd L') open MonoidBigOp (Semilattice→Monoid (Lattice→JoinSemilattice (DistLattice→Lattice L'))) -- extra DistLattice→JoinMonoid? open LatticeTheory (DistLattice→Lattice L') open KroneckerDelta L' ⋁ = bigOp ⋁Ext = bigOpExt ⋁0l = bigOpε ⋁Last = bigOpLast ⋁Split : ∀ {n} → (V W : FinVec L n) → ⋁ (λ i → V i ∨l W i) ≡ ⋁ V ∨l ⋁ W ⋁Split = bigOpSplit ∨lComm ⋁Meetrdist : ∀ {n} → (x : L) → (V : FinVec L n) → x ∧l ⋁ V ≡ ⋁ λ i → x ∧l V i ⋁Meetrdist {n = zero} x _ = 0lRightAnnihilates∧l x ⋁Meetrdist {n = suc n} x V = x ∧l (V zero ∨l ⋁ (V ∘ suc)) ≡⟨ ∧lLdist∨l _ _ _ ⟩ --Ldist and Rdist wrong way around? (x ∧l V zero) ∨l (x ∧l ⋁ (V ∘ suc)) ≡⟨ (λ i → (x ∧l V zero) ∨l ⋁Meetrdist x (V ∘ suc) i) ⟩ (x ∧l V zero) ∨l ⋁ (λ i → x ∧l V (suc i)) ∎ ⋁Meetldist : ∀ {n} → (x : L) → (V : FinVec L n) → (⋁ V) ∧l x ≡ ⋁ λ i → V i ∧l x ⋁Meetldist {n = zero} x _ = 0lLeftAnnihilates∧l x ⋁Meetldist {n = suc n} x V = (V zero ∨l ⋁ (V ∘ suc)) ∧l x ≡⟨ ∧lRdist∨l _ _ _ ⟩ (V zero ∧l x) ∨l ((⋁ (V ∘ suc)) ∧l x) ≡⟨ (λ i → (V zero ∧l x) ∨l ⋁Meetldist x (V ∘ suc) i) ⟩ (V zero ∧l x) ∨l ⋁ (λ i → V (suc i) ∧l x) ∎ ⋁Meetr0 : ∀ {n} → (V : FinVec L n) → ⋁ (λ i → V i ∧l 0l) ≡ 0l ⋁Meetr0 V = sym (⋁Meetldist 0l V) ∙ 0lRightAnnihilates∧l _ ⋁Meet0r : ∀ {n} → (V : FinVec L n) → ⋁ (λ i → 0l ∧l V i) ≡ 0l ⋁Meet0r V = sym (⋁Meetrdist 0l V) ∙ 0lLeftAnnihilates∧l _ ⋁Meetr1 : (n : ℕ) (V : FinVec L n) → (j : Fin n) → ⋁ (λ i → V i ∧l δ i j) ≡ V j ⋁Meetr1 (suc n) V zero = (λ k → ∧lRid (V zero) k ∨l ⋁Meetr0 (V ∘ suc) k) ∙ ∨lRid (V zero) ⋁Meetr1 (suc n) V (suc j) = (λ i → 0lRightAnnihilates∧l (V zero) i ∨l ⋁ (λ x → V (suc x) ∧l δ x j)) ∙∙ ∨lLid _ ∙∙ ⋁Meetr1 n (V ∘ suc) j ⋁Meet1r : (n : ℕ) (V : FinVec L n) → (j : Fin n) → ⋁ (λ i → (δ j i) ∧l V i) ≡ V j ⋁Meet1r (suc n) V zero = (λ k → ∧lLid (V zero) k ∨l ⋁Meet0r (V ∘ suc) k) ∙ ∨lRid (V zero) ⋁Meet1r (suc n) V (suc j) = (λ i → 0lLeftAnnihilates∧l (V zero) i ∨l ⋁ (λ i → (δ j i) ∧l V (suc i))) ∙∙ ∨lLid _ ∙∙ ⋁Meet1r n (V ∘ suc) j -- inequalities of big joins open JoinSemilattice (Lattice→JoinSemilattice (DistLattice→Lattice L')) open PosetReasoning IndPoset open PosetStr (IndPoset .snd) hiding (_≤_) ⋁IsMax : {n : ℕ} (U : FinVec L n) (x : L) → (∀ i → U i ≤ x) → ⋁ U ≤ x ⋁IsMax {n = zero} _ _ _ = ∨lLid _ ⋁IsMax {n = suc n} U x U≤x = ⋁ U ≤⟨ is-refl _ ⟩ U zero ∨l ⋁ (U ∘ suc) ≤⟨ ≤-∨LPres _ _ _ (⋁IsMax _ _ (U≤x ∘ suc)) ⟩ U zero ∨l x ≤⟨ ∨lIsMax _ _ _ (U≤x zero) (is-refl x) ⟩ x ◾ ≤-⋁Ext : {n : ℕ} (U W : FinVec L n) → (∀ i → U i ≤ W i) → ⋁ U ≤ ⋁ W ≤-⋁Ext {n = zero} U W U≤W = is-refl 0l ≤-⋁Ext {n = suc n} U W U≤W = ⋁ U ≤⟨ is-refl _ ⟩ U zero ∨l ⋁ (U ∘ suc) ≤⟨ ≤-∨Pres _ _ _ _ (U≤W zero) (≤-⋁Ext _ _ (U≤W ∘ suc)) ⟩ W zero ∨l ⋁ (W ∘ suc) ≤⟨ is-refl _ ⟩ ⋁ W ◾ module Meet (L' : DistLattice ℓ) where private L = fst L' open DistLatticeStr (snd L') open MonoidBigOp (Semilattice→Monoid (Lattice→MeetSemilattice (DistLattice→Lattice L'))) -- extra DistLattice→MeetMonoid? open LatticeTheory (DistLattice→Lattice L') open KroneckerDelta L' ⋀ = bigOp ⋀Ext = bigOpExt ⋀1l = bigOpε ⋀Last = bigOpLast ⋀Split : ∀ {n} → (V W : FinVec L n) → ⋀ (λ i → V i ∧l W i) ≡ ⋀ V ∧l ⋀ W ⋀Split = bigOpSplit ∧lComm ⋀Joinrdist : ∀ {n} → (x : L) → (V : FinVec L n) → x ∨l ⋀ V ≡ ⋀ λ i → x ∨l V i ⋀Joinrdist {n = zero} x _ = 1lRightAnnihilates∨l x ⋀Joinrdist {n = suc n} x V = x ∨l (V zero ∧l ⋀ (V ∘ suc)) ≡⟨ ∨lLdist∧l _ _ _ ⟩ --Ldist and Rdist wrong way around? (x ∨l V zero) ∧l (x ∨l ⋀ (V ∘ suc)) ≡⟨ (λ i → (x ∨l V zero) ∧l ⋀Joinrdist x (V ∘ suc) i) ⟩ (x ∨l V zero) ∧l ⋀ (λ i → x ∨l V (suc i)) ∎ ⋀Joinldist : ∀ {n} → (x : L) → (V : FinVec L n) → (⋀ V) ∨l x ≡ ⋀ λ i → V i ∨l x ⋀Joinldist {n = zero} x _ = 1lLeftAnnihilates∨l x ⋀Joinldist {n = suc n} x V = (V zero ∧l ⋀ (V ∘ suc)) ∨l x ≡⟨ ∨lRdist∧l _ _ _ ⟩ (V zero ∨l x) ∧l ((⋀ (V ∘ suc)) ∨l x) ≡⟨ (λ i → (V zero ∨l x) ∧l ⋀Joinldist x (V ∘ suc) i) ⟩ (V zero ∨l x) ∧l ⋀ (λ i → V (suc i) ∨l x) ∎ ⋀Joinr1 : ∀ {n} → (V : FinVec L n) → ⋀ (λ i → V i ∨l 1l) ≡ 1l ⋀Joinr1 V = sym (⋀Joinldist 1l V) ∙ 1lRightAnnihilates∨l _ ⋀Join1r : ∀ {n} → (V : FinVec L n) → ⋀ (λ i → 1l ∨l V i) ≡ 1l ⋀Join1r V = sym (⋀Joinrdist 1l V) ∙ 1lLeftAnnihilates∨l _
{ "alphanum_fraction": 0.5671950379, "avg_line_length": 36.5031446541, "ext": "agda", "hexsha": "53a49c5e870302d2d79ad89682f577fa3510b069", "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": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dolio/cubical", "max_forks_repo_path": "Cubical/Algebra/DistLattice/BigOps.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "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": "dolio/cubical", "max_issues_repo_path": "Cubical/Algebra/DistLattice/BigOps.agda", "max_line_length": 101, "max_stars_count": null, "max_stars_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dolio/cubical", "max_stars_repo_path": "Cubical/Algebra/DistLattice/BigOps.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2774, "size": 5804 }
module examplesPaperJFP.IOExampleConsole where open import examplesPaperJFP.BasicIO hiding (main) open import examplesPaperJFP.Console hiding (main) open import examplesPaperJFP.NativeIOSafe open import examplesPaperJFP.CatTerm main : NativeIO Unit main = translateIOConsole cat
{ "alphanum_fraction": 0.8576512456, "avg_line_length": 28.1, "ext": "agda", "hexsha": "17b356f4f611447772465a3e1f15f1d90a35cbe6", "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": "examples/examplesPaperJFP/IOExampleConsole.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": "examples/examplesPaperJFP/IOExampleConsole.agda", "max_line_length": 50, "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": "examples/examplesPaperJFP/IOExampleConsole.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": 66, "size": 281 }
{-# OPTIONS --safe #-} module Cubical.Categories.Additive where open import Cubical.Categories.Additive.Base public open import Cubical.Categories.Additive.Properties public open import Cubical.Categories.Additive.Quotient public
{ "alphanum_fraction": 0.8275862069, "avg_line_length": 29, "ext": "agda", "hexsha": "01f66ab77d82b17ad65380dc6cae2fc216f1d595", "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/Categories/Additive.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/Categories/Additive.agda", "max_line_length": 57, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Categories/Additive.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 45, "size": 232 }
{- This second-order term syntax was created from the following second-order syntax description: syntax CTLC | ΛC type N : 0-ary _↣_ : 2-ary | r30 ¬_ : 1-ary | r30 term app : α ↣ β α -> β | _$_ l20 lam : α.β -> α ↣ β | ƛ_ r10 throw : α ¬ α -> β callcc : ¬ α.α -> α theory (ƛβ) b : α.β a : α |> app (lam(x.b[x]), a) = b[a] (ƛη) f : α ↣ β |> lam (x. app(f, x)) = f -} module CTLC.Syntax where open import SOAS.Common open import SOAS.Context open import SOAS.Variable open import SOAS.Families.Core open import SOAS.Construction.Structure open import SOAS.ContextMaps.Inductive open import SOAS.Metatheory.Syntax open import CTLC.Signature private variable Γ Δ Π : Ctx α β : ΛCT 𝔛 : Familyₛ -- Inductive term declaration module ΛC:Terms (𝔛 : Familyₛ) where data ΛC : Familyₛ where var : ℐ ⇾̣ ΛC mvar : 𝔛 α Π → Sub ΛC Π Γ → ΛC α Γ _$_ : ΛC (α ↣ β) Γ → ΛC α Γ → ΛC β Γ ƛ_ : ΛC β (α ∙ Γ) → ΛC (α ↣ β) Γ throw : ΛC α Γ → ΛC (¬ α) Γ → ΛC β Γ callcc : ΛC α ((¬ α) ∙ Γ) → ΛC α Γ infixl 20 _$_ infixr 10 ƛ_ open import SOAS.Metatheory.MetaAlgebra ⅀F 𝔛 ΛCᵃ : MetaAlg ΛC ΛCᵃ = record { 𝑎𝑙𝑔 = λ where (appₒ ⋮ a , b) → _$_ a b (lamₒ ⋮ a) → ƛ_ a (throwₒ ⋮ a , b) → throw a b (callccₒ ⋮ a) → callcc a ; 𝑣𝑎𝑟 = var ; 𝑚𝑣𝑎𝑟 = λ 𝔪 mε → mvar 𝔪 (tabulate mε) } module ΛCᵃ = MetaAlg ΛCᵃ module _ {𝒜 : Familyₛ}(𝒜ᵃ : MetaAlg 𝒜) where open MetaAlg 𝒜ᵃ 𝕤𝕖𝕞 : ΛC ⇾̣ 𝒜 𝕊 : Sub ΛC Π Γ → Π ~[ 𝒜 ]↝ Γ 𝕊 (t ◂ σ) new = 𝕤𝕖𝕞 t 𝕊 (t ◂ σ) (old v) = 𝕊 σ v 𝕤𝕖𝕞 (mvar 𝔪 mε) = 𝑚𝑣𝑎𝑟 𝔪 (𝕊 mε) 𝕤𝕖𝕞 (var v) = 𝑣𝑎𝑟 v 𝕤𝕖𝕞 (_$_ a b) = 𝑎𝑙𝑔 (appₒ ⋮ 𝕤𝕖𝕞 a , 𝕤𝕖𝕞 b) 𝕤𝕖𝕞 (ƛ_ a) = 𝑎𝑙𝑔 (lamₒ ⋮ 𝕤𝕖𝕞 a) 𝕤𝕖𝕞 (throw a b) = 𝑎𝑙𝑔 (throwₒ ⋮ 𝕤𝕖𝕞 a , 𝕤𝕖𝕞 b) 𝕤𝕖𝕞 (callcc a) = 𝑎𝑙𝑔 (callccₒ ⋮ 𝕤𝕖𝕞 a) 𝕤𝕖𝕞ᵃ⇒ : MetaAlg⇒ ΛCᵃ 𝒜ᵃ 𝕤𝕖𝕞 𝕤𝕖𝕞ᵃ⇒ = record { ⟨𝑎𝑙𝑔⟩ = λ{ {t = t} → ⟨𝑎𝑙𝑔⟩ t } ; ⟨𝑣𝑎𝑟⟩ = refl ; ⟨𝑚𝑣𝑎𝑟⟩ = λ{ {𝔪 = 𝔪}{mε} → cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-tab mε)) } } where open ≡-Reasoning ⟨𝑎𝑙𝑔⟩ : (t : ⅀ ΛC α Γ) → 𝕤𝕖𝕞 (ΛCᵃ.𝑎𝑙𝑔 t) ≡ 𝑎𝑙𝑔 (⅀₁ 𝕤𝕖𝕞 t) ⟨𝑎𝑙𝑔⟩ (appₒ ⋮ _) = refl ⟨𝑎𝑙𝑔⟩ (lamₒ ⋮ _) = refl ⟨𝑎𝑙𝑔⟩ (throwₒ ⋮ _) = refl ⟨𝑎𝑙𝑔⟩ (callccₒ ⋮ _) = refl 𝕊-tab : (mε : Π ~[ ΛC ]↝ Γ)(v : ℐ α Π) → 𝕊 (tabulate mε) v ≡ 𝕤𝕖𝕞 (mε v) 𝕊-tab mε new = refl 𝕊-tab mε (old v) = 𝕊-tab (mε ∘ old) v module _ (g : ΛC ⇾̣ 𝒜)(gᵃ⇒ : MetaAlg⇒ ΛCᵃ 𝒜ᵃ g) where open MetaAlg⇒ gᵃ⇒ 𝕤𝕖𝕞! : (t : ΛC α Γ) → 𝕤𝕖𝕞 t ≡ g t 𝕊-ix : (mε : Sub ΛC Π Γ)(v : ℐ α Π) → 𝕊 mε v ≡ g (index mε v) 𝕊-ix (x ◂ mε) new = 𝕤𝕖𝕞! x 𝕊-ix (x ◂ mε) (old v) = 𝕊-ix mε v 𝕤𝕖𝕞! (mvar 𝔪 mε) rewrite cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-ix mε)) = trans (sym ⟨𝑚𝑣𝑎𝑟⟩) (cong (g ∘ mvar 𝔪) (tab∘ix≈id mε)) 𝕤𝕖𝕞! (var v) = sym ⟨𝑣𝑎𝑟⟩ 𝕤𝕖𝕞! (_$_ a b) rewrite 𝕤𝕖𝕞! a | 𝕤𝕖𝕞! b = sym ⟨𝑎𝑙𝑔⟩ 𝕤𝕖𝕞! (ƛ_ a) rewrite 𝕤𝕖𝕞! a = sym ⟨𝑎𝑙𝑔⟩ 𝕤𝕖𝕞! (throw a b) rewrite 𝕤𝕖𝕞! a | 𝕤𝕖𝕞! b = sym ⟨𝑎𝑙𝑔⟩ 𝕤𝕖𝕞! (callcc a) rewrite 𝕤𝕖𝕞! a = sym ⟨𝑎𝑙𝑔⟩ -- Syntax instance for the signature ΛC:Syn : Syntax ΛC:Syn = record { ⅀F = ⅀F ; ⅀:CS = ⅀:CompatStr ; mvarᵢ = ΛC:Terms.mvar ; 𝕋:Init = λ 𝔛 → let open ΛC:Terms 𝔛 in record { ⊥ = ΛC ⋉ ΛCᵃ ; ⊥-is-initial = record { ! = λ{ {𝒜 ⋉ 𝒜ᵃ} → 𝕤𝕖𝕞 𝒜ᵃ ⋉ 𝕤𝕖𝕞ᵃ⇒ 𝒜ᵃ } ; !-unique = λ{ {𝒜 ⋉ 𝒜ᵃ} (f ⋉ fᵃ⇒) {x = t} → 𝕤𝕖𝕞! 𝒜ᵃ f fᵃ⇒ t } } } } -- Instantiation of the syntax and metatheory open Syntax ΛC:Syn public open ΛC:Terms public open import SOAS.Families.Build public open import SOAS.Syntax.Shorthands ΛCᵃ public open import SOAS.Metatheory ΛC:Syn public
{ "alphanum_fraction": 0.5204951857, "avg_line_length": 26.3405797101, "ext": "agda", "hexsha": "a346871f12bdf7799d45e6fbf226f1603d12a567", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "out/CTLC/Syntax.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "out/CTLC/Syntax.agda", "max_line_length": 93, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "out/CTLC/Syntax.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 2374, "size": 3635 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.RingSolver.Examples where open import Cubical.Foundations.Prelude open import Cubical.Data.FinData open import Cubical.Data.Nat using (ℕ) open import Cubical.Data.Vec.Base open import Cubical.Algebra.RingSolver.AlmostRing open import Cubical.Algebra.RingSolver.NatAsAlmostRing open import Cubical.Algebra.RingSolver.RingExpression open import Cubical.Algebra.RingSolver.RawRing renaming (⟨_⟩ to ⟨_⟩ᵣ) open import Cubical.Algebra.RingSolver.HornerForms open import Cubical.Algebra.RingSolver.Solver private variable ℓ : Level module MultivariateSolving where open AlmostRing ℕAsAlmostRing ℕAsRawRing = AlmostRing→RawRing ℕAsAlmostRing open EqualityToNormalform ℕAsAlmostRing ℕ[X₀,X₁] = IteratedHornerOperations.asRawRing ℕAsRawRing 2 X₀ : ⟨ ℕ[X₀,X₁] ⟩ᵣ X₀ = Variable 2 ℕAsRawRing (Fin.zero) X₁ : ⟨ ℕ[X₀,X₁] ⟩ᵣ X₁ = Variable 2 ℕAsRawRing (suc Fin.zero) Two : ⟨ ℕ[X₀,X₁] ⟩ᵣ Two = Constant 2 ℕAsRawRing 2 _ : eval 2 X₀ (1 ∷ 0 ∷ []) ≡ 1 _ = refl _ : eval 2 X₁ (0 ∷ 1 ∷ []) ≡ 1 _ = refl X : Expr ℕ 3 X = ∣ Fin.zero Y : Expr ℕ 3 Y = ∣ (suc Fin.zero) Z : Expr ℕ 3 Z = ∣ (suc (suc Fin.zero)) {- 'normalize' maps an expression to its Horner Normalform. Two expressions evaluating to the same ring element have the same Horner Normal form. This means equality of the represented ring elements can be checked by agda's unification (so refl is a proof) -} _ : normalize 3 ((K 2) ⊗ X) ≡ normalize 3 (X ⊕ X) _ = refl _ : normalize 3 ((K 2) ⊗ X) ≡ normalize 3 (X ⊕ X) _ = refl _ : normalize 3 (((K 2) ⊗ X) ⊗ Y) ≡ normalize 3 (Y ⊗ (X ⊕ X)) _ = refl _ : normalize 3 (Z ⊗ (((K 2) ⊗ X) ⊗ Y)) ≡ normalize 3 (Z ⊗ (Y ⊗ (X ⊕ X))) _ = refl {- The solver needs to produce an equality between actual ring elements. So we need a proof that those actual ring elements are equal to a normal form: -} _ : (x y z : ℕ) → eval 3 (normalize 3 ((K 2) ⊗ X ⊗ Y)) (x ∷ y ∷ z ∷ []) ≡ 2 · x · y _ = λ x y z → isEqualToNormalform 3 ((K 2) ⊗ X ⊗ Y) (x ∷ y ∷ z ∷ []) {- Now two of these proofs can be plugged together to solve an equation: -} open Eval ℕAsRawRing _ : (x y z : ℕ) → 3 + x + y · y ≡ y · y + x + 1 + 2 _ = let lhs = (K 3) ⊕ X ⊕ (Y ⊗ Y) rhs = Y ⊗ Y ⊕ X ⊕ (K 1) ⊕ (K 2) in (λ x y z → ⟦ lhs ⟧ (x ∷ y ∷ z ∷ []) ≡⟨ sym (isEqualToNormalform 3 lhs (x ∷ y ∷ z ∷ [])) ⟩ eval 3 (normalize 3 lhs) (x ∷ y ∷ z ∷ []) ≡⟨ refl ⟩ eval 3 (normalize 3 rhs) (x ∷ y ∷ z ∷ []) ≡⟨ isEqualToNormalform 3 rhs (x ∷ y ∷ z ∷ []) ⟩ ⟦ rhs ⟧ (x ∷ y ∷ z ∷ []) ∎) {- Parts of that can be automated easily: -} _ : (x y z : ℕ) → (x + y) · (x + y) ≡ x · x + 2 · x · y + y · y _ = λ x y z → let lhs = (X ⊕ Y) ⊗ (X ⊕ Y) rhs = X ⊗ X ⊕ (K 2) ⊗ X ⊗ Y ⊕ Y ⊗ Y in solve lhs rhs (x ∷ y ∷ z ∷ []) refl {- A bigger example -} _ : (x y z : ℕ) → (x + y) · (x + y) · (x + y) · (x + y) ≡ x · x · x · x + 4 · x · x · x · y + 6 · x · x · y · y + 4 · x · y · y · y + y · y · y · y _ = λ x y z → let lhs = (X ⊕ Y) ⊗ (X ⊕ Y) ⊗ (X ⊕ Y) ⊗ (X ⊕ Y) rhs = X ⊗ X ⊗ X ⊗ X ⊕ (K 4) ⊗ X ⊗ X ⊗ X ⊗ Y ⊕ (K 6) ⊗ X ⊗ X ⊗ Y ⊗ Y ⊕ (K 4) ⊗ X ⊗ Y ⊗ Y ⊗ Y ⊕ Y ⊗ Y ⊗ Y ⊗ Y in solve lhs rhs (x ∷ y ∷ z ∷ []) refl {- this one cannot work so far: _ : (x y z : ℕ) → (x + y) · (x - y) ≡ (x · x - (y · y)) _ = λ x y z → let lhs = (X ⊕ Y) ⊗ (X ⊕ (⊝ Y)) rhs = (X ⊗ X) ⊕ (⊝ (Y ⊗ Y)) in solve lhs rhs (x ∷ y ∷ z ∷ []) {!!} -} module ExamplesForArbitraryRings (R : AlmostRing {ℓ}) where open AlmostRing R open EqualityToNormalform R X : Expr ⟨ R ⟩ 4 X = ∣ Fin.zero Y : Expr ⟨ R ⟩ 4 Y = ∣ (suc Fin.zero) A : Expr ⟨ R ⟩ 4 A = ∣ (suc (suc Fin.zero)) B : Expr ⟨ R ⟩ 4 B = ∣ (suc (suc (suc Fin.zero))) _ : (x y a b : ⟨ R ⟩) → (x + y) + (a + b) ≡ (y + b) + (x + a) _ = λ x y a b → let lhs = (X ⊕ Y) ⊕ (A ⊕ B) rhs = (Y ⊕ B) ⊕ (X ⊕ A) in solve lhs rhs (x ∷ y ∷ a ∷ b ∷ []) refl _ : (x y a b : ⟨ R ⟩) → (x + y) · (x + y) ≡ x · x + x · y + x · y + y · y _ = λ x y a b → let lhs = (X ⊕ Y) ⊗ (X ⊕ Y) rhs = (X ⊗ X) ⊕ (X ⊗ Y) ⊕ (X ⊗ Y) ⊕ (Y ⊗ Y) in solve lhs rhs (x ∷ y ∷ a ∷ b ∷ []) refl _ : (x y a b : ⟨ R ⟩) → x · a ≡ a · x _ = λ x y a b → let lhs = X ⊗ A rhs = A ⊗ X in solve lhs rhs (x ∷ y ∷ a ∷ b ∷ []) refl {- this one should work, but doesn't: _ : (x y a b : ⟨ R ⟩) → x · (a + b) ≡ a · x + b · x _ = λ x y a b → let lhs = X ⊗ (A ⊕ B) rhs = (A ⊗ X) ⊕ (B ⊗ X) in solve lhs rhs (x ∷ y ∷ a ∷ b ∷ []) refl the reason ist, that lhs and rhs evaluate to definitionally different things: (0r · x + (0r · y + ((0r · a + (0r · b + 1r · 1r)) · a + ((0r · b + 1r · 1r) · b + 1r · 0r)))) · x + 0r (0r · x + (0r · y + ((0r · a + (0r · b + 1r · 1r)) · a + ((0r · b + 1r · 1r) · b + (0r + 0r · 1r))))) · x + 0r -} {- '-' is problematic... _ : (x y a b : ⟨ R ⟩) → (x + y) · (x - y) ≡ (x · x - (y · y)) _ = λ x y a b → let lhs = (X ⊕ Y) ⊗ (X ⊕ (⊝ Y)) rhs = (X ⊗ X) ⊕ (⊝ (Y ⊗ Y)) in solve lhs rhs (x ∷ y ∷ a ∷ b ∷ []) {!!} -}
{ "alphanum_fraction": 0.4477982955, "avg_line_length": 27.3398058252, "ext": "agda", "hexsha": "454b40ddcfc3f30ae4555400f2d591a2e4618493", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "apabepa10/cubical", "max_forks_repo_path": "Cubical/Algebra/RingSolver/Examples.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "apabepa10/cubical", "max_issues_repo_path": "Cubical/Algebra/RingSolver/Examples.agda", "max_line_length": 79, "max_stars_count": null, "max_stars_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "apabepa10/cubical", "max_stars_repo_path": "Cubical/Algebra/RingSolver/Examples.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2369, "size": 5632 }
{- This file contains: - Eliminators of direct limit, especially an index-shifting version; - Connectivity of inclusion maps. -} {-# OPTIONS --safe #-} module Cubical.HITs.SequentialColimit.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv.Properties open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Function open import Cubical.Data.Nat hiding (elim) open import Cubical.HITs.SequentialColimit.Base open import Cubical.Homotopy.Connected private variable ℓ ℓ' : Level module _ (X : Sequence ℓ) where open Sequence private inl∞ : (n : ℕ) → X .space n → Lim→ X inl∞ n = inl {n = n} record ElimData (P : Lim→ X → Type ℓ') : Type (ℓ-max ℓ ℓ') where field finl : {k : ℕ}(x : X .space k) → P (inl x) fpush : {k : ℕ}(x : X .space k) → PathP (λ i → P (push x i)) (finl x) (finl (X .map x)) record ElimShiftData (n : ℕ)(P : Lim→ X → Type ℓ') : Type (ℓ-max ℓ ℓ') where field finl : {k : ℕ}(x : X .space (k + n)) → P (inl x) fpush : {k : ℕ}(x : X .space (k + n)) → PathP (λ i → P (push x i)) (finl x) (finl (X .map x)) open ElimData open ElimShiftData ElimData→ElimShiftData : (n : ℕ)(P : Lim→ X → Type ℓ') → ElimData P → ElimShiftData n P ElimData→ElimShiftData n P datum .finl = datum .finl ElimData→ElimShiftData n P datum .fpush = datum .fpush -- Preliminary lemmas -- The difficulty is mainly due to natural numbers having no strict +-commutativity private alg-path : (a b : ℕ) → a + (1 + b) ≡ 1 + (a + b) alg-path a b = +-assoc a 1 b ∙ (λ i → +-comm a 1 i + b) module _ (P : Lim→ X → Type ℓ') (datum : ElimShiftData 0 P) where +-zero-0 : refl ≡ +-zero 0 +-zero-0 i j = isSet→SquareP (λ i j → isSetℕ) refl refl refl (+-zero 0) j i finl'-filler : (k : ℕ) → (i : I) → (x : X .space (+-zero k i)) → P (inl x) finl'-filler k i = transport-filler (λ i → (x : X .space (+-zero k i)) → P (inl x)) (datum .finl) i finl' : (k : ℕ) → (x : X .space k) → P (inl x) finl' k = finl'-filler k i1 finl'-0-eq : datum .finl ≡ finl' 0 finl'-0-eq = sym (transportRefl _) ∙ (λ j → transport (λ i → (x : X .space (+-zero-0 j i)) → P (inl x)) (datum .finl {k = 0})) fpush' : (k : ℕ) → (x : X .space k) → PathP (λ i → P (push x i)) (finl' k x) (finl' (1 + k) (X .map x)) fpush' k = transport (λ i → (x : X .space (+-zero k i)) → PathP (λ i → P (push x i)) (finl'-filler k i x) (finl'-filler (1 + k) i (X .map x))) (datum .fpush) ElimShiftData0→ElimData : ElimData P ElimShiftData0→ElimData .finl = finl' _ ElimShiftData0→ElimData .fpush = fpush' _ module _ (n : ℕ)(P : Lim→ X → Type ℓ') (datum : ElimShiftData (1 + n) P) where alg-path-0 : (b : ℕ) → refl ≡ alg-path 0 b alg-path-0 b i j = isSet→SquareP (λ i j → isSetℕ) refl refl refl (alg-path 0 b) j i finl-n-filler : (k : ℕ) → (i : I) → ((x : X .space (alg-path k n i)) → P (inl x)) finl-n-filler k i = transport-filler (λ i → (x : X .space (alg-path k n i)) → P (inl x)) (datum .finl) i finl-n : (k : ℕ) → (x : X .space ((1 + k) + n)) → P (inl x) finl-n k = finl-n-filler k i1 fpush-n : (k : ℕ) → (x : X .space ((1 + k) + n)) → PathP (λ i → P (push x i)) (finl-n k x) (finl-n (1 + k) (X .map x)) fpush-n k = transport (λ i → (x : X .space (alg-path k n i)) → PathP (λ i → P (push x i)) (finl-n-filler k i x) (finl-n-filler (1 + k) i (X .map x))) (datum .fpush) finl-0-filler : (x : X .space n) → (i : I) → P (push x i) finl-0-filler x i = transport-filler (λ i → P (push x (~ i))) (datum .finl {k = 0} (X .map x)) (~ i) finl-0 : (x : X .space n) → P (inl x) finl-0 x = finl-0-filler x i0 finl-0-eq : datum .finl {k = 0} ≡ finl-n 0 finl-0-eq = sym (transportRefl _) ∙ (λ j → transport (λ i → (x : X .space (alg-path-0 n j i)) → P (inl x)) (datum .finl {k = 0})) fpush-0 : (x : X .space n) → PathP (λ i → P (push x i)) (finl-0 x) (finl-n 0 (X .map x)) fpush-0 x i = hcomp (λ j → λ { (i = i0) → finl-0 x ; (i = i1) → finl-0-eq j (X .map x) }) (finl-0-filler x i) elimShiftDataSuc : ElimShiftData n P elimShiftDataSuc .finl {k = 0} = finl-0 elimShiftDataSuc .finl {k = suc k} = finl-n k elimShiftDataSuc .fpush {k = 0} = fpush-0 elimShiftDataSuc .fpush {k = suc k} = fpush-n k -- The eliminators elim : (P : Lim→ X → Type ℓ') → ElimData P → (x : Lim→ X) → P x elim P datum (inl x) = datum .finl x elim P datum (push x i) = datum .fpush x i elimShift : (n : ℕ) → (P : Lim→ X → Type ℓ') → ElimShiftData n P → (x : Lim→ X) → P x elimShift 0 _ datum = elim _ (ElimShiftData0→ElimData _ datum) elimShift (suc n) _ datum = elimShift n _ (elimShiftDataSuc _ _ datum) elimShiftβ : (n : ℕ)(k : ℕ) → (P : Lim→ X → Type ℓ') → (datum : ElimShiftData n P) → elimShift _ _ datum ∘ inl∞ (k + n) ≡ datum .finl elimShiftβ 0 0 _ datum = sym (finl'-0-eq _ datum) elimShiftβ 0 (suc k) P datum = transport (λ i → elimShift _ _ datum ∘ inl∞ (+-zero (suc k) (~ i)) ≡ finl'-filler P datum (suc k) (~ i)) refl elimShiftβ (suc n) 0 _ datum = elimShiftβ n _ _ (elimShiftDataSuc _ _ datum) ∙ sym (finl-0-eq _ _ datum) elimShiftβ (suc n) (suc k) P datum = transport (λ i → elimShift _ _ datum ∘ inl∞ (alg-path (suc k) n (~ i)) ≡ finl-n-filler n P datum (suc k) (~ i)) (elimShiftβ n (suc (suc k)) P (elimShiftDataSuc _ _ datum)) -- Lemma to lift sections open Iso private transpSec : (n : ℕ)(Y : Lim→ X → Type ℓ') (sec : (x : X .space n) → Y (inl x)) → (x : X .space n) → Y (inl (X .map x)) transpSec n Y sec x = transport (λ i → Y (push x i)) (sec x) module _ (d : ℕ)(n : ℕ) (conn : isConnectedFun d (X .map {n = n})) (Y : Lim→ X → TypeOfHLevel ℓ' d) where module _ (sec : (x : X .space n) → Y (inl (X .map x)) .fst) where lift-iso = elim.isIsoPrecompose _ d (Y ∘ inl) conn liftSec' : (x : X .space (1 + n)) → Y (inl x) .fst liftSec' = lift-iso .inv sec liftSecPath' : (x : X .space n) → sec x ≡ liftSec' (X .map x) liftSecPath' x i = lift-iso .rightInv sec (~ i) x module _ (sec : (x : X .space n) → Y (inl x) .fst) where liftSec : (x : X .space (1 + n)) → Y (inl x) .fst liftSec = liftSec' (transpSec n (λ x → Y x .fst) sec) liftSecPath : (x : X .space n) → PathP (λ i → Y (push x i) .fst) (sec x) (liftSec (X .map x)) liftSecPath x i = hcomp (λ j → λ { (i = i0) → sec x ; (i = i1) → liftSecPath' (transpSec n (λ x → Y x .fst) sec) x j }) (transport-filler (λ i → Y (push x i) .fst) (sec x) i) module _ (d : ℕ)(n : ℕ) (conn : (k : ℕ) → isConnectedFun d (X .map {n = k + n})) where private module _ (Y : Lim→ X → TypeOfHLevel ℓ' d) where lifting : (k : ℕ)(sec : (x : X .space n) → Y (inl x) .fst) → (x : X .space (k + n)) → Y (inl x) .fst lifting 0 sec = sec lifting (suc k) sec = liftSec d _ (conn _) Y (lifting k sec) liftingPath : (k : ℕ)(sec : (x : X .space n) → Y (inl x) .fst) → (x : X .space (k + n)) → PathP (λ i → Y (push x i) .fst) (lifting k sec x) (lifting (1 + k) sec (X .map x)) liftingPath k sec = liftSecPath d _ (conn _) Y (lifting k sec) liftingData : ((x : X .space n) → Y (inl x) .fst) → ElimShiftData n (λ x → Y x .fst) liftingData sec .finl = lifting _ sec liftingData sec .fpush = liftingPath _ sec hasSectionInl∘ : hasSection (λ (sec : (x : Lim→ X) → Y x .fst) → sec ∘ inl {n = n}) hasSectionInl∘ .fst sec = elimShift _ _ (liftingData sec) hasSectionInl∘ .snd sec = elimShiftβ _ _ _ (liftingData sec) -- Connectivity of inclusion map isConnectedInl∞ : isConnectedFun d (inl∞ n) isConnectedInl∞ = elim.isConnectedPrecompose _ _ hasSectionInl∘
{ "alphanum_fraction": 0.5372314453, "avg_line_length": 34.4201680672, "ext": "agda", "hexsha": "3108d2f26c546343047a2a713bd86a2c3abc76f5", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/HITs/SequentialColimit/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/HITs/SequentialColimit/Properties.agda", "max_line_length": 111, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/HITs/SequentialColimit/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 3161, "size": 8192 }
------------------------------------------------------------------------ -- Small coinductive higher lenses ------------------------------------------------------------------------ {-# OPTIONS --cubical --guardedness #-} import Equality.Path as P module Lens.Non-dependent.Higher.Coinductive.Small {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq open import Logical-equivalence using (_⇔_) open import Prelude as P hiding (id) open import Bijection equality-with-J as B using (_↔_) import Coherently-constant eq as CC open import Equality.Decidable-UIP equality-with-J using (Constant) open import Equality.Path.Isomorphisms eq open import Equivalence equality-with-J as Eq using (_≃_; Is-equivalence) open import Function-universe equality-with-J as F hiding (id; _∘_) open import H-level equality-with-J as H-level open import H-level.Closure equality-with-J open import H-level.Truncation.Propositional eq using (∥_∥) open import H-level.Truncation.Propositional.One-step eq as O using (∥_∥¹; ∣_∣) open import Preimage equality-with-J as Preimage using (_⁻¹_) open import Tactic.Sigma-cong equality-with-J open import Univalence-axiom equality-with-J open import Lens.Non-dependent eq import Lens.Non-dependent.Higher eq as Higher import Lens.Non-dependent.Higher.Combinators eq as HC import Lens.Non-dependent.Higher.Capriotti eq as Capriotti import Lens.Non-dependent.Higher.Coinductive eq as Coinductive open import Lens.Non-dependent.Higher.Coherently.Coinductive eq import Lens.Non-dependent.Higher.Coherently.Not-coinductive eq as NC private variable a b c d p q : Level A B C : Type a P : A → Type p z : A n : ℕ ------------------------------------------------------------------------ -- Constant-≃ -- A variant of Constant for type-valued functions. Constant-≃ : {A : Type a} → (A → Type p) → Type (a ⊔ p) Constant-≃ P = ∀ x y → P x ≃ P y -- Constant and Constant-≃ are pointwise equivalent (assuming -- univalence). Constant≃Constant-≃ : {P : A → Type p} → Univalence p → Constant P ≃ Constant-≃ P Constant≃Constant-≃ univ = ∀-cong ext λ _ → ∀-cong ext λ _ → ≡≃≃ univ -- The right-to-left direction of Constant-≃-get-⁻¹-≃ (which is -- defined below). Constant-≃-get-⁻¹-≃⁻¹ : {get : A → B} → (∃ λ (set : A → B → A) → ∃ λ (get-set : (a : A) (b : B) → get (set a b) ≡ b) → ∀ b₁ b₂ → let f : get ⁻¹ b₁ → get ⁻¹ b₂ f = λ (a , _) → set a b₂ , get-set a b₂ in Is-equivalence f) → Constant-≃ (get ⁻¹_) Constant-≃-get-⁻¹-≃⁻¹ (_ , _ , eq) b₁ b₂ = Eq.⟨ _ , eq b₁ b₂ ⟩ -- Constant-≃ (get ⁻¹_) can be expressed in terms of a "setter" and a -- "get-set" law that form a family of equivalences in a certain way. -- -- This lemma was suggested by Andrea Vezzosi when we discussed -- coinductive lenses with erased "proofs". -- -- The left-to-right direction of the lemma is not blocked, but the -- rest is. Constant-≃-get-⁻¹-≃ : Block "Constant-≃-get-⁻¹-≃" → {A : Type a} {B : Type b} {get : A → B} → Constant-≃ (get ⁻¹_) ≃ (∃ λ (set : A → B → A) → ∃ λ (get-set : (a : A) (b : B) → get (set a b) ≡ b) → ∀ b₁ b₂ → let f : get ⁻¹ b₁ → get ⁻¹ b₂ f = λ (a , _) → set a b₂ , get-set a b₂ in Is-equivalence f) Constant-≃-get-⁻¹-≃ bl {A = A} {B = B} {get = get} = inverse (equiv₃ bl) where equiv₁ = Constant-≃ (get ⁻¹_) ↔⟨⟩ (∀ b₁ b₂ → get ⁻¹ b₁ ≃ get ⁻¹ b₂) ↔⟨ (∀-cong ext λ _ → ∀-cong ext λ _ → Eq.≃-as-Σ) ⟩ (∀ b₁ b₂ → ∃ λ (f : get ⁻¹ b₁ → get ⁻¹ b₂) → Is-equivalence f) ↔⟨ Π-comm ⟩ (∀ b₂ b₁ → ∃ λ (f : get ⁻¹ b₁ → get ⁻¹ b₂) → Is-equivalence f) ↝⟨ (∀-cong ext λ _ → ∀-cong ext λ _ → Σ-cong-id currying) ⟩ (∀ b₂ b₁ → ∃ λ (f : ∀ a → get a ≡ b₁ → get ⁻¹ b₂) → Is-equivalence (uncurry f)) ↔⟨ (∀-cong ext λ _ → ΠΣ-comm) ⟩ (∀ b₂ → ∃ λ (f : ∀ b₁ a → get a ≡ b₁ → get ⁻¹ b₂) → ∀ b₁ → Is-equivalence (uncurry (f b₁))) ↝⟨ (∀-cong ext λ _ → Σ-cong-id Π-comm) ⟩ (∀ b₂ → ∃ λ (f : ∀ a b₁ → get a ≡ b₁ → get ⁻¹ b₂) → ∀ b₁ → Is-equivalence (uncurry (flip f b₁))) ↝⟨ (∀-cong ext λ _ → Σ-cong (∀-cong ext λ _ → inverse $ ∀-intro {k = equivalence} ext _) λ f → ∀-cong ext λ b₁ → Is-equivalence-cong {k = equivalence} ext λ (a , eq) → uncurry (f a) (b₁ , eq) ≡⟨ cong (uncurry (f a)) $ sym $ proj₂ (other-singleton-contractible _) _ ⟩∎ uncurry (f a) (get a , refl _) ∎) ⟩ (∀ b₂ → ∃ λ (f : A → get ⁻¹ b₂) → ∀ b₁ → Is-equivalence (f ∘ proj₁)) ↔⟨ ΠΣ-comm ⟩ (∃ λ (f : (b : B) → A → get ⁻¹ b) → ∀ b₂ b₁ → Is-equivalence (f b₂ ∘ proj₁)) ↝⟨ Σ-cong-refl Π-comm (λ _ → Π-comm) ⟩ (∃ λ (f : A → (b : B) → get ⁻¹ b) → ∀ b₁ b₂ → Is-equivalence ((_$ b₂) ∘ f ∘ proj₁)) ↝⟨ Σ-cong-refl (∀-cong ext λ _ → ΠΣ-comm) (λ _ → Eq.id) ⟩ (∃ λ (f : A → ∃ λ (set : B → A) → (b : B) → get (set b) ≡ b) → ∀ b₁ b₂ → Is-equivalence (Σ-map (_$ b₂) (_$ b₂) ∘ f ∘ proj₁)) ↝⟨ Σ-cong-id ΠΣ-comm ⟩ (∃ λ ((set , get-set) : ∃ λ (set : A → B → A) → (a : A) (b : B) → get (set a b) ≡ b) → ∀ b₁ b₂ → Is-equivalence λ (a , _) → set a b₂ , get-set a b₂) ↔⟨ inverse Σ-assoc ⟩□ (∃ λ (set : A → B → A) → ∃ λ (get-set : (a : A) (b : B) → get (set a b) ≡ b) → ∀ b₁ b₂ → Is-equivalence λ (a , _) → set a b₂ , get-set a b₂) □ equiv₂ = Eq.with-other-function (inverse equiv₁) Constant-≃-get-⁻¹-≃⁻¹ (λ (set , get-set , _) → ⟨ext⟩ λ b₁ → ⟨ext⟩ λ b₂ → Eq.lift-equality ext $ ⟨ext⟩ λ (a , _) → subst (λ _ → get ⁻¹ b₂) _ (set a b₂ , get-set a b₂) ≡⟨ subst-const _ ⟩∎ (set a b₂ , get-set a b₂) ∎) equiv₃ : Unit → _ ≃ _ equiv₃ _ ._≃_.to = _≃_.to equiv₂ equiv₃ ⊠ ._≃_.is-equivalence = _≃_.is-equivalence equiv₂ -- Constant-≃-get-⁻¹-≃ computes in a certain way. _ : ∀ {bl : Block "Constant-≃-get-⁻¹-≃"} {get : A → B} {set : A → B → A} {get-set : (a : A) (b : B) → get (set a b) ≡ b} {eq : ∀ b₁ b₂ → let f : get ⁻¹ b₁ → get ⁻¹ b₂ f = λ (a , _) → set a b₂ , get-set a b₂ in Is-equivalence f} {b₁ b₂} → _≃_.to (_≃_.from (Constant-≃-get-⁻¹-≃ bl) (set , get-set , eq) b₁ b₂) ≡ (λ (a , _) → set a b₂ , get-set a b₂) _ = refl _ ------------------------------------------------------------------------ -- Coherently-constant -- Coherently constant type-valued functions. Coherently-constant : Univalence p → {A : Type a} → (A → Type p) → Type (a ⊔ p) Coherently-constant univ = Coherently Constant-≃ (λ P c → O.rec′ P (λ x y → ≃⇒≡ univ (c x y))) -- Two variants of Coherently-constant are pointwise equivalent -- (when applicable, assuming univalence). Coinductive-coherently-constant≃Coherently-constant : {A : Type a} {P : A → Type p} → Univalence (a ⊔ lsuc p) → (univ : Univalence p) → Coinductive.Coherently-constant P ≃ Coherently-constant univ P Coinductive-coherently-constant≃Coherently-constant univ′ univ = Coherently-cong univ′ (λ _ → Constant≃Constant-≃ univ) (λ _ _ → refl _) -- Two variants of Coherently-constant are pointwise equivalent -- (when applicable, assuming univalence). Coherently-constant≃Coherently-constant : {A : Type a} {P : A → Type p} → Univalence (a ⊔ lsuc p) → (univ : Univalence p) → CC.Coherently-constant P ≃ Coherently-constant univ P Coherently-constant≃Coherently-constant {P = P} univ′ univ = CC.Coherently-constant P ↝⟨ Coinductive.Coherently-constant≃Coherently-constant univ′ ⟩ Coinductive.Coherently-constant P ↝⟨ Coinductive-coherently-constant≃Coherently-constant univ′ univ ⟩□ Coherently-constant univ P □ -- A map lemma for Coherently-constant. Coherently-constant-map : {P : A → Type p} {Q : B → Type q} (univ₁ : Univalence p) → (univ₂ : Univalence q) → (f : B → A) → (∀ x → P (f x) ≃ Q x) → Coherently-constant univ₁ P → Coherently-constant univ₂ Q Coherently-constant-map {P = P} {Q = Q} _ _ f P≃Q c .property x y = Q x ↝⟨ inverse $ P≃Q x ⟩ P (f x) ↝⟨ c .property (f x) (f y) ⟩ P (f y) ↝⟨ P≃Q y ⟩□ Q y □ Coherently-constant-map {P = P} {Q = Q} univ₁ univ₂ f P≃Q c .coherent = Coherently-constant-map univ₁ univ₂ (O.∥∥¹-map f) (O.elim λ where .O.Elim.∣∣ʳ → P≃Q .O.Elim.∣∣-constantʳ x y → Eq.lift-equality ext (_≃_.to (subst (λ z → O.rec′ P g (O.∥∥¹-map f z) ≃ O.rec′ Q h z) (O.∣∣-constant x y) (P≃Q x)) ≡⟨ Eq.to-subst ⟩ subst (λ z → O.rec′ P g (O.∥∥¹-map f z) → O.rec′ Q h z) (O.∣∣-constant x y) (_≃_.to (P≃Q x)) ≡⟨ (⟨ext⟩ λ _ → subst-→) ⟩ subst (O.rec′ Q h) (O.∣∣-constant x y) ∘ _≃_.to (P≃Q x) ∘ subst (O.rec′ P g ∘ O.∥∥¹-map f) (sym (O.∣∣-constant x y)) ≡⟨ cong₂ (λ f g → f ∘ _≃_.to (P≃Q x) ∘ g) (⟨ext⟩ λ q → subst-∘ P.id (O.rec′ Q h) (O.∣∣-constant x y) {p = q}) (⟨ext⟩ λ p → trans (subst-∘ P.id (O.rec′ P g ∘ O.∥∥¹-map f) (sym (O.∣∣-constant x y)) {p = p}) $ cong (λ eq → subst P.id eq p) $ trans (cong-sym _ _) $ cong sym $ sym $ cong-∘ _ _ _) ⟩ subst P.id (cong (O.rec′ Q h) (O.∣∣-constant x y)) ∘ _≃_.to (P≃Q x) ∘ subst P.id (sym (cong (O.rec′ P g) (cong (O.∥∥¹-map f) (O.∣∣-constant x y)))) ≡⟨ cong₂ (λ p q → subst P.id p ∘ _≃_.to (P≃Q x) ∘ subst P.id (sym q)) O.rec-∣∣-constant (trans (cong (cong (O.rec′ P g)) O.rec-∣∣-constant) $ O.rec-∣∣-constant) ⟩ subst P.id (h x y) ∘ _≃_.to (P≃Q x) ∘ subst P.id (sym (g (f x) (f y))) ≡⟨ cong₂ (λ p q → p ∘ _≃_.to (P≃Q x) ∘ q) (trans (⟨ext⟩ λ _ → subst-id-in-terms-of-≡⇒↝ equivalence) $ cong _≃_.to $ _≃_.right-inverse-of (≡≃≃ univ₂) _) (trans (⟨ext⟩ λ _ → subst-id-in-terms-of-inverse∘≡⇒↝ equivalence) $ cong _≃_.from $ _≃_.right-inverse-of (≡≃≃ univ₁) _) ⟩ _≃_.to (P≃Q y) ∘ _≃_.to (c .property (f x) (f y)) ∘ _≃_.from (P≃Q x) ∘ _≃_.to (P≃Q x) ∘ _≃_.from (c .property (f x) (f y)) ≡⟨ (⟨ext⟩ λ _ → cong (_≃_.to (P≃Q y) ∘ _≃_.to (c .property (f x) (f y))) $ _≃_.left-inverse-of (P≃Q x) _) ⟩ _≃_.to (P≃Q y) ∘ _≃_.to (c .property (f x) (f y)) ∘ _≃_.from (c .property (f x) (f y)) ≡⟨ (⟨ext⟩ λ _ → cong (_≃_.to (P≃Q y)) $ _≃_.right-inverse-of (c .property (f x) (f y)) _) ⟩∎ _≃_.to (P≃Q y) ∎)) (c .coherent) where g = λ x y → ≃⇒≡ univ₁ (c .property x y) h = λ x y → ≃⇒≡ univ₂ ((P≃Q y F.∘ c .property (f x) (f y)) F.∘ inverse (P≃Q x)) private -- A lemma used below. elim-Σ-≡,≡→≡-∣∣-constant : ∀ (e : O.Elim (λ x → P x → A)) {x y p} → let p′ = subst P (O.∣∣-constant x y) p in cong (uncurry $ O.elim e) (Σ-≡,≡→≡ (O.∣∣-constant x y) (refl p′)) ≡ trans (O.∣∣ʳ e x p ≡⟨ cong (O.∣∣ʳ e x) $ sym $ subst-sym-subst _ ⟩ O.∣∣ʳ e x (subst P (sym (O.∣∣-constant x y)) (subst P (O.∣∣-constant x y) p)) ≡⟨ sym $ subst-→-domain _ _ ⟩∎ subst (λ x → P x → A) (O.∣∣-constant x y) (O.∣∣ʳ e x) (subst P (O.∣∣-constant x y) p) ∎) (cong (_$ p′) (e .O.∣∣-constantʳ x y)) elim-Σ-≡,≡→≡-∣∣-constant {P = P} {A = A} e {x = x} {y = y} {p = p} = cong (uncurry $ O.elim e) (Σ-≡,≡→≡ (O.∣∣-constant x y) (refl _)) ≡⟨ elim¹ (λ eq → cong (uncurry $ O.elim e) (Σ-≡,≡→≡ eq (refl _)) ≡ trans (trans (cong (O.∣∣ʳ e x) $ sym $ subst-sym-subst _) (sym $ subst-→-domain _ _)) (cong (_$ subst P eq p) (dcong (O.elim e) eq))) ( cong (uncurry $ O.elim e) (Σ-≡,≡→≡ (refl ∣ x ∣) (refl _)) ≡⟨ cong (cong (uncurry $ O.elim e)) Σ-≡,≡→≡-refl-refl ⟩ cong (uncurry $ O.elim e) (cong (∣ x ∣ ,_) (sym (subst-refl _ _))) ≡⟨ cong-∘ _ _ _ ⟩ cong (O.elim e ∣ x ∣) (sym (subst-refl _ _)) ≡⟨⟩ cong (O.∣∣ʳ e x) (sym (subst-refl _ _)) ≡⟨ sym $ trans (cong (flip trans _) $ trans (sym $ trans-assoc _ _ _) $ trans (cong (flip trans _) $ trans-[trans]-sym _ _) $ trans (sym $ trans-assoc _ _ _) $ cong (flip trans _) $ trans-[trans]-sym _ _) $ trans-[trans-sym]- _ _ ⟩ trans (trans (trans (trans (cong (O.∣∣ʳ e x) (sym (subst-refl _ _))) (cong (O.∣∣ʳ e x) (sym (subst-refl _ _)))) (cong (O.∣∣ʳ e x) $ sym (cong (flip (subst P) _) sym-refl))) (trans (sym $ cong (O.∣∣ʳ e x) $ sym (cong (flip (subst P) _) sym-refl)) (trans (sym $ cong (O.∣∣ʳ e x) (sym (subst-refl _ _))) (sym $ cong (_$ subst P (refl _) p) (subst-refl _ _))))) (cong (_$ subst P (refl _) p) (subst-refl _ _)) ≡⟨ sym $ cong (flip trans _) $ cong₂ trans (trans (cong (cong (O.∣∣ʳ e x)) $ sym-trans _ _) $ trans (cong-trans _ _ _) $ cong (flip trans _) $ trans (cong (cong (O.∣∣ʳ e x)) $ sym-trans _ _) $ cong-trans _ _ _) (trans (sym-trans _ _) $ trans (cong (flip trans _) $ trans (sym-trans _ _) $ cong (flip trans _) $ cong sym $ trans (sym $ cong-∘ _ _ _) $ cong (cong (O.∣∣ʳ e x)) $ cong-sym _ _) $ trans-assoc _ _ _) ⟩ trans (trans (cong (O.∣∣ʳ e x) $ sym $ trans (cong (flip (subst P) _) sym-refl) (trans (subst-refl _ _) (subst-refl _ _))) (sym $ trans (cong (_$ subst P (refl _) p) (subst-refl _ _)) (trans (cong (O.∣∣ʳ e x) (sym (subst-refl _ _))) (cong (O.∣∣ʳ e x ∘ flip (subst P) _) (sym sym-refl))))) (cong (_$ subst P (refl _) p) (subst-refl _ _)) ≡⟨ sym $ cong₂ (λ eq₁ eq₂ → trans (trans (cong (O.∣∣ʳ e x) $ sym eq₁) (sym eq₂)) (cong (_$ subst P (refl _) p) (subst-refl _ _))) (subst-sym-subst-refl _) subst-→-domain-refl ⟩ trans (trans (cong (O.∣∣ʳ e x) $ sym $ subst-sym-subst _) (sym $ subst-→-domain _ _)) (cong (_$ subst P (refl _) p) (subst-refl _ _)) ≡⟨ cong (trans _) $ cong (cong _) $ sym $ dcong-refl _ ⟩∎ trans (trans (cong (O.∣∣ʳ e x) $ sym $ subst-sym-subst _) (sym $ subst-→-domain _ _)) (cong (_$ subst P (refl _) p) (dcong (O.elim e) (refl _))) ∎) _ ⟩ trans (trans (cong (O.∣∣ʳ e x) $ sym $ subst-sym-subst _) (sym $ subst-→-domain _ _)) (cong (_$ subst P (O.∣∣-constant x y) p) (dcong (O.elim e) (O.∣∣-constant x y))) ≡⟨ cong (trans _) $ cong (cong _) O.elim-∣∣-constant ⟩∎ trans (trans (cong (O.∣∣ʳ e x) $ sym $ subst-sym-subst _) (sym $ subst-→-domain _ _)) (cong (_$ subst P (O.∣∣-constant x y) p) (e .O.∣∣-constantʳ x y)) ∎ -- Coherently-constant is, in a certain sense, closed under Σ. -- -- This lemma is based on a lemma due to Paolo Capriotti (see -- Capriotti.Coherently-constant-Σ). -- -- TODO: Can the ".coherent" clause be simplified? Coherently-constant-Σ : {P : A → Type p} {Q : ∃ P → Type q} (univ₁ : Univalence p) (univ₂ : Univalence q) (univ₃ : Univalence (p ⊔ q)) → Coherently-constant univ₁ P → Coherently-constant univ₂ Q → Coherently-constant univ₃ (λ x → ∃ λ (y : P x) → Q (x , y)) Coherently-constant-Σ {p = p} {q = q} univ₁ univ₂ univ₃ = Coherently-constant-Σ′ (λ _ → F.id) where Coherently-constant-Σ′ : {P : A → Type p} {Q : ∃ P → Type q} {R : A → Type (p ⊔ q)} → (∀ x → R x ≃ ∃ λ (p : P x) → Q (x , p)) → Coherently-constant univ₁ P → Coherently-constant univ₂ Q → Coherently-constant univ₃ R Coherently-constant-Σ′ {P = P} {Q = Q} {R = R} R≃ c₁ c₂ .property x y = R x ↝⟨ R≃ _ ⟩ (∃ λ (p : P x) → Q (x , p)) ↝⟨ (Σ-cong (c₁ .property _ _) λ _ → c₂ .property _ _) ⟩ (∃ λ (p : P y) → Q (y , p)) ↝⟨ inverse $ R≃ _ ⟩□ R y □ Coherently-constant-Σ′ {P = P} {Q = Q} {R = R} R≃ c₁ c₂ .coherent = Coherently-constant-Σ′ {P = P′} {Q = Q′} (O.elim λ where .O.Elim.∣∣ʳ → R≃ .O.Elim.∣∣-constantʳ x y → Eq.lift-equality ext $ ⟨ext⟩ λ r → let p′ , q′ = _≃_.from (Σ-cong (c₁ .property _ _) λ p → c₂ .property (_ , p) _) (_≃_.to (R≃ y) r) lemma₁ = subst P′ (O.∣∣-constant x y) p′ ≡⟨ subst-∘ _ _ _ ⟩ subst P.id (cong P′ (O.∣∣-constant x y)) p′ ≡⟨ cong (λ eq → subst P.id eq _) O.rec-∣∣-constant ⟩ subst P.id (≃⇒≡ univ₁ (c₁ .property x y)) p′ ≡⟨ subst-id-in-terms-of-≡⇒↝ equivalence ⟩ ≡⇒→ (≃⇒≡ univ₁ (c₁ .property x y)) p′ ≡⟨ cong (λ eq → _≃_.to eq p′) $ _≃_.right-inverse-of (≡≃≃ univ₁) _ ⟩∎ _≃_.to (c₁ .property x y) p′ ∎ lemma₂ = subst (λ p → Q (y , p)) lemma₁ (subst Q′ (Σ-≡,≡→≡ (O.∣∣-constant x y) (refl _)) q′) ≡⟨ cong (subst (λ p → Q (y , p)) lemma₁) $ subst-∘ _ _ _ ⟩ subst (λ p → Q (y , p)) lemma₁ (subst (O.rec′ Q λ x y → ≃⇒≡ univ₂ (c₂ .property x y)) (cong f (Σ-≡,≡→≡ (O.∣∣-constant x y) (refl _))) q′) ≡⟨ cong (λ eq → subst (λ p → Q (y , p)) lemma₁ (subst (O.rec′ Q λ x y → ≃⇒≡ univ₂ (c₂ .property x y)) eq q′)) $ elim-Σ-≡,≡→≡-∣∣-constant e ⟩ subst (λ p → Q (y , p)) lemma₁ (subst (O.rec′ Q λ x y → ≃⇒≡ univ₂ (c₂ .property x y)) (trans (trans (cong (λ p → ∣ x , p ∣) (sym (subst-sym-subst _))) (sym (subst-→-domain _ _))) (cong (_$ subst P′ (O.∣∣-constant x y) p′) (⟨ext⟩ λ p → trans (subst-→-domain _ _) (O.∣∣-constant _ (_ , p))))) q′) ≡⟨ cong (λ eq → subst (λ p → Q (y , p)) lemma₁ (subst (O.rec′ Q λ x y → ≃⇒≡ univ₂ (c₂ .property x y)) (trans (trans (cong (λ p → ∣ x , p ∣) (sym (subst-sym-subst _))) (sym $ subst-→-domain _ _)) eq) q′)) $ cong-ext (λ p → trans (subst-→-domain P′ {f = λ p → ∣ x , p ∣} (O.∣∣-constant x y)) (O.∣∣-constant _ (_ , p))) ⟩ subst (λ p → Q (y , p)) lemma₁ (subst (O.rec′ Q λ x y → ≃⇒≡ univ₂ (c₂ .property x y)) (trans (trans (cong (λ p → ∣ x , p ∣) (sym (subst-sym-subst _))) (sym (subst-→-domain _ _))) (trans (subst-→-domain _ _) (O.∣∣-constant _ _))) q′) ≡⟨ cong (λ eq → subst (λ p → Q (y , p)) lemma₁ (subst (O.rec′ Q λ x y → ≃⇒≡ univ₂ (c₂ .property x y)) eq q′)) $ trans (trans-assoc _ _ _) $ cong (trans (cong (λ p → ∣ x , p ∣) $ sym $ subst-sym-subst _)) $ trans-sym-[trans] _ (O.∣∣-constant _ _) ⟩ subst (λ p → Q (y , p)) lemma₁ (subst (O.rec′ Q λ x y → ≃⇒≡ univ₂ (c₂ .property x y)) (trans (cong (λ p → ∣ x , p ∣) (sym (subst-sym-subst _))) (O.∣∣-constant _ _)) q′) ≡⟨ cong (λ q → subst (λ p → Q (y , p)) lemma₁ q) $ trans (subst-∘ _ _ _) $ cong (λ eq → subst P.id eq q′) $ trans (cong-trans _ _ _) $ cong₂ trans (cong-∘ _ _ _) O.rec-∣∣-constant ⟩ subst (λ p → Q (y , p)) lemma₁ (subst P.id (trans (cong (λ p → Q (x , p)) (sym (subst-sym-subst _))) (≃⇒≡ univ₂ (c₂ .property _ _))) q′) ≡⟨ cong (subst (λ p → Q (y , p)) lemma₁) $ trans (subst-id-in-terms-of-≡⇒↝ equivalence) $ trans (cong (_$ q′) $ ≡⇒↝-trans equivalence) $ trans (cong (λ eq → _≃_.to eq (≡⇒→ (cong (λ p → Q (x , p)) (sym (subst-sym-subst _))) q′)) $ _≃_.right-inverse-of (≡≃≃ univ₂) _) $ cong (_≃_.to (c₂ .property _ _)) $ sym $ subst-in-terms-of-≡⇒↝ equivalence _ _ _ ⟩ subst (λ p → Q (y , p)) lemma₁ (_≃_.to (c₂ .property _ _) $ subst (λ p → Q (x , p)) (sym (subst-sym-subst _)) q′) ≡⟨⟩ subst (λ p → Q (y , p)) lemma₁ (_≃_.to (c₂ .property (x , subst P′ (sym (O.∣∣-constant x y)) (subst P′ (O.∣∣-constant x y) p′)) (y , subst P′ (O.∣∣-constant x y) p′)) $ subst (λ p → Q (x , p)) (sym (subst-sym-subst _)) q′) ≡⟨ elim¹ (λ {p″} eq → subst (λ p → Q (y , p)) lemma₁ (_≃_.to (c₂ .property (x , p″) (y , subst P′ (O.∣∣-constant x y) p′)) $ subst (λ p → Q (x , p)) eq q′) ≡ subst (λ p → Q (y , p)) lemma₁ (_≃_.to (c₂ .property (x , p′) (y , subst P′ (O.∣∣-constant x y) p′)) q′)) (cong (λ q → subst (λ p → Q (y , p)) lemma₁ (_≃_.to (c₂ .property _ _) q)) $ subst-refl _ _) _ ⟩ subst (λ p → Q (y , p)) lemma₁ (_≃_.to (c₂ .property (x , p′) (y , subst P′ (O.∣∣-constant x y) p′)) q′) ≡⟨ elim₁ (λ {p″} eq → subst (λ p → Q (y , p)) eq (_≃_.to (c₂ .property (x , p′) (y , p″)) q′) ≡ _≃_.to (c₂ .property _ _) q′) (subst-refl _ _) _ ⟩∎ _≃_.to (c₂ .property (x , p′) (y , _≃_.to (c₁ .property x y) p′)) q′ ∎ in _≃_.to (subst (λ x → O.rec′ R (λ x y → ≃⇒≡ univ₃ (pr x y)) x ≃ ∃ λ (p : P′ x) → Q′ (x , p)) (O.∣∣-constant x y) (R≃ x)) r ≡⟨ cong (_$ r) Eq.to-subst ⟩ subst (λ x → O.rec′ R (λ x y → ≃⇒≡ univ₃ (pr x y)) x → ∃ λ (p : P′ x) → Q′ (x , p)) (O.∣∣-constant x y) (_≃_.to (R≃ x)) r ≡⟨ subst-→ ⟩ subst (λ x → ∃ λ (p : P′ x) → Q′ (x , p)) (O.∣∣-constant x y) (_≃_.to (R≃ x) (subst (O.rec′ R (λ x y → ≃⇒≡ univ₃ (pr x y))) (sym (O.∣∣-constant x y)) r)) ≡⟨ cong (subst (λ x → ∃ λ p → Q′ (x , p)) (O.∣∣-constant x y)) $ cong (_≃_.to (R≃ x)) $ trans (subst-∘ _ _ _) $ cong (flip (subst P.id) r) $ trans (cong-sym _ _) $ cong sym O.rec-∣∣-constant ⟩ subst (λ x → ∃ λ (p : P′ x) → Q′ (x , p)) (O.∣∣-constant x y) (_≃_.to (R≃ x) (subst P.id (sym (≃⇒≡ univ₃ (pr x y))) r)) ≡⟨ cong (subst (λ x → ∃ λ p → Q′ (x , p)) (O.∣∣-constant x y)) $ cong (_≃_.to (R≃ x)) $ trans (subst-id-in-terms-of-inverse∘≡⇒↝ equivalence) $ cong (λ eq → _≃_.from eq r) $ _≃_.right-inverse-of (≡≃≃ univ₃) _ ⟩ subst (λ x → ∃ λ (p : P′ x) → Q′ (x , p)) (O.∣∣-constant x y) (_≃_.to (R≃ x) (_≃_.from (pr x y) r)) ≡⟨⟩ subst (λ x → ∃ λ (p : P′ x) → Q′ (x , p)) (O.∣∣-constant x y) (_≃_.to (R≃ x) $ _≃_.from (R≃ x) $ _≃_.from (Σ-cong (c₁ .property _ _) λ _ → c₂ .property _ _) $ _≃_.to (R≃ y) r) ≡⟨⟩ subst (λ x → ∃ λ (p : P′ x) → Q′ (x , p)) (O.∣∣-constant x y) (_≃_.to (R≃ x) (_≃_.from (R≃ x) (p′ , q′))) ≡⟨ cong (subst (λ x → ∃ λ p → Q′ (x , p)) (O.∣∣-constant x y)) $ _≃_.right-inverse-of (R≃ x) _ ⟩ subst (λ x → ∃ λ (p : P′ x) → Q′ (x , p)) (O.∣∣-constant x y) (p′ , q′) ≡⟨ push-subst-pair _ _ ⟩ subst P′ (O.∣∣-constant x y) p′ , subst Q′ (Σ-≡,≡→≡ (O.∣∣-constant x y) (refl _)) q′ ≡⟨ Σ-≡,≡→≡ lemma₁ lemma₂ ⟩ _≃_.to (c₁ .property _ _) p′ , _≃_.to (c₂ .property _ _) q′ ≡⟨⟩ _≃_.to (Σ-cong (c₁ .property _ _) λ p → c₂ .property (x , p) _) (_≃_.from (Σ-cong (c₁ .property _ _) λ _ → c₂ .property _ _) (_≃_.to (R≃ y) r)) ≡⟨ _≃_.right-inverse-of (Σ-cong (c₁ .property _ _) λ p → c₂ .property (_ , p) _) _ ⟩∎ _≃_.to (R≃ y) r ∎) (c₁ .coherent) (Coherently-constant-map univ₂ univ₂ f (λ _ → F.id) (c₂ .coherent)) where mutual P′ = O.rec′ P (λ x y → ≃⇒≡ univ₁ (c₁ .property x y)) Q′ = O.rec′ Q (λ x y → ≃⇒≡ univ₂ (c₂ .property x y)) ∘ f e = λ where .O.Elim.∣∣ʳ x p → ∣ x , p ∣ .O.Elim.∣∣-constantʳ x y → ⟨ext⟩ λ p → subst (λ x → P′ x → ∥ ∃ P ∥¹) (O.∣∣-constant x y) (λ p → ∣ x , p ∣) p ≡⟨ subst-→-domain _ _ ⟩ ∣ x , subst P′ (sym (O.∣∣-constant x y)) p ∣ ≡⟨ O.∣∣-constant _ _ ⟩∎ ∣ y , p ∣ ∎ f = uncurry $ O.elim e pr : ∀ _ _ → _ pr x y = (inverse (R≃ y) F.∘ (Σ-cong (c₁ .property _ _) λ _ → c₂ .property _ _)) F.∘ R≃ x private -- A unit test that ensures that Coherently-constant-Σ satisfies a -- certain definitional equality. _ : ∀ {P : A → Type p} {Q : ∃ P → Type q} {univ₁ : Univalence p} {univ₂ : Univalence q} {univ₃ : Univalence (p ⊔ q)} {c₁ : Coherently-constant univ₁ P} {c₂ : Coherently-constant univ₂ Q} {x y} → _≃_.to (Coherently-constant-Σ univ₁ univ₂ univ₃ c₁ c₂ .property x y) ≡ Σ-map (_≃_.to (c₁ .property _ _)) (_≃_.to (c₂ .property _ _)) _ = refl _ -- A different proof of Coherently-constant-Σ, with three extra -- univalence assumptions. -- -- This proof does not, at the time of writing, satisfy the -- definitional equality above (rephrased in an obvious way). Coherently-constant-Σ′ : {A : Type a} {P : A → Type p} {Q : ∃ P → Type q} (univ₁ : Univalence p) (univ₂ : Univalence q) (univ₃ : Univalence (p ⊔ q)) → Univalence (a ⊔ lsuc p) → Univalence (a ⊔ p ⊔ lsuc q) → Univalence (a ⊔ lsuc (p ⊔ q)) → Coherently-constant univ₁ P → Coherently-constant univ₂ Q → Coherently-constant univ₃ (λ x → ∃ λ (y : P x) → Q (x , y)) Coherently-constant-Σ′ {P = P} {Q = Q} univ₁ univ₂ univ₃ univ₄ univ₅ univ₆ = curry (Coherently-constant univ₁ P × Coherently-constant univ₂ Q ↔⟨ inverse (Coherently-constant≃Coherently-constant univ₄ univ₁ ×-cong Coherently-constant≃Coherently-constant univ₅ univ₂) ⟩ CC.Coherently-constant P × CC.Coherently-constant Q ↝⟨ uncurry Capriotti.Coherently-constant-Σ ⟩ CC.Coherently-constant (λ x → ∃ λ (y : P x) → Q (x , y)) ↔⟨ Coherently-constant≃Coherently-constant univ₆ univ₃ ⟩□ Coherently-constant univ₃ (λ x → ∃ λ (y : P x) → Q (x , y)) □) ------------------------------------------------------------------------ -- The lens type family -- Small coinductive lenses, based on an idea due to Paolo Capriotti. -- -- The lenses are defined as a record type to make it easier for Agda -- to infer the argument univ from a value of type Lens univ A B. record Lens (univ : Univalence (a ⊔ b)) (A : Type a) (B : Type b) : Type (a ⊔ b) where field -- A getter. get : A → B -- The family of fibres of the getter is coherently constant. get⁻¹-coherently-constant : Coherently-constant univ (get ⁻¹_) -- All the getter's fibres are equivalent. get⁻¹-constant : (b₁ b₂ : B) → get ⁻¹ b₁ ≃ get ⁻¹ b₂ get⁻¹-constant = get⁻¹-coherently-constant .property -- A setter. set : A → B → A set a b = $⟨ _≃_.to (get⁻¹-constant (get a) b) ⟩ (get ⁻¹ get a → get ⁻¹ b) ↝⟨ _$ (a , refl _) ⟩ get ⁻¹ b ↝⟨ proj₁ ⟩□ A □ -- The setter could have been defined using Constant-≃-get-⁻¹-≃. set≡ : ∀ bl → set ≡ proj₁ (_≃_.to (Constant-≃-get-⁻¹-≃ bl) get⁻¹-constant) set≡ ⊠ = refl _ instance -- The lenses defined above have getters and setters. has-getter-and-setter : {univ : Univalence (a ⊔ b)} → Has-getter-and-setter (Lens {a = a} {b = b} univ) has-getter-and-setter = record { get = Lens.get ; set = Lens.set } -- Lens can be expressed as a Σ-type. Lens-as-Σ : {A : Type a} {B : Type b} {univ : Univalence (a ⊔ b)} → Lens univ A B ≃ (∃ λ (get : A → B) → Coherently-constant univ (get ⁻¹_)) Lens-as-Σ = Eq.↔→≃ (λ l → Lens.get l , Lens.get⁻¹-coherently-constant l) (λ (g , c) → record { get = g; get⁻¹-coherently-constant = c }) refl refl -- Lens is pointwise equivalent to Coinductive.Lens (assuming -- univalence). Coinductive-lens≃Lens : Block "Coinductive-lens≃Lens" → {A : Type a} {B : Type b} → Univalence (lsuc (a ⊔ b)) → (univ : Univalence (a ⊔ b)) → Coinductive.Lens A B ≃ Lens univ A B Coinductive-lens≃Lens ⊠ {A = A} {B = B} univ₁ univ₂ = Coinductive.Lens A B ↔⟨⟩ (∃ λ (get : A → B) → Coinductive.Coherently-constant (get ⁻¹_)) ↝⟨ (∃-cong λ _ → Coinductive-coherently-constant≃Coherently-constant univ₁ univ₂) ⟩ (∃ λ (get : A → B) → Coherently-constant univ₂ (get ⁻¹_)) ↝⟨ inverse Lens-as-Σ ⟩□ Lens univ₂ A B □ -- The equivalence preserves getters and setters. Coinductive-lens≃Lens-preserves-getters-and-setters : (bl : Block "Coinductive-lens≃Lens") {A : Type a} {B : Type b} (univ₁ : Univalence (lsuc (a ⊔ b))) (univ₂ : Univalence (a ⊔ b)) → Preserves-getters-and-setters-⇔ A B (_≃_.logical-equivalence (Coinductive-lens≃Lens bl univ₁ univ₂)) Coinductive-lens≃Lens-preserves-getters-and-setters ⊠ univ₁ univ₂ = Preserves-getters-and-setters-→-↠-⇔ (_≃_.surjection (Coinductive-lens≃Lens ⊠ univ₁ univ₂)) (λ _ → refl _ , refl _) private -- A lemma used to implement Higher-lens≃Lens and -- Higher-lens≃Lens-preserves-getters-and-setters. Higher-lens≃Lens′ : Block "Higher-lens≃Lens" → {A : Type a} {B : Type b} → Univalence (lsuc (a ⊔ b)) → (univ : Univalence (a ⊔ b)) → ∃ λ (eq : Higher.Lens A B ≃ Lens univ A B) → Preserves-getters-and-setters-⇔ A B (_≃_.logical-equivalence eq) Higher-lens≃Lens′ ⊠ {A = A} {B = B} univ₁ univ₂ = block λ b → (Higher.Lens A B ↝⟨ inverse $ Capriotti.Lens≃Higher-lens b univ₂ ⟩ Capriotti.Lens A B ↝⟨ Coinductive.Higher-lens≃Lens b univ₁ ⟩ Coinductive.Lens A B ↝⟨ Coinductive-lens≃Lens b univ₁ univ₂ ⟩□ Lens univ₂ A B □) , Preserves-getters-and-setters-⇔-∘ {f = _≃_.logical-equivalence (Coinductive-lens≃Lens b univ₁ univ₂) F.∘ _≃_.logical-equivalence (Coinductive.Higher-lens≃Lens b univ₁)} {g = inverse $ _≃_.logical-equivalence $ Capriotti.Lens≃Higher-lens b univ₂} (Preserves-getters-and-setters-⇔-∘ {f = _≃_.logical-equivalence (Coinductive-lens≃Lens b univ₁ univ₂)} {g = _≃_.logical-equivalence (Coinductive.Higher-lens≃Lens b univ₁)} (Coinductive-lens≃Lens-preserves-getters-and-setters b univ₁ univ₂) (Coinductive.Higher-lens≃Lens-preserves-getters-and-setters b univ₁)) (Preserves-getters-and-setters-⇔-inverse {f = _≃_.logical-equivalence (Capriotti.Lens≃Higher-lens b univ₂)} $ Capriotti.Lens≃Higher-lens-preserves-getters-and-setters b univ₂) -- Lens is pointwise equivalent to Higher.Lens (assuming univalence). Higher-lens≃Lens : Block "Higher-lens≃Lens" → {A : Type a} {B : Type b} → Univalence (lsuc (a ⊔ b)) → (univ : Univalence (a ⊔ b)) → Higher.Lens A B ≃ Lens univ A B Higher-lens≃Lens b univ₁ univ₂ = proj₁ $ Higher-lens≃Lens′ b univ₁ univ₂ -- The equivalence preserves getters and setters. Higher-lens≃Lens-preserves-getters-and-setters : (bl : Block "Higher-lens≃Lens") {A : Type a} {B : Type b} (univ₁ : Univalence (lsuc (a ⊔ b))) (univ₂ : Univalence (a ⊔ b)) → Preserves-getters-and-setters-⇔ A B (_≃_.logical-equivalence (Higher-lens≃Lens bl univ₁ univ₂)) Higher-lens≃Lens-preserves-getters-and-setters b univ₁ univ₂ = proj₂ $ Higher-lens≃Lens′ b univ₁ univ₂ -- Lenses with stable view types are equal if their setters are equal -- (assuming univalence). lenses-equal-if-setters-equal : {A : Type a} {B : Type b} → Univalence (lsuc (a ⊔ b)) → (univ : Univalence (a ⊔ b)) → (l₁ l₂ : Lens univ A B) → (∥ B ∥ → B) → Lens.set l₁ ≡ Lens.set l₂ → l₁ ≡ l₂ lenses-equal-if-setters-equal univ′ univ l₁ l₂ stable = block λ bl → let equiv = Higher-lens≃Lens bl univ′ univ in Lens.set l₁ ≡ Lens.set l₂ ↔⟨ ≡⇒≃ $ sym $ cong₂ _≡_ (proj₂ $ proj₂ (Higher-lens≃Lens-preserves-getters-and-setters bl univ′ univ) l₁) (proj₂ $ proj₂ (Higher-lens≃Lens-preserves-getters-and-setters bl univ′ univ) l₂) ⟩ Higher.Lens.set (_≃_.from equiv l₁) ≡ Higher.Lens.set (_≃_.from equiv l₂) ↝⟨ Higher.lenses-equal-if-setters-equal univ _ _ (λ _ → stable) ⟩ _≃_.from equiv l₁ ≡ _≃_.from equiv l₂ ↔⟨ Eq.≃-≡ (inverse equiv) ⟩□ l₁ ≡ l₂ □ ------------------------------------------------------------------------ -- Identity -- An identity lens. id : {A : Type a} (univ : Univalence a) → Lens univ A A id univ .Lens.get = P.id id univ .Lens.get⁻¹-coherently-constant = coherently-constant λ x → $⟨ Preimage.id⁻¹-contractible x ⟩ Contractible (P.id ⁻¹ x) ↝⟨ Eq.↔⇒≃ ∘ _⇔_.to contractible⇔↔⊤ ⟩□ P.id ⁻¹ x ≃ ⊤ □ where coherently-constant : (∀ x → P x ≃ ⊤) → Coherently-constant univ P coherently-constant {P = P} P≃⊤ .property x y = P x ↝⟨ P≃⊤ x ⟩ ⊤ ↝⟨ inverse $ P≃⊤ y ⟩□ P y □ coherently-constant P≃⊤ .coherent = coherently-constant (O.elim λ where .O.Elim.∣∣ʳ → P≃⊤ .O.Elim.∣∣-constantʳ _ _ → Eq.lift-equality ext $ refl (λ _ → tt)) ------------------------------------------------------------------------ -- Composition -- Composition. -- -- Paolo Capriotti came up with the idea to use Coherently-constant-Σ. -- At first we had a problem related to universe levels. Andrea -- Vezzosi came up with a first workaround (involving lifting), and -- later I found a more direct solution. infix 9 ⟨_,_⟩_∘_ ⟨_,_⟩_∘_ : {A : Type a} {B : Type b} {C : Type c} {univ₁ : Univalence (b ⊔ c)} {univ₂ : Univalence (a ⊔ b)} (univ₃ : Univalence (a ⊔ c)) → Univalence (a ⊔ b ⊔ c) → Lens univ₁ B C → Lens univ₂ A B → Lens univ₃ A C (⟨ _ , _ ⟩ l₁ ∘ l₂) .Lens.get = get l₁ ∘ get l₂ where open Lens ⟨_,_⟩_∘_ {b = ℓb} {univ₁ = univ₁} {univ₂ = univ₂} univ₃ univ₄ l₁ l₂ .Lens.get⁻¹-coherently-constant = $⟨ Coherently-constant-Σ {P = get l₁ ⁻¹_} {Q = λ (_ , b , _) → get l₂ ⁻¹ b} univ₁ univ₂ univ₄ (get⁻¹-coherently-constant l₁) (Coherently-constant-map univ₂ univ₂ (proj₁ ∘ proj₂) (λ _ → F.id) (get⁻¹-coherently-constant l₂)) ⟩ Coherently-constant univ₄ (λ c → ∃ λ ((b , _) : get l₁ ⁻¹ c) → get l₂ ⁻¹ b) ↝⟨ Coherently-constant-map univ₄ univ₃ P.id (λ _ → inverse $ ∘⁻¹≃ (get l₁) (get l₂)) ⟩□ Coherently-constant univ₃ ((get l₁ ∘ get l₂) ⁻¹_) □ where open Lens -- The setter of a lens formed using composition is defined in the -- "right" way. set-∘ : ∀ {A : Type a} {B : Type b} {C : Type c} {univ₁ : Univalence (b ⊔ c)} {univ₂ : Univalence (a ⊔ b)} (univ₃ : Univalence (a ⊔ c)) (univ₄ : Univalence (a ⊔ b ⊔ c)) (l₁ : Lens univ₁ B C) (l₂ : Lens univ₂ A B) {a c} → Lens.set (⟨ univ₃ , univ₄ ⟩ l₁ ∘ l₂) a c ≡ Lens.set l₂ a (Lens.set l₁ (Lens.get l₂ a) c) set-∘ _ _ _ _ = refl _ -- Composition is associative if the view type of the resulting lens -- is stable (assuming univalence). associativity : {A : Type a} {B : Type b} {C : Type c} {D : Type d} → (∥ D ∥ → D) → (univ₁ : Univalence (c ⊔ d)) (univ₂ : Univalence (b ⊔ c)) (univ₃ : Univalence (a ⊔ b)) (univ₄ : Univalence (a ⊔ d)) (univ₅ : Univalence (a ⊔ c ⊔ d)) (univ₆ : Univalence (a ⊔ c)) (univ₇ : Univalence (a ⊔ b ⊔ c)) (univ₈ : Univalence (a ⊔ b ⊔ d)) (univ₉ : Univalence (b ⊔ d)) (univ₁₀ : Univalence (b ⊔ c ⊔ d)) → Univalence (lsuc (a ⊔ d)) → (l₁ : Lens univ₁ C D) (l₂ : Lens univ₂ B C) (l₃ : Lens univ₃ A B) → ⟨ univ₄ , univ₅ ⟩ l₁ ∘ (⟨ univ₆ , univ₇ ⟩ l₂ ∘ l₃) ≡ ⟨ univ₄ , univ₈ ⟩ (⟨ univ₉ , univ₁₀ ⟩ l₁ ∘ l₂) ∘ l₃ associativity stable _ _ _ univ₄ _ _ _ _ _ _ univ₁₁ l₁ l₂ l₃ = lenses-equal-if-setters-equal univ₁₁ univ₄ _ _ stable (refl _) -- The identity lens is a left identity of composition if the view -- type of the resulting lens is stable (assuming univalence). left-identity : {A : Type a} {B : Type b} → (∥ B ∥ → B) → (univ₁ : Univalence (a ⊔ b)) (univ₂ : Univalence (a ⊔ b)) (univ₃ : Univalence b) → Univalence (lsuc (a ⊔ b)) → (l : Lens univ₁ A B) → ⟨ univ₁ , univ₂ ⟩ id univ₃ ∘ l ≡ l left-identity stable univ₁ univ₂ univ₃ univ₄ l = lenses-equal-if-setters-equal univ₄ univ₁ _ _ stable (refl _) -- The identity lens is a right identity of composition if the view -- type of the resulting lens is stable (assuming univalence). right-identity : {A : Type a} {B : Type b} → (∥ B ∥ → B) → (univ₁ : Univalence (a ⊔ b)) (univ₂ : Univalence (a ⊔ b)) (univ₃ : Univalence a) → Univalence (lsuc (a ⊔ b)) → (l : Lens univ₁ A B) → ⟨ univ₁ , univ₂ ⟩ l ∘ id univ₃ ≡ l right-identity stable univ₁ univ₂ univ₃ univ₄ l = lenses-equal-if-setters-equal univ₄ univ₁ _ _ stable (refl _) -- The definitions in the following module use seven instances of -- univalence. module _ {A : Type a} {B : Type b} {C : Type c} (univ₁ : Univalence (b ⊔ c)) (univ₂ : Univalence (lsuc (b ⊔ c))) (univ₃ : Univalence (a ⊔ b)) (univ₄ : Univalence (lsuc (a ⊔ b))) (univ₅ : Univalence (a ⊔ c)) (univ₆ : Univalence (lsuc (a ⊔ c))) (univ₇ : Univalence (a ⊔ b ⊔ c)) where -- An unrestricted composition operator for Higher.Lens (defined using -- univalence). infix 9 ⟨_,_,_,_,_,_,_,_⟩_⊚_ ⟨_,_,_,_,_,_,_,_⟩_⊚_ : Block "Higher-lens≃Lens" → Higher.Lens B C → Higher.Lens A B → Higher.Lens A C ⟨_,_,_,_,_,_,_,_⟩_⊚_ b l₁ l₂ = _≃_.from (Higher-lens≃Lens b univ₆ univ₅) (⟨ univ₅ , univ₇ ⟩ _≃_.to (Higher-lens≃Lens b univ₂ univ₁) l₁ ∘ _≃_.to (Higher-lens≃Lens b univ₄ univ₃) l₂) -- The setter of a lens formed using composition is defined in the -- "right" way. set-⊚ : (b : Block "Higher-lens≃Lens") → ∀ (l₁ : Higher.Lens B C) (l₂ : Higher.Lens A B) a c → Higher.Lens.set (⟨_,_,_,_,_,_,_,_⟩_⊚_ b l₁ l₂) a c ≡ Higher.Lens.set l₂ a (Higher.Lens.set l₁ (Higher.Lens.get l₂ a) c) set-⊚ b l₁ l₂ a c = Higher.Lens.set (_≃_.from (Higher-lens≃Lens b univ₆ univ₅) (⟨ univ₅ , univ₇ ⟩ _≃_.to (Higher-lens≃Lens b univ₂ univ₁) l₁ ∘ _≃_.to (Higher-lens≃Lens b univ₄ univ₃) l₂)) a c ≡⟨ cong (λ f → f a c) $ proj₂ $ proj₂ (Higher-lens≃Lens-preserves-getters-and-setters b univ₆ univ₅) (⟨ univ₅ , univ₇ ⟩ _≃_.to (Higher-lens≃Lens b univ₂ univ₁) l₁ ∘ _≃_.to (Higher-lens≃Lens b univ₄ univ₃) l₂) ⟩ Lens.set (⟨ univ₅ , univ₇ ⟩ _≃_.to (Higher-lens≃Lens b univ₂ univ₁) l₁ ∘ _≃_.to (Higher-lens≃Lens b univ₄ univ₃) l₂) a c ≡⟨⟩ Lens.set (_≃_.to (Higher-lens≃Lens b univ₄ univ₃) l₂) a (Lens.set (_≃_.to (Higher-lens≃Lens b univ₂ univ₁) l₁) (Lens.get (_≃_.to (Higher-lens≃Lens b univ₄ univ₃) l₂) a) c) ≡⟨ cong (λ f → f a (Lens.set (_≃_.to (Higher-lens≃Lens b univ₂ univ₁) l₁) (Lens.get (_≃_.to (Higher-lens≃Lens b univ₄ univ₃) l₂) a) c)) $ proj₂ $ proj₁ (Higher-lens≃Lens-preserves-getters-and-setters b univ₄ univ₃) l₂ ⟩ Higher.Lens.set l₂ a (Lens.set (_≃_.to (Higher-lens≃Lens b univ₂ univ₁) l₁) (Lens.get (_≃_.to (Higher-lens≃Lens b univ₄ univ₃) l₂) a) c) ≡⟨ cong (Higher.Lens.set l₂ a) $ cong₂ (λ f g → f (g a) c) (proj₂ $ proj₁ (Higher-lens≃Lens-preserves-getters-and-setters b univ₂ univ₁) l₁) (proj₁ $ proj₁ (Higher-lens≃Lens-preserves-getters-and-setters b univ₄ univ₃) l₂) ⟩∎ Higher.Lens.set l₂ a (Higher.Lens.set l₁ (Higher.Lens.get l₂ a) c) ∎ -- If the view type of the resulting lens is stable, then the -- definition of composition above matches the one in higher (when -- applicable). ⊚≡∘ : (bl : Block "Higher-lens≃Lens") → ∀ a b {A : Type (a ⊔ b ⊔ c)} {B : Type (b ⊔ c)} {C : Type c} (univ₁ : Univalence (b ⊔ c)) (univ₂ : Univalence (lsuc (b ⊔ c))) (univ₃ : Univalence (a ⊔ b ⊔ c)) (univ₄ : Univalence (lsuc (a ⊔ b ⊔ c))) (univ₅ : Univalence (a ⊔ b ⊔ c)) (univ₆ : Univalence (lsuc (a ⊔ b ⊔ c))) (univ₇ : Univalence (a ⊔ b ⊔ c)) (l₁ : Higher.Lens B C) (l₂ : Higher.Lens A B) → (∥ C ∥ → C) → ⟨ univ₁ , univ₂ , univ₃ , univ₄ , univ₅ , univ₆ , univ₇ , bl ⟩ l₁ ⊚ l₂ ≡ HC.⟨ a , b ⟩ l₁ ∘ l₂ ⊚≡∘ bl a b univ₁ univ₂ univ₃ univ₄ univ₅ univ₆ univ₇ l₁ l₂ stable = cong (λ f → f l₁ l₂) $ HC.composition≡∘ a b univ₇ stable ⟨ univ₁ , univ₂ , univ₃ , univ₄ , univ₅ , univ₆ , univ₇ , bl ⟩_⊚_ (set-⊚ univ₁ univ₂ univ₃ univ₄ univ₅ univ₆ univ₇ bl) ------------------------------------------------------------------------ -- An alternative definition that does not make use of coinduction -- A variant of Lens. -- -- This definition does not make use of coinduction, but it is not -- small. Not-coinductive-lens : Univalence (a ⊔ b) → Type a → Type b → Type (lsuc (a ⊔ b)) Not-coinductive-lens univ A B = ∃ λ (get : A → B) → NC.Coherently Constant-≃ (λ P c → O.rec′ P (λ x y → ≃⇒≡ univ (c x y))) (get ⁻¹_) -- Not-coinductive-lens is pointwise equivalent to Lens (assuming -- univalence). Not-coinductive-lens≃Lens : {univ : Univalence (a ⊔ b)} {A : Type a} {B : Type b} → Univalence (lsuc (a ⊔ b)) → Not-coinductive-lens univ A B ≃ Lens univ A B Not-coinductive-lens≃Lens {univ = univ} {A = A} {B = B} univ′ = Not-coinductive-lens univ A B ↝⟨ (∃-cong λ _ → inverse $ Coherently≃Not-coinductive-coherently univ′ univ′) ⟩ (∃ λ (get : A → B) → Coherently-constant univ (get ⁻¹_)) ↝⟨ inverse Lens-as-Σ ⟩□ Lens univ A B □ ------------------------------------------------------------------------ -- H-levels -- If P has h-level n (pointwise), then Coherently-constant univ P has -- h-level n (assuming univalence). -- -- I think that Paolo Capriotti suggested that something like this -- could be proved by using the result (due to Ahrens, Capriotti and -- Spadotti, see "Non-wellfounded trees in Homotopy Type Theory") that -- M-types for indexed containers have h-level n if all shapes have -- h-level n. H-level-Coherently-constant : {A : Type a} {P : A → Type p} → Univalence (lsuc (a ⊔ p)) → (univ : Univalence p) → ((a : A) → H-level n (P a)) → H-level n (Coherently-constant univ P) H-level-Coherently-constant {a = a} {p = p} {n = n} univ _ h = H-level-Coherently-→Type univ univ h lemma P.id where lemma : {A : Type a} {P : A → Type p} → ((a : A) → H-level n (P a)) → H-level n (Constant-≃ P) lemma h = Π-closure ext n λ _ → Π-closure ext n λ _ → Eq.h-level-closure ext n (h _) (h _) -- If P has h-level n (pointwise), then -- Coinductive.Coherently-constant P has h-level n (assuming -- univalence). H-level-Coinductive-Coherently-constant : {A : Type a} {P : A → Type p} → Univalence (lsuc (a ⊔ p)) → Univalence (a ⊔ lsuc p) → Univalence p → ((a : A) → H-level n (P a)) → H-level n (Coinductive.Coherently-constant P) H-level-Coinductive-Coherently-constant {n = n} {P = P} univ₁ univ₂ univ₃ = (∀ a → H-level n (P a)) ↝⟨ H-level-Coherently-constant univ₁ univ₃ ⟩ H-level n (Coherently-constant univ₃ P) ↝⟨ H-level-cong _ n (inverse $ Coinductive-coherently-constant≃Coherently-constant univ₂ univ₃) ⟩□ H-level n (Coinductive.Coherently-constant P) □ -- If A and B have h-level n given the assumption that the other type -- is inhabited, then Lens univ A B has h-level n (assuming -- univalence). -- -- I do not remember who came up with the idea to prove this for the -- coinductive lenses (rather than the ones in -- Lens.Non-dependent.Higher). It may have been Paolo Capriotti or -- Andrea Vezzosi. lens-preserves-h-level : {A : Type a} {B : Type b} → Univalence (lsuc (a ⊔ b)) → (univ : Univalence (a ⊔ b)) → ∀ n → (B → H-level n A) → (A → H-level n B) → H-level n (Lens univ A B) lens-preserves-h-level univ′ univ n hA hB = H-level-cong _ n (inverse Lens-as-Σ) $ Σ-closure n (Π-closure ext n λ a → hB a) λ _ → H-level-Coherently-constant univ′ univ λ b → Σ-closure n (hA b) λ a → H-level.⇒≡ n (hB a) -- If the domain of a lens is inhabited and has h-level n, then the -- codomain also has h-level n (assuming univalence). h-level-respects-lens-from-inhabited : {A : Type a} {B : Type b} → Univalence (lsuc (a ⊔ b)) → (univ : Univalence (a ⊔ b)) → ∀ n → Lens univ A B → A → H-level n A → H-level n B h-level-respects-lens-from-inhabited univ′ univ n = Higher.h-level-respects-lens-from-inhabited n ∘ _≃_.from (Higher-lens≃Lens ⊠ univ′ univ) -- If A has positive h-level n, then Lens univ A B also has h-level n -- (assuming univalence). lens-preserves-h-level-of-domain : {A : Type a} {B : Type b} → Univalence (lsuc (a ⊔ b)) → (univ : Univalence (a ⊔ b)) → ∀ n → H-level (1 + n) A → H-level (1 + n) (Lens univ A B) lens-preserves-h-level-of-domain univ′ univ n hA = H-level.[inhabited⇒+]⇒+ n λ l → lens-preserves-h-level univ′ univ (1 + n) (λ _ → hA) λ a → h-level-respects-lens-from-inhabited univ′ univ _ l a hA
{ "alphanum_fraction": 0.3996392813, "avg_line_length": 46.5667189953, "ext": "agda", "hexsha": "3f196005d3c38b934c21ba4c68b2e19f5d0b0316", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-07-01T14:33:26.000Z", "max_forks_repo_forks_event_min_datetime": "2020-07-01T14:33:26.000Z", "max_forks_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/dependent-lenses", "max_forks_repo_path": "src/Lens/Non-dependent/Higher/Coinductive/Small.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "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/dependent-lenses", "max_issues_repo_path": "src/Lens/Non-dependent/Higher/Coinductive/Small.agda", "max_line_length": 148, "max_stars_count": 3, "max_stars_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/dependent-lenses", "max_stars_repo_path": "src/Lens/Non-dependent/Higher/Coinductive/Small.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:55:52.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T12:10:46.000Z", "num_tokens": 18688, "size": 59326 }
module test where data Bool : Set where True : Bool False : Bool !_ : Bool → Bool ! True = False ! False = True if_then_else_ : {A : Set} → Bool → A → A → A if True then x else y = x if False then x else y = y data ℕ : Set where zero : ℕ suc : ℕ → ℕ _+_ : ℕ → ℕ → ℕ zero + a = a suc a + b = suc (a + b) low = suc zero high = low + (low + low) data List (A : Set) : Set where Nil : List A Cons : A → List A → List A length : {A : Set} → List A → ℕ length Nil = zero length (Cons x x₁) = suc (length x₁) map : {A B : Set} → (A → B) → List A → List B map f Nil = Nil map f (Cons x l) = Cons (f x) (map f l) concat : {A : Set} → List A → List A → List A concat Nil m = m concat (Cons x l) m = Cons x (concat l m)
{ "alphanum_fraction": 0.5488621151, "avg_line_length": 18.2195121951, "ext": "agda", "hexsha": "b1932deb831155f26baf2ec422ef04a347d63e23", "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": "2867aee2c18b4e1d4e8f4dc8e8453006fde4d349", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "foxx3r/agda_tasks", "max_forks_repo_path": "test.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2867aee2c18b4e1d4e8f4dc8e8453006fde4d349", "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": "foxx3r/agda_tasks", "max_issues_repo_path": "test.agda", "max_line_length": 45, "max_stars_count": 1, "max_stars_repo_head_hexsha": "2867aee2c18b4e1d4e8f4dc8e8453006fde4d349", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "foxx3r/agda_tasks", "max_stars_repo_path": "test.agda", "max_stars_repo_stars_event_max_datetime": "2020-06-24T02:30:55.000Z", "max_stars_repo_stars_event_min_datetime": "2020-06-24T02:30:55.000Z", "num_tokens": 280, "size": 747 }
{-# OPTIONS --without-K --safe #-} module Data.Binary.Conversion.Fast.Strict where open import Data.Binary.Definition open import Data.Nat.DivMod open import Data.Nat.Base using (ℕ; suc; zero) open import Strict open import Data.Bool ⟦_⇑⟧⟨_⟩ : ℕ → ℕ → 𝔹 ⟦ suc n ⇑⟧⟨ suc w ⟩ = let! m =! even n in! let! ms =! ⟦ n ÷ 2 ⇑⟧⟨ w ⟩ in! if m then 1ᵇ ms else 2ᵇ ms ⟦ zero ⇑⟧⟨ _ ⟩ = 0ᵇ ⟦ suc _ ⇑⟧⟨ zero ⟩ = 0ᵇ -- will not happen ⟦_⇑⟧ : ℕ → 𝔹 ⟦ n ⇑⟧ = ⟦ n ⇑⟧⟨ n ⟩ {-# INLINE ⟦_⇑⟧ #-} -- Without the added argument to the recursor, the function does not -- pass the termination checker: -- {-# TERMINATING #-} -- ⟦_⇑⟧″ : ℕ → 𝔹 -- ⟦ zero ⇑⟧″ = 0ᵇ -- ⟦ suc n ⇑⟧″ = -- if rem n 2 ℕ.≡ᴮ 0 -- then 1ᵇ ⟦ n ÷ 2 ⇑⟧″ -- else 2ᵇ ⟦ n ÷ 2 ⇑⟧″ -- The "principled" version (which uses well-founded recursion) is -- incredibly slow. (and the following doesn't even compute, because of -- cubical) -- open import Data.Nat.WellFounded -- ⟦_⇑⟧‴ : ℕ → 𝔹 -- ⟦ n ⇑⟧‴ = go n (≤-wellFounded n) -- where -- go : ∀ n → Acc _<_ n → 𝔹 -- go zero wf = 0ᵇ -- go (suc n) (acc wf) = -- if rem n 2 ℕ.≡ᴮ 0 -- then 1ᵇ go (n ÷ 2) (wf (n ÷ 2) (s≤s (div2≤ n))) -- else 2ᵇ go (n ÷ 2) (wf (n ÷ 2) (s≤s (div2≤ n)))
{ "alphanum_fraction": 0.540942928, "avg_line_length": 25.1875, "ext": "agda", "hexsha": "90cee05b878f7b179551774cbd453adac2d09a45", "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/Binary/Conversion/Fast/Strict.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/Binary/Conversion/Fast/Strict.agda", "max_line_length": 71, "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/Binary/Conversion/Fast/Strict.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": 591, "size": 1209 }
-- Andreas, 2017-10-04, issue #2753, reported by nad -- Here, late solving of size constraints, prevented assignment -- of instance metas to their solutions, since the metaOccurs -- check then had more information through meta instantiation -- and saw the loop. -- To solve this issue, we switch off the meta-occurs check -- for instance metas. Instance search termination responsiblity -- rests already in the hand of the user. -- {-# OPTIONS -v tc.instance:30 #-} -- {-# OPTIONS -v tc.constr.solve:30 #-} -- {-# OPTIONS -v tc.size.solve:30 #-} -- {-# OPTIONS -v tc.meta.assign:10 #-} open import Agda.Builtin.Size -- Worked without sized types since instance search succeeds -- then quicker (not having to wait on the size constraint solver). -- postulate -- Size : Set -- Size<_ : Size → Set -- Size< i = Size mutual data D (i : Size) : Set where c : D′ i → D i data D′ (i : Size) : Set where box : (j : Size< i) → D j → D′ i record Fun (A B : Set) : Set where field applyTo : A → B open Fun ⦃ … ⦄ public mutual instance r : ∀ {i} → Fun (D i) (D i) Fun.applyTo r (c y) = c (applyTo y) r′ : ∀ {i} → Fun (D′ i) (D′ i) Fun.applyTo r′ (box j e) = box j (applyTo e) -- Andreas' analysis as put on the bug tracker: -- -- @UlfNorell is correct: the metaOccurs check prevents the -- solution. However, why does it work without the sized types then? The -- meta-occurs check does not go into solutions of metas. Thus, in the -- case without sized types, where instance search succeeds immediately -- (solving the hidden argument i by the conversion check), we are lucky -- enough to slip through the meta-occurs check. However, in the case -- with sized types, instance search does not succeed immediately because -- the constraint on size i does not give a solution for i -- directly. After size solving, instance search is retried, but then -- (when we solve the second instance variable), instantiateFull already -- has put in the solution for the first instance variable. Thus, the -- loop becomes apparent, and metaOccurs protests.
{ "alphanum_fraction": 0.6880689986, "avg_line_length": 31.6212121212, "ext": "agda", "hexsha": "ec6a03e6ba416e1cbdb84c9039d72c8e0ee5124c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue2753.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue2753.agda", "max_line_length": 73, "max_stars_count": 2, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue2753.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 573, "size": 2087 }
{- Matrix with coefficients in a commutative ring -} {-# OPTIONS --safe #-} module Cubical.Algebra.Matrix.CommRingCoefficient where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Powerset open import Cubical.Data.Nat hiding (_+_ ; _·_) open import Cubical.Data.FinData open import Cubical.Data.Sigma open import Cubical.Data.Empty as Empty open import Cubical.Relation.Nullary open import Cubical.Algebra.Ring open import Cubical.Algebra.Ring.BigOps open import Cubical.Algebra.CommRing open import Cubical.Algebra.RingSolver.Reflection open import Cubical.Algebra.Matrix private variable ℓ : Level m n k l : ℕ module Coefficient (𝓡 : CommRing ℓ) where private R = 𝓡 .fst 𝑹 = CommRing→Ring 𝓡 AbR = Ring→AbGroup 𝑹 open CommRingStr (𝓡 .snd) renaming ( is-set to isSetR ) open Sum 𝑹 open FinMatrixAbGroup -- Convenient renaming Mat : (m n : ℕ) → Type ℓ Mat m n = FinMatrix R m n isSetMat : isSet (Mat m n) isSetMat = isSetΠ2 (λ _ _ → isSetR) isContrEmpty : {n : ℕ} → isContr (Mat 0 n) isContrEmpty = isOfHLevelRespectEquiv _ (equiv→ (uninhabEquiv (λ ()) ¬Fin0) (idEquiv _)) isContr⊥→A isContrEmptyᵗ : {m : ℕ} → isContr (Mat m 0) isContrEmptyᵗ = isContrΠ (λ _ → isOfHLevelRespectEquiv _ (equiv→ (uninhabEquiv (λ ()) ¬Fin0) (idEquiv _)) isContr⊥→A) 𝟙 : Mat n n 𝟙 = oneFinMatrix 𝑹 𝟘 : Mat m n 𝟘 = zeroFinMatrix AbR _⋆_ : Mat m n → Mat n k → Mat m k M ⋆ N = mulFinMatrix 𝑹 M N infixl 8 _⋆_ ⋆lUnit : (M : Mat m n) → 𝟙 ⋆ M ≡ M ⋆lUnit = mulFinMatrix1r 𝑹 ⋆rUnit : (M : Mat m n) → M ⋆ 𝟙 ≡ M ⋆rUnit = mulFinMatrixr1 𝑹 ⋆Assoc : (M : Mat m n)(N : Mat n k)(K : Mat k l) → M ⋆ (N ⋆ K) ≡ (M ⋆ N) ⋆ K ⋆Assoc = mulFinMatrixAssoc 𝑹 -- Transposition _ᵗ : Mat m n → Mat n m (M ᵗ) i j = M j i idemᵗ : (M : Mat m n) → (M ᵗ)ᵗ ≡ M idemᵗ M t i j = M i j compᵗ : (M : Mat m n)(N : Mat n k) → (M ⋆ N)ᵗ ≡ N ᵗ ⋆ M ᵗ compᵗ M N t i j = ∑ (λ l → ·Comm (M j l) (N l i) t) 𝟙ᵗ : 𝟙 ᵗ ≡ 𝟙 {n = n} 𝟙ᵗ t zero zero = 1r 𝟙ᵗ t (suc i) zero = 0r 𝟙ᵗ t zero (suc j) = 0r 𝟙ᵗ t (suc i) (suc j) = 𝟙ᵗ t i j -- Invertible matrices isInv' : Mat n n → Mat n n → Type ℓ isInv' {n = n} M N = (M ⋆ N ≡ 𝟙) × (N ⋆ M ≡ 𝟙) isPropIsInv' : (M N : Mat n n) → isProp (isInv' M N) isPropIsInv' M N = isProp× (isSetMat _ _) (isSetMat _ _) invUniq : (M N N' : Mat n n) → isInv' M N → isInv' M N' → N ≡ N' invUniq M N N' p q = sym (⋆lUnit N) ∙ (λ i → q .snd (~ i) ⋆ N) ∙ sym (⋆Assoc N' M N) ∙ (λ i → N' ⋆ p .fst i) ∙ ⋆rUnit N' isInv : Mat n n → Type ℓ isInv {n = n} M = Σ[ N ∈ Mat n n ] isInv' M N isPropIsInv : (M : Mat n n) → isProp (isInv M) isPropIsInv M p q = Σ≡Prop (λ _ → isPropIsInv' M _) (invUniq M _ _ (p .snd) (q .snd)) isInv⋆ : {M M' : Mat n n} → isInv M → isInv M' → isInv (M ⋆ M') isInv⋆ (N , p) (N' , q) .fst = N' ⋆ N isInv⋆ {M = M} {M' = M'} (N , p) (N' , q) .snd .fst = sym (⋆Assoc M M' (N' ⋆ N)) ∙ (λ i → M ⋆ ⋆Assoc M' N' N i) ∙ (λ i → M ⋆ (q .fst i ⋆ N)) ∙ (λ i → M ⋆ ⋆lUnit N i) ∙ p .fst isInv⋆ {M = M} {M' = M'} (N , p) (N' , q) .snd .snd = sym (⋆Assoc N' N (M ⋆ M')) ∙ (λ i → N' ⋆ ⋆Assoc N M M' i) ∙ (λ i → N' ⋆ (p .snd i ⋆ M')) ∙ (λ i → N' ⋆ ⋆lUnit M' i) ∙ q .snd InvMat : (n : ℕ) → Type ℓ InvMat n = Σ[ M ∈ Mat n n ] isInv M isInv𝟙 : isInv {n = n} 𝟙 isInv𝟙 .fst = 𝟙 isInv𝟙 .snd .fst = ⋆lUnit _ isInv𝟙 .snd .snd = ⋆lUnit _ isInvᵗ : {M : Mat n n} → isInv M → isInv (M ᵗ) isInvᵗ {M = M} isInvM .fst = (isInvM .fst)ᵗ isInvᵗ {M = M} isInvM .snd .fst = (sym (compᵗ _ M)) ∙ (λ t → (isInvM .snd .snd t)ᵗ) ∙ 𝟙ᵗ isInvᵗ {M = M} isInvM .snd .snd = (sym (compᵗ M _)) ∙ (λ t → (isInvM .snd .fst t)ᵗ) ∙ 𝟙ᵗ -- Inversion formula for 2 × 2 matrices dot2 : (V W : FinVec R 2) → (∑ λ i → V i · W i) ≡ V zero · W zero + V one · W one dot2 V W i = V zero · W zero + (+Rid (V one · W one) i) mul2 : (M : Mat m 2)(N : Mat 2 n) → (i : Fin m)(j : Fin n) → (M ⋆ N) i j ≡ M i zero · N zero j + M i one · N one j mul2 M N i j = dot2 (M i) (λ k → N k j) open Units 𝓡 det2×2 : Mat 2 2 → R det2×2 M = M zero zero · M one one - M zero one · M one zero module _ (M : Mat 2 2)(p : det2×2 M ∈ Rˣ) where private Δ = det2×2 M Δ⁻¹ = (_⁻¹) Δ ⦃ p ⦄ ·rInv : Δ · Δ⁻¹ ≡ 1r ·rInv = ·-rinv _ ⦃ p ⦄ M⁻¹ : Mat 2 2 M⁻¹ zero zero = M one one · Δ⁻¹ M⁻¹ zero one = - M zero one · Δ⁻¹ M⁻¹ one zero = - M one zero · Δ⁻¹ M⁻¹ one one = M zero zero · Δ⁻¹ isInvMat2x2 : isInv M isInvMat2x2 .fst = M⁻¹ isInvMat2x2 .snd .fst i zero zero = (mul2 M M⁻¹ zero zero ∙ helper _ _ _ _ _ ∙ ·rInv) i where helper : (x y z w d : R) → x · (w · d) + y · (- z · d) ≡ (x · w - y · z) · d helper = solve 𝓡 isInvMat2x2 .snd .fst i zero one = (mul2 M M⁻¹ zero one ∙ helper _ _ _) i where helper : (x y d : R) → x · (- y · d) + y · (x · d) ≡ 0r helper = solve 𝓡 isInvMat2x2 .snd .fst i one zero = (mul2 M M⁻¹ one zero ∙ helper _ _ _) i where helper : (z w d : R) → z · (w · d) + w · (- z · d) ≡ 0r helper = solve 𝓡 isInvMat2x2 .snd .fst i one one = (mul2 M M⁻¹ one one ∙ helper _ _ _ _ _ ∙ ·rInv) i where helper : (x y z w d : R) → z · (- y · d) + w · (x · d) ≡ (x · w - y · z) · d helper = solve 𝓡 isInvMat2x2 .snd .snd i zero zero = (mul2 M⁻¹ M zero zero ∙ helper _ _ _ _ _ ∙ ·rInv) i where helper : (x y z w d : R) → (w · d) · x + (- y · d) · z ≡ (x · w - y · z) · d helper = solve 𝓡 isInvMat2x2 .snd .snd i zero one = (mul2 M⁻¹ M zero one ∙ helper _ _ _) i where helper : (y w d : R) → (w · d) · y + (- y · d) · w ≡ 0r helper = solve 𝓡 isInvMat2x2 .snd .snd i one zero = (mul2 M⁻¹ M one zero ∙ helper _ _ _) i where helper : (x z d : R) → (- z · d) · x + (x · d) · z ≡ 0r helper = solve 𝓡 isInvMat2x2 .snd .snd i one one = (mul2 M⁻¹ M one one ∙ helper _ _ _ _ _ ∙ ·rInv) i where helper : (x y z w d : R) → (- z · d) · y + (x · d) · w ≡ (x · w - y · z) · d helper = solve 𝓡 -- Similarity of matrices record SimRel (M N : Mat m n) : Type ℓ where field transMatL : Mat m m transMatR : Mat n n transEq : N ≡ transMatL ⋆ M ⋆ transMatR isInvTransL : isInv transMatL isInvTransR : isInv transMatR open SimRel record Sim (M : Mat m n) : Type ℓ where field result : Mat m n simrel : SimRel M result open Sim idSimRel : (M : Mat m n) → SimRel M M idSimRel _ .transMatL = 𝟙 idSimRel _ .transMatR = 𝟙 idSimRel M .transEq = sym ((λ t → ⋆lUnit M t ⋆ 𝟙) ∙ ⋆rUnit _) idSimRel _ .isInvTransL = isInv𝟙 idSimRel _ .isInvTransR = isInv𝟙 idSim : (M : Mat m n) → Sim M idSim M .result = M idSim M .simrel = idSimRel M ≡SimRel : {M N : Mat m n} → M ≡ N → SimRel M N ≡SimRel p .transMatL = 𝟙 ≡SimRel p .transMatR = 𝟙 ≡SimRel {M = M} p .transEq = sym p ∙ sym ((λ t → ⋆lUnit M t ⋆ 𝟙) ∙ ⋆rUnit _) ≡SimRel p .isInvTransL = isInv𝟙 ≡SimRel p .isInvTransR = isInv𝟙 ≡Sim : {M N : Mat m n} → M ≡ N → Sim M ≡Sim _ .result = _ ≡Sim p .simrel = ≡SimRel p compSimRel : {M N K : Mat m n} → SimRel M N → SimRel N K → SimRel M K compSimRel p q .transMatL = q .transMatL ⋆ p .transMatL compSimRel p q .transMatR = p .transMatR ⋆ q .transMatR compSimRel {M = M} p q .transEq = let L = p .transMatL R = p .transMatR L' = q .transMatL R' = q .transMatR in q .transEq ∙ (λ t → L' ⋆ p .transEq t ⋆ R') ∙ (λ t → L' ⋆ ⋆Assoc L M R (~ t) ⋆ R') ∙ (λ t → ⋆Assoc L' (L ⋆ (M ⋆ R)) R' (~ t)) ∙ (λ t → L' ⋆ ⋆Assoc L (M ⋆ R) R' (~ t)) ∙ (λ t → L' ⋆ (L ⋆ ⋆Assoc M R R' (~ t))) ∙ (λ t → L' ⋆ ⋆Assoc L M (R ⋆ R') t) ∙ (λ t → ⋆Assoc L' (L ⋆ M) (R ⋆ R') t) ∙ (λ t → ⋆Assoc L' L M t ⋆ (R ⋆ R')) compSimRel p q .isInvTransL = isInv⋆ (q .isInvTransL) (p .isInvTransL) compSimRel p q .isInvTransR = isInv⋆ (p .isInvTransR) (q .isInvTransR) compSim : {M : Mat m n}(p : Sim M)(q : Sim (p .result)) → Sim M compSim p q .result = q .result compSim p q .simrel = compSimRel (p .simrel) (q .simrel) -- Add a new element at upper-left corner _⊕_ : R → Mat m n → Mat (suc m) (suc n) (a ⊕ M) zero zero = a (a ⊕ M) (suc i) zero = 0r (a ⊕ M) zero (suc j) = 0r (a ⊕ M) (suc i) (suc j) = M i j infixr 5 _⊕_ sucMat : (M : Mat (suc m) (suc n)) → Mat m n sucMat M i j = M (suc i) (suc j) 𝟙suc : (i j : Fin m) → 𝟙 i j ≡ sucMat 𝟙 i j 𝟙suc zero zero = refl 𝟙suc (suc i) zero = refl 𝟙suc zero (suc j) = refl 𝟙suc (suc i) (suc j) = refl 1⊕𝟙 : 1r ⊕ 𝟙 {n = n} ≡ 𝟙 1⊕𝟙 t zero zero = 1r 1⊕𝟙 t (suc i) zero = 0r 1⊕𝟙 t zero (suc j) = 0r 1⊕𝟙 t (suc i) (suc j) = 𝟙suc i j t ⊕-⋆ : (a b : R)(M : Mat m n)(N : Mat n k) → (a ⊕ M) ⋆ (b ⊕ N) ≡ (a · b) ⊕ (M ⋆ N) ⊕-⋆ {n = n} a b M N t zero zero = ((λ t → a · b + ∑Mul0r {n = n} (λ i → 0r) t) ∙ helper _ _) t where helper : (a b : R) → a · b + 0r ≡ a · b helper = solve 𝓡 ⊕-⋆ a b M N t zero (suc j) = (helper a _ ∙ ∑Mul0r (λ i → N i j)) t where helper : (a c : R) → a · 0r + c ≡ c helper = solve 𝓡 ⊕-⋆ a b M N t (suc i) zero = (helper b _ ∙ ∑Mulr0 (λ j → M i j)) t where helper : (b c : R) → 0r · b + c ≡ c helper = solve 𝓡 ⊕-⋆ _ _ M N t (suc i) (suc j) = helper ((M ⋆ N) i j) t where helper : (c : R) → 0r · 0r + c ≡ c helper = solve 𝓡 isInv⊕ : (M : Mat m m) → isInv M → (isInv (1r ⊕ M)) isInv⊕ M isInvM .fst = 1r ⊕ isInvM .fst isInv⊕ M isInvM .snd .fst = ⊕-⋆ _ _ _ _ ∙ (λ t → ·Lid 1r t ⊕ isInvM .snd .fst t) ∙ 1⊕𝟙 isInv⊕ M isInvM .snd .snd = ⊕-⋆ _ _ _ _ ∙ (λ t → ·Rid 1r t ⊕ isInvM .snd .snd t) ∙ 1⊕𝟙 ⊕SimRel : (a : R){M N : Mat m n} → (sim : SimRel M N) → SimRel (a ⊕ M) (a ⊕ N) ⊕SimRel _ sim .transMatL = 1r ⊕ sim .transMatL ⊕SimRel _ sim .transMatR = 1r ⊕ sim .transMatR ⊕SimRel a {M = M} sim .transEq = let P = sim .transMatL Q = sim .transMatR in (λ t → helper a t ⊕ sim .transEq t) ∙ sym (⊕-⋆ _ _ _ Q) ∙ (λ t → ⊕-⋆ 1r a P M (~ t) ⋆ (1r ⊕ Q)) where helper : (a : R) → a ≡ (1r · a) · 1r helper = solve 𝓡 ⊕SimRel _ sim .isInvTransL = isInv⊕ _ (sim .isInvTransL) ⊕SimRel _ sim .isInvTransR = isInv⊕ _ (sim .isInvTransR) ⊕Sim : (a : R){M : Mat m n} → (sim : Sim M) → Sim (a ⊕ M) ⊕Sim a sim .result = a ⊕ sim .result ⊕Sim _ sim .simrel = ⊕SimRel _ (sim .simrel)
{ "alphanum_fraction": 0.5136678525, "avg_line_length": 31.0523255814, "ext": "agda", "hexsha": "ec10c810055a13573a6de073866bbc9b6d15d6b2", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_path": "Cubical/Algebra/Matrix/CommRingCoefficient.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_path": "Cubical/Algebra/Matrix/CommRingCoefficient.agda", "max_line_length": 105, "max_stars_count": null, "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_path": "Cubical/Algebra/Matrix/CommRingCoefficient.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5229, "size": 10682 }
{-# OPTIONS --without-K #-} module M-types.Coalg where open import M-types.Coalg.Core public open import M-types.Coalg.Bisim public open import M-types.Coalg.M public
{ "alphanum_fraction": 0.7071823204, "avg_line_length": 22.625, "ext": "agda", "hexsha": "f6716596c654d8c92c44a3842d84c7a1f7e76d9c", "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": "5b70f4b3dc3e50365ad7a3a80b0cd14efbfa4369", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DDOtten/M-types", "max_forks_repo_path": "Coalg.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5b70f4b3dc3e50365ad7a3a80b0cd14efbfa4369", "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": "DDOtten/M-types", "max_issues_repo_path": "Coalg.agda", "max_line_length": 42, "max_stars_count": null, "max_stars_repo_head_hexsha": "5b70f4b3dc3e50365ad7a3a80b0cd14efbfa4369", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DDOtten/M-types", "max_stars_repo_path": "Coalg.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 46, "size": 181 }
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module PolynomialFunctors where -- From: Ulf Norell. Dependently typed programming in Agda. In Koopman -- et al., editors. Advanced Functional Programming (AFP 2008), volume -- 5832 of LNCS. Springer-Verlag, 2009. pages 230–266. infixr 50 _|+|_ _⊕_ infixr 60 _|x|_ _×_ record True : Set where data _⊕_ (A B : Set) : Set where inl : A → A ⊕ B inr : B → A ⊕ B data _×_ (A B : Set) : Set where _,_ : A → B → A × B data Functor : Set₁ where |Id| : Functor |K| : Set → Functor _|+|_ : Functor → Functor → Functor _|x|_ : Functor → Functor → Functor [_] : Functor → Set → Set [ |Id| ] X = X [ |K| A ] X = A [ F |+| G ] X = [ F ] X ⊕ [ G ] X [ F |x| G ] X = [ F ] X × [ G ] X data μ_ (F : Functor) : Set where <_> : [ F ] (μ F) → μ F NatF : Functor NatF = |K| True |+| |Id| NAT : Set NAT = μ NatF Z : NAT Z = < inl _ > S : NAT → NAT S n = < inr n > _+_ : NAT → NAT → NAT m + < inl _ > = m m + < inr n > = S (m + n) ListF : (A : Set) → Functor ListF = λ A → |K| True |+| |K| A |x| |Id| LIST : (A : Set) → Set LIST = λ A → μ (ListF A) nil : {A : Set} → LIST A nil = < inl _ > cons : {A : Set} → A → LIST A → LIST A cons x xs = < inr (x , xs) >
{ "alphanum_fraction": 0.5174203113, "avg_line_length": 20.4393939394, "ext": "agda", "hexsha": "76f7f62ec45662b687177415adccbc1bc9092990", "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/fixed-points/PolynomialFunctors.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/fixed-points/PolynomialFunctors.agda", "max_line_length": 70, "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/fixed-points/PolynomialFunctors.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": 531, "size": 1349 }
{-# OPTIONS --safe --no-qualified-instances #-} module JVM.Syntax.Instructions where open import Level open import Data.Unit open import Data.Product hiding (swap) open import Data.String using (String) open import Data.List open import Data.List.Membership.Propositional using () renaming (_∈_ to Reg) open import JVM.Types open import JVM.Syntax.Values open import JVM.Model StackTy open import Relation.Unary hiding (_∈_) open import Relation.Ternary.Core open import Relation.Ternary.Structures open import Relation.Ternary.Structures.Syntax open import Relation.Ternary.Monad.Weakening data NativeBinOp : Ty → Ty → Ty → Set where add sub mul div xor : NativeBinOp int int int data Comparator : List Ty → Set where eq ne lt ge gt le : {{IsIntegral a}} → Comparator [ a ] icmpge icmpgt icmpeq icmpne icmplt icmple : Comparator (int ∷ [ int ]) {- Instructions -} module _ (𝑭 : FrameTy) where open import Data.List.Membership.Propositional 𝑹[_] : Ty → Set 𝑹[ a ] = a ∈ 𝑭 -- True to bytecode, the collection of registers is fixed. -- The stack typing varies. data ⟨_↝_⟩ : StackTy → StackTy → Pred Labels 0ℓ where noop : ε[ ⟨ ψ ↝ ψ ⟩ ] -- stack manipulation pop : ε[ ⟨ a ∷ ψ ↝ ψ ⟩ ] push : Const a → ε[ ⟨ ψ ↝ a ∷ ψ ⟩ ] dup : ε[ ⟨ a ∷ ψ ↝ a ∷ a ∷ ψ ⟩ ] swap : ε[ ⟨ a ∷ b ∷ ψ ↝ b ∷ a ∷ ψ ⟩ ] -- binary operations on primitive types bop : NativeBinOp a b c → ε[ ⟨ b ∷ a ∷ ψ ↝ c ∷ ψ ⟩ ] -- register manipulation load : 𝑹[ a ] → ε[ ⟨ ψ ↝ a ∷ ψ ⟩ ] store : 𝑹[ a ] → ε[ ⟨ a ∷ ψ ↝ ψ ⟩ ] -- jumps goto : ∀[ One ψ₁ ⇒ ⟨ ψ₁ ↝ ψ₂ ⟩ ] if : ∀ {as} → Comparator as → ∀[ One ψ ⇒ ⟨ as ++ ψ ↝ ψ ⟩ ] ⟨_∣_↝_⟩ = ⟨_↝_⟩ Instr = ⟨_↝_⟩ open import JVM.Syntax.Bytecode StackTy ⟨_↝_⟩ as BC open BC using (Code) public ⟪_∣_↜_⟫ = ⟪_↜_⟫ ⟪_∣_↝_⟫ = ⟪_↝_⟫ ⟪_∣_↝_⟫+ = ⟪_↝_⟫+ module _ {𝑭} where open import JVM.Syntax.Bytecode StackTy ⟨ 𝑭 ∣_↝_⟩ hiding (⟪_↜_⟫; ⟪_↝_⟫; ⟪_↝_⟫+; Code) public
{ "alphanum_fraction": 0.5984134854, "avg_line_length": 28.0138888889, "ext": "agda", "hexsha": "bfb857acffade40e199926c15fee7ceda65b4436", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ajrouvoet/jvm.agda", "max_forks_repo_path": "src/JVM/Syntax/Instructions.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "ajrouvoet/jvm.agda", "max_issues_repo_path": "src/JVM/Syntax/Instructions.agda", "max_line_length": 77, "max_stars_count": 6, "max_stars_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ajrouvoet/jvm.agda", "max_stars_repo_path": "src/JVM/Syntax/Instructions.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": 776, "size": 2017 }
open import Nat open import Prelude open import dynamics-core open import contexts open import preservation module complete-preservation where -- if you substitute a complete term into a complete term, the result is -- still complete. cp-subst : ∀ {x d1 d2} → d1 dcomplete → d2 dcomplete → ([ d2 / x ] d1) dcomplete cp-subst {x = y} (DCVar {x = x}) dc2 with natEQ x y cp-subst DCVar dc2 | Inl refl = dc2 cp-subst DCVar dc2 | Inr x₂ = DCVar cp-subst DCNum dc2 = DCNum cp-subst (DCPlus dc1 dc2) dc3 = DCPlus (cp-subst dc1 dc3) (cp-subst dc2 dc3) cp-subst {x = x} (DCLam {x = y} dc1 x₂) dc2 with natEQ y x cp-subst (DCLam dc1 x₃) dc2 | Inl refl = DCLam dc1 x₃ cp-subst (DCLam dc1 x₃) dc2 | Inr x₂ = DCLam (cp-subst dc1 dc2) x₃ cp-subst (DCAp dc1 dc2) dc3 = DCAp (cp-subst dc1 dc3) (cp-subst dc2 dc3) cp-subst (DCCast dc1 x₁ x₂) dc2 = DCCast (cp-subst dc1 dc2) x₁ x₂ cp-subst (DCInl x dc1) dc2 = DCInl x (cp-subst dc1 dc2) cp-subst (DCInr x dc1) dc2 = DCInr x (cp-subst dc1 dc2) cp-subst {x = x} (DCCase {x = y} {y = z} dc dc1 dc3) dc2 with natEQ y x | natEQ z x ... | Inl refl | Inl refl = DCCase (cp-subst dc dc2) dc1 dc3 ... | Inl refl | Inr z≠x = DCCase (cp-subst dc dc2 ) dc1 (cp-subst dc3 dc2) ... | Inr y≠x | Inl refl = DCCase (cp-subst dc dc2) (cp-subst dc1 dc2) dc3 ... | Inr y≠x | Inr z≠x = DCCase (cp-subst dc dc2) (cp-subst dc1 dc2) (cp-subst dc3 dc2) cp-subst (DCPair dc1 dc3) dc2 = DCPair (cp-subst dc1 dc2) (cp-subst dc3 dc2) cp-subst (DCFst dc1) dc2 = DCFst (cp-subst dc1 dc2) cp-subst (DCSnd dc1) dc2 = DCSnd (cp-subst dc1 dc2) -- this just lets me pull the particular x out of a derivation; it's not -- bound in any of the constructors explicitly since it's only in the -- lambda case; so below i have no idea how else to get a name for it, -- instead of leaving it dotted in the context lem-proj : {x : Nat} {d : ihexp} { τ : htyp} → (·λ x ·[ τ ] d) dcomplete → Σ[ y ∈ Nat ] (y == x) lem-proj {x} (DCLam dc x₁) = x , refl -- a complete well typed term steps to a complete term. cp-rhs : ∀{d τ d' Δ} → d dcomplete → Δ , ∅ ⊢ d :: τ → d ↦ d' → d' dcomplete cp-rhs dc TANum (Step FHOuter () FHOuter) cp-rhs (DCPlus dc dc₁) (TAPlus wt wt₁) (Step FHOuter (ITPlus refl) FHOuter) = DCNum cp-rhs (DCPlus dc dc₁) (TAPlus wt wt₁) (Step (FHPlus1 x) x₁ (FHPlus1 x₂)) with cp-rhs dc wt (Step x x₁ x₂) ... | q = DCPlus q dc₁ cp-rhs (DCPlus dc dc₁) (TAPlus wt wt₁) (Step (FHPlus2 x) x₁ (FHPlus2 x₂)) with cp-rhs dc₁ wt₁ (Step x x₁ x₂) ... | q = DCPlus dc q cp-rhs dc (TAVar x₁) stp = abort (somenotnone (! x₁)) cp-rhs dc (TALam _ wt) (Step FHOuter () FHOuter) -- this case is a little more complicated than it feels like it ought to -- be, just from horsing around with agda implicit variables. cp-rhs (DCAp dc dc₁) (TAAp wt wt₁) (Step FHOuter ITLam FHOuter) with lem-proj dc cp-rhs (DCAp dc dc₁) (TAAp wt wt₁) (Step FHOuter ITLam FHOuter) | x , refl with cp-subst {x = x} dc dc₁ ... | qq with natEQ x x cp-rhs (DCAp dc dc₁) (TAAp wt wt₁) (Step FHOuter ITLam FHOuter) | x , refl | DCLam qq x₁ | Inl refl = cp-subst qq dc₁ cp-rhs (DCAp dc dc₁) (TAAp wt wt₁) (Step FHOuter ITLam FHOuter) | x , refl | qq | Inr x₁ = abort (x₁ refl) cp-rhs (DCAp (DCCast dc (TCArr x x₁) (TCArr x₂ x₃)) dc₁) (TAAp (TACast wt x₄) wt₁) (Step FHOuter ITApCast FHOuter) = DCCast (DCAp dc (DCCast dc₁ x₂ x)) x₁ x₃ cp-rhs (DCAp dc dc₁) (TAAp wt wt₁) (Step (FHAp1 x) x₁ (FHAp1 x₂)) = DCAp (cp-rhs dc wt (Step x x₁ x₂)) dc₁ cp-rhs (DCAp dc dc₁) (TAAp wt wt₁) (Step (FHAp2 x) x₁ (FHAp2 x₂)) = DCAp dc (cp-rhs dc₁ wt₁ (Step x x₁ x₂)) cp-rhs () (TAEHole x x₁) stp cp-rhs () (TANEHole x wt x₁) stp cp-rhs (DCCast dc x x₁) (TACast wt x₂) (Step FHOuter ITCastID FHOuter) = dc cp-rhs (DCCast dc () x₁) (TACast wt x₂) (Step FHOuter (ITCastSucceed x₃) FHOuter) cp-rhs (DCCast dc () x₁) (TACast wt x₂) (Step FHOuter (ITCastFail x₃ x₄ x₅) FHOuter) cp-rhs (DCCast dc x ()) (TACast wt x₂) (Step FHOuter (ITGround x₃) FHOuter) cp-rhs (DCCast dc () x₁) (TACast wt x₂) (Step FHOuter (ITExpand x₃) FHOuter) cp-rhs (DCCast dc x x₁) (TACast wt x₂) (Step (FHCast x₃) x₄ (FHCast x₅)) = DCCast (cp-rhs dc wt (Step x₃ x₄ x₅)) x x₁ cp-rhs () (TAFailedCast wt x x₁ x₂) stp cp-rhs (DCInl x dc) (TAInl wt) (Step (FHInl x₁) x₂ (FHInl x₃)) = DCInl x (cp-rhs dc wt (Step x₁ x₂ x₃)) cp-rhs (DCInr x dc) (TAInr wt) (Step (FHInr x₁) x₂ (FHInr x₃)) = DCInr x (cp-rhs dc wt (Step x₁ x₂ x₃)) cp-rhs (DCCase (DCInl x₂ dc) dc₁ dc₂) (TACase wt x wt₁ x₁ wt₂) (Step FHOuter ITCaseInl FHOuter) = cp-subst dc₁ dc cp-rhs (DCCase (DCInr x₂ dc) dc₁ dc₂) (TACase wt x wt₁ x₁ wt₂) (Step FHOuter ITCaseInr FHOuter) = cp-subst dc₂ dc cp-rhs (DCCase (DCCast dc (TCSum x₂ x₄) (TCSum x₃ x₅)) dc₁ dc₂) (TACase wt x wt₁ x₁ wt₂) (Step FHOuter ITCaseCast FHOuter) = DCCase dc (cp-subst dc₁ (DCCast DCVar x₂ x₃)) (cp-subst dc₂ (DCCast DCVar x₄ x₅)) cp-rhs (DCCase dc dc₁ dc₂) (TACase wt x wt₁ x₁ wt₂) (Step (FHCase x₂) x₃ (FHCase x₄)) = DCCase (cp-rhs dc wt (Step x₂ x₃ x₄)) dc₁ dc₂ cp-rhs (DCInl x dc) (TAInl dc₁) (Step FHOuter () FHOuter) cp-rhs (DCInr x dc) (TAInr dc₁) (Step FHOuter () FHOuter) cp-rhs (DCPair dc dc₁) (TAPair dc₂ dc₃) (Step (FHPair1 x₁) x₂ (FHPair1 x₃)) = DCPair (cp-rhs dc dc₂ (Step x₁ x₂ x₃)) dc₁ cp-rhs (DCPair dc dc₁) (TAPair dc₂ dc₃) (Step (FHPair2 x₁) x₂ (FHPair2 x₃)) = DCPair dc (cp-rhs dc₁ dc₃ (Step x₁ x₂ x₃)) cp-rhs (DCFst (DCPair dc dc₃)) (TAFst dc₁) (Step FHOuter ITFstPair FHOuter) = dc cp-rhs (DCFst (DCCast dc (TCProd x x₁) (TCProd x₃ x₄))) (TAFst dc₁) (Step FHOuter ITFstCast FHOuter) = DCCast (DCFst dc) x x₃ cp-rhs (DCFst dc) (TAFst dc₁) (Step (FHFst x₁) x₂ (FHFst x₃)) = DCFst (cp-rhs dc dc₁ (Step x₁ x₂ x₃)) cp-rhs (DCSnd (DCPair dc dc₂)) (TASnd dc₁) (Step FHOuter ITSndPair FHOuter) = dc₂ cp-rhs (DCSnd (DCCast dc (TCProd x x₁) (TCProd x₂ x₃))) (TASnd dc₁) (Step FHOuter ITSndCast FHOuter) = DCCast (DCSnd dc) x₁ x₃ cp-rhs (DCSnd dc) (TASnd dc₁) (Step (FHSnd x₁) x₂ (FHSnd x₃)) = DCSnd (cp-rhs dc dc₁ (Step x₁ x₂ x₃)) -- this is the main result of this file. complete-preservation : ∀{d τ d' Δ} → binders-unique d → d dcomplete → Δ , ∅ ⊢ d :: τ → d ↦ d' → (Δ , ∅ ⊢ d' :: τ) × (d' dcomplete) complete-preservation bd dc wt stp = preservation bd wt stp , cp-rhs dc wt stp
{ "alphanum_fraction": 0.6270253745, "avg_line_length": 62.3047619048, "ext": "agda", "hexsha": "679a1406c9909423985cc84e3873a486bc823dce", "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": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-agda", "max_forks_repo_path": "complete-preservation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "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": "hazelgrove/hazelnut-agda", "max_issues_repo_path": "complete-preservation.agda", "max_line_length": 209, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-agda", "max_stars_repo_path": "complete-preservation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2844, "size": 6542 }
module Logic.Congruence where import Prelude import Logic.Relations import Logic.Equivalence open Prelude open Logic.Relations open Logic.Equivalence using (Equivalence) renaming (module Equivalence to Proj) data Congruence (A : Set) : Set1 where congruence : (Eq : Equivalence A) -> Congruent (Proj._==_ Eq) -> Congruence A module Projections where eq : {A : Set} -> Congruence A -> Rel A eq (congruence Eq _) = Proj._==_ Eq refl : {A : Set}(Cong : Congruence A) -> Reflexive (eq Cong) refl (congruence Eq _) = Proj.refl Eq sym : {A : Set}(Cong : Congruence A) -> Symmetric (eq Cong) sym (congruence Eq _) = Proj.sym Eq trans : {A : Set}(Cong : Congruence A) -> Transitive (eq Cong) trans (congruence Eq _) = Proj.trans Eq cong : {A : Set}(Cong : Congruence A) -> Congruent (eq Cong) cong (congruence _ c) = c module Congruence {A : Set}(Cong : Congruence A) where _==_ = Projections.eq Cong refl = Projections.refl Cong sym = Projections.sym Cong trans = Projections.trans Cong cong = Projections.cong Cong cong2 : (f : A -> A -> A)(a b c d : A) -> a == c -> b == d -> f a b == f c d cong2 f a b c d ac bd = trans _ _ _ rem1 rem2 where rem1 : f a b == f a d rem1 = cong (f a) _ _ bd rem2 : f a d == f c d rem2 = cong (flip f d) _ _ ac
{ "alphanum_fraction": 0.6112737921, "avg_line_length": 25.7735849057, "ext": "agda", "hexsha": "570c0211ec6243fd8c9454f771ced967b5d757fa", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/lib/Logic/Congruence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "examples/lib/Logic/Congruence.agda", "max_line_length": 78, "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": "examples/lib/Logic/Congruence.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": 461, "size": 1366 }
{- This second-order term syntax was created from the following second-order syntax description: syntax CommMonoid | CM type * : 0-ary term unit : * | ε add : * * -> * | _⊕_ l20 theory (εU⊕ᴸ) a |> add (unit, a) = a (εU⊕ᴿ) a |> add (a, unit) = a (⊕A) a b c |> add (add(a, b), c) = add (a, add(b, c)) (⊕C) a b |> add(a, b) = add(b, a) -} module CommMonoid.Syntax where open import SOAS.Common open import SOAS.Context open import SOAS.Variable open import SOAS.Families.Core open import SOAS.Construction.Structure open import SOAS.ContextMaps.Inductive open import SOAS.Metatheory.Syntax open import CommMonoid.Signature private variable Γ Δ Π : Ctx α : *T 𝔛 : Familyₛ -- Inductive term declaration module CM:Terms (𝔛 : Familyₛ) where data CM : Familyₛ where var : ℐ ⇾̣ CM mvar : 𝔛 α Π → Sub CM Π Γ → CM α Γ ε : CM * Γ _⊕_ : CM * Γ → CM * Γ → CM * Γ infixl 20 _⊕_ open import SOAS.Metatheory.MetaAlgebra ⅀F 𝔛 CMᵃ : MetaAlg CM CMᵃ = record { 𝑎𝑙𝑔 = λ where (unitₒ ⋮ _) → ε (addₒ ⋮ a , b) → _⊕_ a b ; 𝑣𝑎𝑟 = var ; 𝑚𝑣𝑎𝑟 = λ 𝔪 mε → mvar 𝔪 (tabulate mε) } module CMᵃ = MetaAlg CMᵃ module _ {𝒜 : Familyₛ}(𝒜ᵃ : MetaAlg 𝒜) where open MetaAlg 𝒜ᵃ 𝕤𝕖𝕞 : CM ⇾̣ 𝒜 𝕊 : Sub CM Π Γ → Π ~[ 𝒜 ]↝ Γ 𝕊 (t ◂ σ) new = 𝕤𝕖𝕞 t 𝕊 (t ◂ σ) (old v) = 𝕊 σ v 𝕤𝕖𝕞 (mvar 𝔪 mε) = 𝑚𝑣𝑎𝑟 𝔪 (𝕊 mε) 𝕤𝕖𝕞 (var v) = 𝑣𝑎𝑟 v 𝕤𝕖𝕞 ε = 𝑎𝑙𝑔 (unitₒ ⋮ tt) 𝕤𝕖𝕞 (_⊕_ a b) = 𝑎𝑙𝑔 (addₒ ⋮ 𝕤𝕖𝕞 a , 𝕤𝕖𝕞 b) 𝕤𝕖𝕞ᵃ⇒ : MetaAlg⇒ CMᵃ 𝒜ᵃ 𝕤𝕖𝕞 𝕤𝕖𝕞ᵃ⇒ = record { ⟨𝑎𝑙𝑔⟩ = λ{ {t = t} → ⟨𝑎𝑙𝑔⟩ t } ; ⟨𝑣𝑎𝑟⟩ = refl ; ⟨𝑚𝑣𝑎𝑟⟩ = λ{ {𝔪 = 𝔪}{mε} → cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-tab mε)) } } where open ≡-Reasoning ⟨𝑎𝑙𝑔⟩ : (t : ⅀ CM α Γ) → 𝕤𝕖𝕞 (CMᵃ.𝑎𝑙𝑔 t) ≡ 𝑎𝑙𝑔 (⅀₁ 𝕤𝕖𝕞 t) ⟨𝑎𝑙𝑔⟩ (unitₒ ⋮ _) = refl ⟨𝑎𝑙𝑔⟩ (addₒ ⋮ _) = refl 𝕊-tab : (mε : Π ~[ CM ]↝ Γ)(v : ℐ α Π) → 𝕊 (tabulate mε) v ≡ 𝕤𝕖𝕞 (mε v) 𝕊-tab mε new = refl 𝕊-tab mε (old v) = 𝕊-tab (mε ∘ old) v module _ (g : CM ⇾̣ 𝒜)(gᵃ⇒ : MetaAlg⇒ CMᵃ 𝒜ᵃ g) where open MetaAlg⇒ gᵃ⇒ 𝕤𝕖𝕞! : (t : CM α Γ) → 𝕤𝕖𝕞 t ≡ g t 𝕊-ix : (mε : Sub CM Π Γ)(v : ℐ α Π) → 𝕊 mε v ≡ g (index mε v) 𝕊-ix (x ◂ mε) new = 𝕤𝕖𝕞! x 𝕊-ix (x ◂ mε) (old v) = 𝕊-ix mε v 𝕤𝕖𝕞! (mvar 𝔪 mε) rewrite cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-ix mε)) = trans (sym ⟨𝑚𝑣𝑎𝑟⟩) (cong (g ∘ mvar 𝔪) (tab∘ix≈id mε)) 𝕤𝕖𝕞! (var v) = sym ⟨𝑣𝑎𝑟⟩ 𝕤𝕖𝕞! ε = sym ⟨𝑎𝑙𝑔⟩ 𝕤𝕖𝕞! (_⊕_ a b) rewrite 𝕤𝕖𝕞! a | 𝕤𝕖𝕞! b = sym ⟨𝑎𝑙𝑔⟩ -- Syntax instance for the signature CM:Syn : Syntax CM:Syn = record { ⅀F = ⅀F ; ⅀:CS = ⅀:CompatStr ; mvarᵢ = CM:Terms.mvar ; 𝕋:Init = λ 𝔛 → let open CM:Terms 𝔛 in record { ⊥ = CM ⋉ CMᵃ ; ⊥-is-initial = record { ! = λ{ {𝒜 ⋉ 𝒜ᵃ} → 𝕤𝕖𝕞 𝒜ᵃ ⋉ 𝕤𝕖𝕞ᵃ⇒ 𝒜ᵃ } ; !-unique = λ{ {𝒜 ⋉ 𝒜ᵃ} (f ⋉ fᵃ⇒) {x = t} → 𝕤𝕖𝕞! 𝒜ᵃ f fᵃ⇒ t } } } } -- Instantiation of the syntax and metatheory open Syntax CM:Syn public open CM:Terms public open import SOAS.Families.Build public open import SOAS.Syntax.Shorthands CMᵃ public open import SOAS.Metatheory CM:Syn public
{ "alphanum_fraction": 0.5388634879, "avg_line_length": 24.496, "ext": "agda", "hexsha": "ab46823aeb77fefc51f78fddb0554047deb5e999", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "out/CommMonoid/Syntax.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "out/CommMonoid/Syntax.agda", "max_line_length": 93, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "out/CommMonoid/Syntax.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 1884, "size": 3062 }
{-# OPTIONS --without-K --safe #-} open import Algebra.Structures.Bundles.Field module Algebra.Linear.Structures.FiniteDimensional {k ℓᵏ} (K : Field k ℓᵏ) where open import Algebra.Linear.Core open import Algebra.FunctionProperties open import Relation.Binary using (Rel) open import Algebra.Linear.Morphism.Bundles K open import Algebra.Linear.Structures.VectorSpace K open import Function.Equality open import Level using (_⊔_; suc) open import Data.Nat using (ℕ) import Algebra.Linear.Construct.Vector K as Vec private K' : Set k K' = Field.Carrier K record IsFiniteDimensional {v ℓ} {V : Set v} (_≈_ : Rel V ℓ) (_+_ : Op₂ V) (_∙_ : K' → V → V) (-_ : Op₁ V) (0# : V) (n : ℕ) : Set (suc (v ⊔ k ⊔ ℓ ⊔ ℓᵏ)) where field isVectorSpace : IsVectorSpace _≈_ _+_ _∙_ -_ 0# embed : LinearIsomorphism (record { isVectorSpace = isVectorSpace }) (record { isVectorSpace = Vec.isVectorSpace {n} }) open IsVectorSpace isVectorSpace public module Vector {n} where open Vec isFiniteDimensional : IsFiniteDimensional (Vec._≈_) (Vec._+_) (Vec._∙_) (Vec.-_) (Vec.0#) n isFiniteDimensional = record { isVectorSpace = Vec.isVectorSpace ; embed = Vec.embed }
{ "alphanum_fraction": 0.6533333333, "avg_line_length": 26.5625, "ext": "agda", "hexsha": "240817300a344126e5810b1bc0f2a669573b3557", "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": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "felko/linear-algebra", "max_forks_repo_path": "src/Algebra/Linear/Structures/FiniteDimensional.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "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": "felko/linear-algebra", "max_issues_repo_path": "src/Algebra/Linear/Structures/FiniteDimensional.agda", "max_line_length": 93, "max_stars_count": 15, "max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "felko/linear-algebra", "max_stars_repo_path": "src/Algebra/Linear/Structures/FiniteDimensional.agda", "max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z", "num_tokens": 390, "size": 1275 }
{-# OPTIONS --without-K #-} infixr 1 _‘→’_ data Type : Set where _‘→’_ : Type → Type → Type ‘□’ : Type → Type data □ : Type → Set where Lӧb : ∀ {X} → □ (‘□’ X ‘→’ X) → □ X ⌞_⌟ : Type → Set ⌞ A ‘→’ B ⌟ = ⌞ A ⌟ → ⌞ B ⌟ ⌞ ‘□’ T ⌟ = □ T ⌞_⌟t : ∀ {T : Type} → □ T → ⌞ T ⌟ ⌞ (Lӧb □‘X’→X) ⌟t = ⌞ □‘X’→X ⌟t (Lӧb □‘X’→X) lӧb : ∀ {‘X’} → □ (‘□’ ‘X’ ‘→’ ‘X’) → ⌞ ‘X’ ⌟ lӧb f = ⌞ Lӧb f ⌟t
{ "alphanum_fraction": 0.3538461538, "avg_line_length": 19.5, "ext": "agda", "hexsha": "485fce9043d14cd5f0783aacbc08fd503072d6ff", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-07-17T18:53:37.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-17T18:53:37.000Z", "max_forks_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JasonGross/lob", "max_forks_repo_path": "internal/mini-mini-mini-lob.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_issues_repo_issues_event_max_datetime": "2015-07-17T20:20:43.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-17T20:20:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JasonGross/lob", "max_issues_repo_path": "internal/mini-mini-mini-lob.agda", "max_line_length": 45, "max_stars_count": 19, "max_stars_repo_head_hexsha": "716129208eaf4fe3b5f629f95dde4254805942b3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JasonGross/lob", "max_stars_repo_path": "internal/mini-mini-mini-lob.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-17T14:04:53.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-17T17:53:30.000Z", "num_tokens": 274, "size": 390 }
------------------------------------------------------------------------ -- Queue instances for the queues in Queue.Simple ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality module Queue.Simple.Instances {c⁺} (eq : ∀ {a p} → Equality-with-J a p c⁺) where open Derived-definitions-and-properties eq open import Prelude open import Queue eq open import Queue.Simple eq as Q using (Queue) private variable ℓ ℓ₁ ℓ₂ : Level instance -- Instances. Queue-is-queue : Is-queue (λ A → Queue A) (λ _ → ↑ _ ⊤) ℓ Queue-is-queue .Is-queue.to-List = λ _ → Q.to-List Queue-is-queue .Is-queue.from-List = Q.from-List Queue-is-queue .Is-queue.to-List-from-List = Q.to-List-from-List Queue-is-queue .Is-queue.enqueue = Q.enqueue Queue-is-queue .Is-queue.to-List-enqueue {q = q} = Q.to-List-enqueue q Queue-is-queue .Is-queue.dequeue = λ _ → Q.dequeue Queue-is-queue .Is-queue.to-List-dequeue {q = q} = Q.to-List-dequeue q Queue-is-queue .Is-queue.dequeue⁻¹ = Q.dequeue⁻¹ Queue-is-queue .Is-queue.to-List-dequeue⁻¹ {x = x} = Q.to-List-dequeue⁻¹ x Queue-is-queue-with-map : Is-queue-with-map (λ A → Queue A) ℓ₁ ℓ₂ Queue-is-queue-with-map .Is-queue-with-map.map = Q.map Queue-is-queue-with-map .Is-queue-with-map.to-List-map {q = q} = Q.to-List-map q
{ "alphanum_fraction": 0.5569877883, "avg_line_length": 34.2790697674, "ext": "agda", "hexsha": "71513d21cc8759bd2e3cd83ea31fab645fd7a7c8", "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/Instances.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/Instances.agda", "max_line_length": 76, "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/Instances.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": 427, "size": 1474 }
-- Andreas, 2015-11-28 -- Aliases in parentheses should also parse. -- Parenthesized aliases are accepted in lets. -- With type annotation, parenthesized aliases are accepted in wheres. id0 : {A : Set} → A → A id0 {A} x = let z = y in z where y : A y = x id1 : {A : Set} → A → A id1 {A} x = let (z) = y in z where y : A (y) = x id2 : {A : Set} → A → A id2 {A} x = let ((z)) = y in z where y : A ((y)) = x works0 : {A : Set} → A → A works0 x = let z = y in z where y = x -- Without type annotation, parenthesized aliases should also be accepted in wheres. -- Should work: test1 : {A : Set} → A → A test1 x = let (z) = y in z where (y) = x -- Should work: test2 : {A : Set} → A → A test2 x = let ((z)) = y in z where ((y)) = x
{ "alphanum_fraction": 0.5421994885, "avg_line_length": 17.7727272727, "ext": "agda", "hexsha": "528511a0d14a983178803e4f449d4e35becada3c", "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/ParenthesizedAlias.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/ParenthesizedAlias.agda", "max_line_length": 84, "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/ParenthesizedAlias.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": 299, "size": 782 }
module Structure.Operator.Vector.LinearMap where open import Functional open import Logic open import Logic.Predicate open import Logic.Propositional import Lvl open import Structure.Function open import Structure.Function.Domain open import Structure.Function.Multi open import Structure.Operator open import Structure.Operator.Field.VectorSpace open import Structure.Operator.Properties using (Distributivityₗ ; Distributivityᵣ) open import Structure.Operator.Vector open import Structure.Setoid open import Type open import Syntax.Function open import Syntax.Transitivity private variable ℓ ℓᵥ ℓᵥₗ ℓᵥᵣ ℓₛ ℓᵥₑ ℓᵥₑₗ ℓᵥₑᵣ ℓᵥₑ₁ ℓᵥₑ₂ ℓᵥₑ₃ ℓₛₑ : Lvl.Level private variable V Vₗ Vᵣ V₁ V₂ V₃ S : Type{ℓ} private variable _+ᵥ_ _+ᵥₗ_ _+ᵥᵣ_ _+ᵥ₁_ _+ᵥ₂_ _+ᵥ₃_ : V → V → V private variable _⋅ₛᵥ_ _⋅ₛᵥₗ_ _⋅ₛᵥᵣ_ _⋅ₛᵥ₁_ _⋅ₛᵥ₂_ _⋅ₛᵥ₃_ : S → V → V private variable _+ₛ_ _⋅ₛ_ : S → S → S module _ ⦃ equiv-Vₗ : Equiv{ℓᵥₑₗ}(Vₗ) ⦄ ⦃ equiv-Vᵣ : Equiv{ℓᵥₑᵣ}(Vᵣ) ⦄ ⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄ (vectorSpaceₗ : VectorSpace{V = Vₗ}{S = S}(_+ᵥₗ_)(_⋅ₛᵥₗ_)(_+ₛ_)(_⋅ₛ_)) (vectorSpaceᵣ : VectorSpace{V = Vᵣ}{S = S}(_+ᵥᵣ_)(_⋅ₛᵥᵣ_)(_+ₛ_)(_⋅ₛ_)) (f : Vₗ → Vᵣ) where record LinearMap : Type{Lvl.of(Vₗ) Lvl.⊔ ℓᵥₑₗ Lvl.⊔ ℓᵥₑᵣ Lvl.⊔ Lvl.of(S)} where constructor intro field ⦃ function ⦄ : Function(f) ⦃ preserves-[+ᵥ] ⦄ : Preserving₂(f)(_+ᵥₗ_)(_+ᵥᵣ_) ⦃ preserves-[⋅ₛᵥ] ⦄ : ∀{s} → Preserving₁(f)(s ⋅ₛᵥₗ_)(s ⋅ₛᵥᵣ_) _→ˡⁱⁿᵉᵃʳᵐᵃᵖ_ : ⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄ → VectorSpaceVObject{ℓᵥ = ℓᵥₗ}{ℓᵥₑ = ℓᵥₑₗ}{S = S}(_+ₛ_)(_⋅ₛ_) → VectorSpaceVObject{ℓᵥ = ℓᵥᵣ}{ℓᵥₑ = ℓᵥₑᵣ}{S = S}(_+ₛ_)(_⋅ₛ_) → Stmt V₁ →ˡⁱⁿᵉᵃʳᵐᵃᵖ V₂ = ∃(LinearMap(VectorSpaceVObject.vectorSpace(V₁)) (VectorSpaceVObject.vectorSpace(V₂))) _↔ˡⁱⁿᵉᵃʳᵐᵃᵖ_ : ⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄ → VectorSpaceVObject{ℓᵥ = ℓᵥₗ}{ℓᵥₑ = ℓᵥₑₗ}{S = S}(_+ₛ_)(_⋅ₛ_) → VectorSpaceVObject{ℓᵥ = ℓᵥᵣ}{ℓᵥₑ = ℓᵥₑᵣ}{S = S}(_+ₛ_)(_⋅ₛ_) → Stmt V₁ ↔ˡⁱⁿᵉᵃʳᵐᵃᵖ V₂ = ∃(f ↦ Invertible(f) ∧ LinearMap(VectorSpaceVObject.vectorSpace(V₁)) (VectorSpaceVObject.vectorSpace(V₂))(f)) module _ ⦃ equiv-V : Equiv{ℓᵥₑ}(V) ⦄ ⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄ (vectorSpace : VectorSpace{V = V}{S = S}(_+ᵥ_)(_⋅ₛᵥ_)(_+ₛ_)(_⋅ₛ_)) (f : V → V) where LinearOperator = LinearMap(vectorSpace)(vectorSpace) (f) module _ ⦃ equiv-V : Equiv{ℓᵥₑ}(V) ⦄ ⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄ (vectorSpace : VectorSpace{V = V}{S = S}(_+ᵥ_)(_⋅ₛᵥ_)(_+ₛ_)(_⋅ₛ_)) (f : V → S) where LinearFunctional = LinearMap(vectorSpace)(fieldVectorSpace(VectorSpace.scalarField(vectorSpace))) (f) module _ ⦃ equiv-V₁ : Equiv{ℓᵥₑ₁}(V₁) ⦄ ⦃ equiv-V₂ : Equiv{ℓᵥₑ₂}(V₂) ⦄ ⦃ equiv-V₃ : Equiv{ℓᵥₑ₃}(V₃) ⦄ ⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄ (vectorSpace₁ : VectorSpace{V = V₁}{S = S}(_+ᵥ₁_)(_⋅ₛᵥ₁_)(_+ₛ_)(_⋅ₛ_)) (vectorSpace₂ : VectorSpace{V = V₂}{S = S}(_+ᵥ₂_)(_⋅ₛᵥ₂_)(_+ₛ_)(_⋅ₛ_)) (vectorSpace₃ : VectorSpace{V = V₃}{S = S}(_+ᵥ₃_)(_⋅ₛᵥ₃_)(_+ₛ_)(_⋅ₛ_)) (f : V₁ → V₂ → V₃) where record BilinearMap : Type{Lvl.of(V₁) Lvl.⊔ Lvl.of(V₂) Lvl.⊔ ℓᵥₑ₁ Lvl.⊔ ℓᵥₑ₂ Lvl.⊔ ℓᵥₑ₃ Lvl.⊔ Lvl.of(S)} where constructor intro field ⦃ linearMap₁ ⦄ : ∀{y} → LinearMap vectorSpace₁ vectorSpace₃ (x ↦ f(x)(y)) ⦃ linearMap₂ ⦄ : ∀{x} → LinearMap vectorSpace₂ vectorSpace₃ (y ↦ f(x)(y)) open module LinearMapₗ{y} = LinearMap(linearMap₁{y}) renaming (function to functionₗ ; preserves-[+ᵥ] to preserves-[+ᵥ]ₗ ; preserves-[⋅ₛᵥ] to preserves-[⋅ₛᵥ]ₗ) public open module LinearMapᵣ{x} = LinearMap(linearMap₂{x}) renaming (function to functionᵣ ; preserves-[+ᵥ] to preserves-[+ᵥ]ᵣ ; preserves-[⋅ₛᵥ] to preserves-[⋅ₛᵥ]ᵣ) public binaryOperator : BinaryOperator(f) binaryOperator = functions-to-binaryOperator(f) ⦃ functionₗ ⦄ ⦃ functionᵣ ⦄ module _ ⦃ equiv-V : Equiv{ℓᵥₑ}(V) ⦄ ⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄ (vectorSpace : VectorSpace{V = V}{S = S}(_+ᵥ_)(_⋅ₛᵥ_)(_+ₛ_)(_⋅ₛ_)) (_▫_ : V → V → V) where BilinearOperator = BilinearMap(vectorSpace)(vectorSpace)(vectorSpace) (_▫_) module BilinearOperator(bilinearOper : BilinearOperator) where -- TODO: Move the proof for distributivity from preserving [+ᵥ]-distributivityₗ : Distributivityₗ(_▫_)(_+ᵥ_) Distributivityₗ.proof [+ᵥ]-distributivityₗ {x}{y}{z} = x ▫ (y +ᵥ z) 🝖[ _≡_ ]-[ preserving₂(x ▫_)(_+ᵥ_)(_+ᵥ_) ⦃ LinearMap.preserves-[+ᵥ] (BilinearMap.linearMap₂ bilinearOper) ⦄ ] (x ▫ y) +ᵥ (x ▫ z) 🝖-end [+ᵥ]-distributivityᵣ : Distributivityᵣ(_▫_)(_+ᵥ_) Distributivityᵣ.proof [+ᵥ]-distributivityᵣ {x}{y}{z} = (x +ᵥ y) ▫ z 🝖[ _≡_ ]-[ preserving₂(_▫ z)(_+ᵥ_)(_+ᵥ_) ⦃ LinearMap.preserves-[+ᵥ] (BilinearMap.linearMap₁ bilinearOper) ⦄ ] (x ▫ z) +ᵥ (y ▫ z) 🝖-end
{ "alphanum_fraction": 0.6567815089, "avg_line_length": 42.462962963, "ext": "agda", "hexsha": "4da1da58ca51e7c042d6b37505626648115ae5b2", "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/LinearMap.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/LinearMap.agda", "max_line_length": 173, "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/LinearMap.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": 2528, "size": 4586 }
module STLC2.Kovacs.Completeness where open import STLC2.Kovacs.Normalisation public open import STLC2.Kovacs.Convertibility public -- TODO: Remove this postulate █ : ∀ {ℓ} → {X : Set ℓ} → X -------------------------------------------------------------------------------- -- (_≈_) mutual infix 3 _≫_ _≫_ : ∀ {A Γ} → Γ ⊢ A → Γ ⊩ A → Set _≫_ {⎵} {Γ} M N = M ∼ embⁿᶠ N _≫_ {A ⇒ B} {Γ} M f = ∀ {Γ′} → (η : Γ′ ⊇ Γ) → {N : Γ′ ⊢ A} {∂a : Γ′ ∂⊩ A} → N ∂≫ ∂a → ren η M ∙ N ∂≫ f η ∂a _≫_ {A ⩕ B} {Γ} M s = π₁ M ∂≫ proj₁ s × π₂ M ∂≫ proj₂ s _≫_ {⫪} {Γ} M s = ⊤ _≫_ {⫫} {Γ} M s = ⊥ _≫_ {A ⩖ B} {Γ} M s = elim⊎ s (λ ∂a → Σ (Γ ⊢ A) (λ M₁ → M₁ ∂≫ ∂a)) (λ ∂b → Σ (Γ ⊢ B) (λ M₂ → M₂ ∂≫ ∂b)) infix 3 _∂≫_ _∂≫_ : ∀ {Γ A} → Γ ⊢ A → Γ ∂⊩ A → Set _∂≫_ {Γ} {A} M ∂a = ∀ {Γ′ C} → (η : Γ′ ⊇ Γ) → {N : Γ′ ⊢ C} → {Nⁿᶠ : Γ′ ⊢ⁿᶠ C} → (f : ∀ {Γ″} → (η′ : Γ″ ⊇ Γ′) → {a : Γ″ ⊩ A} → ren (η ○ η′) M ≫ a → ren η′ N ∼ embⁿᶠ (renⁿᶠ η′ Nⁿᶠ)) → N ∼ embⁿᶠ Nⁿᶠ -- (_≈ᶜ_) infix 3 _∂≫⋆_ data _∂≫⋆_ : ∀ {Γ Ξ} → Γ ⊢⋆ Ξ → Γ ∂⊩⋆ Ξ → Set where ∅ : ∀ {Γ} → ∅ {Γ} ∂≫⋆ ∅ _,_ : ∀ {Γ Ξ A} → {σ : Γ ⊢⋆ Ξ} {ρ : Γ ∂⊩⋆ Ξ} → (χ : σ ∂≫⋆ ρ) → {M : Γ ⊢ A} {∂a : Γ ∂⊩ A} → (∂q : M ∂≫ ∂a) → σ , M ∂≫⋆ ρ , ∂a -------------------------------------------------------------------------------- -- (_∼◾≈_) mutual coe≫ : ∀ {A Γ} → {M₁ M₂ : Γ ⊢ A} → M₁ ∼ M₂ → {a : Γ ⊩ A} → M₁ ≫ a → M₂ ≫ a coe≫ {⎵} p {N} q = p ⁻¹ ⦙ q coe≫ {A ⇒ B} p {f} g = λ η {N} {∂a} ∂q → ∂coe≫ {∂a = λ η′ f′ → f η ∂a η′ f′} (ren∼ η p ∙∼ (refl∼ {M = N})) (g η {N} {∂a} ∂q) coe≫ {A ⩕ B} p {s} q = ∂coe≫ {∂a = proj₁ s} (π₁∼ p) (proj₁ q) , ∂coe≫ {∂a = proj₂ s} (π₂∼ p) (proj₂ q) coe≫ {⫪} p {s} q = tt coe≫ {⫫} p {s} q = elim⊥ s coe≫ {A ⩖ B} p {inj₁ a} q = q coe≫ {A ⩖ B} p {inj₂ b} q = q ∂coe≫ : ∀ {A Γ} → {M₁ M₂ : Γ ⊢ A} {∂a : Γ ∂⊩ A} → M₁ ∼ M₂ → M₁ ∂≫ ∂a → M₂ ∂≫ ∂a ∂coe≫ p ∂q = λ η {N} {Nⁿᶠ} f → ∂q η {N} {Nⁿᶠ} (λ η′ {a} q → f η′ (coe≫ (ren∼ (η ○ η′) p) q)) -------------------------------------------------------------------------------- -- (≈ₑ) mutual acc≫ : ∀ {A Γ Γ′} → (η : Γ′ ⊇ Γ) → {M : Γ ⊢ A} {a : Γ ⊩ A} → M ≫ a → ren η M ≫ acc η a acc≫ {⎵} η {M} {N} p = coe ((λ N′ → ren η M ∼ N′) & natembⁿᶠ η N ⁻¹) (ren∼ η p) acc≫ {A ⇒ B} η {M} {f} g η′ {N} {∂a} rewrite ren○ η′ η M ⁻¹ = g (η ○ η′) {N} {∂a} acc≫ {A ⩕ B} η {M} {s} q = ∂acc≫ η {π₁ M} {proj₁ s} (proj₁ q) , ∂acc≫ η {π₂ M} {proj₂ s} (proj₂ q) acc≫ {⫪} η {M} {s} q = tt acc≫ {⫫} η {M} {s} q = elim⊥ s acc≫ {A ⩖ B} η {M} {inj₁ a} (M₁ , ∂a) = ren η M₁ , ∂acc≫ η {M₁} {a} ∂a acc≫ {A ⩖ B} η {M} {inj₂ b} (M₂ , ∂b) = ren η M₂ , ∂acc≫ η {M₂} {b} ∂b ∂acc≫ : ∀ {A Γ Γ′} → (η : Γ′ ⊇ Γ) → {M : Γ ⊢ A} {∂a : Γ ∂⊩ A} → M ∂≫ ∂a → ren η M ∂≫ ∂acc η ∂a ∂acc≫ η {M} ∂q = λ η′ {N} {Nⁿᶠ} f → ∂q (η ○ η′) {N} {Nⁿᶠ} (λ η″ q → f η″ (coe≫ (coe (_∼_ & ((λ η‴ → ren η‴ M) & assoc○ η″ η′ η ⁻¹) ⊗ ren○ (η′ ○ η″) η M) refl∼) q)) -- (≈ᶜₑ) -- NOTE: _⬖≫_ = ∂acc≫⋆ _⬖≫_ : ∀ {Γ Γ′ Ξ} → {σ : Γ ⊢⋆ Ξ} {ρ : Γ ∂⊩⋆ Ξ} → (χ : σ ∂≫⋆ ρ) (η : Γ′ ⊇ Γ) → σ ◐ η ∂≫⋆ ρ ⬖ η ∅ ⬖≫ η = ∅ _,_ χ {M} {∂a} ∂q ⬖≫ η = χ ⬖≫ η , ∂acc≫ η {M} {∂a} ∂q -------------------------------------------------------------------------------- return≫ : ∀ {A Γ} → {M : Γ ⊢ A} {a : Γ ⊩ A} → M ≫ a → M ∂≫ return a return≫ {M = M} {a} q = λ η {N} {Nⁿᶠ} f → coe (_∼_ & idren N ⊗ embⁿᶠ & idrenⁿᶠ Nⁿᶠ) (f idₑ {acc η a} (coe≫ (coe ((λ η′ → ren η M ∼ ren η′ M) & (rid○ η ⁻¹)) refl∼) (acc≫ η {M} {a} q))) bind≫ : ∀ {A C Γ} → {M : Γ ⊢ A} {∂a : Γ ∂⊩ A} {N : Γ ⊢ C} {∂c : Γ ∂⊩ C} → M ∂≫ ∂a → (∀ {Γ′} → (η : Γ′ ⊇ Γ) → {a : Γ′ ⊩ A} → ren η M ≫ a → ren η N ∂≫ ∂acc η ∂c) → N ∂≫ ∂c bind≫ {M = M} {∂a} {N} {∂c} ∂q f = λ η {N′} {Nⁿᶠ′} f′ → ∂q η {N′} {Nⁿᶠ′} (λ η′ {a} q → f (η ○ η′) {a} q idₑ {ren η′ N′} {renⁿᶠ η′ Nⁿᶠ′} (λ η″ {c} q′ → coe (_∼_ & ren○ η″ η′ N′ ⊗ embⁿᶠ & renⁿᶠ○ η″ η′ Nⁿᶠ′) (f′ (η′ ○ η″) (coe≫ (coe (_∼_ & ren○ (idₑ ○ η″) (η ○ η′) N ⊗ (λ η‴ → ren η‴ N) & ( (λ η‴ → (η ○ η′) ○ η‴) & lid○ η″ ⦙ assoc○ η″ η′ η )) refl∼) q′)))) -------------------------------------------------------------------------------- -- (∈≈) get≫ : ∀ {Γ Ξ A} → {σ : Γ ⊢⋆ Ξ} {ρ : Γ ∂⊩⋆ Ξ} → σ ∂≫⋆ ρ → (i : Ξ ∋ A) → getₛ σ i ∂≫ getᵥ ρ i get≫ (χ , p) zero = p get≫ (χ , p) (suc i) = get≫ χ i -- (Tm≈) eval≫ : ∀ {Γ Ξ A} → {σ : Γ ⊢⋆ Ξ} {ρ : Γ ∂⊩⋆ Ξ} → σ ∂≫⋆ ρ → (M : Ξ ⊢ A) → sub σ M ∂≫ eval ρ M eval≫ {σ = σ} {ρ} χ (𝓋 i) = get≫ χ i eval≫ {σ = σ} {ρ} χ (ƛ M) = return≫ {M = ƛ (sub (liftₛ σ) M)} {a = λ {Γ′} η ∂a → eval (ρ ⬖ η , ∂a) M} (λ {Γ′} η {N} {∂a} ∂q → ∂coe≫ {∂a = eval (ρ ⬖ η , ∂a) M} (coe (((ƛ (ren (liftₑ η) (sub (liftₛ σ) M)) ∙ N) ∼_) & ( sub◑ (idₛ , N) (liftₑ η) (sub (liftₛ σ) M) ⁻¹ ⦙ sub● (liftₑ η ◑ (idₛ , N)) (liftₛ σ) M ⁻¹ ⦙ (λ σ′ → sub (σ′ , N) M) & ( comp●◑ (η ◑ idₛ , N) (wkₑ idₑ) σ ⦙ (σ ●_) & lid◑ (η ◑ idₛ) ⦙ comp●◑ idₛ η σ ⁻¹ ⦙ rid● (σ ◐ η) ) )) (red⇒ (ren (liftₑ η) (sub (liftₛ σ) M)) N) ⁻¹) (eval≫ (_,_ (χ ⬖≫ η) {∂a = ∂a} (∂q)) M)) eval≫ {σ = σ} {ρ} χ (M ∙ N) = bind≫ {M = sub σ M} {∂a = eval ρ M} {N = sub σ M ∙ sub σ N} {∂c = eval ρ M ∂!∙ eval ρ N} (eval≫ χ M) (λ η {f} g → ∂coe≫ {∂a = eval (ρ ⬖ η) M ∂!∙ eval (ρ ⬖ η) N} (coe (_∼_ & ((λ M′ → M′ ∙ ren η (sub σ N)) & ( (λ η′ → ren η′ (sub σ M)) & (rid○ η ⁻¹) ⦙ ren○ idₑ η (sub σ M) )) ⊗ refl) refl∼) (g idₑ {∂a = ∂acc η (eval ρ N)} (∂coe≫ {∂a = eval (ρ ⬖ η) N} (≡→∼ (sub◐ η σ N)) (eval≫ (χ ⬖≫ η) N)))) eval≫ {σ = σ} {ρ} χ (M , N) = return≫ {M = sub σ M , sub σ N} {a = eval ρ M , eval ρ N} ( ∂coe≫ {∂a = eval ρ M} (red⩕₁ (sub σ M) (sub σ N) ⁻¹) (eval≫ χ M) , ∂coe≫ {∂a = eval ρ N} (red⩕₂ (sub σ M) (sub σ N) ⁻¹) (eval≫ χ N) ) eval≫ {σ = σ} {ρ} χ (π₁ M) = bind≫ {M = sub σ M} {∂a = eval ρ M} {N = π₁ (sub σ M)} {∂c = ∂!π₁ (eval ρ M)} (eval≫ χ M) (λ η q → proj₁ q) eval≫ {σ = σ} {ρ} χ (π₂ M) = bind≫ {M = sub σ M} {∂a = eval ρ M} {N = π₂ (sub σ M)} {∂c = ∂!π₂ (eval ρ M)} (eval≫ χ M) (λ η q → proj₂ q) eval≫ {σ = σ} {ρ} χ τ = return≫ {M = τ} tt eval≫ {σ = σ} {ρ} χ (φ M) = bind≫ {M = sub σ M} {∂a = eval ρ M} {N = φ (sub σ M)} {∂c = ∂!φ (eval ρ M)} (eval≫ χ M) (λ η q → elim⊥ q) eval≫ {σ = σ} {ρ} χ (ι₁ M) = return≫ {M = ι₁ (sub σ M)} {a = inj₁ (eval ρ M)} (sub σ M , eval≫ χ M) eval≫ {σ = σ} {ρ} χ (ι₂ M) = return≫ {M = ι₂ (sub σ M)} {a = inj₂ (eval ρ M)} (sub σ M , eval≫ χ M) eval≫ {σ = σ} {ρ} χ (M ⁇ N₁ ∥ N₂) = bind≫ {M = sub σ M} {∂a = eval ρ M} {N = sub σ M ⁇ sub (liftₛ σ) N₁ ∥ sub (liftₛ σ) N₂} {∂c = eval ρ M ∂!⁇ (λ η ∂a → eval (ρ ⬖ η , ∂a) N₁) ∂!∥ (λ η ∂b → eval (ρ ⬖ η , ∂b) N₂)} (eval≫ χ M) (λ { η {inj₁ ∂a} (M₁ , ∂q) → λ η′ {N} {Nⁿᶠ} f → ∂q η′ {N} {Nⁿᶠ} (λ η″ {a} q → █) ; η {inj₂ ∂b} (M₂ , ∂q) → λ η′ {N} {Nⁿᶠ} f → ∂q η′ {N} {Nⁿᶠ} (λ η″ {a} q → █) }) -------------------------------------------------------------------------------- mutual -- (q≈) reify≫ : ∀ {A Γ} → {M : Γ ⊢ A} {a : Γ ∂⊩ A} → (∂q : M ∂≫ a) → M ∼ embⁿᶠ (reify a) reify≫ {⎵} {M = M} {∂a} ∂q = ∂q idₑ {M} {reify ∂a} (λ η {N} p → █) reify≫ {A ⇒ B} {M = M} {∂a} ∂q = ∂q idₑ {M} {reify ∂a} (λ η {f} g → █) reify≫ {A ⩕ B} {M = M} {∂a} ∂q = ∂q idₑ {M} {reify ∂a} (λ η {s} q → █) reify≫ {⫪} {M = M} {∂a} ∂q = ∂q idₑ {M} {reify ∂a} (λ η {s} q → coe ((λ M′ → ren η M ∼ M′) & natembⁿᶠ η (∂a idₑ (λ η′ s′ → τ)) ⁻¹) (ren∼ {M₁ = M} {M₂ = embⁿᶠ (∂a idₑ (λ η′ s′ → τ))} η █)) reify≫ {⫫} {M = M} {∂a} ∂q = ∂q idₑ {M} {reify ∂a} (λ η {s} q → █) reify≫ {A ⩖ B} {M = M} {∂a} ∂q = ∂q idₑ {M} {reify ∂a} (λ η {s} q → █) -- (u≈) reflect≫ : ∀ {A Γ} → (M : Γ ⊢ⁿᵉ A) → embⁿᵉ M ∂≫ reflect M reflect≫ {⎵} M = return≫ {M = embⁿᵉ M} {a = ne M} refl∼ reflect≫ {A ⇒ B} M = return≫ {M = embⁿᵉ M} {a = λ η ∂a → reflect (renⁿᵉ η M ∙ reify ∂a)} (λ η {N} {∂a} ∂q → ∂coe≫ {∂a = ∂acc η (reflect M) ∂!∙ ∂a} (≡→∼ (natembⁿᵉ η M ⁻¹) ∙∼ reify≫ ∂q ⁻¹) (reflect≫ (renⁿᵉ η M ∙ reify ∂a))) reflect≫ {A ⩕ B} M = return≫ {M = embⁿᵉ M} {a = reflect (π₁ M) , reflect (π₂ M)} (reflect≫ (π₁ M) , reflect≫ (π₂ M)) reflect≫ {⫪} M = return≫ {M = embⁿᵉ M} {a = tt} tt reflect≫ {⫫} M = λ η {N} {Nⁿᶠ} f → coe (_∼_ & idren N ⊗ embⁿᶠ & idrenⁿᶠ Nⁿᶠ) (f idₑ {█} █) reflect≫ {A ⩖ B} M = λ η {N} {Nⁿᶠ} f → coe (_∼_ & idren N ⊗ embⁿᶠ & idrenⁿᶠ Nⁿᶠ) (f idₑ {█} █) -------------------------------------------------------------------------------- -- (uᶜ≈) id≫⋆ : ∀ {Γ} → idₛ {Γ} ∂≫⋆ idᵥ id≫⋆ {∅} = ∅ id≫⋆ {Γ , A} = id≫⋆ ⬖≫ wkₑ idₑ , reflect≫ 0 complete : ∀ {Γ A} → (M : Γ ⊢ A) → M ∼ embⁿᶠ (nf M) complete M = coe ((_∼ embⁿᶠ (reify (eval idᵥ M))) & idsub M) (reify≫ (eval≫ id≫⋆ M)) --------------------------------------------------------------------------------
{ "alphanum_fraction": 0.2457585644, "avg_line_length": 30.4975124378, "ext": "agda", "hexsha": "f15801140f7a3c690a4df891c5e41c436d911379", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/coquand-kovacs", "max_forks_repo_path": "src/STLC2/Kovacs/Completeness.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/coquand-kovacs", "max_issues_repo_path": "src/STLC2/Kovacs/Completeness.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/coquand-kovacs", "max_stars_repo_path": "src/STLC2/Kovacs/Completeness.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5747, "size": 12260 }
-- Andreas, 2010-09-24 module ParseForallAbsurd where parseFails : forall () -> Set1 parseFails x = Set -- this does no longer give the error message -- "absurd lambda cannot have a body"
{ "alphanum_fraction": 0.7315789474, "avg_line_length": 21.1111111111, "ext": "agda", "hexsha": "294ff4ff76ea1f9f01c2339399de59d3177bd729", "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/ParseForallAbsurd.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/ParseForallAbsurd.agda", "max_line_length": 45, "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/ParseForallAbsurd.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": 56, "size": 190 }
-- 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.Integer as ℤ using (ℤ) open import Data.List open import Data.List.Relation.Unary.All as List module quantifierIn-output where private VEHICLE_PROJECT_FILE = "TODO_projectFile" emptyList : List ℤ emptyList = [] abstract empty : List.All (λ (x : ℤ) → ⊤) emptyList empty = checkProperty record { projectFile = VEHICLE_PROJECT_FILE ; propertyUUID = "TODO_propertyUUID" }
{ "alphanum_fraction": 0.7121661721, "avg_line_length": 23.2413793103, "ext": "agda", "hexsha": "18151dfc1725840d94ba9c955f3b948bc9c719f9", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2021-11-16T14:30:47.000Z", "max_forks_repo_forks_event_min_datetime": "2021-03-15T15:22:31.000Z", "max_forks_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "wenkokke/vehicle", "max_forks_repo_path": "examples/simple/quantifierIn/quantifierIn-output.agda", "max_issues_count": 53, "max_issues_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674", "max_issues_repo_issues_event_max_datetime": "2021-12-15T22:42:01.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-16T07:26:42.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "wenkokke/vehicle", "max_issues_repo_path": "examples/simple/quantifierIn/quantifierIn-output.agda", "max_line_length": 60, "max_stars_count": 11, "max_stars_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "wenkokke/vehicle", "max_stars_repo_path": "examples/simple/quantifierIn/quantifierIn-output.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T01:35:39.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-24T05:55:15.000Z", "num_tokens": 188, "size": 674 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Base open import lib.PathGroupoid open import lib.Relation module lib.NType where module _ {i} where {- Definition of contractible types and truncation levels -} -- We define `has-level' as a record, so that it does not unfold when -- applied to (S n), in order for instance arguments to work correctly -- (idea by Dan Licata) record has-level (n : ℕ₋₂) (A : Type i) : Type i has-level-aux : ℕ₋₂ → (Type i → Type i) has-level-aux ⟨-2⟩ A = Σ A (λ x → ((y : A) → x == y)) has-level-aux (S n) A = (x y : A) → has-level n (x == y) record has-level n A where -- Agda notices that the record is recursive, so we need to specify that we want eta-equality inductive eta-equality constructor has-level-in field has-level-apply : has-level-aux n A open has-level public instance has-level-apply-instance : {A : Type i} {n : ℕ₋₂} {x y : A} {{p : has-level (S n) A}} → has-level n (x == y) has-level-apply-instance {x = x} {y} {{p}} = has-level-apply p x y is-contr = has-level -2 is-prop = has-level -1 is-set = has-level 0 contr-center : {A : Type i} (p : is-contr A) → A contr-center p = fst (has-level-apply p) contr-path : {A : Type i} (p : is-contr A) (y : A) → contr-center p == y contr-path p y = snd (has-level-apply p) y prop-path : {A : Type i} (p : is-prop A) (x y : A) → x == y prop-path p x y = contr-center (has-level-apply p x y) {- To be a mere proposition, it is sufficient that all points are equal -} has-all-paths : Type i → Type i has-all-paths A = (x y : A) → x == y abstract all-paths-is-prop : {A : Type i} → (has-all-paths A → is-prop A) all-paths-is-prop {A} c = has-level-in (λ x y → has-level-in (c x y , canon-path)) where canon-path : {x y : A} (p : x == y) → c x y == p canon-path {.y} {y} idp = c y y =⟨ lemma (! (c y y)) ⟩ (! (c y y)) ∙ c y y =⟨ !-inv-l (c y y) ⟩ idp =∎ where lemma : {x y : A} (p : x == y) → c x y == p ∙ c y y lemma idp = idp {- Truncation levels are cumulative -} raise-level : {A : Type i} (n : ℕ₋₂) → (has-level n A → has-level (S n) A) raise-level ⟨-2⟩ q = all-paths-is-prop (λ x y → ! (contr-path q x) ∙ contr-path q y) raise-level (S n) q = has-level-in (λ x y → raise-level n (has-level-apply q x y)) {- Having decidable equality is stronger that being a set -} has-dec-onesided-eq : {A : Type i} → A → Type i has-dec-onesided-eq x = ∀ y → Dec (x == y) has-dec-eq : Type i → Type i has-dec-eq A = (x : A) → has-dec-onesided-eq x abstract -- XXX naming dec-onesided-eq-is-prop : {A : Type i} (x : A) → has-dec-onesided-eq x → (∀ y → is-prop (x == y)) dec-onesided-eq-is-prop {A} x d y = all-paths-is-prop UIP where T : {y : A} → x == y → Type i T {y} p with d x | d y T {y} p | inr _ | _ = Lift ⊥ T {y} p | inl _ | inr _ = Lift ⊥ T {y} p | inl dx | inl dy = ! dx ∙ dy == p lemma : {y : A} → (p : x == y) → T p lemma idp with d x lemma idp | inl r = !-inv-l r lemma idp | inr r⊥ = lift (r⊥ idp) UIP : {y : A} (p q : x == y) → p == q UIP idp q with d x | lemma q UIP idp q | inl r | s = ! (!-inv-l r) ∙' s UIP idp q | inr r⊥ | _ = Empty-elim (r⊥ idp) dec-eq-is-set : {A : Type i} → has-dec-eq A → is-set A dec-eq-is-set d = has-level-in (λ x y → dec-onesided-eq-is-prop x (d x) y) {- Relationships between levels -} module _ {A : Type i} where abstract contr-has-all-paths : {{_ : is-contr A}} → has-all-paths A contr-has-all-paths {{c}} x y = ! (contr-path c x) ∙ contr-path c y prop-has-all-paths : {{_ : is-prop A}} → has-all-paths A prop-has-all-paths {{c}} x y = prop-path c x y inhab-prop-is-contr : A → {{_ : is-prop A}} → is-contr A inhab-prop-is-contr x₀ {{p}} = has-level-in (x₀ , λ y → prop-path p x₀ y) inhab-to-contr-is-prop : (A → is-contr A) → is-prop A inhab-to-contr-is-prop c = all-paths-is-prop $ λ x y → ! (contr-path (c x) x) ∙ contr-path (c x) y inhab-to-prop-is-prop : (A → is-prop A) → is-prop A inhab-to-prop-is-prop c = has-level-in (λ x y → has-level-apply (c x) x y) contr-has-level : {n : ℕ₋₂} → (is-contr A → has-level n A) contr-has-level {n = ⟨-2⟩} p = p contr-has-level {n = S n} p = raise-level n (contr-has-level p) prop-has-level-S : {n : ℕ₋₂} → (is-prop A → has-level (S n) A) prop-has-level-S {n = ⟨-2⟩} p = p prop-has-level-S {n = S n} p = raise-level (S n) (prop-has-level-S p) set-has-level-SS : {n : ℕ₋₂} → (is-set A → has-level (S (S n)) A) set-has-level-SS {n = ⟨-2⟩} p = p set-has-level-SS {n = S n} p = raise-level (S (S n)) (set-has-level-SS p) contr-is-prop : is-contr A → is-prop A contr-is-prop = contr-has-level contr-is-set : is-contr A → is-set A contr-is-set = contr-has-level prop-is-set : is-prop A → is-set A prop-is-set = prop-has-level-S =-preserves-contr : {x y : A} → is-contr A → is-contr (x == y) =-preserves-contr p = has-level-in (contr-has-all-paths {{p}} _ _ , unique-path) where unique-path : {u v : A} (q : u == v) → contr-has-all-paths {{p}} u v == q unique-path idp = !-inv-l (contr-path p _) {- If [A] has level [n], then so does [x == y] for [x y : A] -} instance =-preserves-level : {n : ℕ₋₂} {x y : A} → has-level n A → has-level n (x == y) =-preserves-level {⟨-2⟩} = =-preserves-contr =-preserves-level {S n} {x} {y} p = raise-level n (has-level-apply p x y) {- The type of paths from a fixed point is contractible -} instance pathfrom-is-contr : (x : A) → is-contr (Σ A (λ t → x == t)) pathfrom-is-contr x = has-level-in ((x , idp) , pathfrom-unique-path) where pathfrom-unique-path : {u : A} (pp : Σ A (λ t → u == t)) → (u , idp) == pp pathfrom-unique-path (u , idp) = idp {- The type of paths to a fixed point is contractible -} instance pathto-is-contr : (x : A) → is-contr (Σ A (λ t → t == x)) pathto-is-contr x = has-level-in ((x , idp) , pathto-unique-path) where pathto-unique-path : {u : A} (pp : Σ A (λ t → t == u)) → (u , idp) == pp pathto-unique-path (u , idp) = idp {- If [B] is a fibration over a contractible type [A], then any point in any fiber of [B] gives a section -} contr-has-section : ∀ {j} {A : Type i} {B : A → Type j} → (is-contr A → (x : A) → (u : B x) → Π A B) contr-has-section {B = B} p x₀ y₀ t = transport B (! (contr-path p x₀) ∙ contr-path p t) y₀ {- Subtypes -} -- TODO: replace them by records, with the second field an instance field module _ {i} (A : Type i) where SubtypeProp : ∀ j → Type (lmax i (lsucc j)) SubtypeProp j = Σ (A → Type j) (λ P → ∀ a → is-prop (P a)) module SubtypeProp {i j} {A : Type i} (P : SubtypeProp A j) where prop = fst P level = snd P module _ {i j} {A : Type i} (P : SubtypeProp A j) where private module P = SubtypeProp P Subtype : Type (lmax i j) Subtype = Σ A P.prop
{ "alphanum_fraction": 0.5442722745, "avg_line_length": 35.960199005, "ext": "agda", "hexsha": "73cfc30dbed576691f336f376e325d8df14829ae", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "core/lib/NType.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "core/lib/NType.agda", "max_line_length": 112, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "core/lib/NType.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2619, "size": 7228 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import cw.CW open import cw.FinCW open import cw.FinBoundary open import cohomology.Theory module cw.cohomology.cochainequiv.DualizedHigherBoundary (OT : OrdinaryTheory lzero) {n} (⊙fin-skel : ⊙FinSkeleton (S (S n))) where open OrdinaryTheory OT private fin-skel = ⊙FinSkeleton.skel ⊙fin-skel I = AttachedFinSkeleton.numCells fin-skel fin-skel₋₁ = AttachedFinSkeleton.skel fin-skel I₋₁ = AttachedFinSkeleton.numCells fin-skel₋₁ module FAG = FreeAbelianGroup (Fin I) module FAG₋₁ = FreeAbelianGroup (Fin I₋₁) open FAG renaming (FreeAbGroup to G) using () open FAG₋₁ renaming (FreeAbGroup to G₋₁) using () abstract rephrase-dualized-higher-boundary-in-degree : ∀ (g : Fin I₋₁ → Group.El (C2 0)) <I → GroupIso.g (FAG.Freeness.extend-iso (C2-abgroup 0)) (GroupIso.f (FAG₋₁.Freeness.extend-iso (C2-abgroup 0)) g ∘ᴳ fboundary-last fin-skel) <I == Group.sum (C2 0) (λ <I₋₁ → Group.exp (C2 0) (g <I₋₁) (fdegree-last fin-skel <I <I₋₁)) rephrase-dualized-higher-boundary-in-degree g <I = γ.f (GroupHom.f (fboundary-last fin-skel) (FAG.insert <I)) =⟨ ap γ.f $ app= (is-equiv.g-f (snd (FAG.Freeness.extend-equiv G₋₁)) (fboundary'-last fin-skel)) <I ⟩ γ.f (G₋₁.sum (λ <I₋₁ → G₋₁.exp (FAG₋₁.insert <I₋₁) (deg <I₋₁))) =⟨ γ.pres-sum (λ <I₋₁ → G₋₁.exp (FAG₋₁.insert <I₋₁) (deg <I₋₁)) ⟩ C⁰2.sum (λ <I₋₁ → γ.f (G₋₁.exp (FAG₋₁.insert <I₋₁) (deg <I₋₁))) =⟨ ap C⁰2.sum (λ= $ λ <I₋₁ → γ.pres-exp (FAG₋₁.insert <I₋₁) (deg <I₋₁)) ⟩ C⁰2.sum (λ <I₋₁ → C⁰2.exp (γ.f (FAG₋₁.insert <I₋₁)) (deg <I₋₁)) =⟨ ap C⁰2.sum (λ= λ <I₋₁ → ap (λ g → C⁰2.exp g (deg <I₋₁)) $ app= (is-equiv.g-f (snd (FAG₋₁.Freeness.extend-equiv C⁰2)) g) <I₋₁) ⟩ C⁰2.sum (λ <I₋₁ → C⁰2.exp (g <I₋₁) (deg <I₋₁)) =∎ where deg : Fin I₋₁ → ℤ deg <I₋₁ = fdegree-last fin-skel <I <I₋₁ C⁰2 : AbGroup lzero C⁰2 = C2-abgroup 0 module C⁰2 = AbGroup C⁰2 γ : G₋₁.grp →ᴳ C⁰2.grp γ = FAG₋₁.Freeness.extend C⁰2 g module γ = GroupHom γ
{ "alphanum_fraction": 0.608778626, "avg_line_length": 38.8148148148, "ext": "agda", "hexsha": "d73918b5a3e922055cb96c89b27f92b1bd817880", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AntoineAllioux/HoTT-Agda", "max_forks_repo_path": "theorems/cw/cohomology/cochainequiv/DualizedHigherBoundary.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "AntoineAllioux/HoTT-Agda", "max_issues_repo_path": "theorems/cw/cohomology/cochainequiv/DualizedHigherBoundary.agda", "max_line_length": 107, "max_stars_count": 294, "max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AntoineAllioux/HoTT-Agda", "max_stars_repo_path": "theorems/cw/cohomology/cochainequiv/DualizedHigherBoundary.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 913, "size": 2096 }
open import Common.Prelude pattern [_] x = x ∷ [] pattern tail {x} xs = x ∷ xs length : ∀ {A} → List A → Nat length [] = 0 length [ _ ] = 1 length (tail [ _ ]) = 2 length (tail (tail xs)) = 2 + length xs data Vec (A : Set) : Nat → Set where nil : Vec A 0 cons : ∀ n → A → Vec A n → Vec A (suc n) pattern _∷v_ {n} x xs = cons n x xs map : ∀ {A B n} → (A → B) → Vec A n → Vec B n map f nil = nil map f (x ∷v xs) = f x ∷v map f xs data SomeVec (A : Set) : Set where someVec : ∀ n → Vec A n → SomeVec A pattern some {n} xs = someVec n xs null : ∀ {A} → SomeVec A → Bool null (some nil) = true null (some (_ ∷v _)) = false -- check that the hidden arg can be instantiated to a dot pattern
{ "alphanum_fraction": 0.5673758865, "avg_line_length": 22.7419354839, "ext": "agda", "hexsha": "0ba2690dcc8d6b793a16dc58b7c7f3b00d68a194", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/Issue860.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/Issue860.agda", "max_line_length": 95, "max_stars_count": 1, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/succeed/Issue860.agda", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "num_tokens": 270, "size": 705 }
{-# OPTIONS --without-K #-} module hott.core.univalence where open import hott.core.universe open import hott.functions open import hott.core.equality open import hott.core.sigma -- The core idea of univalence is to "identify" isomorphic types as -- equal. Of course the normal definition of isomorphism is that there -- should be a map from A to B that is witnesses the equivalence of the -- two type. This is captured by the following record. record _≃_ {a b : Level}(A : Type a)(B : Type b) : Type (a ⊔ b) where constructor IdentifyTypesVia field equiv : (A → B) -- The equivalence left-inv : (B → A) -- its left inverse right-inv : (B → A) -- and its right inverse -- The proofs of the fact that the left and right inverses are actually -- left and right inverses. left-inv∘equiv~idA : left-inv ∘ equiv ~ id iso∘right-equiv~idB : equiv ∘ right-inv ~ id -- Of course a type should be equivalent to itself via identity. A≃A : {ℓ : Level}{A : Type ℓ} → A ≃ A A≃A {ℓ} {A} = IdentifyTypesVia id id id (λ _ → refl) (λ _ → refl) -- Equal types are equivalent. ≡→≃ : {ℓ : Level}{A B : Type ℓ} → A ≡ B → A ≃ B ≡→≃ refl = A≃A -- For the converse we need the univalence. However Univalence says -- something. Not only can we infer A ≡ B from A ≃ B via the postulate -- ua, this map together with ≡→≃ gives an equivalence of types. module Univalence {ℓ : Level}{A B : Type ℓ} where -- The main axiom is to identify A ≃ B with A ≡ B postulate ua : A ≃ B → A ≡ B -- Now we are ready for the univalence axiom. UnivalenceAxiom : (A ≃ B) ≃ (A ≡ B) UnivalenceAxiom = IdentifyTypesVia ua ≡→≃ ≡→≃ linv-prf rinv-prf where postulate rinv-prf : ua ∘ ≡→≃ ~ id postulate linv-prf : ≡→≃ ∘ ua ~ id -- The next function helps in clean use of the univalence -- axioms in equational reasoning. -- -- -- begin ... -- ≡ B by univalence -- ... -- -- provided an appropriate instance of A ≃ B is available in the -- vicinity. -- univalence : ⦃ a≃b : A ≃ B ⦄ → A ≡ B univalence ⦃ a≃b ⦄ = ua a≃b open Univalence public
{ "alphanum_fraction": 0.6368794326, "avg_line_length": 32.0454545455, "ext": "agda", "hexsha": "5ec7c02e47dc7dc040ab8ab4430fb9e4f77c4924", "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": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_path": "agda/hott/core/univalence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "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": "piyush-kurur/hott", "max_issues_repo_path": "agda/hott/core/univalence.agda", "max_line_length": 75, "max_stars_count": null, "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_path": "agda/hott/core/univalence.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 696, "size": 2115 }
-- The category Ab of abelian groups {-# OPTIONS --safe #-} module Cubical.Categories.Instances.AbGroups where open import Cubical.Algebra.AbGroup.Base open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Categories.Category.Base open import Cubical.Foundations.Prelude module _ {ℓ : Level} where open Category AbGroupCategory : Category (ℓ-suc ℓ) ℓ AbGroupCategory .ob = AbGroup ℓ AbGroupCategory .Hom[_,_] = AbGroupHom AbGroupCategory .id = idGroupHom AbGroupCategory ._⋆_ = compGroupHom AbGroupCategory .⋆IdL f = GroupHom≡ refl AbGroupCategory .⋆IdR f = GroupHom≡ refl AbGroupCategory .⋆Assoc f g h = GroupHom≡ refl AbGroupCategory .isSetHom = isSetGroupHom
{ "alphanum_fraction": 0.769121813, "avg_line_length": 29.4166666667, "ext": "agda", "hexsha": "59205e29633e7e812a73cfbe1fe4544e55b50e43", "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": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Seanpm2001-web/cubical", "max_forks_repo_path": "Cubical/Categories/Instances/AbGroups.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "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": "Seanpm2001-web/cubical", "max_issues_repo_path": "Cubical/Categories/Instances/AbGroups.agda", "max_line_length": 52, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "FernandoLarrain/cubical", "max_stars_repo_path": "Cubical/Categories/Instances/AbGroups.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z", "num_tokens": 214, "size": 706 }
------------------------------------------------------------------------ -- A total parser combinator library -- -- Nils Anders Danielsson ------------------------------------------------------------------------ module TotalParserCombinators where -- Check out TotalRecognisers for an introduction to the ideas used -- below in the simplified setting of recognisers (as opposed to -- parsers). import TotalRecognisers -- The parser type, and its semantics. import TotalParserCombinators.Parser import TotalParserCombinators.Semantics -- Forcing of parsers (can be used for inspection/debugging purposes). import TotalParserCombinators.Force -- Some lemmas about initial bags. import TotalParserCombinators.InitialBag -- A small library of derived parser combinators. import TotalParserCombinators.Lib -- A Brzozowski derivative operator for parsers. import TotalParserCombinators.Derivative -- A breadth-first backend, based on the derivative operator. import TotalParserCombinators.BreadthFirst -- An alternative, coinductive definition of equality (and related -- orderings) between parsers. import TotalParserCombinators.CoinductiveEquality -- Language equivalence and parser equivalence are both congruences. -- The various orderings are compatible preorders. import TotalParserCombinators.Congruence import TotalParserCombinators.Congruence.Sound -- However, it is possible to construct combinators which do not -- preserve equality. import TotalParserCombinators.NotACongruence -- Proofs of various laws, for instance the monad laws. import TotalParserCombinators.Laws -- A proof showing that all functions of type List Bool → List R can -- be realised using parser combinators (for any R, assuming that bag -- equality is used for the lists of results). import TotalParserCombinators.ExpressiveStrength -- Definitions of asymmetric choice, and and not. Note that no -- extension of the library is required to define these combinators, -- which make use of a general operator which lifts initial bag -- operations to parsers. This operator is defined using the -- breadth-first backend's derivative operator. import TotalParserCombinators.Pointwise import TotalParserCombinators.AsymmetricChoice import TotalParserCombinators.And import TotalParserCombinators.Not -- A lookahead operator cannot be defined. import TotalParserCombinators.NoLookahead -- An alternative semantics. import TotalParserCombinators.Semantics.Continuation -- Simplification of parsers. import TotalParserCombinators.Simplification -- Definition of unambiguity. import TotalParserCombinators.Unambiguity -- An example: a left recursive expression grammar. import TotalParserCombinators.Examples.Expression -- Recognisers defined on top of the parsers, and a variant of the -- left recursive expression grammar mentioned above. import TotalParserCombinators.Recogniser import TotalParserCombinators.Recogniser.Expression -- Another example: parsing PBM image files. import TotalParserCombinators.Examples.PBM -- An extended example: mixfix operator parsing. import Mixfix -- For code related to the paper "Structurally Recursive Descent -- Parsing", developed together with Ulf Norell, see the following -- module: import StructurallyRecursiveDescentParsing
{ "alphanum_fraction": 0.7821450335, "avg_line_length": 28.2931034483, "ext": "agda", "hexsha": "be0c02fae828ffc7bbd8a256a05e843f7e092dd8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "TotalParserCombinators.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "TotalParserCombinators.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/parser-combinators", "max_stars_repo_path": "TotalParserCombinators.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": 687, "size": 3282 }
{- Reported by Nils Anders Danielsson, 2011-07-06 From the release notes for Agda 2.2.10: "Projections now preserve sizes, both in patterns and expressions." However, the following code is rejected: -} module SubTermAndProjections where record _×_ (A B : Set) : Set where constructor _,_ field proj₁ : A proj₂ : B open _×_ postulate i : {A : Set} → A → A data I : Set where c1 : I → I c2 : I → I → I data D : I → Set where d : (j : I × I) → D (c1 (proj₁ j)) → D (proj₂ j) → D (c2 (c1 (proj₁ j)) (proj₂ j)) f : ∀ i → D i → Set f .(c2 (c1 (proj₁ j)) (proj₂ j)) (d j l r) = f (c1 (proj₁ j)) (i l) {- Is this intentional? I guess the issue here is the subterm relation rather than the sizes. Should we modify the subterm relation? -} -- Andreas, 2011-07-07 this should termination check.
{ "alphanum_fraction": 0.635250918, "avg_line_length": 22.0810810811, "ext": "agda", "hexsha": "31d4b43abe2091d43e68a30dd6d870497432b79a", "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/SubTermAndProjections.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/SubTermAndProjections.agda", "max_line_length": 85, "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/SubTermAndProjections.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": 287, "size": 817 }
open import Agda.Primitive using (_⊔_) open import Categories.Category open import Categories.Functor open import Categories.Monad.Relative module SecondOrder.RelativeKleisli {o l e o' l' e'} {𝒞 : Category o l e} {𝒟 : Category o' l' e'} {J : Functor 𝒞 𝒟} (M : Monad J) where Kleisli : Category o l' e' Kleisli = let open Category in let open Functor in record { Obj = Obj 𝒞 ; _⇒_ = λ A B → 𝒟 [ F₀ J A , Monad.F₀ M B ] ; _≈_ = _≈_ 𝒟 ; id = Monad.unit M ; _∘_ = λ f g → _∘_ 𝒟 (Monad.extend M f) g ; assoc = λ {A} {B} {C} {D} {f} {g} {h} → Equiv.trans 𝒟 (∘-resp-≈ˡ 𝒟 (Monad.assoc M)) (assoc 𝒟) ; sym-assoc = λ {A} {B} {C} {D} {f} {g} {h} → Equiv.sym 𝒟 (Equiv.trans 𝒟 (∘-resp-≈ˡ 𝒟 (Monad.assoc M)) (assoc 𝒟)) ; identityˡ = λ {A} {B} {f} → Equiv.trans 𝒟 (∘-resp-≈ˡ 𝒟 (Monad.identityˡ M)) (identityˡ 𝒟) ; identityʳ = λ {A} {B} {f} → Monad.identityʳ M ; identity² = λ {A} → Equiv.trans 𝒟 ((∘-resp-≈ˡ 𝒟 (Monad.identityˡ M))) (identityˡ 𝒟) ; equiv = equiv 𝒟 ; ∘-resp-≈ = λ p₁ p₂ → ∘-resp-≈ 𝒟 (Monad.extend-≈ M p₁) p₂ }
{ "alphanum_fraction": 0.4971659919, "avg_line_length": 34.3055555556, "ext": "agda", "hexsha": "810e0272e60b95a141b624b9c583e9ffca62825e", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z", "max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z", "max_forks_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/formaltt", "max_forks_repo_path": "src/SecondOrder/RelativeKleisli.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejbauer/formaltt", "max_issues_repo_path": "src/SecondOrder/RelativeKleisli.agda", "max_line_length": 91, "max_stars_count": 21, "max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cilinder/formaltt", "max_stars_repo_path": "src/SecondOrder/RelativeKleisli.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-19T15:50:08.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-16T14:07:06.000Z", "num_tokens": 510, "size": 1235 }