Search is not available for this dataset
text
string
meta
dict
{-# OPTIONS --without-K --safe #-} module Categories.Category.Discrete where open import Categories.Category open import Function open import Relation.Binary.PropositionalEquality as ≡ Discrete : ∀ {a} (A : Set a) → Category a a a Discrete A = record { Obj = A ; _⇒_ = _≡_ ; _≈_ = _≡_ ; id = refl ; _∘_ = flip ≡.trans ; assoc = λ {_ _ _ _ g} → sym (trans-assoc g) ; sym-assoc = λ {_ _ _ _ g} → trans-assoc g ; identityˡ = λ {_ _ f} → trans-reflʳ f ; identityʳ = refl ; identity² = refl ; equiv = isEquivalence ; ∘-resp-≈ = λ where refl refl → refl }
{ "alphanum_fraction": 0.5746388443, "avg_line_length": 24.92, "ext": "agda", "hexsha": "8d724bfe22e4d5475e91b466d58067cfd5c97684", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Category/Discrete.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Category/Discrete.agda", "max_line_length": 54, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Category/Discrete.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 218, "size": 623 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 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.ImplShared.Base.Types open import LibraBFT.Abstract.Types.EpochConfig UID NodeId open EpochConfig open import LibraBFT.Concrete.System open import LibraBFT.Concrete.System.Parameters open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.Util.Crypto open import Optics.All open import Util.Hash open import Util.KVMap open import Util.PKCS open import Util.Prelude open import Yasm.Base -- This module contains definitions and proofs used by both the VotesOnce and PreferredRoundRule -- proofs. module LibraBFT.Concrete.Properties.Common (iiah : SystemInitAndHandlers ℓ-RoundManager ConcSysParms) (𝓔 : EpochConfig) where open SystemTypeParameters ConcSysParms open SystemInitAndHandlers iiah open ParamsWithInitAndHandlers iiah open import LibraBFT.ImplShared.Util.HashCollisions iiah open import Yasm.Yasm ℓ-RoundManager ℓ-VSFP ConcSysParms iiah PeerCanSignForPK PeerCanSignForPK-stable record VoteForRound∈ (pk : PK)(round : ℕ)(epoch : ℕ)(bId : HashValue)(pool : SentMessages) : Set where constructor mkVoteForRound∈ field msgWhole : NetworkMsg msgVote : Vote msg⊆ : msgVote ⊂Msg msgWhole msgSender : ℕ msg∈pool : (msgSender , msgWhole) ∈ pool msgSigned : WithVerSig pk msgVote msgEpoch≡ : msgVote ^∙ vEpoch ≡ epoch msgRound≡ : msgVote ^∙ vRound ≡ round msgBId≡ : msgVote ^∙ vProposedId ≡ bId open VoteForRound∈ public ImplObl-bootstrapVotesRound≡0 : Set ImplObl-bootstrapVotesRound≡0 = ∀ {pk v} → (wvs : WithVerSig pk v) → ∈BootstrapInfo bootstrapInfo (ver-signature wvs) → v ^∙ vRound ≡ 0 ImplObl-bootstrapVotesConsistent : Set ImplObl-bootstrapVotesConsistent = (v1 v2 : Vote) → ∈BootstrapInfo bootstrapInfo (_vSignature v1) → ∈BootstrapInfo bootstrapInfo (_vSignature v2) → v1 ^∙ vProposedId ≡ v2 ^∙ vProposedId ImplObl-NewVoteRound≢0 : Set (ℓ+1 ℓ-RoundManager) ImplObl-NewVoteRound≢0 = ∀{pid s' outs pk}{pre : SystemState} → ReachableSystemState pre -- For any honest call to /handle/ or /init/, → (sps : StepPeerState pid (msgPool pre) (initialised pre) (peerStates pre pid) (s' , outs)) → ∀{v m} → Meta-Honest-PK pk -- For signed every vote v of every outputted message → v ⊂Msg m → send m ∈ outs → (wvs : WithVerSig pk v) → (¬ ∈BootstrapInfo bootstrapInfo (ver-signature wvs)) → v ^∙ vRound ≢ 0 IncreasingRoundObligation : Set (ℓ+1 ℓ-RoundManager) IncreasingRoundObligation = ∀{pid pid' s' outs pk}{pre : SystemState} → ReachableSystemState pre -- For any honest call to /handle/ or /init/, → (sps : StepPeerState pid (msgPool pre) (initialised pre) (peerStates pre pid) (s' , outs)) → ∀{v m v' m'} → Meta-Honest-PK pk -- For signed every vote v of every outputted message → v ⊂Msg m → send m ∈ outs → (sig : WithVerSig pk v) → ¬ (∈BootstrapInfo bootstrapInfo (ver-signature sig)) → ¬ (MsgWithSig∈ pk (ver-signature sig) (msgPool pre)) → PeerCanSignForPK (StepPeer-post {pre = pre} (step-honest sps)) v pid pk -- And if there exists another v' that has been sent before → v' ⊂Msg m' → (pid' , m') ∈ (msgPool pre) → (sig' : WithVerSig pk v') → ¬ (∈BootstrapInfo bootstrapInfo (ver-signature sig')) -- If v and v' share the same epoch → v ^∙ vEpoch ≡ v' ^∙ vEpoch → v' ^∙ vRound < v ^∙ vRound ⊎ VoteForRound∈ pk (v ^∙ vRound) (v ^∙ vEpoch) (v ^∙ vProposedId) (msgPool pre) module ConcreteCommonProperties (st : SystemState) (r : ReachableSystemState st) (sps-corr : StepPeerState-AllValidParts) (Impl-bsvr : ImplObl-bootstrapVotesRound≡0) (Impl-nvr≢0 : ImplObl-NewVoteRound≢0) where open Structural sps-corr open PerReachableState r msgSentB4⇒VoteRound∈ : ∀ {v pk pool} → (vv : WithVerSig pk v) → (m : MsgWithSig∈ pk (ver-signature vv) pool) → Σ (VoteForRound∈ pk (v ^∙ vRound) (v ^∙ vEpoch) (v ^∙ vProposedId) pool) (λ v4r → ver-signature (msgSigned v4r) ≡ ver-signature vv) msgSentB4⇒VoteRound∈ {v} vv m with sameSig⇒sameVoteDataNoCol (msgSigned m) vv (msgSameSig m) ...| refl = mkVoteForRound∈ (msgWhole m) (msgPart m) (msg⊆ m) (msgSender m) (msg∈pool m) (msgSigned m) refl refl refl , msgSameSig m VoteRound∈⇒msgSent : ∀ {round eid bid pk pool} → (v4r : VoteForRound∈ pk round eid bid pool) → Σ (MsgWithSig∈ pk (ver-signature $ msgSigned v4r) pool) (λ mws → ( ver-signature (msgSigned mws) ≡ ver-signature (msgSigned v4r) × (msgPart mws) ^∙ vRound ≡ round)) VoteRound∈⇒msgSent (mkVoteForRound∈ msgWhole₁ msgVote₁ msg⊆₁ msgSender₁ msg∈pool₁ msgSigned₁ msgEpoch≡₁ msgRound≡₁ msgBId≡₁) = mkMsgWithSig∈ msgWhole₁ msgVote₁ msg⊆₁ msgSender₁ msg∈pool₁ msgSigned₁ refl , refl , msgRound≡₁ -- If a Vote signed for an honest PK has been sent, and it is not in bootstrapInfo, then -- it is for a round > 0 NewVoteRound≢0 : ∀ {pk round epoch bId} {st : SystemState} → ReachableSystemState st → Meta-Honest-PK pk → (v : VoteForRound∈ pk round epoch bId (msgPool st)) → ¬ ∈BootstrapInfo bootstrapInfo (ver-signature (msgSigned v)) → round ≢ 0 NewVoteRound≢0 (step-s r (step-peer (step-honest stP))) pkH v ¬bootstrap r≡0 with msgRound≡ v ...| refl with newMsg⊎msgSentB4 r stP pkH (msgSigned v) ¬bootstrap (msg⊆ v) (msg∈pool v) ...| Left (m∈outs , _ , _) = ⊥-elim (Impl-nvr≢0 r stP pkH (msg⊆ v) m∈outs (msgSigned v) ¬bootstrap r≡0) ...| Right m with msgSameSig m ...| refl with sameSig⇒sameVoteDataNoCol (msgSigned m) (msgSigned v) (msgSameSig m) ...| refl = let vsb4 = mkVoteForRound∈ (msgWhole m) (msgPart m) (msg⊆ m) (msgSender m) (msg∈pool m) (msgSigned m) refl refl refl in ⊥-elim (NewVoteRound≢0 r pkH vsb4 ¬bootstrap r≡0) NewVoteRound≢0 (step-s r (step-peer cheat@(step-cheat c))) pkH v ¬bootstrap r≡0 with ¬cheatForgeNewSig r cheat unit pkH (msgSigned v) (msg⊆ v) (msg∈pool v) ¬bootstrap ...| m with msgSameSig m ...| refl with sameSig⇒sameVoteDataNoCol (msgSigned m) (msgSigned v) (msgSameSig m) ...| refl = let vsb4 = mkVoteForRound∈ (msgWhole m) (msgPart m) (msg⊆ m) (msgSender m) (msg∈pool m) (msgSigned m) refl refl refl in ⊥-elim (NewVoteRound≢0 r pkH vsb4 ¬bootstrap (trans (msgRound≡ v) r≡0)) ¬Bootstrap∧Round≡⇒¬Bootstrap : ∀ {v pk round epoch bId} {st : SystemState} → ReachableSystemState st → Meta-Honest-PK pk → (vfr : VoteForRound∈ pk round epoch bId (msgPool st)) → ¬ (∈BootstrapInfo bootstrapInfo (ver-signature (msgSigned vfr))) → (sig : WithVerSig pk v) → v ^∙ vRound ≡ round → ¬ (∈BootstrapInfo bootstrapInfo (ver-signature sig)) ¬Bootstrap∧Round≡⇒¬Bootstrap r pkH v₁ ¬bootstrapV₁ sigV₂ refl bootstrapV₂ = let v₁r≢0 = NewVoteRound≢0 r pkH v₁ ¬bootstrapV₁ in ⊥-elim (v₁r≢0 (Impl-bsvr sigV₂ bootstrapV₂))
{ "alphanum_fraction": 0.6209811707, "avg_line_length": 48.1913580247, "ext": "agda", "hexsha": "86bc44dff63824d182e1c78cb9519a544d7942e4", "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": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_forks_repo_path": "src/LibraBFT/Concrete/Properties/Common.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "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": "LaudateCorpus1/bft-consensus-agda", "max_issues_repo_path": "src/LibraBFT/Concrete/Properties/Common.agda", "max_line_length": 127, "max_stars_count": null, "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_stars_repo_path": "src/LibraBFT/Concrete/Properties/Common.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2465, "size": 7807 }
module Issue249 where postulate A B : Set module A where X = A Y = B open A renaming (X to C; Y to C) -- open A using (X) renaming (Y to X)
{ "alphanum_fraction": 0.6158940397, "avg_line_length": 10.7857142857, "ext": "agda", "hexsha": "c0860108a41fcf184ae58f9439439b41a151382f", "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/Issue249.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/Issue249.agda", "max_line_length": 37, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue249.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": 54, "size": 151 }
module Relator.Equals where open import Logic import Lvl open import Type open import Type.Cubical open import Type.Cubical.Path open import Type.Cubical.Path.Proofs infix 15 _≡_ _≡_ = Path -- _≢_ : ∀{ℓ}{T} → T → T → Stmt{ℓ} -- _≢_ a b = ¬(a ≡ b) {-# BUILTIN REWRITE _≡_ #-} data Id {ℓ}{T : Type{ℓ}} : T → T → Stmt{ℓ} where instance intro : ∀{x : T} → (Id x x) {-# BUILTIN EQUALITY Id #-}
{ "alphanum_fraction": 0.612345679, "avg_line_length": 16.875, "ext": "agda", "hexsha": "26c9344c987b06b3a99707ccb15650e82416a688", "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": "old/Mathematical/Relator/Equals.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": "old/Mathematical/Relator/Equals.agda", "max_line_length": 48, "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": "old/Mathematical/Relator/Equals.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": 156, "size": 405 }
{-# OPTIONS --type-in-type #-} open import Data.Empty open import Data.Unit open import Data.Bool hiding ( T ) open import Data.Product hiding ( curry ; uncurry ) open import Data.Nat open import Data.String open import Relation.Binary.PropositionalEquality using ( refl ; _≢_ ; _≡_ ) open import Function module ClosedTheory2 where ---------------------------------------------------------------------- data Tel : Set₁ where Emp : Tel Ext : (A : Set) (B : A → Tel) → Tel Scope : Tel → Set Scope Emp = ⊤ Scope (Ext A B) = Σ A λ a → Scope (B a) ---------------------------------------------------------------------- UncurriedScope : (T : Tel) (X : Scope T → Set) → Set UncurriedScope T X = (xs : Scope T) → X xs CurriedScope : (T : Tel) (X : Scope T → Set) → Set CurriedScope Emp X = X tt CurriedScope (Ext A B) X = (a : A) → CurriedScope (B a) (λ b → X (a , b)) curryScope : (T : Tel) (X : Scope T → Set) → UncurriedScope T X → CurriedScope T X curryScope Emp X f = f tt curryScope (Ext A B) X f a = curryScope (B a) (λ b → X (a , b)) (λ b → f (a , b)) ---------------------------------------------------------------------- data Desc (I : Set) : Set₁ where End : (i : I) → Desc I Rec : (i : I) (D : Desc I) → Desc I Arg : (A : Set) (B : A → Desc I) → Desc I ISet : Set → Set₁ ISet I = I → Set El : {I : Set} (D : Desc I) → ISet I → ISet I El (End j) X i = j ≡ i El (Rec j D) X i = X j × El D X i El (Arg A B) X i = Σ A (λ a → El (B a) X i) data μ {I : Set} (D : Desc I) (i : I) : Set where init : El D (μ D) i → μ D i ---------------------------------------------------------------------- UncurriedEl : {I : Set} (D : Desc I) (X : ISet I) → Set UncurriedEl D X = ∀{i} → El D X i → X i CurriedEl : {I : Set} (D : Desc I) (X : ISet I) → Set CurriedEl (End i) X = X i CurriedEl (Rec i D) X = (x : X i) → CurriedEl D X CurriedEl (Arg A B) X = (a : A) → CurriedEl (B a) X curryEl : {I : Set} (D : Desc I) (X : ISet I) → UncurriedEl D X → CurriedEl D X curryEl (End i) X cn = cn refl curryEl (Rec i D) X cn = λ x → curryEl D X (λ xs → cn (x , xs)) curryEl (Arg A B) X cn = λ a → curryEl (B a) X (λ xs → cn (a , xs)) ---------------------------------------------------------------------- record Data : Set₁ where field E : Set P : Tel I : Scope P → Tel C : (p : Scope P) (t : E) → Desc (Scope (I p)) ---------------------------------------------------------------------- UncurriedFormer : Set UncurriedFormer = UncurriedScope P λ p → UncurriedScope (I p) λ i → Set FormUncurried : UncurriedFormer FormUncurried p = μ (Arg E (C p)) Former : Set Former = CurriedScope P λ p → CurriedScope (I p) λ i → Set Form : Former Form = curryScope P (λ p → CurriedScope (I p) λ i → Set) λ p → curryScope (I p) (λ i → Set) λ i → FormUncurried p i ---------------------------------------------------------------------- InjUncurried : E → Set InjUncurried t = UncurriedScope P λ p → CurriedEl (C p t ) (FormUncurried p) injUncurried : (t : E) → InjUncurried t injUncurried t p = curryEl (C p t) (FormUncurried p) (λ xs → init (t , xs)) Inj : E → Set Inj t = CurriedScope P λ p → CurriedEl (C p t) (FormUncurried p) inj : (t : E) → Inj t inj t = curryScope P (λ p → CurriedEl (C p t) (FormUncurried p)) (injUncurried t) ---------------------------------------------------------------------- open Data using ( Former ; Form ; Inj ; inj ) ---------------------------------------------------------------------- data VecT : Set where nilT consT : VecT VecR : Data VecR = record { E = VecT ; P = Ext Set λ _ → Emp ; I = λ _ → Ext ℕ λ _ → Emp ; C = λ { (A , tt) → λ { nilT → End (zero , tt) ; consT → Arg ℕ λ n → Arg A λ _ → Rec (n , tt) $ End (suc n , tt) } } } Vec : (A : Set) → ℕ → Set Vec = Form VecR nil : (A : Set) → Vec A zero nil = inj VecR nilT cons : (A : Set) (n : ℕ) (x : A) (xs : Vec A n) → Vec A (suc n) cons = inj VecR consT ---------------------------------------------------------------------- data TreeT : Set where leaf₁T leaf₂T branchT : TreeT TreeR : Data TreeR = record { E = TreeT ; P = Ext Set λ _ → Ext Set λ _ → Emp ; I = λ _ → Ext ℕ λ _ → Ext ℕ λ _ → Emp ; C = λ { (A , B , tt) → λ { leaf₁T → Arg A λ _ → End (suc zero , zero , tt) ; leaf₂T → Arg B λ _ → End (zero , suc zero , tt) ; branchT → Arg ℕ λ m → Arg ℕ λ n → Arg ℕ λ x → Arg ℕ λ y → Rec (m , n , tt) $ Rec (x , y , tt) $ End (m + x , n + y , tt) } } } Tree : (A B : Set) (m n : ℕ) → Set Tree = Form TreeR leaf₁ : (A B : Set) → A → Tree A B (suc zero) zero leaf₁ = inj TreeR leaf₁T ----------------------------------------------------------------------
{ "alphanum_fraction": 0.4611181169, "avg_line_length": 27.1885714286, "ext": "agda", "hexsha": "1d68ce359e50bcedfea29569464fb859e9a223e5", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:31:22.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-02T08:56:15.000Z", "max_forks_repo_head_hexsha": "832383d7adf37aa2364213fb0aeb67e9f61a248f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/generic-elim", "max_forks_repo_path": "slides/ClosedTheory2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "832383d7adf37aa2364213fb0aeb67e9f61a248f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/generic-elim", "max_issues_repo_path": "slides/ClosedTheory2.agda", "max_line_length": 82, "max_stars_count": 11, "max_stars_repo_head_hexsha": "832383d7adf37aa2364213fb0aeb67e9f61a248f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/generic-elim", "max_stars_repo_path": "slides/ClosedTheory2.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-09T08:46:42.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-02T14:05:20.000Z", "num_tokens": 1611, "size": 4758 }
------------------------------------------------------------------------ -- A README directed towards readers of the paper -- "Correct-by-Construction Pretty-Printing" -- -- Nils Anders Danielsson ------------------------------------------------------------------------ {-# OPTIONS --guardedness #-} module README.Correct-by-Construction-Pretty-Printing where ------------------------------------------------------------------------ -- 2: Grammars -- The basic grammar data type, including its semantics. Only a small -- number of derived combinators is defined directly for this data -- type. It is proved that an inductive version of this type would be -- quite restrictive. import Grammar.Infinite.Basic -- The extended grammar data type mentioned in Section 4.3, along with -- a semantics and lots of derived combinators. This type is proved to -- be no more expressive than the previous one; but it is also proved -- that every language that can be recursively enumerated can be -- represented by a (unit-valued) grammar. import Grammar.Infinite ------------------------------------------------------------------------ -- 3: Pretty-Printers import Pretty ------------------------------------------------------------------------ -- 4: Examples -- Reusable document combinators introduced in this section. import Pretty -- The symbol combinator and the heuristic procedure -- trailing-whitespace. import Grammar.Infinite -- 4.1: Boolean literals. import Examples.Bool -- 4.2: Expressions, and 4.3: Expressions, Take Two. import Examples.Expression -- 4.4: Identifiers. import Examples.Identifier -- 4.5: Other Examples. -- Some of these examples are not mentioned in the paper. -- Another expression example based on one in Matsuda and Wang's -- "FliPpr: A Prettier Invertible Printing System". import Examples.Expression -- An example based on one in Swierstra and Chitil's "Linear, bounded, -- functional pretty-printing". import Examples.Identifier-list -- Two examples, both based on examples in Wadler's "A prettier -- printer". import Examples.Tree import Examples.XML -- The fill combinator. import Pretty -- A general grammar and pretty-printer for binary operators of -- various (not necessarily linearly ordered) precedences. import Examples.Precedence ------------------------------------------------------------------------ -- 5: Renderers import Renderer -- Unambiguous and Parser. import Grammar.Infinite
{ "alphanum_fraction": 0.6261187958, "avg_line_length": 25.6041666667, "ext": "agda", "hexsha": "3df64beea5a5a6f8a6baa96880476bba112fc292", "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": "README/Correct-by-Construction-Pretty-Printing.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": "README/Correct-by-Construction-Pretty-Printing.agda", "max_line_length": 72, "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": "README/Correct-by-Construction-Pretty-Printing.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 478, "size": 2458 }
module HC-Lec2 where open import HC-Lec1 -- ============================================================================== -- Lecture 4 : Sigma, Difference, Vector Take -- https://www.youtube.com/watch?v=OZeDRtRmgkw -- 43:14 data Vec (X : Set) : Nat -> Set where [] : Vec X zero _::_ : {n : Nat} -> X -> Vec X n -> Vec X (suc n) infixr 4 _::_ vTake : (m n : Nat) -> m >= n -> {X : Set} -> Vec X m -> Vec X n vTake m zero m>=n xs = [] vTake (suc m) (suc n) m>=n (x :: xs) = x :: vTake m n m>=n xs vTake32 : Set vTake32 = vTake 3 2 <> (1 :: 2 :: 3 :: []) == (1 :: 2 :: []) -- 47:35 : taking ALL elements is an identity vTakeIdFact : (n : Nat) {X : Set} (xs : Vec X n) -> vTake n n (refl->= n) xs == xs vTakeIdFact .0 [] = refl [] vTakeIdFact (suc n) (x :: xs) rewrite vTakeIdFact n xs = refl (x :: xs) -- 48:17 : taking p elements from Vm is same as taking n elements from Vm, forming Vn -- then taking p elments from Vn vTakeCpFact : (m n p : Nat) (m>=n : m >= n) (n>=p : n >= p) {X : Set} (xs : Vec X m) -> vTake m p (trans->= m n p m>=n n>=p) xs == vTake n p n>=p (vTake m n m>=n xs) vTakeCpFact m n zero m>=n n>=p _ = refl [] vTakeCpFact (suc m) (suc n) (suc p) m>=n n>=p (x :: xs) rewrite vTakeCpFact m n p m>=n n>=p xs = refl (x :: (vTake n p n>=p (vTake m n m>=n xs))) -- 48:54 -- vTakeIdFact : reflexivity turns into identity -- vTakeCpFact : transitivity turns into composition -- ============================================================================== -- Lecture 5 : How Rewrite Works -- https://www.youtube.com/watch?v=b5salYMZoyM -- 3:34 vTake53 : Vec Nat 3 vTake53 = vTake 5 3 <> (1 :: 2 :: 3 :: 4 :: 5 :: []) -- 5:30 vTake' : ∀ {m : Nat} {X : Set} -> (n : Nat) -> m >= n -> Vec X m -> Vec X n vTake' {m} zero m>=n xs = [] vTake' {suc m} (suc n) m>=n (x :: xs) = x :: vTake' {m} n m>=n xs {- -- 7:45 rigid symbols : constructors (value and type) - if you are trying to tell if two usages of constructors match each other, you can compare them component-wise - no defined computational meaning - they are what they are - e.g., Vec Nat 3 non-rigid - e.g., >= - can compute -- 15:48 vTake : think of as turning a '>=' proof into a vector operation. - In comes a proof on numbers, out comes an operation on vectors. vTakeIdFact : identity proof on numbers turns into identity operation on vectors vTakeCpFact : proof of transitivity on numbers turns into composition operation on vectors -- 24:08 : best practice : use record (instead of data) when possible : agda is more aggressive -- 24:28 : HOW REWRITE WORKS Rewrite is shorthand for - abstract the LHS of the equation using 'with' - abstract the proof of the equation using 'with' - then pattern matching on the proof -} ------------------------------------------------------------------------------ -- Splittings (which bear some relationship to <= from ex1) -- 39:00 data _<[_]>_ : Nat -> Nat -> Nat -> Set where zzz : zero <[ zero ]> zero lll : {l m r : Nat} -> l <[ m ]> r -> suc l <[ suc m ]> r rrr : {l m r : Nat} -> l <[ m ]> r -> l <[ suc m ]> suc r -- xzzz : Set -- xzzz = zero <[ zero ]> zero -- x1z1 : Set -- x1z1 = 1 <[ zero ]> 1 -- x159 : Set -- x159 = 1 <[ 5 ]> 9 -- x951 : Set -- x951 = 9 <[ 5 ]> 1 -- 41:08 -- combine two vectors into one according to given instructions -- this is kind of a "double-sided" '<=' {- collection * <--- * * ---> * * ---> * * <--- * * ---> * 3 from left 2 from right -} _>[_]<_ : {X : Set} {l m r : Nat} -> Vec X l -> l <[ m ]> r -- instructions -> Vec X r -> Vec X m -- why is rrr the first line? -- 29:49 https://www.youtube.com/watch?v=RW4aC_6n0yQ -- do NOT pattern match on vector first (LHS of first clause) -- pattern match on instructions first -- i.e., no pattern match on xl, so goes to try to match instruction : >[ rrr mmm ]< xl >[ rrr mmm ]< (x :: xr) = x :: (xl >[ mmm ]< xr) (x :: xl) >[ lll mmm ]< xr = x :: (xl >[ mmm ]< xr) [] >[ zzz ]< [] = [] v6rl : Vec Nat 6 v6rl = (0 :: 2 :: 3 :: []) >[ rrr (rrr (rrr (lll (lll (lll zzz))))) ]< (7 :: 8 :: 9 :: []) _ : v6rl == (7 :: 8 :: 9 :: 0 :: 2 :: 3 :: []) _ = refl (7 :: 8 :: 9 :: 0 :: 2 :: 3 :: []) v6 : Vec Nat 6 v6 = (0 :: 2 :: 3 :: []) >[ lll (rrr (lll (rrr (lll (rrr zzz))))) ]< (7 :: 8 :: 9 :: []) _ : v6 == (0 :: 7 :: 2 :: 8 :: 3 :: 9 :: []) _ = refl (0 :: 7 :: 2 :: 8 :: 3 :: 9 :: []) -- 44:27 -- split a vector into two vectors according to given instructions -- reverses '<[ m ]>' - instructions for taking things apart data FindSplit {X : Set} {l m r : Nat} (nnn : l <[ m ]> r) : (xs : Vec X m) -> Set where splitBits : (xl : Vec X l) (xr : Vec X r) -> FindSplit nnn (xl >[ nnn ]< xr) -- proves FindSplit findSplit : {X : Set} {l m r : Nat} (nnn : l <[ m ]> r) (xs : Vec X m) -> FindSplit nnn xs findSplit zzz [] = splitBits [] [] findSplit (lll nnn) (x :: xs) with findSplit nnn xs -- FindSplit (lll nnn) (x :: (xl >[ nnn ]< xr)) findSplit (lll nnn) (x :: .(xl >[ nnn ]< xr)) | splitBits xl xr = splitBits (x :: xl) xr findSplit (rrr nnn) (x :: xs) with findSplit nnn xs -- FindSplit (rrr nnn) (x :: (xl >[ nnn ]< xr)) findSplit (rrr nnn) (x :: .(xl >[ nnn ]< xr)) | splitBits xl xr = splitBits xl (x :: xr) -- ============================================================================== -- https://www.youtube.com/watch?v=RW4aC_6n0yQ -- 5:08 {- The o' <= constructor : you can keep increasing the RHS oz -- stop os -- take this one and keep going o' -- skip this one and keep going Tabulating the ways of choosing N things from M things A path is a way to get a specific embedding. The numbers in parenthesis shows the number of paths to a specific embedding (Pascal's triangle). oz 0<=0 (1) / \ / \ / \ o' os 0<=1 1<=1 (1) (1) / \ / \ / \ / \ / \ / \ o' os o' os 0<=2 1<=2 2<=2 (1) (2) (2) / \ / \ / \ / \ / \ / \ / \ / \ / \ o' os o' os o' os 0<=3 1<=3 2<=3 3<=3 (1) (3) (3) (1) witnesses to M choose N read a value in a set of this type as instructions for choosing -} -- 14:58 -- 'findSplit' (above) -- 23:20 -- last clause of 'findSplit' -- 29:49 : the same ERROR I had before changing order of clauses in _>[_]<_ -- 34:22 : rule of thumb -- if there is one column of args, where on every line is a constructor then no change -- otherwise, choose ordering carefully -- 35:52 : final order of clauses of of _>[_]<_ -- tidy to have nil case at top or bottom -- 40:15 shows how agda/haskell does case splitting on _>[_]<_
{ "alphanum_fraction": 0.4467813894, "avg_line_length": 35.0223214286, "ext": "agda", "hexsha": "ccc52f366eb056b8d74befc718c4443b2951da93", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/course/2017-conor_mcbride_cs410/HC-Lec2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/course/2017-conor_mcbride_cs410/HC-Lec2.agda", "max_line_length": 97, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/course/2017-conor_mcbride_cs410/HC-Lec2.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "num_tokens": 2440, "size": 7845 }
module Generic.Main where open import Generic.Core public open import Generic.Function.FoldMono public open import Generic.Property.Eq public open import Generic.Reflection.ReadData public open import Generic.Reflection.DeriveEq public
{ "alphanum_fraction": 0.7748091603, "avg_line_length": 32.75, "ext": "agda", "hexsha": "63b43003965a8fca1ffac8aef4bb1de175d03ae4", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2021-01-27T12:57:09.000Z", "max_forks_repo_forks_event_min_datetime": "2017-07-17T07:23:39.000Z", "max_forks_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "turion/Generic", "max_forks_repo_path": "src/Generic/Main.agda", "max_issues_count": 9, "max_issues_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_issues_repo_issues_event_max_datetime": "2022-01-04T15:43:14.000Z", "max_issues_repo_issues_event_min_datetime": "2017-04-06T18:58:09.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "turion/Generic", "max_issues_repo_path": "src/Generic/Main.agda", "max_line_length": 46, "max_stars_count": 30, "max_stars_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "turion/Generic", "max_stars_repo_path": "src/Generic/Main.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T10:19:38.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-19T21:10:54.000Z", "num_tokens": 49, "size": 262 }
{-# OPTIONS --universe-polymorphism #-} module Issue441 where open import Common.Level postulate C : ∀ ℓ → Set ℓ → Set ℓ I : ∀ a b (A : Set a) (B : Set b) → (A → B) → B → Set (a ⊔ b) E : ∀ a b (A : Set a) → (A → Set b) → Set (a ⊔ b) c : ∀ a (A : Set a) → ((B : A → Set a) → E a a A B) → C a A foo : (∀ a b (A : Set a) (B : A → Set b) → E a b A B) → ∀ a b (A : Set a) (B : Set b) (f : A → B) x → C (a ⊔ b) (I a b A B f x) foo e a b A B f x = c _ _ (λ B′ → e _ _ _ _) infix 4 _≡_ data _≡_ {a} {A : Set a} : A → A → Set a where refl : ∀ x → x ≡ x elim : ∀ {a p} {A : Set a} (P : {x y : A} → x ≡ y → Set p) → (∀ x → P (refl x)) → ∀ {x y} (x≡y : x ≡ y) → P x≡y elim P r (refl x) = r _ cong : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) {x y : A} → x ≡ y → f x ≡ f y cong f (refl x) = refl (f x) bar : ∀ {a} {A : Set a} {x y : A} (x≡y : x ≡ y) (f : x ≡ y → x ≡ y) → f x≡y ≡ f x≡y bar = elim (λ {x} {y} x≡y → (f : x ≡ y → x ≡ y) → f x≡y ≡ f x≡y) (λ x f → cong {a = _} {b = _} f (refl (refl x)))
{ "alphanum_fraction": 0.3909774436, "avg_line_length": 28, "ext": "agda", "hexsha": "6bd2744a176d06b27a7a8c5ab3b52f91b73c74fd", "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/Issue441.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/Issue441.agda", "max_line_length": 64, "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/Issue441.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": 537, "size": 1064 }
{-# OPTIONS --without-K --exact-split #-} module 00-preamble where open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) public UU : (i : Level) → Set (lsuc i) UU i = Set i
{ "alphanum_fraction": 0.6538461538, "avg_line_length": 18.2, "ext": "agda", "hexsha": "891c80dc7d5fa50295c967970f20e67ab8d210eb", "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": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "hemangandhi/HoTT-Intro", "max_forks_repo_path": "Agda/00-preamble.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "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": "hemangandhi/HoTT-Intro", "max_issues_repo_path": "Agda/00-preamble.agda", "max_line_length": 65, "max_stars_count": null, "max_stars_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "hemangandhi/HoTT-Intro", "max_stars_repo_path": "Agda/00-preamble.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 59, "size": 182 }
module Everything where open import Oscar.Prelude public -- meta-class open import Oscar.Class public -- classes open import Oscar.Class.Amgu public open import Oscar.Class.Apply public open import Oscar.Class.Bind public open import Oscar.Class.Category public open import Oscar.Class.Congruity public open import Oscar.Class.Fmap public open import Oscar.Class.Functor public open import Oscar.Class.HasEquivalence public open import Oscar.Class.Hmap public open import Oscar.Class.Injectivity public open import Oscar.Class.IsCategory public open import Oscar.Class.IsDecidable public open import Oscar.Class.IsEquivalence public open import Oscar.Class.IsFunctor public open import Oscar.Class.IsPrecategory public open import Oscar.Class.IsPrefunctor public open import Oscar.Class.Leftstar public open import Oscar.Class.Leftunit public open import Oscar.Class.Map public open import Oscar.Class.Precategory public open import Oscar.Class.Prefunctor public open import Oscar.Class.Properthing public open import Oscar.Class.Pure public open import Oscar.Class.Quadricity public open import Oscar.Class.Reflexivity public open import Oscar.Class.Setoid public open import Oscar.Class.Similarity public open import Oscar.Class.SimilarityM public open import Oscar.Class.SimilaritySingleton public open import Oscar.Class.Smap public open import Oscar.Class.Smapoid public open import Oscar.Class.Successor₀ public open import Oscar.Class.Successor₁ public open import Oscar.Class.Surjection public open import Oscar.Class.Surjextensionality public open import Oscar.Class.Surjidentity public open import Oscar.Class.Surjtranscommutativity public open import Oscar.Class.Symmetrical public open import Oscar.Class.Symmetry public open import Oscar.Class.Thickandthin public open import Oscar.Class.Transassociativity public open import Oscar.Class.Transextensionality public open import Oscar.Class.Transitivity public open import Oscar.Class.Transleftidentity public open import Oscar.Class.Transrightidentity public open import Oscar.Class.Unit public open import Oscar.Class.[ExtensibleType] public open import Oscar.Class.[IsExtensionB] public -- individual instances open import Oscar.Class.Amgu.Term∃SubstitistMaybe public open import Oscar.Class.Congruity.Proposequality public open import Oscar.Class.Congruity.Proposextensequality public open import Oscar.Class.HasEquivalence.ExtensionṖroperty public open import Oscar.Class.HasEquivalence.Ṗroperty public open import Oscar.Class.HasEquivalence.Substitunction public open import Oscar.Class.Hmap.Transleftidentity public open import Oscar.Class.Injectivity.Vec public open import Oscar.Class.IsDecidable.Fin public open import Oscar.Class.IsDecidable.¶ public open import Oscar.Class.Properthing.ExtensionṖroperty public open import Oscar.Class.Properthing.Ṗroperty public open import Oscar.Class.Reflexivity.Function public open import Oscar.Class.Smap.ExtensionFinExtensionTerm public open import Oscar.Class.Smap.ExtensionṖroperty public open import Oscar.Class.Smap.TransitiveExtensionLeftṖroperty public open import Oscar.Class.Surjection.⋆ public open import Oscar.Class.Symmetrical.ExtensionalUnifies public open import Oscar.Class.Symmetrical.Symmetry public open import Oscar.Class.Symmetrical.Unifies public open import Oscar.Class.Transextensionality.Proposequality public open import Oscar.Class.Transitivity.Function public open import Oscar.Class.[ExtensibleType].Proposequality public -- instance bundles open import Oscar.Property.Category.AListProposequality public open import Oscar.Property.Category.ExtensionProposextensequality public open import Oscar.Property.Category.Function public open import Oscar.Property.Functor.SubstitistProposequalitySubstitunctionProposextensequality public open import Oscar.Property.Functor.SubstitunctionExtensionTerm public open import Oscar.Property.Monad.Maybe public open import Oscar.Property.Propergroup.Substitunction public open import Oscar.Property.Setoid.ProductIndexEquivalence public open import Oscar.Property.Setoid.Proposequality public open import Oscar.Property.Setoid.Proposextensequality public open import Oscar.Property.Setoid.ṖropertyEquivalence public open import Oscar.Property.Thickandthin.FinFinProposequalityMaybeProposequality public open import Oscar.Property.Thickandthin.FinTermProposequalityMaybeProposequality public -- data open import Oscar.Data.Constraint public open import Oscar.Data.Decidable public open import Oscar.Data.Descender public open import Oscar.Data.ExtensionṖroperty public open import Oscar.Data.Fin public open import Oscar.Data.List public open import Oscar.Data.Maybe public open import Oscar.Data.ProductIndexEquivalence public open import Oscar.Data.ProperlyExtensionNothing public open import Oscar.Data.Proposequality public open import Oscar.Data.ṖropertyEquivalence public open import Oscar.Data.Substitist public open import Oscar.Data.Substitunction public open import Oscar.Data.Surjcollation public open import Oscar.Data.Surjextenscollation public open import Oscar.Data.Term public open import Oscar.Data.Vec public open import Oscar.Data.¶ public open import Oscar.Data.𝟘 public open import Oscar.Data.𝟙 public open import Oscar.Data.𝟚 public -- class derivations open import Oscar.Class.Leftunit.ToUnit public open import Oscar.Class.Symmetry.ToSym public open import Oscar.Class.Transleftidentity.ToLeftunit public
{ "alphanum_fraction": 0.5553968821, "avg_line_length": 66.6904761905, "ext": "agda", "hexsha": "1dbb3e275400c1c3d392e0d90f277d21a2a05c71", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Everything.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Everything.agda", "max_line_length": 103, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Everything.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1278, "size": 8403 }
open import Relation.Nullary.Decidable using (False; map) open import Relation.Nullary.Negation using (contradiction) open import Relation.Binary using (Decidable) open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; sym; cong; module ≡-Reasoning) open ≡-Reasoning open import Function.Equivalence as FE using () open import Data.Unit using (⊤; tt) open import Agda.Builtin.FromNat using (Number) module AKS.Modular.Quotient.Base where open import AKS.Nat using (ℕ; zero; suc; _<_; _∸_) renaming (_+_ to _+ℕ_; _*_ to _*ℕ_; _≟_ to _≟ℕ_) open import AKS.Nat using (≢⇒¬≟; ∸-mono-<ʳ; 0<1+n; <⇒≤; <-irrelevant; 0≢⇒0<) open import AKS.Nat.Divisibility using (_%_; n%m<m; 0%m≡0; 1%m≡1; [m+kn]%n≡m%n; m%n%n≡m%n; %-distribˡ-+; %-distribˡ-*) open import AKS.Nat.GCD using (+ʳ; +ˡ) open import AKS.Primality using (IsPrime; Prime; prime≢0; bézout-prime) open Prime record ℤ/[_] (P : Prime) : Set where constructor ℤ✓ field mod : ℕ mod<p : mod < prime P open ℤ/[_] public module Operations {P : Prime} where open Prime P using () renaming (prime to p; isPrime to p-isPrime) open IsPrime p-isPrime using (1<p) p≢0 : False (p ≟ℕ 0) p≢0 = ≢⇒¬≟ (prime≢0 p-isPrime) [_] : ℕ → ℤ/[ P ] [ n ] = ℤ✓ ((n % p) {p≢0}) (n%m<m n p) instance ℤ/[]-number : Number (ℤ/[ P ]) ℤ/[]-number = record { Constraint = λ _ → ⊤ ; fromNat = λ n → [ n ] } infixl 6 _+_ _+_ : ℤ/[ P ] → ℤ/[ P ] → ℤ/[ P ] n + m = [ mod n +ℕ mod m ] infix 8 -_ -_ : ℤ/[ P ] → ℤ/[ P ] - (ℤ✓ zero 0<p) = ℤ✓ zero 0<p - (ℤ✓ (suc n) 1+n<p) = ℤ✓ (p ∸ suc n) (∸-mono-<ʳ (<⇒≤ 1+n<p) 0<1+n) infixl 7 _*_ _*_ : ℤ/[ P ] → ℤ/[ P ] → ℤ/[ P ] n * m = [ mod n *ℕ mod m ] ℤ/[]-irrelevance : ∀ {x y : ℤ/[ P ]} → mod x ≡ mod y → x ≡ y ℤ/[]-irrelevance {ℤ✓ mod[x] mod[x]<p} {ℤ✓ .mod[x] mod[y]<p} refl = cong (λ z<p → ℤ✓ mod[x] z<p) (<-irrelevant mod[x]<p mod[y]<p) n≢0⇒mod[n]≢0 : ∀ {n} → n ≢ 0 → mod n ≢ 0 n≢0⇒mod[n]≢0 {ℤ✓ zero _} n≢0 = contradiction (ℤ/[]-irrelevance (sym (0%m≡0 p))) n≢0 n≢0⇒mod[n]≢0 {ℤ✓ (suc n) _} n≢0 = λ () bézout-x∤p : ∀ n x y → 1 +ℕ x *ℕ n ≡ y *ℕ p → 0 ≢ (x % p) {p≢0} bézout-x∤p n x y 1+x*n≡y*p 0≡x%p = contradiction 1≡0 (λ ()) where 1≡0 : 1 ≡ zero 1≡0 = begin 1 ≡⟨ sym (1%m≡1 1<p) ⟩ (1 +ℕ 0 *ℕ n) % p ≡⟨ cong (λ t → ((1 +ℕ t *ℕ n) % p) {p≢0}) 0≡x%p ⟩ (1 +ℕ (x % p) *ℕ n) % p ≡⟨ %-distribˡ-+ 1 ((x % p) *ℕ n) p ⟩ (1 % p +ℕ ((x % p) *ℕ n) % p) % p ≡⟨ cong (λ t → ((1 % p +ℕ t) % p) {p≢0}) (%-distribˡ-* (x % p) n p) ⟩ (1 % p +ℕ ((x % p % p) *ℕ (n % p)) % p) % p ≡⟨ cong (λ t → (1 % p +ℕ (t *ℕ (n % p)) % p) % p) (m%n%n≡m%n x p) ⟩ (1 % p +ℕ ((x % p) *ℕ (n % p)) % p) % p ≡⟨ cong (λ t → (1 % p +ℕ t) % p) (sym (%-distribˡ-* x n p)) ⟩ (1 % p +ℕ (x *ℕ n) % p) % p ≡⟨ sym (%-distribˡ-+ 1 (x *ℕ n) p) ⟩ (1 +ℕ x *ℕ n) % p ≡⟨ cong (λ t → (t % p) {p≢0}) 1+x*n≡y*p ⟩ (y *ℕ p) % p ≡⟨ [m+kn]%n≡m%n 0 y p {p≢0} ⟩ 0 % p ≡⟨ 0%m≡0 p ⟩ 0 ∎ -- x⁻¹ * x - 1 ≡ z * p infix 8 _⁻¹ _⁻¹ : ∀ (n : ℤ/[ P ]) {n≢0 : n ≢ 0} → ℤ/[ P ] (n ⁻¹) {n≢0} with bézout-prime (mod n) p (n≢0⇒mod[n]≢0 n≢0) (mod<p n) p-isPrime ... | +ʳ x y 1+x*n≡y*p = ℤ✓ (p ∸ (x % p) {p≢0}) (∸-mono-<ʳ (<⇒≤ (n%m<m x p)) (0≢⇒0< (bézout-x∤p (mod n) x y 1+x*n≡y*p))) ... | +ˡ x y 1+y*p≡x*n = [ x ] infixl 7 _/_ _/_ : ∀ (n m : ℤ/[ P ]) {m≢0 : m ≢ 0} → ℤ/[ P ] (n / m) {m≢0} = n * (m ⁻¹) {m≢0} _≟_ : Decidable {A = ℤ/[ P ]} _≡_ ℤ✓ x x<p ≟ ℤ✓ y y<p = map (FE.equivalence ℤ/[]-irrelevance (λ { refl → refl })) (x ≟ℕ y) open Operations public
{ "alphanum_fraction": 0.4843617921, "avg_line_length": 36.96875, "ext": "agda", "hexsha": "ef7ebce401c1e4b511ea2c8d34f17f8579a74d7b", "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/Modular/Quotient/Base.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/Modular/Quotient/Base.agda", "max_line_length": 130, "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/Modular/Quotient/Base.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": 1893, "size": 3549 }
-- Jesper, 2016-11-04 -- Absurd patterns should *not* be counted as a UnusedArg. open import Common.Equality data ⊥ : Set where data Bool : Set where true false : Bool abort : (A : Set) → ⊥ → A abort A () test : (x y : ⊥) → abort Bool x ≡ abort Bool y test x y = refl
{ "alphanum_fraction": 0.6363636364, "avg_line_length": 17.1875, "ext": "agda", "hexsha": "9be1e10ccf1b485e98e7994ad28bb6604133d3a7", "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/AbsurdPatternNotUnused.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/AbsurdPatternNotUnused.agda", "max_line_length": 58, "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/AbsurdPatternNotUnused.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": 93, "size": 275 }
postulate [_…_] : Set → Set → Set
{ "alphanum_fraction": 0.5405405405, "avg_line_length": 9.25, "ext": "agda", "hexsha": "637c80e87c2d26397bd8fc72978cff6be0f93db7", "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/Issue3139.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/Issue3139.agda", "max_line_length": 25, "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/Issue3139.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": 15, "size": 37 }
module Issue1494.Helper where record Record : Set₁ where field _≡_ : {A : Set} → A → A → Set module Module (r : Record) where open Record r public
{ "alphanum_fraction": 0.6753246753, "avg_line_length": 17.1111111111, "ext": "agda", "hexsha": "37d2b2326533017a620ddc363c565c735dbd0a6b", "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/Issue1494/Helper.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/Issue1494/Helper.agda", "max_line_length": 37, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue1494/Helper.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": 48, "size": 154 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Finite.Fin.Instance.Span where open import Data.Nat using (ℕ) open import Data.Fin open import Data.Fin.Patterns open import Relation.Binary.PropositionalEquality using (_≡_ ; refl) open import Categories.Category.Finite.Fin open import Categories.Category open import Categories.Functor using (Functor; _∘F_) renaming (id to idF) open import Categories.NaturalTransformation using (ntHelper) open import Categories.NaturalTransformation.NaturalIsomorphism using (_≃_) open import Categories.Adjoint.Equivalence using (_⊣⊢_; ⊣Equivalence; withZig) import Categories.Morphism as Mor import Categories.Category.Instance.Span as Sp private variable a b c d : Fin 3 -- The diagram is the following: -- -- 1 <------- 0 -------> 2 -- SpanShape : FinCatShape SpanShape = record { size = 3 ; ∣_⇒_∣ = morph ; hasShape = record { id = id ; _∘_ = _∘_ ; assoc = assoc ; identityˡ = identityˡ ; identityʳ = identityʳ } } where morph : Fin 3 → Fin 3 → ℕ morph 0F 0F = 1 morph 0F 1F = 1 morph 0F 2F = 1 morph 1F 1F = 1 morph 2F 2F = 1 morph _ _ = 0 id : Fin (morph a a) id {0F} = 0F id {1F} = 0F id {2F} = 0F _∘_ : ∀ {a b c} → Fin (morph b c) → Fin (morph a b) → Fin (morph a c) _∘_ {0F} {0F} {0F} 0F 0F = 0F _∘_ {0F} {0F} {1F} 0F 0F = 0F _∘_ {0F} {0F} {2F} 0F 0F = 0F _∘_ {0F} {1F} {1F} 0F 0F = 0F _∘_ {0F} {2F} {2F} 0F 0F = 0F _∘_ {1F} {1F} {1F} 0F 0F = 0F _∘_ {2F} {2F} {2F} 0F 0F = 0F assoc : ∀ {f : Fin (morph a b)} {g : Fin (morph b c)} {h : Fin (morph c d)} → ((h ∘ g) ∘ f) ≡ (h ∘ (g ∘ f)) assoc {0F} {0F} {0F} {0F} {0F} {0F} {0F} = refl assoc {0F} {0F} {0F} {1F} {0F} {0F} {0F} = refl assoc {0F} {0F} {0F} {2F} {0F} {0F} {0F} = refl assoc {0F} {0F} {1F} {1F} {0F} {0F} {0F} = refl assoc {0F} {0F} {2F} {2F} {0F} {0F} {0F} = refl assoc {0F} {1F} {1F} {1F} {0F} {0F} {0F} = refl assoc {0F} {2F} {2F} {2F} {0F} {0F} {0F} = refl assoc {1F} {1F} {1F} {1F} {0F} {0F} {0F} = refl assoc {2F} {2F} {2F} {2F} {0F} {0F} {0F} = refl identityˡ : ∀ {f : Fin (morph a b)} → (id ∘ f) ≡ f identityˡ {0F} {0F} {0F} = refl identityˡ {0F} {1F} {0F} = refl identityˡ {0F} {2F} {0F} = refl identityˡ {1F} {1F} {0F} = refl identityˡ {2F} {2F} {0F} = refl identityʳ : ∀ {f : Fin (morph a b)} → (f ∘ id) ≡ f identityʳ {0F} {0F} {0F} = refl identityʳ {0F} {1F} {0F} = refl identityʳ {0F} {2F} {0F} = refl identityʳ {1F} {1F} {0F} = refl identityʳ {2F} {2F} {0F} = refl Span : Category _ _ _ Span = FinCategory SpanShape module Span = Category Span open FinCatShape SpanShape SpanToF : Functor Span Sp.Span SpanToF = record { F₀ = F₀ ; F₁ = F₁ ; identity = identity ; homomorphism = homomorphism ; F-resp-≈ = F-resp-≈ } where F₀ : Fin 3 → Sp.SpanObj F₀ 0F = Sp.center F₀ 1F = Sp.left F₀ 2F = Sp.right F₁ : Fin ∣ a ⇒ b ∣ → Sp.SpanArr (F₀ a) (F₀ b) F₁ {0F} {0F} 0F = Sp.span-id F₁ {0F} {1F} 0F = Sp.span-arrˡ F₁ {0F} {2F} 0F = Sp.span-arrʳ F₁ {1F} {1F} 0F = Sp.span-id F₁ {2F} {2F} 0F = Sp.span-id identity : F₁ (id {a}) ≡ Sp.span-id identity {0F} = refl identity {1F} = refl identity {2F} = refl homomorphism : ∀ {f : Fin ∣ a ⇒ b ∣} {g : Fin ∣ b ⇒ c ∣} → F₁ (g ∘ f) ≡ Sp.span-compose (F₁ g) (F₁ f) homomorphism {0F} {0F} {0F} {0F} {0F} = refl homomorphism {0F} {0F} {1F} {0F} {0F} = refl homomorphism {0F} {0F} {2F} {0F} {0F} = refl homomorphism {0F} {1F} {1F} {0F} {0F} = refl homomorphism {0F} {2F} {2F} {0F} {0F} = refl homomorphism {1F} {1F} {1F} {0F} {0F} = refl homomorphism {2F} {2F} {2F} {0F} {0F} = refl F-resp-≈ : ∀ {f g : Fin ∣ a ⇒ b ∣} → f ≡ g → F₁ f ≡ F₁ g F-resp-≈ {0F} {0F} {0F} {0F} _ = refl F-resp-≈ {0F} {1F} {0F} {0F} _ = refl F-resp-≈ {0F} {2F} {0F} {0F} _ = refl F-resp-≈ {1F} {1F} {0F} {0F} _ = refl F-resp-≈ {2F} {2F} {0F} {0F} _ = refl module SpanToF = Functor SpanToF SpanFromF : Functor Sp.Span Span SpanFromF = record { F₀ = F₀ ; F₁ = F₁ ; identity = identity ; homomorphism = homomorphism ; F-resp-≈ = F-resp-≈ } where F₀ : Sp.SpanObj → Fin 3 F₀ Sp.center = 0F F₀ Sp.left = 1F F₀ Sp.right = 2F F₁ : ∀ {A B} → Sp.Span [ A , B ] → Span [ F₀ A , F₀ B ] F₁ {Sp.center} Sp.span-id = 0F F₁ {Sp.left} Sp.span-id = 0F F₁ {Sp.right} Sp.span-id = 0F F₁ Sp.span-arrˡ = 0F F₁ Sp.span-arrʳ = 0F identity : ∀ {A} → F₁ (Category.id Sp.Span {A}) ≡ id identity {Sp.center} = refl identity {Sp.left} = refl identity {Sp.right} = refl homomorphism : ∀ {X Y Z} {f : Sp.Span [ X , Y ]} {g : Sp.Span [ Y , Z ]} → F₁ (Sp.Span [ g ∘ f ]) ≡ F₁ g ∘ F₁ f homomorphism {Sp.center} {_} {_} {Sp.span-id} {Sp.span-id} = refl homomorphism {Sp.left} {_} {_} {Sp.span-id} {Sp.span-id} = refl homomorphism {Sp.right} {_} {_} {Sp.span-id} {Sp.span-id} = refl homomorphism {_} {_} {_} {Sp.span-id} {Sp.span-arrˡ} = refl homomorphism {_} {_} {_} {Sp.span-id} {Sp.span-arrʳ} = refl homomorphism {_} {_} {_} {Sp.span-arrˡ} {Sp.span-id} = refl homomorphism {_} {_} {_} {Sp.span-arrʳ} {Sp.span-id} = refl F-resp-≈ : ∀ {A B} {f g : Sp.Span [ A , B ]} → f ≡ g → F₁ f ≡ F₁ g F-resp-≈ {Sp.center} {_} {Sp.span-id} {Sp.span-id} _ = refl F-resp-≈ {Sp.left} {_} {Sp.span-id} {Sp.span-id} _ = refl F-resp-≈ {Sp.right} {_} {Sp.span-id} {Sp.span-id} _ = refl F-resp-≈ {.Sp.center} {.Sp.left} {Sp.span-arrˡ} {Sp.span-arrˡ} _ = refl F-resp-≈ {.Sp.center} {.Sp.right} {Sp.span-arrʳ} {Sp.span-arrʳ} _ = refl module SpanFromF = Functor SpanFromF SpansEquivF : SpanToF ⊣⊢ SpanFromF SpansEquivF = withZig record { unit = unit ; counit = counit ; zig = zig } where unit⇒η : ∀ a → Fin ∣ a ⇒ SpanFromF.₀ (SpanToF.₀ a) ∣ unit⇒η 0F = 0F unit⇒η 1F = 0F unit⇒η 2F = 0F unit⇐η : ∀ a → Fin ∣ SpanFromF.₀ (SpanToF.₀ a) ⇒ a ∣ unit⇐η 0F = 0F unit⇐η 1F = 0F unit⇐η 2F = 0F unit : idF ≃ SpanFromF ∘F SpanToF unit = record { F⇒G = ntHelper record { η = unit⇒η ; commute = commute₁ } ; F⇐G = ntHelper record { η = unit⇐η ; commute = commute₂ } ; iso = iso } where open Mor Span commute₁ : ∀ (f : Fin ∣ a ⇒ b ∣) → unit⇒η b ∘ f ≡ SpanFromF.₁ (SpanToF.₁ f) ∘ unit⇒η a commute₁ {0F} {0F} 0F = refl commute₁ {0F} {1F} 0F = refl commute₁ {0F} {2F} 0F = refl commute₁ {1F} {1F} 0F = refl commute₁ {2F} {2F} 0F = refl commute₂ : ∀ (f : Fin ∣ a ⇒ b ∣) → unit⇐η b ∘ SpanFromF.₁ (SpanToF.₁ f) ≡ f ∘ unit⇐η a commute₂ {0F} {0F} 0F = refl commute₂ {0F} {1F} 0F = refl commute₂ {0F} {2F} 0F = refl commute₂ {1F} {1F} 0F = refl commute₂ {2F} {2F} 0F = refl iso : ∀ a → Iso (unit⇒η a) (unit⇐η a) iso 0F = record { isoˡ = refl ; isoʳ = refl } iso 1F = record { isoˡ = refl ; isoʳ = refl } iso 2F = record { isoˡ = refl ; isoʳ = refl } counit⇒η : ∀ X → Sp.Span [ Functor.F₀ (SpanToF ∘F SpanFromF) X , X ] counit⇒η Sp.center = Sp.span-id counit⇒η Sp.left = Sp.span-id counit⇒η Sp.right = Sp.span-id counit⇐η : ∀ X → Sp.Span [ X , Functor.F₀ (SpanToF ∘F SpanFromF) X ] counit⇐η Sp.center = Sp.span-id counit⇐η Sp.left = Sp.span-id counit⇐η Sp.right = Sp.span-id counit : SpanToF ∘F SpanFromF ≃ idF counit = record { F⇒G = ntHelper record { η = counit⇒η ; commute = commute₁ } ; F⇐G = ntHelper record { η = counit⇐η ; commute = commute₂ } ; iso = iso } where open Mor Sp.Span commute₁ : ∀ {X Y} (f : Sp.SpanArr X Y) → Sp.span-compose (counit⇒η Y) (SpanToF.₁ (SpanFromF.₁ f)) ≡ Sp.span-compose f (counit⇒η X) commute₁ {Sp.center} {.Sp.center} Sp.span-id = refl commute₁ {Sp.left} {.Sp.left} Sp.span-id = refl commute₁ {Sp.right} {.Sp.right} Sp.span-id = refl commute₁ {.Sp.center} {.Sp.left} Sp.span-arrˡ = refl commute₁ {.Sp.center} {.Sp.right} Sp.span-arrʳ = refl commute₂ : ∀ {X Y} (f : Sp.SpanArr X Y) → Sp.span-compose (counit⇐η Y) f ≡ Sp.span-compose (SpanToF.₁ (SpanFromF.₁ f)) (counit⇐η X) commute₂ {Sp.center} {.Sp.center} Sp.span-id = refl commute₂ {Sp.left} {.Sp.left} Sp.span-id = refl commute₂ {Sp.right} {.Sp.right} Sp.span-id = refl commute₂ {.Sp.center} {.Sp.left} Sp.span-arrˡ = refl commute₂ {.Sp.center} {.Sp.right} Sp.span-arrʳ = refl iso : ∀ X → Iso (counit⇒η X) (counit⇐η X) iso Sp.center = record { isoˡ = refl ; isoʳ = refl } iso Sp.left = record { isoˡ = refl ; isoʳ = refl } iso Sp.right = record { isoˡ = refl ; isoʳ = refl } zig : ∀ {a} → Sp.span-compose (counit⇒η (SpanToF.₀ a)) (SpanToF.₁ (unit⇒η a)) ≡ Sp.span-id zig {0F} = refl zig {1F} = refl zig {2F} = refl SpansEquiv : ⊣Equivalence Span Sp.Span SpansEquiv = record { L⊣⊢R = SpansEquivF } module SpansEquiv = ⊣Equivalence SpansEquiv
{ "alphanum_fraction": 0.4689958786, "avg_line_length": 35.7056856187, "ext": "agda", "hexsha": "9b702ac69c479f67a16751d8d9b05fee7f2b3ce7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Category/Finite/Fin/Instance/Span.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Category/Finite/Fin/Instance/Span.agda", "max_line_length": 118, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Category/Finite/Fin/Instance/Span.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4158, "size": 10676 }
-- Basic intuitionistic modal logic S4, without ∨, ⊥, or ◇. -- Gentzen-style formalisation of syntax, after Bierman-de Paiva. -- Simple terms. module BasicIS4.Syntax.Gentzen where open import BasicIS4.Syntax.Common public -- Derivations. mutual infix 3 _⊢_ data _⊢_ (Γ : Cx Ty) : Ty → Set where var : ∀ {A} → A ∈ Γ → Γ ⊢ A lam : ∀ {A B} → Γ , A ⊢ B → Γ ⊢ A ▻ B app : ∀ {A B} → Γ ⊢ A ▻ B → Γ ⊢ A → Γ ⊢ B multibox : ∀ {A Δ} → Γ ⊢⋆ □⋆ Δ → □⋆ Δ ⊢ A → Γ ⊢ □ A down : ∀ {A} → Γ ⊢ □ A → Γ ⊢ A pair : ∀ {A B} → Γ ⊢ A → Γ ⊢ B → Γ ⊢ A ∧ B fst : ∀ {A B} → Γ ⊢ A ∧ B → Γ ⊢ A snd : ∀ {A B} → Γ ⊢ A ∧ B → Γ ⊢ B unit : Γ ⊢ ⊤ infix 3 _⊢⋆_ _⊢⋆_ : Cx Ty → Cx Ty → Set Γ ⊢⋆ ∅ = 𝟙 Γ ⊢⋆ Ξ , A = Γ ⊢⋆ Ξ × Γ ⊢ A -- Monotonicity with respect to context inclusion. mutual mono⊢ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢ A → Γ′ ⊢ A mono⊢ η (var i) = var (mono∈ η i) mono⊢ η (lam t) = lam (mono⊢ (keep η) t) mono⊢ η (app t u) = app (mono⊢ η t) (mono⊢ η u) mono⊢ η (multibox ts u) = multibox (mono⊢⋆ η ts) u mono⊢ η (down t) = down (mono⊢ η t) mono⊢ η (pair t u) = pair (mono⊢ η t) (mono⊢ η u) mono⊢ η (fst t) = fst (mono⊢ η t) mono⊢ η (snd t) = snd (mono⊢ η t) mono⊢ η unit = unit mono⊢⋆ : ∀ {Ξ Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢⋆ Ξ → Γ′ ⊢⋆ Ξ mono⊢⋆ {∅} η ∙ = ∙ mono⊢⋆ {Ξ , A} η (ts , t) = mono⊢⋆ η ts , mono⊢ η t -- Shorthand for variables. v₀ : ∀ {A Γ} → Γ , A ⊢ A v₀ = var i₀ v₁ : ∀ {A B Γ} → Γ , A , B ⊢ A v₁ = var i₁ v₂ : ∀ {A B C Γ} → Γ , A , B , C ⊢ A v₂ = var i₂ -- Reflexivity. refl⊢⋆ : ∀ {Γ} → Γ ⊢⋆ Γ refl⊢⋆ {∅} = ∙ refl⊢⋆ {Γ , A} = mono⊢⋆ weak⊆ refl⊢⋆ , v₀ -- Deduction theorem is built-in. lam⋆ : ∀ {Ξ Γ A} → Γ ⧺ Ξ ⊢ A → Γ ⊢ Ξ ▻⋯▻ A lam⋆ {∅} = I lam⋆ {Ξ , B} = lam⋆ {Ξ} ∘ lam lam⋆₀ : ∀ {Γ A} → Γ ⊢ A → ∅ ⊢ Γ ▻⋯▻ A lam⋆₀ {∅} = I lam⋆₀ {Γ , B} = lam⋆₀ ∘ lam -- Detachment theorem. det : ∀ {A B Γ} → Γ ⊢ A ▻ B → Γ , A ⊢ B det t = app (mono⊢ weak⊆ t) v₀ det⋆ : ∀ {Ξ Γ A} → Γ ⊢ Ξ ▻⋯▻ A → Γ ⧺ Ξ ⊢ A det⋆ {∅} = I det⋆ {Ξ , B} = det ∘ det⋆ {Ξ} det⋆₀ : ∀ {Γ A} → ∅ ⊢ Γ ▻⋯▻ A → Γ ⊢ A det⋆₀ {∅} = I det⋆₀ {Γ , B} = det ∘ det⋆₀ -- Cut and multicut. cut : ∀ {A B Γ} → Γ ⊢ A → Γ , A ⊢ B → Γ ⊢ B cut t u = app (lam u) t multicut : ∀ {Ξ A Γ} → Γ ⊢⋆ Ξ → Ξ ⊢ A → Γ ⊢ A multicut {∅} ∙ u = mono⊢ bot⊆ u multicut {Ξ , B} (ts , t) u = app (multicut ts (lam u)) t -- Transitivity. trans⊢⋆ : ∀ {Γ″ Γ′ Γ} → Γ ⊢⋆ Γ′ → Γ′ ⊢⋆ Γ″ → Γ ⊢⋆ Γ″ trans⊢⋆ {∅} ts ∙ = ∙ trans⊢⋆ {Γ″ , A} ts (us , u) = trans⊢⋆ ts us , multicut ts u -- Contraction. ccont : ∀ {A B Γ} → Γ ⊢ (A ▻ A ▻ B) ▻ A ▻ B ccont = lam (lam (app (app v₁ v₀) v₀)) cont : ∀ {A B Γ} → Γ , A , A ⊢ B → Γ , A ⊢ B cont t = det (app ccont (lam (lam t))) -- Exchange, or Schönfinkel’s C combinator. cexch : ∀ {A B C Γ} → Γ ⊢ (A ▻ B ▻ C) ▻ B ▻ A ▻ C cexch = lam (lam (lam (app (app v₂ v₀) v₁))) exch : ∀ {A B C Γ} → Γ , A , B ⊢ C → Γ , B , A ⊢ C exch t = det (det (app cexch (lam (lam t)))) -- Composition, or Schönfinkel’s B combinator. ccomp : ∀ {A B C Γ} → Γ ⊢ (B ▻ C) ▻ (A ▻ B) ▻ A ▻ C ccomp = lam (lam (lam (app v₂ (app v₁ v₀)))) comp : ∀ {A B C Γ} → Γ , B ⊢ C → Γ , A ⊢ B → Γ , A ⊢ C comp t u = det (app (app ccomp (lam t)) (lam u)) -- Useful theorems in functional form. dist : ∀ {A B Γ} → Γ ⊢ □ (A ▻ B) → Γ ⊢ □ A → Γ ⊢ □ B dist t u = multibox ((∙ , t) , u) (app (down v₁) (down v₀)) up : ∀ {A Γ} → Γ ⊢ □ A → Γ ⊢ □ □ A up t = multibox (∙ , t) v₀ distup : ∀ {A B Γ} → Γ ⊢ □ (□ A ▻ B) → Γ ⊢ □ A → Γ ⊢ □ B distup t u = dist t (up u) box : ∀ {A Γ} → ∅ ⊢ A → Γ ⊢ □ A box t = multibox ∙ t unbox : ∀ {A C Γ} → Γ ⊢ □ A → Γ , □ A ⊢ C → Γ ⊢ C unbox t u = app (lam u) t -- Useful theorems in combinatory form. ci : ∀ {A Γ} → Γ ⊢ A ▻ A ci = lam v₀ ck : ∀ {A B Γ} → Γ ⊢ A ▻ B ▻ A ck = lam (lam v₁) cs : ∀ {A B C Γ} → Γ ⊢ (A ▻ B ▻ C) ▻ (A ▻ B) ▻ A ▻ C cs = lam (lam (lam (app (app v₂ v₀) (app v₁ v₀)))) cdist : ∀ {A B Γ} → Γ ⊢ □ (A ▻ B) ▻ □ A ▻ □ B cdist = lam (lam (dist v₁ v₀)) cup : ∀ {A Γ} → Γ ⊢ □ A ▻ □ □ A cup = lam (up v₀) cdown : ∀ {A Γ} → Γ ⊢ □ A ▻ A cdown = lam (down v₀) cdistup : ∀ {A B Γ} → Γ ⊢ □ (□ A ▻ B) ▻ □ A ▻ □ B cdistup = lam (lam (dist v₁ (up v₀))) cunbox : ∀ {A C Γ} → Γ ⊢ □ A ▻ (□ A ▻ C) ▻ C cunbox = lam (lam (app v₀ v₁)) cpair : ∀ {A B Γ} → Γ ⊢ A ▻ B ▻ A ∧ B cpair = lam (lam (pair v₁ v₀)) cfst : ∀ {A B Γ} → Γ ⊢ A ∧ B ▻ A cfst = lam (fst v₀) csnd : ∀ {A B Γ} → Γ ⊢ A ∧ B ▻ B csnd = lam (snd v₀) -- Internalisation, or lifting, and additional theorems. lift : ∀ {Γ A} → Γ ⊢ A → □⋆ Γ ⊢ □ A lift {∅} t = box t lift {Γ , B} t = det (app cdist (lift (lam t))) hypup : ∀ {A B Γ} → Γ ⊢ A ▻ B → Γ ⊢ □ A ▻ B hypup t = lam (app (mono⊢ weak⊆ t) (down v₀)) hypdown : ∀ {A B Γ} → Γ ⊢ □ □ A ▻ B → Γ ⊢ □ A ▻ B hypdown t = lam (app (mono⊢ weak⊆ t) (up v₀)) cxup : ∀ {Γ A} → Γ ⊢ A → □⋆ Γ ⊢ A cxup {∅} t = t cxup {Γ , B} t = det (hypup (cxup (lam t))) cxdown : ∀ {Γ A} → □⋆ □⋆ Γ ⊢ A → □⋆ Γ ⊢ A cxdown {∅} t = t cxdown {Γ , B} t = det (hypdown (cxdown (lam t))) box⋆ : ∀ {Ξ Γ} → ∅ ⊢⋆ Ξ → Γ ⊢⋆ □⋆ Ξ box⋆ {∅} ∙ = ∙ box⋆ {Ξ , A} (ts , t) = box⋆ ts , box t lift⋆ : ∀ {Ξ Γ} → Γ ⊢⋆ Ξ → □⋆ Γ ⊢⋆ □⋆ Ξ lift⋆ {∅} ∙ = ∙ lift⋆ {Ξ , A} (ts , t) = lift⋆ ts , lift t up⋆ : ∀ {Ξ Γ} → Γ ⊢⋆ □⋆ Ξ → Γ ⊢⋆ □⋆ □⋆ Ξ up⋆ {∅} ∙ = ∙ up⋆ {Ξ , A} (ts , t) = up⋆ ts , up t down⋆ : ∀ {Ξ Γ} → Γ ⊢⋆ □⋆ Ξ → Γ ⊢⋆ Ξ down⋆ {∅} ∙ = ∙ down⋆ {Ξ , A} (ts , t) = down⋆ ts , down t dist′ : ∀ {A B Γ} → Γ ⊢ □ (A ▻ B) → Γ ⊢ □ A ▻ □ B dist′ t = lam (dist (mono⊢ weak⊆ t) v₀) mpair : ∀ {A B Γ} → Γ ⊢ □ A → Γ ⊢ □ B → Γ ⊢ □ (A ∧ B) mpair t u = multibox ((∙ , t) , u) (pair (down v₁) (down v₀)) mfst : ∀ {A B Γ} → Γ ⊢ □ (A ∧ B) → Γ ⊢ □ A mfst t = multibox (∙ , t) (fst (down v₀)) msnd : ∀ {A B Γ} → Γ ⊢ □ (A ∧ B) → Γ ⊢ □ B msnd t = multibox (∙ , t) (snd (down v₀)) -- Closure under context concatenation. concat : ∀ {A B Γ} Γ′ → Γ , A ⊢ B → Γ′ ⊢ A → Γ ⧺ Γ′ ⊢ B concat Γ′ t u = app (mono⊢ (weak⊆⧺₁ Γ′) (lam t)) (mono⊢ weak⊆⧺₂ u) -- Substitution. mutual [_≔_]_ : ∀ {A B Γ} → (i : A ∈ Γ) → Γ ∖ i ⊢ A → Γ ⊢ B → Γ ∖ i ⊢ B [ i ≔ s ] var j with i ≟∈ j [ i ≔ s ] var .i | same = s [ i ≔ s ] var ._ | diff j = var j [ i ≔ s ] lam t = lam ([ pop i ≔ mono⊢ weak⊆ s ] t) [ i ≔ s ] app t u = app ([ i ≔ s ] t) ([ i ≔ s ] u) [ i ≔ s ] multibox ts u = multibox ([ i ≔ s ]⋆ ts) u [ i ≔ s ] down t = down ([ i ≔ s ] t) [ i ≔ s ] pair t u = pair ([ i ≔ s ] t) ([ i ≔ s ] u) [ i ≔ s ] fst t = fst ([ i ≔ s ] t) [ i ≔ s ] snd t = snd ([ i ≔ s ] t) [ i ≔ s ] unit = unit [_≔_]⋆_ : ∀ {Ξ A Γ} → (i : A ∈ Γ) → Γ ∖ i ⊢ A → Γ ⊢⋆ Ξ → Γ ∖ i ⊢⋆ Ξ [_≔_]⋆_ {∅} i s ∙ = ∙ [_≔_]⋆_ {Ξ , B} i s (ts , t) = [ i ≔ s ]⋆ ts , [ i ≔ s ] t -- Convertibility. data _⋙_ {Γ : Cx Ty} : ∀ {A} → Γ ⊢ A → Γ ⊢ A → Set where refl⋙ : ∀ {A} → {t : Γ ⊢ A} → t ⋙ t trans⋙ : ∀ {A} → {t t′ t″ : Γ ⊢ A} → t ⋙ t′ → t′ ⋙ t″ → t ⋙ t″ sym⋙ : ∀ {A} → {t t′ : Γ ⊢ A} → t ⋙ t′ → t′ ⋙ t conglam⋙ : ∀ {A B} → {t t′ : Γ , A ⊢ B} → t ⋙ t′ → lam t ⋙ lam t′ congapp⋙ : ∀ {A B} → {t t′ : Γ ⊢ A ▻ B} → {u u′ : Γ ⊢ A} → t ⋙ t′ → u ⋙ u′ → app t u ⋙ app t′ u′ -- TODO: What about multibox? congdown⋙ : ∀ {A} → {t t′ : Γ ⊢ □ A} → t ⋙ t′ → down t ⋙ down t′ congpair⋙ : ∀ {A B} → {t t′ : Γ ⊢ A} → {u u′ : Γ ⊢ B} → t ⋙ t′ → u ⋙ u′ → pair t u ⋙ pair t′ u′ congfst⋙ : ∀ {A B} → {t t′ : Γ ⊢ A ∧ B} → t ⋙ t′ → fst t ⋙ fst t′ congsnd⋙ : ∀ {A B} → {t t′ : Γ ⊢ A ∧ B} → t ⋙ t′ → snd t ⋙ snd t′ beta▻⋙ : ∀ {A B} → {t : Γ , A ⊢ B} → {u : Γ ⊢ A} → app (lam t) u ⋙ ([ top ≔ u ] t) eta▻⋙ : ∀ {A B} → {t : Γ ⊢ A ▻ B} → t ⋙ lam (app (mono⊢ weak⊆ t) v₀) -- TODO: What about beta and eta for □? beta∧₁⋙ : ∀ {A B} → {t : Γ ⊢ A} → {u : Γ ⊢ B} → fst (pair t u) ⋙ t beta∧₂⋙ : ∀ {A B} → {t : Γ ⊢ A} → {u : Γ ⊢ B} → snd (pair t u) ⋙ u eta∧⋙ : ∀ {A B} → {t : Γ ⊢ A ∧ B} → t ⋙ pair (fst t) (snd t) eta⊤⋙ : ∀ {t : Γ ⊢ ⊤} → t ⋙ unit
{ "alphanum_fraction": 0.3757589911, "avg_line_length": 26.4320987654, "ext": "agda", "hexsha": "bdab478e446efc09065c5df8900104420b951674", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/hilbert-gentzen", "max_forks_repo_path": "BasicIS4/Syntax/Gentzen.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/hilbert-gentzen", "max_issues_repo_path": "BasicIS4/Syntax/Gentzen.agda", "max_line_length": 69, "max_stars_count": 29, "max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/hilbert-gentzen", "max_stars_repo_path": "BasicIS4/Syntax/Gentzen.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z", "num_tokens": 4530, "size": 8564 }
module Not-named-according-to-the-Haskell-lexical-syntax where postulate IO : Set -> Set {-# BUILTIN IO IO #-} {-# COMPILED_TYPE IO IO #-} postulate return : {A : Set} -> A -> IO A {-# COMPILED return (\_ -> return :: a -> IO a) #-} {-# COMPILED_EPIC return (u1 : Unit, a : Any) -> Any = ioreturn(a) #-} data Unit : Set where unit : Unit {-# COMPILED_DATA Unit () () #-}
{ "alphanum_fraction": 0.5953002611, "avg_line_length": 20.1578947368, "ext": "agda", "hexsha": "1e6f9021050f6c43f707e07aa9114e849856d993", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/compiler/Not-named-according-to-the-Haskell-lexical-syntax.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "examples/compiler/Not-named-according-to-the-Haskell-lexical-syntax.agda", "max_line_length": 70, "max_stars_count": 1, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "examples/compiler/Not-named-according-to-the-Haskell-lexical-syntax.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": 118, "size": 383 }
module examplesPaperJFP.NativeIOSafe where open import Data.Maybe.Base using (Maybe; nothing; just) public open import Data.String.Base using (String) public record Unit : Set where constructor unit {-# COMPILE GHC Unit = () #-} postulate NativeIO : Set → Set nativeReturn : {A : Set} → A → NativeIO A _native>>=_ : {A B : Set} → NativeIO A → (A → NativeIO B) → NativeIO B {-# BUILTIN IO NativeIO #-} {-# COMPILE GHC NativeIO = IO #-} -- IO.FF-I.AgdaIO {-# COMPILE GHC _native>>=_ = (\_ _ -> (>>=) :: IO a -> (a -> IO b) -> IO b) #-} {-# COMPILE GHC nativeReturn = (\_ -> return :: a -> IO a) #-} postulate nativeGetLine : NativeIO (Maybe String) nativePutStrLn : String → NativeIO Unit {-# FOREIGN GHC import Data.Text #-} {-# FOREIGN GHC import System.IO.Error #-} {-# COMPILE GHC nativePutStrLn = (\ s -> putStrLn (Data.Text.unpack s)) #-} {-# COMPILE GHC nativeGetLine = (fmap (Just . Data.Text.pack) getLine `System.IO.Error.catchIOError` \ err -> if System.IO.Error.isEOFError err then return Nothing else ioError err) #-}
{ "alphanum_fraction": 0.65, "avg_line_length": 34.1935483871, "ext": "agda", "hexsha": "0bcf3dd2e515293b0bbbfac93711b877c7b53c13", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "examples/examplesPaperJFP/NativeIOSafe.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "examples/examplesPaperJFP/NativeIOSafe.agda", "max_line_length": 185, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "examples/examplesPaperJFP/NativeIOSafe.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 298, "size": 1060 }
module Data.String.Instance where open import Agda.Builtin.String open import Class.Equality open import Class.Monoid open import Class.Show open import Data.String renaming (_≟_ to _≟S_) instance String-Eq : Eq String String-Eq = record { _≟_ = _≟S_ } String-EqB : EqB String String-EqB = record { _≣_ = primStringEquality } String-Monoid : Monoid String String-Monoid = record { mzero = "" ; _+_ = _++_ } String-Show : Show String String-Show = record { show = λ x -> x }
{ "alphanum_fraction": 0.6949494949, "avg_line_length": 23.5714285714, "ext": "agda", "hexsha": "24933f681daa492020cd97acd223d51b616c646d", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_path": "stdlib-exts/Data/String/Instance.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_path": "stdlib-exts/Data/String/Instance.agda", "max_line_length": 52, "max_stars_count": 35, "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_path": "stdlib-exts/Data/String/Instance.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "num_tokens": 154, "size": 495 }
module Numeral.Natural.Function.Proofs where import Lvl open import Data.Tuple open import Functional open import Logic.Propositional open import Logic.Propositional.Theorems open import Numeral.Natural open import Numeral.Natural.Function open import Numeral.Natural.Relation.Order as ≤ using (_≤_ ; _≥_) open import Numeral.Natural.Oper open import Numeral.Natural.Oper.Proofs open import Numeral.Natural.Oper.Proofs.Order open import Numeral.Natural.Relation.Order.Proofs open import Relator.Equals open import Relator.Equals.Proofs open import Structure.Function.Domain import Structure.Operator.Names as Names open import Structure.Operator.Properties open import Structure.Relator.Properties open import Syntax.Transitivity max-0ₗ : ∀{b} → (max 𝟎 b ≡ b) max-0ₗ {𝟎} = [≡]-intro max-0ₗ {𝐒 b} = [≡]-intro {-# REWRITE max-0ₗ #-} max-0ᵣ : ∀{a} → (max a 𝟎 ≡ a) max-0ᵣ {𝟎} = [≡]-intro max-0ᵣ {𝐒 a} = [≡]-intro {-# REWRITE max-0ᵣ #-} min-0ₗ : ∀{b} → (min 𝟎 b ≡ 𝟎) min-0ₗ {𝟎} = [≡]-intro min-0ₗ {𝐒 b} = [≡]-intro {-# REWRITE min-0ₗ #-} min-0ᵣ : ∀{a} → (min a 𝟎 ≡ 𝟎) min-0ᵣ {𝟎} = [≡]-intro min-0ᵣ {𝐒 a} = [≡]-intro {-# REWRITE min-0ᵣ #-} instance min-idempotence : Idempotence(min) min-idempotence = intro proof where proof : Names.Idempotence(min) proof{𝟎} = [≡]-intro proof{𝐒 x} = [≡]-with(𝐒) (proof{x}) instance max-idempotence : Idempotence(max) max-idempotence = intro proof where proof : Names.Idempotence(max) proof{𝟎} = [≡]-intro proof{𝐒 x} = [≡]-with(𝐒) (proof{x}) max-elementary : ∀{a b} → (max(a)(b) ≡ a + (b −₀ a)) max-elementary {𝟎} {𝟎} = [≡]-intro max-elementary {𝟎} {𝐒(b)} = [≡]-intro max-elementary {𝐒(a)} {𝟎} = [≡]-intro max-elementary {𝐒(a)} {𝐒(b)} = [≡]-with(𝐒) (max-elementary {a} {b}) min-elementary : ∀{a b} → (min(a)(b) ≡ b −₀ (b −₀ a)) min-elementary {𝟎} {𝟎} = [≡]-intro min-elementary {𝟎} {𝐒(b)} = [≡]-intro min-elementary {𝐒(a)} {𝟎} = [≡]-intro min-elementary {𝐒(a)} {𝐒(b)} = ([≡]-with(𝐒) (min-elementary {a} {b})) 🝖 (symmetry(_≡_) ([↔]-to-[→] [−₀][𝐒]ₗ-equality ([−₀]-lesser {b}{a}))) instance min-commutativity : Commutativity(min) Commutativity.proof(min-commutativity) = proof where proof : Names.Commutativity(min) proof{𝟎} {𝟎} = [≡]-intro proof{𝟎} {𝐒(b)} = [≡]-intro proof{𝐒(a)}{𝟎} = [≡]-intro proof{𝐒(a)}{𝐒(b)} = [≡]-with(𝐒) (proof{a}{b}) instance min-associativity : Associativity(min) Associativity.proof(min-associativity) = proof where proof : Names.Associativity(min) proof{𝟎} {𝟎} {𝟎} = [≡]-intro proof{𝟎} {𝟎} {𝐒(c)} = [≡]-intro proof{𝟎} {𝐒(b)}{𝟎} = [≡]-intro proof{𝐒(a)}{𝟎} {𝟎} = [≡]-intro proof{𝟎} {𝐒(b)}{𝐒(c)} = [≡]-intro proof{𝐒(a)}{𝟎} {𝐒(c)} = [≡]-intro proof{𝐒(a)}{𝐒(b)}{𝟎} = [≡]-intro proof{𝐒(a)}{𝐒(b)}{𝐒(c)} = [≡]-with(𝐒) (proof{a}{b}{c}) -- min(min(𝐒x)(𝐒y))(𝐒z) -- = min(𝐒min(x)(y))(𝐒z) -- = 𝐒(min(min(x)(y))(z)) -- = 𝐒(min(x)(min(y)(z))) -- = min(𝐒x)(𝐒min(y)(z)) -- = min(𝐒x)(min(𝐒y)(𝐒z) instance min-orderₗ : ∀{a b} → (min(a)(b) ≤ a) min-orderₗ {𝟎} {𝟎} = [≤]-minimum {𝟎} min-orderₗ {𝐒(a)}{𝟎} = [≤]-minimum {𝐒(a)} min-orderₗ {𝟎} {𝐒(b)} = [≤]-minimum {𝟎} min-orderₗ {𝐒(a)}{𝐒(b)} = [≤]-with-[𝐒] ⦃ min-orderₗ {a}{b} ⦄ instance min-orderᵣ : ∀{a b} → (min(a)(b) ≤ b) min-orderᵣ {𝟎} {𝟎} = [≤]-minimum {𝟎} min-orderᵣ {𝐒(a)}{𝟎} = [≤]-minimum {𝟎} min-orderᵣ {𝟎} {𝐒(b)} = [≤]-minimum {𝐒(b)} min-orderᵣ {𝐒(a)}{𝐒(b)} = [≤]-with-[𝐒] ⦃ min-orderᵣ {a}{b} ⦄ min-arg : ∀{a b} → (min(a)(b) ≡ a) ∨ (min(a)(b) ≡ b) min-arg {𝟎} {𝟎} = [∨]-introₗ([≡]-intro) min-arg {𝟎} {𝐒(b)} = [∨]-introₗ([≡]-intro) min-arg {𝐒(a)}{𝟎} = [∨]-introᵣ([≡]-intro) min-arg {𝐒(a)}{𝐒(b)} = constructive-dilemma ([≡]-with(𝐒)) ([≡]-with(𝐒)) (min-arg {a}{b}) min-defₗ : ∀{a b} → (a ≤ b) ↔ (min(a)(b) ≡ a) min-defₗ {a}{b} = [↔]-intro (l{a}{b}) (r{a}{b}) where l : ∀{a b} → (a ≤ b) ← (min(a)(b) ≡ a) l {𝟎} {𝟎} _ = [≤]-minimum {𝟎} l {𝟎} {𝐒(b)} _ = [≤]-minimum {𝐒(b)} l {𝐒(_)}{𝟎} () l {𝐒(a)}{𝐒(b)} minaba = [≤]-with-[𝐒] ⦃ l{a}{b} (injective(𝐒) (minaba)) ⦄ r : ∀{a b} → (a ≤ b) → (min(a)(b) ≡ a) r {𝟎} {𝟎} _ = [≡]-intro r {𝟎} {𝐒(b)} _ = [≡]-intro r {𝐒(_)}{𝟎} () r {𝐒(a)}{𝐒(b)} (≤.succ ab) = [≡]-with(𝐒) (r{a}{b} (ab)) min-defᵣ : ∀{a b} → (b ≤ a) ↔ (min(a)(b) ≡ b) min-defᵣ {a}{b} = [≡]-substitutionᵣ (commutativity(min)) {expr ↦ (b ≤ a) ↔ (expr ≡ b)} (min-defₗ{b}{a}) instance max-commutativity : Commutativity(max) Commutativity.proof(max-commutativity) = proof where proof : Names.Commutativity(max) proof{𝟎} {𝟎} = [≡]-intro proof{𝟎} {𝐒(b)} = [≡]-intro proof{𝐒(a)}{𝟎} = [≡]-intro proof{𝐒(a)}{𝐒(b)} = [≡]-with(𝐒) (proof{a}{b}) instance max-associativity : Associativity(max) Associativity.proof(max-associativity) = proof where proof : Names.Associativity(max) proof{𝟎} {𝟎} {𝟎} = [≡]-intro proof{𝟎} {𝟎} {𝐒(c)} = [≡]-intro proof{𝟎} {𝐒(b)}{𝟎} = [≡]-intro proof{𝐒(a)}{𝟎} {𝟎} = [≡]-intro proof{𝟎} {𝐒(b)}{𝐒(c)} = [≡]-intro proof{𝐒(a)}{𝟎} {𝐒(c)} = [≡]-intro proof{𝐒(a)}{𝐒(b)}{𝟎} = [≡]-intro proof{𝐒(a)}{𝐒(b)}{𝐒(c)} = [≡]-with(𝐒) (proof{a}{b}{c}) -- max-[+]-distributivityₗ : Distributivityₗ(max) -- max-[+]-distributivityᵣ : Distributivityᵣ(max) instance max-orderₗ : ∀{a b} → (max(a)(b) ≥ a) max-orderₗ {𝟎} {𝟎} = [≤]-minimum {max(𝟎)(𝟎)} max-orderₗ {𝐒(a)}{𝟎} = reflexivity(_≥_) max-orderₗ {𝟎} {𝐒(b)} = [≤]-minimum {max(𝟎)(𝐒(b))} max-orderₗ {𝐒(a)}{𝐒(b)} = [≤]-with-[𝐒] ⦃ max-orderₗ {a}{b} ⦄ instance max-orderᵣ : ∀{a b} → (max(a)(b) ≥ b) max-orderᵣ {𝟎} {𝟎} = [≤]-minimum {max(𝟎)(𝟎)} max-orderᵣ {𝐒(a)}{𝟎} = [≤]-minimum {max(𝐒(a))(𝟎)} max-orderᵣ {𝟎} {𝐒(b)} = reflexivity(_≥_) max-orderᵣ {𝐒(a)}{𝐒(b)} = [≤]-with-[𝐒] ⦃ max-orderᵣ {a}{b} ⦄ max-arg : ∀{a b} → (max(a)(b) ≡ a)∨(max(a)(b) ≡ b) max-arg {𝟎} {𝟎} = [∨]-introₗ([≡]-intro) max-arg {𝟎} {𝐒(b)} = [∨]-introᵣ([≡]-intro) max-arg {𝐒(a)}{𝟎} = [∨]-introₗ([≡]-intro) max-arg {𝐒(a)}{𝐒(b)} = constructive-dilemma ([≡]-with(𝐒)) ([≡]-with(𝐒)) (max-arg {a}{b}) max-defₗ : ∀{a b} → (a ≥ b) ↔ (max(a)(b) ≡ a) max-defₗ {a}{b} = [↔]-intro (l{a}{b}) (r{a}{b}) where l : ∀{a b} → (a ≥ b) ← (max(a)(b) ≡ a) l {𝟎} {𝟎} _ = [≤]-minimum {𝟎} l {𝟎} {𝐒(_)} () l {𝐒(a)}{𝟎} _ = [≤]-minimum {𝐒(a)} l {𝐒(a)}{𝐒(b)} maxaba = [≤]-with-[𝐒] ⦃ l{a}{b}(injective(𝐒) (maxaba)) ⦄ r : ∀{a b} → (a ≥ b) → (max(a)(b) ≡ a) r {𝟎} {𝟎} _ = [≡]-intro r {𝟎} {𝐒(_)} () r {𝐒(_)}{𝟎} _ = [≡]-intro r {𝐒(a)}{𝐒(b)} (≤.succ ab) = [≡]-with(𝐒) (r{a}{b} (ab)) max-defᵣ : ∀{a b} → (b ≥ a) ↔ (max(a)(b) ≡ b) max-defᵣ {a}{b} = [≡]-substitutionᵣ (commutativity(max)) {expr ↦ (b ≥ a) ↔ (expr ≡ b)} (max-defₗ{b}{a}) min-with-max : ∀{a b} → (min(a)(b) ≡ (a + b) −₀ max(a)(b)) min-with-max {a}{b} = min(a)(b) 🝖-[ min-elementary{a}{b} ] b −₀ (b −₀ a) 🝖-[ [−₀][+]ₗ-nullify {a}{b}{b −₀ a} ]-sym (a + b) −₀ (a + (b −₀ a)) 🝖-[ [≡]-with((a + b) −₀_) (max-elementary{a}{b}) ]-sym (a + b) −₀ max(a)(b) 🝖-end max-with-min : ∀{a b} → (max(a)(b) ≡ (a + b) −₀ min(a)(b)) max-with-min {a}{b} with [≤][>]-dichotomy {a}{b} ... | [∨]-introₗ ab = max(a)(b) 🝖-[ [↔]-to-[→] max-defᵣ ab ] b 🝖-[ [−₀]ₗ[+]ₗ-nullify {a}{b} ]-sym (a + b) −₀ a 🝖-[ [≡]-with((a + b) −₀_) ([↔]-to-[→] min-defₗ ab) ]-sym (a + b) −₀ min(a)(b) 🝖-end ... | [∨]-introᵣ 𝐒ba with ba ← [≤]-predecessor 𝐒ba = max(a)(b) 🝖-[ [↔]-to-[→] max-defₗ ba ] a 🝖-[ [−₀]ₗ[+]ᵣ-nullify {a}{b} ]-sym (a + b) −₀ b 🝖-[ [≡]-with((a + b) −₀_) ([↔]-to-[→] min-defᵣ ba) ]-sym (a + b) −₀ min(a)(b) 🝖-end [≤]-conjunction-min : ∀{a b c} → ((a ≤ b) ∧ (a ≤ c)) ↔ (a ≤ min b c) [≤]-conjunction-min {a}{b}{c} = [↔]-intro (a≤bc ↦ [∧]-intro (a≤bc 🝖 min-orderₗ) (a≤bc 🝖 min-orderᵣ)) (uncurry r) where r : ∀{a b c} → (a ≤ b) → (a ≤ c) → (a ≤ min b c) r {.0} {b} {c} ≤.min ≤.min = ≤.min r {.(𝐒 a)} {.(𝐒 b)} {.(𝐒 c)} (≤.succ {a} {b} ab) (≤.succ {y = c} ac) = [≤]-with-[𝐒] ⦃ r {a}{b}{c} ab ac ⦄ [≤]-conjunction-max : ∀{a b c} → ((a ≤ c) ∧ (b ≤ c)) ↔ (max a b ≤ c) [≤]-conjunction-max {a}{b}{c} = [↔]-intro (ab≤c ↦ [∧]-intro (max-orderₗ 🝖 ab≤c) ((max-orderᵣ 🝖 ab≤c))) (uncurry r) where r : ∀{a b c} → (a ≤ c) → (b ≤ c) → (max a b ≤ c) r {.0} {b@(𝐒 _)}{c} ≤.min bc = bc r {a} {.0} {c} ac ≤.min = ac r {𝐒 a} {𝐒 b} {𝐒 c} (≤.succ ac) (≤.succ bc) = [≤]-with-[𝐒] ⦃ r {a}{b}{c} ac bc ⦄ [≤]-disjunction-min : ∀{a b c} → ((a ≤ c) ∨ (b ≤ c)) ↔ (min a b ≤ c) [≤]-disjunction-min = [↔]-intro (ab≤c ↦ [∨]-elim2 ((_🝖 ab≤c) ∘ [≡]-to-[≤] ∘ symmetry(_≡_)) ((_🝖 ab≤c) ∘ [≡]-to-[≤] ∘ symmetry(_≡_)) min-arg ) ([∨]-elim (min-orderₗ 🝖_) (min-orderᵣ 🝖_) ) [≤]-disjunction-max : ∀{a b c} → ((a ≤ b) ∨ (a ≤ c)) ↔ (a ≤ max b c) [≤]-disjunction-max = [↔]-intro (a≤bc ↦ [∨]-elim2 ((_🝖 a≤bc) ∘ [≡]-to-[≤]) ((_🝖 a≤bc) ∘ [≡]-to-[≤]) max-arg ) ([∨]-elim (_🝖 max-orderₗ) (_🝖 max-orderᵣ) ) min-order-max : ∀{a b} → (min(a)(b) ≤ max(a)(b)) min-order-max {𝟎} {b} = [≤]-minimum min-order-max {𝐒 a} {𝟎} = [≤]-minimum min-order-max {𝐒 a} {𝐒 b} = [≤]-with-[𝐒] ⦃ min-order-max {a}{b} ⦄ max-order-[+] : ∀{a b} → (max(a)(b) ≤ a + b) max-order-[+] {a}{b} = [↔]-to-[→] [≤]-conjunction-max ([∧]-intro [≤]-of-[+]ₗ ([≤]-of-[+]ᵣ {a}{b}))
{ "alphanum_fraction": 0.474908329, "avg_line_length": 36.5708812261, "ext": "agda", "hexsha": "6674d008ff7223f85161b50f5914d3e0c8a07cc6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Numeral/Natural/Function/Proofs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Numeral/Natural/Function/Proofs.agda", "max_line_length": 139, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Numeral/Natural/Function/Proofs.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 5074, "size": 9545 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.DStructures.Equivalences.XModPeifferGraph where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Functions.FunExtEquiv open import Cubical.Homotopy.Base open import Cubical.Data.Sigma open import Cubical.Data.Unit open import Cubical.Relation.Binary open import Cubical.Structures.Subtype open import Cubical.Algebra.Group open import Cubical.Structures.LeftAction open import Cubical.Algebra.Group.Semidirect open import Cubical.DStructures.Base open import Cubical.DStructures.Meta.Properties open import Cubical.DStructures.Meta.Isomorphism open import Cubical.DStructures.Structures.Constant open import Cubical.DStructures.Structures.Type open import Cubical.DStructures.Structures.Group open import Cubical.DStructures.Structures.Action open import Cubical.DStructures.Structures.XModule open import Cubical.DStructures.Structures.ReflGraph open import Cubical.DStructures.Structures.PeifferGraph open import Cubical.DStructures.Equivalences.GroupSplitEpiAction open import Cubical.DStructures.Equivalences.PreXModReflGraph private variable ℓ ℓ' ℓ'' ℓ₁ ℓ₁' ℓ₁'' ℓ₂ ℓA ℓA' ℓ≅A ℓ≅A' ℓB ℓB' ℓ≅B ℓC ℓ≅C ℓ≅ᴰ ℓ≅ᴰ' ℓ≅B' : Level open Kernel open GroupHom -- such .fun! open GroupLemmas open MorphismLemmas open ActionLemmas module _ (ℓ ℓ' : Level) where private ℓℓ' = ℓ-max ℓ ℓ' ℱ = Iso-PreXModule-ReflGraph ℓ ℓℓ' F = Iso.fun ℱ 𝒮ᴰ-S2G = 𝒮ᴰ-ReflGraph\Peiffer 𝒮ᴰ-♭PIso-XModule-Strict2Group : 𝒮ᴰ-♭PIso F (𝒮ᴰ-XModule ℓ ℓℓ') (𝒮ᴰ-S2G ℓ ℓℓ') RelIso.fun (𝒮ᴰ-♭PIso-XModule-Strict2Group (((((G₀' , H) , _α_) , isAct) , φ) , isEqui)) isPeif a b = q where -- G₀ = G₀', but the former is introduced in ReflGraphNotation as well open GroupNotationᴴ H -- open GroupNotation₀ G₀ f = GroupHom.fun φ A = groupaction _α_ isAct open ActionNotationα A using (α-assoc ; α-hom) SG = F (((((G₀' , H) , _α_) , isAct) , φ) , isEqui) -- H⋊G : Group {ℓℓ'} H⋊G = snd (fst (fst (fst (fst SG)))) -- open GroupNotation₁ H⋊G open ReflGraphNotation SG -- σ : GroupHom H⋊G G₀ -- ι : GroupHom G₀ H⋊G -- τ : GroupHom H⋊G G₀ u = fst a v = snd a x = fst b y = snd b abstract -- alright folks, let's do some simple arithmetic with a `twist`, that is Peiffer identities and equivariance r = ((0ᴴ +ᴴ (y α (u +ᴴ (v α ((-₀ ((f u) +₀ v)) α (-ᴴ 0ᴴ)))))) +ᴴ ((y +₀ (v +₀ (-₀ (f u +₀ v)))) α (((-₀ y) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ y) α x)))) +ᴴ (((y +₀ (v +₀ (-₀ (f u +₀ v)))) +₀ ((-₀ y) +₀ y)) α 0ᴴ) ≡⟨ cong (((0ᴴ +ᴴ (y α (u +ᴴ (v α ((-₀ ((f u) +₀ v)) α (-ᴴ 0ᴴ)))))) +ᴴ ((y +₀ (v +₀ (-₀ (f u +₀ v)))) α (((-₀ y) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ y) α x)))) +ᴴ_) (actOnUnit A ((y +₀ (v +₀ (-₀ (f u +₀ v)))) +₀ ((-₀ y) +₀ y))) ⟩ ((0ᴴ +ᴴ (y α (u +ᴴ (v α ((-₀ ((f u) +₀ v)) α (-ᴴ 0ᴴ)))))) +ᴴ ((y +₀ (v +₀ (-₀ (f u +₀ v)))) α (((-₀ y) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ y) α x)))) +ᴴ 0ᴴ ≡⟨ rIdᴴ ((0ᴴ +ᴴ (y α (u +ᴴ (v α ((-₀ ((f u) +₀ v)) α (-ᴴ 0ᴴ)))))) +ᴴ ((y +₀ (v +₀ (-₀ (f u +₀ v)))) α (((-₀ y) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ y) α x)))) ⟩ (0ᴴ +ᴴ (y α (u +ᴴ (v α ((-₀ ((f u) +₀ v)) α (-ᴴ 0ᴴ)))))) +ᴴ ((y +₀ (v +₀ (-₀ (f u +₀ v)))) α (((-₀ y) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ y) α x))) ≡⟨ cong (_+ᴴ ((y +₀ (v +₀ (-₀ (f u +₀ v)))) α (((-₀ y) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ y) α x)))) (lIdᴴ (y α (u +ᴴ (v α ((-₀ ((f u) +₀ v)) α (-ᴴ 0ᴴ)))))) ⟩ (y α (u +ᴴ (v α ((-₀ ((f u) +₀ v)) α (-ᴴ 0ᴴ))))) +ᴴ ((y +₀ (v +₀ (-₀ (f u +₀ v)))) α (((-₀ y) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ y) α x))) ≡⟨ cong (λ z → (y α (u +ᴴ (v α ((-₀ ((f u) +₀ v)) α (-ᴴ 0ᴴ))))) +ᴴ ((y +₀ (v +₀ (-₀ (f u +₀ v)))) α (z +ᴴ ((-₀ y) α x)))) (actOn-Unit A (-₀ y)) ⟩ (y α (u +ᴴ (v α ((-₀ ((f u) +₀ v)) α (-ᴴ 0ᴴ))))) +ᴴ ((y +₀ (v +₀ (-₀ (f u +₀ v)))) α (0ᴴ +ᴴ ((-₀ y) α x))) ≡⟨ cong (λ z → (y α (u +ᴴ (v α ((-₀ ((f u) +₀ v)) α (-ᴴ 0ᴴ))))) +ᴴ ((y +₀ (v +₀ (-₀ (f u +₀ v)))) α z)) (lIdᴴ ((-₀ y) α x)) ⟩ (y α (u +ᴴ (v α ((-₀ ((f u) +₀ v)) α (-ᴴ 0ᴴ))))) +ᴴ ((y +₀ (v +₀ (-₀ (f u +₀ v)))) α ((-₀ y) α x)) ≡⟨ cong (λ z → (y α (u +ᴴ (v α z))) +ᴴ ((y +₀ (v +₀ (-₀ (f u +₀ v)))) α ((-₀ y) α x))) (actOn-Unit A (-₀ ((f u) +₀ v))) ⟩ (y α (u +ᴴ (v α 0ᴴ))) +ᴴ ((y +₀ (v +₀ (-₀ (f u +₀ v)))) α ((-₀ y) α x)) ≡⟨ cong (λ z → (y α (u +ᴴ z)) +ᴴ ((y +₀ (v +₀ (-₀ (f u +₀ v)))) α ((-₀ y) α x))) (actOnUnit A v) ⟩ (y α (u +ᴴ 0ᴴ)) +ᴴ ((y +₀ (v +₀ (-₀ (f u +₀ v)))) α ((-₀ y) α x)) ≡⟨ cong (λ z → (y α z) +ᴴ ((y +₀ (v +₀ (-₀ (f u +₀ v)))) α ((-₀ y) α x))) (rIdᴴ u) ⟩ (y α u) +ᴴ ((y +₀ (v +₀ (-₀ (f u +₀ v)))) α ((-₀ y) α x)) ≡⟨ cong (λ z → (y α u) +ᴴ ((y +₀ (v +₀ z)) α ((-₀ y) α x))) (invDistr G₀ (f u) v) ⟩ (y α u) +ᴴ ((y +₀ (v +₀ ((-₀ v) +₀ (-₀ (f u))))) α ((-₀ y) α x)) ≡⟨ cong (λ z → (y α u) +ᴴ ((y +₀ z) α ((-₀ y) α x))) (assoc-rCancel G₀ v (-₀ f u)) ⟩ (y α u) +ᴴ ((y +₀ (-₀ (f u))) α ((-₀ y) α x)) ≡⟨ cong ((y α u) +ᴴ_) (sym (α-assoc (y +₀ (-₀ f u)) (-₀ y) x)) ⟩ (y α u) +ᴴ (((y +₀ (-₀ (f u))) +₀ (-₀ y)) α x) ≡⟨ cong (λ z → (y α u) +ᴴ (((y +₀ z) +₀ (-₀ y)) α x)) (sym (mapInv φ u)) ⟩ (y α u) +ᴴ (((y +₀ (f (-ᴴ u))) -₀ y) α x) -- apply equivariance here ≡⟨ cong (λ z → (y α u) +ᴴ (z α x)) (sym (isEqui y (-ᴴ u))) ⟩ (y α u) +ᴴ ((f (y α (-ᴴ u))) α x) -- apply peiffer condition here ≡⟨ cong ((y α u) +ᴴ_) (isPeif (y α (-ᴴ u)) x) ⟩ (y α u) +ᴴ (((y α (-ᴴ u)) +ᴴ x) +ᴴ (-ᴴ (y α (-ᴴ u)))) ≡⟨ cong (λ z → (y α u) +ᴴ ((z +ᴴ x) +ᴴ (-ᴴ z))) (actOn- A y u) ⟩ (y α u) +ᴴ (((-ᴴ (y α u)) +ᴴ x) +ᴴ (-ᴴ (-ᴴ (y α u)))) ≡⟨ cong (λ z → (y α u) +ᴴ (((-ᴴ (y α u)) +ᴴ x) +ᴴ z)) (invInvo H (y α u)) ⟩ (y α u) +ᴴ (((-ᴴ (y α u)) +ᴴ x) +ᴴ (y α u)) ≡⟨ assoc-assoc H (y α u) (-ᴴ (y α u)) x (y α u) ⟩ (((y α u) +ᴴ (-ᴴ (y α u))) +ᴴ x) +ᴴ (y α u) ≡⟨ cong (_+ᴴ (y α u)) (rCancel-lId H (y α u) x) ⟩ x +ᴴ (y α u) ∎ r' = ((y +₀ (v +₀ (-₀ (f u +₀ v)))) +₀ ((-₀ y) +₀ y)) +₀ (f u +₀ v) ≡⟨ cong (_+₀ (f u +₀ v)) (lCancel-rId G₀ (y +₀ (v +₀ (-₀ (f u +₀ v)))) y) ⟩ (y +₀ (v +₀ (-₀ (f u +₀ v)))) +₀ (f u +₀ v) ≡⟨ cong (λ z → (y +₀ (v +₀ z)) +₀ (f u +₀ v)) (invDistr G₀ (f u) v) ⟩ (y +₀ (v +₀ ((-₀ v) +₀ (-₀ f u)))) +₀ (f u +₀ v) ≡⟨ cong (λ z → (y +₀ z) +₀ (f u +₀ v)) (assoc-rCancel G₀ v (-₀ f u)) ⟩ (y +₀ (-₀ f u)) +₀ (f u +₀ v) ≡⟨ assoc⁻-assocr-lCancel-lId G₀ y (f u) v ⟩ y +₀ v ∎ q = ((is b +₁ (a +₁ -it a)) +₁ (-is b +₁ b)) +₁ it a ≡⟨ refl ⟩ ((0ᴴ +ᴴ (y α (u +ᴴ (v α ((-₀ ((f u) +₀ v)) α (-ᴴ 0ᴴ)))))) +ᴴ ((y +₀ (v +₀ (-₀ (f u +₀ v)))) α (((-₀ y) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ y) α x)))) +ᴴ (((y +₀ (v +₀ (-₀ (f u +₀ v)))) +₀ ((-₀ y) +₀ y)) α 0ᴴ) , ((y +₀ (v +₀ (-₀ (f u +₀ v)))) +₀ ((-₀ y) +₀ y)) +₀ (f u +₀ v) ≡⟨ ΣPathP (r , r') ⟩ x +ᴴ (y α u) , y +₀ v ≡⟨ refl ⟩ b +₁ a ∎ RelIso.inv (𝒮ᴰ-♭PIso-XModule-Strict2Group (((((G₀' , H) , _α_) , isAct) , φ) , isEqui)) ♭isPeif h h' = q where open GroupNotationᴴ H f = GroupHom.fun φ A = groupaction _α_ isAct open ActionNotationα A using (α-assoc ; α-hom ; α-id) SG = F (((((G₀' , H) , _α_) , isAct) , φ) , isEqui) -- H⋊G : Group {ℓℓ'} H⋊G = snd (fst (fst (fst (fst SG)))) -- open GroupNotation₁ H⋊G open ReflGraphNotation SG -- σ : GroupHom H⋊G G₀ -- ι : GroupHom G₀ H⋊G -- τ : GroupHom H⋊G G₀ -h = -ᴴ h abstract r₁ = ((0ᴴ +ᴴ (0₀ α (-h +ᴴ (0₀ α ((-₀ ((f -h) +₀ 0₀)) α (-ᴴ 0ᴴ)))))) +ᴴ ((0₀ +₀ (0₀ +₀ (-₀ (f -h +₀ 0₀)))) α (((-₀ 0₀) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ 0₀) α h')))) +ᴴ (((0₀ +₀ (0₀ +₀ (-₀ ((f -h) +₀ 0₀)))) +₀ ((-₀ 0₀) +₀ 0₀)) α 0ᴴ) ≡⟨ cong fst (♭isPeif (-h , 0₀) (h' , 0₀)) ⟩ h' +ᴴ (0₀ α -h) ≡⟨ cong (h' +ᴴ_) (α-id -h) ⟩ h' +ᴴ -h ∎ r₂ = ((0ᴴ +ᴴ (0₀ α (-h +ᴴ (0₀ α ((-₀ ((f -h) +₀ 0₀)) α (-ᴴ 0ᴴ)))))) +ᴴ ((0₀ +₀ (0₀ +₀ (-₀ (f -h +₀ 0₀)))) α (((-₀ 0₀) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ 0₀) α h')))) +ᴴ (((0₀ +₀ (0₀ +₀ (-₀ ((f -h) +₀ 0₀)))) +₀ ((-₀ 0₀) +₀ 0₀)) α 0ᴴ) ≡⟨ cong (((0ᴴ +ᴴ (0₀ α (-h +ᴴ (0₀ α ((-₀ ((f -h) +₀ 0₀)) α (-ᴴ 0ᴴ)))))) +ᴴ ((0₀ +₀ (0₀ +₀ (-₀ (f -h +₀ 0₀)))) α (((-₀ 0₀) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ 0₀) α h')))) +ᴴ_) (actOnUnit A (((0₀ +₀ (0₀ +₀ (-₀ ((f -h) +₀ 0₀)))) +₀ ((-₀ 0₀) +₀ 0₀)))) ∙ rIdᴴ _ ⟩ (0ᴴ +ᴴ (0₀ α (-h +ᴴ (0₀ α ((-₀ ((f -h) +₀ 0₀)) α (-ᴴ 0ᴴ)))))) +ᴴ ((0₀ +₀ (0₀ +₀ (-₀ (f -h +₀ 0₀)))) α (((-₀ 0₀) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ 0₀) α h'))) ≡⟨ cong (λ z → (0ᴴ +ᴴ (0₀ α (-h +ᴴ (0₀ α z)))) +ᴴ ((0₀ +₀ (0₀ +₀ (-₀ (f -h +₀ 0₀)))) α (((-₀ 0₀) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ 0₀) α h')))) (actOn-Unit A (-₀ ((f -h) +₀ 0₀))) ⟩ (0ᴴ +ᴴ (0₀ α (-h +ᴴ (0₀ α 0ᴴ)))) +ᴴ ((0₀ +₀ (0₀ +₀ (-₀ (f -h +₀ 0₀)))) α (((-₀ 0₀) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ 0₀) α h'))) ≡⟨ cong (λ z → (0ᴴ +ᴴ (0₀ α (-h +ᴴ z))) +ᴴ ((0₀ +₀ (0₀ +₀ (-₀ (f -h +₀ 0₀)))) α (((-₀ 0₀) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ 0₀) α h')))) (actOnUnit A 0₀) ⟩ (0ᴴ +ᴴ (0₀ α (-h +ᴴ 0ᴴ))) +ᴴ ((0₀ +₀ (0₀ +₀ (-₀ (f -h +₀ 0₀)))) α (((-₀ 0₀) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ 0₀) α h'))) ≡⟨ cong (λ z → (0ᴴ +ᴴ (0₀ α z)) +ᴴ ((0₀ +₀ (0₀ +₀ (-₀ (f -h +₀ 0₀)))) α (((-₀ 0₀) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ 0₀) α h')))) (rIdᴴ -h) ⟩ (0ᴴ +ᴴ (0₀ α -h)) +ᴴ ((0₀ +₀ (0₀ +₀ (-₀ (f -h +₀ 0₀)))) α (((-₀ 0₀) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ 0₀) α h'))) ≡⟨ cong (λ z → (0ᴴ +ᴴ z) +ᴴ ((0₀ +₀ (0₀ +₀ (-₀ (f -h +₀ 0₀)))) α (((-₀ 0₀) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ 0₀) α h')))) (α-id -h) ⟩ (0ᴴ +ᴴ -h) +ᴴ ((0₀ +₀ (0₀ +₀ (-₀ (f -h +₀ 0₀)))) α (((-₀ 0₀) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ 0₀) α h'))) ≡⟨ cong (_+ᴴ ((0₀ +₀ (0₀ +₀ (-₀ (f -h +₀ 0₀)))) α (((-₀ 0₀) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ 0₀) α h')))) (lIdᴴ -h) ⟩ -h +ᴴ ((0₀ +₀ (0₀ +₀ (-₀ (f -h +₀ 0₀)))) α (((-₀ 0₀) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ 0₀) α h'))) ≡⟨ cong (λ z → -h +ᴴ (z α (((-₀ 0₀) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ 0₀) α h')))) (lId-lId G₀ (-₀ (f -h +₀ 0₀))) ⟩ -h +ᴴ ((-₀ (f -h +₀ 0₀)) α (((-₀ 0₀) α (-ᴴ 0ᴴ)) +ᴴ ((-₀ 0₀) α h'))) ≡⟨ cong (λ z → -h +ᴴ ((-₀ (f -h +₀ 0₀)) α (z +ᴴ ((-₀ 0₀) α h')))) (actOn-Unit A (-₀ 0₀)) ⟩ -h +ᴴ ((-₀ (f -h +₀ 0₀)) α (0ᴴ +ᴴ ((-₀ 0₀) α h'))) ≡⟨ cong (λ z → -h +ᴴ ((-₀ (f -h +₀ 0₀)) α z)) (lIdᴴ ((-₀ 0₀) α h')) ⟩ -h +ᴴ ((-₀ (f -h +₀ 0₀)) α ((-₀ 0₀) α h')) ≡⟨ cong (λ z → -h +ᴴ ((-₀ (f -h +₀ 0₀)) α z)) (-idAct A h') ⟩ -h +ᴴ ((-₀ (f -h +₀ 0₀)) α h') ≡⟨ cong (λ z → -h +ᴴ ((-₀ z) α h')) (rId₀ (f -h)) ⟩ -h +ᴴ ((-₀ (f -h)) α h') ≡⟨ cong (λ z → -h +ᴴ (z α h')) (cong -₀_ (mapInv φ h) ∙ invInvo G₀ (f h)) ⟩ -h +ᴴ (f h α h') ∎ q = f h α h' ≡⟨ sym (lIdᴴ (f h α h')) ∙∙ sym (cong (_+ᴴ (f h α h')) (rCancelᴴ h)) ∙∙ sym (assocᴴ h -h (f h α h')) ⟩ h +ᴴ (-h +ᴴ (f h α h')) ≡⟨ cong (h +ᴴ_) (sym r₂ ∙ r₁) ⟩ h +ᴴ (h' +ᴴ -h) ≡⟨ assocᴴ h h' -h ⟩ (h +ᴴ h') +ᴴ (-ᴴ h) ∎ RelIso.leftInv (𝒮ᴰ-♭PIso-XModule-Strict2Group _) _ = tt RelIso.rightInv (𝒮ᴰ-♭PIso-XModule-Strict2Group _) _ = tt Iso-XModule-PeifferGraph : Iso (XModule ℓ ℓℓ') (PeifferGraph ℓ ℓℓ') Iso-XModule-PeifferGraph = 𝒮ᴰ-♭PIso-Over→TotalIso ℱ (𝒮ᴰ-XModule ℓ ℓℓ') (𝒮ᴰ-S2G ℓ ℓℓ') 𝒮ᴰ-♭PIso-XModule-Strict2Group
{ "alphanum_fraction": 0.3761212496, "avg_line_length": 53.6597510373, "ext": "agda", "hexsha": "46fd70ab0addb62477a8c45adb6a820c2b03a674", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_path": "Cubical/DStructures/Equivalences/XModPeifferGraph.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Schippmunk/cubical", "max_issues_repo_path": "Cubical/DStructures/Equivalences/XModPeifferGraph.agda", "max_line_length": 226, "max_stars_count": null, "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_path": "Cubical/DStructures/Equivalences/XModPeifferGraph.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6285, "size": 12932 }
{-# OPTIONS --universe-polymorphism #-} open import Level open import Categories.Category module Categories.Power.NaturalTransformation {o ℓ e : Level} (C : Category o ℓ e) where open import Function using () renaming (_∘_ to _∙_) open import Data.Fin using (Fin; inject+; raise) open import Data.Sum using (_⊎_; [_,_]′; inj₁; inj₂) open import Data.Product using (_,_) import Categories.Power module Pow = Categories.Power C open Pow public open import Categories.Bifunctor using (Bifunctor) open import Categories.Bifunctor.NaturalTransformation renaming (id to idⁿ; _≡_ to _≡ⁿ_) open import Categories.Functor using (module Functor) renaming (_∘_ to _∘F_) flattenPⁿ : ∀ {D : Category o ℓ e} {n m} {F G : Powerfunctor′ D (Fin n ⊎ Fin m)} (η : NaturalTransformation F G) → NaturalTransformation (flattenP F) (flattenP G) flattenPⁿ {n = n} {m} η = record { η = λ Xs → η.η (Xs ∙ pack) ; commute = λ fs → η.commute (fs ∙ pack) } where private module η = NaturalTransformation η pack = [ inject+ m , raise n ]′ reduceN′ : ∀ (H : Bifunctor C C C) {I} {F F′ : Powerendo′ I} (φ : NaturalTransformation F F′) {J} {G G′ : Powerendo′ J} (γ : NaturalTransformation G G′) → NaturalTransformation (reduce′ H F G) (reduce′ H F′ G′) reduceN′ H {I} {F} {F′} φ {J} {G} {G′} γ = record { η = my-η ; commute = λ {Xs Ys} → my-commute Xs Ys } where module F = Functor F module F′ = Functor F′ module G = Functor G module G′ = Functor G′ module φ = NaturalTransformation φ module γ = NaturalTransformation γ module H = Functor H module L = Functor (reduce′ H F G) module R = Functor (reduce′ H F′ G′) my-η : ∀ Xs → C [ L.F₀ Xs , R.F₀ Xs ] my-η Xs = H.F₁ ((φ.η (Xs ∙ inj₁)) , (γ.η (Xs ∙ inj₂))) .my-commute : ∀ Xs Ys fs → C.CommutativeSquare (L.F₁ fs) (my-η Xs) (my-η Ys) (R.F₁ fs) my-commute Xs Ys fs = begin my-η Ys ∘ L.F₁ fs ↑⟨ H.homomorphism ⟩ H.F₁ ((φ.η (Ys ∙ inj₁) ∘ F.F₁ (fs ∙ inj₁)) , (γ.η (Ys ∙ inj₂) ∘ G.F₁ (fs ∙ inj₂))) ↓⟨ H.F-resp-≡ ((φ.commute (fs ∙ inj₁)) , (γ.commute (fs ∙ inj₂))) ⟩ H.F₁ ((F′.F₁ (fs ∙ inj₁) ∘ φ.η (Xs ∙ inj₁)) , (G′.F₁ (fs ∙ inj₂) ∘ γ.η (Xs ∙ inj₂))) ↓⟨ H.homomorphism ⟩ R.F₁ fs ∘ my-η Xs ∎ where open C using (_∘_; _≡_) open C.HomReasoning reduceN : ∀ (H : Bifunctor C C C) {n} {F F′ : Powerendo n} (φ : NaturalTransformation F F′) {m} {G G′ : Powerendo m} (γ : NaturalTransformation G G′) → NaturalTransformation (reduce H F G) (reduce H F′ G′) reduceN H {n} {F = f} {f′} F {m} {g} {g′} G = flattenPⁿ {F = a} {G = b} (reduceN′ H F G) where a : Categories.Bifunctor.Functor (Categories.Power.Exp C (Fin n ⊎ Fin m)) C a = reduce′ H f g b : Categories.Bifunctor.Functor (Categories.Power.Exp C (Fin n ⊎ Fin m)) C b = reduce′ H f′ g′ overlapN : ∀ (H : Bifunctor C C C) {n} {F F′ : Powerendo n} (φ : NaturalTransformation F F′) {G G′ : Powerendo n} (γ : NaturalTransformation G G′) → NaturalTransformation (overlaps {C} {C} H F G) (overlaps {C} {C} H F′ G′) overlapN H F G = overlapN-× {D₁ = C} {D₂ = C} H F G
{ "alphanum_fraction": 0.6142763589, "avg_line_length": 43.6285714286, "ext": "agda", "hexsha": "5582c4643c0839c9ea92480fbae1e4f20194ef2b", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Power/NaturalTransformation.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Power/NaturalTransformation.agda", "max_line_length": 222, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Power/NaturalTransformation.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 1197, "size": 3054 }
{-# OPTIONS --erased-cubical #-} open import Erased-cubical-Pattern-matching.Cubical -- The following definition should be rejected. Matching on a -- non-erased constructor that is treated as erased because it was -- defined in a module that uses --cubical should not on its own make -- it possible to use erased definitions in the right-hand side. f : D → D f c = c
{ "alphanum_fraction": 0.7432432432, "avg_line_length": 30.8333333333, "ext": "agda", "hexsha": "6194cf36b7fd1135ccf8ae413fb31d8cea72bdaa", "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/Erased-cubical-Pattern-matching.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/Erased-cubical-Pattern-matching.agda", "max_line_length": 69, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Erased-cubical-Pattern-matching.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": 93, "size": 370 }
-- Andreas, 2014-09-01 -- This module exports a module M module Imports.Module where module M where
{ "alphanum_fraction": 0.7450980392, "avg_line_length": 14.5714285714, "ext": "agda", "hexsha": "09f0f45d9301b5cef9f68fb7a4f06582fd118236", "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/Imports/Module.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/Imports/Module.agda", "max_line_length": 33, "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/Imports/Module.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": 28, "size": 102 }
{-# OPTIONS --allow-unsolved-metas #-} module Avionics.Probability where open import Data.Nat using (ℕ; zero; suc) open import Relation.Unary using (_∈_) open import Avionics.Real using ( ℝ; _+_; _-_; _*_; _÷_; _^_; √_; 1/_; _^2; -1/2; π; e; 2ℝ; ⟨0,∞⟩; [0,∞⟩; [0,1]) --postulate -- Vec : Set → ℕ → Set -- Mat : Set → ℕ → ℕ → Set record Dist (Input : Set) : Set where field pdf : Input → ℝ cdf : Input → ℝ pdf→[0,∞⟩ : ∀ x → pdf x ∈ [0,∞⟩ cdf→[0,1] : ∀ x → cdf x ∈ [0,1] --∫pdf≡cdf : ∫ pdf ≡ cdf --∫pdf[-∞,∞]≡1ℝ : ∫ pdf [ -∞ , ∞ ] ≡ 1ℝ record NormalDist : Set where constructor ND field μ : ℝ σ : ℝ dist : Dist ℝ dist = record { pdf = pdf ; cdf = ? ; pdf→[0,∞⟩ = ? ; cdf→[0,1] = ? } where √2π = (√ (2ℝ * π)) 1/⟨σ√2π⟩ = (1/ (σ * √2π)) pdf : ℝ → ℝ pdf x = 1/⟨σ√2π⟩ * e ^ (-1/2 * (⟨x-μ⟩÷σ ^2)) where ⟨x-μ⟩÷σ = ((x - μ) ÷ σ) --MultiNormal : ∀ {n : ℕ} → Vec ℝ n → Mat ℝ n n → Dist (Vec ℝ n) --MultiNormal {n} means cov = record -- { -- pdf = ? -- ; cdf = ? -- } --Things to prove using this approach --_ : ∀ (mean1 std1 mean2 std2 x) -- → Dist.pdf (Normal mean1 std1) x + Dist.pdf (Normal mean2 std2) x ≡ Dist.pdf (Normal (mean1 + mean2) (...))
{ "alphanum_fraction": 0.4731098987, "avg_line_length": 21.7457627119, "ext": "agda", "hexsha": "39a88769e3a876207b8d1af3b0f2fd860796400b", "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": "896e67a2ad21041a1c9ef5f3ad6318c67d730341", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "RPI-WCL/safety-envelopes-sentinels", "max_forks_repo_path": "agda/Avionics/Probability.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "896e67a2ad21041a1c9ef5f3ad6318c67d730341", "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": "RPI-WCL/safety-envelopes-sentinels", "max_issues_repo_path": "agda/Avionics/Probability.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "896e67a2ad21041a1c9ef5f3ad6318c67d730341", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "RPI-WCL/safety-envelopes-sentinels", "max_stars_repo_path": "agda/Avionics/Probability.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 568, "size": 1283 }
module Isos.TreeLike where open import Isos.Isomorphism open import Trees open import Tuples open import Equality open import Data.Product open import Data.Unit ------------------------------------------------------------------------ -- internal stuffs private pattern ∅ = Empty tt ∅′ : BareBinTree ∅′ = Empty tt _,,_ : BareBinTree → BareBinTree → BareBinTree _,,_ = Node tt infixl 4 _,,_ pattern [_,_] a b = Node tt a b tree⁷->tree : BareBinTree ⁷ → BareBinTree tree⁷->tree (∅ , ∅ , ∅ , ∅ , ∅ , ∅ , [ [ [ [ a , b ] , c ] , d ] , e ]) = ∅′ ,, a ,, b ,, c ,, d ,, e tree⁷->tree (∅ , ∅ , ∅ , ∅ , ∅ , ∅ , a) = a tree⁷->tree (∅ , ∅ , ∅ , ∅ , ∅ , t₅ , t₆) = t₅ ,, t₆ ,, ∅′ ,, ∅′ ,, ∅′ ,, ∅′ ,, ∅′ tree⁷->tree (∅ , ∅ , ∅ , ∅ , [ a , b ] , t₅ , t₆) = ∅′ ,, t₆ ,, t₅ ,, a ,, b tree⁷->tree (t₀ , t₁ , t₂ , t₃ , t₄ , t₅ , t₆) = t₆ ,, t₅ ,, t₄ ,, t₃ ,, t₂ ,, t₁ ,, t₀ tree->tree⁷ : BareBinTree → BareBinTree ⁷ tree->tree⁷ [ [ [ [ [ ∅ , a ] , b ] , c ] , d ] , e ] = ∅ , ∅ , ∅ , ∅ , ∅ , ∅ , (a ,, b ,, c ,, d ,, e) tree->tree⁷ [ [ [ [ [ t₆ , t₅ ] , ∅ ] , ∅ ] , ∅ ] , ∅ ] = ∅ , ∅ , ∅ , ∅ , ∅ , t₅ , t₆ tree->tree⁷ [ [ [ [ ∅ , t₆ ] , t₅ ] , a ] , b ] = ∅ , ∅ , ∅ , ∅ , (a ,, b) , t₅ , t₆ tree->tree⁷ [ [ [ [ [ [ t₆ , t₅ ] , t₄ ] , t₃ ] , t₂ ] , t₁ ] , t₀ ] = t₀ , t₁ , t₂ , t₃ , t₄ , t₅ , t₆ tree->tree⁷ a = ∅ , ∅ , ∅ , ∅ , ∅ , ∅ , a tree⁷<=>tree : BareBinTree ⁷ ⇔ BareBinTree tree⁷<=>tree = ∧-intro tree⁷->tree tree->tree⁷ -- too hard -- proofL : ∀ tree → tree⁷->tree (tree->tree⁷ tree) ≡ tree -- proofL [ [ [ [ [ ∅ , a ] , b ] , c ] , d ] , e ] -- = refl -- proofL [ [ [ [ [ Node x t₆ t7 , t₅ ] , ∅ ] , ∅ ] , ∅ ] , ∅ ] -- = {!!} -- proofL [ [ [ [ ∅ , t₆ ] , t₅ ] , a ] , b ] -- = refl -- proofL [ [ [ [ [ [ t₆ , t₅ ] , t₄ ] , t₃ ] , t₂ ] , t₁ ] , t₀ ] -- = {!!} -- proofL _ = {!!} ------------------------------------------------------------------------ -- public aliases iso-seven-tree-in-one : BareBinTree ⁷ ⇔ BareBinTree iso-seven-tree-in-one = tree⁷<=>tree
{ "alphanum_fraction": 0.3645116919, "avg_line_length": 32.0735294118, "ext": "agda", "hexsha": "656f7646957d2ffccff124aa7a04e0735ddc8918", "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": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ice1k/Theorems", "max_forks_repo_path": "src/Isos/TreeLike.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "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": "ice1k/Theorems", "max_issues_repo_path": "src/Isos/TreeLike.agda", "max_line_length": 73, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ice1k/Theorems", "max_stars_repo_path": "src/Isos/TreeLike.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z", "num_tokens": 963, "size": 2181 }
module Categories.Category.CartesianClosed.Bundle where open import Categories.Category using (Category) open import Categories.Category.CartesianClosed using (CartesianClosed) open import Level record CartesianClosedCategory o ℓ e : Set (suc (o ⊔ ℓ ⊔ e)) where field U : Category o ℓ e cartesianClosed : CartesianClosed U open Category U public open CartesianClosed cartesianClosed public
{ "alphanum_fraction": 0.7892156863, "avg_line_length": 27.2, "ext": "agda", "hexsha": "cdd9ca7b016ef86d4d99864c7fe2cfd3465ca4d9", "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": "7541ab22debdfe9d529ac7a210e5bd102c788ad9", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "elpinal/exsub-ccc", "max_forks_repo_path": "Categories/Category/CartesianClosed/Bundle.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7541ab22debdfe9d529ac7a210e5bd102c788ad9", "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": "elpinal/exsub-ccc", "max_issues_repo_path": "Categories/Category/CartesianClosed/Bundle.agda", "max_line_length": 71, "max_stars_count": 3, "max_stars_repo_head_hexsha": "7541ab22debdfe9d529ac7a210e5bd102c788ad9", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "elpinal/exsub-ccc", "max_stars_repo_path": "Categories/Category/CartesianClosed/Bundle.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T13:30:48.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-05T06:16:32.000Z", "num_tokens": 93, "size": 408 }
module String where open import Common.IO open import Common.List open import Common.String open import Common.Unit testString : String testString = "To boldly go where no man gone before" printList : {A : Set} -> (A -> IO Unit) -> List A -> IO Unit printList p [] = return unit printList p (x ∷ xs) = p x ,, printList p xs main : IO Unit main = putStrLn testString ,, printList printChar (stringToList testString) ,, putStrLn "" ,, putStrLn (fromList (stringToList testString)) ,, return unit
{ "alphanum_fraction": 0.6812144213, "avg_line_length": 21.08, "ext": "agda", "hexsha": "591d54bb6a43c369069bb7c1d91322165abcef76", "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/Compiler/simple/String.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/Compiler/simple/String.agda", "max_line_length": 60, "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/Compiler/simple/String.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 141, "size": 527 }
module SafetyProof where open import Algebra import Algebra.Properties.CommutativeSemigroup as CommutativeSemigroupProperties open import Data.List open import Data.List.Relation.Unary.All using (All; []; _∷_) open import Data.Fin.Patterns using (0F; 1F) open import Data.Nat using (z≤n; s≤s) open import Data.Integer using (+≤+; +<+; +_) open import Data.Vec using (_∷_) import Data.Vec.Functional as Vector open import Data.Product using (_×_; _,_; uncurry) open import Data.Sum open import Level using (0ℓ) open import Relation.Binary.PropositionalEquality open import Relation.Nullary using (yes; no) open import Vehicle.Data.Tensor open import AbstractRationals import WindControllerSpec as Vehicle open ≤-Reasoning ------------------------------------------------------------------------ -- Setup toTensor : ℚ → ℚ → Tensor ℚ (2 ∷ []) toTensor x y = Vector.fromList (x ∷ y ∷ []) roadWidth : ℚ roadWidth = + 3 / 1 maxWindShift : ℚ maxWindShift = 1ℚ maxSensorError : ℚ maxSensorError = + 1 / 4 roadWidth≥0 : roadWidth ≥ 0ℚ roadWidth≥0 = *≤* (+≤+ z≤n) maxWindShift≥0 : maxWindShift ≥ 0ℚ maxWindShift≥0 = *≤* (+≤+ z≤n) maxSensorError≥0 : maxSensorError ≥ 0ℚ maxSensorError≥0 = *≤* (+≤+ z≤n) ------------------------------------------------------------------------ -- Model data record State : Set where constructor state field windSpeed : ℚ position : ℚ velocity : ℚ sensor : ℚ open State record Observation : Set where constructor observe field windShift : ℚ sensorError : ℚ open Observation ------------------------------------------------------------------------ -- Model transitions initialState : State initialState = record { windSpeed = 0ℚ ; position = 0ℚ ; velocity = 0ℚ ; sensor = 0ℚ } controller : ℚ → ℚ → ℚ controller x y = Vehicle.controller (toTensor x y) nextState : Observation → State → State nextState o s = record { windSpeed = newWindSpeed ; position = newPosition ; velocity = newVelocity ; sensor = newSensor } where newWindSpeed = windSpeed s + windShift o newPosition = position s + velocity s + newWindSpeed newSensor = newPosition + sensorError o newVelocity = velocity s + controller newSensor (sensor s) finalState : List Observation → State finalState xs = foldr nextState initialState xs ------------------------------------------------------------------------ -- Definition of correctness nextPosition-windShift : State → ℚ nextPosition-windShift s = position s + velocity s + windSpeed s -- The vehicle is on the road if its position is less than the -- width of the road. OnRoad : State → Set OnRoad s = ∣ position s ∣ ≤ roadWidth -- The vehicle is in a "safe" state if it's more than the maxWindShift away -- from the edge of the road. SafeDistanceFromEdge : State → Set SafeDistanceFromEdge s = ∣ nextPosition-windShift s ∣ < roadWidth - maxWindShift -- The vehicle's previous sensor reading is accurate if it is no more than the -- maximum error away from it's true location. AccurateSensorReading : State → Set AccurateSensorReading s = ∣ position s - sensor s ∣ ≤ maxSensorError -- The vehicle's previous sensor reading was not off the road SensorReadingNotOffRoad : State → Set SensorReadingNotOffRoad s = ∣ sensor s ∣ ≤ roadWidth + maxSensorError -- A state is safe if it both a safe distance from the edge and it's sensor -- reading is accurate. SafeState : State → Set SafeState s = SafeDistanceFromEdge s × AccurateSensorReading s × SensorReadingNotOffRoad s -- An observation is valid if the observed sensor error and the wind shift -- are less than the expected maximum shifts. ValidObservation : Observation → Set ValidObservation o = ∣ sensorError o ∣ ≤ maxSensorError × ∣ windShift o ∣ ≤ maxWindShift ------------------------------------------------------------------------ -- Proof of correctness -- Initial state is both a safe distance from the edge and on the road initialState-onRoad : OnRoad initialState initialState-onRoad = roadWidth≥0 initialState-safe : SafeState initialState initialState-safe rewrite +-eq | *-eq | neg-eq = *<* (+<+ (s≤s z≤n)) , *≤* (+≤+ z≤n) , *≤* (+≤+ z≤n) -- Transitions are well-behaved controller-lem : ∀ x y → ∣ x ∣ ≤ roadWidth + maxSensorError → ∣ y ∣ ≤ roadWidth + maxSensorError → ∣ controller x y + 2ℚ * x - y ∣ < roadWidth - maxWindShift - 3ℚ * maxSensorError controller-lem x y ∣x∣≤rw+εₘₐₓ ∣y∣≤rw+εₘₐₓ rewrite +-eq | *-eq | neg-eq = uncurry -p<q<p⇒∣q∣<p (Vehicle.safe (toTensor x y) (λ { 0F → ∣p∣≤q⇒-q≤p≤q x ∣x∣≤rw+εₘₐₓ ; 1F → ∣p∣≤q⇒-q≤p≤q y ∣y∣≤rw+εₘₐₓ })) valid⇒nextState-accurateSensor : ∀ o → ValidObservation o → ∀ s → AccurateSensorReading (nextState o s) valid⇒nextState-accurateSensor o (ε≤εₘₐₓ , _) s = let s' = nextState o s in begin ∣ position s' - sensor s' ∣ ≡⟨⟩ ∣ position s' - (position s' + sensorError o) ∣ ≡⟨ cong ∣_∣ (p-[p+q]≡q (position s') (sensorError o)) ⟩ ∣ sensorError o ∣ ≤⟨ ε≤εₘₐₓ ⟩ maxSensorError ∎ valid+safe⇒nextState-onRoad : ∀ o → ValidObservation o → ∀ s → SafeState s → OnRoad (nextState o s) valid+safe⇒nextState-onRoad o (_ , δw≤δwₘₐₓ) s (safeDist , _ , _) = begin ∣ position s + velocity s + (windSpeed s + windShift o) ∣ ≡˘⟨ cong ∣_∣ (+-assoc (position s + velocity s) (windSpeed s) (windShift o)) ⟩ ∣ position s + velocity s + windSpeed s + windShift o ∣ ≤⟨ ∣p+q∣≤∣p∣+∣q∣ _ (windShift o) ⟩ ∣ nextPosition-windShift s ∣ + ∣ windShift o ∣ ≤⟨ +-mono-≤ (<⇒≤ safeDist) δw≤δwₘₐₓ ⟩ roadWidth - maxWindShift + maxWindShift ≡⟨ p-q+q≡p roadWidth maxWindShift ⟩ roadWidth ∎ valid+safe⇒nextState-sensorReadingNotOffRoad : ∀ s → SafeState s → ∀ o → ValidObservation o → SensorReadingNotOffRoad (nextState o s) valid+safe⇒nextState-sensorReadingNotOffRoad s safe o valid@(ε≤εₘₐₓ , _) = begin ∣ position (nextState o s) + sensorError o ∣ ≤⟨ ∣p+q∣≤∣p∣+∣q∣ (position s + velocity s + (windSpeed s + windShift o)) (sensorError o) ⟩ ∣ position (nextState o s) ∣ + ∣ sensorError o ∣ ≤⟨ +-mono-≤ (valid+safe⇒nextState-onRoad o valid s safe) ε≤εₘₐₓ ⟩ roadWidth + maxSensorError ∎ valid+safe⇒nextState-safeDistanceFromEdge : ∀ o → ValidObservation o → ∀ s → SafeState s → SafeDistanceFromEdge (nextState o s) valid+safe⇒nextState-safeDistanceFromEdge o valid@(ε-accurate , _) s safe@(safeDist , ε'-accurate , s-notOffRoad) = let s' = nextState o s y = position s; y' = position s' v = velocity s; v' = velocity s' w = windSpeed s; w' = windSpeed s' p = sensor s; p' = sensor s' ε = y - p; ε' = sensorError o dw = windShift o dv = controller p' p ∣dv+2p'-p∣ = ∣ dv + 2ℚ * p' - p ∣ s'-notOffRoad = valid+safe⇒nextState-sensorReadingNotOffRoad s safe o valid in begin-strict ∣ y' + v' + w' ∣ ≡⟨ cong ∣_∣ (sym (p+q-q≡p (y' + v' + w') _)) ⟩ ∣ y' + (v + dv) + w' + (y + ε' + ε' - p) - (y + ε' + ε' - p) ∣ ≡⟨ cong ∣_∣ (lem1 y' v dv w' y ε' p) ⟩ ∣ dv + (y' + ε' + (y + v + w' + ε')) - p - (ε' + ε' + (y - p)) ∣ ≡⟨⟩ ∣ dv + (p' + p') - p - (ε' + ε' + (y - p)) ∣ ≡⟨ cong ∣_∣ (cong₂ (λ a b → dv + a - p - (b + (y - p))) (sym (2*p≡p+p p')) (sym (2*p≡p+p ε'))) ⟩ ∣ dv + 2ℚ * p' - p - (2ℚ * ε' + (y - p)) ∣ ≤⟨ ∣p-q∣≤∣p∣+∣q∣ (dv + 2ℚ * p' - p) (2ℚ * ε' + (y - p)) ⟩ ∣ dv + 2ℚ * p' - p ∣ + ∣ 2ℚ * ε' + (y - p) ∣ ≤⟨ +-monoʳ-≤ _ (∣p+q∣≤∣p∣+∣q∣ (2ℚ * ε') (y - p)) ⟩ ∣ dv + 2ℚ * p' - p ∣ + (∣ 2ℚ * ε' ∣ + ∣ y - p ∣) ≡⟨ cong (λ v → ∣dv+2p'-p∣ + v) (cong (_+ _) (∣p*q∣≡∣p∣*∣q∣ 2ℚ ε')) ⟩ ∣ dv + 2ℚ * p' - p ∣ + (2ℚ * ∣ ε' ∣ + ∣ ε ∣) ≤⟨ +-monoʳ-≤ _ (+-mono-≤ (*-monoʳ-≤ 2ℚ _ ε-accurate) ε'-accurate) ⟩ ∣ dv + 2ℚ * p' - p ∣ + (2ℚ * maxSensorError + maxSensorError) ≡⟨ cong (λ v → ∣dv+2p'-p∣ + v) (2p+p≡3p maxSensorError) ⟩ ∣ dv + 2ℚ * p' - p ∣ + 3ℚ * maxSensorError <⟨ p<r-q⇒p+q<r _ _ _ (controller-lem p' p s'-notOffRoad s-notOffRoad) ⟩ roadWidth - maxWindShift ∎ safe⇒nextState-safe : ∀ s → SafeState s → ∀ o → ValidObservation o → SafeState (nextState o s) safe⇒nextState-safe s safe o valid = valid+safe⇒nextState-safeDistanceFromEdge o valid s safe , valid⇒nextState-accurateSensor o valid s , valid+safe⇒nextState-sensorReadingNotOffRoad s safe o valid finalState-safe : ∀ xs → All ValidObservation xs → SafeState (finalState xs) finalState-safe [] [] = initialState-safe finalState-safe (x ∷ xs) (px ∷ pxs) = safe⇒nextState-safe (finalState xs) (finalState-safe xs pxs) x px finalState-onRoad : ∀ xs → All ValidObservation xs → OnRoad (finalState xs) finalState-onRoad [] [] = initialState-onRoad finalState-onRoad (x ∷ xs) (px ∷ pxs) = valid+safe⇒nextState-onRoad x px (finalState xs) (finalState-safe xs pxs)
{ "alphanum_fraction": 0.5706480986, "avg_line_length": 40.5869565217, "ext": "agda", "hexsha": "8be896ffb948b498ec4daa67d0ddddb993c23db1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "vehicle-lang/vehicle", "max_forks_repo_path": "examples/windController/agdaProof/SafetyProof.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_issues_repo_issues_event_max_datetime": "2022-03-31T20:49:39.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-07T14:09:13.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "vehicle-lang/vehicle", "max_issues_repo_path": "examples/windController/agdaProof/SafetyProof.agda", "max_line_length": 164, "max_stars_count": 9, "max_stars_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "vehicle-lang/vehicle", "max_stars_repo_path": "examples/windController/agdaProof/SafetyProof.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-17T18:51:05.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-10T12:56:42.000Z", "num_tokens": 3259, "size": 9335 }
------------------------------------------------------------------------------ -- First-order Peano arithmetic ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module PA.Inductive.README where -- Formalization of first-order Peano arithmetic using Agda data types -- and primitive recursive functions for addition and multiplication. ------------------------------------------------------------------------------ -- Inductive definitions open import PA.Inductive.Base -- Some properties open import PA.Inductive.PropertiesATP open import PA.Inductive.PropertiesI open import PA.Inductive.PropertiesByInduction open import PA.Inductive.PropertiesByInductionATP open import PA.Inductive.PropertiesByInductionI
{ "alphanum_fraction": 0.5502183406, "avg_line_length": 35.2307692308, "ext": "agda", "hexsha": "138593e91b1626bdc30726bbca96d1622785ac40", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/PA/Inductive/README.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/PA/Inductive/README.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/PA/Inductive/README.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 151, "size": 916 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use `Data.Vec.Functional` instead. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} -- Disabled to prevent warnings from other Table modules {-# OPTIONS --warn=noUserWarning #-} module Data.Table.Relation.Equality where open import Data.Table.Relation.Binary.Equality public {-# WARNING_ON_IMPORT "Data.Table.Relation.Equality was deprecated in v1.0. Use Data.Vec.Functional.Relation.Binary.Pointwise instead." #-}
{ "alphanum_fraction": 0.578099839, "avg_line_length": 31.05, "ext": "agda", "hexsha": "23cf52a28a54b02ed942dfdfa316ef45d7cf672a", "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/Table/Relation/Equality.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/Table/Relation/Equality.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Table/Relation/Equality.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": 112, "size": 621 }
-- Andreas, 2012-01-11 module Issue551b where data Box (A : Set) : Set where [_] : .A → Box A implicit : {A : Set}{{a : A}} -> A implicit {{a}} = a postulate A : Set .a : A a' : Box A a' = [ implicit ] -- this should succeed f : {X : Set} → Box X → Box (Box X) f [ x ] = [ [ implicit ] ] -- this as well
{ "alphanum_fraction": 0.5301587302, "avg_line_length": 15, "ext": "agda", "hexsha": "b9f87bc44e1bc3f35157b69a9a919ed4492d28f3", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_path": "test/succeed/Issue551b.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_path": "test/succeed/Issue551b.agda", "max_line_length": 35, "max_stars_count": null, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/succeed/Issue551b.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 122, "size": 315 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.GradedRing.Instances.CohomologyRing where open import Cubical.Foundations.Prelude open import Cubical.Data.Nat open import Cubical.Data.Sigma open import Cubical.Algebra.Monoid open import Cubical.Algebra.Monoid.Instances.NatPlusBis open import Cubical.Algebra.AbGroup open import Cubical.Algebra.AbGroup.Instances.Unit open import Cubical.Algebra.DirectSum.DirectSumHIT.Base open import Cubical.Algebra.GradedRing.Base open import Cubical.Algebra.GradedRing.DirectSumHIT 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 open GradedRing-⊕HIT-index open GradedRing-⊕HIT-⋆ module _ (A : Type ℓ) where CohomologyRing-GradedRing : GradedRing ℓ-zero ℓ CohomologyRing-GradedRing = makeGradedRingSelf NatPlusBis-Monoid (λ 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-⌣ _ _ _ _ _)
{ "alphanum_fraction": 0.60609358, "avg_line_length": 38.2916666667, "ext": "agda", "hexsha": "e6bc75e22ff1d0b1258c21ab85a0f7975656ed1d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Algebra/GradedRing/Instances/CohomologyRing.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Algebra/GradedRing/Instances/CohomologyRing.agda", "max_line_length": 128, "max_stars_count": null, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/GradedRing/Instances/CohomologyRing.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 547, "size": 1838 }
module RandomAccessList.Redundant where open import RandomAccessList.Redundant.Core open import RandomAccessList.Redundant.Core.Properties open import BuildingBlock.BinaryLeafTree using (BinaryLeafTree; Node; Leaf) import BuildingBlock.BinaryLeafTree as BLT -- open import Data.Fin open import Data.Num.Nat open import Data.Num.Redundant open import Data.Num.Redundant.Properties open import Data.Nat renaming (_<_ to _<ℕ_) open import Data.Nat.DivMod open import Data.Nat.Etc open import Data.Product open import Relation.Nullary using (Dec; yes; no) open import Relation.Nullary.Negation using (contradiction; contraposition) open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; _≢_; refl; cong; trans; sym; subst; inspect) -------------------------------------------------------------------------------- -- Operations -------------------------------------------------------------------------------- consₙ : ∀ {n A} → BinaryLeafTree A n → 0-2-RAL A n → 0-2-RAL A n consₙ a [] = a 1∷ [] consₙ a ( 0∷ xs) = a 1∷ xs consₙ a (x 1∷ xs) = a , x 2∷ xs consₙ a (x , y 2∷ xs) = a 1∷ consₙ (Node x y) xs cons : ∀ {A} → A → 0-2-RAL A 0 → 0-2-RAL A 0 cons a xs = consₙ (Leaf a) xs headₙ : ∀ {n A} → (xs : 0-2-RAL A n) → ⟦ xs ⟧ₙ ≉ zero ∷ [] → BinaryLeafTree A n headₙ [] p = contradiction (eq refl) p headₙ ( 0∷ xs) p = proj₁ (BLT.split (headₙ xs (contraposition (>>-zero ⟦ xs ⟧ₙ) p))) headₙ (x 1∷ xs) p = x headₙ (x , y 2∷ xs) p = x head : ∀ {A} → (xs : 0-2-RAL A 0) → ⟦ xs ⟧ ≉ zero ∷ [] → A head xs p = BLT.head (headₙ xs p) tailₙ : ∀ {n A} → (xs : 0-2-RAL A n) → ⟦ xs ⟧ₙ ≉ zero ∷ [] → 0-2-RAL A n tailₙ [] p = contradiction (eq refl) p tailₙ ( 0∷ xs) p = proj₂ (BLT.split (headₙ xs (contraposition (>>-zero ⟦ xs ⟧ₙ) p))) 1∷ tailₙ xs (contraposition (>>-zero ⟦ xs ⟧ₙ) p) tailₙ (x 1∷ xs) p = 0∷ xs tailₙ (x , y 2∷ xs) p = y 1∷ xs tail : ∀ {A} → (xs : 0-2-RAL A 0) → ⟦ xs ⟧ ≉ zero ∷ [] → 0-2-RAL A 0 tail xs p = tailₙ xs p -------------------------------------------------------------------------------- -- Searching -------------------------------------------------------------------------------- data Finite : Redundant → Set where finite : ∀ {bound} -- # of elements → (a : Redundant) -- inhabitant → {a<bound : a < bound} → Finite bound elemAt : ∀ {n A} → (xs : 0-2-RAL A n) → Finite ⟦ xs ⟧ → A elemAt {n} {A} [] (finite a {a<[]}) = contradiction a<[] {! !} -- elemAt {n} {A} [] (finite a {a<b}) = contradiction a<b (contraposition (map-≤ refl (to≡ (<<<-zero 0 ⟦ [] {A} {n} ⟧ {⟦[]⟧≈zero∷[] ([] {A} {n}) {refl}}))) (λ ())) elemAt (0∷ xs) i = elemAt xs {! !} elemAt (x 1∷ xs) i = {! !} elemAt (x , y 2∷ xs) i = {! !} {- -- data Occurrence : Set where -- here : ∀ {a n} → a * Fin (2 ^ n) → Occurrence -- there : Occurrence transportFin : ∀ {a b} → a ≡ b → Fin a → Fin b transportFin refl i = i elemAt : ∀ {n A} → (xs : 0-2-RAL A n) → Fin ⟦ xs ⟧ → A elemAt {zero} [] () elemAt {suc n} {A} [] i = elemAt {n} ([] {A} {n}) (transportFin (⟦[]⟧≡⟦[]⟧ {m = suc n} {n = n} {A = A}) i) elemAt ( 0∷ xs) i = elemAt xs (transportFin (⟦0∷xs⟧≡⟦xs⟧ xs) i) elemAt {n} (x 1∷ xs) i with (1 * 2 ^ n) ≤? toℕ i elemAt (x 1∷ xs) i | yes p rewrite splitIndex x xs = elemAt xs (reduce≥ i p) elemAt {n} (x 1∷ xs) i | no ¬p with toℕ i divMod (2 ^ n) elemAt (x 1∷ xs) i | no ¬p | result quotient remainder property = BLT.elemAt x remainder elemAt {n} (x , y 2∷ xs) i with (2 * 2 ^ n) ≤? toℕ i elemAt (x , y 2∷ xs) i | yes p rewrite splitIndex2 x y xs = elemAt xs (reduce≥ i p) elemAt {n} (x , y 2∷ xs) i | no ¬p with toℕ i divMod (2 ^ n) elemAt (x , y 2∷ xs) i | no ¬p | result zero remainder property = BLT.elemAt x remainder elemAt (x , y 2∷ xs) i | no ¬p | result (suc quotient) remainder property = BLT.elemAt y remainder -}
{ "alphanum_fraction": 0.5204991087, "avg_line_length": 42.2258064516, "ext": "agda", "hexsha": "441d7e5ad265c1231fc2f1fac498b9fd61b93d10", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_path": "legacy/RandomAccessList/Redundant.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_path": "legacy/RandomAccessList/Redundant.agda", "max_line_length": 163, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_path": "legacy/RandomAccessList/Redundant.agda", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "num_tokens": 1504, "size": 3927 }
module examplesPaperJFP.Object where open import Data.Product open import Data.String.Base open import examplesPaperJFP.NativeIOSafe open import examplesPaperJFP.BasicIO hiding (main) open import examplesPaperJFP.Console hiding (main) record Interface : Set₁ where field Method : Set Result : (m : Method) → Set open Interface public record Object (I : Interface) : Set where coinductive field objectMethod : (m : Method I) → Result I m × Object I open Object public record IOObject (Iᵢₒ : IOInterface) (I : Interface) : Set where coinductive field method : (m : Method I) → IO Iᵢₒ (Result I m × IOObject Iᵢₒ I) open IOObject public data CellMethod A : Set where get : CellMethod A put : A → CellMethod A CellResult : ∀{A} → CellMethod A → Set CellResult {A} get = A CellResult (put _) = Unit cellJ : (A : Set) → Interface Method (cellJ A) = CellMethod A Result (cellJ A) m = CellResult m CellC : Set CellC = IOObject ConsoleInterface (cellJ String) simpleCell : (s : String) → CellC force (method (simpleCell s) get) = exec′ (putStrLn ("getting (" ++ s ++ ")")) λ _ → delay (return′ (s , simpleCell s)) force (method (simpleCell s) (put x)) = exec′ (putStrLn ("putting (" ++ x ++ ")")) λ _ → delay (return′ (unit , simpleCell x)) {-# TERMINATING #-} program : IOConsole Unit force program = let c₁ = simpleCell "Start" in exec′ getLine λ{ nothing → return unit; (just s) → method c₁ (put s) >>= λ{ (_ , c₂) → method c₂ get >>= λ{ (s′ , _ ) → exec (putStrLn s′) λ _ → program }}} main : NativeIO Unit main = translateIOConsole program
{ "alphanum_fraction": 0.6366863905, "avg_line_length": 25.223880597, "ext": "agda", "hexsha": "ad6db68ea9c8a20712e0c5ae47896270475e3210", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "examples/examplesPaperJFP/Object.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "examples/examplesPaperJFP/Object.agda", "max_line_length": 70, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "examples/examplesPaperJFP/Object.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 525, "size": 1690 }
-- -- Created by Dependently-Typed Lambda Calculus on 2019-05-15 -- imports -- Author: ice1000 -- {-# OPTIONS --without-K --safe #-} import Relation.Binary.PropositionalEquality open import Relation.Binary.PropositionalEquality import Relation.Binary.PropositionalEquality using () import Relation.Binary.PropositionalEquality using (sym) hiding (cong) import Relation.Binary.PropositionalEquality renaming (sym to symBla)
{ "alphanum_fraction": 0.7957746479, "avg_line_length": 28.4, "ext": "agda", "hexsha": "5aa3e87d8f4fd8965c231074701522fd7857f14e", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-03-12T21:33:35.000Z", "max_forks_repo_forks_event_min_datetime": "2019-10-07T01:38:12.000Z", "max_forks_repo_head_hexsha": "ee25a3a81dacebfe4449de7a9aaff029171456be", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "dubinsky/intellij-dtlc", "max_forks_repo_path": "testData/parse/agda/imports.agda", "max_issues_count": 16, "max_issues_repo_head_hexsha": "ee25a3a81dacebfe4449de7a9aaff029171456be", "max_issues_repo_issues_event_max_datetime": "2021-03-15T17:04:36.000Z", "max_issues_repo_issues_event_min_datetime": "2019-03-30T04:29:32.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "dubinsky/intellij-dtlc", "max_issues_repo_path": "testData/parse/agda/imports.agda", "max_line_length": 70, "max_stars_count": 30, "max_stars_repo_head_hexsha": "ee25a3a81dacebfe4449de7a9aaff029171456be", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "dubinsky/intellij-dtlc", "max_stars_repo_path": "testData/parse/agda/imports.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-29T13:18:34.000Z", "max_stars_repo_stars_event_min_datetime": "2019-05-11T16:26:38.000Z", "num_tokens": 96, "size": 426 }
{-# OPTIONS --allow-unsolved-metas #-} {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Data.List.PostulatesVersusDataTypes where -- See Agda mailing list. -- Subject: Agda's unification: postulates versus data types module M₁ where data D : Set where _∷_ : D → D → D data List : D → Set where cons : ∀ x xs → List xs → List (x ∷ xs) tail : ∀ {x xs} → List (x ∷ xs) → List xs tail {x} {xs} (cons .x .xs xsL) = xsL module M₂ where postulate D : Set _∷_ : D → D → D data List : D → Set where cons : ∀ x xs → List xs → List (x ∷ xs) tail : ∀ {x xs} → List (x ∷ xs) → List xs tail l = {!!} -- C-c C-c fails
{ "alphanum_fraction": 0.5447667087, "avg_line_length": 24.78125, "ext": "agda", "hexsha": "a92d8937ea91992f7dbd194b1a1dd15b79b875c1", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Data/List/PostulatesVersusDataTypes.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Data/List/PostulatesVersusDataTypes.agda", "max_line_length": 60, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Data/List/PostulatesVersusDataTypes.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 259, "size": 793 }
------------------------------------------------------------------------ -- Some tactics aimed at making equational reasoning proofs more -- readable for path equality ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} module Tactic.By.Path where import Agda.Builtin.Cubical.Path open import Equality.Path open import Prelude open import List equality-with-J as L open import Maybe equality-with-J open import Monad equality-with-J open import Tactic.By equality-with-J as TB open import TC-monad equality-with-J as TC hiding (Type) open TB public using (⟨_⟩) private -- Constructs the type of equalities between its two arguments. equality : Term → Term → TC.Type equality lhs rhs = def (quote _≡_) (varg lhs ∷ varg rhs ∷ []) -- An illustration of what the cong functions constructed by -- make-cong-called look like. cong₃′ : ∀ {a b c d : Level} {A : Type a} {B : Type b} {C : Type c} {D : Type d} {x₁ y₁ x₂ y₂ x₃ y₃} (f : A → B → C → D) → x₁ ≡ y₁ → x₂ ≡ y₂ → x₃ ≡ y₃ → f x₁ x₂ x₃ ≡ f y₁ y₂ y₃ cong₃′ f eq₁ eq₂ eq₃ = λ i → f (eq₁ i) (eq₂ i) (eq₃ i) -- Constructs a "cong" function, with the given name, for functions -- with the given number of arguments. make-cong-called : Name → ℕ → TC ⊤ make-cong-called cong n = do declareDef (varg cong) (type-of-cong equality n) defineFun cong (the-clause ∷ []) where arguments : ℕ → List (Arg Term) arguments zero = [] arguments (suc m) = varg (var (suc m) (varg (var 0 []) ∷ [])) ∷ arguments m the-clause = clause (("f" , varg unknown) ∷ replicate n ("eq" , varg unknown)) (varg (var n) ∷ L.map (varg ∘ var) (nats-< n)) (lam visible $ abs "i" $ var (n + 1) (arguments n)) unquoteDecl cong₃ = make-cong-called cong₃ 3 unquoteDecl cong₄ = make-cong-called cong₄ 4 unquoteDecl cong₅ = make-cong-called cong₅ 5 unquoteDecl cong₆ = make-cong-called cong₆ 6 unquoteDecl cong₇ = make-cong-called cong₇ 7 unquoteDecl cong₈ = make-cong-called cong₈ 8 unquoteDecl cong₉ = make-cong-called cong₉ 9 unquoteDecl cong₁₀ = make-cong-called cong₁₀ 10 -- Constructs a "cong" function (similar to cong and cong₂ in -- Equality) for functions with the given number of arguments. The -- name of the constructed function is returned (for 1 and 2 the -- functions in Equality are returned). The cong functions for -- functions with 3 up to 10 arguments are cached to avoid creating -- lots of copies of the same functions. make-cong : ℕ → TC Name make-cong 1 = return (quote cong) make-cong 2 = return (quote cong₂) make-cong 3 = return (quote cong₃) make-cong 4 = return (quote cong₄) make-cong 5 = return (quote cong₅) make-cong 6 = return (quote cong₆) make-cong 7 = return (quote cong₇) make-cong 8 = return (quote cong₈) make-cong 9 = return (quote cong₉) make-cong 10 = return (quote cong₁₀) make-cong n = do cong ← freshName "cong" make-cong-called cong n return cong open Tactics (λ where (def (quote Agda.Builtin.Cubical.Path.PathP) (arg _ a ∷ arg _ P ∷ arg _ x ∷ arg _ y ∷ [])) → do A ← case P of λ where (lam _ (abs _ A)) → case bound? 0 A of λ where (definitely true) → return unknown _ → return (strengthen-term 0 1 A) _ → return unknown return $ just (a , A , x , y) _ → return nothing) equality (λ a A x → def (quote refl) (harg a ∷ harg A ∷ harg x ∷ [])) (λ p → def (quote sym) (varg p ∷ [])) (λ lhs rhs f p → def (quote cong) (replicate 3 (harg unknown) ++ harg lhs ∷ harg rhs ∷ varg f ∷ varg p ∷ [])) false make-cong true public ------------------------------------------------------------------------ -- Some unit tests -- Test cases that are commented out fail (or at least they failed at -- some point). private module Tests (assumption : 48 ≡ 42) (lemma : ∀ n → n + 8 ≡ n + 2) (f : ℕ → ℕ → ℕ → ℕ) where g : ℕ → ℕ → ℕ → ℕ g zero _ _ = 12 g (suc _) _ _ = 12 fst : ∀ {a b} {A : Type a} {B : A → Type b} → Σ A B → A fst = proj₁ {-# NOINLINE fst #-} _≡′_ : {A : Type} → A → A → Type _≡′_ = _≡_ {-# NOINLINE _≡′_ #-} record R (F : Type → Type) : Type₁ where field p : {A : Type} {x : F A} → x ≡ x open R ⦃ … ⦄ public -- Tests for by. module By-tests where test₁ : 40 + 2 ≡ 42 test₁ = by definition test₂ : 48 ≡ 42 → 42 ≡ 48 test₂ eq = by eq test₃ : (f : ℕ → ℕ) → f 42 ≡ f 48 test₃ f = by assumption test₄ : (f : ℕ → ℕ) → f 48 ≡ f 42 test₄ f = by assumption test₅ : (f : ℕ → ℕ → ℕ) → f 42 48 ≡ f 48 42 test₅ f = by assumption test₆ : (f : ℕ → ℕ → ℕ → ℕ) → f 42 45 48 ≡ f 48 45 42 test₆ f = by assumption test₇ : f 48 (f 42 45 48) 42 ≡ f 48 (f 48 45 42) 48 test₇ = by assumption test₈ : ∀ n → g n (g n 45 48) 42 ≡ g n (g n 45 42) 48 test₈ n = by assumption test₉ : (f : ℕ → ℕ) → f 42 ≡ f 48 test₉ f = by (lemma 40) test₁₀ : (f : ℕ → ℕ) → f 42 ≡ f 48 test₁₀ f = by (λ (_ : ⊤) → assumption) test₁₁ : (f : ℕ × ℕ → ℕ × ℕ) → (∀ x → f x ≡′ x) → fst (f (12 , 73)) ≡ fst {B = λ _ → ℕ} (12 , 73) test₁₁ _ hyp = by hyp test₁₂ : (h : ℕ → Maybe ℕ) → ((xs : ℕ) → h xs ≡ just xs) → (xs : ℕ) → suc ⟨$⟩ h xs ≡ suc ⟨$⟩ return xs test₁₂ h hyp xs = suc ⟨$⟩ h xs ≡⟨ by (hyp xs) ⟩∎h suc ⟨$⟩ return xs ∎ -- test₁₃ : (h : List ⊤ → Maybe (List ⊤)) → -- ((xs : List ⊤) → h xs ≡ just xs) → -- (x : ⊤) (xs : List ⊤) → _ ≡ _ -- test₁₃ h hyp x xs = -- _∷_ ⟨$⟩ return x ⊛ h xs ≡⟨ by (hyp xs) ⟩∎ -- _∷_ ⟨$⟩ return x ⊛ return xs ∎ test₁₅ : (F : Type → Type → Type) (G : Bool → Type → Type) → ((A : Type) → F (G false A) A ≡ G false (F A A)) → (A : Type) → G false (F (G false A) A) ≡ G false (G false (F A A)) test₁₅ F G hyp A = G false (F (G false A) A) ≡⟨ by hyp ⟩∎ G false (G false (F A A)) ∎ test₁₇ : (P : ℕ → Type) (f : ∀ {n} → P n → P n) (p : P 0) → f (subst P refl p) ≡ f p test₁₇ P _ _ = by (subst-refl P) test₁₈ : (subst′ : ∀ {a p} {A : Type a} {x y : A} (P : A → Type p) → x ≡ y → P x → P y) → (∀ {a p} {A : Type a} {x : A} (P : A → Type p) (p : P x) → subst′ P refl p ≡ p) → (P : ℕ → Type) (f : ∀ {n} → P n → P n) (p : P 0) → f (subst′ P refl p) ≡ f p test₁₈ _ subst′-refl P _ _ = by (subst′-refl P) -- test₁₉ : -- {F : Type → Type} ⦃ r : R F ⦄ {A : Type} {x₁ x₂ : F A} -- (p₁ p₂ : x₁ ≡ x₂) (assumption : p₁ ≡ p₂) → -- trans p p₁ ≡ trans p p₂ -- test₁₉ p₁ p₂ assumption = -- trans p p₁ ≡⟨ by assumption ⟩∎ -- trans p p₂ ∎ -- Tests for ⟨by⟩. module ⟨By⟩-tests where test₁ : ⟨ 40 + 2 ⟩ ≡ 42 test₁ = ⟨by⟩ refl test₂ : 48 ≡ 42 → ⟨ 42 ⟩ ≡ 48 test₂ eq = ⟨by⟩ eq test₃ : (f : ℕ → ℕ) → f ⟨ 42 ⟩ ≡ f 48 test₃ f = ⟨by⟩ assumption test₄ : (f : ℕ → ℕ) → f ⟨ 48 ⟩ ≡ f 42 test₄ f = ⟨by⟩ assumption test₅ : (f : ℕ → ℕ → ℕ) → f ⟨ 42 ⟩ ⟨ 42 ⟩ ≡ f 48 48 test₅ f = ⟨by⟩ assumption test₆ : (f : ℕ → ℕ → ℕ → ℕ) → f ⟨ 48 ⟩ 45 ⟨ 48 ⟩ ≡ f 42 45 42 test₆ f = ⟨by⟩ assumption test₇ : f ⟨ 48 ⟩ (f ⟨ 48 ⟩ 45 ⟨ 48 ⟩) ⟨ 48 ⟩ ≡ f 42 (f 42 45 42) 42 test₇ = ⟨by⟩ assumption test₈ : ∀ n → g n (g n 45 ⟨ 48 ⟩) ⟨ 48 ⟩ ≡ g n (g n 45 42) 42 test₈ n = ⟨by⟩ assumption test₉ : (f : ℕ → ℕ) → f ⟨ 42 ⟩ ≡ f 48 test₉ f = ⟨by⟩ (lemma 40) test₁₀ : (f : ℕ → ℕ) → f ⟨ 42 ⟩ ≡ f 48 test₁₀ f = ⟨by⟩ (λ (_ : ⊤) → assumption) test₁₁ : (f : ℕ × ℕ → ℕ × ℕ) → (∀ x → f x ≡′ x) → fst ⟨ f (12 , 73) ⟩ ≡ fst {B = λ _ → ℕ} (12 , 73) test₁₁ _ hyp = ⟨by⟩ hyp test₁₂ : (h : ℕ → Maybe ℕ) → ((xs : ℕ) → h xs ≡ just xs) → (xs : ℕ) → suc ⟨$⟩ h xs ≡ suc ⟨$⟩ return xs test₁₂ h hyp xs = suc ⟨$⟩ ⟨ h xs ⟩ ≡⟨ ⟨by⟩ (hyp xs) ⟩∎ suc ⟨$⟩ return xs ∎ test₁₃ : (h : List ⊤ → Maybe (List ⊤)) → ((xs : List ⊤) → h xs ≡ just xs) → (x : ⊤) (xs : List ⊤) → _ ≡ _ test₁₃ h hyp x xs = _∷_ ⟨$⟩ return x ⊛ ⟨ h xs ⟩ ≡⟨ ⟨by⟩ (hyp xs) ⟩∎ _∷_ ⟨$⟩ return x ⊛ return xs ∎ test₁₄ : (h : List ℕ → Maybe (List ℕ)) → ((xs : List ℕ) → h xs ≡ just xs) → (x : ℕ) (xs : List ℕ) → _ ≡ _ test₁₄ h hyp x xs = _∷_ ⟨$⟩ ⟨ h xs ⟩ ≡⟨ ⟨by⟩ (hyp xs) ⟩∎ _∷_ ⟨$⟩ return xs ∎ test₁₅ : (F : Type → Type → Type) (G : Bool → Type → Type) → ((A : Type) → F (G false A) A ≡ G false (F A A)) → (A : Type) → G false (F (G false A) A) ≡ G false (G false (F A A)) test₁₅ F G hyp A = G false ⟨ F (G false A) A ⟩ ≡⟨ ⟨by⟩ hyp ⟩∎ G false (G false (F A A)) ∎ test₁₆ : 48 ≡ 42 → _≡_ {A = ℕ → ℕ} (λ x → x + ⟨ 42 ⟩) (λ x → x + 48) test₁₆ hyp = ⟨by⟩ hyp test₁₇ : (P : ℕ → Type) (f : ∀ {n} → P n → P n) (p : P 0) → f ⟨ subst P refl p ⟩ ≡ f p test₁₇ P _ _ = ⟨by⟩ (subst-refl P) test₁₈ : (subst′ : ∀ {a p} {A : Type a} {x y : A} (P : A → Type p) → x ≡ y → P x → P y) → (∀ {a p} {A : Type a} {x : A} (P : A → Type p) (p : P x) → subst′ P refl p ≡ p) → (P : ℕ → Type) (f : ∀ {n} → P n → P n) (p : P 0) → f ⟨ subst′ P refl p ⟩ ≡ f p test₁₈ _ subst′-refl _ _ _ = ⟨by⟩ subst′-refl -- test₁₉ : -- {F : Type → Type} ⦃ r : R F ⦄ {A : Type} {x₁ x₂ : F A} -- (p₁ p₂ : x₁ ≡ x₂) (assumption : p₁ ≡ p₂) → -- trans p p₁ ≡ trans p p₂ -- test₁₉ p₁ p₂ assumption = -- trans p p₁ ≡⟨⟩ -- trans p ⟨ p₁ ⟩ ≡⟨ ⟨by⟩ assumption ⟩∎ -- trans p p₂ ∎
{ "alphanum_fraction": 0.4600793574, "avg_line_length": 30.3911764706, "ext": "agda", "hexsha": "d25dba96491bb06752d33214690f3f92cfc50d02", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Tactic/By/Path.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Tactic/By/Path.agda", "max_line_length": 73, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Tactic/By/Path.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 4036, "size": 10333 }
{-# OPTIONS --without-K --safe #-} open import Polynomial.Simple.AlmostCommutativeRing open import Relation.Binary open import Data.Bool using (Bool; false; true ; _∧_; _∨_; not; if_then_else_) open import Data.String using (String) open import EqBool module Relation.Traced {c ℓ} (base : AlmostCommutativeRing c ℓ) ⦃ eqBase : HasEqBool (AlmostCommutativeRing.Carrier base) ⦄ (showBase : AlmostCommutativeRing.Carrier base → String) where open import Data.Sum open import Relation.Binary.Construct.Closure.Equivalence open import Relation.Binary.Construct.Closure.Symmetric open import Relation.Binary.Construct.Closure.ReflexiveTransitive open import Data.String open import Relation.Nullary open import Function open import Level using (_⊔_) open import Algebra.FunctionProperties open import Data.String renaming (_==_ to eqBoolString) open import Data.Maybe open import Data.Nat using (ℕ) open AlmostCommutativeRing base open import Polynomial.Expr.Normalising rawRing showBase open import Agda.Builtin.FromNat using (Number; fromNat) public instance numberVar : {{nc : Number Carrier}} → Number Expr numberVar {{nc}} = record { Constraint = Number.Constraint nc ; fromNat = λ n → C ( (Number.fromNat nc n)) } data BinOp : Set where [+] : BinOp [*] : BinOp instance eqBinOp : HasEqBool BinOp EqBool._==_ ⦃ eqBinOp ⦄ [+] [+] = true EqBool._==_ ⦃ eqBinOp ⦄ [+] [*] = false EqBool._==_ ⦃ eqBinOp ⦄ [*] [+] = false EqBool._==_ ⦃ eqBinOp ⦄ [*] [*] = true liftBinOp : BinOp → Expr → Expr → Expr liftBinOp [+] (C x) (C y) = normalise (C (x + y)) liftBinOp [+] (C x) (O y) = normalise (O (K x ⊕ y)) liftBinOp [+] (O x) (C y) = normalise (O (x ⊕ K y)) liftBinOp [+] (O x) (O y) = normalise (O (x ⊕ y)) liftBinOp [*] (C x) (C y) = normalise (C (x * y)) liftBinOp [*] (C x) (O y) = normalise (O (K x ⊗ y)) liftBinOp [*] (O x) (C y) = normalise (O (x ⊗ K y)) liftBinOp [*] (O x) (O y) = normalise (O (x ⊗ y)) ⊟_ : Expr → Expr ⊟ C x = C (- x) ⊟ O x = normalise (O (⊝ x)) data Step : Set c where [sym] : Step → Step [cong] : Step → BinOp → Step → Step [-cong] : Step → Step [refl] : Expr → Step [assoc] : BinOp → Expr → Expr → Expr → Step [ident] : BinOp → Expr → Step [comm] : BinOp → Expr → Expr → Step [zero] : Expr → Step [distrib] : Expr → Expr → Expr → Step [-distrib] : Expr → Expr → Step [-+comm] : Expr → Expr → Step _==S_ : Step → Step → Bool _==S_ ([sym] x) ([sym] y) = x ==S y _==S_ ([cong] x x₁ x₂) ([cong] y y₁ y₂) = x ==S y ∧ x₁ EqBool.== y₁ ∧ x₂ ==S y₂ _==S_ ([-cong] x) ([-cong] y) = x ==S y _==S_ ([assoc] x x₁ x₂ x₃) ([assoc] y y₁ y₂ y₃) = x EqBool.== y ∧ x₁ EqBool.== y₁ ∧ x₂ EqBool.== y₂ ∧ x₃ EqBool.== y₃ _==S_ ([ident] x x₁) ([ident] y y₁) = x EqBool.== y ∧ x₁ EqBool.== y₁ _==S_ ([comm] x x₁ x₂) ([comm] y y₁ y₂) = x EqBool.== y ∧ x₁ EqBool.== y₁ ∧ x₂ EqBool.== y₂ _==S_ ([zero] x) ([zero] y) = x EqBool.== y _==S_ ([distrib] x x₁ x₂) ([distrib] y y₁ y₂) = x EqBool.== y ∧ x₁ EqBool.== y₁ ∧ x₂ EqBool.== y₂ _==S_ ([-distrib] x x₁) ([-distrib] y y₁) = x EqBool.== y ∧ x₁ EqBool.== y₁ _==S_ ([-+comm] x x₁) ([-+comm] y y₁) = x EqBool.== y ∧ x₁ EqBool.== y₁ _==S_ ([refl] x) ([refl] y) = x EqBool.== y _==S_ _ _ = false instance eqStep : HasEqBool Step EqBool._==_ {{eqStep}} = _==S_ record _≈ⁱ_ (x y : Expr) : Set c where constructor ~?_ field why : Step open _≈ⁱ_ interesting : Step → Maybe Step interesting ([sym] x) = interesting x interesting ([-cong] x) = interesting x interesting ([refl] x) = nothing interesting ([assoc] x x₁ x₂ x₃) = nothing interesting ([ident] x x₁) = nothing interesting ([zero] x) = nothing interesting ([cong] x x₁ x₂) with interesting x | interesting x₂ interesting ([cong] x x₁ x₂) | just res₁ | just res₂ = just ([cong] res₁ x₁ res₂) interesting ([cong] x x₁ x₂) | just res₁ | nothing = just res₁ interesting ([cong] x x₁ x₂) | nothing | just res₂ = just res₂ interesting ([cong] x x₁ x₂) | nothing | nothing = nothing interesting s@([comm] _ x y) with x EqBool.== y interesting s@([comm] _ x y) | true = nothing interesting s@([comm] o (C x) (C y)) | false = nothing interesting s@([comm] [+] (C x) x₂) | false = if x EqBool.== 0# then nothing else just s interesting s@([comm] [+] (O x) (C x₁)) | false = if x₁ EqBool.== 0# then nothing else just s interesting s@([comm] [+] (O x) (O x₁)) | false = just s interesting s@([comm] [*] (C x) x₂) | false = if (x EqBool.== 0# ∨ x EqBool.== 1#) then nothing else just s interesting s@([comm] [*] (O x) (C x₁)) | false = if (x₁ EqBool.== 0# ∨ x₁ EqBool.== 1#) then nothing else just s interesting s@([comm] [*] (O x) (O x₁)) | false = just s interesting s@([distrib] (C _) (C _) (C _)) = nothing interesting s@([distrib] (C x) x₁ x₂) = if (x EqBool.== 0# ∨ x EqBool.== 1#) then nothing else just s interesting s@([distrib] x x₁ x₂) = just s interesting s@([-distrib] x x₁) = nothing interesting s@([-+comm] x x₁) = nothing neg-cong : ∀ {x y} → x ≈ⁱ y → ⊟_ x ≈ⁱ ⊟_ y neg-cong (~? reason) = ~? ( [-cong] reason) zip-cong : BinOp → (f : Expr → Expr → Expr) → Congruent₂ (EqClosure _≈ⁱ_) f zip-cong op f {x₁} {x₂} {y₁} {y₂} ε ε = ε zip-cong op f {x₁} {x₂} {y₁} {y₂} ε (inj₁ (~? yr) ◅ ys) = inj₁ (~? ([cong] ([refl] x₁) op yr)) ◅ zip-cong op f ε ys zip-cong op f {x₁} {x₂} {y₁} {y₂} ε (inj₂ (~? yr) ◅ ys) = inj₂ (~? ([cong] ([refl] x₁) op yr)) ◅ zip-cong op f ε ys zip-cong op f {x₁} {x₂} {y₁} {y₂} (inj₁ (~? xr) ◅ xs) ε = inj₁ (~? ([cong] xr op ([refl] y₁))) ◅ zip-cong op f xs ε zip-cong op f {x₁} {x₂} {y₁} {y₂} (inj₂ (~? xr) ◅ xs) ε = inj₂ (~? ([cong] xr op ([refl] y₁))) ◅ zip-cong op f xs ε zip-cong op f {x₁} {x₂} {y₁} {y₂} (inj₁ (~? xr) ◅ xs) (inj₁ (~? yr) ◅ ys) = inj₁ (~? ([cong] xr op yr)) ◅ zip-cong op f xs ys zip-cong op f {x₁} {x₂} {y₁} {y₂} (inj₁ (~? xr) ◅ xs) (inj₂ (~? yr) ◅ ys) = inj₁ (~? ([cong] xr op ([sym] yr))) ◅ zip-cong op f xs ys zip-cong op f {x₁} {x₂} {y₁} {y₂} (inj₂ (~? xr) ◅ xs) (inj₁ (~? yr) ◅ ys) = inj₂ (~? ([cong] xr op ([sym] yr))) ◅ zip-cong op f xs ys zip-cong op f {x₁} {x₂} {y₁} {y₂} (inj₂ (~? xr) ◅ xs) (inj₂ (~? yr) ◅ ys) = inj₂ (~? ([cong] xr op yr)) ◅ zip-cong op f xs ys isZero : (x : Expr) → Maybe (EqClosure _≈ⁱ_ (C 0#) x) isZero (C x) = if 0# EqBool.== x then just (inj₁ (~? [refl] (C x)) ◅ ε) else nothing isZero _ = nothing tracedRing : AlmostCommutativeRing c c tracedRing = record { Carrier = Expr ; _≈_ = EqClosure _≈ⁱ_ ; _+_ = liftBinOp [+] ; _*_ = liftBinOp [*] ; -_ = ⊟_ ; 0# = C 0# ; 1# = C 1# ; 0≟_ = isZero ; isAlmostCommutativeRing = record { -‿cong = Relation.Binary.Construct.Closure.ReflexiveTransitive.gmap ⊟_ (Data.Sum.map neg-cong neg-cong) ; -‿*-distribˡ = λ x y → return (inj₁ (~? [-distrib] x y)) ; -‿+-comm = λ x y → return (inj₁ (~? [-+comm] x y)) ; isCommutativeSemiring = record { distribʳ = λ x y z → return (inj₁ (~? [distrib] x y z)) ; zeroˡ = λ x → return (inj₁ (~? ([zero] x))) ; *-isCommutativeMonoid = record { identityˡ = λ x → return (inj₁ (~? [ident] [*] x)) ; comm = λ x y → return (inj₁ (~? [comm] [*] x y)) ; isSemigroup = record { assoc = λ x y z → return (inj₁ (~? [assoc] [*] x y z)) ; isMagma = record { isEquivalence = Relation.Binary.Construct.Closure.Equivalence.isEquivalence _≈ⁱ_ ; ∙-cong = zip-cong [*] (liftBinOp [*]) } } } ; +-isCommutativeMonoid = record { identityˡ = λ x → return (inj₁ (~? ([ident] [+] x))) ; comm = λ x y → return (inj₁ (~? ([comm] [+] x y))) ; isSemigroup = record { assoc = λ x y z → return (inj₁ (~? ([assoc] [+] x y z))) ; isMagma = record { isEquivalence = Relation.Binary.Construct.Closure.Equivalence.isEquivalence _≈ⁱ_ ; ∙-cong = zip-cong [+] (liftBinOp [+]) } } } } } } open import Data.List as List using (List; _∷_; []) record Explanation {a} (A : Set a) : Set (a ⊔ c) where constructor _≈⟨_⟩≈_ field lhs : A step : Step rhs : A open Explanation toExplanation : ∀ {x y} → x ≈ⁱ y → Explanation Expr toExplanation {x} {y} x≈y = x ≈⟨ why x≈y ⟩≈ y showProof′ : ∀ {x y} → EqClosure _≈ⁱ_ x y → List (Explanation Expr) showProof′ ε = [] showProof′ (inj₁ x ◅ xs) = toExplanation x ∷ showProof′ xs showProof′ (inj₂ y ◅ xs) = toExplanation y ∷ showProof′ xs open import Data.String.Printf open Printf standard ⟨_⟩ₛ : Step → String ⟨ [sym] x ⟩ₛ = printf "sym (%s)" ⟨ x ⟩ₛ ⟨ [cong] x [+] x₂ ⟩ₛ = printf "(%s) + (%s)" ⟨ x ⟩ₛ ⟨ x₂ ⟩ₛ ⟨ [cong] x [*] x₂ ⟩ₛ = printf "(%s) * (%s)" ⟨ x ⟩ₛ ⟨ x₂ ⟩ₛ ⟨ [-cong] x ⟩ₛ = printf "- (%s)" ⟨ x ⟩ₛ ⟨ [refl] x ⟩ₛ = "eval" ⟨ [assoc] [+] x₁ x₂ x₃ ⟩ₛ = printf "+-assoc(%s, %s, %s)" ⟨ x₁ ⟩ₑ ⟨ x₂ ⟩ₑ ⟨ x₃ ⟩ₑ ⟨ [assoc] [*] x₁ x₂ x₃ ⟩ₛ = printf "*-assoc(%s, %s, %s)" ⟨ x₁ ⟩ₑ ⟨ x₂ ⟩ₑ ⟨ x₃ ⟩ₑ ⟨ [ident] [+] x₁ ⟩ₛ = printf "+-ident(%s)" ⟨ x₁ ⟩ₑ ⟨ [ident] [*] x₁ ⟩ₛ = printf "*-ident(%s)" ⟨ x₁ ⟩ₑ ⟨ [comm] [+] x₁ x₂ ⟩ₛ = printf "+-comm(%s, %s)" ⟨ x₁ ⟩ₑ ⟨ x₂ ⟩ₑ ⟨ [comm] [*] x₁ x₂ ⟩ₛ = printf "*-comm(%s, %s)" ⟨ x₁ ⟩ₑ ⟨ x₂ ⟩ₑ ⟨ [zero] x ⟩ₛ = printf "*-zero(%s)" ⟨ x ⟩ₑ ⟨ [distrib] x x₁ x₂ ⟩ₛ = printf "*-distrib(%s, %s, %s)" ⟨ x ⟩ₑ ⟨ x₁ ⟩ₑ ⟨ x₂ ⟩ₑ ⟨ [-distrib] x x₁ ⟩ₛ = printf "-‿distrib(%s, %s)" ⟨ x ⟩ₑ ⟨ x₁ ⟩ₑ ⟨ [-+comm] x x₁ ⟩ₛ = printf "-+-comm(%s, %s)" ⟨ x ⟩ₑ ⟨ x₁ ⟩ₑ showProof : ∀ {x y} → EqClosure _≈ⁱ_ x y → List String showProof = List.foldr unparse [] ∘ List.foldr spotReverse [] ∘ List.mapMaybe interesting′ ∘ showProof′ where unparse : Explanation Expr → List String → List String unparse (lhs₁ ≈⟨ step₁ ⟩≈ rhs₁) [] = ⟨ lhs₁ ⟩ₑ ∷ printf " ={ %s }" ⟨ step₁ ⟩ₛ ∷ ⟨ rhs₁ ⟩ₑ ∷ [] unparse (lhs₁ ≈⟨ step₁ ⟩≈ rhs₁) (y ∷ ys) = if r EqBool.== y then l ∷ m ∷ y ∷ ys else l ∷ m ∷ r ∷ " ={ eval }" ∷ y ∷ ys where l = ⟨ lhs₁ ⟩ₑ m = printf " ={ %s }" ⟨ step₁ ⟩ₛ r = ⟨ rhs₁ ⟩ₑ spotReverse : Explanation Expr → List (Explanation Expr) → List (Explanation Expr) spotReverse x [] = x ∷ [] spotReverse x (y ∷ xs) = if lhs x EqBool.== rhs y then xs else x ∷ y ∷ xs interesting′ : Explanation Expr → Maybe (Explanation Expr) interesting′ (lhs ≈⟨ stp ⟩≈ rhs) with interesting stp interesting′ (lhs ≈⟨ stp ⟩≈ rhs) | just x = just (lhs ≈⟨ x ⟩≈ rhs) interesting′ (lhs ≈⟨ stp ⟩≈ rhs) | nothing = nothing open import Agda.Builtin.FromString using (IsString; fromString) public import Data.String.Literals open import Data.Unit using (⊤) open import Level using (Lift) instance stringString : IsString String stringString = Data.String.Literals.isString instance lift-inst : ∀ {ℓ a} { A : Set a } → ⦃ x : A ⦄ → Lift ℓ A lift-inst ⦃ x = x ⦄ = Level.lift x instance exprString : IsString Expr exprString = record { Constraint = λ _ → Lift _ ⊤ ; fromString = λ s → O (V s) }
{ "alphanum_fraction": 0.5590494262, "avg_line_length": 40.9888888889, "ext": "agda", "hexsha": "8fd092f813f36980828bab76f24ab7a7fd6e02ac", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-20T07:07:11.000Z", "max_forks_repo_forks_event_min_datetime": "2019-04-16T02:23:16.000Z", "max_forks_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mckeankylej/agda-ring-solver", "max_forks_repo_path": "src/Relation/Traced.agda", "max_issues_count": 5, "max_issues_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_issues_repo_issues_event_max_datetime": "2022-03-12T01:55:42.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-17T20:48:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mckeankylej/agda-ring-solver", "max_issues_repo_path": "src/Relation/Traced.agda", "max_line_length": 133, "max_stars_count": 36, "max_stars_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mckeankylej/agda-ring-solver", "max_stars_repo_path": "src/Relation/Traced.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-15T00:57:55.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-25T16:40:52.000Z", "num_tokens": 4493, "size": 11067 }
module Pi-1 where open import Data.Empty open import Data.Unit open import Data.Product open import Relation.Binary.PropositionalEquality open import Groupoid import Pi-2 as P --infixr 10 _◎_ --infixr 30 _⟷_ ------------------------------------------------------------------------------ -- Level -1: -- Types are -1 groupoids or equivalently all types are mere propositions -- -- Types and values are defined without references to programs -- Types include PATHs from the previous level in addition to the usual types data U : Set where ZERO : U ONE : U TIMES : U → U → U PATH : {t₁ t₂ : P.U•} → (t₁ P.⟷ t₂) → U data Path {t₁ t₂ : P.U•} : P.Space t₁ → P.Space t₂ → Set where path : (c : t₁ P.⟷ t₂) → Path (P.point t₁) (P.point t₂) ⟦_⟧ : U → Set ⟦ ZERO ⟧ = ⊥ ⟦ ONE ⟧ = ⊤ ⟦ TIMES t₁ t₂ ⟧ = ⟦ t₁ ⟧ × ⟦ t₂ ⟧ ⟦ PATH {t₁} {t₂} c ⟧ = Path {t₁} {t₂} (P.point t₁) (P.point t₂) -- Proof that all types are mere propositions. Def. 3.3.1 in the HoTT book isMereProposition : (t : U) → (v v' : ⟦ t ⟧) → (v ≡ v') isMereProposition ZERO () isMereProposition ONE tt tt = refl isMereProposition (TIMES t₁ t₂) (v₁ , v₂) (v₁' , v₂') = cong₂ _,′_ (isMereProposition t₁ v₁ v₁') (isMereProposition t₂ v₂ v₂') isMereProposition (PATH {t₁} {t₂} c) (path c₁) (path c₂) = {!!} -- c₁ : t₁ ⟷ t₂ in Pi-2 -- c₂ : t₁ ⟷ t₂ in Pi-2 -- Proof that every type is a groupoid; this does not depend on the -- definition of programs isGroupoid : U → 1Groupoid isGroupoid ZERO = discrete ⊥ isGroupoid ONE = discrete ⊤ isGroupoid (TIMES t₁ t₂) = isGroupoid t₁ ×G isGroupoid t₂ isGroupoid (PATH {t₁} {t₂} c) = {!!} {-- ------------------------------------------------------------------------------ -- Level -1: -- if types are non-empty they must contain one point only like above -- types may however be empty -- -- We can prove that all types are either empty or equivalent to the unit -- type (i.e., they are mere propositions) module Pi-1 where data U : Set where ZERO : U ONE : U TIMES : U → U → U ⟦_⟧ : U → Set ⟦ ZERO ⟧ = ⊥ ⟦ ONE ⟧ = ⊤ ⟦ TIMES t₁ t₂ ⟧ = ⟦ t₁ ⟧ × ⟦ t₂ ⟧ ------------------------------------------------------------------------------ -- Level 0: -- types may contain any number of points (including none) -- they are sets -- -- We define isomorphisms between these sets that are reified to paths in the -- next level (level 1). These isomorphisms are the combinators for a -- commutative semiring structure which is sound and complete for sets. module Pi0 where infixr 10 _◎_ infixr 30 _⟷_ -- types data U : Set where ZERO : U ONE : U PLUS : U → U → U TIMES : U → U → U -- values ⟦_⟧ : U → Set ⟦ ZERO ⟧ = ⊥ ⟦ ONE ⟧ = ⊤ ⟦ PLUS t₁ t₂ ⟧ = ⟦ t₁ ⟧ ⊎ ⟦ t₂ ⟧ ⟦ TIMES t₁ t₂ ⟧ = ⟦ t₁ ⟧ × ⟦ t₂ ⟧ -- pointed types record U• : Set where constructor •[_,_] field ∣_∣ : U • : ⟦ ∣_∣ ⟧ open U• Space : (t• : U•) → Set Space •[ t , v ] = ⟦ t ⟧ point : (t• : U•) → Space t• point •[ t , v ] = v -- examples ONE• : U• ONE• = •[ ONE , tt ] BOOL : U BOOL = PLUS ONE ONE BOOL² : U BOOL² = TIMES BOOL BOOL TRUE : ⟦ BOOL ⟧ TRUE = inj₁ tt FALSE : ⟦ BOOL ⟧ FALSE = inj₂ tt BOOL•F : U• BOOL•F = •[ BOOL , FALSE ] BOOL•T : U• BOOL•T = •[ BOOL , TRUE ] -- isomorphisms between pointed types data _⟷_ : U• → U• → Set where unite₊ : {t : U•} → •[ PLUS ZERO ∣ t ∣ , inj₂ (• t) ] ⟷ t uniti₊ : {t : U•} → t ⟷ •[ PLUS ZERO ∣ t ∣ , inj₂ (• t) ] swap1₊ : {t₁ t₂ : U•} → •[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₁ (• t₁) ] ⟷ •[ PLUS ∣ t₂ ∣ ∣ t₁ ∣ , inj₂ (• t₁) ] swap2₊ : {t₁ t₂ : U•} → •[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₂ (• t₂) ] ⟷ •[ PLUS ∣ t₂ ∣ ∣ t₁ ∣ , inj₁ (• t₂) ] assocl1₊ : {t₁ t₂ t₃ : U•} → •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁) ] ⟷ •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₁ (• t₁)) ] assocl2₊ : {t₁ t₂ t₃ : U•} → •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₁ (• t₂)) ] ⟷ •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₂ (• t₂)) ] assocl3₊ : {t₁ t₂ t₃ : U•} → •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₂ (• t₃)) ] ⟷ •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₂ (• t₃) ] assocr1₊ : {t₁ t₂ t₃ : U•} → •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₁ (• t₁)) ] ⟷ •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁) ] assocr2₊ : {t₁ t₂ t₃ : U•} → •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₂ (• t₂)) ] ⟷ •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₁ (• t₂)) ] assocr3₊ : {t₁ t₂ t₃ : U•} → •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₂ (• t₃) ] ⟷ •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₂ (• t₃)) ] unite⋆ : {t : U•} → •[ TIMES ONE ∣ t ∣ , (tt , • t) ] ⟷ t uniti⋆ : {t : U•} → t ⟷ •[ TIMES ONE ∣ t ∣ , (tt , • t) ] swap⋆ : {t₁ t₂ : U•} → •[ TIMES ∣ t₁ ∣ ∣ t₂ ∣ , (• t₁ , • t₂) ] ⟷ •[ TIMES ∣ t₂ ∣ ∣ t₁ ∣ , (• t₂ , • t₁) ] assocl⋆ : {t₁ t₂ t₃ : U•} → •[ TIMES ∣ t₁ ∣ (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , (• t₁ , (• t₂ , • t₃)) ] ⟷ •[ TIMES (TIMES ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , ((• t₁ , • t₂) , • t₃) ] assocr⋆ : {t₁ t₂ t₃ : U•} → •[ TIMES (TIMES ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , ((• t₁ , • t₂) , • t₃) ] ⟷ •[ TIMES ∣ t₁ ∣ (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , (• t₁ , (• t₂ , • t₃)) ] distz : {t : U•} {absurd : ⟦ ZERO ⟧} → •[ TIMES ZERO ∣ t ∣ , (absurd , • t) ] ⟷ •[ ZERO , absurd ] factorz : {t : U•} {absurd : ⟦ ZERO ⟧} → •[ ZERO , absurd ] ⟷ •[ TIMES ZERO ∣ t ∣ , (absurd , • t) ] dist1 : {t₁ t₂ t₃ : U•} → •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₁ (• t₁) , • t₃) ] ⟷ •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁ , • t₃) ] dist2 : {t₁ t₂ t₃ : U•} → •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₂ (• t₂) , • t₃) ] ⟷ •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (• t₂ , • t₃) ] factor1 : {t₁ t₂ t₃ : U•} → •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁ , • t₃) ] ⟷ •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₁ (• t₁) , • t₃) ] factor2 : {t₁ t₂ t₃ : U•} → •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (• t₂ , • t₃) ] ⟷ •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₂ (• t₂) , • t₃) ] id⟷ : {t : U•} → t ⟷ t sym⟷ : {t₁ t₂ : U•} → (t₁ ⟷ t₂) → (t₂ ⟷ t₁) _◎_ : {t₁ t₂ t₃ : U•} → (t₁ ⟷ t₂) → (t₂ ⟷ t₃) → (t₁ ⟷ t₃) _⊕1_ : {t₁ t₂ t₃ t₄ : U•} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (•[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₁ (• t₁) ] ⟷ •[ PLUS ∣ t₃ ∣ ∣ t₄ ∣ , inj₁ (• t₃) ]) _⊕2_ : {t₁ t₂ t₃ t₄ : U•} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (•[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₂ (• t₂) ] ⟷ •[ PLUS ∣ t₃ ∣ ∣ t₄ ∣ , inj₂ (• t₄) ]) _⊗_ : {t₁ t₂ t₃ t₄ : U•} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (•[ TIMES ∣ t₁ ∣ ∣ t₂ ∣ , (• t₁ , • t₂ ) ] ⟷ •[ TIMES ∣ t₃ ∣ ∣ t₄ ∣ , (• t₃ , • t₄ ) ]) -- examples NOT•T : •[ BOOL , TRUE ] ⟷ •[ BOOL , FALSE ] NOT•T = swap1₊ NOT•F : •[ BOOL , FALSE ] ⟷ •[ BOOL , TRUE ] NOT•F = swap2₊ CNOT•Fx : {b : ⟦ BOOL ⟧} → •[ BOOL² , (FALSE , b) ] ⟷ •[ BOOL² , (FALSE , b) ] CNOT•Fx = dist2 ◎ ((id⟷ ⊗ NOT•F) ⊕2 id⟷) ◎ factor2 CNOT•TF : •[ BOOL² , (TRUE , FALSE) ] ⟷ •[ BOOL² , (TRUE , TRUE) ] CNOT•TF = dist1 ◎ ((id⟷ ⊗ NOT•F) ⊕1 (id⟷ {•[ TIMES ONE BOOL , (tt , FALSE) ]})) ◎ factor1 CNOT•TT : •[ BOOL² , (TRUE , TRUE) ] ⟷ •[ BOOL² , (TRUE , FALSE) ] CNOT•TT = dist1 ◎ ((id⟷ ⊗ NOT•T) ⊕1 (id⟷ {•[ TIMES ONE BOOL , (tt , TRUE) ]})) ◎ factor1 ------------------------------------------------------------------------------ -- Level 1 -- types are 1groupoids; they consist of points with collections of -- non-trivial paths between them; the paths are defined at the previous -- level (level 0). -- -- We define isomorphisms between these level 1 paths that are reified as -- 2paths in the next level (level 2). These isomorphisms include groupoid -- combinators and commutative semiring combinators module Pi1 where infixr 10 _◎_ infixr 30 _⟷_ -- types data U : Set where ZERO : U ONE : U PLUS : U → U → U TIMES : U → U → U PATH : {t₁ t₂ : Pi0.U•} → (t₁ Pi0.⟷ t₂) → U -- values data Path {t₁ t₂ : Pi0.U•} : (Pi0.Space t₁) → (Pi0.Space t₂) → Set where path : (c : t₁ Pi0.⟷ t₂) → Path (Pi0.point t₁) (Pi0.point t₂) ⟦_⟧ : U → Set ⟦ ZERO ⟧ = ⊥ ⟦ ONE ⟧ = ⊤ ⟦ PLUS t₁ t₂ ⟧ = ⟦ t₁ ⟧ ⊎ ⟦ t₂ ⟧ ⟦ TIMES t₁ t₂ ⟧ = ⟦ t₁ ⟧ × ⟦ t₂ ⟧ ⟦ PATH {t₁} {t₂} c ⟧ = Path {t₁} {t₂} (Pi0.point t₁) (Pi0.point t₂) -- pointed types record U• : Set where constructor •[_,_] field ∣_∣ : U • : ⟦ ∣_∣ ⟧ open U• Space : (t• : U•) → Set Space •[ t , p ] = ⟦ t ⟧ point : (t• : U•) → Space t• point •[ t , p ] = p _∘_ : {t₁ t₂ t₃ : Pi0.U•} → Path (Pi0.point t₁) (Pi0.point t₂) → Path (Pi0.point t₂) (Pi0.point t₃) → Path (Pi0.point t₁) (Pi0.point t₃) path c₁ ∘ path c₂ = path (c₁ Pi0.◎ c₂) PathSpace : {t₁ t₂ : Pi0.U•} → (c : t₁ Pi0.⟷ t₂) → U• PathSpace c = •[ PATH c , path c ] -- examples -- several paths between T and F; some of these will be equivalent p₁ p₂ p₃ p₄ : Path Pi0.TRUE Pi0.FALSE p₁ = path Pi0.swap1₊ p₂ = path (Pi0.swap1₊ Pi0.◎ Pi0.id⟷) p₃ = path (Pi0.swap1₊ Pi0.◎ Pi0.swap2₊ Pi0.◎ Pi0.swap1₊) p₄ = path (Pi0.uniti⋆ Pi0.◎ Pi0.swap⋆ Pi0.◎ (Pi0.swap1₊ Pi0.⊗ Pi0.id⟷) Pi0.◎ Pi0.swap⋆ Pi0.◎ Pi0.unite⋆) -- groupoid combinators to reason about id, sym, and trans -- commutative semiring combinators for 0, 1, +, * data _⟷_ : U• → U• → Set where -- common combinators id⟷ : {t : U•} → t ⟷ t sym⟷ : {t₁ t₂ : U•} → (t₁ ⟷ t₂) → (t₂ ⟷ t₁) _◎_ : {t₁ t₂ t₃ : U•} → (t₁ ⟷ t₂) → (t₂ ⟷ t₃) → (t₁ ⟷ t₃) -- groupoid combinators lidl : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (Pi0.id⟷ Pi0.◎ c) ⟷ PathSpace c lidr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace c ⟷ PathSpace (Pi0.id⟷ Pi0.◎ c) ridl : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (c Pi0.◎ Pi0.id⟷) ⟷ PathSpace c ridr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace c ⟷ PathSpace (c Pi0.◎ Pi0.id⟷) invll : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (Pi0.sym⟷ c Pi0.◎ c) ⟷ PathSpace {t₂} {t₂} Pi0.id⟷ invlr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace {t₂} {t₂} Pi0.id⟷ ⟷ PathSpace (Pi0.sym⟷ c Pi0.◎ c) invrl : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (c Pi0.◎ Pi0.sym⟷ c) ⟷ PathSpace {t₁} {t₁} Pi0.id⟷ invrr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace {t₁} {t₁} Pi0.id⟷ ⟷ PathSpace (c Pi0.◎ Pi0.sym⟷ c) invinvl : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (Pi0.sym⟷ (Pi0.sym⟷ c)) ⟷ PathSpace c invinvr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace c ⟷ PathSpace (Pi0.sym⟷ (Pi0.sym⟷ c)) tassocl : {t₁ t₂ t₃ t₄ : Pi0.U•} {c₁ : t₁ Pi0.⟷ t₂} {c₂ : t₂ Pi0.⟷ t₃} {c₃ : t₃ Pi0.⟷ t₄} → PathSpace (c₁ Pi0.◎ (c₂ Pi0.◎ c₃)) ⟷ PathSpace ((c₁ Pi0.◎ c₂) Pi0.◎ c₃) tassocr : {t₁ t₂ t₃ t₄ : Pi0.U•} {c₁ : t₁ Pi0.⟷ t₂} {c₂ : t₂ Pi0.⟷ t₃} {c₃ : t₃ Pi0.⟷ t₄} → PathSpace ((c₁ Pi0.◎ c₂) Pi0.◎ c₃) ⟷ PathSpace (c₁ Pi0.◎ (c₂ Pi0.◎ c₃)) -- resp◎ is closely related to Eckmann-Hilton resp◎ : {t₁ t₂ t₃ : Pi0.U•} {c₁ : t₁ Pi0.⟷ t₂} {c₂ : t₂ Pi0.⟷ t₃} {c₃ : t₁ Pi0.⟷ t₂} {c₄ : t₂ Pi0.⟷ t₃} → (PathSpace c₁ ⟷ PathSpace c₃) → (PathSpace c₂ ⟷ PathSpace c₄) → PathSpace (c₁ Pi0.◎ c₂) ⟷ PathSpace (c₃ Pi0.◎ c₄) -- commutative semiring combinators unite₊ : {t : U•} → •[ PLUS ZERO ∣ t ∣ , inj₂ (• t) ] ⟷ t uniti₊ : {t : U•} → t ⟷ •[ PLUS ZERO ∣ t ∣ , inj₂ (• t) ] swap1₊ : {t₁ t₂ : U•} → •[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₁ (• t₁) ] ⟷ •[ PLUS ∣ t₂ ∣ ∣ t₁ ∣ , inj₂ (• t₁) ] swap2₊ : {t₁ t₂ : U•} → •[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₂ (• t₂) ] ⟷ •[ PLUS ∣ t₂ ∣ ∣ t₁ ∣ , inj₁ (• t₂) ] assocl1₊ : {t₁ t₂ t₃ : U•} → •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁) ] ⟷ •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₁ (• t₁)) ] assocl2₊ : {t₁ t₂ t₃ : U•} → •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₁ (• t₂)) ] ⟷ •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₂ (• t₂)) ] assocl3₊ : {t₁ t₂ t₃ : U•} → •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₂ (• t₃)) ] ⟷ •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₂ (• t₃) ] assocr1₊ : {t₁ t₂ t₃ : U•} → •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₁ (• t₁)) ] ⟷ •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁) ] assocr2₊ : {t₁ t₂ t₃ : U•} → •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₂ (• t₂)) ] ⟷ •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₁ (• t₂)) ] assocr3₊ : {t₁ t₂ t₃ : U•} → •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₂ (• t₃) ] ⟷ •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₂ (• t₃)) ] unite⋆ : {t : U•} → •[ TIMES ONE ∣ t ∣ , (tt , • t) ] ⟷ t uniti⋆ : {t : U•} → t ⟷ •[ TIMES ONE ∣ t ∣ , (tt , • t) ] swap⋆ : {t₁ t₂ : U•} → •[ TIMES ∣ t₁ ∣ ∣ t₂ ∣ , (• t₁ , • t₂) ] ⟷ •[ TIMES ∣ t₂ ∣ ∣ t₁ ∣ , (• t₂ , • t₁) ] assocl⋆ : {t₁ t₂ t₃ : U•} → •[ TIMES ∣ t₁ ∣ (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , (• t₁ , (• t₂ , • t₃)) ] ⟷ •[ TIMES (TIMES ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , ((• t₁ , • t₂) , • t₃) ] assocr⋆ : {t₁ t₂ t₃ : U•} → •[ TIMES (TIMES ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , ((• t₁ , • t₂) , • t₃) ] ⟷ •[ TIMES ∣ t₁ ∣ (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , (• t₁ , (• t₂ , • t₃)) ] distz : {t : U•} {absurd : ⟦ ZERO ⟧} → •[ TIMES ZERO ∣ t ∣ , (absurd , • t) ] ⟷ •[ ZERO , absurd ] factorz : {t : U•} {absurd : ⟦ ZERO ⟧} → •[ ZERO , absurd ] ⟷ •[ TIMES ZERO ∣ t ∣ , (absurd , • t) ] dist1 : {t₁ t₂ t₃ : U•} → •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₁ (• t₁) , • t₃) ] ⟷ •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁ , • t₃) ] dist2 : {t₁ t₂ t₃ : U•} → •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₂ (• t₂) , • t₃) ] ⟷ •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (• t₂ , • t₃) ] factor1 : {t₁ t₂ t₃ : U•} → •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁ , • t₃) ] ⟷ •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₁ (• t₁) , • t₃) ] factor2 : {t₁ t₂ t₃ : U•} → •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (• t₂ , • t₃) ] ⟷ •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₂ (• t₂) , • t₃) ] _⊕1_ : {t₁ t₂ t₃ t₄ : U•} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (•[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₁ (• t₁) ] ⟷ •[ PLUS ∣ t₃ ∣ ∣ t₄ ∣ , inj₁ (• t₃) ]) _⊕2_ : {t₁ t₂ t₃ t₄ : U•} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (•[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₂ (• t₂) ] ⟷ •[ PLUS ∣ t₃ ∣ ∣ t₄ ∣ , inj₂ (• t₄) ]) _⊗_ : {t₁ t₂ t₃ t₄ : U•} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (•[ TIMES ∣ t₁ ∣ ∣ t₂ ∣ , (• t₁ , • t₂ ) ] ⟷ •[ TIMES ∣ t₃ ∣ ∣ t₄ ∣ , (• t₃ , • t₄ ) ]) -- proof that we have a 1Groupoid structure G : 1Groupoid G = record { set = Pi0.U• ; _↝_ = Pi0._⟷_ ; _≈_ = λ c₀ c₁ → PathSpace c₀ ⟷ PathSpace c₁ ; id = Pi0.id⟷ ; _∘_ = λ c₀ c₁ → c₁ Pi0.◎ c₀ ; _⁻¹ = Pi0.sym⟷ ; lneutr = λ _ → ridl ; rneutr = λ _ → lidl ; assoc = λ _ _ _ → tassocl ; equiv = record { refl = id⟷ ; sym = λ c → sym⟷ c ; trans = λ c₀ c₁ → c₀ ◎ c₁ } ; linv = λ _ → invrl ; rinv = λ _ → invll ; ∘-resp-≈ = λ f⟷h g⟷i → resp◎ g⟷i f⟷h } ------------------------------------------------------------------------------ -- Level 2 -- types are 2groupoids; they are points with non-trivial paths between them -- and non-trivial 2paths between the paths module Pi2 where infixr 10 _◎_ infixr 30 _⟷_ -- types data U : Set where ZERO : U ONE : U PLUS : U → U → U TIMES : U → U → U PATH : {t₁ t₂ : Pi0.U•} → (t₁ Pi0.⟷ t₂) → U 2PATH : {t₁ t₂ : Pi1.U•} → (t₁ Pi1.⟷ t₂) → U -- values data Path {t₁ t₂ : Pi0.U•} : (Pi0.Space t₁) → (Pi0.Space t₂) → Set where path : (c : t₁ Pi0.⟷ t₂) → Path (Pi0.point t₁) (Pi0.point t₂) data 2Path {t₁ t₂ : Pi1.U•} : Pi1.Space t₁ → Pi1.Space t₂ → Set where 2path : (c : t₁ Pi1.⟷ t₂) → 2Path (Pi1.point t₁) (Pi1.point t₂) ⟦_⟧ : U → Set ⟦ ZERO ⟧ = ⊥ ⟦ ONE ⟧ = ⊤ ⟦ PLUS t₁ t₂ ⟧ = ⟦ t₁ ⟧ ⊎ ⟦ t₂ ⟧ ⟦ TIMES t₁ t₂ ⟧ = ⟦ t₁ ⟧ × ⟦ t₂ ⟧ ⟦ PATH {t₁} {t₂} c ⟧ = Path {t₁} {t₂} (Pi0.point t₁) (Pi0.point t₂) ⟦ 2PATH {t₁} {t₂} c ⟧ = 2Path {t₁} {t₂} (Pi1.point t₁) (Pi1.point t₂) -- pointed types record U• : Set where constructor •[_,_] field ∣_∣ : U • : ⟦ ∣_∣ ⟧ open U• Space : (t• : U•) → Set Space •[ t , p ] = ⟦ t ⟧ point : (t• : U•) → Space t• point •[ t , p ] = p _∘1_ : {t₁ t₂ t₃ : Pi0.U•} → Path (Pi0.point t₁) (Pi0.point t₂) → Path (Pi0.point t₂) (Pi0.point t₃) → Path (Pi0.point t₁) (Pi0.point t₃) path c₁ ∘1 path c₂ = path (c₁ Pi0.◎ c₂) _∘2_ : {t₁ t₂ t₃ : Pi1.U•} → 2Path (Pi1.point t₁) (Pi1.point t₂) → 2Path (Pi1.point t₂) (Pi1.point t₃) → 2Path (Pi1.point t₁) (Pi1.point t₃) 2path c₁ ∘2 2path c₂ = 2path (c₁ Pi1.◎ c₂) PathSpace : {t₁ t₂ : Pi0.U•} → (c : t₁ Pi0.⟷ t₂) → U• PathSpace c = •[ PATH c , path c ] 2PathSpace : {t₁ t₂ : Pi1.U•} → (c : t₁ Pi1.⟷ t₂) → U• 2PathSpace c = •[ 2PATH c , 2path c ] -- examples -- groupoid combinators to reason about id, sym, and trans -- commutative semiring combinators for 0, 1, +, * data _⟷_ : U• → U• → Set where -- common combinators id⟷ : {t : U•} → t ⟷ t sym⟷ : {t₁ t₂ : U•} → (t₁ ⟷ t₂) → (t₂ ⟷ t₁) _◎_ : {t₁ t₂ t₃ : U•} → (t₁ ⟷ t₂) → (t₂ ⟷ t₃) → (t₁ ⟷ t₃) -- 1groupoid combinators 1lidl : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (Pi0.id⟷ Pi0.◎ c) ⟷ PathSpace c 1lidr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace c ⟷ PathSpace (Pi0.id⟷ Pi0.◎ c) 1ridl : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (c Pi0.◎ Pi0.id⟷) ⟷ PathSpace c 1ridr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace c ⟷ PathSpace (c Pi0.◎ Pi0.id⟷) 1invll : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (Pi0.sym⟷ c Pi0.◎ c) ⟷ PathSpace {t₂} {t₂} Pi0.id⟷ 1invlr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace {t₂} {t₂} Pi0.id⟷ ⟷ PathSpace (Pi0.sym⟷ c Pi0.◎ c) 1invrl : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (c Pi0.◎ Pi0.sym⟷ c) ⟷ PathSpace {t₁} {t₁} Pi0.id⟷ 1invrr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace {t₁} {t₁} Pi0.id⟷ ⟷ PathSpace (c Pi0.◎ Pi0.sym⟷ c) 1invinvl : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (Pi0.sym⟷ (Pi0.sym⟷ c)) ⟷ PathSpace c 1invinvr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace c ⟷ PathSpace (Pi0.sym⟷ (Pi0.sym⟷ c)) 1tassocl : {t₁ t₂ t₃ t₄ : Pi0.U•} {c₁ : t₁ Pi0.⟷ t₂} {c₂ : t₂ Pi0.⟷ t₃} {c₃ : t₃ Pi0.⟷ t₄} → PathSpace (c₁ Pi0.◎ (c₂ Pi0.◎ c₃)) ⟷ PathSpace ((c₁ Pi0.◎ c₂) Pi0.◎ c₃) 1tassocr : {t₁ t₂ t₃ t₄ : Pi0.U•} {c₁ : t₁ Pi0.⟷ t₂} {c₂ : t₂ Pi0.⟷ t₃} {c₃ : t₃ Pi0.⟷ t₄} → PathSpace ((c₁ Pi0.◎ c₂) Pi0.◎ c₃) ⟷ PathSpace (c₁ Pi0.◎ (c₂ Pi0.◎ c₃)) -- resp◎ is closely related to Eckmann-Hilton 1resp◎ : {t₁ t₂ t₃ : Pi0.U•} {c₁ : t₁ Pi0.⟷ t₂} {c₂ : t₂ Pi0.⟷ t₃} {c₃ : t₁ Pi0.⟷ t₂} {c₄ : t₂ Pi0.⟷ t₃} → (PathSpace c₁ ⟷ PathSpace c₃) → (PathSpace c₂ ⟷ PathSpace c₄) → PathSpace (c₁ Pi0.◎ c₂) ⟷ PathSpace (c₃ Pi0.◎ c₄) -- 2groupoid combinators lidl : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace (Pi1.id⟷ Pi1.◎ c) ⟷ 2PathSpace c lidr : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace c ⟷ 2PathSpace (Pi1.id⟷ Pi1.◎ c) ridl : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace (c Pi1.◎ Pi1.id⟷) ⟷ 2PathSpace c ridr : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace c ⟷ 2PathSpace (c Pi1.◎ Pi1.id⟷) invll : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace (Pi1.sym⟷ c Pi1.◎ c) ⟷ 2PathSpace {t₂} {t₂} Pi1.id⟷ invlr : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace {t₂} {t₂} Pi1.id⟷ ⟷ 2PathSpace (Pi1.sym⟷ c Pi1.◎ c) invrl : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace (c Pi1.◎ Pi1.sym⟷ c) ⟷ 2PathSpace {t₁} {t₁} Pi1.id⟷ invrr : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace {t₁} {t₁} Pi1.id⟷ ⟷ 2PathSpace (c Pi1.◎ Pi1.sym⟷ c) invinvl : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace (Pi1.sym⟷ (Pi1.sym⟷ c)) ⟷ 2PathSpace c invinvr : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace c ⟷ 2PathSpace (Pi1.sym⟷ (Pi1.sym⟷ c)) tassocl : {t₁ t₂ t₃ t₄ : Pi1.U•} {c₁ : t₁ Pi1.⟷ t₂} {c₂ : t₂ Pi1.⟷ t₃} {c₃ : t₃ Pi1.⟷ t₄} → 2PathSpace (c₁ Pi1.◎ (c₂ Pi1.◎ c₃)) ⟷ 2PathSpace ((c₁ Pi1.◎ c₂) Pi1.◎ c₃) tassocr : {t₁ t₂ t₃ t₄ : Pi1.U•} {c₁ : t₁ Pi1.⟷ t₂} {c₂ : t₂ Pi1.⟷ t₃} {c₃ : t₃ Pi1.⟷ t₄} → 2PathSpace ((c₁ Pi1.◎ c₂) Pi1.◎ c₃) ⟷ 2PathSpace (c₁ Pi1.◎ (c₂ Pi1.◎ c₃)) -- resp◎ is closely related to Eckmann-Hilton resp◎ : {t₁ t₂ t₃ : Pi1.U•} {c₁ : t₁ Pi1.⟷ t₂} {c₂ : t₂ Pi1.⟷ t₃} {c₃ : t₁ Pi1.⟷ t₂} {c₄ : t₂ Pi1.⟷ t₃} → (2PathSpace c₁ ⟷ 2PathSpace c₃) → (2PathSpace c₂ ⟷ 2PathSpace c₄) → 2PathSpace (c₁ Pi1.◎ c₂) ⟷ 2PathSpace (c₃ Pi1.◎ c₄) -- commutative semiring combinators unite₊ : {t : U•} → •[ PLUS ZERO ∣ t ∣ , inj₂ (• t) ] ⟷ t uniti₊ : {t : U•} → t ⟷ •[ PLUS ZERO ∣ t ∣ , inj₂ (• t) ] swap1₊ : {t₁ t₂ : U•} → •[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₁ (• t₁) ] ⟷ •[ PLUS ∣ t₂ ∣ ∣ t₁ ∣ , inj₂ (• t₁) ] swap2₊ : {t₁ t₂ : U•} → •[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₂ (• t₂) ] ⟷ •[ PLUS ∣ t₂ ∣ ∣ t₁ ∣ , inj₁ (• t₂) ] assocl1₊ : {t₁ t₂ t₃ : U•} → •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁) ] ⟷ •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₁ (• t₁)) ] assocl2₊ : {t₁ t₂ t₃ : U•} → •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₁ (• t₂)) ] ⟷ •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₂ (• t₂)) ] assocl3₊ : {t₁ t₂ t₃ : U•} → •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₂ (• t₃)) ] ⟷ •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₂ (• t₃) ] assocr1₊ : {t₁ t₂ t₃ : U•} → •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₁ (• t₁)) ] ⟷ •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁) ] assocr2₊ : {t₁ t₂ t₃ : U•} → •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₂ (• t₂)) ] ⟷ •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₁ (• t₂)) ] assocr3₊ : {t₁ t₂ t₃ : U•} → •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₂ (• t₃) ] ⟷ •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₂ (• t₃)) ] unite⋆ : {t : U•} → •[ TIMES ONE ∣ t ∣ , (tt , • t) ] ⟷ t uniti⋆ : {t : U•} → t ⟷ •[ TIMES ONE ∣ t ∣ , (tt , • t) ] swap⋆ : {t₁ t₂ : U•} → •[ TIMES ∣ t₁ ∣ ∣ t₂ ∣ , (• t₁ , • t₂) ] ⟷ •[ TIMES ∣ t₂ ∣ ∣ t₁ ∣ , (• t₂ , • t₁) ] assocl⋆ : {t₁ t₂ t₃ : U•} → •[ TIMES ∣ t₁ ∣ (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , (• t₁ , (• t₂ , • t₃)) ] ⟷ •[ TIMES (TIMES ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , ((• t₁ , • t₂) , • t₃) ] assocr⋆ : {t₁ t₂ t₃ : U•} → •[ TIMES (TIMES ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , ((• t₁ , • t₂) , • t₃) ] ⟷ •[ TIMES ∣ t₁ ∣ (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , (• t₁ , (• t₂ , • t₃)) ] distz : {t : U•} {absurd : ⟦ ZERO ⟧} → •[ TIMES ZERO ∣ t ∣ , (absurd , • t) ] ⟷ •[ ZERO , absurd ] factorz : {t : U•} {absurd : ⟦ ZERO ⟧} → •[ ZERO , absurd ] ⟷ •[ TIMES ZERO ∣ t ∣ , (absurd , • t) ] dist1 : {t₁ t₂ t₃ : U•} → •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₁ (• t₁) , • t₃) ] ⟷ •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁ , • t₃) ] dist2 : {t₁ t₂ t₃ : U•} → •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₂ (• t₂) , • t₃) ] ⟷ •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (• t₂ , • t₃) ] factor1 : {t₁ t₂ t₃ : U•} → •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁ , • t₃) ] ⟷ •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₁ (• t₁) , • t₃) ] factor2 : {t₁ t₂ t₃ : U•} → •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (• t₂ , • t₃) ] ⟷ •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₂ (• t₂) , • t₃) ] _⊕1_ : {t₁ t₂ t₃ t₄ : U•} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (•[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₁ (• t₁) ] ⟷ •[ PLUS ∣ t₃ ∣ ∣ t₄ ∣ , inj₁ (• t₃) ]) _⊕2_ : {t₁ t₂ t₃ t₄ : U•} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (•[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₂ (• t₂) ] ⟷ •[ PLUS ∣ t₃ ∣ ∣ t₄ ∣ , inj₂ (• t₄) ]) _⊗_ : {t₁ t₂ t₃ t₄ : U•} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (•[ TIMES ∣ t₁ ∣ ∣ t₂ ∣ , (• t₁ , • t₂ ) ] ⟷ •[ TIMES ∣ t₃ ∣ ∣ t₄ ∣ , (• t₃ , • t₄ ) ]) -- proof that we have a 2Groupoid structure; this is 1Groupoid whose -- equivalences are themselves a 1Groupoid G : 1Groupoid G = record { set = Pi1.U• ; _↝_ = Pi1._⟷_ ; _≈_ = λ c₀ c₁ → 2PathSpace c₀ ⟷ 2PathSpace c₁ ; id = Pi1.id⟷ ; _∘_ = λ c₀ c₁ → c₁ Pi1.◎ c₀ ; _⁻¹ = Pi1.sym⟷ ; lneutr = λ _ → ridl ; rneutr = λ _ → lidl ; assoc = λ _ _ _ → tassocl ; equiv = record { refl = id⟷ ; sym = λ c → sym⟷ c ; trans = λ c₀ c₁ → c₀ ◎ c₁ } ; linv = λ _ → invrl ; rinv = λ _ → invll ; ∘-resp-≈ = λ f⟷h g⟷i → resp◎ g⟷i f⟷h } -- examples ------------------------------------------------------------------------------ --}
{ "alphanum_fraction": 0.40714596, "avg_line_length": 39.3504273504, "ext": "agda", "hexsha": "186017cce6aca0f27d43cb2fe517ce1782c5cba2", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/PiWithLevels/Pi-1.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/PiWithLevels/Pi-1.agda", "max_line_length": 78, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/PiWithLevels/Pi-1.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 13479, "size": 27624 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import cohomology.ChainComplex open import cohomology.Theory open import groups.KernelImage open import cw.CW module cw.cohomology.ReconstructedZerothCohomologyGroup {i : ULevel} (OT : OrdinaryTheory i) where open OrdinaryTheory OT import cw.cohomology.TipCoboundary OT as TC import cw.cohomology.TipAndAugment OT as TAA open import cw.cohomology.Descending OT open import cw.cohomology.ReconstructedCochainComplex OT import cw.cohomology.ZerothCohomologyGroup OT as ZCG import cw.cohomology.ZerothCohomologyGroupOnDiag OT as ZCGD private ≤-dec-has-all-paths : {m n : ℕ} → has-all-paths (Dec (m ≤ n)) ≤-dec-has-all-paths = prop-has-all-paths (Dec-level ≤-is-prop) private abstract zeroth-cohomology-group-descend : ∀ {n} (⊙skel : ⊙Skeleton {i} (2 + n)) → cohomology-group (cochain-complex ⊙skel) 0 == cohomology-group (cochain-complex (⊙cw-init ⊙skel)) 0 zeroth-cohomology-group-descend {n = O} ⊙skel = ap (λ δ → Ker/Im δ (TAA.cw-coε (⊙cw-take (lteSR lteS) ⊙skel)) (TAA.C2×CX₀-is-abelian (⊙cw-take (lteSR lteS) ⊙skel) 0)) (coboundary-first-template-descend-from-two ⊙skel) zeroth-cohomology-group-descend {n = S n} ⊙skel = ap (λ δ → Ker/Im δ (TAA.cw-coε (⊙cw-take (inr (O<S (2 + n))) ⊙skel)) (TAA.C2×CX₀-is-abelian (⊙cw-take (inr (O<S (2 + n))) ⊙skel) 0)) (coboundary-first-template-descend-from-far ⊙skel (O<S (1 + n)) (<-+-l 1 (O<S n))) zeroth-cohomology-group-β : ∀ (⊙skel : ⊙Skeleton {i} 1) → cohomology-group (cochain-complex ⊙skel) 0 == Ker/Im (TC.cw-co∂-head ⊙skel) (TAA.cw-coε (⊙cw-init ⊙skel)) (TAA.C2×CX₀-is-abelian (⊙cw-init ⊙skel) 0) zeroth-cohomology-group-β ⊙skel = ap (λ δ → Ker/Im δ (TAA.cw-coε (⊙cw-init ⊙skel)) (TAA.C2×CX₀-is-abelian (⊙cw-init ⊙skel) 0)) (coboundary-first-template-β ⊙skel) abstract zeroth-cohomology-group : ∀ {n} (⊙skel : ⊙Skeleton {i} n) → ⊙has-cells-with-choice 0 ⊙skel i → C 0 ⊙⟦ ⊙skel ⟧ ≃ᴳ cohomology-group (cochain-complex ⊙skel) 0 zeroth-cohomology-group {n = 0} ⊙skel ac = ZCGD.C-cw-iso-ker/im ⊙skel ac zeroth-cohomology-group {n = 1} ⊙skel ac = coe!ᴳ-iso (zeroth-cohomology-group-β ⊙skel) ∘eᴳ ZCG.C-cw-iso-ker/im ⊙skel ac zeroth-cohomology-group {n = S (S n)} ⊙skel ac = coe!ᴳ-iso (zeroth-cohomology-group-descend ⊙skel) ∘eᴳ zeroth-cohomology-group (⊙cw-init ⊙skel) (⊙init-has-cells-with-choice ⊙skel ac) ∘eᴳ C-cw-descend-at-lower ⊙skel (O<S n) ac
{ "alphanum_fraction": 0.6090775988, "avg_line_length": 42.0307692308, "ext": "agda", "hexsha": "d75b2da861d0566983bbf4afdd302b90fa55df2f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "theorems/cw/cohomology/ReconstructedZerothCohomologyGroup.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "theorems/cw/cohomology/ReconstructedZerothCohomologyGroup.agda", "max_line_length": 98, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "theorems/cw/cohomology/ReconstructedZerothCohomologyGroup.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1059, "size": 2732 }
{-# OPTIONS --prop --without-K --rewriting #-} module Calf.Types.Sum where open import Calf.Prelude open import Calf.Metalanguage open import Data.Sum using (_⊎_; inj₁; inj₂) public sum : tp pos → tp pos → tp pos sum A B = U (meta (val A ⊎ val B)) sum/case : ∀ A B (X : val (sum A B) → tp neg) → (s : val (sum A B)) → ((a : val A) → cmp (X (inj₁ a))) → ((b : val B) → cmp (X (inj₂ b))) → cmp (X s) sum/case A B X (inj₁ x) b₁ _ = b₁ x sum/case A B X (inj₂ x) _ b₂ = b₂ x
{ "alphanum_fraction": 0.5849056604, "avg_line_length": 29.8125, "ext": "agda", "hexsha": "6df17093b7747ebf761f4dddd8bc1ffab6a9f2d1", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z", "max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "jonsterling/agda-calf", "max_forks_repo_path": "src/Calf/Types/Sum.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "jonsterling/agda-calf", "max_issues_repo_path": "src/Calf/Types/Sum.agda", "max_line_length": 149, "max_stars_count": 29, "max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "jonsterling/agda-calf", "max_stars_repo_path": "src/Calf/Types/Sum.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z", "num_tokens": 189, "size": 477 }
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.FiniteMultiset.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.HITs.FiniteMultiset.Base private variable A : Type₀ infixr 30 _++_ _++_ : ∀ (xs ys : FMSet A) → FMSet A [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ xs ++ ys comm x y xs i ++ ys = comm x y (xs ++ ys) i trunc xs zs p q i j ++ ys = trunc (xs ++ ys) (zs ++ ys) (cong (_++ ys) p) (cong (_++ ys) q) i j unitl-++ : ∀ (xs : FMSet A) → [] ++ xs ≡ xs unitl-++ xs = refl unitr-++ : ∀ (xs : FMSet A) → xs ++ [] ≡ xs unitr-++ = FMSetElimProp.f (trunc _ _) refl (λ x p → cong (_∷_ x) p) assoc-++ : ∀ (xs ys zs : FMSet A) → xs ++ (ys ++ zs) ≡ (xs ++ ys) ++ zs assoc-++ = FMSetElimProp.f (propPi (λ _ → propPi (λ _ → trunc _ _))) (λ ys zs → refl) (λ x p ys zs → cong (_∷_ x) (p ys zs)) cons-++ : ∀ (x : A) (xs : FMSet A) → x ∷ xs ≡ xs ++ [ x ] cons-++ x = FMSetElimProp.f (trunc _ _) refl (λ y {xs} p → comm x y xs ∙ cong (_∷_ y) p) comm-++ : ∀ (xs ys : FMSet A) → xs ++ ys ≡ ys ++ xs comm-++ = FMSetElimProp.f (propPi (λ _ → trunc _ _)) (λ ys → sym (unitr-++ ys)) (λ x {xs} p ys → cong (x ∷_) (p ys) ∙ cong (_++ xs) (cons-++ x ys) ∙ sym (assoc-++ ys [ x ] xs)) module FMSetUniversal {ℓ} {M : Type ℓ} (MSet : isSet M) (e : M) (_⊗_ : M → M → M) (comm-⊗ : ∀ x y → x ⊗ y ≡ y ⊗ x) (assoc-⊗ : ∀ x y z → x ⊗ (y ⊗ z) ≡ (x ⊗ y) ⊗ z) (unit-⊗ : ∀ x → e ⊗ x ≡ x) (f : A → M) where f-extend : FMSet A → M f-extend = FMSetRec.f MSet e (λ x m → f x ⊗ m) (λ x y m → comm-⊗ (f x) (f y ⊗ m) ∙ sym (assoc-⊗ (f y) m (f x)) ∙ cong (f y ⊗_) (comm-⊗ m (f x))) f-extend-nil : f-extend [] ≡ e f-extend-nil = refl f-extend-cons : ∀ x xs → f-extend (x ∷ xs) ≡ f x ⊗ f-extend xs f-extend-cons x xs = refl f-extend-sing : ∀ x → f-extend [ x ] ≡ f x f-extend-sing x = comm-⊗ (f x) e ∙ unit-⊗ (f x) f-extend-++ : ∀ xs ys → f-extend (xs ++ ys) ≡ f-extend xs ⊗ f-extend ys f-extend-++ = FMSetElimProp.f (propPi λ _ → MSet _ _) (λ ys → sym (unit-⊗ (f-extend ys))) (λ x {xs} p ys → cong (f x ⊗_) (p ys) ∙ assoc-⊗ (f x) (f-extend xs) (f-extend ys)) module _ (h : FMSet A → M) (h-nil : h [] ≡ e) (h-sing : ∀ x → h [ x ] ≡ f x) (h-++ : ∀ xs ys → h (xs ++ ys) ≡ h xs ⊗ h ys) where f-extend-unique : h ≡ f-extend f-extend-unique = funExt (FMSetElimProp.f (MSet _ _) h-nil (λ x {xs} p → (h-++ [ x ] xs) ∙ cong (_⊗ h xs) (h-sing x) ∙ cong (f x ⊗_) p))
{ "alphanum_fraction": 0.486202876, "avg_line_length": 32.9871794872, "ext": "agda", "hexsha": "b9f6f14863e3c6d434f9b613edc58d74814dd532", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/HITs/FiniteMultiset/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_path": "Cubical/HITs/FiniteMultiset/Properties.agda", "max_line_length": 107, "max_stars_count": null, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/HITs/FiniteMultiset/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1122, "size": 2573 }
{-# OPTIONS --allow-unsolved-metas #-} data C (A : Set) : Set where c : (x : A) → C A data D : Set where data E (A : Set) : Set where e : A → E A postulate F : {A : Set} → A → Set G : {A : Set} → C A → Set G (c x) = E (F x) postulate H : {A : Set} → (A → Set) → C A → Set f : {A : Set} {P : A → Set} {y : C A} → H P y → (x : A) → G y → P x g : {A : Set} {y : C A} {P : A → Set} → ((x : A) → G y → P x) → H P y variable A : Set P : A → Set x : A y : C A postulate h : {p : ∀ x → G y → P x} → (∀ x (g : G y) → F (p x g)) → F (g p) id : (A : Set) → A → A id _ x = x -- i : (h : H P y) → (∀ x (g : G y) → F (f h x g)) → F (g (f h)) -- i x y = id (F (g (f x))) (h y)
{ "alphanum_fraction": 0.3933717579, "avg_line_length": 19.2777777778, "ext": "agda", "hexsha": "9ef546522c4d71a3540de4c0dfc3c44bc5142798", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue3672.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue3672.agda", "max_line_length": 71, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue3672.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": 336, "size": 694 }
{-# OPTIONS --guardedness #-} import Tutorials.Monday-Complete import Tutorials.Tuesday-Complete import Tutorials.Wednesday-Complete import Tutorials.Thursday-Complete
{ "alphanum_fraction": 0.8284023669, "avg_line_length": 24.1428571429, "ext": "agda", "hexsha": "f890566fd8ddf6808cf7897d5e70bdfdce19f042", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-11-24T10:50:55.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-23T08:50:13.000Z", "max_forks_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "poncev/agda-bcam", "max_forks_repo_path": "Everything.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "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": "poncev/agda-bcam", "max_issues_repo_path": "Everything.agda", "max_line_length": 35, "max_stars_count": 27, "max_stars_repo_head_hexsha": "ccd2a78642e93754011deffbe85e9ef5071e4cb7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "poncev/agda-bcam", "max_stars_repo_path": "Everything.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-03T22:53:51.000Z", "max_stars_repo_stars_event_min_datetime": "2021-09-23T17:59:21.000Z", "num_tokens": 39, "size": 169 }
open import Agda.Builtin.Equality postulate A : Set B : A → Set variable a : A b : B a postulate C : B a → Set postulate f : (b : B a) → {!!} g : (c : C b) → {!!} module _ (a′ : A) where postulate h : (b : B a) (b′ : B a′) → {!!} j : (b′ : B a) (c : C b) (c′ : C b′) → {!!}
{ "alphanum_fraction": 0.4342105263, "avg_line_length": 13.2173913043, "ext": "agda", "hexsha": "c22b87261b55a9572cb23395084bf76b68bbed50", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/Issue3340.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/Issue3340.agda", "max_line_length": 47, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue3340.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": 137, "size": 304 }
{-# OPTIONS --copatterns --sized-types --without-K #-} module Poly where open import Level using (Level) open import Data.Product open import Data.Nat open import Data.Fin open import Data.Unit open import Data.Empty open import Data.Vec hiding (_∈_; [_]) open import Relation.Binary.PropositionalEquality open import Function open import Data.Sum open import Size infixr 2 _and_ Fam : Set → Set₁ Fam I = I → Set Fam₂ : Set → Set → Set₁ Fam₂ I J = I → J → Set -- | Morphisms between families MorFam : {I : Set} (P₁ P₂ : Fam I) → Set MorFam {I} P₁ P₂ = (x : I) → P₁ x → P₂ x _⇒_ = MorFam compMorFam : {I : Set} {P₁ P₂ P₃ : Fam I} → MorFam P₁ P₂ → MorFam P₂ P₃ → MorFam P₁ P₃ compMorFam f₁ f₂ a = f₂ a ∘ f₁ a _⊚_ = compMorFam -- | Reindexing of families _* : {I J : Set} → (I → J) → Fam J → Fam I (u *) P = P ∘ u -- | Reindexing on morphisms of families _*₁ : {I J : Set} → (u : I → J) → {P₁ P₂ : Fam J} → (P₁ ⇒ P₂) → (u *) P₁ ⇒ (u *) P₂ (u *₁) f i = f (u i) -- | This notation for Π-types is more useful for our purposes here. Π : (A : Set) (P : Fam A) → Set Π A P = (x : A) → P x _and_ = _×_ -- | Fully general Σ-type, which we need to interpret the interpretation -- of families of containers as functors for inductive types. data Σ' {A B : Set} (f : A → B) (P : Fam A) : B → Set where ins : (a : A) → P a → Σ' f P (f a) p₁' : {A B : Set} {u : A → B} {P : Fam A} {b : B} → Σ' u P b → A p₁' (ins a _) = a p₂' : {A B : Set} {u : A → B} {P : Fam A} {b : B} → (x : Σ' u P b) → P (p₁' x) p₂' (ins _ x) = x p₌' : {A B : Set} {u : A → B} {P : Fam A} {b : B} → (x : Σ' u P b) → u (p₁' x) ≡ b p₌' (ins _ _) = refl ins' : {A B : Set} {u : A → B} {P : Fam A} → (a : A) → (b : B) → u a ≡ b → P a → Σ' u P b ins' a ._ refl x = ins a x Σ'-eq : {A B : Set} {f : A → B} {P : Fam A} → (a a' : A) (x : P a) (x' : P a') (a≡a' : a ≡ a') (x≡x' : subst P a≡a' x ≡ x') → subst (Σ' f P) (cong f a≡a') (ins a x) ≡ ins a' x' Σ'-eq a .a x .x refl refl = refl Σ-eq : {a b : Level} {A : Set a} {B : A → Set b} → (a a' : A) (x : B a) (x' : B a') (a≡a' : a ≡ a') (x≡x' : subst B a≡a' x ≡ x') → (a , x) ≡ (a' , x') Σ-eq a .a x .x refl refl = refl ×-eq : {ℓ : Level} {A : Set ℓ} {B : Set ℓ} → (a a' : A) (b b' : B) → a ≡ a' → b ≡ b' → (a , b) ≡ (a' , b') ×-eq a .a b .b refl refl = refl ×-eqˡ : {A B : Set} {a a' : A} {b b' : B} → (a , b) ≡ (a' , b') → a ≡ a' ×-eqˡ refl = refl ×-eqʳ : {A B : Set} {a a' : A} {b b' : B} → (a , b) ≡ (a' , b') → b ≡ b' ×-eqʳ refl = refl -- | Comprehension ⟪_⟫ : {I : Set} → Fam I → Set ⟪_⟫ {I} B = Σ I B ⟪_⟫² : {I J : Set} → (J → Fam I) → Fam J ⟪_⟫² {I} B j = Σ I (B j) π : {I : Set} → (B : Fam I) → ⟪ B ⟫ → I π B = proj₁ _⊢₁_ : {I : Set} {A : Fam I} → (i : I) → A i → ⟪ A ⟫ i ⊢₁ a = (i , a) _,_⊢₂_ : {I : Set} {A : Fam I} {B : Fam ⟪ A ⟫} → (i : I) → (a : A i) → B (i , a) → ⟪ B ⟫ i , a ⊢₂ b = ((i , a) , b) -- Not directly definable... -- record Π' {A B : Set} (u : A → B) (P : A → Set) : B → Set where -- field -- app : (a : A) → Π' u P (u a) → P a -- | ... but this does the job. Π' : {I J : Set} (u : I → J) (P : Fam I) → Fam J Π' {I} u P j = Π (∃ λ i → u i ≡ j) (λ { (i , _) → P i}) Π'' : {I J : Set} (u : I → J) (j : J) (P : Fam (∃ λ i → u i ≡ j)) → Set Π'' {I} u j P = Π (∃ λ i → u i ≡ j) P -- | Application for fully general Π-types. app : {I J : Set} {u : I → J} {P : Fam I} → (u *) (Π' u P) ⇒ P app i f = f (i , refl) -- | Abstraction for fully general Π-types. abs : {I J : Set} {u : I → J} {P : Fam I} → ((i : I) → P i) → ((j : J) → Π' u P j) abs {u = u} f .(u i) (i , refl) = f i -- | Abstraction for fully general Π-types. abs' : {I J : Set} {u : I → J} {P : Fam I} {X : Fam J} → ((u *) X ⇒ P) → (X ⇒ Π' u P) abs' {u = u} f .(u i) x (i , refl) = f i x -- | Abstraction for fully general Π-types. abs'' : {I J : Set} {u : I → J} {P : Fam I} → (j : J) → ((i : I) → u i ≡ j → P i) → Π' u P j abs'' j f (i , p) = f i p abs₃ : {I J : Set} {u : I → J} (j : J) {P : Fam (Σ I (λ i → u i ≡ j))} → ((i : I) → (p : u i ≡ j) → P (i , p)) → Π'' u j P abs₃ j f (i , p) = f i p -- | Functorial action of Π' Π'₁ : {I J : Set} {u : I → J} {P Q : Fam I} → (f : P ⇒ Q) → (Π' u P ⇒ Π' u Q) Π'₁ {u = u} f .(u i) g (i , refl) = f i (app i g) -- | Turn morphism into a family toFam : ∀ {A B : Set} → (h : B → A) → Fam A toFam {A} {B} h a = Σ[ b ∈ B ] (h b ≡ a) -- | Turn family into a morphism fromFam : ∀ {A B : Set} → (X : Fam A) → (Σ A X → A) fromFam {A} {B} X = proj₁ -- | Set comprehension record ⟪_⟫' {A : Set} (φ : A → Set) : Set where constructor elem field a : A .isElem : φ a inc : {A : Set} {φ : A → Set} → ⟪ φ ⟫' → A inc (elem a isElem) = a compr-syntax : (A : Set) (φ : A → Set) → Set compr-syntax A = ⟪_⟫' syntax compr-syntax A (λ x → φ) = ⟪ x ∈ A ∥ φ ⟫ compr-syntax' : {A : Set} (φ ψ : A → Set) → Set compr-syntax' φ ψ = ⟪ (λ a → φ a and ψ a) ⟫' syntax compr-syntax' φ (λ x → ψ) = ⟪ x ∈ φ ∥ ψ ⟫' -- | Subsets of A Sub : Set → Set₁ Sub A = Σ[ φ ∈ (A → Set) ] ⟪ φ ⟫' _∈_ : {A : Set} → A → (φ : A → Set) → Set x ∈ φ = φ x _⊆_ : {A : Set} → (φ₁ φ₂ : A → Set) → Set φ₁ ⊆ φ₂ = φ₁ ⇒ φ₂ _≅_ : {A : Set} → (φ₁ φ₂ : A → Set) → Set φ₁ ≅ φ₂ = (φ₁ ⊆ φ₂) × (φ₂ ⊆ φ₁) predToFam : {I A : Set} → (A → I) → (A → Set) → Fam I predToFam {I} {A} h φ = Σ' h φ -- | Dependent polynomials record DPoly {I : Set} -- ^ Global index of constructed type -- {N : Set} -- ^ Index set for parameters -- {J : N → Set} -- ^ Index of each parameter {J : Set} : Set₁ where constructor dpoly field -- J ←t- E -p→ A -s→ I A : Set -- ^ Labels s : A → I E : Set p : E → A t : E → J -- | Interpretation of polynomial as functor T : {I : Set} {J : Set} → DPoly {I} {J} → (X : Fam J) → -- ^ Parameter (Fam I) T {I} {N} (dpoly A s E p t) X = Σ' s (λ a → Π' p (λ e → X (t e) ) a ) -- | Functorial action of T T₁ : {I : Set} {J : Set} → (C : DPoly {I} {J}) → {X Y : J → Set} → (f : (j : J) → X j → Y j) (i : I) → T C X i → T C Y i T₁ {I} {J} (dpoly A s E p t) {X} {Y} f .(s a) (ins a v) = ins a (Π'₁ ((t *₁) f) a v) -- | Dependent, multivariate polynomials record DMPoly {I : Set} -- ^ Global index of constructed type {N : Set} -- ^ Index set for parameters {J : N → Set} -- ^ Index of each parameter : Set₁ where constructor dpoly₁ field -- J ←t- E -p→ A -s→ I A₁ : Set -- ^ Labels s₁ : A₁ → I E₁ : N → Set p₁ : (n : N) → E₁ n → A₁ t₁ : (n : N) → E₁ n → J n -- | Create multiparameter polynomial paramPoly : {I : Set} {N : Set} {J : N → Set} → DMPoly {I} {N} {J} → DPoly {I} {Σ N J} paramPoly {I} {N} (dpoly₁ A₁ s₁ E₁ p₁ t₁) = dpoly A₁ s₁ ⟪ E₁ ⟫ (λ {(n , e) → p₁ n e}) (λ {(n , e) → (n , t₁ n e)}) -- | Functor on product category for multivariate polynomials. TM : {I : Set} {N : Set} {J : N → Set} → DMPoly {I} {N} {J} → (X : (n : N) → J n → Set) → (I → Set) TM P X = T (paramPoly P) (λ {(n , j) → X n j}) {- ----- Example: Vectors seen fixed point of (A, X) ↦ Σ z ⊤ + Σ s (A × X) ------ in the second variable. Here, z is the zero map, s the successor and ------ A is implicitely weakend. Vec-Cons = Fin 2 Vec-Loc-Ind : Vec-Cons → Set Vec-Loc-Ind zero = ⊤ Vec-Loc-Ind (suc x) = ℕ Vars : Set Vars = Fin 2 Var-Types : Vars → Set Var-Types zero = ⊤ Var-Types (suc m) = ℕ C : DPoly {ℕ} {Vars} {Var-Types} C = dpoly ⟪ Vec-Loc-Ind ⟫ f Dom pp g where f : ⟪ Vec-Loc-Ind ⟫ → ℕ f (zero , tt) = 0 f (suc _ , k) = suc k -- | Domain exponents Dom' : Vars → Fam Vec-Cons Dom' _ zero = ⊥ Dom' _ (suc _) = ℕ Dom : Vars → Set Dom zero = ⟪ Dom' zero ⟫ Dom (suc n) = ⟪ Dom' (suc n) ⟫ pp : (n : Vars) → Dom n → ⟪ Vec-Loc-Ind ⟫ pp zero (zero , ()) pp (suc n) (zero , ()) pp zero (suc c , k) = suc c ⊢₁ k pp (suc n) (suc c , k) = suc c ⊢₁ k Params : Vars → ⟪ Vec-Loc-Ind ⟫ → Set Params x (zero , _) = ⊥ Params zero ((suc a) , k) = ⊤ Params (suc x) ((suc a) , k) = ⊤ g : (n : Vars) → Dom n → Var-Types n g zero (zero , ()) g (suc n) (zero , ()) g zero (suc c , k) = tt g (suc n) (suc c , k) = k F : ((m : Vars) → Var-Types m → Set) → (ℕ → Set) F = T C -- Fix the variables, so that we can apply F. Fix-Vars : Set → (ℕ → Set) → (p : Vars) → Var-Types p → Set Fix-Vars A _ zero _ = A Fix-Vars A X (suc n) = X -- | Algebra structure on vectors, using the functor F. in-vec : ∀ {A} → (n : ℕ) → F (Fix-Vars A (Vec A)) n → Vec A n in-vec {A} .0 (ins (zero , tt) _) = [] in-vec {A} .(suc k) (ins ((suc i) , k) v) = a ∷ x where a : A a = app (suc i ⊢₁ k) (v zero) x : Vec A k x = app (suc i ⊢₁ k) (v (suc zero)) -- | Recursion for F-algebras rec-vec : {A : Set} {X : ℕ → Set} → ((n : ℕ) → F (Fix-Vars A X) n → X n) → (n : ℕ) → Vec A n → X n rec-vec {A} {X} u .0 [] = u 0 (ins (zero ⊢₁ tt) v₀) where v₀ : Π Vars (λ n → Π' (p C n) (λ e → Fix-Vars A X n (t C n e)) (zero ⊢₁ tt)) v₀ zero = abs'' (zero ⊢₁ tt) q₀ where q₀ : (i : E C zero) → p C zero i ≡ zero ⊢₁ tt → A q₀ (zero , ()) p q₀ (suc d , _) () v₀ (suc n) = abs'' (zero ⊢₁ tt) q₁ where q₁ : (d : E C (suc n)) → p C (suc n) d ≡ zero ⊢₁ tt → X (t C (suc n) d) q₁ (zero , ()) p q₁ (suc d , _) () rec-vec {A} {X} f (suc k) (a ∷ x) = f (suc k) (ins (suc zero ⊢₁ k) v') where v' : Π Vars (λ n → Π' (p C n) (λ e → Fix-Vars A X n (t C n e)) (suc zero ⊢₁ k)) v' zero = abs'' (suc zero ⊢₁ k) q₀ where q₀ : (d : E C zero) → p C zero d ≡ suc zero ⊢₁ k → A q₀ d p = a v' (suc n) = abs'' (suc zero ⊢₁ k) q₁ where q₁ : (d : E C (suc n)) → p C (suc n) d ≡ suc zero ⊢₁ k → X (t C (suc n) d) q₁ (zero , ()) p q₁ (suc .zero , .k) refl = rec-vec f k x --- Example 2: Partial streams record ℕ∞ : Set where coinductive field pred∞ : ⊤ ⊎ ℕ∞ open ℕ∞ suc∞ : ℕ∞ → ℕ∞ pred∞ (suc∞ n) = inj₂ n PS-Vars : Set PS-Vars = Fin 2 PS-Types : PS-Vars → Set PS-Types zero = ⊤ PS-Types (suc n) = ℕ∞ PS-C : DPoly {ℕ∞} {PS-Vars} {PS-Types} PS-C = dpoly ℕ∞ id Codom codom-dep var-reidx where Codom : PS-Vars → Set Codom _ = ℕ∞ codom-dep : (n : PS-Vars) → Codom n → ℕ∞ codom-dep _ = suc∞ var-reidx : (n : PS-Vars) → Codom n → PS-Types n var-reidx zero _ = tt var-reidx (suc v) = id PS-F : ((m : PS-Vars) → PS-Types m → Set) → (ℕ∞ → Set) PS-F = T PS-C -- Fix the variables, so that we can apply F. PS-Fix-Vars : Set → Fam ℕ∞ → (p : PS-Vars) → Fam (PS-Types p) PS-Fix-Vars A _ zero _ = A PS-Fix-Vars A X (suc n) = X record PStr {i : Size} (A : Set) (n : ℕ∞) : Set where coinductive field out : ∀ {j : Size< i} → PS-F (PS-Fix-Vars A (PStr {j} A)) n open PStr P-hd : ∀ {A} {n : ℕ∞} → PStr A (suc∞ n) → A P-hd {A} {n} s = q (out s) where q : PS-F (PS-Fix-Vars A (PStr A)) (suc∞ n) → A q (ins .(suc∞ n) v) = app n (v zero) P-tl : ∀ {A} {n : ℕ∞} → PStr A (suc∞ n) → PStr A n P-tl {A} {n} s = q (out s) where q : PS-F (PS-Fix-Vars A (PStr A)) (suc∞ n) → PStr A n q (ins .(suc∞ n) v) = app n (v (suc zero)) P-corec : {A : Set} {X : Fam ℕ∞} → (c : X ⇒ PS-F (PS-Fix-Vars A X)) → (∀{i} → X ⇒ PStr {i} A) out (P-corec {A} {X} c n x) {j} = ins n (h n x) where h : (n : ℕ∞) → X n → Π PS-Vars (λ v → Π' (p PS-C v) (λ e → PS-Fix-Vars A (PStr {j} A) v (t PS-C v e)) n) h n x zero = abs'' n (q n x) where q : (n : ℕ∞) → (X n) → (d : E PS-C zero) → p PS-C zero d ≡ n → A q .(suc∞ n) x n refl = r (c (suc∞ n) x) where r : PS-F (PS-Fix-Vars A X) (suc∞ n) → A r (ins .(suc∞ n) ch) = app n (ch zero) h n x (suc v) = abs'' n (q n x) where q : (n : ℕ∞) → (X n) → (i : E PS-C (suc v)) → p PS-C (suc v) i ≡ n → PStr {j} A (t PS-C (suc v) i) q .(suc∞ k) x k refl = P-corec c k (r (c (suc∞ k) x)) where r : PS-F (PS-Fix-Vars A X) (suc∞ k) → X k r (ins .(suc∞ k) ch) = app k (ch (suc zero)) ------- End examples -------- -} -- | Non-dependent polynomials in one variable record Poly : Set₁ where constructor poly field Sym : Set Arit : Set f : Arit → Sym open Poly -- | Interpretation as functors ⟦_⟧ : Poly → Set → Set ⟦ poly A B f ⟧ X = Σ A ((Π' f) (λ e → X)) ⟦_⟧₁ : {P : Poly} {A B : Set} → (A → B) → (⟦ P ⟧ A → ⟦ P ⟧ B) ⟦_⟧₁ {poly Sym Arit f} {A} {B} f₁ (a , v) = (a , abs'' a (v' a v)) where v' : (a' : Sym) (v' : Π' f (λ e → A) a') (b : Arit) → f b ≡ a' → B v' ._ v' b refl = f₁ (app b v') -- | Lifting to predicates ⟦_⟧' : (p : Poly) → ∀ {X} → Fam X → Fam (⟦ p ⟧ X) ⟦ poly A B f ⟧' P (s , α) = ∀ (x : toFam f s) → P (α x) -- | Lifting to relations ⟦_⟧'' : (p : Poly) → ∀ {X Y} → Fam₂ X Y → Fam₂ (⟦ p ⟧ X) (⟦ p ⟧ Y) ⟦ poly A B f ⟧'' P (s₁ , α₁) (s₂ , α₂) = Σ[ e ∈ (s₁ ≡ s₂) ] (∀ (x : toFam f s₁) → P (α₁ x) (α₂ (proj₁ x , trans (proj₂ x) e))) eq-preserving : ∀ {p X} (x y : ⟦ p ⟧ X) → x ≡ y → ⟦ p ⟧'' _≡_ x y eq-preserving {p} x .x refl = refl , q where lem : ∀ {X : Set} {x y : X} (e : x ≡ y) → trans e refl ≡ e lem refl = refl q : (z : toFam (f p) (proj₁ x)) → proj₂ x z ≡ proj₂ x (proj₁ z , trans (proj₂ z) refl) q (s , e) = cong (λ u → proj₂ x (s , u)) (sym (lem e)) -- | Final coalgebras for non-dependent polynomials record M {i : Size} (P : Poly) : Set where coinductive field ξ : ∀ {j : Size< i} → ⟦ P ⟧ (M {j} P) open M ξ' : ∀ {P} → M P → ⟦ P ⟧ (M P) ξ' x = ξ x mutual -- | Equality for M types is given by bisimilarity record _~_ {P : Poly} (x y : M P) : Set where coinductive field ~pr : ⟦ P ⟧'' _~_ (ξ' x) (ξ' y) open _~_ public IsBisim : ∀{p X Y} → (X → ⟦ p ⟧ X) → (Y → ⟦ p ⟧ Y) → Fam₂ X Y → Set IsBisim {p} f g _R_ = ∀ x y → x R y → ⟦ p ⟧'' _R_ (f x) (g y) root : ∀ {P} → M P → Sym P root = proj₁ ∘ ξ' corec-M : ∀ {P : Poly} {X : Set} → (X → ⟦ P ⟧ X) → (∀{i} → X → M {i} P) ξ (corec-M {poly Sym Arit f} {X} c x) {j} = (c₁ , abs'' c₁ (v x)) where c₁ = proj₁ (c x) v : (x : X) (b : Arit) → f b ≡ proj₁ (c x) → M {j} (poly Sym Arit f) v x b p = corec-M c (proj₂ (c x) (b , p)) Bisim→~ : ∀{p X Y} {f : X → ⟦ p ⟧ X} {g : Y → ⟦ p ⟧ Y} {_R_} → IsBisim f g _R_ → ∀ x y → x R y → corec-M f x ~ corec-M g y ~pr (Bisim→~ isBisim x y xRy) with isBisim x y xRy ~pr (Bisim→~ {p} {X} {Y} {f} {g} isBisim x y xRy) | (e , β) = (e , (λ z → Bisim→~ isBisim (proj₂ (f x) z) (proj₂ (g y) (proj₁ z , trans (proj₂ z) e)) (β z))) {- corec-M-hom : {P : Poly} {X : Set} (c : X → ⟦ P ⟧ X) → (x : X) → ξ' (corec-M c x) R~ ⟦ corec-M c ⟧₁ (c x) sym≡ (corec-M-hom c x) = refl arit~ (corec-M-hom {poly A B f} {X} c x) = abs₃ (proj₁ (c x)) {!!} -- (pr x (c x) refl refl) where P = poly A B f pr : (x : X) (x' : ⟦ P ⟧ X) (p₀ : x' ≡ c x) (p : proj₁ (ξ' (corec-M c x)) ≡ proj₁ (⟦ corec-M c ⟧₁ x')) (b : B) (p₁ : f b ≡ proj₁ (ξ' (corec-M c x))) → -- (p₁ : f b ≡ proj₁ x') → arit~-pr (ξ' (corec-M c x)) (⟦ corec-M c ⟧₁ x') p (b , p₁) pr x₁ (._ , ._) refl p₁ b p₂ = {!!} -} record PolyHom (P₁ P₂ : Poly) : Set where constructor polyHom field SymMor : Sym P₁ → Sym P₂ AritMor : (SymMor *) (toFam (f P₂)) ⇒ toFam (f P₁) coalg : {P₁ P₂ : Poly} → PolyHom P₁ P₂ → (∀ X → ⟦ P₁ ⟧ X → ⟦ P₂ ⟧ X) coalg {poly Sym₁ Arit₁ f₁} {poly Sym₂ Arit₂ f₂} (polyHom α β) X (a , v) = (α a , abs'' (α a) (v' a v)) where v' : (a : Sym₁) (v : Π' f₁ (λ e → X) a) (b : Arit₂) → f₂ b ≡ α a → X v' a v b p = v (β a (b , p)) -- | Functoriality M₁ : ∀ {P₁ P₂} → PolyHom P₁ P₂ → M P₁ → M P₂ M₁ {P₁} h = corec-M (coalg h (M P₁) ∘ ξ') -- | Product of maps _⊗_ : {A B C D : Set} → (A → B) → (C → D) → (A × C → B × D) (f ⊗ g) x = ((f (proj₁ x)) , (g (proj₂ x))) ⊗-eq : {A B C : Set} {f : A → C} {g : B → C} (a : A) (b : B) (p : f a ≡ g b)→ (f ⊗ g) (a , b) ≡ (g b , g b) ⊗-eq {f = f} {g} a b p = ×-eq (f a) (g b) (g b) (g b) p refl -- | Extend polynomial by index I-poly : Poly → Set → Poly I-poly P I = poly (Sym P × I) (Arit P × I) (f P ⊗ id) _⋊_ = I-poly {- -- | Projects away the I from M (P × I) u₁ : ∀ {i} → (P : Poly) (I : Set) → M (I-poly I P) → M {i} P ξ (u₁ P I x) {j} = q (ξ x) where q : R (I-poly I P) (M (I-poly I P)) → ⟦ P ⟧ (M {j} P) q (s , v) = (proj₁ s , abs'' (proj₁ s) (r (s , v))) where r : (u : R (I-poly I P) (M (I-poly I P))) (a : Arit P) → f P a ≡ proj₁ (proj₁ u) → M {j} P r ((.(f P a) , i) , v) a refl = u₁ P I (app (a , i) v) -} -- | Forget changes of dependencies of a polynomial in one variable. simple : {I : Set} → DPoly {I} {I} → Poly simple C = poly (DPoly.A C) (DPoly.E C) (DPoly.p C) ↓_ = simple module MTypes {I : Set} (C : DPoly {I} {I}) where open DPoly C P = ↓ C idx : M P → I idx = s ∘ root inj : (X : I → Set) → ⟪ T C X ⟫ → ⟦ ↓ C ⟧ ⟪ X ⟫ inj X (.(s a) , (ins a v)) = (a , abs'' a (u a v)) where u : (a' : A) (v' : Π' p (λ e → X (t e)) a') (b : E) → f (↓ C) b ≡ a' → ⟪ X ⟫ u ._ v' b refl = (t b , app b v') -- | Applies r corecursively, thus essentially constructs an element of -- M (P × I) where the second component is given by r. u₁ : M P → M (P ⋊ I) u₁ = M₁ (polyHom α β) where α : Sym (↓ C) → Sym ((↓ C) ⋊ I) α = < id , s > β : (α *) (toFam (f P ⊗ id)) ⇒ toFam p β ._ ((b , ._) , refl) = (b , refl) K : ⟦ P ⋊ I ⟧ (M (P ⋊ I)) → ⟦ P ⋊ I ⟧ (M (P ⋊ I) × E) K (a , v) = (a , abs'' a (v' a v)) where v' : (a : Sym (P ⋊ I)) (v : Π' (f (P ⋊ I)) (λ e → M (P ⋊ I)) a) (bi : Arit (P ⋊ I)) → f (P ⋊ I) bi ≡ a → M (P ⋊ I) × E v' ._ v₁ bi refl = (v₁ (bi , refl) , proj₁ bi) φ : M (P ⋊ I) × Arit P → M (P ⋊ I) φ = corec-M c where h : ⟦ P ⋊ I ⟧ (M (P ⋊ I)) × Arit P → ⟦ P ⋊ I ⟧ (M (P ⋊ I) × Arit P) h (((a , i) , v) , b) = ((a , t b) , abs'' (a , t b) (v' (a , t b) b v)) where v' : (ai' : Sym (P ⋊ I)) (b : Arit P) (v : Π' (f (P ⋊ I)) (λ _ → M (P ⋊ I)) (proj₁ ai' , i)) (i : Arit (P ⋊ I)) → f (P ⋊ I) i ≡ ai' → M (P ⋊ I) × Arit P v' ._ b v₁ (b₁ , _) refl = (app (b₁ , i) v₁ , b) c : M (P ⋊ I) × Arit P → ⟦ P ⋊ I ⟧ (M (P ⋊ I) × Arit P) c = h ∘ (ξ' ⊗ id) ψ : M (P ⋊ I) → M (P ⋊ I) ψ = corec-M c where c : M (P ⋊ I) → ⟦ P ⋊ I ⟧ (M (P ⋊ I)) c = ⟦ φ ⟧₁ ∘ K ∘ ξ' u₂ : M P → M (P ⋊ I) u₂ = ψ ∘ u₁ {- {- -- | Same as u₂??? u₂' : ∀ {I} (C : DPoly {I}) → M (↓ C) → M (↓ C ⋊ I) u₂' {I} C x = M₁ (polyHom α β) x where α : Sym (↓ C) → Sym ((↓ C) ⋊ I) α a = (a , t C {!!}) -- (root x)) -- (s C (root x))) β : (α *) (toFam (f (↓ C) ⊗ id)) ⇒ toFam (p C tt) β ._ ((a , ._) , refl) = (a , refl) φ : {I : Set} (C : DPoly {I}) {i : Size} → M {i} (↓ C ⋊ I) × Arit (↓ C) → M {i} (↓ C ⋊ I) ξ (φ {I} C (x , b)) {j} = q (ξ x) where m : ⟦ ↓ C ⋊ I ⟧ (M {j} (↓ C ⋊ I)) → Sym (↓ C ⋊ I) m ((a , i) , v) = (a , (t C b)) q : ⟦ ↓ C ⋊ I ⟧ (M {j} (↓ C ⋊ I)) → ⟦ ↓ C ⋊ I ⟧ (M {j} (↓ C ⋊ I)) q u = (m u , abs'' (m u) (v' u)) where v' : (u : ⟦ ↓ C ⋊ I ⟧ (M {j} (↓ C ⋊ I))) (b : Arit (↓ C ⋊ I)) → f (↓ C ⋊ I) b ≡ m u → M {j} (↓ C ⋊ I) v' ((._ , i) , v) (b , ._) refl = φ C ((app (b , i) v) , b) ψ : {I : Set} (C : DPoly {I}) {i : Size} → M {i} (↓ C ⋊ I) → M {i} (↓ C ⋊ I) ξ (ψ {I} C x) {j} = q (ξ x) where q : ⟦ ↓ C ⋊ I ⟧ (M {j} (↓ C ⋊ I)) → ⟦ ↓ C ⋊ I ⟧ (M {j} (↓ C ⋊ I)) q (a , v) = (a , abs'' a (v' (a , v))) where v' : (u' : ⟦ ↓ C ⋊ I ⟧ (M {j} (↓ C ⋊ I))) (a' : Arit (↓ C ⋊ I)) → f (↓ C ⋊ I) a' ≡ proj₁ u' → M {j} (↓ C ⋊ I) v' (._ , v) a' refl = φ C (app a' v , proj₁ a') u₂ : ∀ {i} {I} (C : DPoly {I}) → M (↓ C) → M {i} (↓ C ⋊ I) u₂ C = ψ C ∘ u₁ C -} Vφ : (i : I) → (M P → Set) Vφ i x = (s (root x) ≡ i) × (u₁ x ≡ u₂ x) --V' : {I : Set} (C : DPoly {I} {I}) → Fam I --V' C = ⟪ Vφ C ⟫² {- lem₂ : {I : Set} {C : DPoly {I} {I}} → (x : M (↓ C)) (b : E C) (v : Π' (p C) (λ e → M (↓ C)) (p C b)) → ξ' x ≡ (_ , v) → u₁ C x ≡ u₂ C x → u₁ C (app b v) ≡ u₂ C (app b v) lem₂ {I} {C} x b v pr≡ u₁≡u₂ = {!!} where w : (x : ⟦ ↓ C ⟧ (M (↓ C))) (b : E C) (v : Π' (p C) (λ e → M (↓ C)) (p C b)) → x ≡ (_ , v) → u₁ C (app b v) ≡ u₂ C (app b v) w ._ b v refl = {!!} -- bar : ξ' (u₁ C x) ≡ ⟦ ↓ C ⟧₁ u₁ (M₁ lem₁ : {I : Set} {C : DPoly {I} {I}} → (x : M (↓ C)) (b : E C) (v : Π' (p C) (λ e → M (↓ C)) (p C b)) → ξ' x ≡ (_ , v) → u₁ C x ≡ u₂ C x → s C (root (app b v)) ≡ t C b lem₁ x b v pr≡ u₁≡u₂ = {!!} {- ξV : ∀ {I} {C : DPoly {I} {I}} → V' C ⇒ T C (V' C) ξV {C = dpoly A s E p t} .(s (proj₁ (ξ x))) (x , refl , u₁≡u₂) = ins (root x) (abs'' (root x) (v' (root x) (proj₂ (ξ' x)) refl)) where C = dpoly A s E p t v' : (a : A) (v : Π' p (λ e → M (↓ C)) a) (q : ξ' x ≡ (a , v)) (b : E) → p b ≡ a → Σ (M (↓ C)) (Vφ C (t b)) v' .(p b) v q b refl = (app b v , lem₁ x b v q u₁≡u₂ , (lem₂ x b v q u₁≡u₂)) -} -} V' : M P → Set V' x = u₁ x ≡ u₂ x Φ : (M P → Set) → (M P → Set) Φ U x = let (a , v) = ξ' x in Π'' (f P) a (λ {(b , pr) → Σ[ y ∈ M P ] ( U y and idx y ≡ t b and q b (a , v) pr y ) }) where q : (b : E) (u : ⟦ P ⟧ (M P)) → f P b ≡ proj₁ u → M P → Set q b (._ , v) refl y = app b v ≡ y {- q : (b : E) (u : ⟦ P ⟧ (M P)) → f P b ≡ proj₁ u → (j : I) → U' j → Set q b (._ , v) refl .(idx y) (ins y z) = app b v ≡ y -} {- V'-postFP : V' ⊆ Φ V' V'-postFP x x∈V' (b , fb≡ξx₁) = (r b (ξ' x) fb≡ξx₁ , {!!}) where r : (b₁ : E) (u : ⟦ P ⟧ (M P)) → f P b₁ ≡ proj₁ u → predToFam idx V' (t b₁) r b₁ (._ , v) refl = r' b₁ (app b₁ v) where r' : (b₂ : E) (x' : M P) → predToFam idx V' (t b₂) r' b₂ x' = ins ? {!!} -} V'-final : (U : M P → Set) → U ⊆ Φ U → U ⊆ V' V'-final = {!!} -- | This predicate on M (↓ C) ensures that we can define a map -- V → s a ≡ ⟦ ↓ C ⟧ (i × (t *) V. record V-pred (i : I) (x : M P) : Set where coinductive field -- | For ξ x = (a , v), we require s a = i sigma-idx : s (proj₁ (ξ x)) ≡ i -- | For ξ x = (a , v), we require ∀ b with p b = a that -- idx (v b) = s a and v b ∈ V (t b) reidx : Π'' (f P) (proj₁ (ξ x)) (λ {(e , eq) → idx ((proj₂ (ξ x)) (e , eq)) ≡ t e × V-pred (t e) ((proj₂ (ξ x)) (e , eq)) }) open V-pred {- V : {I : Set} (C : DPoly {I} {I}) → Fam I V C i = Σ (M (↓ C)) (V-pred C i) Σ≡₁ : {I : Set} {A : Fam I} → {x y : Σ I A} → x ≡ y → proj₁ x ≡ proj₁ y Σ≡₁ {x = i , a} {.i , .a} refl = refl foofoo : {I : Set} {A : Fam I} → (x y : Σ I A) → (p : x ≡ y) → A (proj₁ y) foofoo x .x refl = proj₂ x Σ≡₂ : {I : Set} {A : Fam I} → {x y : Σ I A} → (p : x ≡ y) → foofoo x y p ≡ proj₂ y Σ≡₂ {x = i , a} {.i , .a} refl = refl out-V : {I : Set} {C : DPoly {I} {I}} → V C ⇒ T C (V C) out-V {I} {C = dpoly A s E p t} i (x , v-proof) = foo i v-proof (sigma-idx v-proof) where P : DPoly P = dpoly A s E p t u : ⟦ ↓ P ⟧ (M (↓ P)) u = ξ x -- uaie : (u' : ⟦ ↓ P ⟧ (M (↓ P))) → f (↓ P) e ≡ proj₁ u' → A → Set -- uaie u' pr = Π' (p tt) (λ e → V-pred P (t e) ((proj₂ u') (e , {!!}))) foo : (i' : I) → V-pred P i' x → s (proj₁ u) ≡ i' → T P (V P) i' foo .(s (proj₁ u)) pr refl = ins (proj₁ u) (v'' u refl) where v'' : (u' : ⟦ ↓ P ⟧ (M (↓ P))) → u' ≡ ξ x → Π' p (λ e → V P (t e)) (proj₁ u') v'' (.(p e) , v) u'=ξx (e , refl) = (x' , {!!}) -- bar x {!v!} {!!} {!!} pr) where x' : M (↓ P) x' = v (e , refl) aiu = proj₂ (reidx pr (e , {!!})) bar : (x' : M (↓ P)) (v₁ : Π' (f (↓ P)) (λ e₁ → M (↓ P)) (proj₁ (ξ x'))) → v₁ ≡ proj₂ (ξ x') → (q : f (↓ P) e ≡ proj₁ (ξ x')) → V-pred P (s (proj₁ (ξ x'))) x' → V-pred P (t e) (v₁ (e , q)) bar x'' .(proj₂ (ξ x'')) refl q pr' = proj₂ (reidx pr' (e , q)) tu : s (root (proj₂ (ξ x) (e , Σ≡₁ u'=ξx))) ≡ t e tu = proj₁ (reidx pr (e , Σ≡₁ u'=ξx)) {- bar : (v₁ : Π' (f (↓ P)) (λ e₁ → M (↓ P)) (proj₁ (ξ x))) → v₁ ≡ proj₂ (ξ x) → V-pred P (t e) x' bar ._ refl = proj₂ (reidx pr ?) -} tiu : V-pred P (t e) (proj₂ (ξ x) (e , Σ≡₁ u'=ξx)) tiu = proj₂ (reidx pr (e , Σ≡₁ u'=ξx)) -- Want out-s : M (↓ C ⋊ I) → T C (M {i} (↓ C ⋊ I)) T' : {I : Set} → DPoly {I} {I} → (X : I → Set) → -- ^ Parameter (I → Set) T' C X = T C {!!} {- out-s' : ∀ {i} {I} {C : DPoly {I}} → M (↓ C ⋊ I) → T' C (M {i} (↓ C ⋊ I)) out-s' = ? -} -- | Candidate for R C out-s : ∀ {i} {I} {C : DPoly {I}} → M (↓ C ⋊ I) → ⟦ ↓ C ⟧ (M {i} (↓ C ⋊ I)) out-s {i} {I} {C} x = (q (ξ x) , abs'' (q (ξ x)) (h (ξ x))) where q : ⟦ ↓ C ⋊ I ⟧ (M {i} (↓ C ⋊ I)) → Sym (↓ C) q (a , _) = proj₁ a h : (u : ⟦ ↓ C ⋊ I ⟧ (M {i} (↓ C ⋊ I))) (a : Arit (↓ C)) → f (↓ C) a ≡ q u → M {i} (↓ C ⋊ I) h ((._ , b) , v') a refl = app (a , b) v' -} -}
{ "alphanum_fraction": 0.4048664049, "avg_line_length": 27.8990332975, "ext": "agda", "hexsha": "bde99d2ac7b5ce1d7d8b4589894b084cbbad5642", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hbasold/Sandbox", "max_forks_repo_path": "TypeTheory/Container/Poly.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hbasold/Sandbox", "max_issues_repo_path": "TypeTheory/Container/Poly.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hbasold/Sandbox", "max_stars_repo_path": "TypeTheory/Container/Poly.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 12418, "size": 25974 }
------------------------------------------------------------------------ -- The Agda standard library -- -- An abstraction of various forms of recursion/induction ------------------------------------------------------------------------ -- The idea underlying Induction.* comes from Epigram 1, see Section 4 -- of "The view from the left" by McBride and McKinna. -- Note: The types in this module can perhaps be easier to understand -- if they are normalised. Note also that Agda can do the -- normalisation for you. module Induction where open import Level open import Relation.Unary -- A RecStruct describes the allowed structure of recursion. The -- examples in Induction.Nat should explain what this is all about. RecStruct : ∀ {a} → Set a → (ℓ₁ ℓ₂ : Level) → Set _ RecStruct A ℓ₁ ℓ₂ = Pred A ℓ₁ → Pred A ℓ₂ -- A recursor builder constructs an instance of a recursion structure -- for a given input. RecursorBuilder : ∀ {a ℓ₁ ℓ₂} {A : Set a} → RecStruct A ℓ₁ ℓ₂ → Set _ RecursorBuilder Rec = ∀ P → Rec P ⊆′ P → Universal (Rec P) -- A recursor can be used to actually compute/prove something useful. Recursor : ∀ {a ℓ₁ ℓ₂} {A : Set a} → RecStruct A ℓ₁ ℓ₂ → Set _ Recursor Rec = ∀ P → Rec P ⊆′ P → Universal P -- And recursors can be constructed from recursor builders. build : ∀ {a ℓ₁ ℓ₂} {A : Set a} {Rec : RecStruct A ℓ₁ ℓ₂} → RecursorBuilder Rec → Recursor Rec build builder P f x = f x (builder P f x) -- We can repeat the exercise above for subsets of the type we are -- recursing over. SubsetRecursorBuilder : ∀ {a ℓ₁ ℓ₂ ℓ₃} {A : Set a} → Pred A ℓ₁ → RecStruct A ℓ₂ ℓ₃ → Set _ SubsetRecursorBuilder Q Rec = ∀ P → Rec P ⊆′ P → Q ⊆′ Rec P SubsetRecursor : ∀ {a ℓ₁ ℓ₂ ℓ₃} {A : Set a} → Pred A ℓ₁ → RecStruct A ℓ₂ ℓ₃ → Set _ SubsetRecursor Q Rec = ∀ P → Rec P ⊆′ P → Q ⊆′ P subsetBuild : ∀ {a ℓ₁ ℓ₂ ℓ₃} {A : Set a} {Q : Pred A ℓ₁} {Rec : RecStruct A ℓ₂ ℓ₃} → SubsetRecursorBuilder Q Rec → SubsetRecursor Q Rec subsetBuild builder P f x q = f x (builder P f x q)
{ "alphanum_fraction": 0.6058569371, "avg_line_length": 35.3050847458, "ext": "agda", "hexsha": "0effa83c42c7f8a199c298b376605153a2b55009", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Induction.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Induction.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Induction.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 633, "size": 2083 }
-- {-# OPTIONS -v tc.constr.add:45 #-} module _ where open import Agda.Builtin.Nat open import Agda.Builtin.Equality ==_] : ∀ {a} {A : Set a} (x : A) → x ≡ x == x ] = refl [ : ∀ {a} {A : Set a} (x : A) {y : A} → x ≡ y → A [ x refl = x case_of_ : ∀ {a b} {A : Set a} {B : Set b} → A → (A → B) → B case x of f = f x infixr 5 _∷_ data Vec {a} (A : Set a) : Nat → Set a where [] : Vec A zero _∷_ : ∀ {n} → A → Vec A n → Vec A (suc n) infixr 5 _∷[_]_ pattern _∷[_]_ x n xs = _∷_ {n} x xs module _ {a} {A : Set a} where id : A → A id x = x len : ∀ {n} → Vec A n → Nat len {n} _ = n module _ {b} {B : Set b} where map : ∀ {n} → (A → B) → Vec A n → Vec B n map f [] = [] map f (x ∷ xs) = f x ∷ map f xs const : A → B → A const x _ = x _!>_ : A → B → B _ !> x = x module SomeParameters {a} (n : Nat) (A : Set a) (xs : Vec A n) (ys : Vec A (n * 2)) where simpleRefine : Vec A n → Nat simpleRefine [] = [ n == 0 ] simpleRefine (x ∷[ m ] xs) = [ n == suc m ] moreComplex : Vec A n → Nat moreComplex [] = 0 moreComplex (z ∷ zs) with map id xs moreComplex (z ∷ zs) | x ∷ [] = [ n == 1 ] + [ 2 == len ys ] moreComplex (z ∷ zs) | x ∷ x₁ ∷[ k ] xs′ with [ n == 2 + k ] !> map id zs moreComplex (z ∷ zs) | x ∷ x₁ ∷ xs′ | z₁ ∷ [] = [ n == 2 ] moreComplex (z ∷ zs) | x ∷ x₁ ∷ xs′ | z₁ ∷ z₂ ∷[ k ] zs′ = let n+_ = λ m → [ n == 3 + k ] + m n+k = n+ k in case [ n+k == 3 + k + k ] of λ i → let n+i = [ n == 3 + k ] + i in case map id zs′ of λ where [] → [ (n+ i) == 3 + i ] + [ n+k == 3 ] + [ n+i == 3 + i ] (z₃ ∷[ j ] zs″) → let _ = [ n == 4 + j ] _ = [ k == 1 + j ] _ = [ n+k == 4 + j + (1 + j) ] _ = [ (n+ i) == 4 + j + i ] in [ (len xs′) == 2 + j ] + [ (len ys) == (4 + j) * 2 ]
{ "alphanum_fraction": 0.3913270637, "avg_line_length": 26.5833333333, "ext": "agda", "hexsha": "f7fbd76bba0e817eabfd85f00100c074f54c9662", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/RefineParam.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/RefineParam.agda", "max_line_length": 89, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/RefineParam.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": 837, "size": 1914 }
{-# OPTIONS --without-K #-} module FT-Fin where import Data.Fin as F import Data.Nat as N open import FT open import FT-Nat using (toℕ) ------------------------------------------------------------------ -- Finite Types and the natural numbers are intimately related. -- toFin : (b : FT) → F.Fin (N.suc (toℕ b)) toFin b = F.fromℕ (toℕ b) ------------------------------------------------------------------
{ "alphanum_fraction": 0.4534313725, "avg_line_length": 24, "ext": "agda", "hexsha": "010098bf999a43b7144c5ce5c079dca49fe95645", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/OldUnivalence/FT-Fin.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/OldUnivalence/FT-Fin.agda", "max_line_length": 66, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/OldUnivalence/FT-Fin.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 93, "size": 408 }
module Cats.Category.Cat.Facts where open import Cats.Category.Cat.Facts.Initial public using (hasInitial) open import Cats.Category.Cat.Facts.Terminal public using (hasTerminal) open import Cats.Category.Cat.Facts.Product public using (hasBinaryProducts) open import Cats.Category.Cat.Facts.Exponential public using (hasExponentials) open import Cats.Category.Cat using (Cat) open import Cats.Category.Constructions.Product using (HasFiniteProducts) open import Cats.Category.Constructions.CCC using (IsCCC) instance hasFiniteProducts : ∀ lo la l≈ → HasFiniteProducts (Cat lo la l≈) hasFiniteProducts _ _ _ = record {} isCCC : ∀ l → IsCCC (Cat l l l) isCCC _ = record {}
{ "alphanum_fraction": 0.7813411079, "avg_line_length": 34.3, "ext": "agda", "hexsha": "bd44038a16136f90f812e96ed6801cbf158ebaf0", "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/Cat/Facts.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/Cat/Facts.agda", "max_line_length": 78, "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/Cat/Facts.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 167, "size": 686 }
open import Preliminaries module Focusing where data Tp : Set where b : Tp _⇒'_ : Tp → Tp → Tp _×'_ : Tp → Tp → Tp Ctx = List Tp data _∈_ : Tp → Ctx → Set where i0 : ∀ {Γ τ} → τ ∈ τ :: Γ iS : ∀ {Γ τ τ1} → τ ∈ Γ → τ ∈ τ1 :: Γ -- datatype of focused proofs for negative fragment of intuitionistic logic data _,,_|-_ : Ctx → Maybe Tp → Tp → Set where -- focus and init focus : ∀ {Γ A P} → A ∈ Γ → Γ ,, (Some A) |- P -------------------------- focus → Γ ,, None |- P init : ∀ {Γ P} → ------------------ init Γ ,, (Some P) |- P -- synchronous rules arr-l : ∀ {Γ A B P} → Γ ,, None |- A → Γ ,, (Some B) |- P ----------------------------------- impl-left → Γ ,, (Some (A ⇒' B)) |- P conj-l1 : ∀ {Γ A B P} → Γ ,, (Some A) |- P --------------------------- conj-left1 → Γ ,, (Some (A ×' B)) |- P conj-l2 : ∀ {Γ A B P} → Γ ,, (Some B) |- P --------------------------- conj-left2 → Γ ,, (Some (A ×' B)) |- P -- asynchronous rules arr-r : ∀ {Γ A B} → (A :: Γ) ,, None |- B ----------------------- impl-right → Γ ,, None |- (A ⇒' B) conj-r : ∀ {Γ A B} → Γ ,, None |- A → Γ ,, None |- B ------------------------------- conj-right → Γ ,, None |- (A ×' B) -- examples i : ∀ {A} → [] ,, None |- (A ⇒' A) i = arr-r (focus i0 init) #2 : ∀ {A B} → [] ,, None |- (A ⇒' (B ⇒' B)) #2 = arr-r (arr-r (focus i0 init)) k : ∀ {A B} → [] ,, None |- (A ⇒' (B ⇒' A)) k = arr-r (arr-r (focus (iS i0) init)) s : ∀ {A B C} → [] ,, None |- ((A ⇒' (B ⇒' C)) ⇒' ((A ⇒' B) ⇒' (A ⇒' C))) s = arr-r (arr-r (arr-r (focus (iS (iS i0)) (arr-l (focus i0 init) (arr-l (focus (iS i0) (arr-l (focus i0 init) init)) init))))) #5 : ∀ {A B} → [] ,, None |- (A ⇒' (B ⇒' (A ×' B))) #5 = arr-r (arr-r (conj-r (focus (iS i0) init) (focus i0 init))) #6 : ∀ {A B} → [] ,, None |- (A ⇒' (A ×' (B ⇒' B))) #6 = arr-r (conj-r (focus i0 init) (arr-r (focus i0 init))) mp : ∀ {A B} → [] ,, None |- ((A ×' (A ⇒' B)) ⇒' B) mp = arr-r (focus i0 (conj-l2 (arr-l (focus i0 (conj-l1 init)) init)))
{ "alphanum_fraction": 0.35670194, "avg_line_length": 25.7727272727, "ext": "agda", "hexsha": "c071f80c8aa9fb39814cc52d78ca54ec375bc9ba", "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": "scraps/Focusing.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": "scraps/Focusing.agda", "max_line_length": 130, "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": "scraps/Focusing.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": 831, "size": 2268 }
{-# OPTIONS --safe --warning=error --without-K --guardedness #-} open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Setoids.Setoids open import Rings.Definition open import Rings.Lemmas open import Rings.Orders.Partial.Definition open import Rings.Orders.Total.Definition open import Groups.Definition open import Groups.Groups open import Fields.Fields open import Fields.Orders.Total.Definition open import Sets.EquivalenceRelations open import Sequences open import Setoids.Orders.Partial.Definition open import Setoids.Orders.Total.Definition open import Functions.Definition open import LogicalFormulae open import Numbers.Naturals.Semiring open import Numbers.Naturals.Addition open import Numbers.Naturals.Order open import Numbers.Naturals.Order.Lemmas open import Semirings.Definition open import Groups.Homomorphisms.Definition open import Rings.Homomorphisms.Definition open import Groups.Lemmas open import Orders.Total.Definition module Fields.CauchyCompletion.PartiallyOrderedRing {m n o : _} {A : Set m} {S : Setoid {m} {n} A} {_+_ : A → A → A} {_*_ : A → A → A} {_<_ : Rel {m} {o} A} {pOrder : SetoidPartialOrder S _<_} {R : Ring S _+_ _*_} {pRing : PartiallyOrderedRing R pOrder} (order : TotallyOrderedRing pRing) (F : Field R) where private lemma3 : {c d : _} {C : Set c} {S : Setoid {c} {d} C} {_+_ : C → C → C} (G : Group S _+_) → ({x y : C} → Setoid._∼_ S (x + y) (y + x)) → (x y z : C) → Setoid._∼_ S (((Group.inverse G x) + y) + (x + z)) (y + z) lemma3 {S = S} {_+_ = _+_} G ab x y z = transitive +Associative (+WellDefined (transitive (ab {inverse x + y}) (transitive +Associative (transitive (+WellDefined invRight reflexive) identLeft))) reflexive) where open Setoid S open Equivalence (Setoid.eq S) open Group G open Setoid S open SetoidTotalOrder (TotallyOrderedRing.total order) open SetoidPartialOrder pOrder open Equivalence eq open PartiallyOrderedRing pRing open Ring R open Group additiveGroup open Field F open import Fields.Lemmas F open import Rings.Orders.Partial.Lemmas pRing open import Rings.Orders.Total.Lemmas order open import Fields.Orders.Lemmas {F = F} {pRing} (record { oRing = order }) open import Fields.Orders.Total.Lemmas {F = F} (record { oRing = order }) open import Fields.CauchyCompletion.Definition order F open import Fields.CauchyCompletion.Addition order F open import Fields.CauchyCompletion.Multiplication order F open import Fields.CauchyCompletion.Approximation order F open import Fields.CauchyCompletion.Group order F open import Fields.CauchyCompletion.Ring order F open import Fields.CauchyCompletion.Comparison order F open import Fields.CauchyCompletion.Setoid order F open import Groups.Homomorphisms.Lemmas CInjectionGroupHom open import Setoids.Orders.Total.Lemmas (TotallyOrderedRing.total order) private productPositives : (a b : A) → (injection 0R) <Cr a → (injection 0R) <Cr b → (injection 0R) <Cr (a * b) productPositives a b record { e = eA ; 0<e = 0<eA ; N = Na ; property = prA } record { e = eB ; 0<e = 0<eB ; N = Nb ; property = prB } = record { e = eA * eB ; 0<e = orderRespectsMultiplication 0<eA 0<eB ; N = Na +N Nb ; property = ans } where ans : (m : ℕ) → Na +N Nb <N m → ((eA * eB) + index (CauchyCompletion.elts (injection 0R)) m) < (a * b) ans m <m = <WellDefined (symmetric (transitive (+WellDefined reflexive (identityOfIndiscernablesRight _∼_ reflexive (indexAndConst 0R m))) identRight)) reflexive (ringMultiplyPositives 0<eA 0<eB (<WellDefined (transitive (+WellDefined reflexive (identityOfIndiscernablesRight _∼_ reflexive (indexAndConst 0R m))) identRight) reflexive (prA m (inequalityShrinkLeft <m))) (<WellDefined (transitive (+WellDefined reflexive (identityOfIndiscernablesRight _∼_ reflexive (indexAndConst 0R m))) identRight) reflexive (prB m (inequalityShrinkRight <m)))) productPositives' : (a b : CauchyCompletion) (interA interB : A) → (0R < interA) → (0R < interB) → (interA r<C a) → (interB r<C b) → (interA * interB) r<C (a *C b) productPositives' a b interA interB 0<iA 0<iB record { e = interA' ; 0<e = 0<interA' ; N = Na ; pr = prA } record { e = interB' ; 0<e = 0<interB' ; N = Nb ; pr = prB } = record { e = interA' * interB' ; 0<e = orderRespectsMultiplication 0<interA' 0<interB' ; N = Na +N Nb ; pr = ans } where ans : (m : ℕ) → (Na +N Nb <N m) → ((interA * interB) + (interA' * interB')) < index (CauchyCompletion.elts (a *C b)) m ans m <m rewrite indexAndApply (CauchyCompletion.elts a) (CauchyCompletion.elts b) _*_ {m} = <Transitive (<WellDefined identRight (symmetric *DistributesOver+) (<WellDefined reflexive (+WellDefined *Commutative *Commutative) (<WellDefined reflexive (+WellDefined (symmetric *DistributesOver+) (symmetric *DistributesOver+)) (<WellDefined groupIsAbelian (transitive (transitive groupIsAbelian (transitive (symmetric +Associative) (+WellDefined *Commutative (transitive groupIsAbelian (transitive (+WellDefined reflexive *Commutative) (symmetric +Associative)))))) +Associative) (orderRespectsAddition (<WellDefined identRight reflexive (ringAddInequalities (orderRespectsMultiplication 0<iB 0<interA') (orderRespectsMultiplication 0<interB' 0<iA))) ((interA * interB) + (interA' * interB'))))))) (ringMultiplyPositives (<WellDefined identRight reflexive (ringAddInequalities 0<iA 0<interA')) (<WellDefined identRight reflexive (ringAddInequalities 0<iB 0<interB')) (prA m (inequalityShrinkLeft <m)) (prB m (inequalityShrinkRight <m))) <COrderRespectsMultiplication : (a b : CauchyCompletion) → (injection 0R <C a) → (injection 0R <C b) → (injection 0R <C (a *C b)) <COrderRespectsMultiplication a b record { i = interA ; a<i = 0<interA ; i<b = interA<a } record { i = interB ; a<i = 0<interB ; i<b = interB<b } = record { i = interA * interB ; a<i = productPositives interA interB 0<interA 0<interB ; i<b = productPositives' a b interA interB (<CCollapsesL 0R _ 0<interA) (<CCollapsesL 0R _ 0<interB) interA<a interB<b } cOrderRespectsAdditionLeft' : (a : CauchyCompletion) (b : A) (c : A) → (a <Cr b) → (a +C injection c) <C (injection b +C injection c) cOrderRespectsAdditionLeft' a b c record { e = e ; 0<e = 0<e ; N = N ; property = pr } = <CWellDefined {a +C injection c} {a +C injection c} {injection (b + c)} {(injection b) +C (injection c)} (Equivalence.reflexive (Setoid.eq cauchyCompletionSetoid) {a +C injection c}) (GroupHom.groupHom (RingHom.groupHom CInjectionRingHom)) (<CRelaxR (record { e = e ; 0<e = 0<e ; N = N ; property = λ m N<m → <WellDefined (transitive (symmetric +Associative) (+WellDefined reflexive (ans m))) reflexive (orderRespectsAddition (pr m N<m) c) })) where ans : (m : ℕ) → (index (CauchyCompletion.elts a) m + c) ∼ index (apply _+_ (CauchyCompletion.elts a) (constSequence c)) m ans m rewrite indexAndApply (CauchyCompletion.elts a) (constSequence c) _+_ {m} | indexAndConst c m = reflexive l1 : (a : A) (b : CauchyCompletion) → a r<C b → 0R r<C (b +C injection (inverse a)) l1 a b record { e = e ; 0<e = 0<e ; N = N ; pr = pr } = record { e = e ; 0<e = 0<e ; N = N ; pr = λ m N<m → <WellDefined (transitive groupIsAbelian (transitive +Associative (+WellDefined invLeft reflexive))) (ans m) (orderRespectsAddition (pr m N<m) (inverse a)) } where ans : (m : ℕ) → (index (CauchyCompletion.elts b) m + inverse a) ∼ index (CauchyCompletion.elts (b +C injection (inverse a))) m ans m rewrite indexAndApply (CauchyCompletion.elts b) (constSequence (inverse a)) _+_ {m} | indexAndConst (inverse a) m = reflexive l1' : (a : A) (b : CauchyCompletion) → 0R r<C (b +C injection a) → (inverse a) r<C b l1' a b record { e = e ; 0<e = 0<e ; N = N ; pr = pr } = record { e = e ; 0<e = 0<e ; N = N ; pr = λ m N<m → <WellDefined (transitive (+WellDefined identLeft reflexive) groupIsAbelian) (symmetric (ans m)) (orderRespectsAddition (pr m N<m) (inverse a)) } where ans : (m : ℕ) → (index (CauchyCompletion.elts b) m) ∼ (index (CauchyCompletion.elts (b +C injection a)) m + inverse a) ans m rewrite indexAndApply (CauchyCompletion.elts b) (constSequence a) _+_ {m} | indexAndConst a m = transitive (symmetric identRight) (transitive (+WellDefined reflexive (symmetric invRight)) +Associative) l2 : (a : CauchyCompletion) (b : A) → a <Cr b → 0R r<C (injection b +C (-C a)) l2 a b record { e = e ; 0<e = 0<e ; N = N ; property = property } = record { e = e ; 0<e = 0<e ; N = N ; pr = λ m N<m → <WellDefined (transitive (transitive (symmetric +Associative) (+WellDefined reflexive invRight)) groupIsAbelian) (ans m) (orderRespectsAddition (property m N<m) (inverse (index (CauchyCompletion.elts a) m))) } where ans : (m : ℕ) → (b + inverse (index (CauchyCompletion.elts a) m)) ∼ index (CauchyCompletion.elts (injection b +C (-C a))) m ans m rewrite indexAndApply (CauchyCompletion.elts (injection b)) (CauchyCompletion.elts (-C a)) _+_ {m} | indexAndConst b m | mapAndIndex (CauchyCompletion.elts a) inverse m = reflexive l2' : (a : CauchyCompletion) (b : A) → 0R r<C (injection b +C a) → (-C a) <Cr b l2' a b record { e = e ; 0<e = 0<e ; N = N ; pr = pr } = record { e = e ; 0<e = 0<e ; N = N ; property = λ m N<m → <WellDefined (+WellDefined identLeft reflexive) (ans m) (orderRespectsAddition (pr m N<m) (index (CauchyCompletion.elts (-C a)) m)) } where ans : (m : ℕ) → (index (CauchyCompletion.elts (injection b +C a)) m + index (map inverse (CauchyCompletion.elts a)) m) ∼ b ans m rewrite indexAndApply (CauchyCompletion.elts (injection b)) (CauchyCompletion.elts a) _+_ {m} | indexAndConst b m | equalityCommutative (mapAndIndex (CauchyCompletion.elts a) inverse m) = transitive (symmetric +Associative) (transitive (+WellDefined reflexive invRight) identRight) invInj : (i : A) → Setoid._∼_ cauchyCompletionSetoid (injection (inverse i) +C injection i) (injection 0R) invInj i = Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {record { converges = CauchyCompletion.converges (injection (inverse i) +C injection i) }} {record { converges = CauchyCompletion.converges ((-C (injection i)) +C injection i) }} {record { converges = CauchyCompletion.converges (injection 0R) }} (Group.+WellDefinedLeft CGroup {record { converges = CauchyCompletion.converges (injection (inverse i)) }} {record { converges = CauchyCompletion.converges (injection i)}} {record { converges = CauchyCompletion.converges (-C (injection i)) }} homRespectsInverse) (Group.invLeft CGroup {injection i}) cOrderMove : (a b : A) (c : CauchyCompletion) → (injection a +C c) <Cr b → a r<C (injection b +C (-C c)) cOrderMove a b c record { e = e ; 0<e = 0<e ; N = N ; property = property } = record { e = e ; 0<e = 0<e ; N = N ; pr = λ m N<m → <WellDefined (transitive (symmetric +Associative) (transitive (+WellDefined reflexive (transitive (+WellDefined (identityOfIndiscernablesRight _∼_ reflexive (indexAndApply (CauchyCompletion.elts (injection a)) (CauchyCompletion.elts c) _+_ {m})) reflexive) (transitive (symmetric +Associative) (transitive (+WellDefined (identityOfIndiscernablesRight _∼_ reflexive (indexAndConst a m)) invRight) identRight)))) groupIsAbelian)) (transitive (+WellDefined (identityOfIndiscernablesLeft _∼_ reflexive (indexAndConst b m)) (identityOfIndiscernablesRight _∼_ reflexive (mapAndIndex (CauchyCompletion.elts c) inverse m))) (identityOfIndiscernablesLeft _∼_ reflexive (indexAndApply (CauchyCompletion.elts (injection b)) (CauchyCompletion.elts (-C c)) _+_ {m}))) (orderRespectsAddition (property m N<m) (inverse (index (CauchyCompletion.elts c) m))) } cOrderMove' : (a b : A) (c : CauchyCompletion) → (injection a +C (-C c)) <Cr b → a r<C (injection b +C c) cOrderMove' a b c pr = r<CWellDefinedRight _ _ _ (Group.+WellDefinedRight CGroup {record { converges = CauchyCompletion.converges (injection b) }} {record { converges = CauchyCompletion.converges (-C (-C c)) }} {record {converges = CauchyCompletion.converges c }} (invTwice CGroup record { converges = CauchyCompletion.converges c })) (cOrderMove a b (-C c) pr) cOrderMove'' : (a : CauchyCompletion) (b c : A) → (a +C (-C injection b)) <Cr c → a <Cr (b + c) cOrderMove'' a b c record { e = e ; 0<e = 0<e ; N = N ; property = property } = record { e = e ; 0<e = 0<e ; N = N ; property = λ m N<m → <WellDefined (transitive (symmetric +Associative) (+WellDefined reflexive (transitive (+WellDefined (identityOfIndiscernablesRight _∼_ reflexive (indexAndApply (CauchyCompletion.elts a) _ _+_ {m})) reflexive) (transitive (transitive (symmetric +Associative) (+WellDefined reflexive (transitive (+WellDefined (transitive (identityOfIndiscernablesLeft _∼_ reflexive (mapAndIndex _ inverse m)) (inverseWellDefined additiveGroup (identityOfIndiscernablesRight _∼_ reflexive (indexAndConst b m)))) reflexive) invLeft))) identRight)))) groupIsAbelian (orderRespectsAddition (property m N<m) b) } cOrderRespectsAdditionLeft'' : (a b : A) (c : CauchyCompletion) → (a < b) → (injection a +C c) <C (injection b +C c) cOrderRespectsAdditionLeft'' a b c a<b with halve charNot2 (b + inverse a) ... | b-a/2 , prDiff with approximateAbove c b-a/2 (halvePositive' prDiff (moveInequality a<b)) ... | aboveC , (c<aboveC ,, aboveC-C<e) = record { i = a + aboveC ; a<i = <CRelaxR' (SetoidPartialOrder.<WellDefined <COrder (Ring.groupIsAbelian CRing {record { converges = CauchyCompletion.converges c }} {record { converges = CauchyCompletion.converges (injection a) }}) (Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {record { converges = CauchyCompletion.converges (injection aboveC +C injection a) }} {record { converges = CauchyCompletion.converges (injection a +C injection aboveC) }} {record { converges = CauchyCompletion.converges (injection (a + aboveC)) }} (Ring.groupIsAbelian CRing {record { converges = CauchyCompletion.converges (injection aboveC) }} {record { converges = CauchyCompletion.converges (injection a) }}) (Equivalence.symmetric (Setoid.eq cauchyCompletionSetoid) {record { converges = CauchyCompletion.converges (injection (a + aboveC)) }} {record { converges = CauchyCompletion.converges (injection a +C injection aboveC) }} (GroupHom.groupHom CInjectionGroupHom))) (cOrderRespectsAdditionLeft' c aboveC a c<aboveC)) ; i<b = cOrderMove' _ _ _ (<CRelaxR' (<CTransitive (<CRelaxR t) (<CInherited u))) } where g : ((injection aboveC +C (-C c)) +C injection a) <C ((injection b-a/2) +C (injection a)) g = cOrderRespectsAdditionLeft' _ _ a (<CRelaxR' aboveC-C<e) g' : ((injection aboveC +C (-C c)) +C injection a) <C (injection (b-a/2 + a)) g' = <CWellDefined (Equivalence.reflexive (Setoid.eq cauchyCompletionSetoid) {record { converges = CauchyCompletion.converges ((injection aboveC +C (-C c)) +C injection a) }}) (Equivalence.symmetric (Setoid.eq cauchyCompletionSetoid) {record { converges = CauchyCompletion.converges (injection (b-a/2 + a)) }} {record { converges = CauchyCompletion.converges (injection b-a/2 +C injection a) }} (GroupHom.groupHom CInjectionGroupHom)) g t : (injection (a + aboveC) +C (-C c)) <Cr (b-a/2 + a) t = <CRelaxR' (<CWellDefined (Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {record { converges = CauchyCompletion.converges (((injection aboveC) +C (-C c)) +C injection a) }} {record { converges = CauchyCompletion.converges (injection a +C ((injection aboveC) +C (-C c))) }} {record { converges = CauchyCompletion.converges (injection (a + aboveC) +C (-C c)) }} (Ring.groupIsAbelian CRing {record { converges = CauchyCompletion.converges (injection aboveC +C (-C c)) }} {record { converges = CauchyCompletion.converges (injection a) }}) (Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {record { converges = CauchyCompletion.converges (injection a +C ((injection aboveC) +C (-C c))) }} {record { converges = CauchyCompletion.converges (((injection a) +C (injection aboveC)) +C (-C c)) }} {record { converges = CauchyCompletion.converges ((injection (a + aboveC)) +C (-C c)) }} (Group.+Associative CGroup {record { converges = CauchyCompletion.converges (injection a) }} {record { converges = CauchyCompletion.converges (injection aboveC) }} {record { converges = CauchyCompletion.converges (-C c) }}) (Group.+WellDefinedLeft CGroup {record { converges = CauchyCompletion.converges (injection a +C injection aboveC) }} {record { converges = CauchyCompletion.converges (-C c) }} {record { converges = CauchyCompletion.converges (injection (a + aboveC)) }} (Equivalence.symmetric (Setoid.eq cauchyCompletionSetoid) {record { converges = CauchyCompletion.converges (injection (a + aboveC)) }} {record { converges = CauchyCompletion.converges (injection a +C injection aboveC) }} (GroupHom.groupHom CInjectionGroupHom))))) (Equivalence.reflexive (Setoid.eq cauchyCompletionSetoid) {record { converges = CauchyCompletion.converges (injection (b-a/2 + a)) }}) g') lemm : 0R < b-a/2 lemm = halvePositive' prDiff (moveInequality a<b) u : (b-a/2 + a) < b u = <WellDefined (transitive (+WellDefined (symmetric prDiff) reflexive) (transitive groupIsAbelian (transitive +Associative (transitive (+WellDefined (transitive (symmetric +Associative) (transitive (+WellDefined reflexive invLeft) identRight)) reflexive) groupIsAbelian)))) (transitive (symmetric +Associative) (transitive (+WellDefined reflexive invLeft) identRight)) (orderRespectsAddition (<WellDefined identLeft (transitive (transitive +Associative (transitive (+WellDefined (transitive groupIsAbelian (+WellDefined reflexive (symmetric (invTwice additiveGroup b-a/2)))) reflexive) (symmetric +Associative))) (+WellDefined reflexive (symmetric (invContravariant additiveGroup)))) (orderRespectsAddition lemm (b + inverse a))) (a + inverse b-a/2)) cOrderRespectsAdditionLeft''Flip : (a b : A) (c : CauchyCompletion) → (a < b) → (c +C injection a) <C (c +C injection b) cOrderRespectsAdditionLeft''Flip a b c a<b = <CWellDefined ((Ring.groupIsAbelian CRing {record { converges = CauchyCompletion.converges (injection a) }} {record { converges = CauchyCompletion.converges c }})) (Ring.groupIsAbelian CRing {record { converges = CauchyCompletion.converges (injection b) }} {record { converges = CauchyCompletion.converges c }}) (cOrderRespectsAdditionLeft'' a b c a<b) cOrderRespectsAdditionLeft''' : (a b : CauchyCompletion) (c : A) → (a <C b) → (a +C injection c) <C (b +C injection c) cOrderRespectsAdditionLeft''' a b c record { i = i ; a<i = a<i ; i<b = i<b } = <CTransitive (cOrderRespectsAdditionLeft' a i c a<i) (<CWellDefined (Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {record { converges = CauchyCompletion.converges (injection (c + i)) }} {record { converges = CauchyCompletion.converges (injection c +C injection i) }} {record { converges = CauchyCompletion.converges (injection i +C injection c) }} (GroupHom.groupHom CInjectionGroupHom) (Ring.groupIsAbelian CRing {record { converges = CauchyCompletion.converges (injection c) }} {record { converges = CauchyCompletion.converges (injection i) }})) (Ring.groupIsAbelian CRing {record { converges = CauchyCompletion.converges (injection c) }} {record { converges = CauchyCompletion.converges b }}) (flip<C' {record { converges = CauchyCompletion.converges (injection (c + i)) }} {record { converges = CauchyCompletion.converges (injection c +C b) }} (<CWellDefined (Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {record { converges = CauchyCompletion.converges ((-C b) +C injection (inverse c)) }} {record { converges = CauchyCompletion.converges ((-C b) +C (-C (injection c))) }} {record { converges = CauchyCompletion.converges (-C (injection c +C b)) }} (Group.+WellDefinedRight CGroup {record { converges = CauchyCompletion.converges (-C b) }} {record { converges = CauchyCompletion.converges (injection (inverse c)) }} {record { converges = CauchyCompletion.converges (-C (injection c)) }} homRespectsInverse) (Equivalence.symmetric (Setoid.eq cauchyCompletionSetoid) {record { converges = CauchyCompletion.converges (-C (injection c +C b)) }} {record { converges = CauchyCompletion.converges ((-C b) +C (-C (injection c))) }} (invContravariant CGroup {record { converges = CauchyCompletion.converges (injection c) }} {record { converges = CauchyCompletion.converges b }}))) homRespectsInverse' (cOrderRespectsAdditionLeft' (-C b) (inverse i) (inverse c) (flipR<C i<b))))) cOrderRespectsAdditionRightZero : (a : CauchyCompletion) → (0R r<C a) → (c : CauchyCompletion) → c <C (a +C c) cOrderRespectsAdditionRightZero a record { e = e ; 0<e = 0<e ; N = N1 ; pr = pr } c with halve charNot2 e ... | e/2 , prE/2 with approximateAbove c e/2 (halvePositive' prE/2 0<e) ... | c+ , (c<c+ ,, c+<c+e/2) with approximateBelow (a +C c) e/2 (halvePositive' prE/2 0<e) ... | α , (α<a+c ,, a+c<α+e/2) with totality c+ α ... | inl (inl c+<α) = record { i = α ; a<i = <CRelaxR' (<CTransitive (<CRelaxR c<c+) (<CInherited c+<α)) ; i<b = α<a+c } -- The remaining cases can't actually happen, but it's easier to go this way ... | inr c+=α = record { i = α ; a<i = <CrWellDefinedRight c _ _ c+=α c<c+ ; i<b = α<a+c } ... | inl (inr α<c+) with cOrderMove'' (a +C c) α e/2 (<CRelaxR' a+c<α+e/2) ... | record { e = f ; 0<e = 0<f ; N = M ; property = pr2 } with CauchyCompletion.converges c e/2 (halvePositive' prE/2 0<e) ... | N3 , pr4 = record { i = α ; a<i = record { e = f ; 0<e = 0<f ; N = u ; property = ans } ; i<b = α<a+c } where u : ℕ u = succ ((N1 +N M) +N N3) help : (m : ℕ) → u <N m → index (CauchyCompletion.elts c) m < (e/2 + index (CauchyCompletion.elts c) u) help m size with pr4 {m} {u} (lessTransitive (le (N1 +N M) refl) size) (le (N1 +N M) refl) ... | bl with totality 0G (index (CauchyCompletion.elts c) m + inverse (index (CauchyCompletion.elts c) u)) ... | inl (inl 0<t) = <WellDefined (transitive (symmetric +Associative) (transitive (+WellDefined reflexive invLeft) identRight)) reflexive (orderRespectsAddition bl (index (CauchyCompletion.elts c) u)) ... | inl (inr cm-cU<0) = <Transitive (<WellDefined (transitive (transitive (symmetric +Associative) (+WellDefined reflexive invLeft)) identRight) reflexive (orderRespectsAddition cm-cU<0 (index (CauchyCompletion.elts c) u))) (orderRespectsAddition (halvePositive' prE/2 0<e) (index (CauchyCompletion.elts c) u)) ... | inr (0=t) = <WellDefined (transitive (symmetric +Associative) (transitive (+WellDefined reflexive invLeft) identRight)) reflexive (orderRespectsAddition bl (index (CauchyCompletion.elts c) u)) ans : (m : ℕ) → u <N m → (f + index (CauchyCompletion.elts c) m) < α ans m size = <Transitive (<WellDefined reflexive +Associative (<WellDefined groupIsAbelian groupIsAbelian (orderRespectsAddition (<Transitive (<WellDefined reflexive (transitive (+WellDefined (symmetric (transitive (+WellDefined (transitive identLeft (symmetric prE/2)) reflexive) (transitive (transitive (symmetric +Associative) (+WellDefined reflexive invRight)) identRight))) reflexive) (symmetric +Associative)) (help m size)) (<WellDefined reflexive (transitive groupIsAbelian (transitive (symmetric +Associative) (+WellDefined reflexive groupIsAbelian))) (orderRespectsAddition (pr u (le (M +N N3) (applyEquality succ (transitivity (additionNIsCommutative _ N1) (Semiring.+Associative ℕSemiring N1 M _))))) (inverse e/2 + index (CauchyCompletion.elts c) u)))) f))) (<WellDefined (transitive groupIsAbelian (transitive +Associative (+WellDefined groupIsAbelian (identityOfIndiscernablesRight _∼_ reflexive (indexAndApply (CauchyCompletion.elts a) (CauchyCompletion.elts c) _+_ {u}))))) (transitive (transitive (symmetric +Associative) (+WellDefined reflexive invRight)) identRight) (orderRespectsAddition (pr2 u (le (N1 +N N3) (applyEquality succ (transitivity (equalityCommutative (Semiring.+Associative ℕSemiring N1 _ _)) (transitivity (applyEquality (N1 +N_) (additionNIsCommutative N3 M)) (Semiring.+Associative ℕSemiring N1 _ _)))))) (inverse e/2))) cOrderRespectsAdditionLeft : (a : CauchyCompletion) (b : A) (c : CauchyCompletion) → (a <Cr b) → (a +C c) <C (injection b +C c) cOrderRespectsAdditionLeft a b c a<b = <CWellDefined {record { converges = CauchyCompletion.converges (a +C c) }}{record { converges = CauchyCompletion.converges (a +C c) }}{record { converges = CauchyCompletion.converges (((-C a) +C injection b) +C (a +C c)) }}{record { converges = CauchyCompletion.converges (injection b +C c) }} (Equivalence.reflexive (Setoid.eq cauchyCompletionSetoid) {record { converges = CauchyCompletion.converges (a +C c)}}) (lemma3 CGroup (λ {x} {y} → Ring.groupIsAbelian CRing {x} {y}) a (injection b) c) (cOrderRespectsAdditionRightZero ((-C a) +C injection b) (r<CWellDefinedLeft (inverse b + b) 0R ((-C a) +C injection b) invLeft (<CRelaxL' (<CWellDefined {record { converges = CauchyCompletion.converges (injection (inverse b) +C injection b) }}{record { converges = CauchyCompletion.converges (injection (inverse b + b)) }}{record { converges = CauchyCompletion.converges ((-C a) +C injection b) }}{record { converges = CauchyCompletion.converges ((-C a) +C injection b) }} (GroupHom.groupHom' CInjectionGroupHom) (Equivalence.reflexive (Setoid.eq cauchyCompletionSetoid) {record { converges = CauchyCompletion.converges ((-C a) +C injection b) }}) (cOrderRespectsAdditionLeft''' _ _ b (<CRelaxL (flip<CR a<b)))))) (a +C c)) lemma2 : (a b : CauchyCompletion) → Setoid._∼_ cauchyCompletionSetoid (Group.inverse CGroup ((-C a) +C (-C b))) (a +C b) lemma2 a b = tr {record { converges = CauchyCompletion.converges (-C ((-C a) +C (-C b))) }} {record { converges = CauchyCompletion.converges ((-C (-C b)) +C (-C (-C a))) }} {record { converges = CauchyCompletion.converges (a +C b) }} (invContravariant CGroup {record { converges = CauchyCompletion.converges (-C a) }} {record { converges = CauchyCompletion.converges (-C b) }}) (tr {record { converges = CauchyCompletion.converges ((-C (-C b)) +C (-C (-C a))) }} {record { converges = CauchyCompletion.converges (b +C a) }} {record { converges = CauchyCompletion.converges (a +C b) }} (Group.+WellDefined CGroup {record { converges = CauchyCompletion.converges (-C (-C b)) }} {record { converges = CauchyCompletion.converges (-C (-C a)) }} {record { converges = CauchyCompletion.converges b }} {record { converges = CauchyCompletion.converges a }} (invTwice CGroup b) (invTwice CGroup a)) (Ring.groupIsAbelian CRing {record { converges = CauchyCompletion.converges b }} {record { converges = CauchyCompletion.converges a }})) where open Setoid cauchyCompletionSetoid open Equivalence (Setoid.eq cauchyCompletionSetoid) renaming (transitive to tr) cOrderRespectsAdditionRight : (a : A) (b : CauchyCompletion) (c : CauchyCompletion) → (a r<C b) → (injection a +C c) <C (b +C c) cOrderRespectsAdditionRight a b c a<b = <CWellDefined (Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {record { converges = CauchyCompletion.converges (Group.inverse CGroup (injection (inverse a) +C (-C c))) }} {record { converges = CauchyCompletion.converges (Group.inverse CGroup ((-C injection a) +C (-C c))) }} {record { converges = CauchyCompletion.converges (injection a +C c) }} (inverseWellDefined CGroup {record { converges = CauchyCompletion.converges (injection (inverse a) +C (-C c)) }} {record { converges = CauchyCompletion.converges ((-C (injection a)) +C (-C c)) }} (Group.+WellDefinedLeft CGroup {record { converges = CauchyCompletion.converges (injection (inverse a)) }} {record { converges = CauchyCompletion.converges (-C c) }} {record { converges = CauchyCompletion.converges (-C (injection a)) }} homRespectsInverse)) (lemma2 (injection a) c)) (lemma2 b c) (flip<C (cOrderRespectsAdditionLeft _ _ (Group.inverse CGroup c) (flipR<C a<b))) cOrderRespectsAddition : (a b : CauchyCompletion) → (a <C b) → (c : CauchyCompletion) → (a +C c) <C (b +C c) cOrderRespectsAddition a b record { i = i ; a<i = a<i ; i<b = i<b } c = SetoidPartialOrder.<Transitive <COrder (cOrderRespectsAdditionLeft a i c a<i) (cOrderRespectsAdditionRight i b c i<b) CpOrderedRing : PartiallyOrderedRing CRing <COrder PartiallyOrderedRing.orderRespectsAddition CpOrderedRing {a} {b} = cOrderRespectsAddition a b PartiallyOrderedRing.orderRespectsMultiplication CpOrderedRing {a} {b} 0<a 0<b = <COrderRespectsMultiplication a b 0<a 0<b
{ "alphanum_fraction": 0.7112265451, "avg_line_length": 152.9675675676, "ext": "agda", "hexsha": "e0d8229036cf708517f01885b899548f223759ba", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Fields/CauchyCompletion/PartiallyOrderedRing.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Fields/CauchyCompletion/PartiallyOrderedRing.agda", "max_line_length": 1981, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Fields/CauchyCompletion/PartiallyOrderedRing.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": 9278, "size": 28299 }
{-# OPTIONS --cubical-compatible --show-implicit #-} -- {-# OPTIONS -v tc.data:100 #-} module WithoutK9 where module Eq {A : Set} (x : A) where data _≡_ : A → Set where refl : _≡_ x open Eq module Bad {A : Set} {x : A} where module E = Eq x weak-K : {y : A} (p q : E._≡_ y) (α β : p ≡ q) → α ≡ β weak-K refl .refl refl refl = refl
{ "alphanum_fraction": 0.5542857143, "avg_line_length": 18.4210526316, "ext": "agda", "hexsha": "075df493cebb9904279beba12dff166d11653019", "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/Fail/WithoutK9.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/Fail/WithoutK9.agda", "max_line_length": 56, "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/Fail/WithoutK9.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 135, "size": 350 }
module Generate where open import Data.List open import Data.Fin hiding (_+_) open import Data.Nat open import Data.Product open import Data.Bool open import Function using (_∘_ ; _$_ ; _∋_ ; id ; case_return_of_ ; flip ) open import Function.Injection hiding (_∘_) open import Function.Surjection hiding (_∘_) open import Function.Bijection hiding (_∘_) open import Function.LeftInverse hiding (_∘_) open import Relation.Binary using (Setoid ; Decidable) open import Relation.Binary.PropositionalEquality hiding ( [_] ) open import Relation.Nullary.Negation open import Relation.Nullary open import Function.Equality using (_⟶_ ; _⟨$⟩_ ; Π ) open import Reflection open import Level open import Serializer open import Helper.Fin open import Helper.CodeGeneration open import Serializer.Bool open import Serializer.Fin open import With hiding (subst) -- ; _+_ ; A) open Serializer.Serializer {{...}} --open Serializer.Serializer {{Fin 2}} ------------------------- -- Generic from/to term's. data Test : Set where A : Bool -> Test B : Bool -> Test C : Bool -> Test D : Bool -> Test conSize : (n : Name) -> Term conSize n with (definition n) conSize n | constructor′ with (type n) conSize n | constructor′ | el (lit n₁) (pi (arg i (el s t)) t₂) = def (quote size) [ a1 t ] conSize n | constructor′ | el _ _ = quoteTerm 0 conSize n | _ = quoteTerm 0 sumTerms : List Name -> Term sumTerms [] = quoteTerm 0 sumTerms (x ∷ ls) = def (quote _+_) (a (conSize x) ∷ a (sumTerms ls) ∷ []) cons`` : (n : Name) -> List (_×_ Name (_×_ (List Name) (List Name))) cons`` n = zipWith _,_ (cons n) (zipWith _,_ (inits (cons n)) (drop 1 (tails (cons n)))) {- fromTest : Test -> Fin 4 fromTest (A z) = +₁ 2 (2 + 0) (fromBool z) fromTest (B z) = +₂ 2 2 (fromBool z) toTest : Fin 4 -> Test toTest x = (Helper.Fin.[ (λ z₁ → A (toBool z₁)) , (λ z₁ → B (toBool z₁)) ] (⨁ 2 2 x)) -} {- fromTest : Test -> Fin 6 fromTest (A x) = +₁ 4 2 (+₁ 2 2 (from x)) fromTest (B x) = +₁ 4 2 (+₂ 2 2 (from x)) fromTest (C x) = +₂ 4 2 (from x) toTest : Fin 6 -> Test toTest x = Helper.Fin.[ (\y -> Helper.Fin.[ (\z -> A $ to z) , (\z -> B $ to z) ] (⨁ 2 2 y) ) , (\y -> C $ to y) ] (⨁ 4 2 x) -} cons` : Name -> List (_×_ Name (_×_ (List Name) (List Name))) cons` n = zipWith _,_ (reverse (cons n)) (zipWith _,_ (inits (reverse (cons n))) (Data.List.map reverse (drop 1 (tails (reverse (cons n)))))) {-# TERMINATING #-} genFrom : (n : Name) -> FunctionDef genFrom n = fun-def (t0 $ fun_type) clauses where fun_type = pi (a ∘ t0 $ def n []) (abs "_" (t0 (def (quote Fin) [ a (sumTerms (cons n)) ]))) construct : (_×_ Name (_×_ (List Name) (List Name))) -> Term construct (c , [] , []) = (def (quote from) [ a (var 0 []) ]) construct (c , x ∷ xs , []) = def (quote +₂) ((a (sumTerms (x ∷ xs))) ∷ (a (conSize c)) ∷ (a (construct (c , ([] , [])))) ∷ []) construct (c , xs , y ∷ ys) = def (quote +₁) ((a (sumTerms (c ∷ (xs ++ ys)))) ∷ (a (conSize y)) ∷ (a (construct (c , (xs , ys)))) ∷ []) clauses = Data.List.map (\{ (c , xs) -> clause [ a $ con c [ a (var "_") ] ] (construct (c , xs))}) (cons` n) unquoteDecl fromTest = genFrom (quote Test) genTo : (n : Name) -> FunctionDef genTo n = fun-def (t0 $ fun_type) clauses where fun_type = pi (a (t0 (def (quote Fin) [ a (sumTerms (cons n)) ]))) (abs "_" (t0 $ def n [])) match : List Name -> Term match [] = unknown match (x ∷ []) = con x [ a (def (quote to) [ a (var 0 []) ]) ] match (x ∷ x₁ ∷ cons) = def (quote [_,_]) ( (a (lam visible (abs "_" (match (x₁ ∷ cons))))) -- (a (lam visible (abs "_" (con x [ a (def (quote to) [ a (var 0 []) ]) ])))) ∷ (a (lam visible (abs "_" (con x [ a (def (quote to) [ a (var 0 []) ]) ])))) ∷ (a (def (quote ⨁) ((a (sumTerms (x₁ ∷ cons))) ∷ (a (quoteTerm 2)) ∷ (a (var 0 [])) ∷ []))) ∷ []) clauses = [ clause [ a (var "_") ] (match (cons n)) ] unquoteDecl toTest = genTo (quote Test) makePresEq : {T : Set} {n : ℕ} -> (T -> (Fin n)) -> setoid T ⟶ setoid (Fin n) makePresEq f = record { _⟨$⟩_ = f ; cong = (\{ {i} {.i} refl → refl }) } genPresEq' : (n : Name) -> Term genPresEq' n = def (quote makePresEq) [ a (def (quote fromTest) []) ] -- [(a (genFrom' n))] where setoidFrom = def (quote setoid) [(a (def n []))] setoidTo = def (quote setoid) [(a (def (quote Fin) [ a (sumTerms (cons n)) ]))] fun_type1 = t0 (def (quote _⟶_) ( (a setoidFrom) ∷ (a setoidTo) ∷ [])) genPresEq : (n : Name) -> FunctionDef genPresEq n = fun-def fun_type1 [(clause [] (genPresEq' n) ) ] where setoidFrom = def (quote setoid) [(a (def n []))] setoidTo = def (quote setoid) [(a (def (quote Fin) [ a (sumTerms (cons n)) ]))] fun_type1 = t0 (def (quote _⟶_) ( (a setoidFrom) ∷ (a setoidTo) ∷ [])) unquoteDecl genTest = genPresEq (quote Test) t2 : {x y : Bool} → fromBool x ≡ fromBool y → x ≡ y t2 = Bijective.injective (Bijection.bijective (bijection {Bool})) bijection' : Term bijection' = quoteTerm t2 refl' : Term refl' = pat-lam [ clause ( (a1 (var "d1")) ∷ (a1 (dot)) ∷ ( a (con (quote refl) []) ) ∷ []) (con (quote refl) []) ] [] x₁≡x₂' : Term x₁≡x₂' = def (quote _≡_) ((a $ var 1 []) ∷ (a $ var 0 []) ∷ []) +-eq₁' : Term -> Term +-eq₁' t = (def (quote +-eq₁) [ a t ]) +-eq₂' : ℕ -> ℕ -> Term -> Term +-eq₂' n1 n2 t = (def (quote +-eq₂) ( a1 (lit (nat n1)) ∷ a1 (lit (nat n2)) ∷ a t ∷ [] ) ) ¬+-eq₁' : Term ¬+-eq₁' = def (quote ¬+-eq₁) [] ¬+-eq₂' : Term ¬+-eq₂' = def (quote ¬+-eq₂) [] _$'_ : Term -> Term -> Term x $' y = def (quote _$_) ((a x) ∷ (a y) ∷ []) contradiction' : Term -> Term -> Term contradiction' t1 t2 = def (quote contradiction) ( (a t1) ∷ (a t2) ∷ [] ) genInjective : (n : Name) -> FunctionDef genInjective n = fun-def fun_type1 [ (clause [] ( pat-lam (clauses 0 (var 0 []) (indexed_cons)) [] )) ] where fun_type1 = t0 (def (quote Injective) [ (a (def (quote genTest) [])) ] ) ncons = (length (cons n)) indexed_cons = zipWith (_,_) (cons n) ((downFrom (length (cons n)))) clause'' : Name -> Name -> Term -> Clause clause'' l r t = clause ( (a1 $ con l [ a (var "x") ]) ∷ (a1 $ con r [ a (var "y") ]) ∷ (a (var "p")) ∷ [] ) t clause' : ℕ -> Term -> (_×_ Name ℕ) -> (_×_ Name ℕ) -> Clause clause' n t (n1 , i1) (n2 , i2) with (Data.Nat.compare i1 i2) clause' n t (n1 , i1) (n2 , ._) | less .i1 k = clause'' n1 n2 (contradiction' (t) ¬+-eq₁') clause' n t (n1 , ℕ.zero) (n2 , .0) | equal .0 = clause'' n1 n2 (with' x₁≡x₂' (bijection' $' (t)) refl') clause' n t (n1 , ℕ.suc i1) (n2 , .(ℕ.suc i1)) | equal .(ℕ.suc i1) = clause'' n1 n2 (with' x₁≡x₂' (bijection' $' (+-eq₂' ((ncons ∸ n ∸ 1) * 2) 2 (t))) refl') clause' n t (n1 , ._) (n2 , i2) | greater .i2 k = clause'' n1 n2 (contradiction' (t) ¬+-eq₂') clauses : ℕ -> Term -> List (_×_ Name ℕ) -> List Clause clauses n t [] = [] clauses n t (x ∷ cs) = (Data.List.map (clause' n t x) (x ∷ cs)) ++ (Data.List.map ((flip (clause' n t)) x) cs) ++ (clauses (ℕ.suc n) (+-eq₁' t) cs) -- Data.List.map clause' c unquoteDecl testInjective = genInjective (quote Test) makePresEqTo : {T : Set} {n : ℕ} -> ((Fin n) -> T) -> setoid (Fin n) ⟶ setoid T makePresEqTo f = record { _⟨$⟩_ = f ; cong = (\{ {i} {.i} refl → refl }) } genPresEqTo' : (n : Name) -> Term genPresEqTo' n = def (quote makePresEqTo) [ a (def (quote toTest) []) ] where setoidTo = def (quote setoid) [(a (def n []))] setoidFrom = def (quote setoid) [(a (def (quote Fin) [ a (sumTerms (cons n)) ]))] fun_type1 = t0 (def (quote _⟶_) ( (a setoidFrom) ∷ (a setoidTo) ∷ [])) genPresEqTo : (n : Name) -> FunctionDef genPresEqTo n = fun-def infer_type [ (clause [] (genPresEqTo' n) ) ] unquoteDecl genTestTo = genPresEqTo (quote Test) Fin+' : ℕ -> ℕ -> Term Fin+' n1 n2 = def (quote Fin+) ((a (lit (nat n1))) ∷ (a (lit (nat n2))) ∷ (a $ var 0 []) ∷ []) ⨁' : ℕ -> ℕ -> Term ⨁' n1 n2 = def (quote ⨁) ((a (lit (nat n1))) ∷ (a (lit (nat n2))) ∷ (a $ var 0 []) ∷ []) x₂≡x₁' : Term x₂≡x₁' = def (quote _≡_) ( (a $ var 0 []) ∷ (a $ var 1 []) ∷ []) right-inverse-of' : Term right-inverse-of' = quoteTerm (Surjective.right-inverse-of (Bijective.surjective (Bijection.bijective (bijection {Bool})))) fromToBool' : Term fromToBool' = (def (quote fromBool) (arg (arg-info visible relevant) (def (quote toBool) (arg (arg-info visible relevant) (var 0 []) ∷ [])) ∷ [])) matchFin+ : Term -> Term -> Term matchFin+ t1 t2 = pat-lam ((clause ( (a1 (dot)) ∷ (a (con (quote is+₁) [ a $ (var "u") ])) ∷ []) t1) ∷ (clause ( (a1 (dot)) ∷ (a (con (quote is+₂) [ a $ (var "u") ])) ∷ []) t2) ∷ []) [] step2 : Term step2 = rewrite'' x₂≡x₁' (quoteTerm fromToBool') (quoteTerm (right-inverse-of' $' var 0 [])) refl' ⨁'' : ℕ -> ℕ -> Term ⨁'' m1 m2 = With.subst (quoteTerm (⨁' 1337 2)) (lit (nat 1337)) (lit (nat m1)) genRightInv' : (List Name) -> Term genRightInv' [] = unknown genRightInv' (x ∷ []) = step2 genRightInv' (x ∷ x₁ ∷ cons) = with'' (Fin+' l 2) (⨁'' l 2) (matchFin+ (genRightInv' (x₁ ∷ cons)) step2) where l = (length (x₁ ∷ cons) * 2) right-inverse-of : genTestTo RightInverseOf genTest right-inverse-of x = unquote (genRightInv' (cons (quote Test))) {- from-bijection : Bijection (setoid Test) (setoid (Fin 6)) from-bijection = record { to = genTest ; bijective = record { injective = testInjective ; surjective = record { from = genTestTo ; right-inverse-of = right-inverse-of } } } instance serializerTest : Serializer Test serializerTest = record { size = 6 ; from = fromTest ; to = toTest ; bijection = from-bijection } -}
{ "alphanum_fraction": 0.5629228687, "avg_line_length": 37.52734375, "ext": "agda", "hexsha": "b9828e112d7c6b75d3989e340951d858a99d0167", "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": "cb95986b772b7a01195619be5e8e590f2429c759", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mathijsb/generic-in-agda", "max_forks_repo_path": "Generate.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cb95986b772b7a01195619be5e8e590f2429c759", "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": "mathijsb/generic-in-agda", "max_issues_repo_path": "Generate.agda", "max_line_length": 185, "max_stars_count": 6, "max_stars_repo_head_hexsha": "cb95986b772b7a01195619be5e8e590f2429c759", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mathijsb/generic-in-agda", "max_stars_repo_path": "Generate.agda", "max_stars_repo_stars_event_max_datetime": "2016-08-04T16:05:24.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-09T09:59:27.000Z", "num_tokens": 3606, "size": 9607 }
{-# OPTIONS --without-K #-} module library.Basics where open import library.Base public open import library.PathGroupoid public open import library.PathFunctor public open import library.NType public open import library.Equivalences public open import library.Univalence public open import library.Funext public open import library.PathOver public
{ "alphanum_fraction": 0.8314285714, "avg_line_length": 26.9230769231, "ext": "agda", "hexsha": "badafb97b5ca7049254cfb029dec121a2a713ddf", "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/library/Basics.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/library/Basics.agda", "max_line_length": 39, "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/library/Basics.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": 72, "size": 350 }
open import FRP.JS.Nat using ( ℕ ; _*_ ) open import FRP.JS.Bool using ( Bool ) open import FRP.JS.String using ( String ) open import FRP.JS.RSet using ( ⟦_⟧ ; ⟨_⟩ ) open import FRP.JS.Behaviour using ( Beh ) open import FRP.JS.Delay using ( Delay ) renaming ( _≟_ to _≟d_ ; _≠_ to _≠d_ ; _≤_ to _≤d_ ; _<_ to _<d_ ; _+_ to _+d_ ; _∸_ to _∸d_ ) module FRP.JS.Time where open import FRP.JS.Time.Core public using ( Time ; epoch ) _≟_ : Time → Time → Bool epoch t ≟ epoch u = t ≟d u {-# COMPILED_JS _≟_ function(d) { return function(e) { return d === e; }; } #-} _≠_ : Time → Time → Bool epoch t ≠ epoch u = t ≠d u {-# COMPILED_JS _≠_ function(d) { return function(e) { return d !== e; }; } #-} _≤_ : Time → Time → Bool epoch t ≤ epoch u = t ≤d u {-# COMPILED_JS _≤_ function(d) { return function(e) { return d <= e; }; } #-} _<_ : Time → Time → Bool epoch t < epoch u = t <d u {-# COMPILED_JS _<_ function(d) { return function(e) { return d < e; }; } #-} _+_ : Time → Delay → Time epoch t + d = epoch (t +d d) {-# COMPILED_JS _+_ function(d) { return function(e) { return d + e; }; } #-} _∸_ : Time → Time → Delay epoch t ∸ epoch u = t ∸d u {-# COMPILED_JS _∸_ function(d) { return function(e) { return Math.min(0, d - e); }; } #-} postulate toUTCString : Time → String every : Delay → ⟦ Beh ⟨ Time ⟩ ⟧ {-# COMPILED_JS toUTCString function(t) { return require("agda.frp").date(t).toUTCString(); } #-} {-# COMPILED_JS every function(d) { return function(t) { return require("agda.frp").every(d); }; } #-}
{ "alphanum_fraction": 0.6031434185, "avg_line_length": 31.1632653061, "ext": "agda", "hexsha": "fc3b27d3f653e702bcb88628c81b10a14440245a", "lang": "Agda", "max_forks_count": 7, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z", "max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z", "max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_forks_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_forks_repo_name": "agda/agda-frp-js", "max_forks_repo_path": "src/agda/FRP/JS/Time.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_issues_repo_name": "agda/agda-frp-js", "max_issues_repo_path": "src/agda/FRP/JS/Time.agda", "max_line_length": 102, "max_stars_count": 63, "max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_stars_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_stars_repo_name": "agda/agda-frp-js", "max_stars_repo_path": "src/agda/FRP/JS/Time.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z", "num_tokens": 543, "size": 1527 }
module Lib.Logic where infix 30 _∨_ infix 40 _∧_ infix 50 ¬_ data _∨_ (A B : Set) : Set where inl : A -> A ∨ B inr : B -> A ∨ B data _∧_ (A B : Set) : Set where _,_ : A -> B -> A ∧ B data False : Set where record True : Set where ¬_ : Set -> Set ¬ A = A -> False
{ "alphanum_fraction": 0.5415162455, "avg_line_length": 14.5789473684, "ext": "agda", "hexsha": "fe5b3ee75b8d192ca31075f429d2dbec7823b7d7", "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": "examples/simple-lib/Lib/Logic.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "examples/simple-lib/Lib/Logic.agda", "max_line_length": 32, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "examples/simple-lib/Lib/Logic.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": 119, "size": 277 }
------------------------------------------------------------------------ -- Lexicographic induction ------------------------------------------------------------------------ module Induction.Lexicographic where open import Induction open import Data.Product -- The structure of lexicographic induction. _⊗_ : ∀ {a b} → RecStruct a → RecStruct b → RecStruct (a × b) _⊗_ RecA RecB P (x , y) = -- Either x is constant and y is "smaller", ... RecB (λ y' → P (x , y')) y × -- ...or x is "smaller" and y is arbitrary. RecA (λ x' → ∀ y' → P (x' , y')) x -- Constructs a recursor builder for lexicographic induction. [_⊗_] : ∀ {a} {RecA : RecStruct a} → RecursorBuilder RecA → ∀ {b} {RecB : RecStruct b} → RecursorBuilder RecB → RecursorBuilder (RecA ⊗ RecB) [_⊗_] {RecA = RecA} recA {RecB = RecB} recB P f (x , y) = (p₁ x y p₂x , p₂x) where p₁ : ∀ x y → RecA (λ x' → ∀ y' → P (x' , y')) x → RecB (λ y' → P (x , y')) y p₁ x y x-rec = recB (λ y' → P (x , y')) (λ y y-rec → f (x , y) (y-rec , x-rec)) y p₂ : ∀ x → RecA (λ x' → ∀ y' → P (x' , y')) x p₂ = recA (λ x → ∀ y → P (x , y)) (λ x x-rec y → f (x , y) (p₁ x y x-rec , x-rec)) p₂x = p₂ x ------------------------------------------------------------------------ -- Example private open import Data.Nat open import Induction.Nat as N -- The Ackermann function à la Rózsa Péter. ackermann : ℕ → ℕ → ℕ ackermann m n = build [ N.rec-builder ⊗ N.rec-builder ] AckPred ack (m , n) where AckPred : ℕ × ℕ → Set AckPred _ = ℕ ack : ∀ p → (N.Rec ⊗ N.Rec) AckPred p → AckPred p ack (zero , n) _ = 1 + n ack (suc m , zero) (_ , ackm•) = ackm• 1 ack (suc m , suc n) (ack[1+m]n , ackm•) = ackm• ack[1+m]n
{ "alphanum_fraction": 0.4466019417, "avg_line_length": 29.9032258065, "ext": "agda", "hexsha": "556236e647903d01f79c043b747a2d463a6a3efe", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Induction/Lexicographic.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Induction/Lexicographic.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Induction/Lexicographic.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 631, "size": 1854 }
------------------------------------------------------------------------ -- Products (variants for Set₁) ------------------------------------------------------------------------ -- I want universe polymorphism. module Data.Product1 where open import Data.Function open import Relation.Nullary infixr 4 _,_ infixr 2 _×₀₁_ _×₁₀_ _×₁₁_ ------------------------------------------------------------------------ -- Definition data Σ₀₁ (a : Set) (b : a → Set₁) : Set₁ where _,_ : (x : a) (y : b x) → Σ₀₁ a b data Σ₁₀ (a : Set₁) (b : a → Set) : Set₁ where _,_ : (x : a) (y : b x) → Σ₁₀ a b data Σ₁₁ (a : Set₁) (b : a → Set₁) : Set₁ where _,_ : (x : a) (y : b x) → Σ₁₁ a b ∃₀₁ : {A : Set} → (A → Set₁) → Set₁ ∃₀₁ = Σ₀₁ _ ∃₁₀ : {A : Set₁} → (A → Set) → Set₁ ∃₁₀ = Σ₁₀ _ ∃₁₁ : {A : Set₁} → (A → Set₁) → Set₁ ∃₁₁ = Σ₁₁ _ _×₀₁_ : Set → Set₁ → Set₁ A ×₀₁ B = Σ₀₁ A (λ _ → B) _×₁₀_ : Set₁ → Set → Set₁ A ×₁₀ B = Σ₁₀ A (λ _ → B) _×₁₁_ : Set₁ → Set₁ → Set₁ A ×₁₁ B = Σ₁₁ A (λ _ → B) ------------------------------------------------------------------------ -- Functions proj₀₁₁ : ∀ {a b} → Σ₀₁ a b → a proj₀₁₁ (x , y) = x proj₀₁₂ : ∀ {a b} → (p : Σ₀₁ a b) → b (proj₀₁₁ p) proj₀₁₂ (x , y) = y proj₁₀₁ : ∀ {a b} → Σ₁₀ a b → a proj₁₀₁ (x , y) = x proj₁₀₂ : ∀ {a b} → (p : Σ₁₀ a b) → b (proj₁₀₁ p) proj₁₀₂ (x , y) = y proj₁₁₁ : ∀ {a b} → Σ₁₁ a b → a proj₁₁₁ (x , y) = x proj₁₁₂ : ∀ {a b} → (p : Σ₁₁ a b) → b (proj₁₁₁ p) proj₁₁₂ (x , y) = y map₀₁ : ∀ {A B P Q} → (f : A → B) → (∀ {x} → P x → Q (f x)) → Σ₀₁ A P → Σ₀₁ B Q map₀₁ f g p = (f (proj₀₁₁ p) , g (proj₀₁₂ p)) map₁₀ : ∀ {A B P Q} → (f : A → B) → (∀ {x} → P x → Q (f x)) → Σ₁₀ A P → Σ₁₀ B Q map₁₀ f g p = (f (proj₁₀₁ p) , g (proj₁₀₂ p)) map₁₁ : ∀ {A B P Q} → (f : A → B) → (∀ {x} → P x → Q (f x)) → Σ₁₁ A P → Σ₁₁ B Q map₁₁ f g p = (f (proj₁₁₁ p) , g (proj₁₁₂ p))
{ "alphanum_fraction": 0.4066168623, "avg_line_length": 23.425, "ext": "agda", "hexsha": "f024668b7f3ea84891136f755bbc1f917e806c52", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Data/Product1.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Data/Product1.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Data/Product1.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 856, "size": 1874 }
module Categories.Pushout where
{ "alphanum_fraction": 0.875, "avg_line_length": 16, "ext": "agda", "hexsha": "4ed3dbb6e9c7c535e87a4e6f42af8a16412010c5", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Pushout.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Pushout.agda", "max_line_length": 31, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Pushout.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 6, "size": 32 }
open import Prelude module Implicits.Syntax.MetaType where open import Implicits.Syntax.Type mutual data MetaSimpleType (m ν : ℕ) : Set where tvar : Fin ν → MetaSimpleType m ν mvar : Fin m → MetaSimpleType m ν _→'_ : (a b : MetaType m ν) → MetaSimpleType m ν tc : ℕ → MetaSimpleType m ν data MetaType (m ν : ℕ) : Set where _⇒_ : (a b : MetaType m ν) → MetaType m ν ∀' : MetaType m (suc ν) → MetaType m ν simpl : MetaSimpleType m ν → MetaType m ν s-tvar : ∀ {ν m} → Fin ν → MetaType m ν s-tvar n = simpl (tvar n) s-mvar : ∀ {ν m} → Fin m → MetaType m ν s-mvar n = simpl (mvar n) s-tc : ∀ {ν m} → ℕ → MetaType m ν s-tc c = simpl (tc c) mutual to-smeta : ∀ {m ν} → SimpleType ν → MetaSimpleType m ν to-smeta (tc x) = (tc x) to-smeta (tvar n) = (tvar n) to-smeta (a →' b) = (to-meta a) →' (to-meta b) to-meta : ∀ {m ν} → Type ν → MetaType m ν to-meta (simpl x) = simpl (to-smeta x) to-meta (a ⇒ b) = (to-meta a) ⇒ (to-meta b) to-meta (∀' a) = ∀' (to-meta a) mutual from-smeta : ∀ {ν} → MetaSimpleType zero ν → SimpleType ν from-smeta (tvar x) = tvar x from-smeta (mvar ()) from-smeta (tc c) = tc c from-smeta (a →' b) = from-meta a →' from-meta b from-meta : ∀ {ν} → MetaType zero ν → Type ν from-meta (simpl τ) = simpl (from-smeta τ) from-meta (a ⇒ b) = from-meta a ⇒ from-meta b from-meta (∀' x) = ∀' (from-meta x) is-m∀' : ∀ {m ν} → MetaType m ν → Set is-m∀' (simpl x) = ⊥ is-m∀' (a ⇒ b) = ⊥ is-m∀' (∀' x) = ⊤
{ "alphanum_fraction": 0.5731543624, "avg_line_length": 27.0909090909, "ext": "agda", "hexsha": "a65fbd8b10f96baa1fb2847c32a46b6c74d32bd1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Implicits/Syntax/MetaType.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Implicits/Syntax/MetaType.agda", "max_line_length": 59, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Implicits/Syntax/MetaType.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 601, "size": 1490 }
{-# OPTIONS --cubical --safe #-} module Subtyping where open import Cubical.Core.Everything hiding (Type) open import Cubical.Foundations.Prelude using (refl; sym; symP; cong; _∙_; transport; subst; transportRefl; transport-filler; toPathP; fromPathP; congP) open import Cubical.Foundations.Transport using (transport⁻Transport) open import Cubical.Data.Nat using (ℕ; zero; suc; _+_; +-comm; snotz; znots; +-suc; +-zero; injSuc; isSetℕ) open import Cubical.Data.Nat.Order using (_≟_; lt; eq; gt; ≤-k+; ≤-+k; ≤-trans; pred-≤-pred; _≤_; _<_; ¬m+n<m; ¬-<-zero; suc-≤-suc; <-k+; <-+k; zero-≤; m≤n-isProp; <≤-trans; ≤-refl; <-weaken) open import Cubical.Data.Fin using (Fin; toℕ; fzero; fsuc; Fin-fst-≡) open import Cubical.Data.Sigma using (_×_; _,_; fst; snd; ΣPathP; Σ-cong-snd) open import Cubical.Data.Sum using (_⊎_; inl; inr) import Cubical.Data.Empty as Empty open import Label using (Label; Record; nil; cons; _∈_; find; l∈r-isProp) -- A term with at most `n` free variables. data Term (n : ℕ) : Set where var : Fin n -> Term n abs : Term (suc n) -> Term n _·_ : Term n -> Term n -> Term n rec : forall {l} -> Record (Term n) l -> Term n _#_ : Term n -> Label -> Term n shift : forall {m : ℕ} (n : ℕ) (i : Fin (suc m)) (e : Term m) -> Term (m + n) shiftRecord : forall {m : ℕ} (n : ℕ) (i : Fin (suc m)) {l : Label} (r : Record (Term m) l) -> Record (Term (m + n)) l shift {m} n i (var j) with toℕ i ≟ toℕ j ... | lt _ = var (toℕ j + n , ≤-+k (snd j)) ... | eq _ = var (toℕ j + n , ≤-+k (snd j)) ... | gt _ = var (toℕ j , ≤-trans (snd j) (n , +-comm n m)) shift n i (abs e) = abs (shift n (fsuc i) e) shift n i (e · e₁) = shift n i e · shift n i e₁ shift n i (rec r) = rec (shiftRecord n i r) shift n i (e # l) = shift n i e # l shiftRecord n i nil = nil shiftRecord n i (cons r l' x x₁) = cons (shiftRecord n i r) l' (shift n i x) x₁ subst′ : forall {m n : ℕ} -> (e' : Term m) -> (i : Fin (suc n)) -> (e1 : Term (suc (n + m))) -> Term (n + m) substRecord : forall {m n : ℕ} -> (e' : Term m) -> (i : Fin (suc n)) -> forall {l : Label} -> (r1 : Record (Term (suc (n + m))) l) -> Record (Term (n + m)) l subst′ {m} {n} e' i (var j) with toℕ j ≟ toℕ i ... | lt j<i = var (toℕ j , <≤-trans j<i (pred-≤-pred (≤-trans (snd i) (suc-≤-suc (m , +-comm m n))))) ... | eq _ = transport (λ i₁ → Term (+-comm m n i₁)) (shift n fzero e') ... | gt i<j with j ... | zero , _ = Empty.rec (¬-<-zero i<j) ... | suc fst₁ , snd₁ = var (fst₁ , pred-≤-pred snd₁) subst′ e' i (abs e1) = abs (subst′ e' (fsuc i) e1) subst′ e' i (e1 · e2) = subst′ e' i e1 · subst′ e' i e2 subst′ e' i (rec r) = rec (substRecord e' i r) subst′ e' i (e # l) = subst′ e' i e # l substRecord e' i nil = nil substRecord e' i (cons r1 l' x x₁) = cons (substRecord e' i r1) l' (subst′ e' i x) x₁ infix 3 _▷_ data _▷_ {n : ℕ} : Term n -> Term n -> Set where beta/=> : forall {e1 : Term (suc n)} {e2 : Term n} -> abs e1 · e2 ▷ subst′ e2 fzero e1 cong/app : forall {e1 e1' e2 : Term n} -> e1 ▷ e1' -> e1 · e2 ▷ e1' · e2 beta/rec : forall {l'} {r : Record (Term n) l'} {l} {l∈r : l ∈ r} -> rec r # l ▷ find l r l∈r cong/# : forall {e e' : Term n} {l} -> e ▷ e' -> e # l ▷ e' # l data Base : Set where Unit : Base Int : Base infixr 8 _=>_ data Type : Set where base : Base -> Type Top : Type _=>_ : Type -> Type -> Type rec : forall {l} -> Record Type l -> Type data Context : ℕ -> Set where [] : Context 0 _∷_ : forall {n} -> Type -> Context n -> Context (suc n) data _[_]=_ : forall {n} -> Context n -> Fin n -> Type -> Set where here : forall {n} A (G : Context n) -> (A ∷ G) [ 0 , suc-≤-suc zero-≤ ]= A there : forall {n} {A} B {G : Context n} {i} -> G [ i ]= A -> (B ∷ G) [ fsuc i ]= A lookup : forall {n} -> Context n -> Fin n -> Type lookup [] (fst₁ , snd₁) = Empty.rec (¬-<-zero snd₁) lookup (A ∷ G) (zero , snd₁) = A lookup (A ∷ G) (suc fst₁ , snd₁) = lookup G (fst₁ , pred-≤-pred snd₁) lookup-[]= : forall {n} (G : Context n) i -> G [ i ]= lookup G i lookup-[]= [] (fst₁ , snd₁) = Empty.rec (¬-<-zero snd₁) lookup-[]= (A ∷ G) (zero , snd₁) = subst (λ f -> (A ∷ G) [ f ]= A) (Fin-fst-≡ refl) (here A G) lookup-[]= (A ∷ G) (suc fst₁ , snd₁) = subst (λ f -> (A ∷ G) [ f ]= lookup G (fst₁ , pred-≤-pred snd₁)) (Fin-fst-≡ refl) (there A (lookup-[]= G (fst₁ , pred-≤-pred snd₁))) _++_ : forall {m n} -> Context m -> Context n -> Context (m + n) [] ++ G2 = G2 (A ∷ G1) ++ G2 = A ∷ (G1 ++ G2) ++-[]= : forall {m n} {G : Context m} (G' : Context n) {j : Fin m} {A} -> G [ j ]= A -> (G' ++ G) [ n + toℕ j , <-k+ (snd j) ]= A ++-[]= [] l = subst (λ f → _ [ f ]= _) (Fin-fst-≡ refl) l ++-[]= {G = G} (C ∷ G') {A = A} l = subst (λ f → ((C ∷ G') ++ G) [ f ]= A) (Fin-fst-≡ refl) (there C (++-[]= G' l)) inserts : forall {m n} -> Fin (suc m) -> Context n -> Context m -> Context (m + n) inserts {m} {n} (zero , snd₁) G' G = subst Context (+-comm n m) (G' ++ G) inserts (suc fst₁ , snd₁) G' [] = Empty.rec (¬-<-zero (pred-≤-pred snd₁)) inserts (suc fst₁ , snd₁) G' (A ∷ G) = A ∷ inserts (fst₁ , pred-≤-pred snd₁) G' G inserts-[]=-unaffected : forall {m n} (G : Context m) (G' : Context n) {j : Fin m} (i : Fin (suc m)) {A} -> toℕ j < toℕ i -> G [ j ]= A -> inserts i G' G [ toℕ j , ≤-trans (snd j) (n , +-comm n m) ]= A inserts-[]=-unaffected (A ∷ G) G' (zero , snd₁) j<i (here .A .G) = Empty.rec (¬-<-zero j<i) inserts-[]=-unaffected (A ∷ G) G' (suc fst₁ , snd₁) j<i (here .A .G) = subst (λ f → inserts (suc fst₁ , snd₁) G' (A ∷ G) [ f ]= A) (Fin-fst-≡ refl) (here A (inserts (fst₁ , pred-≤-pred snd₁) G' G)) inserts-[]=-unaffected (B ∷ _) G' (zero , snd₁) j<i (there .B l) = Empty.rec (¬-<-zero j<i) inserts-[]=-unaffected (B ∷ G) G' (suc fst₁ , snd₁) {A = A} j<i (there .B l) = subst (λ f → inserts (suc fst₁ , snd₁) G' (B ∷ G) [ f ]= A) (Fin-fst-≡ refl) (there B (inserts-[]=-unaffected G G' (fst₁ , pred-≤-pred snd₁) (pred-≤-pred j<i) l)) helper1 : forall m n (j : Fin m) -> PathP (λ i -> Fin (+-comm n m i)) (n + toℕ j , <-k+ (snd j)) (toℕ j + n , ≤-+k (snd j)) helper1 m n j = ΣPathP (+-comm n (toℕ j) , toPathP (m≤n-isProp _ _)) helper2 : forall m n (G : Context m) (G' : Context n) -> PathP (λ i → Context (+-comm n m i)) (G' ++ G) (subst Context (+-comm n m) (G' ++ G)) helper2 m n G G' = toPathP refl inserts-[]=-shifted : forall {m n} (G : Context m) (G' : Context n) {j : Fin m} (i : Fin (suc m)) {A} -> toℕ i ≤ toℕ j -> G [ j ]= A -> inserts i G' G [ toℕ j + n , ≤-+k (snd j) ]= A inserts-[]=-shifted {m} {n} G G' {j} (zero , snd₁) {A} i≤j l = transport (λ i -> helper2 m n G G' i [ helper1 m n j i ]= A) (++-[]= G' l) inserts-[]=-shifted (B ∷ G) G' (suc fst₁ , snd₁) i≤j (here .B .G) = Empty.rec (¬-<-zero i≤j) inserts-[]=-shifted (B ∷ G) G' {j = suc fst₂ , snd₂} (suc fst₁ , snd₁) {A = A} i≤j (there .B l) = subst (λ f → inserts (suc fst₁ , snd₁) G' (B ∷ G) [ f ]= A) (Fin-fst-≡ refl) (there B (inserts-[]=-shifted G G' (fst₁ , pred-≤-pred snd₁) (pred-≤-pred i≤j) l)) _+++_+++_ : forall {m n} -> Context m -> Type -> Context n -> Context (suc (m + n)) [] +++ A +++ G2 = A ∷ G2 (B ∷ G1) +++ A +++ G2 = B ∷ (G1 +++ A +++ G2) ++++++-[]=-unaffected : forall {m n} (G1 : Context m) (G2 : Context n) {A B} {j : Fin (suc (n + m))} -> (j<n : toℕ j < n) -> (G2 +++ A +++ G1) [ j ]= B -> (G2 ++ G1) [ toℕ j , <≤-trans j<n (m , +-comm m n) ]= B ++++++-[]=-unaffected G1 [] j<n l = Empty.rec (¬-<-zero j<n) ++++++-[]=-unaffected G1 (C ∷ G2) j<n (here .C .(G2 +++ _ +++ G1)) = subst (λ f -> (C ∷ (G2 ++ G1)) [ f ]= C) (Fin-fst-≡ refl) (here C (G2 ++ G1)) ++++++-[]=-unaffected G1 (C ∷ G2) {B = B} j<n (there .C l) = let a = ++++++-[]=-unaffected G1 G2 (pred-≤-pred j<n) l in subst (λ f -> (C ∷ (G2 ++ G1)) [ f ]= B) (Fin-fst-≡ refl) (there C a) -- Note that `j` stands for `suc fst₁`. ++++++-[]=-shifted : forall {m n} (G1 : Context m) (G2 : Context n) {A B} {fst₁ : ℕ} {snd₁ : suc (fst₁) < suc (n + m)} -> (n<j : n < suc fst₁) -> (G2 +++ A +++ G1) [ suc fst₁ , snd₁ ]= B -> (G2 ++ G1) [ fst₁ , pred-≤-pred snd₁ ]= B ++++++-[]=-shifted G1 [] n<j (there _ l) = subst (λ f → G1 [ f ]= _) (Fin-fst-≡ refl) l ++++++-[]=-shifted {m} {suc n} G1 (C ∷ G2) n<j (there .C {i = zero , snd₁} l) = Empty.rec (¬-<-zero (pred-≤-pred n<j)) ++++++-[]=-shifted {m} {suc n} G1 (C ∷ G2) {B = B} n<j (there .C {i = suc fst₁ , snd₁} l) = let a = ++++++-[]=-shifted G1 G2 (pred-≤-pred n<j) l in subst (λ f → (C ∷ (G2 ++ G1)) [ f ]= B) (Fin-fst-≡ refl) (there C a) ++++++-[]=-hit : forall {m n} (G1 : Context m) (G2 : Context n) {A B} {j : Fin (suc (n + m))} -> toℕ j ≡ n -> (G2 +++ A +++ G1) [ j ]= B -> A ≡ B ++++++-[]=-hit G1 [] j≡n (here _ .G1) = refl ++++++-[]=-hit G1 [] j≡n (there _ l) = Empty.rec (snotz j≡n) ++++++-[]=-hit G1 (C ∷ G2) j≡n (here .C .(G2 +++ _ +++ G1)) = Empty.rec (znots j≡n) ++++++-[]=-hit G1 (C ∷ G2) j≡n (there .C l) = ++++++-[]=-hit G1 G2 (injSuc j≡n) l infix 2 _<:_ infix 2 _<::_ data _<:_ : Type -> Type -> Set data _<::_ {l1 l2 : Label} : Record Type l1 -> Record Type l2 -> Set data _<:_ where S-Refl : forall {A} -> A <: A S-Arr : forall {A1 B1 A2 B2} -> A2 <: A1 -> B1 <: B2 -> A1 => B1 <: A2 => B2 S-Top : forall {A} -> A <: Top S-Record : forall {l1 l2} {r1 : Record Type l1} {r2 : Record Type l2} -> r1 <:: r2 -> rec r1 <: rec r2 data _<::_ {l1} {l2} where S-nil : l2 ≤ l1 -> nil <:: nil S-cons1 : forall {l1'} {r1 : Record Type l1'} {r2 : Record Type l2} {A} {l1'<l1 : l1' < l1} -> r1 <:: r2 -> cons r1 l1 A l1'<l1 <:: r2 S-cons2 : forall {l1' l2'} {r1 : Record Type l1'} {r2 : Record Type l2'} {A B} {l1'<l1 : l1' < l1} .{l2'<l2 : l2' < l2} -> r1 <:: r2 -> A <: B -> l1 ≡ l2 -> cons r1 l1 A l1'<l1 <:: cons r2 l2 B l2'<l2 <::-implies-≥ : forall {l1 l2} {r1 : Record Type l1} {r2 : Record Type l2} -> r1 <:: r2 -> l2 ≤ l1 <::-implies-≥ (S-nil x) = x <::-implies-≥ (S-cons1 {l1'<l1 = l1'<l1} s) = ≤-trans (<::-implies-≥ s) (<-weaken l1'<l1) <::-implies-≥ (S-cons2 s x x₁) = 0 , sym x₁ helper/<::-∈ : forall {l1 l2} {r1 : Record Type l1} {r2 : Record Type l2} -> r1 <:: r2 -> forall {l} -> l ∈ r2 -> l ∈ r1 helper/<::-∈ (S-cons1 {l1'<l1 = l1'<l1} s) l∈r2 = _∈_.there {lt = l1'<l1} (helper/<::-∈ s l∈r2) helper/<::-∈ (S-cons2 {r1 = r1} {A = A} {l1'<l1 = l1'<l1} _ x l1≡l2) (_∈_.here {lt = a} e) = transport (λ i -> (l1≡l2 ∙ sym e) i ∈ cons r1 _ A l1'<l1) (_∈_.here {lt = l1'<l1} refl) helper/<::-∈ (S-cons2 {l1'<l1 = l1'<l1} s x l1≡l2) (_∈_.there l∈r2) = _∈_.there {lt = l1'<l1} (helper/<::-∈ s l∈r2) infix 2 _⊢_::_ infix 2 _⊢_:::_ data _⊢_::_ {n : ℕ} (G : Context n) : Term n -> Type -> Set data _⊢_:::_ {n : ℕ} (G : Context n) {l} : Record (Term n) l -> Record Type l -> Set data _⊢_::_ {n} G where axiom : forall {i : Fin n} {A} -> G [ i ]= A -> G ⊢ var i :: A =>I : forall {A B : Type} {e : Term (suc n)} -> A ∷ G ⊢ e :: B -> G ⊢ abs e :: A => B =>E : forall {A B : Type} {e1 e2 : Term n} -> G ⊢ e1 :: A => B -> G ⊢ e2 :: A -> G ⊢ e1 · e2 :: B recI : forall {l} {r : Record (Term n) l} {rt : Record Type l} -> G ⊢ r ::: rt -> G ⊢ rec r :: rec rt recE : forall {l'} {r : Record Type l'} {e : Term n} {l : Label} -> G ⊢ e :: rec r -> (l∈r : l ∈ r) -> G ⊢ e # l :: find l r l∈r sub : forall {A B : Type} {e} -> G ⊢ e :: A -> A <: B -> G ⊢ e :: B data _⊢_:::_ {n} G {l} where rec/nil : G ⊢ nil ::: nil rec/cons : forall {l'} {r : Record (Term n) l'} {rt : Record Type l'} {e A} .{l'<l : (l' < l)} -> G ⊢ r ::: rt -> G ⊢ e :: A -> G ⊢ cons r l e l'<l ::: cons rt l A l'<l helper/∈ : forall {n} {G : Context n} {l} {r : Record (Term n) l} {rt : Record Type l} -> G ⊢ r ::: rt -> forall {l₁} -> l₁ ∈ r -> l₁ ∈ rt helper/∈ (rec/cons D x) (_∈_.here {lt = y} e) = _∈_.here {lt = y} e helper/∈ (rec/cons D x) (_∈_.there {lt = y} l₁∈r) = _∈_.there {lt = y} (helper/∈ D l₁∈r) helper/∈′ : forall {n} {G : Context n} {l} {r : Record (Term n) l} {rt : Record Type l} -> G ⊢ r ::: rt -> forall {l₁} -> l₁ ∈ rt -> l₁ ∈ r helper/∈′ (rec/cons D x) (_∈_.here {lt = y} e) = _∈_.here {lt = y} e helper/∈′ (rec/cons D x) (_∈_.there {lt = y} l₁∈r) = _∈_.there {lt = y} (helper/∈′ D l₁∈r) weakening : forall {m n} (i : Fin (suc m)) {G : Context m} (G' : Context n) {e : Term m} {A} -> G ⊢ e :: A -> inserts i G' G ⊢ shift n i e :: A weakeningRecord : forall {m n} (i : Fin (suc m)) {G : Context m} (G' : Context n) {l} {r : Record (Term m) l} {rt} -> G ⊢ r ::: rt -> inserts i G' G ⊢ shiftRecord n i r ::: rt weakening {m = m} {n = n} i {G = G} G' {e = var j} (axiom l) with toℕ i ≟ toℕ j ... | lt i<j = axiom (inserts-[]=-shifted G G' i (≤-trans (1 , refl) i<j) l) ... | eq i≡j = axiom (inserts-[]=-shifted G G' i (0 , i≡j) l) ... | gt j<i = axiom (inserts-[]=-unaffected G G' i j<i l) weakening {n = n} i {G = G} G' {e = abs e} {A = A => B} (=>I D) = =>I (subst (λ f -> (A ∷ inserts f G' G) ⊢ shift n (fsuc i) e :: B) (Fin-fst-≡ {j = i} refl) (weakening (fsuc i) G' D)) weakening i G' (=>E D D₁) = =>E (weakening i G' D) (weakening i G' D₁) weakening i G' (sub D s) = sub (weakening i G' D) s weakening i G' (recI D) = recI (weakeningRecord i G' D) weakening i G' (recE D l∈r) = recE (weakening i G' D) l∈r weakeningRecord i G' rec/nil = rec/nil weakeningRecord i G' (rec/cons x x₁) = rec/cons (weakeningRecord i G' x) (weakening i G' x₁) helper3 : forall {n} -> (suc n , ≤-refl) ≡ (suc n , suc-≤-suc ≤-refl) helper3 = Fin-fst-≡ refl helper4 : forall m n (j : Fin (suc (n + m))) j<n -> (toℕ j , <≤-trans j<n (m , +-comm m n)) ≡ (toℕ j , <≤-trans j<n (pred-≤-pred (≤-trans (0 , refl) (suc-≤-suc (m , +-comm m n))))) helper4 m n j j<n = Fin-fst-≡ refl helper5 : forall m n (G1 : Context m) (G2 : Context n) -> PathP (λ i -> Context (+-comm n m (~ i))) (subst Context (+-comm n m) (G2 ++ G1)) (G2 ++ G1) helper5 m n G1 G2 = symP {A = λ i -> Context (+-comm n m i)} (toPathP refl) helper6 : forall m n (e : Term (m + n)) -> PathP (λ i -> Term (+-comm m n i)) e (transport (λ i -> Term (+-comm m n i)) e) helper6 m n e = toPathP refl helper' : forall m n -> +-comm m n ≡ sym (+-comm n m) helper' m n = isSetℕ (m + n) (n + m) (+-comm m n) (sym (+-comm n m)) helper7 : forall m n (e : Term (m + n)) -> PathP (λ i -> Term (+-comm n m (~ i))) e (transport (λ i -> Term (+-comm m n i)) e) helper7 m n e = subst (λ m+n≡n+m → PathP (λ i → Term (m+n≡n+m i)) e (transport (λ i -> Term (+-comm m n i)) e)) (helper' m n) (helper6 m n e) substitution : forall {m n} (G1 : Context m) (G2 : Context n) (e1 : Term (suc (n + m))) {e2 : Term m} {A B} -> G1 ⊢ e2 :: A -> G2 +++ A +++ G1 ⊢ e1 :: B -> G2 ++ G1 ⊢ subst′ e2 (n , ≤-refl) e1 :: B substitutionRecord : forall {m n} (G1 : Context m) (G2 : Context n) {l} (r : Record (Term (suc (n + m))) l) {e2 : Term m} {A} {rt} -> G1 ⊢ e2 :: A -> G2 +++ A +++ G1 ⊢ r ::: rt -> G2 ++ G1 ⊢ substRecord e2 (n , ≤-refl) r ::: rt substitution G1 G2 e1 D' (sub D s) = sub (substitution G1 G2 e1 D' D) s substitution {m} {n} G1 G2 (var j) {e2 = e2} {B = B} D' (axiom l) with toℕ j ≟ toℕ (n , ≤-refl) ... | lt j<n = axiom (transport (λ i -> (G2 ++ G1) [ helper4 m n j j<n i ]= B) (++++++-[]=-unaffected G1 G2 j<n l)) ... | eq j≡n = let a = weakening fzero G2 D' in transport (λ i → helper5 m n G1 G2 i ⊢ helper7 m n (shift n fzero e2) i :: ++++++-[]=-hit G1 G2 j≡n l i ) a ... | gt n<j with j ... | zero , snd₁ = Empty.rec (¬-<-zero n<j) ... | suc fst₁ , snd₁ = axiom (++++++-[]=-shifted G1 G2 n<j l) substitution G1 G2 (abs e1) {e2 = e2} D' (=>I {A} {B} D) = =>I (transport (λ i → (A ∷ (G2 ++ G1)) ⊢ subst′ e2 (helper3 i) e1 :: B) (substitution G1 (A ∷ G2) e1 D' D)) substitution G1 G2 (e · e') D' (=>E D D₁) = =>E (substitution G1 G2 e D' D) (substitution G1 G2 e' D' D₁) substitution G1 G2 (rec r) D' (recI D) = recI (substitutionRecord G1 G2 r D' D) substitution G1 G2 (e # l) D' (recE D l∈r) = recE (substitution G1 G2 e D' D) l∈r substitutionRecord G1 G2 nil D' rec/nil = rec/nil substitutionRecord G1 G2 (cons r l e _) D' (rec/cons D x) = rec/cons (substitutionRecord G1 G2 r D' D) (substitution G1 G2 e D' x) S-Trans : forall {A B C} -> A <: B -> B <: C -> A <: C S-TransRecord : forall {l1 l2 l3} {r1 : Record Type l1} {r2 : Record Type l2} {r3 : Record Type l3} -> r1 <:: r2 -> r2 <:: r3 -> r1 <:: r3 S-Trans S-Refl s2 = s2 S-Trans (S-Arr s1 s3) S-Refl = S-Arr s1 s3 S-Trans (S-Arr s1 s3) (S-Arr s2 s4) = S-Arr (S-Trans s2 s1) (S-Trans s3 s4) S-Trans (S-Arr s1 s3) S-Top = S-Top S-Trans S-Top S-Refl = S-Top S-Trans S-Top S-Top = S-Top S-Trans (S-Record s1) S-Refl = S-Record s1 S-Trans (S-Record s1) S-Top = S-Top S-Trans (S-Record s1) (S-Record s2) = S-Record (S-TransRecord s1 s2) S-TransRecord (S-nil x) (S-nil y) = S-nil (≤-trans y x) S-TransRecord (S-cons1 {l1'<l1 = l1'<l1} x) x₁ = S-cons1 {l1'<l1 = l1'<l1} (S-TransRecord x x₁) S-TransRecord (S-cons2 {l1'<l1 = a} x x₂ _) (S-cons1 x₁) = S-cons1 {l1'<l1 = a} (S-TransRecord x x₁) S-TransRecord (S-cons2 {l1'<l1 = a} x x₂ l1≡l2) (S-cons2 x₁ x₃ l2≡l3) = S-cons2 {l1'<l1 = a} (S-TransRecord x x₁) (S-Trans x₂ x₃) (l1≡l2 ∙ l2≡l3) inversion/S-Arr : forall {A1 B1 A2 B2} -> A1 => B1 <: A2 => B2 -> (A2 <: A1) × (B1 <: B2) inversion/S-Arr S-Refl = S-Refl , S-Refl inversion/S-Arr (S-Arr s s₁) = s , s₁ helper/inversion/S-Record : forall {l1 l2} {r1 : Record Type l1} {r2 : Record Type l2} -> (s : r1 <:: r2) -> forall {l} -> (l∈r2 : l ∈ r2) -> find l r1 (helper/<::-∈ s l∈r2) <: find l r2 l∈r2 helper/inversion/S-Record (S-cons1 s) l∈r2 = helper/inversion/S-Record s l∈r2 helper/inversion/S-Record {l1} {r1 = cons r1 l1 A k} (S-cons2 {B = B} {l1'<l1 = l1'<l1} _ x l1≡l2) {l = l} (_∈_.here {lt = u} e) = subst (λ z -> find l (cons r1 l1 A k) z <: B) (l∈r-isProp l (cons r1 l1 A k) (_∈_.here {lt = l1'<l1} (e ∙ sym l1≡l2)) (transport (λ i → (l1≡l2 ∙ sym e) i ∈ cons r1 l1 A k) (_∈_.here refl))) x helper/inversion/S-Record (S-cons2 s x x₁) (_∈_.there l∈r2) = helper/inversion/S-Record s l∈r2 inversion/S-Record : forall {l1 l2} {r1 : Record Type l1} {r2 : Record Type l2} -> rec r1 <: rec r2 -> forall {l} (l∈r2 : l ∈ r2) -> Σ[ l∈r1 ∈ (l ∈ r1) ] (find l r1 l∈r1 <: find l r2 l∈r2) inversion/S-Record S-Refl l∈r2 = l∈r2 , S-Refl inversion/S-Record (S-Record s) l∈r2 = helper/<::-∈ s l∈r2 , helper/inversion/S-Record s l∈r2 inversion/=>I : forall {n} {G : Context n} {e : Term (suc n)} {A} -> G ⊢ abs e :: A -> Σ[ B ∈ Type ] Σ[ C ∈ Type ] ((B ∷ G ⊢ e :: C) × (B => C <: A)) inversion/=>I (=>I D) = _ , _ , D , S-Refl inversion/=>I (sub D s) with inversion/=>I D ... | B , C , D' , s' = B , C , D' , S-Trans s' s helper/inversion/recI : forall {n} {G : Context n} {l} {r : Record (Term n) l} {rt : Record Type l} -> (D : G ⊢ r ::: rt) -> forall {l₁} -> (l₁∈r : l₁ ∈ r) -> G ⊢ find l₁ r l₁∈r :: find l₁ rt (helper/∈ D l₁∈r) helper/inversion/recI (rec/cons D x) (_∈_.here e) = x helper/inversion/recI (rec/cons D x) (_∈_.there l₁∈r) = helper/inversion/recI D l₁∈r inversion/recI : forall {n} {G : Context n} {l} {r : Record (Term n) l} {A} -> G ⊢ rec r :: A -> Σ[ rt ∈ Record Type l ] Σ[ f ∈ (forall {l₁} -> l₁ ∈ r -> l₁ ∈ rt) ] Σ[ g ∈ (forall {l₁} -> l₁ ∈ rt -> l₁ ∈ r) ] ((forall {l₁} (l₁∈r : l₁ ∈ r) -> (G ⊢ find l₁ r l₁∈r :: find l₁ rt (f l₁∈r))) × (rec rt <: A)) inversion/recI (recI D) = _ , helper/∈ D , helper/∈′ D , (helper/inversion/recI D) , S-Refl inversion/recI (sub D s) with inversion/recI D ... | rt , f , g , x , s' = rt , f , g , x , S-Trans s' s preservation : forall {n} {G : Context n} (e : Term n) {e' : Term n} {A} -> G ⊢ e :: A -> e ▷ e' -> G ⊢ e' :: A preservation e (sub D s) st = sub (preservation e D st) s preservation (_ · _) (=>E D D₁) (cong/app s) = =>E (preservation _ D s) D₁ preservation {G = G} (abs e1 · e2) (=>E D D₁) beta/=> with inversion/=>I D ... | _ , _ , D , s with inversion/S-Arr s ... | sdom , scod = substitution G [] e1 (sub D₁ sdom) (sub D scod) preservation (e # l) (recE D l∈r) (cong/# s) = recE (preservation e D s) l∈r preservation {G = G} (rec r # l) (recE D l∈r) (beta/rec {l∈r = l∈r′}) with inversion/recI D ... | rt , f , _ , x , s with inversion/S-Record s ... | sr = let a = x l∈r′ in let l∈rt , b = sr l∈r in sub (subst (λ z -> G ⊢ find l r l∈r′ :: find l rt z) (l∈r-isProp l rt (f l∈r′) (l∈rt)) a) b -- Path. data P {n : ℕ} : Term n -> Set where var : forall {i : Fin n} -> P (var i) app : forall {e1 e2 : Term n} -> P e1 -> P (e1 · e2) proj : forall {e} {l} -> P e -> P (e # l) data Whnf {n : ℕ} : Term n -> Set where `_ : forall {p : Term n} -> P p -> Whnf p abs : forall {e : Term (suc n)} -> Whnf (abs e) rec : forall {l} {r : Record (Term n) l} -> Whnf (rec r) =>Whnf : forall {n} {G : Context n} {e : Term n} {A B : Type} -> G ⊢ e :: A => B -> Whnf e -> P e ⊎ (Σ[ e' ∈ Term (suc n) ] e ≡ abs e') =>Whnf {e = var x} D (` x₁) = inl x₁ =>Whnf {e = abs e} D abs = inr (e , refl) =>Whnf {e = e · e₁} D (` x) = inl x =>Whnf {e = rec x} D w with inversion/recI D ... | () =>Whnf {e = e # x} D (` x₁) = inl x₁ recWhnf : forall {n} {G : Context n} {e : Term n} {l} {rt : Record Type l} -> G ⊢ e :: rec rt -> Whnf e -> P e ⊎ (Σ[ l' ∈ Label ] Σ[ r ∈ Record (Term n) l' ] e ≡ rec r) recWhnf {e = var x} D (` x₁) = inl x₁ recWhnf {e = abs e} D w with inversion/=>I D ... | () recWhnf {e = e · e₁} D (` x) = inl x recWhnf {e = rec x} D rec = inr (_ , x , refl) recWhnf {e = e # x} D (` x₁) = inl x₁ helper/progress : forall {n} {G : Context n} {l1 l2} {r : Record _ l1} {rt : Record _ l2} -> G ⊢ rec r :: rec rt -> forall {l} -> l ∈ rt -> l ∈ r helper/progress D l∈rt with inversion/recI D ... | rt0 , f , g , x , s with inversion/S-Record s l∈rt ... | l∈rt0 , s' = g l∈rt0 progress : forall {n} {G : Context n} {e : Term n} {A} -> G ⊢ e :: A -> (Σ[ e' ∈ Term n ] e ▷ e') ⊎ Whnf e progress (axiom x) = inr (` var) progress (=>I D) = inr abs progress {n} {e = e1 · e2} (=>E D D₁) with progress D ... | inl (e1' , s) = inl ((e1' · e2) , cong/app s) ... | inr w with =>Whnf D w ... | inl p = inr (` app p) ... | inr (e1 , x) = inl (transport (Σ-cong-snd λ x₁ i → (x (~ i) · e2) ▷ x₁) (subst′ e2 fzero e1 , beta/=>)) progress (sub D _) = progress D progress (recI D) = inr rec progress {G = G} {e = e # l} (recE D l∈r) with progress D ... | inl (e' , s) = inl ((e' # l) , cong/# s) ... | inr w with recWhnf D w ... | inl p = inr (` proj p) ... | inr (l' , r , x) = inl (transport (Σ-cong-snd λ x₁ i → x (~ i) # l ▷ x₁) (find l r (helper/progress (subst (λ x₁ → G ⊢ x₁ :: _) x D) l∈r) , beta/rec))
{ "alphanum_fraction": 0.5138821021, "avg_line_length": 45.5688259109, "ext": "agda", "hexsha": "aae9872a558dfade66ddb5b768f17b071bcc8166", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-01-24T10:47:09.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-24T10:47:09.000Z", "max_forks_repo_head_hexsha": "fca08c53394f72c63d1bd7260fabfd70f73040b3", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "elpinal/subtyping-agda", "max_forks_repo_path": "Subtyping.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fca08c53394f72c63d1bd7260fabfd70f73040b3", "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": "elpinal/subtyping-agda", "max_issues_repo_path": "Subtyping.agda", "max_line_length": 241, "max_stars_count": 10, "max_stars_repo_head_hexsha": "fca08c53394f72c63d1bd7260fabfd70f73040b3", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "elpinal/subtyping-agda", "max_stars_repo_path": "Subtyping.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T17:17:26.000Z", "max_stars_repo_stars_event_min_datetime": "2022-01-16T07:11:04.000Z", "num_tokens": 10276, "size": 22511 }
postulate I : Set D : I → Set T : Set record R : Set where field t0 : T {i0} : I t1 : T d0 : D i0 {i1} : I d1 : D i1 t2 : T module M0 where postulate t0 t1 : T module MI where postulate i1 : I d1 : D i1 module MD {i0 : I} where postulate d0 : D i0 t0 : T r : R r = record { M0; t2 = M0.t0; MD; MI; i0 = i0 } module My where postulate i0 : I r' : R r' = record { R r; t0 = R.t1 r } where module Rr = R r
{ "alphanum_fraction": 0.4927835052, "avg_line_length": 13.1081081081, "ext": "agda", "hexsha": "e628fea49e054038761bc6129550a277573ac911", "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/RecordFromModuleAmb.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/RecordFromModuleAmb.agda", "max_line_length": 46, "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/RecordFromModuleAmb.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": 221, "size": 485 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Functions.Definition module Orders.WellFounded.Definition {a b : _} {A : Set a} (_<_ : Rel {a} {b} A) where data Accessible (x : A) : Set (lsuc a ⊔ b) where access : (∀ y → y < x → Accessible y) → Accessible x WellFounded : Set (lsuc a ⊔ b) WellFounded = ∀ x → Accessible x
{ "alphanum_fraction": 0.6517412935, "avg_line_length": 30.9230769231, "ext": "agda", "hexsha": "cf7842af978594c7c3a5420c3f7e57d183f0f6ac", "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": "Orders/WellFounded/Definition.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Orders/WellFounded/Definition.agda", "max_line_length": 86, "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": "Orders/WellFounded/Definition.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 134, "size": 402 }
------------------------------------------------------------------------------ -- Quicksort using the Bove-Capretta method ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Program.QuickSort.QuickSortBC where open import Data.List.Base open import Data.Nat.Base open import Data.Nat.Properties open import Induction open import Induction.Nat open import Induction.WellFounded open import Level open import Relation.Unary open import Relation.Binary open import Relation.Binary.PropositionalEquality open import Relation.Nullary module InvImg = Induction.WellFounded.Inverse-image {A = List ℕ} {ℕ} {_<′_} length ------------------------------------------------------------------------------ -- Non-terminating quicksort. {-# TERMINATING #-} qsNT : List ℕ → List ℕ qsNT [] = [] qsNT (x ∷ xs) = qsNT (filter (λ y → y ≤′? x) xs) ++ x ∷ qsNT (filter (λ y → x ≤′? y) xs) -- Domain predicate for quicksort. data QSDom : List ℕ → Set where qsDom-[] : QSDom [] qsDom-∷ : ∀ {x xs} → (QSDom (filter (λ y → y ≤′? x) xs)) → (QSDom (filter (λ y → x ≤′? y) xs)) → QSDom (x ∷ xs) -- Induction principle associated to the domain predicate of quicksort. -- (It was not necessary). QSDom-ind : (P : List ℕ → Set) → P [] → (∀ {x xs} → QSDom (filter (λ y → y ≤′? x) xs) → P (filter (λ y → y ≤′? x) xs) → QSDom (filter (λ y → x ≤′? y) xs) → P (filter (λ y → x ≤′? y) xs) → P (x ∷ xs)) → (∀ {xs} → QSDom xs → P xs) QSDom-ind P P[] ih qsDom-[] = P[] QSDom-ind P P[] ih (qsDom-∷ h₁ h₂) = ih h₁ (QSDom-ind P P[] ih h₁) h₂ (QSDom-ind P P[] ih h₂) -- Well-founded relation on lists. _⟪′_ : {A : Set} → List A → List A → Set xs ⟪′ ys = length xs <′ length ys wf-⟪′ : WellFounded _⟪′_ wf-⟪′ = InvImg.well-founded <′-wellFounded -- The well-founded induction principle on _⟪′_. -- postulate wfi-⟪′ : (P : List ℕ → Set) → -- (∀ xs → (∀ ys → ys ⟪′ xs → P ys) → P xs) → -- ∀ xs → P xs -- The quicksort algorithm is total. filter-length : {A : Set} {P : Pred A Level.zero} → (P? : Relation.Unary.Decidable P ) → ∀ xs → length (filter P? xs) ≤′ length xs filter-length P? [] = ≤′-refl filter-length P? (x ∷ xs) with P? x ... | yes _ = ≤⇒≤′ (s≤s (≤′⇒≤ (filter-length P? xs))) ... | no _ = ≤′-step (filter-length P? xs) module AllWF = Induction.WellFounded.All wf-⟪′ allQSDom : ∀ xs → QSDom xs -- If we use wfi-⟪′ then allQSDom = wfi-⟪′ P ih allQSDom = build (AllWF.wfRec-builder _) P ih where P : List ℕ → Set P = QSDom -- If we use wfi-⟪′ then -- ih : ∀ zs → (∀ ys → ys ⟪′ zs → P ys) → P zs ih : ∀ zs → WfRec _⟪′_ P zs → P zs ih [] h = qsDom-[] ih (z ∷ zs) h = qsDom-∷ prf₁ prf₂ where c₁ : (y : ℕ) → Dec (y ≤′ z) c₁ y = y ≤′? z c₂ : (y : ℕ) → Dec (z ≤′ y) c₂ y = z ≤′? y f₁ : List ℕ f₁ = filter c₁ zs f₂ : List ℕ f₂ = filter c₂ zs prf₁ : QSDom (filter (λ y → y ≤′? z) zs) prf₁ = h f₁ (≤⇒≤′ (s≤s (≤′⇒≤ (filter-length c₁ zs)))) prf₂ : QSDom (filter (λ y → z ≤′? y) zs) prf₂ = h f₂ (≤⇒≤′ (s≤s (≤′⇒≤ (filter-length c₂ zs)))) -- Quicksort algorithm by structural recursion on the domain predicate. qsDom : ∀ xs → QSDom xs → List ℕ qsDom .[] qsDom-[] = [] qsDom (x ∷ xs) (qsDom-∷ h₁ h₂) = qsDom (filter (λ y → y ≤′? x) xs) h₁ ++ x ∷ qsDom (filter (λ y → x ≤′? y) xs) h₂ -- The quicksort algorithm. qs : List ℕ → List ℕ qs xs = qsDom xs (allQSDom xs) -- Testing. l₁ : List ℕ l₁ = [] l₂ = 1 ∷ 2 ∷ 3 ∷ 4 ∷ 5 ∷ [] l₃ = 5 ∷ 4 ∷ 3 ∷ 2 ∷ 1 ∷ [] l₄ = 4 ∷ 1 ∷ 3 ∷ 5 ∷ 2 ∷ [] t₁ : qs l₁ ≡ l₁ t₁ = refl t₂ : qs l₂ ≡ l₂ t₂ = refl t₃ : qs l₃ ≡ l₂ t₃ = refl t₄ : qs l₄ ≡ l₂ t₄ = refl
{ "alphanum_fraction": 0.4904537565, "avg_line_length": 27.8137931034, "ext": "agda", "hexsha": "e1e494978feb99822c240a4a6338f96181049c6e", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Program/QuickSort/QuickSortBC.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Program/QuickSort/QuickSortBC.agda", "max_line_length": 94, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Program/QuickSort/QuickSortBC.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 1494, "size": 4033 }
------------------------------------------------------------------------------ -- Totality properties respect to Tree ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Program.SortList.Properties.Totality.TreeI where open import FOTC.Base open import FOTC.Data.Nat.List.Type open import FOTC.Data.Nat.Type open import FOTC.Program.SortList.SortList ------------------------------------------------------------------------------ -- See the ATP version. postulate toTree-Tree : ∀ {item t} → N item → Tree t → Tree (toTree · item · t) makeTree-Tree : ∀ {is} → ListN is → Tree (makeTree is) makeTree-Tree lnnil = subst Tree (sym (lit-[] toTree nil)) tnil makeTree-Tree (lncons {i} {is} Ni LNis) = subst Tree (sym (lit-∷ toTree i is nil)) (toTree-Tree Ni (makeTree-Tree LNis))
{ "alphanum_fraction": 0.496031746, "avg_line_length": 37.3333333333, "ext": "agda", "hexsha": "b86c96d5e9e8c59a1b9fc607bb4c828b908e0bff", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Program/SortList/Properties/Totality/TreeI.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Program/SortList/Properties/Totality/TreeI.agda", "max_line_length": 79, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Program/SortList/Properties/Totality/TreeI.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 227, "size": 1008 }
{- Theory about equivalences Definitions are in Core/Glue.agda but re-exported by this module - isEquiv is a proposition ([isPropIsEquiv]) - Any isomorphism is an equivalence ([isoToEquiv]) There are more statements about equivalences in Equiv/Properties.agda: - if f is an equivalence then (cong f) is an equivalence - if f is an equivalence then precomposition with f is an equivalence - if f is an equivalence then postcomposition with f is an equivalence -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Foundations.Equiv where open import Cubical.Foundations.Function open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Equiv.Base public open import Cubical.Data.Sigma.Base private variable ℓ ℓ' ℓ'' : Level A B C D : Type ℓ equivIsEquiv : (e : A ≃ B) → isEquiv (equivFun e) equivIsEquiv e = snd e equivCtr : (e : A ≃ B) (y : B) → fiber (equivFun e) y equivCtr e y = e .snd .equiv-proof y .fst equivCtrPath : (e : A ≃ B) (y : B) → (v : fiber (equivFun e) y) → Path _ (equivCtr e y) v equivCtrPath e y = e .snd .equiv-proof y .snd -- Proof using isPropIsContr. This is slow and the direct proof below is better isPropIsEquiv' : (f : A → B) → isProp (isEquiv f) equiv-proof (isPropIsEquiv' f u0 u1 i) y = isPropIsContr (u0 .equiv-proof y) (u1 .equiv-proof y) i -- Direct proof that computes quite ok (can be optimized further if -- necessary, see: -- https://github.com/mortberg/cubicaltt/blob/pi4s3_dimclosures/examples/brunerie2.ctt#L562 isPropIsEquiv : (f : A → B) → isProp (isEquiv f) equiv-proof (isPropIsEquiv f p q i) y = let p2 = p .equiv-proof y .snd q2 = q .equiv-proof y .snd in p2 (q .equiv-proof y .fst) i , λ w j → hcomp (λ k → λ { (i = i0) → p2 w j ; (i = i1) → q2 w (j ∨ ~ k) ; (j = i0) → p2 (q2 w (~ k)) i ; (j = i1) → w }) (p2 w (i ∨ j)) equivEq : {e f : A ≃ B} → (h : e .fst ≡ f .fst) → e ≡ f equivEq {e = e} {f = f} h = λ i → (h i) , isProp→PathP (λ i → isPropIsEquiv (h i)) (e .snd) (f .snd) i module _ {f : A → B} (equivF : isEquiv f) where funIsEq : A → B funIsEq = f invIsEq : B → A invIsEq y = equivF .equiv-proof y .fst .fst secIsEq : section f invIsEq secIsEq y = equivF .equiv-proof y .fst .snd retIsEq : retract f invIsEq retIsEq a i = equivF .equiv-proof (f a) .snd (a , refl) i .fst commSqIsEq : ∀ a → Square (secIsEq (f a)) refl (cong f (retIsEq a)) refl commSqIsEq a i = equivF .equiv-proof (f a) .snd (a , refl) i .snd module _ (w : A ≃ B) where invEq : B → A invEq = invIsEq (snd w) secEq : section invEq (w .fst) secEq = retIsEq (snd w) retEq : retract invEq (w .fst) retEq = secIsEq (snd w) open Iso equivToIso : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → A ≃ B → Iso A B fun (equivToIso e) = e .fst inv (equivToIso e) = invEq e rightInv (equivToIso e) = retEq e leftInv (equivToIso e) = secEq e -- TODO: there should be a direct proof of this that doesn't use equivToIso invEquiv : A ≃ B → B ≃ A invEquiv e = isoToEquiv (invIso (equivToIso e)) invEquivIdEquiv : (A : Type ℓ) → invEquiv (idEquiv A) ≡ idEquiv A invEquivIdEquiv _ = equivEq refl -- TODO: there should be a direct proof of this that doesn't use equivToIso compEquiv : A ≃ B → B ≃ C → A ≃ C compEquiv f g = isoToEquiv (compIso (equivToIso f) (equivToIso g)) compEquivIdEquiv : (e : A ≃ B) → compEquiv (idEquiv A) e ≡ e compEquivIdEquiv e = equivEq refl compEquivEquivId : (e : A ≃ B) → compEquiv e (idEquiv B) ≡ e compEquivEquivId e = equivEq refl invEquiv-is-rinv : (e : A ≃ B) → compEquiv e (invEquiv e) ≡ idEquiv A invEquiv-is-rinv e = equivEq (funExt (secEq e)) invEquiv-is-linv : (e : A ≃ B) → compEquiv (invEquiv e) e ≡ idEquiv B invEquiv-is-linv e = equivEq (funExt (retEq e)) compEquiv-assoc : (f : A ≃ B) (g : B ≃ C) (h : C ≃ D) → compEquiv f (compEquiv g h) ≡ compEquiv (compEquiv f g) h compEquiv-assoc f g h = equivEq refl LiftEquiv : A ≃ Lift {i = ℓ} {j = ℓ'} A LiftEquiv .fst a .lower = a LiftEquiv .snd .equiv-proof = strictContrFibers lower Lift≃Lift : (e : A ≃ B) → Lift {j = ℓ'} A ≃ Lift {j = ℓ''} B Lift≃Lift e .fst a .lower = e .fst (a .lower) Lift≃Lift e .snd .equiv-proof b .fst .fst .lower = invEq e (b .lower) Lift≃Lift e .snd .equiv-proof b .fst .snd i .lower = e .snd .equiv-proof (b .lower) .fst .snd i Lift≃Lift e .snd .equiv-proof b .snd (a , p) i .fst .lower = e .snd .equiv-proof (b .lower) .snd (a .lower , cong lower p) i .fst Lift≃Lift e .snd .equiv-proof b .snd (a , p) i .snd j .lower = e .snd .equiv-proof (b .lower) .snd (a .lower , cong lower p) i .snd j isContr→Equiv : isContr A → isContr B → A ≃ B isContr→Equiv Actr Bctr = isoToEquiv (isContr→Iso Actr Bctr) propBiimpl→Equiv : (Aprop : isProp A) (Bprop : isProp B) (f : A → B) (g : B → A) → A ≃ B propBiimpl→Equiv Aprop Bprop f g = f , hf where hf : isEquiv f hf .equiv-proof y .fst = (g y , Bprop (f (g y)) y) hf .equiv-proof y .snd h i .fst = Aprop (g y) (h .fst) i hf .equiv-proof y .snd h i .snd = isProp→isSet' Bprop (Bprop (f (g y)) y) (h .snd) (cong f (Aprop (g y) (h .fst))) refl i isEquivPropBiimpl→Equiv : isProp A → isProp B → ((A → B) × (B → A)) ≃ (A ≃ B) isEquivPropBiimpl→Equiv {A = A} {B = B} Aprop Bprop = isoToEquiv isom where isom : Iso (Σ (A → B) (λ _ → B → A)) (A ≃ B) isom .fun (f , g) = propBiimpl→Equiv Aprop Bprop f g isom .inv e = equivFun e , invEq e isom .rightInv e = equivEq refl isom .leftInv _ = refl equivΠCod : ∀ {F : A → Type ℓ} {G : A → Type ℓ'} → ((x : A) → F x ≃ G x) → ((x : A) → F x) ≃ ((x : A) → G x) equivΠCod k .fst f x = k x .fst (f x) equivΠCod k .snd .equiv-proof f .fst .fst x = equivCtr (k x) (f x) .fst equivΠCod k .snd .equiv-proof f .fst .snd i x = equivCtr (k x) (f x) .snd i equivΠCod k .snd .equiv-proof f .snd (g , p) i .fst x = equivCtrPath (k x) (f x) (g x , λ j → p j x) i .fst equivΠCod k .snd .equiv-proof f .snd (g , p) i .snd j x = equivCtrPath (k x) (f x) (g x , λ k → p k x) i .snd j equivImplicitΠCod : ∀ {F : A → Type ℓ} {G : A → Type ℓ'} → ({x : A} → F x ≃ G x) → ({x : A} → F x) ≃ ({x : A} → G x) equivImplicitΠCod k .fst f {x} = k {x} .fst (f {x}) equivImplicitΠCod k .snd .equiv-proof f .fst .fst {x} = equivCtr (k {x}) (f {x}) .fst equivImplicitΠCod k .snd .equiv-proof f .fst .snd i {x} = equivCtr (k {x}) (f {x}) .snd i equivImplicitΠCod k .snd .equiv-proof f .snd (g , p) i .fst {x} = equivCtrPath (k {x}) (f {x}) (g {x} , λ j → p j {x}) i .fst equivImplicitΠCod k .snd .equiv-proof f .snd (g , p) i .snd j {x} = equivCtrPath (k {x}) (f {x}) (g {x} , λ k → p k {x}) i .snd j equiv→Iso : (A ≃ B) → (C ≃ D) → Iso (A → C) (B → D) equiv→Iso h k .Iso.fun f b = equivFun k (f (invEq h b)) equiv→Iso h k .Iso.inv g a = invEq k (g (equivFun h a)) equiv→Iso h k .Iso.rightInv g = funExt λ b → retEq k _ ∙ cong g (retEq h b) equiv→Iso h k .Iso.leftInv f = funExt λ a → secEq k _ ∙ cong f (secEq h a) equiv→ : (A ≃ B) → (C ≃ D) → (A → C) ≃ (B → D) equiv→ h k = isoToEquiv (equiv→Iso h k) equivCompIso : (A ≃ B) → (C ≃ D) → Iso (A ≃ C) (B ≃ D) equivCompIso h k .Iso.fun f = compEquiv (compEquiv (invEquiv h) f) k equivCompIso h k .Iso.inv g = compEquiv (compEquiv h g) (invEquiv k) equivCompIso h k .Iso.rightInv g = equivEq (equiv→Iso h k .Iso.rightInv (equivFun g)) equivCompIso h k .Iso.leftInv f = equivEq (equiv→Iso h k .Iso.leftInv (equivFun f)) equivComp : (A ≃ B) → (C ≃ D) → (A ≃ C) ≃ (B ≃ D) equivComp h k = isoToEquiv (equivCompIso h k) -- Some helpful notation: _≃⟨_⟩_ : (X : Type ℓ) → (X ≃ B) → (B ≃ C) → (X ≃ C) _ ≃⟨ f ⟩ g = compEquiv f g _■ : (X : Type ℓ) → (X ≃ X) _■ = idEquiv infixr 0 _≃⟨_⟩_ infix 1 _■ composesToId→Equiv : (f : A → B) (g : B → A) → f ∘ g ≡ idfun B → isEquiv f → isEquiv g composesToId→Equiv f g id iseqf = isoToIsEquiv (iso g f (λ b → (λ i → equiv-proof iseqf (f b) .snd (g (f b) , cong (λ h → h (f b)) id) (~ i) .fst) ∙∙ cong (λ x → equiv-proof iseqf (f b) .fst .fst) id ∙∙ λ i → equiv-proof iseqf (f b) .snd (b , refl) i .fst) λ a i → id i a)
{ "alphanum_fraction": 0.5964531307, "avg_line_length": 37.6772727273, "ext": "agda", "hexsha": "30a088bb794d0d365bd70cc716656ec1a7d1229b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Edlyr/cubical", "max_forks_repo_path": "Cubical/Foundations/Equiv.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Edlyr/cubical", "max_issues_repo_path": "Cubical/Foundations/Equiv.agda", "max_line_length": 102, "max_stars_count": null, "max_stars_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Edlyr/cubical", "max_stars_repo_path": "Cubical/Foundations/Equiv.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3336, "size": 8289 }
module Scratch where open import OutsideIn.Prelude open import OutsideIn.X open import OutsideIn.Instantiations.Simple as Simple import OutsideIn data DCs : ℕ → Set where True : DCs 0 False : DCs 0 data TCs : Set where BoolT : TCs open OutsideIn(Simple DCs) data ⊥ : Set where import OutsideIn.Inference.Separator as S open S(Simple DCs) ep : ∀ {v} → SConstraint v ep = SConstraint.ε _~_ : ∀ {v} → Simple.Type v → Simple.Type v → SConstraint v _~_ = SConstraint._∼_ con : SConstraint (TCs ⨁ 7) con = (((((SConstraint.ε ∧′ (Var (suc (suc zero)) SConstraint.∼ Var (suc (suc (suc (suc zero)))))) ∧′ (Var (suc (suc (suc zero))) SConstraint.∼ Var (suc (suc (suc (suc (suc zero))))))) ∧′ ((((Var (suc zero) SConstraint.∼ Var (suc (suc (suc zero)))) ∧′ (Var (suc zero) SConstraint.∼ Var (suc (suc (suc (suc (suc (suc (suc BoolT))))))))) ∧′ (Var (suc (suc (suc (suc (suc (suc (suc BoolT))))))) SConstraint.∼ Var (suc (suc zero)))) ∧′ ((((Var zero SConstraint.∼ Var (suc (suc (suc zero)))) ∧′ (Var zero SConstraint.∼ Var (suc (suc (suc (suc (suc (suc (suc BoolT))))))))) ∧′ (Var (suc (suc (suc (suc (suc (suc (suc BoolT))))))) SConstraint.∼ Var (suc (suc zero)))) ∧′ SConstraint.ε))) ∧′ (Var (suc (suc (suc (suc (suc (suc zero)))))) SConstraint.∼ ((funTy · Var (suc (suc (suc (suc zero))))) · Var (suc (suc (suc (suc (suc zero))))))))) con-s : SConstraint (SVar TCs 7) con-s = Functor.map sconstraint-is-functor svar-iso₁ con con′ : SConstraint (TCs ⨁ 1) con′ = SConstraint.ε ∧′ ((Var zero) SConstraint.∼ (Var (suc BoolT)) ) conn : SConstraint (TCs ⨁ 2) conn = (Var (suc zero)) Simple.∼ ((funTy · Var zero) · Var zero) v = Simple.simplifier (λ a b → true) 1 ax SConstraint.ε conn open import Data.List -- -- zero --> suc suc zero -- suc zero --> zero -- suc suc zero --> suc zero -- suc suc suc zero --> suc suc zero -- suc suc suc suc zero --> suc suc suc zero -- suc suc suc suc suc zero --> suc suc suc suc zero -- suc suc suc suc suc suc zero --> suc suc suc suc suc zero e : ∀ {tv} → Expression tv TCs _ e = λ′ case Var (N zero) of ( DC True →′ Var (DC False) ∣ DC False →′ Var (DC True ) ∣ esac ) e2 : ∀ {tv ev} → Expression tv ev _ e2 = λ′ Var (N zero) p2 : Program ⊥ TCs p2 = bind₂ 1 · e2 ∷ SConstraint.ε ⇒ Var zero ⟶ Var zero , bind₁ e2 , end p : Program ⊥ TCs p = bind₂ 0 · e ∷ SConstraint.ε ⇒ Var BoolT ⟶ Var BoolT , bind₁ e , end Γ : Environment ⊥ TCs Γ (DC True) = DC∀ 0 · [] ⟶ BoolT Γ (DC False) = DC∀ 0 · [] ⟶ BoolT Γ (N ()) open import Data.Fin test = go ax Γ (λ a b → true) p test2 = go ax Γ (λ a b → true) p2
{ "alphanum_fraction": 0.5426703372, "avg_line_length": 29.6530612245, "ext": "agda", "hexsha": "5bc762c9262c1c9ec1c24cede7d22e8ecd0422eb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "liamoc/outside-in", "max_forks_repo_path": "Scratch.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "liamoc/outside-in", "max_issues_repo_path": "Scratch.agda", "max_line_length": 164, "max_stars_count": 2, "max_stars_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "liamoc/outside-in", "max_stars_repo_path": "Scratch.agda", "max_stars_repo_stars_event_max_datetime": "2020-11-19T14:30:07.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-14T05:22:15.000Z", "num_tokens": 1062, "size": 2906 }
-- ----------------------------- -- Equality module Homogenous.Equality where import Homogenous.Base import EqBase import PolyDepPrelude open PolyDepPrelude using ( Datoid ; Bool; true; false; _&&_ ; Pair; pair ; Either; left; right ; suc; zero ; _::_; nil ; cmp; Unit; unit ) open Homogenous.Base using (Arity; Sig; Fa; F; T; It; out) eq_step_ar : (n : Arity){X : Set}(fs : Fa n (X -> Bool))(xs : Fa n X) -> Bool eq_step_ar zero unit unit = true eq_step_ar (suc m) (pair f fs') (pair x xs') = f x && eq_step_ar m fs' xs' -- We write left as This (as in "This constructor" and right as Other -- (as in "one of the Other constructors") to help the reader eq_step' : (fi : Sig){X : Set} -> F fi (X -> Bool) -> F fi X -> Bool eq_step' (nil) () () -- empty eq_step' (n :: ns) (left fs ) (left xs ) = eq_step_ar n fs xs eq_step' (n :: ns) (left fs ) (right y') = false eq_step' (n :: ns) (right x') (left xs ) = false eq_step' (n :: ns) (right x') (right y') = eq_step' ns x' y' eq_step : (fi : Sig)(x : F fi (T fi -> Bool)) -> T fi -> Bool eq_step fi x = \t -> eq_step' fi x (out fi t) equal' : (fi : Sig) -> T fi -> (T fi -> Bool) equal' fi = It fi (eq_step fi) equal : (fi : Sig) -> T fi -> T fi -> Bool equal fi x y = equal' fi x y
{ "alphanum_fraction": 0.5210263721, "avg_line_length": 33.4047619048, "ext": "agda", "hexsha": "7aedda17759cfb8af9ee3d745100319879abf786", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "examples/AIM5/PolyDep/Homogenous/Equality.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "examples/AIM5/PolyDep/Homogenous/Equality.agda", "max_line_length": 77, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/AIM5/PolyDep/Homogenous/Equality.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": 442, "size": 1403 }
module Structure.Monoid.Laws where open import Prelude record MonoidLaws {a} (A : Set a) {{Mon : Monoid A}} : Set a where field idLeft : (x : A) → mempty <> x ≡ x idRight : (x : A) → x <> mempty ≡ x <>assoc : (x y z : A) → x <> (y <> z) ≡ (x <> y) <> z open MonoidLaws {{...}} public {-# DISPLAY MonoidLaws.idLeft _ = idLeft #-} {-# DISPLAY MonoidLaws.idRight _ = idRight #-} {-# DISPLAY MonoidLaws.<>assoc _ = <>assoc #-} instance MonoidLawsList : ∀ {a} {A : Set a} → MonoidLaws (List A) idLeft {{MonoidLawsList}} xs = refl idRight {{MonoidLawsList}} [] = refl idRight {{MonoidLawsList}} (x ∷ xs) = x ∷_ $≡ idRight xs <>assoc {{MonoidLawsList}} [] ys zs = refl <>assoc {{MonoidLawsList}} (x ∷ xs) ys zs = x ∷_ $≡ <>assoc xs ys zs MonoidLawsMaybe : ∀ {a} {A : Set a} {{_ : Monoid A}} {{_ : MonoidLaws A}} → MonoidLaws (Maybe A) idLeft {{MonoidLawsMaybe}} x = refl idRight {{MonoidLawsMaybe}} nothing = refl idRight {{MonoidLawsMaybe}} (just _) = refl <>assoc {{MonoidLawsMaybe}} nothing y z = refl <>assoc {{MonoidLawsMaybe}} (just x) y z = refl -- Can't do function lifting because no extentionality.
{ "alphanum_fraction": 0.5905644482, "avg_line_length": 34.9117647059, "ext": "agda", "hexsha": "579bc96e79998985f0235dd79c04aa08165ba3ef", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_path": "src/Structure/Monoid/Laws.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lclem/agda-prelude", "max_issues_repo_path": "src/Structure/Monoid/Laws.agda", "max_line_length": 98, "max_stars_count": null, "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_path": "src/Structure/Monoid/Laws.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 435, "size": 1187 }
module _ where import DummyModule Set Set
{ "alphanum_fraction": 0.7954545455, "avg_line_length": 8.8, "ext": "agda", "hexsha": "d6ca362534f864a3a16e656b6605872a4782567a", "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/Issue2579.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/Issue2579.agda", "max_line_length": 26, "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/Issue2579.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 11, "size": 44 }
module Data.HVec where open import Data.Fin using (Fin; zero; suc) open import Data.Nat using (ℕ; zero; suc; _+_) open import Function using (const) open import Data.Vec as V using (Vec; []; _∷_; _[_]≔_) open import Level as L using (Level; suc) -- ------------------------------------------------------------------------ -- Hetrogenous Vectors infixr 5 _∷_ data HVec { ℓ } : ( n : ℕ ) → Vec (Set ℓ) n → Set ℓ where [] : HVec 0 [] _∷_ : ∀ { n } { A : Set ℓ } { As } → A → HVec n As -- ---------------------- → HVec (1 + n) (A ∷ As) -- -- ------------------------------------------------------------------------ private variable ℓ : Level A : Set ℓ n : ℕ As : Vec (Set ℓ) n length : HVec n As → ℕ length { n = n } _ = n head : HVec (1 + n) As → (V.head As) head (x ∷ xs) = x tail : HVec (1 + n) As → HVec n (V.tail As) tail (x ∷ xs) = xs lookup : HVec n As → (i : Fin n) → (V.lookup As i) lookup (x ∷ xs) zero = x lookup (x ∷ xs) (suc i) = lookup xs i insert : HVec n As → (i : Fin (1 + n)) → A → HVec (1 + n) (V.insert As i A) insert xs zero v = v ∷ xs insert (x ∷ xs) (suc i) v = x ∷ insert xs i v remove : HVec (1 + n) As → (i : Fin (1 + n)) → HVec n (V.remove As i) remove (x ∷ xs) zero = xs remove (x₁ ∷ x₂ ∷ xs) (suc i) = x₁ ∷ remove (x₂ ∷ xs) i updateAt : ∀ { ℓ n } { A : Set ℓ } { As : Vec (Set ℓ) n } (i : Fin n) → (V.lookup As i → A) → HVec n As → HVec n (As [ i ]≔ A) updateAt zero f (x ∷ xs) = f x ∷ xs updateAt (suc i) f (x ∷ xs) = x ∷ updateAt i f xs infixl 6 _[_]$=_ _[_]$=_ : HVec n As → (i : Fin n) → (V.lookup As i → A) → HVec n (As [ i ]≔ A) xs [ i ]$= f = updateAt i f xs infixl 6 _[_]&=_ _[_]&=_ : HVec n As → (i : Fin n) → A → HVec n (As [ i ]≔ A) xs [ i ]&= y = xs [ i ]$= const y -- -- ------------------------------------------------------------------------
{ "alphanum_fraction": 0.4444444444, "avg_line_length": 25.2739726027, "ext": "agda", "hexsha": "c1f74ba2ce75b170a72564863c2ddb87f382f532", "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": "bb895fa8a3ccbefbd2c4a135c79744ba06895be7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "johnyob/agda-sigma", "max_forks_repo_path": "src/Data/HVec.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bb895fa8a3ccbefbd2c4a135c79744ba06895be7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "johnyob/agda-sigma", "max_issues_repo_path": "src/Data/HVec.agda", "max_line_length": 126, "max_stars_count": null, "max_stars_repo_head_hexsha": "bb895fa8a3ccbefbd2c4a135c79744ba06895be7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "johnyob/agda-sigma", "max_stars_repo_path": "src/Data/HVec.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 705, "size": 1845 }
open import Oscar.Prelude open import Oscar.Data.Proposequality module Oscar.Class.Symmetrical where private module _ {𝔞} {𝔄 : Ø 𝔞} {𝔟} {𝔅 : Ø 𝔟} where module Visible (_∼_ : 𝔄 → 𝔄 → 𝔅) {ℓ} (_↦_ : 𝔅 → 𝔅 → Ø ℓ) where 𝓼ymmetrical = λ x y → (x ∼ y) ↦ (y ∼ x) 𝓈ymmetrical = ∀ x y → 𝓼ymmetrical x y record 𝓢ymmetrical {𝓢 : 𝔄 → 𝔄 → Ø ℓ} ⦃ _ : 𝓢 ≡ 𝓼ymmetrical ⦄ : Ø 𝔞 ∙̂ ℓ where field symmetrical : 𝓈ymmetrical -- FIXME might there be some reason to use "∀ x y → 𝓢 x y" here instead? Symmetrical : Ø _ Symmetrical = 𝓢ymmetrical ⦃ ∅ ⦄ symmetrical⟦_/_⟧ : ⦃ _ : Symmetrical ⦄ → 𝓈ymmetrical symmetrical⟦_/_⟧ ⦃ I ⦄ = 𝓢ymmetrical.symmetrical I module Hidden {_∼_ : 𝔄 → 𝔄 → 𝔅} {ℓ} {_↦_ : 𝔅 → 𝔅 → Ø ℓ} where open Visible _∼_ _↦_ symmetrical : ⦃ _ : Symmetrical ⦄ → 𝓈ymmetrical symmetrical = symmetrical⟦_/_⟧ open Visible public open Hidden public
{ "alphanum_fraction": 0.5523138833, "avg_line_length": 25.4871794872, "ext": "agda", "hexsha": "a24dc0811c324b482f55ee254b60521246eb5d1a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Symmetrical.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Symmetrical.agda", "max_line_length": 112, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Symmetrical.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 420, "size": 994 }
-- Andreas, 2012-06-07 -- {-# OPTIONS --show-implicit -v tc.rec:100 -v tc.meta.assign:15 #-} module Issue387 where import Common.Level mutual record R' (A : Set) : Set where field f : _ c' : {A : Set} -> A -> R' A c' a = record { f = a } -- previous to fix of 387, this had an unresolved meta -- because two metas were created for _
{ "alphanum_fraction": 0.617816092, "avg_line_length": 20.4705882353, "ext": "agda", "hexsha": "858431542ea31ed004896523b9b5ef27dd713c94", "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/Issue387.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/Issue387.agda", "max_line_length": 69, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue387.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": 113, "size": 348 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category.Core using (Category) module Categories.Diagram.Pushout {o ℓ e} (C : Category o ℓ e) where open Category C open HomReasoning open Equiv open import Categories.Morphism.Reasoning C as Square renaming (glue to glue-square) hiding (id-unique) open import Level private variable A B E X Y Z : Obj f g h j : A ⇒ B record Pushout (f : X ⇒ Y) (g : X ⇒ Z) : Set (o ⊔ ℓ ⊔ e) where field {Q} : Obj i₁ : Y ⇒ Q i₂ : Z ⇒ Q field commute : i₁ ∘ f ≈ i₂ ∘ g universal : {h₁ : Y ⇒ B} {h₂ : Z ⇒ B} → h₁ ∘ f ≈ h₂ ∘ g → Q ⇒ B unique : {h₁ : Y ⇒ E} {h₂ : Z ⇒ E} {j : Q ⇒ E} {eq : h₁ ∘ f ≈ h₂ ∘ g} → j ∘ i₁ ≈ h₁ → j ∘ i₂ ≈ h₂ → j ≈ universal eq universal∘i₁≈h₁ : {h₁ : Y ⇒ E} {h₂ : Z ⇒ E} {eq : h₁ ∘ f ≈ h₂ ∘ g} → universal eq ∘ i₁ ≈ h₁ universal∘i₂≈h₂ : {h₁ : Y ⇒ E} {h₂ : Z ⇒ E} {eq : h₁ ∘ f ≈ h₂ ∘ g} → universal eq ∘ i₂ ≈ h₂ unique-diagram : h ∘ i₁ ≈ j ∘ i₁ → h ∘ i₂ ≈ j ∘ i₂ → h ≈ j unique-diagram {h = h} {j = j} eq₁ eq₂ = begin h ≈⟨ unique eq₁ eq₂ ⟩ universal eq ≈˘⟨ unique refl refl ⟩ j ∎ where eq = extendˡ commute
{ "alphanum_fraction": 0.4769585253, "avg_line_length": 27.7021276596, "ext": "agda", "hexsha": "0efd95bea92bef7aed09b0baee4b2fa311dbc66c", "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": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Diagram/Pushout.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "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": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Diagram/Pushout.agda", "max_line_length": 78, "max_stars_count": 5, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Diagram/Pushout.agda", "max_stars_repo_stars_event_max_datetime": "2019-05-22T03:54:24.000Z", "max_stars_repo_stars_event_min_datetime": "2019-05-21T17:07:19.000Z", "num_tokens": 521, "size": 1302 }
module Basic.Compiler.Machine where open import Basic.AST open import Basic.BigStep open import Basic.Compiler.Code open import Utils.Decidable open import Data.Product open import Relation.Nullary open import Relation.Nullary.Decidable open import Data.List hiding (unfold) open import Data.Bool open import Data.Nat open import Data.Maybe {- This is a simple interpreter for the abstract machine code. There's no corresponding part in the book. A nice thing about the abstract machine is that each transition is decidable, so we can tell at each point whether our program is stuck or may continue. Of course, this doesn't mean that *computation sequences* are decidable! (it's pretty much just the halting problem). What we can do is specify how many steps we'd like to compute, and then compute that far. The "steps" function below only computes the ending configuration, while "trace" returns a list of all intermediate configurations. "unfold" returns a computation sequence if the program terminates or gets stuck in the given number of steps. -} step : ∀ {n} (c : Code n) e s → Dec (∃₂ λ c' e' -> ∃ λ s' → ⟨ c , e , s ⟩▷⟨ c' , e' , s' ⟩) step [] e s = no (λ {(c' , e' , s' , ())}) step (PUSH x ∷ c) e s = yes (c , nat x ∷ e , s , PUSH x) step (FETCH x ∷ c) e s = yes (c , nat _ ∷ e , s , FETCH x) step (STORE x ∷ c) [] s = no (λ {(c' , e' , s' , ())}) step (STORE x ∷ c) (nat x₁ ∷ e) s = yes (c , e , _ , STORE x) step (STORE x ∷ c) (bool x₁ ∷ e) s = no (λ {(c' , e' , s' , ())}) step (ADD ∷ c) [] s = no (λ { (c' , e' , s' , ()) }) step (ADD ∷ c) (nat x ∷ []) s = no (λ { (c' , e' , s' , ()) }) step (ADD ∷ c) (nat x ∷ nat x₁ ∷ e) s = yes (c , nat _ ∷ e , s , ADD x x₁) step (ADD ∷ c) (nat x ∷ bool x₁ ∷ e) s = no (λ { (c' , e' , s' , ()) }) step (ADD ∷ c) (bool x ∷ e) s = no (λ { (c' , e' , s' , ()) }) step (MUL ∷ c) [] s = no (λ { (c' , e' , s' , ()) }) step (MUL ∷ c) (nat x ∷ []) s = no (λ { (c' , e' , s' , ()) }) step (MUL ∷ c) (nat x ∷ nat x₁ ∷ e) s = yes (c , nat _ ∷ e , s , MUL x x₁) step (MUL ∷ c) (nat x ∷ bool x₁ ∷ e) s = no (λ { (c' , e' , s' , ()) }) step (MUL ∷ c) (bool x ∷ e) s = no (λ { (c' , e' , s' , ()) }) step (SUB ∷ c) [] s = no (λ { (c' , e' , s' , ()) }) step (SUB ∷ c) (nat x ∷ []) s = no (λ { (c' , e' , s' , ()) }) step (SUB ∷ c) (nat x ∷ nat x₁ ∷ e) s = yes (c , nat _ ∷ e , s , SUB x x₁) step (SUB ∷ c) (nat x ∷ bool x₁ ∷ e) s = no (λ { (c' , e' , s' , ()) }) step (SUB ∷ c) (bool x ∷ e) s = no (λ { (c' , e' , s' , ()) }) step (TRUE ∷ c) e s = yes (c , bool true ∷ e , s , TRUE) step (FALSE ∷ c) e s = yes (c , bool false ∷ e , s , FALSE) step (EQ ∷ c) [] s = no (λ { (c' , e' , s' , ()) }) step (EQ ∷ c) (nat x ∷ []) s = no (λ { (c' , e' , s' , ()) }) step (EQ ∷ c) (nat x ∷ nat x₁ ∷ e) s = yes (c , bool ⌊ x ≡⁇ x₁ ⌋ ∷ e , s , EQ x x₁) step (EQ ∷ c) (nat x ∷ bool x₁ ∷ e) s = no (λ { (c' , e' , s' , ()) }) step (EQ ∷ c) (bool x ∷ e) s = no (λ { (c' , e' , s' , ()) }) step (LTE ∷ c) [] s = no (λ { (c' , e' , s' , ()) }) step (LTE ∷ c) (nat x ∷ []) s = no (λ { (c' , e' , s' , ()) }) step (LTE ∷ c) (nat x ∷ nat x₁ ∷ e) s = yes (c , bool ⌊ x ≤⁇ x₁ ⌋ ∷ e , s , LTE x x₁) step (LTE ∷ c) (nat x ∷ bool x₁ ∷ e) s = no (λ { (c' , e' , s' , ()) }) step (LTE ∷ c) (bool x ∷ e) s = no (λ { (c' , e' , s' , ()) }) step (LT ∷ c) [] s = no (λ { (c' , e' , s' , ()) }) step (LT ∷ c) (nat x ∷ []) s = no (λ { (c' , e' , s' , ()) }) step (LT ∷ c) (nat x ∷ nat x₁ ∷ e) s = yes (c , bool ⌊ x <⁇ x₁ ⌋ ∷ e , s , LT x x₁) step (LT ∷ c) (nat x ∷ bool x₁ ∷ e) s = no (λ { (c' , e' , s' , ()) }) step (LT ∷ c) (bool x ∷ e) s = no (λ { (c' , e' , s' , ()) }) step (AND ∷ c) [] s = no (λ { (c' , e' , s' , ()) }) step (AND ∷ c) (nat x ∷ e) s = no (λ { (c' , e' , s' , ()) }) step (AND ∷ c) (bool x ∷ []) s = no (λ { (c' , e' , s' , ()) }) step (AND ∷ c) (bool x ∷ nat x₁ ∷ e) s = no (λ { (c' , e' , s' , ()) }) step (AND ∷ c) (bool x ∷ bool x₁ ∷ e) s = yes (c , bool (x ∧ x₁) ∷ e , s , AND x x₁) step (NOT ∷ c) [] s = no (λ { (c' , e' , s' , ()) }) step (NOT ∷ c) (nat x ∷ e) s = no (λ { (c' , e' , s' , ()) }) step (NOT ∷ c) (bool x ∷ e) s = yes (c , bool _ ∷ e , s , NOT x) step (NOOP ∷ c) e s = yes (c , e , s , NOOP) step (BRANCH x x₁ ∷ c) [] s = no (λ { (c' , e' , s' , ()) }) step (BRANCH x x₁ ∷ c) (nat x₂ ∷ e) s = no (λ { (c' , e' , s' , ()) }) step (BRANCH x x₁ ∷ c) (bool true ∷ e) s = yes (x ++ c , e , s , BRANCH) step (BRANCH x x₁ ∷ c) (bool false ∷ e) s = yes (x₁ ++ c , e , s , BRANCH) step (LOOP x x₁ ∷ c) e s = yes (x ++ BRANCH (x₁ ++ LOOP x x₁ ∷ []) (NOOP ∷ []) ∷ c , e , s , LOOP) steps : ∀ {n} → Code n → Stack → State n → ℕ → (Code n × Stack × State n) steps c e s zero = c , e , s steps c e s (suc n) with step c e s ... | yes (c' , e' , s' , p) = steps c' e' s' n ... | no _ = c , e , s trace : ∀ {n} → Code n → Stack → State n → ℕ → List (Code n × Stack × State n) trace c e s zero = [] trace c e s (suc n) with step c e s ... | yes (c' , e' , s' , p) = (c , e , s) ∷ trace c' e' s' n ... | no _ = (c , e , s) ∷ [] unfold : ∀ {n} c e (s : State n) → ℕ → Maybe (∃₂ λ c' e' → ∃ λ s' → ⟨ c , e , s ⟩▷*⟨ c' , e' , s' ⟩) unfold [] e s n₁ = just ([] , e , s , done) unfold (x ∷ c) e s zero = nothing unfold (x ∷ c) e s (suc n) with step (x ∷ c) e s ... | no ¬p = just (x ∷ c , e , s , stuck (λ c' e' s' z → ¬p (c' , e' , s' , z))) ... | yes (c' , e' , s' , p) with unfold c' e' s' n ... | nothing = nothing ... | just (c'' , e'' , s'' , seq) = just (c'' , e'' , s'' , p ∷ seq)
{ "alphanum_fraction": 0.4646853788, "avg_line_length": 43.2619047619, "ext": "agda", "hexsha": "2f21c9ebcbbd8806c27e4233ce7faa237025bef2", "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": "05200d60b4a4b2c6fa37806ced9247055d24db94", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AndrasKovacs/SemanticsWithApplications", "max_forks_repo_path": "Basic/Compiler/Machine.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94", "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": "AndrasKovacs/SemanticsWithApplications", "max_issues_repo_path": "Basic/Compiler/Machine.agda", "max_line_length": 98, "max_stars_count": 8, "max_stars_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AndrasKovacs/SemanticsWithApplications", "max_stars_repo_path": "Basic/Compiler/Machine.agda", "max_stars_repo_stars_event_max_datetime": "2020-02-02T10:01:52.000Z", "max_stars_repo_stars_event_min_datetime": "2016-09-12T04:25:39.000Z", "num_tokens": 2380, "size": 5451 }
{-# OPTIONS --safe --without-K #-} module Generics.All where open import Generics.Prelude open import Generics.Telescope open import Generics.Desc open import Generics.Mu private variable P : Telescope ⊤ p : ⟦ P ⟧tel tt V I : ExTele P ℓ c : Level n : ℕ levelAllIndArg : ConDesc P V I → Level → Level levelAllIndArg (var _) c = c levelAllIndArg (π {ℓ} _ _ C) c = ℓ ⊔ levelAllIndArg C c levelAllIndArg (A ⊗ B) c = levelAllIndArg A c ⊔ levelAllIndArg B c AllIndArg : {X : ⟦ P , I ⟧xtel → Set ℓ} (Pr : ∀ {i} → X (p , i) → Set c) (C : ConDesc P V I) → ∀ {v} → ⟦ C ⟧IndArg X (p , v) → Set (levelAllIndArg C c) AllIndArg Pr (var _) x = Pr x AllIndArg Pr (π (n , ai) S C) x = (s : < relevance ai > S _) → AllIndArg Pr C (app< n , ai > x s) AllIndArg Pr (A ⊗ B) (xa , xb) = AllIndArg Pr A xa × AllIndArg Pr B xb AllIndArgω : {X : ⟦ P , I ⟧xtel → Set ℓ} (Pr : ∀ {i} → X (p , i) → Setω) (C : ConDesc P V I) → ∀ {v} → ⟦ C ⟧IndArg X (p , v) → Setω AllIndArgω Pr (var _) x = Pr x AllIndArgω Pr (π (n , ai) S C) x = (s : < relevance ai > S _) → AllIndArgω Pr C (app< n , ai > x s) AllIndArgω Pr (A ⊗ B) (xa , xb) = AllIndArgω Pr A xa ×ω AllIndArgω Pr B xb levelAllCon : ConDesc P V I → Level → Level levelAllCon (var _) c = lzero levelAllCon (π {ℓ} _ _ C) c = levelAllCon C c levelAllCon (A ⊗ B) c = levelAllIndArg A c ⊔ levelAllCon B c AllCon : {X : ⟦ P , I ⟧xtel → Set ℓ} (Pr : ∀ {i} → X (p , i) → Set c) (C : ConDesc P V I) → ∀ {v i} → ⟦ C ⟧Con X (p , v , i) → Set (levelAllCon C c) AllCon Pr (var _) x = ⊤ AllCon Pr (π _ _ C) (_ , x) = AllCon Pr C x AllCon Pr (A ⊗ B) (xa , xb) = AllIndArg Pr A xa × AllCon Pr B xb AllConω : {X : ⟦ P , I ⟧xtel → Set ℓ} (Pr : ∀ {i} → X (p , i) → Setω) (C : ConDesc P V I) → ∀ {v i} → ⟦ C ⟧Con X (p , v , i) → Setω AllConω Pr (var f) x = ⊤ω AllConω Pr (π ia S C) (_ , x) = AllConω Pr C x AllConω Pr (A ⊗ B) (xa , xb) = AllIndArgω Pr A xa ×ω AllConω Pr B xb AllData : {X : ⟦ P , I ⟧xtel → Set ℓ} (Pr : ∀ {i} → X (p , i) → Set c) (D : DataDesc P I n) → ∀ {i} ((k , x) : ⟦ D ⟧Data X (p , i)) → Set (levelAllCon (lookupCon D k) c) AllData Pr D (k , x) = AllCon Pr (lookupCon D k) x AllDataω : {X : ⟦ P , I ⟧xtel → Set ℓ} (Pr : ∀ {i} → X (p , i) → Setω) (D : DataDesc P I n) → ∀ {i} (x : ⟦ D ⟧Data X (p , i)) → Setω AllDataω Pr D (k , x) = AllConω Pr (lookupCon D k) x
{ "alphanum_fraction": 0.527324633, "avg_line_length": 31.0379746835, "ext": "agda", "hexsha": "a5cd792019c3ba959a2d0a315180317cede5134a", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-01-14T10:35:16.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-08T08:32:42.000Z", "max_forks_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "flupe/generics", "max_forks_repo_path": "src/Generics/All.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_issues_repo_issues_event_max_datetime": "2022-01-14T10:48:30.000Z", "max_issues_repo_issues_event_min_datetime": "2021-09-13T07:33:50.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "flupe/generics", "max_issues_repo_path": "src/Generics/All.agda", "max_line_length": 99, "max_stars_count": 11, "max_stars_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "flupe/generics", "max_stars_repo_path": "src/Generics/All.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T09:35:17.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-08T15:10:20.000Z", "num_tokens": 1067, "size": 2452 }
module OList.Properties {A : Set}(_≤_ : A → A → Set) where open import Data.List open import Bound.Lower A open import Bound.Lower.Order _≤_ open import List.Sorted _≤_ open import OList _≤_ lemma-olist-sorted : {b : Bound} → (xs : OList b) → Sorted (forget xs) lemma-olist-sorted onil = nils lemma-olist-sorted (:< {x = x} _ onil) = singls x lemma-olist-sorted (:< b≤x (:< (lexy x≤y) ys)) = conss x≤y (lemma-olist-sorted (:< (lexy x≤y) ys))
{ "alphanum_fraction": 0.6659192825, "avg_line_length": 29.7333333333, "ext": "agda", "hexsha": "2cf30a13e92e290a83e7ca16af650fabe2ceeeab", "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/OList/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/OList/Properties.agda", "max_line_length": 98, "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/OList/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": 166, "size": 446 }
{-# OPTIONS --without-K #-} module LeqLemmas where open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _<_; _≤_; _≤?_; z≤n; s≤s; module ≤-Reasoning) open import Data.Nat.Properties.Simple using (*-comm; +-right-identity; +-comm; +-assoc) open import Data.Nat.Properties using (cancel-+-left-≤; n≤m+n) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; cong; module ≡-Reasoning) open import Relation.Binary using (Decidable) open import Relation.Binary.Core using (Transitive; _⇒_) open import Data.Fin using (Fin; zero; suc; toℕ; fromℕ; raise; inject≤) open import Data.Fin.Properties using (bounded; to-from) ------------------------------------------------------------------------------ -- Proofs and definitions about ≤ on natural numbers _<?_ : Decidable _<_ i <? j = suc i ≤? j -- buried in Data.Nat refl′ : _≡_ ⇒ _≤_ refl′ {0} refl = z≤n refl′ {suc m} refl = s≤s (refl′ refl) trans< : Transitive _<_ trans< (s≤s z≤n) (s≤s _) = s≤s z≤n trans< (s≤s (s≤s i≤j)) (s≤s sj<k) = s≤s (trans< (s≤s i≤j) sj<k) trans≤ : Transitive _≤_ trans≤ z≤n x = z≤n trans≤ (s≤s m≤n) (s≤s n≤o) = s≤s (trans≤ m≤n n≤o) i*1≡i : (i : ℕ) → i * 1 ≡ i i*1≡i i = begin (i * 1 ≡⟨ *-comm i 1 ⟩ 1 * i ≡⟨ refl ⟩ i + 0 ≡⟨ +-right-identity i ⟩ i ∎) where open ≡-Reasoning i≤i : (i : ℕ) → i ≤ i i≤i 0 = z≤n i≤i (suc i) = s≤s (i≤i i) i≤si : (i : ℕ) → i ≤ suc i i≤si 0 = z≤n i≤si (suc i) = s≤s (i≤si i) i≤j+i : ∀ {i j} → i ≤ j + i i≤j+i {i} {0} = i≤i i i≤j+i {i} {suc j} = begin (i ≤⟨ i≤j+i {i} {j} ⟩ j + i ≤⟨ i≤si (j + i) ⟩ suc j + i ∎) where open ≤-Reasoning cong+r≤ : ∀ {i j} → i ≤ j → (k : ℕ) → i + k ≤ j + k cong+r≤ {0} {j} z≤n k = n≤m+n j k cong+r≤ {suc i} {0} () k -- absurd cong+r≤ {suc i} {suc j} (s≤s i≤j) k = s≤s (cong+r≤ {i} {j} i≤j k) cong+l≤ : ∀ {i j} → i ≤ j → (k : ℕ) → k + i ≤ k + j cong+l≤ {i} {j} i≤j k = begin (k + i ≡⟨ +-comm k i ⟩ i + k ≤⟨ cong+r≤ i≤j k ⟩ j + k ≡⟨ +-comm j k ⟩ k + j ∎) where open ≤-Reasoning cong*r≤ : ∀ {i j} → i ≤ j → (k : ℕ) → i * k ≤ j * k cong*r≤ {0} {j} z≤n k = z≤n cong*r≤ {suc i} {0} () k -- absurd cong*r≤ {suc i} {suc j} (s≤s i≤j) k = cong+l≤ (cong*r≤ i≤j k) k sinj : ∀ {i j} → suc i ≡ suc j → i ≡ j sinj = cong (λ { 0 → 0 ; (suc x) → x }) sinj≤ : ∀ {i j} → suc i ≤ suc j → i ≤ j sinj≤ {0} {j} _ = z≤n sinj≤ {suc i} {0} (s≤s ()) -- absurd sinj≤ {suc i} {suc j} (s≤s p) = p i*n+n≤sucm*n : ∀ {m n} → (i : Fin (suc m)) → toℕ i * n + n ≤ suc m * n i*n+n≤sucm*n {0} {n} zero = begin (n ≡⟨ sym (+-right-identity n) ⟩ n + 0 ≤⟨ i≤i (n + 0) ⟩ n + 0 ∎) where open ≤-Reasoning i*n+n≤sucm*n {0} {n} (suc ()) i*n+n≤sucm*n {suc m} {n} i = begin (toℕ i * n + n ≡⟨ +-comm (toℕ i * n) n ⟩ n + toℕ i * n ≡⟨ refl ⟩ suc (toℕ i) * n ≤⟨ cong*r≤ (bounded i) n ⟩ suc (suc m) * n ∎) where open ≤-Reasoning i*n+k≤m*n : ∀ {m n} → (i : Fin m) → (k : Fin n) → (suc (toℕ i * n + toℕ k) ≤ m * n) i*n+k≤m*n {0} {_} () _ i*n+k≤m*n {_} {0} _ () i*n+k≤m*n {suc m} {suc n} i k = begin (suc (toℕ i * suc n + toℕ k) ≡⟨ cong suc (+-comm (toℕ i * suc n) (toℕ k)) ⟩ suc (toℕ k + toℕ i * suc n) ≡⟨ refl ⟩ suc (toℕ k) + (toℕ i * suc n) ≤⟨ cong+r≤ (bounded k) (toℕ i * suc n) ⟩ suc n + (toℕ i * suc n) ≤⟨ cong+l≤ (cong*r≤ (sinj≤ (bounded i)) (suc n)) (suc n) ⟩ suc n + (m * suc n) ≡⟨ refl ⟩ suc m * suc n ∎) where open ≤-Reasoning bounded' : (m : ℕ) → (j : Fin (suc m)) → (toℕ j ≤ m) bounded' m j with bounded j ... | s≤s pr = pr simplify-≤ : {m n m' n' : ℕ} → (m ≤ n) → (m ≡ m') → (n ≡ n') → (m' ≤ n') simplify-≤ leq refl refl = leq cancel-Fin : ∀ (n y z : ℕ) → ((x : Fin (suc n)) → toℕ x + y ≤ n + z) → y ≤ z cancel-Fin 0 y z pf = pf zero cancel-Fin (suc n) y z pf = cancel-+-left-≤ n (trans≤ leq (sinj≤ (pf (fromℕ (suc n))))) where leq : n + y ≤ toℕ (fromℕ n) + y leq = begin (n + y ≡⟨ cong (λ x → x + y) (sym (to-from n)) ⟩ toℕ (fromℕ n) + y ∎) where open ≤-Reasoning ≤-proof-irrelevance : {m n : ℕ} → (p q : m ≤ n) → p ≡ q ≤-proof-irrelevance z≤n z≤n = refl ≤-proof-irrelevance (s≤s p) (s≤s q) = cong s≤s (≤-proof-irrelevance p q) raise-suc' : (n a b n+a : ℕ) (n+a≡ : n+a ≡ n + a) → (leq : suc a ≤ b) → (leq' : suc n+a ≤ n + b) → raise n (inject≤ (fromℕ a) leq) ≡ inject≤ (fromℕ n+a) leq' raise-suc' 0 a b .a refl leq leq' = cong (inject≤ (fromℕ a)) (≤-proof-irrelevance leq leq') raise-suc' (suc n) a b .(suc (n + a)) refl leq (s≤s leq') = cong suc (raise-suc' n a b (n + a) refl leq leq') raise-suc : (m n : ℕ) (j : Fin (suc m)) (d : Fin (suc n)) (leq : suc (toℕ j * suc n + toℕ d) ≤ suc m * suc n) → (leq' : suc (toℕ (suc j) * suc n + toℕ d) ≤ suc (suc m) * suc n) → raise (suc n) (inject≤ (fromℕ (toℕ j * suc n + toℕ d)) leq) ≡ inject≤ (fromℕ (toℕ (suc j) * suc n + toℕ d)) leq' raise-suc m n j d leq leq' = raise-suc' (suc n) (toℕ j * suc n + toℕ d) (suc m * suc n) (toℕ (suc j) * suc n + toℕ d) (begin (toℕ (suc j) * suc n + toℕ d ≡⟨ refl ⟩ (suc n + toℕ j * suc n) + toℕ d ≡⟨ +-assoc (suc n) (toℕ j * suc n) (toℕ d) ⟩ suc n + (toℕ j * suc n + toℕ d) ∎)) leq leq' where open ≡-Reasoning {- -- buried in Data.Nat refl′ : _≡_ ⇒ _≤_ refl′ {0} refl = z≤n refl′ {suc m} refl = s≤s (refl′ refl) trans< : Transitive _<_ trans< (s≤s z≤n) (s≤s _) = s≤s z≤n trans< (s≤s (s≤s i≤j)) (s≤s sj<k) = s≤s (trans< (s≤s i≤j) sj<k) trans≤ : Transitive _≤_ trans≤ z≤n x = z≤n trans≤ (s≤s m≤n) (s≤s n≤o) = s≤s (trans≤ m≤n n≤o) i*1≡i : (i : ℕ) → i * 1 ≡ i i*1≡i i = begin (i * 1 ≡⟨ *-comm i 1 ⟩ 1 * i ≡⟨ refl ⟩ i + 0 ≡⟨ +-right-identity i ⟩ i ∎) where open ≡-Reasoning i≤i : (i : ℕ) → i ≤ i i≤i 0 = z≤n i≤i (suc i) = s≤s (i≤i i) i≤si : (i : ℕ) → i ≤ suc i i≤si 0 = z≤n i≤si (suc i) = s≤s (i≤si i) i≤j+i : ∀ {i j} → i ≤ j + i i≤j+i {i} {0} = i≤i i i≤j+i {i} {suc j} = begin (i ≤⟨ i≤j+i {i} {j} ⟩ j + i ≤⟨ i≤si (j + i) ⟩ suc j + i ∎) where open ≤-Reasoning sinj : ∀ {i j} → suc i ≡ suc j → i ≡ j sinj = cong (λ { 0 → 0 ; (suc x) → x }) i*n+n≤sucm*n : ∀ {m n} → (i : Fin (suc m)) → toℕ i * n + n ≤ suc m * n i*n+n≤sucm*n {0} {n} zero = begin (n ≡⟨ sym (+-right-identity n) ⟩ n + 0 ≤⟨ i≤i (n + 0) ⟩ n + 0 ∎) where open ≤-Reasoning i*n+n≤sucm*n {0} {n} (suc ()) i*n+n≤sucm*n {suc m} {n} i = begin (toℕ i * n + n ≡⟨ +-comm (toℕ i * n) n ⟩ n + toℕ i * n ≡⟨ refl ⟩ suc (toℕ i) * n ≤⟨ cong*r≤ (bounded i) n ⟩ suc (suc m) * n ∎) where open ≤-Reasoning i*n+k≤m*n : ∀ {m n} → (i : Fin m) → (k : Fin n) → (suc (toℕ i * n + toℕ k) ≤ m * n) i*n+k≤m*n {0} {_} () _ i*n+k≤m*n {_} {0} _ () i*n+k≤m*n {suc m} {suc n} i k = begin (suc (toℕ i * suc n + toℕ k) ≡⟨ cong suc (+-comm (toℕ i * suc n) (toℕ k)) ⟩ suc (toℕ k + toℕ i * suc n) ≡⟨ refl ⟩ suc (toℕ k) + (toℕ i * suc n) ≤⟨ cong+r≤ (bounded k) (toℕ i * suc n) ⟩ suc n + (toℕ i * suc n) ≤⟨ cong+l≤ (cong*r≤ (sinj≤ (bounded i)) (suc n)) (suc n) ⟩ suc n + (m * suc n) ≡⟨ refl ⟩ suc m * suc n ∎) where open ≤-Reasoning bounded' : (m : ℕ) → (j : Fin (suc m)) → (toℕ j ≤ m) bounded' m j with bounded j ... | s≤s pr = pr simplify-≤ : {m n m' n' : ℕ} → (m ≤ n) → (m ≡ m') → (n ≡ n') → (m' ≤ n') simplify-≤ leq refl refl = leq cancel-Fin : ∀ (n y z : ℕ) → ((x : Fin (suc n)) → toℕ x + y ≤ n + z) → y ≤ z cancel-Fin 0 y z pf = pf zero cancel-Fin (suc n) y z pf = cancel-+-left-≤ n (trans≤ leq (sinj≤ (pf (fromℕ (suc n))))) where leq : n + y ≤ toℕ (fromℕ n) + y leq = begin (n + y ≡⟨ cong (λ x → x + y) (sym (to-from n)) ⟩ toℕ (fromℕ n) + y ∎) where open ≤-Reasoning ≤-proof-irrelevance : {m n : ℕ} → (p q : m ≤ n) → p ≡ q ≤-proof-irrelevance z≤n z≤n = refl ≤-proof-irrelevance (s≤s p) (s≤s q) = cong s≤s (≤-proof-irrelevance p q) raise-suc' : (n a b n+a : ℕ) (n+a≡ : n+a ≡ n + a) → (leq : suc a ≤ b) → (leq' : suc n+a ≤ n + b) → raise n (inject≤ (fromℕ a) leq) ≡ inject≤ (fromℕ n+a) leq' raise-suc' 0 a b .a refl leq leq' = cong (inject≤ (fromℕ a)) (≤-proof-irrelevance leq leq') raise-suc' (suc n) a b .(suc (n + a)) refl leq (s≤s leq') = cong suc (raise-suc' n a b (n + a) refl leq leq') raise-suc : (m n : ℕ) (j : Fin (suc m)) (d : Fin (suc n)) (leq : suc (toℕ j * suc n + toℕ d) ≤ suc m * suc n) → (leq' : suc (toℕ (suc j) * suc n + toℕ d) ≤ suc (suc m) * suc n) → raise (suc n) (inject≤ (fromℕ (toℕ j * suc n + toℕ d)) leq) ≡ inject≤ (fromℕ (toℕ (suc j) * suc n + toℕ d)) leq' raise-suc m n j d leq leq' = raise-suc' (suc n) (toℕ j * suc n + toℕ d) (suc m * suc n) (toℕ (suc j) * suc n + toℕ d) (begin (toℕ (suc j) * suc n + toℕ d ≡⟨ refl ⟩ (suc n + toℕ j * suc n) + toℕ d ≡⟨ +-assoc (suc n) (toℕ j * suc n) (toℕ d) ⟩ suc n + (toℕ j * suc n + toℕ d) ∎)) leq leq' where open ≡-Reasoning -}
{ "alphanum_fraction": 0.435783145, "avg_line_length": 30.4321766562, "ext": "agda", "hexsha": "9041f2932c485cd4acf12d35710c745c6655dfe1", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/Obsolete/LeqLemmas.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/Obsolete/LeqLemmas.agda", "max_line_length": 78, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/Obsolete/LeqLemmas.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 4697, "size": 9647 }
------------------------------------------------------------------------ -- Non-dependent and dependent lenses -- Nils Anders Danielsson ------------------------------------------------------------------------ {-# OPTIONS --cubical --safe #-} module README where -- Non-dependent lenses. import Lens.Non-dependent import Lens.Non-dependent.Traditional import Lens.Non-dependent.Higher import Lens.Non-dependent.Higher.Capriotti import Lens.Non-dependent.Higher.Surjective-remainder import Lens.Non-dependent.Equivalent-preimages import Lens.Non-dependent.Bijection -- Non-dependent lenses with erased proofs. import Lens.Non-dependent.Traditional.Erased import Lens.Non-dependent.Higher.Erased -- Dependent lenses. import Lens.Dependent -- Comparisons of different kinds of lenses, focusing on the -- definition of composable record getters and setters. import README.Record-getters-and-setters
{ "alphanum_fraction": 0.6751381215, "avg_line_length": 27.4242424242, "ext": "agda", "hexsha": "29e2cec12cfb5c932bed92f50ac400932c5c8bbc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b7921cc6b52858cd7d8a52c183c7a6544d1a4062", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Saizan/dependent-lenses", "max_forks_repo_path": "README.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b7921cc6b52858cd7d8a52c183c7a6544d1a4062", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Saizan/dependent-lenses", "max_issues_repo_path": "README.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "b7921cc6b52858cd7d8a52c183c7a6544d1a4062", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Saizan/dependent-lenses", "max_stars_repo_path": "README.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 168, "size": 905 }
{- Transferring properties of terms between equivalent structures -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Structures.Transfer where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.SIP open import Cubical.Foundations.Transport open import Cubical.Structures.Product private variable ℓ ℓ₀ ℓ₁ ℓ₂ ℓ₂' : Level transfer : {ℓ₂' ℓ₀ : Level} {S : Type ℓ → Type ℓ₁} {H : Type ℓ → Type ℓ₂} (P : ∀ X → S X → H X → Type ℓ₀) (α : EquivAction H) (τ : TransportStr α) (ι : StrEquiv S ℓ₂') (θ : UnivalentStr S ι) {X Y : Type ℓ} {s : S X} {t : S Y} (e : (X , s) ≃[ ι ] (Y , t)) → (h : H Y) → P X s (invEq (α (e .fst)) h) → P Y t h transfer P α τ ι θ {X} {Y} {s} {t} e h = subst (λ {(Z , u , h) → P Z u h}) (sip (productUnivalentStr ι θ (EquivAction→StrEquiv α) (TransportStr→UnivalentStr α τ)) (X , s , invEq (α (e .fst)) h) (Y , t , h) (e .fst , e .snd , retEq (α (e .fst)) h)) transfer⁻ : {ℓ₂' ℓ₀ : Level} {S : Type ℓ → Type ℓ₁} {H : Type ℓ → Type ℓ₂} (P : ∀ X → S X → H X → Type ℓ₀) (α : EquivAction H) (τ : TransportStr α) (ι : StrEquiv S ℓ₂') (θ : UnivalentStr S ι) {X Y : Type ℓ} {s : S X} {t : S Y} (e : (X , s) ≃[ ι ] (Y , t)) → (h : H X) → P Y t (equivFun (α (e .fst)) h) → P X s h transfer⁻ P α τ ι θ {X} {Y} {s} {t} e h = subst⁻ (λ {(Z , u , h) → P Z u h}) (sip (productUnivalentStr ι θ (EquivAction→StrEquiv α) (TransportStr→UnivalentStr α τ)) (X , s , h) (Y , t , equivFun (α (e .fst)) h) (e .fst , e .snd , refl))
{ "alphanum_fraction": 0.5559724828, "avg_line_length": 33.3125, "ext": "agda", "hexsha": "fbc24df8882f29570016b331441d6dacb85441ce", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Structures/Transfer.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Structures/Transfer.agda", "max_line_length": 89, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Structures/Transfer.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 674, "size": 1599 }
module Relations where open import Level as Level using (zero) open import Size open import Function open import Relation.Binary open import Relation.Binary.PropositionalEquality as P open ≡-Reasoning RelTrans : Set → Set₁ RelTrans B = Rel B Level.zero → Rel B Level.zero Monotone : ∀{B} → RelTrans B → Set₁ Monotone F = ∀ {R S} → R ⇒ S → F R ⇒ F S -- | Useful example of a compatible up-to technique: equivalence closure. data EquivCls {B : Set} (R : Rel B Level.zero) : Rel B Level.zero where cls-incl : {a b : B} → R a b → EquivCls R a b cls-refl : {b : B} → EquivCls R b b cls-sym : {a b : B} → EquivCls R a b → EquivCls R b a cls-trans : {a b c : B} → EquivCls R a b → EquivCls R b c → EquivCls R a c -- | The operation of taking the equivalence closure is monotone. equivCls-monotone : ∀{B} → Monotone {B} EquivCls equivCls-monotone R≤S (cls-incl xRy) = cls-incl (R≤S xRy) equivCls-monotone R≤S cls-refl = cls-refl equivCls-monotone R≤S (cls-sym p) = cls-sym (equivCls-monotone R≤S p) equivCls-monotone R≤S (cls-trans p q) = cls-trans (equivCls-monotone R≤S p) (equivCls-monotone R≤S q) -- | The equivalence closure is indeed a closure operator. equivCls-expanding : ∀{B R} → R ⇒ EquivCls {B} R equivCls-expanding p = cls-incl p equivCls-idempotent : ∀{B R} → EquivCls (EquivCls R) ⇒ EquivCls {B} R equivCls-idempotent (cls-incl p) = p equivCls-idempotent cls-refl = cls-refl equivCls-idempotent (cls-sym p) = cls-sym (equivCls-idempotent p) equivCls-idempotent (cls-trans p q) = cls-trans (equivCls-idempotent p) (equivCls-idempotent q) -- | Equivalence closure gives indeed equivalence relation equivCls-equiv : ∀{A} → (R : Rel A _) → IsEquivalence (EquivCls R) equivCls-equiv R = record { refl = cls-refl ; sym = cls-sym ; trans = cls-trans }
{ "alphanum_fraction": 0.6834254144, "avg_line_length": 36.9387755102, "ext": "agda", "hexsha": "0e9a7e2cfc1e12c084cce2f6bfabd05ca6874a31", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hbasold/Sandbox", "max_forks_repo_path": "Streams/Relations.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hbasold/Sandbox", "max_issues_repo_path": "Streams/Relations.agda", "max_line_length": 76, "max_stars_count": null, "max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hbasold/Sandbox", "max_stars_repo_path": "Streams/Relations.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 626, "size": 1810 }
{-# OPTIONS --cubical --safe --postfix-projections #-} module Algebra.Construct.Free.Semilattice.Direct where open import Algebra open import Prelude open import Path.Reasoning infixl 6 _∪_ data 𝒦 (A : Type a) : Type a where η : A → 𝒦 A _∪_ : 𝒦 A → 𝒦 A → 𝒦 A ∅ : 𝒦 A ∪-assoc : ∀ xs ys zs → (xs ∪ ys) ∪ zs ≡ xs ∪ (ys ∪ zs) ∪-commutative : ∀ xs ys → xs ∪ ys ≡ ys ∪ xs ∪-idempotent : ∀ xs → xs ∪ xs ≡ xs ∪-identity : ∀ xs → xs ∪ ∅ ≡ xs trunc : isSet (𝒦 A) module _ (semiLattice : Semilattice b) where open Semilattice semiLattice module _ (sIsSet : isSet 𝑆) (h : A → 𝑆) where μ : 𝒦 A → 𝑆 μ (η x) = h x μ (xs ∪ ys) = μ xs ∙ μ ys μ ∅ = ε μ (∪-assoc xs ys zs i) = assoc (μ xs) (μ ys) (μ zs) i μ (∪-commutative xs ys i) = comm (μ xs) (μ ys) i μ (∪-idempotent xs i) = idem (μ xs) i μ (∪-identity xs i) = ∙ε (μ xs) i μ (trunc xs ys x y i j) = sIsSet (μ xs) (μ ys) (cong μ x) (cong μ y) i j module Eliminators where record _⇘_ {a p} (A : Type a) (P : 𝒦 A → Type p) : Type (a ℓ⊔ p) where constructor elim field ⟦_⟧-set : ∀ {xs} → isSet (P xs) ⟦_⟧∅ : P ∅ ⟦_⟧_∪_⟨_∪_⟩ : ∀ xs ys → P xs → P ys → P (xs ∪ ys) ⟦_⟧η : ∀ x → P (η x) private z = ⟦_⟧∅; f = ⟦_⟧_∪_⟨_∪_⟩ field ⟦_⟧-assoc : ∀ xs ys zs pxs pys pzs → f (xs ∪ ys) zs (f xs ys pxs pys) pzs ≡[ i ≔ P (∪-assoc xs ys zs i ) ]≡ f xs (ys ∪ zs) pxs (f ys zs pys pzs) ⟦_⟧-commutative : ∀ xs ys pxs pys → f xs ys pxs pys ≡[ i ≔ P (∪-commutative xs ys i) ]≡ f ys xs pys pxs ⟦_⟧-idempotent : ∀ xs pxs → f xs xs pxs pxs ≡[ i ≔ P (∪-idempotent xs i) ]≡ pxs ⟦_⟧-identity : ∀ xs pxs → f xs ∅ pxs z ≡[ i ≔ P (∪-identity xs i) ]≡ pxs ⟦_⟧⇓ : ∀ xs → P xs ⟦ η x ⟧⇓ = ⟦_⟧η x ⟦ xs ∪ ys ⟧⇓ = f xs ys ⟦ xs ⟧⇓ ⟦ ys ⟧⇓ ⟦ ∅ ⟧⇓ = z ⟦ ∪-assoc xs ys zs i ⟧⇓ = ⟦_⟧-assoc xs ys zs ⟦ xs ⟧⇓ ⟦ ys ⟧⇓ ⟦ zs ⟧⇓ i ⟦ ∪-commutative xs ys i ⟧⇓ = ⟦_⟧-commutative xs ys ⟦ xs ⟧⇓ ⟦ ys ⟧⇓ i ⟦ ∪-idempotent xs i ⟧⇓ = ⟦_⟧-idempotent xs ⟦ xs ⟧⇓ i ⟦ ∪-identity xs i ⟧⇓ = ⟦_⟧-identity xs ⟦ xs ⟧⇓ i ⟦ trunc xs ys x y i j ⟧⇓ = isOfHLevel→isOfHLevelDep 2 (λ xs → ⟦_⟧-set {xs}) ⟦ xs ⟧⇓ ⟦ ys ⟧⇓ (cong ⟦_⟧⇓ x) (cong ⟦_⟧⇓ y) (trunc xs ys x y) i j open _⇘_ public infixr 0 ⇘-syntax ⇘-syntax = _⇘_ syntax ⇘-syntax A (λ xs → Pxs) = xs ∈𝒦 A ⇒ Pxs record _⇲_ {a p} (A : Type a) (P : 𝒦 A → Type p) : Type (a ℓ⊔ p) where constructor elim-prop field ∥_∥-prop : ∀ {xs} → isProp (P xs) ∥_∥∅ : P ∅ ∥_∥_∪_⟨_∪_⟩ : ∀ xs ys → P xs → P ys → P (xs ∪ ys) ∥_∥η : ∀ x → P (η x) private z = ∥_∥∅; f = ∥_∥_∪_⟨_∪_⟩ ∥_∥⇑ = elim (λ {xs} → isProp→isSet (∥_∥-prop {xs})) z f ∥_∥η (λ xs ys zs pxs pys pzs → toPathP (∥_∥-prop (transp (λ i → P (∪-assoc xs ys zs i)) i0 (f (xs ∪ ys) zs (f xs ys pxs pys) pzs)) (f xs (ys ∪ zs) pxs (f ys zs pys pzs) ))) (λ xs ys pxs pys → toPathP (∥_∥-prop (transp (λ i → P (∪-commutative xs ys i)) i0 (f xs ys pxs pys)) (f ys xs pys pxs) )) (λ xs pxs → toPathP (∥_∥-prop (transp (λ i → P (∪-idempotent xs i)) i0 (f xs xs pxs pxs)) pxs)) (λ xs pxs → toPathP (∥_∥-prop (transp (λ i → P (∪-identity xs i)) i0 (f xs ∅ pxs z)) pxs)) ∥_∥⇓ = ⟦ ∥_∥⇑ ⟧⇓ open _⇲_ public elim-prop-syntax : ∀ {a p} → (A : Type a) → (𝒦 A → Type p) → Type (a ℓ⊔ p) elim-prop-syntax = _⇲_ syntax elim-prop-syntax A (λ xs → Pxs) = xs ∈𝒦 A ⇒∥ Pxs ∥ module _ {a} {A : Type a} where open Semilattice open CommutativeMonoid open Monoid 𝒦-semilattice : Semilattice a 𝒦-semilattice .commutativeMonoid .monoid .𝑆 = 𝒦 A 𝒦-semilattice .commutativeMonoid .monoid ._∙_ = _∪_ 𝒦-semilattice .commutativeMonoid .monoid .ε = ∅ 𝒦-semilattice .commutativeMonoid .monoid .assoc = ∪-assoc 𝒦-semilattice .commutativeMonoid .monoid .ε∙ x = ∪-commutative ∅ x ; ∪-identity x 𝒦-semilattice .commutativeMonoid .monoid .∙ε = ∪-identity 𝒦-semilattice .commutativeMonoid .comm = ∪-commutative 𝒦-semilattice .idem = ∪-idempotent import Algebra.Construct.Free.Semilattice as Listed Listed→Direct : Listed.𝒦 A → 𝒦 A Listed→Direct = Listed.μ 𝒦-semilattice trunc η Direct→Listed : 𝒦 A → Listed.𝒦 A Direct→Listed = μ Listed.𝒦-semilattice Listed.trunc (Listed._∷ Listed.[]) Listed→Direct→Listed : (xs : Listed.𝒦 A) → Direct→Listed (Listed→Direct xs) ≡ xs Listed→Direct→Listed = ∥ ldl ∥⇓ where open Listed using (_⇲_; elim-prop-syntax) open _⇲_ ldl : xs ∈𝒦 A ⇒∥ Direct→Listed (Listed→Direct xs) ≡ xs ∥ ∥ ldl ∥-prop = Listed.trunc _ _ ∥ ldl ∥[] = refl ∥ ldl ∥ x ∷ xs ⟨ Pxs ⟩ = cong (x Listed.∷_) Pxs open Eliminators Direct→Listed→Direct : (xs : 𝒦 A) → Listed→Direct (Direct→Listed xs) ≡ xs Direct→Listed→Direct = ∥ dld ∥⇓ where dld : xs ∈𝒦 A ⇒∥ Listed→Direct (Direct→Listed xs) ≡ xs ∥ ∥ dld ∥-prop = trunc _ _ ∥ dld ∥∅ = refl ∥ dld ∥η x = ∪-identity (η x) ∥ dld ∥ xs ∪ ys ⟨ Pxs ∪ Pys ⟩ = sym (Listed.∙-hom 𝒦-semilattice trunc η (Direct→Listed xs) (Direct→Listed ys)) ; cong₂ _∪_ Pxs Pys Direct⇔Listed : 𝒦 A ⇔ Listed.𝒦 A Direct⇔Listed .fun = Direct→Listed Direct⇔Listed .inv = Listed→Direct Direct⇔Listed .rightInv = Listed→Direct→Listed Direct⇔Listed .leftInv = Direct→Listed→Direct
{ "alphanum_fraction": 0.5486018642, "avg_line_length": 36.0068493151, "ext": "agda", "hexsha": "a0eb057a40d6d5a74f7e3ab7f1a1c9deea29ae09", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Algebra/Construct/Free/Semilattice/Direct.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Algebra/Construct/Free/Semilattice/Direct.agda", "max_line_length": 179, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Algebra/Construct/Free/Semilattice/Direct.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 2560, "size": 5257 }
-- Andreas, 2017-08-10, issue #2667, reported by xekoukou, -- test case by gallais -- {-# OPTIONS -v tc.with.split:40 #-} data Bot : Set where data A : Set where s : A → A data P : A → Set where p : ∀ {a} → P (s a) poo : ∀{b} → P b → Set poo p with Bot poo {b = s c} p | _ = P c -- Error WAS (2.5.3): Panic, unbound variable c -- Expected (as in 2.5.2): -- -- Inaccessible (dotted) patterns from the parent clause must also be -- inaccessible in the with clause, when checking the pattern {b = s c}, -- when checking that the clause -- poo p with Bot -- poo {b = s c} p | _ = P c -- has type {b : A} → P b → Set -- Ideally: succeed. -- 2018-01-05, Jesper: We're one step closer to an ideal world.
{ "alphanum_fraction": 0.6090014065, "avg_line_length": 22.21875, "ext": "agda", "hexsha": "f95ba8c7da9c7486b043c674dc6b9768aae9fe1f", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue2667.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue2667.agda", "max_line_length": 72, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue2667.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": 250, "size": 711 }
{-# OPTIONS --cubical --safe --guardedness #-} module Container.Fixpoint where open import Container open import Prelude data μ {s p} (C : Container s p) : Type (s ℓ⊔ p) where sup : ⟦ C ⟧ (μ C) → μ C record ν {s p} (C : Container s p) : Type (s ℓ⊔ p) where coinductive field inf : ⟦ C ⟧ (ν C) open ν public
{ "alphanum_fraction": 0.6246056782, "avg_line_length": 21.1333333333, "ext": "agda", "hexsha": "084c41c49b6b4a2e04c8c2292bb2ef542d544b7c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Container/Fixpoint.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Container/Fixpoint.agda", "max_line_length": 56, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Container/Fixpoint.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 117, "size": 317 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020 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 -- This module contains a model of a key-value store, along with its -- functionality and various properties about it. Most of the properties -- are not currently used, but they are included here based on our -- experience in other work, as we think many of them will be needed when -- reasoning about an actual LibraBFT implementation. -- Although we believe the assumptions here are reasonable, it is always -- possible that we made a mistake in postulating one of the properties, -- making it impossible to implement. Thus, it would a useful contribution -- to: -- -- TODO-1: construct an actual implementation and provide and prove the -- necessary properties to satisfy the requirements of this module -- -- Note that this would require some work, but should be relatively -- straightforward and requires only "local" changes. module LibraBFT.Base.KVMap where private variable Key : Set Val : Set k k' : Key v v' : Val postulate -- valid assumptions, but would be good to eliminate with a reference implementation (above) _≟Key_ : ∀ (k1 k2 : Key) → Dec (k1 ≡ k2) KVMap : Set → Set → Set _∈KV_ : Key → KVMap Key Val → Set _∈KV?_ : (k : Key) (kvm : KVMap Key Val) → Dec (k ∈KV kvm) ∈KV-irrelevant : (k : Key) (kvm : KVMap Key Val) → (r s : k ∈KV kvm) → r ≡ s -- functionality empty : KVMap Key Val ∈KV-empty-⊥ : k ∈KV (empty {Val = Val}) → ⊥ lookup : Key → KVMap Key Val → Maybe Val kvm-insert : (k : Key)(v : Val)(kvm : KVMap Key Val) → lookup k kvm ≡ nothing → KVMap Key Val -- TODO-3: update properties to reflect kvm-update, consider combining insert/update kvm-update : (k : Key)(v : Val)(kvm : KVMap Key Val) → lookup k kvm ≢ nothing → KVMap Key Val kvm-size : KVMap Key Val → ℕ -- TODO-1: add properties relating kvm-toList to empty, kvm-insert and kvm-update kvm-toList : KVMap Key Val → List (Key × Val) kvm-toList-length : (kvm : KVMap Key Val) → length (kvm-toList kvm) ≡ kvm-size kvm -- TODO-1: need properties showing that the resulting map contains (k , v) for -- each pair in the list, provided there is no pair (k , v') in the list -- after (k , v). This is consistent with Haskell's Data.Map.fromList kvm-fromList : List (Key × Val) → KVMap Key Val -- properties lookup-correct : {kvm : KVMap Key Val} → (prf : lookup k kvm ≡ nothing) → lookup k (kvm-insert k v kvm prf) ≡ just v lookup-correct-update : {kvm : KVMap Key Val} → (prf : lookup k kvm ≢ nothing) → lookup k (kvm-update k v kvm prf) ≡ just v lookup-stable : {kvm : KVMap Key Val}{k k' : Key}{v' : Val} → (prf : lookup k kvm ≡ nothing) → lookup k' kvm ≡ just v → lookup k' (kvm-insert k v' kvm prf) ≡ just v insert-target : {kvm : KVMap Key Val} → (prf : lookup k kvm ≡ nothing) → lookup k' kvm ≢ just v → lookup k' (kvm-insert k v' kvm prf) ≡ just v → k' ≡ k × v ≡ v' insert-target-≢ : {kvm : KVMap Key Val}{k k' : Key} → (prf : lookup k kvm ≡ nothing) → k' ≢ k → lookup k' kvm ≡ lookup k' (kvm-insert k v kvm prf) update-target-≢ : {kvm : KVMap Key Val} → ∀ {k1 k2 x} → k2 ≢ k1 → lookup k1 kvm ≡ lookup k1 (kvm-update k2 v kvm x) kvm-empty : lookup {Val = Val} k empty ≡ nothing kvm-empty-⊥ : {k : Key} {v : Val} → lookup k empty ≡ just v → ⊥ KVM-extensionality : ∀ {kvm1 kvm2 : KVMap Key Val} → (∀ (x : Key) → lookup x kvm1 ≡ lookup x kvm2) → kvm1 ≡ kvm2 -- Corollaries lookup-stable-1 : {kvm : KVMap Key Val}{k k' : Key}{v' : Val} → (prf : lookup k kvm ≡ nothing) → lookup k' kvm ≡ just v' → lookup k' (kvm-insert k v kvm prf) ≡ lookup k' kvm lookup-stable-1 prf hyp = trans (lookup-stable prf hyp) (sym hyp) lookup-correct-update-2 : {kvm : KVMap Key Val} → (prf : lookup k kvm ≢ nothing) → lookup k (kvm-update k v kvm prf) ≡ just v' → v ≡ v' lookup-correct-update-2 {kvm} prf lkup = just-injective (trans (sym (lookup-correct-update prf)) lkup) update-target : {kvm : KVMap Key Val} → ∀ {k1 k2 x} → lookup k1 kvm ≢ lookup k1 (kvm-update k2 v kvm x) → k2 ≡ k1 update-target {kvm = kvm}{k1 = k1}{k2 = k2}{x} vneq with k1 ≟Key k2 ...| yes refl = refl ...| no neq = ⊥-elim (vneq (update-target-≢ {k1 = k1} {k2 = k2} (neq ∘ sym))) lookup-correct-update-3 : ∀ {kvm : KVMap Key Val}{k1 k2 v2} → (prf : lookup k2 kvm ≢ nothing) → lookup k2 kvm ≡ just v2 → lookup k1 (kvm-update k2 v2 kvm prf) ≡ lookup k1 kvm lookup-correct-update-3 {kvm = kvm} {k1 = k1} {k2 = k2} {v2 = v2} prf with k1 ≟Key k2 ...| yes refl = λ pr → trans (lookup-correct-update {v = v2} prf) (sym pr) ...| no neq = λ pr → sym (update-target-≢ {k1 = k1} {k2 = k2} {prf} λ k2≢k1 → ⊥-elim (neq (sym k2≢k1))) lookup-correct-update-4 : ∀ {orig : KVMap Key Val}{k1}{v1} {rdy : lookup k1 orig ≢ nothing} → lookup k1 orig ≡ just v1 → kvm-update k1 v1 orig rdy ≡ orig lookup-correct-update-4 {orig = orig} {k1 = k1} {v1 = v1} {rdy = rdy} hyp = KVM-extensionality {kvm1 = kvm-update k1 v1 orig rdy} {kvm2 = orig} λ x → lookup-correct-update-3 rdy hyp insert-target-0 : {kvm : KVMap Key Val} → (prf : lookup k kvm ≡ nothing) → lookup k' kvm ≢ lookup k' (kvm-insert k v kvm prf) → k ≡ k' insert-target-0 {k = k} {k' = k'} prf lookups≢ with k' ≟Key k ...| yes refl = refl ...| no neq = ⊥-elim (lookups≢ (insert-target-≢ prf neq))
{ "alphanum_fraction": 0.5485617074, "avg_line_length": 39.4268292683, "ext": "agda", "hexsha": "ae61ee3c709536e3e870941cb126ece538923ed8", "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/Base/KVMap.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/Base/KVMap.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/Base/KVMap.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1993, "size": 6466 }
module 747Negation where -- Library open import Relation.Binary.PropositionalEquality using (_≡_; refl) -- added last open import Data.Nat using (ℕ; zero; suc) open import Data.Empty using (⊥; ⊥-elim) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Data.Product using (_×_; proj₁; proj₂) -- Negation is defined as implying false. ¬_ : Set → Set ¬ A = A → ⊥ -- if both ¬ A and A hold, then ⊥ holds (not surprisingly). ¬-elim : ∀ {A : Set} → ¬ A → A --- → ⊥ ¬-elim = {!!} infix 3 ¬_ -- Double negation introduction. ¬¬-intro : ∀ {A : Set} → A ----- → ¬ ¬ A ¬¬-intro = {!!} -- Double negation cannot be eliminated in intuitionistic logic. -- Triple negation elimination. ¬¬¬-elim : ∀ {A : Set} → ¬ ¬ ¬ A ------- → ¬ A ¬¬¬-elim = {!!} -- One direction of the contrapositive. contraposition : ∀ {A B : Set} → (A → B) ----------- → (¬ B → ¬ A) contraposition = {!!} -- The other direction cannot be proved in intuitionistic logic. -- not-equal-to. _≢_ : ∀ {A : Set} → A → A → Set x ≢ y = ¬ (x ≡ y) _ : 1 ≢ 2 _ = {!!} -- One of the first-order Peano axioms. peano : ∀ {m : ℕ} → zero ≢ suc m peano = {!!} -- Copied from 747Isomorphism. postulate extensionality : ∀ {A B : Set} {f g : A → B} → (∀ (x : A) → f x ≡ g x) ----------------------- → f ≡ g -- Two proofs of ⊥ → ⊥ which look different but are the same -- (assuming extensionality). id : ⊥ → ⊥ id x = x id′ : ⊥ → ⊥ id′ () id≡id′ : id ≡ id′ id≡id′ = extensionality (λ()) -- Assuming extensionality, any two proofs of a negation are the same assimilation : ∀ {A : Set} (¬x ¬x′ : ¬ A) → ¬x ≡ ¬x′ assimilation ¬x ¬x′ = extensionality λ x → ⊥-elim (¬x x) -- Strict inequality (copied from 747Relations). infix 4 _<_ data _<_ : ℕ → ℕ → Set where z<s : ∀ {n : ℕ} ------------ → zero < suc n s<s : ∀ {m n : ℕ} → m < n ------------- → suc m < suc n -- 747/PLFA exercise: NotFourLTThree (1 point) -- Show ¬ (4 < 3). ¬4<3 : ¬ (4 < 3) ¬4<3 = {!!} -- 747/PLFA exercise: LTIrrefl (1 point) -- < is irreflexive (never reflexive). ¬n<n : ∀ (n : ℕ) → ¬ (n < n) ¬n<n n = {!!} -- 747/PLFA exercise: LTTrich (3 points) -- Show that strict inequality satisfies trichotomy, -- in the sense that exactly one of the three possibilities holds. -- Here is the expanded definition of trichotomy. data Trichotomy (m n : ℕ) : Set where is-< : m < n → ¬ m ≡ n → ¬ n < m → Trichotomy m n is-≡ : m ≡ n → ¬ m < n → ¬ n < m → Trichotomy m n is-> : n < m → ¬ m ≡ n → ¬ m < n → Trichotomy m n <-trichotomy : ∀ (m n : ℕ) → Trichotomy m n <-trichotomy m n = {!!} -- PLFA exercise: one of DeMorgan's Laws as isomorphism -- ⊎-dual-× : ∀ {A B : Set} → ¬ (A ⊎ B) ≃ (¬ A) × (¬ B) -- Expand negation as implies-false, then look in 747Relations -- for a law of which this is a special case. -- What about ¬ (A × B) ≃ (¬ A) ⊎ (¬ B)? -- Answer: RHS implies LHS but converse cannot be proved in intuitionistic logic. -- Intuitionistic vs classical logic. -- The law of the excluded middle (LEM, or just em) cannot be -- proved in intuitionistic logic. -- But we can add it, and get classical logic. -- postulate -- em : ∀ {A : Set} → A ⊎ ¬ A -- How do we know this does not give a contradiction? -- The following theorem of intuitionistic logic demonstrates this. -- (The proof is compact, but takes some thought.) em-irrefutable : ∀ {A : Set} → ¬ ¬ (A ⊎ ¬ A) em-irrefutable = {!!} -- PLFA exercise: classical equivalences -- Excluded middle cannot be proved in intuitionistic logic, -- but adding it is consistent and gives classical logic. -- Here are four other classical theorems with the same property. -- You can show that each of them is logically equivalent to all the others. -- You do not need to prove twenty implications, since implication is transitive. -- But there is a lot of choice as to how to proceed! -- Excluded Middle em = ∀ {A : Set} → A ⊎ ¬ A -- Double Negation Elimination dne = ∀ {A : Set} → ¬ ¬ A → A -- Peirce’s Law peirce = ∀ {A B : Set} → ((A → B) → A) → A -- Implication as disjunction iad = ∀ {A B : Set} → (A → B) → ¬ A ⊎ B -- De Morgan: dem = ∀ {A B : Set} → ¬ (¬ A × ¬ B) → A ⊎ B -- End of classical five exercise. -- Definition: a formula is stable if double negation holds for it. Stable : Set → Set Stable A = ¬ ¬ A → A -- PLFA exercise: every negated formula is stable. -- This is triple negation elimination. -- PLFA exercise: the conjunction of two stable formulas is stable. -- This is the version of DeMorgan's Law that is a special case, above. -- Where negation sits in the standard library. import Relation.Nullary using (¬_) import Relation.Nullary.Negation using (contraposition) -- Unicode used in this chapter: {- ¬ U+00AC NOT SIGN (\neg) ≢ U+2262 NOT IDENTICAL TO (\==n) -}
{ "alphanum_fraction": 0.5980432973, "avg_line_length": 22.8761904762, "ext": "agda", "hexsha": "c7bc080f842876b7a6f9640cc85da89d6065a6a6", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x07-747Negation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x07-747Negation.agda", "max_line_length": 81, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x07-747Negation.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "num_tokens": 1574, "size": 4804 }
------------------------------------------------------------------------ -- Simple regular expression matcher ------------------------------------------------------------------------ open import Eq open import Setoids open import Prelude import RegExps module SimpleMatcher (D : Datoid) where private open module D' = Datoid D open module S' = Setoid setoid open module R = RegExps setoid infix 4 _∈‿⟦_⟧¿ ------------------------------------------------------------------------ -- A lemma private lemma : forall {a x xs₂} -> (xs₁ : [ a ]) -> (xs₁ ++ x ∷ []) ++ xs₂ ≡ xs₁ ++ x ∷ xs₂ lemma [] = refl lemma (x ∷ xs) = cong (\ys -> x ∷ ys) (lemma xs) ------------------------------------------------------------------------ -- Regular expression matcher -- The type of _∈‿⟦_⟧¿ documents its soundness (assuming that the code -- is terminating). To prove completeness more work is necessary. matches-⊙¿ : forall xs₁ xs₂ re₁ re₂ -> Maybe (xs₁ ++ xs₂ ∈‿⟦ re₁ ⊙ re₂ ⟧) _∈‿⟦_⟧¿ : (xs : [ carrier ]) -> (re : RegExp) -> Maybe (xs ∈‿⟦ re ⟧) [] ∈‿⟦ ε ⟧¿ = just matches-ε _ ∷ [] ∈‿⟦ • ⟧¿ = just matches-• x ∷ [] ∈‿⟦ sym y ⟧¿ with x ≟ y x ∷ [] ∈‿⟦ sym y ⟧¿ | yes eq = just (matches-sym eq) x ∷ [] ∈‿⟦ sym y ⟧¿ | no _ = nothing xs ∈‿⟦ re₁ ∣ re₂ ⟧¿ with xs ∈‿⟦ re₁ ⟧¿ xs ∈‿⟦ re₁ ∣ re₂ ⟧¿ | just m = just (matches-∣ˡ m) xs ∈‿⟦ re₁ ∣ re₂ ⟧¿ | nothing with xs ∈‿⟦ re₂ ⟧¿ xs ∈‿⟦ re₁ ∣ re₂ ⟧¿ | nothing | just m = just (matches-∣ʳ m) xs ∈‿⟦ re₁ ∣ re₂ ⟧¿ | nothing | nothing = nothing xs ∈‿⟦ re₁ ⊙ re₂ ⟧¿ = matches-⊙¿ [] xs re₁ re₂ [] ∈‿⟦ re ⋆ ⟧¿ = just (matches-⋆ (matches-∣ˡ matches-ε)) x ∷ xs ∈‿⟦ re ⋆ ⟧¿ with matches-⊙¿ (x ∷ []) xs re (re ⋆) x ∷ xs ∈‿⟦ re ⋆ ⟧¿ | just m = just (matches-⋆ (matches-∣ʳ m)) x ∷ xs ∈‿⟦ re ⋆ ⟧¿ | nothing = nothing _ ∈‿⟦ _ ⟧¿ = nothing matches-⊙¿ xs₁ xs₂ re₁ re₂ with xs₁ ∈‿⟦ re₁ ⟧¿ | xs₂ ∈‿⟦ re₂ ⟧¿ matches-⊙¿ xs₁ xs₂ re₁ re₂ | just m₁ | just m₂ = just (matches-⊙ m₁ m₂) matches-⊙¿ xs₁ [] re₁ re₂ | _ | _ = nothing matches-⊙¿ xs₁ (x ∷ xs₂) re₁ re₂ | _ | _ = subst (\xs -> Maybe (xs ∈‿⟦ re₁ ⊙ re₂ ⟧)) (lemma xs₁) (matches-⊙¿ (xs₁ ++ x ∷ []) xs₂ re₁ re₂)
{ "alphanum_fraction": 0.4445939883, "avg_line_length": 35.380952381, "ext": "agda", "hexsha": "2fd76c1df7c68ead2e5275cb7c0f19f263dff2ba", "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": "examples/AIM6/RegExp/talk/SimpleMatcher.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "examples/AIM6/RegExp/talk/SimpleMatcher.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "examples/AIM6/RegExp/talk/SimpleMatcher.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": 892, "size": 2229 }
module Issue353 where data Func : Set₁ where K : (A : Set) → Func -- Doesn't work. module M where const : ∀ {A B : Set₁} → A → B → A const x = λ _ → x ⟦_⟧ : Func → Set → Set ⟦ K A ⟧ X = const A X data μ (F : Func) : Set where ⟨_⟩ : ⟦ F ⟧ (μ F) → μ F -- Error: μ is not strictly positive, because it occurs in the second -- argument to ⟦_⟧ in the type of the constructor ⟨_⟩ in the -- definition of μ.
{ "alphanum_fraction": 0.5651162791, "avg_line_length": 19.5454545455, "ext": "agda", "hexsha": "d81fc101220beadbe2cd7d0ee96df42257c5e1d1", "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/Issue353.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/Issue353.agda", "max_line_length": 71, "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/Issue353.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 160, "size": 430 }
{- A couple of general facts about equivalences: - if f is an equivalence then (cong f) is an equivalence ([equivCong]) - if f is an equivalence then pre- and postcomposition with f are equivalences ([preCompEquiv], [postCompEquiv]) - if f is an equivalence then (Σ[ g ] section f g) and (Σ[ g ] retract f g) are contractible ([isContr-section], [isContr-retract]) (these are not in 'Equiv.agda' because they need Univalence.agda (which imports Equiv.agda)) -} {-# OPTIONS --cubical --safe #-} module Cubical.Foundations.Equiv.Properties where open import Cubical.Core.Everything open import Cubical.Data.Sigma open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.Univalence open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.FunExtEquiv isEquivCong : ∀ {ℓ} {A B : Type ℓ} {x y : A} (e : A ≃ B) → isEquiv (λ (p : x ≡ y) → (cong (fst e) p)) isEquivCong e = EquivJ (λ (B' A' : Type _) (e' : A' ≃ B') → (x' y' : A') → isEquiv (λ (p : x' ≡ y') → cong (fst e') p)) (λ _ x' y' → idIsEquiv (x' ≡ y')) _ _ e _ _ congEquiv : ∀ {ℓ} {A B : Type ℓ} {x y : A} (e : A ≃ B) → (x ≡ y) ≃ (e .fst x ≡ e .fst y) congEquiv e = ((λ (p : _ ≡ _) → cong (fst e) p) , isEquivCong e) isEquivPreComp : ∀ {ℓ ℓ′} {A B : Type ℓ} {C : Type ℓ′} (e : A ≃ B) → isEquiv (λ (φ : B → C) → φ ∘ e .fst) isEquivPreComp {A = A} {C = C} e = EquivJ (λ (B A : Type _) (e' : A ≃ B) → isEquiv (λ (φ : B → C) → φ ∘ e' .fst)) (λ A → idIsEquiv (A → C)) _ _ e isEquivPostComp : ∀ {ℓ ℓ′} {A B : Type ℓ} {C : Type ℓ′} (e : A ≃ B) → isEquiv (λ (φ : C → A) → e .fst ∘ φ) isEquivPostComp {A = A} {C = C} e = EquivJ (λ (B A : Type _) (e' : A ≃ B) → isEquiv (λ (φ : C → A) → e' .fst ∘ φ)) (λ A → idIsEquiv (C → A)) _ _ e preCompEquiv : ∀ {ℓ ℓ′} {A B : Type ℓ} {C : Type ℓ′} (e : A ≃ B) → (B → C) ≃ (A → C) preCompEquiv e = (λ φ x → φ (fst e x)) , isEquivPreComp e postCompEquiv : ∀ {ℓ ℓ′} {A B : Type ℓ} {C : Type ℓ′} (e : A ≃ B) → (C → A) ≃ (C → B) postCompEquiv e = (λ φ x → fst e (φ x)) , isEquivPostComp e isContr-section : ∀ {ℓ} {A B : Type ℓ} (e : A ≃ B) → isContr (Σ[ g ∈ (B → A) ] section (fst e) g) fst (isContr-section e) = invEq e , retEq e snd (isContr-section e) (f , ε) i = (λ b → fst (p b i)) , (λ b → snd (p b i)) where p : ∀ b → (invEq e b , retEq e b) ≡ (f b , ε b) p b = snd (equiv-proof (snd e) b) (f b , ε b) -- there is a (much slower) alternate proof that also works for retract isContr-section' : ∀ {ℓ} {A B : Type ℓ} (e : A ≃ B) → isContr (Σ[ g ∈ (B → A) ] section (fst e) g) isContr-section' {_} {A} {B} e = transport (λ i → isContr (Σ[ g ∈ (B → A) ] eq g i)) (equiv-proof (isEquivPostComp e) (idfun _)) where eq : ∀ (g : B → A) → ((fst e) ∘ g ≡ idfun _) ≡ (section (fst e) g) eq g = sym (funExtPath {f = (fst e) ∘ g} {g = idfun _}) isContr-retract : ∀ {ℓ} {A B : Type ℓ} (e : A ≃ B) → isContr (Σ[ g ∈ (B → A) ] retract (fst e) g) isContr-retract {_} {A} {B} e = transport (λ i → isContr (Σ[ g ∈ (B → A) ] eq g i)) (equiv-proof (isEquivPreComp e) (idfun _)) where eq : ∀ (g : B → A) → (g ∘ (fst e) ≡ idfun _) ≡ (retract (fst e) g) eq g = sym (funExtPath {f = g ∘ (fst e)} {g = idfun _})
{ "alphanum_fraction": 0.5291402193, "avg_line_length": 45.6052631579, "ext": "agda", "hexsha": "711deecec0002e3cc03f2085e7f7e02e75e999b6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/Foundations/Equiv/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_path": "Cubical/Foundations/Equiv/Properties.agda", "max_line_length": 131, "max_stars_count": null, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/Foundations/Equiv/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1378, "size": 3466 }
module Printf where _∘_ : {A : Set}{B : A -> Set}{C : {x : A} -> B x -> Set} -> (f : {x : A}(y : B x) -> C y)(g : (x : A) -> B x)(x : A) -> C (g x) (f ∘ g) x = f (g x) infixr 10 _::_ data List (A : Set) : Set where nil : List A _::_ : A -> List A -> List A {-# BUILTIN LIST List #-} {-# BUILTIN NIL nil #-} {-# BUILTIN CONS _::_ #-} [_] : {A : Set} -> A -> List A [ x ] = x :: nil module Primitive where postulate String : Set Float : Set Char : Set data Nat : Set where zero : Nat suc : Nat → Nat data Int : Set where pos : Nat → Int negsuc : Nat → Int {-# BUILTIN NATURAL Nat #-} {-# BUILTIN INTEGER Int #-} {-# BUILTIN INTEGERPOS pos #-} {-# BUILTIN INTEGERNEGSUC negsuc #-} {-# BUILTIN STRING String #-} {-# BUILTIN FLOAT Float #-} {-# BUILTIN CHAR Char #-} private primitive primStringAppend : String -> String -> String primStringToList : String -> List Char primStringFromList : List Char -> String primShowChar : Char -> String primShowInteger : Int -> String primShowFloat : Float -> String _++_ = primStringAppend showChar = primShowChar showInt = primShowInteger showFloat = primShowFloat stringToList = primStringToList listToString = primStringFromList open Primitive data Unit : Set where unit : Unit infixr 8 _×_ infixr 8 _◅_ data _×_ (A B : Set) : Set where _◅_ : A -> B -> A × B data Format : Set where stringArg : Format intArg : Format floatArg : Format charArg : Format litChar : Char -> Format badFormat : Char -> Format data BadFormat (c : Char) : Set where format : String -> List Format format = format' ∘ stringToList where format' : List Char -> List Format format' ('%' :: 's' :: fmt) = stringArg :: format' fmt format' ('%' :: 'd' :: fmt) = intArg :: format' fmt format' ('%' :: 'f' :: fmt) = floatArg :: format' fmt format' ('%' :: 'c' :: fmt) = charArg :: format' fmt format' ('%' :: '%' :: fmt) = litChar '%' :: format' fmt format' ('%' :: c :: fmt) = badFormat c :: format' fmt format' (c :: fmt) = litChar c :: format' fmt format' nil = nil Printf' : List Format -> Set Printf' (stringArg :: fmt) = String × Printf' fmt Printf' (intArg :: fmt) = Int × Printf' fmt Printf' (floatArg :: fmt) = Float × Printf' fmt Printf' (charArg :: fmt) = Char × Printf' fmt Printf' (badFormat c :: fmt) = BadFormat c Printf' (litChar _ :: fmt) = Printf' fmt Printf' nil = Unit Printf : String -> Set Printf fmt = Printf' (format fmt) printf : (fmt : String) -> Printf fmt -> String printf = printf' ∘ format where printf' : (fmt : List Format) -> Printf' fmt -> String printf' (stringArg :: fmt) (s ◅ args) = s ++ printf' fmt args printf' (intArg :: fmt) (n ◅ args) = showInt n ++ printf' fmt args printf' (floatArg :: fmt) (x ◅ args) = showFloat x ++ printf' fmt args printf' (charArg :: fmt) (c ◅ args) = showChar c ++ printf' fmt args printf' (litChar c :: fmt) args = listToString [ c ] ++ printf' fmt args printf' (badFormat _ :: fmt) () printf' nil unit = ""
{ "alphanum_fraction": 0.5373178709, "avg_line_length": 28.7435897436, "ext": "agda", "hexsha": "d75ab4fbc2b5a2146c7658a40f555fe02be26caa", "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/Printf.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/Printf.agda", "max_line_length": 84, "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/Printf.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": 1057, "size": 3363 }
-- Basic intuitionistic propositional calculus, without ∨ or ⊥. -- Kripke-style semantics with abstract worlds. -- Gödel embedding. module BasicIPC.Semantics.KripkeGodel where open import BasicIPC.Syntax.Common public -- Kripke models. record Model : Set₁ where infix 3 _⊩ᵅ_ field World : Set -- Intuitionistic accessibility; preorder. _≤_ : World → World → Set refl≤ : ∀ {w} → w ≤ w trans≤ : ∀ {w w′ w″} → w ≤ w′ → w′ ≤ w″ → w ≤ w″ -- Forcing for atomic propositions. _⊩ᵅ_ : World → Atom → Set open Model {{…}} public -- Forcing in a particular world of a particular model, based on the Gödel embedding of IPC in S4. module _ {{_ : Model}} where infix 3 _⊩_ _⊩_ : World → Ty → Set w ⊩ α P = ∀ {w′} → w ≤ w′ → w′ ⊩ᵅ P w ⊩ A ▻ B = ∀ {w′} → w ≤ w′ → w′ ⊩ A → w′ ⊩ B w ⊩ A ∧ B = ∀ {w′} → w ≤ w′ → w′ ⊩ A × w′ ⊩ B w ⊩ ⊤ = ∀ {w′} → w ≤ w′ → 𝟙 infix 3 _⊩⋆_ _⊩⋆_ : World → Cx Ty → Set w ⊩⋆ ∅ = 𝟙 w ⊩⋆ Ξ , A = w ⊩⋆ Ξ × w ⊩ A -- Monotonicity with respect to intuitionistic accessibility. module _ {{_ : Model}} where mono⊩ : ∀ {A w w′} → w ≤ w′ → w ⊩ A → w′ ⊩ A mono⊩ {α P} ξ s = λ ξ′ → s (trans≤ ξ ξ′) mono⊩ {A ▻ B} ξ s = λ ξ′ → s (trans≤ ξ ξ′) mono⊩ {A ∧ B} ξ s = λ ξ′ → s (trans≤ ξ ξ′) mono⊩ {⊤} ξ s = λ ξ′ → ∙ mono⊩⋆ : ∀ {Ξ w w′} → w ≤ w′ → w ⊩⋆ Ξ → w′ ⊩⋆ Ξ mono⊩⋆ {∅} ξ ∙ = ∙ mono⊩⋆ {Ξ , A} ξ (γ , a) = mono⊩⋆ {Ξ} ξ γ , mono⊩ {A} ξ a -- Additional useful equipment. module _ {{_ : Model}} where _⟪$⟫_ : ∀ {A B w} → w ⊩ A ▻ B → w ⊩ A → w ⊩ B s ⟪$⟫ a = s refl≤ a ⟪K⟫ : ∀ {A B w} → w ⊩ A → w ⊩ B ▻ A ⟪K⟫ {A} a ξ = K (mono⊩ {A} ξ a) ⟪S⟫ : ∀ {A B C w} → w ⊩ A ▻ B ▻ C → w ⊩ A ▻ B → w ⊩ A → w ⊩ C ⟪S⟫ {A} {B} {C} s₁ s₂ a = _⟪$⟫_ {B} {C} (_⟪$⟫_ {A} {B ▻ C} s₁ a) (_⟪$⟫_ {A} {B} s₂ a) ⟪S⟫′ : ∀ {A B C w} → w ⊩ A ▻ B ▻ C → w ⊩ (A ▻ B) ▻ A ▻ C ⟪S⟫′ {A} {B} {C} s₁ ξ s₂ ξ′ a = let s₁′ = mono⊩ {A ▻ B ▻ C} (trans≤ ξ ξ′) s₁ s₂′ = mono⊩ {A ▻ B} ξ′ s₂ in ⟪S⟫ {A} {B} {C} s₁′ s₂′ a _⟪,⟫_ : ∀ {A B w} → w ⊩ A → w ⊩ B → w ⊩ A ∧ B _⟪,⟫_ {A} {B} a b ξ = mono⊩ {A} ξ a , mono⊩ {B} ξ b _⟪,⟫′_ : ∀ {A B w} → w ⊩ A → w ⊩ B ▻ A ∧ B _⟪,⟫′_ {A} {B} a ξ = _⟪,⟫_ {A} {B} (mono⊩ {A} ξ a) ⟪π₁⟫ : ∀ {A B w} → w ⊩ A ∧ B → w ⊩ A ⟪π₁⟫ s = π₁ (s refl≤) ⟪π₂⟫ : ∀ {A B w} → w ⊩ A ∧ B → w ⊩ B ⟪π₂⟫ s = π₂ (s refl≤) -- Forcing in a particular world of a particular model, for sequents. module _ {{_ : Model}} where infix 3 _⊩_⇒_ _⊩_⇒_ : World → Cx Ty → Ty → Set w ⊩ Γ ⇒ A = w ⊩⋆ Γ → w ⊩ A infix 3 _⊩_⇒⋆_ _⊩_⇒⋆_ : World → Cx Ty → Cx Ty → Set w ⊩ Γ ⇒⋆ Ξ = w ⊩⋆ Γ → w ⊩⋆ Ξ -- Entailment, or forcing in all worlds of all models, for sequents. infix 3 _⊨_ _⊨_ : Cx Ty → Ty → Set₁ Γ ⊨ A = ∀ {{_ : Model}} {w : World} → w ⊩ Γ ⇒ A infix 3 _⊨⋆_ _⊨⋆_ : Cx Ty → Cx Ty → Set₁ Γ ⊨⋆ Ξ = ∀ {{_ : Model}} {w : World} → w ⊩ Γ ⇒⋆ Ξ -- Additional useful equipment, for sequents. module _ {{_ : Model}} where lookup : ∀ {A Γ w} → A ∈ Γ → w ⊩ Γ ⇒ A lookup top (γ , a) = a lookup (pop i) (γ , b) = lookup i γ ⟦λ⟧ : ∀ {A B Γ w} → (∀ {w′} → w′ ⊩ Γ , A ⇒ B) → w ⊩ Γ ⇒ A ▻ B ⟦λ⟧ s γ = λ ξ a → s (mono⊩⋆ ξ γ , a) _⟦$⟧_ : ∀ {A B Γ w} → w ⊩ Γ ⇒ A ▻ B → w ⊩ Γ ⇒ A → w ⊩ Γ ⇒ B _⟦$⟧_ {A} {B} s₁ s₂ γ = _⟪$⟫_ {A} {B} (s₁ γ) (s₂ γ) ⟦K⟧ : ∀ {A B Γ w} → w ⊩ Γ ⇒ A → w ⊩ Γ ⇒ B ▻ A ⟦K⟧ {A} {B} a γ = ⟪K⟫ {A} {B} (a γ) ⟦S⟧ : ∀ {A B C Γ w} → w ⊩ Γ ⇒ A ▻ B ▻ C → w ⊩ Γ ⇒ A ▻ B → w ⊩ Γ ⇒ A → w ⊩ Γ ⇒ C ⟦S⟧ {A} {B} {C} s₁ s₂ a γ = ⟪S⟫ {A} {B} {C} (s₁ γ) (s₂ γ) (a γ) _⟦,⟧_ : ∀ {A B Γ w} → w ⊩ Γ ⇒ A → w ⊩ Γ ⇒ B → w ⊩ Γ ⇒ A ∧ B _⟦,⟧_ {A} {B} a b γ = _⟪,⟫_ {A} {B} (a γ) (b γ) ⟦π₁⟧ : ∀ {A B Γ w} → w ⊩ Γ ⇒ A ∧ B → w ⊩ Γ ⇒ A ⟦π₁⟧ {A} {B} s γ = ⟪π₁⟫ {A} {B} (s γ) ⟦π₂⟧ : ∀ {A B Γ w} → w ⊩ Γ ⇒ A ∧ B → w ⊩ Γ ⇒ B ⟦π₂⟧ {A} {B} s γ = ⟪π₂⟫ {A} {B} (s γ)
{ "alphanum_fraction": 0.4147417597, "avg_line_length": 27.9202898551, "ext": "agda", "hexsha": "55c3b56386ec30fbf30d2a2bb910b5ab6f7c0968", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/hilbert-gentzen", "max_forks_repo_path": "BasicIPC/Semantics/KripkeGodel.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/hilbert-gentzen", "max_issues_repo_path": "BasicIPC/Semantics/KripkeGodel.agda", "max_line_length": 98, "max_stars_count": 29, "max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/hilbert-gentzen", "max_stars_repo_path": "BasicIPC/Semantics/KripkeGodel.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z", "num_tokens": 2195, "size": 3853 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.Cost where open import Cubical.HITs.Cost.Base
{ "alphanum_fraction": 0.7288135593, "avg_line_length": 23.6, "ext": "agda", "hexsha": "33fa43ee5bdd475b1dfe9808cb1a07812f6dbb64", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/HITs/Cost.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/Cost.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/HITs/Cost.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 35, "size": 118 }
{-# OPTIONS --without-K #-} -- Constructions on top of exploration functions open import Level.NP open import Type hiding (★) open import Type.Identities open import Function.NP open import Function.Extensionality open import Algebra.FunctionProperties.NP open import Data.Two.Base open import Data.Indexed open import Data.Nat.NP hiding (_⊔_) open import Data.Nat.Properties open import Data.Fin using (Fin) renaming (zero to fzero) open import Data.Maybe.NP open import Algebra open import Data.Product.NP renaming (map to ×-map) hiding (first) open import Data.Sum.NP renaming (map to ⊎-map) open import Data.Zero using (𝟘) open import Data.One using (𝟙) open import Data.Tree.Binary import Data.List as List open List using (List; _++_) open import Relation.Nullary.Decidable open import Relation.Nullary.NP open import Relation.Binary open import Relation.Binary.Sum using (_⊎-cong_) open import Relation.Binary.Product.Pointwise using (_×-cong_) import Function.Related as FR import Relation.Binary.PropositionalEquality.NP as ≡ open import HoTT open Equivalences open ≡ using (_≡_) open import Explore.Core open import Explore.Properties import Explore.Monad as EM module Explore.Explorable where module _ {m a} {A : ★ a} where open EM {a} m gfilter-explore : ∀ {B} → (A →? B) → Explore m A → Explore m B gfilter-explore f eᴬ = eᴬ >>= λ x → maybe (λ η → point-explore η) empty-explore (f x) filter-explore : (A → 𝟚) → Explore m A → Explore m A filter-explore p = gfilter-explore λ x → [0: nothing 1: just x ] (p x) -- monoidal exploration: explore A with a monoid M explore-monoid : ∀ {ℓ} → Explore m A → ExploreMon m ℓ A explore-monoid eᴬ M = eᴬ ε _·_ where open Mon M renaming (_∙_ to _·_) explore-endo : Explore m A → Explore m A explore-endo eᴬ ε op f = eᴬ id _∘′_ (op ∘ f) ε explore-endo-monoid : ∀ {ℓ} → Explore m A → ExploreMon m ℓ A explore-endo-monoid = explore-monoid ∘ explore-endo explore-backward : Explore m A → Explore m A explore-backward eᴬ ε _∙_ f = eᴬ ε (flip _∙_) f -- explore-backward ∘ explore-backward = id -- (m : a comm monoid) → explore-backward m = explore m private module FindForward {a} {A : ★ a} (explore : Explore a A) where find? : Find? A find? = explore nothing (M?._∣_ _) first : Maybe A first = find? just findKey : FindKey A findKey pred = find? (λ x → [0: nothing 1: just x ] (pred x)) module ExplorePlug {ℓ a} {A : ★ a} where record ExploreIndKit p (P : Explore ℓ A → ★ p) : ★ (a ⊔ ₛ ℓ ⊔ p) where constructor mk field Pε : P empty-explore P∙ : ∀ {e₀ e₁ : Explore ℓ A} → P e₀ → P e₁ → P (merge-explore e₀ e₁) Pf : ∀ x → P (point-explore x) _$kit_ : ∀ {p} {P : Explore ℓ A → ★ p} {e : Explore ℓ A} → ExploreInd p e → ExploreIndKit p P → P e _$kit_ {P = P} ind (mk Pε P∙ Pf) = ind P Pε P∙ Pf _,-kit_ : ∀ {p} {P : Explore ℓ A → ★ p}{Q : Explore ℓ A → ★ p} → ExploreIndKit p P → ExploreIndKit p Q → ExploreIndKit p (P ×° Q) Pk ,-kit Qk = mk (Pε Pk , Pε Qk) (λ x y → P∙ Pk (fst x) (fst y) , P∙ Qk (snd x) (snd y)) (λ x → Pf Pk x , Pf Qk x) where open ExploreIndKit ExploreInd-Extra : ∀ p → Explore ℓ A → ★ _ ExploreInd-Extra p exp = ∀ (Q : Explore ℓ A → ★ p) (Q-kit : ExploreIndKit p Q) (P : Explore ℓ A → ★ p) (Pε : P empty-explore) (P∙ : ∀ {e₀ e₁ : Explore ℓ A} → Q e₀ → Q e₁ → P e₀ → P e₁ → P (merge-explore e₀ e₁)) (Pf : ∀ x → P (point-explore x)) → P exp to-extra : ∀ {p} {e : Explore ℓ A} → ExploreInd p e → ExploreInd-Extra p e to-extra e-ind Q Q-kit P Pε P∙ Pf = snd (e-ind (Q ×° P) (Qε , Pε) (λ { (a , b) (c , d) → Q∙ a c , P∙ a c b d }) (λ x → Qf x , Pf x)) where open ExploreIndKit Q-kit renaming (Pε to Qε; P∙ to Q∙; Pf to Qf) ExplorePlug : ∀ {m} (M : Monoid ℓ m) (e : Explore _ A) → ★ _ ExplorePlug M e = ∀ f x → e∘ ε _∙_ f ∙ x ≈ e∘ x _∙_ f where open Mon M e∘ = explore-endo e plugKit : ∀ {m} (M : Monoid ℓ m) → ExploreIndKit _ (ExplorePlug M) plugKit M = mk (λ _ → fst identity) (λ Ps Ps' f x → trans (∙-cong (! Ps _ _) refl) (trans (assoc _ _ _) (trans (∙-cong refl (Ps' _ x)) (Ps _ _)))) (λ x f _ → ∙-cong (snd identity (f x)) refl) where open Mon M module FromExplore {a} {A : ★ a} (explore : ∀ {ℓ} → Explore ℓ A) where module _ {ℓ} where with-monoid : ∀ {m} → ExploreMon ℓ m A with-monoid = explore-monoid explore with∘ : Explore ℓ A with∘ = explore-endo explore with-endo-monoid : ∀ {m} → ExploreMon ℓ m A with-endo-monoid = explore-endo-monoid explore backward : Explore ℓ A backward = explore-backward explore gfilter : ∀ {B} → (A →? B) → Explore ℓ B gfilter f = gfilter-explore f explore filter : (A → 𝟚) → Explore ℓ A filter p = filter-explore p explore sum : Sum A sum = explore 0 _+_ Card : ℕ Card = sum (const 1) count : Count A count f = sum (𝟚▹ℕ ∘ f) product : (A → ℕ) → ℕ product = explore 1 _*_ big-∧ big-∨ big-xor : (A → 𝟚) → 𝟚 big-∧ = explore 1₂ _∧_ and = big-∧ all = big-∧ big-∨ = explore 0₂ _∨_ or = big-∨ any = big-∨ big-xor = explore 0₂ _xor_ big-lift∧ big-lift∨ : Level → (A → 𝟚) → 𝟚 big-lift∧ ℓ f = lower (explore {ℓ} (lift 1₂) (lift-op₂ _∧_) (lift ∘ f)) big-lift∨ ℓ f = lower (explore {ℓ} (lift 0₂) (lift-op₂ _∨_) (lift ∘ f)) bin-tree : BinTree A bin-tree = explore empty fork leaf list : List A list = explore List.[] _++_ List.[_] module FindBackward = FindForward backward findLast? : Find? A findLast? = FindBackward.find? last : Maybe A last = FindBackward.first findLastKey : FindKey A findLastKey = FindBackward.findKey open FindForward explore public module FromLookup {a} {A : ★ a} {explore : ∀ {ℓ} → Explore ℓ A} (lookup : ∀ {ℓ} → Lookup {ℓ} explore) where module CheckDec! {ℓ}{P : A → ★ ℓ}(decP : ∀ x → Dec (P x)) where CheckDec! : ★ _ CheckDec! = explore (Lift 𝟙) _×_ λ x → ✓ ⌊ decP x ⌋ checkDec! : {p✓ : CheckDec!} → ∀ x → P x checkDec! {p✓} x = toWitness (lookup p✓ x) module FromExploreInd {a} {A : ★ a} {explore : ∀ {ℓ} → Explore ℓ A} (explore-ind : ∀ {p ℓ} → ExploreInd {ℓ} p explore) where open FromExplore explore public module _ {ℓ p} where explore-mon-ext : ExploreMonExt {ℓ} p explore explore-mon-ext m {f} {g} f≈°g = explore-ind (λ s → s _ _ f ≈ s _ _ g) refl ∙-cong f≈°g where open Mon m explore-mono : ExploreMono {ℓ} p explore explore-mono _⊆_ z⊆ _∙-mono_ {f} {g} f⊆°g = explore-ind (λ e → e _ _ f ⊆ e _ _ g) z⊆ _∙-mono_ f⊆°g open ExplorePlug {ℓ} {a} {A} explore∘-plug : (M : Monoid ℓ ℓ) → ExplorePlug M explore explore∘-plug M = explore-ind $kit plugKit M module _ (M : Monoid ℓ ℓ) (open Mon M) (f : A → C) where explore-endo-monoid-spec′ : ∀ z → explore ε _∙_ f ∙ z ≈ explore-endo explore z _∙_ f explore-endo-monoid-spec′ = explore-ind (λ e → ∀ z → e ε _∙_ f ∙ z ≈ explore-endo e z _∙_ f) (fst identity) (λ P₀ P₁ z → trans (assoc _ _ _) (trans (∙-cong refl (P₁ z)) (P₀ _))) (λ _ _ → refl) explore-endo-monoid-spec : with-monoid M f ≈ with-endo-monoid M f explore-endo-monoid-spec = trans (! snd identity _) (explore-endo-monoid-spec′ ε) explore∘-ind : ∀ (M : Monoid ℓ ℓ) → BigOpMonInd ℓ M (with-endo-monoid M) explore∘-ind M P Pε P∙ Pf P≈ = snd (explore-ind (λ e → ExplorePlug M e × P (λ f → e id _∘′_ (_∙_ ∘ f) ε)) (const (fst identity) , Pε) (λ {e} {s'} Ps Ps' → ExploreIndKit.P∙ (plugKit M) {e} {s'} (fst Ps) (fst Ps') , P≈ (λ f → fst Ps f _) (P∙ (snd Ps) (snd Ps'))) (λ x → ExploreIndKit.Pf (plugKit M) x , P≈ (λ f → ! snd identity _) (Pf x))) where open Mon M explore-swap : ∀ {b} → ExploreSwap {ℓ} p explore {b} explore-swap mon {eᴮ} eᴮ-ε pf f = explore-ind (λ e → e _ _ (eᴮ ∘ f) ≈ eᴮ (e _ _ ∘ flip f)) (! eᴮ-ε) (λ p q → trans (∙-cong p q) (! pf _ _)) (λ _ → refl) where open Mon mon explore-ε : Exploreε {ℓ} p explore explore-ε M = explore-ind (λ e → e ε _ (const ε) ≈ ε) refl (λ x≈ε y≈ε → trans (∙-cong x≈ε y≈ε) (fst identity ε)) (λ _ → refl) where open Mon M explore-hom : ExploreHom {ℓ} p explore explore-hom cm f g = explore-ind (λ e → e _ _ (f ∙° g) ≈ e _ _ f ∙ e _ _ g) (! fst identity ε) (λ p₀ p₁ → trans (∙-cong p₀ p₁) (∙-interchange _ _ _ _)) (λ _ → refl) where open CMon cm explore-linˡ : ExploreLinˡ {ℓ} p explore explore-linˡ m _◎_ f k ide dist = explore-ind (λ e → e ε _∙_ (λ x → k ◎ f x) ≈ k ◎ e ε _∙_ f) (! ide) (λ x x₁ → trans (∙-cong x x₁) (! dist k _ _)) (λ x → refl) where open Mon m explore-linʳ : ExploreLinʳ {ℓ} p explore explore-linʳ m _◎_ f k ide dist = explore-ind (λ e → e ε _∙_ (λ x → f x ◎ k) ≈ e ε _∙_ f ◎ k) (! ide) (λ x x₁ → trans (∙-cong x x₁) (! dist k _ _)) (λ x → refl) where open Mon m module ProductMonoid {M : ★₀} (εₘ : M) (_⊕ₘ_ : Op₂ M) {N : ★₀} (εₙ : N) (_⊕ₙ_ : Op₂ N) where ε = (εₘ , εₙ) _⊕_ : Op₂ (M × N) (xₘ , xₙ) ⊕ (yₘ , yₙ) = (xₘ ⊕ₘ yₘ , xₙ ⊕ₙ yₙ) explore-product-monoid : ∀ fₘ fₙ → explore ε _⊕_ < fₘ , fₙ > ≡ (explore εₘ _⊕ₘ_ fₘ , explore εₙ _⊕ₙ_ fₙ) explore-product-monoid fₘ fₙ = explore-ind (λ e → e ε _⊕_ < fₘ , fₙ > ≡ (e εₘ _⊕ₘ_ fₘ , e εₙ _⊕ₙ_ fₙ)) ≡.refl (≡.ap₂ _⊕_) (λ _ → ≡.refl) {- empty-explore: ε ≡ (εₘ , εₙ) ✓ point-explore (x , y): < fₘ , fₙ > (x , y) ≡ (fₘ x , fₙ y) ✓ merge-explore e₀ e₁: e₀ ε _⊕_ < fₘ , fₙ > ⊕ e₁ ε _⊕_ < fₘ , fₙ > ≡ (e₀ εₘ _⊕ₘ_ fₘ , e₀ εₙ _⊕ₙ_ fₙ) ⊕ (e₁ εₘ _⊕ₘ_ fₘ , e₁ εₙ _⊕ₙ_ fₙ) ≡ (e₀ εₘ _⊕ₘ_ fₘ ⊕ e₁ εₘ _⊕ₘ_ fₘ , e₀ εₙ _⊕ₙ_ fₙ ⊕ e₁ εₙ _⊕ₙ_ fₙ) -} module _ {ℓ} where reify : Reify {ℓ} explore reify = explore-ind (λ eᴬ → Πᵉ eᴬ _) _ _,_ unfocus : Unfocus {ℓ} explore unfocus = explore-ind Unfocus (λ{ (lift ()) }) (λ P Q → [ P , Q ]) (λ η → _,_ η) module _ {ℓᵣ aᵣ} {Aᵣ : A → A → ★ aᵣ} (Aᵣ-refl : Reflexive Aᵣ) where ⟦explore⟧ : ⟦Explore⟧ ℓᵣ Aᵣ (explore {ℓ}) (explore {ℓ}) ⟦explore⟧ Mᵣ zᵣ ∙ᵣ fᵣ = explore-ind (λ e → Mᵣ (e _ _ _) (e _ _ _)) zᵣ (λ η → ∙ᵣ η) (λ η → fᵣ Aᵣ-refl) explore-ext : ExploreExt {ℓ} explore explore-ext ε op = explore-ind (λ e → e _ _ _ ≡ e _ _ _) ≡.refl (≡.ap₂ op) module LiftHom {m p} {S T : ★ m} (_≈_ : T → T → ★ p) (≈-refl : Reflexive _≈_) (≈-trans : Transitive _≈_) (zero : S) (_+_ : Op₂ S) (one : T) (_*_ : Op₂ T) (≈-cong-* : _*_ Preserves₂ _≈_ ⟶ _≈_ ⟶ _≈_) (f : S → T) (g : A → S) (hom-0-1 : f zero ≈ one) (hom-+-* : ∀ {x y} → (f (x + y)) ≈ (f x * f y)) where lift-hom : f (explore zero _+_ g) ≈ explore one _*_ (f ∘ g) lift-hom = explore-ind (λ e → f (e zero _+_ g) ≈ e one _*_ (f ∘ g)) hom-0-1 (λ p q → ≈-trans hom-+-* (≈-cong-* p q)) (λ _ → ≈-refl) module _ {ℓ} {P : A → ★_ ℓ} where open LiftHom {S = ★_ ℓ} {★_ ℓ} (λ A B → B → A) id _∘′_ (Lift 𝟘) _⊎_ (Lift 𝟙) _×_ (λ f g → ×-map f g) Dec P (const (no (λ{ (lift ()) }))) (uncurry Dec-⊎) public renaming (lift-hom to lift-Dec) module FromFocus {p} (focus : Focus {p} explore) where Dec-Σ : ∀ {P} → Π A (Dec ∘ P) → Dec (Σ A P) Dec-Σ = map-Dec unfocus focus ∘ lift-Dec ∘ reify lift-hom-≡ : ∀ {m} {S T : ★ m} (zero : S) (_+_ : Op₂ S) (one : T) (_*_ : Op₂ T) (f : S → T) (g : A → S) (hom-0-1 : f zero ≡ one) (hom-+-* : ∀ {x y} → f (x + y) ≡ f x * f y) → f (explore zero _+_ g) ≡ explore one _*_ (f ∘ g) lift-hom-≡ z _+_ o _*_ = LiftHom.lift-hom _≡_ ≡.refl ≡.trans z _+_ o _*_ (≡.ap₂ _*_) -- Since so far S and T should have the same level, we get this mess of resizing -- There is a later version based on ⟦explore⟧. module _ (f : A → 𝟚) {{_ : UA}} where lift-✓all-Πᵉ : ✓ (big-lift∧ ₁ f) ≡ Πᵉ explore (✓ ∘ f) lift-✓all-Πᵉ = lift-hom-≡ (lift 1₂) (lift-op₂ _∧_) (Lift 𝟙) _×_ (✓ ∘ lower) (lift ∘ f) (≡.! Lift≡id) (✓-∧-× _ _) module _ (f : A → 𝟚) where lift-✓any↔Σᵉ : ✓ (big-lift∨ ₁ f) ↔ Σᵉ explore (✓ ∘ f) lift-✓any↔Σᵉ = LiftHom.lift-hom _↔_ (id , id) (zip (flip _∘′_) _∘′_) (lift 0₂) (lift-op₂ _∨_) (Lift 𝟘) _⊎_ (zip ⊎-map ⊎-map) (✓ ∘ lower) (lift ∘ f) ((λ()) , λ{(lift())}) (✓∨-⊎ , ⊎-✓∨) sum-ind : SumInd sum sum-ind P P0 P+ Pf = explore-ind (λ e → P (e 0 _+_)) P0 P+ Pf sum-ext : SumExt sum sum-ext = explore-ext 0 _+_ sum-zero : SumZero sum sum-zero = explore-ε ℕ+.monoid sum-hom : SumHom sum sum-hom = explore-hom ℕ°.+-commutativeMonoid sum-mono : SumMono sum sum-mono = explore-mono _≤_ z≤n _+-mono_ sum-swap' : SumSwap sum sum-swap' {sumᴮ = sᴮ} sᴮ-0 hom f = sum-ind (λ s → s (sᴮ ∘ f) ≡ sᴮ (s ∘ flip f)) (! sᴮ-0) (λ p q → (ap₂ _+_ p q) ∙ (! hom _ _)) (λ _ → refl) where open ≡ sum-lin : SumLin sum sum-lin f zero = sum-zero sum-lin f (suc k) = ≡.trans (sum-hom f (λ x → k * f x)) (≡.ap₂ _+_ (≡.refl {x = sum f}) (sum-lin f k)) sum-const : SumConst sum sum-const x = sum-ext (λ _ → ! snd ℕ°.*-identity x) ∙ sum-lin (const 1) x ∙ ℕ°.*-comm x Card where open ≡ exploreStableUnder→sumStableUnder : ∀ {p} → StableUnder explore p → SumStableUnder sum p exploreStableUnder→sumStableUnder SU-p = SU-p 0 _+_ count-ext : CountExt count count-ext f≗g = sum-ext (≡.cong 𝟚▹ℕ ∘ f≗g) sumStableUnder→countStableUnder : ∀ {p} → SumStableUnder sum p → CountStableUnder count p sumStableUnder→countStableUnder sumSU-p f = sumSU-p (𝟚▹ℕ ∘ f) diff-list = with-endo-monoid (List.monoid A) List.[_] {- list≡diff-list : list ≡ diff-list list≡diff-list = {!explore-endo-monoid-spec (List.monoid A) List.[_]!} -} lift-sum : ∀ ℓ → Sum A lift-sum ℓ f = lower {₀} {ℓ} (explore (lift 0) (lift-op₂ _+_) (lift ∘ f)) Fin-lower-sum≡Σᵉ-Fin : ∀ {{_ : UA}}(f : A → ℕ) → Fin (lift-sum _ f) ≡ Σᵉ explore (Fin ∘ f) Fin-lower-sum≡Σᵉ-Fin f = lift-hom-≡ (lift 0) (lift-op₂ _+_) (Lift 𝟘) _⊎_ (Fin ∘ lower) (lift ∘ f) (Fin0≡𝟘 ∙ ! Lift≡id) (! Fin-⊎-+) where open ≡ module FromTwoExploreInd {a} {A : ★ a} {eᴬ : ∀ {ℓ} → Explore ℓ A} (eᴬ-ind : ∀ {p ℓ} → ExploreInd {ℓ} p eᴬ) {b} {B : ★ b} {eᴮ : ∀ {ℓ} → Explore ℓ B} (eᴮ-ind : ∀ {p ℓ} → ExploreInd {ℓ} p eᴮ) where module A = FromExploreInd eᴬ-ind module B = FromExploreInd eᴮ-ind module _ {c ℓ}(cm : CommutativeMonoid c ℓ) where open CMon cm opᴬ = eᴬ ε _∙_ opᴮ = eᴮ ε _∙_ -- TODO use lift-hom explore-swap' : ∀ f → opᴬ (opᴮ ∘ f) ≈ opᴮ (opᴬ ∘ flip f) explore-swap' = A.explore-swap m (B.explore-ε m) (B.explore-hom cm) sum-swap : ∀ f → A.sum (B.sum ∘ f) ≡ B.sum (A.sum ∘ flip f) sum-swap = explore-swap' ℕ°.+-commutativeMonoid module FromTwoAdequate-sum {{_ : UA}}{{_ : FunExt}} {A}{B} {sumᴬ : Sum A}{sumᴮ : Sum B} (open Adequacy _≡_) (sumᴬ-adq : Adequate-sum sumᴬ) (sumᴮ-adq : Adequate-sum sumᴮ) where open ≡ sumStableUnder : (p : A ≃ B)(f : B → ℕ) → sumᴬ (f ∘ ·→ p) ≡ sumᴮ f sumStableUnder p f = Fin-injective (sumᴬ-adq (f ∘ ·→ p) ∙ Σ-fst≃ p _ ∙ ! sumᴮ-adq f) sumStableUnder′ : (p : A ≃ B)(f : A → ℕ) → sumᴬ f ≡ sumᴮ (f ∘ <– p) sumStableUnder′ p f = Fin-injective (sumᴬ-adq f ∙ Σ-fst≃′ p _ ∙ ! sumᴮ-adq (f ∘ <– p)) module FromAdequate-sum {A} {sum : Sum A} (open Adequacy _≡_) (sum-adq : Adequate-sum sum) {{_ : UA}}{{_ : FunExt}} where open FromTwoAdequate-sum sum-adq sum-adq public open ≡ sum-ext : SumExt sum sum-ext = ap sum ∘ λ= private count : Count A count f = sum (𝟚▹ℕ ∘ f) private module M {p q : A → 𝟚}(same-count : count p ≡ count q) where private P = λ x → p x ≡ 1₂ Q = λ x → q x ≡ 1₂ ¬P = λ x → p x ≡ 0₂ ¬Q = λ x → q x ≡ 0₂ π : Σ A P ≡ Σ A Q π = ! Σ=′ _ (count-≡ p) ∙ ! (sum-adq (𝟚▹ℕ ∘ p)) ∙ ap Fin same-count ∙ sum-adq (𝟚▹ℕ ∘ q) ∙ Σ=′ _ (count-≡ q) lem1 : ∀ px qx → 𝟚▹ℕ qx ≡ (𝟚▹ℕ (px ∧ qx)) + 𝟚▹ℕ (not px) * 𝟚▹ℕ qx lem1 1₂ 1₂ = ≡.refl lem1 1₂ 0₂ = ≡.refl lem1 0₂ 1₂ = ≡.refl lem1 0₂ 0₂ = ≡.refl lem2 : ∀ px qx → 𝟚▹ℕ px ≡ (𝟚▹ℕ (px ∧ qx)) + 𝟚▹ℕ px * 𝟚▹ℕ (not qx) lem2 1₂ 1₂ = ≡.refl lem2 1₂ 0₂ = ≡.refl lem2 0₂ 1₂ = ≡.refl lem2 0₂ 0₂ = ≡.refl lemma1 : ∀ px qx → (qx ≡ 1₂) ≡ (Fin (𝟚▹ℕ (px ∧ qx)) ⊎ (px ≡ 0₂ × qx ≡ 1₂)) lemma1 px qx = ! Fin-≡-≡1₂ qx ∙ ap Fin (lem1 px qx) ∙ ! Fin-⊎-+ ∙ ⊎= refl (! Fin-×-* ∙ ×= (Fin-≡-≡0₂ px) (Fin-≡-≡1₂ qx)) lemma2 : ∀ px qx → (Fin (𝟚▹ℕ (px ∧ qx)) ⊎ (px ≡ 1₂ × qx ≡ 0₂)) ≡ (px ≡ 1₂) lemma2 px qx = ! ⊎= refl (! Fin-×-* ∙ ×= (Fin-≡-≡1₂ px) (Fin-≡-≡0₂ qx)) ∙ Fin-⊎-+ ∙ ap Fin (! lem2 px qx) ∙ Fin-≡-≡1₂ px π' : (Fin (sum (λ x → 𝟚▹ℕ (p x ∧ q x))) ⊎ Σ A (λ x → P x × ¬Q x)) ≡ (Fin (sum (λ x → 𝟚▹ℕ (p x ∧ q x))) ⊎ Σ A (λ x → ¬P x × Q x)) π' = ⊎= (sum-adq (λ x → 𝟚▹ℕ (p x ∧ q x))) refl ∙ ! Σ⊎-split ∙ Σ=′ _ (λ x → lemma2 (p x) (q x)) ∙ π ∙ Σ=′ _ (λ x → lemma1 (p x) (q x)) ∙ Σ⊎-split ∙ ! ⊎= (sum-adq (λ x → 𝟚▹ℕ (p x ∧ q x))) refl π'' : Σ A (P ×° ¬Q) ≡ Σ A (¬P ×° Q) π'' = Fin⊎-injective (sum (λ x → 𝟚▹ℕ (p x ∧ q x))) π' open EquivalentSubsets π'' public same-count→iso : ∀{p q : A → 𝟚}(same-count : count p ≡ count q) → p ≡ q ∘ M.π {p} {q} same-count same-count→iso {p} {q} sc = M.prop {p} {q} sc module From⟦Explore⟧ {-a-} {A : ★₀ {- a-}} {explore : ∀ {ℓ} → Explore ℓ A} (⟦explore⟧ : ∀ {ℓ₀ ℓ₁} ℓᵣ → ⟦Explore⟧ {ℓ₀} {ℓ₁} ℓᵣ _≡_ explore explore) {{_ : UA}} where open FromExplore explore module AlsoInFromExploreInd {ℓ}(M : Monoid ℓ ℓ) (open Mon M) (f : A → C) where explore-endo-monoid-spec′ : ∀ z → explore ε _∙_ f ∙ z ≈ explore-endo explore z _∙_ f explore-endo-monoid-spec′ = ⟦explore⟧ ₀ {C} {C → C} (λ r s → ∀ z → r ∙ z ≈ s z) (fst identity) (λ P₀ P₁ z → trans (assoc _ _ _) (trans (∙-cong refl (P₁ z)) (P₀ _))) (λ xᵣ _ → ∙-cong (reflexive (≡.ap f xᵣ)) refl) explore-endo-monoid-spec : with-monoid M f ≈ with-endo-monoid M f explore-endo-monoid-spec = trans (! snd identity _) (explore-endo-monoid-spec′ ε) open ≡ module _ (f : A → ℕ) where sum⇒Σᵉ : Fin (explore 0 _+_ f) ≡ explore (Lift 𝟘) _⊎_ (Fin ∘ f) sum⇒Σᵉ = ⟦explore⟧ {₀} {₁} ₁ (λ n X → Fin n ≡ X) (Fin0≡𝟘 ∙ ! Lift≡id) (λ p q → ! Fin-⊎-+ ∙ ⊎= p q) (ap (Fin ∘ f)) product⇒Πᵉ : Fin (explore 1 _*_ f) ≡ explore (Lift 𝟙) _×_ (Fin ∘ f) product⇒Πᵉ = ⟦explore⟧ {₀} {₁} ₁ (λ n X → Fin n ≡ X) (Fin1≡𝟙 ∙ ! Lift≡id) (λ p q → ! Fin-×-* ∙ ×= p q) (ap (Fin ∘ f)) module _ (f : A → 𝟚) where ✓all-Πᵉ : ✓ (all f) ≡ Πᵉ explore (✓ ∘ f) ✓all-Πᵉ = ⟦explore⟧ {₀} {₁} ₁ (λ b X → ✓ b ≡ X) (! Lift≡id) (λ p q → ✓-∧-× _ _ ∙ ×= p q) (ap (✓ ∘ f)) ✓any→Σᵉ : ✓ (any f) → Σᵉ explore (✓ ∘ f) ✓any→Σᵉ p = ⟦explore⟧ {₀} {ₛ ₀} ₁ (λ b (X : ★₀) → Lift (✓ b) → X) (λ x → lift (lower x)) (λ { {0₂} {x₁} xᵣ {y₀} {y₁} yᵣ zᵣ → inr (yᵣ zᵣ) ; {1₂} {x₁} xᵣ {y₀} {y₁} yᵣ zᵣ → inl (xᵣ _) }) (λ xᵣ x → tr (✓ ∘ f) xᵣ (lower x)) (lift p) module FromAdequate-Σᵉ (adequate-Σᵉ : ∀ {ℓ} → Adequate-Σ {ℓ} (Σᵉ explore)) where open Adequacy adequate-sum : Adequate-sum _≡_ sum adequate-sum f = sum⇒Σᵉ f ∙ adequate-Σᵉ (Fin ∘ f) open FromAdequate-sum adequate-sum public adequate-any : Adequate-any -→- any adequate-any f e = coe (adequate-Σᵉ (✓ ∘ f)) (✓any→Σᵉ f e) module FromAdequate-Πᵉ (adequate-Πᵉ : ∀ {ℓ} → Adequate-Π {ℓ} (Πᵉ explore)) where open Adequacy adequate-product : Adequate-product _≡_ product adequate-product f = product⇒Πᵉ f ∙ adequate-Πᵉ (Fin ∘ f) adequate-all : Adequate-all _≡_ all adequate-all f = ✓all-Πᵉ f ∙ adequate-Πᵉ _ check! : (f : A → 𝟚) {pf : ✓ (all f)} → (∀ x → ✓ (f x)) check! f {pf} = coe (adequate-all f) pf {- module ExplorableRecord where record Explorable A : ★₁ where constructor mk field explore : Explore₀ A explore-ind : ExploreInd₀ explore open FromExploreInd explore-ind field adequate-sum : Adequate-sum sum -- adequate-product : AdequateProduct product open FromExploreInd explore-ind public open Explorable public ExploreForFun : ★₀ → ★₁ ExploreForFun A = ∀ {X} → Explorable X → Explorable (A → X) record Funable A : ★₂ where constructor _,_ field explorable : Explorable A negative : ExploreForFun A module DistFun {A} (μA : Explorable A) (μA→ : ExploreForFun A) {B} (μB : Explorable B){X} (_≈_ : X → X → ★ ₀) (0′ : X) (_+_ : X → X → X) (_*_ : X → X → X) where Σᴮ = explore μB 0′ _+_ Π' = explore μA 0′ _*_ Σ' = explore (μA→ μB) 0′ _+_ DistFun = ∀ f → Π' (Σᴮ ∘ f) ≈ Σ' (Π' ∘ _ˢ_ f) DistFun : ∀ {A} → Explorable A → ExploreForFun A → ★₁ DistFun μA μA→ = ∀ {B} (μB : Explorable B) c → let open CMon {₀}{₀} c in ∀ _*_ → Zero _≈_ ε _*_ → _DistributesOver_ _≈_ _*_ _∙_ → _*_ Preserves₂ _≈_ ⟶ _≈_ ⟶ _≈_ → DistFun.DistFun μA μA→ μB _≈_ ε _∙_ _*_ DistFunable : ∀ {A} → Funable A → ★₁ DistFunable (μA , μA→) = DistFun μA μA→ module _ {{_ : UA}}{{_ : FunExt}} where μ-iso : ∀ {A B} → (A ≃ B) → Explorable A → Explorable B μ-iso {A}{B} A≃B μA = mk (EM.map _ A→B (explore μA)) (EM.map-ind _ A→B (explore-ind μA)) ade where open ≡ A→B = –> A≃B ade = λ f → adequate-sum μA (f ∘ A→B) ∙ Σ-fst≃ A≃B _ -- I guess this could be more general μ-iso-preserve : ∀ {A B} (A≃B : A ≃ B) f (μA : Explorable A) → sum μA f ≡ sum (μ-iso A≃B μA) (f ∘ <– A≃B) μ-iso-preserve A≃B f μA = sum-ext μA (λ x → ap f (! (<–-inv-l A≃B x))) where open ≡ {- μLift : ∀ {A} → Explorable A → Explorable (Lift A) μLift = μ-iso {!(! Lift↔id)!} where open ≡ -} -- -} -- -} -- -} -- -}
{ "alphanum_fraction": 0.4935878692, "avg_line_length": 33.8121468927, "ext": "agda", "hexsha": "e0bf0cec777158bbba22ff7e33e5aab70750c16a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "crypto-agda/explore", "max_forks_repo_path": "lib/Explore/Explorable.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "crypto-agda/explore", "max_issues_repo_path": "lib/Explore/Explorable.agda", "max_line_length": 164, "max_stars_count": 2, "max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "crypto-agda/explore", "max_stars_repo_path": "lib/Explore/Explorable.agda", "max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z", "num_tokens": 9941, "size": 23939 }
module Data.Num.Bijective.Properties where open import Data.Num.Bijective open import Data.Nat open import Data.Nat.DM open import Data.Nat.Properties open import Data.Nat.Properties.Simple open import Data.Nat.Properties.Extra open import Data.Fin as Fin using (Fin) open import Data.Fin.Extra open import Data.Fin.Properties as FinP hiding (_≟_) renaming (toℕ-injective to Fin-toℕ-injective) open import Data.Fin.Properties.Extra as FinPX renaming (cancel-suc to Fin-cancel-suc) open import Data.Product open import Function open import Function.Injection hiding (_∘_) open import Relation.Nullary open import Relation.Nullary.Negation using (contradiction) open import Relation.Binary.PropositionalEquality as PropEq open ≡-Reasoning -- begin -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ∎ ------------------------------------------------------------------------ -- Various ≡-related lemmata ------------------------------------------------------------------------ 1+-never-∙ : ∀ {b} xs → 1+ {b} xs ≢ ∙ 1+-never-∙ ∙ () 1+-never-∙ {b} (x ∷ xs) +1xs≡∙ with full x 1+-never-∙ (x ∷ xs) () | yes p 1+-never-∙ (x ∷ xs) () | no ¬p fromℕ-∙-0 : ∀ {b} n → fromℕ {b} n ≡ ∙ → n ≡ 0 fromℕ-∙-0 zero p = refl fromℕ-∙-0 (suc n) p = contradiction p (1+-never-∙ (fromℕ n)) toℕ-∙-0 : ∀ {b} xs → toℕ {suc b} xs ≡ 0 → xs ≡ ∙ toℕ-∙-0 ∙ p = refl toℕ-∙-0 (x ∷ xs) () digit+1-never-0 : ∀ {b} (x : Fin (suc b)) → (¬p : Fin.toℕ x ≢ b) → digit+1 x ¬p ≢ Fin.zero digit+1-never-0 {b} x ¬p eq with Fin.toℕ x ≟ b digit+1-never-0 {b} x ¬p eq | yes q = contradiction q ¬p digit+1-never-0 {zero} Fin.zero ¬p eq | no ¬q = contradiction refl ¬p digit+1-never-0 {suc b} Fin.zero ¬p eq | no ¬q = contradiction eq (λ ()) digit+1-never-0 {zero} (Fin.suc ()) ¬p eq | no ¬q digit+1-never-0 {suc b} (Fin.suc x) ¬p () | no ¬q Fin⇒ℕ-digit+1 : ∀ {b} → (x : Fin (suc b)) → (¬p : Fin.toℕ x ≢ b) → Fin.toℕ (digit+1 x ¬p) ≡ suc (Fin.toℕ x) Fin⇒ℕ-digit+1 {b} x ¬p = toℕ-fromℕ≤ (s≤s (digit+1-lemma (Fin.toℕ x) b (bounded x) ¬p)) ------------------------------------------------------------------------ -- injectivity ------------------------------------------------------------------------ ∷-injective : ∀ {b} → {x y : Fin (suc b)} → {xs ys : Bij (suc b)} → x ∷ xs ≡ y ∷ ys → x ≡ y × xs ≡ ys ∷-injective refl = refl , refl digit+1-injective : ∀ {b} (x y : Fin (suc b)) → (¬p : Fin.toℕ x ≢ b) → (¬q : Fin.toℕ y ≢ b) → digit+1 x ¬p ≡ digit+1 y ¬q → x ≡ y digit+1-injective Fin.zero Fin.zero ¬p ¬q eq = refl digit+1-injective {zero} Fin.zero (Fin.suc ()) ¬p ¬q eq digit+1-injective {suc b} Fin.zero (Fin.suc y) ¬p ¬q eq = Fin-toℕ-injective (cancel-suc eq') where eq' : Fin.toℕ {suc (suc b)} (digit+1 Fin.zero ¬p) ≡ suc (Fin.toℕ {suc (suc b)} (Fin.suc y)) eq' = begin Fin.toℕ {suc (suc b)} (Fin.suc Fin.zero) ≡⟨ cong Fin.toℕ eq ⟩ suc (Fin.toℕ (Fin.fromℕ≤ (s≤s (digit+1-lemma (Fin.toℕ y) b (bounded y) (¬q ∘ cong suc))))) ≡⟨ cong suc (toℕ-fromℕ≤ (s≤s (digit+1-lemma (Fin.toℕ y) b (bounded y) (¬q ∘ cong suc)))) ⟩ suc (Fin.toℕ {suc (suc b)} (Fin.suc y)) ∎ digit+1-injective {zero} (Fin.suc ()) Fin.zero ¬p ¬q eq digit+1-injective {suc b} (Fin.suc x) Fin.zero ¬p ¬q eq = Fin-toℕ-injective (cancel-suc eq') where eq' : suc (Fin.toℕ {suc (suc b)} (Fin.suc x)) ≡ Fin.toℕ {suc (suc b)} (digit+1 Fin.zero ¬q) eq' = begin suc (Fin.toℕ {suc (suc b)} (Fin.suc x)) ≡⟨ cong suc (sym (toℕ-fromℕ≤ (s≤s (digit+1-lemma (Fin.toℕ x) b (bounded x) (¬p ∘ cong suc))))) ⟩ suc (Fin.toℕ (Fin.fromℕ≤ (s≤s (digit+1-lemma (Fin.toℕ x) b (bounded x) (¬p ∘ cong suc))))) ≡⟨ cong Fin.toℕ eq ⟩ Fin.toℕ {suc (suc b)} (Fin.suc Fin.zero) ∎ digit+1-injective {zero} (Fin.suc ()) (Fin.suc y) ¬p ¬q eq digit+1-injective {suc b} (Fin.suc x) (Fin.suc y) ¬p ¬q eq = cong Fin.suc (digit+1-injective x y (¬p ∘ cong suc) (¬q ∘ cong suc) (Fin-cancel-suc eq)) where open import Data.Fin.Properties.Extra 1+-injective : ∀ b → (xs ys : Bij (suc b)) → 1+ xs ≡ 1+ ys → xs ≡ ys 1+-injective b ∙ ∙ eq = refl 1+-injective b ∙ (y ∷ ys) eq with full y 1+-injective b ∙ (y ∷ ys) eq | yes p = contradiction (proj₂ (∷-injective (sym eq))) (1+-never-∙ ys) 1+-injective b ∙ (y ∷ ys) eq | no ¬p = contradiction (proj₁ (∷-injective (sym eq))) (digit+1-never-0 y ¬p) 1+-injective b (x ∷ xs) ∙ eq with full x 1+-injective b (x ∷ xs) ∙ eq | yes p = contradiction (proj₂ (∷-injective eq)) (1+-never-∙ xs) 1+-injective b (x ∷ xs) ∙ eq | no ¬p = contradiction (proj₁ (∷-injective eq)) (digit+1-never-0 x ¬p) 1+-injective b (x ∷ xs) (y ∷ ys) eq with full x | full y 1+-injective b (x ∷ xs) (y ∷ ys) eq | yes p | yes q = cong₂ _∷_ x≡y xs≡ys where x≡y : x ≡ y x≡y = Fin-toℕ-injective (trans p (sym q)) xs≡ys : xs ≡ ys xs≡ys = 1+-injective b xs ys (proj₂ (∷-injective eq)) 1+-injective b (x ∷ xs) (y ∷ ys) eq | yes p | no ¬q = contradiction (sym (proj₁ (∷-injective eq))) (digit+1-never-0 y ¬q) 1+-injective b (x ∷ xs) (y ∷ ys) eq | no ¬p | yes q = contradiction (proj₁ (∷-injective eq)) (digit+1-never-0 x ¬p) 1+-injective b (x ∷ xs) (y ∷ ys) eq | no ¬p | no ¬q = cong₂ _∷_ (digit+1-injective x y ¬p ¬q (proj₁ (∷-injective eq))) (proj₂ (∷-injective eq)) toℕ-injective : ∀ {b} → (xs ys : Bij (suc b)) → toℕ xs ≡ toℕ ys → xs ≡ ys toℕ-injective ∙ ∙ eq = refl toℕ-injective ∙ (y ∷ ys) () toℕ-injective (x ∷ xs) ∙ () toℕ-injective (x ∷ xs) (y ∷ ys) eq = cong₂ _∷_ (proj₁ ind) (toℕ-injective xs ys (proj₂ ?)) where ind : x ≡ y × toℕ xs ≡ toℕ ys ind = some-lemma x y (toℕ xs) (toℕ ys) (cancel-suc eq) fromℕ-injective : ∀ b m n → fromℕ {b} m ≡ fromℕ {b} n → m ≡ n fromℕ-injective b zero zero eq = refl fromℕ-injective b zero (suc n) eq = contradiction (sym eq) (1+-never-∙ (fromℕ n)) fromℕ-injective b (suc m) zero eq = contradiction eq (1+-never-∙ (fromℕ m)) fromℕ-injective b (suc m) (suc n) eq = cong suc (fromℕ-injective b m n (1+-injective b (fromℕ m) (fromℕ n) eq)) -- -- xs ─── 1+ ──➞ 1+ xs -- | | -- toℕ toℕ -- ↓ ↓ -- n ─── suc ──➞ suc n -- toℕ-1+ : ∀ b xs → toℕ {suc b} (1+ xs) ≡ suc (toℕ xs) toℕ-1+ b ∙ = refl toℕ-1+ b (x ∷ xs) with full x toℕ-1+ b (x ∷ xs) | yes p = begin toℕ (Fin.zero ∷ 1+ xs) ≡⟨ cong (λ w → suc (w * suc b)) (toℕ-1+ b xs) ⟩ suc (suc (b + toℕ xs * suc b)) ≡⟨ cong (λ w → suc (suc (w + toℕ xs * suc b))) (sym p) ⟩ suc (toℕ (x ∷ xs)) ∎ toℕ-1+ b (x ∷ xs) | no ¬p = cong (λ w → suc w + toℕ xs * suc b) (toℕ-fromℕ≤ (s≤s (digit+1-lemma (Fin.toℕ x) b (bounded x) ¬p))) -- -- xs ── n+ n ──➞ n+ n xs -- | | -- toℕ toℕ -- ↓ ↓ -- m ── n + ──➞ n + m -- toℕ-n+ : ∀ b n xs → toℕ {suc b} (n+ n xs) ≡ n + (toℕ xs) toℕ-n+ b zero xs = refl toℕ-n+ b (suc n) xs = begin toℕ (1+ (n+ n xs)) ≡⟨ toℕ-1+ b (n+ n xs) ⟩ suc (toℕ (n+ n xs)) ≡⟨ cong suc (toℕ-n+ b n xs) ⟩ suc (n + toℕ xs) ∎ toℕ-fromℕ : ∀ b n → toℕ {suc b} (fromℕ {b} n) ≡ n toℕ-fromℕ b zero = refl toℕ-fromℕ b (suc n) with fromℕ {b} n | inspect (fromℕ {b}) n toℕ-fromℕ b (suc n) | ∙ | [ eq ] = cong suc (sym (fromℕ-∙-0 n eq)) toℕ-fromℕ b (suc n) | x ∷ xs | [ eq ] with full x toℕ-fromℕ b (suc n) | x ∷ xs | [ eq ] | yes p = begin toℕ (Fin.zero ∷ 1+ xs) ≡⟨ refl ⟩ suc (toℕ (1+ xs) * suc b) ≡⟨ cong (λ w → suc (w * suc b)) (toℕ-1+ b xs) ⟩ suc (suc (b + toℕ xs * suc b)) ≡⟨ cong (λ w → suc (suc (w + toℕ xs * suc b))) (sym p) ⟩ suc (suc (Fin.toℕ x) + toℕ xs * suc b) ≡⟨ cong (λ w → suc (toℕ w)) (sym eq) ⟩ suc (toℕ (fromℕ n)) ≡⟨ cong suc (toℕ-fromℕ b n) ⟩ suc n ∎ toℕ-fromℕ b (suc n) | x ∷ xs | [ eq ] | no ¬p = begin toℕ (digit+1 x ¬p ∷ xs) ≡⟨ cong (λ w → suc (w + toℕ xs * suc b)) (toℕ-fromℕ≤ (s≤s (digit+1-lemma (Fin.toℕ x) b (bounded x) ¬p))) ⟩ suc (suc (Fin.toℕ x + toℕ xs * suc b)) ≡⟨ cong (λ w → suc (toℕ w)) (sym eq) ⟩ suc (toℕ (fromℕ n)) ≡⟨ cong suc (toℕ-fromℕ b n) ⟩ suc n ∎ fromℕ-toℕ : ∀ {b} xs → fromℕ {b} (toℕ {suc b} xs) ≡ xs fromℕ-toℕ {b} xs = toℕ-injective (fromℕ (toℕ xs)) xs (toℕ-fromℕ b (toℕ xs)) toℕ-fromℕ-reverse : ∀ b {m} {n} → toℕ (fromℕ {b} m) ≡ n → m ≡ n toℕ-fromℕ-reverse b {m} {n} eq = begin m ≡⟨ sym (toℕ-fromℕ b m) ⟩ toℕ (fromℕ m) ≡⟨ eq ⟩ n ∎ fromℕ-toℕ-reverse : ∀ b {xs} {ys} → fromℕ {b} (toℕ {suc b} xs) ≡ ys → xs ≡ ys fromℕ-toℕ-reverse b {xs} {ys} eq = begin xs ≡⟨ sym (fromℕ-toℕ xs) ⟩ fromℕ (toℕ xs) ≡⟨ eq ⟩ ys ∎ ------------------------------------------------------------------------ -- surjectivity ------------------------------------------------------------------------ toℕ-surjective : ∀ b n → Σ[ xs ∈ Bij (suc b) ] toℕ xs ≡ n toℕ-surjective b zero = ∙ , refl toℕ-surjective b (suc n) = (fromℕ (suc n)) , toℕ-fromℕ b (suc n) fromℕ-surjective : ∀ {b} (xs : Bij (suc b)) → Σ[ n ∈ ℕ ] fromℕ n ≡ xs fromℕ-surjective ∙ = zero , refl fromℕ-surjective (x ∷ xs) = toℕ (x ∷ xs) , fromℕ-toℕ (x ∷ xs) ------------------------------------------------------------------------ -- _⊹_ ------------------------------------------------------------------------ toℕ-⊹-homo : ∀ {b} (xs ys : Bij (suc b)) → toℕ (xs ⊹ ys) ≡ toℕ xs + toℕ ys toℕ-⊹-homo {b} ∙ ys = refl toℕ-⊹-homo {b} (x ∷ xs) ∙ = sym (+-right-identity (suc (Fin.toℕ x + toℕ xs * suc b))) toℕ-⊹-homo {b} (x ∷ xs) (y ∷ ys) with suc (Fin.toℕ x + Fin.toℕ y) divMod (suc b) toℕ-⊹-homo {b} (x ∷ xs) (y ∷ ys) | result quotient remainder property div-eq mod-eq rewrite div-eq | mod-eq = begin suc (Fin.toℕ remainder + toℕ (n+ quotient (xs ⊹ ys)) * suc b) -- apply "toℕ-n+" to remove "n+" ≡⟨ cong (λ w → suc (Fin.toℕ remainder + w * suc b)) (toℕ-n+ b quotient (xs ⊹ ys)) ⟩ suc (Fin.toℕ remainder + (quotient + toℕ (xs ⊹ ys)) * suc b) -- the induction hypothesis ≡⟨ cong (λ w → suc (Fin.toℕ remainder + (quotient + w) * suc b)) (toℕ-⊹-homo xs ys) ⟩ suc (Fin.toℕ remainder + (quotient + (toℕ xs + toℕ ys)) * suc b) ≡⟨ cong (λ w → suc (Fin.toℕ remainder) + w) (distribʳ-*-+ (suc b) quotient (toℕ xs + toℕ ys)) ⟩ suc (Fin.toℕ remainder + (quotient * suc b + (toℕ xs + toℕ ys) * suc b)) ≡⟨ cong suc (sym (+-assoc (Fin.toℕ remainder) (quotient * suc b) ((toℕ xs + toℕ ys) * suc b))) ⟩ suc (Fin.toℕ remainder + quotient * suc b + (toℕ xs + toℕ ys) * suc b) -- apply "property" ≡⟨ cong (λ w → suc (w + (toℕ xs + toℕ ys) * suc b)) (sym property) ⟩ suc (suc (Fin.toℕ x + Fin.toℕ y + (toℕ xs + toℕ ys) * suc b)) ≡⟨ cong (λ w → suc (suc (Fin.toℕ x + Fin.toℕ y + w))) (distribʳ-*-+ (suc b) (toℕ xs) (toℕ ys)) ⟩ suc (suc (Fin.toℕ x + Fin.toℕ y + (toℕ xs * suc b + toℕ ys * suc b))) ≡⟨ cong (λ w → suc (suc w)) (+-assoc (Fin.toℕ x) (Fin.toℕ y) (toℕ xs * suc b + toℕ ys * suc b)) ⟩ suc (suc (Fin.toℕ x + (Fin.toℕ y + (toℕ xs * suc b + toℕ ys * suc b)))) ≡⟨ cong (λ w → suc (suc (Fin.toℕ x + w))) (sym (+-assoc (Fin.toℕ y) (toℕ xs * suc b) (toℕ ys * suc b))) ⟩ suc (suc (Fin.toℕ x + (Fin.toℕ y + toℕ xs * suc b + toℕ ys * suc b))) ≡⟨ cong (λ w → suc (suc (Fin.toℕ x + (w + toℕ ys * suc b)))) (+-comm (Fin.toℕ y) (toℕ xs * suc b)) ⟩ suc (suc (Fin.toℕ x + (toℕ xs * suc b + Fin.toℕ y + toℕ ys * suc b))) ≡⟨ cong (λ w → suc (suc (Fin.toℕ x + w))) (+-assoc (toℕ xs * suc b) (Fin.toℕ y) (toℕ ys * suc b)) ⟩ suc (suc (Fin.toℕ x + (toℕ xs * suc b + (Fin.toℕ y + toℕ ys * suc b)))) ≡⟨ cong (λ w → suc (suc w)) (sym (+-assoc (Fin.toℕ x) (toℕ xs * suc b) (Fin.toℕ y + toℕ ys * suc b))) ⟩ suc (suc ((Fin.toℕ x + toℕ xs * suc b) + (Fin.toℕ y + toℕ ys * suc b))) ≡⟨ cong suc (sym (+-suc (Fin.toℕ x + toℕ xs * suc b) (Fin.toℕ y + toℕ ys * suc b))) ⟩ suc (Fin.toℕ x + toℕ xs * suc b + suc (Fin.toℕ y + toℕ ys * suc b)) ≡⟨ refl ⟩ toℕ (x ∷ xs) + toℕ (y ∷ ys) ∎ fromℕ-⊹-homo : ∀ {b} (m n : ℕ) → fromℕ {b} (m + n) ≡ fromℕ m ⊹ fromℕ n fromℕ-⊹-homo {b} m n = toℕ-injective (fromℕ (m + n)) (fromℕ m ⊹ fromℕ n) $ begin toℕ (fromℕ (m + n)) ≡⟨ toℕ-fromℕ b (m + n) ⟩ m + n ≡⟨ sym (cong₂ _+_ (toℕ-fromℕ b m) (toℕ-fromℕ b n)) ⟩ toℕ (fromℕ m) + toℕ (fromℕ n) ≡⟨ sym (toℕ-⊹-homo (fromℕ m) (fromℕ n)) ⟩ toℕ (fromℕ m ⊹ fromℕ n) ∎ ⊹-1+ : ∀ {b} (xs ys : Bij (suc b)) → (1+ xs) ⊹ ys ≡ 1+ (xs ⊹ ys) ⊹-1+ {b} xs ys = toℕ-injective (1+ xs ⊹ ys) (1+ (xs ⊹ ys)) $ begin toℕ (1+ xs ⊹ ys) ≡⟨ toℕ-⊹-homo (1+ xs) ys ⟩ toℕ (1+ xs) + toℕ ys ≡⟨ cong (λ w → w + toℕ ys) (toℕ-1+ b xs) ⟩ suc (toℕ xs + toℕ ys) ≡⟨ cong suc (sym (toℕ-⊹-homo xs ys)) ⟩ suc (toℕ (xs ⊹ ys)) ≡⟨ sym (toℕ-1+ b (xs ⊹ ys)) ⟩ toℕ (1+ (xs ⊹ ys)) ∎ ⊹-assoc : ∀ {b} (xs ys zs : Bij (suc b)) → (xs ⊹ ys) ⊹ zs ≡ xs ⊹ (ys ⊹ zs) ⊹-assoc xs ys zs = toℕ-injective (xs ⊹ ys ⊹ zs) (xs ⊹ (ys ⊹ zs)) $ begin toℕ (xs ⊹ ys ⊹ zs) ≡⟨ toℕ-⊹-homo (xs ⊹ ys) zs ⟩ toℕ (xs ⊹ ys) + toℕ zs ≡⟨ cong (λ w → w + toℕ zs) (toℕ-⊹-homo xs ys) ⟩ toℕ xs + toℕ ys + toℕ zs ≡⟨ +-assoc (toℕ xs) (toℕ ys) (toℕ zs) ⟩ toℕ xs + (toℕ ys + toℕ zs) ≡⟨ cong (λ w → toℕ xs + w) (sym (toℕ-⊹-homo ys zs)) ⟩ toℕ xs + toℕ (ys ⊹ zs) ≡⟨ sym (toℕ-⊹-homo xs (ys ⊹ zs)) ⟩ toℕ (xs ⊹ (ys ⊹ zs)) ∎ ⊹-comm : ∀ {b} (xs ys : Bij (suc b)) → xs ⊹ ys ≡ ys ⊹ xs ⊹-comm xs ys = toℕ-injective (xs ⊹ ys) (ys ⊹ xs) $ begin toℕ (xs ⊹ ys) ≡⟨ toℕ-⊹-homo xs ys ⟩ toℕ xs + toℕ ys ≡⟨ +-comm (toℕ xs) (toℕ ys) ⟩ toℕ ys + toℕ xs ≡⟨ sym (toℕ-⊹-homo ys xs) ⟩ toℕ (ys ⊹ xs) ∎ increase-base-lemma : ∀ b → (xs : Bij (suc b)) → toℕ (increase-base xs) ≡ toℕ xs increase-base-lemma b ∙ = refl increase-base-lemma b (x ∷ xs) with fromℕ {suc b} (toℕ (increase-base xs) * suc b) | inspect (λ ws → fromℕ {suc b} (toℕ ws * suc b)) (increase-base xs) increase-base-lemma b (x ∷ xs) | ∙ | [ eq ] = cong suc $ begin Fin.toℕ (Fin.inject₁ x) + 0 ≡⟨ cong (λ w → w + 0) (FinP.inject₁-lemma x) ⟩ Fin.toℕ x + 0 ≡⟨ cong (λ w → Fin.toℕ x + w) $ begin zero ≡⟨ cong toℕ (sym eq) ⟩ toℕ (fromℕ (toℕ (increase-base xs) * suc b)) ≡⟨ toℕ-fromℕ (suc b) (toℕ (increase-base xs) * suc b) ⟩ toℕ (increase-base xs) * suc b ∎ ⟩ Fin.toℕ x + toℕ (increase-base xs) * suc b ≡⟨ cong (λ w → Fin.toℕ x + w * suc b) (increase-base-lemma b xs) ⟩ Fin.toℕ x + toℕ xs * suc b ∎ increase-base-lemma b (x ∷ xs) | y ∷ ys | [ eq ] with (suc (Fin.toℕ x + Fin.toℕ y)) divMod (suc (suc b)) increase-base-lemma b (x ∷ xs) | y ∷ ys | [ eq ] | result quotient remainder property div-eq mod-eq rewrite div-eq | mod-eq = cong suc $ begin Fin.toℕ remainder + toℕ (n+ quotient ys) * suc (suc b) ≡⟨ cong (λ w → Fin.toℕ remainder + w * suc (suc b)) (toℕ-n+ (suc b) quotient ys) ⟩ Fin.toℕ remainder + (quotient + toℕ ys) * suc (suc b) ≡⟨ cong (λ w → Fin.toℕ remainder + w) (distribʳ-*-+ (suc (suc b)) quotient (toℕ ys)) ⟩ Fin.toℕ remainder + (quotient * suc (suc b) + toℕ ys * suc (suc b)) ≡⟨ sym (+-assoc (Fin.toℕ remainder) (quotient * suc (suc b)) (toℕ ys * suc (suc b))) ⟩ Fin.toℕ remainder + quotient * suc (suc b) + toℕ ys * suc (suc b) ≡⟨ cong (λ w → w + toℕ ys * suc (suc b)) (sym property) ⟩ suc (Fin.toℕ x + Fin.toℕ y + toℕ ys * suc (suc b)) ≡⟨ cong suc (+-assoc (Fin.toℕ x) (Fin.toℕ y) (toℕ ys * suc (suc b))) ⟩ suc (Fin.toℕ x + (Fin.toℕ y + toℕ ys * suc (suc b))) ≡⟨ sym (+-suc (Fin.toℕ x) (Fin.toℕ y + toℕ ys * suc (suc b))) ⟩ Fin.toℕ x + suc (Fin.toℕ y + toℕ ys * suc (suc b)) ≡⟨ cong (λ w → Fin.toℕ x + toℕ w) (sym eq) ⟩ Fin.toℕ x + toℕ (fromℕ (toℕ (increase-base xs) * suc b)) ≡⟨ cong (λ w → Fin.toℕ x + w) (toℕ-fromℕ (suc b) (toℕ (increase-base xs) * suc b)) ⟩ Fin.toℕ x + toℕ (increase-base xs) * suc b ≡⟨ cong (λ w → Fin.toℕ x + w * suc b) (increase-base-lemma b xs) ⟩ Fin.toℕ x + toℕ xs * suc b ∎ decrease-base-lemma : ∀ b → (xs : Bij (suc (suc b))) → toℕ (decrease-base xs) ≡ toℕ xs decrease-base-lemma b ∙ = refl decrease-base-lemma b (x ∷ xs) with fromℕ {b} (toℕ (decrease-base xs) * suc (suc b)) | inspect (λ ws → fromℕ {b} (toℕ ws * suc (suc b))) (decrease-base xs) decrease-base-lemma b (x ∷ xs) | ∙ | [ eq ] with full x decrease-base-lemma b (x ∷ xs) | ∙ | [ eq ] | yes p = cong suc $ begin suc (b + 0) ≡⟨ cong (λ w → w + 0) (sym p)⟩ Fin.toℕ x + zero ≡⟨ cong (λ w → Fin.toℕ x + w) $ begin zero ≡⟨ cong toℕ (sym eq) ⟩ toℕ (fromℕ (toℕ (decrease-base xs) * suc (suc b))) ≡⟨ toℕ-fromℕ b (toℕ (decrease-base xs) * suc (suc b)) ⟩ toℕ (decrease-base xs) * suc (suc b) ∎ ⟩ Fin.toℕ x + toℕ (decrease-base xs) * suc (suc b) ≡⟨ cong (λ w → Fin.toℕ x + w * suc (suc b)) (decrease-base-lemma b xs) ⟩ Fin.toℕ x + toℕ xs * suc (suc b) ∎ decrease-base-lemma b (x ∷ xs) | ∙ | [ eq ] | no ¬p = cong suc $ begin Fin.toℕ (inject-1 x ¬p) + 0 ≡⟨ cong (λ w → w + 0) (inject-1-lemma x ¬p) ⟩ Fin.toℕ x + 0 ≡⟨ cong (λ w → Fin.toℕ x + w) $ begin zero ≡⟨ cong toℕ (sym eq) ⟩ toℕ (fromℕ (toℕ (decrease-base xs) * suc (suc b))) ≡⟨ toℕ-fromℕ b (toℕ (decrease-base xs) * suc (suc b)) ⟩ toℕ (decrease-base xs) * suc (suc b) ∎ ⟩ Fin.toℕ x + toℕ (decrease-base xs) * suc (suc b) ≡⟨ cong (λ w → Fin.toℕ x + w * suc (suc b)) (decrease-base-lemma b xs) ⟩ Fin.toℕ x + toℕ xs * suc (suc b) ∎ decrease-base-lemma b (x ∷ xs) | y ∷ ys | [ eq ] with (suc (Fin.toℕ x + Fin.toℕ y)) divMod (suc b) decrease-base-lemma b (x ∷ xs) | y ∷ ys | [ eq ] | result quotient remainder property div-eq mod-eq rewrite div-eq | mod-eq = cong suc $ begin Fin.toℕ remainder + toℕ (n+ quotient ys) * suc b ≡⟨ cong (λ w → Fin.toℕ remainder + w * suc b) (toℕ-n+ b quotient ys) ⟩ Fin.toℕ remainder + (quotient + toℕ ys) * suc b ≡⟨ cong (λ w → Fin.toℕ remainder + w) (distribʳ-*-+ (suc b) quotient (toℕ ys)) ⟩ Fin.toℕ remainder + (quotient * suc b + toℕ ys * suc b) ≡⟨ sym (+-assoc (Fin.toℕ remainder) (quotient * suc b) (toℕ ys * suc b)) ⟩ Fin.toℕ remainder + quotient * suc b + toℕ ys * suc b ≡⟨ cong (λ w → w + toℕ ys * suc b) (sym property) ⟩ suc (Fin.toℕ x + Fin.toℕ y + toℕ ys * suc b) ≡⟨ cong suc (+-assoc (Fin.toℕ x) (Fin.toℕ y) (toℕ ys * suc b)) ⟩ suc (Fin.toℕ x + (Fin.toℕ y + toℕ ys * suc b)) ≡⟨ sym (+-suc (Fin.toℕ x) (Fin.toℕ y + toℕ ys * suc b)) ⟩ Fin.toℕ x + suc (Fin.toℕ y + toℕ ys * suc b) ≡⟨ cong (λ w → Fin.toℕ x + toℕ w) (sym eq) ⟩ Fin.toℕ x + toℕ (fromℕ (toℕ (decrease-base xs) * suc (suc b))) ≡⟨ cong (λ w → Fin.toℕ x + w) (toℕ-fromℕ b (toℕ (decrease-base xs) * suc (suc b))) ⟩ Fin.toℕ x + toℕ (decrease-base xs) * suc (suc b) ≡⟨ cong (λ w → Fin.toℕ x + w * suc (suc b)) (decrease-base-lemma b xs) ⟩ Fin.toℕ x + toℕ xs * suc (suc b) ∎ -- begin -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ∎
{ "alphanum_fraction": 0.4724594993, "avg_line_length": 42.7941176471, "ext": "agda", "hexsha": "0a4af4e4dc7f105e318a9979062e5c0cdc3c39b1", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_path": "Data/Num/Bijective/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_path": "Data/Num/Bijective/Properties.agda", "max_line_length": 151, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_path": "Data/Num/Bijective/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "num_tokens": 8838, "size": 20370 }
-- Andreas, 2011-04-11 adapted from Data.Nat.Properties module FrozenMVar2 where open import Common.Level open import Common.Equality Rel : ∀ {a} → Set a → (ℓ : Level) → Set (a ⊔ lsuc ℓ) Rel A ℓ = A → A → Set ℓ Op₂ : ∀ {ℓ} → Set ℓ → Set ℓ Op₂ A = A → A → A module FunctionProperties {a ℓ} {A : Set a} (_≈_ : Rel A ℓ) where Associative : Op₂ A → Set _ Associative _∙_ = ∀ x y z → ((x ∙ y) ∙ z) ≈ (x ∙ (y ∙ z)) open FunctionProperties _≡_ -- THIS produces frozen metas data ℕ : Set where zℕ : ℕ sℕ : (n : ℕ) → ℕ infixl 6 _+_ _+_ : ℕ → ℕ → ℕ zℕ + n = n sℕ m + n = sℕ (m + n) +-assoc : Associative _+_ -- +-assoc : ∀ x y z -> ((x + y) + z) ≡ (x + (y + z)) -- this works +-assoc zℕ _ _ = refl +-assoc (sℕ m) n o = cong sℕ (+-assoc m n o) -- Due to a frozen meta we get: -- Type mismatch when checking that the pattern zℕ has type _95
{ "alphanum_fraction": 0.5671296296, "avg_line_length": 22.7368421053, "ext": "agda", "hexsha": "30d62f28be82b86a086fe6b2b241259b6075a714", "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/FrozenMVar2.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/FrozenMVar2.agda", "max_line_length": 67, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/FrozenMVar2.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": 354, "size": 864 }
open import Agda.Primitive Type : (i : Level) → Set (lsuc i) Type i = Set i postulate T : (i : Level) (A : Type i) → Set -- Give 'T lzero ?', then give '? → ?'. -- An internal error has occurred. Please report this as a bug. -- Location of the error: src/full/Agda/TypeChecking/Rules/Term.hs:178 Bug : Set Bug = {!T lzero ?!} -- Now: Failed to give (? → ?) -- Ideally, this should succeed.
{ "alphanum_fraction": 0.6297229219, "avg_line_length": 22.0555555556, "ext": "agda", "hexsha": "75f99cda7f54edc43b4f42acf40d3cfaab75cd02", "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/Issue3000.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/Issue3000.agda", "max_line_length": 70, "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/Issue3000.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": 127, "size": 397 }
{-# OPTIONS --without-K #-} module pointed where open import pointed.core public open import pointed.equality public
{ "alphanum_fraction": 0.7711864407, "avg_line_length": 19.6666666667, "ext": "agda", "hexsha": "5d020655065bbedf4b8fb7ffdd33358ff34ff17e", "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/pointed.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/pointed.agda", "max_line_length": 35, "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/pointed.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": 23, "size": 118 }