Search is not available for this dataset
text
string
meta
dict
module L.Base.Sigma.Properties where open import L.Base.Sigma.Core choice : ∀{a b c} {A : Set a} {B : Set b} → {C : A → B → Set c} → ((x : A) → Σ B (λ y → C x y)) → Σ (A → B) (λ f → (a : A) → C a (f a)) choice = λ F → ((λ x → fst (F x)) , λ a → snd (F a))
{ "alphanum_fraction": 0.4606741573, "avg_line_length": 33.375, "ext": "agda", "hexsha": "552687620d8a5dc2566bd36f3a88ce5f952f3837", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "borszag/smallib", "max_forks_repo_path": "src/L/Base/Sigma/Properties.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_issues_repo_issues_event_max_datetime": "2020-11-09T16:40:39.000Z", "max_issues_repo_issues_event_min_datetime": "2020-10-19T10:13:16.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "borszag/smallib", "max_issues_repo_path": "src/L/Base/Sigma/Properties.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "borszag/smallib", "max_stars_repo_path": "src/L/Base/Sigma/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 113, "size": 267 }
open import Data.Product using ( ∃ ; _×_ ; _,_ ) open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl ) open import Relation.Nullary using ( ¬_ ) open import Relation.Unary using ( _∈_ ; ∅ ) open import Web.Semantic.DL.Signature using ( Signature ; CN ; RN ) open import Web.Semantic.Util using ( Setoid ; Subset ; _∘_ ; False ) module Web.Semantic.DL.TBox.Interp where data Interp (Σ : Signature) : Set₁ where interp : (Δ : Set) → (_≈_ : Δ → Δ → Set) → (ref : ∀ {x} → (x ≈ x)) → (sym : ∀ {x y} → (x ≈ y) → (y ≈ x)) → (trans : ∀ {x y z} → (x ≈ y) → (y ≈ z) → (x ≈ z)) → (con : CN Σ → Subset Δ) → (rol : RN Σ → Subset (Δ × Δ)) → (con-≈ : ∀ {x y} c → (x ∈ con c) → (x ≈ y) → (y ∈ con c)) → (rol-≈ : ∀ {w x y z} r → (w ≈ x) → ((x , y) ∈ rol r) → (y ≈ z) → ((w , z) ∈ rol r)) → Interp Σ Δ : ∀ {Σ} → Interp Σ → Set Δ (interp Δ _≈_ ref sym trans con rol con-≈ rol-≈) = Δ _⊨_≈_ : ∀ {Σ} → (I : Interp Σ) → (Δ I) → (Δ I) → Set _⊨_≈_ (interp Δ _≈_ ref sym trans con rol con-≈ rol-≈) = _≈_ ≈-refl : ∀ {Σ} → (I : Interp Σ) → ∀ {x} → (I ⊨ x ≈ x) ≈-refl (interp Δ _≈_ ref sym trans con rol con-≈ rol-≈) = ref ≈-sym : ∀ {Σ} → (I : Interp Σ) → ∀ {x y} → (I ⊨ x ≈ y) → (I ⊨ y ≈ x) ≈-sym (interp Δ _≈_ ref sym trans con rol con-≈ rol-≈) = sym ≈-trans : ∀ {Σ} → (I : Interp Σ) → ∀ {x y z} → (I ⊨ x ≈ y) → (I ⊨ y ≈ z) → (I ⊨ x ≈ z) ≈-trans (interp Δ _≈_ ref sym trans con rol con-≈ rol-≈) = trans con : ∀ {Σ} → (I : Interp Σ) → CN Σ → Subset (Δ I) con (interp Δ _≈_ ref sym trans con rol con-≈ rol-≈) = con rol : ∀ {Σ} → (I : Interp Σ) → RN Σ → Subset (Δ I × Δ I) rol (interp Δ _≈_ ref sym trans con rol con-≈ rol-≈) = rol con-≈ : ∀ {Σ} → (I : Interp Σ) → ∀ {x y} c → (x ∈ con I c) → (I ⊨ x ≈ y) → (y ∈ con I c) con-≈ (interp Δ _≈_ ref sym trans con rol con-≈ rol-≈) = con-≈ rol-≈ : ∀ {Σ} → (I : Interp Σ) → ∀ {w x y z} r → (I ⊨ w ≈ x) → ((x , y) ∈ rol I r) → (I ⊨ y ≈ z) → ((w , z) ∈ rol I r) rol-≈ (interp Δ _≈_ ref sym trans con rol con-≈ rol-≈) = rol-≈ _⊨_≉_ : ∀ {Σ} → (I : Interp Σ) → (Δ I) → (Δ I) → Set I ⊨ x ≉ y = ¬(I ⊨ x ≈ y) emp : ∀ {Σ} → Interp Σ emp = interp False (λ ()) (λ {}) (λ {}) (λ {}) (λ c → ∅) (λ r → ∅) (λ {}) (λ {}) ≈-refl′ : ∀ {Σ} (I : Interp Σ) → ∀ {x y} → (x ≡ y) → (I ⊨ x ≈ y) ≈-refl′ I refl = ≈-refl I
{ "alphanum_fraction": 0.4700742682, "avg_line_length": 39.4655172414, "ext": "agda", "hexsha": "f5519c54f5721336a54a37dd298f1bd1a1f13cdb", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z", "max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z", "max_forks_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-web-semantic", "max_forks_repo_path": "src/Web/Semantic/DL/TBox/Interp.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-web-semantic", "max_issues_repo_path": "src/Web/Semantic/DL/TBox/Interp.agda", "max_line_length": 118, "max_stars_count": 9, "max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-web-semantic", "max_stars_repo_path": "src/Web/Semantic/DL/TBox/Interp.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z", "num_tokens": 1139, "size": 2289 }
module InductiveAndCoinductiveConstructors where open import Common.Coinduction record ⊤ : Set where data _×_ (A : Set) (B : Set) : Set where _,_ : (x : A) (y : B) → A × B data Stream (A : Set) : Set where _≺_ : (x : A) (xs : ∞ (Stream A)) → Stream A data U : Set where stream : (a : U) → U _⊗_ : (a b : U) → U unit : U El : U → Set El (stream a) = Stream (El a) El (a ⊗ b) = El a × El b El unit = ⊤ mutual data WHNF : U → Set where _≺_ : ∀ {a} → El a → Prog (stream a) → WHNF (stream a) _,_ : ∀ {a b} → WHNF a → WHNF b → WHNF (a ⊗ b) data Prog : U → Set where ↓_ : ∀ {a} → ∞ (WHNF a) → Prog a fst : ∀ {a b} → Prog (a ⊗ b) → Prog a snd : ∀ {a b} → Prog (a ⊗ b) → Prog b lab : Prog (stream unit) → Prog (stream (stream unit)) → Prog (stream unit ⊗ stream (stream unit)) whnf : ∀ {a} → Prog a → WHNF a whnf (↓ w) = ♭ w whnf (fst p) with whnf p ... | (x , y) = x whnf (snd p) with whnf p ... | (x , y) = y whnf (lab xs lss) with whnf xs | whnf lss ... | _ ≺ xs′ | (x ≺ ls) ≺ lss′ = ((_ ≺ fst (lab xs′ lss′)) , (♭ ls ≺ snd (lab xs′ lss′))) ⟦_⟧ : Prog (stream unit) → Stream ⊤ ⟦ p ⟧ with whnf p ... | x ≺ xs = x ≺ ♯ ⟦ xs ⟧ data _≈_ : Stream ⊤ → Stream ⊤ → Set where cons : ∀ {xs xs′} → ∞ ((♭ xs) ≈ (♭ xs′)) → (_ ≺ xs) ≈ (_ ≺ xs′) lemma : ∀ xs lss → ⟦ fst (lab xs lss) ⟧ ≈ ⟦ xs ⟧ lemma xs lss with whnf xs | whnf lss ... | _ ≺ xs′ | (x ≺ ls) ≺ lss′ = cons (♯ lemma xs′ lss′) label : Prog (stream unit) → Stream ⊤ → Prog (stream unit ⊗ stream (stream unit)) label xs ls = lab xs (↓ (♯ (ls ≺ snd (label xs ls)))) shape-preserved : ∀ xs ls → ⟦ fst (label xs ls) ⟧ ≈ ⟦ xs ⟧ shape-preserved xs ls = lemma xs _
{ "alphanum_fraction": 0.5026611473, "avg_line_length": 26.8412698413, "ext": "agda", "hexsha": "29777d5862ca3b41952909c2a7f1d6048660dd7f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/agda-kanso", "max_forks_repo_path": "test/succeed/InductiveAndCoinductiveConstructors.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/agda-kanso", "max_issues_repo_path": "test/succeed/InductiveAndCoinductiveConstructors.agda", "max_line_length": 65, "max_stars_count": null, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/InductiveAndCoinductiveConstructors.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 744, "size": 1691 }
open import Agda.Builtin.Bool f : Bool → Bool f x = let id : Bool → Bool id b = {!!} in id x
{ "alphanum_fraction": 0.5480769231, "avg_line_length": 13, "ext": "agda", "hexsha": "6017f26e2aaf9fb52d5c9345bd036e7df1dfce69", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue3501.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue3501.agda", "max_line_length": 29, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue3501.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": 36, "size": 104 }
module Aexamples where open import Data.List hiding (reverse) open import Data.List.All open import Data.Nat open import Typing open import Syntax open import Async {- Lithmus test for asynchronous operations A thread send something to an asynchronous channel and receives it afterwards. -} aex1 : Expr [] TUnit aex1 = letbind [] (anew [] (delay send!)) (letpair (left []) (here []) (letbind (left (rght [])) (aclose (here [])) (await (there UUnit (here []))))) -- just replace synchronous operations by the asynchronous ones asyncex1 : Expr [] TUnit asyncex1 = letbind [] (anew [] (delay send!)) (letpair (left []) (here []) (letbind (rght (left [])) (fork (await (here []))) (aclose (there UUnit (here []))))) -- sending and receiving asyncex2 : Expr [] TUnit asyncex2 = letbind [] (anew [] (delay (send TInt (delay send!)))) (letpair (left []) (here []) (letbind (left (rght [])) (fork (letbind (rght []) (nat [] 42) (letbind (left (left [])) (asend (rght (left [])) (here []) (here [])) (letbind (left []) (aclose (here [])) (var (here [])))))) (letbind (rght (left [])) (arecv (here [])) (letpair (left (rght [])) (here []) (letbind (left (left (rght []))) (await (here (UInt ∷ []))) (var (here (UUnit ∷ []))))))))
{ "alphanum_fraction": 0.5764354959, "avg_line_length": 30.4772727273, "ext": "agda", "hexsha": "3a3adc06500feb34d2ac680eba841e6fd9868a5f", "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": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "peterthiemann/definitional-session", "max_forks_repo_path": "src/Aexamples.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c", "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": "peterthiemann/definitional-session", "max_issues_repo_path": "src/Aexamples.agda", "max_line_length": 87, "max_stars_count": 9, "max_stars_repo_head_hexsha": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "peterthiemann/definitional-session", "max_stars_repo_path": "src/Aexamples.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-18T08:10:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-19T16:33:27.000Z", "num_tokens": 401, "size": 1341 }
{-# OPTIONS --warning=error --safe --without-K #-} open import LogicalFormulae open import Orders.WellFounded.Definition open import Numbers.Naturals.Semiring open import Numbers.Naturals.Order open import Semirings.Definition module Numbers.Naturals.Order.WellFounded where open Semiring ℕSemiring <NWellfounded : WellFounded _<N_ <NWellfounded = λ x → access (go x) where lemma : {a b c : ℕ} → a <N b → b <N succ c → a <N c lemma {a} {b} {c} (le y succYAeqB) (le z zbEqC') = le (y +N z) p where zbEqC : z +N b ≡ c zSuccYAEqC : z +N (succ y +N a) ≡ c zSuccYAEqC' : z +N (succ (y +N a)) ≡ c zSuccYAEqC'' : succ (z +N (y +N a)) ≡ c zSuccYAEqC''' : succ ((z +N y) +N a) ≡ c p : succ ((y +N z) +N a) ≡ c p = identityOfIndiscernablesLeft _≡_ zSuccYAEqC''' (applyEquality (λ n → succ (n +N a)) (commutative z y)) zSuccYAEqC''' = identityOfIndiscernablesLeft _≡_ zSuccYAEqC'' (applyEquality succ (+Associative z y a)) zSuccYAEqC'' = identityOfIndiscernablesLeft _≡_ zSuccYAEqC' (succExtracts z (y +N a)) zSuccYAEqC' = identityOfIndiscernablesLeft _≡_ zSuccYAEqC (applyEquality (λ r → z +N r) refl) zbEqC = succInjective zbEqC' zSuccYAEqC = identityOfIndiscernablesLeft _≡_ zbEqC (applyEquality (λ r → z +N r) (equalityCommutative succYAeqB)) go : ∀ n m → m <N n → Accessible _<N_ m go zero m (le x ()) go (succ n) zero mLessN = access (λ y ()) go (succ n) (succ m) smLessSN = access (λ o (oLessSM : o <N succ m) → go n o (lemma oLessSM smLessSN))
{ "alphanum_fraction": 0.6323155216, "avg_line_length": 46.2352941176, "ext": "agda", "hexsha": "011af8d57728f707fc05750e899c32f659436648", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Numbers/Naturals/Order/WellFounded.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Numbers/Naturals/Order/WellFounded.agda", "max_line_length": 122, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Numbers/Naturals/Order/WellFounded.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": 601, "size": 1572 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Prelude open import LibraBFT.Base.PKCS open import LibraBFT.Yasm.Types -- This module defines the types used to define a SystemModel. module LibraBFT.Yasm.Base (ℓ-PeerState : Level) where -- Our system is configured through a value of type -- SystemParameters where we specify: record SystemParameters : Set (ℓ+1 ℓ-PeerState) where constructor mkSysParms field PeerId : Set _≟PeerId_ : ∀ (p₁ p₂ : PeerId) → Dec (p₁ ≡ p₂) Genesis : Set genInfo : Genesis -- The same genesis information is given to any uninitialised peer before -- it can handle any messages. PeerState : Set ℓ-PeerState initPS : PeerState -- Represents an uninitialised PeerState, about which we know nothing whatsoever Msg : Set Part : Set -- Types of interest that can be represented in Msgs -- The messages must be able to carry signatures instance Part-sig : WithSig Part -- A relation specifying what Parts are included in a Msg. _⊂Msg_ : Part → Msg → Set -- A relation specifying what Signatures are included in genInfo ∈GenInfo : Signature → Set -- Initializes a potentially-empty state with an EpochConfig init : PeerId → Genesis → PeerState × List (Action Msg) -- Handles a message on a previously initialized peer. handle : PeerId → Msg → PeerState → PeerState × List (Action Msg)
{ "alphanum_fraction": 0.6973134328, "avg_line_length": 38.9534883721, "ext": "agda", "hexsha": "60a0edc33cab5df7945d84f9993ecfe9b08b8396", "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": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "cwjnkins/bft-consensus-agda", "max_forks_repo_path": "LibraBFT/Yasm/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "cwjnkins/bft-consensus-agda", "max_issues_repo_path": "LibraBFT/Yasm/Base.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "cwjnkins/bft-consensus-agda", "max_stars_repo_path": "LibraBFT/Yasm/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 433, "size": 1675 }
module NotLeqSort where data Err : Set where err : (A : Set) -> Err
{ "alphanum_fraction": 0.6301369863, "avg_line_length": 10.4285714286, "ext": "agda", "hexsha": "5ad2603d7199fa799049c10653fbdfecd777fe2d", "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/NotLeqSort.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/NotLeqSort.agda", "max_line_length": 24, "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/NotLeqSort.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": 73 }
{-# OPTIONS --safe #-} module Cubical.Algebra.Direct-Sum.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Algebra.AbGroup -- Conventions : -- Elements of the index are named r, s, t... -- Elements of the groups are called a, b, c... -- Elements of the direct sum are named x, y, z... -- Elements in the fiber of Q x, Q y are called xs, ys... private variable ℓ ℓ' ℓ'' : Level data ⊕ (Idx : Type ℓ) (P : Idx → Type ℓ') (AGP : (r : Idx) → AbGroupStr (P r)) : Type (ℓ-max ℓ ℓ') where -- elements neutral : ⊕ Idx P AGP base : (r : Idx) → (P r) → ⊕ Idx P AGP _add_ : ⊕ Idx P AGP → ⊕ Idx P AGP → ⊕ Idx P AGP -- eq group addAssoc : (x y z : ⊕ Idx P AGP) → x add (y add z) ≡ (x add y) add z addRid : (x : ⊕ Idx P AGP) → x add neutral ≡ x addComm : (x y : ⊕ Idx P AGP) → x add y ≡ y add x -- eq base base-neutral : (r : Idx) → base r (AbGroupStr.0g (AGP r)) ≡ neutral base-add : (r : Idx) → (a b : P r) → (base r a) add (base r b) ≡ base r (AbGroupStr._+_ (AGP r) a b) -- set trunc : isSet (⊕ Idx P AGP) module _ (Idx : Type ℓ) (P : Idx → Type ℓ') (AGP : (r : Idx) → AbGroupStr (P r)) where module DS-Ind-Set (Q : (x : ⊕ Idx P AGP) → Type ℓ'') (issd : (x : ⊕ Idx P AGP) → isSet (Q x)) -- elements (neutral* : Q neutral) (base* : (r : Idx) → (a : P r) → Q (base r a)) (_add*_ : {x y : ⊕ Idx P AGP} → Q x → Q y → Q (x add y)) -- eq group (addAssoc* : {x y z : ⊕ Idx P AGP} → (xs : Q x) → (ys : Q y) → (zs : Q z) → PathP ( λ i → Q ( addAssoc x y z i)) (xs add* (ys add* zs)) ((xs add* ys) add* zs)) (addRid* : {x : ⊕ Idx P AGP} → (xs : Q x) → PathP (λ i → Q (addRid x i)) (xs add* neutral*) xs ) (addComm* : {x y : ⊕ Idx P AGP} → (xs : Q x) → (ys : Q y) → PathP (λ i → Q (addComm x y i)) (xs add* ys) (ys add* xs)) -- -- eq base (base-neutral* : (r : Idx) → PathP (λ i → Q (base-neutral r i)) (base* r (AbGroupStr.0g (AGP r))) neutral*) (base-add* : (r : Idx) → (a b : P r) → PathP (λ i → Q (base-add r a b i)) ((base* r a) add* (base* r b)) (base* r (AbGroupStr._+_ (AGP r) a b))) where f : (x : ⊕ Idx P AGP) → Q x f neutral = neutral* f (base r a) = base* r a f (x add y) = (f x) add* (f y) f (addAssoc x y z i) = addAssoc* (f x) (f y) (f z) i f (addRid x i) = addRid* (f x) i f (addComm x y i) = addComm* (f x) (f y) i f (base-neutral r i) = base-neutral* r i f (base-add r a b i) = base-add* r a b i f (trunc x y p q i j) = isOfHLevel→isOfHLevelDep 2 (issd) (f x) (f y) (cong f p) (cong f q) (trunc x y p q) i j module DS-Rec-Set (B : Type ℓ'') (iss : isSet(B)) (neutral* : B) (base* : (r : Idx) → P r → B) (_add*_ : B → B → B) (addAssoc* : (xs ys zs : B) → (xs add* (ys add* zs)) ≡ ((xs add* ys) add* zs)) (addRid* : (xs : B) → xs add* neutral* ≡ xs) (addComm* : (xs ys : B) → xs add* ys ≡ ys add* xs) (base-neutral* : (r : Idx) → base* r (AbGroupStr.0g (AGP r)) ≡ neutral*) (base-add* : (r : Idx) → (a b : P r) → (base* r a) add* (base* r b) ≡ base* r (AbGroupStr._+_ (AGP r) a b)) where f : ⊕ Idx P AGP → B f z = DS-Ind-Set.f (λ _ → B) (λ _ → iss) neutral* base* _add*_ addAssoc* addRid* addComm* base-neutral* base-add* z module DS-Ind-Prop (Q : (x : ⊕ Idx P AGP) → Type ℓ'') (ispd : (x : ⊕ Idx P AGP) → isProp (Q x)) -- elements (neutral* : Q neutral) (base* : (r : Idx) → (a : P r) → Q (base r a)) (_add*_ : {x y : ⊕ Idx P AGP} → Q x → Q y → Q (x add y)) where f : (x : ⊕ Idx P AGP) → Q x f x = DS-Ind-Set.f Q (λ x → isProp→isSet (ispd x)) neutral* base* _add*_ (λ {x} {y} {z} xs ys zs → toPathP (ispd _ (transport (λ i → Q (addAssoc x y z i)) (xs add* (ys add* zs))) ((xs add* ys) add* zs))) (λ {x} xs → toPathP (ispd _ (transport (λ i → Q (addRid x i)) (xs add* neutral*)) xs)) (λ {x} {y} xs ys → toPathP (ispd _ (transport (λ i → Q (addComm x y i)) (xs add* ys)) (ys add* xs))) (λ r → toPathP (ispd _ (transport (λ i → Q (base-neutral r i)) (base* r (AbGroupStr.0g (AGP r)))) neutral*)) (λ r a b → toPathP (ispd _ (transport (λ i → Q (base-add r a b i)) ((base* r a) add* (base* r b))) (base* r (AbGroupStr._+_ (AGP r) a b) ))) x module DS-Rec-Prop (B : Type ℓ'') (isp : isProp B) (neutral* : B) (base* : (r : Idx) → P r → B) (_add*_ : B → B → B) where f : ⊕ Idx P AGP → B f x = DS-Ind-Prop.f (λ _ → B) (λ _ → isp) neutral* base* _add*_ x
{ "alphanum_fraction": 0.4681496461, "avg_line_length": 41.2083333333, "ext": "agda", "hexsha": "11bcb8ca8b043bc5861a9355e472e362f4a83ad6", "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/Direct-Sum/Base.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/Direct-Sum/Base.agda", "max_line_length": 166, "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/Direct-Sum/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1998, "size": 4945 }
{-# OPTIONS --safe #-} module CF.Syntax.Hoisted where open import Level open import Data.List open import Relation.Unary hiding (_⊢_) open import Relation.Ternary.Core open import Relation.Ternary.Structures open import Relation.Ternary.Structures.Syntax open import CF.Types open import CF.Contexts.Lexical open import CF.Syntax using (module Statements) open import CF.Syntax using (Exp) public mutual Stmt = Statements.Statement Block {- This is Bigstar, but Agda cannot termination check that -} data Block (r : Ty) : Pred Ctx 0ℓ where nil : ε[ Block r ] cons : ∀[ Stmt r ✴ Block r ⇒ Block r ] open import Relation.Unary.PredicateTransformer hiding (_⍮_) open import Data.Product -- make constructors visible open Exp public open Statements Block public open CoDeBruijn public open import CF.Contexts.Lexical using (_⊢_) public
{ "alphanum_fraction": 0.762295082, "avg_line_length": 25.8787878788, "ext": "agda", "hexsha": "c0536a48a4998eec7e5672014eac781fd0b5a1df", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ajrouvoet/jvm.agda", "max_forks_repo_path": "src/CF/Syntax/Hoisted.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "ajrouvoet/jvm.agda", "max_issues_repo_path": "src/CF/Syntax/Hoisted.agda", "max_line_length": 63, "max_stars_count": 6, "max_stars_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ajrouvoet/jvm.agda", "max_stars_repo_path": "src/CF/Syntax/Hoisted.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": 217, "size": 854 }
------------------------------------------------------------------------------ -- Incompatible options ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- The @--schematic-propositional-functions@ and -- @--without-predicate-symbols@ options are incompatible. module SchematicPropositionalFunctionsWithoutPredicateSymbols where postulate D : Set postulate id : {P : D → Set}{x : D} → P x → P x {-# ATP prove id #-}
{ "alphanum_fraction": 0.4678456592, "avg_line_length": 32.7368421053, "ext": "agda", "hexsha": "118ff4a08fafb28df5a8d47599e63ccbddb2a9a8", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z", "max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/apia", "max_forks_repo_path": "test/Fail/Errors/SchematicPropositionalFunctionsWithoutPredicateSymbols.agda", "max_issues_count": 121, "max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/apia", "max_issues_repo_path": "test/Fail/Errors/SchematicPropositionalFunctionsWithoutPredicateSymbols.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/Fail/Errors/SchematicPropositionalFunctionsWithoutPredicateSymbols.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": 113, "size": 622 }
module Structure.Type.Identity.Proofs.Multi where open import Data.Tuple.Raise open import Data.Tuple.RaiseTypeᵣ import Data.Tuple.RaiseTypeᵣ.Functions as RaiseType import Lvl open import Functional using (_→ᶠ_ ; id ; _on₂_ ; swap ; _$_ ; apply) open import Function.Multi import Function.Multi.Functions as Multi open import Logic open import Logic.Propositional open import Logic.Propositional.Proofs.Structures open import Numeral.Natural open import Structure.Function open import Structure.Function.Multi open import Structure.Setoid using (Equiv ; intro) renaming (_≡_ to _≡ₛ_) open import Structure.Relator.Equivalence import Structure.Relator.Names as Names open import Structure.Relator.Properties open import Structure.Relator.Properties.Proofs open import Structure.Relator open import Structure.Type.Identity open import Structure.Type.Identity.Proofs open import Syntax.Function open import Type private variable ℓ ℓ₁ ℓ₂ ℓₑ₁ ℓₑ₂ ℓₑ ℓₘₑ ℓₚ ℓₒ : Lvl.Level private variable T A B : Type{ℓ} private variable x y : T private variable _≡_ _▫_ : T → T → Stmt{ℓ} module _ {B : Type{ℓ}} ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ -- {_≡_ : ∀{ℓ}{T : Type{ℓ}} → T → T → Stmt{ℓₑ}} -- ⦃ minRefl : ∀{ℓ}{T : Type{ℓ}} → MinimalReflexiveRelation{ℓₚ = ℓₑ₂}(_≡_ {T = T}) ⦄ -- TODO: Temporary where minimal-reflection-to-function₊ : ∀{n}{ℓ𝓈 ℓ𝓈ₑ}{As : Types{n}(ℓ𝓈)}{f : As ⇉ B} → Multi.quantifier₊ᵢₙₛₜ(n) {!!} (Multi.composeᵢₙₛₜ(n) (apply f) (Names.Function₊ ⦃ equiv-B = equiv-B ⦄ (n) {ℓ𝓈ₑ = ℓ𝓈ₑ} {As = As})) {-minimal-reflection-to-function₊ {0} {f = f} = reflexivity(_≡ₛ_) minimal-reflection-to-function₊ {1} {f = f} = congruence₁(f) ⦃ minimal-reflection-to-function ⦃ minRefl = {!!} ⦄ ⦄ minimal-reflection-to-function₊ {𝐒(𝐒(n))} {f = f} = {!!} -}
{ "alphanum_fraction": 0.7063447501, "avg_line_length": 40.4772727273, "ext": "agda", "hexsha": "4474580c73780d8fcb9c9d15404fd7088f799379", "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/Type/Identity/Proofs/Multi.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/Type/Identity/Proofs/Multi.agda", "max_line_length": 210, "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/Type/Identity/Proofs/Multi.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": 644, "size": 1781 }
{-# OPTIONS --cubical --no-exact-split --safe #-} module Multidimensional.Data.Extra.Nat.Properties where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Data.Nat open import Cubical.Data.Empty open import Cubical.Relation.Nullary open import Multidimensional.Data.Extra.Nat.Base sucnsuc : (n m : ℕ) → sucn n (suc m) ≡ suc (sucn n m) sucnsuc zero m = refl sucnsuc (suc n) m = sucn (suc n) (suc m) ≡⟨ refl ⟩ suc (sucn n (suc m)) ≡⟨ cong suc (sucnsuc n m) ⟩ suc (suc (sucn n m)) ∎ doublePred : (n : ℕ) → doubleℕ (predℕ n) ≡ predℕ (predℕ (doubleℕ n)) doublePred zero = refl doublePred (suc n) = refl sucPred : (n : ℕ) → ¬ (n ≡ zero) → suc (predℕ n) ≡ n sucPred zero 0≠0 = ⊥-elim (0≠0 refl) sucPred (suc n) sucn≠0 = refl doubleDoubles : (n m : ℕ) → doubleℕ (doublesℕ n m) ≡ doublesℕ (suc n) m doubleDoubles zero m = refl doubleDoubles (suc n) m = doubleDoubles n (doubleℕ m) doublePos : (n : ℕ) → ¬ (n ≡ 0) → ¬ (doubleℕ n ≡ 0) doublePos zero 0≠0 = ⊥-elim (0≠0 refl) doublePos (suc n) sn≠0 = snotz doublesPos : (n m : ℕ) → ¬ (m ≡ 0) → ¬ (doublesℕ n m ≡ 0) doublesPos zero m m≠0 = m≠0 doublesPos (suc n) m m≠0 = doublesPos n (doubleℕ m) (doublePos m (m≠0)) predDoublePos : (n : ℕ) → ¬ (n ≡ 0) → ¬ (predℕ (doubleℕ n)) ≡ 0 predDoublePos zero n≠0 = ⊥-elim (n≠0 refl) predDoublePos (suc n) sn≠0 = snotz doubleDoublesOne≠0 : (n : ℕ) → ¬ (doubleℕ (doublesℕ n (suc zero)) ≡ 0) doubleDoublesOne≠0 zero = snotz doubleDoublesOne≠0 (suc n) = doublePos (doublesℕ n 2) (doublesPos n 2 (snotz)) predDoubleDoublesOne≠0 : (n : ℕ) → ¬ (predℕ (doubleℕ (doublesℕ n (suc zero))) ≡ 0) predDoubleDoublesOne≠0 zero = snotz predDoubleDoublesOne≠0 (suc n) = predDoublePos (doublesℕ n 2) (doublesPos n 2 snotz) doublesZero : (n : ℕ) → doublesℕ n zero ≡ zero doublesZero zero = refl doublesZero (suc n) = doublesZero n doubleSucn : (i n : ℕ) → doubleℕ (sucn i n) ≡ sucn (doubleℕ i) (doubleℕ n) doubleSucn zero n = refl doubleSucn (suc i) n = suc (suc (doubleℕ (sucn i n))) ≡⟨ cong (λ z → suc (suc z)) (doubleSucn i n) ⟩ suc (suc (sucn (doubleℕ i) (doubleℕ n))) ≡⟨ refl ⟩ suc (sucn (suc (doubleℕ i)) (doubleℕ n)) ≡⟨ cong suc refl ⟩ sucn (suc (suc (doubleℕ i))) (doubleℕ n) ∎ doublesSucn : (i n m : ℕ) → doublesℕ n (sucn i m) ≡ sucn (doublesℕ n i) (doublesℕ n m) doublesSucn i zero m = refl doublesSucn i (suc n) m = doublesℕ n (doubleℕ (sucn i m)) ≡⟨ cong (doublesℕ n) (doubleSucn i m) ⟩ doublesℕ n (sucn (doubleℕ i) (doubleℕ m)) ≡⟨ doublesSucn (doubleℕ i) n (doubleℕ m) ⟩ sucn (doublesℕ n (doubleℕ i)) (doublesℕ n (doubleℕ m)) ∎ -- 2^n * (m + 2) = doublesSucSuc : (n m : ℕ) → doublesℕ n (suc (suc m)) ≡ sucn (doublesℕ (suc n) 1) (doublesℕ n m) doublesSucSuc zero m = refl doublesSucSuc (suc n) m = doublesℕ (suc n) (suc (suc m)) ≡⟨ refl ⟩ doublesℕ n (sucn 4 (doubleℕ m)) ≡⟨ doublesSucn 4 n (doubleℕ m) ⟩ sucn (doublesℕ n 4) (doublesℕ n (doubleℕ m)) ∎ n+n≡2n : (n : ℕ) → sucn n n ≡ doubleℕ n n+n≡2n zero = refl n+n≡2n (suc n) = sucn (suc n) (suc n) ≡⟨ sucnsuc (suc n) n ⟩ suc (sucn (suc n) n) ≡⟨ refl ⟩ suc (suc (sucn n n)) ≡⟨ cong (λ z → suc (suc z)) (n+n≡2n n) ⟩ suc (suc (doubleℕ n)) ∎
{ "alphanum_fraction": 0.6199752628, "avg_line_length": 31.3980582524, "ext": "agda", "hexsha": "c312c72ef049f1d512a2e6cb307b8732520d1a34", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "55709dd950e319c4a105ace33ddaf8b955354add", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "wrrnhttn/agda-cubical-multidimensional", "max_forks_repo_path": "Multidimensional/Data/Extra/Nat/Properties.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "55709dd950e319c4a105ace33ddaf8b955354add", "max_issues_repo_issues_event_max_datetime": "2019-07-02T16:24:01.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-19T20:40:07.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "wrrnhttn/agda-cubical-multidimensional", "max_issues_repo_path": "Multidimensional/Data/Extra/Nat/Properties.agda", "max_line_length": 95, "max_stars_count": null, "max_stars_repo_head_hexsha": "55709dd950e319c4a105ace33ddaf8b955354add", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wrrnhttn/agda-cubical-multidimensional", "max_stars_repo_path": "Multidimensional/Data/Extra/Nat/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1502, "size": 3234 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Coprimality ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Integer.Coprimality where open import Data.Integer open import Data.Integer.Divisibility open import Data.Integer.Properties import Data.Nat.Coprimality as ℕ import Data.Nat.Divisibility as ℕ open import Function using (_on_) open import Level using (0ℓ) open import Relation.Binary using (Rel; Decidable; Symmetric) open import Relation.Binary.PropositionalEquality using (subst) ------------------------------------------------------------------------ -- Definition Coprime : Rel ℤ 0ℓ Coprime = ℕ.Coprime on ∣_∣ ------------------------------------------------------------------------ -- Properties of coprimality sym : Symmetric Coprime sym = ℕ.sym coprime? : Decidable Coprime coprime? x y = ℕ.coprime? ∣ x ∣ ∣ y ∣ coprime-divisor : ∀ i j k → Coprime i j → i ∣ j * k → i ∣ k coprime-divisor i j k c eq = ℕ.coprime-divisor c (subst (∣ i ∣ ℕ.∣_ ) (abs-*-commute j k) eq)
{ "alphanum_fraction": 0.5338078292, "avg_line_length": 28.8205128205, "ext": "agda", "hexsha": "322dc44d586fc12991f465c25e88de8b701330e3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Integer/Coprimality.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/Integer/Coprimality.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Integer/Coprimality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 275, "size": 1124 }
open import Relation.Nullary.Decidable using (False) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; cong; cong₂) open import Relation.Binary.PropositionalEquality.WithK using (≡-erase) module AKS.Nat.Divisibility where open import Data.Nat.Divisibility using (_∣_) public open import Agda.Builtin.Nat using () renaming (mod-helper to modₕ; div-helper to divₕ) public open import Data.Nat.DivMod using (_/_; _%_; %-distribˡ-+) public open import Data.Nat.DivMod.Core using (a≤n⇒a[modₕ]n≡a) open import Data.Nat.DivMod using (/-congˡ; /-congʳ) renaming (m≡m%n+[m/n]*n to div-lemma) open import AKS.Nat.Base using (ℕ; _+_; _*_; _∸_; _≟_; lte; _≤_; _<_) open ℕ open import AKS.Nat.Properties using (+-suc) open import AKS.Nat.Properties using (m≤m+n; m≤n+m; suc-mono-≤; ∸-mono-≤ˡ; +-lower-≤; ≤-refl; ≢⇒¬≟; module ≤-Reasoning) open import AKS.Nat.Properties using (*-comm; +-identityʳ) open ≤-Reasoning import Data.Nat.DivMod as Nat import Data.Nat.Properties as Nat open import Data.Nat.Properties using (*-zeroʳ) open import Polynomial.Simple.AlmostCommutativeRing.Instances using (module Nat) open import Polynomial.Simple.Reflection using (solve) a[modₕ]n≤n : ∀ acc d n → modₕ acc (acc + n) d n ≤ acc + n a[modₕ]n≤n acc zero n = m≤m+n a[modₕ]n≤n acc (suc d) zero = a[modₕ]n≤n zero d (acc + 0) a[modₕ]n≤n acc (suc d) (suc n) rewrite +-suc acc n = a[modₕ]n≤n (suc acc) d n n%m<m : ∀ n m {≢0 : False (m ≟ 0)} → (n % m) {≢0} < m n%m<m n (suc m) = suc-mono-≤ (a[modₕ]n≤n 0 n m) a[modₕ]n≤a : ∀ acc a n → modₕ acc (acc + n) a n ≤ acc + a a[modₕ]n≤a acc zero n rewrite +-identityʳ acc = ≤-refl a[modₕ]n≤a acc (suc a) (suc n) = begin modₕ acc (acc + suc n) (suc a) (suc n) ≡⟨ cong (λ v → modₕ acc v (suc a) (suc n)) (+-suc acc n) ⟩ modₕ acc (suc acc + n) (suc a) (suc n) ≤⟨ a[modₕ]n≤a (suc acc) a n ⟩ suc acc + a ≡⟨ sym (+-suc acc a) ⟩ acc + suc a ∎ a[modₕ]n≤a acc (suc a) zero = begin modₕ acc (acc + 0) (suc a) 0 ≡⟨ cong (λ v → modₕ acc v (suc a) 0) (+-identityʳ acc) ⟩ modₕ acc acc (suc a) 0 ≤⟨ a[modₕ]n≤a 0 a acc ⟩ a ≤⟨ m≤n+m ⟩ suc a ≤⟨ m≤n+m ⟩ acc + suc a ∎ n%m≤n : ∀ n m {≢0} → (n % m) {≢0} ≤ n n%m≤n n (suc m) = a[modₕ]n≤a 0 n m n<m⇒n%m≡n : ∀ {n m} {≢0 : False (m ≟ 0)} → n < m → (n % m) {≢0} ≡ n n<m⇒n%m≡n {n} {suc m} (lte k refl) = ≡-erase (a≤n⇒a[modₕ]n≡a 0 (n + k) n k) 0%m≡0 : ∀ m {≢0 : False (m ≟ 0)} → (0 % m) {≢0} ≡ 0 0%m≡0 (suc m) = refl 1%m≡1 : ∀ {m} {≢0} → 1 < m → (1 % m) {≢0} ≡ 1 1%m≡1 {suc (suc m)} 1<m = refl record Euclidean (n : ℕ) (m : ℕ) : Set where constructor Euclidean✓ field q : ℕ r : ℕ division : n ≡ r + m * q r<m : r < m m≡m%n+[m/n]*n : ∀ m n {n≢0 : False (n ≟ 0)} → m ≡ (m % n) {n≢0} + (m / n) {n≢0} * n m≡m%n+[m/n]*n m (suc n) = div-lemma m n m%n≡m∸m/n*n : ∀ m n {n≢0 : False (n ≟ 0)} → (m % n) {n≢0} ≡ m ∸ (m / n) {n≢0} * n m%n≡m∸m/n*n m (suc n) = Nat.m%n≡m∸m/n*n m n m%n%n≡m%n : ∀ m n {n≢0 : False (n ≟ 0)} → ((m % n) {n≢0} % n) {n≢0} ≡ (m % n) {n≢0} m%n%n≡m%n m (suc n) = Nat.m%n%n≡m%n m n n%n≡0 : ∀ n {n≢0 : False (n ≟ 0)} → (n % n) {n≢0} ≡ 0 n%n≡0 (suc n) = Nat.n%n≡0 n [m+kn]%n≡m%n : ∀ m k n {n≢0 : False (n ≟ 0)} → ((m + k * n) % n) {n≢0} ≡ (m % n) {n≢0} [m+kn]%n≡m%n m k (suc n) = Nat.[m+kn]%n≡m%n m k n %-distribˡ-* : ∀ m n d {≢0} → ((m * n) % d) {≢0} ≡ (((m % d) {≢0} * (n % d) {≢0}) % d) {≢0} %-distribˡ-* m n (suc d) = begin-equality (m * n) % suc d ≡⟨ cong (λ x → (x * n) % suc d) (m≡m%n+[m/n]*n m (suc d)) ⟩ ((m % suc d + m / suc d * suc d) * n) % suc d ≡⟨ cong (λ x → x % suc d) (Nat.*-distribʳ-+ n (m % suc d) (m / suc d * suc d)) ⟩ ((m % suc d) * n + (m / suc d * suc d) * n) % suc d ≡⟨ cong (λ x → ((m % suc d) * n + x) % suc d) (lemma (m / suc d) (suc d) n) ⟩ ((m % suc d) * n + (m / suc d * n) * suc d) % suc d ≡⟨ Nat.[m+kn]%n≡m%n ((m % suc d) * n) (m / suc d * n) d ⟩ ((m % suc d) * n) % suc d ≡⟨ cong (λ x → ((m % suc d) * x) % suc d) (m≡m%n+[m/n]*n n (suc d)) ⟩ ((m % suc d) * (n % suc d + n / suc d * suc d)) % suc d ≡⟨ cong (λ x → x % suc d) (Nat.*-distribˡ-+ (m % suc d) (n % suc d) (n / suc d * suc d)) ⟩ ((m % suc d) * (n % suc d) + (m % suc d) * (n / suc d * suc d)) % suc d ≡⟨ cong (λ x → ((m % suc d) * (n % suc d) + x) % suc d) (sym (Nat.*-assoc (m % suc d) (n / suc d) (suc d))) ⟩ ((m % suc d) * (n % suc d) + ((m % suc d) * (n / suc d)) * suc d) % suc d ≡⟨ Nat.[m+kn]%n≡m%n ((m % suc d) * (n % suc d)) ((m % suc d) * (n / suc d)) d ⟩ ((m % suc d) * (n % suc d)) % suc d ∎ where lemma : ∀ x y z → (x * y) * z ≡ (x * z) * y lemma = solve Nat.ring [m∸n]%n≡m%n : ∀ m n {n≢0 : False (n ≟ 0)} → n ≤ m → ((m ∸ n) % n) {n≢0} ≡ (m % n) {n≢0} [m∸n]%n≡m%n (suc .(n + k)) (suc n) (lte k refl) = begin-equality ((suc n + k) ∸ suc n) % suc n ≡⟨ cong (λ t → t % suc n) (Nat.m+n∸m≡n (suc n) k) ⟩ k % suc n ≡⟨ sym (Nat.[m+n]%n≡m%n k n) ⟩ (k + suc n) % suc n ≡⟨ cong (λ t → t % suc n) (Nat.+-comm k (suc n)) ⟩ (suc n + k) % suc n ∎ [m∸kn]%n≡m%n : ∀ m k n {n≢0 : False (n ≟ 0)} → k * n ≤ m → ((m ∸ k * n) % n) {n≢0} ≡ (m % n) {n≢0} [m∸kn]%n≡m%n m zero (suc n) n≤m = refl [m∸kn]%n≡m%n m (suc k) (suc n) k*n≤m = begin-equality (m ∸ (suc n + k * suc n)) % suc n ≡⟨ cong (λ t → t % suc n) (sym (Nat.∸-+-assoc m (suc n) (k * suc n))) ⟩ ((m ∸ suc n) ∸ k * suc n) % suc n ≡⟨ [m∸kn]%n≡m%n (m ∸ suc n) k (suc n) k*n≤m∸n ⟩ (m ∸ suc n) % suc n ≡⟨ [m∸n]%n≡m%n m (suc n) (+-lower-≤ (k * suc n) k*n≤m) ⟩ m % suc n ∎ where k*n≤m∸n : k * suc n ≤ m ∸ suc n k*n≤m∸n = begin k * suc n ≡⟨ sym (Nat.m+n∸m≡n (suc n) (k * suc n)) ⟩ (suc n + k * suc n) ∸ suc n ≤⟨ ∸-mono-≤ˡ {suc n} m≤m+n k*n≤m ⟩ m ∸ suc n ∎ %-distribˡ-∸ : ∀ m n d {≢0} → n ≤ m → ((m ∸ n) % d) {≢0} ≡ ((m ∸ (n % d) {≢0}) % d) {≢0} %-distribˡ-∸ m n (suc d) n≤m = begin-equality (m ∸ n) % suc d ≡⟨ cong (λ t → (m ∸ t) % suc d) (m≡m%n+[m/n]*n n (suc d)) ⟩ (m ∸ (n % suc d + n / suc d * suc d)) % suc d ≡⟨ cong (λ t → t % suc d) (sym (Nat.∸-+-assoc m (n % suc d) (n / suc d * suc d))) ⟩ ((m ∸ n % suc d) ∸ n / suc d * suc d) % suc d ≡⟨ [m∸kn]%n≡m%n (m ∸ n % suc d) (n / suc d) (suc d) n/d*d≤m∸n%d ⟩ (m ∸ n % suc d) % suc d ∎ where n/d*d≤m∸n%d : n / suc d * suc d ≤ m ∸ n % suc d n/d*d≤m∸n%d = begin n / suc d * suc d ≡⟨ sym (Nat.m+n∸m≡n (n % suc d) (n / suc d * suc d)) ⟩ (n % suc d + n / suc d * suc d) ∸ n % suc d ≡⟨ cong (λ t → t ∸ n % suc d) (sym (m≡m%n+[m/n]*n n (suc d))) ⟩ n ∸ n % suc d ≤⟨ ∸-mono-≤ˡ {n % suc d} (n%m≤n n (suc d)) n≤m ⟩ m ∸ n % suc d ∎ open import AKS.Unsafe using (trustMe) /-cancelˡ : ∀ c a b {b≢0} {b*c≢0} → ((c * a) / (c * b)) {b*c≢0} ≡ (a / b) {b≢0} /-cancelˡ (suc c) a (suc b) {b≢0} {b*c≢0} = trustMe /-cancelʳ : ∀ c a b {b≢0} {b*c≢0} → ((a * c) / (b * c)) {b*c≢0} ≡ (a / b) {b≢0} /-cancelʳ c a b {b≢0} {b*c≢0} = begin-equality (a * c) / (b * c) ≡⟨ /-congˡ {o≢0 = b*c≢0} (*-comm a c) ⟩ (c * a) / (b * c) ≡⟨ /-congʳ (*-comm b c) ⟩ (c * a) / (c * b) ≡⟨ /-cancelˡ c a b {b≢0} {c*b≢0} ⟩ a / b ∎ where c*b≢0 : False (c * b ≟ 0) c*b≢0 rewrite *-comm b c = b*c≢0 _div_ : ∀ n m {≢0 : False (m ≟ 0)} → Euclidean n m n div suc m = Euclidean✓ (n / suc m) (n % suc m) (≡-erase div-proof) (n%m<m n (suc m)) where div-proof : n ≡ n % suc m + suc m * (n / suc m) div-proof rewrite *-comm (suc m) (n / suc m) = m≡m%n+[m/n]*n n (suc m)
{ "alphanum_fraction": 0.4428862825, "avg_line_length": 50.2820512821, "ext": "agda", "hexsha": "81319f8c831679afc5867e6bf9c1eac3229a0681", "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": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mckeankylej/thesis", "max_forks_repo_path": "proofs/AKS/Nat/Divisibility.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "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": "mckeankylej/thesis", "max_issues_repo_path": "proofs/AKS/Nat/Divisibility.agda", "max_line_length": 185, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mckeankylej/thesis", "max_stars_repo_path": "proofs/AKS/Nat/Divisibility.agda", "max_stars_repo_stars_event_max_datetime": "2020-12-01T22:38:27.000Z", "max_stars_repo_stars_event_min_datetime": "2020-12-01T22:38:27.000Z", "num_tokens": 3950, "size": 7844 }
{-# OPTIONS --without-K --safe #-} module Tools.Embedding where open import Agda.Primitive data ι {ℓ : Level} (A : Set ℓ) : Set (lsuc ℓ) where ιx : A → ι A data ι′ {ℓ : Level} (A : Set) : Set ℓ where ιx : A → ι′ A data ι″ {ℓ} (A : Set ℓ) : Setω where ιx : A → ι″ A
{ "alphanum_fraction": 0.5615942029, "avg_line_length": 18.4, "ext": "agda", "hexsha": "c4de67b09e928eff2ed2837557f089980b11eaf2", "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": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "loic-p/logrel-mltt", "max_forks_repo_path": "Tools/Embedding.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "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": "loic-p/logrel-mltt", "max_issues_repo_path": "Tools/Embedding.agda", "max_line_length": 51, "max_stars_count": null, "max_stars_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "loic-p/logrel-mltt", "max_stars_repo_path": "Tools/Embedding.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 123, "size": 276 }
{-# OPTIONS --rewriting #-} module Everything where import Examples import Properties import PrettyPrinter import Interpreter
{ "alphanum_fraction": 0.8046875, "avg_line_length": 14.2222222222, "ext": "agda", "hexsha": "d8a1fd5ae93630f3703208ea984a8ad6328df484", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "XanderYZZ/luau", "max_forks_repo_path": "prototyping/Everything.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "XanderYZZ/luau", "max_issues_repo_path": "prototyping/Everything.agda", "max_line_length": 27, "max_stars_count": 1, "max_stars_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "TheGreatSageEqualToHeaven/luau", "max_stars_repo_path": "prototyping/Everything.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-05T21:53:03.000Z", "max_stars_repo_stars_event_min_datetime": "2021-12-05T21:53:03.000Z", "num_tokens": 23, "size": 128 }
{-# OPTIONS --safe #-} module Cubical.HITs.AssocList.Properties where open import Cubical.HITs.AssocList.Base as AL open import Cubical.Foundations.Everything open import Cubical.Foundations.SIP open import Cubical.HITs.FiniteMultiset as FMS hiding (_++_; unitl-++; unitr-++; assoc-++; cons-++; comm-++) open import Cubical.Data.Nat using (ℕ; zero; suc; _+_; +-assoc; isSetℕ) open import Cubical.Structures.MultiSet open import Cubical.Relation.Nullary open import Cubical.Relation.Nullary.DecidableEq private variable ℓ : Level A : Type ℓ multiPer : (a b : A) (m n : ℕ) (xs : AssocList A) → ⟨ a , m ⟩∷ ⟨ b , n ⟩∷ xs ≡ ⟨ b , n ⟩∷ ⟨ a , m ⟩∷ xs multiPer a b zero n xs = del a (⟨ b , n ⟩∷ xs) ∙ cong (λ ys → ⟨ b , n ⟩∷ ys) (sym (del a xs)) multiPer a b (suc m) zero xs = cong (λ ys → ⟨ a , suc m ⟩∷ ys) (del b xs) ∙ sym (del b (⟨ a , suc m ⟩∷ xs)) multiPer a b (suc m) (suc n) xs = ⟨ a , suc m ⟩∷ ⟨ b , suc n ⟩∷ xs ≡⟨ sym (agg a 1 m (⟨ b , suc n ⟩∷ xs)) ⟩ ⟨ a , 1 ⟩∷ ⟨ a , m ⟩∷ ⟨ b , suc n ⟩∷ xs ≡⟨ cong (λ ys → ⟨ a , 1 ⟩∷ ys) (multiPer a b m (suc n) xs) ⟩ ⟨ a , 1 ⟩∷ ⟨ b , suc n ⟩∷ ⟨ a , m ⟩∷ xs ≡⟨ cong (λ ys → ⟨ a , 1 ⟩∷ ys) (sym (agg b 1 n (⟨ a , m ⟩∷ xs))) ⟩ ⟨ a , 1 ⟩∷ ⟨ b , 1 ⟩∷ ⟨ b , n ⟩∷ ⟨ a , m ⟩∷ xs ≡⟨ per a b (⟨ b , n ⟩∷ ⟨ a , m ⟩∷ xs) ⟩ ⟨ b , 1 ⟩∷ ⟨ a , 1 ⟩∷ ⟨ b , n ⟩∷ ⟨ a , m ⟩∷ xs ≡⟨ cong (λ ys → ⟨ b , 1 ⟩∷ ⟨ a , 1 ⟩∷ ys) (multiPer b a n m xs) ⟩ ⟨ b , 1 ⟩∷ ⟨ a , 1 ⟩∷ ⟨ a , m ⟩∷ ⟨ b , n ⟩∷ xs ≡⟨ cong (λ ys → ⟨ b , 1 ⟩∷ ys) (agg a 1 m (⟨ b , n ⟩∷ xs)) ⟩ ⟨ b , 1 ⟩∷ ⟨ a , suc m ⟩∷ ⟨ b , n ⟩∷ xs ≡⟨ cong (λ ys → ⟨ b , 1 ⟩∷ ys) (multiPer a b (suc m) n xs) ⟩ ⟨ b , 1 ⟩∷ ⟨ b , n ⟩∷ ⟨ a , suc m ⟩∷ xs ≡⟨ agg b 1 n (⟨ a , suc m ⟩∷ xs) ⟩ ⟨ b , suc n ⟩∷ ⟨ a , suc m ⟩∷ xs ∎ -- Show that association lists and finite multisets are equivalent multi-∷ : A → ℕ → FMSet A → FMSet A multi-∷ x zero xs = xs multi-∷ x (suc n) xs = x ∷ multi-∷ x n xs multi-∷-agg : (x : A) (m n : ℕ) (b : FMSet A) → multi-∷ x m (multi-∷ x n b) ≡ multi-∷ x (m + n) b multi-∷-agg x zero n b = refl multi-∷-agg x (suc m) n b i = x ∷ (multi-∷-agg x m n b i) infixr 30 _++_ _++_ : (xs ys : AssocList A) → AssocList A ⟨⟩ ++ ys = ys (⟨ a , n ⟩∷ xs) ++ ys = ⟨ a , n ⟩∷ (xs ++ ys) per a b xs i ++ ys = per a b (xs ++ ys) i agg a m n xs i ++ ys = agg a m n (xs ++ ys) i del a xs i ++ ys = del a (xs ++ ys) i trunc xs ys p q i j ++ zs = trunc (xs ++ zs) (ys ++ zs) (cong (_++ _) p) (cong (_++ _) q) i j unitl-++ : (xs : AssocList A) → ⟨⟩ ++ xs ≡ xs unitl-++ xs = refl unitr-++ : (xs : AssocList A) → xs ++ ⟨⟩ ≡ xs unitr-++ = AL.ElimProp.f (trunc _ _) refl λ _ _ → cong (⟨ _ , _ ⟩∷_) assoc-++ : (xs ys zs : AssocList A) → xs ++ (ys ++ zs) ≡ (xs ++ ys) ++ zs assoc-++ = AL.ElimProp.f (isPropΠ2 (λ _ _ → trunc _ _)) (λ ys zs → refl) λ x n p ys zs → cong (⟨ _ , _ ⟩∷_) (p ys zs) cons-++ : ∀ x n (xs : AssocList A) → ⟨ x , n ⟩∷ xs ≡ xs ++ (⟨ x , n ⟩∷ ⟨⟩) cons-++ x n = AL.ElimProp.f (trunc _ _) refl λ y m p → multiPer _ _ _ _ _ ∙ cong (⟨ _ , _ ⟩∷_) p comm-++ : (xs ys : AssocList A) → xs ++ ys ≡ ys ++ xs comm-++ = AL.ElimProp.f (isPropΠ (λ _ → trunc _ _)) (sym ∘ unitr-++) λ x n {xs} p ys → cong (⟨ _ , _ ⟩∷_) (p ys) ∙ cong (_++ _) (cons-++ x n ys) ∙ sym (assoc-++ ys _ xs) AL→FMS : AssocList A → FMSet A AL→FMS = AL.Rec.f FMS.trunc [] multi-∷ comm multi-∷-agg λ _ _ → refl FMS→AL : FMSet A → AssocList A FMS→AL = FMS.Rec.f AL.trunc ⟨⟩ (λ x xs → ⟨ x , 1 ⟩∷ xs) per AL→FMS∘FMS→AL≡id : section {A = AssocList A} AL→FMS FMS→AL AL→FMS∘FMS→AL≡id = FMS.ElimProp.f (FMS.trunc _ _) refl (λ x p → cong (λ ys → x ∷ ys) p) -- need a little lemma for other direction multi-∷-id : (x : A) (n : ℕ) (u : FMSet A) → FMS→AL (multi-∷ x n u) ≡ ⟨ x , n ⟩∷ FMS→AL u multi-∷-id x zero u = sym (del x (FMS→AL u)) multi-∷-id x (suc n) u = FMS→AL (multi-∷ x (suc n) u) ≡⟨ cong (λ ys → ⟨ x , 1 ⟩∷ ys) (multi-∷-id x n u) ⟩ ⟨ x , 1 ⟩∷ ⟨ x , n ⟩∷ (FMS→AL u) ≡⟨ agg x 1 n (FMS→AL u) ⟩ ⟨ x , (suc n) ⟩∷ (FMS→AL u) ∎ FMS→AL∘AL→FMS≡id : retract {A = AssocList A} AL→FMS FMS→AL FMS→AL∘AL→FMS≡id = AL.ElimProp.f (AL.trunc _ _) refl (λ x n {xs} p → (multi-∷-id x n (AL→FMS xs)) ∙ cong (λ ys → ⟨ x , n ⟩∷ ys) p) AssocList≃FMSet : AssocList A ≃ FMSet A AssocList≃FMSet = isoToEquiv (iso AL→FMS FMS→AL AL→FMS∘FMS→AL≡id FMS→AL∘AL→FMS≡id) FMSet≃AssocList : FMSet A ≃ AssocList A FMSet≃AssocList = isoToEquiv (iso FMS→AL AL→FMS FMS→AL∘AL→FMS≡id AL→FMS∘FMS→AL≡id) AssocList≡FMSet : AssocList A ≡ FMSet A AssocList≡FMSet = ua AssocList≃FMSet -- We want to define a multiset structure on AssocList A, we use the recursor to define the count-function module _(discA : Discrete A) where setA = Discrete→isSet discA ALcount-⟨,⟩∷* : A → A → ℕ → ℕ → ℕ ALcount-⟨,⟩∷* a x n xs with discA a x ... | yes a≡x = n + xs ... | no a≢x = xs ALcount-per* : (a x y : A) (xs : ℕ) → ALcount-⟨,⟩∷* a x 1 (ALcount-⟨,⟩∷* a y 1 xs) ≡ ALcount-⟨,⟩∷* a y 1 (ALcount-⟨,⟩∷* a x 1 xs) ALcount-per* a x y xs with discA a x | discA a y ALcount-per* a x y xs | yes a≡x | yes a≡y = refl ALcount-per* a x y xs | yes a≡x | no a≢y = refl ALcount-per* a x y xs | no a≢x | yes a≡y = refl ALcount-per* a x y xs | no a≢x | no a≢y = refl ALcount-agg* : (a x : A) (m n xs : ℕ) → ALcount-⟨,⟩∷* a x m (ALcount-⟨,⟩∷* a x n xs) ≡ ALcount-⟨,⟩∷* a x (m + n) xs ALcount-agg* a x m n xs with discA a x ... | yes _ = +-assoc m n xs ... | no _ = refl ALcount-del* : (a x : A) (xs : ℕ) → ALcount-⟨,⟩∷* a x 0 xs ≡ xs ALcount-del* a x xs with discA a x ... | yes _ = refl ... | no _ = refl ALcount : A → AssocList A → ℕ ALcount a = AL.Rec.f isSetℕ 0 (ALcount-⟨,⟩∷* a) (ALcount-per* a) (ALcount-agg* a) (ALcount-del* a) AL-with-str : MultiSet A setA AL-with-str = (AssocList A , ⟨⟩ , ⟨_, 1 ⟩∷_ , ALcount) -- We want to show that Al-with-str ≅ FMS-with-str as multiset-structures FMS→AL-EquivStr : MultiSetEquivStr A setA (FMS-with-str discA) (AL-with-str) FMSet≃AssocList FMS→AL-EquivStr = refl , (λ a xs → refl) , φ where φ : ∀ a xs → FMScount discA a xs ≡ ALcount a (FMS→AL xs) φ a = FMS.ElimProp.f (isSetℕ _ _) refl ψ where ψ : (x : A) {xs : FMSet A} → FMScount discA a xs ≡ ALcount a (FMS→AL xs) → FMScount discA a (x ∷ xs) ≡ ALcount a (FMS→AL (x ∷ xs)) ψ x {xs} p = subst B α θ where B = λ ys → FMScount discA a (x ∷ xs) ≡ ALcount a ys α : ⟨ x , 1 ⟩∷ FMS→AL xs ≡ FMS→AL (x ∷ xs) α = sym (multi-∷-id x 1 xs) θ : FMScount discA a (x ∷ xs) ≡ ALcount a (⟨ x , 1 ⟩∷ (FMS→AL xs)) θ with discA a x ... | yes _ = cong suc p ... | no ¬p = p FMS-with-str≡AL-with-str : FMS-with-str discA ≡ AL-with-str FMS-with-str≡AL-with-str = sip (multiSetUnivalentStr A setA) (FMS-with-str discA) AL-with-str (FMSet≃AssocList , FMS→AL-EquivStr)
{ "alphanum_fraction": 0.5103085454, "avg_line_length": 35.3417085427, "ext": "agda", "hexsha": "2de9f199277ea7e0f417eeb7eca3f728a426791a", "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/HITs/AssocList/Properties.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/HITs/AssocList/Properties.agda", "max_line_length": 130, "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/HITs/AssocList/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3212, "size": 7033 }
{-# OPTIONS --cubical --safe #-} module DivModAlt where open import Cubical.Core.Everything using (_≡_; Level; Type; Σ; _,_; fst; snd; _≃_; ~_) open import Cubical.Foundations.Prelude using (refl; sym; _∙_; cong; transport; subst; funExt; transp; I; i0; i1; hcomp; primPOr; _∨_) open import Cubical.Foundations.Function using (_∘_) open import Cubical.Foundations.Isomorphism using (iso; Iso; isoToPath; section; retract; isoToEquiv) open import Data.Empty using (⊥) open import Data.Fin using (Fin; toℕ; fromℕ<; #_; _≟_) renaming (zero to fz; suc to fs) open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _≤_ ; _>_; _<_; _≥_; z≤n; s≤s; NonZero) open import Data.Product using (_×_) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Data.Unit using (⊤; tt) open import Fin +-assoc : (m n o : ℕ) → (m + n) + o ≡ m + (n + o) +-assoc zero _ _ = refl +-assoc (suc m) n o = cong suc (+-assoc m n o) ≤-refl : {n : ℕ} → n ≤ n ≤-refl {zero} = z≤n ≤-refl {suc n} = s≤s (≤-refl {n}) ≤-trans : {m n o : ℕ} → m ≤ n → n ≤ o → m ≤ o ≤-trans z≤n _ = z≤n ≤-trans (s≤s x) (s≤s y) = s≤s (≤-trans x y) ≤-step : {m n : ℕ} → m ≤ n → m ≤ 1 + n ≤-step z≤n = z≤n ≤-step (s≤s m≤n) = s≤s (≤-step m≤n) n≤1+n : (n : ℕ) → n ≤ 1 + n n≤1+n _ = ≤-step ≤-refl ≤-pred : {m n : ℕ} → suc m ≤ suc n → m ≤ n ≤-pred (s≤s m≤n) = m≤n _-_ : (n m : ℕ) → {m ≤ n} → ℕ (n - zero) {z≤n} = n (suc n - suc m) {s≤s p} = _-_ n m {p} <-∨-≥ : (m n : ℕ) → m < n ⊎ m ≥ n <-∨-≥ zero zero = inj₂ z≤n <-∨-≥ zero (suc n) = inj₁ (s≤s z≤n) <-∨-≥ (suc m) zero = inj₂ z≤n <-∨-≥ (suc m) (suc n) with <-∨-≥ m n ... | inj₁ m<n = inj₁ (s≤s m<n) ... | inj₂ m≥n = inj₂ (s≤s m≥n) sucn-1 : (n : ℕ) → (suc n - 1) {s≤s z≤n} ≡ n sucn-1 n = refl -decreasing : (n m : ℕ) → (m≤n : suc m ≤ n) → ((n - suc m) {m≤n}) < n -decreasing (suc n) zero (s≤s z≤n) = ≤-refl -decreasing (suc n) (suc m) (s≤s m≤n) = ≤-trans (-decreasing n m m≤n) (n≤1+n n) -decreasing1 : (c n m : ℕ) → (m≤n : suc m ≤ n) → (n ≤ suc c) → ((n - suc m) {m≤n}) ≤ c -decreasing1 c (suc n) m (s≤s m≤n) (s≤s n≤c) = ≤-trans (≤-pred (-decreasing (suc n) m (s≤s m≤n))) n≤c lemma1 : (n m : ℕ) → {m≤n : m ≤ n} → m + ((n - m) {m≤n}) ≡ n lemma1 n zero {z≤n} = refl lemma1 (suc n) (suc m) {s≤s p} = cong suc (lemma1 n m {p}) lemma2 : (n m a : ℕ) → {m≤n : m ≤ n} → (n - m) {m≤n} ≡ a → n ≡ m + a lemma2 n m a {m≤n} x = subst (λ y → y ≡ m + a) (lemma1 n m {m≤n} ) (cong (m +_) x) lemma3 : (n m d r : ℕ) → {m≤n : m ≤ n} → (n - m) {m≤n} ≡ d * m + r → n ≡ (suc d) * m + r lemma3 n m d r {m≤n} x = lemma2 n m (d * m + r) x ∙ sym (+-assoc m (d * m) r) --infixl 7 _div_ _mod_ _mod'_ record DivMod (n m : ℕ) : Type where constructor divMod field q : ℕ r : Fin m n=q*m+r : n ≡ q * m + toℕ r record DivMod0 (n m : ℕ) : Type where constructor divMod0 field q : ℕ r : ℕ r<m : r < m n=q*m+r : n ≡ q * m + r record DivMod1 (n m : ℕ) : Type where constructor divMod1 field q : ℕ r : Fin1 m n=q*m+r : n ≡ q * m + Fin1.r r divmod1 : (c n m : ℕ) → (n ≤ c) → {m > 0} → DivMod n m divmod1 zero zero (suc m) z≤n = divMod 0 (# 0) refl divmod1 (suc c) n (suc m) n≤c with <-∨-≥ n (suc m) ... | inj₁ n<m = divMod 0 (fromℕ< n<m) (sym (toℕ-fromℕ< n<m)) ... | inj₂ n≥m = let (divMod q r n-m≡q*m+r) = divmod1 c ((n - (suc m)) {n≥m}) (suc m) (-decreasing1 c n m n≥m n≤c ) {s≤s z≤n} in divMod (suc q) r (lemma3 n (suc m) q (toℕ r) n-m≡q*m+r) divmod : (n m : ℕ) → {m > 0} → DivMod n m divmod n (suc m) = divmod1 n n (suc m) ≤-refl {s≤s z≤n} -- NOTE: We can't use {m > 0} here because Agda can't figure out -- the implicit proof (even for constants), so use {NonZero m} instead. _div_ : (n m : ℕ) → {NonZero m} → ℕ n div (suc m) = DivMod.q (divmod n (suc m) {s≤s z≤n}) _mod_ : (n m : ℕ) → {NonZero m} → Fin m n mod (suc m) = DivMod.r (divmod n (suc m) {s≤s z≤n}) _mod'_ : (n m : ℕ) → {NonZero m} → ℕ n mod' (suc m) = toℕ (n mod (suc m)) --------- dm0→dm1 : {m n : ℕ} → DivMod0 n m → DivMod1 n m dm0→dm1 {m} {n} (divMod0 q r r<m n=q*m+r) = divMod1 q (fin1 r r<m) n=q*m+r dm1→dm0 : {m n : ℕ} → DivMod1 n m → DivMod0 n m dm1→dm0 (divMod1 q r n=q*m+r) = divMod0 q (Fin1.r r) (Fin1.r<n r) n=q*m+r dm0→dm1→dm0 : {m n : ℕ} → (dm0 : DivMod0 n m) → (dm1→dm0 ∘ dm0→dm1) dm0 ≡ dm0 dm0→dm1→dm0 _ = refl dm1→dm0→dm1 : {m n : ℕ} → (dm1 : DivMod1 n m) → (dm0→dm1 ∘ dm1→dm0) dm1 ≡ dm1 dm1→dm0→dm1 _ = refl dm0≃dm1 : {n m : ℕ} → Iso (DivMod0 n m) (DivMod1 n m) dm0≃dm1 = iso dm0→dm1 dm1→dm0 dm1→dm0→dm1 dm0→dm1→dm0 dm0≡dm1 : {n m : ℕ} → DivMod0 n m ≡ DivMod1 n m dm0≡dm1 = isoToPath dm0≃dm1 --------- dm1→dm : {m n : ℕ} → DivMod1 n m → DivMod n m dm1→dm {m} {n} (divMod1 q r n=q*m+r) = divMod q (fin1→fin r) (subst (λ x → n ≡ q * m + x) (sym (Fin1r≡toℕ1 r)) n=q*m+r) dm→dm1 : {m n : ℕ} → DivMod n m → DivMod1 n m dm→dm1 {m} {n} (divMod q r n=q*m+r) = divMod1 q (fin→fin1 r) (subst (λ x → n ≡ q * m + x) (toℕ≡Fin1r1 r) n=q*m+r) dm1→dm→dm1 : {m n : ℕ} → (dm1 : DivMod1 n m) → (dm→dm1 ∘ dm1→dm) dm1 ≡ dm1 dm1→dm→dm1 {m} {n} (divMod1 q r n=q*m+r) i = divMod1 q (fin1→fin→fin1 r i) {!!} dm→dm1→dm : {m n : ℕ} → (dm : DivMod n m) → (dm1→dm ∘ dm→dm1) dm ≡ dm dm→dm1→dm (divMod q r n=q*m+r) i = divMod q (fin→fin1→fin r i) (λ j → {!n=q*m+r j!}) dm1≃dm : {n m : ℕ} → Iso (DivMod1 n m) (DivMod n m) dm1≃dm = iso dm1→dm dm→dm1 dm→dm1→dm dm1→dm→dm1 dm1≡dm : {n m : ℕ} → DivMod1 n m ≡ DivMod n m dm1≡dm = isoToPath dm1≃dm --------- dm0≡dm : {n m : ℕ} → DivMod0 n m ≡ DivMod n m dm0≡dm = dm0≡dm1 ∙ dm1≡dm --------- n%m<m : (n m : ℕ) {m≠0 : NonZero m} → toℕ ((n mod m) {m≠0}) < m n%m<m n (suc m) = toℕ<n (DivMod.r (divmod n (suc m) {s≤s z≤n})) n≡divmod : (n m : ℕ) {m≠0 : NonZero m} → n ≡ ((n div m) {m≠0}) * m + toℕ ((n mod m) {m≠0}) n≡divmod n (suc m) = DivMod.n=q*m+r (divmod n (suc m) {s≤s z≤n})
{ "alphanum_fraction": 0.512519162, "avg_line_length": 33.3579545455, "ext": "agda", "hexsha": "4b47020ddc6666d6bf5c58c46a764fa60ba86296", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2020-11-10T04:04:40.000Z", "max_forks_repo_forks_event_min_datetime": "2019-01-12T17:02:36.000Z", "max_forks_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "halfaya/MusicTools", "max_forks_repo_path": "agda/DivModAlt.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_issues_repo_issues_event_max_datetime": "2020-11-17T00:58:55.000Z", "max_issues_repo_issues_event_min_datetime": "2020-11-13T01:26:20.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "halfaya/MusicTools", "max_issues_repo_path": "agda/DivModAlt.agda", "max_line_length": 138, "max_stars_count": 28, "max_stars_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "halfaya/MusicTools", "max_stars_repo_path": "agda/DivModAlt.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T18:04:07.000Z", "max_stars_repo_stars_event_min_datetime": "2017-04-21T09:08:52.000Z", "num_tokens": 3001, "size": 5871 }
module PiQ.Properties where open import Data.Empty open import Data.Unit hiding (_≟_) open import Data.Sum open import Data.Product open import Data.Maybe open import Data.Maybe.Properties open import Data.Nat hiding (_≟_) open import Data.Nat.Induction open import Data.Nat.Properties hiding (_≟_) open import Function using (_∘_) open import Relation.Binary.Core open import Relation.Binary open import Relation.Nullary open import Relation.Binary.PropositionalEquality open import PiQ.Syntax open import PiQ.Opsem open import PiQ.AuxLemmas open import PiQ.NoRepeat open import PiQ.Invariants open import PiQ.Eval open import PiQ.Interp -- Change the direction of the given state flip : (st : State) → st ≢ ⊠ → State flip ⟨ c ∣ v ∣ κ ⟩▷ _ = ⟨ c ∣ v ∣ κ ⟩◁ flip [ c ∣ v ∣ κ ]▷ _ = [ c ∣ v ∣ κ ]◁ flip ⟨ c ∣ v ∣ κ ⟩◁ _ = ⟨ c ∣ v ∣ κ ⟩▷ flip [ c ∣ v ∣ κ ]◁ _ = [ c ∣ v ∣ κ ]▷ flip ⊠ st≢⊠ = ⊥-elim (st≢⊠ refl) Rev : ∀ {st st'} → st ↦ st' → (nf : st ≢ ⊠) (nf' : st' ≢ ⊠) → flip st' nf' ↦ flip st nf Rev ↦⃗₁ _ _ = ↦⃖₁ Rev ↦⃗₂ _ _ = ↦⃖₂ Rev ↦⃗₃ _ _ = ↦⃖₃ Rev ↦⃗₄ _ _ = ↦⃖₄ Rev ↦⃗₅ _ _ = ↦⃖₅ Rev ↦⃗₆ _ _ = ↦⃖₆ Rev ↦⃗₇ _ _ = ↦⃖₇ Rev ↦⃗₈ _ _ = ↦⃖₈ Rev ↦⃗₉ _ _ = ↦⃖₉ Rev ↦⃗₁₀ _ _ = ↦⃖₁₀ Rev ↦⃗₁₁ _ _ = ↦⃖₁₁ Rev ↦⃗₁₂ _ _ = ↦⃖₁₂ Rev ↦⃖₁ _ _ = ↦⃗₁ Rev ↦⃖₂ _ _ = ↦⃗₂ Rev ↦⃖₃ _ _ = ↦⃗₃ Rev ↦⃖₄ _ _ = ↦⃗₄ Rev ↦⃖₅ _ _ = ↦⃗₅ Rev ↦⃖₆ _ _ = ↦⃗₆ Rev ↦⃖₇ _ _ = ↦⃗₇ Rev ↦⃖₈ _ _ = ↦⃗₈ Rev ↦⃖₉ _ _ = ↦⃗₉ Rev ↦⃖₁₀ _ _ = ↦⃗₁₀ Rev ↦⃖₁₁ _ _ = ↦⃗₁₁ Rev ↦⃖₁₂ _ _ = ↦⃗₁₂ Rev ↦η₊₁ _ _ = ↦η₊₂ Rev ↦η₊₂ _ _ = ↦η₊₁ Rev ↦ε₊₁ _ _ = ↦ε₊₂ Rev ↦ε₊₂ _ _ = ↦ε₊₁ Rev ↦⃗ηₓ _ _ = ↦⃖ηₓ₁ {eq = refl} Rev (↦⃖ηₓ₁ {eq = refl}) _ _ = ↦⃗ηₓ Rev ↦⃖ηₓ₂ _ nf' = ⊥-elim (nf' refl) Rev (↦⃗εₓ₁ {eq = refl}) _ _ = ↦⃖εₓ Rev ↦⃗εₓ₂ _ nf' = ⊥-elim (nf' refl) Rev ↦⃖εₓ _ _ = ↦⃗εₓ₁ {eq = refl} Rev* : ∀ {st st'} → st ↦* st' → (nf : st ≢ ⊠) → (nf' : st' ≢ ⊠) → flip st' nf' ↦* flip st nf Rev* {⟨ _ ∣ _ ∣ _ ⟩▷} ◾ _ _ = ◾ Rev* {[ _ ∣ _ ∣ _ ]▷} ◾ _ _ = ◾ Rev* {⟨ _ ∣ _ ∣ _ ⟩◁} ◾ _ _ = ◾ Rev* {[ _ ∣ _ ∣ _ ]◁} ◾ _ _ = ◾ Rev* {⊠} ◾ nf _ = ⊥-elim (nf refl) Rev* (r ∷ ◾) nf nf' = Rev r nf nf' ∷ ◾ Rev* (r ∷ (r' ∷ rs)) nf nf' = Rev* (r' ∷ rs) nf'' nf' ++↦ (Rev r nf nf'' ∷ ◾) where nf'' = λ eq → ⊠-is-stuck eq (_ , r') -- Helper functions inspect⊎ : ∀ {ℓ ℓ₁ ℓ₂ ℓ₃} {P : Set ℓ} {Q : Set ℓ₁} {R : Set ℓ₂} {S : Set ℓ₃} → (f : P → Q ⊎ R ⊎ S) → (p : P) → (∃[ q ] (inj₁ q ≡ f p)) ⊎ (∃[ r ] (inj₂ (inj₁ r) ≡ f p)) ⊎ (∃[ s ] (inj₂ (inj₂ s) ≡ f p)) inspect⊎ f p with f p ... | inj₁ q = inj₁ (q , refl) ... | inj₂ (inj₁ r) = inj₂ (inj₁ (r , refl)) ... | inj₂ (inj₂ r) = inj₂ (inj₂ (r , refl)) Val≢ : ∀ {A B v₁ v₂} → _⃗ {A} {B} v₁ ≢ v₂ ⃖ Val≢ () Maybe≢ : ∀ {ℓ} {A : Set ℓ} {a : A} → just a ≢ nothing Maybe≢ () toState : ∀ {A B} → (A ↔ B) → Maybe (Val B A) → State toState c (just (b ⃗)) = [ c ∣ b ∣ ☐ ]▷ toState c (just (a ⃖)) = ⟨ c ∣ a ∣ ☐ ⟩◁ toState c nothing = ⊠ is-stuck-toState : ∀ {A B} → (c : A ↔ B) → (v : Maybe (Val B A)) → is-stuck (toState c v) is-stuck-toState c (just (b ⃗)) = λ () is-stuck-toState c (just (a ⃖)) = λ () is-stuck-toState c nothing = λ () toStateEq₁ : ∀ {A B b} → (c : A ↔ B) → (x : Maybe (Val B A)) → [ c ∣ b ∣ ☐ ]▷ ≡ toState c x → just (b ⃗) ≡ x toStateEq₁ c (just (x ⃗)) refl = refl toStateEq₂ : ∀ {A B a} → (c : A ↔ B) → (x : Maybe (Val B A)) → ⟨ c ∣ a ∣ ☐ ⟩◁ ≡ toState c x → just (a ⃖) ≡ x toStateEq₂ c (just (x ⃖)) refl = refl toStateEq₃ : ∀ {A B} → (c : A ↔ B) → (x : Maybe (Val B A)) → ⊠ ≡ toState c x → nothing ≡ x toStateEq₃ c nothing refl = refl toStateEq₃ c (just (x ⃗)) () toStateEq₃ c (just (x ⃖)) () toState≡₁ : ∀ {A B b x} {c : A ↔ B} → toState c x ≡ [ c ∣ b ∣ ☐ ]▷ → x ≡ just (b ⃗) toState≡₁ {x = just (x ⃗)} refl = refl toState≡₂ : ∀ {A B a x} {c : A ↔ B} → toState c x ≡ ⟨ c ∣ a ∣ ☐ ⟩◁ → x ≡ just (a ⃖) toState≡₂ {x = just (x ⃖)} refl = refl toState≡₃ : ∀ {A B x} {c : A ↔ B} → toState c x ≡ ⊠ → x ≡ nothing toState≡₃ {x = nothing} refl = refl toState≡₃ {x = just (x ⃗)} () toState≡₃ {x = just (x ⃖)} () eval-toState₁ : ∀ {A B a x} {c : A ↔ B} → ⟨ c ∣ a ∣ ☐ ⟩▷ ↦* (toState c x) → eval c (a ⃗) ≡ x eval-toState₁ {a = a} {just (b ⃗)} {c} rs with inspect⊎ (run ⟨ c ∣ a ∣ ☐ ⟩▷) (λ ()) eval-toState₁ {a = a} {just (b ⃗)} {c} rs | inj₁ ((a' , rs') , eq) with deterministic* rs rs' (λ ()) (λ ()) ... | () eval-toState₁ {a = a} {just (b ⃗)} {c} rs | inj₂ (inj₁ ((b' , rs') , eq)) with deterministic* rs rs' (λ ()) (λ ()) ... | refl = subst (λ x → [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x ≡ just (b ⃗)) eq refl eval-toState₁ {a = a} {just (b ⃗)} {c} rs | inj₂ (inj₂ (rs' , eq)) with deterministic* rs rs' (λ ()) (λ ()) ... | () eval-toState₁ {a = a} {just (a' ⃖)} {c} rs with inspect⊎ (run ⟨ c ∣ a ∣ ☐ ⟩▷) (λ ()) eval-toState₁ {a = a} {just (a' ⃖)} {c} rs | inj₁ ((a'' , rs') , eq) with deterministic* rs rs' (λ ()) (λ ()) ... | refl = subst (λ x → [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x ≡ just (a' ⃖)) eq refl eval-toState₁ {a = a} {just (a' ⃖)} {c} rs | inj₂ (inj₁ ((b' , rs') , eq)) with deterministic* rs rs' (λ ()) (λ ()) ... | () eval-toState₁ {a = a} {just (a' ⃖)} {c} rs | inj₂ (inj₂ (rs' , eq)) with deterministic* rs rs' (λ ()) (λ ()) ... | () eval-toState₁ {a = a} {nothing} {c} rs with inspect⊎ (run ⟨ c ∣ a ∣ ☐ ⟩▷) (λ ()) eval-toState₁ {a = a} {nothing} {c} rs | inj₁ ((a' , rs') , eq) with deterministic* rs rs' (λ ()) (λ ()) ... | () eval-toState₁ {a = a} {nothing} {c} rs | inj₂ (inj₁ ((b' , rs') , eq)) with deterministic* rs rs' (λ ()) (λ ()) ... | () eval-toState₁ {a = a} {nothing} {c} rs | inj₂ (inj₂ (rs' , eq)) with deterministic* rs rs' (λ ()) (λ ()) ... | refl = subst (λ x → [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x ≡ nothing) eq refl eval-toState₂ : ∀ {A B b x} {c : A ↔ B} → [ c ∣ b ∣ ☐ ]◁ ↦* (toState c x) → eval c (b ⃖) ≡ x eval-toState₂ {b = b} {just (b' ⃗)} {c} rs with inspect⊎ (run [ c ∣ b ∣ ☐ ]◁) (λ ()) eval-toState₂ {b = b} {just (b' ⃗)} {c} rs | inj₁ ((a' , rs') , eq) with deterministic* rs rs' (λ ()) (λ ()) ... | () eval-toState₂ {b = b} {just (b' ⃗)} {c} rs | inj₂ (inj₁ ((b'' , rs') , eq)) with deterministic* rs rs' (λ ()) (λ ()) ... | refl = subst (λ x → [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x ≡ just (b' ⃗)) eq refl eval-toState₂ {b = b} {just (b' ⃗)} {c} rs | inj₂ (inj₂ (rs' , eq)) with deterministic* rs rs' (λ ()) (λ ()) ... | () eval-toState₂ {b = b} {just (a ⃖)} {c} rs with inspect⊎ (run [ c ∣ b ∣ ☐ ]◁) (λ ()) eval-toState₂ {b = b} {just (a ⃖)} {c} rs | inj₁ ((a'' , rs') , eq) with deterministic* rs rs' (λ ()) (λ ()) ... | refl = subst (λ x → [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x ≡ just (a ⃖)) eq refl eval-toState₂ {b = b} {just (a ⃖)} {c} rs | inj₂ (inj₁ ((b' , rs') , eq)) with deterministic* rs rs' (λ ()) (λ ()) ... | () eval-toState₂ {b = b} {just (a ⃖)} {c} rs | inj₂ (inj₂ (rs' , eq)) with deterministic* rs rs' (λ ()) (λ ()) ... | () eval-toState₂ {b = b} {nothing} {c} rs with inspect⊎ (run [ c ∣ b ∣ ☐ ]◁) (λ ()) eval-toState₂ {b = b} {nothing} {c} rs | inj₁ ((a' , rs') , eq) with deterministic* rs rs' (λ ()) (λ ()) ... | () eval-toState₂ {b = b} {nothing} {c} rs | inj₂ (inj₁ ((b' , rs') , eq)) with deterministic* rs rs' (λ ()) (λ ()) ... | () eval-toState₂ {b = b} {nothing} {c} rs | inj₂ (inj₂ (rs' , eq)) with deterministic* rs rs' (λ ()) (λ ()) ... | refl = subst (λ x → [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x ≡ nothing) eq refl getₜᵣ⃗ : ∀ {A B} → (c : A ↔ B) → {v : ⟦ A ⟧} {v' : Maybe (Val B A)} → eval c (v ⃗) ≡ v' → ⟨ c ∣ v ∣ ☐ ⟩▷ ↦* toState c v' getₜᵣ⃗ c {v} {v'} eq with inspect⊎ (run ⟨ c ∣ v ∣ ☐ ⟩▷) (λ ()) getₜᵣ⃗ c {v} {nothing} eq | inj₁ ((x₁ , rs₁) , eq₁) with trans (subst (λ x → just (x₁ ⃖) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq₁ refl) eq ... | () getₜᵣ⃗ c {v} {just (x ⃗)} eq | inj₁ ((x₁ , rs₁) , eq₁) with trans (subst (λ x → just (x₁ ⃖) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq₁ refl) eq ... | () getₜᵣ⃗ c {v} {just (x ⃖)} eq | inj₁ ((x₁ , rs₁) , eq₁) with trans (subst (λ x → just (x₁ ⃖) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq₁ refl) eq ... | refl = rs₁ getₜᵣ⃗ c {v} {nothing} eq | inj₂ (inj₁ ((x₁ , rs₁) , eq₁)) with trans (subst (λ x → just (x₁ ⃗) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq₁ refl) eq ... | () getₜᵣ⃗ c {v} {just (x ⃗)} eq | inj₂ (inj₁ ((x₁ , rs₁) , eq₁)) with trans (subst (λ x → just (x₁ ⃗) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq₁ refl) eq ... | refl = rs₁ getₜᵣ⃗ c {v} {just (x ⃖)} eq | inj₂ (inj₁ ((x₁ , rs₁) , eq₁)) with trans (subst (λ x → just (x₁ ⃗) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq₁ refl) eq ... | () getₜᵣ⃗ c {v} {nothing} eq | inj₂ (inj₂ (rs₁ , eq₁)) with trans (subst (λ x → nothing ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq₁ refl) eq ... | refl = rs₁ getₜᵣ⃗ c {v} {just (x ⃗)} eq | inj₂ (inj₂ (rs₁ , eq₁)) with trans (subst (λ x → nothing ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq₁ refl) eq ... | () getₜᵣ⃗ c {v} {just (x ⃖)} eq | inj₂ (inj₂ (rs₁ , eq₁)) with trans (subst (λ x → nothing ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq₁ refl) eq ... | () getₜᵣ⃖ : ∀ {A B} → (c : A ↔ B) → {v : ⟦ B ⟧} {v' : Maybe (Val B A)} → eval c (v ⃖) ≡ v' → [ c ∣ v ∣ ☐ ]◁ ↦* toState c v' getₜᵣ⃖ c {v} {v'} eq with inspect⊎ (run [ c ∣ v ∣ ☐ ]◁) (λ ()) getₜᵣ⃖ c {v} {nothing} eq | inj₁ ((x₁ , rs₁) , eq₁) with trans (subst (λ x → just (x₁ ⃖) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq₁ refl) eq ... | () getₜᵣ⃖ c {v} {just (x ⃗)} eq | inj₁ ((x₁ , rs₁) , eq₁) with trans (subst (λ x → just (x₁ ⃖) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq₁ refl) eq ... | () getₜᵣ⃖ c {v} {just (x ⃖)} eq | inj₁ ((x₁ , rs₁) , eq₁) with trans (subst (λ x → just (x₁ ⃖) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq₁ refl) eq ... | refl = rs₁ getₜᵣ⃖ c {v} {nothing} eq | inj₂ (inj₁ ((x₁ , rs₁) , eq₁)) with trans (subst (λ x → just (x₁ ⃗) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq₁ refl) eq ... | () getₜᵣ⃖ c {v} {just (x ⃗)} eq | inj₂ (inj₁ ((x₁ , rs₁) , eq₁)) with trans (subst (λ x → just (x₁ ⃗) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq₁ refl) eq ... | refl = rs₁ getₜᵣ⃖ c {v} {just (x ⃖)} eq | inj₂ (inj₁ ((x₁ , rs₁) , eq₁)) with trans (subst (λ x → just (x₁ ⃗) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq₁ refl) eq ... | () getₜᵣ⃖ c {v} {nothing} eq | inj₂ (inj₂ (rs₁ , eq₁)) with trans (subst (λ x → nothing ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq₁ refl) eq ... | refl = rs₁ getₜᵣ⃖ c {v} {just (x ⃗)} eq | inj₂ (inj₂ (rs₁ , eq₁)) with trans (subst (λ x → nothing ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq₁ refl) eq ... | () getₜᵣ⃖ c {v} {just (x ⃖)} eq | inj₂ (inj₂ (rs₁ , eq₁)) with trans (subst (λ x → nothing ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq₁ refl) eq ... | () -- Forward evaluator is reversible evalIsRev : ∀ {A B} → (c : A ↔ B) (v₁ : Val A B) (v₂ : Val B A) → eval c v₁ ≡ (just v₂) → evalᵣₑᵥ c v₂ ≡ (just v₁) evalIsRev c (v₁ ⃗) (v₂ ⃗) eq with inspect⊎ (run ⟨ c ∣ v₁ ∣ ☐ ⟩▷) (λ ()) evalIsRev c (v₁ ⃗) (v₂ ⃗) eq | inj₁ ((u , rs) , eq') = ⊥-elim (Val≢ (sym (just-injective contr))) where contr : just (u ⃖) ≡ just (v₂ ⃗) contr = trans (subst (λ x → just (u ⃖) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq evalIsRev c (v₁ ⃗) (v₂ ⃗) eq | inj₂ (inj₁ ((u , rs) , eq')) = subst (λ x → evalᵣₑᵥ c x ≡ just (v₁ ⃗)) u≡v₂ rsinv where u≡v₂ : (u ⃗) ≡ (v₂ ⃗) u≡v₂ = just-injective (trans (subst (λ x → just (u ⃗) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq) rsinv : evalᵣₑᵥ c (u ⃗) ≡ just (v₁ ⃗) rsinv with u≡v₂ | inspect⊎ (run [ c ∣ v₂ ∣ ☐ ]◁) (λ ()) rsinv | refl | inj₁ ((w , rs') , eq'') with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | refl = subst (λ x → [ just ∘ _⃗ ∘ proj₁ , [ just ∘ _⃖ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x ≡ just (v₁ ⃗)) eq'' refl rsinv | refl | inj₂ (inj₁ ((w , rs') , eq'')) with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | () rsinv | refl | inj₂ (inj₂ (rs' , eq'')) with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | () evalIsRev c (v₁ ⃗) (v₂ ⃗) eq | inj₂ (inj₂ (rs , eq')) = ⊥-elim (Maybe≢ (sym contr)) where contr : nothing ≡ just (v₂ ⃗) contr = trans (subst (λ x → nothing ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq evalIsRev c (v₁ ⃗) (v₂ ⃖) eq with inspect⊎ (run ⟨ c ∣ v₁ ∣ ☐ ⟩▷) (λ ()) evalIsRev c (v₁ ⃗) (v₂ ⃖) eq | inj₁ ((u , rs) , eq') = subst (λ x → evalᵣₑᵥ c x ≡ just (v₁ ⃗)) u≡v₂ rsinv where u≡v₂ : (u ⃖) ≡ (v₂ ⃖) u≡v₂ = just-injective (trans (subst (λ x → just (u ⃖) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq) rsinv : evalᵣₑᵥ c (u ⃖) ≡ just (v₁ ⃗) rsinv with u≡v₂ | inspect⊎ (run ⟨ c ∣ u ∣ ☐ ⟩▷) (λ ()) rsinv | refl | inj₁ ((w , rs') , eq'') with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | refl = subst (λ x → [ just ∘ _⃗ ∘ proj₁ , [ just ∘ _⃖ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x ≡ just (v₁ ⃗)) eq'' refl rsinv | refl | inj₂ (inj₁ ((w , rs') , eq'')) with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | () rsinv | refl | inj₂ (inj₂ (rs' , eq'')) with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | () evalIsRev c (v₁ ⃗) (v₂ ⃖) eq | inj₂ (inj₁ ((u , rs) , eq')) = ⊥-elim (Val≢ (just-injective contr)) where contr : just (u ⃗) ≡ just (v₂ ⃖) contr = trans (subst (λ x → just (u ⃗) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq evalIsRev c (v₁ ⃗) (v₂ ⃖) eq | inj₂ (inj₂ (rs , eq')) = ⊥-elim (Maybe≢ (sym contr)) where contr : nothing ≡ just (v₂ ⃖) contr = trans (subst (λ x → nothing ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq evalIsRev c (v₁ ⃖) (v₂ ⃗) eq with inspect⊎ (run [ c ∣ v₁ ∣ ☐ ]◁) (λ ()) evalIsRev c (v₁ ⃖) (v₂ ⃗) eq | inj₁ ((u , rs) , eq') = ⊥-elim (Val≢ (just-injective (sym contr))) where contr : just (u ⃖) ≡ just (v₂ ⃗) contr = trans (subst (λ x → just (u ⃖) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq evalIsRev c (v₁ ⃖) (v₂ ⃗) eq | inj₂ (inj₁ ((u , rs) , eq')) = subst (λ x → evalᵣₑᵥ c x ≡ just (v₁ ⃖)) u≡v₂ rsinv where u≡v₂ : (u ⃗) ≡ (v₂ ⃗) u≡v₂ = just-injective (trans (subst (λ x → just (u ⃗) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq) rsinv : evalᵣₑᵥ c (u ⃗) ≡ just (v₁ ⃖) rsinv with u≡v₂ | inspect⊎ (run [ c ∣ u ∣ ☐ ]◁) (λ ()) rsinv | refl | inj₁ ((w , rs') , eq'') with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | () rsinv | refl | inj₂ (inj₁ ((w , rs') , eq'')) with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | refl = subst (λ x → [ just ∘ _⃗ ∘ proj₁ , [ just ∘ _⃖ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x ≡ just (v₁ ⃖)) eq'' refl rsinv | refl | inj₂ (inj₂ (rs' , eq'')) with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | () evalIsRev c (v₁ ⃖) (v₂ ⃗) eq | inj₂ (inj₂ (rs , eq')) = ⊥-elim (Maybe≢ (sym contr)) where contr : nothing ≡ just (v₂ ⃗) contr = trans (subst (λ x → nothing ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq evalIsRev c (v₁ ⃖) (v₂ ⃖) eq with inspect⊎ (run [ c ∣ v₁ ∣ ☐ ]◁) (λ ()) evalIsRev c (v₁ ⃖) (v₂ ⃖) eq | inj₁ ((u , rs) , eq') = subst (λ x → evalᵣₑᵥ c x ≡ just (v₁ ⃖)) u≡v₂ rsinv where u≡v₂ : (u ⃖) ≡ (v₂ ⃖) u≡v₂ = just-injective (trans (subst (λ x → just (u ⃖) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq) rsinv : evalᵣₑᵥ c (u ⃖) ≡ just (v₁ ⃖) rsinv with u≡v₂ | inspect⊎ (run ⟨ c ∣ u ∣ ☐ ⟩▷) (λ ()) rsinv | refl | inj₁ ((w , rs') , eq'') with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | () rsinv | refl | inj₂ (inj₁ ((w , rs') , eq'')) with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | refl = subst (λ x → [ just ∘ _⃗ ∘ proj₁ , [ just ∘ _⃖ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x ≡ just (v₁ ⃖)) eq'' refl rsinv | refl | inj₂ (inj₂ (rs' , eq'')) with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | () evalIsRev c (v₁ ⃖) (v₂ ⃖) eq | inj₂ (inj₁ ((u , rs) , eq')) = ⊥-elim (Val≢ (just-injective contr)) where contr : just (u ⃗) ≡ just (v₂ ⃖) contr = trans (subst (λ x → just (u ⃗) ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq evalIsRev c (v₁ ⃖) (v₂ ⃖) eq | inj₂ (inj₂ (rs , eq')) = ⊥-elim (Maybe≢ (sym contr)) where contr : nothing ≡ just (v₂ ⃖) contr = trans (subst (λ x → nothing ≡ [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq -- Backward evaluator is reversible evalᵣₑᵥIsRev : ∀ {A B} → (c : A ↔ B) (v₁ : Val B A) (v₂ : Val A B) → evalᵣₑᵥ c v₁ ≡ (just v₂) → eval c v₂ ≡ (just v₁) evalᵣₑᵥIsRev c (v₁ ⃗) (v₂ ⃗) eq with inspect⊎ (run [ c ∣ v₁ ∣ ☐ ]◁) (λ ()) evalᵣₑᵥIsRev c (v₁ ⃗) (v₂ ⃗) eq | inj₁ ((u , rs) , eq') = subst (λ x → eval c x ≡ just (v₁ ⃗)) u≡v₂ rsinv where u≡v₂ : (u ⃗) ≡ (v₂ ⃗) u≡v₂ = just-injective (trans (subst (λ x → just (u ⃗) ≡ [ just ∘ _⃗ ∘ proj₁ , [ just ∘ _⃖ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq) rsinv : eval c (u ⃗) ≡ just (v₁ ⃗) rsinv with inspect⊎ (run ⟨ c ∣ u ∣ ☐ ⟩▷) (λ ()) rsinv | inj₁ ((w , rs') , eq'') with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | () rsinv | inj₂ (inj₁ ((w , rs') , eq'')) with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | refl = subst (λ x → [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x ≡ just (v₁ ⃗)) eq'' refl rsinv | inj₂ (inj₂ (rs' , eq'')) with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | () evalᵣₑᵥIsRev c (v₁ ⃗) (v₂ ⃗) eq | inj₂ (inj₁ ((u , rs) , eq')) = ⊥-elim (Val≢ (sym (just-injective contr))) where contr : just (u ⃖) ≡ just (v₂ ⃗) contr = trans (subst (λ x → just (u ⃖) ≡ [ just ∘ _⃗ ∘ proj₁ , [ just ∘ _⃖ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq evalᵣₑᵥIsRev c (v₁ ⃗) (v₂ ⃗) eq | inj₂ (inj₂ (rs' , eq')) = ⊥-elim (Maybe≢ (sym contr)) where contr : nothing ≡ just (v₂ ⃗) contr = trans (subst (λ x → nothing ≡ [ just ∘ _⃗ ∘ proj₁ , [ just ∘ _⃖ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq evalᵣₑᵥIsRev c (v₁ ⃗) (v₂ ⃖) eq with inspect⊎ (run [ c ∣ v₁ ∣ ☐ ]◁) (λ ()) evalᵣₑᵥIsRev c (v₁ ⃗) (v₂ ⃖) eq | inj₁ ((u , rs) , eq') = ⊥-elim (Val≢ (just-injective contr)) where contr : just (u ⃗) ≡ just (v₂ ⃖) contr = trans (subst (λ x → just (u ⃗) ≡ [ just ∘ _⃗ ∘ proj₁ , [ just ∘ _⃖ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq evalᵣₑᵥIsRev c (v₁ ⃗) (v₂ ⃖) eq | inj₂ (inj₁ ((u , rs) , eq')) = subst (λ x → eval c x ≡ just (v₁ ⃗)) u≡v₂ rsinv where u≡v₂ : (u ⃖) ≡ (v₂ ⃖) u≡v₂ = just-injective (trans (subst (λ x → just (u ⃖) ≡ [ just ∘ _⃗ ∘ proj₁ , [ just ∘ _⃖ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq) rsinv : eval c (u ⃖) ≡ just (v₁ ⃗) rsinv with inspect⊎ (run [ c ∣ u ∣ ☐ ]◁) (λ ()) rsinv | inj₁ ((w , rs') , eq'') with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | () rsinv | inj₂ (inj₁ ((w , rs') , eq'')) with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | refl = subst (λ x → [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x ≡ just (v₁ ⃗)) eq'' refl rsinv | inj₂ (inj₂ (rs' , eq'')) with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | () evalᵣₑᵥIsRev c (v₁ ⃗) (v₂ ⃖) eq | inj₂ (inj₂ (rs' , eq')) = ⊥-elim (Maybe≢ (sym contr)) where contr : nothing ≡ just (v₂ ⃖) contr = trans (subst (λ x → nothing ≡ [ just ∘ _⃗ ∘ proj₁ , [ just ∘ _⃖ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq evalᵣₑᵥIsRev c (v₁ ⃖) (v₂ ⃗) eq with inspect⊎ (run ⟨ c ∣ v₁ ∣ ☐ ⟩▷) (λ ()) evalᵣₑᵥIsRev c (v₁ ⃖) (v₂ ⃗) eq | inj₁ ((u , rs) , eq') = subst (λ x → eval c x ≡ just (v₁ ⃖)) u≡v₂ rsinv where u≡v₂ : (u ⃗) ≡ (v₂ ⃗) u≡v₂ = just-injective (trans (subst (λ x → just (u ⃗) ≡ [ just ∘ _⃗ ∘ proj₁ , [ just ∘ _⃖ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq) rsinv : eval c (u ⃗) ≡ just (v₁ ⃖) rsinv with inspect⊎ (run ⟨ c ∣ u ∣ ☐ ⟩▷) (λ ()) rsinv | inj₁ ((w , rs') , eq'') with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | refl = subst (λ x → [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x ≡ just (v₁ ⃖)) eq'' refl rsinv | inj₂ (inj₁ ((w , rs') , eq'')) with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | () rsinv | inj₂ (inj₂ (rs' , eq'')) with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | () evalᵣₑᵥIsRev c (v₁ ⃖) (v₂ ⃗) eq | inj₂ (inj₁ ((u , rs) , eq')) = ⊥-elim (Val≢ (sym (just-injective contr))) where contr : just (u ⃖) ≡ just (v₂ ⃗) contr = trans (subst (λ x → just (u ⃖) ≡ [ just ∘ _⃗ ∘ proj₁ , [ just ∘ _⃖ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq evalᵣₑᵥIsRev c (v₁ ⃖) (v₂ ⃗) eq | inj₂ (inj₂ (rs' , eq')) = ⊥-elim (Maybe≢ (sym contr)) where contr : nothing ≡ just (v₂ ⃗) contr = trans (subst (λ x → nothing ≡ [ just ∘ _⃗ ∘ proj₁ , [ just ∘ _⃖ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq evalᵣₑᵥIsRev c (v₁ ⃖) (v₂ ⃖) eq with inspect⊎ (run ⟨ c ∣ v₁ ∣ ☐ ⟩▷) (λ ()) evalᵣₑᵥIsRev c (v₁ ⃖) (v₂ ⃖) eq | inj₁ ((u , rs) , eq') = ⊥-elim (Val≢ (just-injective contr)) where contr : just (u ⃗) ≡ just (v₂ ⃖) contr = trans (subst (λ x → just (u ⃗) ≡ [ just ∘ _⃗ ∘ proj₁ , [ just ∘ _⃖ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq evalᵣₑᵥIsRev c (v₁ ⃖) (v₂ ⃖) eq | inj₂ (inj₁ ((u , rs) , eq')) = subst (λ x → eval c x ≡ just (v₁ ⃖)) u≡v₂ rsinv where u≡v₂ : (u ⃖) ≡ (v₂ ⃖) u≡v₂ = just-injective (trans (subst (λ x → just (u ⃖) ≡ [ just ∘ _⃗ ∘ proj₁ , [ just ∘ _⃖ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq) rsinv : eval c (u ⃖) ≡ just (v₁ ⃖) rsinv with inspect⊎ (run [ c ∣ u ∣ ☐ ]◁) (λ ()) rsinv | inj₁ ((w , rs') , eq'') with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | refl = subst (λ x → [ just ∘ _⃖ ∘ proj₁ , [ just ∘ _⃗ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x ≡ just (v₁ ⃖)) eq'' refl rsinv | inj₂ (inj₁ ((w , rs') , eq'')) with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | () rsinv | inj₂ (inj₂ (rs' , eq'')) with deterministic* rs' (Rev* rs (λ ()) (λ ())) (λ ()) (λ ()) ... | () evalᵣₑᵥIsRev c (v₁ ⃖) (v₂ ⃖) eq | inj₂ (inj₂ (rs' , eq')) = ⊥-elim (Maybe≢ (sym contr)) where contr : nothing ≡ just (v₂ ⃖) contr = trans (subst (λ x → nothing ≡ [ just ∘ _⃗ ∘ proj₁ , [ just ∘ _⃖ ∘ proj₁ , (λ _ → nothing) ]′ ]′ x) eq' refl) eq -- The abstract machine semantics is equivalent to the big-step semantics mutual eval≡interp : ∀ {A B} → (c : A ↔ B) → (v : Val A B) → eval c v ≡ interp c v eval≡interp unite₊l (inj₂ v ⃗) = refl eval≡interp unite₊l (v ⃖) = refl eval≡interp uniti₊l (v ⃗) = refl eval≡interp uniti₊l (inj₂ v ⃖) = refl eval≡interp swap₊ (inj₁ x ⃗) = refl eval≡interp swap₊ (inj₂ y ⃗) = refl eval≡interp swap₊ (inj₁ x ⃖) = refl eval≡interp swap₊ (inj₂ y ⃖) = refl eval≡interp assocl₊ (inj₁ x ⃗) = refl eval≡interp assocl₊ (inj₂ (inj₁ y) ⃗) = refl eval≡interp assocl₊ (inj₂ (inj₂ z) ⃗) = refl eval≡interp assocl₊ (inj₁ (inj₁ x) ⃖) = refl eval≡interp assocl₊ (inj₁ (inj₂ y) ⃖) = refl eval≡interp assocl₊ (inj₂ z ⃖) = refl eval≡interp assocr₊ (inj₁ (inj₁ x) ⃗) = refl eval≡interp assocr₊ (inj₁ (inj₂ y) ⃗) = refl eval≡interp assocr₊ (inj₂ z ⃗) = refl eval≡interp assocr₊ (inj₁ x ⃖) = refl eval≡interp assocr₊ (inj₂ (inj₁ y) ⃖) = refl eval≡interp assocr₊ (inj₂ (inj₂ z) ⃖) = refl eval≡interp unite⋆l ((tt , v) ⃗) = refl eval≡interp unite⋆l (v ⃖) = refl eval≡interp uniti⋆l (v ⃗) = refl eval≡interp uniti⋆l ((tt , v) ⃖) = refl eval≡interp swap⋆ ((x , y) ⃗) = refl eval≡interp swap⋆ ((y , x) ⃖) = refl eval≡interp assocl⋆ ((x , (y , z)) ⃗) = refl eval≡interp assocl⋆ (((x , y) , z) ⃖) = refl eval≡interp assocr⋆ (((x , y) , z) ⃗) = refl eval≡interp assocr⋆ ((x , (y , z)) ⃖) = refl eval≡interp absorbr (() ⃗) eval≡interp absorbr (() ⃖) eval≡interp factorzl (() ⃗) eval≡interp factorzl (() ⃖) eval≡interp dist ((inj₁ x , z) ⃗) = refl eval≡interp dist ((inj₂ y , z) ⃗) = refl eval≡interp dist (inj₁ (x , z) ⃖) = refl eval≡interp dist (inj₂ (y , z) ⃖) = refl eval≡interp factor (inj₁ (x , z) ⃗) = refl eval≡interp factor (inj₂ (y , z) ⃗) = refl eval≡interp factor ((inj₁ x , z) ⃖) = refl eval≡interp factor ((inj₂ y , z) ⃖) = refl eval≡interp id↔ (v ⃗) = refl eval≡interp id↔ (v ⃖) = refl eval≡interp η₊ (inj₁ x ⃖) = refl eval≡interp η₊ (inj₂ (- x) ⃖) = refl eval≡interp ε₊ (inj₁ x ⃗) = refl eval≡interp ε₊ (inj₂ (- x) ⃗) = refl eval≡interp (ηₓ v) (tt ⃗) = refl eval≡interp (ηₓ v) ((v' , ↻) ⃖) with v ≟ v' ... | yes refl = refl ... | no neq = refl eval≡interp (εₓ v) ((v' , ↻) ⃗) with v ≟ v' ... | yes refl = refl ... | no neq = refl eval≡interp (εₓ v) (tt ⃖) = refl eval≡interp (c₁ ⨾ c₂) (a ⃗) with interp c₁ (a ⃗) | inspect (interp c₁) (a ⃗) eval≡interp (c₁ ⨾ c₂) (a ⃗) | just (b ⃗) | [ eq₁ ] = lem where rs : ⟨ c₁ ⨾ c₂ ∣ a ∣ ☐ ⟩▷ ↦* [ c₁ ∣ b ∣ ☐⨾ c₂ • ☐ ]▷ rs = ↦⃗₃ ∷ appendκ↦* ((getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (a ⃗)) eq₁))) (λ ()) (λ ()) refl (☐⨾ c₂ • ☐) rs' : [ c₁ ∣ b ∣ ☐⨾ c₂ • ☐ ]▷ ↦* (toState (c₁ ⨾ c₂) (eval (c₁ ⨾ c₂) (a ⃗))) rs' = proj₁ (deterministic*' rs (getₜᵣ⃗ (c₁ ⨾ c₂) refl) (is-stuck-toState _ _)) lem : eval (c₁ ⨾ c₂) (a ⃗) ≡ (c₁ ⨾[ b ⃗]⨾ c₂) lem = proj₁ (loop (len↦ rs') b) rs' refl eval≡interp (c₁ ⨾ c₂) (a ⃗) | just (a₁ ⃖) | [ eq₁ ] = lem where rs : ⟨ c₁ ⨾ c₂ ∣ a ∣ ☐ ⟩▷ ↦* ⟨ c₁ ⨾ c₂ ∣ a₁ ∣ ☐ ⟩◁ rs = ↦⃗₃ ∷ appendκ↦* ((getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (a ⃗)) eq₁))) (λ ()) (λ ()) refl (☐⨾ c₂ • ☐) ++↦ ↦⃖₃ ∷ ◾ lem : eval (c₁ ⨾ c₂) (a ⃗) ≡ just (a₁ ⃖) lem = eval-toState₁ rs eval≡interp (c₁ ⨾ c₂) (a ⃗) | nothing | [ eq₁ ] = lem where rs' : ⟨ c₁ ⨾ c₂ ∣ a ∣ ☐ ⟩▷ ↦* ⊠ rs' = ↦⃗₃ ∷ appendκ↦*⊠ ((getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (a ⃗)) eq₁))) (λ ()) (☐⨾ c₂ • ☐) lem : eval (c₁ ⨾ c₂) (a ⃗) ≡ nothing lem = eval-toState₁ rs' eval≡interp (c₁ ⨾ c₂) (c ⃖) with interp c₂ (c ⃖) | inspect (interp c₂) (c ⃖) eval≡interp (c₁ ⨾ c₂) (c ⃖) | just (c' ⃗) | [ eq' ] = lem where rs' : [ c₁ ⨾ c₂ ∣ c ∣ ☐ ]◁ ↦* [ c₁ ⨾ c₂ ∣ c' ∣ ☐ ]▷ rs' = ↦⃖₁₀ ∷ appendκ↦* ((getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (c ⃖)) eq'))) (λ ()) (λ ()) refl (c₁ ⨾☐• ☐) ++↦ ↦⃗₁₀ ∷ ◾ lem : eval (c₁ ⨾ c₂) (c ⃖) ≡ just (c' ⃗) lem = eval-toState₂ rs' eval≡interp (c₁ ⨾ c₂) (c ⃖) | just (b ⃖) | [ eq' ] = lem where rs : [ c₁ ⨾ c₂ ∣ c ∣ ☐ ]◁ ↦* ⟨ c₂ ∣ b ∣ c₁ ⨾☐• ☐ ⟩◁ rs = ↦⃖₁₀ ∷ appendκ↦* ((getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (c ⃖)) eq'))) (λ ()) (λ ()) refl (c₁ ⨾☐• ☐) rs' : ⟨ c₂ ∣ b ∣ c₁ ⨾☐• ☐ ⟩◁ ↦* (toState (c₁ ⨾ c₂) (eval (c₁ ⨾ c₂) (c ⃖))) rs' = proj₁ (deterministic*' rs (getₜᵣ⃖ (c₁ ⨾ c₂) refl) (is-stuck-toState _ _)) lem : eval (c₁ ⨾ c₂) (c ⃖) ≡ (c₁ ⨾[ b ⃖]⨾ c₂) lem = proj₂ (loop (len↦ rs') b) rs' refl eval≡interp (c₁ ⨾ c₂) (c ⃖) | nothing | [ eq' ] = lem where rs' : [ c₁ ⨾ c₂ ∣ c ∣ ☐ ]◁ ↦* ⊠ rs' = ↦⃖₁₀ ∷ appendκ↦*⊠ ((getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (c ⃖)) eq'))) (λ ()) (c₁ ⨾☐• ☐) lem : eval (c₁ ⨾ c₂) (c ⃖) ≡ nothing lem = eval-toState₂ rs' eval≡interp (c₁ ⊕ c₂) (inj₁ x ⃗) with interp c₁ (x ⃗) | inspect (interp c₁) (x ⃗) eval≡interp (c₁ ⊕ c₂) (inj₁ x ⃗) | just (x₁ ⃗) | [ eq₁ ] = eval-toState₁ rs' where rs' : ⟨ c₁ ⊕ c₂ ∣ inj₁ x ∣ ☐ ⟩▷ ↦* [ c₁ ⊕ c₂ ∣ inj₁ x₁ ∣ ☐ ]▷ rs' = ↦⃗₄ ∷ appendκ↦* (getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (x ⃗)) eq₁)) (λ ()) (λ ()) refl (☐⊕ c₂ • ☐) ++↦ ↦⃗₁₁ ∷ ◾ eval≡interp (c₁ ⊕ c₂) (inj₁ x ⃗) | just (x₁ ⃖) | [ eq₁ ] = eval-toState₁ rs' where rs' : ⟨ c₁ ⊕ c₂ ∣ inj₁ x ∣ ☐ ⟩▷ ↦* ⟨ c₁ ⊕ c₂ ∣ inj₁ x₁ ∣ ☐ ⟩◁ rs' = ↦⃗₄ ∷ appendκ↦* (getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (x ⃗)) eq₁)) (λ ()) (λ ()) refl (☐⊕ c₂ • ☐) ++↦ ↦⃖₄ ∷ ◾ eval≡interp (c₁ ⊕ c₂) (inj₁ x ⃗) | nothing | [ eq₁ ] = eval-toState₁ rs' where rs' : ⟨ c₁ ⊕ c₂ ∣ inj₁ x ∣ ☐ ⟩▷ ↦* ⊠ rs' = ↦⃗₄ ∷ appendκ↦*⊠ (getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (x ⃗)) eq₁)) (λ ()) (☐⊕ c₂ • ☐) eval≡interp (c₁ ⊕ c₂) (inj₂ y ⃗) with interp c₂ (y ⃗) | inspect (interp c₂) (y ⃗) eval≡interp (c₁ ⊕ c₂) (inj₂ y ⃗) | just (y₁ ⃗) | [ eq₁ ] = eval-toState₁ rs' where rs' : ⟨ c₁ ⊕ c₂ ∣ inj₂ y ∣ ☐ ⟩▷ ↦* [ c₁ ⊕ c₂ ∣ inj₂ y₁ ∣ ☐ ]▷ rs' = ↦⃗₅ ∷ appendκ↦* (getₜᵣ⃗ c₂ (trans (eval≡interp c₂ (y ⃗)) eq₁)) (λ ()) (λ ()) refl (c₁ ⊕☐• ☐) ++↦ ↦⃗₁₂ ∷ ◾ eval≡interp (c₁ ⊕ c₂) (inj₂ y ⃗) | just (y₁ ⃖) | [ eq₁ ] = eval-toState₁ rs' where rs' : ⟨ c₁ ⊕ c₂ ∣ inj₂ y ∣ ☐ ⟩▷ ↦* ⟨ c₁ ⊕ c₂ ∣ inj₂ y₁ ∣ ☐ ⟩◁ rs' = ↦⃗₅ ∷ appendκ↦* (getₜᵣ⃗ c₂ (trans (eval≡interp c₂ (y ⃗)) eq₁)) (λ ()) (λ ()) refl (c₁ ⊕☐• ☐) ++↦ ↦⃖₅ ∷ ◾ eval≡interp (c₁ ⊕ c₂) (inj₂ y ⃗) | nothing | [ eq₁ ] = eval-toState₁ rs' where rs' : ⟨ c₁ ⊕ c₂ ∣ inj₂ y ∣ ☐ ⟩▷ ↦* ⊠ rs' = ↦⃗₅ ∷ appendκ↦*⊠ (getₜᵣ⃗ c₂ (trans (eval≡interp c₂ (y ⃗)) eq₁)) (λ ()) (c₁ ⊕☐• ☐) eval≡interp (c₁ ⊕ c₂) (inj₁ x ⃖) with interp c₁ (x ⃖) | inspect (interp c₁) (x ⃖) eval≡interp (c₁ ⊕ c₂) (inj₁ x ⃖) | just (x₁ ⃗) | [ eq₁ ] = eval-toState₂ rs' where rs' : [ c₁ ⊕ c₂ ∣ inj₁ x ∣ ☐ ]◁ ↦* [ c₁ ⊕ c₂ ∣ inj₁ x₁ ∣ ☐ ]▷ rs' = ↦⃖₁₁ ∷ appendκ↦* (getₜᵣ⃖ c₁ (trans (eval≡interp c₁ (x ⃖)) eq₁)) (λ ()) (λ ()) refl (☐⊕ c₂ • ☐) ++↦ ↦⃗₁₁ ∷ ◾ eval≡interp (c₁ ⊕ c₂) (inj₁ x ⃖) | just (x₁ ⃖) | [ eq₁ ] = eval-toState₂ rs' where rs' : [ c₁ ⊕ c₂ ∣ inj₁ x ∣ ☐ ]◁ ↦* ⟨ c₁ ⊕ c₂ ∣ inj₁ x₁ ∣ ☐ ⟩◁ rs' = ↦⃖₁₁ ∷ appendκ↦* (getₜᵣ⃖ c₁ (trans (eval≡interp c₁ (x ⃖)) eq₁)) (λ ()) (λ ()) refl (☐⊕ c₂ • ☐) ++↦ ↦⃖₄ ∷ ◾ eval≡interp (c₁ ⊕ c₂) (inj₁ x ⃖) | nothing | [ eq₁ ] = eval-toState₂ rs' where rs' : [ c₁ ⊕ c₂ ∣ inj₁ x ∣ ☐ ]◁ ↦* ⊠ rs' = ↦⃖₁₁ ∷ appendκ↦*⊠ (getₜᵣ⃖ c₁ (trans (eval≡interp c₁ (x ⃖)) eq₁)) (λ ()) (☐⊕ c₂ • ☐) eval≡interp (c₁ ⊕ c₂) (inj₂ y ⃖) with interp c₂ (y ⃖) | inspect (interp c₂) (y ⃖) eval≡interp (c₁ ⊕ c₂) (inj₂ y ⃖) | just (y₁ ⃗) | [ eq₁ ] = eval-toState₂ rs' where rs' : [ c₁ ⊕ c₂ ∣ inj₂ y ∣ ☐ ]◁ ↦* [ c₁ ⊕ c₂ ∣ inj₂ y₁ ∣ ☐ ]▷ rs' = ↦⃖₁₂ ∷ appendκ↦* (getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (y ⃖)) eq₁)) (λ ()) (λ ()) refl (c₁ ⊕☐• ☐) ++↦ ↦⃗₁₂ ∷ ◾ eval≡interp (c₁ ⊕ c₂) (inj₂ y ⃖) | just (y₁ ⃖) | [ eq₁ ] = eval-toState₂ rs' where rs' : [ c₁ ⊕ c₂ ∣ inj₂ y ∣ ☐ ]◁ ↦* ⟨ c₁ ⊕ c₂ ∣ inj₂ y₁ ∣ ☐ ⟩◁ rs' = ↦⃖₁₂ ∷ appendκ↦* (getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (y ⃖)) eq₁)) (λ ()) (λ ()) refl (c₁ ⊕☐• ☐) ++↦ ↦⃖₅ ∷ ◾ eval≡interp (c₁ ⊕ c₂) (inj₂ y ⃖) | nothing | [ eq₁ ] = eval-toState₂ rs' where rs' : [ c₁ ⊕ c₂ ∣ inj₂ y ∣ ☐ ]◁ ↦* ⊠ rs' = ↦⃖₁₂ ∷ appendκ↦*⊠ (getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (y ⃖)) eq₁)) (λ ()) (c₁ ⊕☐• ☐) eval≡interp (c₁ ⊗ c₂) ((x , y) ⃗) with interp c₁ (x ⃗) | inspect (interp c₁) (x ⃗) eval≡interp (c₁ ⊗ c₂) ((x , y) ⃗) | just (x₁ ⃗) | [ eq₁ ] with interp c₂ (y ⃗) | inspect (interp c₂) (y ⃗) eval≡interp (c₁ ⊗ c₂) ((x , y) ⃗) | just (x₁ ⃗) | [ eq₁ ] | just (y₁ ⃗) | [ eq₂ ] = eval-toState₁ rs' where rs' : ⟨ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ⟩▷ ↦* [ c₁ ⊗ c₂ ∣ (x₁ , y₁) ∣ ☐ ]▷ rs' = ↦⃗₆ ∷ appendκ↦* (getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (x ⃗)) eq₁)) (λ ()) (λ ()) refl (☐⊗[ c₂ , y ]• ☐) ++↦ ↦⃗₈ ∷ appendκ↦* (getₜᵣ⃗ c₂ (trans (eval≡interp c₂ (y ⃗)) eq₂)) (λ ()) (λ ()) refl ([ c₁ , x₁ ]⊗☐• ☐) ++↦ ↦⃗₉ ∷ ◾ eval≡interp (c₁ ⊗ c₂) ((x , y) ⃗) | just (x₁ ⃗) | [ eq₁ ] | just (y₁ ⃖) | [ eq₂ ] = eval-toState₁ rs' where rs' : ⟨ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ⟩▷ ↦* ⟨ c₁ ⊗ c₂ ∣ (x , y₁) ∣ ☐ ⟩◁ rs' = ↦⃗₆ ∷ appendκ↦* (getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (x ⃗)) eq₁)) (λ ()) (λ ()) refl (☐⊗[ c₂ , y ]• ☐) ++↦ ↦⃗₈ ∷ appendκ↦* (getₜᵣ⃗ c₂ (trans (eval≡interp c₂ (y ⃗)) eq₂)) (λ ()) (λ ()) refl ([ c₁ , x₁ ]⊗☐• ☐) ++↦ ↦⃖₈ ∷ Rev* (appendκ↦* (getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (x ⃗)) eq₁)) (λ ()) (λ ()) refl (☐⊗[ c₂ , y₁ ]• ☐)) (λ ()) (λ ()) ++↦ ↦⃖₆ ∷ ◾ eval≡interp (c₁ ⊗ c₂) ((x , y) ⃗) | just (x₁ ⃗) | [ eq₁ ] | nothing | [ eq₂ ] = eval-toState₁ rs' where rs' : ⟨ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ⟩▷ ↦* ⊠ rs' = ↦⃗₆ ∷ appendκ↦* (getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (x ⃗)) eq₁)) (λ ()) (λ ()) refl (☐⊗[ c₂ , y ]• ☐) ++↦ ↦⃗₈ ∷ appendκ↦*⊠ (getₜᵣ⃗ c₂ (trans (eval≡interp c₂ (y ⃗)) eq₂)) (λ ()) ([ c₁ , x₁ ]⊗☐• ☐) eval≡interp (c₁ ⊗ c₂) ((x , y) ⃗) | just (x₁ ⃖) | [ eq₁ ] = eval-toState₁ rs' where rs' : ⟨ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ⟩▷ ↦* ⟨ c₁ ⊗ c₂ ∣ (x₁ , y) ∣ ☐ ⟩◁ rs' = ↦⃗₆ ∷ appendκ↦* (getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (x ⃗)) eq₁)) (λ ()) (λ ()) refl (☐⊗[ c₂ , y ]• ☐) ++↦ ↦⃖₆ ∷ ◾ eval≡interp (c₁ ⊗ c₂) ((x , y) ⃗) | nothing | [ eq₁ ] = eval-toState₁ rs' where rs' : ⟨ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ⟩▷ ↦* ⊠ rs' = ↦⃗₆ ∷ appendκ↦*⊠ (getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (x ⃗)) eq₁)) (λ ()) (☐⊗[ c₂ , y ]• ☐) eval≡interp (c₁ ⊗ c₂) ((x , y) ⃖) with interp c₂ (y ⃖) | inspect (interp c₂) (y ⃖) eval≡interp (c₁ ⊗ c₂) ((x , y) ⃖) | just (y₁ ⃗) | [ eq₂ ] = eval-toState₂ rs' where rs' : [ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ]◁ ↦* [ c₁ ⊗ c₂ ∣ (x , y₁) ∣ ☐ ]▷ rs' = ↦⃖₉ ∷ appendκ↦* (getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (y ⃖)) eq₂)) (λ ()) (λ ()) refl ([ c₁ , x ]⊗☐• ☐) ++↦ ↦⃗₉ ∷ ◾ eval≡interp (c₁ ⊗ c₂) ((x , y) ⃖) | just (y₁ ⃖) | [ eq₂ ] with interp c₁ (x ⃖) | inspect (interp c₁) (x ⃖) eval≡interp (c₁ ⊗ c₂) ((x , y) ⃖) | just (y₁ ⃖) | [ eq₂ ] | just (x₁ ⃗) | [ eq₁ ] = eval-toState₂ rs' where rs' : [ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ]◁ ↦* [ c₁ ⊗ c₂ ∣ (x₁ , y) ∣ ☐ ]▷ rs' = ↦⃖₉ ∷ appendκ↦* (getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (y ⃖)) eq₂)) (λ ()) (λ ()) refl ([ c₁ , x ]⊗☐• ☐) ++↦ ↦⃖₈ ∷ appendκ↦* (getₜᵣ⃖ c₁ (trans (eval≡interp c₁ (x ⃖)) eq₁)) (λ ()) (λ ()) refl (☐⊗[ c₂ , y₁ ]• ☐) ++↦ ↦⃗₈ ∷ Rev* (appendκ↦* (getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (y ⃖)) eq₂)) (λ ()) (λ ()) refl ([ c₁ , x₁ ]⊗☐• ☐)) (λ ()) (λ ()) ++↦ ↦⃗₉ ∷ ◾ eval≡interp (c₁ ⊗ c₂) ((x , y) ⃖) | just (y₁ ⃖) | [ eq₂ ] | just (x₁ ⃖) | [ eq₁ ] = eval-toState₂ rs' where rs' : [ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ]◁ ↦* ⟨ c₁ ⊗ c₂ ∣ (x₁ , y₁) ∣ ☐ ⟩◁ rs' = ↦⃖₉ ∷ appendκ↦* (getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (y ⃖)) eq₂)) (λ ()) (λ ()) refl ([ c₁ , x ]⊗☐• ☐) ++↦ ↦⃖₈ ∷ appendκ↦* (getₜᵣ⃖ c₁ (trans (eval≡interp c₁ (x ⃖)) eq₁)) (λ ()) (λ ()) refl (☐⊗[ c₂ , y₁ ]• ☐) ++↦ ↦⃖₆ ∷ ◾ eval≡interp (c₁ ⊗ c₂) ((x , y) ⃖) | just (y₁ ⃖) | [ eq₂ ] | nothing | [ eq₁ ] = eval-toState₂ rs' where rs' : [ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ]◁ ↦* ⊠ rs' = ↦⃖₉ ∷ appendκ↦* (getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (y ⃖)) eq₂)) (λ ()) (λ ()) refl ([ c₁ , x ]⊗☐• ☐) ++↦ ↦⃖₈ ∷ appendκ↦*⊠ (getₜᵣ⃖ c₁ (trans (eval≡interp c₁ (x ⃖)) eq₁)) (λ ()) (☐⊗[ c₂ , y₁ ]• ☐) eval≡interp (c₁ ⊗ c₂) ((x , y) ⃖) | nothing | [ eq₂ ] = eval-toState₂ rs' where rs' : [ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ]◁ ↦* ⊠ rs' = ↦⃖₉ ∷ appendκ↦*⊠ (getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (y ⃖)) eq₂)) (λ ()) ([ c₁ , x ]⊗☐• ☐) private loop : ∀ {A B C x} {c₁ : A ↔ B} {c₂ : B ↔ C} (n : ℕ) → ∀ b → ((rs : [ c₁ ∣ b ∣ ☐⨾ c₂ • ☐ ]▷ ↦* toState (c₁ ⨾ c₂) x) → len↦ rs ≡ n → x ≡ c₁ ⨾[ b ⃗]⨾ c₂) × ((rs : ⟨ c₂ ∣ b ∣ c₁ ⨾☐• ☐ ⟩◁ ↦* toState (c₁ ⨾ c₂) x) → len↦ rs ≡ n → x ≡ c₁ ⨾[ b ⃖]⨾ c₂) loop {A} {B} {C} {x} {c₁} {c₂} = <′-rec (λ n → _) loop-rec where loop-rec : (n : ℕ) → (∀ m → m <′ n → _) → _ loop-rec n R b = loop₁ , loop₂ where loop₁ : (rs : [ c₁ ∣ b ∣ ☐⨾ c₂ • ☐ ]▷ ↦* toState (c₁ ⨾ c₂) x) → len↦ rs ≡ n → x ≡ c₁ ⨾[ b ⃗]⨾ c₂ loop₁ rs refl with interp c₂ (b ⃗) | inspect (interp c₂) (b ⃗) loop₁ rs refl | just (c ⃗) | [ eq ] = toState≡₁ (deterministic* rs rs' (is-stuck-toState _ _) (λ ())) where rs' : [ c₁ ∣ b ∣ ☐⨾ c₂ • ☐ ]▷ ↦* [ c₁ ⨾ c₂ ∣ c ∣ ☐ ]▷ rs' = ↦⃗₇ ∷ appendκ↦* (getₜᵣ⃗ c₂ (trans (eval≡interp c₂ (b ⃗)) eq)) (λ ()) (λ ()) refl (c₁ ⨾☐• ☐) ++↦ ↦⃗₁₀ ∷ ◾ loop₁ rs refl | just (b' ⃖) | [ eq ] = proj₂ (R (len↦ rs'') le b') rs'' refl where rs' : [ c₁ ∣ b ∣ ☐⨾ c₂ • ☐ ]▷ ↦* ⟨ c₂ ∣ b' ∣ c₁ ⨾☐• ☐ ⟩◁ rs' = ↦⃗₇ ∷ appendκ↦* (getₜᵣ⃗ c₂ (trans (eval≡interp c₂ (b ⃗)) eq)) (λ ()) (λ ()) refl (c₁ ⨾☐• ☐) rs'' : ⟨ c₂ ∣ b' ∣ c₁ ⨾☐• ☐ ⟩◁ ↦* toState (c₁ ⨾ c₂) x rs'' = proj₁ (deterministic*' rs' rs (is-stuck-toState _ _)) req : len↦ rs ≡ len↦ rs' + len↦ rs'' req = proj₂ (deterministic*' rs' rs (is-stuck-toState _ _)) le : len↦ rs'' <′ len↦ rs le rewrite req = s≤′s (n≤′m+n _ _) loop₁ rs refl | nothing | [ eq ] = toState≡₃ (deterministic* rs rs' (is-stuck-toState _ _) (λ ())) where rs' : [ c₁ ∣ b ∣ ☐⨾ c₂ • ☐ ]▷ ↦* ⊠ rs' = ↦⃗₇ ∷ appendκ↦*⊠ (getₜᵣ⃗ c₂ (trans (eval≡interp c₂ (b ⃗)) eq)) (λ ()) (c₁ ⨾☐• ☐) loop₂ : (rs : ⟨ c₂ ∣ b ∣ c₁ ⨾☐• ☐ ⟩◁ ↦* toState (c₁ ⨾ c₂) x) → len↦ rs ≡ n → x ≡ c₁ ⨾[ b ⃖]⨾ c₂ loop₂ rs refl with interp c₁ (b ⃖) | inspect (interp c₁) (b ⃖) loop₂ rs refl | just (b' ⃗) | [ eq ] = proj₁ (R (len↦ rs'') le b') rs'' refl where rs' : ⟨ c₂ ∣ b ∣ c₁ ⨾☐• ☐ ⟩◁ ↦* [ c₁ ∣ b' ∣ ☐⨾ c₂ • ☐ ]▷ rs' = ↦⃖₇ ∷ appendκ↦* (getₜᵣ⃖ c₁ (trans (eval≡interp c₁ (b ⃖)) eq)) (λ ()) (λ ()) refl (☐⨾ c₂ • ☐) rs'' : [ c₁ ∣ b' ∣ ☐⨾ c₂ • ☐ ]▷ ↦* toState (c₁ ⨾ c₂) x rs'' = proj₁ (deterministic*' rs' rs (is-stuck-toState _ _)) req : len↦ rs ≡ len↦ rs' + len↦ rs'' req = proj₂ (deterministic*' rs' rs (is-stuck-toState _ _)) le : len↦ rs'' <′ len↦ rs le rewrite req = s≤′s (n≤′m+n _ _) loop₂ rs refl | just (a ⃖) | [ eq ] = toState≡₂ (deterministic* rs rs' (is-stuck-toState _ _) (λ ())) where rs' : ⟨ c₂ ∣ b ∣ c₁ ⨾☐• ☐ ⟩◁ ↦* ⟨ c₁ ⨾ c₂ ∣ a ∣ ☐ ⟩◁ rs' = ↦⃖₇ ∷ appendκ↦* (getₜᵣ⃖ c₁ (trans (eval≡interp c₁ (b ⃖)) eq)) (λ ()) (λ ()) refl (☐⨾ c₂ • ☐) ++↦ ↦⃖₃ ∷ ◾ loop₂ rs refl | nothing | [ eq ] = toState≡₃ (deterministic* rs rs' (is-stuck-toState _ _) (λ ())) where rs' : ⟨ c₂ ∣ b ∣ c₁ ⨾☐• ☐ ⟩◁ ↦* ⊠ rs' = ↦⃖₇ ∷ appendκ↦*⊠ (getₜᵣ⃖ c₁ (trans (eval≡interp c₁ (b ⃖)) eq)) (λ ()) (☐⨾ c₂ • ☐)
{ "alphanum_fraction": 0.4660952531, "avg_line_length": 57.0269058296, "ext": "agda", "hexsha": "6af62c5216f732152951c354875e6f4923b5b464", "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": "PiQ/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": "PiQ/Properties.agda", "max_line_length": 182, "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": "PiQ/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": 20778, "size": 38151 }
-- Proof irrelevance is nice when you want to work with subsets. module Subset where data True : Prop where tt : True data False : Prop where data (|) (A:Set)(P:A -> Prop) : Set where sub : (x:A) -> P x -> A | P data Nat : Set where zero : Nat suc : Nat -> Nat mutual IsEven : Nat -> Prop IsEven zero = True IsEven (suc n) = IsOdd n IsOdd : Nat -> Prop IsOdd zero = False IsOdd (suc n) = IsEven n Even : Set Even = Nat | IsEven Odd : Set Odd = Nat | IsOdd (+) : Nat -> Nat -> Nat zero + m = m suc n + m = suc (n + m)
{ "alphanum_fraction": 0.5809352518, "avg_line_length": 15.4444444444, "ext": "agda", "hexsha": "cc26ed971332ade95bb015b4ce26fd937b3fddd8", "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": "examples/outdated-and-incorrect/Subset.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": "examples/outdated-and-incorrect/Subset.agda", "max_line_length": 64, "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": "examples/outdated-and-incorrect/Subset.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": 200, "size": 556 }
------------------------------------------------------------------------ -- Document renderers ------------------------------------------------------------------------ {-# OPTIONS --guardedness #-} module Renderer where open import Algebra open import Data.Bool open import Data.Char using (Char) open import Data.Empty open import Data.Integer using (ℤ; +_; -[1+_]; _-_; _⊖_) open import Data.List as List hiding ([_]) open import Data.List.NonEmpty using (_∷⁺_) open import Data.List.Properties open import Data.Nat open import Data.Product open import Data.String as String using (String) open import Data.Unit open import Function open import Function.Equality using (_⟨$⟩_) open import Function.Inverse using (module Inverse) open import Relation.Binary.PropositionalEquality as P using (_≡_) open import Relation.Nullary open import Tactic.MonoidSolver private module LM {A : Set} = Monoid (++-monoid A) open import Grammar.Infinite as G hiding (_⊛_; _<⊛_; _⊛>_) open import Pretty using (Doc; Docs; Pretty-printer) open Pretty.Doc open Pretty.Docs open import Utilities ------------------------------------------------------------------------ -- Renderers record Renderer : Set₁ where field -- The function that renders. render : ∀ {A} {g : Grammar A} {x : A} → Doc g x → List Char -- The rendered string must be parsable. parsable : ∀ {A} {g : Grammar A} {x : A} (d : Doc g x) → x ∈ g · render d ---------------------------------------------------------------------- -- Some derived definitions and properties -- Pretty-printers are correct by definition, for any renderer, -- assuming that the underlying grammar is unambiguous. correct : ∀ {A} {g : Grammar A} (pretty : Pretty-printer g) → ∀ x → x ∈ g · render (pretty x) correct pretty x = parsable (pretty x) correct-if-locally-unambiguous : ∀ {A} {g : Grammar A} → (parse : Parser g) (pretty : Pretty-printer g) → ∀ x → Locally-unambiguous g (render (pretty x)) → ∃ λ p → parse (render (pretty x)) ≡ yes (x , p) correct-if-locally-unambiguous parse pretty x unambiguous = c where c : ∃ λ p → parse (render (pretty x)) ≡ yes (x , p) c with parse (render (pretty x)) c | no no-parse = ⊥-elim (no-parse (x , correct pretty x)) c | yes (y , y∈g) with unambiguous y∈g (correct pretty x) c | yes (.x , x∈g) | P.refl = (x∈g , P.refl) correct-if-unambiguous : ∀ {A} {g : Grammar A} → Unambiguous g → (parse : Parser g) (pretty : Pretty-printer g) → ∀ x → ∃ λ p → parse (render (pretty x)) ≡ yes (x , p) correct-if-unambiguous unambiguous parse pretty x = correct-if-locally-unambiguous parse pretty x unambiguous -- If there is only one grammatically correct string, then the -- renderer returns this string. render-unique-string : ∀ {A} {g : Grammar A} {x s} → (∀ {s′} → x ∈ g · s′ → s′ ≡ s) → (d : Doc g x) → render d ≡ s render-unique-string unique d = unique (parsable d) -- Thus, in particular, documents for the grammar "string s" are -- always rendered in the same way. render-string : ∀ {s s′} (d : Doc (string s) s′) → render d ≡ s render-string = render-unique-string λ s′∈ → P.sym $ proj₂ (Inverse.to string-sem′ ⟨$⟩ s′∈) -- The property of ignoring (top-level) emb constructors. Ignores-emb : Set₁ Ignores-emb = ∀ {A B x y} {g₁ : Grammar A} {g₂ : Grammar B} {f : ∀ {s} → x ∈ g₁ · s → y ∈ g₂ · s} {d : Doc g₁ x} → render (emb f d) ≡ render d -- If the renderer ignores emb constructors then, for every valid -- string, there is a document that renders as that string. (The -- renderers below ignore emb.) every-string-possible : Ignores-emb → ∀ {A} {g : Grammar A} {x s} → x ∈ g · s → ∃ λ (d : Doc g x) → render d ≡ s every-string-possible ignores-emb {g = g} {x} {s} x∈ = (Pretty.embed lemma₁ text , lemma₂) where open P.≡-Reasoning lemma₁ : ∀ {s′} → s ∈ string s · s′ → x ∈ g · s′ lemma₁ s∈ = cast (proj₂ (Inverse.to string-sem′ ⟨$⟩ s∈)) x∈ lemma₂ = begin render (Pretty.embed lemma₁ text) ≡⟨ ignores-emb ⟩ render text ≡⟨ render-string _ ⟩ s ∎ ------------------------------------------------------------------------ -- An example renderer -- This renderer renders every occurrence of "line" as a single space -- character. ugly-renderer : Renderer ugly-renderer = record { render = render ; parsable = parsable } where mutual render : ∀ {A} {g : Grammar A} {x} → Doc g x → List Char render (d₁ ◇ d₂) = render d₁ ++ render d₂ render (text {s = s}) = s render line = String.toList " " render (group d) = render d render (nest _ d) = render d render (emb _ d) = render d render (fill ds) = render-fills ds render-fills : ∀ {A} {g : Grammar A} {x} → Docs g x → List Char render-fills [ d ] = render d render-fills (d ∷ ds) = render d ++ ' ' ∷ render-fills ds mutual parsable : ∀ {A x} {g : Grammar A} (d : Doc g x) → x ∈ g · render d parsable (d₁ ◇ d₂) = >>=-sem (parsable d₁) (parsable d₂) parsable text = string-sem parsable line = <$-sem single-space-sem parsable (group d) = parsable d parsable (nest _ d) = parsable d parsable (emb f d) = f (parsable d) parsable (fill ds) = parsable-fills ds parsable-fills : ∀ {A xs} {g : Grammar A} (ds : Docs g xs) → xs ∈ g sep-by whitespace + · render-fills ds parsable-fills [ d ] = sep-by-sem-singleton (parsable d) parsable-fills (d ∷ ds) = sep-by-sem-∷ (parsable d) single-space-sem (parsable-fills ds) -- The "ugly renderer" ignores emb constructors. ugly-renderer-ignores-emb : Renderer.Ignores-emb ugly-renderer ugly-renderer-ignores-emb = P.refl ------------------------------------------------------------------------ -- A general document property, proved using ugly-renderer -- For every document of type Doc g x there is a string that witnesses -- that the value x is generated by the grammar g. string-exists : ∀ {A} {g : Grammar A} {x} → Doc g x → ∃ λ s → x ∈ g · s string-exists d = (render d , parsable d) where open Renderer ugly-renderer ------------------------------------------------------------------------ -- An example renderer, based on the one in Wadler's "A prettier -- printer" module Wadler's-renderer where -- Layouts (representations of certain strings). data Layout-element : Set where text : List Char → Layout-element line : ℕ → Layout-element Layout : Set Layout = List Layout-element -- Conversion of layouts into strings. show-element : Layout-element → List Char show-element (text s) = s show-element (line i) = '\n' ∷ replicate i ' ' show : Layout → List Char show = concat ∘ List.map show-element -- Documents with unions instead of groups, and no fills. An extra -- index—the nesting level—is also included, and the line -- combinator's type is more precise (it can't be used for single -- spaces, only for newline-plus-indentation). infixr 20 _◇_ data DocN : ∀ {A} → ℕ → Grammar A → A → Set₁ where _◇_ : ∀ {i c₁ c₂ A B x y} {g₁ : ∞Grammar c₁ A} {g₂ : A → ∞Grammar c₂ B} → DocN i (♭? g₁) x → DocN i (♭? (g₂ x)) y → DocN i (g₁ >>= g₂) y text : ∀ {i} (s : List Char) → DocN i (string s) s line : (i : ℕ) → let s = show-element (line i) in DocN i (string s) s union : ∀ {i A} {g : Grammar A} {x} → DocN i g x → DocN i g x → DocN i g x nest : ∀ {i A} {g : Grammar A} {x} (j : ℕ) → DocN (j + i) g x → DocN i g x emb : ∀ {i A B} {g₁ : Grammar A} {g₂ : Grammar B} {x y} → (∀ {s} → x ∈ g₁ · s → y ∈ g₂ · s) → DocN i g₁ x → DocN i g₂ y -- Some derived combinators. infix 21 <$>_ infixl 20 _⊛_ _⊛>_ embed : ∀ {i A B} {g₁ : Grammar A} {g₂ : Grammar B} {x y} → (∀ {s} → x ∈ g₁ · s → y ∈ g₂ · s) → DocN i g₁ x → DocN i g₂ y embed f (emb g d) = emb (f ∘ g) d embed f d = emb f d nil : ∀ {i A} {x : A} → DocN i (return x) x nil = embed lemma (text []) where lemma : ∀ {x s} → [] ∈ string [] · s → x ∈ return x · s lemma return-sem = return-sem <$>_ : ∀ {i c A B} {f : A → B} {x} {g : ∞Grammar c A} → DocN i (♭? g) x → DocN i (f <$> g) (f x) <$> d = embed <$>-sem d _⊛_ : ∀ {i c₁ c₂ A B f x} {g₁ : ∞Grammar c₁ (A → B)} {g₂ : ∞Grammar c₂ A} → DocN i (♭? g₁) f → DocN i (♭? g₂) x → DocN i (g₁ G.⊛ g₂) (f x) _⊛_ {g₁ = g₁} {g₂} d₁ d₂ = embed lemma (d₁ ◇ <$> d₂) where lemma : ∀ {x s} → x ∈ (g₁ >>= λ f → f <$> g₂) · s → x ∈ g₁ G.⊛ g₂ · s lemma (>>=-sem f∈ (<$>-sem x∈)) = ⊛-sem f∈ x∈ _⊛>_ : ∀ {i c₁ c₂ A B x y} {g₁ : ∞Grammar c₁ A} {g₂ : ∞Grammar c₂ B} → DocN i (♭? g₁) x → DocN i (♭? g₂) y → DocN i (g₁ G.⊛> g₂) y _⊛>_ {g₁ = g₁} {g₂} d₁ d₂ = embed lemma (nil ⊛ d₁ ⊛ d₂) where lemma : ∀ {y s} → y ∈ return (λ _ x → x) G.⊛ g₁ G.⊛ g₂ · s → y ∈ g₁ G.⊛> g₂ · s lemma (⊛-sem (⊛-sem return-sem x∈) y∈) = ⊛>-sem x∈ y∈ cons : ∀ {i A B} {g : Grammar A} {sep : Grammar B} {x xs} → DocN i g x → DocN i (tt <$ sep) tt → DocN i (g sep-by sep) xs → DocN i (g sep-by sep) (x ∷⁺ xs) cons {g = g} {sep} d₁ d₂ d₃ = embed lemma (<$> d₁ ⊛ (d₂ ⊛> d₃)) where lemma : ∀ {ys s} → ys ∈ _∷⁺_ <$> g G.⊛ ((tt <$ sep) G.⊛> (g sep-by sep)) · s → ys ∈ g sep-by sep · s lemma (⊛-sem (<$>-sem x∈) (⊛>-sem (<$-sem y∈) xs∈)) = sep-by-sem-∷ x∈ y∈ xs∈ -- A single space character. imprecise-space : ∀ {i} → DocN i (tt <$ whitespace +) tt imprecise-space = embed lemma (text (String.toList " ")) where lemma : ∀ {s} → String.toList " " ∈ string′ " " · s → tt ∈ tt <$ whitespace + · s lemma s∈ = cast (proj₂ (Inverse.to string-sem′ ⟨$⟩ s∈)) (<$-sem single-space-sem) -- A variant of line that has the same type as Pretty.line (except -- for the indentation index). imprecise-line : (i : ℕ) → DocN i (tt <$ whitespace +) tt imprecise-line i = embed lemma (line i) where replicate-lemma : ∀ i → replicate i ' ' ∈ whitespace ⋆ · replicate i ' ' replicate-lemma zero = ⋆-[]-sem replicate-lemma (suc i) = ⋆-∷-sem (left-sem tok-sem) (replicate-lemma i) lemma : ∀ {i s′} → let s = show-element (line i) in s ∈ string s · s′ → tt ∈ tt <$ whitespace + · s′ lemma s∈ = cast (proj₂ (Inverse.to string-sem′ ⟨$⟩ s∈)) (<$-sem (+-sem (right-sem tok-sem) (replicate-lemma _))) mutual -- Replaces line constructors with single spaces, removes groups. flatten : ∀ {i A} {g : Grammar A} {x} → Doc g x → DocN i g x flatten (d₁ ◇ d₂) = flatten d₁ ◇ flatten d₂ flatten text = text _ flatten line = imprecise-space flatten (group d) = flatten d flatten (nest _ d) = flatten d flatten (emb f d) = embed f (flatten d) flatten (fill ds) = flatten-fills ds flatten-fills : ∀ {i A} {g : Grammar A} {xs} → Docs g xs → DocN i (g sep-by whitespace +) xs flatten-fills [ d ] = embed sep-by-sem-singleton (flatten d) flatten-fills (d ∷ ds) = cons (flatten d) imprecise-space (flatten-fills ds) mutual -- Converts ("expands") groups to unions. expand : ∀ {i A} {g : Grammar A} {x} → Doc g x → DocN i g x expand (d₁ ◇ d₂) = expand d₁ ◇ expand d₂ expand text = text _ expand line = imprecise-line _ expand (group d) = union (flatten d) (expand d) expand (nest j d) = nest j (expand d) expand (emb f d) = embed f (expand d) expand (fill ds) = expand-fills false ds expand-fills : Bool → -- Unconditionally flatten the first document? ∀ {i A} {g : Grammar A} {xs} → Docs g xs → DocN i (g sep-by whitespace +) xs expand-fills fl [ d ] = embed sep-by-sem-singleton (flatten/expand fl d) expand-fills fl (d ∷ ds) = union (cons (flatten d) imprecise-space (expand-fills true ds)) (cons (flatten/expand fl d) (imprecise-line _) (expand-fills false ds)) flatten/expand : Bool → -- Flatten? ∀ {i A} {g : Grammar A} {x} → Doc g x → DocN i g x flatten/expand true d = flatten d flatten/expand false d = expand d -- Does the first line of the layout fit on a line with the given -- number of characters? fits : ℤ → Layout → Bool fits -[1+ w ] _ = false fits w [] = true fits w (text s ∷ x) = fits (w - + length s) x fits w (line i ∷ x) = true module _ (width : ℕ) where -- Chooses the first layout if it fits, otherwise the second. The -- natural number is the current column number. better : ℕ → Layout → Layout → Layout better c x y = if fits (width ⊖ c) x then x else y -- If, for any starting column c, κ c is the layout for some text, -- then best i d κ c is the layout for the document d followed by -- this text, given the current indentation i and the current column -- number c. best : ∀ {i A} {g : Grammar A} {x} → DocN i g x → (ℕ → Layout) → (ℕ → Layout) best (d₁ ◇ d₂) = best d₁ ∘ best d₂ best (text []) = id best (text s) = λ κ c → text s ∷ κ (length s + c) best (line i) = λ κ _ → line i ∷ κ i best (union d₁ d₂) = λ κ c → better c (best d₁ κ c) (best d₂ κ c) best (nest _ d) = best d best (emb _ d) = best d -- Renders a document. renderN : ∀ {A i} {g : Grammar A} {x} → DocN i g x → List Char renderN d = show (best d (λ _ → []) 0) -- Renders a document. render : ∀ {A} {g : Grammar A} {x} → Doc g x → List Char render d = renderN (expand {i = 0} d) -- A simple lemma. if-lemma : ∀ {A} {g : Grammar A} {x l₁ l₂} s b → x ∈ g · s ++ show l₁ → x ∈ g · s ++ show l₂ → x ∈ g · s ++ show (if b then l₁ else l₂) if-lemma _ true ∈l₁ ∈l₂ = ∈l₁ if-lemma _ false ∈l₁ ∈l₂ = ∈l₂ -- The main correctness property for best. best-lemma : ∀ {c A B i} {g : Grammar A} {g′ : Grammar B} {x y κ} s (d : DocN i g x) → (∀ {s′ c′} → x ∈ g · s′ → y ∈ g′ · s ++ s′ ++ show (κ c′)) → y ∈ g′ · s ++ show (best d κ c) best-lemma s (text []) hyp = hyp return-sem best-lemma s (text (_ ∷ _)) hyp = hyp string-sem best-lemma s (line i) hyp = hyp string-sem best-lemma {c} s (union d₁ d₂) hyp = if-lemma s (fits (width ⊖ c) _) (best-lemma s d₁ hyp) (best-lemma s d₂ hyp) best-lemma s (nest _ d) hyp = best-lemma s d hyp best-lemma s (emb f d) hyp = best-lemma s d (hyp ∘ f) best-lemma s (d₁ ◇ d₂) hyp = best-lemma s d₁ λ {s′} f∈ → cast (LM.assoc s _ _) (best-lemma (s ++ s′) d₂ λ x∈ → cast lemma (hyp (>>=-sem f∈ x∈))) where lemma : ∀ {s′ s″ s‴} → s ++ (s′ ++ s″) ++ s‴ ≡ (s ++ s′) ++ s″ ++ s‴ lemma = solve (++-monoid Char) -- A corollary. best-lemma′ : ∀ {A i} {g : Grammar A} {x} (d : DocN i g x) → x ∈ g · renderN d best-lemma′ d = best-lemma [] d (cast (P.sym $ proj₂ LM.identity _)) -- The renderer is correct. parsable : ∀ {A} {g : Grammar A} {x} (d : Doc g x) → x ∈ g · render d parsable d = best-lemma′ (expand d) -- The renderer. wadler's-renderer : Renderer wadler's-renderer = record { render = render ; parsable = parsable } -- The renderer ignores emb constructors. ignores-emb : ∀ {w} → Renderer.Ignores-emb (wadler's-renderer w) ignores-emb {d = d} with expand {i = 0} d ... | _ ◇ _ = P.refl ... | text _ = P.refl ... | line ._ = P.refl ... | union _ _ = P.refl ... | nest _ _ = P.refl ... | emb _ _ = P.refl -- A (heterogeneous) notion of document equivalence. infix 4 _≈_ _≈_ : ∀ {A₁ i₁ g₁} {x₁ : A₁} {A₂ i₂ g₂} {x₂ : A₂} → DocN i₁ g₁ x₁ → DocN i₂ g₂ x₂ → Set d₁ ≈ d₂ = ∀ width → renderN width d₁ ≡ renderN width d₂ -- Some laws satisfied by the DocN combinators. text-++ : ∀ {i₁ i₂} s₁ s₂ → text {i = i₁} (s₁ ++ s₂) ≈ _⊛>_ {c₁ = false} {c₂ = false} (text {i = i₂} s₁) (text s₂) text-++ [] [] _ = P.refl text-++ [] (t₂ ∷ s₂) _ = P.refl text-++ (t₁ ∷ s₁) [] _ = lemma where lemma : ∀ {s₁} → (s₁ ++ []) ++ [] ≡ s₁ ++ [] lemma = solve (++-monoid Char) text-++ (t₁ ∷ s₁) (t₂ ∷ s₂) _ = lemma (_ ∷ s₁) where lemma : ∀ s₁ {s₂} → (s₁ ++ s₂) ++ [] ≡ s₁ ++ s₂ ++ [] lemma _ = solve (++-monoid Char) nest-union : ∀ {A i j g} {x : A} {d₁ d₂ : DocN (j + i) g x} → nest j (union d₁ d₂) ≈ union (nest j d₁) (nest j d₂) nest-union _ = P.refl union-◇ : ∀ {A B i x y c₁ c₂} {g₁ : ∞Grammar c₁ A} {g₂ : A → ∞Grammar c₂ B} {d₁ d₂ : DocN i (♭? g₁) x} {d₃ : DocN i (♭? (g₂ x)) y} → _◇_ {g₁ = g₁} {g₂ = g₂} (union d₁ d₂) d₃ ≈ union (d₁ ◇ d₃) (_◇_ {g₁ = g₁} {g₂ = g₂} d₂ d₃) union-◇ _ = P.refl -- A law that is /not/ satisfied by the DocN combinators. ¬-◇-union : ¬ (∀ {A B i x y} c₁ c₂ {g₁ : ∞Grammar c₁ A} {g₂ : A → ∞Grammar c₂ B} (d₁ : DocN i (♭? g₁) x) (d₂ d₃ : DocN i (♭? (g₂ x)) y) → _◇_ {g₁ = g₁} {g₂ = g₂} d₁ (union d₂ d₃) ≈ union (d₁ ◇ d₂) (_◇_ {g₁ = g₁} {g₂ = g₂} d₁ d₃)) ¬-◇-union hyp with hyp false false d₁ d₂ d₁ 0 where d₁ = imprecise-line 0 d₂ = imprecise-space -- The following four definitions are not part of the proof. left : DocN 0 _ _ left = _◇_ {c₁ = false} {c₂ = false} d₁ (union d₂ d₁) right : DocN 0 _ _ right = union (d₁ ◇ d₂) (_◇_ {c₁ = false} {c₂ = false} d₁ d₁) -- Note that left and right are not rendered in the same way. left-hand-string : renderN 0 left ≡ String.toList "\n\n" left-hand-string = P.refl right-hand-string : renderN 0 right ≡ String.toList "\n " right-hand-string = P.refl ... | () -- Uses Wadler's-renderer.render to render a document using the -- given line width. render : ∀ {A} {g : Grammar A} {x} → ℕ → Doc g x → String render w d = String.fromList (Wadler's-renderer.render w d)
{ "alphanum_fraction": 0.5193835653, "avg_line_length": 33.972826087, "ext": "agda", "hexsha": "788e47ec718605cad4afbfcd281f11241ed42063", "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": "b956803ba90b6c5f57bbbaab01bb18485d948492", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/pretty", "max_forks_repo_path": "Renderer.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b956803ba90b6c5f57bbbaab01bb18485d948492", "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/pretty", "max_issues_repo_path": "Renderer.agda", "max_line_length": 83, "max_stars_count": null, "max_stars_repo_head_hexsha": "b956803ba90b6c5f57bbbaab01bb18485d948492", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/pretty", "max_stars_repo_path": "Renderer.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6450, "size": 18753 }
module Optics where open import Agda.Primitive using (_⊔_; lsuc) open import Data.Maybe using (Maybe; just) open import Data.Sum using (_⊎_; inj₁) open import Function using (const; id) open import Category.Functor.Arr open import Category.Functor.Const open import Category.Functor.Either open import Category.Profunctor.Joker open import Category.Profunctor.Star Optic : ∀ {l p} (c : (Set l → Set l → Set l) → Set p) (s t a b : Set l) → Set (lsuc l ⊔ p) Optic {l} c s t a b = ∀ {p : Set l → Set l → Set l} (isClass : c p) → p a b → p s t setOptic : ∀ {l p} (S T A B : Set l) {c : (Set l → Set l → Set l) → Set p} (isClass : c (Star (Arr B))) → Optic c S T A B → S → B → T setOptic _ _ _ _ isClass l = l isClass (const id) putOptic : ∀ {l p} (S T A B : Set l) {c : (Set l → Set l → Set l) → Set p} (isClass : c (Joker (Arr B))) → Optic c S T A B → B → T putOptic _ _ _ _ isClass l = l isClass id getOptic : ∀ {l p} (S T A B : Set l) {c : (Set l → Set l → Set l) → Set p} (isClass : c (Star (Const A))) → Optic c S T A B → S → A getOptic _ _ _ _ isClass l = l isClass id matchingOptic : ∀ {l p} (S T A B : Set l) {c : (Set l → Set l → Set l) → Set p} (isClass : c (Star (Either A))) → Optic c S T A B → S → A ⊎ T matchingOptic _ _ _ _ isClass l = l isClass inj₁ previewOptic : ∀ {l p} (S T A B : Set l) {c : (Set l → Set l → Set l) → Set p} (isClass : c (Star (Const (Maybe A)))) → Optic c S T A B → S → Maybe A previewOptic _ _ _ _ isClass l = l isClass just
{ "alphanum_fraction": 0.6053169734, "avg_line_length": 48.9, "ext": "agda", "hexsha": "f72f2e388ba43a0478d85e97a1e9b39d59099658", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "308afeeaa905870dbf1a995fa82e8825dfaf2d74", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "crisoagf/agda-optics", "max_forks_repo_path": "src/Optics.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "308afeeaa905870dbf1a995fa82e8825dfaf2d74", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "crisoagf/agda-optics", "max_issues_repo_path": "src/Optics.agda", "max_line_length": 149, "max_stars_count": null, "max_stars_repo_head_hexsha": "308afeeaa905870dbf1a995fa82e8825dfaf2d74", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "crisoagf/agda-optics", "max_stars_repo_path": "src/Optics.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 568, "size": 1467 }
{-# OPTIONS --safe #-} module Cubical.Experiments.ZCohomologyExperiments where open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.Properties open import Cubical.ZCohomology.GroupStructure open import Cubical.ZCohomology.Groups.Sn open import Cubical.ZCohomology.Groups.WedgeOfSpheres open import Cubical.Foundations.Prelude open import Cubical.HITs.Truncation open import Cubical.HITs.SetTruncation open import Cubical.HITs.Pushout open import Cubical.HITs.S1 open import Cubical.HITs.Sn open import Cubical.HITs.Susp open import Cubical.Data.Int open import Cubical.Foundations.Equiv open import Cubical.Data.Sigma open import Cubical.Foundations.Isomorphism open import Cubical.Algebra.Group hiding (Int) private ⋁-to : coHom 2 S²⋁S¹⋁S¹ → Int ⋁-to = Iso.fun (GroupIso.isom H²-S²⋁S¹⋁S¹) ⋁-from : Int → coHom 2 S²⋁S¹⋁S¹ ⋁-from = Iso.inv (GroupIso.isom H²-S²⋁S¹⋁S¹) g : S²⋁S¹⋁S¹ → ∥ S₊ 2 ∥ 4 g (inl x) = ∣ x ∣ g (inr x) = 0ₖ 2 g (push a i) = 0ₖ 2 G = ∣ g ∣₂ {- This computes: ⋁-to (⋁-from 1 +ₕ ⋁-from 1) ≡ 2 ⋁-to = refl We have ⋁-from 1 ≡ G and G is much simpler But this does not compute: test₀ : ⋁-to (G +ₕ G) ≡ 2 test₀ = refl With the strange addition it does: test₁ : ⋁-to (G +'ₕ G) ≡ 2 test₁ = refl -} -- Similar stuff happens with Sⁿ. private S²-to : coHom 2 (S₊ 2) → Int S²-to = Iso.fun (GroupIso.isom (Hⁿ-Sⁿ≅ℤ 1)) S²-from : Int → coHom 2 (S₊ 2) S²-from = Iso.inv (GroupIso.isom (Hⁿ-Sⁿ≅ℤ 1)) one : coHom 2 (S₊ 2) one = ∣ ∣_∣ ∣₂ {- Does not compute test₂ : S²-to (S²-from 1 +ₕ S²-from 1) ≡ 2 test₂ = refl But this does test₂ : S²-to (S²-from 1 +'ₕ S²-from 1) ≡ 2 test₂ = refl This doesn't test₃ : S²-to (one +ₕ one) ≡ 2 test₃ = refl But this does test₃ : S²-to (one +'ₕ one) ≡ 2 test₃ = refl -}
{ "alphanum_fraction": 0.6853741497, "avg_line_length": 22.05, "ext": "agda", "hexsha": "62ab820d19fa863756eee62ce0fdf6f1295710ac", "lang": "Agda", "max_forks_count": 134, "max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z", "max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z", "max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "marcinjangrzybowski/cubical", "max_forks_repo_path": "Cubical/Experiments/ZCohomologyExperiments.agda", "max_issues_count": 584, "max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z", "max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "marcinjangrzybowski/cubical", "max_issues_repo_path": "Cubical/Experiments/ZCohomologyExperiments.agda", "max_line_length": 55, "max_stars_count": 301, "max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "marcinjangrzybowski/cubical", "max_stars_repo_path": "Cubical/Experiments/ZCohomologyExperiments.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z", "num_tokens": 779, "size": 1764 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Reflexive closures -- -- This module is DEPRECATED. Please use the -- Relation.Binary.Construct.Closure.Reflexive module directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.ReflexiveClosure where open import Relation.Binary.Construct.Closure.Reflexive public
{ "alphanum_fraction": 0.515625, "avg_line_length": 29.8666666667, "ext": "agda", "hexsha": "6470798e28e7750b6639dc66d62aab4a6052311f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/ReflexiveClosure.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/ReflexiveClosure.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/ReflexiveClosure.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 71, "size": 448 }
open import Relation.Binary.Core module BBHeap.Drop.Properties {A : Set} (_≤_ : A → A → Set) (tot≤ : Total _≤_) (trans≤ : Transitive _≤_) where open import BBHeap _≤_ open import BBHeap.Compound _≤_ open import BBHeap.Drop _≤_ tot≤ trans≤ open import BBHeap.Equality _≤_ open import BBHeap.Equality.Properties _≤_ open import BBHeap.Push _≤_ tot≤ trans≤ open import BBHeap.Push.Properties _≤_ tot≤ trans≤ open import BBHeap.Subtyping _≤_ trans≤ open import BBHeap.Subtyping.Properties _≤_ trans≤ open import Bound.Lower A open import Bound.Lower.Order _≤_ open import Data.Nat open import Data.List hiding (drop) open import Data.Sum open import Data.Product open import Nat.Sum open import List.Permutation.Base A open import List.Permutation.Base.Concatenation A open import List.Permutation.Base.Equivalence A open import Order.Total _≤_ tot≤ mutual lemma-drop⋘# : {b : Bound}{x : A}{l r : BBHeap (val x)}(b≤x : LeB b (val x))(l⋘r : l ⋘ r) → # (drop⋘ b≤x l⋘r) ≡ # l + # r lemma-drop⋘# b≤x lf⋘ = refl lemma-drop⋘# b≤x (ll⋘ {x = y₁} {x' = y₂} {l = l₁} {r = r₁} {l' = l₂} {r' = r₂} x≤y₁ x≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂) with tot≤ y₁ y₂ | lemma-drop⋘ (cl x≤y₁ l₁⋘r₁) (cl x≤y₂ l₂⋘r₂) (ll⋘ x≤y₁ x≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂) ... | inj₁ y₁≤y₂ | inj₁ (_ , l⋙dr) with # (drop⋘ x≤y₂ l₂⋘r₂) | lemma-drop⋘# x≤y₂ l₂⋘r₂ | # (push⋘ (lexy y₁≤y₂) (lexy refl≤) l₁⋘r₁) | lemma-push# (lexy y₁≤y₂) (left (lexy refl≤) l₁⋘r₁) | # (subtyping (lexy y₁≤y₂) (drop⋘ x≤y₂ l₂⋘r₂)) | lemma-subtyping# (lexy y₁≤y₂) (drop⋘ x≤y₂ l₂⋘r₂) | # l₁ + # r₁ + suc (# l₂ + # r₂) | +assoc (# l₁ + # r₁) (# l₂ + # r₂) ... | ._ | refl | ._ | refl | ._ | refl | ._ | refl = refl lemma-drop⋘# b≤x (ll⋘ {l = l₁} {r = r₁} {l' = l₂} {r' = r₂} x≤y₁ x≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂) | inj₁ y₁≤y₂ | inj₂ dl⋘r with # (drop⋘ x≤y₁ l₁⋘r₁) | lemma-drop⋘# x≤y₁ l₁⋘r₁ ... | ._ | refl = refl lemma-drop⋘# b≤x (ll⋘ {l = l₁} {r = r₁} {l' = l₂} {r' = r₂} x≤y₁ x≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂) | inj₂ y₂≤y₁ | inj₁ (_ , l⋙dr) with # (drop⋘ x≤y₂ l₂⋘r₂) | lemma-drop⋘# x≤y₂ l₂⋘r₂ | (# l₁ + # r₁) + suc (# l₂ + # r₂) | +assoc (# l₁ + # r₁) (# l₂ + # r₂) ... | ._ | refl | ._ | refl = refl lemma-drop⋘# b≤x (ll⋘ {l = l₁} {r = r₁} {l' = l₂} {r' = r₂} x≤y₁ x≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂) | inj₂ y₂≤y₁ | inj₂ dl⋘r with # (drop⋘ x≤y₁ l₁⋘r₁) | lemma-drop⋘# x≤y₁ l₁⋘r₁ | # (push⋘ (lexy y₂≤y₁) (lexy refl≤) l₂⋘r₂) | lemma-push# (lexy y₂≤y₁) (left (lexy refl≤) l₂⋘r₂) | # (subtyping (lexy y₂≤y₁) (drop⋘ x≤y₁ l₁⋘r₁)) | lemma-subtyping# (lexy y₂≤y₁) (drop⋘ x≤y₁ l₁⋘r₁) ... | ._ | refl | ._ | refl | ._ | refl = refl lemma-drop⋘# b≤x (lr⋘ {x = y₁} {x' = y₂} {l = l₁} {r = r₁} {l' = l₂} {r' = r₂} x≤y₁ x≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂) with tot≤ y₁ y₂ | lemma-drop⋘ (cr x≤y₁ l₁⋙r₁) (cl x≤y₂ l₂⋘r₂) (lr⋘ x≤y₁ x≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂) ... | _ | inj₁ (() , _) ... | inj₁ y₁≤y₂ | inj₂ dl⋘r with # (drop⋙ x≤y₁ l₁⋙r₁) | lemma-drop⋙# x≤y₁ l₁⋙r₁ ... | ._ | refl = refl lemma-drop⋘# b≤x (lr⋘ {l = l₁} {r = r₁} {l' = l₂} {r' = r₂} x≤y₁ x≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂) | inj₂ y₂≤y₁ | inj₂ dl⋘r with # (drop⋙ x≤y₁ l₁⋙r₁) | lemma-drop⋙# x≤y₁ l₁⋙r₁ | # (push⋘ (lexy y₂≤y₁) (lexy refl≤) l₂⋘r₂) | lemma-push# (lexy y₂≤y₁) (left (lexy refl≤) l₂⋘r₂) | # (subtyping (lexy y₂≤y₁) (drop⋙ x≤y₁ l₁⋙r₁)) | lemma-subtyping# (lexy y₂≤y₁) (drop⋙ x≤y₁ l₁⋙r₁) ... | ._ | refl | ._ | refl | ._ | refl = refl lemma-drop⋙# : {b : Bound}{x : A}{l r : BBHeap (val x)}(b≤x : LeB b (val x))(l⋙r : l ⋙ r) → # (drop⋙ b≤x l⋙r) ≡ # l + # r lemma-drop⋙# b≤x (⋙lf x≤y) = refl lemma-drop⋙# b≤x (⋙rl {x = y₁} {x' = y₂} {l = l₁} {r = r₁} {l' = l₂} {r' = r₂} x≤y₁ x≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂) with tot≤ y₁ y₂ | lemma-drop⋙ (cl x≤y₁ l₁⋘r₁) (cl x≤y₂ l₂⋘r₂) (⋙rl x≤y₁ x≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂) ... | inj₁ y₁≤y₂ | inj₁ (_ , dl⋘r) with # (drop⋘ x≤y₁ l₁⋘r₁) | lemma-drop⋘# x≤y₁ l₁⋘r₁ ... | ._ | refl = refl lemma-drop⋙# b≤x (⋙rl {l = l₁} {r = r₁} {l' = l₂} {r' = r₂} x≤y₁ x≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂) | inj₁ y₁≤y₂ | inj₂ l⋙dr with # (drop⋘ x≤y₂ l₂⋘r₂) | lemma-drop⋘# x≤y₂ l₂⋘r₂ | # (push⋘ (lexy y₁≤y₂) (lexy refl≤) l₁⋘r₁) | lemma-push# (lexy y₁≤y₂) (left (lexy refl≤) l₁⋘r₁) | # (subtyping (lexy y₁≤y₂) (drop⋘ x≤y₂ l₂⋘r₂)) | lemma-subtyping# (lexy y₁≤y₂) (drop⋘ x≤y₂ l₂⋘r₂) | # l₁ + # r₁ + suc (# l₂ + # r₂) | +assoc (# l₁ + # r₁) (# l₂ + # r₂) ... | ._ | refl | ._ | refl | ._ | refl | ._ | refl = refl lemma-drop⋙# b≤x (⋙rl x≤y₁ x≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂) | inj₂ y₂≤y₁ | inj₁ (_ , dl⋘r) with # (drop⋘ x≤y₁ l₁⋘r₁) | lemma-drop⋘# x≤y₁ l₁⋘r₁ | # (push⋘ (lexy y₂≤y₁) (lexy refl≤) l₂⋘r₂) | lemma-push# (lexy y₂≤y₁) (left (lexy refl≤) l₂⋘r₂) | # (subtyping (lexy y₂≤y₁) (drop⋘ x≤y₁ l₁⋘r₁)) | lemma-subtyping# (lexy y₂≤y₁) (drop⋘ x≤y₁ l₁⋘r₁) ... | ._ | refl | ._ | refl | ._ | refl = refl lemma-drop⋙# b≤x (⋙rl {l = l₁} {r = r₁} {l' = l₂} {r' = r₂} x≤y₁ x≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂) | inj₂ y₂≤y₁ | inj₂ l⋙dr with # (drop⋘ x≤y₂ l₂⋘r₂) | lemma-drop⋘# x≤y₂ l₂⋘r₂ | (# l₁ + # r₁) + suc (# l₂ + # r₂) | +assoc (# l₁ + # r₁) (# l₂ + # r₂) ... | ._ | refl | ._ | refl = refl lemma-drop⋙# b≤x (⋙rr {x = y₁} {x' = y₂} {l = l₁} {r = r₁} {l' = l₂} {r' = r₂} x≤y₁ x≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂) with tot≤ y₁ y₂ | lemma-drop⋙ (cl x≤y₁ l₁⋘r₁) (cr x≤y₂ l₂⋙r₂) (⋙rr x≤y₁ x≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂) ... | _ | inj₁ (() , _) ... | inj₁ y₁≤y₂ | inj₂ l⋙dr with # (drop⋙ x≤y₂ l₂⋙r₂) | lemma-drop⋙# x≤y₂ l₂⋙r₂ | # (push⋘ (lexy y₁≤y₂) (lexy refl≤) l₁⋘r₁) | lemma-push# (lexy y₁≤y₂) (left (lexy refl≤) l₁⋘r₁) | # (subtyping (lexy y₁≤y₂) (drop⋙ x≤y₂ l₂⋙r₂)) | lemma-subtyping# (lexy y₁≤y₂) (drop⋙ x≤y₂ l₂⋙r₂) | # l₁ + # r₁ + suc (# l₂ + # r₂) | +assoc (# l₁ + # r₁) (# l₂ + # r₂) ... | ._ | refl | ._ | refl | ._ | refl | ._ | refl = refl lemma-drop⋙# b≤x (⋙rr {l = l₁} {r = r₁} {l' = l₂} {r' = r₂} x≤y₁ x≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂) | inj₂ y₂≤y₁ | inj₂ l⋙dr with # (drop⋙ x≤y₂ l₂⋙r₂) | lemma-drop⋙# x≤y₂ l₂⋙r₂ | (# l₁ + # r₁) + suc (# l₂ + # r₂) | +assoc (# l₁ + # r₁) (# l₂ + # r₂) ... | ._ | refl | ._ | refl = refl lemma-drop# : {b : Bound}{h : BBHeap b}(cₕ : Compound h) → suc (# (drop cₕ)) ≡ # h lemma-drop# (cl b≤x l⋘r) with # (drop (cl b≤x l⋘r)) | lemma-drop⋘# b≤x l⋘r ... | ._ | refl = refl lemma-drop# (cr b≤x l⋙r) with # (drop (cr b≤x l⋙r)) | lemma-drop⋙# b≤x l⋙r ... | ._ | refl = refl lemma-drop≤′ : {b : Bound}{h : BBHeap b}(cₕ : Compound h) → suc (# (drop cₕ)) ≤′ # h lemma-drop≤′ cₕ with suc (# (drop cₕ)) | lemma-drop# cₕ ... | ._ | refl = ≤′-refl mutual lemma-drop⋘∼ : {b : Bound}{x : A}{l r : BBHeap (val x)}(b≤x : LeB b (val x))(l⋘r : l ⋘ r) → flatten (drop⋘ b≤x l⋘r) ∼ (flatten l ++ flatten r) lemma-drop⋘∼ b≤x lf⋘ = ∼[] lemma-drop⋘∼ b≤x (ll⋘ {x = y₁} {x' = y₂} {l = l₁} {r = r₁} x≤y₁ x≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂) with tot≤ y₁ y₂ | lemma-drop⋘ (cl x≤y₁ l₁⋘r₁) (cl x≤y₂ l₂⋘r₂) (ll⋘ x≤y₁ x≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂) ... | inj₁ y₁≤y₂ | inj₁ (_ , l⋙dr) = let fdr∼fl₂fr₂ = lemma-drop⋘∼ x≤y₂ l₂⋘r₂ ; fdr'∼fdr = lemma-subtyping∼ (lexy y₁≤y₂) (drop⋘ x≤y₂ l₂⋘r₂) ; fdr'∼fl₂fr₂ = trans∼ fdr'∼fdr fdr∼fl₂fr₂ ; fpl'∼y₂fl₁fr₁ = lemma-push⋘∼ (lexy y₁≤y₂) (lexy refl≤) l₁⋘r₁ ; fpl'fdr'∼y₂fl₁fr₁fl₂fr₂ = lemma++∼ fpl'∼y₂fl₁fr₁ fdr'∼fl₂fr₂ ; fl₁fr₁fr/y₂⟶fl₁fr₁fl₂fr₂ = lemma++/ {xs = flatten l₁ ++ flatten r₁} ; y₂fl₁fr₁fl₂fr₂∼fl₁fr₁fr = ∼x /head fl₁fr₁fr/y₂⟶fl₁fr₁fl₂fr₂ refl∼ ; fpl'fdr'∼fl₁fr₁fr = trans∼ fpl'fdr'∼y₂fl₁fr₁fl₂fr₂ y₂fl₁fr₁fl₂fr₂∼fl₁fr₁fr in ∼x /head /head fpl'fdr'∼fl₁fr₁fr ... | inj₁ y₁≤y₂ | inj₂ dl⋘r = let fdl∼fl₁fr₁ = lemma-drop⋘∼ x≤y₁ l₁⋘r₁ ; fdlfr∼fl₁fr₁fr = lemma++∼r fdl∼fl₁fr₁ in ∼x /head /head fdlfr∼fl₁fr₁fr ... | inj₂ y₂≤y₁ | inj₁ (_ , l⋙dr) = let fdr∼fl₂fr₂ = lemma-drop⋘∼ x≤y₂ l₂⋘r₂ ; fl = y₁ ∷ (flatten l₁ ++ flatten r₁) ; flfdr∼flfl₂fr₂ = lemma++∼l {xs = fl} fdr∼fl₂fr₂ ; flfr/y₂⟶flfl₂fr₂ = lemma++/ {xs = fl} in ∼x {x = y₂} /head flfr/y₂⟶flfl₂fr₂ flfdr∼flfl₂fr₂ ... | inj₂ y₂≤y₁ | inj₂ dl⋘r = let fdl∼fl₁fr₁ = lemma-drop⋘∼ x≤y₁ l₁⋘r₁ ; fdl'∼fdl = lemma-subtyping∼ (lexy y₂≤y₁) (drop⋘ x≤y₁ l₁⋘r₁) ; fdl'∼fl₁fr₁ = trans∼ fdl'∼fdl fdl∼fl₁fr₁ ; fpr'∼y₁fl₂fr₂ = lemma-push⋘∼ (lexy y₂≤y₁) (lexy refl≤) l₂⋘r₂ ; fdl'fpr'∼fl₁fr₁y₁fl₂fr₂ = lemma++∼ fdl'∼fl₁fr₁ fpr'∼y₁fl₂fr₂ ; flfr/y₂⟶flfl₂fr₂ = lemma++/ {xs = y₁ ∷ (flatten l₁ ++ flatten r₁)} ; fl₁fr₁y₁fl₂fr₂/y₁⟶fl₁fr₁fl₂fr₂ = lemma++/ {xs = flatten l₁ ++ flatten r₁} ; fl₁fr₁y₁fl₂fr₂∼flfl₂fr₂ = ∼x fl₁fr₁y₁fl₂fr₂/y₁⟶fl₁fr₁fl₂fr₂ /head refl∼ ; fdl'fpr'∼flfl₂fr₂ = trans∼ fdl'fpr'∼fl₁fr₁y₁fl₂fr₂ fl₁fr₁y₁fl₂fr₂∼flfl₂fr₂ in ∼x /head flfr/y₂⟶flfl₂fr₂ fdl'fpr'∼flfl₂fr₂ lemma-drop⋘∼ b≤x (lr⋘ {x = y₁} {x' = y₂} {l = l₁} {r = r₁} x≤y₁ x≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂) with tot≤ y₁ y₂ | lemma-drop⋘ (cr x≤y₁ l₁⋙r₁) (cl x≤y₂ l₂⋘r₂) (lr⋘ x≤y₁ x≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂) ... | _ | inj₁ (() , _) ... | inj₁ y₁≤y₂ | inj₂ dl⋘r = let fdl∼fl₁fr₁ = lemma-drop⋙∼ x≤y₁ l₁⋙r₁ ; fdlfr∼fl₁fr₁fr = lemma++∼r fdl∼fl₁fr₁ in ∼x /head /head fdlfr∼fl₁fr₁fr ... | inj₂ y₂≤y₁ | inj₂ dl⋘r = let fdl∼fl₁fr₁ = lemma-drop⋙∼ x≤y₁ l₁⋙r₁ ; fdl'∼fdl = lemma-subtyping∼ (lexy y₂≤y₁) (drop⋙ x≤y₁ l₁⋙r₁) ; fdl'∼fl₁fr₁ = trans∼ fdl'∼fdl fdl∼fl₁fr₁ ; fpr'∼y₁fl₂fr₂ = lemma-push⋘∼ (lexy y₂≤y₁) (lexy refl≤) l₂⋘r₂ ; fdl'fpr'∼fl₁fr₁y₁fl₂fr₂ = lemma++∼ fdl'∼fl₁fr₁ fpr'∼y₁fl₂fr₂ ; flfr/y₂⟶flfl₂fr₂ = lemma++/ {xs = y₁ ∷ (flatten l₁ ++ flatten r₁)} ; fl₁fr₁y₁fl₂fr₂/y₁⟶fl₁fr₁fl₂fr₂ = lemma++/ {xs = flatten l₁ ++ flatten r₁} ; fl₁fr₁y₁fl₂fr₂∼flfl₂fr₂ = ∼x fl₁fr₁y₁fl₂fr₂/y₁⟶fl₁fr₁fl₂fr₂ /head refl∼ ; fdl'fpr'∼flfl₂fr₂ = trans∼ fdl'fpr'∼fl₁fr₁y₁fl₂fr₂ fl₁fr₁y₁fl₂fr₂∼flfl₂fr₂ in ∼x /head flfr/y₂⟶flfl₂fr₂ fdl'fpr'∼flfl₂fr₂ lemma-drop⋙∼ : {b : Bound}{x : A}{l r : BBHeap (val x)}(b≤x : LeB b (val x))(l⋙r : l ⋙ r) → flatten (drop⋙ b≤x l⋙r) ∼ (flatten l ++ flatten r) lemma-drop⋙∼ b≤x (⋙lf x≤y) = ∼x /head /head ∼[] lemma-drop⋙∼ b≤x (⋙rl {x = y₁} {x' = y₂} {l = l₁} {r = r₁} x≤y₁ x≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂) with tot≤ y₁ y₂ | lemma-drop⋙ (cl x≤y₁ l₁⋘r₁) (cl x≤y₂ l₂⋘r₂) (⋙rl x≤y₁ x≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂) ... | inj₁ y₁≤y₂ | inj₁ (_ , dl⋘r) = let fdl∼fl₁fr₁ = lemma-drop⋘∼ x≤y₁ l₁⋘r₁ ; fdlfr∼fl₁fr₁fr = lemma++∼r fdl∼fl₁fr₁ in ∼x /head /head fdlfr∼fl₁fr₁fr ... | inj₁ y₁≤y₂ | inj₂ l⋙dr = let fdr∼fl₂fr₂ = lemma-drop⋘∼ (lexy refl≤) l₂⋘r₂ ; fdr'∼fdr = lemma-subtyping∼ (lexy y₁≤y₂) (drop⋘ x≤y₂ l₂⋘r₂) ; fdr'∼fl₂fr₂ = trans∼ fdr'∼fdr fdr∼fl₂fr₂ ; fpl'∼y₂fl₁fr₁ = lemma-push⋘∼ (lexy y₁≤y₂) (lexy refl≤) l₁⋘r₁ ; fpl'fdr'∼y₂fl₁fr₁fl₂fr₂ = lemma++∼ fpl'∼y₂fl₁fr₁ fdr'∼fl₂fr₂ ; fl₁fr₁fr/y₂⟶fl₁fr₁fl₂fr₂ = lemma++/ {xs = flatten l₁ ++ flatten r₁} ; y₂fl₁fr₁fl₂fr₂∼fl₁fr₁fr = ∼x /head fl₁fr₁fr/y₂⟶fl₁fr₁fl₂fr₂ refl∼ ; fpl'fdr'∼fl₁fr₁fr = trans∼ fpl'fdr'∼y₂fl₁fr₁fl₂fr₂ y₂fl₁fr₁fl₂fr₂∼fl₁fr₁fr in ∼x /head /head fpl'fdr'∼fl₁fr₁fr ... | inj₂ y₂≤y₁ | inj₁ (_ , dl⋘r) = let fdl∼fl₁fr₁ = lemma-drop⋘∼ x≤y₁ l₁⋘r₁ ; fdl'∼fdl = lemma-subtyping∼ (lexy y₂≤y₁) (drop⋘ x≤y₁ l₁⋘r₁) ; fdl'∼fl₁fr₁ = trans∼ fdl'∼fdl fdl∼fl₁fr₁ ; fpr'∼y₁fl₂fr₂ = lemma-push⋘∼ (lexy y₂≤y₁) (lexy refl≤) l₂⋘r₂ ; fdl'fpr'∼fl₁fr₁y₁fl₂fr₂ = lemma++∼ fdl'∼fl₁fr₁ fpr'∼y₁fl₂fr₂ ; flfr/y₂⟶flfl₂fr₂ = lemma++/ {xs = y₁ ∷ (flatten l₁ ++ flatten r₁)} ; fl₁fr₁y₁fl₂fr₂/y₁⟶fl₁fr₁fl₂fr₂ = lemma++/ {xs = flatten l₁ ++ flatten r₁} ; fl₁fr₁y₁fl₂fr₂∼flfl₂fr₂ = ∼x fl₁fr₁y₁fl₂fr₂/y₁⟶fl₁fr₁fl₂fr₂ /head refl∼ ; fdl'fpr'∼flfl₂fr₂ = trans∼ fdl'fpr'∼fl₁fr₁y₁fl₂fr₂ fl₁fr₁y₁fl₂fr₂∼flfl₂fr₂ in ∼x /head flfr/y₂⟶flfl₂fr₂ fdl'fpr'∼flfl₂fr₂ ... | inj₂ y₂≤y₁ | inj₂ l⋙dr = let fdr∼fl₂fr₂ = lemma-drop⋘∼ x≤y₂ l₂⋘r₂ ; fl = y₁ ∷ (flatten l₁ ++ flatten r₁) ; flfdr∼flfl₂fr₂ = lemma++∼l {xs = fl} fdr∼fl₂fr₂ ; flfr/y₂⟶flfl₂fr₂ = lemma++/ {xs = fl} in ∼x {x = y₂} /head flfr/y₂⟶flfl₂fr₂ flfdr∼flfl₂fr₂ lemma-drop⋙∼ b≤x (⋙rr {x = y₁} {x' = y₂} {l = l₁} {r = r₁} x≤y₁ x≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂) with tot≤ y₁ y₂ | lemma-drop⋙ (cl x≤y₁ l₁⋘r₁) (cr x≤y₂ l₂⋙r₂) (⋙rr x≤y₁ x≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂) ... | _ | inj₁ (() , _) ... | inj₁ y₁≤y₂ | inj₂ l⋙dr = let fdr∼fl₂fr₂ = lemma-drop⋙∼ (lexy refl≤) l₂⋙r₂ ; fdr'∼fdr = lemma-subtyping∼ (lexy y₁≤y₂) (drop⋙ x≤y₂ l₂⋙r₂) ; fdr'∼fl₂fr₂ = trans∼ fdr'∼fdr fdr∼fl₂fr₂ ; fpl'∼y₂fl₁fr₁ = lemma-push⋘∼ (lexy y₁≤y₂) (lexy refl≤) l₁⋘r₁ ; fpl'fdr'∼y₂fl₁fr₁fl₂fr₂ = lemma++∼ fpl'∼y₂fl₁fr₁ fdr'∼fl₂fr₂ ; fl₁fr₁fr/y₂⟶fl₁fr₁fl₂fr₂ = lemma++/ {xs = flatten l₁ ++ flatten r₁} ; y₂fl₁fr₁fl₂fr₂∼fl₁fr₁fr = ∼x /head fl₁fr₁fr/y₂⟶fl₁fr₁fl₂fr₂ refl∼ ; fpl'fdr'∼fl₁fr₁fr = trans∼ fpl'fdr'∼y₂fl₁fr₁fl₂fr₂ y₂fl₁fr₁fl₂fr₂∼fl₁fr₁fr in ∼x /head /head fpl'fdr'∼fl₁fr₁fr ... | inj₂ y₂≤y₁ | inj₂ l⋙dr = let fdr∼fl₂fr₂ = lemma-drop⋙∼ x≤y₂ l₂⋙r₂ ; fl = y₁ ∷ (flatten l₁ ++ flatten r₁) ; flfdr∼flfl₂fr₂ = lemma++∼l {xs = fl} fdr∼fl₂fr₂ ; flfr/y₂⟶flfl₂fr₂ = lemma++/ {xs = fl} in ∼x {x = y₂} /head flfr/y₂⟶flfl₂fr₂ flfdr∼flfl₂fr₂
{ "alphanum_fraction": 0.4997628887, "avg_line_length": 72.3578431373, "ext": "agda", "hexsha": "ba15495ec74cfe1f2226089d03cd7df58bab77ae", "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/Drop/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/BBHeap/Drop/Properties.agda", "max_line_length": 325, "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/Drop/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 8000, "size": 14761 }
module Inductive.Examples.Product where open import Inductive open import Tuple open import Data.Fin open import Data.Product hiding (_×_; <_,_>) open import Data.List open import Data.Vec _×_ : Set → Set → Set A × B = Inductive (((A ∷ (B ∷ [])) , []) ∷ []) <_,_> : {A B : Set} → A → B → A × B < a , b > = construct zero (a ∷ (b ∷ [])) [] fst : {A B : Set} → A × B → A fst = rec ((λ a b → a) ∷ []) snd : {A B : Set} → A × B → B snd = rec ((λ a b → b) ∷ [])
{ "alphanum_fraction": 0.5313174946, "avg_line_length": 21.0454545455, "ext": "agda", "hexsha": "3b0e2d6618a04bf2b38aa70b60e4fa05cd38d433", "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": "dc157acda597a2c758e82b5637e4fd6717ccec3f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mr-ohman/general-induction", "max_forks_repo_path": "Inductive/Examples/Product.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "dc157acda597a2c758e82b5637e4fd6717ccec3f", "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": "mr-ohman/general-induction", "max_issues_repo_path": "Inductive/Examples/Product.agda", "max_line_length": 46, "max_stars_count": null, "max_stars_repo_head_hexsha": "dc157acda597a2c758e82b5637e4fd6717ccec3f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mr-ohman/general-induction", "max_stars_repo_path": "Inductive/Examples/Product.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 171, "size": 463 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.NatPlusOne where open import Cubical.Data.NatPlusOne.Base public open import Cubical.Data.NatPlusOne.Properties public
{ "alphanum_fraction": 0.7864583333, "avg_line_length": 27.4285714286, "ext": "agda", "hexsha": "6e14f84c45f86de4716314de6427a950783469d2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Data/NatPlusOne.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Data/NatPlusOne.agda", "max_line_length": 53, "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/Data/NatPlusOne.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 48, "size": 192 }
{-# OPTIONS -v tc.conv.fun:20 #-} -- Andreas, 2019-11-06, issue #4175, reported and test case by nad. -- Check quantity for function type subtyping. postulate F : Set → Set G : (@0 Set → Set) → Set -- If an erased function is expected, we cannot pass one -- that might actually use its arguments. ShouldFail : Set ShouldFail = G F -- Note the eta-expanded version already failed: -- Fails = G λ x → F x
{ "alphanum_fraction": 0.677184466, "avg_line_length": 22.8888888889, "ext": "agda", "hexsha": "b51840ad627689a1e2a2a7c2342472424f75de36", "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/Issue4175.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/Issue4175.agda", "max_line_length": 67, "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/Issue4175.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": 116, "size": 412 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import groups.Cokernel open import cw.WedgeOfCells open import cohomology.Theory open import cw.CW module cw.cohomology.reconstructed.HigherCoboundary {i} (OT : OrdinaryTheory i) {n} (⊙skel : ⊙Skeleton {i} (S (S n))) where open OrdinaryTheory OT open import cw.cohomology.grid.LongExactSequence cohomology-theory (ℕ-to-ℤ (S n)) (⊙cw-incl-last (⊙cw-init ⊙skel)) (⊙cw-incl-last ⊙skel) open import cw.cohomology.WedgeOfCells OT cw-co∂-last : CXₙ/Xₙ₋₁ (⊙cw-init ⊙skel) (ℕ-to-ℤ (S n)) →ᴳ CXₙ/Xₙ₋₁ ⊙skel (ℕ-to-ℤ (S (S n))) cw-co∂-last = grid-co∂ cw-∂-before-Susp : Xₙ/Xₙ₋₁ (⊙Skeleton.skel ⊙skel) → Susp (Xₙ/Xₙ₋₁ (cw-init (⊙Skeleton.skel ⊙skel))) cw-∂-before-Susp = grid-∂-before-Susp ⊙cw-∂-before-Susp : ⊙Xₙ/Xₙ₋₁ (⊙Skeleton.skel ⊙skel) ⊙→ ⊙Susp (⊙Xₙ/Xₙ₋₁ (cw-init (⊙Skeleton.skel ⊙skel))) ⊙cw-∂-before-Susp = ⊙grid-∂-before-Susp cw-∂-before-Susp-glue-β = grid-∂-before-Susp-glue-β cw-co∂-last-β = grid-co∂-β module CokerCo∂ where grp = Coker cw-co∂-last (CXₙ/Xₙ₋₁-is-abelian ⊙skel (ℕ-to-ℤ (S (S n)))) open Group grp public CokerCo∂ = CokerCo∂.grp
{ "alphanum_fraction": 0.6752899197, "avg_line_length": 32.0285714286, "ext": "agda", "hexsha": "49e23a057b46de50d0c83fc593c645473647fcf7", "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": "theorems/cw/cohomology/reconstructed/HigherCoboundary.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": "theorems/cw/cohomology/reconstructed/HigherCoboundary.agda", "max_line_length": 104, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/cw/cohomology/reconstructed/HigherCoboundary.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 529, "size": 1121 }
module Structure.Sets where open import Functional open import Lang.Instance import Lvl open import Logic open import Logic.Propositional open import Logic.Predicate open import Structure.Setoid open import Structure.Sets.Relator open import Type private variable ℓ ℓₑ ℓₗ : Lvl.Level private variable S E : Type{ℓ} module _ ⦃ equiv-S : let _ = E ; _ = S ; _ = ℓₗ in Equiv{ℓₑ}(S) ⦄ where module _ (_∈_ : E → S → Stmt{ℓₗ}) where SetExtensionality = SetEqualityRelation(_∈_)(_∈_) (Equiv._≡_ equiv-S) module SetExtensionality = SetEqualityRelation{_∈ₗ_ = _∈_}{_∈ᵣ_ = _∈_}{_≡_ = Equiv._≡_ equiv-S} set-extensionality = inst-fn SetExtensionality.membership
{ "alphanum_fraction": 0.7295690936, "avg_line_length": 32.0476190476, "ext": "agda", "hexsha": "b302c6b91de5ca00be01fa9b0391a49047c70a8f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Sets.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Sets.agda", "max_line_length": 99, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Sets.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": 229, "size": 673 }
-- The SIP applied to groups {-# OPTIONS --safe #-} module Cubical.Algebra.Group.GroupPath where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.HLevels open import Cubical.Foundations.Transport open import Cubical.Foundations.Univalence open import Cubical.Foundations.SIP open import Cubical.Foundations.Function using (_∘_) open import Cubical.Foundations.GroupoidLaws hiding (assoc) open import Cubical.Data.Sigma open import Cubical.Displayed.Base open import Cubical.Displayed.Auto open import Cubical.Displayed.Record open import Cubical.Displayed.Universe open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Group.Properties open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties private variable ℓ ℓ' ℓ'' : Level open Iso open GroupStr open IsGroupHom 𝒮ᴰ-Group : DUARel (𝒮-Univ ℓ) GroupStr ℓ 𝒮ᴰ-Group = 𝒮ᴰ-Record (𝒮-Univ _) IsGroupEquiv (fields: data[ _·_ ∣ autoDUARel _ _ ∣ pres· ] data[ 1g ∣ autoDUARel _ _ ∣ pres1 ] data[ inv ∣ autoDUARel _ _ ∣ presinv ] prop[ isGroup ∣ (λ _ _ → isPropIsGroup _ _ _) ]) where open GroupStr open IsGroupHom GroupPath : (M N : Group ℓ) → GroupEquiv M N ≃ (M ≡ N) GroupPath = ∫ 𝒮ᴰ-Group .UARel.ua -- TODO: Induced structure results are temporarily inconvenient while we transition between algebra -- representations module _ (G : Group ℓ) {A : Type ℓ} (m : A → A → A) (e : ⟨ G ⟩ ≃ A) (p· : ∀ x y → e .fst (G .snd ._·_ x y) ≡ m (e .fst x) (e .fst y)) where private module G = GroupStr (G .snd) FamilyΣ : Σ[ B ∈ Type ℓ ] (B → B → B) → Type ℓ FamilyΣ (B , n) = Σ[ e ∈ B ] Σ[ i ∈ (B → B) ] IsGroup e n i inducedΣ : FamilyΣ (A , m) inducedΣ = subst FamilyΣ (UARel.≅→≡ (autoUARel (Σ[ B ∈ Type ℓ ] (B → B → B))) (e , p·)) (G.1g , G.inv , G.isGroup) InducedGroup : Group ℓ InducedGroup .fst = A InducedGroup .snd ._·_ = m InducedGroup .snd .1g = inducedΣ .fst InducedGroup .snd .inv = inducedΣ .snd .fst InducedGroup .snd .isGroup = inducedΣ .snd .snd InducedGroupEquiv : GroupEquiv G InducedGroup fst InducedGroupEquiv = e snd InducedGroupEquiv = makeIsGroupHom p· InducedGroupPath : G ≡ InducedGroup InducedGroupPath = GroupPath _ _ .fst InducedGroupEquiv uaGroup : {G H : Group ℓ} → GroupEquiv G H → G ≡ H uaGroup {G = G} {H = H} = equivFun (GroupPath G H) -- Group-ua functoriality Group≡ : (G H : Group ℓ) → ( Σ[ p ∈ ⟨ G ⟩ ≡ ⟨ H ⟩ ] Σ[ q ∈ PathP (λ i → p i) (1g (snd G)) (1g (snd H)) ] Σ[ r ∈ PathP (λ i → p i → p i → p i) (_·_ (snd G)) (_·_ (snd H)) ] Σ[ s ∈ PathP (λ i → p i → p i) (inv (snd G)) (inv (snd H)) ] PathP (λ i → IsGroup (q i) (r i) (s i)) (isGroup (snd G)) (isGroup (snd H))) ≃ (G ≡ H) Group≡ G H = isoToEquiv theIso where theIso : Iso _ _ fun theIso (p , q , r , s , t) i = p i , groupstr (q i) (r i) (s i) (t i) inv theIso x = cong ⟨_⟩ x , cong (1g ∘ snd) x , cong (_·_ ∘ snd) x , cong (inv ∘ snd) x , cong (isGroup ∘ snd) x rightInv theIso _ = refl leftInv theIso _ = refl caracGroup≡ : {G H : Group ℓ} (p q : G ≡ H) → cong ⟨_⟩ p ≡ cong ⟨_⟩ q → p ≡ q caracGroup≡ {G = G} {H = H} p q P = sym (transportTransport⁻ (ua (Group≡ G H)) p) ∙∙ cong (transport (ua (Group≡ G H))) helper ∙∙ transportTransport⁻ (ua (Group≡ G H)) q where helper : transport (sym (ua (Group≡ G H))) p ≡ transport (sym (ua (Group≡ G H))) q helper = Σ≡Prop (λ _ → isPropΣ (isOfHLevelPathP' 1 (is-set (snd H)) _ _) λ _ → isPropΣ (isOfHLevelPathP' 1 (isSetΠ2 λ _ _ → is-set (snd H)) _ _) λ _ → isPropΣ (isOfHLevelPathP' 1 (isSetΠ λ _ → is-set (snd H)) _ _) λ _ → isOfHLevelPathP 1 (isPropIsGroup _ _ _) _ _) (transportRefl (cong ⟨_⟩ p) ∙ P ∙ sym (transportRefl (cong ⟨_⟩ q))) uaGroupId : (G : Group ℓ) → uaGroup (idGroupEquiv {G = G}) ≡ refl uaGroupId G = caracGroup≡ _ _ uaIdEquiv uaCompGroupEquiv : {F G H : Group ℓ} (f : GroupEquiv F G) (g : GroupEquiv G H) → uaGroup (compGroupEquiv f g) ≡ uaGroup f ∙ uaGroup g uaCompGroupEquiv f g = caracGroup≡ _ _ ( cong ⟨_⟩ (uaGroup (compGroupEquiv f g)) ≡⟨ uaCompEquiv _ _ ⟩ cong ⟨_⟩ (uaGroup f) ∙ cong ⟨_⟩ (uaGroup g) ≡⟨ sym (cong-∙ ⟨_⟩ (uaGroup f) (uaGroup g)) ⟩ cong ⟨_⟩ (uaGroup f ∙ uaGroup g) ∎) -- J-rule for GroupEquivs GroupEquivJ : {G : Group ℓ} (P : (H : Group ℓ) → GroupEquiv G H → Type ℓ') → P G idGroupEquiv → ∀ {H} e → P H e GroupEquivJ {G = G} P p {H} e = transport (λ i → P (GroupPath G H .fst e i) (transp (λ j → GroupEquiv G (GroupPath G H .fst e (i ∨ ~ j))) i e)) (subst (P G) (sym lem) p) where lem : transport (λ j → GroupEquiv G (GroupPath G H .fst e (~ j))) e ≡ idGroupEquiv lem = Σ≡Prop (λ _ → isPropIsGroupHom _ _) (Σ≡Prop (λ _ → isPropIsEquiv _) (funExt λ x → (λ i → fst (fst (fst e .snd .equiv-proof (transportRefl (fst (fst e) (transportRefl x i)) i)))) ∙ retEq (fst e) x))
{ "alphanum_fraction": 0.5995550612, "avg_line_length": 35.7218543046, "ext": "agda", "hexsha": "5536de9310bbff8c0464f241243e47b6c070118b", "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": "ce3120d3f8d692847b2744162bcd7a01f0b687eb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "guilhermehas/cubical", "max_forks_repo_path": "Cubical/Algebra/Group/GroupPath.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb", "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": "guilhermehas/cubical", "max_issues_repo_path": "Cubical/Algebra/Group/GroupPath.agda", "max_line_length": 114, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "guilhermehas/cubical", "max_stars_repo_path": "Cubical/Algebra/Group/GroupPath.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": 2010, "size": 5394 }
{-# OPTIONS --cubical-compatible #-} module Common.Char where open import Agda.Builtin.Char public open import Common.Bool charEq : Char -> Char -> Bool charEq = primCharEquality
{ "alphanum_fraction": 0.7472527473, "avg_line_length": 18.2, "ext": "agda", "hexsha": "7cfe769ed1c880c35040c143f8a2eb21663525f0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Common/Char.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Common/Char.agda", "max_line_length": 36, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Common/Char.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 43, "size": 182 }
module Array where open import Array.Base public open import Array.Properties public
{ "alphanum_fraction": 0.8181818182, "avg_line_length": 12.5714285714, "ext": "agda", "hexsha": "aff6f71abb3d51359c137673d7884b8dc169376a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-10-12T07:19:48.000Z", "max_forks_repo_forks_event_min_datetime": "2020-10-12T07:19:48.000Z", "max_forks_repo_head_hexsha": "584fedb30552f820c0668cedae53ec3d926860b5", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "ashinkarov/agda-array", "max_forks_repo_path": "Array.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "584fedb30552f820c0668cedae53ec3d926860b5", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "ashinkarov/agda-array", "max_issues_repo_path": "Array.agda", "max_line_length": 35, "max_stars_count": 6, "max_stars_repo_head_hexsha": "584fedb30552f820c0668cedae53ec3d926860b5", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "ashinkarov/agda-array", "max_stars_repo_path": "Array.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-15T14:21:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-09T13:53:46.000Z", "num_tokens": 17, "size": 88 }
module Data.Tuple.Category where import Lvl open import Data.Tuple as Tuple using (_⨯_ ; _,_) open import Data.Tuple.Equivalence import Functional as Fn open import Logic.Propositional open import Logic.Predicate open import Structure.Category open import Structure.Category.Functor open import Structure.Category.Functor.Functors open import Structure.Categorical.Properties open import Structure.Function open import Structure.Operator open import Structure.Relator.Equivalence open import Structure.Relator.Properties open import Structure.Setoid open import Syntax.Transitivity open import Type private variable ℓ ℓₒ ℓₘ ℓₑ ℓₒ₁ ℓₘ₁ ℓₑ₁ ℓₒ₂ ℓₘ₂ ℓₑ₂ : Lvl.Level private variable Obj Obj₁ Obj₂ Obj₁ₗ Obj₁ᵣ Obj₂ₗ Obj₂ᵣ : Type{ℓ} private variable Morphism Morphism₁ Morphism₂ Morphism₁ₗ Morphism₂ₗ Morphism₁ᵣ Morphism₂ᵣ : Obj → Obj → Type{ℓ} private variable ⦃ morphism-equiv morphism-equiv₁ morphism-equiv₂ morphism-equiv₁ₗ morphism-equiv₂ₗ morphism-equiv₁ᵣ morphism-equiv₂ᵣ ⦄ : ∀{x y : Obj} → Equiv{ℓₑ}(Morphism x y) private variable F F₁ F₂ : Obj₁ → Obj₂ private variable C Cₗ Cᵣ C₁ₗ C₁ᵣ C₂ₗ C₂ᵣ C₁ C₂ C₃ : CategoryObject{ℓₒ}{ℓₘ}{ℓₑ} module _ (cat₁ : Category{Obj = Obj₁} (Morphism₁) ⦃ \{x y} → morphism-equiv₁{x}{y} ⦄) (cat₂ : Category{Obj = Obj₂} (Morphism₂) ⦃ \{x y} → morphism-equiv₂{x}{y} ⦄) where open Category ⦃ … ⦄ private instance _ = cat₁ private instance _ = cat₂ productCategory : Category{Obj = Obj₁ ⨯ Obj₂} (\{(x₁ , x₂) (y₁ , y₂) → (Morphism₁ x₁ y₁) ⨯ (Morphism₂ x₂ y₂)}) Category._∘_ productCategory (f₁ , f₂) (g₁ , g₂) = ((f₁ ∘ g₁) , (f₂ ∘ g₂)) Category.id productCategory = (id , id) _⨯_.left (BinaryOperator.congruence (Category.binaryOperator productCategory) (p₁l , p₁r) (p₂l , p₂r)) = congruence₂(_∘_) p₁l p₂l _⨯_.right (BinaryOperator.congruence (Category.binaryOperator productCategory) (p₁l , p₁r) (p₂l , p₂r)) = congruence₂(_∘_) p₁r p₂r _⨯_.left (Morphism.Associativity.proof (Category.associativity productCategory)) = Morphism.associativity(_∘_) _⨯_.right (Morphism.Associativity.proof (Category.associativity productCategory)) = Morphism.associativity(_∘_) _⨯_.left (Morphism.Identityₗ.proof (_⨯_.left (Category.identity productCategory))) = Morphism.identityₗ(_∘_)(id) _⨯_.right (Morphism.Identityₗ.proof (_⨯_.left (Category.identity productCategory))) = Morphism.identityₗ(_∘_)(id) _⨯_.left (Morphism.Identityᵣ.proof (_⨯_.right (Category.identity productCategory))) = Morphism.identityᵣ(_∘_)(id) _⨯_.right (Morphism.Identityᵣ.proof (_⨯_.right (Category.identity productCategory))) = Morphism.identityᵣ(_∘_)(id) _⨯ᶜᵃᵗ_ : CategoryObject{ℓₒ₁}{ℓₘ₁}{ℓₑ₁} → CategoryObject{ℓₒ₂}{ℓₘ₂}{ℓₑ₂} → CategoryObject (intro C₁) ⨯ᶜᵃᵗ (intro C₂) = intro (productCategory C₁ C₂) module Tupleᶜᵃᵗ where open CategoryObject ⦃ … ⦄ open Functor ⦃ … ⦄ renaming (map to fmap) private open module CategoryObjectEquiv {ℓₒ ℓₘ ℓₑ} ⦃ C : CategoryObject{ℓₒ}{ℓₘ}{ℓₑ} ⦄ {x}{y} = Equivalence (Equiv-equivalence ⦃ CategoryObject.morphism-equiv(C){x}{y} ⦄) using () private open module CategoryObjectCategory {ℓₒ ℓₘ ℓₑ} ⦃ C : CategoryObject{ℓₒ}{ℓₘ}{ℓₑ} ⦄ = Category(category ⦃ C ⦄) open Structure.Category.Functor.Functors.Wrapped map : (C₁ₗ →ᶠᵘⁿᶜᵗᵒʳ C₁ᵣ) → (C₂ₗ →ᶠᵘⁿᶜᵗᵒʳ C₂ᵣ) → ((C₁ₗ ⨯ᶜᵃᵗ C₂ₗ) →ᶠᵘⁿᶜᵗᵒʳ (C₁ᵣ ⨯ᶜᵃᵗ C₂ᵣ)) map {C₁ₗ = C₁ₗ} {C₁ᵣ = C₁ᵣ} {C₂ₗ = C₂ₗ} {C₂ᵣ = C₂ᵣ} ([∃]-intro F₁ ⦃ functor₁ ⦄) ([∃]-intro F₂ ⦃ functor₂ ⦄) = [∃]-intro _ ⦃ productMapFunctor ⦄ where instance _ = C₁ₗ ; instance _ = C₁ᵣ ; instance _ = C₂ₗ ; instance _ = C₂ᵣ instance _ = C₁ₗ ⨯ᶜᵃᵗ C₂ₗ ; instance _ = C₁ᵣ ⨯ᶜᵃᵗ C₂ᵣ productMapFunctor : Functor(productCategory (category ⦃ C₁ₗ ⦄) (category ⦃ C₂ₗ ⦄))(productCategory (category ⦃ C₁ᵣ ⦄) (category ⦃ C₂ᵣ ⦄)) (Tuple.map F₁ F₂) Functor.map productMapFunctor = Tuple.map fmap fmap Tuple.left (Functor.op-preserving productMapFunctor) = op-preserving Tuple.right (Functor.op-preserving productMapFunctor) = op-preserving Tuple.left (Functor.id-preserving productMapFunctor) = id-preserving Tuple.right (Functor.id-preserving productMapFunctor) = id-preserving mapLeft : (C₁ₗ →ᶠᵘⁿᶜᵗᵒʳ C₁ᵣ) → ((C₁ₗ ⨯ᶜᵃᵗ C₂) →ᶠᵘⁿᶜᵗᵒʳ (C₁ᵣ ⨯ᶜᵃᵗ C₂)) mapLeft F = map F idᶠᵘⁿᶜᵗᵒʳ mapRight : (C₂ₗ →ᶠᵘⁿᶜᵗᵒʳ C₂ᵣ) → ((C₁ ⨯ᶜᵃᵗ C₂ₗ) →ᶠᵘⁿᶜᵗᵒʳ (C₁ ⨯ᶜᵃᵗ C₂ᵣ)) mapRight F = map idᶠᵘⁿᶜᵗᵒʳ F left : ((Cₗ ⨯ᶜᵃᵗ Cᵣ) →ᶠᵘⁿᶜᵗᵒʳ Cₗ) ∃.witness left = Tuple.left Functor.map (∃.proof left) = Tuple.left Functor.op-preserving (∃.proof (left {Cₗ = Cₗ} {Cᵣ = Cᵣ})) {f = (fₗ , fᵣ)} {g = (gₗ , gᵣ)} = Tuple.left ((fₗ , fᵣ) ∘ (gₗ , gᵣ)) 🝖[ _≡_ ]-[] Tuple.left ((fₗ ∘ gₗ) , (fᵣ ∘ gᵣ)) 🝖[ _≡_ ]-[] fₗ ∘ gₗ 🝖[ _≡_ ]-[] Tuple.left(fₗ , fᵣ) ∘ Tuple.left(gₗ , gᵣ) 🝖-end where instance _ = Cₗ ; instance _ = Cᵣ ; instance _ = Cₗ ⨯ᶜᵃᵗ Cᵣ Functor.id-preserving (∃.proof (left {Cₗ = Cₗ} {Cᵣ = Cᵣ})) {x , y} = Tuple.left (id ⦃ Cₗ ⨯ᶜᵃᵗ Cᵣ ⦄ {x , y}) 🝖[ _≡_ ]-[] Tuple.left (id ⦃ Cₗ ⦄ {x} , id ⦃ Cᵣ ⦄ {y}) 🝖[ _≡_ ]-[] id ⦃ Cₗ ⦄ {x} 🝖-end where instance _ = Cₗ ; instance _ = Cᵣ ; instance _ = Cₗ ⨯ᶜᵃᵗ Cᵣ right : ((Cₗ ⨯ᶜᵃᵗ Cᵣ) →ᶠᵘⁿᶜᵗᵒʳ Cᵣ) ∃.witness right = Tuple.right Functor.map (∃.proof right) = Tuple.right Functor.op-preserving (∃.proof (right {Cₗ = Cₗ} {Cᵣ = Cᵣ})) {f = (fₗ , fᵣ)} {g = (gₗ , gᵣ)} = Tuple.right ((fₗ , fᵣ) ∘ (gₗ , gᵣ)) 🝖[ _≡_ ]-[] Tuple.right ((fₗ ∘ gₗ) , (fᵣ ∘ gᵣ)) 🝖[ _≡_ ]-[] fᵣ ∘ gᵣ 🝖[ _≡_ ]-[] Tuple.right(fₗ , fᵣ) ∘ Tuple.right(gₗ , gᵣ) 🝖-end where instance _ = Cₗ ; instance _ = Cᵣ ; instance _ = Cₗ ⨯ᶜᵃᵗ Cᵣ Functor.id-preserving (∃.proof (right {Cₗ = Cₗ} {Cᵣ = Cᵣ})) {x , y} = Tuple.right (id ⦃ Cₗ ⨯ᶜᵃᵗ Cᵣ ⦄ {x , y}) 🝖[ _≡_ ]-[] Tuple.right (id ⦃ Cₗ ⦄ {x} , id ⦃ Cᵣ ⦄ {y}) 🝖[ _≡_ ]-[] id ⦃ Cᵣ ⦄ {y} 🝖-end where instance _ = Cₗ ; instance _ = Cᵣ ; instance _ = Cₗ ⨯ᶜᵃᵗ Cᵣ repeat : (C →ᶠᵘⁿᶜᵗᵒʳ (C ⨯ᶜᵃᵗ C)) ∃.witness repeat = Tuple.repeat Functor.map (∃.proof repeat) = Tuple.repeat Functor.op-preserving (∃.proof (repeat {C = C})) {f = f} {g = g} = Tuple.repeat(f ∘ g) 🝖[ _≡_ ]-[] Tuple.repeat(f) ∘ Tuple.repeat(g) 🝖-end where instance _ = C ; instance _ = C ⨯ᶜᵃᵗ C (Functor.id-preserving (∃.proof (repeat {C = C})) {x}) = Tuple.repeat(id{x = x}) 🝖[ _≡_ ]-[] id{x = (x , x)} 🝖-end where instance _ = C ; instance _ = C ⨯ᶜᵃᵗ C constₗ : CategoryObject.Object(Cₗ) → (Cᵣ →ᶠᵘⁿᶜᵗᵒʳ (Cₗ ⨯ᶜᵃᵗ Cᵣ)) constₗ c = mapLeft (constᶠᵘⁿᶜᵗᵒʳ c) ∘ᶠᵘⁿᶜᵗᵒʳ repeat constᵣ : CategoryObject.Object(Cᵣ) → (Cₗ →ᶠᵘⁿᶜᵗᵒʳ (Cₗ ⨯ᶜᵃᵗ Cᵣ)) constᵣ c = mapRight (constᶠᵘⁿᶜᵗᵒʳ c) ∘ᶠᵘⁿᶜᵗᵒʳ repeat associateLeft : (C₁ ⨯ᶜᵃᵗ (C₂ ⨯ᶜᵃᵗ C₃)) →ᶠᵘⁿᶜᵗᵒʳ ((C₁ ⨯ᶜᵃᵗ C₂) ⨯ᶜᵃᵗ C₃) ∃.witness associateLeft = Tuple.associateLeft Functor.map (∃.proof associateLeft) = Tuple.associateLeft Functor.op-preserving (∃.proof (associateLeft {C₁ = C₁}{C₂ = C₂}{C₃ = C₃})) {f = f}{g = g} = Tuple.associateLeft(f ∘ g) 🝖[ _≡_ ]-[] Tuple.associateLeft f ∘ Tuple.associateLeft g 🝖-end where instance _ = C₁ ; instance _ = C₂ ; instance _ = C₃ instance _ = C₁ ⨯ᶜᵃᵗ C₂ ; instance _ = C₂ ⨯ᶜᵃᵗ C₃ instance _ = C₁ ⨯ᶜᵃᵗ (C₂ ⨯ᶜᵃᵗ C₃) ; instance _ = (C₁ ⨯ᶜᵃᵗ C₂) ⨯ᶜᵃᵗ C₃ Functor.id-preserving (∃.proof (associateLeft {C₁ = C₁}{C₂ = C₂}{C₃ = C₃})) = Tuple.associateLeft(id) 🝖[ _≡_ ]-[] id 🝖-end where instance _ = C₁ ; instance _ = C₂ ; instance _ = C₃ instance _ = C₁ ⨯ᶜᵃᵗ C₂ ; instance _ = C₂ ⨯ᶜᵃᵗ C₃ instance _ = C₁ ⨯ᶜᵃᵗ (C₂ ⨯ᶜᵃᵗ C₃) ; instance _ = (C₁ ⨯ᶜᵃᵗ C₂) ⨯ᶜᵃᵗ C₃ associateRight : ((C₁ ⨯ᶜᵃᵗ C₂) ⨯ᶜᵃᵗ C₃) →ᶠᵘⁿᶜᵗᵒʳ (C₁ ⨯ᶜᵃᵗ (C₂ ⨯ᶜᵃᵗ C₃)) ∃.witness associateRight = Tuple.associateRight Functor.map (∃.proof associateRight) = Tuple.associateRight Functor.op-preserving (∃.proof (associateRight {C₁ = C₁}{C₂ = C₂}{C₃ = C₃})) {f = f}{g = g} = Tuple.associateRight(f ∘ g) 🝖[ _≡_ ]-[] Tuple.associateRight f ∘ Tuple.associateRight g 🝖-end where instance _ = C₁ ; instance _ = C₂ ; instance _ = C₃ instance _ = C₁ ⨯ᶜᵃᵗ C₂ ; instance _ = C₂ ⨯ᶜᵃᵗ C₃ instance _ = C₁ ⨯ᶜᵃᵗ (C₂ ⨯ᶜᵃᵗ C₃) ; instance _ = (C₁ ⨯ᶜᵃᵗ C₂) ⨯ᶜᵃᵗ C₃ Functor.id-preserving (∃.proof (associateRight {C₁ = C₁}{C₂ = C₂}{C₃ = C₃})) = Tuple.associateRight(id) 🝖[ _≡_ ]-[] id 🝖-end where instance _ = C₁ ; instance _ = C₂ ; instance _ = C₃ instance _ = C₁ ⨯ᶜᵃᵗ C₂ ; instance _ = C₂ ⨯ᶜᵃᵗ C₃ instance _ = C₁ ⨯ᶜᵃᵗ (C₂ ⨯ᶜᵃᵗ C₃) ; instance _ = (C₁ ⨯ᶜᵃᵗ C₂) ⨯ᶜᵃᵗ C₃
{ "alphanum_fraction": 0.6241447292, "avg_line_length": 53.5590062112, "ext": "agda", "hexsha": "f170b50a146951c5cf594521eb37466216bbebda", "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/Tuple/Category.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Data/Tuple/Category.agda", "max_line_length": 180, "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/Tuple/Category.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 4503, "size": 8623 }
module Haskell.Prim.Integer where open import Agda.Builtin.Nat open import Agda.Builtin.Bool open import Agda.Builtin.List open import Agda.Builtin.String open import Agda.Builtin.Char open import Agda.Builtin.Unit import Agda.Builtin.Int open Agda.Builtin.Int public using () renaming (Int to Integer) open Agda.Builtin.Int renaming (Int to Integer) open import Haskell.Prim open import Haskell.Prim.Bool -------------------------------------------------- -- Literals private negNat : Nat → Integer negNat 0 = pos 0 negNat (suc n) = negsuc n instance iNumberInteger : Number Integer iNumberInteger .Number.Constraint _ = ⊤ iNumberInteger .fromNat n = pos n iNegativeInteger : Negative Integer iNegativeInteger .Negative.Constraint _ = ⊤ iNegativeInteger .fromNeg n = negNat n -------------------------------------------------- -- Arithmetic private subNat : Nat → Nat → Integer subNat n m = if n < m then negsuc (m - suc n) else pos (n - m) negateInteger : Integer → Integer negateInteger (pos 0) = pos 0 negateInteger (pos (suc n)) = negsuc n negateInteger (negsuc n) = pos (suc n) addInteger : Integer → Integer → Integer addInteger (pos n) (pos m) = pos (n + m) addInteger (pos n) (negsuc m) = subNat n (suc m) addInteger (negsuc n) (pos m) = subNat m (suc n) addInteger (negsuc n) (negsuc m) = negsuc (n + m + 1) subInteger : Integer → Integer → Integer subInteger n m = addInteger n (negateInteger m) mulInteger : Integer → Integer → Integer mulInteger (pos n) (pos m) = pos (n * m) mulInteger (pos n) (negsuc m) = negNat (n * suc m) mulInteger (negsuc n) (pos m) = negNat (suc n * m) mulInteger (negsuc n) (negsuc m) = pos (suc n * suc m) absInteger : Integer → Integer absInteger (pos n) = pos n absInteger (negsuc n) = pos (suc n) signInteger : Integer → Integer signInteger (pos 0) = 0 signInteger (pos (suc _)) = 1 signInteger (negsuc _) = -1 -------------------------------------------------- -- Comparisons eqInteger : Integer → Integer → Bool eqInteger (pos n) (pos m) = n == m eqInteger (negsuc n) (negsuc m) = n == m eqInteger _ _ = false ltInteger : Integer → Integer → Bool ltInteger (pos n) (pos m) = n < m ltInteger (pos n) (negsuc _) = false ltInteger (negsuc n) (pos _) = true ltInteger (negsuc n) (negsuc m) = m < n -------------------------------------------------- -- Show showInteger : Integer → List Char showInteger n = primStringToList (primShowInteger n) -------------------------------------------------- -- Constraints isNegativeInteger : Integer → Bool isNegativeInteger (pos _) = false isNegativeInteger (negsuc _) = true IsNonNegativeInteger : Integer → Set IsNonNegativeInteger (pos _) = ⊤ IsNonNegativeInteger n@(negsuc _) = TypeError (primStringAppend (primShowInteger n) (" is negative"))
{ "alphanum_fraction": 0.6223922114, "avg_line_length": 26.8785046729, "ext": "agda", "hexsha": "27566ff0572e8554fe017172bef464d35691ca20", "lang": "Agda", "max_forks_count": 18, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:42:52.000Z", "max_forks_repo_forks_event_min_datetime": "2020-10-21T22:19:09.000Z", "max_forks_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "seanpm2001/agda2hs", "max_forks_repo_path": "lib/Haskell/Prim/Integer.agda", "max_issues_count": 63, "max_issues_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_issues_repo_issues_event_max_datetime": "2022-02-25T15:47:30.000Z", "max_issues_repo_issues_event_min_datetime": "2020-10-22T05:19:27.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "seanpm2001/agda2hs", "max_issues_repo_path": "lib/Haskell/Prim/Integer.agda", "max_line_length": 67, "max_stars_count": 55, "max_stars_repo_head_hexsha": "8c8f24a079ed9677dbe6893cf786e7ed52dfe8b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dxts/agda2hs", "max_stars_repo_path": "lib/Haskell/Prim/Integer.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-26T21:57:56.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-20T13:36:25.000Z", "num_tokens": 849, "size": 2876 }
{-# OPTIONS --without-K --exact-split --safe #-} module Fragment.Extensions.Semigroup where open import Fragment.Equational.Theory.Bundles open import Fragment.Algebra.Signature open import Fragment.Algebra.Homomorphism Σ-magma open import Fragment.Algebra.Free Σ-magma hiding (_~_) open import Fragment.Algebra.Algebra Σ-magma using (Algebra; IsAlgebra; Interpretation; Congruence; algebra) open import Fragment.Equational.FreeExtension Θ-semigroup open import Fragment.Equational.Model Θ-semigroup open import Fragment.Setoid.Morphism using (_↝_) open import Level using (Level; _⊔_) open import Data.Nat using (ℕ) open import Data.Fin using (Fin; #_) open import Data.Vec using (Vec; []; _∷_; map) open import Data.Vec.Relation.Binary.Pointwise.Inductive using ([]; _∷_) import Relation.Binary.Reasoning.Setoid as Reasoning open import Relation.Binary using (Setoid; IsEquivalence) open import Relation.Binary.PropositionalEquality as PE using (_≡_) private variable a ℓ : Level module _ (A : Model {a} {ℓ}) (n : ℕ) where private open module A = Setoid ∥ A ∥/≈ _·_ : ∥ A ∥ → ∥ A ∥ → ∥ A ∥ x · y = A ⟦ • ⟧ (x ∷ y ∷ []) ·-cong : ∀ {x y z w} → x ≈ y → z ≈ w → x · z ≈ y · w ·-cong x≈y z≈w = (A ⟦ • ⟧-cong) (x≈y ∷ z≈w ∷ []) ·-assoc : ∀ (x y z : ∥ A ∥) → (x · y) · z ≈ x · (y · z) ·-assoc x y z = ∥ A ∥ₐ-models assoc (env {A = ∥ A ∥ₐ} (x ∷ y ∷ z ∷ [])) mutual data STree : Set a where leaf : ∥ A ∥ → STree cons : ∥ A ∥ → DTree → STree data DTree : Set a where leaf : Fin n → DTree cons : Fin n → Tree → DTree data Tree : Set a where sta : STree → Tree dyn : DTree → Tree mutual infix 6 _≋_ _≋⟨s⟩_ _≋⟨d⟩_ data _≋⟨s⟩_ : STree → STree → Set (a ⊔ ℓ) where leaf : ∀ {x y} → x ≈ y → leaf x ≋⟨s⟩ leaf y cons : ∀ {x y xs ys} → x ≈ y → xs ≋⟨d⟩ ys → cons x xs ≋⟨s⟩ cons y ys data _≋⟨d⟩_ : DTree → DTree → Set (a ⊔ ℓ) where leaf : ∀ {x y} → x ≡ y → leaf x ≋⟨d⟩ leaf y cons : ∀ {x y xs ys} → x ≡ y → xs ≋ ys → cons x xs ≋⟨d⟩ cons y ys data _≋_ : Tree → Tree → Set (a ⊔ ℓ) where sta : ∀ {x y} → x ≋⟨s⟩ y → sta x ≋ sta y dyn : ∀ {x y} → x ≋⟨d⟩ y → dyn x ≋ dyn y mutual ≋⟨s⟩-refl : ∀ {x} → x ≋⟨s⟩ x ≋⟨s⟩-refl {leaf x} = leaf A.refl ≋⟨s⟩-refl {cons x xs} = cons A.refl ≋⟨d⟩-refl ≋⟨d⟩-refl : ∀ {x} → x ≋⟨d⟩ x ≋⟨d⟩-refl {leaf x} = leaf PE.refl ≋⟨d⟩-refl {cons x xs} = cons PE.refl ≋-refl ≋-refl : ∀ {x} → x ≋ x ≋-refl {sta x} = sta ≋⟨s⟩-refl ≋-refl {dyn x} = dyn ≋⟨d⟩-refl mutual ≋⟨s⟩-sym : ∀ {x y} → x ≋⟨s⟩ y → y ≋⟨s⟩ x ≋⟨s⟩-sym (leaf p) = leaf (A.sym p) ≋⟨s⟩-sym (cons p ps) = cons (A.sym p) (≋⟨d⟩-sym ps) ≋⟨d⟩-sym : ∀ {x y} → x ≋⟨d⟩ y → y ≋⟨d⟩ x ≋⟨d⟩-sym (leaf p) = leaf (PE.sym p) ≋⟨d⟩-sym (cons p ps) = cons (PE.sym p) (≋-sym ps) ≋-sym : ∀ {x y} → x ≋ y → y ≋ x ≋-sym (sta p) = sta (≋⟨s⟩-sym p) ≋-sym (dyn p) = dyn (≋⟨d⟩-sym p) mutual ≋⟨s⟩-trans : ∀ {x y z} → x ≋⟨s⟩ y → y ≋⟨s⟩ z → x ≋⟨s⟩ z ≋⟨s⟩-trans (leaf p) (leaf q) = leaf (A.trans p q) ≋⟨s⟩-trans (cons p ps) (cons q qs) = cons (A.trans p q) (≋⟨d⟩-trans ps qs) ≋⟨d⟩-trans : ∀ {x y z} → x ≋⟨d⟩ y → y ≋⟨d⟩ z → x ≋⟨d⟩ z ≋⟨d⟩-trans (leaf p) (leaf q) = leaf (PE.trans p q) ≋⟨d⟩-trans (cons p ps) (cons q qs) = cons (PE.trans p q) (≋-trans ps qs) ≋-trans : ∀ {x y z} → x ≋ y → y ≋ z → x ≋ z ≋-trans (sta p) (sta q) = sta (≋⟨s⟩-trans p q) ≋-trans (dyn p) (dyn q) = dyn (≋⟨d⟩-trans p q) ≋-isEquivalence : IsEquivalence _≋_ ≋-isEquivalence = record { refl = ≋-refl ; sym = ≋-sym ; trans = ≋-trans } Tree/≋ : Setoid _ _ Tree/≋ = record { Carrier = Tree ; _≈_ = _≋_ ; isEquivalence = ≋-isEquivalence } mutual _++⟨d⟩_ : DTree → Tree → DTree (leaf x) ++⟨d⟩ y = cons x y (cons x xs) ++⟨d⟩ y = cons x (xs ++ y) _++_ : Tree → Tree → Tree sta (leaf x) ++ sta (leaf y) = sta (leaf (x · y)) sta (leaf x) ++ sta (cons y ys) = sta (cons (x · y) ys) sta (leaf x) ++ dyn y = sta (cons x y) sta (cons x xs) ++ y = sta (cons x (xs ++⟨d⟩ y)) dyn x ++ y = dyn (x ++⟨d⟩ y) mutual ++⟨d⟩-assoc : ∀ x y z → (x ++⟨d⟩ y) ++⟨d⟩ z ≋⟨d⟩ x ++⟨d⟩ (y ++ z) ++⟨d⟩-assoc (leaf x) y z = ≋⟨d⟩-refl ++⟨d⟩-assoc (cons x xs) y z = cons PE.refl (++-assoc xs y z) ++-assoc : ∀ x y z → (x ++ y) ++ z ≋ x ++ (y ++ z) ++-assoc (sta (leaf x)) (sta (leaf y)) (sta (leaf z)) = sta (leaf (·-assoc x y z)) ++-assoc (sta (leaf x)) (sta (leaf y)) (sta (cons z zs)) = sta (cons (·-assoc x y z) ≋⟨d⟩-refl) ++-assoc (sta (leaf x)) (sta (leaf y)) (dyn z) = ≋-refl ++-assoc (sta (leaf x)) (sta (cons y ys)) z = ≋-refl ++-assoc (sta (leaf x)) (dyn y) z = ≋-refl ++-assoc (sta (cons x xs)) y z = sta (cons A.refl (++⟨d⟩-assoc xs y z)) ++-assoc (dyn x) y z = dyn (++⟨d⟩-assoc x y z) mutual ++⟨d⟩-cong : ∀ {x y z w} → x ≋⟨d⟩ y → z ≋ w → x ++⟨d⟩ z ≋⟨d⟩ y ++⟨d⟩ w ++⟨d⟩-cong (leaf p) q = cons p q ++⟨d⟩-cong (cons p ps) q = cons p (++-cong ps q) ++-cong : ∀ {x y z w} → x ≋ y → z ≋ w → x ++ z ≋ y ++ w ++-cong (sta (leaf p)) (sta (leaf q)) = sta (leaf (·-cong p q)) ++-cong (sta (leaf p)) (sta (cons q qs)) = sta (cons (·-cong p q) qs) ++-cong (sta (leaf p)) (dyn q) = sta (cons p q) ++-cong (sta (cons p ps)) q = sta (cons p (++⟨d⟩-cong ps q)) ++-cong (dyn p) q = dyn (++⟨d⟩-cong p q) Tree⟦_⟧ : Interpretation Tree/≋ Tree⟦ • ⟧ (x ∷ y ∷ []) = x ++ y Tree⟦_⟧-cong : Congruence Tree/≋ Tree⟦_⟧ Tree⟦ • ⟧-cong (p ∷ q ∷ []) = ++-cong p q Tree/≋-isAlgebra : IsAlgebra Tree/≋ Tree/≋-isAlgebra = record { ⟦_⟧ = Tree⟦_⟧ ; ⟦⟧-cong = Tree⟦_⟧-cong } Tree/≋-algebra : Algebra Tree/≋-algebra = record { ∥_∥/≈ = Tree/≋ ; ∥_∥/≈-isAlgebra = Tree/≋-isAlgebra } Tree/≋-models : Models Tree/≋-algebra Tree/≋-models assoc θ = ++-assoc (θ (# 0)) (θ (# 1)) (θ (# 2)) Tree/≋-isModel : IsModel Tree/≋ Tree/≋-isModel = record { isAlgebra = Tree/≋-isAlgebra ; models = Tree/≋-models } Frex : Model Frex = record { ∥_∥/≈ = Tree/≋ ; isModel = Tree/≋-isModel } ∣inl∣ : ∥ A ∥ → ∥ Frex ∥ ∣inl∣ x = sta (leaf x) ∣inl∣-cong : Congruent _≈_ _≋_ ∣inl∣ ∣inl∣-cong p = sta (leaf p) ∣inl∣⃗ : ∥ A ∥/≈ ↝ ∥ Frex ∥/≈ ∣inl∣⃗ = record { ∣_∣ = ∣inl∣ ; ∣_∣-cong = ∣inl∣-cong } ∣inl∣-hom : Homomorphic ∥ A ∥ₐ ∥ Frex ∥ₐ ∣inl∣ ∣inl∣-hom • (x ∷ y ∷ []) = ≋-refl inl : ∥ A ∥ₐ ⟿ ∥ Frex ∥ₐ inl = record { ∣_∣⃗ = ∣inl∣⃗ ; ∣_∣-hom = ∣inl∣-hom } inr : ∥ J n ∥ₐ ⟿ ∥ Frex ∥ₐ inr = interp Frex (λ k → dyn (leaf k)) module _ {b ℓ} (X : Model {b} {ℓ}) where private open module X = Setoid ∥ X ∥/≈ renaming (_≈_ to _~_) _⊕_ : ∥ X ∥ → ∥ X ∥ → ∥ X ∥ x ⊕ y = X ⟦ • ⟧ (x ∷ y ∷ []) ⊕-cong : ∀ {x y z w} → x ~ y → z ~ w → x ⊕ z ~ y ⊕ w ⊕-cong p q = (X ⟦ • ⟧-cong) (p ∷ q ∷ []) ⊕-assoc : ∀ (x y z : ∥ X ∥) → (x ⊕ y) ⊕ z ~ x ⊕ (y ⊕ z) ⊕-assoc x y z = ∥ X ∥ₐ-models assoc (env {A = ∥ X ∥ₐ} (x ∷ y ∷ z ∷ [])) module _ (f : ∥ A ∥ₐ ⟿ ∥ X ∥ₐ) (g : ∥ J n ∥ₐ ⟿ ∥ X ∥ₐ) where ∣resid∣ : ∥ Frex ∥ → ∥ X ∥ ∣resid∣ (sta (leaf x)) = ∣ f ∣ x ∣resid∣ (sta (cons x xs)) = ∣ f ∣ x ⊕ ∣resid∣ (dyn xs) ∣resid∣ (dyn (leaf x)) = ∣ g ∣ (atom (dyn x)) ∣resid∣ (dyn (cons x xs)) = ∣ g ∣ (atom (dyn x)) ⊕ ∣resid∣ xs ∣resid∣-cong : Congruent _≋_ _~_ ∣resid∣ ∣resid∣-cong (sta (leaf p)) = ∣ f ∣-cong p ∣resid∣-cong (sta (cons p ps)) = ⊕-cong (∣ f ∣-cong p) (∣resid∣-cong (dyn ps)) ∣resid∣-cong (dyn (leaf p)) = ∣ g ∣-cong (inherit (atom (dyn p))) ∣resid∣-cong (dyn (cons p ps)) = ⊕-cong (∣ g ∣-cong (inherit (atom (dyn p)))) (∣resid∣-cong ps) open Reasoning ∥ X ∥/≈ ∣resid∣-hom : Homomorphic ∥ Frex ∥ₐ ∥ X ∥ₐ ∣resid∣ ∣resid∣-hom • (sta (leaf x) ∷ sta (leaf y) ∷ []) = ∣ f ∣-hom • (x ∷ y ∷ []) ∣resid∣-hom • (sta (leaf x) ∷ sta (cons y ys) ∷ []) = begin ∣ f ∣ x ⊕ (∣ f ∣ y ⊕ ∣resid∣ (dyn ys)) ≈⟨ X.sym (⊕-assoc (∣ f ∣ x) (∣ f ∣ y) _) ⟩ (∣ f ∣ x ⊕ ∣ f ∣ y) ⊕ ∣resid∣ (dyn ys) ≈⟨ ⊕-cong (∣ f ∣-hom • (x ∷ y ∷ [])) X.refl ⟩ ∣ f ∣ (x · y) ⊕ ∣resid∣ (dyn ys) ∎ ∣resid∣-hom • (sta (leaf x) ∷ dyn y ∷ []) = X.refl ∣resid∣-hom • (sta (cons x xs) ∷ y ∷ []) = begin (∣ f ∣ x ⊕ ∣resid∣ (dyn xs)) ⊕ ∣resid∣ y ≈⟨ ⊕-assoc (∣ f ∣ x) _ (∣resid∣ y) ⟩ ∣ f ∣ x ⊕ (∣resid∣ (dyn xs) ⊕ ∣resid∣ y) ≈⟨ ⊕-cong X.refl (∣resid∣-hom • (dyn xs ∷ y ∷ [])) ⟩ ∣ f ∣ x ⊕ ∣resid∣ (dyn xs ++ y) ∎ ∣resid∣-hom • (dyn (leaf x) ∷ y ∷ []) = X.refl ∣resid∣-hom • (dyn (cons x xs) ∷ y ∷ []) = begin (∣ g ∣ (atom (dyn x)) ⊕ ∣resid∣ xs) ⊕ ∣resid∣ y ≈⟨ ⊕-assoc _ (∣resid∣ xs) (∣resid∣ y) ⟩ ∣ g ∣ (atom (dyn x)) ⊕ (∣resid∣ xs ⊕ ∣resid∣ y) ≈⟨ ⊕-cong X.refl (∣resid∣-hom • (xs ∷ y ∷ [])) ⟩ ∣ g ∣ (atom (dyn x)) ⊕ ∣resid∣ (xs ++ y) ∎ ∣resid∣⃗ : ∥ Frex ∥/≈ ↝ ∥ X ∥/≈ ∣resid∣⃗ = record { ∣_∣ = ∣resid∣ ; ∣_∣-cong = ∣resid∣-cong } _[_,_] : ∥ Frex ∥ₐ ⟿ ∥ X ∥ₐ _[_,_] = record { ∣_∣⃗ = ∣resid∣⃗ ; ∣_∣-hom = ∣resid∣-hom } module _ {b ℓ} {X : Model {b} {ℓ}} where private open module X = Setoid ∥ X ∥/≈ renaming (_≈_ to _~_) _⊕_ : ∥ X ∥ → ∥ X ∥ → ∥ X ∥ x ⊕ y = X ⟦ • ⟧ (x ∷ y ∷ []) ⊕-cong : ∀ {x y z w} → x ~ y → z ~ w → x ⊕ z ~ y ⊕ w ⊕-cong p q = (X ⟦ • ⟧-cong) (p ∷ q ∷ []) ⊕-assoc : ∀ (x y z : ∥ X ∥) → (x ⊕ y) ⊕ z ~ x ⊕ (y ⊕ z) ⊕-assoc x y z = ∥ X ∥ₐ-models assoc (env {A = ∥ X ∥ₐ} (x ∷ y ∷ z ∷ [])) module _ {f : ∥ A ∥ₐ ⟿ ∥ X ∥ₐ} {g : ∥ J n ∥ₐ ⟿ ∥ X ∥ₐ} where commute₁ : X [ f , g ] ⊙ inl ≗ f commute₁ = X.refl open Reasoning ∥ X ∥/≈ commute₂ : X [ f , g ] ⊙ inr ≗ g commute₂ {atom (dyn k)} = ∣ X [ f , g ] ∣-cong (≋-refl {x = dyn (leaf k)}) commute₂ {t@(term • (x ∷ y ∷ []))} = begin ∣ X [ f , g ] ∣ (∣ inr ∣ t) ≈⟨ ∣ X [ f , g ] ∣-cong (∣ inr ∣-hom • (x ∷ y ∷ [])) ⟩ ∣ X [ f , g ] ∣ (∣ inr ∣ x ++ ∣ inr ∣ y) ≈⟨ X.sym (∣ X [ f , g ] ∣-hom • (∣ inr ∣ x ∷ ∣ inr ∣ y ∷ [])) ⟩ ∣ X [ f , g ] ∣ (∣ inr ∣ x) ⊕ ∣ X [ f , g ] ∣ (∣ inr ∣ y) ≈⟨ ⊕-cong commute₂ commute₂ ⟩ ∣ g ∣ x ⊕ ∣ g ∣ y ≈⟨ ∣ g ∣-hom • (x ∷ y ∷ []) ⟩ ∣ g ∣ t ∎ module _ {h : ∥ Frex ∥ₐ ⟿ ∥ X ∥ₐ} (c₁ : h ⊙ inl ≗ f) (c₂ : h ⊙ inr ≗ g) where universal : X [ f , g ] ≗ h universal {sta (leaf x)} = X.sym c₁ universal {dyn (leaf x)} = X.sym c₂ universal {sta (cons x xs)} = begin ∣ f ∣ x ⊕ ∣ X [ f , g ] ∣ (dyn xs) ≈⟨ ⊕-cong (X.sym c₁) universal ⟩ ∣ h ∣ (sta (leaf x)) ⊕ ∣ h ∣ (dyn xs) ≈⟨ ∣ h ∣-hom • (sta (leaf x) ∷ dyn xs ∷ []) ⟩ ∣ h ∣ (sta (leaf x) ++ dyn xs) ∎ universal {dyn (cons x xs)} = begin ∣ g ∣ (atom (dyn x)) ⊕ ∣ X [ f , g ] ∣ xs ≈⟨ ⊕-cong (X.sym c₂) universal ⟩ ∣ h ∣ (dyn (leaf x)) ⊕ ∣ h ∣ xs ≈⟨ ∣ h ∣-hom • (dyn (leaf x) ∷ xs ∷ []) ⟩ ∣ h ∣ (dyn (leaf x) ++ xs) ∎ SemigroupFrex : FreeExtension SemigroupFrex = record { _[_] = Frex ; _[_]-isFrex = isFrex } where isFrex : IsFreeExtension Frex isFrex A n = record { inl = inl A n ; inr = inr A n ; _[_,_] = _[_,_] A n ; commute₁ = λ {_ _ X f g} → commute₁ A n {X = X} {f} {g} ; commute₂ = λ {_ _ X f g} → commute₂ A n {X = X} {f} {g} ; universal = λ {_ _ X f g h} → universal A n {X = X} {f} {g} {h} }
{ "alphanum_fraction": 0.4039273979, "avg_line_length": 34.2680965147, "ext": "agda", "hexsha": "f720073db43aca89049faf4e21c7afbb749ada81", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z", "max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z", "max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "yallop/agda-fragment", "max_forks_repo_path": "src/Fragment/Extensions/Semigroup.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z", "max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "yallop/agda-fragment", "max_issues_repo_path": "src/Fragment/Extensions/Semigroup.agda", "max_line_length": 107, "max_stars_count": 18, "max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yallop/agda-fragment", "max_stars_repo_path": "src/Fragment/Extensions/Semigroup.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z", "num_tokens": 5829, "size": 12782 }
module _ where open import Agda.Builtin.Equality open import Agda.Builtin.Nat module Vars (A : Set) where variable x : A -- Was -- Panic: Unbound name: Issue3121._.x [0,10,12]@8066984681118411118 -- when checking that the expression -- {A : Set} (let open Vars A) → ;Issue3121.x ≡ ;Issue3121.x has type _2 -- Should be -- scope error on x r : {A : Set} (let open Vars A) → x ≡ x r = refl
{ "alphanum_fraction": 0.657635468, "avg_line_length": 21.3684210526, "ext": "agda", "hexsha": "d48bbd4b5725e67342b1506eb981c763dd763356", "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/Issue3292a.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/Issue3292a.agda", "max_line_length": 74, "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/Issue3292a.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": 149, "size": 406 }
------------------------------------------------------------------------ -- Virtual machine instructions, state etc. ------------------------------------------------------------------------ open import Prelude module Lambda.Virtual-machine.Instructions (Name : Type) where open import Equality.Propositional open import Lambda.Syntax Name ------------------------------------------------------------------------ -- Instruction set mutual -- Instructions. data Instr (n : ℕ) : Type where var : Fin n → Instr n clo : Code (suc n) → Instr n app ret : Instr n cal tcl : Name → Instr n -- Calls and tail calls. con : Bool → Instr n bra : Code n → Code n → Instr n -- Code. Code : ℕ → Type Code n = List (Instr n) -- Environments and values. open Closure Code ------------------------------------------------------------------------ -- Stacks and states -- Stacks. data Stack-element : Type where val : Value → Stack-element ret : ∀ {n} → Code n → Env n → Stack-element Stack : Type Stack = List Stack-element -- States. data State : Type where ⟨_,_,_⟩ : ∀ {n} → Code n → Stack → Env n → State ------------------------------------------------------------------------ -- Results -- The result of running the VM one step. data Result : Type where continue : State → Result done : Value → Result crash : Result
{ "alphanum_fraction": 0.4673366834, "avg_line_length": 22.1111111111, "ext": "agda", "hexsha": "ebda6171d7b049ffe395583e809245b70f878f55", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "dec8cd2d2851340840de25acb0feb78f7b5ffe96", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/definitional-interpreters", "max_forks_repo_path": "src/Lambda/Virtual-machine/Instructions.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "dec8cd2d2851340840de25acb0feb78f7b5ffe96", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/definitional-interpreters", "max_issues_repo_path": "src/Lambda/Virtual-machine/Instructions.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "dec8cd2d2851340840de25acb0feb78f7b5ffe96", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/definitional-interpreters", "max_stars_repo_path": "src/Lambda/Virtual-machine/Instructions.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 300, "size": 1393 }
{-# OPTIONS --without-K --safe #-} module Categories.Adjoint.Equivalence.Properties where open import Level open import Categories.Category open import Categories.Adjoint.Equivalence open import Categories.Functor renaming (id to idF) open import Categories.Functor.Properties open import Categories.NaturalTransformation.NaturalIsomorphism as ≃ using (_≃_; NaturalIsomorphism) import Categories.Morphism.Reasoning as MR import Categories.Category.Construction.Cones as Co import Categories.Diagram.Limit as Lim private variable o ℓ e : Level C D E : Category o ℓ e -- diagrams are preserved by adjoint equivalence -- -- if categories C and D are adjoint equivalent, then a limit from one determines one from another module _ (⊣equiv : ⊣Equivalence C D) (F : Functor C E) where private module LF where open Co F public open Lim F public module C = Category C module D = Category D module E = Category E module F = Functor F module ⊣equiv = ⊣Equivalence ⊣equiv open ⊣equiv open E open MR E open HomReasoning open LF FR = F ∘F R module LFR where open Co FR public open Lim FR public module _ (Lm : Limit) where private module Lm = Lim.Limit Lm open Lm ⊤cone : LFR.Cone ⊤cone = record { N = Lm.apex ; apex = record { ψ = λ d → proj (R.₀ d) ; commute = λ f → limit-commute (R.₁ f) } } module _ {K : LFR.Cone} where private module K = LFR.Cone K K′ : Cone K′ = record { N = K.N ; apex = record { ψ = λ c → F.₁ (unit.⇐.η c) ∘ K.ψ (L.₀ c) ; commute = λ {X} {Y} f → begin F.₁ f ∘ F.₁ (unit.⇐.η X) ∘ K.ψ (L.₀ X) ≈˘⟨ pushˡ ([ F ]-resp-square (unit.⇐.commute f)) ⟩ (F.₁ (unit.⇐.η Y) ∘ F.₁ (Functor.F₁ (R ∘F L) f)) ∘ K.ψ (L.₀ X) ≈⟨ pullʳ (K.commute (L.₁ f)) ⟩ F.₁ (unit.⇐.η Y) ∘ K.ψ (L.₀ Y) ∎ } } !cone : LFR.Cones [ K , ⊤cone ] !cone = record { arr = rep K′ ; commute = λ {d} → begin proj (R.₀ d) ∘ rep K′ ≈⟨ commute ⟩ F.₁ (unit.⇐.η (R.₀ d)) ∘ K.ψ (L.₀ (R.₀ d)) ≈˘⟨ F.F-resp-≈ (MR.flip-fromʳ C unit.FX≅GX zag) ⟩∘⟨refl ⟩ (F.₁ (R.₁ (counit.⇒.η d)) ∘ K.ψ (L.₀ (R.₀ d))) ≈⟨ K.commute (counit.⇒.η d) ⟩ K.ψ d ∎ } module _ {K : LFR.Cone} (f : LFR.Cones [ K , ⊤cone ]) where private module K = LFR.Cone K module f = LFR.Cone⇒ f !cone-unique : LFR.Cones [ !cone ≈ f ] !cone-unique = begin rep (K′ {K}) ≈⟨ terminal.!-unique {K′ {K}} (record { arr = f.arr ; commute = eq }) ⟩ f.arr ∎ where eq : ∀ {c} → proj c ∘ f.arr ≈ F.₁ (unit.⇐.η c) ∘ K.ψ (L.₀ c) eq {c} = begin proj c ∘ f.arr ≈˘⟨ pullˡ (limit-commute (unit.⇐.η c)) ⟩ F.₁ (unit.⇐.η c) ∘ proj (R.₀ (L.₀ c)) ∘ f.arr ≈⟨ refl⟩∘⟨ f.commute ⟩ F.₁ (unit.⇐.η c) ∘ K.ψ (L.₀ c) ∎ ⊣equiv-preserves-diagram : Lim.Limit FR ⊣equiv-preserves-diagram = record { terminal = record { ⊤ = ⊤cone ; ! = !cone ; !-unique = !cone-unique } }
{ "alphanum_fraction": 0.4833285836, "avg_line_length": 31.6126126126, "ext": "agda", "hexsha": "bf22e9cc9e2c9fb0d48cecedc6854c7786fd38ca", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Adjoint/Equivalence/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Adjoint/Equivalence/Properties.agda", "max_line_length": 127, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Adjoint/Equivalence/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1223, "size": 3509 }
{- Copyright (c) 2017 Diego Pedraza. This is Free/Libre Open Source Software, released under the MIT License. For the full copyright and license information, please view the LICENSE file that was distributed with this source code. -} module R1 where open import Data.List using (List; _∷_; _++_; [_]; []) open import Data.Nat open import Data.Bool record Pair (A B : Set) : Set where constructor _,_ field fst : A snd : B {- ---------------------------------------------------------------- Ejercicio 1. Definir, por recursión, la función longitud :: 'a list ⇒ nat tal que (longitud xs) es la longitud de la listas xs. Por ejemplo, longitud [a,b,c] = 3 ----------------------------------------------------------------- -} longitud : ∀ {A : Set} → List A → ℕ longitud [] = 0 longitud (x ∷ xs) = 1 + longitud xs {- --------------------------------------------------------------- Ejercicio 2. Definir la función fun intercambia :: 'a × 'b ⇒ 'b × 'a tal que (intercambia p) es el par obtenido intercambiando las componentes del par p. Por ejemplo, intercambia (u,v) = (v,u) ---------------------------------------------------------------- -} intercambia : ∀ {A} {B : Set} → Pair A B → Pair B A intercambia (a , b) = (b , a) {- --------------------------------------------------------------- Ejercicio 3. Definir, por recursión, la función inversa :: 'a list ⇒ 'a list tal que (inversa xs) es la lista obtenida invirtiendo el orden de los elementos de xs. Por ejemplo, inversa [a,d,c] = [c,d,a] ---------------------------------------------------------------- -} inversa : ∀ {A : Set} → List A → List A inversa (x ∷ xs) = inversa (xs) ++ [ x ] inversa [] = [] {- --------------------------------------------------------------- Ejercicio 4. Definir la función repite :: nat ⇒ 'a ⇒ 'a list tal que (repite n x) es la lista formada por n copias del elemento x. Por ejemplo, repite 3 a = [a,a,a] ---------------------------------------------------------------- -} repite : ∀ {A : Set} → ℕ → A → List A repite 0 x = [] repite (suc n) x = x ∷ repite n x {- --------------------------------------------------------------- Ejercicio 5. Definir la función conc :: 'a list ⇒ 'a list ⇒ 'a list tal que (conc xs ys) es la concatención de las listas xs e ys. Por ejemplo, conc [a,d] [b,d,a,c] = [a,d,b,d,a,c] ---------------------------------------------------------------- -} conc : ∀ {A : Set} → List A → List A → List A conc [] ys = ys conc (x ∷ xs) ys = x ∷ conc xs ys {- --------------------------------------------------------------- Ejercicio 6. Definir la función coge :: nat ⇒ 'a list ⇒ 'a list tal que (coge n xs) es la lista de los n primeros elementos de xs. Por ejemplo, coge 2 [a,c,d,b,e] = [a,c] ---------------------------------------------------------------- -} coge : ∀ {A : Set} -> ℕ → List A → List A coge 0 xs = [] coge n [] = [] coge (suc n) (x ∷ xs) = x ∷ coge n xs {- --------------------------------------------------------------- Ejercicio 7. Definir la función elimina :: nat ⇒ 'a list ⇒ 'a list tal que (elimina n xs) es la lista obtenida eliminando los n primeros elementos de xs. Por ejemplo, elimina 2 [a,c,d,b,e] = [d,b,e] ---------------------------------------------------------------- -} elimina : ∀ {A : Set} → ℕ → List A → List A elimina 0 xs = xs elimina n [] = [] elimina (suc n) (x ∷ xs) = elimina n xs {- --------------------------------------------------------------- Ejercicio 8. Definir la función esVacia :: 'a list ⇒ bool tal que (esVacia xs) se verifica si xs es la lista vacía. Por ejemplo, esVacia [a] = False ---------------------------------------------------------------- -} esVacia : ∀ {A : Set} → List A → Bool esVacia [] = true esVacia (x ∷ xs) = false {- --------------------------------------------------------------- Ejercicio 9. Definir la función inversaAc :: 'a list ⇒ 'a list tal que (inversaAc xs) es a inversa de xs calculada usando acumuladores. Por ejemplo, inversaAc [a,c,b,e] = [e,b,c,a] ---------------------------------------------------------------- -} inversaAcAux : ∀ {A : Set} → List A → List A → List A inversaAcAux [] ys = ys inversaAcAux (x ∷ xs) ys = inversaAcAux xs (x ∷ ys) inversaAc : ∀ {A : Set} → List A → List A inversaAc xs = inversaAcAux xs [] {- --------------------------------------------------------------- Ejercicio 10. Definir la función sum :: nat list ⇒ nat tal que (sum xs) es la suma de los elementos de xs. Por ejemplo, sum [3,2,5] = 10 ---------------------------------------------------------------- -} sum : List ℕ → ℕ sum [] = 0 sum (x ∷ xs) = x + sum xs {- --------------------------------------------------------------- Ejercicio 11. Definir la función map :: ('a ⇒ 'b) ⇒ 'a list ⇒ 'b list tal que (map f xs) es la lista obtenida aplicando la función f a los elementos de xs. Por ejemplo, map (λx. 2*x) [3,2,5] = [6,4,10] ---------------------------------------------------------------- -} map : ∀ {A B : Set} → (A → B) → List A → List B map f (x ∷ xs) = f x ∷ (map f xs) map f [] = []
{ "alphanum_fraction": 0.4315567485, "avg_line_length": 34.091503268, "ext": "agda", "hexsha": "f2029b77112623e169abfbe5eed73df7388c333f", "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": "cc2e64e1a42ac225c3d1a6a998721f916065418b", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "Zegeri/TFG-TeoriaCategorias", "max_forks_repo_path": "Ejercicios/Agda/R1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cc2e64e1a42ac225c3d1a6a998721f916065418b", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "Zegeri/TFG-TeoriaCategorias", "max_issues_repo_path": "Ejercicios/Agda/R1.agda", "max_line_length": 75, "max_stars_count": null, "max_stars_repo_head_hexsha": "cc2e64e1a42ac225c3d1a6a998721f916065418b", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "Zegeri/TFG-TeoriaCategorias", "max_stars_repo_path": "Ejercicios/Agda/R1.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1435, "size": 5216 }
{-# OPTIONS --copatterns #-} module Copatterns where record Stream (A : Set) : Set where field head : A tail : Stream A open Stream repeat : {A : Set}(a : A) -> Stream A head (repeat a) = a tail (repeat a) = repeat a map : {A B : Set}(f : A -> B)(as : Stream A) -> Stream B head (map f as) = f (head as) tail (map f as) = map f (tail as) iterate : {A : Set}(f : A -> A)(a : A) -> Stream A head (iterate f a) = a tail (iterate f a) = iterate f (f a) scanl : {A B : Set} -> (B -> A -> B) -> B -> Stream A -> Stream B head (scanl f b as) = b tail (scanl f b as) = scanl f (f b (head as)) (tail as) data Nat : Set where zero : Nat suc : Nat -> Nat nats : Stream Nat nats = iterate suc zero alternate : Stream Nat ( head alternate ) = zero (head (tail alternate)) = suc zero (tail (tail alternate)) = alternate record _×_ (A B : Set) : Set where field fst : A snd : B open _×_ build : {A S : Set} → (S → A × S) -> S -> Stream A head (build step s) = fst (step s) tail (build step s) = build step (snd (step s)) -- build step s = mapSnd (build step) (step s) build1 : {A S : Set} → (S → A × S) -> S -> Stream A build1 step s = record { head = fst (step s) ; tail = build1 step (snd (step s)) } build2 : {A S : Set} → (S → A × S) -> S -> Stream A build2 step s = record { head = fst p ; tail = build2 step (snd p) } where p = step s mapSnd : {A B C : Set}(f : B → C) → A × B → A × C fst (mapSnd f p) = fst p snd (mapSnd f p) = f (snd p) record Str (A : Set) : Set where field out : A × Str A open Str build' : {A S : Set} → (S → A × S) -> S -> Stream A out (build' step s) = mapSnd (build' step) (step s)
{ "alphanum_fraction": 0.5551558753, "avg_line_length": 22.24, "ext": "agda", "hexsha": "15cc6374981b7d37beb8cc08cc19fbf620c4a9fc", "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/features/Copatterns.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/features/Copatterns.agda", "max_line_length": 65, "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/features/Copatterns.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": 615, "size": 1668 }
module Numeral.Integer.Sign where open import Numeral.Natural using (ℕ) open import Numeral.Integer open import Numeral.Sign as Sign using (+|− ; +|0|−) sign : ℤ → (+|−) sign(+ₙ _) = Sign.➕ sign(−𝐒ₙ _) = Sign.➖ sign0 : ℤ → (+|0|−) sign0(𝟎) = Sign.𝟎 sign0(+𝐒ₙ _) = Sign.➕ sign0(−𝐒ₙ _) = Sign.➖ signum0 : ℤ → ℤ signum0(𝟎) = 𝟎 signum0(+𝐒ₙ _) = +𝐒ₙ(ℕ.𝟎) signum0(−𝐒ₙ _) = −𝐒ₙ(ℕ.𝟎)
{ "alphanum_fraction": 0.5989583333, "avg_line_length": 17.4545454545, "ext": "agda", "hexsha": "1514952bdb331dda413d0bab1a2fd261fb847939", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Numeral/Integer/Sign.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Numeral/Integer/Sign.agda", "max_line_length": 33, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Numeral/Integer/Sign.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": 213, "size": 384 }
------------------------------------------------------------------------ -- And ------------------------------------------------------------------------ module TotalParserCombinators.And where open import Category.Monad open import Data.List.Relation.Binary.BagAndSetEquality open import Data.List.Membership.Propositional.Properties import Data.List.Categorical open import Data.Product open import Data.Product.Function.NonDependent.Propositional open import Function.Base open import Function.Inverse using (_↔_) import Function.Related as Related open import Function.Related.TypeIsomorphisms open import Level open RawMonadPlus {f = zero} Data.List.Categorical.monadPlus using (_⊗_) open Related using (SK-sym) open import TotalParserCombinators.Congruence using (_∼[_]P_; _≅P_) open import TotalParserCombinators.Derivative using (D) open import TotalParserCombinators.Parser import TotalParserCombinators.Pointwise as Pointwise open import TotalParserCombinators.Semantics using (_∈_·_) -- _&_ is defined as a pointwise lifting of _⊗_. private module And {R₁ R₂ : Set} = Pointwise R₁ R₂ id _⊗_ ⊗-cong -- p₁ & p₂ returns a result if both p₁ and p₂ do. infixr 6 _&_ _&-cong_ _&_ : ∀ {Tok R₁ R₂ xs₁ xs₂} → Parser Tok R₁ xs₁ → Parser Tok R₂ xs₂ → Parser Tok (R₁ × R₂) (xs₁ ⊗ xs₂) _&_ = And.lift -- D distributes over _&_. D-& : ∀ {Tok R₁ R₂ xs₁ xs₂ t} (p₁ : Parser Tok R₁ xs₁) (p₂ : Parser Tok R₂ xs₂) → D t (p₁ & p₂) ≅P D t p₁ & D t p₂ D-& = And.D-lift -- _&_ preserves equality. _&-cong_ : ∀ {k Tok R xs₁ xs₁′ xs₂ xs₂′} {p₁ : Parser Tok R xs₁} {p₁′ : Parser Tok R xs₁′} {p₂ : Parser Tok R xs₂} {p₂′ : Parser Tok R xs₂′} → p₁ ∼[ k ]P p₁′ → p₂ ∼[ k ]P p₂′ → p₁ & p₂ ∼[ k ]P p₁′ & p₂′ _&-cong_ = And.lift-cong -- _&_ is correct. correct : ∀ {Tok R₁ R₂ xs₁ xs₂ x₁ x₂ s} (p₁ : Parser Tok R₁ xs₁) (p₂ : Parser Tok R₂ xs₂) → (x₁ , x₂) ∈ p₁ & p₂ · s ↔ (x₁ ∈ p₁ · s × x₂ ∈ p₂ · s) correct {x₁ = x₁} {x₂} = And.lift-property (λ F G H → H (x₁ , x₂) ↔ (F x₁ × G x₂)) (λ F↔F′ G↔G′ H↔H′ → Related-cong (H↔H′ (x₁ , x₂)) (F↔F′ x₁ ×-↔ G↔G′ x₂)) (SK-sym ⊗-∈↔) where open Related.EquationalReasoning
{ "alphanum_fraction": 0.6083220262, "avg_line_length": 31.5857142857, "ext": "agda", "hexsha": "f01dd871f08a0cff860df718d7e44bc74679b39c", "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/And.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/And.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/And.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": 774, "size": 2211 }
test : Set test = {! M !}
{ "alphanum_fraction": 0.4615384615, "avg_line_length": 8.6666666667, "ext": "agda", "hexsha": "7e3c2caa7c8b22bdebae0e580c1139dc008e7c2b", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue1925.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue1925.agda", "max_line_length": 14, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue1925.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": 10, "size": 26 }
module Eq.Theory where open import Prelude open import T open import DynTheory open import SubstTheory open import Contexts open import Eq.Defs open import Eq.KleeneTheory open import Eq.ObsTheory open import Eq.LogicalTheory -- Theory about the interactions between the relationships between the equivs -- Now that we have shown that logical equivalence is a consistent congruence, -- it follows that it is contained in observational equivalence. obs-contains-logical : ∀{Γ} {A} → OLogicalEq Γ A ⊆ ObservEq Γ A obs-contains-logical = obs-is-coarsest OLogicalEq log-is-con-congruence obs-contains-clogical : ∀{A} → (LogicalEq A) ⊆ (ObservEq [] A) obs-contains-clogical leq = obs-contains-logical (closed-logical-imp-open leq) -- Show that observational equivalence implies logical for closed terms. obs-implies-closed-logical : ∀{A} {e e' : TCExp A} → [] ⊢ e ≅ e' :: A → e ~ e' :: A obs-implies-closed-logical {nat} oeq = ObservEq.observe oeq ∘ obs-implies-closed-logical {A ⇒ B} {e} {e'} oeq = body where body : (e₁ e₁' : TExp [] A) → LogicalEq A e₁ e₁' → LogicalEq B (e $ e₁) (e' $ e₁') body e₁ e₁' leq with obs-contains-clogical leq ... | oeq' with obs-trans (obs-congruence oeq' (e e$ ∘)) (obs-congruence oeq (∘ $e e₁')) ... | oeq'' = obs-implies-closed-logical oeq'' obs-contains-logical-subst : ∀{Γ} → SubstRel LogicalEq Γ ⊆ SubstRel (ObservEq []) Γ obs-contains-logical-subst η x = obs-contains-clogical (η x) -- Since observational implies logical for closed terms and -- respects substitution of observational equivalent terms, -- logical equivalence contains observational. logical-contains-obs : ∀{Γ} {A} → ObservEq Γ A ⊆ OLogicalEq Γ A logical-contains-obs {Γ} {A} {e} {e'} oeq {γ} {γ'} η with substs-respect-obs oeq (obs-contains-logical-subst η) ... | coeq = obs-implies-closed-logical coeq -- This is sort of silly. We need these lemmas to prove that logical -- equivalence contains definitional. nat-val-weakening : ∀{Γ} {n : TNat} → TVal n → Σ[ e :: TExp Γ nat ] (∀{γ : TSubst Γ []} → n ≡ ssubst γ e) nat-val-weakening val-zero = zero , (λ {γ} → Refl) nat-val-weakening {Γ} {suc n} (val-suc v) with nat-val-weakening {Γ} v ... | e , subst-thing = (suc e) , (λ {γ} → resp suc subst-thing) nat-logical-equiv-val : ∀{Γ} (γ : TSubst Γ []) (e : TExp Γ nat) → Σ[ n :: TExp Γ nat ] ((ssubst γ n ~ ssubst γ e :: nat) × TVal (ssubst γ n)) nat-logical-equiv-val {Γ} γ e with kleene-refl {ssubst γ e} ... | kleeneq n val E1 E2 with nat-val-weakening {Γ} val ... | n' , is-val = n' , ((kleeneq n val (ID.coe1 (λ x → x ~>* n) is-val eval-refl) E1) , ID.coe1 TVal is-val val) -- Logical equivalence contains definitional equivalence. logical-contains-def : ∀{Γ} {A} → DefEq Γ A ⊆ OLogicalEq Γ A logical-contains-def {y = e} def-refl η = ological-refl e η logical-contains-def {x = e} {y = e'} (def-sym defeq) η = ological-sym {_} {_} {e'} {e} (logical-contains-def defeq) η logical-contains-def {x = e} {y = e''} (def-trans {e' = e'} defeq1 defeq2) η with logical-contains-def defeq1 | logical-contains-def defeq2 ... | leq1 | leq2 = ological-trans {_} {_} {e} {e'} {e''} leq1 leq2 η logical-contains-def (def-cong defeq C) η = ological-is-congruence (logical-contains-def defeq) C η logical-contains-def {Γ} {A} (def-beta {e = e} {e' = e'}) {γ} {γ'} η with step-beta {e = (ssubst (liftγ γ) e)} {e' = ssubst γ e'} ... | step with ological-refl e (extendLogicalEQΓ η (ological-refl e' η)) ... | leq with subeq (compose-subst-noob γ' e') e ≡≡ subcomp γ' (singγ e') e ... | subeq-r with subcomp (singγ (ssubst γ e')) (liftγ γ) e ... | subeq-l with ID.coe2 (LogicalEq A) subeq-l subeq-r leq ... | leq' = logical-converse-evaluation-1 leq' (eval-step step) logical-contains-def {Γ} {A} (def-rec-z {e0 = e0} {es = es}) {γ} {γ'} η with ological-refl e0 η ... | leq = logical-converse-evaluation-1 leq (eval-step step-rec-z) -- This is super nasty. It has some code duplication when handling the congruence stuff. -- And it also needs to deal with a bunch of nasty substitution crap. -- The main source of nonstupid complication is that the step rule requires -- n to be a value, and definitional equivalence does not. logical-contains-def {Γ} {A} (def-rec-s {e = en} {e0 = e0} {es = es}) {γ} {γ'} η with nat-logical-equiv-val γ en ... | n , num-leq , is-val with ological-refl (rec en e0 es) η ... | full-leq with ological-is-congruence {e = ssubst γ n} {e' = ssubst γ en} (closed-logical-imp-open num-leq) (rec1 ∘ (ssubst γ e0) (ssubst (liftγ γ) es)) (emptyLogicalEqΓ {γ = emptyγ} {γ' = emptyγ}) ... | eq-with-γn-and-nasty-subst with ID.coe2 (LogicalEq A) (subid _) (subid _) eq-with-γn-and-nasty-subst ... | eq-with-γn with logical-trans eq-with-γn full-leq ... | leq-subrec with ological-refl (rec (suc en) e0 es) (logicalγ-refl {x = γ}) ... | full-leq-s with ological-is-congruence {e = ssubst γ n} {e' = ssubst γ en} (closed-logical-imp-open num-leq) (rec1 (suc ∘) (ssubst γ e0) (ssubst (liftγ γ) es)) (emptyLogicalEqΓ {γ = emptyγ} {γ' = emptyγ}) ... | eq-with-sγn-and-nasty-subst with ID.coe2 (LogicalEq A) (subid _) (subid _) eq-with-sγn-and-nasty-subst ... | eq-with-sγn with logical-trans eq-with-sγn full-leq-s ... | leq-subrec-2 with ological-refl es (extendLogicalEQΓ η leq-subrec) ... | leq-unrolled with subeq (compose-subst-noob γ' (rec en e0 es)) es ≡≡ subcomp γ' (singγ (rec en e0 es)) es ... | subeq-l with subcomp (singγ (ssubst γ (rec n e0 es))) (liftγ γ) es ... | subeq-r with ID.coe2 (LogicalEq A) subeq-r subeq-l leq-unrolled ... | leq with step-rec-s {e = ssubst γ n} {e₀ = ssubst γ e0} {es = ssubst (liftγ γ) es} is-val ... | step with logical-converse-evaluation-1 leq (eval-step step) ... | leq-stepped = logical-trans (logical-sym leq-subrec-2) leq-stepped -- Obvious corollary that observational equivalence contains definitional. obs-contains-def : ∀{Γ} {A} → DefEq Γ A ⊆ ObservEq Γ A obs-contains-def = obs-contains-logical o logical-contains-def -- Proving this mostly out of spite, because one formulation -- of my theory needed this for observational equivalence, -- and there wasn't a good way to prove it other than appealing -- to observational equivalence coinciding with logical, which -- was what we were trying to prove. weakened-equiv-log : ∀{Γ} {A} {e e' : TCExp A} → e ~ e' :: A → Γ ⊢ weaken-closed e ~ weaken-closed e' :: A weakened-equiv-log {Γ} {A} {e} {e'} leq {γ} {γ'} η with subren γ closed-wkγ e | subren γ' closed-wkγ e' ... | eq1 | eq2 with closed-subst (γ o closed-wkγ) e | closed-subst (γ' o closed-wkγ) e' ... | eq1' | eq2' = ID.coe2 (LogicalEq A) (symm eq1' ≡≡ symm eq1) (symm eq2' ≡≡ symm eq2) leq weakened-equiv-obs : ∀{Γ} {A} {e e' : TCExp A} → [] ⊢ e ≅ e' :: A → Γ ⊢ weaken-closed e ≅ weaken-closed e' :: A weakened-equiv-obs {Γ} {A} {e} {e'} oeq = obs-contains-logical (weakened-equiv-log {Γ} {A} {e} {e'} (obs-implies-closed-logical oeq)) -- Some more stuff about renaming. wkren1 : ∀{Γ A} → TRen Γ (A :: Γ) wkren1 = (λ x → S x) weaken1 : ∀{Γ A B} → TExp Γ B → TExp (A :: Γ) B weaken1 e = ren wkren1 e weakening-ignores : ∀{Γ A} (e₁ : TCExp A) (γ : TSubst Γ []) → Sub≡ (λ x₁ → ssubst (singγ e₁) (ren wkren1 (γ x₁))) γ weakening-ignores e₁ γ x = subren (singγ e₁) wkren1 (γ x) ≡≡ subid (γ x) -- Functional extensionality function-ext-log : ∀{Γ A B} {e e' : TExp Γ (A ⇒ B)} → (A :: Γ) ⊢ weaken1 e $ var Z ~ weaken1 e' $ var Z :: B → Γ ⊢ e ~ e' :: A ⇒ B function-ext-log {Γ} {A} {B} {e} {e'} leq {γ} {γ'} η e₁ e₁' leq' with leq (extendLogicalEQΓ η leq') ... | leq'' with subren (subComp (singγ e₁) (liftγ γ)) wkren1 e | subren (subComp (singγ e₁') (liftγ γ')) wkren1 e' ... | eq1' | eq2' with eq1' ≡≡ subeq (weakening-ignores e₁ γ) e | eq2' ≡≡ subeq (weakening-ignores e₁' γ') e' ... | eq1 | eq2 = ID.coe2 (LogicalEq B) (resp (λ x → x $ e₁) eq1) (resp (λ x → x $ e₁') eq2) leq'' function-ext-obs : ∀{Γ A B} {e e' : TExp Γ (A ⇒ B)} → (A :: Γ) ⊢ weaken1 e $ var Z ≅ weaken1 e' $ var Z :: B → Γ ⊢ e ≅ e' :: A ⇒ B function-ext-obs {e = e} {e' = e'} oeq = obs-contains-logical (function-ext-log {e = e} {e' = e'} (logical-contains-obs oeq)) -- Eta, essentially -- The important part of the proof is the def-beta and the function-ext-obs, -- but most of the actual work is fucking around with substitutions. function-eta-obs : ∀{Γ A B} (e : TExp Γ (A ⇒ B)) → Γ ⊢ e ≅ (Λ (weaken1 e $ var Z)) :: A ⇒ B function-eta-obs {Γ} {A} {B} e with obs-sym (obs-contains-def (def-beta {e = ren (wk wkren1) (ren wkren1 e) $ var Z} {e' = var Z})) ... | beta-eq with (subren (singγ (var Z)) (wk wkren1) (weaken1 e)) ≡≡ (subren (λ x → singγ (var Z) (wk wkren1 x)) wkren1 e) ≡≡ symm (subren emptyγ wkren1 e) ≡≡ subid (weaken1 e) ... | eq2 with resp (λ x → x $ var Z) eq2 ... | eq with ID.coe2 (ObservEq (A :: Γ) B) eq refl beta-eq ... | oeq = function-ext-obs oeq obs-equiv-nat-val : (e : TNat) → Σ[ n :: TNat ] (TVal n × ([] ⊢ e ≅ n :: nat)) obs-equiv-nat-val e with ological-equiv-nat-val e obs-equiv-nat-val e | n , val , eq = n , val , obs-contains-logical eq -- OK, maybe we are trying this with numerals again. Argh. t-numeral : ∀{Γ} → Nat → TExp Γ nat t-numeral Z = zero t-numeral (S n) = suc (t-numeral n) numeral-val : ∀{Γ} → (n : Nat) → TVal {Γ} (t-numeral n) numeral-val Z = val-zero numeral-val (S n) = val-suc (numeral-val n) val-numeral : ∀{Γ} {e : TExp Γ nat} → TVal e → Σ[ n :: Nat ] (e ≡ t-numeral n) val-numeral val-zero = Z , Refl val-numeral (val-suc v) with val-numeral v ... | n , eq = (S n) , (resp suc eq) numeral-subst-dontcare : ∀{Γ Γ'} (n : Nat) (γ : TSubst Γ Γ') → ssubst γ (t-numeral n) ≡ t-numeral n numeral-subst-dontcare Z γ = Refl numeral-subst-dontcare (S n) γ = resp suc (numeral-subst-dontcare n γ) -- obs-equiv-numeral : (e : TNat) → Σ[ n :: Nat ] ([] ⊢ e ≅ t-numeral n :: nat) obs-equiv-numeral e with obs-equiv-nat-val e obs-equiv-numeral e | en , val , oeq with val-numeral val ... | n , eq = n , (ID.coe1 (ObservEq [] nat e) eq oeq) dropSubstRel : ∀(R : CRel) {Γ A} {γ γ' : TSubst (A :: Γ) []} → SubstRel R (A :: Γ) γ γ' → SubstRel R Γ (dropγ γ) (dropγ γ') dropSubstRel R η n = η (S n) dropLogicalEqΓ = dropSubstRel LogicalEq -- Allow induction over nats, essentially function-induction-log : ∀{Γ A} {e e' : TExp (nat :: Γ) A} → ((n : Nat) → Γ ⊢ ssubst (singγ (t-numeral n)) e ~ ssubst (singγ (t-numeral n)) e' :: A) → (nat :: Γ) ⊢ e ~ e' :: A function-induction-log {Γ} {A} {e} {e'} f {γ} {γ'} η with η Z | obs-equiv-numeral (γ Z) ... | n-eq | n , oeq-n with f n (dropLogicalEqΓ η) ... | butt with subcomp (dropγ γ) (singγ (t-numeral n)) e | subcomp (dropγ γ') (singγ (t-numeral n)) e' ... | lol1 | lol2 with subeq (compose-subst-noob (dropγ γ) (t-numeral n)) e | subeq (compose-subst-noob (dropγ γ') (t-numeral n)) e' ... | lol1' | lol2' with ID.coe2 (LogicalEq A) (symm lol1 ≡≡ symm lol1') (symm lol2 ≡≡ symm lol2') butt ... | wtf with ID.coe2 (λ x y → LogicalEq A (ssubst (extendγ (dropγ γ) x) e) (ssubst (extendγ (dropγ γ') y) e')) (numeral-subst-dontcare n (dropγ γ)) (numeral-subst-dontcare n (dropγ γ')) wtf ... | wtf' with ological-refl e (extendLogicalEQΓ (dropLogicalEqΓ (logicalγ-refl {x = γ})) (obs-consistent oeq-n)) ... | leq-e with ID.coe2 (LogicalEq A) (symm (subeq (drop-fix γ) e)) Refl leq-e ... | leq-e' with ological-refl e' (extendLogicalEQΓ (dropLogicalEqΓ (logicalγ-refl {x = γ'})) (kleene-trans (kleene-sym n-eq) (obs-consistent oeq-n))) ... | leq-e2 with ID.coe2 (LogicalEq A) (symm (subeq (drop-fix γ') e')) Refl leq-e2 ... | leq-e2' = logical-trans leq-e' (logical-trans wtf' (logical-sym leq-e2')) function-induction-obs : ∀{Γ A} {e e' : TExp (nat :: Γ) A} → ((n : Nat) → Γ ⊢ ssubst (singγ (t-numeral n)) e ≅ ssubst (singγ (t-numeral n)) e' :: A) → (nat :: Γ) ⊢ e ≅ e' :: A function-induction-obs {Γ} {A} {e} {e'} f = obs-contains-logical (function-induction-log {Γ} {A} {e} {e'} (λ n → logical-contains-obs (f n)))
{ "alphanum_fraction": 0.5889929742, "avg_line_length": 50.8333333333, "ext": "agda", "hexsha": "4d4aa5269fdd5fc763cfae1573f41a8f6d33ad35", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-05-04T22:37:18.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-26T11:39:14.000Z", "max_forks_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "msullivan/godels-t", "max_forks_repo_path": "Eq/Theory.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "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": "msullivan/godels-t", "max_issues_repo_path": "Eq/Theory.agda", "max_line_length": 133, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "msullivan/godels-t", "max_stars_repo_path": "Eq/Theory.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-22T00:28:03.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-25T01:52:57.000Z", "num_tokens": 4586, "size": 12810 }
{-# OPTIONS --prop #-} open import Agda.Primitive open import Agda.Builtin.Equality open import Agda.Builtin.List open import Agda.Builtin.Reflection macro doQuote : ∀ {ℓ} {A : Set ℓ} → A → Term → TC _ doQuote x hole = bindTC (quoteTC x) (λ qx → bindTC (quoteTC qx) (unify hole)) testQuote₁ : doQuote Prop ≡ agda-sort (propLit 0) testQuote₁ = refl testQuote₂ : ∀ {ℓ} → doQuote (Prop ℓ) ≡ agda-sort (prop (var 0 [])) testQuote₂ = refl macro doUnquote : Term → Term → TC _ doUnquote t hole = bindTC (unquoteTC t) (unify hole) testUnquote₁ : doUnquote (agda-sort (propLit 0)) ≡ Prop testUnquote₁ = refl testUnquote₂ : ∀ {ℓ} → doUnquote (agda-sort (prop (var 0 []))) ≡ Prop ℓ testUnquote₂ = refl
{ "alphanum_fraction": 0.6817538897, "avg_line_length": 26.1851851852, "ext": "agda", "hexsha": "515c4c74943e80091d99f3496acebe9448b04aec", "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/QuoteProp.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/QuoteProp.agda", "max_line_length": 79, "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/QuoteProp.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 252, "size": 707 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} open import Cubical.Core.Everything open import Cubical.Relation.Binary module Cubical.Relation.Binary.Construct.StrictToNonStrict {a ℓ} {A : Type a} (_<_ : Rel A ℓ) where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Logic hiding (_⇒_) renaming (inl to inlₚ; inr to inrₚ) open import Cubical.Data.Prod open import Cubical.Data.Sum.Base renaming (rec to ⊎-rec) open import Cubical.Data.Empty renaming (elim to ⊥-elim) using (isProp⊥) open import Cubical.Relation.Binary.Properties open import Cubical.Relation.Nullary open import Cubical.HITs.PropositionalTruncation as PT ------------------------------------------------------------------------ -- Conversion -- _<_ can be turned into _≤_ as follows: _≤_ : Rel A _ x ≤ y = (x < y) ⊔ (x ≡ₚ y) ------------------------------------------------------------------------ -- The converted relations have certain properties -- (if the original relations have certain other properties) <⇒≤ : _<_ ⇒ _≤_ <⇒≤ = inlₚ ≤-fromEq : FromEq _≤_ ≤-fromEq = inrₚ ≤-reflexive : Reflexive _≤_ ≤-reflexive = fromeq→reflx _≤_ ≤-fromEq ≤-antisym : Transitive _<_ → Irreflexive _<_ → Antisymmetric _≤_ ≤-antisym transitive irrefl = rec2 squash λ { (inl x) (inl y) → ⊥-elim (irrefl (transitive x y)) ; (inl x) (inr y) → PT.map sym y ; (inr x) _ → x } ≤-transitive : Transitive _<_ → Transitive _≤_ ≤-transitive <-trans = rec2 squash λ { (inl x) (inl y) → inlₚ (<-trans x y) ; (inl x) (inr y) → inlₚ (substₚ (λ k → _ < k) y x) ; (inr x) (inl y) → inlₚ (substₚ (λ i → i < _) (PT.map sym x) y) ; (inr x) (inr y) → inrₚ (PT.map2 _∙_ x y) } <-≤-trans : Transitive _<_ → Trans _<_ _≤_ _<_ <-≤-trans transitive x<y = rec (isProp[ _<_ ] _ _) λ { (inl x) → transitive x<y x ; (inr x) → substₚ (λ k → _ < k) x x<y } ≤-<-trans : Transitive _<_ → Trans _≤_ _<_ _<_ ≤-<-trans transitive = rec (isPropΠ λ _ → isProp[ _<_ ] _ _) λ { (inl x) y → transitive x y ; (inr x) y → substₚ (λ i → i < _) (PT.map sym x) y } ≤-total : Trichotomous _<_ → Total _≤_ ≤-total <-tri x y with <-tri x y ... | tri< x<y x≢y x≯y = inlₚ (inlₚ x<y) ... | tri≡ x≮y x≡y x≯y = inlₚ (inrₚ ∣ x≡y ∣) ... | tri> x≮y x≢y x>y = inrₚ (inlₚ x>y) ≤-decidable : Discrete A → Decidable _<_ → Decidable _≤_ ≤-decidable _≟_ _<?_ x y with x <? y ... | yes x<y = yes (inlₚ x<y) ... | no x≮y with x ≟ y ... | yes x≡y = yes (inrₚ ∣ x≡y ∣) ... | no x≢y = no (rec isProp⊥ λ { (inl x<y) → x≮y x<y ; (inr x≡y) → x≢y (rec (Discrete→isSet _≟_ _ _) id x≡y) }) ≤-decidable′ : Trichotomous _<_ → Decidable _≤_ ≤-decidable′ compare x y with compare x y ... | tri< x<y x≢y x≯y = yes (inlₚ x<y) ... | tri≡ x≮y x≡y x≯y = yes (inrₚ ∣ x≡y ∣) ... | tri> x≮y x≢y x>y = no (rec isProp⊥ λ { (inl x<y) → x≮y x<y ; (inr x≡y) → x≢y (rec (Discrete→isSet (tri→dec≡ _<_ compare) _ _) id x≡y) }) ------------------------------------------------------------------------ -- Converting structures isPreorder : Transitive _<_ → IsPreorder _≤_ isPreorder transitive = record { reflexive = ≤-reflexive ; transitive = ≤-transitive transitive } isPartialOrder : IsStrictPartialOrder _<_ → IsPartialOrder _≤_ isPartialOrder spo = record { isPreorder = isPreorder S.transitive ; antisym = ≤-antisym S.transitive S.irrefl } where module S = IsStrictPartialOrder spo isTotalOrder : IsStrictTotalOrder _<_ → IsTotalOrder _≤_ isTotalOrder sto = record { isPartialOrder = isPartialOrder S.isStrictPartialOrder ; total = ≤-total S.compare } where module S = IsStrictTotalOrder sto isDecTotalOrder : IsStrictTotalOrder _<_ → IsDecTotalOrder _≤_ isDecTotalOrder sto = record { isTotalOrder = isTotalOrder sto ; _≤?_ = ≤-decidable′ S.compare } where module S = IsStrictTotalOrder sto
{ "alphanum_fraction": 0.5828513955, "avg_line_length": 32.0725806452, "ext": "agda", "hexsha": "e4da26a988f80ca7f70093217a7db21f4d2c2302", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Relation/Binary/Construct/StrictToNonStrict.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Relation/Binary/Construct/StrictToNonStrict.agda", "max_line_length": 100, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Relation/Binary/Construct/StrictToNonStrict.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1495, "size": 3977 }
-- Andreas, 2010-09-24 deactivated this annoying test case in Makefile module Impossible where -- The only way to trigger an __IMPOSSIBLE__ that isn't a bug. {-# IMPOSSIBLE #-}
{ "alphanum_fraction": 0.7528089888, "avg_line_length": 29.6666666667, "ext": "agda", "hexsha": "c016aa511dd2ce14e2913e59ec87fec99ba1269c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/Impossible.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/Impossible.agda", "max_line_length": 70, "max_stars_count": 3, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Impossible.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": 48, "size": 178 }
-- Andreas, 2019-08-17, issue #1346 -- Allow changing fixity in renaming statement module Issue1346 where data Bool : Set where true false : Bool module Product where infixr 4 _,_ record _×_ (A B : Set) : Set where constructor _,_ field fst : A snd : B module List where infixr 5 _∷_ data List (A : Set) : Set where [] : List A _∷_ : A → List A → List A open List public hiding (module List) open Product public using () renaming ( _,_ to infixr 5 _∷_ -- change binding strength of _,_ when imported as _∷_ ; _×_ to infixr 8 _×_ -- make _×_ right associatives ) -- Non-empty lists. List⁺ : Set → Set List⁺ A = A × List A head : ∀{A} → List⁺ A → A head (a ∷ as) = a private test₁ : List⁺ Bool test₁ = true ∷ false ∷ [] -- mixing _∷_ of _×_ and List open Product public using (_,_) -- _,_ is still available with original fixity private test₂ : ∀{A : Set} → A → List A × List⁺ A × List⁺ A test₂ a = [] , a ∷ [] , a ∷ a ∷ [] -- mixing _,_ and _∷_ of _×_
{ "alphanum_fraction": 0.6058536585, "avg_line_length": 20.5, "ext": "agda", "hexsha": "562c571c15b8dba3bbb9a4b79dff1fc8b7b54d4e", "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/Issue1346.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/Issue1346.agda", "max_line_length": 80, "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/Issue1346.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": 360, "size": 1025 }
{-# OPTIONS --without-K #-} module lib.groups.Groups where open import lib.groups.Homomorphisms public open import lib.groups.Lift public open import lib.groups.Unit public open import lib.groups.PropSubgroup public open import lib.groups.GroupProduct public open import lib.groups.PullbackGroup public open import lib.groups.TruncationGroup public open import lib.groups.HomotopyGroup public open import lib.groups.FormalSum public
{ "alphanum_fraction": 0.8260869565, "avg_line_length": 27.3125, "ext": "agda", "hexsha": "d4dd30e547c7367b04e108facde35a10259fcd62", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_path": "core/lib/groups/Groups.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_path": "core/lib/groups/Groups.agda", "max_line_length": 45, "max_stars_count": null, "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_path": "core/lib/groups/Groups.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 95, "size": 437 }
-- Exponential and compatible strengths module SOAS.Abstract.ExpStrength {T : Set} where open import SOAS.Families.Core {T} open import SOAS.Context open import SOAS.Variable open import SOAS.ContextMaps.Combinators open import SOAS.ContextMaps.CategoryOfRenamings open import SOAS.Common open import SOAS.Coalgebraic.Strength import SOAS.Abstract.Coalgebra as →□ open →□.Sorted open →□.Unsorted using (⊤ᵇ) renaming (Coalg to UCoalg ; Coalg⇒ to UCoalg⇒ ; □ᵇ to □ᵘᵇ) import SOAS.Abstract.Box as □ ; open □.Sorted open import SOAS.Families.BCCC using (⊤ₘ) private variable X : Family 𝒴 𝒵 : Familyₛ Γ Δ Θ : Ctx α : T -- Mixed-sorted Cartesian and linear exponentials _⇨_ : Family → Familyₛ → Familyₛ (X ⇨ 𝒴) τ Γ = X Γ → 𝒴 τ Γ _➡_ : Family → Familyₛ → Familyₛ X ➡ 𝒴 = □ (X ⇨ 𝒴) _⊸_ : Family → Familyₛ → Familyₛ (X ⊸ 𝒴) α Γ = {Δ : Ctx} → X Δ → 𝒴 α (Γ ∔ Δ) [_⊸_] : Familyₛ → Familyₛ → Family [ 𝒳 ⊸ 𝒴 ] Γ = {τ : T}{Δ : Ctx} → 𝒳 τ Δ → 𝒴 τ (Δ ∔ Γ) -- Linear exponential [ 𝒳 ⊸ 𝒴 ] is an unsorted coalgebra if 𝒴 is sorted coalgebra [_⊸_]ᵇ : (𝒳 {𝒴} : Familyₛ) → Coalg 𝒴 → UCoalg ([ 𝒳 ⊸ 𝒴 ]) [ 𝒳 ⊸ 𝒴ᵇ ]ᵇ = record { r = λ l ρ {_}{Δ} x → r (l x) (Δ ∔∣ ρ) ; counit = λ{ {Γ = Γ}{t = l} → iext (dext λ {Δ} ρ → trans (r≈₂ (Concatʳ.identity Γ {Δ})) counit) } ; comult = λ{ {Γ = Γ}{Δ}{Θ}{ρ = ρ}{ϱ}{l} → iext (dext λ {Ξ} x → trans (r≈₂ (Functor.homomorphism (Ξ ∔F-))) comult) } } where open Coalg 𝒴ᵇ -- Shorthands ⟅_⇨_⟆ : Familyₛ → Familyₛ → Familyₛ ⟅ 𝒳 ⇨ 𝒴 ⟆ = [ 𝒳 ⊸ 𝒴 ] ⇨ 𝒴 ⟅_➡_⟆ : Familyₛ → Familyₛ → Familyₛ ⟅ 𝒳 ➡ 𝒴 ⟆ = [ 𝒳 ⊸ 𝒴 ] ➡ 𝒴 ⟅_⊸_⟆ : Familyₛ → Familyₛ → Familyₛ ⟅ 𝒳 ⊸ 𝒴 ⟆ = [ 𝒳 ⊸ 𝒴 ] ⊸ 𝒴 -- Exponential strength of an endofunctor record ExpStrength (Fᶠ : Functor 𝔽amiliesₛ 𝔽amiliesₛ) : Set₁ where open Functor Fᶠ field -- Strength transformation that lifts a 𝒫-substitution over an endofunctor F₀ estr : {X : Family}(Xᵇ : UCoalg X)(𝒴 : Familyₛ) → F₀ (X ⇨ 𝒴) ⇾̣ (X ⇨ F₀ 𝒴) -- Naturality conditions for the two components estr-nat₁ : {X X′ : Family}{Xᵇ : UCoalg X}{X′ᵇ : UCoalg X′}{𝒴 : Familyₛ} → {f : X′ ⇾ X}(fᵇ⇒ : UCoalg⇒ X′ᵇ Xᵇ f) → (e : F₀ (X ⇨ 𝒴) α Γ) (x : X′ Γ) → estr Xᵇ 𝒴 e (f x) ≡ estr X′ᵇ 𝒴 (F₁ (λ e x → e (f x)) e) x estr-nat₂ : {X : Family}{Xᵇ : UCoalg X}{𝒴 𝒴′ : Familyₛ} → (g : 𝒴 ⇾̣ 𝒴′)(e : F₀ (X ⇨ 𝒴) α Γ)(x : X Γ) → estr Xᵇ 𝒴′ (F₁ (λ e x → g (e x)) e) x ≡ F₁ g (estr Xᵇ 𝒴 e x) estr-unit : {𝒴 : Familyₛ}{e : F₀ (⊤ₘ ⇨ 𝒴) α Γ} → estr ⊤ᵇ 𝒴 e tt ≡ F₁ (λ e′ → e′ tt) e -- Derived unit law estr-unit′ : {X : Family}{Xᵇ : UCoalg X}{𝒴 : Familyₛ}{e : F₀ (X ⇨ 𝒴) α Γ} {x : {Γ : Ctx} → X Γ}(fᵇ⇒ : UCoalg⇒ ⊤ᵇ Xᵇ (λ _ → x)) → estr Xᵇ 𝒴 e x ≡ F₁ (λ e′ → e′ x) e estr-unit′ {X = X}{Xᵇ}{𝒴}{e}{x} fᵇ⇒ = begin estr Xᵇ 𝒴 e x ≡⟨⟩ estr Xᵇ 𝒴 e ((λ _ → x) tt) ≡⟨ estr-nat₁ fᵇ⇒ e tt ⟩ estr ⊤ᵇ 𝒴 (F₁ (λ e′ _ → e′ x) e) tt ≡⟨ estr-unit ⟩ F₁ (λ e′ → e′ tt) (F₁ (λ e′ _ → e′ x) e) ≡˘⟨ homomorphism ⟩ F₁ (λ e′ → e′ x) e ∎ where open ≡-Reasoning -- Combination of coalgebraic and exponential strength over X ➡ 𝒴 = □ (X ⇨ 𝒴) module ➡-Strength (F:Str : Strength Fᶠ) where open Strength F:Str open ≡-Reasoning □estr : (Xᵇ : UCoalg X)(𝒴 : Familyₛ) → F₀ (X ➡ 𝒴) ⇾̣ (X ➡ F₀ 𝒴) □estr {X} Xᵇ 𝒴 e ρ x = estr Xᵇ 𝒴 (str ℐᴮ (X ⇨ 𝒴) e ρ) x -- Compatible exponential and coalgebraic strengths -- (for now no extra condition) record CompatStrengths (Fᶠ : Functor 𝔽amiliesₛ 𝔽amiliesₛ) : Set₁ where open Functor Fᶠ field CoalgStr : Strength Fᶠ ExpStr : ExpStrength Fᶠ open Strength CoalgStr public open ExpStrength ExpStr public open ➡-Strength CoalgStr public
{ "alphanum_fraction": 0.550912457, "avg_line_length": 33.4601769912, "ext": "agda", "hexsha": "a262074cb15f7acd5d03e0911a485c92b3d382ba", "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": "b224d31e20cfd010b7c924ce940f3c2f417777e3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "k4rtik/agda-soas", "max_forks_repo_path": "SOAS/Abstract/ExpStrength.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b224d31e20cfd010b7c924ce940f3c2f417777e3", "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": "k4rtik/agda-soas", "max_issues_repo_path": "SOAS/Abstract/ExpStrength.agda", "max_line_length": 120, "max_stars_count": null, "max_stars_repo_head_hexsha": "b224d31e20cfd010b7c924ce940f3c2f417777e3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "k4rtik/agda-soas", "max_stars_repo_path": "SOAS/Abstract/ExpStrength.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1849, "size": 3781 }
module Structure.Operator.Monoid.Monoids.Function where open import Functional open import Function.Equals open import Function.Equals.Proofs import Lvl open import Logic open import Logic.Predicate open import Structure.Function open import Structure.Operator.Monoid open import Structure.Operator.Properties open import Structure.Operator open import Structure.Setoid open import Type private variable ℓ ℓₑ : Lvl.Level private variable T : Type{ℓ} function-monoid : ⦃ equiv : Equiv{ℓₑ}(T)⦄ ⦃ function : ∀{f : T → T} → Function(f) ⦄ → Monoid(_∘_ {X = T}{Y = T}{Z = T}) Monoid.binary-operator function-monoid = [⊜][∘]-binaryOperator Monoid.associativity function-monoid = intro(\{f g h} → [⊜]-associativity {x = f}{y = g}{z = h}) Monoid.identity-existence function-monoid = [∃]-intro id ⦃ [⊜]-identity ⦄
{ "alphanum_fraction": 0.7341463415, "avg_line_length": 35.652173913, "ext": "agda", "hexsha": "89867fdcfb64216d80820aaf89e8d860ca136a1f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Operator/Monoid/Monoids/Function.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Operator/Monoid/Monoids/Function.agda", "max_line_length": 119, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Operator/Monoid/Monoids/Function.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 243, "size": 820 }
{-# OPTIONS --rewriting #-} open import Agda.Builtin.Equality postulate A : Set x0 : A f : A → A → A {-# BUILTIN REWRITE _≡_ #-} postulate fxx : (x : A) → (f x x) ≡ x {-# REWRITE fxx #-} meta : A meta-reveal : meta ≡ x0 test : f x0 meta ≡ x0 meta = _ test = refl meta-reveal = refl
{ "alphanum_fraction": 0.5723905724, "avg_line_length": 12.375, "ext": "agda", "hexsha": "29124991e6cbd6c1f02c6e916c0b714521b46fee", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/Issue2302.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Succeed/Issue2302.agda", "max_line_length": 33, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/Issue2302.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": 114, "size": 297 }
-- Implementation of Gödel's System T as an example for -- Σ-terms (Σ = {Z, S}; α(Z) = 0; α(S) = 1) with primitive recursion module SystemT where open import Data.Vec hiding (_++_) open import Data.Nat open import Data.List open import Data.List.All -- Not in use yet: -- Σ is a vector of given length n of natural numbers denoting the arity of symbols data Σ {n : ℕ} : Set where intr : Vec ℕ n → Σ -- Successor has arity one, Zero has arity 0 Σ-Nat = intr (1 ∷ 0 ∷ []) -- Types data Type : Set where Nat : Type Fun : Type → Type → Type -- Type environment Env : Set Env = List Type -- Environment lookup data _∈`_ : Type → Env → Set where here : ∀ {φ A} → A ∈` (A ∷ φ) there : ∀ {φ A A'} → A ∈` φ → A ∈` (A' ∷ φ) -- Zero & Successor, Variables, prim. recursion on Σ-Nat, Abstraction, Application data Expr : Env → Type → Set where Z : ∀ {φ} → Expr φ Nat S : ∀ {φ} → Expr φ Nat → Expr φ Nat Var : ∀ {φ A} → A ∈` φ → Expr φ A NatRec : ∀ {φ A} → Expr φ A → Expr (A ∷ φ) A → Expr φ Nat → Expr φ A Abs : ∀ {φ A B} → Expr (A ∷ φ) B → Expr φ (Fun A B) App : ∀ {φ A B} → Expr φ (Fun A B) → Expr φ A → Expr φ B ----- Big step semantics using Agda semantics ----- Value : Type → Set Value Nat = ℕ Value (Fun A B) = Value A → Value B -- Lookup in environment of values access : ∀ {A φ} → A ∈` φ → All Value φ → Value A access here (px ∷ p) = px access (there x) (px ∷ p) = access x p -- Conversion of a natural number to an expression natconv : ∀ {φ} → ℕ → Expr φ Nat natconv zero = Z natconv (suc n) = S (natconv n) natrec : ∀ {A : Set} → A → (A → A) → ℕ → A natrec vz vs zero = vz natrec vz vs (suc n) = vs (natrec vz vs n) -- Evaluation eval : ∀ {φ A} → Expr φ A → All Value φ → Value A eval Z ϱ = zero eval (S x) ϱ = suc (eval x ϱ) eval (Var x) ϱ = access x ϱ eval (NatRec ez es enat) ϱ = natrec (eval ez ϱ) (λ v → eval es (v ∷ ϱ)) (eval enat ϱ) eval (Abs e) ϱ = λ x → eval e (x ∷ ϱ) eval (App e e₁) ϱ = (eval e ϱ) (eval e₁ ϱ) ----- Small step semantics ----- ----- Substitution: Two methods. -- a) Define simultaneous substitution with a map from variables to expression; see LDLC.agda and -- the book "Programming Language Foundations in Agda" -- b) Define singular substitution but "within" environments, i.e. for terms of the form (φ' ++ A ∷ φ) -- This makes the Var case a tiny bit more tricky. See also type substitution in LDLC.agda ----- Method b is chosen since it is a bit shorter and (subjectively) easier to understand -- Lemmas required for substitution, esp. Var case -- 0) Insertion: Insert a variable and adjust DeBruijn indices -- 0.1) De Bruijn adjustement insdebr : ∀ {φ φ'} {A B} → B ∈` (φ' ++ φ) → B ∈` (φ' ++ (A ∷ φ)) insdebr {φ' = []} here = there here insdebr {φ' = []} (there x) = there (there x) insdebr {φ' = y ∷ ys} here = here insdebr {φ' = y ∷ ys} (there x) = there (insdebr x) -- 0.2) Insertion ins : ∀ {φ φ'} {A B} → Expr (φ' ++ φ) B → Expr (φ' ++ A ∷ φ) B ins Z = Z ins (S x) = S (ins x) ins (Var x) = Var (insdebr x) ins {φ' = φ'} (NatRec{A = A'} ez es en) = NatRec (ins ez) (ins{φ' = A' ∷ φ'} es) (ins en) ins {φ' = φ'} (Abs{A = A'} x) = Abs (ins{φ' = A' ∷ φ'} x) ins (App x y) = App (ins x) (ins y) -- 1) Variable substitution varsub : ∀ {φ φ'} {A B} → A ∈` (φ' ++ B ∷ φ) → Expr φ B → Expr (φ' ++ φ) A varsub {φ' = []} here M = M varsub {φ' = []} (there x) M = Var x varsub {φ' = z ∷ zs} here M = Var here varsub {φ' = z ∷ zs} (there x) M = ins{φ' = []} (varsub x M) -- Substitution: Given an expression that binds topmost variable to B and has type A & -- an expression of type B => we get an expression of type A by binding the topmost -- variable to that expression _[[_]] : ∀ {φ φ'} {A B : Type} → Expr (φ' ++ B ∷ φ) A → Expr φ B → Expr (φ' ++ φ) A Z [[ M ]] = Z S N [[ M ]] = S (N [[ M ]]) Var x [[ M ]] = varsub x M NatRec N N' N'' [[ M ]] = NatRec (N [[ M ]]) (N' [[ M ]]) (N'' [[ M ]]) Abs N [[ M ]] = Abs (N [[ M ]]) App N N' [[ M ]] = App (N [[ M ]]) (N' [[ M ]]) -- Values data Value' {φ} : (t : Type) → Expr φ t → Set where VZero : Value' Nat Z VSuc : ∀ {x} → Value' Nat x → Value' Nat (S x) VFun : ∀ {A B exp} → Value' (Fun A B) (Abs exp) -- Semantics data _↠_ {φ} : {A : Type} → Expr φ A → Expr φ A → Set where -- Basic call-by-value λ-calc. stuff -- Application: Elimination & Reduction ξ-App1 : ∀ {A B} {L L' : Expr φ (Fun B A)} {M} → L ↠ L' → App L M ↠ App L' M ξ-App2 : ∀ {A B} {M M' : Expr φ A} {L : Expr φ (Fun A B)} → Value' (Fun A B) L → M ↠ M' → App L M ↠ App L M' β-App : ∀ {A B M exp} → Value' B M → App{B = A} (Abs exp) M ↠ (exp [[ M ]]) -- Elimination for successor ξ-Nat : ∀ {L L'} → L ↠ L' → S L ↠ S L' -- Interesting cases ξ-NatRec : ∀ {A} {Ez : Expr φ A} {Es En En'} → En ↠ En' → NatRec Ez Es En ↠ NatRec Ez Es En' β-NatRec-Z : ∀ {A} {Ez : Expr φ A} {Es} → NatRec Ez Es Z ↠ Ez β-NatRec-S : ∀ {A} {Ez : Expr φ A} {Es} {n} → Value' Nat n → NatRec Ez Es (S n) ↠ (Es [[ NatRec Ez Es n ]]) ----- Reflexive & Transitive closure of ↠; defined for chain reasoning infix 1 begin_ infix 2 _⇨_ infix 2 _⇨⟨_⟩_ infix 3 _∎ data _⇨_ : ∀ {φ} {A} → Expr φ A → Expr φ A → Set where -- Reflexivity / end of Reasoning _∎ : ∀ {φ} {A} (L : Expr φ A) → (L ⇨ L) -- Transitivity / chain Reasoning _⇨⟨_⟩_ : ∀ {φ A} {L' M : Expr φ A} → (L : Expr φ A) → L ↠ L' → L' ⇨ M → L ⇨ M -- Highlight the start of a chain of reasoning begin_ : ∀ {φ} {A} {M N : Expr φ A} → M ⇨ N → M ⇨ N begin x = x ----- Progress Theorem; also used to generate evaluation sequence (since it defines how to evaluate) -- Definition: ∀ M : (Value'(M) ∨ (∃ N : M ↠ N)) data Progress {A} (M : Expr [] A) : Set where step : ∀ {N : Expr [] A} → M ↠ N → Progress M done : Value' A M → Progress M -- Proof progress : ∀ {A} → (M : Expr [] A) → Progress M progress Z = done VZero progress (S L) with progress L ... | step L↠N = step (ξ-Nat L↠N) ... | done y = done (VSuc y) progress (NatRec ez es en) with progress en ... | step en↠en' = step (ξ-NatRec en↠en') ... | done (VZero) = step (β-NatRec-Z) ... | done (VSuc x) = step (β-NatRec-S x) progress (Abs L) = done VFun progress (App L N) with progress L ... | step L↠L' = step (ξ-App1 L↠L') ... | done VFun with progress N ... | step N↠N' = step (ξ-App2 VFun N↠N') ... | done val = step (β-App val) ----- Generation of evaluation sequence (idea & implementation from PLFA) -- Used to limit number of steps taken data Gas : Set where gas : ℕ → Gas -- Either enough steps taken or Value' reached data Finished {φ A} (N : Expr φ A) : Set where done : Value' A N → Finished N out-of-gas : Finished N -- Encapsulates the steps taken data Steps : ∀ {A} → Expr [] A → Set where steps : ∀ {A} {L N : Expr [] A} → L ⇨ N → Finished N → Steps L -- Generation of evaluation eval' : ∀ {A} → Gas → (L : Expr [] A) → Steps L eval' (gas zero) L = steps (L ∎) out-of-gas eval' (gas (suc m)) L with progress L ... | done VL = steps (L ∎) (done VL) ... | step {M} L↠M with eval' (gas m) M ... | steps M⇨N fin = steps (L ⇨⟨ L↠M ⟩ M⇨N) fin ----- Examples import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl) emptyenv : All Value [] emptyenv = [] -- Addition of two numbers defined as primitive recursion _plus_ : ℕ → ℕ → Expr [] Nat n plus m = NatRec (natconv n) (S (Var here)) (natconv m) -- _ : eval (3 plus 5) emptyenv ≡ 8 -- _ = refl _ : eval' (gas 5) (1 plus 2) ≡ steps (NatRec (S Z) (S (Var here)) (S (S Z)) ⇨⟨ β-NatRec-S (VSuc VZero) ⟩ (S (NatRec (S Z) (S (Var here)) (S Z)) ⇨⟨ ξ-Nat (β-NatRec-S VZero) ⟩ (S (S (NatRec (S Z) (S (Var here)) Z)) ⇨⟨ ξ-Nat (ξ-Nat β-NatRec-Z) ⟩ S (S (S Z)) ∎))) (done (VSuc (VSuc (VSuc VZero)))) -- 3 _ = {!!} -- Multiplication of two numbers defined as primitive recursion using addition _times_ : ℕ → ℕ → Expr [] Nat n times m = NatRec Z (NatRec (natconv n) (S (Var here)) (Var here)) (natconv m) -- _ : eval (50 times 5) emptyenv ≡ 250 -- _ = refl _ : eval' (gas 10) (2 times 2) ≡ steps (NatRec Z (NatRec (S (S Z)) (S (Var here)) (Var here)) (S (S Z)) ⇨⟨ β-NatRec-S (VSuc VZero) ⟩ (NatRec (S (S Z)) (S (Var here)) (NatRec Z (NatRec (S (S Z)) (S (Var here)) (Var here)) (S Z)) ⇨⟨ ξ-NatRec (β-NatRec-S VZero) ⟩ (NatRec (S (S Z)) (S (Var here)) (NatRec (S (S Z)) (S (Var here)) (NatRec Z (NatRec (S (S Z)) (S (Var here)) (Var here)) Z)) ⇨⟨ ξ-NatRec (ξ-NatRec β-NatRec-Z) ⟩ (NatRec (S (S Z)) (S (Var here)) (NatRec (S (S Z)) (S (Var here)) Z) ⇨⟨ ξ-NatRec β-NatRec-Z ⟩ (NatRec (S (S Z)) (S (Var here)) (S (S Z)) ⇨⟨ β-NatRec-S (VSuc VZero) ⟩ (S (NatRec (S (S Z)) (S (Var here)) (S Z)) ⇨⟨ ξ-Nat (β-NatRec-S VZero) ⟩ (S (S (NatRec (S (S Z)) (S (Var here)) Z)) ⇨⟨ ξ-Nat (ξ-Nat β-NatRec-Z) ⟩ S (S (S (S Z))) ∎))))))) (done (VSuc (VSuc (VSuc (VSuc VZero))))) -- 4 _ = {!!}
{ "alphanum_fraction": 0.5181837292, "avg_line_length": 35.9018867925, "ext": "agda", "hexsha": "f0d849a1870971bf2fea6df3592fe90c578166ea", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-14T17:52:29.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-14T17:52:29.000Z", "max_forks_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "kcaliban/ldlc", "max_forks_repo_path": "src/sigmatypes/SystemT.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "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": "kcaliban/ldlc", "max_issues_repo_path": "src/sigmatypes/SystemT.agda", "max_line_length": 103, "max_stars_count": null, "max_stars_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "kcaliban/ldlc", "max_stars_repo_path": "src/sigmatypes/SystemT.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3546, "size": 9514 }
{- Box operator. -} module TemporalOps.Box where open import CategoryTheory.Categories open import CategoryTheory.Instances.Sets open import CategoryTheory.Instances.Reactive open import CategoryTheory.BCCCs open import CategoryTheory.Functor open import CategoryTheory.CartesianStrength open import CategoryTheory.NatTrans open import CategoryTheory.Adjunction open import CategoryTheory.Comonad open import TemporalOps.Common -- The box operator can be derived as a comonad from an adjunction K ⊣ G K : Functor 𝕊et ℝeactive K = record { omap = λ A -> (λ n -> A) ; fmap = λ f -> (λ n -> λ x -> f x) ; fmap-id = refl ; fmap-∘ = refl ; fmap-cong = λ z → z } G : Functor ℝeactive 𝕊et G = record { omap = λ A -> (∀(n : ℕ) -> A n) ; fmap = λ f -> λ a -> (λ n -> f n (a n)) ; fmap-id = refl ; fmap-∘ = refl ; fmap-cong = λ pf → ext (λ n → pf) } K⊣G : K ⊣ G K⊣G = record { η = record { at = λ A x n → x ; nat-cond = refl } ; ε = record { at = λ A n a → a n ; nat-cond = refl } ; tri1 = refl ; tri2 = refl } -- | Box operator -- Comonad instance from adjunction W-□ : Comonad ℝeactive W-□ = AdjComonad K⊣G -- Endofunctor from comonad F-□ : Endofunctor ℝeactive F-□ = Comonad.W W-□ -- Operator from functor □_ : τ -> τ □_ = Functor.omap (Comonad.W W-□) infixr 65 □_ -- Extensional equality for boxed values □-≡ : ∀{A} n l {v : (□ A) n}{w : (□ A) l} -> v ≡ w -> ∀ m -> v m ≡ w m □-≡ n l refl m = refl -- □ is a Cartesian functor F-cart-□ : CartesianFunctor F-□ ℝeactive-cart ℝeactive-cart F-cart-□ = record { u = λ n a _ → a ; m = m-□ ; m-nat₁ = λ f → refl ; m-nat₂ = λ f → refl ; associative = refl ; unital-right = refl ; unital-left = refl } where m-□ : ∀(A B : τ) -> □ A ⊗ □ B ⇴ □ (A ⊗ B) m-□ A B n (a , b) = λ k → a k , b k open CartesianFunctor F-cart-□ public -- □ is a Cartesian comonad W-cart-□ : CartesianComonad W-□ ℝeactive-cart W-cart-□ = record { cart-fun = F-cart-□ ; u-ε = refl ; u-δ = refl ; m-ε = refl ; m-δ = refl } open CartesianComonad W-cart-□ public
{ "alphanum_fraction": 0.5771561772, "avg_line_length": 23.3152173913, "ext": "agda", "hexsha": "33ed65c6b4ab53eeb4c4df13ccc389146dc604ea", "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": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DimaSamoz/temporal-type-systems", "max_forks_repo_path": "src/TemporalOps/Box.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "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": "DimaSamoz/temporal-type-systems", "max_issues_repo_path": "src/TemporalOps/Box.agda", "max_line_length": 72, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DimaSamoz/temporal-type-systems", "max_stars_repo_path": "src/TemporalOps/Box.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z", "max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z", "num_tokens": 805, "size": 2145 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Lists.Lists open import Setoids.Setoids open import Functions.Definition open import Sets.EquivalenceRelations module Setoids.Lists where listEquality : {a b : _} {A : Set a} (S : Setoid {a} {b} A) → Rel {a} {b} (List A) listEquality S [] [] = True' listEquality S [] (x :: w2) = False' listEquality S (x :: w1) [] = False' listEquality S (x :: w1) (y :: w2) = (Setoid._∼_ S x y) && listEquality S w1 w2 listEqualityReflexive : {a b : _} {A : Set a} (S : Setoid {a} {b} A) (w : List A) → listEquality S w w listEqualityReflexive S [] = record {} listEqualityReflexive S (x :: w) = Equivalence.reflexive (Setoid.eq S) ,, listEqualityReflexive S w listEqualitySymmetric : {a b : _} {A : Set a} (S : Setoid {a} {b} A) {w1 w2 : List A} → listEquality S w1 w2 → listEquality S w2 w1 listEqualitySymmetric S {w1 = []} {[]} pr = record {} listEqualitySymmetric S {[]} {x :: xs} () listEqualitySymmetric S {x :: xs} {[]} () listEqualitySymmetric S {w1 = x :: w1} {y :: w2} (pr1 ,, pr2) = Equivalence.symmetric (Setoid.eq S) pr1 ,, listEqualitySymmetric S pr2 listEqualityTransitive : {a b : _} {A : Set a} (S : Setoid {a} {b} A) {w1 w2 w3 : List A} → listEquality S w1 w2 → listEquality S w2 w3 → listEquality S w1 w3 listEqualityTransitive S {w1 = []} {[]} {[]} w1=w2 w2=w3 = record {} listEqualityTransitive S {w1 = []} {[]} {x :: xs} w1=w2 () listEqualityTransitive S {w1 = []} {x :: xs} {w3} () w2=w3 listEqualityTransitive S {w1 = x :: w1} {[]} {w3} () w2=w3 listEqualityTransitive S {w1 = x :: w1} {y :: ys} {[]} w1=w2 () listEqualityTransitive S {w1 = x :: w1} {y :: w2} {z :: w3} (pr1 ,, pr2) (pr3 ,, pr4) = Equivalence.transitive (Setoid.eq S) pr1 pr3 ,, listEqualityTransitive S pr2 pr4 listEqualityRespectsMap : {a b c d : _} {A : Set a} {B : Set b} (S : Setoid {a} {c} A) (T : Setoid {b} {d} B) (f : A → B) (fWD : {x y : A} → Setoid._∼_ S x y → Setoid._∼_ T (f x) (f y)) → {w1 w2 : List A} (w1=w2 : listEquality S w1 w2) → listEquality T (map f w1) (map f w2) listEqualityRespectsMap S T f fWD {[]} {[]} w1=w2 = record {} listEqualityRespectsMap S T f fWD {[]} {x :: w2} () listEqualityRespectsMap S T f fWD {x :: w1} {[]} () listEqualityRespectsMap S T f fWD {x :: w1} {y :: w2} (x=y ,, w1=w2) = fWD x=y ,, listEqualityRespectsMap S T f fWD {w1} {w2} w1=w2 listSetoid : {a b : _} {A : Set a} (S : Setoid {a} {b} A) → Setoid (List A) Setoid._∼_ (listSetoid S) word1 word2 = listEquality S word1 word2 Equivalence.reflexive (Setoid.eq (listSetoid S)) {word} = listEqualityReflexive S word Equivalence.symmetric (Setoid.eq (listSetoid S)) pr = listEqualitySymmetric S pr Equivalence.transitive (Setoid.eq (listSetoid S)) pr1 pr2 = listEqualityTransitive S pr1 pr2 consWellDefined : {a b : _} {A : Set a} {S : Setoid {a} {b} A} (xs : List A) {x y : A} (x=y : Setoid._∼_ S x y) → Setoid._∼_ (listSetoid S) (x :: xs) (y :: xs) consWellDefined {S = S} xs x=y = x=y ,, Equivalence.reflexive (Setoid.eq (listSetoid S)) appendWellDefined : {a b : _} {A : Set a} {S : Setoid {a} {b} A} {xs ys as bs : List A} (xs=as : Setoid._∼_ (listSetoid S) xs as) → (ys=bs : Setoid._∼_ (listSetoid S) ys bs) → Setoid._∼_ (listSetoid S) (xs ++ ys) (as ++ bs) appendWellDefined {S = S} {[]} {[]} {[]} {[]} record {} record {} = record {} appendWellDefined {S = S} {[]} {[]} {[]} {x :: bs} record {} () appendWellDefined {S = S} {[]} {x :: ys} {[]} {[]} record {} ys=bs = ys=bs appendWellDefined {S = S} {[]} {x :: ys} {[]} {x₁ :: bs} record {} ys=bs = ys=bs appendWellDefined {S = S} {[]} {ys} {x :: as} {bs} () ys=bs appendWellDefined {S = S} {x :: xs} {ys} {[]} {bs} () ys=bs appendWellDefined {S = S} {x :: xs} {[]} {x₁ :: as} {[]} xs=as record {} = _&&_.fst xs=as ,, identityOfIndiscernablesRight (listEquality S) (identityOfIndiscernablesLeft (listEquality S) (_&&_.snd xs=as) (equalityCommutative (appendEmptyList xs))) (equalityCommutative (appendEmptyList as)) appendWellDefined {S = S} {x :: xs} {[]} {x₁ :: as} {x₂ :: bs} xs=as () appendWellDefined {S = S} {x :: xs} {x₂ :: ys} {x₁ :: as} {[]} xs=as () appendWellDefined {S = S} {x :: xs} {x₂ :: ys} {x₁ :: as} {x₃ :: bs} (fst ,, snd) ys=bs = fst ,, appendWellDefined snd ys=bs
{ "alphanum_fraction": 0.6147463253, "avg_line_length": 69.1475409836, "ext": "agda", "hexsha": "de9011267a0a30f6651892fbd482d07bc3a73c75", "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": "Setoids/Lists.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": "Setoids/Lists.agda", "max_line_length": 290, "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": "Setoids/Lists.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": 1621, "size": 4218 }
open import Common.Reflection open import Common.Prelude hiding (_<$>_) open import Common.Equality _<$>_ : ∀ {A B : Set} → (A → B) → Maybe A → Maybe B f <$> just x = just (f x) f <$> nothing = nothing _==_ = primQNameEquality -- This is awkward! awkwardUnquoteBool : Term → Maybe Bool awkwardUnquoteBool (con c []) = if c == quote true then just true else if c == quote false then just false else nothing awkwardUnquoteBool v = nothing testAwkward : just false ≡ awkwardUnquoteBool (quoteTerm false) testAwkward = refl -- This is nicer! pattern `false = con (quote false) [] pattern `true = con (quote true) [] unquoteBool : Term → Maybe Bool unquoteBool `false = just false unquoteBool `true = just true unquoteBool _ = nothing test : just true ≡ unquoteBool (quoteTerm true) test = refl
{ "alphanum_fraction": 0.697044335, "avg_line_length": 23.8823529412, "ext": "agda", "hexsha": "3b54388a1213dae27523a1d192e98180cd0533b5", "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/Issue619.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/Issue619.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/Succeed/Issue619.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": 237, "size": 812 }
{-# OPTIONS --cubical --no-import-sorts #-} module Number.Instances.QuoIntFromIntSIP where open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero) open import Cubical.Foundations.Everything hiding (⋆) renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Foundations.Logic renaming (inl to inlᵖ; inr to inrᵖ) -- open import Cubical.Relation.Nullary.Base renaming (¬_ to ¬ᵗ_) -- open import Cubical.Relation.Binary.Base -- open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_) open import Cubical.Data.Sigma.Base renaming (_×_ to infixr 4 _×_) -- open import Cubical.Data.Sigma -- open import Cubical.Data.Bool as Bool using (Bool; not; true; false) -- open import Cubical.Data.Empty renaming (elim to ⊥-elim; ⊥ to ⊥⊥) -- `⊥` and `elim` -- open import Cubical.Foundations.Logic renaming (¬_ to ¬ᵖ_; inl to inlᵖ; inr to inrᵖ) -- open import Function.Base using (it; _∋_; _$_) open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.HITs.PropositionalTruncation --.Properties open import Cubical.Foundations.SIP -- open import Utils using (!_; !!_) -- open import MoreLogic.Reasoning open import MoreLogic.Definitions -- open import MoreLogic.Properties -- open import MorePropAlgebra.Definitions hiding (_≤''_) -- open import MorePropAlgebra.Structures -- open import MorePropAlgebra.Bundles -- open import MorePropAlgebra.Consequences open import Number.Structures2 open import Number.Bundles2 -- import Agda.Builtin.Int as Builtin -- import Data.Integer.Base as BuiltinBase -- import Data.Integer.Properties as BuiltinProps -- open import Cubical.Data.Nat.Literals -- open import Number.Prelude.Nat -- open import Number.Prelude.Int -- import Cubical.Data.Int as Int -- import Number.Instances.Int -- LinearlyOrderedCommRing ≡ LOCR record LOCRStructure {ℓ ℓ'} (Carrier : Type ℓ) : Type (ℓ-max ℓ (ℓ-suc ℓ')) where constructor locrstructure field 0f 1f : Carrier _+_ : Carrier → Carrier → Carrier -_ : Carrier → Carrier _·_ : Carrier → Carrier → Carrier min max : Carrier → Carrier → Carrier _<_ : hPropRel Carrier Carrier ℓ' is-LOCR : [ isLinearlyOrderedCommRing 0f 1f _+_ _·_ -_ _<_ min max ] LOCRΣ : ∀{ℓ ℓ'} → Type (ℓ-suc (ℓ-max ℓ ℓ')) LOCRΣ {ℓ} {ℓ'} = TypeWithStr {ℓ' = ℓ-max ℓ (ℓ-suc ℓ')} ℓ (LOCRStructure {ℓ} {ℓ'}) record LOCRΣEquiv {ℓ} {ℓ'} (Σ₁ Σ₂ : LOCRΣ {ℓ} {ℓ'}) (Carrier₁≃₂ : fst Σ₁ ≃ fst Σ₂) : Type (ℓ-max ℓ (ℓ-suc ℓ')) where constructor locrΣequiv Carrier₁ = fst Σ₁ Carrier₂ = fst Σ₂ Structure₁ = snd Σ₁ Structure₂ = snd Σ₂ private module ₁ = LOCRStructure Structure₁ module ₂ = LOCRStructure Structure₂ 〚_〛 = equivFun Carrier₁≃₂ field pres0 : 〚 ₁.0f 〛 ≡ ₂.0f pres1 : 〚 ₁.1f 〛 ≡ ₂.1f isHom-- : ∀ y → 〚 ₁.- y 〛 ≡ ₂.- 〚 y 〛 isHom-+ : ∀ x y → 〚 x ₁.+ y 〛 ≡ 〚 x 〛 ₂.+ 〚 y 〛 isHom-· : ∀ x y → 〚 x ₁.· y 〛 ≡ 〚 x 〛 ₂.· 〚 y 〛 isHom-min : ∀ x y → 〚 ₁.min x y 〛 ≡ ₂.min 〚 x 〛 〚 y 〛 isHom-max : ∀ x y → 〚 ₁.max x y 〛 ≡ ₂.max 〚 x 〛 〚 y 〛 isHom-< : ∀ x y → x ₁.< y ≡ 〚 x 〛 ₂.< 〚 y 〛 LOCREquivStr : ∀{ℓ ℓ'} → StrEquiv (LOCRStructure {ℓ} {ℓ'}) (ℓ-max ℓ (ℓ-suc ℓ')) LOCREquivStr Σ₁@(Carrier₁ , Structure₁) Σ₂@(Carrier₂ , Structure₂) Carrier₁≃₂ = LOCRΣEquiv Σ₁ Σ₂ Carrier₁≃₂ LOCRUnivalentStructure : ∀{ℓ ℓ'} → UnivalentStr (LOCRStructure {ℓ} {ℓ'}) LOCREquivStr LOCRUnivalentStructure {A = Σ₁@(Carrier₁ , Structure₁)} {B = Σ₂@(Carrier₂ , Structure₂)} Carrier₁≃₂ = f , φ where Carrier₁≡Carrier₂ : Carrier₁ ≡ Carrier₂ Carrier₁≡Carrier₂ = ua Carrier₁≃₂ module ₁ = LOCRStructure Structure₁ module ₂ = LOCRStructure Structure₂ 〚_〛 = equivFun Carrier₁≃₂ -- {-# DISPLAY equivFun Carrier₁≃₂ x = 〚 x 〛 #-} -- somehow omits its `x` ? -- I guess this is what we have "the machinery" for f : LOCREquivStr Σ₁ Σ₂ Carrier₁≃₂ → PathP (λ i → LOCRStructure (Carrier₁≡Carrier₂ i)) Structure₁ Structure₂ f (locrΣequiv pres0 pres1 isHom-- isHom-+ isHom-· isHom-min isHom-max isHom-<) = {! !} φ : isEquiv f φ .equiv-proof Structure₁≡₂ = {! !} -- R ≃[ LOCREquivStr ] S ≡ Σ _ (LOCRΣEquiv R S) -- LOCRΣPath : ∀{ℓ ℓ'} (R S : LOCRΣ {ℓ} {ℓ'}) → (R ≃[ LOCREquivStr ] S) ≃ (R ≡ S) -- "an equivalence between the two carriers that fulfills the axioms in `LOCRΣEquiv` is equivalent to a path between the two structures" LOCRΣPath* : ∀{ℓ ℓ'} (R S : LOCRΣ {ℓ} {ℓ'}) → Σ _ (LOCRΣEquiv R S) ≃ (R ≡ S) LOCRΣPath* = SIP LOCRUnivalentStructure open import Cubical.Structures.Axioms open import Cubical.Structures.Auto open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint -- congIso module _ {ℓ ℓ'} where LOCRRawStructure' = λ(X : Type ℓ) → X × X × (X → X) × (X → X → X) × (X → X → X) × (X → X → X) × (X → X → X) × (X → X → hProp ℓ') LOCRRawEquivStr' = AutoEquivStr LOCRRawStructure' LOCRRawUnivalentStr' : UnivalentStr _ LOCRRawEquivStr' LOCRRawUnivalentStr' = autoUnivalentStr LOCRRawStructure' LOCRAxioms' : (X : Type ℓ) (Structure : LOCRRawStructure' X) → _ LOCRAxioms' X (0f , 1f , -_ , _+_ , _·_ , min , max , _<_) = [ isLinearlyOrderedCommRing 0f 1f _+_ _·_ -_ _<_ min max ] LOCRStructure' = AxiomsStructure LOCRRawStructure' LOCRAxioms' LOCRΣ' = TypeWithStr ℓ LOCRStructure' LOCREquivStr' = AxiomsEquivStr LOCRRawEquivStr' LOCRAxioms' LOCRUnivalentStructure' : UnivalentStr LOCRStructure' LOCREquivStr' LOCRUnivalentStructure' = axiomsUnivalentStr _ γ LOCRRawUnivalentStr' where γ : (X : Type ℓ) (s : LOCRRawStructure' X) → isProp (LOCRAxioms' X s) γ X (0f , 1f , -_ , _+_ , _·_ , min , max , _<_) = isProp[] (isLinearlyOrderedCommRing 0f 1f _+_ _·_ -_ _<_ min max) LOCRΣPath' : (A B : LOCRΣ') → (A ≃[ LOCREquivStr' ] B) ≃ (A ≡ B) LOCRΣPath' = SIP LOCRUnivalentStructure' LOCRΣ→' : LOCRΣ {ℓ} {ℓ'} → LOCRΣ' LOCRΣ→' (X , s) = let open LOCRStructure s in X , (0f , 1f , -_ , _+_ , _·_ , min , max , _<_) , is-LOCR LOCRΣ←' : LOCRΣ' → LOCRΣ {ℓ} {ℓ'} LOCRΣ←' (X , (0f , 1f , -_ , _+_ , _·_ , min , max , _<_) , is-LOCR) = (X , γ) where γ : LOCRStructure {ℓ} {ℓ'} X γ .LOCRStructure.0f = 0f γ .LOCRStructure.1f = 1f γ .LOCRStructure._+_ = _+_ γ .LOCRStructure.-_ = -_ γ .LOCRStructure._·_ = _·_ γ .LOCRStructure.min = min γ .LOCRStructure.max = max γ .LOCRStructure._<_ = _<_ γ .LOCRStructure.is-LOCR = is-LOCR LOCRΣIso : Iso LOCRΣ LOCRΣ' LOCRΣIso = iso LOCRΣ→' LOCRΣ←' (λ _ → refl) (λ _ → refl) LOCRΣEquiv' = λ(A B : LOCRΣ {ℓ} {ℓ'}) → LOCRΣ→' A ≃[ LOCREquivStr' ] LOCRΣ→' B LOCRΣEquivIso : {R S : LOCRΣ} → Iso (Σ _ (LOCRΣEquiv R S)) (LOCRΣEquiv' R S) LOCRΣEquivIso .Iso.fun (Carrier₁≃₂ , locrΣequiv pres0 pres1 isHom-- isHom-+ isHom-· isHom-min isHom-max isHom-<) = (Carrier₁≃₂ , pres0 , pres1 , isHom-- , isHom-+ , isHom-· , isHom-min , isHom-max , isHom-<) LOCRΣEquivIso .Iso.inv (Carrier₁≃₂ , pres0 , pres1 , isHom-- , isHom-+ , isHom-· , isHom-min , isHom-max , isHom-<) = (Carrier₁≃₂ , locrΣequiv pres0 pres1 isHom-- isHom-+ isHom-· isHom-min isHom-max isHom-<) LOCRΣEquivIso .Iso.rightInv _ = refl LOCRΣEquivIso .Iso.leftInv _ = refl -- obtained by SIP-machinery: -- our previously defined LOCRΣEquiv-record is equivalent to a path LOCRΣPath : (R S : LOCRΣ {ℓ} {ℓ'}) → Σ _ (LOCRΣEquiv R S) ≃ (R ≡ S) LOCRΣPath R S = Σ _ (LOCRΣEquiv R S) ≃⟨ isoToEquiv LOCRΣEquivIso ⟩ LOCRΣEquiv' R S ≃⟨ LOCRΣPath' _ _ ⟩ LOCRΣ→' R ≡ LOCRΣ→' S ≃⟨ isoToEquiv (invIso (congIso LOCRΣIso)) ⟩ R ≡ S ■
{ "alphanum_fraction": 0.6332730093, "avg_line_length": 45.5058823529, "ext": "agda", "hexsha": "05ff8e69e127c64c2b36943f0abf7edb47761003", "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/Instances/QuoIntFromIntSIP.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/Instances/QuoIntFromIntSIP.agda", "max_line_length": 136, "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/Instances/QuoIntFromIntSIP.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": 3149, "size": 7736 }
{-# OPTIONS --universe-polymorphism #-} -- There was a bug with reducing levels which could leave -- instantiated metas in the term. module Issue469 where open import Common.Level postulate ∃ : ∀ {a b} {A : Set a} → (A → Set b) → Set (a ⊔ b) E : ∀ {c d} → Set c → Set d → Set (c ⊔ d) data K : Set where k₁ : K P : ∀ {e f} → K → Set e → Set f → Set (e ⊔ f) P k₁ A B = E A B postulate lemma₁ : ∀ {g h} {A : Set g} {B : Set h} → E A B → E A B lemma₂ : ∀ {i j k l} {A : Set i} {B₁ : A → Set j} {B₂ : A → Set k} → (∀ x → P l (B₁ x) (B₂ x)) → P l (∃ B₁) (∃ B₂) lemma₃ : ∀ {m n} {A₁ A₂ : Set m} → E A₁ A₂ → P n A₁ A₂ Foo : ∀ o {A : Set} {B₁ B₂ : A → Set o} → (∀ x → E (B₁ x) (B₂ x)) → E (∃ B₁) (∃ B₂) Foo o B₁↔B₂ = lemma₁ (lemma₂ (λ r → lemma₃ (B₁↔B₂ r))) -- Unsolved constraints: -- -- o = o -- -- This constraint shouldn't be too hard to solve... -- -- I haven't checked, but I suspect that this code type checks using -- Agda 2.2.10.
{ "alphanum_fraction": 0.525388601, "avg_line_length": 24.7435897436, "ext": "agda", "hexsha": "5f56a05c54c325e4358a57c4ee53ccaa77f4007c", "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/Issue469.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/Issue469.agda", "max_line_length": 68, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue469.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": 403, "size": 965 }
{-# OPTIONS --without-K #-} open import Data.Product using (_×_) open import Data.String open import Level open import Relation.Binary.PropositionalEquality.Core Valence : Set Valence = String data Type : Set where Outgoing : Type Incoming : Type infix 5 _,_⦂_ data Context : Set where ∅ : Context _,_⦂_ : Context → Valence → Type → Context _+_ : Context → Context → Context ∅ + Γ₂ = Γ₂ (Γ₁ , x ⦂ A) + Γ₂ = (Γ₁ + Γ₂) , x ⦂ A rename : Context → (Valence → Valence) → Context rename ∅ ϕ = ∅ rename (Γ , x ⦂ A) ϕ = rename Γ ϕ , ϕ x ⦂ A data Agent {ℓ} : Context → Set ℓ → Set (suc ℓ) where Nil : ∀ {A : Set ℓ} → Agent ∅ A _∙_ : ∀ {Γ A} → (ion : Valence) → (com : Type) → (x : A) → Agent (Γ , ion ⦂ com) A _∣_ : ∀ {Γ₁ Γ₂} {A B : Set ℓ} → Agent Γ₁ A → Agent Γ₂ B → Agent (Γ₁ + Γ₂) (A × B) _/_ : ∀ {Γ A} → A → (ion : Valence) → Agent (Γ , ion ⦂ Outgoing) A _[_] : ∀ {Γ A} → (ϕ : Valence → Valence) → Agent Γ A → Agent (rename Γ ϕ) A fix_ : ∀ {Γ} {A B : Set ℓ} → (f : A → B) → Agent Γ A → Agent Γ B infix 4 _∋_⦂_ data _∋_⦂_ : Context → Valence → Type → Set where Z : ∀ {Γ x A} ----------------- → Γ , x ⦂ A ∋ x ⦂ A S : ∀ {Γ x y A B} → x ≢ y → Γ ∋ x ⦂ A ----------------- → Γ , y ⦂ B ∋ x ⦂ A data _⊢_⦂_ : Context → Valence → Type → Set where ⊢ : ∀ {Γ x A} → Γ ∋ x ⦂ A ---------- → Γ ⊢ x ⦂ A
{ "alphanum_fraction": 0.4564204923, "avg_line_length": 20.3108108108, "ext": "agda", "hexsha": "b0835853d1ae3c116a4e83cd65712d84e3fac0df", "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": "292023fc36fa67ca4a81cff9a875a325a79b9d6f", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "riz0id/chemical-abstract-machine", "max_forks_repo_path": "agda/Language.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "292023fc36fa67ca4a81cff9a875a325a79b9d6f", "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": "riz0id/chemical-abstract-machine", "max_issues_repo_path": "agda/Language.agda", "max_line_length": 54, "max_stars_count": null, "max_stars_repo_head_hexsha": "292023fc36fa67ca4a81cff9a875a325a79b9d6f", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "riz0id/chemical-abstract-machine", "max_stars_repo_path": "agda/Language.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 610, "size": 1503 }
module Cats.Category.Wedges where open import Level using (_⊔_ ; suc) open import Relation.Binary using (Rel ; IsEquivalence) open import Cats.Category open import Cats.Category.Setoids using (Setoids) open import Cats.Profunctor open import Cats.Util.Function using (_on_ ; on-isEquivalence) module _ {lo la l≈ lo′ la′ l≈′} {C : Category lo la l≈} {D : Category lo′ la′ l≈′} (F : Profunctor C C D) where private module C = Category C module D = Category D module F = Profunctor F record Wedge : Set (lo ⊔ la ⊔ lo′ ⊔ la′ ⊔ l≈′) where open D field Apex : Obj arr : ∀ x → Apex ⇒ pobj F x x commute : ∀ {a b} (f : a C.⇒ b) → pmap₂ F f ∘ arr a ≈ pmap₁ F f ∘ arr b Obj = Wedge record _⇒_ (A B : Obj) : Set (lo ⊔ la′ ⊔ l≈′) where open Wedge open D field θ : Apex A D.⇒ Apex B commute : ∀ x → arr B x ∘ θ ≈ arr A x _≈_ : ∀ {A B} → Rel (A ⇒ B) l≈′ _≈_ = D._≈_ on _⇒_.θ equiv : ∀ {A B} → IsEquivalence (_≈_ {A} {B}) equiv = on-isEquivalence _⇒_.θ D.equiv id : ∀ {A} → A ⇒ A id = record { θ = D.id ; commute = λ x → D.id-r } _∘_ : ∀ {A B C} → B ⇒ C → A ⇒ B → A ⇒ C _∘_ {A} {B} {C} f g = record { θ = θ f ∘S θ g ; commute = λ j → begin arr C j ∘S θ f ∘S θ g ≈⟨ D.unassoc ⟩ (arr C j ∘S θ f) ∘S θ g ≈⟨ D.∘-resp-l (commute f j) ⟩ arr B j ∘S θ g ≈⟨ commute g j ⟩ arr A j ∎ } where open Wedge using (arr) open _⇒_ open D using () renaming (_∘_ to _∘S_) open D.≈-Reasoning Wedges : Category (lo ⊔ la ⊔ lo′ ⊔ la′ ⊔ l≈′) (lo ⊔ la′ ⊔ l≈′) l≈′ Wedges = record { Obj = Obj ; _⇒_ = _⇒_ ; _≈_ = _≈_ ; id = id ; _∘_ = _∘_ ; equiv = equiv ; ∘-resp = D.∘-resp ; id-r = D.id-r ; id-l = D.id-l ; assoc = D.assoc }
{ "alphanum_fraction": 0.4894067797, "avg_line_length": 20.085106383, "ext": "agda", "hexsha": "32847d4d3116e9036b907c74093cfc9cac1fe999", "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": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_path": "Cats/Category/Wedges.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "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": "alessio-b-zak/cats", "max_issues_repo_path": "Cats/Category/Wedges.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_path": "Cats/Category/Wedges.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 805, "size": 1888 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.Join.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.HITs.S1 open import Cubical.HITs.S3 -- redtt version : https://github.com/RedPRL/redtt/blob/master/library/cool/s3-to-join.red data join {ℓ ℓ'} (A : Type ℓ) (B : Type ℓ') : Type (ℓ-max ℓ ℓ') where inl : A → join A B inr : B → join A B push : ∀ a b → inl a ≡ inr b facek01 : I → I → I → join S¹ S¹ facek01 i j k = hfill (λ l → λ { (j = i0) → push base base (~ l ∧ ~ k) ; (j = i1) → push base base (~ l ∧ ~ k) ; (k = i0) → push (loop j) base (~ l) ; (k = i1) → inl base }) (inS (push base base (~ k))) i border-contraction : I → I → I → I → join S¹ S¹ border-contraction i j k m = hfill (λ l → λ { (i = i0) → facek01 i1 j l ; (i = i1) → push base (loop k) (~ l) ; (j = i0) → push base (loop k) (i ∧ ~ l) ; (j = i1) → push base (loop k) (i ∧ ~ l) ; (k = i0) → facek01 (~ i) j l ; (k = i1) → facek01 (~ i) j l }) (inS (push (loop j) (loop k) i)) m S³→joinS¹S¹ : S³ → join S¹ S¹ S³→joinS¹S¹ base = inl base S³→joinS¹S¹ (surf j k i) = border-contraction i j k i1 joinS¹S¹→S³ : join S¹ S¹ → S³ joinS¹S¹→S³ (inl x) = base joinS¹S¹→S³ (inr x) = base joinS¹S¹→S³ (push base b i) = base joinS¹S¹→S³ (push (loop x) base i) = base joinS¹S¹→S³ (push (loop i) (loop j) k) = surf i j k connection : I → I → I → I → S³ connection i j k l = hfill (λ m → λ { (k = i0) → joinS¹S¹→S³ (facek01 m i j) ; (k = i1) → base ; (j = i0) → base ; (j = i1) → base ; (i = i0) → base ; (i = i1) → base }) (inS base) l S³→joinS¹S¹→S³ : ∀ x → joinS¹S¹→S³ (S³→joinS¹S¹ x) ≡ x S³→joinS¹S¹→S³ base l = base S³→joinS¹S¹→S³ (surf j k i) l = hcomp (λ m → λ { (l = i0) → joinS¹S¹→S³ (border-contraction i j k m) ; (l = i1) → surf j k i ; (i = i0) → connection j m l i1 ; (i = i1) → base ; (j = i0) → base ; (j = i1) → base ; (k = i0) → connection j m l (~ i) ; (k = i1) → connection j m l (~ i) }) (surf j k i) joinS¹S¹→S³→joinS¹S¹ : ∀ x → S³→joinS¹S¹ (joinS¹S¹→S³ x) ≡ x joinS¹S¹→S³→joinS¹S¹ (inl base) l = inl base joinS¹S¹→S³→joinS¹S¹ (inl (loop i)) l = facek01 i1 i (~ l) joinS¹S¹→S³→joinS¹S¹ (inr base) l = push base base l joinS¹S¹→S³→joinS¹S¹ (inr (loop i)) l = push base (loop i) l joinS¹S¹→S³→joinS¹S¹ (push base base i) l = push base base (i ∧ l) joinS¹S¹→S³→joinS¹S¹ (push base (loop k) i) l = push base (loop k) (i ∧ l) joinS¹S¹→S³→joinS¹S¹ (push (loop k) base i) l = facek01 (~ i) k (~ l) joinS¹S¹→S³→joinS¹S¹ (push (loop j) (loop k) i) l = border-contraction i j k (~ l) S³IsojoinS¹S¹ : Iso S³ (join S¹ S¹) Iso.fun S³IsojoinS¹S¹ = S³→joinS¹S¹ Iso.inv S³IsojoinS¹S¹ = joinS¹S¹→S³ Iso.rightInv S³IsojoinS¹S¹ = joinS¹S¹→S³→joinS¹S¹ Iso.leftInv S³IsojoinS¹S¹ = S³→joinS¹S¹→S³ S³≡joinS¹S¹ : S³ ≡ join S¹ S¹ S³≡joinS¹S¹ = isoToPath S³IsojoinS¹S¹
{ "alphanum_fraction": 0.5348062954, "avg_line_length": 37.5454545455, "ext": "agda", "hexsha": "7cf02157f7bb5befdaaddd48cf5334428efec4d4", "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/HITs/Join/Base.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/HITs/Join/Base.agda", "max_line_length": 90, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/HITs/Join/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1388, "size": 3304 }
module _ where open import Agda.Builtin.Nat postulate F : Set → Set pure : ∀ {A} → A → F A _<*>_ : ∀ {A B} → F (A → B) → F A → F B data Vec (A : Set) : Nat → Set where [] : Vec A zero _∷_ : ∀ {n} → A → Vec A n → Vec A (suc n) ok : ∀ n → F Nat → F (Vec Nat n) → F (Vec Nat (suc n)) ok n a as = (| a ∷ as |) ok₂ : ∀ n → F Nat → F (Vec Nat n) → F (Vec Nat (suc n)) ok₂ n a as = (| (_∷_ {n = n}) a as |) fail : ∀ n → F Nat → F (Vec Nat n) → F (Vec Nat (suc n)) fail n a as = (| _∷_ {n = n} a as |)
{ "alphanum_fraction": 0.462890625, "avg_line_length": 22.2608695652, "ext": "agda", "hexsha": "d0922624bf2304a946c23bab21f382eab02e79c7", "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/IdiomBracketsImplicit.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/IdiomBracketsImplicit.agda", "max_line_length": 56, "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/IdiomBracketsImplicit.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": 234, "size": 512 }
-- Andreas, 2016-08-02 issue #2127 reported by petercommand data Test : Set₁ where field A : Set B : Set -- second field necessary to trigger internal error -- WAS: internal error -- Should give proper error
{ "alphanum_fraction": 0.6981981982, "avg_line_length": 20.1818181818, "ext": "agda", "hexsha": "cc44af0f5242ac1ba1157e90e89cf81116cc02f8", "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/Issue2127.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/Issue2127.agda", "max_line_length": 64, "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/Issue2127.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": 60, "size": 222 }
-- Andreas, 2011-10-03 -- allow matching on irrelevant data as long as there is at most one -- matching constructor {-# OPTIONS --experimental-irrelevance #-} module MatchIrrelevant where data Nat : Set where zero : Nat suc : Nat -> Nat data NAT : Nat -> Set where Zero : NAT zero Suc : (n : Nat) -> NAT n -> NAT (suc n) -- should succeed: f : (n : Nat).(N : NAT n) -> Nat f zero Zero = zero f (suc n) (Suc .n N) = f n N -- prove the equations to test reduction data _≡_ {A : Set}(a : A) : A → Set where refl : a ≡ a fzero : f zero Zero ≡ zero fzero = refl fsuc : (n : Nat)(N : NAT n) -> f (suc n) (Suc n N) ≡ f n N fsuc n N = refl {- DOES NOT YET WORK and probably should never work fzero' : (N : NAT zero) → f zero N ≡ zero fzero' N = refl -} {- -- should fail: f' : (n : Nat).(N : NAT n) -> Nat f' zero Zero = zero f' (suc _) (Suc n N) = n -} {- -- should fail: g : {n : Nat}.(N : NAT n) -> Nat g Zero = zero g (Suc _ N) = g N -} {- data Fin : Nat -> Set where zero : (n : Nat) -> Fin (suc n) suc : (n : Nat) -> Fin n -> Fin (suc n) -- should fail: toNat : {n : Nat} → .(Fin n) -> Nat toNat (zero n) = zero toNat (suc n i) = suc (toNat i) -} {- -- fails for other reasons weak : {n : Nat} → .(Fin n) -> Fin (suc n) weak (zero n) = zero (suc n) weak (suc n i) = suc (suc n) (weak i) -}
{ "alphanum_fraction": 0.5625473844, "avg_line_length": 19.3970588235, "ext": "agda", "hexsha": "01819c15e4a53c929f5ca2264a8bc0cc65c0e245", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Succeed/MatchIrrelevant.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "test/Succeed/MatchIrrelevant.agda", "max_line_length": 68, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Succeed/MatchIrrelevant.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": 502, "size": 1319 }
{-# OPTIONS --without-K #-} open import lib.Basics module lib.types.Sigma where -- Cartesian product _×_ : ∀ {i j} (A : Type i) (B : Type j) → Type (lmax i j) A × B = Σ A (λ _ → B) module _ {i j} {A : Type i} {B : A → Type j} where pair : (a : A) (b : B a) → Σ A B pair a b = (a , b) -- pair= has already been defined fst= : {ab a'b' : Σ A B} (p : ab == a'b') → (fst ab == fst a'b') fst= = ap fst snd= : {ab a'b' : Σ A B} (p : ab == a'b') → (snd ab == snd a'b' [ B ↓ fst= p ]) snd= {._} {_} idp = idp fst=-β : {a a' : A} (p : a == a') {b : B a} {b' : B a'} (q : b == b' [ B ↓ p ]) → fst= (pair= p q) == p fst=-β idp idp = idp snd=-β : {a a' : A} (p : a == a') {b : B a} {b' : B a'} (q : b == b' [ B ↓ p ]) → snd= (pair= p q) == q [ (λ v → b == b' [ B ↓ v ]) ↓ fst=-β p q ] snd=-β idp idp = idp pair=-η : {ab a'b' : Σ A B} (p : ab == a'b') → p == pair= (fst= p) (snd= p) pair=-η {._} {_} idp = idp pair== : {a a' : A} {p p' : a == a'} (α : p == p') {b : B a} {b' : B a'} {q : b == b' [ B ↓ p ]} {q' : b == b' [ B ↓ p' ]} (β : q == q' [ (λ u → b == b' [ B ↓ u ]) ↓ α ]) → pair= p q == pair= p' q' pair== idp idp = idp module _ {i j} {A : Type i} {B : Type j} where fst×= : {ab a'b' : A × B} (p : ab == a'b') → (fst ab == fst a'b') fst×= = ap fst snd×= : {ab a'b' : A × B} (p : ab == a'b') → (snd ab == snd a'b') snd×= = ap snd fst×=-β : {a a' : A} (p : a == a') {b b' : B} (q : b == b') → fst×= (pair×= p q) == p fst×=-β idp idp = idp snd×=-β : {a a' : A} (p : a == a') {b b' : B} (q : b == b') → snd×= (pair×= p q) == q snd×=-β idp idp = idp module _ {i j} {A : Type i} {B : A → Type j} where =Σ : (x y : Σ A B) → Type (lmax i j) =Σ (a , b) (a' , b') = Σ (a == a') (λ p → b == b' [ B ↓ p ]) =Σ-eqv : (x y : Σ A B) → (=Σ x y) ≃ (x == y) =Σ-eqv x y = equiv (λ pq → pair= (fst pq) (snd pq)) (λ p → fst= p , snd= p) (λ p → ! (pair=-η p)) (λ pq → pair= (fst=-β (fst pq) (snd pq)) (snd=-β (fst pq) (snd pq))) =Σ-path : (x y : Σ A B) → (=Σ x y) == (x == y) =Σ-path x y = ua (=Σ-eqv x y) Σ= : ∀ {i j} {A A' : Type i} (p : A == A') {B : A → Type j} {B' : A' → Type j} (q : B == B' [ (λ X → (X → Type j)) ↓ p ]) → Σ A B == Σ A' B' Σ= idp idp = idp abstract Σ-level : ∀ {i j} {n : ℕ₋₂} {A : Type i} {P : A → Type j} → (has-level n A → ((x : A) → has-level n (P x)) → has-level n (Σ A P)) Σ-level {n = ⟨-2⟩} p q = ((fst p , (fst (q (fst p)))) , (λ y → pair= (snd p _) (from-transp! _ _ (snd (q _) _)))) Σ-level {n = S n} p q = λ x y → equiv-preserves-level (=Σ-eqv x y) (Σ-level (p _ _) (λ _ → equiv-preserves-level ((to-transp-equiv _ _)⁻¹) (q _ _ _))) ×-level : ∀ {i j} {n : ℕ₋₂} {A : Type i} {B : Type j} → (has-level n A → has-level n B → has-level n (A × B)) ×-level pA pB = Σ-level pA (λ x → pB) -- Equivalences in a Σ-type equiv-Σ-fst : ∀ {i j k} {A : Type i} {B : Type j} (P : B → Type k) {h : A → B} → is-equiv h → (Σ A (P ∘ h)) ≃ (Σ B P) equiv-Σ-fst {A = A} {B = B} P {h = h} e = equiv f g f-g g-f where f : Σ A (P ∘ h) → Σ B P f (a , r) = (h a , r) g : Σ B P → Σ A (P ∘ h) g (b , s) = (is-equiv.g e b , transport P (! (is-equiv.f-g e b)) s) f-g : ∀ y → f (g y) == y f-g (b , s) = pair= (is-equiv.f-g e b) (trans-↓ P (is-equiv.f-g e b) s) g-f : ∀ x → g (f x) == x g-f (a , r) = pair= (is-equiv.g-f e a) (transport (λ q → transport P (! q) r == r [ P ∘ h ↓ is-equiv.g-f e a ]) (is-equiv.adj e a) (trans-ap-↓ P h (is-equiv.g-f e a) r) ) equiv-Σ-snd : ∀ {i j k} {A : Type i} {B : A → Type j} {C : A → Type k} → (∀ x → B x ≃ C x) → Σ A B ≃ Σ A C equiv-Σ-snd {A = A} {B = B} {C = C} k = equiv f g f-g g-f where f : Σ A B → Σ A C f (a , b) = (a , fst (k a) b) g : Σ A C → Σ A B g (a , c) = (a , is-equiv.g (snd (k a)) c) f-g : ∀ p → f (g p) == p f-g (a , c) = pair= idp (is-equiv.f-g (snd (k a)) c) g-f : ∀ p → g (f p) == p g-f (a , b) = pair= idp (is-equiv.g-f (snd (k a)) b) -- Two ways of simultaneously applying equivalences in each component. module _ {i₀ i₁ j₀ j₁} {A₀ : Type i₀} {A₁ : Type i₁} {B₀ : A₀ → Type j₀} {B₁ : A₁ → Type j₁} where equiv-Σ : (u : A₀ ≃ A₁) (v : ∀ a → B₀ (<– u a) ≃ B₁ a) → Σ A₀ B₀ ≃ Σ A₁ B₁ equiv-Σ u v = Σ A₀ B₀ ≃⟨ equiv-Σ-fst _ (snd (u ⁻¹)) ⁻¹ ⟩ Σ A₁ (B₀ ∘ <– u) ≃⟨ equiv-Σ-snd v ⟩ Σ A₁ B₁ ≃∎ equiv-Σ' : (u : A₀ ≃ A₁) (v : ∀ a → B₀ a ≃ B₁ (–> u a)) → Σ A₀ B₀ ≃ Σ A₁ B₁ equiv-Σ' u v = Σ A₀ B₀ ≃⟨ equiv-Σ-snd v ⟩ Σ A₀ (B₁ ∘ –> u) ≃⟨ equiv-Σ-fst _ (snd u) ⟩ Σ A₁ B₁ ≃∎ -- Implementation of [_∙'_] on Σ Σ-∙' : ∀ {i j} {A : Type i} {B : A → Type j} {x y z : A} {p : x == y} {p' : y == z} {u : B x} {v : B y} {w : B z} (q : u == v [ B ↓ p ]) (r : v == w [ B ↓ p' ]) → (pair= p q ∙' pair= p' r) == pair= (p ∙' p') (q ∙'ᵈ r) Σ-∙' {p = idp} {p' = idp} q idp = idp -- Implementation of [_∙_] on Σ Σ-∙ : ∀ {i j} {A : Type i} {B : A → Type j} {x y z : A} {p : x == y} {p' : y == z} {u : B x} {v : B y} {w : B z} (q : u == v [ B ↓ p ]) (r : v == w [ B ↓ p' ]) → (pair= p q ∙ pair= p' r) == pair= (p ∙ p') (q ∙ᵈ r) Σ-∙ {p = idp} {p' = idp} idp r = idp -- Implementation of [_∙'_] on × ×-∙' : ∀ {i j} {A : Type i} {B : Type j} {x y z : A} (p : x == y) (p' : y == z) {u v w : B} (q : u == v) (q' : v == w) → (pair×= p q ∙' pair×= p' q') == pair×= (p ∙' p') (q ∙' q') ×-∙' idp idp q idp = idp -- Implementation of [_∙_] on × ×-∙ : ∀ {i j} {A : Type i} {B : Type j} {x y z : A} (p : x == y) (p' : y == z) {u v w : B} (q : u == v) (q' : v == w) → (pair×= p q ∙ pair×= p' q') == pair×= (p ∙ p') (q ∙ q') ×-∙ idp idp idp r = idp -- Special case of [ap-,] ap-cst,id : ∀ {i j} {A : Type i} (B : A → Type j) {a : A} {x y : B a} (p : x == y) → ap (λ x → _,_ {B = B} a x) p == pair= idp p ap-cst,id B idp = idp
{ "alphanum_fraction": 0.3851803493, "avg_line_length": 33.4808743169, "ext": "agda", "hexsha": "f8234599edcd2c48196c2f197aaeabcc37924ccd", "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": "c8fb8da3354fc9e0c430ac14160161759b4c5b37", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "sattlerc/HoTT-Agda", "max_forks_repo_path": "lib/types/Sigma.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c8fb8da3354fc9e0c430ac14160161759b4c5b37", "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": "sattlerc/HoTT-Agda", "max_issues_repo_path": "lib/types/Sigma.agda", "max_line_length": 89, "max_stars_count": null, "max_stars_repo_head_hexsha": "c8fb8da3354fc9e0c430ac14160161759b4c5b37", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "sattlerc/HoTT-Agda", "max_stars_repo_path": "lib/types/Sigma.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2923, "size": 6127 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Some properties about subsets ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Fin.Subset.Properties where import Algebra.Definitions as AlgebraicDefinitions import Algebra.Structures as AlgebraicStructures open import Algebra.Bundles import Algebra.Properties.Lattice as L import Algebra.Properties.DistributiveLattice as DL import Algebra.Properties.BooleanAlgebra as BA open import Data.Bool.Base using (not) open import Data.Bool.Properties open import Data.Fin.Base using (Fin; suc; zero) open import Data.Fin.Subset open import Data.Fin.Properties using (any?; decFinSubset) open import Data.Nat.Base import Data.Nat.Properties as ℕₚ open import Data.Product as Product using (∃; ∄; _×_; _,_; proj₁) open import Data.Sum.Base as Sum using (_⊎_; inj₁; inj₂; [_,_]′) open import Data.Vec.Base open import Data.Vec.Properties open import Function.Base using (_∘_; const; id; case_of_) open import Function.Equivalence using (_⇔_; equivalence) open import Relation.Binary as B hiding (Decidable) open import Relation.Binary.PropositionalEquality open import Relation.Nullary using (Dec; yes; no) import Relation.Nullary.Decidable as Dec open import Relation.Nullary.Negation using (contradiction) open import Relation.Nullary.Sum using (_⊎-dec_) open import Relation.Unary using (Pred; Decidable; Satisfiable) ------------------------------------------------------------------------ -- Constructor mangling drop-there : ∀ {s n x} {p : Subset n} → suc x ∈ s ∷ p → x ∈ p drop-there (there x∈p) = x∈p drop-not-there : ∀ {s n x} {p : Subset n} → suc x ∉ s ∷ p → x ∉ p drop-not-there x∉sp x∈p = contradiction (there x∈p) x∉sp drop-∷-⊆ : ∀ {n s₁ s₂} {p₁ p₂ : Subset n} → s₁ ∷ p₁ ⊆ s₂ ∷ p₂ → p₁ ⊆ p₂ drop-∷-⊆ p₁s₁⊆p₂s₂ x∈p₁ = drop-there (p₁s₁⊆p₂s₂ (there x∈p₁)) drop-∷-⊂ : ∀ {n s} {p₁ p₂ : Subset n} → s ∷ p₁ ⊂ s ∷ p₂ → p₁ ⊂ p₂ drop-∷-⊂ {s = inside} (_ , zero , x∈sp₂ , x∉sp₁) = contradiction here x∉sp₁ drop-∷-⊂ {s} (sp₁⊆sp₂ , suc x , there x∈p₂ , x∉sp₁) = drop-∷-⊆ sp₁⊆sp₂ , x , x∈p₂ , drop-not-there x∉sp₁ module _ {n} {p q : Subset n} where out⊆ : ∀ {y} → p ⊆ q → outside ∷ p ⊆ y ∷ q out⊆ p⊆q (there ∈p) = there (p⊆q ∈p) out⊆-⇔ : ∀ {y} → p ⊆ q ⇔ outside ∷ p ⊆ y ∷ q out⊆-⇔ = equivalence out⊆ drop-∷-⊆ in⊆in : p ⊆ q → inside ∷ p ⊆ inside ∷ q in⊆in p⊆q here = here in⊆in p⊆q (there ∈p) = there (p⊆q ∈p) in⊆in-⇔ : p ⊆ q ⇔ inside ∷ p ⊆ inside ∷ q in⊆in-⇔ = equivalence in⊆in drop-∷-⊆ s⊆s : ∀ {s} → p ⊆ q → s ∷ p ⊆ s ∷ q s⊆s p⊆q here = here s⊆s p⊆q (there ∈p) = there (p⊆q ∈p) out⊂ : ∀ {y} → p ⊂ q → outside ∷ p ⊂ y ∷ q out⊂ (p⊆q , x , x∈q , x∉p) = out⊆ p⊆q , suc x , there x∈q , x∉p ∘ drop-there out⊂in : p ⊆ q → outside ∷ p ⊂ inside ∷ q out⊂in p⊆q = out⊆ p⊆q , zero , here , λ () out⊂in-⇔ : p ⊆ q ⇔ outside ∷ p ⊂ inside ∷ q out⊂in-⇔ = equivalence out⊂in (drop-∷-⊆ ∘ proj₁) out⊂out-⇔ : p ⊂ q ⇔ outside ∷ p ⊂ outside ∷ q out⊂out-⇔ = equivalence out⊂ drop-∷-⊂ in⊂in : p ⊂ q → inside ∷ p ⊂ inside ∷ q in⊂in (p⊆q , x , x∈q , x∉p) = in⊆in p⊆q , suc x , there x∈q , x∉p ∘ drop-there in⊂in-⇔ : p ⊂ q ⇔ inside ∷ p ⊂ inside ∷ q in⊂in-⇔ = equivalence in⊂in drop-∷-⊂ ------------------------------------------------------------------------ -- _∈_ infix 4 _∈?_ _∈?_ : ∀ {n} x (p : Subset n) → Dec (x ∈ p) zero ∈? inside ∷ p = yes here zero ∈? outside ∷ p = no λ() suc n ∈? s ∷ p = Dec.map′ there drop-there (n ∈? p) ------------------------------------------------------------------------ -- Empty drop-∷-Empty : ∀ {n s} {p : Subset n} → Empty (s ∷ p) → Empty p drop-∷-Empty ¬∃∈ (x , x∈p) = ¬∃∈ (suc x , there x∈p) Empty-unique : ∀ {n} {p : Subset n} → Empty p → p ≡ ⊥ Empty-unique {_} {[]} ¬∃∈ = refl Empty-unique {_} {inside ∷ p} ¬∃∈ = contradiction (zero , here) ¬∃∈ Empty-unique {_} {outside ∷ p} ¬∃∈ = cong (outside ∷_) (Empty-unique (drop-∷-Empty ¬∃∈)) nonempty? : ∀ {n} → Decidable (Nonempty {n}) nonempty? p = any? (_∈? p) ------------------------------------------------------------------------ -- ∣_∣ ∣p∣≤n : ∀ {n} (p : Subset n) → ∣ p ∣ ≤ n ∣p∣≤n = count≤n (_≟ inside) ------------------------------------------------------------------------ -- ⊥ ∉⊥ : ∀ {n} {x : Fin n} → x ∉ ⊥ ∉⊥ (there p) = ∉⊥ p ⊥⊆ : ∀ {n} {p : Subset n} → ⊥ ⊆ p ⊥⊆ x∈⊥ = contradiction x∈⊥ ∉⊥ ∣⊥∣≡0 : ∀ n → ∣ ⊥ {n = n} ∣ ≡ 0 ∣⊥∣≡0 zero = refl ∣⊥∣≡0 (suc n) = ∣⊥∣≡0 n ------------------------------------------------------------------------ -- ⊤ ∈⊤ : ∀ {n} {x : Fin n} → x ∈ ⊤ ∈⊤ {x = zero} = here ∈⊤ {x = suc x} = there ∈⊤ ⊆⊤ : ∀ {n} {p : Subset n} → p ⊆ ⊤ ⊆⊤ = const ∈⊤ ∣⊤∣≡n : ∀ n → ∣ ⊤ {n = n} ∣ ≡ n ∣⊤∣≡n zero = refl ∣⊤∣≡n (suc n) = cong suc (∣⊤∣≡n n) ∣p∣≡n⇒p≡⊤ : ∀ {n} {p : Subset n} → ∣ p ∣ ≡ n → p ≡ ⊤ ∣p∣≡n⇒p≡⊤ {p = []} _ = refl ∣p∣≡n⇒p≡⊤ {p = outside ∷ p} |p|≡n = contradiction |p|≡n (ℕₚ.<⇒≢ (s≤s (∣p∣≤n p))) ∣p∣≡n⇒p≡⊤ {p = inside ∷ p} |p|≡n = cong (inside ∷_) (∣p∣≡n⇒p≡⊤ (ℕₚ.suc-injective |p|≡n)) ------------------------------------------------------------------------ -- ⁅_⁆ x∈⁅x⁆ : ∀ {n} (x : Fin n) → x ∈ ⁅ x ⁆ x∈⁅x⁆ zero = here x∈⁅x⁆ (suc x) = there (x∈⁅x⁆ x) x∈⁅y⁆⇒x≡y : ∀ {n x} (y : Fin n) → x ∈ ⁅ y ⁆ → x ≡ y x∈⁅y⁆⇒x≡y zero here = refl x∈⁅y⁆⇒x≡y zero (there p) = contradiction p ∉⊥ x∈⁅y⁆⇒x≡y (suc y) (there p) = cong suc (x∈⁅y⁆⇒x≡y y p) x∈⁅y⁆⇔x≡y : ∀ {n} {x y : Fin n} → x ∈ ⁅ y ⁆ ⇔ x ≡ y x∈⁅y⁆⇔x≡y {_} {x} {y} = equivalence (x∈⁅y⁆⇒x≡y y) (λ x≡y → subst (λ y → x ∈ ⁅ y ⁆) x≡y (x∈⁅x⁆ x)) x≢y⇒x∉⁅y⁆ : ∀ {n} {x y : Fin n} → x ≢ y → x ∉ ⁅ y ⁆ x≢y⇒x∉⁅y⁆ x≢y = x≢y ∘ x∈⁅y⁆⇒x≡y _ x∉⁅y⁆⇒x≢y : ∀ {n} {x y : Fin n} → x ∉ ⁅ y ⁆ → x ≢ y x∉⁅y⁆⇒x≢y x∉⁅x⁆ refl = x∉⁅x⁆ (x∈⁅x⁆ _) ∣⁅x⁆∣≡1 : ∀ {n} (i : Fin n) → ∣ ⁅ i ⁆ ∣ ≡ 1 ∣⁅x⁆∣≡1 {suc n} zero = cong suc (∣⊥∣≡0 n) ∣⁅x⁆∣≡1 {_} (suc i) = ∣⁅x⁆∣≡1 i ------------------------------------------------------------------------ -- _⊆_ ⊆-refl : ∀ {n} → Reflexive (_⊆_ {n}) ⊆-refl = id ⊆-reflexive : ∀ {n} → _≡_ ⇒ (_⊆_ {n}) ⊆-reflexive refl = ⊆-refl ⊆-trans : ∀ {n} → Transitive (_⊆_ {n}) ⊆-trans p⊆q q⊆r x∈p = q⊆r (p⊆q x∈p) ⊆-antisym : ∀ {n} → Antisymmetric _≡_ (_⊆_ {n}) ⊆-antisym {i = []} {[]} p⊆q q⊆p = refl ⊆-antisym {i = x ∷ xs} {y ∷ ys} p⊆q q⊆p with x | y ... | inside | inside = cong₂ _∷_ refl (⊆-antisym (drop-∷-⊆ p⊆q) (drop-∷-⊆ q⊆p)) ... | inside | outside = contradiction (p⊆q here) λ() ... | outside | inside = contradiction (q⊆p here) λ() ... | outside | outside = cong₂ _∷_ refl (⊆-antisym (drop-∷-⊆ p⊆q) (drop-∷-⊆ q⊆p)) ⊆-min : ∀ {n} → Minimum (_⊆_ {n}) ⊥ ⊆-min (x ∷ xs) (there v∈⊥) = there (⊆-min xs v∈⊥) ⊆-max : ∀ {n} → Maximum (_⊆_ {n}) ⊤ ⊆-max (inside ∷ xs) here = here ⊆-max (x ∷ xs) (there v∈xs) = there (⊆-max xs v∈xs) infix 4 _⊆?_ _⊆?_ : ∀ {n} → B.Decidable (_⊆_ {n = n}) [] ⊆? [] = yes id outside ∷ p ⊆? y ∷ q = Dec.map out⊆-⇔ (p ⊆? q) inside ∷ p ⊆? outside ∷ q = no (λ p⊆q → case (p⊆q here) of λ()) inside ∷ p ⊆? inside ∷ q = Dec.map in⊆in-⇔ (p ⊆? q) module _ (n : ℕ) where ⊆-isPreorder : IsPreorder _≡_ (_⊆_ {n}) ⊆-isPreorder = record { isEquivalence = isEquivalence ; reflexive = ⊆-reflexive ; trans = ⊆-trans } ⊆-preorder : Preorder _ _ _ ⊆-preorder = record { isPreorder = ⊆-isPreorder } ⊆-isPartialOrder : IsPartialOrder _≡_ (_⊆_ {n}) ⊆-isPartialOrder = record { isPreorder = ⊆-isPreorder ; antisym = ⊆-antisym } ⊆-poset : Poset _ _ _ ⊆-poset = record { isPartialOrder = ⊆-isPartialOrder } p⊆q⇒∣p∣≤∣q∣ : ∀ {n} {p q : Subset n} → p ⊆ q → ∣ p ∣ ≤ ∣ q ∣ p⊆q⇒∣p∣≤∣q∣ {p = []} {[]} p⊆q = z≤n p⊆q⇒∣p∣≤∣q∣ {p = outside ∷ p} {outside ∷ q} p⊆q = p⊆q⇒∣p∣≤∣q∣ (drop-∷-⊆ p⊆q) p⊆q⇒∣p∣≤∣q∣ {p = outside ∷ p} {inside ∷ q} p⊆q = ℕₚ.≤-step (p⊆q⇒∣p∣≤∣q∣ (drop-∷-⊆ p⊆q)) p⊆q⇒∣p∣≤∣q∣ {p = inside ∷ p} {outside ∷ q} p⊆q = contradiction (p⊆q here) λ() p⊆q⇒∣p∣≤∣q∣ {p = inside ∷ p} {inside ∷ q} p⊆q = s≤s (p⊆q⇒∣p∣≤∣q∣ (drop-∷-⊆ p⊆q)) ------------------------------------------------------------------------ -- _⊂_ p⊂q⇒p⊆q : ∀ {n} → {p q : Subset n} → p ⊂ q → p ⊆ q p⊂q⇒p⊆q = proj₁ ⊂-trans : ∀ {n} → Transitive (_⊂_ {n}) ⊂-trans (p⊆q , x , x∈q , x∉p) (q⊆r , _ , _ , _) = ⊆-trans p⊆q q⊆r , x , q⊆r x∈q , x∉p ⊂-⊆-trans : ∀ {n} → Trans {A = Subset n} _⊂_ _⊆_ _⊂_ ⊂-⊆-trans (p⊆q , x , x∈q , x∉p) q⊆r = ⊆-trans p⊆q q⊆r , x , q⊆r x∈q , x∉p ⊆-⊂-trans : ∀ {n} → Trans {A = Subset n} _⊆_ _⊂_ _⊂_ ⊆-⊂-trans p⊆q (q⊆r , x , x∈r , x∉q) = ⊆-trans p⊆q q⊆r , x , x∈r , x∉q ∘ p⊆q ⊂-irref : ∀ {n} → Irreflexive _≡_ (_⊂_ {n}) ⊂-irref refl (_ , x , x∈p , x∉q) = contradiction x∈p x∉q ⊂-antisym : ∀ {n} → Antisymmetric _≡_ (_⊂_ {n}) ⊂-antisym (p⊆q , _) (q⊆p , _) = ⊆-antisym p⊆q q⊆p ⊂-asymmetric : ∀ {n} → Asymmetric (_⊂_ {n}) ⊂-asymmetric (p⊆q , _) (_ , x , x∈p , x∉q) = contradiction (p⊆q x∈p) x∉q infix 4 _⊂?_ _⊂?_ : ∀ {n} → B.Decidable (_⊂_ {n = n}) [] ⊂? [] = no λ () outside ∷ p ⊂? outside ∷ q = Dec.map out⊂out-⇔ (p ⊂? q) outside ∷ p ⊂? inside ∷ q = Dec.map out⊂in-⇔ (p ⊆? q) inside ∷ p ⊂? outside ∷ q = no (λ {(p⊆q , _) → case (p⊆q here) of λ ()}) inside ∷ p ⊂? inside ∷ q = Dec.map in⊂in-⇔ (p ⊂? q) module _ (n : ℕ) where ⊂-isStrictPartialOrder : IsStrictPartialOrder _≡_ (_⊂_ {n}) ⊂-isStrictPartialOrder = record { isEquivalence = isEquivalence ; irrefl = ⊂-irref ; trans = ⊂-trans ; <-resp-≈ = (λ {refl → id}) , (λ {refl → id}) } ⊂-strictPartialOrder : StrictPartialOrder _ _ _ ⊂-strictPartialOrder = record { isStrictPartialOrder = ⊂-isStrictPartialOrder } ⊂-isDecStrictPartialOrder : IsDecStrictPartialOrder _≡_ (_⊂_ {n}) ⊂-isDecStrictPartialOrder = record { isStrictPartialOrder = ⊂-isStrictPartialOrder ; _≟_ = ≡-dec _≟_ ; _<?_ = _⊂?_ } ⊂-decStrictPartialOrder : DecStrictPartialOrder _ _ _ ⊂-decStrictPartialOrder = record { isDecStrictPartialOrder = ⊂-isDecStrictPartialOrder } p⊂q⇒∣p∣<∣q∣ : ∀ {n} → {p q : Subset n} → p ⊂ q → ∣ p ∣ < ∣ q ∣ p⊂q⇒∣p∣<∣q∣ {p = outside ∷ p} {outside ∷ q} op⊂oq@(_ , _ , _ , _) = p⊂q⇒∣p∣<∣q∣ (drop-∷-⊂ op⊂oq) p⊂q⇒∣p∣<∣q∣ {p = outside ∷ p} {inside ∷ q} (op⊆iq , _ , _ , _) = s≤s (p⊆q⇒∣p∣≤∣q∣ (drop-∷-⊆ op⊆iq)) p⊂q⇒∣p∣<∣q∣ {p = inside ∷ p} {outside ∷ q} (ip⊆oq , _ , _ , _) = contradiction (ip⊆oq here) (λ ()) p⊂q⇒∣p∣<∣q∣ {p = inside ∷ p} {inside ∷ q} (_ , zero , _ , x∉ip) = contradiction here x∉ip p⊂q⇒∣p∣<∣q∣ {p = inside ∷ p} {inside ∷ q} ip⊂iq@(_ , suc x , _ , _) = s≤s (p⊂q⇒∣p∣<∣q∣ (drop-∷-⊂ ip⊂iq)) ------------------------------------------------------------------------ -- ∁ x∈p⇒x∉∁p : ∀ {n x} {p : Subset n} → x ∈ p → x ∉ ∁ p x∈p⇒x∉∁p (there x∈p) (there x∈∁p) = x∈p⇒x∉∁p x∈p x∈∁p x∈∁p⇒x∉p : ∀ {n x} {p : Subset n} → x ∈ ∁ p → x ∉ p x∈∁p⇒x∉p (there x∈∁p) (there x∈p) = x∈∁p⇒x∉p x∈∁p x∈p x∉∁p⇒x∈p : ∀ {n x} {p : Subset n} → x ∉ ∁ p → x ∈ p x∉∁p⇒x∈p {x = zero} {outside ∷ p} x∉∁p = contradiction here x∉∁p x∉∁p⇒x∈p {x = zero} {inside ∷ p} x∉∁p = here x∉∁p⇒x∈p {x = suc x} {_ ∷ p} x∉∁p = there (x∉∁p⇒x∈p (x∉∁p ∘ there)) x∉p⇒x∈∁p : ∀ {n x} {p : Subset n} → x ∉ p → x ∈ ∁ p x∉p⇒x∈∁p {x = zero} {outside ∷ p} x∉p = here x∉p⇒x∈∁p {x = zero} {inside ∷ p} x∉p = contradiction here x∉p x∉p⇒x∈∁p {x = suc x} {_ ∷ p} x∉p = there (x∉p⇒x∈∁p (x∉p ∘ there)) p∪∁p≡⊤ : ∀ {n} (p : Subset n) → p ∪ ∁ p ≡ ⊤ p∪∁p≡⊤ [] = refl p∪∁p≡⊤ (outside ∷ p) = cong (inside ∷_) (p∪∁p≡⊤ p) p∪∁p≡⊤ (inside ∷ p) = cong (inside ∷_) (p∪∁p≡⊤ p) ∣∁p∣≡n∸∣p∣ : ∀ {n} (p : Subset n) → ∣ ∁ p ∣ ≡ n ∸ ∣ p ∣ ∣∁p∣≡n∸∣p∣ [] = refl ∣∁p∣≡n∸∣p∣ (inside ∷ p) = ∣∁p∣≡n∸∣p∣ p ∣∁p∣≡n∸∣p∣ (outside ∷ p) = begin suc ∣ ∁ p ∣ ≡⟨ cong suc (∣∁p∣≡n∸∣p∣ p) ⟩ suc (_ ∸ ∣ p ∣) ≡⟨ sym (ℕₚ.+-∸-assoc 1 (∣p∣≤n p)) ⟩ suc _ ∸ ∣ p ∣ ∎ where open ≡-Reasoning ------------------------------------------------------------------------ -- _∩_ module _ {n : ℕ} where open AlgebraicDefinitions {A = Subset n} _≡_ ∩-assoc : Associative _∩_ ∩-assoc = zipWith-assoc ∧-assoc ∩-comm : Commutative _∩_ ∩-comm = zipWith-comm ∧-comm ∩-idem : Idempotent _∩_ ∩-idem = zipWith-idem ∧-idem ∩-identityˡ : LeftIdentity ⊤ _∩_ ∩-identityˡ = zipWith-identityˡ ∧-identityˡ ∩-identityʳ : RightIdentity ⊤ _∩_ ∩-identityʳ = zipWith-identityʳ ∧-identityʳ ∩-identity : Identity ⊤ _∩_ ∩-identity = ∩-identityˡ , ∩-identityʳ ∩-zeroˡ : LeftZero ⊥ _∩_ ∩-zeroˡ = zipWith-zeroˡ ∧-zeroˡ ∩-zeroʳ : RightZero ⊥ _∩_ ∩-zeroʳ = zipWith-zeroʳ ∧-zeroʳ ∩-zero : Zero ⊥ _∩_ ∩-zero = ∩-zeroˡ , ∩-zeroʳ ∩-inverseˡ : LeftInverse ⊥ ∁ _∩_ ∩-inverseˡ = zipWith-inverseˡ ∧-inverseˡ ∩-inverseʳ : RightInverse ⊥ ∁ _∩_ ∩-inverseʳ = zipWith-inverseʳ ∧-inverseʳ ∩-inverse : Inverse ⊥ ∁ _∩_ ∩-inverse = ∩-inverseˡ , ∩-inverseʳ module _ (n : ℕ) where open AlgebraicStructures {A = Subset n} _≡_ ∩-isMagma : IsMagma _∩_ ∩-isMagma = record { isEquivalence = isEquivalence ; ∙-cong = cong₂ _∩_ } ∩-magma : Magma _ _ ∩-magma = record { isMagma = ∩-isMagma } ∩-isSemigroup : IsSemigroup _∩_ ∩-isSemigroup = record { isMagma = ∩-isMagma ; assoc = ∩-assoc } ∩-semigroup : Semigroup _ _ ∩-semigroup = record { isSemigroup = ∩-isSemigroup } ∩-isBand : IsBand _∩_ ∩-isBand = record { isSemigroup = ∩-isSemigroup ; idem = ∩-idem } ∩-band : Band _ _ ∩-band = record { isBand = ∩-isBand } ∩-isSemilattice : IsSemilattice _∩_ ∩-isSemilattice = record { isBand = ∩-isBand ; comm = ∩-comm } ∩-semilattice : Semilattice _ _ ∩-semilattice = record { isSemilattice = ∩-isSemilattice } ∩-isMonoid : IsMonoid _∩_ ⊤ ∩-isMonoid = record { isSemigroup = ∩-isSemigroup ; identity = ∩-identity } ∩-monoid : Monoid _ _ ∩-monoid = record { isMonoid = ∩-isMonoid } ∩-isCommutativeMonoid : IsCommutativeMonoid _∩_ ⊤ ∩-isCommutativeMonoid = record { isMonoid = ∩-isMonoid ; comm = ∩-comm } ∩-commutativeMonoid : CommutativeMonoid _ _ ∩-commutativeMonoid = record { isCommutativeMonoid = ∩-isCommutativeMonoid } ∩-isIdempotentCommutativeMonoid : IsIdempotentCommutativeMonoid _∩_ ⊤ ∩-isIdempotentCommutativeMonoid = record { isCommutativeMonoid = ∩-isCommutativeMonoid ; idem = ∩-idem } ∩-idempotentCommutativeMonoid : IdempotentCommutativeMonoid _ _ ∩-idempotentCommutativeMonoid = record { isIdempotentCommutativeMonoid = ∩-isIdempotentCommutativeMonoid } p∩q⊆p : ∀ {n} (p q : Subset n) → p ∩ q ⊆ p p∩q⊆p [] [] x∈p∩q = x∈p∩q p∩q⊆p (inside ∷ p) (inside ∷ q) here = here p∩q⊆p (inside ∷ p) (_ ∷ q) (there ∈p∩q) = there (p∩q⊆p p q ∈p∩q) p∩q⊆p (outside ∷ p) (_ ∷ q) (there ∈p∩q) = there (p∩q⊆p p q ∈p∩q) p∩q⊆q : ∀ {n} (p q : Subset n) → p ∩ q ⊆ q p∩q⊆q p q rewrite ∩-comm p q = p∩q⊆p q p x∈p∩q⁺ : ∀ {n} {p q : Subset n} {x} → x ∈ p × x ∈ q → x ∈ p ∩ q x∈p∩q⁺ (here , here) = here x∈p∩q⁺ (there x∈p , there x∈q) = there (x∈p∩q⁺ (x∈p , x∈q)) x∈p∩q⁻ : ∀ {n} (p q : Subset n) {x} → x ∈ p ∩ q → x ∈ p × x ∈ q x∈p∩q⁻ (inside ∷ p) (inside ∷ q) here = here , here x∈p∩q⁻ (s ∷ p) (t ∷ q) (there x∈p∩q) = Product.map there there (x∈p∩q⁻ p q x∈p∩q) ∩⇔× : ∀ {n} {p q : Subset n} {x} → x ∈ p ∩ q ⇔ (x ∈ p × x ∈ q) ∩⇔× = equivalence (x∈p∩q⁻ _ _) x∈p∩q⁺ module _ {n} (p q : Subset n) where ∣p∩q∣≤∣p∣ : ∣ p ∩ q ∣ ≤ ∣ p ∣ ∣p∩q∣≤∣p∣ = p⊆q⇒∣p∣≤∣q∣ (p∩q⊆p p q) ∣p∩q∣≤∣q∣ : ∣ p ∩ q ∣ ≤ ∣ q ∣ ∣p∩q∣≤∣q∣ = p⊆q⇒∣p∣≤∣q∣ (p∩q⊆q p q) ∣p∩q∣≤∣p∣⊓∣q∣ : ∣ p ∩ q ∣ ≤ ∣ p ∣ ⊓ ∣ q ∣ ∣p∩q∣≤∣p∣⊓∣q∣ = ℕₚ.⊓-pres-m≤ ∣p∩q∣≤∣p∣ ∣p∩q∣≤∣q∣ ------------------------------------------------------------------------ -- _∪_ module _ {n : ℕ} where open AlgebraicDefinitions {A = Subset n} _≡_ ∪-assoc : Associative _∪_ ∪-assoc = zipWith-assoc ∨-assoc ∪-comm : Commutative _∪_ ∪-comm = zipWith-comm ∨-comm ∪-idem : Idempotent _∪_ ∪-idem = zipWith-idem ∨-idem ∪-identityˡ : LeftIdentity ⊥ _∪_ ∪-identityˡ = zipWith-identityˡ ∨-identityˡ ∪-identityʳ : RightIdentity ⊥ _∪_ ∪-identityʳ = zipWith-identityʳ ∨-identityʳ ∪-identity : Identity ⊥ _∪_ ∪-identity = ∪-identityˡ , ∪-identityʳ ∪-zeroˡ : LeftZero ⊤ _∪_ ∪-zeroˡ = zipWith-zeroˡ ∨-zeroˡ ∪-zeroʳ : RightZero ⊤ _∪_ ∪-zeroʳ = zipWith-zeroʳ ∨-zeroʳ ∪-zero : Zero ⊤ _∪_ ∪-zero = ∪-zeroˡ , ∪-zeroʳ ∪-inverseˡ : LeftInverse ⊤ ∁ _∪_ ∪-inverseˡ = zipWith-inverseˡ ∨-inverseˡ ∪-inverseʳ : RightInverse ⊤ ∁ _∪_ ∪-inverseʳ = zipWith-inverseʳ ∨-inverseʳ ∪-inverse : Inverse ⊤ ∁ _∪_ ∪-inverse = ∪-inverseˡ , ∪-inverseʳ ∪-distribˡ-∩ : _∪_ DistributesOverˡ _∩_ ∪-distribˡ-∩ = zipWith-distribˡ ∨-distribˡ-∧ ∪-distribʳ-∩ : _∪_ DistributesOverʳ _∩_ ∪-distribʳ-∩ = zipWith-distribʳ ∨-distribʳ-∧ ∪-distrib-∩ : _∪_ DistributesOver _∩_ ∪-distrib-∩ = ∪-distribˡ-∩ , ∪-distribʳ-∩ ∩-distribˡ-∪ : _∩_ DistributesOverˡ _∪_ ∩-distribˡ-∪ = zipWith-distribˡ ∧-distribˡ-∨ ∩-distribʳ-∪ : _∩_ DistributesOverʳ _∪_ ∩-distribʳ-∪ = zipWith-distribʳ ∧-distribʳ-∨ ∩-distrib-∪ : _∩_ DistributesOver _∪_ ∩-distrib-∪ = ∩-distribˡ-∪ , ∩-distribʳ-∪ ∪-abs-∩ : _∪_ Absorbs _∩_ ∪-abs-∩ = zipWith-absorbs ∨-abs-∧ ∩-abs-∪ : _∩_ Absorbs _∪_ ∩-abs-∪ = zipWith-absorbs ∧-abs-∨ module _ (n : ℕ) where open AlgebraicStructures {A = Subset n} _≡_ ∪-isMagma : IsMagma _∪_ ∪-isMagma = record { isEquivalence = isEquivalence ; ∙-cong = cong₂ _∪_ } ∪-magma : Magma _ _ ∪-magma = record { isMagma = ∪-isMagma } ∪-isSemigroup : IsSemigroup _∪_ ∪-isSemigroup = record { isMagma = ∪-isMagma ; assoc = ∪-assoc } ∪-semigroup : Semigroup _ _ ∪-semigroup = record { isSemigroup = ∪-isSemigroup } ∪-isBand : IsBand _∪_ ∪-isBand = record { isSemigroup = ∪-isSemigroup ; idem = ∪-idem } ∪-band : Band _ _ ∪-band = record { isBand = ∪-isBand } ∪-isSemilattice : IsSemilattice _∪_ ∪-isSemilattice = record { isBand = ∪-isBand ; comm = ∪-comm } ∪-semilattice : Semilattice _ _ ∪-semilattice = record { isSemilattice = ∪-isSemilattice } ∪-isMonoid : IsMonoid _∪_ ⊥ ∪-isMonoid = record { isSemigroup = ∪-isSemigroup ; identity = ∪-identity } ∪-monoid : Monoid _ _ ∪-monoid = record { isMonoid = ∪-isMonoid } ∪-isCommutativeMonoid : IsCommutativeMonoid _∪_ ⊥ ∪-isCommutativeMonoid = record { isMonoid = ∪-isMonoid ; comm = ∪-comm } ∪-commutativeMonoid : CommutativeMonoid _ _ ∪-commutativeMonoid = record { isCommutativeMonoid = ∪-isCommutativeMonoid } ∪-isIdempotentCommutativeMonoid : IsIdempotentCommutativeMonoid _∪_ ⊥ ∪-isIdempotentCommutativeMonoid = record { isCommutativeMonoid = ∪-isCommutativeMonoid ; idem = ∪-idem } ∪-idempotentCommutativeMonoid : IdempotentCommutativeMonoid _ _ ∪-idempotentCommutativeMonoid = record { isIdempotentCommutativeMonoid = ∪-isIdempotentCommutativeMonoid } ∪-∩-isLattice : IsLattice _∪_ _∩_ ∪-∩-isLattice = record { isEquivalence = isEquivalence ; ∨-comm = ∪-comm ; ∨-assoc = ∪-assoc ; ∨-cong = cong₂ _∪_ ; ∧-comm = ∩-comm ; ∧-assoc = ∩-assoc ; ∧-cong = cong₂ _∩_ ; absorptive = ∪-abs-∩ , ∩-abs-∪ } ∪-∩-lattice : Lattice _ _ ∪-∩-lattice = record { isLattice = ∪-∩-isLattice } ∪-∩-isDistributiveLattice : IsDistributiveLattice _∪_ _∩_ ∪-∩-isDistributiveLattice = record { isLattice = ∪-∩-isLattice ; ∨-distribʳ-∧ = ∪-distribʳ-∩ } ∪-∩-distributiveLattice : DistributiveLattice _ _ ∪-∩-distributiveLattice = record { isDistributiveLattice = ∪-∩-isDistributiveLattice } ∪-∩-isBooleanAlgebra : IsBooleanAlgebra _∪_ _∩_ ∁ ⊤ ⊥ ∪-∩-isBooleanAlgebra = record { isDistributiveLattice = ∪-∩-isDistributiveLattice ; ∨-complementʳ = ∪-inverseʳ ; ∧-complementʳ = ∩-inverseʳ ; ¬-cong = cong ∁ } ∪-∩-booleanAlgebra : BooleanAlgebra _ _ ∪-∩-booleanAlgebra = record { isBooleanAlgebra = ∪-∩-isBooleanAlgebra } ∩-∪-isLattice : IsLattice _∩_ _∪_ ∩-∪-isLattice = L.∧-∨-isLattice ∪-∩-lattice ∩-∪-lattice : Lattice _ _ ∩-∪-lattice = L.∧-∨-lattice ∪-∩-lattice ∩-∪-isDistributiveLattice : IsDistributiveLattice _∩_ _∪_ ∩-∪-isDistributiveLattice = DL.∧-∨-isDistributiveLattice ∪-∩-distributiveLattice ∩-∪-distributiveLattice : DistributiveLattice _ _ ∩-∪-distributiveLattice = DL.∧-∨-distributiveLattice ∪-∩-distributiveLattice ∩-∪-isBooleanAlgebra : IsBooleanAlgebra _∩_ _∪_ ∁ ⊥ ⊤ ∩-∪-isBooleanAlgebra = BA.∧-∨-isBooleanAlgebra ∪-∩-booleanAlgebra ∩-∪-booleanAlgebra : BooleanAlgebra _ _ ∩-∪-booleanAlgebra = BA.∧-∨-booleanAlgebra ∪-∩-booleanAlgebra p⊆p∪q : ∀ {n p} (q : Subset n) → p ⊆ p ∪ q p⊆p∪q (s ∷ q) here = here p⊆p∪q (s ∷ q) (there x∈p) = there (p⊆p∪q q x∈p) q⊆p∪q : ∀ {n} (p q : Subset n) → q ⊆ p ∪ q q⊆p∪q p q rewrite ∪-comm p q = p⊆p∪q p x∈p∪q⁻ : ∀ {n} (p q : Subset n) {x} → x ∈ p ∪ q → x ∈ p ⊎ x ∈ q x∈p∪q⁻ (inside ∷ p) (t ∷ q) here = inj₁ here x∈p∪q⁻ (outside ∷ p) (inside ∷ q) here = inj₂ here x∈p∪q⁻ (s ∷ p) (t ∷ q) (there x∈p∪q) = Sum.map there there (x∈p∪q⁻ p q x∈p∪q) x∈p∪q⁺ : ∀ {n} {p q : Subset n} {x} → x ∈ p ⊎ x ∈ q → x ∈ p ∪ q x∈p∪q⁺ (inj₁ x∈p) = p⊆p∪q _ x∈p x∈p∪q⁺ (inj₂ x∈q) = q⊆p∪q _ _ x∈q ∪⇔⊎ : ∀ {n} {p q : Subset n} {x} → x ∈ p ∪ q ⇔ (x ∈ p ⊎ x ∈ q) ∪⇔⊎ = equivalence (x∈p∪q⁻ _ _) x∈p∪q⁺ module _ {n} (p q : Subset n) where ∣p∣≤∣p∪q∣ : ∣ p ∣ ≤ ∣ p ∪ q ∣ ∣p∣≤∣p∪q∣ = p⊆q⇒∣p∣≤∣q∣ (p⊆p∪q {p = p} q) ∣q∣≤∣p∪q∣ : ∣ q ∣ ≤ ∣ p ∪ q ∣ ∣q∣≤∣p∪q∣ = p⊆q⇒∣p∣≤∣q∣ (q⊆p∪q p q) ∣p∣⊔∣q∣≤∣p∪q∣ : ∣ p ∣ ⊔ ∣ q ∣ ≤ ∣ p ∪ q ∣ ∣p∣⊔∣q∣≤∣p∪q∣ = ℕₚ.⊔-pres-≤m ∣p∣≤∣p∪q∣ ∣q∣≤∣p∪q∣ ------------------------------------------------------------------------ -- Lift Lift? : ∀ {n p} {P : Pred (Fin n) p} → Decidable P → Decidable (Lift P) Lift? P? p = decFinSubset (_∈? p) (λ {x} _ → P? x) ------------------------------------------------------------------------ -- Other module _ {p} {P : Pred (Subset zero) p} where ∃-Subset-zero : ∃⟨ P ⟩ → P [] ∃-Subset-zero ([] , P[]) = P[] ∃-Subset-[]-⇔ : P [] ⇔ ∃⟨ P ⟩ ∃-Subset-[]-⇔ = equivalence ([] ,_) ∃-Subset-zero module _ {p n} {P : Pred (Subset (suc n)) p} where ∃-Subset-suc : ∃⟨ P ⟩ → ∃⟨ P ∘ (inside ∷_) ⟩ ⊎ ∃⟨ P ∘ (outside ∷_) ⟩ ∃-Subset-suc (outside ∷ p , Pop) = inj₂ (p , Pop) ∃-Subset-suc ( inside ∷ p , Pip) = inj₁ (p , Pip) ∃-Subset-∷-⇔ : (∃⟨ P ∘ (inside ∷_) ⟩ ⊎ ∃⟨ P ∘ (outside ∷_) ⟩) ⇔ ∃⟨ P ⟩ ∃-Subset-∷-⇔ = equivalence [ Product.map _ id , Product.map _ id ]′ ∃-Subset-suc anySubset? : ∀ {p n} {P : Pred (Subset n) p} → Decidable P → Dec ∃⟨ P ⟩ anySubset? {n = zero} P? = Dec.map ∃-Subset-[]-⇔ (P? []) anySubset? {n = suc n} P? = Dec.map ∃-Subset-∷-⇔ (anySubset? (P? ∘ ( inside ∷_)) ⊎-dec anySubset? (P? ∘ (outside ∷_))) ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 1.3 p⊆q⇒∣p∣<∣q∣ = p⊆q⇒∣p∣≤∣q∣ {-# WARNING_ON_USAGE p⊆q⇒∣p∣<∣q∣ "Warning: p⊆q⇒∣p∣<∣q∣ was deprecated in v1.3. Please use p⊆q⇒∣p∣≤∣q∣ instead." #-}
{ "alphanum_fraction": 0.4992130673, "avg_line_length": 29.7582278481, "ext": "agda", "hexsha": "b0aa39503600fb179c6a008547b906e5b81f84a0", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/Fin/Subset/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/Data/Fin/Subset/Properties.agda", "max_line_length": 113, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Fin/Subset/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": 12260, "size": 23509 }
{-# OPTIONS --universe-polymorphism #-} module tests.Literals where open import Prelude.Nat open import Prelude.Float open import Prelude.Char open import Prelude.String open import Prelude.Unit open import Prelude.IO afloat : Float afloat = 1.23 astring : String astring = "abc" achar : Char achar = 'd' anat : Nat anat = 123 main : IO Unit main = printFloat afloat ,, putStr astring ,, printChar achar ,, printNat anat ,, putStrLn ""
{ "alphanum_fraction": 0.6950959488, "avg_line_length": 15.6333333333, "ext": "agda", "hexsha": "f84a10756e59fcb3dda4a64571e5b1bf3e308be4", "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/epic/tests/Literals.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/epic/tests/Literals.agda", "max_line_length": 39, "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/epic/tests/Literals.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": 137, "size": 469 }
import Lvl module Structure.Category {ℓₒ ℓₘ ℓₑ : Lvl.Level} where open import Functional using (swap) open import Logic open import Logic.Propositional import Structure.Categorical.Names as Names open import Structure.Categorical.Properties open import Structure.Semicategory{ℓₒ}{ℓₘ}{ℓₑ} open import Structure.Operator import Structure.Relator.Names as Names open import Structure.Relator.Properties open import Structure.Setoid open import Type -- Obj is the collection of objects. -- _⟶_ is the collection of morphisms. module _ {Obj : Type{ℓₒ}} (_⟶_ : Obj → Obj → Type{ℓₘ}) ⦃ morphism-equiv : ∀{x y} → Equiv{ℓₑ}(x ⟶ y) ⦄ where -- A category is a structure on a relation called a morphism. -- -- It can be seen as a generalization of the structure in functions between a collection of types/sets. -- More specifically, the algebraic properties of functions regarding composition and the identity function. -- In this case, sets are objects and functions are morphisms. -- See `Type.Category`. -- -- It can also be seen as a generalized algebraic structure, or more specifically a generalization of monoids. -- The type of a monoid's operator is usually restricted to a single type, but a category allows it to vary (depending on the rules of morphism instead). -- (One can loosely call a category to be a monoid without the "closed" property of algebraic structures). -- In this case, the binary operation is (_∘_) and the laws are the usual identity and associative laws. -- See `Structure.Category.Monoid`. -- -- A category can also be constructed by letting objects be the models of algebraic structures, and morphisms the homomorphisms of the respective algebraic structure. -- -- In the case of categories being the objects in a category, functors are homomorphisms, and therefore also the morphisms. -- See `Structure.Category.Category`. -- -- An alternative interpretation of the definition: -- A type (Obj) and a binary relation (Morphism) on this type is a category when: -- • The relator is transitive. -- • The relator is reflexive. -- • The reflexivity proof inside the transitivity proof does not result in a new proof. -- • Chains of the transitivity proofs can be applied in any order and the resulting proof will be the same. -- See `Relator.Equals.Category` for an example of this kind of binary relation. -- -- A more concrete interpretation of the binary relation one is that a category describes a graph. -- Vertices are objects and morphisms are paths between the vertices. -- The operator joins two paths into one, and the identity is a loop (the empty path). -- See `Graph.Category`. -- -- A category is the common pattern seen in all the examples above. record Category : Stmt{ℓₒ Lvl.⊔ ℓₘ Lvl.⊔ ℓₑ} where field -- Existence of morphisms constructed by connecting two morphisms (The composition of two morphisms). -- Existence of a binary operator on morphisms connecting the ends of two morphisms. -- Also a proof of transitivity for the binary relator (_⟶_). -- Note that this is the operator like the operators in other algebraic structures with binary operators -- ∀{x y z : Obj} → (y ⟶ z) → (x ⟶ y) → (x ⟶ z) _∘_ : Names.SwappedTransitivity(_⟶_) -- Existence of a morphism connected to itself (The identity morphism). -- Also a proof of reflexivity for the binary relator (_⟶_). -- ∀{x : Obj} → (x ⟶ x) id : Names.Reflexivity(_⟶_) infixr 20 _∘_ field -- The binary operator respects the equivalence relation. ⦃ binaryOperator ⦄ : ∀{x y z} → BinaryOperator(_∘_ {x}{y}{z}) -- The binary operator on mophisms is associative. -- Or, the order of applying two transitivies on three proofs does not matter. It is the same proof. -- ∀{x y z w : Obj}{f : y ⟶ x}{g : z ⟶ y}{h : w ⟶ z} → ((f ∘ g) ∘ h ≡ f ∘ (g ∘ h)) ⦃ associativity ⦄ : Morphism.Associativity(\{x} → _∘_ {x}) -- The morphism `id` behaves like aa identity element with respect to the binary operator. -- Or, applying the proof of reflexivity on transitivity is an identity function for proofs. ⦃ identity ⦄ : Morphism.Identity(_∘_)(\{x} → id{x}) instance identityₗ : Morphism.Identityₗ(_∘_)(\{x} → id{x}) identityₗ = [∧]-elimₗ identity instance identityᵣ : Morphism.Identityᵣ(_∘_)(\{x} → id{x}) identityᵣ = [∧]-elimᵣ identity -- As stated in `id`, this can be interpreted as proof of reflexivity when `Morphism` is interpreted as a binary relation. morphism-reflexivity : Reflexivity(_⟶_) morphism-reflexivity = intro id semicategory : Semicategory(_⟶_) Semicategory._∘_ semicategory = _∘_ Semicategory.binaryOperator semicategory = binaryOperator Semicategory.associativity semicategory = associativity open Semicategory(semicategory) hiding (_∘_ ; binaryOperator ; associativity) public -- A category object can be used when one refers to a category as an object. -- Examples of usage are in functors (morphism between categories) or in equivalences of categories. record CategoryObject : Stmt{Lvl.𝐒(ℓₒ Lvl.⊔ ℓₘ Lvl.⊔ ℓₑ)} where constructor intro field {Object} : Type{ℓₒ} {Morphism} : Object → Object → Type{ℓₘ} ⦃ morphism-equiv ⦄ : ∀{x y} → Equiv{ℓₑ}(Morphism x y) category : Category(Morphism) instance category-instance = category
{ "alphanum_fraction": 0.6995064888, "avg_line_length": 47.1637931034, "ext": "agda", "hexsha": "9588bfaa0788917bd42f369a8a2b81bf155843f7", "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/Category.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Category.agda", "max_line_length": 168, "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/Category.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 1503, "size": 5471 }
{-# OPTIONS --without-K --rewriting #-} module PropT where open import Base open import lib.Basics open import lib.types.Sigma open import lib.NType2 open import lib.types.Truncation open import lib.types.Lift _is-contractible : {i : ULevel} (A : Type i) → Type i _is-contractible = is-contr ⊤-is-contr : ⊤ is-contractible ⊤-is-contr = has-level-in (unit , (λ {unit → refl})) contr-≃-⊤ : {i : ULevel} {A : Type i} (c : A is-contractible) → A ≃ ⊤ contr-≃-⊤ {A = A} c = equiv (λ _ → unit) (λ { unit → contr-center c }) (λ {unit → refl}) (λ a → contr-path c a) _is-a-prop : ∀ {i} → (A : Type i) → Type i A is-a-prop = is-prop A PropT : (i : ULevel) → Type _ PropT = hProp PropT₀ = hProp₀ _holds : ∀ {i} (P : PropT i) → Type i _holds = fst _holds-is-a-prop : {i : ULevel} (P : PropT i) → (P holds) is-a-prop _holds-is-a-prop = snd ∥_∥ : ∀ {i} (A : Type i) → Type i ∥_∥ = Trunc -1 True : PropT₀ True = ⊤ , contr-is-prop ⊤-is-contr False : PropT₀ False = ⊥ , has-level-in (λ x → quodlibet x) _And_ : ∀ {i j} → (A : Type i) (B : Type j) → Type (lmax i j) A And B = Σ A (λ _ → B) _And→_ : ∀ {i j k l} {A : Type i} {B : Type j} {C : Type k} {D : Type l} (f : A → C) (g : B → D) → (A And B) → (C And D) f And→ g = λ { (a , b) → f a , g b } infixl 30 _∧_ _∧_ : ∀ {i j} (P : PropT i) (Q : PropT j) → PropT (lmax i j) P ∧ Q = ((P holds) And (Q holds)) , Σ-level (P holds-is-a-prop) (λ _ → Q holds-is-a-prop) infixl 35 _∨_ _∨_ : ∀ {i j} (P : PropT i) (Q : PropT j) → PropT (lmax i j) P ∨ Q = ∥ (P holds) ⊔ (Q holds) ∥ , ⟨⟩ mapping-into-prop-is-a-prop : {i j : ULevel} {A : Type i} {P : A → Type j} (f : (a : A) → ((P a) is-a-prop)) → ((a : A) → P a) is-a-prop mapping-into-prop-is-a-prop f = all-paths-is-prop (λ x y → λ= (λ a → prop-path (f a) (x a) (y a))) _⇒_ : ∀ {i j} (P : PropT i) (Q : PropT j) → PropT (lmax i j) P ⇒ Q = (P holds → Q holds) , mapping-into-prop-is-a-prop (λ _ → Q holds-is-a-prop) not : ∀ {i} (P : PropT i) → PropT i not P = P ⇒ False {- To say ``There exists an a : A such that B a", write ∃ (λ (a : A) → B a) -} ∃ : {i j : ULevel} {A : Type i} (B : A → Type j) → PropT (lmax i j) ∃ {_} {_} {A} B = ∥ (Σ A B) ∥ , ⟨⟩ ∃ₚ : ∀ {i j} {A : Type i} (B : A → PropT j) → PropT (lmax i j) ∃ₚ {A = A} B = ∃ λ (a : A) → (B a) holds ∀ₚ : ∀ {i j} {A : Type i} (P : A → PropT j) → PropT (lmax i j) ∀ₚ P = (∀ a → (P a) holds) , mapping-into-prop-is-a-prop (λ a → (P a) holds-is-a-prop) _holds-implies-dec-eq : {i : ULevel} (P : PropT i) → P holds → (P holds) ≃ (Dec (P holds)) (P holds-implies-dec-eq) p = equiv (λ _ → inl p) ((λ { (inl q) → q ; (inr nq) → quodlibet (nq p) })) (λ { (inl q) → ap inl (prop-path (P holds-is-a-prop) p q) ; (inr nq) → quodlibet (nq p) }) (λ q → prop-path (P holds-is-a-prop) p q) _holds-by_implies-=-True : (P : PropT₀) (p : P holds) → P == True (P , q) holds-by p implies-=-True = pair= left-id right-id where left-id : P == ⊤ left-id = (ua {A = P} {B = True holds} (contr-≃-⊤ {A = P} (inhab-prop-is-contr p {{q}}))) right-id : q == (snd True) [ _is-a-prop ↓ left-id ] right-id = from-transp _is-a-prop left-id (prop-path (has-level-is-prop) (transport _is-a-prop left-id q) (snd True) ) ¬-_holds-by_implies-=-False : (P : PropT₀) (p : ¬ (P holds)) → P == False ¬- (P , q) holds-by np implies-=-False = pair= left-id right-id where left-id : P == ⊥ left-id = ua {A = P} {B = False holds} e where e : P ≃ ⊥ e = equiv np (λ ()) (λ ()) (λ p → quodlibet (np p)) right-id : q == (snd False) [ _is-a-prop ↓ left-id ] right-id = from-transp _is-a-prop left-id (prop-path (has-level-is-prop) (transport _is-a-prop left-id q) (snd False)) iff-to-≃ : ∀ {i j} {P : PropT i} {Q : PropT j} → (P holds → Q holds) → (Q holds → P holds) → (P holds) ≃ (Q holds) iff-to-≃ {P = P} {Q = Q} f g = equiv f g (λ b → prop-path (snd Q) (f (g b)) b) (λ a → prop-path (snd P) (g (f a)) a) -- Propositional Resizing lift-prop : {i j : ULevel} → PropT i → PropT (lmax i j) lift-prop {i} {j} (P , q) = (Lift {i} {j} P) , Lift-level q postulate prop-resize : {i j : ULevel} → (lift-prop {i} {j}) is-an-equiv resize-eq : {i j : ULevel} → PropT i ≃ PropT (lmax i j) resize-eq {i} {j} = (lift-prop {i} {j}) , prop-resize resize₀ : {i : ULevel} → PropT i → PropT₀ resize₀ {i} = <– (resize-eq {lzero} {i}) unresize₀ : {i : ULevel} → PropT₀ → PropT i unresize₀ {i} = –> (resize-eq {lzero} {i})
{ "alphanum_fraction": 0.4693554765, "avg_line_length": 33.9463087248, "ext": "agda", "hexsha": "2164635d8061220e378978ad5cc96e63c0df56ef", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "glangmead/formalization", "max_forks_repo_path": "cohesion/david_jaz_261/PropT.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "glangmead/formalization", "max_issues_repo_path": "cohesion/david_jaz_261/PropT.agda", "max_line_length": 98, "max_stars_count": 6, "max_stars_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "glangmead/formalization", "max_stars_repo_path": "cohesion/david_jaz_261/PropT.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-13T05:51:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-06T17:39:22.000Z", "num_tokens": 1965, "size": 5058 }
{-# OPTIONS --safe --warning=error --without-K --guardedness #-} open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import LogicalFormulae open import Setoids.Subset open import Setoids.Setoids open import Setoids.Orders.Partial.Definition open import Setoids.Orders.Total.Definition open import Sets.EquivalenceRelations open import Rings.Orders.Total.Definition open import Rings.Orders.Partial.Definition open import Rings.Definition open import Fields.Fields open import Groups.Definition open import Sequences open import Numbers.Naturals.Semiring open import Numbers.Naturals.Order open import Semirings.Definition open import Functions.Definition open import Fields.Orders.Total.Definition open import Numbers.Primes.PrimeNumbers module Fields.Orders.Limits.Lemmas {a b c : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} {_*_ : A → A → A} {_<_ : Rel {_} {c} A} {R : Ring S _+_ _*_} {pOrder : SetoidPartialOrder S _<_} {F : Field R} {pRing : PartiallyOrderedRing R pOrder} (oF : TotallyOrderedField F pRing) where open Ring R open TotallyOrderedField oF open TotallyOrderedRing oRing open PartiallyOrderedRing pRing open import Rings.Orders.Total.Lemmas oRing open import Rings.Orders.Total.AbsoluteValue oRing open import Rings.Orders.Partial.Lemmas pRing open SetoidTotalOrder total open SetoidPartialOrder pOrder open Group additiveGroup open import Groups.Lemmas additiveGroup open Setoid S open Equivalence eq open Field F open import Fields.CauchyCompletion.Definition (TotallyOrderedField.oRing oF) F open import Fields.Orders.Limits.Definition oF open import Fields.Lemmas F open import Fields.Orders.Total.Lemmas oF open import Rings.Characteristic R open import Rings.InitialRing R open import Rings.Orders.Total.Cauchy oRing private 2!=3 : 2 ≡ 3 → False 2!=3 () convergentSequenceCauchy : (nontrivial : 0R ∼ 1R → False) → {a : Sequence A} → {r : A} → a ~> r → cauchy a convergentSequenceCauchy _ {a} {r} a->r e 0<e with halve (λ i → charNotN 1 (transitive (transitive +Associative identRight) i)) e ... | e/2 , prE/2 with a->r e/2 (halvePositive' prE/2 0<e) ... | N , pr = N , λ {m} {n} → ans m n where ans : (m n : ℕ) → N <N m → N <N n → abs (index a m + inverse (index a n)) < e ans m n N<m N<n = <WellDefined reflexive prE/2 (bothNearImpliesNear {r} e/2 (halvePositive' prE/2 0<e) (pr m N<m) (pr n N<n))
{ "alphanum_fraction": 0.7485207101, "avg_line_length": 40.1016949153, "ext": "agda", "hexsha": "d9d78ec1bde0d4849e0a2a33fd9dfc3043248269", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Fields/Orders/Limits/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": "Fields/Orders/Limits/Lemmas.agda", "max_line_length": 291, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Fields/Orders/Limits/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": 734, "size": 2366 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.ZCohomology.RingStructure.CohomologyRingFun where {- There is two definitionof the Cohomology Ring. We recommend to use the HIT definition (the other one) as the ring product is eaiser to handle. Nevertheless the equality is harder to handle so this definition can interessting too. -} open import Cubical.Foundations.Prelude open import Cubical.Relation.Nullary open import Cubical.Data.Empty as ⊥ open import Cubical.Data.Nat renaming (_+_ to _+ℕ_) open import Cubical.Data.Nat.Order open import Cubical.Data.Sigma open import Cubical.Algebra.Monoid open import Cubical.Algebra.Ring open import Cubical.Algebra.GradedRing.DirectSumFun open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.GroupStructure open import Cubical.ZCohomology.RingStructure.CupProduct open import Cubical.ZCohomology.RingStructure.RingLaws open import Cubical.ZCohomology.RingStructure.GradedCommutativity private variable ℓ ℓ' : Level open PlusBis module _ (A : Type ℓ) where H*FunR : Ring ℓ H*FunR = ⊕FunGradedRing-Ring _+'_ (makeIsMonoid isSetℕ +'-assoc +'-rid +'-lid) +'≡+ (λ k → coHom k A) (λ k → snd (coHomGroup k A)) 1⌣ _⌣_ (λ {k} {l} → 0ₕ-⌣ k l) (λ {k} {l} → ⌣-0ₕ k l) (λ _ _ _ → sym (ΣPathTransport→PathΣ _ _ ((sym (+'-assoc _ _ _)) , (sym (assoc-⌣ _ _ _ _ _ _))))) (λ _ → sym (ΣPathTransport→PathΣ _ _ (sym (+'-rid _) , sym (lUnit⌣ _ _)))) (λ _ → ΣPathTransport→PathΣ _ _ (refl , transportRefl _ ∙ rUnit⌣ _ _)) (λ _ _ _ → leftDistr-⌣ _ _ _ _ _) λ _ _ _ → rightDistr-⌣ _ _ _ _ _ H*Fun : Type ℓ H*Fun = fst H*FunR
{ "alphanum_fraction": 0.6634560907, "avg_line_length": 31.5178571429, "ext": "agda", "hexsha": "e9ed8645e174a5e142d48701c617541b90b09f7a", "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/ZCohomology/RingStructure/CohomologyRingFun.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/ZCohomology/RingStructure/CohomologyRingFun.agda", "max_line_length": 108, "max_stars_count": null, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/ZCohomology/RingStructure/CohomologyRingFun.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 586, "size": 1765 }
{-# OPTIONS --no-import-sorts #-} open import Agda.Primitive using (Prop) postulate Set₁ : Prop open import Agda.Primitive using (Set) postulate A : Set₁
{ "alphanum_fraction": 0.7037037037, "avg_line_length": 13.5, "ext": "agda", "hexsha": "5b8e7d56f288d520bf75ce3faddee8b970b85dba", "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/AmbiguousSet1b.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/AmbiguousSet1b.agda", "max_line_length": 39, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/AmbiguousSet1b.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 46, "size": 162 }
-- Andreas, 2014-10-09 -- Reported by ohmanjoakim infixr 8 _⇒_ data Ty : Set where _⇒_ : Ty → Ty → Ty ⟦_⟧ : Ty → Set ⟦ A ⇒ B ⟧ = ⟦ A ⟧ → ⟦ B ⟧ data Term : Ty → Set where K : (A B : Ty) → Term (A ⇒ B ⇒ A) test : (A : Ty) (a : Term A) → ⟦ A ⟧ test A a = {!a!} -- When doing a case split on a in foo, the following is written: -- test .(x ⇒ x₁ ⇒ x) (K A B) x x₁ = ? -- Correct is -- test .(A ⇒ B ⇒ A) (K A B) x x₁ = ?
{ "alphanum_fraction": 0.4976525822, "avg_line_length": 18.5217391304, "ext": "agda", "hexsha": "e98fdb7ecd53b2f50c674155f98db10936395669", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/interaction/Issue1298.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "test/interaction/Issue1298.agda", "max_line_length": 65, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/interaction/Issue1298.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 194, "size": 426 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category using (module Commutation) renaming (Category to Setoid-Category) open import Categories.Category.Monoidal using (Monoidal) open import Categories.Category.Monoidal.Symmetric using (Symmetric) module Categories.Enriched.Category.Opposite {o ℓ e} {V : Setoid-Category o ℓ e} {M : Monoidal V} (S : Symmetric M) where -- The dual of a V-enriched category. -- -- Note that, for this construction to work, V needs to be a -- *symmetric* monoidal category. open import Data.Product using (_,_) import Categories.Category.Monoidal.Braided.Properties as BraidedProperties open import Categories.Category.Monoidal.Reasoning M open import Categories.Category.Monoidal.Utilities M using (module Shorthands) open import Categories.Enriched.Category M using (Category) open import Categories.Morphism.Reasoning V open Setoid-Category V renaming (id to idV) using (_⇒_; _∘_; assoc) open Commutation V open Shorthands open Symmetric S open BraidedProperties (Symmetric.braided S) using (braiding-coherence) private σ = λ {A B} → braiding.⇒.η (A , B) -- The opposite of a V-enriched category. op : ∀ {v} → Category v → Category v op C = record { Obj = Obj ; hom = λ A B → hom B A ; id = id ; ⊚ = ⊚ ∘ σ ; ⊚-assoc = begin (⊚ ∘ σ) ∘ (⊚ ∘ σ) ⊗₁ idV ≈⟨ refl⟩∘⟨ split₁ʳ ⟩ (⊚ ∘ σ) ∘ ⊚ ⊗₁ idV ∘ σ ⊗₁ idV ≈⟨ extend² (braiding.⇒.commute _) ⟩ (⊚ ∘ idV ⊗₁ ⊚) ∘ σ ∘ σ ⊗₁ idV ≈⟨ ⊚-assoc′ ⟩∘⟨refl ⟩ (⊚ ∘ ⊚ ⊗₁ idV ∘ α⇐) ∘ σ ∘ σ ⊗₁ idV ≈˘⟨ assoc ⟩∘⟨refl ⟩ ((⊚ ∘ ⊚ ⊗₁ idV) ∘ α⇐) ∘ σ ∘ σ ⊗₁ idV ≈⟨ pullʳ invert-braidings ⟩ (⊚ ∘ ⊚ ⊗₁ idV) ∘ σ ∘ idV ⊗₁ σ ∘ α⇒ ≈˘⟨ refl⟩∘⟨ assoc ⟩ (⊚ ∘ ⊚ ⊗₁ idV) ∘ (σ ∘ idV ⊗₁ σ) ∘ α⇒ ≈˘⟨ pushˡ (extend² (braiding.⇒.commute _)) ⟩ ((⊚ ∘ σ) ∘ idV ⊗₁ ⊚ ∘ idV ⊗₁ σ) ∘ α⇒ ≈˘⟨ pullˡ (refl⟩∘⟨ split₂ʳ) ⟩ (⊚ ∘ σ) ∘ idV ⊗₁ (⊚ ∘ σ) ∘ α⇒ ∎ ; unitˡ = λ {A B} → begin (⊚ ∘ σ) ∘ id ⊗₁ idV ≈⟨ pullʳ (braiding.⇒.commute _) ⟩ ⊚ ∘ idV ⊗₁ id ∘ σ ≈⟨ pullˡ unitʳ ⟩ ρ⇒ ∘ σ ≈˘⟨ switch-fromtoʳ braided-iso braiding-coherence ⟩ λ⇒ ∎ ; unitʳ = begin (⊚ ∘ σ) ∘ idV ⊗₁ id ≈⟨ pullʳ (braiding.⇒.commute _) ⟩ ⊚ ∘ id ⊗₁ idV ∘ σ ≈⟨ pullˡ unitˡ ⟩ λ⇒ ∘ σ ≈⟨ braiding-coherence ⟩ ρ⇒ ∎ } where open Category C ⊚-assoc′ : ∀ {A B C D} → [ hom C D ⊗₀ (hom B C ⊗₀ hom A B) ⇒ hom A D ]⟨ idV ⊗₁ ⊚ ⇒⟨ hom C D ⊗₀ hom A C ⟩ ⊚ ≈ α⇐ ⇒⟨ (hom C D ⊗₀ hom B C) ⊗₀ hom A B ⟩ ⊚ ⊗₁ idV ⇒⟨ hom B D ⊗₀ hom A B ⟩ ⊚ ⟩ ⊚-assoc′ = switch-fromtoʳ associator (assoc ○ ⟺ ⊚-assoc) ○ assoc -- implements the following equation of string diagrams -- -- | | | | | | -- \ / | | \ / -- \ | | \ -- / \ / \ / \ -- | \ / === \ / | -- \ \ / / -- \ / \ / \ / -- \ \ / / -- / \ \ / / \ -- | | | | | | -- invert-braidings : ∀ {A B C} → [ (A ⊗₀ B) ⊗₀ C ⇒ (C ⊗₀ B) ⊗₀ A ]⟨ σ ⊗₁ idV ⇒⟨ (B ⊗₀ A) ⊗₀ C ⟩ σ ⇒⟨ C ⊗₀ (B ⊗₀ A) ⟩ α⇐ ≈ α⇒ ⇒⟨ A ⊗₀ (B ⊗₀ C) ⟩ idV ⊗₁ σ ⇒⟨ A ⊗₀ (C ⊗₀ B) ⟩ σ ⟩ invert-braidings = begin α⇐ ∘ σ ∘ σ ⊗₁ idV ≈⟨ extendʳ (switch-tofromʳ associator (⟺ hexagon₂)) ⟩ ((σ ⊗₁ idV ∘ α⇐) ∘ idV ⊗₁ σ) ∘ α⇒ ∘ σ ⊗₁ idV ≈⟨ assoc ⟩ (σ ⊗₁ idV ∘ α⇐) ∘ idV ⊗₁ σ ∘ α⇒ ∘ σ ⊗₁ idV ≈˘⟨ pushʳ (switch-fromtoˡ associator (⟺ hexagon₁)) ⟩ σ ⊗₁ idV ∘ σ ∘ α⇒ ≈˘⟨ extendʳ (braiding.⇒.commute _) ⟩ σ ∘ idV ⊗₁ σ ∘ α⇒ ∎
{ "alphanum_fraction": 0.4275362319, "avg_line_length": 38.3333333333, "ext": "agda", "hexsha": "07d1b07de37c218b9584fdbe06a925ee31d25bfa", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Enriched/Category/Opposite.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Enriched/Category/Opposite.agda", "max_line_length": 80, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Enriched/Category/Opposite.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 1710, "size": 4140 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use -- Data.Product.Relation.Binary.Pointwise.NonDependent directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Product.Relation.Pointwise.NonDependent where open import Data.Product.Relation.Binary.Pointwise.NonDependent public
{ "alphanum_fraction": 0.5299334812, "avg_line_length": 34.6923076923, "ext": "agda", "hexsha": "a20f3c1b0ec322b659c4a79605c2ae27fa8026e8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Relation/Pointwise/NonDependent.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/Relation/Pointwise/NonDependent.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Relation/Pointwise/NonDependent.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 69, "size": 451 }
{-# OPTIONS --without-K #-} module sets.nat.ordering.lt.core where open import sum open import equality.core open import function.isomorphism.core open import sets.core open import sets.nat.core open import sets.nat.ordering.leq.core _<_ : ℕ → ℕ → Set m < n = suc m ≤ n infixr 4 _<_ z<n : ∀ {n} → 0 < suc n z<n = s≤s z≤n <⇒≤ : ∀ {n m} → n < m → n ≤ m <⇒≤ p = trans≤ suc≤ p trans< : ∀ {n m p} → n < m → m < p → n < p trans< p q = <⇒≤ (trans≤ (s≤s p) q) ap<-suc : ∀ {n m} → n < m → suc n < suc m ap<-suc = s≤s compare : (n m : ℕ) → Ordering _<_ n m compare zero zero = eq refl compare zero (suc m) = lt z<n compare (suc n) zero = gt z<n compare (suc n) (suc m) with compare n m ... | lt p = lt (ap<-suc p) ... | eq p = eq (ap suc p) ... | gt p = gt (ap<-suc p)
{ "alphanum_fraction": 0.5671447197, "avg_line_length": 21.9142857143, "ext": "agda", "hexsha": "aed5976dcb48488a024fe9af15081a3c4ba9ab5b", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_path": "src/sets/nat/ordering/lt/core.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/sets/nat/ordering/lt/core.agda", "max_line_length": 42, "max_stars_count": 20, "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_path": "src/sets/nat/ordering/lt/core.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "num_tokens": 322, "size": 767 }
{- NEW TRANSLATION: notation change to avoid exponential increase in term size during translation -} open import Preliminaries open import Source open import Complexity module Translation-WithLet where mutual ⟨⟨_⟩⟩ : Tp → Complexity.CTp ⟨⟨ unit ⟩⟩ = unit ⟨⟨ nat ⟩⟩ = nat ⟨⟨ susp A ⟩⟩ = || A || ⟨⟨ A ->s B ⟩⟩ = ⟨⟨ A ⟩⟩ ->c || B || ⟨⟨ A ×s B ⟩⟩ = ⟨⟨ A ⟩⟩ ×c ⟨⟨ B ⟩⟩ ⟨⟨ list A ⟩⟩ = list ⟨⟨ A ⟩⟩ ⟨⟨ bool ⟩⟩ = bool ||_|| : Tp → Complexity.CTp || τ || = C ×c ⟨⟨ τ ⟩⟩ ⟨⟨_⟩⟩c : Source.Ctx → Complexity.Ctx ⟨⟨ [] ⟩⟩c = [] ⟨⟨ x :: Γ ⟩⟩c = ⟨⟨ x ⟩⟩ :: ⟨⟨ Γ ⟩⟩c interp-Cost : ∀{Γ} → Cost → Γ Complexity.|- C interp-Cost 0c = 0C interp-Cost 1c = 1C interp-Cost (m +c n) = plusC (interp-Cost m) (interp-Cost n) lookup : ∀{Γ τ} → τ Source.∈ Γ → ⟨⟨ τ ⟩⟩ Complexity.∈ ⟨⟨ Γ ⟩⟩c lookup i0 = i0 lookup (iS x) = iS (lookup x) throw-s : ∀ {Γ Γ' τ} → Complexity.sctx Γ (τ :: Γ') → Complexity.sctx Γ Γ' throw-s Θ x = Θ (iS x) _+C_ : ∀ {Γ τ} → Γ Complexity.|- C → Γ Complexity.|- (C ×c τ)→ Γ Complexity.|- (C ×c τ) c +C e = letc (prod (l-proj (var i0)) (r-proj (var i0))) e -- translation from source expressions to complexity expressions ||_||e : ∀{Γ τ} → Γ Source.|- τ → ⟨⟨ Γ ⟩⟩c Complexity.|- || τ || || unit ||e = prod 0C unit || var x ||e = prod 0C (var (lookup x)) || z ||e = prod 0C z || suc e ||e = (letc (prod (l-proj (var i0)) (s (r-proj (var i0)))) || e ||e) || rec e e0 e1 ||e = letc (l-proj (var i0) +C rec (r-proj (var i0)) (Complexity.wkn (1C +C || e0 ||e)) (Complexity.subst (1C +C || e1 ||e) (Complexity.s-extend (Complexity.s-extend (throw-s Complexity.ids))))) || e ||e || lam e ||e = prod 0C (lam || e ||e) || app e1 e2 ||e = letc (letc (prod (plusC (plusC (l-proj (var (iS i0))) (l-proj (var i0))) (l-proj (app (r-proj (var (iS i0))) (r-proj (var i0))))) (r-proj (app (r-proj (var (iS i0))) (r-proj (var i0))))) (Complexity.wkn || e2 ||e)) || e1 ||e || prod e1 e2 ||e = letc (letc (prod (plusC (l-proj (var (iS i0))) (l-proj (var i0))) (prod (r-proj (var (iS i0))) (r-proj (var i0)))) (Complexity.wkn || e2 ||e)) || e1 ||e || delay e ||e = prod 0C || e ||e || force e ||e = letc (prod (plusC (l-proj (var i0)) (l-proj (r-proj (var i0)))) (r-proj (r-proj (var i0)))) || e ||e || split e0 e1 ||e = letc (prod (plusC (Complexity.wkn (l-proj || e0 ||e)) (l-proj (var i0))) (r-proj (var i0))) E1 where E1 = letc (Complexity.subst || e1 ||e (Complexity.lem4 (l-proj (r-proj (var i0))) (r-proj (r-proj (var i0))) Complexity.ss Complexity.s-extend (Complexity.s-extend (throw-s Complexity.ids)))) || e0 ||e || nil ||e = prod 0C nil || e ::s e₁ ||e = letc (letc (prod (plusC (l-proj (var (iS i0))) (l-proj (var i0))) (r-proj (var (iS i0)) ::c r-proj (var i0))) (Complexity.wkn || e₁ ||e)) || e ||e || listrec e e₁ e₂ ||e = letc (l-proj (var i0) +C listrec (r-proj (var i0)) (Complexity.wkn (1C +C || e₁ ||e)) (Complexity.subst (1C +C || e₂ ||e) (Complexity.s-extend (Complexity.s-extend (Complexity.s-extend (throw-s Complexity.ids)))))) || e ||e || true ||e = prod 0C true || false ||e = prod 0C false {- module Proofs where open NewTranslation renaming (||_||e to ||_||new) open import Translation renaming (||_||e to ||_||old) convert-type : Complexity-WithLet.CTp → Complexity.CTp convert-type unit = unit convert-type nat = nat convert-type (τ ->c τ₁) = convert-type τ ->c convert-type τ₁ convert-type (τ ×c τ₁) = convert-type τ ×c convert-type τ₁ convert-type (list τ) = list (convert-type τ) convert-type bool = bool convert-type C = C convert-type rnat = rnat convert-ctx : Complexity-WithLet.Ctx → Complexity.Ctx convert-ctx [] = [] convert-ctx (x :: Γ) = convert-type x :: convert-ctx Γ convert-var : ∀ {Γ τ} → τ Complexity-WithLet.∈ Γ → convert-type τ Complexity.∈ convert-ctx Γ convert-var i0 = i0 convert-var (iS x) = iS (convert-var x) convert-exp : ∀{Γ τ} → (e : Γ Complexity-WithLet.|- τ) → convert-ctx Γ Complexity.|- convert-type τ convert-exp unit = unit convert-exp 0C = 0C convert-exp 1C = 1C convert-exp (plusC e e₁) = plusC (convert-exp e) (convert-exp e₁) convert-exp (var x) = var (convert-var x) convert-exp z = z convert-exp (s e) = s (convert-exp e) convert-exp (rec e e₁ e₂) = rec (convert-exp e) (convert-exp e₁) (convert-exp e₂) convert-exp (lam e) = lam (convert-exp e) convert-exp (app e e₁) = app (convert-exp e) (convert-exp e₁) convert-exp (prod e e₁) = {!!} convert-exp (l-proj e) = {!!} convert-exp (r-proj e) = {!!} convert-exp nil = {!!} convert-exp (e ::c e₁) = {!!} convert-exp (listrec e e₁ e₂) = {!!} convert-exp true = true convert-exp false = false convert-exp (max x e e₁) = max {!!} {!!} {!!} convert-exp (letc e e₁) = app (lam (convert-exp e)) (convert-exp e₁) trans-eq : ∀{Γ τ} → (e : Γ Source.|- τ) → (t1 : convert-exp ?) --((NewTranslation.⟨⟨ Γ ⟩⟩c) Complexity-WithLet.|- NewTranslation.|| τ ||)) → (t2 : Translation.⟨⟨ Γ ⟩⟩c Complexity.|- Translation.|| τ ||) → {!convert-exp t1!} == t2 trans-eq e = {!!} -}
{ "alphanum_fraction": 0.5480750996, "avg_line_length": 45.0683760684, "ext": "agda", "hexsha": "d2acafed17e0b6fb1527f0da17dc31401189a7a0", "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": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "benhuds/Agda", "max_forks_repo_path": "complexity/complexity-final/submit/Translation-WithLet.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_issues_repo_issues_event_max_datetime": "2020-05-12T00:32:45.000Z", "max_issues_repo_issues_event_min_datetime": "2020-03-23T08:39:04.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "benhuds/Agda", "max_issues_repo_path": "complexity/complexity-final/submit/Translation-WithLet.agda", "max_line_length": 214, "max_stars_count": 2, "max_stars_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "benhuds/Agda", "max_stars_repo_path": "complexity/complexity-final/submit/Translation-WithLet.agda", "max_stars_repo_stars_event_max_datetime": "2019-08-08T12:27:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-04-26T20:22:22.000Z", "num_tokens": 2012, "size": 5273 }
module _ where record LinearOrderStr (D : Set) : Set₁ where no-eta-equality field _<_ : D -> D -> Set open LinearOrderStr {{...}} postulate D : Set module _ {{O : LinearOrderStr D}} where abstract broken : {b c : D} -> (b < c) -> b < c broken {b} {c} b<c = b<c where b<c2 : b < c b<c2 = b<c
{ "alphanum_fraction": 0.5299401198, "avg_line_length": 15.9047619048, "ext": "agda", "hexsha": "16e74b55ed2628d8ab68a7aba2a019d0a25cb1c2", "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": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Succeed/Issue5620.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "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-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Succeed/Issue5620.agda", "max_line_length": 44, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Succeed/Issue5620.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": 123, "size": 334 }
------------------------------------------------------------------------ -- A simple backend ------------------------------------------------------------------------ module RecursiveDescent.Hybrid.Simple where open import Data.Bool renaming (true to ⊤; false to ⊥) open import Data.Product.Record import Data.Product as Prod open import Data.Maybe open import Data.BoundedVec.Inefficient import Data.List as L open import Data.Nat open import Data.Function using (id; _∘_) open import Category.Applicative.Indexed open import Category.Monad.Indexed open import Category.Monad.State open import RecursiveDescent.Hybrid.Type open import Utilities ------------------------------------------------------------------------ -- Parser monad private P : Set -> IFun ℕ P tok = IStateT (BoundedVec tok) L.List open module M₁ {tok} = RawIMonadPlus (StateTIMonadPlus (BoundedVec tok) L.monadPlus) renaming (return to ret) open module M₂ {tok} = RawIMonadState (StateTIMonadState (BoundedVec tok) L.monad) using (get; put; modify) ------------------------------------------------------------------------ -- Run function for the parsers -- For every successful parse the run function returns the remaining -- string. (Since there can be several successful parses a list of -- strings is returned.) -- This function is structurally recursive with respect to the -- following lexicographic measure: -- -- 1) The upper bound of the length of the input string. -- 2) The parser's proper left corner tree. private module Dummy {tok nt} (g : Grammar tok nt) where mutual parse : forall n {e c r} -> Parser tok nt (e , c) r -> P tok n (if e then n else pred n) r parse n (! x) = parse n (g x) parse zero symbol = ∅ parse (suc n) symbol = eat =<< get parse n (return x) = ret x parse n fail = ∅ parse n (p₁ ?>>= p₂) = parse n p₁ >>= parse n ∘′ p₂ parse zero (p₁ !>>= p₂) = ∅ parse (suc n) (p₁ !>>= p₂) = parse (suc n) p₁ >>= parse↑ n ∘′ p₂ parse n (alt ⊤ _ p₁ p₂) = parse n p₁ ∣ parse↑ n p₂ parse n (alt ⊥ ⊤ p₁ p₂) = parse↑ n p₁ ∣ parse n p₂ parse n (alt ⊥ ⊥ p₁ p₂) = parse n p₁ ∣ parse n p₂ parse↑ : forall n {e c r} -> Parser tok nt (e , c) r -> P tok n n r parse↑ n {⊤} p = parse n p parse↑ zero {⊥} p = ∅ parse↑ (suc n) {⊥} p = parse (suc n) p >>= \r -> modify ↑ >> ret r eat : forall {n} -> BoundedVec tok (suc n) -> P tok (suc n) n tok eat [] = ∅ eat (c ∷ s) = put s >> ret c -- Exported run function. parse : forall {tok nt i r} -> Parser tok nt i r -> Grammar tok nt -> L.List tok -> L.List (Prod._×_ r (L.List tok)) parse p g s = L.map (Prod.map id toList) (Dummy.parse g _ p (fromList s)) -- A variant which only returns parses which leave no remaining input. parse-complete : forall {tok nt i r} -> Parser tok nt i r -> Grammar tok nt -> L.List tok -> L.List r parse-complete p g s = L.map Prod.proj₁ (L.filter (L.null ∘ Prod.proj₂) (parse p g s))
{ "alphanum_fraction": 0.5319018405, "avg_line_length": 33.6082474227, "ext": "agda", "hexsha": "b0885ea6e282488de1279571551c7c54f011b077", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "misc/RecursiveDescent/Hybrid/Simple.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": "2018-01-24T16:39:37.000Z", "max_issues_repo_issues_event_min_datetime": "2018-01-22T22:21:41.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "misc/RecursiveDescent/Hybrid/Simple.agda", "max_line_length": 72, "max_stars_count": 7, "max_stars_repo_head_hexsha": "b396d35cc2cb7e8aea50b982429ee385f001aa88", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yurrriq/parser-combinators", "max_stars_repo_path": "misc/RecursiveDescent/Hybrid/Simple.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-22T05:35:31.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-13T05:23:14.000Z", "num_tokens": 912, "size": 3260 }
{-# OPTIONS --cubical --safe #-} module Cardinality.Finite.SplitEnumerable.Isomorphism where open import Prelude open import Container open import Container.List open import Data.Fin open import Container.Membership (ℕ , Fin) open import Path.Reasoning open import Data.Sigma.Properties open import Function.Surjective.Properties open import Data.Fin.Properties import Data.List.Membership as 𝕃 open import Container.List.Isomorphism open import Data.Nat.Properties open import Data.List using (_∷_; []; List) import Cardinality.Finite.SplitEnumerable.Container as ℒ import Cardinality.Finite.SplitEnumerable.Inductive as 𝕃 ∈ℒ⇒∈𝕃 : ∀ (x : A) (xs : ⟦ ℕ , Fin ⟧ A) → x ∈ xs → x 𝕃.∈ ℒ→𝕃 xs ∈ℒ⇒∈𝕃 x (suc l , xs) (f0 , p) = f0 , p ∈ℒ⇒∈𝕃 x (suc l , xs) (fs n , p) = 𝕃.push (∈ℒ⇒∈𝕃 x (l , xs ∘ fs) (n , p)) 𝕃⇔ℒ⟨ℰ!⟩ : 𝕃.ℰ! A ⇔ ℒ.ℰ! A 𝕃⇔ℒ⟨ℰ!⟩ .fun (sup , cov) = 𝕃→ℒ sup , cov 𝕃⇔ℒ⟨ℰ!⟩ .inv (sup , cov) = ℒ→𝕃 sup , λ x → ∈ℒ⇒∈𝕃 x sup (cov x) 𝕃⇔ℒ⟨ℰ!⟩ .rightInv (sup , cov) i .fst = 𝕃⇔ℒ .rightInv sup i 𝕃⇔ℒ⟨ℰ!⟩ .rightInv (sup , cov) i .snd x = ∈ℒ⇒∈𝕃-rightInv sup (cov x) i where ∈ℒ⇒∈𝕃-rightInv : ∀ xs x∈xs → PathP (λ i → x ∈ 𝕃⇔ℒ .rightInv xs i) (∈ℒ⇒∈𝕃 x xs x∈xs) x∈xs ∈ℒ⇒∈𝕃-rightInv (suc l , xs) (f0 , x∈xs) i = f0 , x∈xs ∈ℒ⇒∈𝕃-rightInv (suc l , xs) (fs n , x∈xs) i = let m , q = ∈ℒ⇒∈𝕃-rightInv (l , xs ∘ fs) (n , x∈xs) i in fs m , q 𝕃⇔ℒ⟨ℰ!⟩ .leftInv (sup , cov) i .fst = 𝕃⇔ℒ .leftInv sup i 𝕃⇔ℒ⟨ℰ!⟩ .leftInv (sup , cov) i .snd x = ∈ℒ⇒∈𝕃-leftInv sup (cov x) i where ∈ℒ⇒∈𝕃-leftInv : ∀ xs x∈xs → PathP (λ i → x 𝕃.∈ 𝕃→ℒ→𝕃 xs i) (∈ℒ⇒∈𝕃 x (𝕃→ℒ xs) x∈xs) x∈xs ∈ℒ⇒∈𝕃-leftInv (_ ∷ xs) (f0 , x∈xs) i = f0 , x∈xs ∈ℒ⇒∈𝕃-leftInv (_ ∷ xs) (fs n , x∈xs) i = let m , p = ∈ℒ⇒∈𝕃-leftInv xs (n , x∈xs) i in fs m , p
{ "alphanum_fraction": 0.5908309456, "avg_line_length": 35.612244898, "ext": "agda", "hexsha": "8be1f36189d79d322c95c00b42a2d6f4f4798f03", "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/Cardinality/Finite/SplitEnumerable/Isomorphism.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/Cardinality/Finite/SplitEnumerable/Isomorphism.agda", "max_line_length": 72, "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/Cardinality/Finite/SplitEnumerable/Isomorphism.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": 957, "size": 1745 }
module Σ where A : Set₁ A = Set
{ "alphanum_fraction": 0.6363636364, "avg_line_length": 6.6, "ext": "agda", "hexsha": "e4a8987af1e6f09b8067f3fabfc958cfb33eee27", "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": "8037346494d68356efdb2f6e0ef1458704721acd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "L-TChen/agda", "max_forks_repo_path": "test/LaTeXAndHTML/succeed/Σ.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8037346494d68356efdb2f6e0ef1458704721acd", "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": "L-TChen/agda", "max_issues_repo_path": "test/LaTeXAndHTML/succeed/Σ.agda", "max_line_length": 14, "max_stars_count": null, "max_stars_repo_head_hexsha": "8037346494d68356efdb2f6e0ef1458704721acd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "L-TChen/agda", "max_stars_repo_path": "test/LaTeXAndHTML/succeed/Σ.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 14, "size": 33 }
module STLCRef.SemanticsLB where -- This file contains a definitional interpreter for STLC+Ref as -- described in Section 3 of the paper. The interpreter operates with -- the notion of monadic bind described in Section 3.3 of the paper; -- see `Semantics.agda` for the version of the interpreter of STLC+Ref -- using monadic strength as described in Section 3.4 of the paper. open import Agda.Primitive open import Data.Unit open import Data.Nat hiding (_⊔_ ; _^_) open import Data.Integer hiding (_⊔_) open import Data.List open import Data.Product open import Data.Maybe hiding (_>>=_) open import Data.List.Membership.Propositional open import Data.List.Relation.Unary.All as All open import Data.List.Relation.Unary.Any open import Data.List.Prefix open import Data.List.Properties.Extra open import Data.List.All.Properties.Extra open import Function open import Common.Weakening ------------ -- SYNTAX -- ------------ -- These definitions correspond to Section 3.1, except we have -- included integers, integer operations, and a simple conditional -- expression (if-zero) in the language. data Ty : Set Ctx = List Ty data Ty where _⇒_ : (a b : Ty) → Ty unit : Ty int : Ty ref : Ty -> Ty data Expr (Γ : List Ty) : Ty → Set where unit : Expr Γ unit var : ∀ {t} → t ∈ Γ → Expr Γ t ƛ : ∀ {a b} → Expr (a ∷ Γ) b → Expr Γ (a ⇒ b) _·_ : ∀ {a b} → Expr Γ (a ⇒ b) → Expr Γ a → Expr Γ b num : ℤ → Expr Γ int iop : (ℤ → ℤ → ℤ) → (l r : Expr Γ int) → Expr Γ int ifz : ∀ {t} → Expr Γ int → Expr Γ t → Expr Γ t → Expr Γ t ref : ∀ {t} → Expr Γ t → Expr Γ (ref t) !_ : ∀ {t} → Expr Γ (ref t) → Expr Γ t _≔_ : ∀ {t} → Expr Γ (ref t) → Expr Γ t → Expr Γ unit ----------------------- -- STORES AND VALUES -- ----------------------- StoreTy = List Ty -- `Val` uses `_∈_` from `Relation.Binary` in the Agda Standard -- Library to represent typed locations which witness the existence of -- a store location in the store type. mutual data Val : Ty → (Σ : StoreTy) → Set where loc : ∀ {Σ t} → t ∈ Σ → Val (ref t) Σ unit : ∀ {Σ} → Val unit Σ ⟨_,_⟩ : ∀ {Σ Γ a b} → Expr (a ∷ Γ) b → Env Γ Σ → Val (a ⇒ b) Σ num : ∀ {Σ} → ℤ → Val int Σ Env : (Γ : Ctx)(Σ : StoreTy) → Set Env Γ Σ = All (λ t → Val t Σ) Γ Store : (Σ : StoreTy) → Set Store Σ = All (λ t → Val t Σ) Σ -- The `lookup-store` function is defined in terms of the `lookup` -- function from `Data.List.All` in the Agda Standard Library. lookup-store : ∀ {Σ t} → t ∈ Σ → Store Σ → Val t Σ lookup-store x μ = All.lookup μ x -- The `update-store` function is defined in terms of the update -- function for the `All` type: `_All[_]≔'_` from the Standard Library -- extension (contained in the `lib/*` folder of this artifact). update-store : ∀ {Σ t} → t ∈ Σ → Val t Σ → Store Σ → Store Σ update-store ptr v μ = μ All.[ ptr ]≔ v ----------- -- MONAD -- ----------- -- These definitions correspond to Section 3.3. M : ∀ {i}(Γ : Ctx) → (p : StoreTy → Set i) → (Σ : StoreTy) → Set i M Γ p Σ = Env Γ Σ → Store Σ → Maybe (∃ λ Σ' → Store Σ' × p Σ' × Σ ⊑ Σ') mutual weaken-val : ∀ {a}{Σ Σ' : StoreTy} → Σ ⊑ Σ' → Val a Σ → Val a Σ' weaken-val ext unit = unit weaken-val ext (loc l) = loc (∈-⊒ l ext) weaken-val ext ⟨ e , E ⟩ = ⟨ e , weaken-env ext E ⟩ weaken-val ext (num z) = num z weaken-env : ∀ {Γ}{Σ Σ' : StoreTy} → Σ ⊑ Σ' → Env Γ Σ → Env Γ Σ' weaken-env ext (v ∷ vs) = weaken-val ext v ∷ weaken-env ext vs weaken-env ext [] = [] return : ∀ {Σ Γ}{p : List Ty → Set} → p Σ → M Γ p Σ return x E μ = just (_ , μ , x , ⊑-refl) _>>=_ : ∀ {Σ Γ}{p q : StoreTy → Set} →   (f : M Γ p Σ) → (g : ∀ {Σ'} → Σ ⊑ Σ' → p Σ' → M Γ q Σ') → M Γ q Σ (f >>= c) E μ = case (f E μ) of λ{ nothing → nothing ; (just (_ , μ' , x , ext)) → case (c ext x (weaken-env ext E) μ') of λ{ nothing → nothing ; (just (_ , μ'' , y , ext')) → just (_ , μ'' , y , ext ⊚ ext') }} getEnv : ∀ {Σ Γ} → M Γ (Env Γ) Σ getEnv E = return E E usingEnv : ∀ {Σ Γ Γ'}{p : List Ty → Set} → Env Γ Σ → M Γ p Σ → M Γ' p Σ usingEnv E f _ = f E timeout : ∀ {Σ Γ}{p : List Ty → Set} → M Γ p Σ timeout _ _ = nothing store : ∀ {Σ t Γ} → Val t Σ → M Γ (Val (ref t)) Σ store {Σ} {t} v _ μ = let ext = ∷ʳ-⊒ t Σ v' = loc (∈-∷ʳ Σ t) μ' = (All.map (weaken-val ext) μ) all-∷ʳ (weaken-val ext v) in just (_ , μ' , v' , ext) deref : ∀ {Σ Γ t} → t ∈ Σ → M Γ (Val t) Σ deref x E μ = return (All.lookup μ x) E μ update : ∀ {Σ Γ t} → t ∈ Σ → Val t Σ → M Γ (λ _ → ⊤) Σ update x v E μ = return tt E (update-store x v μ) eval : ℕ → ∀ {Σ Γ t} → Expr Γ t → M Γ (Val t) Σ eval zero _ = timeout eval (suc k) unit = return unit eval (suc k) (var x) = getEnv >>= λ _ E → return (All.lookup E x) eval (suc k) (ƛ e) = getEnv >>= λ _ E → return ⟨ e , E ⟩ eval (suc k) (l · r) = eval k l >>= λ{ ext ⟨ e , E ⟩ → eval k r >>= λ ext' v → usingEnv (v ∷ weaken-env ext' E) (eval k e) } -- explicit weakening eval (suc k) (num x) = return (num x) eval (suc k) (iop f l r) = eval k l >>= λ{ _ (num v) → eval k r >>= λ{ _ (num vᵣ) → return (num (f v vᵣ)) }} eval (suc k) (ifz c t e) = eval k c >>= λ{ _ (num z) → case z of λ{ (+ zero) → eval k t ; _ → eval k e }} eval (suc k) (ref e) = eval k e >>= λ _ v → store v eval (suc k) (! e) = eval k e >>= λ{ _ (loc l) → deref l } eval (suc k) (r ≔ e) = eval k r >>= λ{ _ (loc l) → eval k e >>= λ ext v → update (∈-⊒ l ext) v >>= λ _ _ → -- explicit weakening return unit }
{ "alphanum_fraction": 0.5470039469, "avg_line_length": 30.4590163934, "ext": "agda", "hexsha": "ba131658819a443dcd4ef24c6a9637399c81ec27", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_path": "src/STLCRef/SemanticsLB.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_path": "src/STLCRef/SemanticsLB.agda", "max_line_length": 73, "max_stars_count": 10, "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_path": "src/STLCRef/SemanticsLB.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "num_tokens": 2127, "size": 5574 }
module Library where open import Function using (id; _∘_; _$_) public open import Relation.Binary.HeterogeneousEquality public open ≅-Reasoning renaming (begin_ to proof_) public open import Data.Product renaming (proj₁ to fst; proj₂ to snd) public open import Data.Empty public using (⊥; ⊥-elim) open import Data.Unit public using (⊤) open import Data.Nat public using (ℕ; zero; suc; _+_; module ℕ) open import Data.Nat.Properties.Simple public open import Data.Fin public using (Fin; zero; suc; raise) renaming (_+_ to _F+_; fromℕ to fromNat) open import Level public renaming (suc to lsuc; zero to lzero) hiding (lift) -- needed for setoids congid : ∀{a}{A : Set a}{a a' : A}(p : a ≅ a') → cong id p ≅ p congid refl = refl congcomp : ∀{a b c}{A : Set a}{B : Set b}{C : Set c} {a a' : A}(f : B → C)(g : A → B)(p : a ≅ a') → cong (f ∘ g) p ≅ cong f (cong g p) congcomp f g refl = refl -- should be replaced by dcong cong' : ∀{a b}{A A' : Set a} → A ≅ A' → {B : A → Set b}{B' : A' → Set b} → B ≅ B' → {f : ∀ a → B a}{f' : ∀ a → B' a} → f ≅ f' → {a : A}{a' : A'} → a ≅ a' → f a ≅ f' a' cong' refl refl refl refl = refl -- should be replaced by dicong icong' : ∀{a b}{A A' : Set a} → A ≅ A' → {B : A → Set b}{B' : A' → Set b} → B ≅ B' → {f : ∀ {a} → B a}{f' : ∀ {a} → B' a} → (λ {a} → f {a}) ≅ (λ {a} → f' {a}) → {a : A}{a' : A'} → a ≅ a' → f {a} ≅ f' {a'} icong' refl refl refl refl = refl fcong : ∀{a b}{A : Set a}{B : A → Set b}{f f' : (x : A) → B x} (a : A) → f ≅ f' → f a ≅ f' a fcong a refl = refl dcong : ∀{a b}{A A' : Set a}{B : A → Set b}{B' : A' → Set b} {f : (a : A) → B a}{f' : (a : A') → B' a}{a : A}{a' : A'} → a ≅ a' → B ≅ B' → f ≅ f' → f a ≅ f' a' dcong refl refl refl = refl dicong : ∀{a b}{A A' : Set a}{B : A → Set b}{B' : A' → Set b} {f : ∀ {a} → B a}{f' : ∀ {a} → B' a} → {a : A}{a' : A'} → a ≅ a' → B ≅ B' → (λ {a} → f {a}) ≅ (λ {a} → f' {a}) → f {a} ≅ f' {a'} dicong refl refl refl = refl ifcong : ∀{a b}{A : Set a}{B : A → Set b}{f f' : {x : A} → B x}(a : A) → _≅_ {_}{ {x : A} → B x} f { {x : A} → B x} f' → f {a} ≅ f' {a} ifcong a refl = refl cong₃ : ∀{a b c d}{A : Set a}{B : A → Set b} {C : ∀ x → B x → Set c }{D : ∀ x y → C x y → Set d} (f : ∀ x y z → D x y z) {a a' : A} → a ≅ a' → {b : B a}{b' : B a'} → b ≅ b' → {c : C a b}{c' : C a' b'} → c ≅ c' → f a b c ≅ f a' b' c' cong₃ f refl refl refl = refl ir : ∀{a}{A B : Set a}{x : A}{y : B}(p q : x ≅ y) → p ≅ q ir refl refl = refl stripsubst : ∀{a c}{A : Set a}(C : A → Set c) → {a : A} → (c : C a) → {b : A} → (p : a ≅ b) → subst C p c ≅ c stripsubst C c refl = refl postulate ext : ∀{a b}{A : Set a}{B B' : A → Set b} {f : ∀ a → B a}{g : ∀ a → B' a} → (∀ a → f a ≅ g a) → f ≅ g postulate dext : ∀{a b}{A A' : Set a}{B : A → Set b}{B' : A' → Set b} {f : ∀ a → B a}{g : ∀ a → B' a} → (∀ {a a'} → a ≅ a' → f a ≅ g a') → f ≅ g -- this could just be derived from ext postulate iext : ∀{a b}{A : Set a}{B B' : A → Set b} {f : ∀ {a} → B a}{g : ∀{a} → B' a} → (∀ a → f {a} ≅ g {a}) → _≅_ {_}{ {a : A} → B a} f { {a : A} → B' a} g postulate diext : ∀{a b}{A A' : Set a}{B : A → Set b}{B' : A' → Set b} {f : ∀ {a} → B a}{f' : ∀{a'} → B' a'} → (∀{a a'} → a ≅ a' → f {a} ≅ f' {a'}) → _≅_ {_}{ {a : A} → B a} f { {a' : A'} → B' a'} f' hir : ∀{a}{A A' A'' A''' : Set a}{a : A}{a' : A'}{a'' : A''}{a''' : A'''} {p : a ≅ a'}{q : a'' ≅ a'''} → a ≅ a'' → p ≅ q hir {p = refl} {q = refl} refl = refl hir' : ∀{a}{A A' A'' A''' : Set a}{a : A}{a' : A'}{a'' : A''}{a''' : A'''} {p : a ≅ a'}{q : a'' ≅ a'''} → a' ≅ a''' → p ≅ q hir' {p = refl} {q = refl} refl = refl
{ "alphanum_fraction": 0.3950831885, "avg_line_length": 38.7211538462, "ext": "agda", "hexsha": "b6d20387303df78b51e31985180616f8c4fa4abf", "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": "Library.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": "Library.agda", "max_line_length": 76, "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": "Library.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": 1762, "size": 4027 }
{-# OPTIONS --without-K #-} open import library.Basics hiding (Type ; Σ) open import library.types.Sigma open import Sec2preliminaries open import Sec3hedberg open import Sec4hasConstToSplit -- In this section, we require function extensionality again. module Sec6populatedness where -- Definition 6.1 Pop : Type → Type Pop X = (f : X → X) → const f → fix f -- Theorem 6.2 Trunc→Pop : {X : Type} → Trunc X → Pop X Trunc→Pop z f c = rec {P = fix f} (fixed-point f c) (to-fix f c) z -- Lemma 6.3 module _ {X : Type} where pop→splitSup→X : Pop X → splitSup X → X pop→splitSup→X pop sps = fst (pop (fst fc) (snd fc)) where fc = (snd hasConst↔splitSup sps) use-funct : (splitSup X → X) → Trunc (splitSup X) → Trunc X use-funct f = trunc-functorial f tr-hst-X→pop : (Trunc (splitSup X) → Trunc X) → Pop X tr-hst-X→pop g f c = rec (fixed-point f c) (to-fix f c) (g ∣ hasConst→splitSup (f , c) ∣) -- we formulate the two logical equivalence that we will need explicitly: pop-alt : Pop X ↔ (Trunc (splitSup X) → Trunc X) pop-alt = use-funct ∘ pop→splitSup→X , tr-hst-X→pop pop-alt' : Pop X ↔ (splitSup X → X) pop-alt' = pop→splitSup→X , tr-hst-X→pop ∘ use-funct -- Theorem 6.4 pop-alt₂ : {X : Type} → Pop X ↔₀₁ ((P : Type) → (is-prop P) → (X ↔ P) → P) pop-alt₂ {X} = one , two where one : Pop X → (P : Type) → is-prop P → (X ↔ P) → P one pop P pp (xp , px) = xp (fst (pop f c)) where f : X → X f = px ∘ xp c : const f c x₁ x₂ = ap px (prop-has-all-paths pp _ _) two : ((P : Type) → is-prop P → (X ↔ P) → P) → Pop X two rest f c = rest (fix f) (fixed-point f c) (to-fix f c , from-fix f) -- Theorem 6.5 pop-property₁ : {X : Type} → X → Pop X pop-property₁ = Trunc→Pop ∘ ∣_∣ -- this (and the following results of this section) needs function extensionality open import library.types.Pi pop-property₂ : {X : Type} → is-prop (Pop X) pop-property₂ = Π-is-prop (λ f → Π-is-prop (λ c → fixed-point f c)) -- Theorem 6.6 hasConst↔PopX→X : {X : Type} → (hasConst X) ↔ (Pop X → X) hasConst↔PopX→X {X} = hasConst→PopX→X , rev where hasConst→PopX→X : hasConst X → Pop X → X hasConst→PopX→X (f , c) pop = fst (pop f c) rev : (Pop X → X) → hasConst X rev pp = (pp ∘ pop-property₁) , (λ x₁ x₂ → ap pp (prop-has-all-paths pop-property₂ _ _)) -- Theorem 6.6, second part prop→hasConst×PopX→X : {X : Type} → (is-prop X) → (hasConst X) × (Pop X → X) prop→hasConst×PopX→X p = fc , fst hasConst↔PopX→X fc where fc = idf _ , prop-has-all-paths p -- Theorem 6.7 pop-idem : {X : Type} → (Pop (Pop X)) ≃ (Pop X) pop-idem {X} = equiv f g auto₁ auto₂ where f = snd (prop→hasConst×PopX→X pop-property₂) g = pop-property₁ auto₁ = λ _ → prop-has-all-paths pop-property₂ _ _ auto₂ = λ _ → prop-has-all-paths pop-property₂ _ _
{ "alphanum_fraction": 0.6094800141, "avg_line_length": 28.5555555556, "ext": "agda", "hexsha": "58e504278fda38ee0c85284347bda12876ae4870", "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": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "nicolai/anonymousExistence/Sec6populatedness.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "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": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "nicolai/anonymousExistence/Sec6populatedness.agda", "max_line_length": 92, "max_stars_count": 1, "max_stars_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nicolaikraus/HoTT-Agda", "max_stars_repo_path": "nicolai/anonymousExistence/Sec6populatedness.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "num_tokens": 1059, "size": 2827 }
{-# OPTIONS --type-in-type #-} U = Set id : {A : Set} → A → A id = λ x → x id2 : ∀ {A} → A → A id2 = id id id3 : ∀ {A} → A → A id3 = λ x → id x id4 : {A : Set} -> A -> A id4 = \x -> x the : (A : Set) → A → A the = λ _ x → x constTy = {A B : Set} → A → B → A const : constTy const = λ x y → x constU = const {Set} namedArgTest = const {B = U} U namedArgTest2 = the constTy (λ x y → x) {B = U} U -- Church bools -------------------------------------------------------------------------------- Bool = (B : U) → B → B → B true : Bool true = λ _ t f → t false : Bool false = λ _ t f → f and : Bool → Bool → Bool and = λ b1 b2 → b1 Bool true b2 -- Church natural numbers -------------------------------------------------------------------------------- Nat : U Nat = (n : U) → (n → n) → n → n zero : Nat zero = λ n s z → z suc : Nat → Nat suc = λ a n s z → s (a n s z) n2 : Nat n2 = λ n s z → s (s z) n5 : Nat n5 = λ n s z → s (s (s (s (s z)))) mul : Nat → Nat → Nat mul = λ a b n s z → a n (b n s) z add : Nat → Nat → Nat add = λ a b n s z → a n s (b n s z) n10 = mul n2 n5 n10b = mul n5 n2 n100 = mul n10 n10 n100b = mul n10b n10b n10k = mul n100 n100 n10kb = mul n100b n100b n100k = mul n10k n10 n100kb = mul n10kb n10b n1M = mul n10k n100 n1Mb = mul n10kb n100b n10M = mul n1M n10 n10Mb = mul n1Mb n10b n100M = mul n10M n10 n200M = mul n2 n100M -- Church lists -------------------------------------------------------------------------------- List : U → U List = λ a → (l : U) → (a → l → l) → l → l lnil : ∀{a} → List a lnil = λ l c n → n lcons : ∀{a} → a → List a → List a lcons = λ a as l c n → c a (as l c n) list1 = lcons true (lcons false (lcons false lnil)) map : ∀{a b} → (a → b) → List a → List b map = λ f as l c → as l (λ a → c (f a)) -- Church vectors -------------------------------------------------------------------------------- Vec : U → Nat → U Vec = λ a n → (V : Nat → U) → V zero → (∀{n} → a → V n → V (suc n)) → V n vnil : ∀{a} → Vec a zero vnil = λ V n c → n vcons : ∀{a n} → a → Vec a n → Vec a (suc n) vcons = λ a as V n c → c a (as V n c) vec1 = vcons true (vcons false (vcons true vnil)) vecStress = (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true (vcons true vnil)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))))))))) -- Leibniz (Church) propositional equality, useful for testing conversion. -------------------------------------------------------------------------------- Eq : ∀{A : U} → A → A → U Eq {A} = λ x y → (P : A → U) → P x → P y refl : ∀{A}{x : A} → Eq x x refl = λ P px → px trans : ∀{A}{x y z : A} → Eq x y → Eq y z → Eq x z trans = λ p q → q _ p sym : ∀{A}{x y : A} → Eq x y → Eq y x sym {_}{x}{y} = λ p → p (λ y → Eq y x) refl ap : ∀{A B}(f : A → B){x y : A} → Eq x y → Eq (f x) (f y) ap = λ f {x}{y} p → p (λ y → Eq (f x) (f y)) refl -- Pairs, Top, Bot -------------------------------------------------------------------------------- Pair : U → U → U Pair = λ A B → (Pair : U)(pair : A → B → Pair) → Pair pair : ∀{A B} → A → B → Pair A B pair = λ a b Pair pair → pair a b proj1 : ∀{A B} → Pair A B → A proj1 = λ p → p _ (λ x y → x) proj2 : ∀{A B} → Pair A B → B proj2 = λ p → p _ (λ x y → y) Top : U Top = (Top : U)(tt : Top) → Top tt : Top tt = λ Top tt → tt Bot : U Bot = (Bot : U) → Bot -- Dependent function composition -------------------------------------------------------------------------------- comp : ∀ {A : U} {B : A → U} {C : ∀{a} → B a → U} (f : ∀{a}(b : B a) → C b) (g : (a : A) → B a) (x : A) → C (g x) comp = λ f g a → f (g a) compTest1 : Nat → Nat compTest1 = comp suc suc compTest2 : ∀{m A} → A → Vec A m → Vec A (suc (suc m)) compTest2 = λ a → comp (vcons a) (vcons a) -- Some stress tests -------------------------------------------------------------------------------- nfun : Nat → U nfun n = n U (λ A → U → A) U -- OK synEqTest1 : Eq n1M n1M synEqTest1 = refl -- fail -- synEqTest2 : nfun n10k → nfun n10k -- synEqTest2 = λ x → x -- OK idStress : ∀{A} → A → A idStress = id id id id id id id id id id id id id id id id id id id id id id id id id id id id id id id id id id id id id id id id -- fail -- pairStress : Top -- pairStress = -- let x0 = pair tt tt -- x1 = pair x0 x0 -- x2 = pair x1 x1 -- x3 = pair x2 x2 -- x4 = pair x3 x3 -- x5 = pair x4 x4 -- x6 = pair x5 x5 -- x7 = pair x6 x6 -- x8 = pair x7 x7 -- x9 = pair x8 x8 -- x10 = pair x9 x9 -- x11 = pair x10 x10 -- x12 = pair x11 x11 -- x13 = pair x12 x12 -- x14 = pair x13 x13 -- x15 = pair x14 x14 -- x16 = pair x15 x15 -- x17 = pair x16 x16 -- x18 = pair x17 x17 -- x19 = pair x18 x18 -- x20 = pair x19 x19 -- in tt forceNat : Nat → Bool forceNat n = n _ (λ b → b) true computeTest = forceNat n10M -- Conversion checking tests -------------------------------------------------------------------------------- -- conv100k : Eq n100k n100kb -- conv100k = refl -- conv1M : Eq n1M n1Mb -- conv1M = refl -- OOM -- conv10M : Eq n10M n1M0b -- conv10M = refl -- convNfun1M : Eq (nfun n1M) (nfun n1Mb) -- convNfun1M = refl -- conv10kmeta : Eq n10k (add n10kb _) -- conv10kmeta = refl -- OOM -- conv1Mmeta : Eq n1M (add n1Mb _) -- conv1Mmeta = refl -------------------------------------------------------------------------------- -- normalized instantly lazyU = const U (forceNat n10M) localCBN : Nat → Bool localCBN = λ n → let m = forceNat (mul n n100k) in n _ (λ b → and m b) true cbnReference = forceNat (mul n10 n100k) localCBNtest = localCBN n10 -- Church-coded simply typed lambda calculus -------------------------------------------------------------------------------- Ty : U Ty = (Ty : U) (ι : Ty) (fun : Ty → Ty → Ty) → Ty ι : Ty ι = λ _ ι _ → ι fun : Ty → Ty → Ty fun = λ A B Ty ι fun → fun (A Ty ι fun) (B Ty ι fun) Con : U Con = (Con : U) (nil : Con) (cons : Con → Ty → Con) → Con nil : Con nil = λ Con nil cons → nil cons : Con → Ty → Con cons = λ Γ A Con nil cons → cons (Γ Con nil cons) A Var : Con → Ty → U Var = λ Γ A → (Var : Con → Ty → U) (vz : ∀{Γ A} → Var (cons Γ A) A) (vs : ∀{Γ B A} → Var Γ A → Var (cons Γ B) A) → Var Γ A vz : ∀{Γ A} → Var (cons Γ A) A vz = λ Var vz vs → vz vs : ∀{Γ B A} → Var Γ A → Var (cons Γ B) A vs = λ x Var vz vs → vs (x Var vz vs) Tm : Con → Ty → U Tm = λ Γ A → (Tm : Con → Ty → U) (var : ∀{Γ A} → Var Γ A → Tm Γ A) (lam : ∀{Γ A B} → Tm (cons Γ A) B → Tm Γ (fun A B)) (app : ∀{Γ A B} → Tm Γ (fun A B) → Tm Γ A → Tm Γ B) → Tm Γ A var : ∀{Γ A} → Var Γ A → Tm Γ A var = λ x Tm var lam app → var x lam : ∀{Γ A B} → Tm (cons Γ A) B → Tm Γ (fun A B) lam = λ t Tm var lam app → lam (t Tm var lam app) app : ∀{Γ A B} → Tm Γ (fun A B) → Tm Γ A → Tm Γ B app = λ t u Tm var lam app → app (t Tm var lam app) (u Tm var lam app) -- Well-typed interpreter for Church-coded STLC -------------------------------------------------------------------------------- EvalTy : Ty → U EvalTy = λ A → A _ Bot (λ A B → A → B) EvalCon : Con → U EvalCon = λ Γ → Γ _ Top (λ Δ A → Pair Δ (EvalTy A)) EvalVar : ∀{Γ A} → Var Γ A → EvalCon Γ → EvalTy A EvalVar = λ x → x (λ Γ A → EvalCon Γ → EvalTy A) (λ env → proj2 env) (λ rec env → rec (proj1 env)) EvalTm : ∀{Γ A} → Tm Γ A → EvalCon Γ → EvalTy A EvalTm = λ t → t (λ Γ A → EvalCon Γ → EvalTy A) EvalVar (λ t env α → t (pair env α)) (λ t u env → t env (u env)) -- Large embedded STLC term -------------------------------------------------------------------------------- t1 : Tm nil (fun (fun ι ι) (fun ι ι)) t1 = lam (lam ( app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (app (var (vs vz)) (var vz)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))))))))))) )) -- test evaluation evalTest = EvalTm t1 tt
{ "alphanum_fraction": 0.5235898199, "avg_line_length": 37.1215469613, "ext": "agda", "hexsha": "436d12d82f5a7930af700e5958a419abefd98698", "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": "783840e3444cbdc7927dd4a940d9c0ad5dc47223", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "zarybnicky/smalltt", "max_forks_repo_path": "bench/Bench.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "783840e3444cbdc7927dd4a940d9c0ad5dc47223", "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": "zarybnicky/smalltt", "max_issues_repo_path": "bench/Bench.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "783840e3444cbdc7927dd4a940d9c0ad5dc47223", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "zarybnicky/smalltt", "max_stars_repo_path": "bench/Bench.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 7488, "size": 20157 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category -- Biproducts, a-la Karvonen. -- -- This definition has advantages over more traditional ones, -- namely that that we don't require either enrichment in CMon/Ab, or Zero Objects. -- -- See https://arxiv.org/abs/1801.06488 module Categories.Object.Biproduct {o ℓ e} (𝒞 : Category o ℓ e) where open import Level open import Categories.Object.Coproduct 𝒞 open import Categories.Object.Product 𝒞 open import Categories.Morphism 𝒞 open Category 𝒞 open HomReasoning private variable A B C D : Obj f g h : A ⇒ B record IsBiproduct {A B A⊕B : Obj} (π₁ : A⊕B ⇒ A) (π₂ : A⊕B ⇒ B) (i₁ : A ⇒ A⊕B) (i₂ : B ⇒ A⊕B) : Set (o ⊔ ℓ ⊔ e) where field isCoproduct : IsCoproduct i₁ i₂ isProduct : IsProduct π₁ π₂ π₁∘i₁≈id : π₁ ∘ i₁ ≈ id π₂∘i₂≈id : π₂ ∘ i₂ ≈ id permute : i₁ ∘ π₁ ∘ i₂ ∘ π₂ ≈ i₂ ∘ π₂ ∘ i₁ ∘ π₁ open IsCoproduct isCoproduct public renaming (unique to []-unique) open IsProduct isProduct public renaming (unique to ⟨⟩-unique) record Biproduct (A B : Obj) : Set (o ⊔ ℓ ⊔ e) where field A⊕B : Obj π₁ : A⊕B ⇒ A π₂ : A⊕B ⇒ B i₁ : A ⇒ A⊕B i₂ : B ⇒ A⊕B isBiproduct : IsBiproduct π₁ π₂ i₁ i₂ open IsBiproduct isBiproduct public IsBiproduct⇒Biproduct : {π₁ : C ⇒ A} {π₂ : C ⇒ B} {i₁ : A ⇒ C} {i₂ : B ⇒ C} → IsBiproduct π₁ π₂ i₁ i₂ → Biproduct A B IsBiproduct⇒Biproduct isBiproduct = record { isBiproduct = isBiproduct } Biproduct⇒IsBiproduct : (b : Biproduct A B) → IsBiproduct (Biproduct.π₁ b) (Biproduct.π₂ b) (Biproduct.i₁ b) (Biproduct.i₂ b) Biproduct⇒IsBiproduct biproduct = Biproduct.isBiproduct biproduct Biproduct⇒Product : Biproduct A B → Product A B Biproduct⇒Product b = record { ⟨_,_⟩ = ⟨_,_⟩ ; project₁ = project₁ ; project₂ = project₂ ; unique = ⟨⟩-unique } where open Biproduct b Biproduct⇒Coproduct : Biproduct A B → Coproduct A B Biproduct⇒Coproduct b = record { [_,_] = [_,_] ; inject₁ = inject₁ ; inject₂ = inject₂ ; unique = []-unique } where open Biproduct b
{ "alphanum_fraction": 0.6503394762, "avg_line_length": 25.4567901235, "ext": "agda", "hexsha": "2c5923f90425b9467e31efcbef4322c4f97747c8", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Object/Biproduct.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Object/Biproduct.agda", "max_line_length": 125, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Object/Biproduct.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 841, "size": 2062 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category open import Categories.Category.Monoidal.Core using (Monoidal) module Categories.Category.Monoidal.Rigid {o ℓ e} {C : Category o ℓ e} (M : Monoidal C) where open import Level open import Categories.Functor.Bifunctor open import Categories.NaturalTransformation.NaturalIsomorphism open Category C open Commutation C private variable X : Obj -- left rigid monoidal category record LeftRigid : Set (levelOfTerm M) where open Monoidal M public field _⁻¹ : Obj → Obj η : ∀ {X} → unit ⇒ X ⊗₀ X ⁻¹ ε : ∀ {X} → X ⁻¹ ⊗₀ X ⇒ unit snake₁ : [ X ⇒ X ]⟨ unitorˡ.to ⇒⟨ (unit ⊗₀ X) ⟩ (η ⊗₁ id) ⇒⟨ (X ⊗₀ X ⁻¹) ⊗₀ X ⟩ associator.from ⇒⟨ X ⊗₀ (X ⁻¹ ⊗₀ X) ⟩ (id ⊗₁ ε) ⇒⟨ X ⊗₀ unit ⟩ unitorʳ.from ≈ id ⟩ snake₂ : [ X ⁻¹ ⇒ X ⁻¹ ]⟨ unitorʳ.to ⇒⟨ X ⁻¹ ⊗₀ unit ⟩ (id ⊗₁ η) ⇒⟨ X ⁻¹ ⊗₀ (X ⊗₀ X ⁻¹) ⟩ associator.to ⇒⟨ (X ⁻¹ ⊗₀ X) ⊗₀ X ⁻¹ ⟩ (ε ⊗₁ id) ⇒⟨ unit ⊗₀ X ⁻¹ ⟩ unitorˡ.from ≈ id ⟩ -- right rigid monoidal category record RightRigid : Set (levelOfTerm M) where open Monoidal M public field _⁻¹ : Obj → Obj η : ∀ {X} → unit ⇒ X ⁻¹ ⊗₀ X ε : ∀ {X} → X ⊗₀ X ⁻¹ ⇒ unit snake₁ : [ X ⇒ X ]⟨ unitorʳ.to ⇒⟨ (X ⊗₀ unit) ⟩ (id ⊗₁ η) ⇒⟨ X ⊗₀ (X ⁻¹ ⊗₀ X) ⟩ associator.to ⇒⟨ (X ⊗₀ X ⁻¹) ⊗₀ X ⟩ (ε ⊗₁ id) ⇒⟨ unit ⊗₀ X ⟩ unitorˡ.from ≈ id ⟩ snake₂ : [ X ⁻¹ ⇒ X ⁻¹ ]⟨ unitorˡ.to ⇒⟨ unit ⊗₀ X ⁻¹ ⟩ (η ⊗₁ id) ⇒⟨ (X ⁻¹ ⊗₀ X) ⊗₀ X ⁻¹ ⟩ associator.from ⇒⟨ X ⁻¹ ⊗₀ (X ⊗₀ X ⁻¹) ⟩ (id ⊗₁ ε) ⇒⟨ X ⁻¹ ⊗₀ unit ⟩ unitorʳ.from ≈ id ⟩
{ "alphanum_fraction": 0.4448453608, "avg_line_length": 27.323943662, "ext": "agda", "hexsha": "e551b0ac638c9a9cd1d993b075eb2f7e62360299", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Category/Monoidal/Rigid.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Category/Monoidal/Rigid.agda", "max_line_length": 93, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Category/Monoidal/Rigid.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 785, "size": 1940 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Instance.StrictGroupoids where -- The 'strict' category of groupoids. -- The difference here is that _≈_ is not |NaturalIsomorphism| but |_≡F_| open import Level open import Relation.Binary.PropositionalEquality using (refl) open import Categories.Category using (Category) open import Categories.Category.Groupoid using (Groupoid) open import Categories.Category.Instance.Groupoids using (F-resp-⁻¹) open import Categories.Functor using (Functor; id; _∘F_) open import Categories.Functor.Equivalence private variable o ℓ e : Level open Groupoid using (category) Groupoids : ∀ o ℓ e → Category (suc (o ⊔ ℓ ⊔ e)) (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e) Groupoids o ℓ e = record { Obj = Groupoid o ℓ e ; _⇒_ = λ G H → Functor (category G) (category H) ; _≈_ = _≡F_ ; id = id ; _∘_ = _∘F_ ; assoc = λ {_ _ _ _ F G H} → ≡F-assoc {F = F} {G} {H} ; sym-assoc = λ {_ _ _ _ F G H} → ≡F-sym-assoc {F = F} {G} {H} ; identityˡ = ≡F-identityˡ ; identityʳ = ≡F-identityʳ ; identity² = ≡F-identity² ; equiv = ≡F-equiv ; ∘-resp-≈ = ∘F-resp-≡F }
{ "alphanum_fraction": 0.6350301984, "avg_line_length": 31.3243243243, "ext": "agda", "hexsha": "d0ee96ab8ae2f32f73f6a4a56b76e66e06c50392", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-categories", "max_forks_repo_path": "src/Categories/Category/Instance/StrictGroupoids.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bblfish/agda-categories", "max_issues_repo_path": "src/Categories/Category/Instance/StrictGroupoids.agda", "max_line_length": 73, "max_stars_count": 5, "max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bblfish/agda-categories", "max_stars_repo_path": "src/Categories/Category/Instance/StrictGroupoids.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": 412, "size": 1159 }
open import Data.PropFormula 2 ⋀comm : ∀ {Γ}{φ ψ : PropFormula} → Γ ⊢ φ ∧ ψ ⊃ ψ ∧ φ ⋀comm {Γ} {φ = φ}{ψ} = ⊃-intro $ ∧-intro (∧-proj₂ $ assume {Γ = Γ} $ φ ∧ ψ) (∧-proj₁ {ψ = ψ} $ assume {Γ = Γ} $ φ ∧ ψ)
{ "alphanum_fraction": 0.4459459459, "avg_line_length": 24.6666666667, "ext": "agda", "hexsha": "8a8bd3a76564a05368d97b959f5d0ff9b83a5810", "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": "test/and-example.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": "test/and-example.agda", "max_line_length": 52, "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": "test/and-example.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": 115, "size": 222 }
{-# OPTIONS --without-K #-} module BitVec where open import Data.Bool using (Bool; false; true; _∨_; _∧_) open import Data.Fin using (Fin; toℕ) open import Data.List using (List; []; _∷_; foldr) open import Data.Nat using (ℕ; zero; suc; _≡ᵇ_) open import Data.Product using (_×_; _,_; proj₂) open import Data.String using (String; fromList) open import Data.Vec using (Vec; []; _∷_; map; lookup; replicate; _[_]%=_; toList; zip; zipWith) open import Function using (_∘_) -- Bit vector representation of finite sets BitVec : ℕ → Set BitVec = Vec Bool show : {n : ℕ} → BitVec n → String show = fromList ∘ toList ∘ map (λ {true → '1' ; false → '0'}) empty : {n : ℕ} → BitVec n empty = replicate false insert : {n : ℕ} → Fin n → BitVec n → BitVec n insert k s = s [ k ]%= (λ _ → true) infixr 5 _∪_ _∪_ : {n : ℕ} → BitVec n → BitVec n → BitVec n _∪_ = zipWith _∨_ infixr 6 _∩_ _∩_ : {n : ℕ} → BitVec n → BitVec n → BitVec n _∩_ = zipWith _∧_ infix 4 _∈_ _∈_ : {n : ℕ} → Fin n → BitVec n → Bool b ∈ bv = lookup bv b indices : {n : ℕ} → Vec (Fin n) n indices {ℕ.zero} = [] indices {suc n} = Fin.zero ∷ map Fin.suc (indices {n}) elements : {n : ℕ} → BitVec n → List (Fin n) elements {n} bv = foldr f [] (toList (zip bv indices)) where f : Bool × Fin n → List (Fin n) → List (Fin n) f (false , _) xs = xs f (true , x) xs = x ∷ xs
{ "alphanum_fraction": 0.5857142857, "avg_line_length": 28, "ext": "agda", "hexsha": "9604165707fa9552c2e132d7e9951bbce256268d", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2020-11-10T04:04:40.000Z", "max_forks_repo_forks_event_min_datetime": "2019-01-12T17:02:36.000Z", "max_forks_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "halfaya/MusicTools", "max_forks_repo_path": "doc/icfp20/code/BitVec.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_issues_repo_issues_event_max_datetime": "2020-11-17T00:58:55.000Z", "max_issues_repo_issues_event_min_datetime": "2020-11-13T01:26:20.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "halfaya/MusicTools", "max_issues_repo_path": "doc/icfp20/code/BitVec.agda", "max_line_length": 103, "max_stars_count": 28, "max_stars_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "halfaya/MusicTools", "max_stars_repo_path": "doc/icfp20/code/BitVec.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T18:04:07.000Z", "max_stars_repo_stars_event_min_datetime": "2017-04-21T09:08:52.000Z", "num_tokens": 510, "size": 1400 }
{-# OPTIONS --without-K #-} module NTypes.Negation where open import FunExt open import NTypes open import Types ¬-isProp : ∀ {a} {A : Set a} → isProp (¬ A) ¬-isProp ¬a _ = funext λ a → 0-elim (¬a a)
{ "alphanum_fraction": 0.6386138614, "avg_line_length": 20.2, "ext": "agda", "hexsha": "db6c6be820f5255d12761f130ef4cb5dd55e1e23", "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": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "vituscze/HoTT-lectures", "max_forks_repo_path": "src/NTypes/Negation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "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": "vituscze/HoTT-lectures", "max_issues_repo_path": "src/NTypes/Negation.agda", "max_line_length": 43, "max_stars_count": null, "max_stars_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "vituscze/HoTT-lectures", "max_stars_repo_path": "src/NTypes/Negation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 72, "size": 202 }
-- Some theorems about operations on non-deterministic values module nondet-thms where open import bool open import bool-thms open import nat open import eq open import nat-thms open import functions open import nondet ---------------------------------------------------------------------- -- Theorems about values contained in non-deterministic values: -- A proof that x is value of the non-deterministic tree y: -- either it is equal to a deterministic value (ndrefl) -- or it is somewhere in the tree. -- If it is in the tree then we need to construct both branches of the tree, -- and a proof that x is in one of the branches -- A consequence of this is that any proof that x ∈ y contains the path -- to x in the tree. -- -- Example: -- hInCoin : H ∈ coin -- hInCoin = left (Val H) (Val T) ndrefl -- -- Since H is on the left side of coin, we use the left constructor -- The branches of the tree are (Val H) and (Val T), -- and since H is identically equal to H this completes the proof. data _∈_ {A : Set} (x : A) : (y : ND A) → Set where ndrefl : x ∈ (Val x) left : (l : ND A) → (r : ND A) → x ∈ l → x ∈ (l ?? r) right : (l : ND A) → (r : ND A) → x ∈ r → x ∈ (l ?? r) -- A basic inductive lemma that shows that ∈ is closed under function -- application. That is, if x ∈ nx, then f x ∈ mapND f nx -- -- Example: -- ndCons : ... → xs ∈ nxs → (x :: xs) ∈ mapND (_::_ x) nxs ∈-apply : {A B : Set} → (f : A → B) → (x : A) → (nx : ND A) → x ∈ nx → (f x) ∈ (mapND f nx) ∈-apply f x (Val .x) ndrefl = ndrefl ∈-apply f x (l ?? r) (left .l .r k) = left (mapND f l) (mapND f r) (∈-apply f x l k) ∈-apply f x (l ?? r) (right .l .r k) = right (mapND f l) (mapND f r) (∈-apply f x r k) ---------------------------------------------------------------------- -- Theorems about 'mapND': -- Combine two mapND applications into one: mapND-mapND : ∀ {A B C : Set} → (f : B → C) (g : A → B) (xs : ND A) → mapND f (mapND g xs) ≡ mapND (f ∘ g) xs mapND-mapND f g (Val x) = refl mapND-mapND f g (t1 ?? t2) rewrite mapND-mapND f g t1 | mapND-mapND f g t2 = refl ---------------------------------------------------------------------- -- Theorems about 'always': -- Extend validity of a function with a deterministic argument to validity of -- the corresponding non-deterministic function: always-mapND : ∀ {A : Set} → (p : A → 𝔹) (xs : ND A) → ((y : A) → p y ≡ tt) → always (mapND p xs) ≡ tt always-mapND _ (Val y) prf = prf y always-mapND p (t1 ?? t2) prf rewrite always-mapND p t1 prf | always-mapND p t2 prf = refl -- Extend validity of a function with a deterministic argument to validity of -- the corresponding non-deterministic function: always-with-nd-arg : ∀ {A : Set} → (p : A → ND 𝔹) (xs : ND A) → ((y : A) → always (p y) ≡ tt) → always (with-nd-arg p xs) ≡ tt always-with-nd-arg _ (Val y) prf = prf y always-with-nd-arg p (t1 ?? t2) prf rewrite always-with-nd-arg p t1 prf | always-with-nd-arg p t2 prf = refl -- Extend validity of a deterministic function to validity of -- corresponding function with non-deterministic result: always-toND : ∀ {A : Set} → (p : A → 𝔹) (x : A) → (p x) ≡ tt → always (toND p x) ≡ tt always-toND _ _ p = p -- Extend validity of a deterministic function to validity of -- corresponding non-deterministic function: always-det-to-nd : ∀ {A : Set} → (p : A → 𝔹) → ((y : A) → (p y) ≡ tt) → (xs : ND A) → always (det-to-nd p xs) ≡ tt always-det-to-nd p u xs = always-with-nd-arg (toND p) xs (λ x → always-toND p x (u x)) ---------------------------------------------------------------------- -- Theorems about 'satisfy': -- A theorem like filter-map in functional programming: satisfy-mapND : ∀ {A B : Set} → (f : A → B) (xs : ND A) (p : B → 𝔹) → (mapND f xs) satisfy p ≡ xs satisfy (p ∘ f) satisfy-mapND _ (Val x) _ = refl satisfy-mapND f (t1 ?? t2) p rewrite satisfy-mapND f t1 p | satisfy-mapND f t2 p = refl -- Extend validity of function with deterministic argument to validity of -- non-deterministic function: satisfy-with-nd-arg : ∀ {A B : Set} → (p : B → 𝔹) (f : A → ND B) (xs : ND A) → ((y : A) → (f y) satisfy p ≡ tt) → (with-nd-arg f xs) satisfy p ≡ tt satisfy-with-nd-arg _ _ (Val y) prf = prf y satisfy-with-nd-arg p f (t1 ?? t2) prf rewrite satisfy-with-nd-arg p f t1 prf | satisfy-with-nd-arg p f t2 prf = refl ---------------------------------------------------------------------- -- Theorems about 'every': mapNDval : ∀ (f : ℕ → ℕ) (v : ℕ) (x : ND ℕ) → every _=ℕ_ v x ≡ tt → every _=ℕ_ (f v) (mapND f x) ≡ tt mapNDval f v (Val x) u rewrite =ℕ-to-≡ {v} {x} u | =ℕ-refl (f x) = refl mapNDval f v (t1 ?? t2) u rewrite mapNDval f v t1 (&&-fst u) | mapNDval f v t2 (&&-snd {every _=ℕ_ v t1} {every _=ℕ_ v t2} u) = refl ---------------------------------------------------------------------- -- This theorms allows to weaken a predicate which is always satisfied: weak-always-predicate : ∀ {A : Set} → (p p1 : A → 𝔹) (xs : ND A) → xs satisfy p ≡ tt → xs satisfy (λ x → p1 x || p x) ≡ tt weak-always-predicate p p1 (Val x) u rewrite u | ||-tt (p1 x) = refl weak-always-predicate p p1 (t1 ?? t2) u rewrite weak-always-predicate p p1 t1 (&&-fst u) | weak-always-predicate p p1 t2 (&&-snd {t1 satisfy p} {t2 satisfy p} u) = refl ----------------------------------------------------------------------
{ "alphanum_fraction": 0.5410996189, "avg_line_length": 39.6474820144, "ext": "agda", "hexsha": "80500932f744010f4a470524f4ea4cb59c023f38", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7905bc4f625a94a725f9f6d8a2de1140bea5e471", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "phlummox/curry-tools", "max_forks_repo_path": "currypp/.cpm/packages/verify/imports/nondet-thms.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7905bc4f625a94a725f9f6d8a2de1140bea5e471", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "phlummox/curry-tools", "max_issues_repo_path": "currypp/.cpm/packages/verify/imports/nondet-thms.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "7905bc4f625a94a725f9f6d8a2de1140bea5e471", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "phlummox/curry-tools", "max_stars_repo_path": "currypp/.cpm/packages/verify/imports/nondet-thms.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1801, "size": 5511 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} open import Cubical.Core.Everything open import Cubical.Foundations.HLevels module Cubical.Algebra.Semigroup.Construct.Free {ℓ} (Aˢ : hSet ℓ) where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.Path open import Cubical.Algebra.Semigroup open import Cubical.Data.Empty.Polymorphic open import Cubical.Data.Prod open import Cubical.Relation.Binary.Reasoning.Equality A = ⟨ Aˢ ⟩ isSetA = Aˢ .snd ------------------------------------------------------------------------ -- The direct free semigroup type data FreeS′ : Type ℓ where inj : A → FreeS′ _•_ : Op₂ FreeS′ •-assoc : Associative _•_ squash : isSet FreeS′ elim : ∀ {ℓ′} {B : FreeS′ → Type ℓ′} → (∀ x → isSet (B x)) → (∀ x → B (inj x)) → (op : ∀ x y → B x → B y → B (x • y)) → (∀ x y z (a : B x) (b : B y) (c : B z) → PathP (λ i → B (•-assoc x y z i)) (op _ _ (op _ _ a b) c) (op _ _ a (op _ _ b c))) → (x : FreeS′) → B x elim isSetB f op assc (inj x) = f x elim isSetB f op assc (x • y) = op x y (elim isSetB f op assc x) (elim isSetB f op assc y) elim isSetB f op assc (•-assoc x y z i) = assc x y z (elim isSetB f op assc x) (elim isSetB f op assc y) (elim isSetB f op assc z) i elim isSetB f op assc (squash x y p q i j) = isOfHLevel→isOfHLevelDep 2 isSetB (elim isSetB f op assc x) (elim isSetB f op assc y) (cong (elim isSetB f op assc) p) (cong (elim isSetB f op assc) q) (squash x y p q) i j ------------------------------------------------------------------------ -- The simplified free semigroup type infixl 5 _□ infixr 4 _∶_ data FreeS : Type ℓ where _□ : A → FreeS _∶_ : A → FreeS → FreeS module FreeSPath where Cover : FreeS → FreeS → Type ℓ Cover (x □) (y □) = x ≡ y Cover (x □) (y ∶ ys) = ⊥ Cover (x ∶ xs) (y □) = ⊥ Cover (x ∶ xs) (y ∶ ys) = (x ≡ y) × Cover xs ys isPropCover : ∀ xs ys → isProp (Cover xs ys) isPropCover (x □) (y □) = isSetA x y isPropCover (x □) (y ∶ ys) = isProp⊥ isPropCover (x ∶ xs) (y □) = isProp⊥ isPropCover (x ∶ xs) (y ∶ ys) = isPropProd (isSetA x y) (isPropCover xs ys) reflCover : ∀ xs → Cover xs xs reflCover (x □) = refl reflCover (x ∶ xs) = refl , reflCover xs encode : ∀ xs ys → xs ≡ ys → Cover xs ys encode xs _ = J (λ ys _ → Cover xs ys) (reflCover xs) encodeRefl : ∀ xs → encode xs xs refl ≡ reflCover xs encodeRefl xs = JRefl (λ ys _ → Cover xs ys) (reflCover xs) decode : ∀ xs ys → Cover xs ys → xs ≡ ys decode (x □) (y □) p = cong _□ p decode (x □) (y ∶ ys) () decode (x ∶ xs) (y □) () decode (x ∶ xs) (y ∶ ys) (p , q) = cong₂ _∶_ p (decode xs ys q) decodeRefl : ∀ xs → decode xs xs (reflCover xs) ≡ refl decodeRefl (x □) = refl decodeRefl (x ∶ xs) = cong (cong₂ _∶_ refl) (decodeRefl xs) decodeEncode : ∀ xs ys → (p : xs ≡ ys) → decode xs ys (encode xs ys p) ≡ p decodeEncode xs _ = J (λ ys p → decode xs ys (encode xs ys p) ≡ p) (cong (decode xs xs) (encodeRefl xs) ∙ decodeRefl xs) isSetFreeS : isSet FreeS isSetFreeS x y = isOfHLevelRetract 1 (FreeSPath.encode x y) (FreeSPath.decode x y) (FreeSPath.decodeEncode x y) (FreeSPath.isPropCover x y) _++_ : Op₂ FreeS (x □) ++ ys = x ∶ ys (x ∶ xs) ++ ys = x ∶ xs ++ ys ++-assoc : Associative _++_ ++-assoc (x □) ys zs = refl ++-assoc (x ∶ xs) ys zs = cong (x ∶_) (++-assoc xs ys zs) ------------------------------------------------------------------------ -- Proving the two types are equivalent FreeS→FreeS′ : FreeS → FreeS′ FreeS→FreeS′ (x □) = inj x FreeS→FreeS′ (x ∶ xs) = inj x • FreeS→FreeS′ xs FreeS′→FreeS : FreeS′ → FreeS FreeS′→FreeS = elim (λ _ → isSetFreeS) _□ (λ _ _ → _++_) (λ _ _ _ → ++-assoc) FreeS→FreeS′→FreeS : retract FreeS→FreeS′ FreeS′→FreeS FreeS→FreeS′→FreeS (x □) = refl FreeS→FreeS′→FreeS (x ∶ xs) = cong (x ∶_) (FreeS→FreeS′→FreeS xs) ++-hom : Homomorphic₂ FreeS→FreeS′ _++_ _•_ ++-hom (x □) ys = refl ++-hom (x ∶ xs) ys = cong (inj x •_) (++-hom xs ys) ∙ sym (•-assoc (inj x) (FreeS→FreeS′ xs) (FreeS→FreeS′ ys)) FreeS′→FreeS→FreeS′ : section FreeS→FreeS′ FreeS′→FreeS FreeS′→FreeS→FreeS′ = elim (λ _ → isSet→isGroupoid squash _ _) (λ _ → refl) sectionOp (λ _ _ _ _ _ _ → isOfHLevelPathP' 0 (squash _ _) _ _ .fst) where sectionOp : ∀ x y → FreeS→FreeS′ (FreeS′→FreeS x) ≡ x → FreeS→FreeS′ (FreeS′→FreeS y) ≡ y → FreeS→FreeS′ (FreeS′→FreeS (x • y)) ≡ (x • y) sectionOp x y p q = FreeS→FreeS′ (FreeS′→FreeS (x • y)) ≡⟨⟩ FreeS→FreeS′ (FreeS′→FreeS x ++ FreeS′→FreeS y) ≡⟨ ++-hom (FreeS′→FreeS x) (FreeS′→FreeS y) ⟩ FreeS→FreeS′ (FreeS′→FreeS x) • FreeS→FreeS′ (FreeS′→FreeS y) ≡⟨ cong₂ _•_ p q ⟩ x • y ∎ FreeS≃FreeS′ : FreeS ≃ FreeS′ FreeS≃FreeS′ = isoToEquiv (iso FreeS→FreeS′ FreeS′→FreeS FreeS′→FreeS→FreeS′ FreeS→FreeS′→FreeS) FreeS≡FreeS′ : FreeS ≡ FreeS′ FreeS≡FreeS′ = ua FreeS≃FreeS′ ------------------------------------------------------------------------ -- Semigroup Algebra FreeS′-isSemigroup : IsSemigroup FreeS′ _•_ FreeS′-isSemigroup = record { isMagma = record { is-set = squash } ; assoc = •-assoc } FreeS-isSemigroup : IsSemigroup FreeS _++_ FreeS-isSemigroup = record { isMagma = record { is-set = isSetFreeS } ; assoc = ++-assoc } FreeSemigroup′ : Semigroup ℓ FreeSemigroup′ = record { isSemigroup = FreeS′-isSemigroup } FreeSemigroup : Semigroup ℓ FreeSemigroup = record { isSemigroup = FreeS-isSemigroup } EquivFreeS : SemigroupEquiv FreeSemigroup FreeSemigroup′ EquivFreeS = record { eq = FreeS≃FreeS′ ; isHom = ++-hom } FreeSemigroup≡ : FreeSemigroup ≡ FreeSemigroup′ FreeSemigroup≡ = uaSemigroup EquivFreeS
{ "alphanum_fraction": 0.5724008848, "avg_line_length": 31.9402173913, "ext": "agda", "hexsha": "0dcabe57d0c2204d4b90565a9220a916955eebeb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Algebra/Semigroup/Construct/Free.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Algebra/Semigroup/Construct/Free.agda", "max_line_length": 144, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Algebra/Semigroup/Construct/Free.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2280, "size": 5877 }
-- 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 module let-output where private VEHICLE_PROJECT_FILE = "TODO_projectFile" abstract e1 : let x = ⊤ in x e1 = checkProperty record { projectFile = VEHICLE_PROJECT_FILE ; propertyUUID = "TODO_propertyUUID" }
{ "alphanum_fraction": 0.6937119675, "avg_line_length": 21.4347826087, "ext": "agda", "hexsha": "3bc16925ed95aa1a7bb5aae191aa20ea9195f344", "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/let/let-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/let/let-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/let/let-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": 139, "size": 493 }
----------------------------------------------------------------------- -- This file formalizes the proof that Dial₂(Sets) is a full linear -- -- category. See Lemma 12 of the paper. -- ----------------------------------------------------------------------- module FullLinCat where open import prelude open import Dial2Sets -- Monoidal nat. trans. m⊤ : ⊤ → !⊤: m⊤ : Hom I (!ₒ I) m⊤ = id-set , (λ f → triv) , m⊤-cond where m⊤-cond : {u : ⊤} {l : 𝕃 ⊤} → ι u triv → all-pred (ι u) l m⊤-cond {triv}{[]} triv = triv m⊤-cond {triv}{triv :: l} triv = triv , m⊤-cond {triv}{l} triv -- These diagrams can be found on page 23 of the report. m⊤-diag₁ : _≡h_ {I}{ !ₒ (!ₒ I)} (comp {I} { !ₒ I} { !ₒ (!ₒ I)} m⊤ (!ₐ {I}{ !ₒ I} m⊤)) (comp {I} { !ₒ I} { !ₒ (!ₒ I)} m⊤ (δ {I})) m⊤-diag₁ = refl , refl m⊤-diag₂ : _≡h_ {I}{I} (comp {I}{ !ₒ I}{I} m⊤ (ε {I})) (id {I}) m⊤-diag₂ = refl , ext-set aux where aux : {a : ⊤} → triv ≡ a aux {triv} = refl -- The monoidal nat. trans. m : !A ⊗ !B → !(A ⊗ B): h'₁ : {U V X Y : Set} → (((V → X) × (U → Y)) *) → (V → U → (X *)) h'₁ [] v u = [] h'₁ ((j₁ , j₂) :: js) v u = (j₁ v) :: h'₁ js v u h'₁-append : ∀{U V X Y : Set}{l₁ l₂ : ((V → X) × (U → Y)) *}{v u} → (h'₁ l₁ v u) ++ (h'₁ l₂ v u) ≡ h'₁ (l₁ ++ l₂) v u h'₁-append {l₁ = []} = refl h'₁-append {l₁ = (j₁ , j₂) :: js}{l₂}{v}{u} rewrite h'₁-append {l₁ = js}{l₂}{v}{u} = refl h₁ : {U V X Y : Set} → ((U × V) → (((V → X) × (U → Y)) *)) → (V → U → (X *)) h₁ g v u = h'₁ (g (u , v)) v u h'₂ : {U V X Y : Set} → (((V → X) × (U → Y)) *) → (U → V → (Y *)) h'₂ [] u v = [] h'₂ ((j₁ , j₂) :: js) u v = (j₂ u) :: h'₂ js u v h'₂-append : ∀{U V X Y : Set}{l₁ l₂ : ((V → X) × (U → Y)) *}{v u} → (h'₂ l₁ v u) ++ (h'₂ l₂ v u) ≡ h'₂ (l₁ ++ l₂) v u h'₂-append {l₁ = []} = refl h'₂-append {l₁ = (j₁ , j₂) :: js}{l₂}{v}{u} rewrite h'₂-append {l₁ = js}{l₂}{v}{u} = refl h₂ : {U V X Y : Set} → ((U × V) → (((V → X) × (U → Y)) *)) → (U → V → (Y *)) h₂ g u v = h'₂ (g (u , v)) u v m⊗ : {A B : Obj} → Hom ((!ₒ A) ⊗ₒ (!ₒ B)) (!ₒ (A ⊗ₒ B)) m⊗ {U , X , α} {V , Y , β} = id-set , (λ g → h₁ g , h₂ g) , (λ {u}{y} x → m⊗-cond {u}{y} x) where m⊗-cond : {u : Σ U (λ x → V)} {y : Σ U (λ x → V) → 𝕃 (Σ (V → X) (λ x → U → Y))} → ((λ u₁ f → all-pred (α u₁) (f u₁)) ⊗ᵣ (λ u₁ f → all-pred (β u₁) (f u₁))) u ((λ v u₁ → h'₁ (y (u₁ , v)) v u₁) , (λ u₁ v → h'₂ (y (u₁ , v)) u₁ v)) → all-pred ((α ⊗ᵣ β) u) (y u) m⊗-cond {(u , v)}{g} (p₁ , p₂) = aux p₁ p₂ where aux : ∀{l} → all-pred (α u) (h'₁ l v u) → all-pred (β v) (h'₂ l u v) → all-pred ((α ⊗ᵣ β) (u , v)) l aux {[]} p₁ p₂ = triv aux {(j₁ , j₂) :: js} (p₁ , p₂) (p₃ , p₄) = (p₁ , p₃) , aux {js} p₂ p₄ -- The following diagrams can be found on page 24 of the report. m⊗-diag-A : ∀{A} → (m⊤ ⊗ₐ (id { !ₒ A})) ○ (m⊗ {I} {A} ○ !ₐ (λ⊗ {A})) ≡h λ⊗ { !ₒ A} m⊗-diag-A {U , X , α} = ext-set (λ {a} → aux {a}) , ext-set (λ {g} → cong2 _,_ refl (ext-set (aux' {g}))) where aux : {a : Σ ⊤ (λ x → U)} → snd (⟨ (λ x → x) , (λ x → x) ⟩ a) ≡ snd a aux {triv , u} = refl aux' : {g : U → X *} → {a : ⊤} → (λ v → h'₂ (map (λ x → (λ _ → triv) , (λ _ → x)) (g v)) a v) ≡ g aux' {g}{triv} = ext-set (λ {a} → aux'' {a}{g a}) where aux'' : {a : U}{l : X *} → h'₂ (map (λ x → (λ _ → triv) , (λ _ → x)) l) triv a ≡ l aux'' {u}{[]} = refl aux'' {u}{x :: xs} rewrite aux'' {u}{xs} = refl m⊗-diag-B : ∀{A} → ((id { !ₒ A}) ⊗ₐ m⊤) ○ (m⊗ {A} {I} ○ !ₐ (ρ⊗ {A})) ≡h ρ⊗ { !ₒ A} m⊗-diag-B {U , X , α} = (ext-set (λ {a} → aux {a})) , ext-set (λ {g} → cong2 _,_ (ext-set aux') refl) where aux : {a : Σ U (λ x → ⊤)} → fst (⟨ (λ x → x) , (λ x → x) ⟩ a) ≡ fst a aux {u , triv} = refl aux' : {g : U → X *} → {a : ⊤} → (λ u → h'₁ (map (λ x → (λ x₁ → x) , (λ x₁ → triv)) (g u)) a u) ≡ g aux' {g}{triv} = ext-set (λ {u} → aux'' {g u}{u}) where aux'' : ∀{l : X *}{u : U} → h'₁ (map (λ x → (λ x₁ → x) , (λ x₁ → triv)) l) triv u ≡ l aux'' {[]}{u} = refl aux'' {x :: xs}{u} rewrite aux'' {xs}{u} = refl m⊗-diag-C : ∀{A B} → β⊗ { !ₒ A} { !ₒ B} ○ m⊗ {B} {A} ≡h (m⊗ {A}{B}) ○ (!ₐ (β⊗ {A}{B})) m⊗-diag-C {U , X , α}{V , Y , β} = refl , ext-set (λ {g} → cong2 _,_ (ext-set (λ {v} → ext-set (λ {u} → aux {g (v , u)}{u}{v}))) (ext-set (λ {u} → ext-set (λ {v} → aux' {g (v , u)}{u}{v})))) where aux : ∀{l : 𝕃 (Σ (U → Y) (λ x → V → X))}{u v} → h'₂ l v u ≡ h'₁ (map twist-× l) v u aux {[]} = refl aux {(j₁ , j₂) :: js} {u}{v} rewrite aux {js}{u}{v} = refl aux' : ∀{l : 𝕃 (Σ (U → Y) (λ x → V → X))}{u v} → h'₁ l u v ≡ h'₂ (map twist-× l) u v aux' {[]} = refl aux' {(j₁ , j₂) :: js} {u}{v} rewrite aux' {js}{u}{v} = refl m⊗-diag-D : ∀{A B C : Obj} → α⊗ { !ₒ A} { !ₒ B} { !ₒ C} ○ id { !ₒ A} ⊗ₐ m⊗ {B} {C} ○ m⊗ {A} {B ⊗ₒ C} ≡h ((m⊗ {A}{B}) ⊗ₐ (id { !ₒ C})) ○ (m⊗ {A ⊗ₒ B}{C}) ○ (!ₐ (α⊗ {A}{B}{C})) m⊗-diag-D {U , X , α}{V , Y , β}{W , Z , γ} = ext-set aux , ext-set (λ {g} → cong2 _,_ (ext-set (λ {w} → cong2 _,_ (ext-set (λ {v} → ext-set (λ {u} → aux' {g (u , v , w)}{u}{v}{w}))) (ext-set (λ {u} → ext-set (λ {v} → aux'' {g (u , v , w)}{u}{v}{w}))))) (ext-set (λ {a} → aux''' {a}{g}))) where aux : {a : Σ (Σ U (λ x → V)) (λ x → W)} → ⟨ (λ x → x) , (λ x → x) ⟩ (lr-assoc-× a) ≡ lr-assoc-× (⟨ (λ x → x) , (λ x → x) ⟩ a) aux {((u , v) , w)} = refl aux' : ∀{l : 𝕃 (Σ (Σ V (λ x → W) → X) (λ x → U → Σ (W → Y) (λ x₁ → V → Z)))}{u v w} → h'₁ l (v , w) u ≡ h'₁ (h'₁ (map (Fα {V}{W}{X}{Y}{U}{V}{Z}) l) w (u , v)) v u aux' {[]} = refl aux' {(j₁ , j₂) :: js}{u}{v}{w} rewrite aux' {js}{u}{v}{w} = refl aux'' : ∀{l : 𝕃 (Σ (Σ V (λ x → W) → X) (λ x → U → Σ (W → Y) (λ x₁ → V → Z)))}{u v w} → h'₁ (h'₂ l u (v , w)) w v ≡ h'₂ (h'₁ (map (Fα {V}{W}{X}{Y}{U}{V}{Z}) l) w (u , v)) u v aux'' {[]} = refl aux'' {(j₁ , j₂) :: js}{u}{v}{w} with j₂ u ... | (j₃ , j₄) rewrite aux'' {js}{u}{v}{w} = refl aux''' : ∀{a : Σ U (λ x → V)}{g : Σ U (λ x → Σ V (λ x₁ → W)) → 𝕃 (Σ (Σ V (λ x → W) → X) (λ x → U → Σ (W → Y) (λ x₁ → V → Z)))} → (λ v → h'₂ (h'₂ (g (fst a , snd a , v)) (fst a) (snd a , v)) (snd a) v) ≡ (λ v → h'₂ (map (Fα {V}{W}{X}{Y}{U}{V}{Z}) (g (lr-assoc-× (a , v)))) a v) aux''' {u , v}{g} = ext-set (λ {w} → aux'''' {g (u , v , w)}{w}) where aux'''' : ∀{l : 𝕃 (Σ (Σ V (λ x → W) → X) (λ x → U → Σ (W → Y) (λ x₁ → V → Z)))}{w : W} → h'₂ (h'₂ l u (v , w)) v w ≡ h'₂ (map (Fα {V}{W}{X}{Y}{U}{V}{Z}) l) (u , v) w aux'''' {[]} = refl aux'''' {(j₁ , j₂) :: js}{w} with j₂ u ... | (j₃ , j₄) rewrite aux'''' {js}{w} = refl -- The following diagrams can be found on the bottom of page 26. m⊗-diag-E : ∀{A B : Obj} → ε {A} ⊗ₐ ε {B} ≡h (m⊗ {A}{B}) ○ (ε {A ⊗ₒ B}) m⊗-diag-E {U , X , α}{V , Y , β} = ext-set aux , ext-set aux' where aux : {a : Σ U (λ x → V)} → ⟨ (λ x → x) , (λ x → x) ⟩ a ≡ a aux {u , v} = refl aux' : {a : Σ (V → X) (λ x → U → Y)} → F⊗ {f = λ x → x} {λ x y → x :: []}{λ x → x} {λ x y → x :: []} a ≡ ((λ v u → h'₁ (a :: []) v u) , (λ u v → h'₂ (a :: []) u v)) aux' {j₁ , j₂} = refl m⊗-diag-F : ∀{A B : Obj} → δ {A} ⊗ₐ δ {B} ○ m⊗ { !ₒ A} { !ₒ B} ○ !ₐ (m⊗ {A} {B}) ≡h (m⊗ {A}{B}) ○ (δ {A ⊗ₒ B}) m⊗-diag-F {U , X , α}{V , Y , β} = ext-set aux , ext-set (λ {g} → cong2 _,_ (ext-set (λ {v} → ext-set (λ {u} → aux' {g (u , v)}{v}{u}))) (ext-set (λ {u} → ext-set (λ {v} → aux'' {g (u , v)}{v}{u})))) where aux : {a : Σ U (λ x → V)} → ⟨ (λ x → x) , (λ x → x) ⟩ a ≡ a aux {u , v} = refl aux' : ∀{l : 𝕃 (Σ U (λ x → V) → 𝕃 (Σ (V → X) (λ x → U → Y)))}{v u} → foldr (λ f → _++_ (f u)) [] (h'₁ (map (λ g₁ → (λ v₁ u₁ → h'₁ (g₁ (u₁ , v₁)) v₁ u₁) , (λ u₁ v₁ → h'₂ (g₁ (u₁ , v₁)) u₁ v₁)) l) v u) ≡ h'₁ (foldr (λ f → _++_ (f (u , v))) [] l) v u aux' {[]} = refl aux' {j :: js}{v}{u} with j (u , v) ... | [] rewrite aux' {js}{v}{u} = refl ... | (j₁ , j₂) :: js' rewrite aux' {js}{v}{u} = cong2 {a = j₁ v} _::_ refl (h'₁-append {l₁ = js'}) aux'' : ∀{l : 𝕃 (Σ U (λ x → V) → 𝕃 (Σ (V → X) (λ x → U → Y)))}{v u} → foldr (λ f → _++_ (f v)) [] (h'₂ (map (λ g₁ → (λ v₁ u₂ → h'₁ (g₁ (u₂ , v₁)) v₁ u₂) , (λ u₂ v₁ → h'₂ (g₁ (u₂ , v₁)) u₂ v₁)) l) u v) ≡ h'₂ (foldr (λ f → _++_ (f (u , v))) [] l) u v aux'' {[]} = refl aux'' {j :: js}{v}{u} with j (u , v) ... | [] = aux'' {js} ... | (j₁ , j₂) :: js' rewrite aux'' {js}{v}{u} = cong2 {a = j₂ u} _::_ refl (h'₂-append {l₁ = js'}) -- Now we show that whenever (!A , δ) is a free comonoid, then we have -- distinguished nat. trans. e : !A → ⊤ and d : !A → !A ⊗ !A. These -- constructions and their diagrams can be found on page 27 of the -- report. e : {A : Obj} → Hom (!ₒ A) I e {U , X , α} = (λ x → triv) , (λ x u → []) , (λ {u}{y} x → e-cond {u}{y} x) where e-cond : {u : U} {y : ⊤} → ⊤ → ι triv y e-cond {u}{triv} triv = triv θ : ∀{U X : Set} → ((U → U → (X *)) × (U → U → (X *))) → U → X * θ {U}{X} (f , g) u = (f u u) ++ (g u u) d : {A : Obj} → Hom (!ₒ A) ((!ₒ A) ⊗ₒ (!ₒ A)) d {U , X , α} = (λ x → (x , x)) , θ , d-cond where d-cond : {u : U} {y : Σ (U → U → 𝕃 X) (λ x → U → U → 𝕃 X)} → all-pred (α u) (θ y u) → ((λ u₁ f → all-pred (α u₁) (f u₁)) ⊗ᵣ (λ u₁ f → all-pred (α u₁) (f u₁))) (u , u) y d-cond {u}{f , g} = aux where aux : ∀{l₁ l₂ : X *} → all-pred (α u) (l₁ ++ l₂) → ((all-pred (α u) l₁) × (all-pred (α u) l₂)) aux {[]} p = triv , p aux {x :: xs} (p₁ , p₂) = (p₁ , fst (aux {xs} p₂)) , snd (aux {xs} p₂) -- e must be a monoidal nat. trans. e-diag-G : ∀{A B : Obj}{f : Hom A B} → !ₐ f ○ e {B} ≡h e {A} e-diag-G {U , X , α}{V , Y , β}{(f , F , _)} = refl , refl e-diag-H : _≡h_ {I}{I} (comp {I}{ !ₒ I}{I} m⊤ (e {I})) (id {I}) e-diag-H = ext-set aux , ext-set aux where aux : {a : ⊤} → triv ≡ a aux {triv} = refl e-diag-I : ∀{A B : Obj} → m⊗ {A} {B} ○ e {A ⊗ₒ B} ≡h e {A} ⊗ₐ e {B} ○ λ⊗ {I} e-diag-I {U , X , α}{V , Y , β} = (ext-set (λ {a} → aux {a})) , refl where aux : {a : Σ U (λ x → V)} → triv ≡ snd (⟨ (λ x → triv) , (λ x → triv) ⟩ a) aux {u , v} = refl -- d must be a monoidal nat. trans. The following diagrams can be -- found on page 28 of the report. d-diag-J : ∀{A B : Obj}{f : Hom A B} → !ₐ f ○ d {B} ≡h (d {A}) ○ ((!ₐ f) ⊗ₐ (!ₐ f)) d-diag-J {U , X , α}{V , Y , β}{f , F , _} = refl , ext-set (λ {a} → aux {a}) where aux : {a : Σ (V → V → 𝕃 Y) (λ x → V → V → 𝕃 Y)} → (λ u → map F (θ a (f u))) ≡ θ (F⊗ {f = f} {λ g u → map F (g (f u))} {f} {λ g u → map F (g (f u))} a) aux {j₁ , j₂} = ext-set (λ {u} → map-append F (j₁ (f u) (f u)) (j₂ (f u) (f u))) d-diag-K : _≡h_ {I}{(!ₒ I) ⊗ₒ (!ₒ I)} (comp {I}{ !ₒ I}{(!ₒ I) ⊗ₒ (!ₒ I)} m⊤ (d {I})) (comp {I}{I ⊗ₒ I}{(!ₒ I) ⊗ₒ (!ₒ I)} (λ⁻¹⊗ {I}) (m⊤ ⊗ₐ m⊤)) d-diag-K = ext-set aux , ext-set (λ {a} → aux' {a}) where aux : {a : ⊤} → (a , a) ≡ (triv , a) aux {triv} = refl aux' : {a : Σ (⊤ → ⊤ → 𝕃 ⊤) (λ x → ⊤ → ⊤ → 𝕃 ⊤)} → triv ≡ (snd (F⊗ {f = λ x → x} {λ f → triv} {λ x → x} {λ f → triv} a) triv) aux' {j₁ , j₂} = refl iso : {A B : Obj} → Hom (((!ₒ A) ⊗ₒ (!ₒ A)) ⊗ₒ ((!ₒ B) ⊗ₒ (!ₒ B))) (((!ₒ A) ⊗ₒ (!ₒ B)) ⊗ₒ ((!ₒ A) ⊗ₒ (!ₒ B))) iso {A}{B} = α⊗ {(!ₒ A)} {(!ₒ A)} {(!ₒ B) ⊗ₒ (!ₒ B)} ○ (id {(!ₒ A)} ⊗ₐ α⊗-inv {(!ₒ A)} {(!ₒ B)} {(!ₒ B)} ○ (id {(!ₒ A)} ⊗ₐ (β⊗ {(!ₒ A)} {(!ₒ B)} ⊗ₐ id {(!ₒ B)}) ○ (id {(!ₒ A)} ⊗ₐ α⊗ {(!ₒ B)} {(!ₒ A)} {(!ₒ B)} ○ α⊗-inv {(!ₒ A)} {(!ₒ B)} {(!ₒ A) ⊗ₒ (!ₒ B)}))) d-diag-L : ∀{A B : Obj} → m⊗ {A} {B} ○ d {A ⊗ₒ B} ≡h ((d {A}) ⊗ₐ (d {B})) ○ (iso ○ ((m⊗ {A}{B}) ⊗ₐ (m⊗ {A}{B}))) d-diag-L {U , X , α}{V , Y , β} = ext-set aux , ext-set (λ {a} → aux' {a}) where aux : {a : U × V} → (a , a) ≡ ⟨ (λ x → x) , (λ x → x) ⟩ (rl-assoc-× (⟨ (λ x → x) , lr-assoc-× ⟩ (⟨ (λ x → x) , ⟨ twist-× , (λ x → x) ⟩ ⟩ (⟨ (λ x → x) , rl-assoc-× ⟩ (lr-assoc-× (⟨ (λ x → x , x) , (λ x → x , x) ⟩ a)))))) aux {u , v} = refl -- The type of aux' is the fully expanded version of the following type: -- ((λ v u → h'₁ (θ a (u , v)) v u) , (λ u v → h'₂ (θ a (u , v)) u v)) -- ≡ ((λ v u → fst (fst (F⊗ a) (u , v)) v u ++ fst (snd (F⊗ a) (u , v)) v u) -- , -- (λ u u₁ → snd (fst (F⊗ a) (u , u₁)) u u₁ ++ snd (snd (F⊗ a) (u , u₁)) u u₁). -- Agda's type inference algorithm was having trouble inferring the annotations, and -- so we used Agda to generate the fully expanded version. aux' : {a : Σ {_} {_} (Σ {_} {_} U (λ x → V) → Σ {_} {_} U (λ x → V) → 𝕃 {_} (Σ {_} {_} (V → X) (λ x → U → Y))) (λ x → Σ {_} {_} U (λ x₁ → V) → Σ {_} {_} U (λ x₁ → V) → 𝕃 {_} (Σ {_} {_} (V → X) (λ x₁ → U → Y)))} → _≡_ {_} {Σ {_} {_} (V → U → 𝕃 {_} X) (λ x → U → V → 𝕃 {_} Y)} ((λ v u → h'₁ {U} {V} {X} {Y} (θ {Σ {_} {_} U (λ x → V)} {Σ {_} {_} (V → X) (λ x → U → Y)} a (u , v)) v u) , (λ u v → h'₂ {U} {V} {X} {Y} (θ {Σ {_} {_} U (λ x → V)} {Σ {_} {_} (V → X) (λ x → U → Y)} a (u , v)) u v)) ((λ v u → _++_ {_} {X} (fst {_} {_} {V → U → 𝕃 {_} X} {U → V → 𝕃 {_} Y} (fst {_} {_} {Σ {_} {_} U (λ x → V) → Σ {_} {_} (V → U → 𝕃 {_} X) (λ x → U → V → 𝕃 {_} Y)} {Σ {_} {_} U (λ x → V) → Σ {_} {_} (V → U → 𝕃 {_} X) (λ x → U → V → 𝕃 {_} Y)} (F⊗ {Σ {_} {_} U (λ x → V)} {Σ {_} {_} U (λ x → V) → 𝕃 {_} (Σ {_} {_} (V → X) (λ x → U → Y))} {Σ {_} {_} U (λ x → V)} {Σ {_} {_} U (λ x → V) → 𝕃 {_} (Σ {_} {_} (V → X) (λ x → U → Y))} {Σ {_} {_} U (λ x → V)} {Σ {_} {_} (V → U → 𝕃 {_} X) (λ x → U → V → 𝕃 {_} Y)} {Σ {_} {_} U (λ x → V)} {Σ {_} {_} (V → U → 𝕃 {_} X) (λ x → U → V → 𝕃 {_} Y)} {λ x → x} {λ g → (λ v₁ u₁ → h'₁ {U} {V} {X} {Y} (g (u₁ , v₁)) v₁ u₁) , (λ u₁ v₁ → h'₂ {U} {V} {X} {Y} (g (u₁ , v₁)) u₁ v₁)} {λ x → x} {λ g → (λ v₁ u₁ → h'₁ {U} {V} {X} {Y} (g (u₁ , v₁)) v₁ u₁) , (λ u₁ v₁ → h'₂ {U} {V} {X} {Y} (g (u₁ , v₁)) u₁ v₁)} a) (u , v)) v u) (fst {_} {_} {V → U → 𝕃 {_} X} {U → V → 𝕃 {_} Y} (snd {_} {_} {Σ {_} {_} U (λ x → V) → Σ {_} {_} (V → U → 𝕃 {_} X) (λ x → U → V → 𝕃 {_} Y)} {Σ {_} {_} U (λ x → V) → Σ {_} {_} (V → U → 𝕃 {_} X) (λ x → U → V → 𝕃 {_} Y)} (F⊗ {Σ {_} {_} U (λ x → V)} {Σ {_} {_} U (λ x → V) → 𝕃 {_} (Σ {_} {_} (V → X) (λ x → U → Y))} {Σ {_} {_} U (λ x → V)} {Σ {_} {_} U (λ x → V) → 𝕃 {_} (Σ {_} {_} (V → X) (λ x → U → Y))} {Σ {_} {_} U (λ x → V)} {Σ {_} {_} (V → U → 𝕃 {_} X) (λ x → U → V → 𝕃 {_} Y)} {Σ {_} {_} U (λ x → V)} {Σ {_} {_} (V → U → 𝕃 {_} X) (λ x → U → V → 𝕃 {_} Y)} {λ x → x} {λ g → (λ v₁ u₁ → h'₁ {U} {V} {X} {Y} (g (u₁ , v₁)) v₁ u₁) , (λ u₁ v₁ → h'₂ {U} {V} {X} {Y} (g (u₁ , v₁)) u₁ v₁)} {λ x → x} {λ g → (λ v₁ u₁ → h'₁ {U} {V} {X} {Y} (g (u₁ , v₁)) v₁ u₁) , (λ u₁ v₁ → h'₂ {U} {V} {X} {Y} (g (u₁ , v₁)) u₁ v₁)} a) (u , v)) v u)) , (λ u u₁ → _++_ {_} {Y} (snd {_} {_} {V → U → 𝕃 {_} X} {U → V → 𝕃 {_} Y} (fst {_} {_} {Σ {_} {_} U (λ x → V) → Σ {_} {_} (V → U → 𝕃 {_} X) (λ x → U → V → 𝕃 {_} Y)} {Σ {_} {_} U (λ x → V) → Σ {_} {_} (V → U → 𝕃 {_} X) (λ x → U → V → 𝕃 {_} Y)} (F⊗ {Σ {_} {_} U (λ x → V)} {Σ {_} {_} U (λ x → V) → 𝕃 {_} (Σ {_} {_} (V → X) (λ x → U → Y))} {Σ {_} {_} U (λ x → V)} {Σ {_} {_} U (λ x → V) → 𝕃 {_} (Σ {_} {_} (V → X) (λ x → U → Y))} {Σ {_} {_} U (λ x → V)} {Σ {_} {_} (V → U → 𝕃 {_} X) (λ x → U → V → 𝕃 {_} Y)} {Σ {_} {_} U (λ x → V)} {Σ {_} {_} (V → U → 𝕃 {_} X) (λ x → U → V → 𝕃 {_} Y)} {λ x → x} {λ g → (λ v u₂ → h'₁ {U} {V} {X} {Y} (g (u₂ , v)) v u₂) , (λ u₂ v → h'₂ {U} {V} {X} {Y} (g (u₂ , v)) u₂ v)} {λ x → x} {λ g → (λ v u₂ → h'₁ {U} {V} {X} {Y} (g (u₂ , v)) v u₂) , (λ u₂ v → h'₂ {U} {V} {X} {Y} (g (u₂ , v)) u₂ v)} a) (u , u₁)) u u₁) (snd {_} {_} {V → U → 𝕃 {_} X} {U → V → 𝕃 {_} Y} (snd {_} {_} {Σ {_} {_} U (λ x → V) → Σ {_} {_} (V → U → 𝕃 {_} X) (λ x → U → V → 𝕃 {_} Y)} {Σ {_} {_} U (λ x → V) → Σ {_} {_} (V → U → 𝕃 {_} X) (λ x → U → V → 𝕃 {_} Y)} (F⊗ {Σ {_} {_} U (λ x → V)} {Σ {_} {_} U (λ x → V) → 𝕃 {_} (Σ {_} {_} (V → X) (λ x → U → Y))} {Σ {_} {_} U (λ x → V)} {Σ {_} {_} U (λ x → V) → 𝕃 {_} (Σ {_} {_} (V → X) (λ x → U → Y))} {Σ {_} {_} U (λ x → V)} {Σ {_} {_} (V → U → 𝕃 {_} X) (λ x → U → V → 𝕃 {_} Y)} {Σ {_} {_} U (λ x → V)} {Σ {_} {_} (V → U → 𝕃 {_} X) (λ x → U → V → 𝕃 {_} Y)} {λ x → x} {λ g → (λ v u₂ → h'₁ {U} {V} {X} {Y} (g (u₂ , v)) v u₂) , (λ u₂ v → h'₂ {U} {V} {X} {Y} (g (u₂ , v)) u₂ v)} {λ x → x} {λ g → (λ v u₂ → h'₁ {U} {V} {X} {Y} (g (u₂ , v)) v u₂) , (λ u₂ v → h'₂ {U} {V} {X} {Y} (g (u₂ , v)) u₂ v)} a) (u , u₁)) u u₁))) aux' {j₁ , j₂} = cong2 {a = λ v u → h'₁ (j₁ (u , v) (u , v) ++ j₂ (u , v) (u , v)) v u} _,_ (ext-set (λ {v} → ext-set (λ {u} → sym (h'₁-append {l₁ = j₁ (u , v) (u , v)} {l₂ = j₂ (u , v) (u , v)}{v}{u})))) (ext-set (λ {u} → (ext-set (λ {v} → sym (h'₂-append {l₁ = j₁ (u , v) (u , v)} {l₂ = j₂ (u , v) (u , v)}{u}{v}))))) -- Show that (!A, d, e) is a commutative comonoid. The following -- diagrams can be found on page 29 of the report. de-diag-M : ∀{A : Obj} → ρ⊗-inv {(!ₒ A)} ≡h (d {A}) ○ ((id {(!ₒ A)}) ⊗ₐ (e {A})) de-diag-M {U , X , α} = refl , ext-set (λ {a} → aux {a}) where aux : {a : Σ (⊤ → U → 𝕃 X) (λ x → U → ⊤)} → (fst a triv) ≡ (θ (F⊗ {f = λ x → x} {λ x → x} {λ x → triv} {λ x u → []} a)) aux {j₁ , j₂} = ext-set (λ {u} → sym (++[] (j₁ triv u))) de-diag-N : ∀{A : Obj} → λ⁻¹⊗ {(!ₒ A)} ≡h (d {A}) ○ ((e {A}) ⊗ₐ (id {(!ₒ A)})) de-diag-N {U , X , α} = refl , ext-set (λ {a} → aux {a}) where aux : {a : Σ (U → ⊤) (λ x → ⊤ → U → 𝕃 X)} → _≡_ (snd a triv) (θ (F⊗ {f = λ x → triv} {λ x u → []} {λ x → x} {λ x → x} a)) aux {j₁ , j₂} = refl de-diag-O : ∀{A : Obj} → d {A} ≡h (d {A}) ○ (β⊗ {(!ₒ A)}{(!ₒ A)}) de-diag-O {U , X , α} = refl , ext-set (λ {a} → aux {a}) where aux : {a : Σ (U → U → 𝕃 X) (λ x → U → U → 𝕃 X)} → θ a ≡ θ (twist-× a) aux {j₁ , j₂} = ext-set (λ {u} → *-comm {l₁ = j₁ u u}{j₂ u u}) de-diag-P : ∀{A : Obj} → (d {A}) ○ (((d {A}) ⊗ₐ (id {(!ₒ A)})) ○ (α⊗ {(!ₒ A)}{(!ₒ A)}{(!ₒ A)})) ≡h (d {A}) ○ ((id {(!ₒ A)}) ⊗ₐ (d {A})) de-diag-P {U , X , α} = refl , ext-set ((λ {a} → aux {a})) where aux : {a : Σ (Σ U (λ x → U) → U → 𝕃 X) (λ x → U → Σ (U → U → 𝕃 X) (λ x₁ → U → U → 𝕃 X))} → (θ (F⊗ {f = λ x → x , x} {θ {U} {X}} {λ x → x} {λ x → x} (Fα {U} {U} {U → 𝕃 X} {U → 𝕃 X} {U} {U} {U → 𝕃 X} a))) ≡ (θ (F⊗ {Σ U (λ x → U)} {U → 𝕃 X} {U} {Σ (U → U → 𝕃 X) (λ x → U → U → 𝕃 X)} {U} {U → 𝕃 X} {U} {U → 𝕃 X} {λ x → x} {λ x → x} {λ x → x , x} {θ} a)) aux {x , y} = ext-set (λ {u} → aux') where aux' : ∀{u : U} → (x (u , u) u ++ fst (y u) u u) ++ snd (y u) u u ≡ x (u , u) u ++ θ (y u) u aux' {u} with y u ... | j₁ , j₂ = ++-assoc (x (u , u) u) (j₁ u u) (j₂ u u) -- The morphism e and d must be a coalgebra morphisms. The following -- diagram can be found on page 30 of the report. e-diag-Q : ∀{A : Obj} → δ {A} ○ !ₐ (e {A}) ≡h (e {A}) ○ m⊤ e-diag-Q {U , X , α} = refl , ext-set (λ {a} → ext-set (λ {u} → aux {a triv})) where aux : ∀{l : ⊤ *}{u : U} → _≡_ {_} {𝕃 {_} X} (foldr {_} {_} {U → 𝕃 {_} X} {𝕃 {_} X} (λ f → _++_ {_} {X} (f u)) [] (map {_} {_} {⊤} {U → 𝕃 {_} X} (λ x u₁ → []) l)) [] aux {[]} = refl aux {x :: l}{u} = aux {l}{u} d-diag-R : ∀{A : Obj} → δ {A} ○ !ₐ (d {A}) ≡h (d {A}) ○ (((δ {A}) ⊗ₐ (δ {A})) ○ (m⊗ {(!ₒ A)}{(!ₒ A)})) d-diag-R {U , X , α} = refl , ext-set (λ {a} → ext-set (λ {u} → aux {a (u , u)}{u})) where aux : ∀{l : 𝕃 (Σ (U → U → 𝕃 X) (λ x → U → U → 𝕃 X))}{u : U} → foldr (λ f → _++_ (f u)) [] (map θ l) ≡ foldr (λ f → _++_ (f u)) [] (h'₁ l u u) ++ foldr (λ f → _++_ (f u)) [] (h'₂ l u u) aux {[]} = refl aux {(j₁ , j₂) :: js}{u} rewrite ++-assoc (j₁ u u) (foldr (λ f → _++_ (f u)) [] (h'₁ js u u)) (j₂ u u ++ foldr (λ f → _++_ (f u)) [] (h'₂ js u u)) | sym (++-assoc (foldr (λ f → _++_ (f u)) [] (h'₁ js u u)) (j₂ u u) (foldr (λ f → _++_ (f u)) [] (h'₂ js u u))) | *-comm {l₁ = foldr (λ f → _++_ (f u)) [] (h'₁ js u u)}{j₂ u u} | ++-assoc (j₂ u u) (foldr (λ f → _++_ (f u)) [] (h'₁ js u u)) (foldr (λ f → _++_ (f u)) [] (h'₂ js u u)) | sym (++-assoc (j₁ u u) (j₂ u u) (foldr (λ f → _++_ (f u)) [] (h'₁ js u u) ++ foldr (λ f → _++_ (f u)) [] (h'₂ js u u))) | aux {js}{u} = refl -- The following diagrams can be found on page 31 of the report. diag-S : ∀{A B : Obj}{f : Hom (!ₒ A) (!ₒ B)} → ((δ {A}) ○ (!ₐ f)) ≡h (f ○ (δ {B})) → f ○ (e {B}) ≡h e {A} diag-S {U , X , _}{V , Y , _}{f , F , _} (p , p') = refl , ext-set (λ {a} → ext-set (λ {u} → sym (congf2 {b = λ _ → []} {λ _ → []}{u}{u} p' refl refl))) diag-T : ∀{A B : Obj}{f : Hom (!ₒ A) (!ₒ B)} → ((δ {A}) ○ (!ₐ f)) ≡h (f ○ (δ {B})) → f ○ d {B} ≡h (d {A}) ○ (f ⊗ₐ f) diag-T {U , X , _}{V , Y , _}{f , F , _} (p , p') = refl , ext-set (λ {a} → aux {a}) where aux : {a : Σ (V → V → 𝕃 Y) (λ x → V → V → 𝕃 Y)} → F (θ a) ≡ θ (F⊗ {f = f}{F}{f}{F} a) aux {j₁ , j₂} = ext-set (λ {u} → aux' {u}) where aux'' : ∀{j₁ j₂ : V → V → 𝕃 Y} → (λ u₁ → j₁ u₁ u₁ ++ j₂ u₁ u₁ ++ []) ≡ λ u₁ → j₁ u₁ u₁ ++ j₂ u₁ u₁ aux'' {j₁}{j₂} = ext-set (λ {v} → cong2 {a = j₁ v v} {j₁ v v} {j₂ v v ++ []} {j₂ v v} _++_ refl (++[] (j₂ v v))) aux' : ∀{u : U} → F (λ u₁ → j₁ u₁ u₁ ++ j₂ u₁ u₁) u ≡ F (j₁ (f u)) u ++ F (j₂ (f u)) u aux' {u} with congf2 {b = λ x → j₁ x :: j₂ x :: []} {λ x → j₁ x :: j₂ x :: []} {u}{u} p' refl refl ... | p'' rewrite ++[] (F (j₂ (f u)) u) | aux'' {j₁}{j₂} = sym p''
{ "alphanum_fraction": 0.3054368471, "avg_line_length": 36.8934306569, "ext": "agda", "hexsha": "2a190016731a4dfda93158a08e5ca2ab00fab347", "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": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "heades/AUGL", "max_forks_repo_path": "dialectica-cats/FullLinCat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "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": "heades/AUGL", "max_issues_repo_path": "dialectica-cats/FullLinCat.agda", "max_line_length": 98, "max_stars_count": null, "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "heades/AUGL", "max_stars_repo_path": "dialectica-cats/FullLinCat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 11927, "size": 25272 }
open import Nat open import Prelude open import List open import core -- erasure of cursor in the types and expressions is defined in the paper, -- and in the core file, as a function on zexpressions. because of the -- particular encoding of all the judgments as datatypes and the agda -- semantics for pattern matching, it is sometimes also convenient to have -- a judgemental form of erasure. -- -- this file describes the obvious encoding of the view this function as a -- jugement relating input and output as a datatype, and argues that this -- encoding is correct by showing a isomorphism with the function. we also -- show that as a correlary, the judgement is well moded at (∀, ∃!), which -- is unsurprising if the jugement is written correctly. -- -- taken together, these proofs allow us to move between the judgemental -- form of erasure and the function form when it's convenient. -- -- while we do not have it, the argument given here is sufficiently strong -- to produce an equality between these things in a system with the -- univalence axiom, as described in the homotopy type theory book and the -- associated work done in agda. module judgemental-erase where --cursor erasure for types, as written in the paper _◆t : τ̂ → τ̇ ▹ t ◃ ◆t = t (t1 ==>₁ t2) ◆t = (t1 ◆t) ==> t2 (t1 ==>₂ t2) ◆t = t1 ==> (t2 ◆t) --cursor erasure for expressions, as written in the paper _◆e : ê → ė ▹ x ◃ ◆e = x (e ·:₁ t) ◆e = (e ◆e) ·: t (e ·:₂ t) ◆e = e ·: (t ◆t) ·λ x e ◆e = ·λ x (e ◆e) (e1 ∘₁ e2) ◆e = (e1 ◆e) ∘ e2 (e1 ∘₂ e2) ◆e = e1 ∘ (e2 ◆e) (e1 ·+₁ e2) ◆e = (e1 ◆e) ·+ e2 (e1 ·+₂ e2) ◆e = e1 ·+ (e2 ◆e) ⦇⌜ e ⌟⦈ ◆e = ⦇⌜ e ◆e ⌟⦈ -- this pair of theorems moves from the judgmental form to the function form erase-t◆ : {t : τ̂} {tr : τ̇} → (erase-t t tr) → (t ◆t == tr) erase-t◆ ETTop = refl erase-t◆ (ETArrL p) = ap1 (λ x → x ==> _) (erase-t◆ p) erase-t◆ (ETArrR p) = ap1 (λ x → _ ==> x) (erase-t◆ p) erase-e◆ : {e : ê} {er : ė} → (erase-e e er) → (e ◆e == er) erase-e◆ EETop = refl erase-e◆ (EEAscL p) with erase-e◆ p erase-e◆ (EEAscL p) | refl = refl -- ap1 (λ x → x ·: _) (erase-e◆ p) erase-e◆ (EEAscR p) = ap1 (λ x → _ ·: x) (erase-t◆ p) erase-e◆ (EELam p) = ap1 (λ e → ·λ _ e) (erase-e◆ p) erase-e◆ (EEApL p) = ap1 (λ x → x ∘ _) (erase-e◆ p) erase-e◆ (EEApR p) = ap1 (λ x → _ ∘ x) (erase-e◆ p) erase-e◆ (EEPlusL p) = ap1 (λ x → x ·+ _) (erase-e◆ p) erase-e◆ (EEPlusR p) = ap1 (λ x → _ ·+ x) (erase-e◆ p) erase-e◆ (EENEHole p) = ap1 (λ x → ⦇⌜ x ⌟⦈) (erase-e◆ p) -- this pair of theorems moves back from judgmental form to the function form ◆erase-t : (t : τ̂) (tr : τ̇) → (t ◆t == tr) → (erase-t t tr) ◆erase-t ▹ x ◃ .x refl = ETTop ◆erase-t (t ==>₁ x) (.(t ◆t) ==> .x) refl with ◆erase-t t (t ◆t) refl ... | ih = ETArrL ih ◆erase-t (x ==>₂ t) (.x ==> .(t ◆t)) refl with ◆erase-t t (t ◆t) refl ... | ih = ETArrR ih ◆erase-e : (e : ê) (er : ė) → (e ◆e == er) → (erase-e e er) ◆erase-e ▹ x ◃ .x refl = EETop ◆erase-e (e ·:₁ x) .((e ◆e) ·: x) refl with ◆erase-e e (e ◆e) refl ... | ih = EEAscL ih ◆erase-e (x ·:₂ x₁) .(x ·: (x₁ ◆t)) refl = EEAscR (◆erase-t x₁ (x₁ ◆t) refl) ◆erase-e (·λ x e) .(·λ x (e ◆e)) refl = EELam (◆erase-e e (e ◆e) refl) ◆erase-e (e ∘₁ x) .((e ◆e) ∘ x) refl = EEApL (◆erase-e e (e ◆e) refl) ◆erase-e (x ∘₂ e) .(x ∘ (e ◆e)) refl = EEApR (◆erase-e e (e ◆e) refl) ◆erase-e (e ·+₁ x) .((e ◆e) ·+ x) refl = EEPlusL (◆erase-e e (e ◆e) refl) ◆erase-e (x ·+₂ e) .(x ·+ (e ◆e)) refl = EEPlusR (◆erase-e e (e ◆e) refl) ◆erase-e ⦇⌜ e ⌟⦈ .(⦇⌜ e ◆e ⌟⦈) refl = EENEHole (◆erase-e e (e ◆e) refl) -- jugemental erasure for both types and terms only has one proof for -- relating the a term to its non-judgemental erasure t-contr : (t : τ̂) → (x y : erase-t t (t ◆t)) → x == y t-contr ▹ x ◃ ETTop ETTop = refl t-contr (t ==>₁ x) (ETArrL y) (ETArrL z) = ap1 ETArrL (t-contr t y z) t-contr (x ==>₂ t) (ETArrR y) (ETArrR z) = ap1 ETArrR (t-contr t y z) e-contr : (e : ê) → (x y : erase-e e (e ◆e)) → x == y e-contr ▹ x ◃ EETop EETop = refl e-contr (e ·:₁ x) (EEAscL x₁) (EEAscL y) = ap1 EEAscL (e-contr e x₁ y) e-contr (x₁ ·:₂ x) (EEAscR x₂) (EEAscR x₃) = ap1 EEAscR (t-contr x x₂ x₃) e-contr (·λ x e) (EELam x₁) (EELam y) = ap1 EELam (e-contr e x₁ y) e-contr (e ∘₁ x) (EEApL x₁) (EEApL y) = ap1 EEApL (e-contr e x₁ y) e-contr (x ∘₂ e) (EEApR x₁) (EEApR y) = ap1 EEApR (e-contr e x₁ y) e-contr (e ·+₁ x) (EEPlusL x₁) (EEPlusL y) = ap1 EEPlusL (e-contr e x₁ y) e-contr (x ·+₂ e) (EEPlusR x₁) (EEPlusR y) = ap1 EEPlusR (e-contr e x₁ y) e-contr ⦇⌜ e ⌟⦈ (EENEHole x) (EENEHole y) = ap1 EENEHole (e-contr e x y) -- taken together, these four theorems demonstrate that both round-trips -- of the above functions are stable up to == erase-trt1 : (t : τ̂) (tr : τ̇) → (x : t ◆t == tr) → (erase-t◆ (◆erase-t t tr x)) == x erase-trt1 ▹ x ◃ .x refl = refl erase-trt1 (t ==>₁ x) (.(t ◆t) ==> .x) refl with erase-t◆ (◆erase-t t (t ◆t) refl) erase-trt1 (t ==>₁ x) (.(t ◆t) ==> .x) refl | refl = refl erase-trt1 (x ==>₂ t) (.x ==> .(t ◆t)) refl with erase-t◆ (◆erase-t t (t ◆t) refl) erase-trt1 (x ==>₂ t) (.x ==> .(t ◆t)) refl | refl = refl erase-trt2 : (t : τ̂) (tr : τ̇) → (x : erase-t t tr) → ◆erase-t t tr (erase-t◆ x) == x erase-trt2 .(▹ tr ◃) tr ETTop = refl erase-trt2 _ _ (ETArrL ETTop) = refl erase-trt2 (t1 ==>₁ t2) _ (ETArrL x) with erase-t◆ x erase-trt2 (t1 ==>₁ t2) _ (ETArrL x) | refl = ap1 ETArrL (t-contr _ (◆erase-t t1 (t1 ◆t) refl) x) erase-trt2 (t1 ==>₂ t2) _ (ETArrR x) with erase-t◆ x erase-trt2 (t1 ==>₂ t2) _ (ETArrR x) | refl = ap1 ETArrR (t-contr _ (◆erase-t t2 (t2 ◆t) refl) x) erase-ert1 : (e : ê) (er : ė) → (x : e ◆e == er) → (erase-e◆ (◆erase-e e er x)) == x erase-ert1 ▹ x ◃ .x refl = refl erase-ert1 (e ·:₁ x) .((e ◆e) ·: x) refl with erase-e◆ (◆erase-e e (e ◆e) refl) erase-ert1 (e ·:₁ x) .((e ◆e) ·: x) refl | refl = refl erase-ert1 (x ·:₂ t) .(x ·: (t ◆t)) refl = ap1 (λ a → ap1 (_·:_ x) a) (erase-trt1 t _ refl) erase-ert1 (·λ x e) .(·λ x (e ◆e)) refl = ap1 (λ a → ap1 (·λ x) a) (erase-ert1 e _ refl) erase-ert1 (e ∘₁ x) .((e ◆e) ∘ x) refl = ap1 (λ a → ap1 (λ x₁ → x₁ ∘ x) a) (erase-ert1 e _ refl) erase-ert1 (x ∘₂ e) .(x ∘ (e ◆e)) refl = ap1 (λ a → ap1 (_∘_ x) a) (erase-ert1 e _ refl) erase-ert1 (e ·+₁ x) .((e ◆e) ·+ x) refl = ap1 (λ a → ap1 (λ x₁ → x₁ ·+ x) a) (erase-ert1 e _ refl) erase-ert1 (x ·+₂ e) .(x ·+ (e ◆e)) refl = ap1 (λ a → ap1 (_·+_ x) a) (erase-ert1 e _ refl) erase-ert1 ⦇⌜ e ⌟⦈ .(⦇⌜ e ◆e ⌟⦈) refl = ap1 (λ a → ap1 ⦇⌜_⌟⦈ a) (erase-ert1 e _ refl) erase-ert2 : (e : ê) (er : ė) → (b : erase-e e er) → ◆erase-e e er (erase-e◆ b) == b erase-ert2 .(▹ er ◃) er EETop = refl erase-ert2 (e ·:₁ x) _ (EEAscL b) with erase-e◆ b erase-ert2 (e ·:₁ x) _ (EEAscL b) | refl = ap1 EEAscL (e-contr _ (◆erase-e e (e ◆e) refl) b) erase-ert2 (e ·:₂ x) _ (EEAscR b) with erase-t◆ b erase-ert2 (e ·:₂ x) .(e ·: (x ◆t)) (EEAscR b) | refl = ap1 EEAscR (t-contr _ (◆erase-t x (x ◆t) refl) b) erase-ert2 (·λ x e) _ (EELam b) with erase-e◆ b erase-ert2 (·λ x e) .(·λ x (e ◆e)) (EELam b) | refl = ap1 EELam (e-contr e (◆erase-e e (e ◆e) refl) b) erase-ert2 (e ∘₁ x) _ (EEApL b) with erase-e◆ b erase-ert2 (e ∘₁ x) .((e ◆e) ∘ x) (EEApL b) | refl = ap1 EEApL (e-contr e (◆erase-e e (e ◆e) refl) b) erase-ert2 (e1 ∘₂ e) _ (EEApR b) with erase-e◆ b erase-ert2 (e1 ∘₂ e) .(e1 ∘ (e ◆e)) (EEApR b) | refl = ap1 EEApR (e-contr e (◆erase-e e (e ◆e) refl) b) erase-ert2 (e ·+₁ x) _ (EEPlusL b) with erase-e◆ b erase-ert2 (e ·+₁ x) .((e ◆e) ·+ x) (EEPlusL b) | refl = ap1 EEPlusL (e-contr e (◆erase-e e (e ◆e) refl) b) erase-ert2 (e1 ·+₂ e) _ (EEPlusR b) with erase-e◆ b erase-ert2 (e1 ·+₂ e) .(e1 ·+ (e ◆e)) (EEPlusR b) | refl = ap1 EEPlusR (e-contr e (◆erase-e e (e ◆e) refl) b) erase-ert2 ⦇⌜ e ⌟⦈ _ (EENEHole b) with erase-e◆ b erase-ert2 ⦇⌜ e ⌟⦈ .(⦇⌜ e ◆e ⌟⦈) (EENEHole b) | refl = ap1 EENEHole (e-contr e (◆erase-e e (e ◆e) refl) b) -- since both round trips are stable, these functions demonstrate -- isomorphisms between the jugemental and non-judgemental definitions of -- erasure erase-e-iso : (e : ê) (er : ė) → (e ◆e == er) ≃ (erase-e e er) erase-e-iso e er = (◆erase-e e er) , (erase-e◆ , erase-ert1 e er , erase-ert2 e er) erase-t-iso : (t : τ̂) (tr : τ̇) → (t ◆t == tr) ≃ (erase-t t tr) erase-t-iso t tr = (◆erase-t t tr) , (erase-t◆ , erase-trt1 t tr , erase-trt2 t tr) -- this isomorphism supplies the argument that the judgement has mode (∀, -- !∃), where uniqueness comes from erase-e◆. erase-e-mode : (e : ê) → Σ[ er ∈ ė ] (erase-e e er) erase-e-mode e = (e ◆e) , (◆erase-e e (e ◆e) refl) -- some translations and lemmas to move between the different -- forms. these are not needed to show that this is an ok encoding pair, -- but they are helpful when actually using it. -- even more specifically, the relation relates an expression to its -- functional erasure. rel◆t : (t : τ̂) → (erase-t t (t ◆t)) rel◆t t = ◆erase-t t (t ◆t) refl rel◆ : (e : ê) → (erase-e e (e ◆e)) rel◆ e = ◆erase-e e (e ◆e) refl lem-erase-synth : ∀{e e' Γ t} → erase-e e e' → Γ ⊢ e' => t → Γ ⊢ (e ◆e) => t lem-erase-synth er wt = tr (λ x → _ ⊢ x => _) (! (erase-e◆ er)) wt lem-erase-ana : ∀{e e' Γ t} → erase-e e e' → Γ ⊢ e' <= t → Γ ⊢ (e ◆e) <= t lem-erase-ana er wt = tr (λ x → _ ⊢ x <= _) (! (erase-e◆ er)) wt lem-synth-erase : ∀{Γ e t e' } → Γ ⊢ e ◆e => t → erase-e e e' → Γ ⊢ e' => t lem-synth-erase d1 d2 with erase-e◆ d2 ... | refl = d1 eraset-det : ∀{t t' t''} → erase-t t t' → erase-t t t'' → t' == t'' eraset-det e1 e2 with erase-t◆ e1 ... | refl = erase-t◆ e2 erasee-det : ∀{e e' e''} → erase-e e e' → erase-e e e'' → e' == e'' erasee-det e1 e2 with erase-e◆ e1 ... | refl = erase-e◆ e2 erase-in-hole : ∀ {e e'} → erase-e e e' → erase-e ⦇⌜ e ⌟⦈ ⦇⌜ e' ⌟⦈ erase-in-hole (EENEHole er) = EENEHole (erase-in-hole er) erase-in-hole x = EENEHole x eq-er-trans : ∀{e e◆ e'} → (e ◆e) == (e' ◆e) → erase-e e e◆ → erase-e e' e◆ eq-er-trans {e} {e◆} {e'} eq er = tr (λ f → erase-e e' f) (erasee-det (◆erase-e e (e' ◆e) eq) er) (rel◆ e') eq-ert-trans : ∀{t t' t1 t2} → (t ◆t) == (t' ◆t) → erase-t t t1 → erase-t t' t2 → t1 == t2 eq-ert-trans eq er1 er2 = ! (erase-t◆ er1) · (eq · (erase-t◆ er2))
{ "alphanum_fraction": 0.5427865894, "avg_line_length": 50.3779904306, "ext": "agda", "hexsha": "f91d8fd437a18c3deb7865b336c8cd93b2537c7d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-07-03T03:45:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-07-03T03:45:07.000Z", "max_forks_repo_head_hexsha": "db3d21a1e3f17ef77ad557ed12374979f381b6b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/agda-popl17", "max_forks_repo_path": "judgemental-erase.agda", "max_issues_count": 37, "max_issues_repo_head_hexsha": "db3d21a1e3f17ef77ad557ed12374979f381b6b7", "max_issues_repo_issues_event_max_datetime": "2016-11-09T18:13:55.000Z", "max_issues_repo_issues_event_min_datetime": "2016-07-07T16:23:11.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/agda-popl17", "max_issues_repo_path": "judgemental-erase.agda", "max_line_length": 111, "max_stars_count": 14, "max_stars_repo_head_hexsha": "db3d21a1e3f17ef77ad557ed12374979f381b6b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/agda-popl17", "max_stars_repo_path": "judgemental-erase.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-11T12:30:50.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-01T22:44:11.000Z", "num_tokens": 4931, "size": 10529 }
open import Relation.Binary hiding (_⇒_) open import Level module Relation.Unary.Monotone {c i}(pre : Preorder i c i) where open Preorder pre renaming (Carrier to I; _∼_ to _≤_) open import Relation.Unary open import Data.Product hiding (map) open import Data.List open import Function record Monotone {ℓ}(p : Pred I ℓ) : Set (i ⊔ ℓ) where field wk : ∀ {i j} → i ≤ j → p i → p j open Monotone open Monotone ⦃...⦄ public ∀≥[_] : ∀ {ℓ} → Pred I ℓ → Pred I (i ⊔ ℓ) ∀≥[ P ] i = ∀ {j} → i ≤ j → P j ∃≥[_] : ∀ {ℓ} → Pred I ℓ → Pred I (i ⊔ ℓ) ∃≥[ P ] i = ∃ λ j → i ≤ j × P j infixr 4 _↗_ _↗_ : ∀ {ℓ} → Pred I ℓ → Pred I ℓ → Pred I (i ⊔ ℓ) (P ↗ Q) = ∀≥[ P ⇒ Q ] instance ∀≥-monotone : ∀ {ℓ}{P : Pred I ℓ} → Monotone ∀≥[ P ] wk ∀≥-monotone ext f ext' = f (trans ext ext') mono-∩ : ∀ {i j}{p : Pred I i}{q : Pred I j} ⦃ wp : Monotone p ⦄ ⦃ wq : Monotone q ⦄ → Monotone (p ∩ q) wk (mono-∩ ⦃ wp ⦄ ⦃ wq ⦄) ext (x , y) = (wk wp ext x , wk wq ext y) list-monotone : ∀ {B : Pred I i}⦃ wb : Monotone B ⦄ → Monotone (λ W → List (B W)) wk (list-monotone ⦃ wₐ ⦄) ext v = map (wk wₐ ext) v open import Data.List.All as All all-monotone : ∀ {b i}{B : Set b}{xs : List B}{C : B → Pred I i} ⦃ wₐ : ∀ x → Monotone (C x) ⦄ → Monotone (λ ys → All (λ x → C x ys) xs) wk (all-monotone ⦃ wₐ ⦄) ext v = All.map (λ {a} y → wk (wₐ a) ext y) v open import Data.Vec using (Vec) open import Data.Vec.All as VAll vec-all-monotone : ∀ {b i n}{B : Set b}{xs : Vec B n}{C : B → Pred I i} ⦃ wₐ : ∀ x → Monotone (C x) ⦄ → Monotone (λ ys → VAll.All (λ x → C x ys) xs) wk (vec-all-monotone ⦃ wₐ ⦄) ext v = VAll.map (λ {a} y → wk (wₐ a) ext y) v ≤-mono : ∀ {i} → Monotone (_≤_ i) wk ≤-mono = flip trans open import Data.Maybe as Maybe maybe-monotone : ∀ {i}{P : Pred I i} ⦃ mono : Monotone P ⦄ → Monotone (λ W → Maybe (P W)) wk (maybe-monotone ⦃ mono ⦄) ext mv = Maybe.map (wk mono ext) mv
{ "alphanum_fraction": 0.5328614762, "avg_line_length": 34.1034482759, "ext": "agda", "hexsha": "008f1d8729c969b644b635a4897e3f960ff700d2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_path": "src/Relation/Unary/Monotone.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_path": "src/Relation/Unary/Monotone.agda", "max_line_length": 91, "max_stars_count": 10, "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_path": "src/Relation/Unary/Monotone.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "num_tokens": 878, "size": 1978 }
module AKS.Nat where open import AKS.Nat.Base public open import AKS.Nat.Properties public open import AKS.Nat.WellFounded public open import AKS.Nat.Divisibility public
{ "alphanum_fraction": 0.8304093567, "avg_line_length": 24.4285714286, "ext": "agda", "hexsha": "fecf59d3ad7d7cf59fdfe77172769d3c561ca53d", "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": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mckeankylej/thesis", "max_forks_repo_path": "proofs/AKS/Nat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "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": "mckeankylej/thesis", "max_issues_repo_path": "proofs/AKS/Nat.agda", "max_line_length": 39, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mckeankylej/thesis", "max_stars_repo_path": "proofs/AKS/Nat.agda", "max_stars_repo_stars_event_max_datetime": "2020-12-01T22:38:27.000Z", "max_stars_repo_stars_event_min_datetime": "2020-12-01T22:38:27.000Z", "num_tokens": 47, "size": 171 }