Search is not available for this dataset
text
string
meta
dict
module sn-calculus-compatconf.split where open import sn-calculus-compatconf.base open import sn-calculus open import utility renaming (_U̬_ to _∪_) open import context-properties using (unwrap-rho ; wrap-rho ; ->E-view ; plugc ; unplugc) open import Esterel.Lang open import Esterel.Lang.Properties open import Esterel.Lang.Binding open import Esterel.Lang.CanFunction using (Can ; Canₛ ; Canₛₕ ; Canₖ ; module CodeSet) open import Esterel.Environment as Env using (Env ; Θ ; _←_ ; Dom ; module SigMap ; module ShrMap ; module VarMap) open import Esterel.Context using (EvaluationContext ; EvaluationContext1 ; _⟦_⟧e ; _≐_⟦_⟧e ; Context ; Context1 ; _⟦_⟧c ; _≐_⟦_⟧c) open import Esterel.CompletionCode as Code using () renaming (CompletionCode to Code) open import Esterel.Variable.Signal as Signal using (Signal ; _ₛ) open import Esterel.Variable.Shared as SharedVar using (SharedVar ; _ₛₕ) open import Esterel.Variable.Sequential as SeqVar using (SeqVar ; _ᵥ) open import Relation.Nullary using (¬_ ; Dec ; yes ; no) open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; sym ; cong ; trans ; subst ; module ≡-Reasoning) open import Data.Bool using (Bool ; if_then_else_) open import Data.Empty using (⊥ ; ⊥-elim) open import Data.List using (List ; _∷_ ; [] ; _++_) open import Data.List.Any using (Any ; any ; here ; there) open import Data.List.Any.Properties using () renaming (++⁺ˡ to ++ˡ ; ++⁺ʳ to ++ʳ) open import Data.Maybe using (Maybe ; just ; nothing) open import Data.Nat using (ℕ ; zero ; suc ; _+_) renaming (_⊔_ to _⊔ℕ_) open import Data.Product using (Σ-syntax ; Σ ; _,_ ; _,′_ ; proj₁ ; proj₂ ; _×_ ; ∃) open import Data.Sum using (_⊎_ ; inj₁ ; inj₂ ; map) open import Function using (_∘_ ; id ; _∋_) open import Data.OrderedListMap Signal Signal.unwrap Signal.Status as SigM open import Data.OrderedListMap SharedVar SharedVar.unwrap (Σ SharedVar.Status (λ _ → ℕ)) as ShrM open import Data.OrderedListMap SeqVar SeqVar.unwrap ℕ as SeqM open ->E-view open EvaluationContext1 open _≐_⟦_⟧e open Context1 open _≐_⟦_⟧c open ListSet Data.Nat._≟_ {- Base case where (E, C) = ([], _∷_). Simply switch the reductions. Note that since E = [], the rmerge rule at LHS is actually ρθ.ρθ'.qin sn⟶₁ ρ(θ←θ').qin. Since C = _∷_, the reduction at RHS must go inside ρθ' so it's easy to handle. p ρθ. E⟦ qin ⟧ -- sn⟶₁ -> ρθq. E⟦ qo ⟧ (ρθ) E⟦C⟦rin⟧⟧ -- sn⟶₁ -> (ρθ) E⟦C⟦ro⟧⟧ -} 1-steplρ-E-view-ecsplit : ∀{E C p qin q qo rin r ro θ θq BV FV A Aq} → {ρθ·psn⟶₁ρθq·q : ρ⟨ θ , A ⟩· p sn⟶₁ ρ⟨ θq , Aq ⟩· q} → CorrectBinding p BV FV → two-roads-diverged E C → (p≐E⟦qin⟧ : p ≐ E ⟦ qin ⟧e) → (q≐E⟦qo⟧ : q ≐ E ⟦ qo ⟧e) → ->E-view ρθ·psn⟶₁ρθq·q p≐E⟦qin⟧ q≐E⟦qo⟧ → (p≐E⟦rin⟧ : p ≐ C ⟦ rin ⟧c) → (r≐E⟦ro⟧ : r ≐ C ⟦ ro ⟧c) → (rinsn⟶₁ro : rin sn⟶₁ ro) → ∃ λ po → -- LHS: 0 or 1 step (ρθ) C⟦qo⟧ sn⟶* (ρθ) C⟦poq⟧ reduction inside ρθ [ ] (q ≡ po ⊎ q sn⟶ po) × -- RHS: ρθ. E'⟦ro'⟧ sn⟶₁ ρθq. E'⟦por⟧ Σ (EvaluationContext × Term × Term) λ { (E' , ro' , por) → Σ[ r≐E'⟦ro'⟧ ∈ r ≐ E' ⟦ ro' ⟧e ] Σ[ po≐E'⟦por⟧ ∈ po ≐ E' ⟦ por ⟧e ] Σ[ ρθ·rsn⟶₁ρθq·po ∈ ρ⟨ θ , A ⟩· r sn⟶₁ ρ⟨ θq , Aq ⟩· po ] ->E-view ρθ·rsn⟶₁ρθq·po r≐E'⟦ro'⟧ po≐E'⟦por⟧ } 1-steplρ-E-view-ecsplit cb divout-disjoint dehole dehole vemit () r≐C⟦ro⟧ rinsn⟶₁ro 1-steplρ-E-view-ecsplit cb divout-disjoint dehole dehole vset-shared-value-old () r≐C⟦ro⟧ rinsn⟶₁ro 1-steplρ-E-view-ecsplit cb divout-disjoint dehole dehole vset-shared-value-new () r≐C⟦ro⟧ rinsn⟶₁ro 1-steplρ-E-view-ecsplit cb divout-disjoint dehole dehole vset-var () r≐C⟦ro⟧ rinsn⟶₁ro 1-steplρ-E-view-ecsplit {ρθ·psn⟶₁ρθq·q = ρθ·psn⟶₁ρθq·q} cb divout-disjoint dehole dehole vmerge ρθp≐C⟦rin⟧ ρθr≐C⟦ro⟧ rinsn⟶₁ro with ρθp≐C⟦rin⟧ | ρθr≐C⟦ro⟧ ... | dcenv p≐C⟦rin⟧ | dcenv r≐C⟦ro⟧ with sym (unplugc r≐C⟦ro⟧) ... | refl = _ , inj₂ (rcontext _ p≐C⟦rin⟧ rinsn⟶₁ro) ,′ _ , dehole , dehole , rmerge dehole , vmerge 1-steplρ-E-view-ecsplit {ρθ·psn⟶₁ρθq·q = ris-present {_} {S} S∈ θS≡present dehole} cb divout-disjoint dehole dehole vis-present (dcpresent₁ p≐C⟦rin⟧) (dcpresent₁ r≐C⟦ro⟧) rinsn⟶₁ro with sym (unplugc r≐C⟦ro⟧) ... | refl = _ , inj₂ (rcontext _ p≐C⟦rin⟧ rinsn⟶₁ro) ,′ _ , dehole , dehole , ris-present {_} {S} S∈ θS≡present dehole , vis-present 1-steplρ-E-view-ecsplit {ρθ·psn⟶₁ρθq·q = ris-present {_} {S} S∈ θS≡present dehole} cb divout-disjoint dehole dehole vis-present (dcpresent₂ p≐C⟦rin⟧) (dcpresent₂ r≐C⟦ro⟧) rinsn⟶₁ro = _ , inj₁ refl ,′ _ , dehole , dehole , ris-present {_} {S} S∈ θS≡present dehole , vis-present 1-steplρ-E-view-ecsplit {ρθ·psn⟶₁ρθq·q = ris-absent {_} {S} S∈ θS≡absent dehole} cb divout-disjoint dehole dehole vis-absent (dcpresent₁ p≐C⟦rin⟧) (dcpresent₁ r≐C⟦ro⟧) rinsn⟶₁ro = _ , inj₁ refl ,′ _ , dehole , dehole , ris-absent {_} {S} S∈ θS≡absent dehole , vis-absent 1-steplρ-E-view-ecsplit {ρθ·psn⟶₁ρθq·q = ris-absent {_} {S} S∈ θS≡absent dehole} cb divout-disjoint dehole dehole vis-absent (dcpresent₂ p≐C⟦rin⟧) (dcpresent₂ r≐C⟦ro⟧) rinsn⟶₁ro with sym (unplugc r≐C⟦ro⟧) ... | refl = _ , inj₂ (rcontext _ p≐C⟦rin⟧ rinsn⟶₁ro) ,′ _ , dehole , dehole , ris-absent {_} {S} S∈ θS≡absent dehole , vis-absent 1-steplρ-E-view-ecsplit {ρθ·psn⟶₁ρθq·q = rraise-shared {_} {_} {s} _ _} cb divout-disjoint dehole dehole vraise-shared (dcshared p≐C⟦rin⟧) (dcshared r≐C⟦ro⟧) rinsn⟶₁ro with sym (unplugc r≐C⟦ro⟧) ... | refl = _ , inj₂ (rcontext _ (dcenv p≐C⟦rin⟧) rinsn⟶₁ro) ,′ _ , dehole , dehole , rraise-shared {_} {_} {s} _ _ , vraise-shared 1-steplρ-E-view-ecsplit {ρθ·psn⟶₁ρθq·q = rraise-var {_} {_} {x} _ _} cb divout-disjoint dehole dehole vraise-var (dcvar p≐C⟦rin⟧) (dcvar r≐C⟦ro⟧) rinsn⟶₁ro with sym (unplugc r≐C⟦ro⟧) ... | refl = _ , inj₂ (rcontext _ (dcenv p≐C⟦rin⟧) rinsn⟶₁ro) ,′ _ , dehole , dehole , rraise-var {_} {_} {x} _ _ , vraise-var 1-steplρ-E-view-ecsplit {ρθ·psn⟶₁ρθq·q = rif-false {x = x} x∈ θx≡zero dehole} cb divout-disjoint dehole dehole vif-false (dcif₁ p≐C⟦rin⟧) (dcif₁ r≐C⟦ro⟧) rinsn⟶₁ro = _ , inj₁ refl ,′ _ , dehole , dehole , rif-false {x = x} x∈ θx≡zero dehole , vif-false 1-steplρ-E-view-ecsplit {ρθ·psn⟶₁ρθq·q = rif-false {x = x} x∈ θx≡zero dehole} cb divout-disjoint dehole dehole vif-false (dcif₂ p≐C⟦rin⟧) (dcif₂ r≐C⟦ro⟧) rinsn⟶₁ro with sym (unplugc r≐C⟦ro⟧) ... | refl = _ , inj₂ (rcontext _ p≐C⟦rin⟧ rinsn⟶₁ro) ,′ _ , dehole , dehole , rif-false {x = x} x∈ θx≡zero dehole , vif-false 1-steplρ-E-view-ecsplit {ρθ·psn⟶₁ρθq·q = rif-true {θ} {x = x} x∈ θx≡suc dehole} cb divout-disjoint dehole dehole vif-true (dcif₁ p≐C⟦rin⟧) (dcif₁ r≐C⟦ro⟧) rinsn⟶₁ro with sym (unplugc r≐C⟦ro⟧) ... | refl = _ , inj₂ (rcontext _ p≐C⟦rin⟧ rinsn⟶₁ro) ,′ _ , dehole , dehole , rif-true {x = x} x∈ θx≡suc dehole , vif-true 1-steplρ-E-view-ecsplit {ρθ·psn⟶₁ρθq·q = rif-true {x = x} x∈ θx≡suc dehole} cb divout-disjoint dehole dehole vif-true (dcif₂ p≐C⟦rin⟧) (dcif₂ r≐C⟦ro⟧) rinsn⟶₁ro = _ , inj₁ refl ,′ _ , dehole , dehole , rif-true {x = x} x∈ θx≡suc dehole , vif-true 1-steplρ-E-view-ecsplit cb divpar-split₁ (depar₁ p₁≐E⟦qin⟧) (depar₁ q≐E⟦qo⟧) e-view (dcpar₂ p≐C⟦rin⟧) (dcpar₂ r≐C⟦ro⟧) rinsn⟶₁ro with unwrap-rho _ _ _ p₁≐E⟦qin⟧ q≐E⟦qo⟧ e-view ... | ρθ·p₁sn⟶₁ρθq·q , e-view' with sym (unplugc r≐C⟦ro⟧) ... | refl = _ , inj₂ (rcontext _ (dcpar₂ p≐C⟦rin⟧) rinsn⟶₁ro) ,′ _ , _ , _ , wrap-rho ρθ·p₁sn⟶₁ρθq·q _ _ e-view' _ (depar₁ p₁≐E⟦qin⟧) (depar₁ q≐E⟦qo⟧) 1-steplρ-E-view-ecsplit cb divpar-split₂ (depar₂ p₂≐E⟦qin⟧) (depar₂ q≐E⟦qo⟧) e-view (dcpar₁ p≐C⟦rin⟧) (dcpar₁ r≐C⟦ro⟧) rinsn⟶₁ro with unwrap-rho _ _ _ p₂≐E⟦qin⟧ q≐E⟦qo⟧ e-view ... | ρθ·p₂sn⟶₁ρθq·q , e-view' with sym (unplugc r≐C⟦ro⟧) ... | refl = _ , inj₂ (rcontext _ (dcpar₁ p≐C⟦rin⟧) rinsn⟶₁ro) ,′ _ , _ , _ , wrap-rho ρθ·p₂sn⟶₁ρθq·q _ _ e-view' _ (depar₂ p₂≐E⟦qin⟧) (depar₂ q≐E⟦qo⟧) 1-steplρ-E-view-ecsplit cb divseq-split (deseq p₁≐E⟦qin⟧) (deseq q≐E⟦qo⟧) e-view (dcseq₂ p≐C⟦rin⟧) (dcseq₂ r≐C⟦ro⟧) rinsn⟶₁ro with unwrap-rho _ _ _ p₁≐E⟦qin⟧ q≐E⟦qo⟧ e-view ... | ρθ·p₁sn⟶₁ρθq·q , e-view' with sym (unplugc r≐C⟦ro⟧) ... | refl = _ , inj₂ (rcontext _ (dcseq₂ p≐C⟦rin⟧) rinsn⟶₁ro) ,′ _ , _ , _ , wrap-rho ρθ·p₁sn⟶₁ρθq·q _ _ e-view' _ (deseq p₁≐E⟦qin⟧) (deseq q≐E⟦qo⟧) 1-steplρ-E-view-ecsplit cb divloopˢ-split (deloopˢ p₁≐E⟦qin⟧) (deloopˢ q≐E⟦qo⟧) e-view (dcloopˢ₂ p≐C⟦rin⟧) (dcloopˢ₂ r≐C⟦ro⟧) rinsn⟶₁ro with unwrap-rho _ _ _ p₁≐E⟦qin⟧ q≐E⟦qo⟧ e-view ... | ρθ·p₁sn⟶₁ρθq·q , e-view' with sym (unplugc r≐C⟦ro⟧) ... | refl = _ , inj₂ (rcontext _ (dcloopˢ₂ p≐C⟦rin⟧) rinsn⟶₁ro) ,′ _ , _ , _ , wrap-rho ρθ·p₁sn⟶₁ρθq·q _ _ e-view' _ (deloopˢ p₁≐E⟦qin⟧) (deloopˢ q≐E⟦qo⟧) 1-steplρ-E-view-ecsplit {ρθ·psn⟶₁ρθq·q = ρθ·E₁⟦p⟧sn⟶₁ρθq·E₁⟦q⟧} cb@(CBpar cbp cbq _ _ _ _) (divin div) (depar₁ p≐E⟦qin⟧) (depar₁ q≐E⟦qo⟧) e-view-E₁ (dcpar₁ p≐C⟦rin⟧) (dcpar₁ r≐C⟦ro⟧) rinsn⟶₁ro with unwrap-rho ρθ·E₁⟦p⟧sn⟶₁ρθq·E₁⟦q⟧ (depar₁ p≐E⟦qin⟧) (depar₁ q≐E⟦qo⟧) p≐E⟦qin⟧ q≐E⟦qo⟧ e-view-E₁ ... | (ρθ·psn⟶₁ρθq·q , e-view) with 1-steplρ-E-view-ecsplit cbp div p≐E⟦qin⟧ q≐E⟦qo⟧ e-view p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro ... | _ , qsn⟶po? , _ , r≐E'⟦qin⟧ , po≐E'⟦qo⟧ , _ , e-view' = _ , map (cong _) (Context1-sn⟶ (ceval (epar₁ _))) qsn⟶po? ,′ _ , depar₁ r≐E'⟦qin⟧ , depar₁ po≐E'⟦qo⟧ , wrap-rho _ _ _ e-view' _ _ _ 1-steplρ-E-view-ecsplit {ρθ·psn⟶₁ρθq·q = ρθ·E₁⟦p⟧sn⟶₁ρθq·E₁⟦q⟧} cb@(CBpar cbp cbq _ _ _ _) (divin div) (depar₂ p≐E⟦qin⟧) (depar₂ q≐E⟦qo⟧) e-view-E₁ (dcpar₂ p≐C⟦rin⟧) (dcpar₂ r≐C⟦ro⟧) rinsn⟶₁ro with unwrap-rho ρθ·E₁⟦p⟧sn⟶₁ρθq·E₁⟦q⟧ (depar₂ p≐E⟦qin⟧) (depar₂ q≐E⟦qo⟧) p≐E⟦qin⟧ q≐E⟦qo⟧ e-view-E₁ ... | (ρθ·psn⟶₁ρθq·q , e-view) with 1-steplρ-E-view-ecsplit cbq div p≐E⟦qin⟧ q≐E⟦qo⟧ e-view p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro ... | _ , qsn⟶po? , _ , r≐E'⟦qin⟧ , po≐E'⟦qo⟧ , _ , e-view' = _ , map (cong _) (Context1-sn⟶ (ceval (epar₂ _))) qsn⟶po? ,′ _ , depar₂ r≐E'⟦qin⟧ , depar₂ po≐E'⟦qo⟧ , wrap-rho _ _ _ e-view' _ _ _ 1-steplρ-E-view-ecsplit {ρθ·psn⟶₁ρθq·q = ρθ·E₁⟦p⟧sn⟶₁ρθq·E₁⟦q⟧} cb@(CBseq cbp cbq _) (divin div) (deseq p≐E⟦qin⟧) (deseq q≐E⟦qo⟧) e-view-E₁ (dcseq₁ p≐C⟦rin⟧) (dcseq₁ r≐C⟦ro⟧) rinsn⟶₁ro with unwrap-rho ρθ·E₁⟦p⟧sn⟶₁ρθq·E₁⟦q⟧ (deseq p≐E⟦qin⟧) (deseq q≐E⟦qo⟧) p≐E⟦qin⟧ q≐E⟦qo⟧ e-view-E₁ ... | (ρθ·psn⟶₁ρθq·q , e-view) with 1-steplρ-E-view-ecsplit cbp div p≐E⟦qin⟧ q≐E⟦qo⟧ e-view p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro ... | _ , qsn⟶po? , _ , r≐E'⟦qin⟧ , po≐E'⟦qo⟧ , _ , e-view' = _ , map (cong _) (Context1-sn⟶ (ceval (eseq _))) qsn⟶po? ,′ _ , deseq r≐E'⟦qin⟧ , deseq po≐E'⟦qo⟧ , wrap-rho _ _ _ e-view' _ _ _ 1-steplρ-E-view-ecsplit {ρθ·psn⟶₁ρθq·q = ρθ·E₁⟦p⟧sn⟶₁ρθq·E₁⟦q⟧} cb@(CBloopˢ cbp cbq _ _) (divin div) (deloopˢ p≐E⟦qin⟧) (deloopˢ q≐E⟦qo⟧) e-view-E₁ (dcloopˢ₁ p≐C⟦rin⟧) (dcloopˢ₁ r≐C⟦ro⟧) rinsn⟶₁ro with unwrap-rho ρθ·E₁⟦p⟧sn⟶₁ρθq·E₁⟦q⟧ (deloopˢ p≐E⟦qin⟧) (deloopˢ q≐E⟦qo⟧) p≐E⟦qin⟧ q≐E⟦qo⟧ e-view-E₁ ... | (ρθ·psn⟶₁ρθq·q , e-view) with 1-steplρ-E-view-ecsplit cbp div p≐E⟦qin⟧ q≐E⟦qo⟧ e-view p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro ... | _ , qsn⟶po? , _ , r≐E'⟦qin⟧ , po≐E'⟦qo⟧ , _ , e-view' = _ , map (cong _) (Context1-sn⟶ (ceval (eloopˢ _))) qsn⟶po? ,′ _ , deloopˢ r≐E'⟦qin⟧ , deloopˢ po≐E'⟦qo⟧ , wrap-rho _ _ _ e-view' _ _ _ 1-steplρ-E-view-ecsplit {ρθ·psn⟶₁ρθq·q = ρθ·E₁⟦p⟧sn⟶₁ρθq·E₁⟦q⟧} cb@(CBsusp cb' _) (divin div) (desuspend p≐E⟦qin⟧) (desuspend q≐E⟦qo⟧) e-view-E₁ (dcsuspend p≐C⟦rin⟧) (dcsuspend r≐C⟦ro⟧) rinsn⟶₁ro with unwrap-rho ρθ·E₁⟦p⟧sn⟶₁ρθq·E₁⟦q⟧ (desuspend p≐E⟦qin⟧) (desuspend q≐E⟦qo⟧) p≐E⟦qin⟧ q≐E⟦qo⟧ e-view-E₁ ... | (ρθ·psn⟶₁ρθq·q , e-view) with 1-steplρ-E-view-ecsplit cb' div p≐E⟦qin⟧ q≐E⟦qo⟧ e-view p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro ... | _ , qsn⟶po? , _ , r≐E'⟦qin⟧ , po≐E'⟦qo⟧ , _ , e-view' = _ , map (cong _) (Context1-sn⟶ (ceval (esuspend _))) qsn⟶po? ,′ _ , desuspend r≐E'⟦qin⟧ , desuspend po≐E'⟦qo⟧ , wrap-rho _ _ _ e-view' _ _ _ 1-steplρ-E-view-ecsplit {ρθ·psn⟶₁ρθq·q = ρθ·E₁⟦p⟧sn⟶₁ρθq·E₁⟦q⟧} cb@(CBtrap cb') (divin div) (detrap p≐E⟦qin⟧) (detrap q≐E⟦qo⟧) e-view-E₁ (dctrap p≐C⟦rin⟧) (dctrap r≐C⟦ro⟧) rinsn⟶₁ro with unwrap-rho ρθ·E₁⟦p⟧sn⟶₁ρθq·E₁⟦q⟧ (detrap p≐E⟦qin⟧) (detrap q≐E⟦qo⟧) p≐E⟦qin⟧ q≐E⟦qo⟧ e-view-E₁ ... | (ρθ·psn⟶₁ρθq·q , e-view) with 1-steplρ-E-view-ecsplit cb' div p≐E⟦qin⟧ q≐E⟦qo⟧ e-view p≐C⟦rin⟧ r≐C⟦ro⟧ rinsn⟶₁ro ... | _ , qsn⟶po? , _ , r≐E'⟦qin⟧ , po≐E'⟦qo⟧ , _ , e-view' = _ , map (cong _) (Context1-sn⟶ (ceval etrap)) qsn⟶po? ,′ _ , detrap r≐E'⟦qin⟧ , detrap po≐E'⟦qo⟧ , wrap-rho _ _ _ e-view' _ _ _
{ "alphanum_fraction": 0.6205983797, "avg_line_length": 40.2161290323, "ext": "agda", "hexsha": "9dac96078cd71e1f5222160f040f694937f00fac", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_path": "agda/sn-calculus-compatconf/split.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "florence/esterel-calculus", "max_issues_repo_path": "agda/sn-calculus-compatconf/split.agda", "max_line_length": 107, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_path": "agda/sn-calculus-compatconf/split.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "num_tokens": 6954, "size": 12467 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.PtdMapSequence open import homotopy.CofiberSequence open import groups.Exactness open import groups.ExactSequence open import groups.HomSequence open import cohomology.Theory module cohomology.Sigma {i} (CT : CohomologyTheory i) (n : ℤ) (X : Ptd i) (Y : de⊙ X → Ptd i) where open CohomologyTheory CT open import cohomology.PtdMapSequence CT {- Cⁿ(Σx:X.Y) = Cⁿ(⋁x:X.Y) × Cⁿ(X). The proof is by constructing a - splitting exact sequence 0 → Cⁿ(⋁x:X.Y) → Cⁿ(Σx:X.Y) → Cⁿ(X) - by observing that the map [select : x ↦ (x, pt Yₓ)] has a left inverse - and satisfies [Cofiber select == ⋁x:X.Y. -} ⊙select : X ⊙→ ⊙Σ X Y ⊙select = (bigwedge-f Y , idp) ⊙Σbwin : ⊙Σ X Y ⊙→ ⊙BigWedge Y ⊙Σbwin = ⊙cfcod' ⊙select private abstract cst-C-Σbwin-is-exact : is-exact (cst-hom {G = C n (⊙Susp X)}) (C-fmap n ⊙Σbwin) cst-C-Σbwin-is-exact = equiv-preserves-exact {φ₁ = cst-hom {G = C n (⊙Susp X)}} {ξG = C-fmap n (⊙Susp-to-⊙Cof² ⊙select)} {ξH = idhom _} {ξK = idhom _} (comm-sqrᴳ λ x → CEl-fmap n (⊙cfcod²' ⊙select) x =⟨ ! $ CEl-fmap-idf n $ CEl-fmap n (⊙cfcod²' ⊙select) x ⟩ CEl-fmap n (⊙idf _) (CEl-fmap n (⊙cfcod²' ⊙select) x) =⟨ C-comm-square n (extract-glue-cod²-comm-sqr ⊙select) □$ᴳ x ⟩ CEl-fmap n ⊙extract-glue (CEl-fmap n (⊙Susp-to-⊙Cof² ⊙select) x) =⟨ CEl-fmap-const n (extract-glue-from-BigWedge-is-const Y) _ ⟩ Cident n _ =∎) (comm-sqrᴳ λ _ → idp) (C-isemap n (⊙Susp-to-⊙Cof² ⊙select) (snd (Cof²-equiv-Susp ⊙select ⁻¹))) (idf-is-equiv _) (idf-is-equiv _) (C-exact n ⊙Σbwin) χ : C n X →ᴳ C n (⊙Σ X Y) χ = C-fmap n (⊙fstᵈ Y) abstract select-χ-is-idf : ∀ s → CEl-fmap n ⊙select (GroupHom.f χ s) == s select-χ-is-idf = CEl-fmap-inverse n ⊙select (⊙fstᵈ Y) λ _ → idp C-Σ : C n (⊙Σ X Y) ≃ᴳ C n (⊙BigWedge Y) ×ᴳ C n X C-Σ = Exact.φ-inj-and-ψ-has-rinv-split (C-exact n ⊙select) (C-is-abelian n _) (Exact.φ-const-implies-ψ-is-inj cst-C-Σbwin-is-exact (λ _ → idp)) χ select-χ-is-idf {- ⊙Σbwin-over : CF-hom n ⊙Σbwin == ×ᴳ-inl [ (λ G → GroupHom (C n (⊙BigWedge Y)) G) ↓ path ] ⊙Σbwin-over = SER.φ-over-iso ⊙select-over : CF-hom n ⊙select == ×ᴳ-snd {G = C n (⊙BigWedge Y)} [ (λ G → GroupHom G (C n X)) ↓ path ] ⊙select-over = SER.ψ-over-iso open CofSelect public using (select; ⊙select; ⊙Σbwin) -}
{ "alphanum_fraction": 0.5897332255, "avg_line_length": 32.5526315789, "ext": "agda", "hexsha": "65dcd106269cd877ab6c65f96d32c54c279cec6b", "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": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/cohomology/Sigma.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/cohomology/Sigma.agda", "max_line_length": 83, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/cohomology/Sigma.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1124, "size": 2474 }
module _ where open import Agda.Builtin.Unit open import Agda.Builtin.Reflection data D (B : Set) {{b : B}} : Set where c : D B postulate B : Set instance b : B T : D B → Set macro this : Term → Term → TC ⊤ this thing hole = unify hole thing test₁ : _ test₁ = c {_} {{b}} test₂ : D B test₂ = c {_} {{b}} test₃ : D B test₃ = this (c {{b}})
{ "alphanum_fraction": 0.5905292479, "avg_line_length": 13.2962962963, "ext": "agda", "hexsha": "6e32356150a87128bed1aba5092d19086dad12cc", "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/Issue1989.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/Issue1989.agda", "max_line_length": 38, "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/Issue1989.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": 132, "size": 359 }
-- {-# OPTIONS -v tc:10 -v tc.inj:100 #-} -- 2013-02-18 reported by rotsor module Issue796o where data U : Set where a b : U data A : Set where data B : Set where abstract A' B' : Set A' = A B' = B -- fails if changed to A. Should always fail. [_] : U → Set [_] a = A' [_] b = B' f : ∀ u → [ u ] → U f u _ = u postulate x : A' zzz = f _ x
{ "alphanum_fraction": 0.5391061453, "avg_line_length": 12.7857142857, "ext": "agda", "hexsha": "ba53afa8676d47beaa6e42162e742c7b728e38a6", "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/Issue796o.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/Issue796o.agda", "max_line_length": 56, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue796o.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": 144, "size": 358 }
{-# OPTIONS --without-K --safe #-} module Categories.Functor.Instance.01-Truncation where -- (0,1)-trucation of categories as a functor from Cats to Posets. -- -- This is the right-adjoint of the inclusion functor from Posets to -- Cats (see Categories.Functor.Adjoint.Instance.01-Truncation) open import Level using (_⊔_) open import Function using (flip) open import Data.Product as Prod using (_,_; _×_) open import Relation.Binary.OrderMorphism using (_⇒-Poset_) open import Relation.Binary using (Poset) open import Categories.Category using (Category; _[_≈_]) open import Categories.Functor hiding (id) open import Categories.Category using (Category) open import Categories.Category.Instance.Cats using (Cats) open import Categories.Category.Instance.Posets using (Posets) import Categories.Morphism as Morphism open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism; _≃_) Trunc : ∀ {o ℓ e} → Functor (Cats o ℓ e) (Posets o ℓ ℓ) Trunc {o} {ℓ} {e} = record { F₀ = Trunc₀ ; F₁ = Trunc₁ ; identity = λ {C} → id C , id C ; homomorphism = λ {_ _ C} → id C , id C ; F-resp-≈ = TruncRespNI } where open Functor -- The choice of _≈_ below may seem a bit arbitrary. The -- rationale is as follows: -- -- Since we are defining an Agda stdlib-style poset, we have to -- pick an equality on the carrier set, i.e. on objects. But -- objects do not come with an equality in this library (that's -- considered evil), so we pick isomorphism. In a poset, any -- pair of morphisms f : X ⇒ Y and g : Y ⇒ X constitute an -- isomorphism between X and Y. Hence the definition of _≈_. Trunc₀ : Category o ℓ e → Poset o ℓ ℓ Trunc₀ C = record { Carrier = Obj ; _≈_ = λ x y → x ⇒ y × y ⇒ x ; _≤_ = _⇒_ ; isPartialOrder = record { isPreorder = record { isEquivalence = record { refl = id , id ; sym = Prod.swap ; trans = Prod.zip (flip _∘_) _∘_ } ; reflexive = Prod.proj₁ ; trans = flip _∘_ } ; antisym = _,_ } } where open Category C Trunc₁ : ∀ {C D} → Functor C D → Trunc₀ C ⇒-Poset Trunc₀ D Trunc₁ F = record { fun = F₀ F ; monotone = F₁ F } TruncRespNI : ∀ {C D : Category o ℓ e} {F G : Functor C D} → F ≃ G → Posets o ℓ ℓ [ Trunc₁ F ≈ Trunc₁ G ] TruncRespNI μ {X} = ⇒.η X , ⇐.η X where open NaturalIsomorphism μ open Category
{ "alphanum_fraction": 0.5905011219, "avg_line_length": 35.6533333333, "ext": "agda", "hexsha": "2e4ce3f711a092e43e091916c9e26d5df2610cea", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-categories", "max_forks_repo_path": "src/Categories/Functor/Instance/01-Truncation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bblfish/agda-categories", "max_issues_repo_path": "src/Categories/Functor/Instance/01-Truncation.agda", "max_line_length": 68, "max_stars_count": 5, "max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bblfish/agda-categories", "max_stars_repo_path": "src/Categories/Functor/Instance/01-Truncation.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": 787, "size": 2674 }
module Oscar.Level where open import Agda.Primitive public using () renaming (Level to Ł̂; lzero to Ø̂; lsuc to ↑̂_; _⊔_ to _+̂_) open import Agda.Primitive public using () renaming (Level to Ł̂; lzero to lzero; lsuc to lsuc; _⊔_ to _⊔_) 𝑶 : ∀ a → Set (lsuc a) 𝑶 a = Set a open import Agda.Primitive public using () renaming ( Level to Ł ; lzero to ∅̂ ; lsuc to ↑̂_ ; _⊔_ to _∙̂_ ) infix 0 Ø_ Ø_ : ∀ 𝔬 → Set (↑̂ 𝔬) Ø_ 𝔬 = Set 𝔬 Ø₀ = Ø ∅̂
{ "alphanum_fraction": 0.5734693878, "avg_line_length": 18.1481481481, "ext": "agda", "hexsha": "bae9b7d4f051c7dd962a1b5df1a281b9ff04b8ef", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-2/Oscar/Level.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-2/Oscar/Level.agda", "max_line_length": 66, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-2/Oscar/Level.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 218, "size": 490 }
module pushdown where open import Level renaming ( suc to succ ; zero to Zero ) open import Data.Nat open import Data.List open import Data.Maybe -- open import Data.Bool using ( Bool ; true ; false ) open import Relation.Binary.PropositionalEquality hiding ( [_] ) open import Relation.Nullary using (¬_; Dec; yes; no) open import Level renaming ( suc to succ ; zero to Zero ) -- open import Data.Product open import logic open import automaton data PushDown ( Γ : Set ) : Set where pop : PushDown Γ push : Γ → PushDown Γ none : PushDown Γ record PushDownAutomaton ( Q : Set ) ( Σ : Set ) ( Γ : Set ) : Set where field pδ : Q → Σ → Γ → Q ∧ ( PushDown Γ ) pok : Q → Bool pempty : Γ pmoves : Q → List Γ → Σ → ( Q ∧ List Γ ) pmoves q [] i with pδ q i pempty pmoves q [] i | ⟪ qn , pop ⟫ = ⟪ qn , [] ⟫ pmoves q [] i | ⟪ qn , push x ⟫ = ⟪ qn , ( x ∷ [] ) ⟫ pmoves q [] i | ⟪ qn , none ⟫ = ⟪ qn , [] ⟫ pmoves q ( H ∷ T ) i with pδ q i H pmoves q (H ∷ T) i | ⟪ qn , pop ⟫ = ⟪ qn , T ⟫ pmoves q (H ∷ T) i | ⟪ qn , none ⟫ = ⟪ qn , (H ∷ T) ⟫ pmoves q (H ∷ T) i | ⟪ qn , push x ⟫ = ⟪ qn , x ∷ H ∷ T ⟫ paccept : (q : Q ) ( In : List Σ ) ( sp : List Γ ) → Bool paccept q [] [] = pok q paccept q ( H ∷ T) [] with pδ q H pempty paccept q (H ∷ T) [] | ⟪ qn , pop ⟫ = paccept qn T [] paccept q (H ∷ T) [] | ⟪ qn , none ⟫ = paccept qn T [] paccept q (H ∷ T) [] | ⟪ qn , push x ⟫ = paccept qn T (x ∷ [] ) paccept q [] (_ ∷ _ ) = false paccept q ( H ∷ T ) ( SH ∷ ST ) with pδ q H SH ... | ⟪ nq , pop ⟫ = paccept nq T ST ... | ⟪ nq , none ⟫ = paccept nq T (SH ∷ ST) ... | ⟪ nq , push ns ⟫ = paccept nq T ( ns ∷ SH ∷ ST ) record PDA ( Q : Set ) ( Σ : Set ) ( Γ : Set ) : Set where field automaton : Automaton Q Σ pδ : Q → PushDown Γ open Automaton paccept : (q : Q ) ( In : List Σ ) ( sp : List Γ ) → Bool paccept q [] [] = aend automaton q paccept q (H ∷ T) [] with pδ (δ automaton q H) paccept q (H ∷ T) [] | pop = paccept (δ automaton q H) T [] paccept q (H ∷ T) [] | none = paccept (δ automaton q H) T [] paccept q (H ∷ T) [] | push x = paccept (δ automaton q H) T (x ∷ [] ) paccept q [] (_ ∷ _ ) = false paccept q ( H ∷ T ) ( SH ∷ ST ) with pδ (δ automaton q H) ... | pop = paccept (δ automaton q H) T ST ... | none = paccept (δ automaton q H) T (SH ∷ ST) ... | push ns = paccept (δ automaton q H) T ( ns ∷ SH ∷ ST ) data States0 : Set where sr : States0 data In2 : Set where i0 : In2 i1 : In2 pnn : PushDownAutomaton States0 In2 States0 pnn = record { pδ = pδ ; pempty = sr ; pok = λ q → true } where pδ : States0 → In2 → States0 → States0 ∧ PushDown States0 pδ sr i0 _ = ⟪ sr , push sr ⟫ pδ sr i1 _ = ⟪ sr , pop ⟫ data States2 : Set where ph1 : States2 ph2 : States2 phf : States2 pnnp : PDA States2 In2 States2 pnnp = record { automaton = record { aend = aend ; δ = δ } ; pδ = pδ } where δ : States2 → In2 → States2 δ ph1 i0 = ph1 δ ph1 i1 = ph2 δ ph2 i1 = ph2 δ _ _ = phf aend : States2 → Bool aend ph2 = true aend _ = false pδ : States2 → PushDown States2 pδ ph1 = push ph1 pδ ph2 = pop pδ phf = none data States1 : Set where ss : States1 st : States1 pn1 : PushDownAutomaton States1 In2 States1 pn1 = record { pδ = pδ ; pempty = ss ; pok = pok1 } where pok1 : States1 → Bool pok1 ss = false pok1 st = true pδ : States1 → In2 → States1 → States1 ∧ PushDown States1 pδ ss i0 _ = ⟪ ss , push ss ⟫ pδ ss i1 _ = ⟪ st , pop ⟫ pδ st i0 _ = ⟪ st , push ss ⟫ pδ st i1 _ = ⟪ st , pop ⟫ test1 = PushDownAutomaton.paccept pnn sr ( i0 ∷ i0 ∷ i1 ∷ i1 ∷ [] ) [] test2 = PushDownAutomaton.paccept pnn sr ( i0 ∷ i0 ∷ i1 ∷ i0 ∷ [] ) [] test3 = PushDownAutomaton.pmoves pnn sr [] i0 test4 = PushDownAutomaton.paccept pnn sr ( i0 ∷ i0 ∷ i1 ∷ i1 ∷ i0 ∷ i1 ∷ [] ) [] test5 = PushDownAutomaton.paccept pn1 ss ( i0 ∷ i0 ∷ i1 ∷ i1 ∷ [] ) [] test6 = PushDownAutomaton.paccept pn1 ss ( i0 ∷ i0 ∷ i1 ∷ i1 ∷ i0 ∷ i1 ∷ [] ) []
{ "alphanum_fraction": 0.5033967391, "avg_line_length": 32.9552238806, "ext": "agda", "hexsha": "2a0f807b61e516436d2c122d1645e2846643dc81", "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": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/automaton-in-agda", "max_forks_repo_path": "src/pushdown.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "shinji-kono/automaton-in-agda", "max_issues_repo_path": "src/pushdown.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/automaton-in-agda", "max_stars_repo_path": "src/pushdown.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1751, "size": 4416 }
-- Compiled things must have a Haskell type given by a COMPILED_TYPE pragma module CompiledMustHaveHaskellType where postulate N : Set foo : N -- It is necessary add something like -- {-# COMPILED_TYPE N Int #-} {-# COMPILED foo bar #-}
{ "alphanum_fraction": 0.7183673469, "avg_line_length": 18.8461538462, "ext": "agda", "hexsha": "ecdd2baa76ca58c28f22809db4f6a7635d7433c5", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/CompiledMustHaveHaskellType.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/CompiledMustHaveHaskellType.agda", "max_line_length": 75, "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": "test/Fail/CompiledMustHaveHaskellType.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": 64, "size": 245 }
module FFI.IO where open import Agda.Builtin.IO using (IO) open import Agda.Builtin.Unit using (⊤) open import Agda.Builtin.String using (String) open import FFI.Data.HaskellString using (HaskellString; pack ; unpack) infixl 1 _>>=_ infixl 1 _>>_ postulate return : ∀ {a} {A : Set a} → A → IO A _>>=_ : ∀ {a b} {A : Set a} {B : Set b} → IO A → (A → IO B) → IO B fmap : ∀ {a b} {A : Set a} {B : Set b} → (A → B) → IO A → IO B {-# COMPILE GHC return = \_ _ -> return #-} {-# COMPILE GHC _>>=_ = \_ _ _ _ -> (>>=) #-} {-# COMPILE GHC fmap = \_ _ _ _ -> fmap #-} postulate getHContents : IO HaskellString {-# COMPILE GHC getHContents = getContents #-} postulate putHStrLn : HaskellString → IO ⊤ {-# COMPILE GHC putHStrLn = putStrLn #-} getContents : IO String getContents = fmap pack getHContents putStrLn : String → IO ⊤ putStrLn txt = putHStrLn (unpack txt) _>>_ : ∀ {a} {A : Set a} → IO ⊤ → IO A → IO A a >> b = a >>= (λ _ → b )
{ "alphanum_fraction": 0.6010526316, "avg_line_length": 27.1428571429, "ext": "agda", "hexsha": "825a788f861707fd246883475caf76cd331b75a6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "XanderYZZ/luau", "max_forks_repo_path": "prototyping/FFI/IO.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "XanderYZZ/luau", "max_issues_repo_path": "prototyping/FFI/IO.agda", "max_line_length": 71, "max_stars_count": 1, "max_stars_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "TheGreatSageEqualToHeaven/luau", "max_stars_repo_path": "prototyping/FFI/IO.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-05T21:53:03.000Z", "max_stars_repo_stars_event_min_datetime": "2021-12-05T21:53:03.000Z", "num_tokens": 332, "size": 950 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties satisfied by posets ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Relation.Binary.Properties.Poset {p₁ p₂ p₃} (P : Poset p₁ p₂ p₃) where open Relation.Binary.Poset P hiding (trans) open import Relation.Binary.Construct.NonStrictToStrict _≈_ _≤_ open import Relation.Binary.Properties.Preorder preorder open import Function using (flip) -- The inverse relation is also a poset. invIsPartialOrder : IsPartialOrder _≈_ (flip _≤_) invIsPartialOrder = record { isPreorder = invIsPreorder ; antisym = flip antisym } invPoset : Poset p₁ p₂ p₃ invPoset = record { isPartialOrder = invIsPartialOrder } ------------------------------------------------------------------------ -- Posets can be turned into strict partial orders strictPartialOrder : StrictPartialOrder _ _ _ strictPartialOrder = record { isStrictPartialOrder = <-isStrictPartialOrder isPartialOrder } open StrictPartialOrder strictPartialOrder
{ "alphanum_fraction": 0.6168549088, "avg_line_length": 29.5128205128, "ext": "agda", "hexsha": "37d43470a0ea791917cfb8da8d4d86a3745d12f0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Properties/Poset.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Properties/Poset.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Properties/Poset.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 251, "size": 1151 }
------------------------------------------------------------------------------ -- The division result is correct ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Program.Division.ResultI where open import Common.FOL.Relation.Binary.EqReasoning open import FOTC.Base open import FOTC.Data.Nat open import FOTC.Data.Nat.Inequalities open import FOTC.Data.Nat.PropertiesI open import FOTC.Program.Division.ConversionRulesI open import FOTC.Program.Division.Division open import FOTC.Program.Division.Specification ------------------------------------------------------------------------------ -- The division result is correct when the dividend is less than -- the divisor. div-x<y-helper : ∀ {i j} → N i → N j → i < j → i ≡ j * div i j + i div-x<y-helper {i} {j} Ni Nj i<j = sym prf where prf : j * div i j + i ≡ i prf = j * div i j + i ≡⟨ +-leftCong (*-rightCong (div-x<y i<j)) ⟩ j * zero + i ≡⟨ +-leftCong (*-rightZero Nj) ⟩ zero + i ≡⟨ +-leftIdentity i ⟩ i ∎ div-x<y-resultCorrect : ∀ {i j} → N i → N j → i < j → ∃[ r ] N r ∧ r < j ∧ i ≡ j * div i j + r div-x<y-resultCorrect Ni Nj i<j = _ , Ni , i<j , div-x<y-helper Ni Nj i<j -- The division result is correct when the dividend is greater or equal -- than the divisor. -- Using the inductive hypothesis ih we know that -- -- i ∸ j = j * (div (i ∸ j) j) + r. -- From that we get -- -- i = j * (succ (div (i ∸ j) j)) + r and we know -- -- div i j = succ (div (i ∸ j) j) therefore we get -- -- i = j * div i j + r. postulate helper : ∀ {i j r} → N i → N j → N r → i ∸ j ≡ j * div (i ∸ j) j + r → i ≡ j * succ₁ (div (i ∸ j) j) + r div-x≮y-helper : ∀ {i j r} → N i → N j → N r → i ≮ j → i ∸ j ≡ j * div (i ∸ j) j + r → i ≡ j * div i j + r div-x≮y-helper {i} {j} {r} Ni Nj Nr i≮j helperH = i ≡⟨ helper Ni Nj Nr helperH ⟩ j * succ₁ (div (i ∸ j) j) + r ≡⟨ prf ⟩ j * div i j + r ∎ where prf : j * succ₁ (div (i ∸ j) j) + r ≡ j * div i j + r prf = subst (λ x → j * x + r ≡ j * div i j + r) (div-x≮y i≮j) refl -- 2012-02-29: We are using the existential witness only for -- documenting the types in the where clause. They could be removed. div-x≮y-resultCorrect : ∀ {i j} → N i → N j → (divSpec (i ∸ j) j (div (i ∸ j) j)) → i ≮ j → ∃[ r ] N r ∧ r < j ∧ i ≡ j * div i j + r div-x≮y-resultCorrect {i} {j} Ni Nj (h₁ , r , r-correct) i≮j = r , Nr , r<j , div-x≮y-helper Ni Nj Nr i≮j helperH where Nr : N r Nr = ∧-proj₁ r-correct r<j : r < j r<j = ∧-proj₁ (∧-proj₂ r-correct) helperH : i ∸ j ≡ j * div (i ∸ j) j + r helperH = ∧-proj₂ (∧-proj₂ r-correct)
{ "alphanum_fraction": 0.4680851064, "avg_line_length": 35.1149425287, "ext": "agda", "hexsha": "e3a2f9f81adbb40af148d9de12fa5f52fbd9d718", "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/Division/ResultI.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/Division/ResultI.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/FOTC/Program/Division/ResultI.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": 1026, "size": 3055 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Setoids.Setoids open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Groups.Definition module Groups.Abelian.Definition where record AbelianGroup {a} {b} {A : Set a} {S : Setoid {a} {b} A} {_·_ : A → A → A} (G : Group S _·_) : Set (lsuc a ⊔ b) where open Setoid S field commutative : {a b : A} → (a · b) ∼ (b · a)
{ "alphanum_fraction": 0.6305418719, "avg_line_length": 31.2307692308, "ext": "agda", "hexsha": "fd8657e7bdf36f4b0607b6baacbaad737b5300f7", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Groups/Abelian/Definition.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Groups/Abelian/Definition.agda", "max_line_length": 123, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Groups/Abelian/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": 147, "size": 406 }
{-# OPTIONS --allow-unsolved-metas #-} -- The option is supplied to force a real error to pass the regression test. module StronglyRigidOccurrence where data Nat : Set where zero : Nat suc : Nat -> Nat data _≡_ {A : Set}(a : A) : A -> Set where refl : a ≡ a test : let X : Nat; X = _ in X ≡ suc X test = refl -- this gives an error in the occurs checker
{ "alphanum_fraction": 0.6538461538, "avg_line_length": 24.2666666667, "ext": "agda", "hexsha": "5846283d41d3cf63c68d7d0a34476ac0f28ea132", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dagit/agda", "max_forks_repo_path": "test/fail/StronglyRigidOccurrence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dagit/agda", "max_issues_repo_path": "test/fail/StronglyRigidOccurrence.agda", "max_line_length": 76, "max_stars_count": 1, "max_stars_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dagit/agda", "max_stars_repo_path": "test/fail/StronglyRigidOccurrence.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T07:26:06.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T07:26:06.000Z", "num_tokens": 113, "size": 364 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Universal lifting of predicates over Vectors ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Vec.Functional.Relation.Unary.All where open import Data.Fin.Base open import Data.Fin.Properties open import Data.Nat.Base open import Data.Product using (_,_) open import Data.Vec.Functional as VF hiding (map) open import Level using (Level) open import Relation.Unary private variable a p q ℓ : Level A : Set a ------------------------------------------------------------------------ -- Definition All : Pred A ℓ → ∀ {n} → Vector A n → Set ℓ All P xs = ∀ i → P (xs i) ------------------------------------------------------------------------ -- Operations module _ {P : Pred A p} {Q : Pred A q} where map : P ⊆ Q → ∀ {n} → All P {n = n} ⊆ All Q map p⊆q ps i = p⊆q (ps i) ------------------------------------------------------------------------ -- Properties of predicates preserved by All module _ {P : Pred A p} where all : Decidable P → ∀ {n} → Decidable (All P {n = n}) all p? xs = all? λ i → p? (xs i) universal : Universal P → ∀ {n} → Universal (All P {n = n}) universal uni xs i = uni (xs i) satisfiable : Satisfiable P → ∀ {n} → Satisfiable (All P {n = n}) satisfiable (x , px) = (λ _ → x) , (λ _ → px)
{ "alphanum_fraction": 0.4652631579, "avg_line_length": 27.9411764706, "ext": "agda", "hexsha": "7c6e418a6dd9374fffb258ceeb590f1b94dd0446", "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/Vec/Functional/Relation/Unary/All.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/Vec/Functional/Relation/Unary/All.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/Vec/Functional/Relation/Unary/All.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": 359, "size": 1425 }
{-# OPTIONS --prop --rewriting #-} open import Calf.CostMonoid open import Data.Nat using (ℕ) open import Examples.Sorting.Comparable module Examples.Sorting.Core (costMonoid : CostMonoid) (fromℕ : ℕ → CostMonoid.ℂ costMonoid) (M : Comparable costMonoid fromℕ) where open Comparable M open import Calf costMonoid open import Calf.Types.List open import Relation.Nullary open import Relation.Nullary.Negation open import Relation.Binary open import Relation.Binary.PropositionalEquality as Eq using (_≡_; refl; module ≡-Reasoning) open import Data.Product using (_×_; _,_; ∃; proj₁; proj₂) open import Data.Sum using (inj₁; inj₂) open import Data.Nat as Nat using (ℕ; zero; suc; z≤n; s≤s; _+_; _*_; _^_; ⌊_/2⌋; ⌈_/2⌉) import Data.Nat.Properties as N open import Data.List.Properties using (++-assoc; length-++) public open import Data.List.Relation.Binary.Permutation.Propositional public open import Data.List.Relation.Binary.Permutation.Propositional.Properties using (↭-length; ¬x∷xs↭[]; All-resp-↭; Any-resp-↭; drop-∷; ++-identityʳ) renaming (++-comm to ++-comm-↭; ++⁺ˡ to ++⁺ˡ-↭; ++⁺ʳ to ++⁺ʳ-↭; ++⁺ to ++⁺-↭) public open import Data.List.Relation.Unary.All using (All; []; _∷_; map; lookup) public open import Data.List.Relation.Unary.All.Properties as AllP using () renaming (++⁺ to ++⁺-All) public open import Data.List.Relation.Unary.Any using (Any; here; there) _≥_ : val A → val A → Set x ≥ y = y ≤ x _≰_ : val A → val A → Set x ≰ y = ¬ x ≤ y ≰⇒≥ : _≰_ ⇒ _≥_ ≰⇒≥ {x} {y} h with ≤-total x y ... | inj₁ h₁ = contradiction h₁ h ... | inj₂ h₂ = h₂ _≤*_ : val A → val (list A) → Set _≤*_ x = All (x ≤_) ≤-≤* : ∀ {x₁ x₂ l} → x₁ ≤ x₂ → x₂ ≤* l → x₁ ≤* l ≤-≤* x₁≤x₂ = map (≤-trans x₁≤x₂) data Sorted : val (list A) → Set where [] : Sorted [] _∷_ : ∀ {y ys} → y ≤* ys → Sorted ys → Sorted (y ∷ ys) short-sorted : {l : val (list A)} → length l Nat.≤ 1 → Sorted l short-sorted {[]} _ = [] short-sorted {_ ∷ []} _ = [] ∷ [] short-sorted {_ ∷ _ ∷ _} (s≤s ()) unique-sorted : ∀ {l'₁ l'₂} → Sorted l'₁ → Sorted l'₂ → l'₁ ↭ l'₂ → l'₁ ≡ l'₂ unique-sorted [] [] ↭ = refl unique-sorted [] (h₂ ∷ sorted₂) ↭ = contradiction (↭-sym ↭) ¬x∷xs↭[] unique-sorted (h₁ ∷ sorted₁) [] ↭ = contradiction (↭) ¬x∷xs↭[] unique-sorted (h₁ ∷ sorted₁) (h₂ ∷ sorted₂) ↭ with ≤-antisym (lookup (≤-refl ∷ h₁) (Any-resp-↭ (↭-sym ↭) (here refl))) (lookup (≤-refl ∷ h₂) (Any-resp-↭ (↭) (here refl))) ... | refl = Eq.cong (_ ∷_) (unique-sorted sorted₁ sorted₂ (drop-∷ ↭)) join-sorted : ∀ {l₁ mid l₂} → Sorted l₁ → Sorted l₂ → All (_≤ mid) l₁ → All (mid ≤_) l₂ → Sorted (l₁ ++ [ mid ] ++ l₂) join-sorted [] sorted₂ all₁ all₂ = all₂ ∷ sorted₂ join-sorted (h ∷ sorted₁) sorted₂ (h' ∷ all₁) all₂ = ++⁺-All h (h' ∷ ≤-≤* h' all₂) ∷ (join-sorted sorted₁ sorted₂ all₁ all₂) ++⁻ˡ : ∀ xs {ys} → Sorted (xs ++ ys) → Sorted xs ++⁻ˡ [] sorted = [] ++⁻ˡ (x ∷ xs) (h ∷ sorted) = AllP.++⁻ˡ xs h ∷ (++⁻ˡ xs sorted) ++⁻ʳ : ∀ xs {ys} → Sorted (xs ++ ys) → Sorted ys ++⁻ʳ [] sorted = sorted ++⁻ʳ (x ∷ xs) (h ∷ sorted) = ++⁻ʳ xs sorted split-sorted₁ : ∀ xs {x} → Sorted (xs ∷ʳ x) → All (_≤ x) xs split-sorted₁ [] sorted = [] split-sorted₁ (x ∷ xs) (h ∷ sorted) = proj₂ (AllP.∷ʳ⁻ h) ∷ split-sorted₁ xs sorted uncons₁ : ∀ {x xs} → Sorted (x ∷ xs) → x ≤* xs uncons₁ (h ∷ sorted) = h uncons₂ : ∀ {x xs} → Sorted (x ∷ xs) → Sorted xs uncons₂ (h ∷ sorted) = sorted SortedOf : val (list A) → val (list A) → Set SortedOf l l' = l ↭ l' × Sorted l' SortResult : cmp (Π (list A) λ _ → F (list A)) → val (list A) → Set SortResult sort l = ◯ (∃ λ l' → sort l ≡ ret l' × SortedOf l l') IsSort : cmp (Π (list A) λ _ → F (list A)) → Set IsSort sort = ∀ l → SortResult sort l IsSort⇒≡ : ∀ sort₁ → IsSort sort₁ → ∀ sort₂ → IsSort sort₂ → ◯ (sort₁ ≡ sort₂) IsSort⇒≡ sort₁ correct₁ sort₂ correct₂ u = funext λ l → let (l'₁ , ≡₁ , ↭₁ , sorted₁) = correct₁ l u in let (l'₂ , ≡₂ , ↭₂ , sorted₂) = correct₂ l u in begin sort₁ l ≡⟨ ≡₁ ⟩ ret l'₁ ≡⟨ Eq.cong ret (unique-sorted sorted₁ sorted₂ (trans (↭-sym ↭₁) ↭₂)) ⟩ ret l'₂ ≡˘⟨ ≡₂ ⟩ sort₂ l ∎ where open ≡-Reasoning
{ "alphanum_fraction": 0.5797619048, "avg_line_length": 34.7107438017, "ext": "agda", "hexsha": "b073858fa7aefb0a897527af816969e93edd42ef", "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/Examples/Sorting/Core.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/Examples/Sorting/Core.agda", "max_line_length": 118, "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/Examples/Sorting/Core.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": 1721, "size": 4200 }
{-# OPTIONS --safe #-} module Definition.Typed.Consequences.Canonicity where open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Weakening open import Definition.Typed.Properties open import Definition.Typed.EqRelInstance open import Definition.LogicalRelation open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.ShapeView open import Definition.LogicalRelation.Fundamental.Reducibility open import Tools.Empty open import Tools.Nat open import Tools.Product -- Turns a natural number into its term representation sucᵏ : Nat → Term sucᵏ 0 = zero sucᵏ (1+ n) = suc (sucᵏ n) -- No neutral terms are well-formed in an empty context -- we need to postulate consistency -- as we have several uninhabited propositions, we build an predicate -- to characterize them -- Note that we could also have defined reductions to Empty of other -- forms of unihabited types data isFalse : Term → Set where isEmpty : ∀ {lEmpty} → isFalse (Empty lEmpty) isIdℕΠ : ∀ {r A rA B} → isFalse (Id (Univ r ⁰) ℕ (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰)) isIdΠℕ : ∀ {r A rA B} → isFalse (Id (Univ r ⁰) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰) ℕ) isIdΠΠ%! : ∀ {r A B A' B'} → isFalse (Id (Univ r ⁰) (Π A ^ % ° ⁰ ▹ B ° ⁰ ° ⁰) (Π A' ^ ! ° ⁰ ▹ B' ° ⁰ ° ⁰)) isIdΠΠ!% : ∀ {r A B A' B'} → isFalse (Id (Univ r ⁰) (Π A ^ ! ° ⁰ ▹ B ° ⁰ ° ⁰) (Π A' ^ % ° ⁰ ▹ B' ° ⁰ ° ⁰)) consistency = ∀ {t A l} → isFalse A → ε ⊢ t ∷ A ^ [ % , l ] → ⊥ noNe : ∀ {t A r} → consistency → ε ⊢ t ∷ A ^ r → Neutral t → ⊥ -- impossible cases thanks to consistency noNe consistency (Emptyrecⱼ A ⊢e) Emptyrecₙ = consistency isEmpty ⊢e noNe consistency (castⱼ [A] [A]₁ [A]₂ [A]₃) castℕΠₙ = consistency isIdℕΠ [A]₂ noNe consistency (castⱼ [A] [A]₁ [A]₂ [A]₃) castΠℕₙ = consistency isIdΠℕ [A]₂ noNe consistency (castⱼ [A] [A]₁ [A]₂ [A]₃) castΠΠ%!ₙ = consistency isIdΠΠ%! [A]₂ noNe consistency (castⱼ [A] [A]₁ [A]₂ [A]₃) castΠΠ!%ₙ = consistency isIdΠΠ!% [A]₂ -- possible cases proven by induction noNe consistency (⊢t ∘ⱼ ⊢t₁) (∘ₙ neT) = noNe consistency ⊢t neT noNe consistency (natrecⱼ x ⊢t ⊢t₁ ⊢t₂) (natrecₙ neT) = noNe consistency ⊢t₂ neT noNe consistency (var x₁ ()) (var x) noNe consistency (Idⱼ [A] [A]₁ [A]₂) (Idₙ neT) = noNe consistency [A] neT noNe consistency (Idⱼ [A] [A]₁ [A]₂) (Idℕₙ neT) = noNe consistency [A]₁ neT noNe consistency (Idⱼ [A] [A]₁ [A]₂) (Idℕ0ₙ neT) = noNe consistency [A]₂ neT noNe consistency (Idⱼ [A] [A]₁ [A]₂) (IdℕSₙ neT) = noNe consistency [A]₂ neT noNe consistency (Idⱼ [A] [A]₁ [A]₂) (IdUₙ neT) = noNe consistency [A]₁ neT noNe consistency (Idⱼ [A] [A]₁ [A]₂) (IdUℕₙ neT) = noNe consistency [A]₂ neT noNe consistency (Idⱼ [A] [A]₁ [A]₂) (IdUΠₙ neT) = noNe consistency [A]₂ neT noNe consistency (castⱼ [A] [A]₁ [A]₂ [A]₃) (castₙ neT) = noNe consistency [A] neT noNe consistency (castⱼ [A] [A]₁ [A]₂ [A]₃) (castℕₙ neT) = noNe consistency [A]₁ neT noNe consistency (castⱼ [A] [A]₁ [A]₂ [A]₃) (castΠₙ neT) = noNe consistency [A]₁ neT noNe consistency (castⱼ [A] [A]₁ [A]₂ [A]₃) (castℕℕₙ neT) = noNe consistency [A]₃ neT noNe consistency (conv ⊢t x) (var n) = noNe consistency ⊢t (var n) noNe consistency (conv ⊢t x) (∘ₙ neT) = noNe consistency ⊢t (∘ₙ neT) noNe consistency (conv ⊢t x) (natrecₙ neT) = noNe consistency ⊢t (natrecₙ neT) noNe consistency (conv ⊢t x) (Idₙ neT) = noNe consistency ⊢t (Idₙ neT) noNe consistency (conv ⊢t x) (Idℕₙ neT) = noNe consistency ⊢t (Idℕₙ neT) noNe consistency (conv ⊢t x) (Idℕ0ₙ neT) = noNe consistency ⊢t (Idℕ0ₙ neT) noNe consistency (conv ⊢t x) (IdℕSₙ neT) = noNe consistency ⊢t (IdℕSₙ neT) noNe consistency (conv ⊢t x) (IdUₙ neT) = noNe consistency ⊢t (IdUₙ neT) noNe consistency (conv ⊢t x) (IdUℕₙ neT) = noNe consistency ⊢t (IdUℕₙ neT) noNe consistency (conv ⊢t x) (IdUΠₙ neT) = noNe consistency ⊢t (IdUΠₙ neT) noNe consistency (conv ⊢t x) (castₙ neT) = noNe consistency ⊢t (castₙ neT) noNe consistency (conv ⊢t x) (castℕₙ neT) = noNe consistency ⊢t (castℕₙ neT) noNe consistency (conv ⊢t x) (castΠₙ neT) = noNe consistency ⊢t (castΠₙ neT) noNe consistency (conv ⊢t x) (castℕℕₙ neT) = noNe consistency ⊢t (castℕℕₙ neT) noNe consistency (conv ⊢t x) castℕΠₙ = noNe consistency ⊢t castℕΠₙ noNe consistency (conv ⊢t x) castΠℕₙ = noNe consistency ⊢t castΠℕₙ noNe consistency (conv ⊢t x) castΠΠ%!ₙ = noNe consistency ⊢t castΠΠ%!ₙ noNe consistency (conv ⊢t x) castΠΠ!%ₙ = noNe consistency ⊢t castΠΠ!%ₙ noNe consistency (conv ⊢t x) Emptyrecₙ = noNe consistency ⊢t Emptyrecₙ -- Helper function for canonicity for reducible natural properties canonicity″ : ∀ {t} → consistency → Natural-prop ε t → ∃ λ k → ε ⊢ t ≡ sucᵏ k ∷ ℕ ^ [ ! , ι ⁰ ] canonicity″ consistency (sucᵣ (ℕₜ n₁ d n≡n prop)) = let a , b = canonicity″ consistency prop in 1+ a , suc-cong (trans (subset*Term (redₜ d)) b) canonicity″ consistency zeroᵣ = 0 , refl (zeroⱼ ε) canonicity″ consistency (ne (neNfₜ neK ⊢k k≡k)) = ⊥-elim (noNe consistency ⊢k neK) -- Helper function for canonicity for specific reducible natural numbers canonicity′ : ∀ {t l} → consistency → ([ℕ] : ε ⊩⟨ l ⟩ℕ ℕ) → ε ⊩⟨ l ⟩ t ∷ ℕ ^ [ ! , ι ⁰ ] / ℕ-intr [ℕ] → ∃ λ k → ε ⊢ t ≡ sucᵏ k ∷ ℕ ^ [ ! , ι ⁰ ] canonicity′ consistency (noemb [ℕ]) (ℕₜ n d n≡n prop) = let a , b = canonicity″ consistency prop in a , trans (subset*Term (redₜ d)) b canonicity′ consistency (emb emb< [ℕ]) [t] = canonicity′ consistency [ℕ] [t] canonicity′ consistency (emb ∞< [ℕ]) [t] = canonicity′ consistency [ℕ] [t] -- Canonicity of natural numbers canonicity : ∀ {t} → consistency → ε ⊢ t ∷ ℕ ^ [ ! , ι ⁰ ] → ∃ λ k → ε ⊢ t ≡ sucᵏ k ∷ ℕ ^ [ ! , ι ⁰ ] canonicity consistency ⊢t with reducibleTerm ⊢t canonicity consistency ⊢t | [ℕ] , [t] = canonicity′ consistency (ℕ-elim [ℕ]) (irrelevanceTerm [ℕ] (ℕ-intr (ℕ-elim [ℕ])) [t])
{ "alphanum_fraction": 0.6488783141, "avg_line_length": 49.4453781513, "ext": "agda", "hexsha": "2c50f32f42156781b4be9a3c743621713b4310b4", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/Typed/Consequences/Canonicity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "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": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/Typed/Consequences/Canonicity.agda", "max_line_length": 108, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/Typed/Consequences/Canonicity.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z", "max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z", "num_tokens": 2537, "size": 5884 }
{-# OPTIONS --cubical --safe #-} module Data.Binary.PerformanceTests.Addition where open import Prelude open import Data.Binary.Definition open import Data.Binary.Addition using (_+_) sum-r : 𝔹 → ℕ → 𝔹 sum-r′ : 𝔹 → ℕ → 𝔹 sum-r′ x zero = x sum-r′ x (suc n) = x + sum-r (2ᵇ x) n sum-r x zero = x sum-r x (suc n) = x + sum-r′ (1ᵇ x) n sum-l : 𝔹 → ℕ → 𝔹 sum-l′ : 𝔹 → ℕ → 𝔹 sum-l′ x zero = x sum-l′ x (suc n) = sum-l (2ᵇ x) n + x sum-l x zero = x sum-l x (suc n) = sum-l′ (1ᵇ x) n + x one-thousand : 𝔹 one-thousand = 2ᵇ 1ᵇ 1ᵇ 2ᵇ 1ᵇ 2ᵇ 2ᵇ 2ᵇ 2ᵇ 0ᵇ f : 𝔹 f = one-thousand n : ℕ n = 1000 -- The actual performance test (uncomment and time how long it takes to type-check) -- _ : sum-l one-thousand n ≡ sum-r one-thousand n -- _ = refl
{ "alphanum_fraction": 0.6018641811, "avg_line_length": 19.2564102564, "ext": "agda", "hexsha": "57fcbe3f103e275f9ee8be49c174fd3aba8becb6", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Data/Binary/PerformanceTests/Addition.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Data/Binary/PerformanceTests/Addition.agda", "max_line_length": 83, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Data/Binary/PerformanceTests/Addition.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": 346, "size": 751 }
module Issue2469 where open import Agda.Builtin.Nat open import Agda.Builtin.Unit open import Agda.Builtin.IO renaming (IO to BIO) open import Agda.Builtin.String open import Agda.Builtin.IO open import Common.IO open import Common.Prelude open import Common.Sum open import Common.Product data F : Nat → Set where [] : F zero _∷1 : ∀ {n} → F n → F (suc n) _∷2 : ∀ {n} → F n → F (suc (suc n)) f : ∀ k → F (suc k) → F k ⊎ Maybe ⊥ f zero a = inj₂ nothing f k (xs ∷1) = inj₂ nothing -- to (suc k) xs = inj₂ nothing -- This is fine f (suc k) = λ xs → inj₂ nothing -- This segfaults myshow : F 1 ⊎ Maybe ⊥ → String -- myshow (inj₁ b) = "" -- This is fine myshow (inj₁ (b ∷1)) = "bla" -- This segfaults myshow _ = "blub" main : IO ⊤ main = putStrLn (myshow (f 1 ([] ∷2)))
{ "alphanum_fraction": 0.6279949559, "avg_line_length": 24.78125, "ext": "agda", "hexsha": "1bd3eeda7decb54c99cbbd619e4ec44aa961abc4", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Compiler/simple/Issue2469.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Compiler/simple/Issue2469.agda", "max_line_length": 51, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Compiler/simple/Issue2469.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": 293, "size": 793 }
{-# OPTIONS --type-in-type #-} -- enables cheating -- 2:10 : why -- https://www.youtube.com/watch?v=2LxtHeZlaVw module HC-Lec3 where open import HC-Lec1 open import HC-Lec2 postulate -- equal inputs go to equal outputs -- (whereas structural equality would require equal implementations) extensionality : {S : Set} {T : S -> Set} -- 24:00 : make f and g implicit : https://www.youtube.com/watch?v=RCRddhYegzI -> {f g : (x : S) -> T x} -> ((x : S) -> f x == g x) -> f == g -- 2:45 record Category : Set where field -- things Obj : Set _~>_ : Obj -> Obj -> Set -- operations id~> : {T : Obj} -> T ~> T _>~>_ : {R S T : Obj} -> R ~> S -> S ~> T -> R ~> T -- laws law-id~>>~> : {S T : Obj} -> (f : S ~> T) -> (id~> >~> f) == f law->~>id~> : {S T : Obj} -> (f : S ~> T) -> (f >~> id~>) == f law->~>>~> : {Q R S T : Obj} -> (f : Q ~> R) -> (g : R ~> S) -> (h : S ~> T) -> ((f >~> g) >~> h) == (f >~> (g >~> h)) -- 7:50 SET : Category SET = record { Obj = Set ; _~>_ = λ S T -> S -> T ; id~> = id ; _>~>_ = _>>_ ; law-id~>>~> = refl ; law->~>id~> = refl ; law->~>>~> = λ f g h → refl (λ x → h (g (f x))) } -- 11:50 -- A PREORDER is a category where there is at most one arrow between any two objects. -- Therefore arrows are unique. -- all proofs of '>=' are equivalent unique->= : (m n : Nat) (p q : m >= n) -> p == q unique->= m zero p q = refl <> unique->= (suc m) (suc n) p q = unique->= m n p q NAT->= : Category NAT->= = record { Obj = Nat ; _~>_ = _>=_ ; id~> = λ {n : Nat} → refl->= n ; _>~>_ = λ {r s t : Nat} r>=s s>=t → trans->= r s t r>=s s>=t ; law-id~>>~> = λ {m n : Nat} f → unique->= m n (trans->= m m n (refl->= m) f) f ; law->~>id~> = λ {m n : Nat} f → unique->= m n (trans->= m n n f (refl->= n)) f ; law->~>>~> = λ {q r s t : Nat} q>=r r>=s s>=t → unique->= q t (trans->= q s t (trans->= q r s q>=r r>=s) s>=t) (trans->= q r t q>=r (trans->= r s t r>=s s>=t)) } -- 22:07 -- A MONOID is a category with Obj = One. -- The values in the monoid are the *arrows*. -- Only one object, so arrows are the ways to get from Nat to Nat. ONE-Nat : Category ONE-Nat = record { Obj = One ; _~>_ = λ _ _ -> Nat ; id~> = zero ; _>~>_ = _+N_ ; law-id~>>~> = refl ; law->~>id~> = +N-zero ; law->~>>~> = assocLR-+N } -- 26:05 -- Note : this is controversial : because this notion of equality is structural. -- But equality could be defined by isomorphism instead. -- - In this case, there could be multiple ways for something to be equal to itself. -- - equality on Bool : True to True and False to False -- or True to False and False to True -- structural equality is unique eqUnique : {X : Set} {x y : X} -> (p q : x == y) -> p == q eqUnique (refl x) (refl _) = refl (refl x) eqUnique' : {X : Set} {x y : X} -> (p q : x == y) -> p == q eqUnique' {_} {_} {y} p q rewrite q | p = refl (refl y) DISCRETE : (X : Set) -> Category DISCRETE X = record { Obj = X ; _~>_ = _==_ ; id~> = λ {x} -> refl x ; _>~>_ = λ {(refl x) (refl .x) → refl x} ; law-id~>>~> = λ f → eqUnique _ f ; law->~>id~> = λ f → eqUnique _ f ; law->~>>~> = λ f g h → eqUnique _ _ } -- 40:50 module FUNCTOR where open Category record _=>_ (C D : Category) : Set where -- functor from C to D field -- operations F-Obj : Obj C -> Obj D F-map : {S T : Obj C} -> _~>_ C S T -> _~>_ D (F-Obj S) (F-Obj T) -- laws F-map-id~> : {T : Obj C} -> F-map (id~> C {T}) == id~> D {F-Obj T} F-map->~> : {R S T : Obj C} (f : _~>_ C R S) (g : _~>_ C S T) -> F-map (_>~>_ C f g) == _>~>_ D (F-map f) (F-map g) open FUNCTOR -- https://www.youtube.com/watch?v=RCRddhYegzI -- 4:10 vMap : {n : Nat} {S T : Set} -> (S -> T) -> Vec S n -> Vec T n vMap f [] = [] vMap f (x :: xs) = f x :: vMap f xs vMap-id : {n : Nat} {X : Set} (xs : Vec X n) -> vMap id xs == id xs vMap-id [] = refl [] vMap-id (x :: xs) rewrite vMap-id xs = refl (x :: xs) vMapCp : {n : Nat} {R S T : Set} {r->s : R -> S} {s->t : S -> T} -> (xs : Vec R n) -> vMap (r->s >> s->t) xs == vMap s->t (vMap r->s xs) vMapCp [] = refl [] vMapCp {r->s = r->s} {s->t = s->t} (r :: rs) with vMapCp {r->s = r->s} {s->t = s->t} rs ...| xxx rewrite xxx = refl (s->t (r->s r) :: vMap s->t (vMap r->s rs)) -- vector as a functor VEC : Nat -> SET => SET VEC n = record { F-Obj = λ X -> Vec X n ; F-map = vMap ; F-map-id~> = extensionality vMap-id ; F-map->~> = λ {R S T : Set} (r->s : R → S) (s->t : S → T) → extensionality vMapCp } -- 15:20 vTakeCp : {X : Set} {m n p : Nat} -> (m>=n : m >= n) -> (n>=p : n >= p) -> (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) vTakeCp {_} {m} {n} {zero} m>=n n>=p _ = refl [] vTakeCp {_} {suc m} {suc n} {suc p} m>=n n>=p (x :: xs) rewrite vTakeCp {_} {m} {n} {p} m>=n n>=p xs = refl (x :: vTake n p n>=p (vTake m n m>=n xs)) -- another way to think of vector as a functor VTAKE : Set -> NAT->= => SET VTAKE X = record { F-Obj = Vec X -- something that turns a number into a SET ; F-map = λ {m} {n} m>=n xs -> vTake m n m>=n xs ; F-map-id~> = extensionality (vTakeIdFact _) ; F-map->~> = λ r>=s s>=t → extensionality (vTakeCp r>=s s>=t) } -- 24:53 ADD : Nat -> NAT->= => NAT->= ADD d = record { F-Obj = (d +N_) -- function that adds d to another number ; F-map = λ {s} {t} -> f-map' d s t -- two proofs of >= are equal to each other ; F-map-id~> = λ {T : Nat} -> unique->= (d +N T) (d +N T) (f-map' d T T (refl->= T)) (refl->= (d +N T)) ; F-map->~> = λ {R} {S} {T}f g → unique->= (d +N R) (d +N T) (f-map' d R T (trans->= R S T f g)) (trans->= (d +N R) (d +N S) (d +N T) (f-map' d R S f) (f-map' d S T g)) } where f-map' : ∀ d s t → (NAT->= Category.~> s) t → (NAT->= Category.~> (d +N s)) (d +N t) f-map' zero s t s>=t = s>=t f-map' (suc d) s t s>=t = f-map' d s t s>=t -- 41:00 CATEGORY : Category CATEGORY = record { Obj = Category ; _~>_ = _=>_ ; id~> = λ {T} -> record { F-Obj = id ; F-map = id ; F-map-id~> = refl (Category.id~> T) ; F-map->~> = λ f g → refl ((T Category.>~> f) g) } ; _>~>_ = λ r=>s s=>t → record { F-Obj = F-Obj r=>s >> F-Obj s=>t ; F-map = F-map r=>s >> F-map s=>t ; F-map-id~> = {!!} ; F-map->~> = λ f g → {!!} } ; law-id~>>~> = {!!} ; law->~>id~> = {!!} ; law->~>>~> = {!!} } where open _=>_ -- 45:35 -- Category where Obj are FUNCTORS
{ "alphanum_fraction": 0.3687315634, "avg_line_length": 34.8765432099, "ext": "agda", "hexsha": "fa099dcf6133e2ac5aeab17ce35a6dfe33bee938", "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-Lec3.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-Lec3.agda", "max_line_length": 94, "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-Lec3.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": 2836, "size": 8475 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Prelude open import LibraBFT.Lemmas open import LibraBFT.Base.ByteString open import LibraBFT.Base.Encode open import LibraBFT.Base.KVMap open import LibraBFT.Base.PKCS open import LibraBFT.Hash open import LibraBFT.Impl.Base.Types open import LibraBFT.Impl.Consensus.Types open import LibraBFT.Impl.Util.Util -- This module provides some scaffolding to define the handlers for our fake/simple -- "implementation" and connect them to the interface of the SystemModel. module LibraBFT.Impl.Handle (hash : BitString → Hash) (hash-cr : ∀{x y} → hash x ≡ hash y → Collision hash x y ⊎ x ≡ y) where open import LibraBFT.Impl.Consensus.ChainedBFT.EventProcessor hash hash-cr open RWST-do -- This represents an uninitialised EventProcessor, about which we know nothing, which we use as -- the initial EventProcessor for every peer until it is initialised. postulate fakeEP : EventProcessor -- Eventually, the initialization should establish some properties we care about, but for now we -- just initialise again to fakeEP, which means we cannot prove the base case for various -- properties, e.g., in Impl.Properties.VotesOnce initialEventProcessorAndMessages : (a : Author) → EpochConfig → EventProcessor → EventProcessor × List NetworkMsg initialEventProcessorAndMessages a _ _ = fakeEP , [] handle : NodeId → NetworkMsg → Instant → LBFT Unit handle _self msg now with msg ...| P p = processProposalMsg now p ...| V v = processVote now v ...| C c = return unit -- We don't do anything with commit messages, they are just for defining Correctness. -- For now, the SystemModel supports only one kind of action: to send a Message. Later it might -- include things like logging, crashes, assertion failures, etc. At that point, definitions like -- the following might become part of the SystemModel, but they are included here to enable the -- temporary scaffolding below. data Action (Msg : Set) : Set where send : Msg → Action Msg action-send-injective : ∀ {Msg}{m m' : Msg} → send m ≡ send m' → m ≡ m' action-send-injective refl = refl msgToSend : {Msg : Set} → Action Msg → Msg msgToSend (send m) = m msgToSend≡ : ∀ {Msg x}{m : Msg} → m ≡ msgToSend x → send m ≡ x msgToSend≡ {_} {send m} {m} refl = refl -- Note: the SystemModel allows anyone to receive any message sent, so intended recipient is ignored; -- it is included in the model only to facilitate future work on liveness properties, when we will need -- assumptions about message delivery between honest peers. outputToActions : EventProcessor → Output → List (Action NetworkMsg) outputToActions ep (BroadcastProposal p) = List-map (const (Action.send (P p))) (List-map proj₁ (kvm-toList (:vvAddressToValidatorInfo (₋epValidators (₋epEC ep))))) outputToActions _ (LogErr x) = [] outputToActions _ (SendVote v toList) = List-map (const (Action.send (V v))) toList outputsToActions : ∀ {State} → List Output → List (Action NetworkMsg) outputsToActions {st} = concat ∘ List-map (outputToActions st) runHandler : EventProcessor → LBFT Unit → EventProcessor × List (Action NetworkMsg) runHandler st handler = ×-map₂ (outputsToActions {st}) (proj₂ (LBFT-run handler st)) -- And ultimately, the all-knowing system layer only cares about the -- step function. peerStep : NodeId → NetworkMsg → Instant → EventProcessor → EventProcessor × List (Action NetworkMsg) peerStep nid msg ts st = runHandler st (handle nid msg ts) -- This (temporary) wrapper bridges the gap between our (draft) concrete handler and -- the form required by the new system model, which does not (yet) support actions other -- than send. peerStepWrapper : NodeId → NetworkMsg → EventProcessor → EventProcessor × List NetworkMsg peerStepWrapper nid msg st = ×-map₂ (List-map msgToSend) (peerStep nid msg 0 st)
{ "alphanum_fraction": 0.7179002128, "avg_line_length": 46.9888888889, "ext": "agda", "hexsha": "0c46acddf18b2f39ff2d1518aaabe6aacc133613", "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": "34e4627855fb198665d0c98f377403a906ba75d7", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "haroldcarr/bft-consensus-agda", "max_forks_repo_path": "LibraBFT/Impl/Handle.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "34e4627855fb198665d0c98f377403a906ba75d7", "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": "haroldcarr/bft-consensus-agda", "max_issues_repo_path": "LibraBFT/Impl/Handle.agda", "max_line_length": 131, "max_stars_count": null, "max_stars_repo_head_hexsha": "34e4627855fb198665d0c98f377403a906ba75d7", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "haroldcarr/bft-consensus-agda", "max_stars_repo_path": "LibraBFT/Impl/Handle.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1062, "size": 4229 }
data ⊤ : Set where tt : ⊤ f : ⊤ → ⊤ f tt = tt foo : ⊤ → ⊤ foo t with f t ... | x with f t ... | y with f t ... | z = {!z!}
{ "alphanum_fraction": 0.3858267717, "avg_line_length": 10.5833333333, "ext": "agda", "hexsha": "bc3f7dee65cd7f9267b7239244ce712f753d6135", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/interaction/Issue5633.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/interaction/Issue5633.agda", "max_line_length": 18, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/interaction/Issue5633.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": 62, "size": 127 }
module InequalityReasoningExercise where open import EqualityAux infix 4 _≤_ data _≤_ : ℕ → ℕ → Set where z≤n : ∀ {n : ℕ} -------- → zero ≤ n s≤s : ∀ {m n : ℕ} → m ≤ n ------------- → suc m ≤ suc n ≤-refl : ∀ {n : ℕ} ----- → n ≤ n ≤-refl {zero} = z≤n ≤-refl {suc n} = s≤s ≤-refl ≤-trans : ∀ {m n p : ℕ} → m ≤ n → n ≤ p ----- → m ≤ p ≤-trans z≤n _ = z≤n ≤-trans (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans m≤n n≤p) module ≤-Reasoning where infix 1 ≤-begin_ infixr 2 _≤⟨⟩_ _≤⟨_⟩_ _≤-≡⟨_⟩_ infix 3 _≤-∎ ≤-begin_ : ∀ {x y : ℕ} → x ≤ y ----- → x ≤ y ≤-begin x≤y = x≤y _≤⟨⟩_ : ∀ (x : ℕ) {y : ℕ} → x ≤ y ----- → x ≤ y x ≤⟨⟩ x≤y = x≤y _≤⟨_⟩_ : ∀ (x : ℕ) {y z : ℕ} → x ≤ y → y ≤ z ----- → x ≤ z x ≤⟨ x≤y ⟩ y≤z = ≤-trans x≤y y≤z _≤-≡⟨_⟩_ : ∀ (x : ℕ) {y z : ℕ} → x ≡ y → y ≤ z ----- → x ≤ z x ≤-≡⟨ refl ⟩ y≤z = ≤-trans ≤-refl y≤z _≤-∎ : ∀ (x : ℕ) ----- → x ≤ x x ≤-∎ = ≤-refl open ≤-Reasoning +-monoʳ-≤ : ∀ (n p q : ℕ) → p ≤ q ------------- → n + p ≤ n + q +-monoʳ-≤ zero p q p≤q = ≤-begin zero + p ≤⟨⟩ p ≤⟨ p≤q ⟩ q ≤⟨⟩ zero + q ≤-∎ +-monoʳ-≤ (suc n) p q p≤q = ≤-begin (suc n) + p ≤⟨⟩ suc (n + p) ≤⟨ s≤s (+-monoʳ-≤ n p q p≤q) ⟩ suc (n + q) ≤⟨⟩ (suc n) + q ≤-∎ +-monoˡ-≤ : ∀ (m n p : ℕ) → m ≤ n ------------- → m + p ≤ n + p +-monoˡ-≤ m n p m≤n = ≤-begin m + p ≤-≡⟨ +-comm m p ⟩ p + m ≤⟨ +-monoʳ-≤ p m n m≤n ⟩ p + n ≤-≡⟨ +-comm p n ⟩ n + p ≤-∎ +-mono-≤ : ∀ (m n p q : ℕ) → m ≤ n → p ≤ q ------------- → m + p ≤ n + q +-mono-≤ m n p q m≤n p≤q = ≤-begin m + p ≤⟨ +-monoˡ-≤ m n p m≤n ⟩ n + p ≤⟨ +-monoʳ-≤ n p q p≤q ⟩ n + q ≤-∎
{ "alphanum_fraction": 0.320066335, "avg_line_length": 14.2440944882, "ext": "agda", "hexsha": "f11e62291cbeb2f22c0272e648fa915f263de5c6", "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": "75bef9bb35643160e2d2ab4221a3057f22eb3324", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "abolotina/plfa.github.io", "max_forks_repo_path": "src/plfa/part1/InequalityReasoningExercise.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "75bef9bb35643160e2d2ab4221a3057f22eb3324", "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": "abolotina/plfa.github.io", "max_issues_repo_path": "src/plfa/part1/InequalityReasoningExercise.agda", "max_line_length": 51, "max_stars_count": null, "max_stars_repo_head_hexsha": "75bef9bb35643160e2d2ab4221a3057f22eb3324", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "abolotina/plfa.github.io", "max_stars_repo_path": "src/plfa/part1/InequalityReasoningExercise.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1023, "size": 1809 }
------------------------------------------------------------------------------ -- Terminating mirror function ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Program.Mirror.MirrorListTerminatingSL where open import Data.List ------------------------------------------------------------------------------ -- The rose tree type. data Tree (A : Set) : Set where tree : A → List (Tree A) → Tree A ------------------------------------------------------------------------------ -- An alternative and terminating definition of mirror. Adapted from -- http://stackoverflow.com/questions/9146928/termination-of-structural-induction -- The mirror function. mirror : {A : Set} → Tree A → Tree A mirrorBranch : {A : Set} → List (Tree A) → List (Tree A) mirror (tree a ts) = tree a (reverse (mirrorBranch ts)) mirrorBranch [] = [] mirrorBranch (t ∷ ts) = mirror t ∷ mirrorBranch ts
{ "alphanum_fraction": 0.4576271186, "avg_line_length": 37.3666666667, "ext": "agda", "hexsha": "65073adbf7abbff98760e25ac743949cdde05ef4", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Program/Mirror/MirrorListTerminatingSL.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Program/Mirror/MirrorListTerminatingSL.agda", "max_line_length": 81, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Program/Mirror/MirrorListTerminatingSL.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": 211, "size": 1121 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Application {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Weakening using (id) open import Definition.Typed.Properties open import Definition.Typed.RedSteps open import Definition.LogicalRelation open import Definition.LogicalRelation.ShapeView open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.Properties open import Tools.Embedding open import Tools.Product import Tools.PropositionalEquality as PE -- Helper function for application of specific type derivations. -- unsightly code duplication because of my hack for shapeview -- can't be bothered to fix for now... appTerm′ : ∀ {F G t u Γ l l′ l″} ([F] : Γ ⊩⟨ l″ ⟩ F) ([G[u]] : Γ ⊩⟨ l′ ⟩ G [ u ]) ([ΠFG] : Γ ⊩⟨ l ⟩Π Π F ▹ G) ([t] : Γ ⊩⟨ l ⟩ t ∷ Π F ▹ G / Π-intr [ΠFG]) ([u] : Γ ⊩⟨ l″ ⟩ u ∷ F / [F]) → Γ ⊩⟨ l′ ⟩ t ∘ u ∷ G [ u ] / [G[u]] appTerm′ {t = t} {Γ = Γ} [F] [G[u]] (noemb (Πᵣ F G D ⊢F ⊢G A≡A [F′] [G′] G-ext)) (Πₜ f d funcF f≡f [f] [f]₁) [u] = let ΠFG≡ΠF′G′ = whnfRed* (red D) Πₙ F≡F′ , G≡G′ = Π-PE-injectivity ΠFG≡ΠF′G′ F≡idF′ = PE.trans F≡F′ (PE.sym (wk-id _)) idG′ᵤ≡Gᵤ = PE.cong (λ x → x [ _ ]) (PE.trans (wk-lift-id _) (PE.sym G≡G′)) idf∘u≡f∘u = (PE.cong (λ x → x ∘ _) (wk-id _)) ⊢Γ = wf ⊢F [u]′ = irrelevanceTerm′ F≡idF′ [F] ([F′] id ⊢Γ) [u] [f∘u] = irrelevanceTerm″ idG′ᵤ≡Gᵤ idf∘u≡f∘u ([G′] id ⊢Γ [u]′) [G[u]] ([f]₁ id ⊢Γ [u]′) ⊢u = escapeTerm [F] [u] d′ = PE.subst (λ x → Γ ⊢ t ⇒* f ∷ x) (PE.sym ΠFG≡ΠF′G′) (redₜ d) in proj₁ (redSubst*Term (app-subst* d′ ⊢u) [G[u]] [f∘u]) appTerm′ [F] [G[u]] (emb 0<1 x) (ιx [t]) [u] = appTerm′ [F] [G[u]] x [t] [u] -- Application of reducible terms. appTerm : ∀ {F G t u Γ l l′ l″} ([F] : Γ ⊩⟨ l″ ⟩ F) ([G[u]] : Γ ⊩⟨ l′ ⟩ G [ u ]) ([ΠFG] : Γ ⊩⟨ l ⟩ Π F ▹ G) ([t] : Γ ⊩⟨ l ⟩ t ∷ Π F ▹ G / [ΠFG]) ([u] : Γ ⊩⟨ l″ ⟩ u ∷ F / [F]) → Γ ⊩⟨ l′ ⟩ t ∘ u ∷ G [ u ] / [G[u]] appTerm [F] [G[u]] [ΠFG] [t] [u] = let [t]′ = irrelevanceTerm [ΠFG] (Π-intr (Π-elim [ΠFG])) [t] in appTerm′ [F] [G[u]] (Π-elim [ΠFG]) [t]′ [u] -- Helper function for application congurence of specific type derivations. app-congTerm′ : ∀ {F G t t′ u u′ Γ l l′} ([F] : Γ ⊩⟨ l′ ⟩ F) ([G[u]] : Γ ⊩⟨ l′ ⟩ G [ u ]) ([ΠFG] : Γ ⊩⟨ l ⟩Π Π F ▹ G) ([t≡t′] : Γ ⊩⟨ l ⟩ t ≡ t′ ∷ Π F ▹ G / Π-intr [ΠFG]) ([u] : Γ ⊩⟨ l′ ⟩ u ∷ F / [F]) ([u′] : Γ ⊩⟨ l′ ⟩ u′ ∷ F / [F]) ([u≡u′] : Γ ⊩⟨ l′ ⟩ u ≡ u′ ∷ F / [F]) → Γ ⊩⟨ l′ ⟩ t ∘ u ≡ t′ ∘ u′ ∷ G [ u ] / [G[u]] app-congTerm′ {F′} {G′} {t = t} {t′ = t′} {Γ = Γ} [F] [G[u]] (noemb (Πᵣ F G D ⊢F ⊢G A≡A [F]₁ [G] G-ext)) (Πₜ₌ f g [ ⊢t , ⊢f , d ] [ ⊢t′ , ⊢g , d′ ] funcF funcG t≡u (Πₜ f′ [ _ , ⊢f′ , d″ ] funcF′ f≡f [f] [f]₁) (Πₜ g′ [ _ , ⊢g′ , d‴ ] funcG′ g≡g [g] [g]₁) [t≡u]) [a] [a′] [a≡a′] = let [ΠFG] = Πᵣ′ F G D ⊢F ⊢G A≡A [F]₁ [G] G-ext ΠFG≡ΠF′G′ = whnfRed* (red D) Πₙ F≡F′ , G≡G′ = Π-PE-injectivity ΠFG≡ΠF′G′ f≡f′ = whrDet*Term (d , functionWhnf funcF) (d″ , functionWhnf funcF′) g≡g′ = whrDet*Term (d′ , functionWhnf funcG) (d‴ , functionWhnf funcG′) F≡wkidF′ = PE.trans F≡F′ (PE.sym (wk-id _)) t∘x≡wkidt∘x : {a b : Term} → wk id a ∘ b PE.≡ a ∘ b t∘x≡wkidt∘x {a} {b} = PE.cong (λ x → x ∘ b) (wk-id a) t∘x≡wkidt∘x′ : {a : Term} → wk id g′ ∘ a PE.≡ g ∘ a t∘x≡wkidt∘x′ {a} = PE.cong (λ x → x ∘ a) (PE.trans (wk-id _) (PE.sym g≡g′)) wkidG₁[u]≡G[u] = PE.cong (λ x → x [ _ ]) (PE.trans (wk-lift-id _) (PE.sym G≡G′)) wkidG₁[u′]≡G[u′] = PE.cong (λ x → x [ _ ]) (PE.trans (wk-lift-id _) (PE.sym G≡G′)) ⊢Γ = wf ⊢F [u]′ = irrelevanceTerm′ F≡wkidF′ [F] ([F]₁ id ⊢Γ) [a] [u′]′ = irrelevanceTerm′ F≡wkidF′ [F] ([F]₁ id ⊢Γ) [a′] [u≡u′]′ = irrelevanceEqTerm′ F≡wkidF′ [F] ([F]₁ id ⊢Γ) [a≡a′] [G[u′]] = irrelevance′ wkidG₁[u′]≡G[u′] ([G] id ⊢Γ [u′]′) [G[u≡u′]] = irrelevanceEq″ wkidG₁[u]≡G[u] wkidG₁[u′]≡G[u′] ([G] id ⊢Γ [u]′) [G[u]] (G-ext id ⊢Γ [u]′ [u′]′ [u≡u′]′) [f′] : Γ ⊩⟨ _ ⟩ f′ ∷ Π F′ ▹ G′ / [ΠFG] [f′] = Πₜ f′ (idRedTerm:*: ⊢f′) funcF′ f≡f [f] [f]₁ [g′] : Γ ⊩⟨ _ ⟩ g′ ∷ Π F′ ▹ G′ / [ΠFG] [g′] = Πₜ g′ (idRedTerm:*: ⊢g′) funcG′ g≡g [g] [g]₁ [f∘u] = appTerm [F] [G[u]] [ΠFG] (irrelevanceTerm″ PE.refl (PE.sym f≡f′) [ΠFG] [ΠFG] [f′]) [a] [g∘u′] = appTerm [F] [G[u′]] [ΠFG] (irrelevanceTerm″ PE.refl (PE.sym g≡g′) [ΠFG] [ΠFG] [g′]) [a′] [tu≡t′u] = irrelevanceEqTerm″ t∘x≡wkidt∘x t∘x≡wkidt∘x wkidG₁[u]≡G[u] ([G] id ⊢Γ [u]′) [G[u]] ([t≡u] id ⊢Γ [u]′) [t′u≡t′u′] = irrelevanceEqTerm″ t∘x≡wkidt∘x′ t∘x≡wkidt∘x′ wkidG₁[u]≡G[u] ([G] id ⊢Γ [u]′) [G[u]] ([g] id ⊢Γ [u]′ [u′]′ [u≡u′]′) d₁ = PE.subst (λ x → Γ ⊢ t ⇒* f ∷ x) (PE.sym ΠFG≡ΠF′G′) d d₂ = PE.subst (λ x → Γ ⊢ t′ ⇒* g ∷ x) (PE.sym ΠFG≡ΠF′G′) d′ [tu≡fu] = proj₂ (redSubst*Term (app-subst* d₁ (escapeTerm [F] [a])) [G[u]] [f∘u]) [gu′≡t′u′] = convEqTerm₂ [G[u]] [G[u′]] [G[u≡u′]] (symEqTerm [G[u′]] (proj₂ (redSubst*Term (app-subst* d₂ (escapeTerm [F] [a′])) [G[u′]] [g∘u′]))) in transEqTerm [G[u]] (transEqTerm [G[u]] [tu≡fu] [tu≡t′u]) (transEqTerm [G[u]] [t′u≡t′u′] [gu′≡t′u′]) app-congTerm′ [F] [G[u]] (emb 0<1 x) (ιx [t≡t′]) [u] [u′] [u≡u′] = app-congTerm′ [F] [G[u]] x [t≡t′] [u] [u′] [u≡u′] -- Application congurence of reducible terms. app-congTerm : ∀ {F G t t′ u u′ Γ l l′} ([F] : Γ ⊩⟨ l′ ⟩ F) ([G[u]] : Γ ⊩⟨ l′ ⟩ G [ u ]) ([ΠFG] : Γ ⊩⟨ l ⟩ Π F ▹ G) ([t≡t′] : Γ ⊩⟨ l ⟩ t ≡ t′ ∷ Π F ▹ G / [ΠFG]) ([u] : Γ ⊩⟨ l′ ⟩ u ∷ F / [F]) ([u′] : Γ ⊩⟨ l′ ⟩ u′ ∷ F / [F]) ([u≡u′] : Γ ⊩⟨ l′ ⟩ u ≡ u′ ∷ F / [F]) → Γ ⊩⟨ l′ ⟩ t ∘ u ≡ t′ ∘ u′ ∷ G [ u ] / [G[u]] app-congTerm [F] [G[u]] [ΠFG] [t≡t′] = let [t≡t′]′ = irrelevanceEqTerm [ΠFG] (Π-intr (Π-elim [ΠFG])) [t≡t′] in app-congTerm′ [F] [G[u]] (Π-elim [ΠFG]) [t≡t′]′
{ "alphanum_fraction": 0.4220817407, "avg_line_length": 47.9014084507, "ext": "agda", "hexsha": "e836e4e8dda3c8f4bd704993a8c43bf2d779fa42", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "loic-p/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Application.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "loic-p/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Application.agda", "max_line_length": 82, "max_stars_count": null, "max_stars_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "loic-p/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Application.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3293, "size": 6802 }
{- 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.Base.Types open import LibraBFT.Concrete.System.Parameters open import LibraBFT.Impl.Consensus.BlockStorage.BlockStore import LibraBFT.Impl.Consensus.BlockStorage.BlockTree as BlockTree open import LibraBFT.Impl.Consensus.ConsensusTypes.Vote as Vote import LibraBFT.Impl.Consensus.PersistentLivenessStorage as PersistentLivenessStorage open import LibraBFT.Impl.OBM.Rust.RustTypes open import LibraBFT.Impl.Properties.Util open import LibraBFT.ImplShared.Base.Types open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.Consensus.Types.EpochDep open import LibraBFT.ImplShared.Interface.Output open import LibraBFT.ImplShared.Util.Crypto open import LibraBFT.ImplShared.Util.Dijkstra.All open import Optics.All open import Util.ByteString open import Util.Hash open import Util.KVMap as Map open import Util.PKCS open import Util.Prelude open import Yasm.System ℓ-RoundManager ℓ-VSFP ConcSysParms open Invariants open RoundManagerTransProps open QCProps module LibraBFT.Impl.Consensus.BlockStorage.Properties.BlockStore where module new (storage : PersistentLivenessStorage) (initialData : RecoveryData) (stateComp : StateComputer) (maxPrunedBlocksInMem : Usize) where -- TODO-2: May require refinement (additional requirements and/or properties, particularly regarding ECinfo) Contract : ECinfo → EitherD-Post ErrLog BlockStore Contract _ (Left _) = ⊤ Contract eci (Right bs) = BlockStoreInv (bs , eci) postulate contract : ∀ {eci} → Contract eci (new-e-abs storage initialData stateComp maxPrunedBlocksInMem) module executeBlockESpec (bs : BlockStore) (block : Block) where Ok : Set Ok = ∃[ eb ] (executeBlockE bs block ≡ Right eb) record ContractOk (eb : ExecutedBlock) : Set where constructor mkContractOk field ebBlock≡ : block ≡ eb ^∙ ebBlock postulate -- TODO: prove contract : (isOk : Ok) → ContractOk (proj₁ isOk) module executeAndInsertBlockESpec (bs0 : BlockStore) (vblock : ValidBlock) where block = vbBlock vblock block-c = vbValid vblock open executeAndInsertBlockE bs0 block open import LibraBFT.Impl.Consensus.BlockStorage.Properties.BlockTree blockId = block ^∙ bId ------ These are used only outside this module. Ok : Set Ok = ∃₂ λ bs' eb → executeAndInsertBlockE bs0 block ≡ Right (bs' , eb) open Reqs block (bs0 ^∙ bsInner) record ContractOk (bs' : BlockStore) (eb : ExecutedBlock) : Set where constructor mkContractOk field ebBlock≈ : NoHC1 → eb ^∙ ebBlock ≈Block block bsInv : ∀ {eci} → Preserves BlockStoreInv (bs0 , eci) (bs' , eci) -- executeAndInsertBlockE does not modify BlockTree fields other than btIDToBlock bs≡x : bs0 ≡ (bs' & (bsInner ∙ btIdToBlock) ∙~ (bs0 ^∙ bsInner ∙ btIdToBlock)) Contract : EitherD-Post ErrLog (BlockStore × ExecutedBlock) Contract (Left x) = ⊤ Contract (Right (bs' , eb)) = ContractOk bs' eb -- TUTORIAL: This proof has some additional commentary helping to understand the structure of the -- proof, and showing an example of how using abstract variants of functions makes proofs more -- resilient to change, as explained in -- https://github.com/oracle/bft-consensus-agda/blob/main/docs/PeerHandlerContracts.org contract' : EitherD-weakestPre step₀ Contract -- step₀ is a maybeSD in context of EitherD. Therefore, via MonadMaybeD and EitherD-MonadMaybeD, -- this translates to EitherD-maybe. We first deal with the easy case, applying the NoHC1 -- function provided to ebBlock≈ to evidence eb≡ that eb is in btIdToBlock. proj₂ contract' eb eb≡ = mkContractOk (λ nohc → nohc eb≡ block-c) id refl proj₁ contract' getBlock≡nothing = contract₁ where -- step₁ is again a maybeSD; if bs0 ^∙ bsRoot ≡ nothing, the Contract is trivial contract₁ : EitherD-weakestPre step₁ Contract proj₁ contract₁ _ = tt -- otherwise, bs0 ^∙ bsRoot ≡ just bsr, and we have an ifD; in the true branch, step₁ returns a -- Left, so again it is trivial proj₁ (proj₂ contract₁ bsr bsr≡) _ = tt -- in the else branch, we call step₂ bsr proj₂ (proj₂ contract₁ bsr bsr≡) btr<br = contract₂ where contract₃ : ∀ eb → block ≡ (eb ^∙ ebBlock) → EitherD-weakestPre (step₃ eb) Contract module EB = executeBlockESpec bs0 block open EB.ContractOk contract₂ : EitherD-weakestPre (step₂ bsr) Contract proj₂ contract₂ eb eb≡ ._ executeBlockE≡Right@refl = let con = (EB.contract (eb , eb≡)) in contract₃ eb (EB.ContractOk.ebBlock≡ con) proj₁ contract₂ (ErrCBlockNotFound _) executeBlockE≡Left = tt proj₁ contract₂ (ErrVerify _) executeBlockE≡Left = tt proj₁ contract₂ (ErrInfo _) executeBlockE≡Left = tt -- if executeBlockE returns Left (ErrECCBlockNotFound parentBlockId), then we have two casesdue to -- eitherSD (pathFromRoot parentBlockId bs0) LeftD λ blocksToReexecute → -- in the first case, we have a Left, so it's easy proj₁ (proj₁ contract₂ (ErrECCBlockNotFound parentBlockId) executeBlockE≡Left) _ _ = tt -- in the second case, we have -- case⊎D (forM) blocksToReexecute (executeBlockE bs0 ∘ (_^∙ ebBlock)) of λ where -- and therefore two more cases; if the case⊎D returns Left, it's easy again proj₁ (proj₂ (proj₁ contract₂ (ErrECCBlockNotFound parentBlockId) executeBlockE≡Left) blocksToReexecute btr≡) _ _ = tt -- if the case⊎D returns a Right, we call executeBlockE₀ (the EitherD variant). We use executeBlockE≡ to handle case -- analysis on the result of calling the abstract executeBlockE variant, ensuring we must use the contract for -- executeBlockE because the proof cannot "look into" the implementation of executeBlockE, which makes the proof -- more resilient in case of changes in its implementation. -- TODO-2: clean this up by writing a general version of the contract for executeBlockE proj₂ (proj₂ (proj₁ contract₂ (ErrECCBlockNotFound parentBlockId) executeBlockE≡Left) blocksToReexecute btr≡) _ _ with executeBlockE bs0 block | inspect (executeBlockE bs0) block ... | Left x | [ R ] rewrite executeBlockE≡ R = tt ... | Right y | [ R ] rewrite executeBlockE≡ R = λ where c refl ._ refl → let con = EB.contract (c , R) in contract₃ c (ebBlock≡ con) _ refl contract₃ eb refl _ _ = contract₄ where contract₄ : EitherD-weakestPre (step₄ eb) Contract contract₄ with insertBlockESpec.contract eb (bs0 ^∙ bsInner) ...| con with BlockTree.insertBlockE.E eb (bs0 ^∙ bsInner) ...| Left _ = tt ...| Right (bt' , eb') = λ where ._ refl → mkContractOk IBE.blocks≈ btP bss≡x where module IBE = insertBlockESpec.ContractOk con open BlockStoreInv btP : ∀ {eci} → Preserves BlockStoreInv (bs0 , eci) ((bs0 & bsInner ∙~ bt') , eci) btP (mkBlockStoreInv bti) = mkBlockStoreInv (IBE.btiPres bti) bss≡x : bs0 ≡ (bs0 & bsInner ∙~ bt' & bsInner ∙ btIdToBlock ∙~ (bs0 ^∙ (bsInner ∙ btIdToBlock))) bss≡x rewrite sym IBE.bt≡x = refl contract : Contract (executeAndInsertBlockE bs0 block) contract = EitherD-contract (executeAndInsertBlockE.step₀ bs0 block) Contract contract' module executeAndInsertBlockMSpec (vb : ValidBlock) where b = vbBlock vb -- NOTE: This function returns any errors, rather than producing them as output. module _ (pre : RoundManager) where bs = pre ^∙ lBlockStore contract : ∀ Post → (∀ e → {- At the moment we do not need to know why it failed -} Post (Left e) pre []) → ((isOk : executeAndInsertBlockESpec.Ok bs vb) → let (bs' , eb , _) = isOk in executeAndInsertBlockESpec.ContractOk bs vb bs' eb → Post (Right eb) (pre & rmBlockStore ∙~ bs') []) → LBFT-weakestPre (executeAndInsertBlockM b) Post pre proj₁ (contract Post pfBail pfOk ._ refl) e ≡left = pfBail e proj₂ (contract Post pfBail pfOk ._ refl) (bs' , eb) ≡right ._ refl unit refl with executeAndInsertBlockESpec.contract bs vb ...| con rewrite ≡right = pfOk (bs' , eb , refl) con module insertSingleQuorumCertMSpec (qc : QuorumCert) where module _ (pre : RoundManager) where record Contract (r : Either ErrLog Unit) (post : RoundManager) (outs : List Output) : Set where constructor mkContract field -- General invariants / properties rmInv : Preserves RoundManagerInv pre post noEpochChange : NoEpochChange pre post noMsgOuts : OutputProps.NoMsgs outs -- Voting noVote : VoteNotGenerated pre post true -- Signatures qcPost : ∈Post⇒∈PreOr (_≡ qc) pre post postulate -- TODO-2: prove contract' : LBFT-weakestPre (insertSingleQuorumCertM qc) Contract pre contract : ∀ Q → RWS-Post-⇒ Contract Q → LBFT-weakestPre (insertSingleQuorumCertM qc) Q pre contract Q pf = LBFT-⇒ (insertSingleQuorumCertM qc) pre contract' pf module syncInfoMSpec where syncInfo : RoundManager → SyncInfo syncInfo pre = SyncInfo∙new (pre ^∙ lBlockStore ∙ bsHighestQuorumCert) (pre ^∙ lBlockStore ∙ bsHighestCommitCert) (pre ^∙ lBlockStore ∙ bsHighestTimeoutCert) contract : ∀ pre Post → (Post (syncInfo pre) pre []) → LBFT-weakestPre syncInfoM Post pre contract pre Post pf ._ refl ._ refl ._ refl ._ refl ._ refl ._ refl = pf
{ "alphanum_fraction": 0.6720599842, "avg_line_length": 44.8495575221, "ext": "agda", "hexsha": "7348f674adf728b4ee2e736ff8d039f43a4b7904", "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/Impl/Consensus/BlockStorage/Properties/BlockStore.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/Impl/Consensus/BlockStorage/Properties/BlockStore.agda", "max_line_length": 124, "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/Impl/Consensus/BlockStorage/Properties/BlockStore.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2868, "size": 10136 }
open import Data.Product using ( _×_ ; _,_ ; proj₁ ; proj₂ ) open import FRP.LTL.RSet.Core using ( RSet ; ⟦_⟧ ) open import FRP.LTL.RSet.Globally using ( [_] ) open import FRP.LTL.RSet.Causal using ( _⊵_ ; arr ) open import FRP.LTL.RSet.Stateless using ( _⇒_ ) module FRP.LTL.RSet.Product where infixr 2 _∧_ -- Conjunction of LTL formulae _∧_ : RSet → RSet → RSet (A ∧ B) t = A t × B t -- Product structure fst : ∀ {A B} → ⟦ (A ∧ B) ⊵ A ⟧ fst {A} {B} = arr [ (λ {u} (ab : A u × B u) → proj₁ ab) ] snd : ∀ {A B} → ⟦ (A ∧ B) ⊵ B ⟧ snd {A} {B} = arr [ (λ {u} (ab : A u × B u) → proj₂ ab) ] _&&&_ : ∀ {A B C} → ⟦ (A ⊵ B) ⇒ (A ⊵ C) ⇒ (A ⊵ (B ∧ C)) ⟧ (f &&& g) s≤t σ = (f s≤t σ , g s≤t σ)
{ "alphanum_fraction": 0.5282199711, "avg_line_length": 27.64, "ext": "agda", "hexsha": "d896e0ab82f7b6fd5b9ed12c63a27e85b090dbe5", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z", "max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-frp-ltl", "max_forks_repo_path": "src/FRP/LTL/RSet/Product.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-frp-ltl", "max_issues_repo_path": "src/FRP/LTL/RSet/Product.agda", "max_line_length": 60, "max_stars_count": 21, "max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-frp-ltl", "max_stars_repo_path": "src/FRP/LTL/RSet/Product.agda", "max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z", "num_tokens": 319, "size": 691 }
{-# OPTIONS --without-K #-} open import HoTT.Base open import HoTT.Identity.Sigma module HoTT.Pi.Transport where transport-→ : ∀ {i j k} {X : 𝒰 i} (A : X → 𝒰 j) (B : X → 𝒰 k) {x₁ x₂ : X} (p : x₁ == x₂) (f : A x₁ → B x₁) → transport (λ x → A x → B x) p f == transport B p ∘ f ∘ transport A (p ⁻¹) transport-→ A B refl f = refl module _ {i j k} {X : 𝒰 i} (A : X → 𝒰 j) (B : {x : X} → A x → 𝒰 k) {x₁ x₂ : X} (p : x₁ == x₂) (f : Π[ a ∶ A x₁ ] B a) (a : A x₂) where private B̂ : Σ[ x ∶ X ] A x → 𝒰 k B̂ w = B (pr₂ w) transport-Π : transport (λ x → Π[ a ∶ A x ] B a) p f a == transport {x = x₁ , transport _ (p ⁻¹) a} {y = x₂ , a} B̂ (pair⁼ (p ⁻¹ , refl) ⁻¹) (f (transport A (p ⁻¹) a)) transport-Π rewrite p = refl
{ "alphanum_fraction": 0.4593241552, "avg_line_length": 36.3181818182, "ext": "agda", "hexsha": "2a3d921552444f63759389c1c19e1595ad21ec22", "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": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "michaelforney/hott", "max_forks_repo_path": "HoTT/Pi/Transport.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "michaelforney/hott", "max_issues_repo_path": "HoTT/Pi/Transport.agda", "max_line_length": 87, "max_stars_count": null, "max_stars_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "michaelforney/hott", "max_stars_repo_path": "HoTT/Pi/Transport.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 356, "size": 799 }
{-# OPTIONS --no-unicode #-} -- turn off automatic unicode insertion module 02-agda-start where ------------------------------------------------------------------------------------------------------- -- ADDITIONAL RESOURCES | ------------------------- -- допълнителни ресурси: -- https://github.com/pigworker/CS410-17 - курс (има и домашни) с видео лекции, добър лектор -- ^ има още много repo-та които си струват разглеждане -- един от хората измислили Applicative бтв, както и with-abstraction, което ще видим по-късно -- https://plfa.github.io/ - книга с подробни обяснения и описания, има и упражнения, втората част се занимава с имплементиране на ламбда смятане ------------------------------------------------------------------------------------------------------- -- CHEATSHEETS | ---------------- -- SPACEMACS CHEATSHEET: -- <SPC> h <SPC> -- search for help, including agda's help -- <SPC> <TAB> - go to previous buffer -- helpful to go back after looking at help -- <SPC> z x -/= - decrease/increase font size -- normal emacs agda bindings: -- https://agda.readthedocs.io/en/v2.6.1/tools/emacs-mode.html#keybindings -- spacemacs agda layer bindings (but also can open them with <SPC> h <SPC> inside spacemacs): -- https://github.com/syl20bnr/spacemacs/tree/master/layers/%2Blang/agda#key-bindings -- AGDA CHEATSHEET (descending importance): -- <SPC> m l - reload file -- <SPC> m , - (in goal) show context and goal -- <SPC> m . - (in goal) show type of expression in goal. if goal is empty agda will ask for an expression to type -- <SPC> m c - case split on goal contents -- if goal is empty, will ask for what to split on -- <SPC> m r - introduce constructor (if non-ambiguous) -- can also introduce constructors, lambdas, record constructors -- if there's a function in the goal it will "introduce" it with its arguments as new goals -- <SPC> m <SPC> - when in a goal, replace the goal with the expression currently in the goal -- if the goal is empty, agda will ask for an expression to insert -- obviously only works if types match -- <SPC> m a - (invoke "agsy") agda try your best to figure this out! -- you can add names to a goal to give hints to agda, e.g. if you want to use a function "f" -- <SPC> m x r - restart agda -- <SPC> u <SPC> u <other-command> - kindly ask agda to evaluate and desugar everything as much as it can when executing <other-command> -- <SPC> m f - go to next goal -- <SPC> m n - compute an expression -- <SPC> m h - when in a hole, compute what the type of a helper function you need here would be ------------------------------------------------------------------------------------------------------- -- EXERCISE | ------------- -- a haskell type declaration --data List a -- = Nil -- | Cons a (List a) -- -- same thing but in agda --data List (A : Set) : Set where -- Nil : List A -- Cons : A -> List A -> List A -- X : Y - "X is of type Y" -- Set is the "kind" of types -- it's safe to just read it as "Type" instead -- identity function, with an explicit type as an argument -- in agda we don't have (and don't need) "implicit polymorphic types" -- like how in haskell when we write a -> a we actually mean "for all a (a -> a)" -- so instead we "simulate" it by taking a type as an argument id' : (A : Set) -> A -> A id' _ x = x -- we can also have it implicitly inferred, by using {} to specify the argument -- agda doesn't have global type inference (because it's not decidable in general) - you always need to write top level signatures id : {A : Set} -> A -> A id x = x -- a data type definition -- it has no constructors -- therefore it cannot be constructed! -- this is an encoding of "falsity" exactly because you can't make values (proofs) of it -- called Zero because it contains 0 values data Zero : Set where -- ⊥ -- therefore if you are handed something of Zero -- you can try to inspect it, to show that it's not possible for it to exist! -- this is "efq" naughtE : {A : Set} -> Zero -> A naughtE () -- ^ this bit is special syntax for "impossible case" - not the same thing as () in haskell -- a record type - "dual" in some sense to a data type -- very similar to a struct in C: -- in order to construct a record type, you need to give values for all its fields -- this record has *no* fields, therefore to construct it you need to give *no values* -- and it is therefore very easy to construct -- it encodes "trivial truth" in logic, exactly because you don't need any assumptions to create it -- the "constructor <>" syntax introduces a convenient way to create values from this type, instead of using record syntax -- called One because it contains one value record One : Set where -- unit/top/⊤ constructor <> -- an example value from One one : One one = <> -- an example value constructed with record syntax one' : One one' = record {} -- no values to give! -- example of a record type with some actual fields! --record Student : Set where -- field -- fn : Number -- these types don't actually exist yet, but let's assume they do -- name : String -- --georgi : Student --georgi = -- record -- { fn = {!81248!} -- ; name = {!"Georgi"!} -- } -- boolean values - to construct a Two we either use the ff or the tt constructor -- called Two because it has two values data Two : Set where ff : Two tt : Two -- an example of "mixfix" syntax -- we can define a function with three arguments -- the _s are where we would place arguments if_then_else_ : {A : Set} -> Two -> A -> A -> A if ff then t else e = e if tt then t else e = t -- we can write ordinary functions that return types, based on some value! -- this function "promotes" the boolean *values* to their "corresponding" *logical types* -- e.g. we convert the boolean "false" to our encoding of falsity - the type Zero IsTrue : Two -> Set IsTrue ff = Zero IsTrue tt = One _ : IsTrue tt _ = <> -- a sum type - it's either the left thing or the right thing -- Either in haskell -- as a logical construction it's a proof of either a or either b data _+_ (A B : Set) : Set where -- A || B inl : A -> A + B inr : B -> A + B _ : Zero + One _ = inr <> -- two-tuples defined as a record -- a logical encoding for proof of *both* a *and* b -- (a, b) in haskell -- we will instead get this as a special case from our next construction --record _*_ (A B : Set) : Set where -- A && B -- constructor _,_ -- field -- fst : A -- snd : B -- a **dependent two-tuple** - called a sigma type in books -- **the type of the second field can depend on the value of the first** -- this is an encoding of "exists" quantifiers- -- to prove (constructively) ∃x.P(x), you must give me a x₀, and then prove that P(x₀) -- which is effectively a two-tuple of a value x, and a proof P x record _><_ (A : Set) (P : A -> Set) : Set where constructor _,_ field fst : A snd : P fst infixr 15 _><_ open _><_ -- an example of a dependent tuple -- we give a value, and then show proof that the value satisfies our predicate "IsTrue" -- ofcourse, if we give the value ff, we would not be able to construct this, because we cannot prove Zero _ : Two >< IsTrue _ = tt , <> -- another example of construction of a sigma type --data Nat : Set where -- zero : Nat -- suc : Nat -> Nat -- --three : Nat --three = suc (suc (suc zero)) -- --Even : Nat -> Set --Even zero = One --Even (suc zero) = Zero --Even (suc (suc x)) = Even x -- --twoIsEven : Nat >< Even --twoIsEven = (suc (suc zero)) , <> -- and now we can get our regular 2-tuples for free as a special case of sigma types -- in which the second argument doesn't depend on the first (notice how our lambda ignores its argument) _*_ : (A B : Set) -> Set A * B = A >< \_ -> B infixr 15 _*_ -- we can encode Either using a sigma type with Two as our left type! -- to construct an Either -- you must either use tt (the "left" constructor) in which case our if then else will compute to A, therefore we must give an A -- or you must either use ff (the "right" constructor) in which case our if then else will compute to B, therefore we must give a B Either : (A B : Set) -> Set Either A B = Two >< \b -> if b then A else' B where -- note: I used another version of if_then_else, because our original one had arguments that are **values of some type**, i.e. (x : A), for some A : Set, -- but here we're actually using the **A itself** as an argument, and our original function handle this -- this one is **polymorphic over levels** (similar to kind polymorphism in haskell) - it works for both (x : A) and for (A : Set) and for a lot of other stuff if_then_else'_ : forall {l} -> {A : Set l} -> Two -> A -> A -> A if ff then t else' e = e if tt then t else' e = t -- an example of a function using _*_ -- and a theorem at the same time -- if you know that A * B is true, then you can also prove B * A (so some kind of symmetry/commutativity) *-theorem1 : {A B : Set} -> A * B -> B * A *-theorem1 (x , y) = y , x -- peano-encoded natural numbers data Nat : Set where zero : Nat suc : Nat -> Nat -- a recursive case in a constructor {-# BUILTIN NATURAL Nat #-} -- pragma allows us to write literals, e.g. 2 to mean (suc (suc zero)), and also to compile these to Integer, if we compile to haskell -- traditional left-recursive peano nat addition -- how you define your functions has great repercussions! -- because all your proofs will now have to look at the left argument of n +N m in order to proceed! _+N_ : Nat -> Nat -> Nat zero +N m = m suc n +N m = suc (n +N m) infixr 30 _+N_ -- an equality type -- to show that x == y for some values x and y -- you can do only one thing: show that x and y are actually the same value (by using the refl constructor) -- this "syntactic equality" is internal to agda, but you can think of it as basically "the same structure" (when you look at e.g. constructors) data _==_ {A : Set} : A -> A -> Set where refl : {x : A} -> x == x infix 20 _==_ {-# BUILTIN EQUALITY _==_ #-} -- allows us to use rewrites for this equality type -- a proof that 2 is equal to 2 -- since 2 is the same syntactic object (suc (suc zero)) as itself, we can use refl twoIsTwo : 2 == 2 twoIsTwo = refl -- similarly, in this case 1 +N 1 is not immediately the same thing as 2 -- but agda automatically applies (beta-reduces) the definition of +N as much as possible, -- and can calculate that they are actually the same! onePlusOneIsTwo : (1 +N 1) == 2 onePlusOneIsTwo = refl -- another way to define == where the x is a parameter instead --data _=='_ {A : Set} (x : A) -> A -> Set where -- refl : x == x -- a proof demonstrating how to use == -- this states that if you have two proofs of x and y being equal -- then the proofs themselves are equal to one another! ==-unique : {A : Set} {x y : A} (p1 p2 : x == y) -> p1 == p2 ==-unique refl refl = refl -- note that this is not always true, and it is an active area of research (homotopy type theory), -- which might provide solutions to problems in constructive mathematics -- in it, you cannot prove this theorem, and indeed, there are p1 and p2 there, which *are not* equal to each other -- ap allows us to "apply a function to both sides of an equality" -- i.e. on a piece of paper we automatically assume this, because f is a function ap : {A B : Set} {x y : A} (f : A -> B) -> x == y -> f x == f y ap f refl = refl -- this proof doesn't need to look at n at all, because we have a case for 0 +N _ in the definition of +N -- and agda can automatically compute it +N-left-zero : (n : Nat) -> 0 +N n == n +N-left-zero n = refl -- but it is not the same in this case! -- and thus we use recursion to prove this +N-right-zero : (n : Nat) -> n +N 0 == n +N-right-zero zero = refl +N-right-zero (suc n') = ap suc (+N-right-zero n') -- another alternative to the last case would be to use "rewrite" -- the rewrite declaration allows us to "rewrite" our goal by using an equality provided by us -- i.e. if we have a goal that has some x's in it, and we have a proof (p : x == y) -- then rewrite p will change all the x's into y's in our goal +N-assoc : (n m k : Nat) -> (n +N m) +N k == n +N (m +N k) +N-assoc zero m k = refl +N-assoc (suc n) m k rewrite +N-assoc n m k = refl ---- EXERCISES == -- ---- EXERCISE: == is symmetric --==-symm : {A : Set} {x y : A} -> x == y -> y == x --==-symm = ? -- ---- EXERCISE: == is transitive --==-trans : {A : Set} {x y z : A} -> x == y -> y == z -> x == z --==-trans = ? -- ---- EXERCISES Nats -- ---- EXERCISE: suc is injective --suc-inj : {n m : Nat} -> suc n == suc m -> n == m --suc-inj = ? data _<=_ : Nat -> Nat -> Set where ozero : {n : Nat} -> zero <= n osuc : {n m : Nat} -> n <= m -> suc n <= suc m -- TODO: show some inequalities ---- EXERCISE: <=-refl --<=-refl : (n : Nat) -> n <= n --<=-refl n = ? -- ---- EXERCISE: <=-trans --<=-trans : {n m k : Nat} -> n <= m -> m <= k -> n <= k --<=-trans = ? -- ---- EXERCISE: suc n is not less than or equal to n --suc-suc-not-<= : {n : Nat} -> suc n <= n -> Zero --suc-suc-not-<= = ? -- ---- EXERCISE: <= proofs are unique ---- use ap or rewrite! --<=-unique : {n m : Nat} -> (p1 p2 : n <= m) -> p1 == p2 --<=-unique = ? -- ---- lists -- --data List (A : Set) : Set where -- [] : List A -- _,-_ : A -> List A -> List A -- --infixr 50 _,-_ -- ---- EXERCISE: ---- Define list appending ---- HINT: look at +N if you haven't done this before --_+L_ : {A : Set} -> List A -> List A -> List A --xs +L ys = ? -- --infixr 30 _+L_ -- ---- EXERCISE: ---- +L is a monoid - with what left and right unit? ---- i.e. for what x is it true that for any xs: ---- x +L xs == xs and xs +L x == xs ---- TODO: delete [] --+L-left-id : {A : Set} (xs : List A) -> [] +L xs == xs --+L-left-id = ? -- --+L-right-id : {A : Set} (xs : List A) -> xs +L [] == xs --+L-right-id = ? -- ---- EXERCISE: ---- +L is associative ---- HINT: look at +N-assoc --+L-assoc : {A : Set} (xs ys zs : List A) -> (xs +L ys) +L zs == xs +L (ys +L zs) --+L-assoc = ? -- ---- EXERCISE: list map ---- define map for lists - apply a function to every argument --map : {A B : Set} -> (A -> B) -> List A -> List B --map = ? -- ---- EXERICSE: mapping id is the same as just id --map-id-is-id : {A : Set} -> (xs : List A) -> map id xs == xs --map-id-is-id = ? ---- Note: we apply the argument to avoid extensionality issues -- ---- left-to-right composition --_<<_ : {A B C : Set} -> (B -> C) -> (A -> B) -> A -> C --(f << g) x = ? -- ---- EXERCISE: mapping a composition is the same as composing mappings ---- <SPC> u <SPC> u <other-command> ---- might be useful here --map-compose : {A B C : Set} (f : B -> C) (g : A -> B) (xs : List A) -> map (f << g) xs == (map f << map g) xs --map-compose = ? -- ---- EXERCISE: mapping after appending is the same as first mapping and then appending --map-distrib-+L : {A B : Set} (f : A -> B) (xs ys : List A) -> map f (xs +L ys) == map f xs +L map f ys --map-distrib-+L = ? -- ---- EXERCISE: length-indexed lists - vectors ---- "lists that know their length" -- --data Vector (A : Set) : Nat -> Set where -- [] : Vector A zero -- the empty vector has a length of 0 -- _,-_ : {n : Nat} -> A -> Vector A n -> Vector A (suc n) -- if we cons an element to a vector of length n, we get a vector of length (suc n) -- ---- EXERCISE: We can now define a safe head and tail - you can't call them with [] ---- Compare this to the default ones in haskell, that can throw exceptions --vhead : {A : Set} {n : Nat} -> Vector A (suc n) -> A --vhead = ? -- --vtail : {A : Set} {n : Nat} -> Vector A (suc n) -> Vector A n --vtail = ? -- ---- EXERCISE: We can also define "safe" take, that does not "overshoot" ---- Note how we don't need to pass n explicitly, because n <= m holds this information already --vtake : {A : Set} {n m : Nat} -> n <= m -> Vector A m -> Vector A n --vtake = ? -- ---- EXERCISE: Our zip is also "safe" in that we don't lose any information from either vector --vzip : {A B : Set} {n : Nat} -> Vector A n -> Vector B n -> Vector (A * B) n --vzip = ? -- ---- EXERCISE: Append vectors ---- What type should this function have? ---- _+V_ : ? -- ---- EXERCISE: We can split a vector if we know its size is a sum of two numbers ---- N.B.! you need to pattern match on the left number here, because otherwise agda doesn't know ---- what cases could be possible for the vector --vsplit : {A : Set} (n m : Nat) -> Vector A (n +N m) -> Vector A n * Vector A m --vsplit = ? -- ---- EXERCISE: Appending two vectors and then splitting them should yield the original two vectors! ---- What type should this have? ---- vsplit-+V-id : ? -- ---- EXERCISE: you can also suc on the right in +N --+N-right-suc : (n m : Nat) -> suc (n +N m) == n +N suc m --+N-right-suc = ? -- ---- EXERCISE: +N is commutative ---- prove lemmas if something seems too hard! ---- you'll need to prove a lemma for the recursive case ---- HINT: ---- use ==-symm and +N-right-zero in the base case ---- and +N-right-suc in the recursive case (+ rewrite or ap + ==-trans) --+N-commut : (n m : Nat) -> n +N m == m +N n --+N-commut = ? -- ---- EXERCISE: multiplication ---- use addition --_*N_ : Nat -> Nat -> Nat --n *N m = ? --infixr 40 _*N_ -- ---- EXERCISE: multiplication right identity --*N-right-id : (n : Nat) -> n *N 1 == n --*N-right-id = ? -- ---- EXERCISE: multiplication distributes over addition ---- HINT: use rewrite and ==-symm + +N-assoc in the recursive case --*N-distrib-+N : (n m k : Nat) -> (n +N m) *N k == n *N k +N m *N k --*N-distrib-+N = ? -- ---- EXERCISE: multiplication is associative ---- HINT: user *N-+N-distrib and rewrite --*N-assoc : (n m k : Nat) -> (n *N m) *N k == n *N (m *N k) --*N-assoc = ?
{ "alphanum_fraction": 0.6202939514, "avg_line_length": 36.4742268041, "ext": "agda", "hexsha": "e13f991bfb21ca15c77babcf013b0b828015f168", "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": "9044b382dc9ca3e7e57b4852b3678f1ff3ff5583", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "triffon/lcpt-2019-20", "max_forks_repo_path": "exercises/02-agda-start.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9044b382dc9ca3e7e57b4852b3678f1ff3ff5583", "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": "triffon/lcpt-2019-20", "max_issues_repo_path": "exercises/02-agda-start.agda", "max_line_length": 162, "max_stars_count": 4, "max_stars_repo_head_hexsha": "9044b382dc9ca3e7e57b4852b3678f1ff3ff5583", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "triffon/lcpt-2019-20", "max_stars_repo_path": "exercises/02-agda-start.agda", "max_stars_repo_stars_event_max_datetime": "2020-06-13T22:22:20.000Z", "max_stars_repo_stars_event_min_datetime": "2020-02-25T13:16:34.000Z", "num_tokens": 5411, "size": 17690 }
{-# OPTIONS --without-K --rewriting #-} open import Prelude module Syntax where data Con : (n : ℕ) → Set Ctx : Set Ctx = Σ ℕ Con data Ty : Ctx → Set data Tm : {Γ : Ctx} (A : Ty Γ) → Set data Sub : Ctx → Ctx → Set 𝔻 : (n : ℕ) → Con n dangling : {n : ℕ} (Γ : Con n) → Sub (n , Γ) (n , 𝔻 n) _[_]T : ∀ {Γ Δ} (A : Ty Γ) (σ : Sub Δ Γ) → Ty Δ _[_]tm : ∀ {Γ Δ} {A : Ty Γ} (t : Tm A) (σ : Sub Δ Γ) → Tm (A [ σ ]T) _≃_ : ∀ (Γ Δ : Ctx) {γ : Sub Δ Γ} {δ : Sub Γ Δ} → Set -- Type theory for globular sets data Con where Start : Con (O) Ext : ∀ {n : ℕ} (Γ : Con (n)) → Con (S n) Drop : ∀ {n : ℕ} (Γ : Con (S n)) → Con n Ext' : Ctx → Ctx Ext' Γ = (S (fst Γ) , Ext (snd Γ)) data Ty where ⇒/_ : ∀ {n} {Δ} (σ : Sub Δ (n , 𝔻 n)) → Ty Δ data Sub where id : ∀ {Γ} → Sub Γ Γ _∘_ : ∀ {Γ Δ Θ} (δ : Sub Θ Δ) (γ : Sub Δ Γ) → Sub Θ Γ Drop : ∀ {n} (Γ : Con (S n)) → Sub (S n , Γ) (n , Drop Γ) Drop- : ∀ {n} (Γ : Con (S n)) → Sub (n , Drop Γ) (S n , Γ) π₁ : ∀ (Γ : Ctx) → Sub (Ext' Γ) Γ _,_ : ∀ {Γ Δ} (γ : Sub Δ Γ) (a : Tm ((⇒/ (dangling (snd Γ))) [ γ ]T)) → Sub Δ (Ext' Γ) data Tm where -- π₂ : ∀ {Γ} (A : Ty Γ) → Tm {Γ , A} (A [ π₁ ]T) postulate -- category structure idl : ∀ {Γ Δ} {γ : Sub Δ Γ} → (γ ∘ id) == γ idr : ∀ {Γ Δ} {γ : Sub Δ Γ} → (id ∘ γ) == γ assoc : ∀ {Γ Δ Θ Φ} {γ : Sub Δ Γ} {δ : Sub Θ Δ} {θ : Sub Φ Θ} → (θ ∘ (δ ∘ γ)) == ((θ ∘ δ) ∘ γ) -- skeleton iso : ∀ {n} {Γ : Con (S n)} → ((S n , Γ) ≃ (n , (Drop Γ))) {Drop- Γ} {Drop Γ} 𝔻 O = Start 𝔻 (S n) = Ext (𝔻 n) dangling Start = id dangling (Ext Γ) = {!!} dangling (Drop Γ) = {!!} _≃_ Γ Δ {γ} {δ} = {!((γ ∘ δ) == id) ^ ((δ ∘ γ) == id)!} _[_]T {Γ} {Δ} (⇒/ σ₁) σ = ⇒/ (σ ∘ σ₁) _[_]tm = {!!}
{ "alphanum_fraction": 0.403567447, "avg_line_length": 25.6285714286, "ext": "agda", "hexsha": "fa494f1e6994bed9fc0eae055c58b89458475623", "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": "b1734c0ab6f56403d47855829dcf1808b9c53575", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thibautbenjamin/catt", "max_forks_repo_path": "agda/Syntax.agda", "max_issues_count": 9, "max_issues_repo_head_hexsha": "b1734c0ab6f56403d47855829dcf1808b9c53575", "max_issues_repo_issues_event_max_datetime": "2018-07-12T16:44:10.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-14T09:31:04.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thibautbenjamin/catt", "max_issues_repo_path": "agda/Syntax.agda", "max_line_length": 99, "max_stars_count": 11, "max_stars_repo_head_hexsha": "b1734c0ab6f56403d47855829dcf1808b9c53575", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ThiBen/catt", "max_stars_repo_path": "agda/Syntax.agda", "max_stars_repo_stars_event_max_datetime": "2020-05-21T00:44:36.000Z", "max_stars_repo_stars_event_min_datetime": "2017-05-31T10:06:17.000Z", "num_tokens": 859, "size": 1794 }
{-# OPTIONS --cubical --safe #-} module Algebra.Construct.Dyck where open import Prelude open import Algebra open import Data.Nat using (_+_) import Data.Nat.Properties as ℕ open import Agda.Builtin.Nat using (_-_) record Bal : Type₀ where constructor _⟩⟨_ field left : ℕ right : ℕ open Bal public infix 4.5 _⟩-⟨_ _⟩⟨_ _+⟨_⟩+_ _+⟨⟩+_ _⟩-⟨_ : ℕ → ℕ → Bal zero ⟩-⟨ m = zero ⟩⟨ m suc n ⟩-⟨ zero = suc n ⟩⟨ zero suc n ⟩-⟨ suc m = n ⟩-⟨ m _+⟨_⟩+_ : ℕ → Bal → ℕ → Bal x +⟨ z ⟩+ y = right z + x ⟩⟨ left z + y _+⟨⟩+_ : Bal → Bal → Bal x +⟨⟩+ y = left x +⟨ right x ⟩-⟨ left y ⟩+ right y mempty : Bal mempty = 0 ⟩⟨ 0 diff-zeroʳ : ∀ n → n ⟩-⟨ zero ≡ n ⟩⟨ zero diff-zeroʳ zero = refl diff-zeroʳ (suc n) = refl invert : Bal → Bal invert (x ⟩⟨ y) = y ⟩⟨ x diff-inv : ∀ x y → invert (x ⟩-⟨ y) ≡ y ⟩-⟨ x diff-inv zero zero = refl diff-inv zero (suc y) = refl diff-inv (suc x) zero = refl diff-inv (suc x) (suc y) = diff-inv x y open import Path.Reasoning add-inv : ∀ x y → (x +⟨⟩+ y) ≡ invert (invert y +⟨⟩+ invert x) add-inv (xl ⟩⟨ xr) (yl ⟩⟨ yr) = cong₂ _⟩⟨_ (cong (_+ xl) (cong left (diff-inv xr yl))) (cong (_+ yr) (cong right (diff-inv xr yl))) 0+⟨⟩ : ∀ x → mempty +⟨⟩+ x ≡ x 0+⟨⟩ (zero ⟩⟨ xr) i = zero ⟩⟨ xr 0+⟨⟩ (suc xl ⟩⟨ xr) i = suc (ℕ.+-idʳ xl i) ⟩⟨ xr ⟨⟩+0 : ∀ x → x +⟨⟩+ mempty ≡ x ⟨⟩+0 (xl ⟩⟨ zero ) i = xl ⟩⟨ zero ⟨⟩+0 (xl ⟩⟨ suc xr) i = xl ⟩⟨ suc (ℕ.+-idʳ xr i) diff-sub : ∀ x y → left (x ⟩-⟨ y) ≡ x - y diff-sub zero zero = refl diff-sub zero (suc y) = refl diff-sub (suc x) zero = refl diff-sub (suc x) (suc y) = diff-sub x y diff-subʳ : ∀ x y → right (x ⟩-⟨ y) ≡ y - x diff-subʳ zero zero = refl diff-subʳ zero (suc y) = refl diff-subʳ (suc x) zero = refl diff-subʳ (suc x) (suc y) = diff-subʳ x y minus-plus : ∀ x y z → x - y - z ≡ x - (y + z) minus-plus x zero z = refl minus-plus zero (suc y) zero = refl minus-plus zero (suc y) (suc z) = refl minus-plus (suc x) (suc y) z = minus-plus x y z lhs″ : ∀ zl xr yl yr → (zl - ((xr - yl) + yr)) + (yl - xr) ≡ ((zl - yr) + yl) - xr lhs″ zl zero zero yr = refl lhs″ zl zero (suc yl) yr = refl lhs″ zl (suc xr) zero yr = ℕ.+-idʳ _ ; (cong (zl -_) (ℕ.+-comm (suc xr) yr) ; sym (minus-plus zl yr (suc xr))) ; sym (cong (_- suc xr) (ℕ.+-idʳ (zl - yr))) lhs″ zero (suc xr) (suc yl) zero = lhs″ zero xr yl zero lhs″ zero (suc xr) (suc yl) (suc yr) = lhs″ zero xr yl (suc yr) lhs″ (suc zl) (suc xr) (suc yl) zero = lhs″ (suc zl) xr yl zero ; cong (_- xr) (sym (ℕ.+-suc zl yl)) lhs″ (suc zl) (suc xr) (suc yl) (suc yr) = cong (_+ (yl - xr)) (cong (suc zl -_) (ℕ.+-suc (xr - yl) yr)) ; lhs″ zl (suc xr) (suc yl) yr rhs‴ : ∀ x y z → x + y - z ≡ x - (z - y) + (y - z) rhs‴ zero zero zero = refl rhs‴ zero zero (suc z) = refl rhs‴ zero (suc y) zero = refl rhs‴ (suc x) zero zero = refl rhs‴ (suc x) (suc y) zero = refl rhs‴ zero (suc y) (suc z) = rhs‴ zero y z rhs‴ (suc x) zero (suc z) = cong (_- z) (ℕ.+-idʳ x) ; sym (ℕ.+-idʳ (x - z)) rhs‴ (suc x) (suc y) (suc z) = cong (_- z) (ℕ.+-suc x y) ; rhs‴ (suc x) y z rhs″ : ∀ xr yl yr zl → ((xr - yl) + yr) - zl ≡ xr - (zl - yr + yl) + (yr - zl) rhs″ (suc xr) (suc yl) yr zl = rhs″ xr yl yr zl ; cong (λ zy → suc xr - zy + (yr - zl)) (sym (ℕ.+-suc (zl - yr) yl)) rhs″ zero zero zero zero = refl rhs″ zero zero zero (suc zl) = refl rhs″ zero zero (suc yr) zero = refl rhs″ zero zero (suc yr) (suc zl) = rhs″ zero zero yr zl rhs″ zero (suc yl) zero zero = refl rhs″ zero (suc yl) zero (suc zl) = refl rhs″ zero (suc yl) (suc yr) zero = refl rhs″ zero (suc yl) (suc yr) (suc zl) = rhs″ zero (suc yl) yr zl rhs″ (suc xr) zero zero zero = refl rhs″ (suc xr) zero (suc yr) zero = refl rhs″ (suc xr) zero zero (suc zl) = cong (_- zl) (ℕ.+-idʳ xr) ; cong (xr -_) (sym (ℕ.+-idʳ zl)) ; sym (ℕ.+-idʳ (xr - (zl + zero))) rhs″ (suc xr) zero (suc yr) (suc zl) = cong (_- zl) (ℕ.+-suc xr yr) ; rhs‴ (suc xr) yr zl ; sym (cong (λ zy → suc xr - zy + (yr - zl)) (ℕ.+-idʳ (zl - yr))) ⟨⟩-assoc : Associative _+⟨⟩+_ ⟨⟩-assoc (xl ⟩⟨ xr ) (yl ⟩⟨ yr ) (zl ⟩⟨ zr) = cong₂ _⟩⟨_ lhs rhs where lhs′ : ∀ xr yl yr zl → right (left (xr ⟩-⟨ yl) + yr ⟩-⟨ zl) + right (xr ⟩-⟨ yl) ≡ right (xr ⟩-⟨ right (yr ⟩-⟨ zl) + yl) lhs′ xr yl yr zl = right (left (xr ⟩-⟨ yl) + yr ⟩-⟨ zl) + right (xr ⟩-⟨ yl) ≡⟨ cong₂ _+_ (diff-subʳ (left (xr ⟩-⟨ yl) + yr) zl) (diff-subʳ xr yl) ⟩ (zl - (left (xr ⟩-⟨ yl) + yr)) + (yl - xr) ≡⟨ cong (λ xy → (zl - (xy + yr)) + (yl - xr)) (diff-sub xr yl) ⟩ (zl - ((xr - yl) + yr)) + (yl - xr) ≡⟨ lhs″ zl xr yl yr ⟩ ((zl - yr) + yl) - xr ≡˘⟨ cong (λ yz → (yz + yl) - xr) (diff-subʳ yr zl) ⟩ (right (yr ⟩-⟨ zl) + yl) - xr ≡˘⟨ diff-subʳ xr _ ⟩ right (xr ⟩-⟨ right (yr ⟩-⟨ zl) + yl) ∎ lhs : right (left (xr ⟩-⟨ yl) + yr ⟩-⟨ zl) + (right (xr ⟩-⟨ yl) + xl) ≡ right (xr ⟩-⟨ right (yr ⟩-⟨ zl) + yl) + xl lhs = sym (ℕ.+-assoc _ (right (xr ⟩-⟨ yl)) xl) ; cong (_+ xl) (lhs′ xr yl yr zl) rhs′ : ∀ xr yl yr zl → left (left (xr ⟩-⟨ yl) + yr ⟩-⟨ zl) ≡ left (xr ⟩-⟨ right (yr ⟩-⟨ zl) + yl) + left (yr ⟩-⟨ zl) rhs′ xr yl yr zl = left (left (xr ⟩-⟨ yl) + yr ⟩-⟨ zl) ≡⟨ diff-sub _ zl ⟩ left (xr ⟩-⟨ yl) + yr - zl ≡⟨ cong (_- zl) (cong (_+ yr) (diff-sub xr yl)) ⟩ (xr - yl) + yr - zl ≡⟨ rhs″ xr yl yr zl ⟩ (xr - ((zl - yr) + yl)) + (yr - zl) ≡˘⟨ cong (λ yz → (xr - (yz + yl)) + (yr - zl)) (diff-subʳ yr zl) ⟩ (xr - (right (yr ⟩-⟨ zl) + yl)) + (yr - zl) ≡˘⟨ cong₂ _+_ (diff-sub xr _) (diff-sub yr zl) ⟩ left (xr ⟩-⟨ right (yr ⟩-⟨ zl) + yl) + left (yr ⟩-⟨ zl) ∎ rhs : left (left (xr ⟩-⟨ yl) + yr ⟩-⟨ zl) + zr ≡ left (xr ⟩-⟨ right (yr ⟩-⟨ zl) + yl) + (left (yr ⟩-⟨ zl) + zr) rhs = cong (_+ zr) (rhs′ xr yl yr zl) ; ℕ.+-assoc (left (xr ⟩-⟨ right (yr ⟩-⟨ zl) + yl)) (left (yr ⟩-⟨ zl)) zr semigroupBal : Semigroup _ semigroupBal .Semigroup.𝑆 = Bal semigroupBal .Semigroup._∙_ = _+⟨⟩+_ semigroupBal .Semigroup.assoc = ⟨⟩-assoc monoidBal : Monoid _ Monoid.𝑆 monoidBal = Bal Monoid._∙_ monoidBal = _+⟨⟩+_ Monoid.ε monoidBal = mempty Monoid.assoc monoidBal = ⟨⟩-assoc Monoid.ε∙ monoidBal = 0+⟨⟩ Monoid.∙ε monoidBal = ⟨⟩+0
{ "alphanum_fraction": 0.5257266956, "avg_line_length": 39.3815789474, "ext": "agda", "hexsha": "d8916e2d48f93890913d7d9ce4c7674bb1c6bbf6", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Algebra/Construct/Dyck.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Algebra/Construct/Dyck.agda", "max_line_length": 156, "max_stars_count": 4, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Algebra/Construct/Dyck.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z", "max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z", "num_tokens": 3055, "size": 5986 }
module Structure.Operator.Monoid.Invertible where open import Functional import Lvl open import Logic.Propositional open import Logic.Predicate open import Structure.Setoid open import Type private variable ℓ ℓₗ ℓₑ : Lvl.Level private variable T : Type{ℓ} private variable _⨞_ : T → T → Type{ℓₗ} module _ ⦃ equiv : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) where -- Generalizes the following examples in ℕ: -- • Lesser than or equal: (5+? = 8) ⇔ (5 ≤ 8) -- • Divides : (5*? = 10) ⇔ (5 ∣ 10) record InverseRelationᵣ(_⨞_ : T → T → Type{ℓₗ}) : Type{Lvl.of(T) Lvl.⊔ ℓₑ Lvl.⊔ ℓₗ} where constructor intro field proof : ∀{x y} → (x ⨞ y) ↔ ∃(z ↦ x ▫ z ≡ y) module _ ⦃ invRel : InverseRelationᵣ{ℓₗ}(_⨞_) ⦄ where record InverseOperatorᵣ (_⋄_ : (x : T) → (y : T) → . ⦃ inv : (y ⨞ x) ⦄ → T) : Type{Lvl.of(T) Lvl.⊔ ℓₑ Lvl.⊔ ℓₗ} where constructor intro field proof : ∀{x y} ⦃ inv : (y ⨞ x) ⦄ → (x ⋄ y ≡ [∃]-witness([↔]-to-[→] (InverseRelationᵣ.proof invRel) inv)) {- module _ ⦃ equiv : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) where InverseRelationₗ = InverseRelationᵣ(swap(_▫_)) module _ ⦃ invRel : InverseRelationₗ{ℓₗ}(_⨞_) ⦄ where InverseOperatorₗ = InverseOperatorᵣ -- TODO: Is this correct? -}
{ "alphanum_fraction": 0.6102106969, "avg_line_length": 36.2941176471, "ext": "agda", "hexsha": "69a829a4c90a00441d13803cdf9df9d86916275d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Operator/Monoid/Invertible.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Operator/Monoid/Invertible.agda", "max_line_length": 121, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Operator/Monoid/Invertible.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": 548, "size": 1234 }
module map-compose where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; cong) open Eq.≡-Reasoning open import Function using (_∘_) open import lists using (List; []; _∷_; map) postulate -- 外延性の公理 extensionality : ∀ {A B : Set} {f g : A → B} → (∀ (x : A) → f x ≡ g x) ----------------------- → f ≡ g -- 外延性の公理を用いた証明のための補助定理 lemma : ∀ {A B C : Set} → (f : A → B) → (g : B → C) → (x : List A) → map (g ∘ f) x ≡ (map g ∘ map f) x lemma f g [] = refl lemma f g (x ∷ xs) = begin map (g ∘ f) (x ∷ xs) ≡⟨⟩ (g ∘ f) x ∷ map (g ∘ f) xs ≡⟨ cong ((g ∘ f) x ∷_) (lemma f g xs) ⟩ (g ∘ f) x ∷ (map g ∘ map f) xs ≡⟨⟩ (map g ∘ map f) (x ∷ xs) ∎ -- mapの分配法則の証明 map-compose : ∀ {A B C : Set} → (f : A → B) → (g : B → C) → map (g ∘ f) ≡ map g ∘ map f map-compose f g = extensionality (lemma f g)
{ "alphanum_fraction": 0.4913093859, "avg_line_length": 24.6571428571, "ext": "agda", "hexsha": "0b9e1c7cd0cfa68166517c4b05dbad6e50bd2a9f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_path": "part1/lists/map-compose.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_path": "part1/lists/map-compose.agda", "max_line_length": 66, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_path": "part1/lists/map-compose.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "num_tokens": 401, "size": 863 }
{-# OPTIONS --guardedness #-} module induction-ex where open import Relation.Binary.PropositionalEquality open import Size open import Data.Bool data List (A : Set ) : Set where [] : List A _∷_ : A → List A → List A data Nat : Set where zero : Nat suc : Nat → Nat add : Nat → Nat → Nat add zero x = x add (suc x) y = suc ( add x y ) _++_ : {A : Set} → List A → List A → List A [] ++ y = y (x ∷ t) ++ y = x ∷ ( t ++ y ) test1 = (zero ∷ []) ++ (zero ∷ []) length : {A : Set } → List A → Nat length [] = zero length (_ ∷ t) = suc ( length t ) lemma1 : {A : Set} → (x y : List A ) → length ( x ++ y ) ≡ add (length x) (length y) lemma1 [] y = refl lemma1 (x ∷ t) y = cong ( λ k → suc k ) lemma2 where lemma2 : length (t ++ y) ≡ add (length t) (length y) lemma2 = lemma1 t y -- record List1 ( A : Set ) : Set where -- inductive -- field -- nil : List1 A -- cons : A → List1 A → List1 A -- -- record List2 ( A : Set ) : Set where -- coinductive -- field -- nil : List2 A -- cons : A → List2 A → List2 A data SList (i : Size) (A : Set) : Set where []' : SList i A _∷'_ : {j : Size< i} (x : A) (xs : SList j A) → SList i A map : ∀{i A B} → (A → B) → SList i A → SList i B map f []' = []' map f ( x ∷' xs)= f x ∷' map f xs foldr : ∀{i} {A B : Set} → (A → B → B) → B → SList i A → B foldr c n []' = n foldr c n (x ∷' xs) = c x (foldr c n xs) any : ∀{i A} → (A → Bool) → SList i A → Bool any p xs = foldr _∨_ false (map p xs) -- Sappend : {A : Set } {i j : Size } → SList i A → SList j A → SList {!!} A -- Sappend []' y = y -- Sappend (x ∷' x₁) y = _∷'_ {?} x (Sappend x₁ y) language : { Σ : Set } → Set language {Σ} = List Σ → Bool record Lang (i : Size) (A : Set) : Set where coinductive field ν : Bool δ : ∀{j : Size< i} → A → Lang j A open Lang ∅ : ∀ {i A} → Lang i A ν ∅ = false δ ∅ _ = ∅ ∅' : {i : Size } { A : Set } → Lang i A ∅' {i} {A} = record { ν = false ; δ = lemma3 } where lemma3 : {j : Size< i} → A → Lang j A lemma3 {j} _ = {!!} ∅l : {A : Set } → language {A} ∅l _ = false ε : ∀ {i A} → Lang i A ν ε = true δ ε _ = ∅ εl : {A : Set } → language {A} εl [] = true εl (_ ∷ _) = false _+_ : ∀ {i A} → Lang i A → Lang i A → Lang i A ν (a + b) = ν a ∨ ν b δ (a + b) x = δ a x + δ b x Union : {Σ : Set} → ( A B : language {Σ} ) → language {Σ} Union {Σ} A B x = (A x ) ∨ (B x) _·_ : ∀ {i A} → Lang i A → Lang i A → Lang i A ν (a · b) = ν a ∧ ν b δ (a · b) x = if (ν a) then ((δ a x · b ) + (δ b x )) else ( δ a x · b ) split : {Σ : Set} → (List Σ → Bool) → ( List Σ → Bool) → List Σ → Bool split x y [] = x [] ∨ y [] split x y (h ∷ t) = (x [] ∧ y (h ∷ t)) ∨ split (λ t1 → x ( h ∷ t1 )) (λ t2 → y t2 ) t Concat : {Σ : Set} → ( A B : language {Σ} ) → language {Σ} Concat {Σ} A B = split A B
{ "alphanum_fraction": 0.4756871036, "avg_line_length": 23.8487394958, "ext": "agda", "hexsha": "642cb2e4fd7d09c03cde983f883b92b86b6cc24d", "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": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/automaton-in-agda", "max_forks_repo_path": "src/induction-ex.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "shinji-kono/automaton-in-agda", "max_issues_repo_path": "src/induction-ex.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/automaton-in-agda", "max_stars_repo_path": "src/induction-ex.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1210, "size": 2838 }
-- An ATP hint must be used with functions. -- This error is detected by Syntax.Translation.ConcreteToAbstract. module ATPBadHint1 where data Bool : Set where false true : Bool {-# ATP hint false #-}
{ "alphanum_fraction": 0.7330097087, "avg_line_length": 18.7272727273, "ext": "agda", "hexsha": "4a981f17bae682b8c200a5dccd1671de008fe0f9", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "asr/eagda", "max_forks_repo_path": "test/fail/ATPBadHint1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "asr/eagda", "max_issues_repo_path": "test/fail/ATPBadHint1.agda", "max_line_length": 67, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "asr/eagda", "max_stars_repo_path": "test/fail/ATPBadHint1.agda", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "num_tokens": 48, "size": 206 }
{- Given a type A with a UARel and a family B over A, a SubstRel on B is a family of functions a ≅ a' → B a ≃ B a' path-equal to transport in that family. Any SubstRel gives rise to a DUARel in which b and b' are related over p when the transport of b along p is equial to b'. -} {-# OPTIONS --safe #-} module Cubical.Displayed.Subst where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Path open import Cubical.Foundations.Transport open import Cubical.Foundations.Univalence open import Cubical.Displayed.Base private variable ℓA ℓ≅A ℓB : Level record SubstRel {A : Type ℓA} {ℓ≅A : Level} (𝒮-A : UARel A ℓ≅A) (B : A → Type ℓB) : Type (ℓ-max (ℓ-max ℓA ℓB) ℓ≅A) where no-eta-equality constructor substrel open UARel 𝒮-A field act : {a a' : A} → a ≅ a' → B a ≃ B a' uaˢ : {a a' : A} (p : a ≅ a') (b : B a) → subst B (≅→≡ p) b ≡ equivFun (act p) b uaˢ⁻ : {a a' : A} (p : a ≅ a') (b : B a') → subst B (sym (≅→≡ p)) b ≡ invEq (act p) b uaˢ⁻ p b = subst B (sym (≅→≡ p)) b ≡⟨ cong (subst B (sym (≅→≡ p))) (sym (retEq (act p) b)) ⟩ subst B (sym (≅→≡ p)) (equivFun (act p) (invEq (act p) b)) ≡⟨ cong (subst B (sym (≅→≡ p))) (sym (uaˢ p (invEq (act p) b))) ⟩ subst B (sym (≅→≡ p)) (subst B (≅→≡ p) (invEq (act p) b)) ≡⟨ pathToIso (cong B (≅→≡ p)) .Iso.leftInv (invEq (act p) b) ⟩ invEq (act p) b ∎ Subst→DUA : {A : Type ℓA} {ℓ≅A : Level} {𝒮-A : UARel A ℓ≅A} {B : A → Type ℓB} → SubstRel 𝒮-A B → DUARel 𝒮-A B ℓB DUARel._≅ᴰ⟨_⟩_ (Subst→DUA 𝒮ˢ-B) b p b' = equivFun (SubstRel.act 𝒮ˢ-B p) b ≡ b' DUARel.uaᴰ (Subst→DUA {𝒮-A = 𝒮-A} {B = B} 𝒮ˢ-B) b p b' = equivFun (SubstRel.act 𝒮ˢ-B p) b ≡ b' ≃⟨ invEquiv (compPathlEquiv (sym (SubstRel.uaˢ 𝒮ˢ-B p b))) ⟩ subst B (≅→≡ p) b ≡ b' ≃⟨ invEquiv (PathP≃Path (λ i → B (≅→≡ p i)) b b') ⟩ PathP (λ i → B (UARel.≅→≡ 𝒮-A p i)) b b' ■ where open UARel 𝒮-A
{ "alphanum_fraction": 0.5815353738, "avg_line_length": 32.6721311475, "ext": "agda", "hexsha": "df13e37661abe85b7f6fd33121a789f47279c4fa", "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": "94b474af2909727d04706d562d949928c19faf7b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jespercockx/cubical", "max_forks_repo_path": "Cubical/Displayed/Subst.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "94b474af2909727d04706d562d949928c19faf7b", "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": "jespercockx/cubical", "max_issues_repo_path": "Cubical/Displayed/Subst.agda", "max_line_length": 109, "max_stars_count": null, "max_stars_repo_head_hexsha": "94b474af2909727d04706d562d949928c19faf7b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jespercockx/cubical", "max_stars_repo_path": "Cubical/Displayed/Subst.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 938, "size": 1993 }
-- Andreas, 2018-10-15, issue #3262 reported by Guillaume Brunerie -- -- Missing with clauses should be reported close to problem location -- not just at the type signature of the function which has this problem. data T : Set where a b c : T f : T → Set f a = ? f b = ? f c with c | c ... | _ = ? -- Should trigger the "missing with clauses" error -- at the lhs with the "with".
{ "alphanum_fraction": 0.6692708333, "avg_line_length": 22.5882352941, "ext": "agda", "hexsha": "9c7e91aaf1e70e032c82e4fda53e2f1e1a1021cd", "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/Issue3262.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/Issue3262.agda", "max_line_length": 73, "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/Issue3262.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": 109, "size": 384 }
{-# OPTIONS --allow-unsolved-metas #-} postulate Nat : Set Fin : Nat → Set Foo : (n : Nat) → Fin n → Set Bar : ∀ {n m} → Foo n m → Set variable n : Nat m : Fin _ k : Foo _ m l : Foo n m open import Agda.Builtin.Equality postulate goal-type-error : Bar k foo : Bar _ foo = goal-type-error _ _
{ "alphanum_fraction": 0.5873015873, "avg_line_length": 14.3181818182, "ext": "agda", "hexsha": "651dec7e6c5f0bff8fac0b2aa7a73bedb86c63b2", "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": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/Issue3109.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Succeed/Issue3109.agda", "max_line_length": 38, "max_stars_count": 1, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/Issue3109.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-07T10:49:57.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-07T10:49:57.000Z", "num_tokens": 111, "size": 315 }
-- Andreas, 2017-07-11, issue #2639 reported by nad -- -- Unsolvable size constraints were added to the constraint set -- each time the size solver ran. This lead to exponentially -- many size constraints. -- {-# OPTIONS -v tc.size.solve:40 #-} module Issue2639 (A : Set) where open import Agda.Builtin.Nat open import Agda.Builtin.Size open import Issue2639.DR A postulate P : {i : Size} → D i → Set F : Set₁ F = Set where -- This postulate creates an unsolved size constraint. postulate unused : P a G : Nat → Set → Set₁ G zero = λ { _ → Set } G (suc zero) = λ { _ → Set } G (suc (suc zero)) = λ { _ → Set } G (suc (suc (suc zero))) = λ { _ → Set } G (suc (suc (suc (suc zero)))) = λ { _ → Set } G _ = λ { _ → Set }
{ "alphanum_fraction": 0.6162018592, "avg_line_length": 22.1470588235, "ext": "agda", "hexsha": "7ae6d2754ea0f7a7c4e5ac4727866142a6307b45", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue2639.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue2639.agda", "max_line_length": 63, "max_stars_count": 2, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue2639.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 256, "size": 753 }
-- Andreas, 2012-04-18 module Issue611 where data Nat : Set where zero : Nat suc : Nat -> Nat data Bool : Set where true false : Bool T : Bool -> Set T true = {x : Bool} -> Nat T false = {x : Bool} -> Bool data D (b : Bool) : Set where c : T b -> D b d : D false d = c {_} true
{ "alphanum_fraction": 0.5699658703, "avg_line_length": 14.65, "ext": "agda", "hexsha": "10e83154aa11cc8089b50c3dbcd06c356926c33b", "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/Issue611.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/Issue611.agda", "max_line_length": 29, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue611.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": 108, "size": 293 }
module Data.Finitary.Permutation where open import Data.Nat open import Data.Fin open import Relation.Binary.PropositionalEquality as P using (_≡_; _≢_) open import Function.Inverse as Inv using (Inverse) import Function.Equality as F open import Function.LeftInverse using (_LeftInverseOf_) open import Data.Finitary open import Data.Vec as Vec using (Vec) open import Data.Vec.Distinct as Distinct using (Distinct) open import Data.Product hiding (swap) Permutation : ℕ → Set Permutation n = Finitary (P.setoid (Fin n)) n identity : ∀ {n} → Permutation n identity = Inv.id swap : ∀ {n} → Fin n → Fin n → Permutation n swap {n} i j = record { to = P.→-to-⟶ swap′ ; from = P.→-to-⟶ swap′ ; inverse-of = record { left-inverse-of = swap′-involutive ; right-inverse-of = swap′-involutive } } where open import Data.Fin.Properties as FinP open import Relation.Nullary open import Data.Empty using (⊥-elim) swap′ : Fin n → Fin n swap′ k with k FinP.≟ i swap′ k | yes k≡i = j swap′ k | no ¬p with k FinP.≟ j swap′ k | no ¬p | yes k≡j = i swap′ k | no ¬p | no ¬p₁ = k swap′-involutive : ∀ k → swap′ (swap′ k) ≡ k swap′-involutive k with k FinP.≟ i swap′-involutive k | yes k≡i with k≡i | j FinP.≟ i swap′-involutive _ | yes k≡i | P.refl | yes j≡i = j≡i swap′-involutive _ | yes k≡i | P.refl | no j≢i with j FinP.≟ j swap′-involutive _ | yes k≡i | P.refl | no j≢i | yes j≡j = P.refl swap′-involutive _ | yes k≡i | P.refl | no j≢i | no j≢j = ⊥-elim (j≢j P.refl) swap′-involutive k | no k≢i with k FinP.≟ j swap′-involutive k | no k≢i | yes k≡j with k≡j | i FinP.≟ i swap′-involutive k | no k≢i | yes k≡j | P.refl | yes P.refl = P.refl swap′-involutive k | no k≢i | yes k≡j | P.refl | no i≢i = ⊥-elim (i≢i P.refl) swap′-involutive k | no k≢i | no k≢j = lemma k≢i k≢j where open P.≡-Reasoning lemma : ∀ {k} → k ≢ i → k ≢ j → swap′ k ≡ k lemma {k} k≢i k≢j with k FinP.≟ i lemma k≢i k≢j | yes k≡i = ⊥-elim (k≢i k≡i) lemma {k} k≢i k≢j | no ¬k≡i with k FinP.≟ j lemma {k} k≢i k≢j | no ¬k≡i | yes k≡j = ⊥-elim (k≢j k≡j) lemma {k} k≢i k≢j | no ¬k≡i | no ¬p = P.refl shift : ∀ {n} → Permutation n → Permutation (ℕ.suc n) shift {n} p = record { to = P.→-to-⟶ (shift′ Perm.to) ; from = P.→-to-⟶ (shift′ Perm.from) ; inverse-of = record { left-inverse-of = shift′-inverse-of Perm.left-inverse-of ; right-inverse-of = shift′-inverse-of Perm.right-inverse-of } } where module Perm = Inverse p shift′ : P.setoid (Fin n) F.⟶ P.setoid (Fin n) → Fin (ℕ.suc n) → Fin (ℕ.suc n) shift′ f Fin.zero = Fin.zero shift′ f (Fin.suc i) = Fin.suc (f F.⟨$⟩ i) shift′-inverse-of : ∀ {from : P.setoid (Fin n) F.⟶ P.setoid (Fin n)}{to : P.setoid (Fin n) F.⟶ P.setoid (Fin n)} → from LeftInverseOf to → (P.→-to-⟶ (shift′ from)) LeftInverseOf (P.→-to-⟶ (shift′ to)) shift′-inverse-of inv Fin.zero = P.refl shift′-inverse-of inv (Fin.suc i) = P.cong Fin.suc (inv i) Perm→Distinct : ∀ {n} → Permutation n → ∃ λ (xs : Vec (Fin n) n) → Distinct xs Perm→Distinct {n} p = , xs-distinct where open Inverse p renaming (to to f) open import Data.Vec.Properties xs-distinct : Distinct (Vec.tabulate (f F.⟨$⟩_)) xs-distinct = P.subst Distinct (P.sym (tabulate-allFin _)) (Distinct.map injection (Distinct.allFin n))
{ "alphanum_fraction": 0.5456, "avg_line_length": 41.6666666667, "ext": "agda", "hexsha": "36b8802cc2e0436d5cb67c5b0083ed861b9286e6", "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": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "tizmd/agda-finitary", "max_forks_repo_path": "src/Data/Finitude/Permutation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "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": "tizmd/agda-finitary", "max_issues_repo_path": "src/Data/Finitude/Permutation.agda", "max_line_length": 206, "max_stars_count": null, "max_stars_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "tizmd/agda-finitary", "max_stars_repo_path": "src/Data/Finitude/Permutation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1364, "size": 3750 }
{- This second-order signature was created from the following second-order syntax description: syntax STLC | Λ type N : 0-ary _↣_ : 2-ary | r30 term app : α ↣ β α -> β | _$_ l20 lam : α.β -> α ↣ β | ƛ_ r10 theory (ƛβ) b : α.β a : α |> app (lam(x.b[x]), a) = b[a] (ƛη) f : α ↣ β |> lam (x. app(f, x)) = f -} module STLC.Signature where open import SOAS.Context -- Type declaration data ΛT : Set where N : ΛT _↣_ : ΛT → ΛT → ΛT infixr 30 _↣_ open import SOAS.Syntax.Signature ΛT public open import SOAS.Syntax.Build ΛT public -- Operator symbols data Λₒ : Set where appₒ lamₒ : {α β : ΛT} → Λₒ -- Term signature Λ:Sig : Signature Λₒ Λ:Sig = sig λ { (appₒ {α}{β}) → (⊢₀ α ↣ β) , (⊢₀ α) ⟼₂ β ; (lamₒ {α}{β}) → (α ⊢₁ β) ⟼₁ α ↣ β } open Signature Λ:Sig public
{ "alphanum_fraction": 0.5786864932, "avg_line_length": 17.9333333333, "ext": "agda", "hexsha": "c23fac95f99721d2968ebd2a2a63d35701e5d422", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "out/STLC/Signature.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "out/STLC/Signature.agda", "max_line_length": 91, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "out/STLC/Signature.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 364, "size": 807 }
f : {A B : Set} → (@0 A → B) → A → B f g x = g x
{ "alphanum_fraction": 0.3265306122, "avg_line_length": 16.3333333333, "ext": "agda", "hexsha": "33aa2e3adce8fdeb4aff8c74432a717bf28b3d4e", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Succeed/Erasure-subtyping.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Succeed/Erasure-subtyping.agda", "max_line_length": 36, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Succeed/Erasure-subtyping.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": 27, "size": 49 }
-- Andreas, 2017-04-13, issue #2494, reported by identicalsnowflake -- Consecutive hidden record fields confused the implicit argument insertion -- due to lack of names in NamedArg. -- {-# OPTIONS -v tc.lhs:30 #-} -- {-# OPTIONS -v tc.term.args:100 #-} postulate Red Blue : Set record Colors : Set where field {{red}} : Red {{blue}} : Blue f : Colors → Red f record { blue = blue } = blue
{ "alphanum_fraction": 0.6551724138, "avg_line_length": 22.5555555556, "ext": "agda", "hexsha": "b00d5c38b78682380839816e3e6bacd19b8b4e4b", "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/Issue2494-pattern-instance.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/Issue2494-pattern-instance.agda", "max_line_length": 76, "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/Issue2494-pattern-instance.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": 117, "size": 406 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Metavariables used in the reflection machinery ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Reflection.Meta where import Data.Nat.Properties as ℕₚ open import Function open import Relation.Nullary.Decidable using (map′) open import Relation.Binary import Relation.Binary.Construct.On as On open import Relation.Binary.PropositionalEquality open import Agda.Builtin.Reflection public using (Meta) renaming (primMetaToNat to toℕ) open import Agda.Builtin.Reflection.Properties public renaming (primMetaToNatInjective to toℕ-injective) -- Equality of metas is decidable. _≈_ : Rel Meta _ _≈_ = _≡_ on toℕ _≈?_ : Decidable _≈_ _≈?_ = On.decidable toℕ _≡_ ℕₚ._≟_ infix 4 _≟_ _≟_ : DecidableEquality Meta m ≟ n = map′ (toℕ-injective _ _) (cong toℕ) (m ≈? n)
{ "alphanum_fraction": 0.6362672322, "avg_line_length": 26.9428571429, "ext": "agda", "hexsha": "46fe960e290f9c8afaeaa35f7c4c22dd2b0b0d4b", "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/Reflection/Meta.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/Reflection/Meta.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/Reflection/Meta.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": 250, "size": 943 }
module Thesis.SIRelBigStep.SemEquiv where open import Data.Nat open import Data.Product open import Relation.Binary.PropositionalEquality open import Thesis.SIRelBigStep.Syntax public open import Thesis.SIRelBigStep.OpSem open import Thesis.SIRelBigStep.DenSem ⟦_⟧Val : ∀ {τ} → Val τ → ⟦ τ ⟧Type ⟦_⟧Env : ∀ {Γ} → ⟦ Γ ⟧Context → Den.⟦ Γ ⟧Context ⟦ ∅ ⟧Env = ∅ ⟦ v • ρ ⟧Env = ⟦ v ⟧Val • ⟦ ρ ⟧Env ⟦ closure t ρ ⟧Val = λ v → (⟦ t ⟧Term) (v • ⟦ ρ ⟧Env) ⟦ natV n ⟧Val = n ⟦ pairV v1 v2 ⟧Val = ⟦ v1 ⟧Val , ⟦ v2 ⟧Val ↦-sound : ∀ {Γ τ} ρ (x : Var Γ τ) → Den.⟦ x ⟧Var ⟦ ρ ⟧Env ≡ ⟦ ⟦ x ⟧Var ρ ⟧Val ↦-sound (px • ρ) this = refl ↦-sound (px • ρ) (that x) = ↦-sound ρ x eval-const-sound : ∀ {τ} (c : Const τ) → ⟦ c ⟧Const ≡ ⟦ eval-const c ⟧Val eval-const-sound (lit n) = refl eval-primitive-sound : ∀ {σ τ} (p : Primitive (σ ⇒ τ)) v → ⟦ p ⟧Primitive ⟦ v ⟧Val ≡ ⟦ eval-primitive p v ⟧Val eval-primitive-sound succ (natV n) = refl eval-primitive-sound add (pairV (natV n1) (natV n2)) = refl eval-sound : ∀ {Γ τ} ρ (sv : SVal Γ τ) → ⟦ sv ⟧SVal ⟦ ρ ⟧Env ≡ ⟦ eval sv ρ ⟧Val eval-sound ρ (var x) = ↦-sound ρ x eval-sound ρ (abs t) = refl eval-sound ρ (cons sv1 sv2) rewrite eval-sound ρ sv1 | eval-sound ρ sv2 = refl eval-sound ρ (const c) = eval-const-sound c -- Check it's fine to use i 0 in the derivations for app ↓-sv-1-step : ∀ {Γ τ ρ v} {n} {sv : SVal Γ τ} → ρ ⊢ val sv ↓[ i' n ] v → n ≡ 0 ↓-sv-1-step (val sv) = refl ↓-sound : ∀ {Γ τ ρ v hasIdx} {n : Idx hasIdx} {t : Term Γ τ} → ρ ⊢ t ↓[ n ] v → ⟦ t ⟧Term ⟦ ρ ⟧Env ≡ ⟦ v ⟧Val ↓-sound (val sv) = eval-sound _ sv ↓-sound (app _ _ ↓₁ ↓₂ ↓′) rewrite ↓-sound ↓₁ | ↓-sound ↓₂ | ↓-sound ↓′ = refl ↓-sound (lett n1 n2 vsv s t ↓ ↓₁) rewrite ↓-sound ↓ | ↓-sound ↓₁ = refl ↓-sound {ρ = ρ} (primapp p sv) rewrite eval-sound ρ sv = eval-primitive-sound p (eval sv ρ)
{ "alphanum_fraction": 0.5919603524, "avg_line_length": 34.2641509434, "ext": "agda", "hexsha": "064149d637e90631ddec02d70989c01173305b56", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_path": "Thesis/SIRelBigStep/SemEquiv.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_path": "Thesis/SIRelBigStep/SemEquiv.agda", "max_line_length": 110, "max_stars_count": 10, "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_path": "Thesis/SIRelBigStep/SemEquiv.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "num_tokens": 841, "size": 1816 }
------------------------------------------------------------------------ -- Applicative functors ------------------------------------------------------------------------ -- Note that currently the applicative functor laws are not included -- here. module Category.Applicative where open import Data.Unit open import Category.Applicative.Indexed RawApplicative : (Set → Set) → Set₁ RawApplicative F = RawIApplicative {I = ⊤} (λ _ _ → F) module RawApplicative {F : Set → Set} (app : RawApplicative F) where open RawIApplicative app public
{ "alphanum_fraction": 0.5514705882, "avg_line_length": 30.2222222222, "ext": "agda", "hexsha": "2cb19715484833b3c53bbeedcb7cd5ed04c0fd19", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Category/Applicative.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Category/Applicative.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Category/Applicative.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": 110, "size": 544 }
{-# OPTIONS --safe #-} module Cubical.Algebra.CommAlgebra.FreeCommAlgebra where open import Cubical.Algebra.CommAlgebra.FreeCommAlgebra.Base public open import Cubical.Algebra.CommAlgebra.FreeCommAlgebra.Properties public
{ "alphanum_fraction": 0.8392857143, "avg_line_length": 32, "ext": "agda", "hexsha": "ac7f45ffea21d057651bc613d40a1025911ab7a5", "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/CommAlgebra/FreeCommAlgebra.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/CommAlgebra/FreeCommAlgebra.agda", "max_line_length": 73, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/CommAlgebra/FreeCommAlgebra.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 51, "size": 224 }
{-# OPTIONS --cubical --safe #-} module Cubical.Data.Prod.Properties where open import Cubical.Core.Everything open import Cubical.Data.Prod.Base open import Cubical.Data.Sigma 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 private variable ℓ ℓ' : Level A B : Type ℓ -- Swapping is an equivalence swap : A × B → B × A swap (x , y) = (y , x) swap-invol : (xy : A × B) → swap (swap xy) ≡ xy swap-invol (_ , _) = refl isEquivSwap : (A : Type ℓ) (B : Type ℓ') → isEquiv (λ (xy : A × B) → swap xy) isEquivSwap A B = isoToIsEquiv (iso swap swap swap-invol swap-invol) swapEquiv : (A : Type ℓ) (B : Type ℓ') → A × B ≃ B × A swapEquiv A B = (swap , isEquivSwap A B) swapEq : (A : Type ℓ) (B : Type ℓ') → A × B ≡ B × A swapEq A B = ua (swapEquiv A B) private open import Cubical.Data.Nat -- As × is defined as a datatype this computes as expected -- (i.e. "C-c C-n test1" reduces to (2 , 1)). If × is implemented -- using Sigma this would be "transp (λ i → swapEq ℕ ℕ i) i0 (1 , 2)" test : ℕ × ℕ test = transp (λ i → swapEq ℕ ℕ i) i0 (1 , 2) testrefl : test ≡ (2 , 1) testrefl = refl -- equivalence between the sigma-based definition and the inductive one A×B≡A×ΣB : A × B ≡ A ×Σ B A×B≡A×ΣB = isoToPath (iso (λ { (a , b) → (a , b)}) (λ { (a , b) → (a , b)}) (λ _ → refl) (λ { (a , b) → refl })) -- truncation for products hLevelProd : (n : ℕ) → isOfHLevel n A → isOfHLevel n B → isOfHLevel n (A × B) hLevelProd {A = A} {B = B} n h1 h2 = let h : isOfHLevel n (A ×Σ B) h = isOfHLevelΣ n h1 (λ _ → h2) in transport (λ i → isOfHLevel n (A×B≡A×ΣB {A = A} {B = B} (~ i))) h
{ "alphanum_fraction": 0.5955603682, "avg_line_length": 29.7903225806, "ext": "agda", "hexsha": "e49d01ec6b269e7abc560680ab6b00ddb30435fb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/Data/Prod/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/Data/Prod/Properties.agda", "max_line_length": 77, "max_stars_count": null, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/Data/Prod/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 683, "size": 1847 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Example use case for a trie: a wee generic lexer ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe --sized-types #-} module README.Data.Trie.NonDependent where ------------------------------------------------------------------------ -- Introduction -- A Trie is a tree of values indexed by words in a finite language. It -- allows users to quickly compute the Brzozowski derivative of that -- little mapping from words to values. -- In the most general case, values can depend upon the list of characters -- that constitutes the path leading to them. Here however we consider a -- non-dependent case (cf. README.Trie.Dependent for a dependent use case). -- We can recognize keywords by storing the list of characters they -- correspond to as paths in a Trie and the constructor they are decoded -- to as the tree's values. -- E.g. -- [ . ] is a root -- [ -- m --> ] is an m-labeled edge and is followed when reading 'm' -- [ (X) ] is a value leaf storing constructor X -- --> -- m --> -- m --> -- a --> (LEMMA) -- / -- -- l --> -- e --> -- t --> (LET) -- / -- / -- u --> -- t --> -- u --> -- a --> -- l --> (MUTUAL) -- / / -- .< -- m --> -- o --> -- d --> -- u --> -- l --> -- e --> (MODULE) -- \ -- -- w --> -- h --> -- e --> -- r --> -- e --> (WHERE) -- \ -- --> -- n --> (WHEN) -- after reading 'w', we get the derivative: -- . -- h --> -- e --> -- r --> -- e --> (WHERE) -- \ -- --> -- n --> (WHEN) open import Level open import Data.Unit open import Data.Bool open import Data.Char as Char import Data.Char.Properties as Char open import Data.List as List using (List; []; _∷_) open import Data.List.Fresh as List# using (List#; []; _∷#_) open import Data.Maybe as Maybe open import Data.Product as Prod open import Data.String as String using (String) open import Data.These as These open import Function using (case_of_; _$_; _∘′_; id; _on_) open import Relation.Nary open import Relation.Binary using (Rel) open import Relation.Nullary.Negation using (¬?) open import Data.Trie Char.<-strictTotalOrder-≈ open import Data.AVL.Value ------------------------------------------------------------------------ -- Generic lexer record Lexer t : Set (suc t) where field -- Our lexer is parametrised over the type of tokens Tok : Set t -- Keywords are distinguished strings associated to tokens Keyword : Set t Keyword = String × Tok -- Two keywords are considered distinct if the strings are not equal Distinct : Rel Keyword 0ℓ Distinct a b = ⌊ ¬? ((proj₁ a) String.≟ (proj₁ b)) ⌋ field -- We ask users to provide us with a fresh list of keywords to guarantee -- that no two keywords share the same string representation keywords : List# Keyword Distinct -- Some characters are special: they are separators, breaking a string -- into a list of tokens. Some are associated to a token value -- (e.g. parentheses) others are not (e.g. space) breaking : Char → ∃ λ b → if b then Maybe Tok else Lift _ ⊤ -- Finally, strings which are not decoded as keywords are coerced -- using a function to token values. default : String → Tok module _ {t} (L : Lexer t) where open Lexer L tokenize : String → List Tok tokenize = start ∘′ String.toList where mutual -- A Trie is defined for an alphabet of strictly ordered letters (here -- we have picked Char for letters and decided to use the strict total -- order induced by their injection into ℕ as witnessed by the statement -- open import Data.Trie Char.strictTotalOrder earlier in this file). -- It is parametrised by a set of Values indexed over list of letters. -- Because we focus on the non-dependent case, we pick the constant -- family of Value uniformly equal to Tok. It is trivially compatible -- with the notion of equality underlying the strict total order on Chars. Keywords : Set _ Keywords = Trie (const _ Tok) _ -- We build a trie from the association list so that we may easily -- compute the successive derivatives obtained by eating the -- characters one by one init : Keywords init = fromList $ List.map (Prod.map₁ String.toList) $ proj₁ $ List#.toList keywords -- Kickstart the tokeniser with an empty accumulator and the initial -- trie. start : List Char → List Tok start = loop [] init -- The main loop loop : (acc : List Char) → -- chars read so far in this token (toks : Keywords) → -- keyword candidates left at this point (input : List Char) → -- list of chars to tokenize List Tok -- Empty input: finish up, check whether we have a non-empty accumulator loop acc toks [] = push acc [] -- At least one character loop acc toks (c ∷ cs) = case breaking c of λ where -- if we are supposed to break on this character, we do (true , m) → push acc $ maybe′ _∷_ id m $ start cs -- otherwise we see whether it leads to a recognized keyword (false , _) → case lookupValue (c ∷ []) toks of λ where -- if so we can forget about the current accumulator and -- restart the tokenizer on the rest of the input (just tok) → tok ∷ start cs -- otherwise we record the character we read in the accumulator, -- compute the derivative of the map of keyword candidates and -- keep going with the rest of the input nothing → loop (c ∷ acc) (lookupTrie c toks) cs -- Grab the accumulator and, unless it is empty, push it on top of -- the decoded list of tokens push : List Char → List Tok → List Tok push [] ts = ts push cs ts = default (String.fromList (List.reverse cs)) ∷ ts ------------------------------------------------------------------------ -- Concrete instance -- A small set of keywords for a language with expressions of the form -- `let x = e in b`. module LetIn where data TOK : Set where LET EQ IN : TOK LPAR RPAR : TOK ID : String → TOK keywords : List# (String × TOK) (λ a b → ⌊ ¬? ((proj₁ a) String.≟ (proj₁ b)) ⌋) keywords = ("let" , LET) ∷# ("=" , EQ) ∷# ("in" , IN) ∷# [] -- Breaking characters: spaces (thrown away) and parentheses (kept) breaking : Char → ∃ (λ b → if b then Maybe TOK else Lift 0ℓ ⊤) breaking c = if isSpace c then true , nothing else parens c where parens : Char → _ parens '(' = true , just LPAR parens ')' = true , just RPAR parens _ = false , _ default : String → TOK default = ID letIn : Lexer 0ℓ letIn = record { LetIn } open import Agda.Builtin.Equality -- A test case: open LetIn _ : tokenize letIn "fix f x = let b = fix f in (f b) x" ≡ ID "fix" ∷ ID "f" ∷ ID "x" ∷ EQ ∷ LET ∷ ID "b" ∷ EQ ∷ ID "fix" ∷ ID "f" ∷ IN ∷ LPAR ∷ ID "f" ∷ ID "b" ∷ RPAR ∷ ID "x" ∷ [] _ = refl
{ "alphanum_fraction": 0.5812404607, "avg_line_length": 32.6108597285, "ext": "agda", "hexsha": "66f1a24e9db3e4c364b401f77687a337e789200d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/README/Data/Trie/NonDependent.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/README/Data/Trie/NonDependent.agda", "max_line_length": 88, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/README/Data/Trie/NonDependent.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": 1867, "size": 7207 }
{-# OPTIONS --without-K --exact-split --safe #-} open import Fragment.Equational.Theory module Fragment.Equational.FreeExtension.Properties (Θ : Theory) where open import Fragment.Algebra.Algebra (Σ Θ) using (Algebra) open import Fragment.Algebra.Homomorphism (Σ Θ) open import Fragment.Algebra.Free (Σ Θ) open import Fragment.Equational.Model Θ open import Fragment.Equational.Coproduct Θ open import Fragment.Equational.FreeExtension.Base Θ open import Fragment.Equational.FreeExtension.Synthetic Θ using (SynFrex) open import Level using (Level) open import Data.Nat using (ℕ) open import Data.Vec using (Vec) open import Relation.Binary using (Setoid) import Relation.Binary.Reasoning.Setoid as Reasoning private variable a ℓ₁ : Level module _ (X : FreeExtension) (Y : FreeExtension) (A : Model {a} {ℓ₁}) (n : ℕ) where open FreeExtension X renaming (_[_] to _[_]₁; _[_]-isFrex to _[_]₁-isFrex) open FreeExtension Y renaming (_[_] to _[_]₂; _[_]-isFrex to _[_]₂-isFrex) open IsCoproduct (A [ n ]₁-isFrex) renaming (inl to inl₁; inr to inr₁; _[_,_] to _[_,_]₁; commute₁ to commute₁₁; commute₂ to commute₂₁) open IsCoproduct (A [ n ]₂-isFrex) renaming (inl to inl₂; inr to inr₂; _[_,_] to _[_,_]₂; commute₁ to commute₁₂; commute₂ to commute₂₂) using () to : ∥ A [ n ]₂ ∥ₐ ⟿ ∥ A [ n ]₁ ∥ₐ to = (A [ n ]₁) [ inl₁ , inr₁ ]₂ from : ∥ A [ n ]₁ ∥ₐ ⟿ ∥ A [ n ]₂ ∥ₐ from = (A [ n ]₂) [ inl₂ , inr₂ ]₁ inv : to ⊙ from ≗ id inv = begin to ⊙ from ≈⟨ ≗-sym {f = (A [ n ]₁) [ inl₁ , inr₁ ]₁} {g = to ⊙ from} (universal {h = to ⊙ from} c₁ c₂) ⟩ (A [ n ]₁) [ inl₁ , inr₁ ]₁ ≈⟨ universal {h = id} (id-unitˡ {f = inl₁}) (id-unitˡ {f = inr₁}) ⟩ id ∎ where c₁ : (to ⊙ from) ⊙ inl₁ ≗ inl₁ c₁ = begin (to ⊙ from) ⊙ inl₁ ≈⟨ ⊙-assoc to from inl₁ ⟩ to ⊙ (from ⊙ inl₁) ≈⟨ ⊙-congˡ to (from ⊙ inl₁) inl₂ (commute₁₁ {f = inl₂} {g = inr₂}) ⟩ to ⊙ inl₂ ≈⟨ commute₁₂ {X = A [ n ]₁} {f = inl₁} {g = inr₁} ⟩ inl₁ ∎ where open Reasoning (∥ A ∥ₐ ⟿ ∥ A [ n ]₁ ∥ₐ /≗) c₂ : (to ⊙ from) ⊙ inr₁ ≗ inr₁ c₂ = begin (to ⊙ from) ⊙ inr₁ ≈⟨ ⊙-assoc to from inr₁ ⟩ to ⊙ (from ⊙ inr₁) ≈⟨ ⊙-congˡ to (from ⊙ inr₁) inr₂ (commute₂₁ {f = inl₂} {g = inr₂}) ⟩ to ⊙ inr₂ ≈⟨ commute₂₂ {X = A [ n ]₁} {f = inl₁} {g = inr₁} ⟩ inr₁ ∎ where open Reasoning (∥ J n ∥ₐ ⟿ ∥ A [ n ]₁ ∥ₐ /≗) open Reasoning (∥ A [ n ]₁ ∥ₐ ⟿ ∥ A [ n ]₁ ∥ₐ /≗) module _ (X : FreeExtension) (Y : FreeExtension) (A : Model {a} {ℓ₁}) (n : ℕ) where open FreeExtension X renaming (_[_] to _[_]₁) open FreeExtension Y renaming (_[_] to _[_]₂) iso : ∥ A [ n ]₁ ∥ₐ ≃ ∥ A [ n ]₂ ∥ₐ iso = record { _⃗ = to Y X A n ; _⃖ = from Y X A n ; invˡ = inv Y X A n ; invʳ = inv X Y A n } module _ (X : FreeExtension) (A : Model {a} {ℓ₁}) {n : ℕ} where open FreeExtension X open FreeExtension SynFrex renaming (_[_] to _[_]ₛ; _[_]-isFrex to _[_]ₛ-isFrex) open IsCoproduct (A [ n ]-isFrex) open IsCoproduct (A [ n ]ₛ-isFrex) renaming (_[_,_] to _[_,_]ₛ) using () open Setoid ∥ A [ n ] ∥/≈ renaming (_≈_ to _≋_) open Setoid ∥ A ∥/≈ using (_≈_) norm = to X SynFrex A n syn = from X SynFrex A n reduce : (θ : Env ∥ A ∥ₐ n) → ∥ A [ n ]ₛ ∥ₐ ⟿ ∥ A ∥ₐ reduce θ = A [ id , interp A θ ]ₛ module _ (Γ : Vec ∥ A ∥ n) where private θ : Env ∥ A ∥ₐ n θ = env {A = ∥ A ∥ₐ} Γ frexify : ∀ {lhs rhs : Term (BT ∥ A ∥ n)} → ∣ norm ∣ lhs ≋ ∣ norm ∣ rhs → ∣ reduce θ ∣ lhs ≈ ∣ reduce θ ∣ rhs frexify {lhs = lhs} {rhs = rhs} p = begin ∣ reduce θ ∣ lhs ≈⟨ Setoid.sym ∥ A ∥/≈ (∣ reduce θ ∣-cong (inv SynFrex X A n {x = lhs})) ⟩ ∣ reduce θ ∣ (∣ syn ∣ (∣ norm ∣ lhs)) ≈⟨ ∣ reduce θ ∣-cong (∣ syn ∣-cong p) ⟩ ∣ reduce θ ∣ (∣ syn ∣ (∣ norm ∣ rhs)) ≈⟨ ∣ reduce θ ∣-cong (inv SynFrex X A n {x = rhs}) ⟩ ∣ reduce θ ∣ rhs ∎ where open Reasoning ∥ A ∥/≈
{ "alphanum_fraction": 0.5220379147, "avg_line_length": 30.3597122302, "ext": "agda", "hexsha": "191befb735309b0da163eeddb581260db0f6a5bc", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z", "max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z", "max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "yallop/agda-fragment", "max_forks_repo_path": "src/Fragment/Equational/FreeExtension/Properties.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z", "max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "yallop/agda-fragment", "max_issues_repo_path": "src/Fragment/Equational/FreeExtension/Properties.agda", "max_line_length": 104, "max_stars_count": 18, "max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yallop/agda-fragment", "max_stars_repo_path": "src/Fragment/Equational/FreeExtension/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z", "num_tokens": 1775, "size": 4220 }
{-# OPTIONS --rewriting #-} postulate _↦_ : {A : Set} → A → A → Set idr : {A : Set} {a : A} → a ↦ a {-# BUILTIN REWRITE _↦_ #-} record _×_ (A B : Set) : Set where constructor _,_ field fst : A snd : B postulate A B C : Set g : A → B → C f : A × B → C f (x , y) = g x y postulate D : Set P : (A → B → C) → D res : D rew : P (λ x y → g x y) ↦ res {-# REWRITE rew #-} test : P (λ x y → f (x , y)) ↦ res test = idr
{ "alphanum_fraction": 0.4565701559, "avg_line_length": 14.03125, "ext": "agda", "hexsha": "55b15b775473d0b0595359be33047a8417887550", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/Issue1660.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Succeed/Issue1660.agda", "max_line_length": 34, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/Issue1660.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": 199, "size": 449 }
{-# OPTIONS --universe-polymorphism #-} open import Categories.Category module Categories.Object.Coproduct {o ℓ e} (C : Category o ℓ e) where open Category C open import Level open import Categories.Opposite import Categories.Object.Product as ProductObject module Op× = ProductObject op -- Borrowed from Dan Doel's definition of coproducts record Coproduct (A B : Obj) : Set (o ⊔ ℓ ⊔ e) where field A+B : Obj i₁ : A ⇒ A+B i₂ : B ⇒ A+B [_,_] : ∀ {C} → (A ⇒ C) → (B ⇒ C) → (A+B ⇒ C) .commute₁ : ∀ {C} {f : A ⇒ C} {g : B ⇒ C} → [ f , g ] ∘ i₁ ≡ f .commute₂ : ∀ {C} {f : A ⇒ C} {g : B ⇒ C} → [ f , g ] ∘ i₂ ≡ g .universal : ∀ {C} {f : A ⇒ C} {g : B ⇒ C} {h : A+B ⇒ C} → h ∘ i₁ ≡ f → h ∘ i₂ ≡ g → [ f , g ] ≡ h .g-η : ∀ {C} {f : A+B ⇒ C} → [ f ∘ i₁ , f ∘ i₂ ] ≡ f g-η = universal Equiv.refl Equiv.refl .η : [ i₁ , i₂ ] ≡ id η = universal identityˡ identityˡ .[]-cong₂ : ∀ {C} → {f f′ : A ⇒ C} {g g′ : B ⇒ C} → f ≡ f′ → g ≡ g′ → [ f , g ] ≡ [ f′ , g′ ] []-cong₂ f≡f′ g≡g′ = universal (trans commute₁ (sym f≡f′)) (trans commute₂ (sym g≡g′)) where open Equiv record BinCoproducts : Set (suc o ⊔ ℓ ⊔ e) where field _+_ : (A B : Obj) -> Obj i₁ : {A B : Obj} -> A ⇒ (A + B) i₂ : {A B : Obj} -> B ⇒ (A + B) [_,_] : {A B : Obj} -> ∀ {C} → (A ⇒ C) → (B ⇒ C) → ((A + B) ⇒ C) .commute₁ : {A B : Obj} -> ∀ {C} {f : A ⇒ C} {g : B ⇒ C} → [ f , g ] ∘ i₁ ≡ f .commute₂ : {A B : Obj} -> ∀ {C} {f : A ⇒ C} {g : B ⇒ C} → [ f , g ] ∘ i₂ ≡ g .universal : {A B : Obj} -> ∀ {C} {f : A ⇒ C} {g : B ⇒ C} {h : (A + B) ⇒ C} → h ∘ i₁ ≡ f → h ∘ i₂ ≡ g → [ f , g ] ≡ h coproduct→product : ∀ {A B} → Coproduct A B → Op×.Product A B coproduct→product A+B = record { A×B = A+B.A+B ; π₁ = A+B.i₁ ; π₂ = A+B.i₂ ; ⟨_,_⟩ = A+B.[_,_] ; commute₁ = A+B.commute₁ ; commute₂ = A+B.commute₂ ; universal = A+B.universal } where module A+B = Coproduct A+B product→coproduct : ∀ {A B} → Op×.Product A B → Coproduct A B product→coproduct A×B = record { A+B = A×B.A×B ; i₁ = A×B.π₁ ; i₂ = A×B.π₂ ; [_,_] = A×B.⟨_,_⟩ ; commute₁ = A×B.commute₁ ; commute₂ = A×B.commute₂ ; universal = A×B.universal } where module A×B = Op×.Product A×B open import Categories.Morphisms Commutative : ∀ {A B} → (p₁ : Coproduct A B) (p₂ : Coproduct B A) → _≅_ C (Coproduct.A+B p₁) (Coproduct.A+B p₂) Commutative p₁ p₂ = opⁱ (Op×.Commutative (coproduct→product p₂) (coproduct→product p₁)) Associative : ∀ {X Y Z} (p₁ : Coproduct X Y) (p₂ : Coproduct Y Z) (p₃ : Coproduct X (Coproduct.A+B p₂)) (p₄ : Coproduct (Coproduct.A+B p₁) Z) → _≅_ C (Coproduct.A+B p₃) (Coproduct.A+B p₄) Associative p₁ p₂ p₃ p₄ = reverseⁱ C (opⁱ (Op×.Associative (coproduct→product p₁) (coproduct→product p₂) (coproduct→product p₃) (coproduct→product p₄)))
{ "alphanum_fraction": 0.5116198404, "avg_line_length": 32.7613636364, "ext": "agda", "hexsha": "a9789ee687fc392c2052d1346d9dffa21400250e", "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/Object/Coproduct.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/Object/Coproduct.agda", "max_line_length": 187, "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/Object/Coproduct.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": 1282, "size": 2883 }
open import Agda.Builtin.Equality open import Agda.Builtin.Nat record NoEta : Set where no-eta-equality constructor _,_ field fst : Nat snd : Nat open NoEta data ⊥ : Set where soft-fail : (a : NoEta) (x : Nat) → (fst a , x) ≡ a → ⊥ soft-fail a x () -- Should be yellow (not sure if empty) loop : ⊥ loop = soft-fail (0 , 0) 0 refl
{ "alphanum_fraction": 0.6296296296, "avg_line_length": 17.55, "ext": "agda", "hexsha": "415d45d36f74e528ddeb205985bc1ca2626cd259", "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/Issue4484b.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/Issue4484b.agda", "max_line_length": 57, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue4484b.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": 125, "size": 351 }
module NotStrictlyPositive where data False : Set where data Not (A : Set) : Set where not : (A -> False) -> Not A data Neg (A : Set) : Set where neg : Not A -> Neg A data Bad : Set where bad : Neg Bad -> Bad
{ "alphanum_fraction": 0.6153846154, "avg_line_length": 14.7333333333, "ext": "agda", "hexsha": "414684629c5acb4cf8d942d5eba8253fe8da358c", "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/NotStrictlyPositive.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/NotStrictlyPositive.agda", "max_line_length": 32, "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/NotStrictlyPositive.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 71, "size": 221 }
------------------------------------------------------------------------ -- Some properties that hold for Erased do not hold for every -- topological modality ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality module Erased.Counterexamples {e⁺} (eq : ∀ {a p} → Equality-with-J a p e⁺) where open Derived-definitions-and-properties eq open import Prelude open import Bijection eq using (_↔_) open import Equality.Decision-procedures eq open import Equivalence.Path-split eq open import Function-universe eq hiding (_∘_) open import Erased.Stability eq open import H-level eq open import H-level.Closure eq private variable a b ℓ ℓ′ p : Level A : Type a -- The zero modality. -- -- This modality is taken from "Modalities in Homotopy Type Theory" by -- Rijke, Shulman and Spitters. Zero : Type ℓ → Type ℓ Zero _ = ↑ _ ⊤ -- A type A is Zero-stable if Zero A implies A. Zero-stable : Type ℓ → Type ℓ Zero-stable A = Zero A → A -- A type is Zero-modal if it is contractible. -- -- This definition is based on "Modalities in Homotopy Type Theory" by -- Rijke, Shulman and Spitters. Zero-modal : Type ℓ → Type ℓ Zero-modal = Contractible -- Zero-modal types are Zero-stable. Zero-modal→Zero-stable : Zero-modal A → Zero-stable A Zero-modal→Zero-stable m _ = proj₁ m -- A type A has Zero-stable equality if x ≡ y is Zero-stable for all -- values x and y of type A. Zero-stable-≡ : Type a → Type a Zero-stable-≡ = For-iterated-equality 1 Zero-stable -- A type A has Zero-modal equality if x ≡ y is Zero-modal for all -- values x and y of type A. Zero-modal-≡ : Type a → Type a Zero-modal-≡ = For-iterated-equality 1 Zero-modal -- The zero modality is a Σ-closed reflective subuniverse. -- -- This proof is based on "Modalities in Homotopy Type Theory" by -- Rijke, Shulman and Spitters. Zero-modality : Σ-closed-reflective-subuniverse ℓ Zero-modality {ℓ = ℓ} = λ where .◯ → Zero .η → return .Is-modal → Zero-modal .Is-modal-propositional → λ ext → H-level-propositional ext 0 .Is-modal-◯ → ↑-closure 0 ⊤-contractible .Is-modal-respects-≃ → H-level-cong _ 0 .extendable-along-η → extendable .Σ-closed → Σ-closure 0 where open Σ-closed-reflective-subuniverse return : A → Zero A return = _ extendable : {A B : Type ℓ} → Zero-modal B → Is-∞-extendable-along-[ return {A = A} ] (λ (_ : Zero A) → B) extendable cB zero = _ extendable cB (suc n) = (λ g → (λ _ → proj₁ cB) , (λ x → proj₂ cB (g x))) , (λ _ _ → extendable (⇒≡ 0 cB) n) -- The zero modality is topological (for all universe levels). -- -- This result is based on "Modalities in Homotopy Type Theory" by -- Rijke, Shulman and Spitters. Zero-topological : Topological ℓ′ (Zero-modality {ℓ = ℓ}) Zero-topological {ℓ′ = ℓ′} {ℓ = ℓ} = ↑ ℓ′ ⊤ , (λ _ → ⊥) , (λ _ → ⊥-propositional) , (λ _ → record { to = to; from = from }) where open Σ-closed-reflective-subuniverse Zero-modality to : Zero-modal A → ↑ ℓ′ ⊤ → Is-∞-extendable-along-[ η ] (λ _ → A) to cA _ zero = _ to cA _ (suc n) = (λ _ → (λ _ → proj₁ cA) , (λ ())) , (λ _ _ → to (⇒≡ 0 cA) _ n) from : (↑ ℓ′ ⊤ → Is-∞-extendable-along-[ η ] (λ _ → A)) → Zero-modal A from {A = A} ext = inh , (λ x → ext _ 2 .proj₂ (const inh) (const x) .proj₁ ⊥-elim .proj₁ _) where inh : A inh = ext _ 1 .proj₁ ⊥-elim .proj₁ _ -- It is not the case that Zero ⊥ is isomorphic to ⊥. -- -- Compare with Erased.Level-1.Erased-⊥↔⊥. ¬[Zero-⊥↔⊥] : ¬ (Zero (⊥ {ℓ = ℓ}) ↔ ⊥ {ℓ = ℓ}) ¬[Zero-⊥↔⊥] hyp = $⟨ _ ⟩ ↑ _ ⊤ ↝⟨ hyp ⟩ ⊥ ↝⟨ ⊥↔⊥ ⟩□ ⊥₀ □ -- It is not the case that Zero A implies ¬ ¬ A for all types A. -- -- Compare with Erased.Stability.Erased→¬¬. ¬[Zero→¬¬] : ¬ ({A : Type a} → Zero A → ¬ ¬ A) ¬[Zero→¬¬] hyp = $⟨ _ ⟩ Zero ⊥ ↝⟨ hyp ⟩ ¬ ¬ ⊥ ↝⟨ ⊥-elim ∘ (_$ ⊥-elim) ⟩□ ⊥ □ -- It is not the case that, for all types A, if A is stable for -- double-negation, then A is Zero-stable. -- -- Compare with Erased.Stability.¬¬-stable→Stable. ¬[¬¬-stable→Zero-stable] : ¬ ({A : Type a} → (¬ ¬ A → A) → Zero-stable A) ¬[¬¬-stable→Zero-stable] hyp = $⟨ ⊥-elim ∘ (_$ ⊥-elim) ⟩ (¬ ¬ ⊥ → ⊥) ↝⟨ hyp ⟩ (Zero ⊥ → ⊥) ↝⟨ _$ _ ⟩ ⊥ ↔⟨ ⊥↔⊥ ⟩□ ⊥₀ □ -- It is not the case that, for all types A, if A is decided, then A -- is Zero-stable. -- -- Compare with Erased.Stability.Dec→Stable. ¬[Dec→Zero-stable] : ¬ ({A : Type a} → Dec A → Zero-stable A) ¬[Dec→Zero-stable] hyp = $⟨ inj₂ ⊥-elim ⟩ Dec ⊥ ↝⟨ hyp ⟩ (Zero ⊥ → ⊥) ↝⟨ _$ _ ⟩ ⊥ ↔⟨ ⊥↔⊥ ⟩□ ⊥₀ □ -- It is not the case that, for all types A, if equality is decidable -- for A, then equality for A is Zero-stable. ¬[Decidable-equality→Zero-stable-≡] : ¬ ({A : Type a} → Decidable-equality A → Zero-stable-≡ A) ¬[Decidable-equality→Zero-stable-≡] {a = a} hyp = $⟨ ↑.Dec._≟_ Bool._≟_ ⟩ Decidable-equality (↑ a Bool) ↝⟨ (λ dec → hyp dec _ _) ⟩ (Zero (lift true ≡ lift false) → lift true ≡ lift false) ↝⟨ _$ _ ⟩ lift true ≡ lift false ↝⟨ Bool.true≢false ∘ cong lower ⟩□ ⊥₀ □ -- It is not the case that, for all types A, if equality is decidable -- for A, then equality for A is Zero-modal. -- -- Compare with -- Erased.Stability.[]-cong₁.Decidable-equality→Very-stable-≡. ¬[Decidable-equality→Zero-modal-≡] : ¬ ({A : Type a} → Decidable-equality A → Zero-modal-≡ A) ¬[Decidable-equality→Zero-modal-≡] {a = a} = ({A : Type a} → Decidable-equality A → Zero-modal-≡ A) ↝⟨ (implicit-∀-cong _ $ ∀-cong _ λ _ → ∀-cong _ λ _ → ∀-cong _ λ _ → Zero-modal→Zero-stable) ⟩ ({A : Type a} → Decidable-equality A → Zero-stable-≡ A) ↝⟨ ¬[Decidable-equality→Zero-stable-≡] ⟩□ ⊥ □ -- It is not the case that the empty types are Zero-modal. -- -- Compare with Erased.Stability.Very-stable-⊥. ¬[Zero-modal-⊥] : ¬ Zero-modal (⊥ {ℓ = ℓ}) ¬[Zero-modal-⊥] = Contractible ⊥ ↝⟨ proj₁ ⟩ ⊥ ↔⟨ ⊥↔⊥ ⟩□ ⊥₀ □ -- It is not the case that, for any type A and type family P over A, -- if A is Zero-modal, then W A P is Zero-modal. -- -- Compare with Erased.Stability.[]-cong₂-⊔₁.Very-stable-W, which is -- proved under the assumption of function extensionality. ¬[Zero-modal-W] : ¬ ({A : Type a} {P : A → Type p} → Zero-modal A → Zero-modal (W A P)) ¬[Zero-modal-W] hyp = $⟨ ↑-closure 0 ⊤-contractible ⟩ Zero-modal (↑ _ ⊤) ↝⟨ hyp ⟩ Zero-modal (W (↑ _ ⊤) (λ _ → ↑ _ ⊤)) ↝⟨ proj₁ ⟩ W (↑ _ ⊤) (λ _ → ↑ _ ⊤) ↝⟨ inhabited⇒W-empty _ ⟩□ ⊥ □ -- It is not the case that, for all types A and B, if equality is -- Zero-stable for A and B, then equality is Zero-stable for A ⊎ B. -- -- Compare with Erased.Stability.Stable-≡-⊎. ¬[Zero-stable-≡-⊎] : ¬ ({A : Type a} {B : Type b} → Zero-stable-≡ A → Zero-stable-≡ B → Zero-stable-≡ (A ⊎ B)) ¬[Zero-stable-≡-⊎] hyp = $⟨ (λ _ _ _ → refl _) , (λ _ _ _ → refl _) ⟩ Zero-stable-≡ (↑ _ ⊤) × Zero-stable-≡ (↑ _ ⊤) ↝⟨ uncurry hyp ⟩ Zero-stable-≡ (↑ _ ⊤ ⊎ ↑ _ ⊤) ↝⟨ (_$ _) ∘ (_$ _) ∘ (_$ _) ⟩ inj₁ _ ≡ inj₂ _ ↝⟨ ⊎.inj₁≢inj₂ ⟩□ ⊥ □ -- It is not the case that, for all types A and B, if equality is -- Zero-modal for A and B, then equality is Zero-modal for A ⊎ B. -- -- Compare with Erased.Stability.[]-cong₂-⊔₂.Very-stable-≡-⊎. ¬[Zero-modal-≡-⊎] : ¬ ({A : Type a} {B : Type b} → Zero-modal-≡ A → Zero-modal-≡ B → Zero-modal-≡ (A ⊎ B)) ¬[Zero-modal-≡-⊎] hyp = $⟨ (λ _ _ → +⇒≡ (mono₁ 0 (↑-closure 0 ⊤-contractible))) , (λ _ _ → +⇒≡ (mono₁ 0 (↑-closure 0 ⊤-contractible))) ⟩ Zero-modal-≡ (↑ _ ⊤) × Zero-modal-≡ (↑ _ ⊤) ↝⟨ uncurry hyp ⟩ Zero-modal-≡ (↑ _ ⊤ ⊎ ↑ _ ⊤) ↝⟨ proj₁ ∘ (_$ _) ∘ (_$ _) ⟩ inj₁ _ ≡ inj₂ _ ↝⟨ ⊎.inj₁≢inj₂ ⟩□ ⊥ □ -- It is not the case that, for all types A, if equality is -- Zero-stable for A, then equality is Zero-stable for List A. -- -- Compare with Erased.Stability.Stable-≡-List. ¬[Zero-stable-≡-List] : ¬ ({A : Type a} → Zero-stable-≡ A → Zero-stable-≡ (List A)) ¬[Zero-stable-≡-List] hyp = $⟨ (λ _ _ _ → refl _) ⟩ Zero-stable-≡ (↑ _ ⊤) ↝⟨ hyp ⟩ Zero-stable-≡ (List (↑ _ ⊤)) ↝⟨ (_$ _) ∘ (_$ _) ∘ (_$ _) ⟩ [] ≡ _ ∷ [] ↝⟨ List.[]≢∷ ⟩□ ⊥ □ -- It is not the case that, for all types A, if equality is Zero-modal -- for A, then equality is Zero-modal for List A. -- -- Compare with Erased.Stability.[]-cong₁.Very-stable-≡-List. ¬[Zero-modal-≡-List] : ¬ ({A : Type a} → Zero-modal-≡ A → Zero-modal-≡ (List A)) ¬[Zero-modal-≡-List] hyp = $⟨ (λ _ _ → +⇒≡ (mono₁ 0 (↑-closure 0 ⊤-contractible))) ⟩ Zero-modal-≡ (↑ _ ⊤) ↝⟨ hyp ⟩ Zero-modal-≡ (List (↑ _ ⊤)) ↝⟨ proj₁ ∘ (_$ _) ∘ (_$ _) ⟩ [] ≡ _ ∷ [] ↝⟨ List.[]≢∷ ⟩□ ⊥ □
{ "alphanum_fraction": 0.5046382189, "avg_line_length": 33, "ext": "agda", "hexsha": "9d8afd8bf4825284dd54108b0532232e7f9d9fc4", "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/Erased/Counterexamples.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/Erased/Counterexamples.agda", "max_line_length": 112, "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/Erased/Counterexamples.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": 3572, "size": 9702 }
module Base.Prelude.Bool where open import Data.Bool using (Bool; true; false; if_then_else_) renaming (_∧_ to _∧ᵖ_; _∨_ to _∨ᵖ_; not to notᵖ) open import Base.Free using (Free; pure; _>>=_) 𝔹 : (Shape : Set) → (Shape → Set) → Set 𝔹 _ _ = Bool True : ∀ {S P} → Free S P (𝔹 S P) True = pure true False : ∀ {S P} → Free S P (𝔹 S P) False = pure false _∧_ : ∀ {S P} → Free S P (𝔹 S P) → Free S P (𝔹 S P) → Free S P (𝔹 S P) mx ∧ my = mx >>= λ x → if x then my else False _∨_ : ∀ {S P} → Free S P (𝔹 S P) → Free S P (𝔹 S P) → Free S P (𝔹 S P) mx ∨ my = mx >>= λ x → if x then True else my not : ∀ {S P} → Free S P (𝔹 S P) → Free S P (𝔹 S P) not mb = mb >>= λ b → pure (notᵖ b)
{ "alphanum_fraction": 0.5552282769, "avg_line_length": 29.5217391304, "ext": "agda", "hexsha": "919909b9210aa214a2a14eb23fc703ca87ec6f47", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-05-14T07:48:41.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-08T11:23:46.000Z", "max_forks_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "FreeProving/free-compiler", "max_forks_repo_path": "base/agda/Base/Prelude/Bool.agda", "max_issues_count": 120, "max_issues_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9", "max_issues_repo_issues_event_max_datetime": "2020-12-08T07:46:01.000Z", "max_issues_repo_issues_event_min_datetime": "2020-04-09T09:40:39.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "FreeProving/free-compiler", "max_issues_repo_path": "base/agda/Base/Prelude/Bool.agda", "max_line_length": 111, "max_stars_count": 36, "max_stars_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "FreeProving/free-compiler", "max_stars_repo_path": "base/agda/Base/Prelude/Bool.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-21T13:38:23.000Z", "max_stars_repo_stars_event_min_datetime": "2020-02-06T11:03:34.000Z", "num_tokens": 305, "size": 679 }
data D (A : Set) : Set where c₁ : D A _ : (@0 A : Set) → D A _ = λ A → c₁ {A = A} _ : (@0 A : Set) → D A _ = λ A → D.c₁ {A = A} record R (A : Set) : Set where constructor c₂ field f : A → A g : A → A g x = f (f x) open R public _ : (@0 A : Set) → (A → A) → R A _ = λ A → c₂ {A = A} _ : (@0 A : Set) → R A → A → A _ = λ A → f {A = A} _ : (@0 A : Set) → R A → A → A _ = λ A → R.f {A = A} _ : (A : Set) → R A → A → A _ = λ A → g {A = A} _ : (A : Set) → R A → A → A _ = λ A → R.g {A = A} open module R′ (A : Set) (r : R A) = R {A = A} r renaming (f to f′; g to g′) _ : (A : Set) → R A → A → A _ = λ A → f′ {A = A} _ : (A : Set) → R A → A → A _ = λ A → R′.f {A = A} _ : (A : Set) → R A → A → A _ = λ A → g′ A _ : (A : Set) → R A → A → A _ = λ A → R′.g A
{ "alphanum_fraction": 0.3717948718, "avg_line_length": 15.9183673469, "ext": "agda", "hexsha": "e64b9837aca90d454b7fb7e0e2c60bb4e56eefd1", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Succeed/Issue4786.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Succeed/Issue4786.agda", "max_line_length": 48, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Succeed/Issue4786.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": 394, "size": 780 }
{-# OPTIONS --without-K #-} module function.isomorphism.lift where open import level open import equality open import function.isomorphism.core -- lifting is an isomorphism lift-iso : ∀ {i} j (X : Set i) → X ≅ ↑ j X lift-iso j X = iso lift lower (λ _ → refl) (λ _ → refl)
{ "alphanum_fraction": 0.6824817518, "avg_line_length": 24.9090909091, "ext": "agda", "hexsha": "6d43eab330d76b4058c0375cc009292014b757f0", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_path": "src/function/isomorphism/lift.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/function/isomorphism/lift.agda", "max_line_length": 55, "max_stars_count": 27, "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_path": "function/isomorphism/lift.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "num_tokens": 82, "size": 274 }
{- Inductive eliminators to establish properties of all finite sets directly -} {-# OPTIONS --safe #-} module Cubical.Data.FinSet.Induction where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Equiv renaming (_∙ₑ_ to _⋆_) open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.HITs.PropositionalTruncation as Prop open import Cubical.HITs.SetTruncation as Set open import Cubical.Data.Nat renaming (_+_ to _+ℕ_) hiding (elim) open import Cubical.Data.Unit open import Cubical.Data.Empty as Empty open import Cubical.Data.Sum open import Cubical.Data.Fin renaming (Fin to Finℕ) open import Cubical.Data.SumFin open import Cubical.Data.FinSet.Base open import Cubical.Data.FinSet.Properties open import Cubical.Data.FinSet.Constructors private variable ℓ ℓ' : Level -- definitions mimicking that of natural numbers module _ {ℓ : Level} where 𝟘 : FinSet ℓ 𝟘 = ⊥* , 0 , ∣ uninhabEquiv Empty.rec* Empty.rec ∣ 𝟙 : FinSet ℓ 𝟙 = Unit* , isContr→isFinSet (isContrUnit*) _+_ : FinSet ℓ → FinSet ℓ → FinSet ℓ X + Y = X .fst ⊎ Y .fst , isFinSet⊎ X Y -- 𝔽in can be seen as a universe polymorphic version of SumFin 𝔽in : ℕ → FinSet ℓ 𝔽in 0 = 𝟘 𝔽in (suc n) = 𝟙 + 𝔽in n -- useful properties 𝟘≃Empty : 𝟘 .fst ≃ ⊥ 𝟘≃Empty = uninhabEquiv rec* (λ x → x) 𝟙≃Unit : 𝟙 .fst ≃ Unit 𝟙≃Unit = isContr→≃Unit (isContrUnit*) * : {n : ℕ} → 𝔽in (suc n) .fst * = inl tt* 𝔽in≃Fin : (n : ℕ) → 𝔽in n .fst ≃ Fin n 𝔽in≃Fin 0 = 𝟘≃Empty 𝔽in≃Fin (suc n) = ⊎-equiv 𝟙≃Unit (𝔽in≃Fin n) 𝔽in≃Finℕ : (n : ℕ) → 𝔽in n .fst ≃ Finℕ n 𝔽in≃Finℕ n = 𝔽in≃Fin n ⋆ SumFin≃Fin n -- 𝔽in preserves addition 𝟘+X≡X : {X : FinSet ℓ} → 𝟘 + X ≡ X 𝟘+X≡X {X = X} i .fst = ua (⊎-swap-≃ ⋆ ⊎-equiv (idEquiv (X .fst)) 𝟘≃Empty ⋆ ⊎-⊥-≃) i 𝟘+X≡X {X = X} i .snd = isProp→PathP {B = λ i → isFinSet (𝟘+X≡X {X = X} i .fst)} (λ _ → isPropIsFinSet) ((𝟘 + X) .snd) (X .snd) i 𝔽in1≡𝟙 : 𝔽in 1 ≡ 𝟙 𝔽in1≡𝟙 i .fst = ua (⊎-equiv (idEquiv (𝟙 .fst)) 𝟘≃Empty ⋆ ⊎-⊥-≃) i 𝔽in1≡𝟙 i .snd = isProp→PathP {B = λ i → isFinSet (𝔽in1≡𝟙 i .fst)} (λ _ → isPropIsFinSet) (𝔽in 1 .snd) (𝟙 .snd) i 𝔽in+ : (m n : ℕ) → 𝔽in m + 𝔽in n ≡ 𝔽in (m +ℕ n) 𝔽in+ 0 n = 𝟘+X≡X 𝔽in+ (suc m) n i .fst = (ua (⊎-assoc-≃) ∙ (λ i → (𝟙 + 𝔽in+ m n i) .fst)) i 𝔽in+ (suc m) n i .snd = isProp→PathP {B = λ i → isFinSet (𝔽in+ (suc m) n i .fst)} (λ _ → isPropIsFinSet) ((𝔽in (suc m) + 𝔽in n) .snd) (𝔽in (suc m +ℕ n) .snd) i -- every finite sets are merely equal to some 𝔽in ∣≡𝔽in∣ : (X : FinSet ℓ) → ∥ Σ[ n ∈ ℕ ] X ≡ 𝔽in n ∥ ∣≡𝔽in∣ X = Prop.map (λ (n , p) → n , path X (n , p)) (isFinSet→isFinSet' (X .snd)) where path : (X : FinSet ℓ) → ((n , _) : isFinOrd (X .fst)) → X ≡ 𝔽in n path X (n , p) i .fst = ua (p ⋆ invEquiv (𝔽in≃Fin n)) i path X (n , p) i .snd = isProp→PathP {B = λ i → isFinSet (path X (n , p) i .fst)} (λ _ → isPropIsFinSet) (X .snd) (𝔽in n .snd) i -- the eliminators module _ (P : FinSet ℓ → Type ℓ') (h : (X : FinSet ℓ) → isProp (P X)) where module _ (p : (n : ℕ) → P (𝔽in n)) where elimProp : (X : FinSet ℓ) → P X elimProp X = Prop.rec (h X) (λ (n , q) → transport (λ i → P (q (~ i))) (p n)) (∣≡𝔽in∣ X) module _ (p0 : P 𝟘) (p1 : {X : FinSet ℓ} → P X → P (𝟙 + X)) where elimProp𝔽in : (n : ℕ) → P (𝔽in n) elimProp𝔽in 0 = p0 elimProp𝔽in (suc n) = p1 (elimProp𝔽in n) elimProp𝟙+ : (X : FinSet ℓ) → P X elimProp𝟙+ = elimProp elimProp𝔽in module _ (p0 : P 𝟘)(p1 : P 𝟙) (p+ : {X Y : FinSet ℓ} → P X → P Y → P (X + Y)) where elimProp+ : (X : FinSet ℓ) → P X elimProp+ = elimProp𝟙+ p0 (λ p → p+ p1 p)
{ "alphanum_fraction": 0.5779014308, "avg_line_length": 28.3759398496, "ext": "agda", "hexsha": "e240fad93c95fd7a5d9b5c4780b2ce63b21b37b0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_path": "Cubical/Data/FinSet/Induction.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_path": "Cubical/Data/FinSet/Induction.agda", "max_line_length": 94, "max_stars_count": null, "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_path": "Cubical/Data/FinSet/Induction.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1833, "size": 3774 }
module Data.List.Combinatorics where import Lvl open import Data open import Data.List open import Data.List.Functions open Data.List.Functions.LongOper open import Data.Tuple as Tuple using (_⨯_ ; _,_) open import Data.Tuple.Raiseᵣ as Tuple₊ using (_^_) import Data.Tuple.Raiseᵣ.Functions as Tuple₊ open import Functional open import Numeral.Natural open import Type private variable ℓ : Lvl.Level private variable T : Type{ℓ} -- A list of all non-empty sublists of the specified list. -- The corresponding counting function is `(2 ^ n) − 1` where `n` is the length of the list. -- Note: -- In the inductive case, all of these are permutations of each other: -- • `foldᵣ (prev ↦ rest ↦ (prev ⊰ (x ⊰ prev) ⊰ rest)) ∅ (sublists₊ l)` (This is used because of its "natural" order) -- • `foldᵣ (prev ↦ rest ↦ ((x ⊰ prev) ⊰ prev ⊰ rest)) ∅ (sublists₊ l)` -- • `(map (x ⊰_) (sublists₊ l)) ++ (sublists₊ l)` -- • `(sublists₊ l) ++ (map (x ⊰_) (sublists₊ l))` -- Examples: -- sublists₊ [] = [] -- sublists₊ [1] = [[1]] -- sublists₊ [1,2] = [[1],[2],[1,2]] -- sublists₊ [1,2,3] = [[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]] -- sublists₊ [1,2,3,4] = [[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3],[4],[1,4],[2,4],[1,2,4],[3,4],[1,3,4],[2,3,4],[1,2,3,4]] sublists₊ : List(T) → List(List(T)) sublists₊ ∅ = ∅ sublists₊ (x ⊰ l) = singleton(x) ⊰ concatMap(y ↦ (y ⊰ (x ⊰ y) ⊰ ∅)) (sublists₊ l) -- A list of all sublists of the specified list. -- This is also the list of all subsets when the given list is a set (distinct elements). -- The corresponding counting function is `2 ^ n` where `n` is the length of the list. -- Examples: -- sublists [] = [[]] -- sublists [1] = [[],[1]] -- sublists [1,2] = [[],[1],[2],[1,2]] -- sublists [1,2,3] = [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]] -- sublists [1,2,3,4] = [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3],[4],[1,4],[2,4],[1,2,4],[3,4],[1,3,4],[2,3,4],[1,2,3,4]] sublists : List(T) → List(List(T)) sublists(l) = ∅ ⊰ sublists₊(l) -- A list of all combinations of the specified size of the specified list. -- The corresponding counting function is `𝑐𝐶(n,k)` where `n` is the length of the specified "multiset". -- All subsets of size `n` from the set `l`. -- Every unique subset of size n up to set equality. -- This is also a list of all sublists of the specified size of the specified list. -- Alternative definition that does not pass the termination checker: -- combinations : ℕ → List(T) → List(List(T)) -- combinations 0 _ = ∅ -- combinations _ ∅ = ∅ -- combinations 1 l = map singleton l -- combinations (𝐒(𝐒(n))) l = concat(map f(tails l)) where -- f : List(T) → List(List(T)) -- f ∅ = ∅ -- f(x ⊰ l) = map (x ⊰_) (combinations (𝐒(n)) l) -- Examples: -- combinations _ [] = [] -- combinations 0 [a,b,c,...] = [[]] when the list is non-empty -- combinations 1 [a,b,c,...] = [[a],[b],[c],...] when the list is non-empty -- combinations n l = [] when (n ≥ length(l)) -- combinations n l = [l] when (n = length(l)) -- combinations 2 [a,b,c] = [[a,b],[a,c],[b,c]] -- combinations 2 [a,b,c,d] = [[a,b],[a,c],[a,d],[b,c],[b,d],[c,d]] -- combinations 2 [a,b,c,d,e] = [[a,b],[a,c],[a,d],[a,e],[b,c],[b,d],[b,e],[c,d],[c,e],[d,e]] -- combinations 3 [a,b,c,d] = [[a,b,c],[a,b,d],[a,c,d],[b,c,d]] -- combinations 3 [a,b,c,d,e] = [[a,b,c],[a,b,d],[a,b,e],[a,c,d],[a,c,e],[a,d,e],[b,c,d],[b,c,e],[b,d,e],[c,d,e]] -- combinations 4 [a,b,c,d,e] = [[a,b,c,d],[a,b,c,e],[a,b,d,e],[a,c,d,e],[b,c,d,e]] combinations : (k : ℕ) → List(T) → List(T ^ k) combinations 0 _ = singleton(<>) combinations (𝐒(_)) ∅ = ∅ combinations 1 l@(_ ⊰ _) = l combinations (𝐒(𝐒(k))) (x ⊰ l) = (map(x ,_) (combinations (𝐒(k)) l)) ++ (combinations(𝐒(𝐒(k))) l) -- The corresponding counting function is `𝑐𝐶(n + k − 1 , k)` where `n` is the length of the specified "multiset". -- Examples: -- repeatableCombinations _ [] = [] -- repeatableCombinations 0 [a,b,c,...] = [[]] when the list is non-empty -- repeatableCombinations 1 [a,b,c,...] = [[a],[b],[c],...] when the list is non-empty -- repeatableCombinations n [a] = [repeat n a] -- repeatableCombinations 2 [a,b] = [[a,a],[a,b],[b,b]] -- repeatableCombinations 2 [a,b,c] = [[a,a],[a,b],[a,c],[b,b],[b,c],[c,c]] -- repeatableCombinations 3 [a,b] = [[a,a,a],[a,a,b],[a,b,b],[b,b,b]] -- repeatableCombinations 3 [a,b,c] = [[a,a,a],[a,a,b],[a,a,c],[a,b,b],[a,b,c],[a,c,c],[b,b,b],[b,b,c],[b,c,c],[c,c,c]] -- repeatableCombinations 4 [a,b] = [[a,a,a,a],[a,a,a,b],[a,a,b,b],[a,b,b,b],[b,b,b,b]] -- repeatableCombinations 4 [a,b,c] = [[a,a,a,a],[a,a,a,b],[a,a,a,c],[a,a,b,b],[a,a,b,c],[a,a,c,c],[a,b,b,b],[a,b,b,c],[a,b,c,c],[a,c,c,c],[b,b,b,b],[b,b,b,c],[b,b,c,c],[b,c,c,c],[c,c,c,c]] repeatableCombinations : (k : ℕ) → List(T) → List(T ^ k) repeatableCombinations 0 _ = singleton(<>) repeatableCombinations (𝐒(_)) ∅ = ∅ repeatableCombinations 1 l@(_ ⊰ _) = l repeatableCombinations (𝐒(𝐒(k))) (x ⊰ l) = (map (x ,_) (repeatableCombinations (𝐒(k)) (x ⊰ l))) ++ (repeatableCombinations (𝐒(𝐒(k))) l) -- A list of all tuples of length `n` from the "multiset" `l`. -- Every tuple combination of length `n`. -- The corresponding counting function is `k ^ n` where `k` is the length of the list. -- Examples: -- tuples 0 [a] = [()] -- tuples 1 [a] = [a] -- tuples 2 [a] = [(a,a)] -- tuples 0 [a,b] = [()] -- tuples 1 [a,b] = [a,b] -- tuples 2 [a,b] = [(a,a) , (a,b) , (b,a) , (b,b)] -- tuples 0 [a,b,c] = [()] -- tuples 1 [a,b,c] = [a,b,c] -- tuples 2 [a,b,c] = [(a,a) , (a,b) , (a,c) , (b,a) , (b,b) , (b,c) , (c,a) , (c,b), (c,c)] tuples : (n : ℕ) → List(T) → List(T ^ n) tuples 0 = const(singleton(<>)) tuples 1 = id tuples (𝐒(𝐒(n))) l = concatMap(x ↦ map (Tuple₊.prepend x) (tuples (𝐒(n)) l)) l -- A list of all rotations of a list. -- Examples: -- rotations [] = [] -- rotations [a] = [[a]] -- rotations [a,b] = [[a,b] , [b,a]] -- rotations [a,b,c] = [[a,b,c] , [b,c,a] , [c,a,b]] -- rotations [a,b,c,d] = [[a,b,c,d] , [b,c,d,a] , [c,d,a,b] , [d,a,b,c]] rotations : List(T) → List(List(T)) rotations l = accumulateIterate₀(length l) (rotateₗ(1)) l -- Accumulated `insertAt` for every position of the given list. -- Examples: -- insertedEverywhere i [] = [[i]] -- insertedEverywhere i [a] = [[i,a],[a,i]] -- insertedEverywhere i [a,b] = [[i,a,b],[a,i,b],[a,b,i]] -- insertedEverywhere i [a,b,c] = [[i,a,b,c],[a,i,b,c],[a,b,i,c],[a,b,c,i]] -- insertedEverywhere i [a,b,c,d] = [[i,a,b,c,d],[a,i,b,c,d],[a,b,i,c,d],[a,b,c,i,d],[a,b,c,d,i] insertedEverywhere : T → List(T) → List(List(T)) insertedEverywhere i ∅ = singleton(singleton i) insertedEverywhere i (x ⊰ l) = (i ⊰ x ⊰ l) ⊰ (map (prepend x) (insertedEverywhere i l)) -- Every reordering of the list's elements. -- Examples: -- permutations [] = [[]] -- permutations [a] = [[a]] -- permutations [a,b] = [[a,b],[b,a]] -- permutations [a,b,c] = [[a,b,c],[b,a,c],[b,c,a],[a,c,b],[c,a,b],[c,b,a]] -- permutations [a,b,c,d] = [[a,b,c,d],[b,a,c,d],[b,c,a,d],[b,c,d,a],[a,c,b,d],[c,a,b,d],[c,b,a,d],[c,b,d,a],[a,c,d,b],[c,a,d,b],[c,d,a,b],[c,d,b,a],[a,b,d,c],[b,a,d,c],[b,d,a,c],[b,d,c,a],[a,d,b,c],[d,a,b,c],[d,b,a,c],[d,b,c,a],[a,d,c,b],[d,a,c,b],[d,c,a,b],[d,c,b,a]] permutations : List(T) → List(List(T)) permutations ∅ = singleton(∅) permutations (x ⊰ ∅) = singleton(singleton x) permutations (x ⊰ l@(_ ⊰ _)) = concatMap (insertedEverywhere x) (permutations l)
{ "alphanum_fraction": 0.526336074, "avg_line_length": 52.5945945946, "ext": "agda", "hexsha": "9477d58d0657829d43fb0218570075f54eb2b980", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Data/List/Combinatorics.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Data/List/Combinatorics.agda", "max_line_length": 271, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Data/List/Combinatorics.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": 2930, "size": 7784 }
{-# OPTIONS --rewriting #-} module _ where open import Agda.Builtin.Bool open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Rewrite data D (A : Set) : Set₁ where c₁ : D A c₂ : Set → D A f : {A : Set} → D A → Set f c₁ = Bool f (c₂ X) = X postulate rew : (A : Set) → c₁ {A} ≡ c₂ A -- This rewrite rule is rejected because the A on the lhs of the rule -- only appears in a parameter position, but parameters are erased. -- Reconstructing the parameter would only be possible if we had -- access to the type during reduction, but we don't. {-# REWRITE rew #-} boom : f {Bool} c₁ ≡ Bool boom = refl
{ "alphanum_fraction": 0.6757624398, "avg_line_length": 23.0740740741, "ext": "agda", "hexsha": "e884dc3fdee84a5fe7ac2ffa204bc93ce689025b", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Fail/Issue5238-unbound-parameter.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Fail/Issue5238-unbound-parameter.agda", "max_line_length": 69, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Fail/Issue5238-unbound-parameter.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": 195, "size": 623 }
module Tactic.Reflection.Quote where open import Prelude open import Builtin.Reflection open import Builtin.Float open import Tactic.Reflection.Quote.Class public open import Tactic.Deriving.Quotable open import Container.Traversable --- Instances --- private QuoteLit : {A : Set} → (A → Literal) → Quotable A ` {{QuoteLit f}} x = lit (f x) -- Primitive types -- instance QuotableNat = QuoteLit nat QuotableWord64 = QuoteLit word64 QuotableFloat = QuoteLit float QuotableString = QuoteLit string QuotableChar = QuoteLit char QuotableName = QuoteLit name -- Standard data types -- unquoteDecl QuotableBool = deriveQuotable QuotableBool (quote Bool) unquoteDecl QuotableList = deriveQuotable QuotableList (quote List) unquoteDecl QuotableMaybe = deriveQuotable QuotableMaybe (quote Maybe) unquoteDecl QuotableEither = deriveQuotable QuotableEither (quote Either) instance QuotableΣ : ∀ {a b} {A : Set a} {B : A → Set b} {{_ : Quotable A}} {{_ : {x : A} → Quotable (B x)}} → Quotable (Σ A λ a → B a) QuotableΣ = record { ` = λ { (x , y) → con (quote _,_) ((vArg (` x)) ∷ vArg (` y) ∷ [])} } unquoteDecl Quotable⊤ = deriveQuotable Quotable⊤ (quote ⊤) unquoteDecl Quotable⊥ = deriveQuotable Quotable⊥ (quote ⊥) unquoteDecl Quotable≡ = deriveQuotable Quotable≡ (quote _≡_) unquoteDecl QuotableComparison = deriveQuotable QuotableComparison (quote Comparison) unquoteDecl QuotableLessNat = deriveQuotable QuotableLessNat (quote LessNat) unquoteDecl QuotableInt = deriveQuotable QuotableInt (quote Int) -- The reflection machinery can't deal with computational irrelevance (..) -- unquoteDecl QuotableFin = deriveQuotable QuotableFin (quote Fin) -- unquoteDecl QuotableVec = deriveQuotable QuotableVec (quote Vec) instance QuotableFin : ∀ {n} → Quotable (Fin n) ` {{QuotableFin}} zero = con (quote Fin.zero) [] ` {{QuotableFin}} (suc i) = con (quote Fin.suc) (vArg (` i) ∷ []) QuotableVec : ∀ {a} {A : Set a} {n} {{_ : Quotable A}} → Quotable (Vec A n) ` {{QuotableVec}} [] = con (quote Vec.[]) [] ` {{QuotableVec}} (x ∷ xs) = con (quote Vec._∷_) (vArg (` x) ∷ vArg (` xs) ∷ []) -- Reflection types -- instance QuotableMeta : Quotable Meta ` {{QuotableMeta}} x = lit (meta x) private deriveQuotableTermTypes : Vec Name _ → TC ⊤ deriveQuotableTermTypes is = do let ts : Vec Name _ ts = quote Term ∷ quote Clause ∷ quote Sort ∷ [] its = ⦇ is , ts ⦈ traverse (uncurry declareQuotableInstance) its traverse (uncurry defineQuotableInstance) its pure _ unquoteDecl QuotableVisibility QuotableRelevance QuotableArgInfo QuotableArg QuotableAbs QuotableLiteral = do deriveQuotable QuotableVisibility (quote Visibility) deriveQuotable QuotableRelevance (quote Relevance) deriveQuotable QuotableArgInfo (quote ArgInfo) deriveQuotable QuotableArg (quote Arg) deriveQuotable QuotableAbs (quote Abs) deriveQuotable QuotableLiteral (quote Literal) {-# TERMINATING #-} unquoteDecl QuotablePattern QuotableTerm QuotableClause QuotableSort = do deriveQuotable QuotablePattern (quote Pattern) deriveQuotableTermTypes (QuotableTerm ∷ QuotableClause ∷ QuotableSort ∷ []) quoteList : List Term → Term quoteList = foldr (λ x xs → con (quote List._∷_) (vArg x ∷ vArg xs ∷ [])) (con (quote List.[]) [])
{ "alphanum_fraction": 0.6823156682, "avg_line_length": 38.5777777778, "ext": "agda", "hexsha": "45f08e4f99a4d2a3214a0b5cc2b560bbc98ef869", "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/Tactic/Reflection/Quote.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/Tactic/Reflection/Quote.agda", "max_line_length": 128, "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/Tactic/Reflection/Quote.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1095, "size": 3472 }
-- This combination should not be allowed: {-# OPTIONS --safe --guardedness --sized-types #-} -- note that `--safe` turns off `--guardedness` and `--sized-types`, -- hence `--guardedness --sized-types --safe` works, but does not -- mean the above combination
{ "alphanum_fraction": 0.6781609195, "avg_line_length": 32.625, "ext": "agda", "hexsha": "e5aaa41652df202f5f427aa977e180a51af81435", "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/Issue1209-3.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/Issue1209-3.agda", "max_line_length": 68, "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/Issue1209-3.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": 66, "size": 261 }
open import Data.Product using ( ∃ ; _×_ ) open import FRP.LTL.RSet.Core using ( RSet ; _[_,_⟩ ) open import FRP.LTL.Time using ( _≤_ ) module FRP.LTL.RSet.Until where infixr 2 _U_ _U_ : RSet → RSet → RSet (A U B) t = ∃ λ u → (t ≤ u) × (A [ t , u ⟩) × B u
{ "alphanum_fraction": 0.5961538462, "avg_line_length": 21.6666666667, "ext": "agda", "hexsha": "2e07aa388942b496fb4f19d56850f4e3228f1c7c", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z", "max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-frp-ltl", "max_forks_repo_path": "src/FRP/LTL/RSet/Until.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-frp-ltl", "max_issues_repo_path": "src/FRP/LTL/RSet/Until.agda", "max_line_length": 53, "max_stars_count": 21, "max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-frp-ltl", "max_stars_repo_path": "src/FRP/LTL/RSet/Until.agda", "max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z", "num_tokens": 109, "size": 260 }
open import Data.Product using ( proj₁ ; proj₂ ) open import Data.Sum using ( _⊎_ ; inj₁ ; inj₂ ) open import Relation.Binary.PropositionalEquality using ( refl ) open import Web.Semantic.DL.ABox.Interp using ( ⌊_⌋ ; ind ; _*_ ) open import Web.Semantic.DL.ABox.Interp.Morphism using ( _,_ ) open import Web.Semantic.DL.ABox.Model using ( _⊨a_ ; on-bnode ; bnodes ; _,_ ; ⊨a-resp-≲ ) open import Web.Semantic.DL.Category.Composition using ( _∙_ ) open import Web.Semantic.DL.Category.Properties.Composition.Lemmas using ( compose-left ; compose-right ; compose-resp-⊨a ) open import Web.Semantic.DL.Category.Properties.Tensor.Lemmas using ( tensor-up ; tensor-down ; tensor-resp-⊨a ) open import Web.Semantic.DL.Category.Object using ( Object ; IN ; fin ) open import Web.Semantic.DL.Category.Morphism using ( _⇒_ ; BN ; impl ; _⊑_ ; _≣_ ; _,_ ) open import Web.Semantic.DL.Category.Tensor using ( _⊗_ ; _⟨⊗⟩_ ) open import Web.Semantic.DL.Category.Unit using ( I ) open import Web.Semantic.DL.Category.Wiring using ( wires-≈ ; wires-≈⁻¹ ; assoc ) open import Web.Semantic.DL.Signature using ( Signature ) open import Web.Semantic.DL.TBox using ( TBox ) open import Web.Semantic.DL.TBox.Interp using ( Δ ; _⊨_≈_ ; ≈-refl ; ≈-refl′ ; ≈-sym ) open import Web.Semantic.DL.TBox.Interp.Morphism using ( ≲-refl ) open import Web.Semantic.Util using ( _∘_ ; False ; ⊎-assoc ; ⊎-assoc⁻¹ ; _⊕_⊕_ ; inode ; bnode ; enode ; left ; right ; up ; down ) module Web.Semantic.DL.Category.Properties.Tensor.AssocNatural {Σ : Signature} {S T : TBox Σ} where assoc-natural : ∀ {A₁ A₂ A₃ B₁ B₂ B₃ : Object S T} (F₁ : A₁ ⇒ B₁) (F₂ : A₂ ⇒ B₂) (F₃ : A₃ ⇒ B₃) → (((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) ∙ assoc B₁ B₂ B₃ ≣ assoc A₁ A₂ A₃ ∙ (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃))) assoc-natural {A₁} {A₂} {A₃} {B₁} {B₂} {B₃} F₁ F₂ F₃ = (LHS⊑RHS , RHS⊑LHS) where LHS⊑RHS : ((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) ∙ assoc B₁ B₂ B₃ ⊑ assoc A₁ A₂ A₃ ∙ (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃)) LHS⊑RHS J J⊨STA J⊨LHS = (f , J⊨RHS) where f : (False ⊕ (IN A₁ ⊎ (IN A₂ ⊎ IN A₃)) ⊕ (BN F₁ ⊎ (BN F₂ ⊎ BN F₃))) → Δ ⌊ J ⌋ f (inode ()) f (bnode x) = ind J (inode (⊎-assoc⁻¹ x)) f (enode v) = ind J (bnode (inode (⊎-assoc⁻¹ v))) lemma₁ : ∀ x → ⌊ J ⌋ ⊨ ind J (left (up (up x))) ≈ on-bnode f (ind J) (right (up x)) lemma₁ (inode x) = ≈-refl ⌊ J ⌋ lemma₁ (bnode v) = ≈-refl ⌊ J ⌋ lemma₁ (enode y) = wires-≈ ⊎-assoc⁻¹ (proj₂ (fin (B₁ ⊗ (B₂ ⊗ B₃))) (inj₁ y)) (compose-right ((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) (assoc B₁ B₂ B₃) J J⊨LHS) lemma₂ : ∀ x → ⌊ J ⌋ ⊨ ind J (left (up (down x))) ≈ on-bnode f (ind J) (right (down (up x))) lemma₂ (inode x) = ≈-refl ⌊ J ⌋ lemma₂ (bnode v) = ≈-refl ⌊ J ⌋ lemma₂ (enode y) = wires-≈ ⊎-assoc⁻¹ (proj₂ (fin (B₁ ⊗ (B₂ ⊗ B₃))) (inj₂ (inj₁ y))) (compose-right ((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) (assoc B₁ B₂ B₃) J J⊨LHS) lemma₃ : ∀ x → ⌊ J ⌋ ⊨ ind J (left (down x)) ≈ on-bnode f (ind J) (right (down (down x))) lemma₃ (inode x) = ≈-refl ⌊ J ⌋ lemma₃ (bnode v) = ≈-refl ⌊ J ⌋ lemma₃ (enode y) = wires-≈ ⊎-assoc⁻¹ (proj₂ (fin (B₁ ⊗ (B₂ ⊗ B₃))) (inj₂ (inj₂ y))) (compose-right ((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) (assoc B₁ B₂ B₃) J J⊨LHS) J⊨RHS : bnodes J f ⊨a impl (assoc A₁ A₂ A₃ ∙ (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃))) J⊨RHS = compose-resp-⊨a (assoc A₁ A₂ A₃) (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃)) (bnodes J f) (wires-≈⁻¹ ⊎-assoc⁻¹ (λ x → ≈-refl ⌊ J ⌋) (proj₁ (fin (A₁ ⊗ (A₂ ⊗ A₃))))) (tensor-resp-⊨a F₁ (F₂ ⟨⊗⟩ F₃) (right * bnodes J f) (⊨a-resp-≲ (≲-refl ⌊ J ⌋ , lemma₁) (impl F₁) (tensor-up F₁ F₂ (up * left * J) (tensor-up (F₁ ⟨⊗⟩ F₂) F₃ (left * J) (compose-left ((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) (assoc B₁ B₂ B₃) J J⊨LHS)))) (tensor-resp-⊨a F₂ F₃ (down * right * bnodes J f) (⊨a-resp-≲ (≲-refl ⌊ J ⌋ , lemma₂) (impl F₂) (tensor-down F₁ F₂ (up * left * J) (tensor-up (F₁ ⟨⊗⟩ F₂) F₃ (left * J) (compose-left ((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) (assoc B₁ B₂ B₃) J J⊨LHS)))) (⊨a-resp-≲ (≲-refl ⌊ J ⌋ , lemma₃) (impl F₃) (tensor-down (F₁ ⟨⊗⟩ F₂) F₃ (left * J) (compose-left ((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) (assoc B₁ B₂ B₃) J J⊨LHS))))) RHS⊑LHS : assoc A₁ A₂ A₃ ∙ (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃)) ⊑ ((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) ∙ assoc B₁ B₂ B₃ RHS⊑LHS J J⊨STA J⊨RHS = (f , J⊨LHS) where f : (((BN F₁ ⊎ BN F₂) ⊎ BN F₃) ⊕ ((IN B₁ ⊎ IN B₂) ⊎ IN B₃) ⊕ False) → Δ ⌊ J ⌋ f (inode v) = ind J (bnode (enode (⊎-assoc v))) f (bnode y) = ind J (enode (⊎-assoc y)) f (enode ()) lemma₀ : ∀ x → ⌊ J ⌋ ⊨ ind J (enode (⊎-assoc (⊎-assoc⁻¹ x))) ≈ ind J (enode x) lemma₀ (inj₁ x) = ≈-refl ⌊ J ⌋ lemma₀ (inj₂ (inj₁ x)) = ≈-refl ⌊ J ⌋ lemma₀ (inj₂ (inj₂ y)) = ≈-refl ⌊ J ⌋ lemma₁ : ∀ x → ⌊ J ⌋ ⊨ ind J (right (up x)) ≈ on-bnode f (ind J) (left (up (up x))) lemma₁ (inode x) = ≈-sym ⌊ J ⌋ (wires-≈ ⊎-assoc⁻¹ (proj₂ (fin (A₁ ⊗ (A₂ ⊗ A₃))) (inj₁ x)) (compose-left (assoc A₁ A₂ A₃) (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃)) J J⊨RHS)) lemma₁ (bnode v) = ≈-refl ⌊ J ⌋ lemma₁ (enode y) = ≈-refl ⌊ J ⌋ lemma₂ : ∀ x → ⌊ J ⌋ ⊨ ind J (right (down (up x))) ≈ on-bnode f (ind J) (left (up (down x))) lemma₂ (inode x) = ≈-sym ⌊ J ⌋ (wires-≈ ⊎-assoc⁻¹ (proj₂ (fin (A₁ ⊗ (A₂ ⊗ A₃))) (inj₂ (inj₁ x))) (compose-left (assoc A₁ A₂ A₃) (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃)) J J⊨RHS)) lemma₂ (bnode v) = ≈-refl ⌊ J ⌋ lemma₂ (enode y) = ≈-refl ⌊ J ⌋ lemma₃ : ∀ x → ⌊ J ⌋ ⊨ ind J (right (down (down x))) ≈ on-bnode f (ind J) (left (down x)) lemma₃ (inode x) = ≈-sym ⌊ J ⌋ (wires-≈ ⊎-assoc⁻¹ (proj₂ (fin (A₁ ⊗ (A₂ ⊗ A₃))) (inj₂ (inj₂ x))) (compose-left (assoc A₁ A₂ A₃) (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃)) J J⊨RHS)) lemma₃ (bnode v) = ≈-refl ⌊ J ⌋ lemma₃ (enode y) = ≈-refl ⌊ J ⌋ J⊨LHS : bnodes J f ⊨a impl (((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) ∙ assoc B₁ B₂ B₃) J⊨LHS = compose-resp-⊨a ((F₁ ⟨⊗⟩ F₂) ⟨⊗⟩ F₃) (assoc B₁ B₂ B₃) (bnodes J f) (tensor-resp-⊨a (F₁ ⟨⊗⟩ F₂) F₃ (left * bnodes J f) (tensor-resp-⊨a F₁ F₂ (up * left * bnodes J f) (⊨a-resp-≲ (≲-refl ⌊ J ⌋ , lemma₁) (impl F₁) (tensor-up F₁ (F₂ ⟨⊗⟩ F₃) (right * J) (compose-right (assoc A₁ A₂ A₃) (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃)) J J⊨RHS))) (⊨a-resp-≲ (≲-refl ⌊ J ⌋ , lemma₂) (impl F₂) (tensor-up F₂ F₃ (down * right * J) (tensor-down F₁ (F₂ ⟨⊗⟩ F₃) (right * J) (compose-right (assoc A₁ A₂ A₃) (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃)) J J⊨RHS))))) (⊨a-resp-≲ (≲-refl ⌊ J ⌋ , lemma₃) (impl F₃) (tensor-down F₂ F₃ (down * right * J) (tensor-down F₁ (F₂ ⟨⊗⟩ F₃) (right * J) (compose-right (assoc A₁ A₂ A₃) (F₁ ⟨⊗⟩ (F₂ ⟨⊗⟩ F₃)) J J⊨RHS))))) (wires-≈⁻¹ ⊎-assoc⁻¹ lemma₀ (proj₁ (fin (B₁ ⊗ (B₂ ⊗ B₃)))))
{ "alphanum_fraction": 0.5134615385, "avg_line_length": 46.301369863, "ext": "agda", "hexsha": "23eab2a3262d9a65b242eabef28b2b667eeea423", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z", "max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z", "max_forks_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-web-semantic", "max_forks_repo_path": "src/Web/Semantic/DL/Category/Properties/Tensor/AssocNatural.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-web-semantic", "max_issues_repo_path": "src/Web/Semantic/DL/Category/Properties/Tensor/AssocNatural.agda", "max_line_length": 82, "max_stars_count": 9, "max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-web-semantic", "max_stars_repo_path": "src/Web/Semantic/DL/Category/Properties/Tensor/AssocNatural.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z", "num_tokens": 3463, "size": 6760 }
{-# OPTIONS --allow-unsolved-metas #-} module ExtractDependent where open import Agda.Builtin.Nat open import Agda.Builtin.Bool open import Agda.Builtin.String apply : (A : Set) -> (B : A -> Set) -> ((x : A) -> B x) -> (a : A) -> B a apply A B f a = f a applySameName : (A : Set) -> (A : Set) -> (B : A -> Set) -> (h : Set) -> (h : (x : A) -> B x) -> (a : A) -> B a applySameName C A B g f a = f a -- TODO : Try same test with {A} {B} once the parser can handle that. applyImp : {A : Set} -> {B : A -> Set} -> ((x : A) -> B x) -> (y : A) -> B y applyImp f a = f a applyImpSameName : {A : Set} -> {A : Set} -> {B : A -> Set} -> (h : Set) -> (h : (x : A) -> B x) -> (a : A) -> B a applyImpSameName A B h = B h
{ "alphanum_fraction": 0.4823066841, "avg_line_length": 31.7916666667, "ext": "agda", "hexsha": "0dbc17d8be3077d445ac130cd7e0b82ea1b23fb5", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-01-31T08:40:41.000Z", "max_forks_repo_forks_event_min_datetime": "2019-01-31T08:40:41.000Z", "max_forks_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "omega12345/RefactorAgda", "max_forks_repo_path": "RefactorAgdaEngine/Test/Tests/input/ExtractDependent.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_issues_repo_issues_event_max_datetime": "2019-02-05T12:53:36.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-31T08:03:07.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "omega12345/RefactorAgda", "max_issues_repo_path": "RefactorAgdaEngine/Test/Tests/input/ExtractDependent.agda", "max_line_length": 69, "max_stars_count": 5, "max_stars_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "omega12345/RefactorAgda", "max_stars_repo_path": "RefactorAgdaEngine/Test/Tests/input/ExtractDependent.agda", "max_stars_repo_stars_event_max_datetime": "2019-05-03T10:03:36.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-31T14:10:18.000Z", "num_tokens": 282, "size": 763 }
module FizzBuzz where {-# IMPORT Data.Word #-} {-# IMPORT FizzBuzz #-} open import Data.Nat open import IO.Primitive open import Foreign.Haskell postulate ℕ′ : Set zero′ : ℕ′ suc′ : ℕ′ → ℕ′ {-# COMPILED_TYPE ℕ′ Data.Word.Word32 #-} {-# COMPILED zero′ 0 #-} {-# COMPILED suc′ succ #-} fromℕ : ℕ → ℕ′ fromℕ zero = zero′ fromℕ (suc n) = suc′ (fromℕ n) postulate FizzBuzz : ℕ′ → IO Unit {-# COMPILED FizzBuzz FizzBuzz.fizzBuzz #-} main : IO Unit main = FizzBuzz (fromℕ 10000)
{ "alphanum_fraction": 0.646090535, "avg_line_length": 16.7586206897, "ext": "agda", "hexsha": "b214c48136d8e17c5d31b07d42fd7cfde5054bd1", "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": "49de45be6a59c63402aac09e23c84a581f70e393", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Taneb/AgdaCBuzz", "max_forks_repo_path": "agdabits/FizzBuzz.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "49de45be6a59c63402aac09e23c84a581f70e393", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Taneb/AgdaCBuzz", "max_issues_repo_path": "agdabits/FizzBuzz.agda", "max_line_length": 43, "max_stars_count": null, "max_stars_repo_head_hexsha": "49de45be6a59c63402aac09e23c84a581f70e393", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Taneb/AgdaCBuzz", "max_stars_repo_path": "agdabits/FizzBuzz.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 169, "size": 486 }
-- -- Inspired by a blog post written by Arnaud Bailly -- https://abailly.github.io/posts/dependently-typed-date.html -- {-# OPTIONS --without-K #-} module Date where open import Data.Nat using (ℕ; zero; suc; _≡ᵇ_; _<_; _≤_; z≤n; s≤s; _≤?_; _<?_) open import Data.Nat.DivMod using (_%_) open import Data.Bool using (Bool; true; false; _∧_; _∨_; not) open import Data.Maybe using (Maybe; just; nothing) open import Relation.Nullary using (yes; no) open import Relation.Nullary.Decidable using (True; toWitness) import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; _≢_; refl; cong) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _≡⟨_⟩_; _∎; step-≡) module Day where data t : Set where Day : (n : ℕ) → {True (1 ≤? n)} → t -- Capture a day which should not be zero make : (n : ℕ) → {True (1 ≤? n)} → t make = Day value : t → ℕ value (Day n) = n module Year where t : Set t = ℕ isLeap : t → Bool isLeap y = (check4 ∧ not check100) ∨ check400 where check4 = y % 4 ≡ᵇ 0 check100 = y % 100 ≡ᵇ 0 check400 = y % 400 ≡ᵇ 0 module Month where data t : Set where January : t February : t March : t April : t May : t June : t July : t August : t September : t October : t November : t December : t toNat : t → ℕ toNat January = 1 toNat February = 2 toNat March = 3 toNat April = 4 toNat May = 5 toNat June = 6 toNat July = 7 toNat August = 8 toNat September = 9 toNat October = 10 toNat November = 11 toNat December = 12 next : t → t next January = February next February = March next March = April next April = May next May = June next June = July next July = August next August = September next September = October next October = November next November = December next December = January duration : t → Year.t → Day.t duration January _ = Day.make 31 duration February year with Year.isLeap year ... | true = Day.make 29 ... | false = Day.make 28 duration March _ = Day.make 31 duration April _ = Day.make 30 duration May _ = Day.make 31 duration June _ = Day.make 30 duration July _ = Day.make 31 duration August _ = Day.make 31 duration September _ = Day.make 30 duration October _ = Day.make 31 duration November _ = Day.make 30 duration December _ = Day.make 31 {- module Date where data t : Set where Valid : (year : Year.t) → (month : Month.t) → (day : ℕ) → {≤max : True (day ≤? Day.value (Month.duration month year))} → {min≤ : True (1 ≤? day)} -------------------------------------------------------------- → t make = Valid changeMonth : (year : Year.t) → (month : Month.t) -> t changeMonth year Month.December = make (suc year) Month.January 1 changeMonth year month = make year (Month.next month) 1 addOneDay : t → t addOneDay (Valid year month day) with (suc day) ≤? Day.value (Month.duration month year) ... | yes proof = Valid year month (suc day) {proof} {s≤s z≤n} ... | no _ = changeMonth year month addOneDay d = d -} module Date where data t : Set where Valid : (year : Year.t) → (month : Month.t) → (day : ℕ) → {≤max : day ≤ Day.value (Month.duration month year)} → {min≤ : 1 ≤ day} -------------------------------------------------------------- → t Invalid : t 1≤month : ∀ {month year} -> 1 ≤ Day.value (Month.duration month year) 1≤month {Month.January} {year} = begin 1 ≤ Day.value (Month.duration month year) {- make : (year : Year.t) → (month : Month.t) → (day : ℕ) → t make year month day with day ≤? Day.value (Month.duration month year) | 1 ≤? day ... | yes p1 | yes p2 = Valid year month day {p1} {p2} ... | _ | _ = Invalid changeMonth : (year : Year.t) → (month : Month.t) -> t changeMonth year Month.December = Valid (suc year) Month.January 1 {1≤month} {s≤s z≤n} changeMonth year month = Valid year (Month.next month) 1 {1≤month} {s≤s z≤n} addOneDay : t → t addOneDay (Valid year month day) with (suc day) ≤? Day.value (Month.duration month year) ... | yes proof = Valid year month (suc day) {proof} {s≤s z≤n} ... | no _ = changeMonth year month addOneDay d = d -- addDays : t → ℕ → t -}
{ "alphanum_fraction": 0.5305909376, "avg_line_length": 31.0974025974, "ext": "agda", "hexsha": "82f0a57744c402218811e80dfd7ca389c2ab678a", "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": "a81447af3ab2ba898bb7d57be71369abbba12d81", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "d-plaindoux/colca", "max_forks_repo_path": "src/exercices/Date.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a81447af3ab2ba898bb7d57be71369abbba12d81", "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": "d-plaindoux/colca", "max_issues_repo_path": "src/exercices/Date.agda", "max_line_length": 92, "max_stars_count": 2, "max_stars_repo_head_hexsha": "a81447af3ab2ba898bb7d57be71369abbba12d81", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "d-plaindoux/colca", "max_stars_repo_path": "src/exercices/Date.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-04T09:35:36.000Z", "max_stars_repo_stars_event_min_datetime": "2021-03-12T18:31:14.000Z", "num_tokens": 1471, "size": 4789 }
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-} module Cubical.Data.InfNat.Base where open import Cubical.Data.Nat as ℕ using (ℕ) open import Cubical.Core.Primitives data ℕ+∞ : Type₀ where ∞ : ℕ+∞ fin : ℕ → ℕ+∞ suc : ℕ+∞ → ℕ+∞ suc ∞ = ∞ suc (fin n) = fin (ℕ.suc n) zero : ℕ+∞ zero = fin ℕ.zero caseInfNat : ∀ {ℓ} → {A : Type ℓ} → (aF aI : A) → ℕ+∞ → A caseInfNat aF aI (fin n) = aF caseInfNat aF aI ∞ = aI infixl 6 _+_ _+_ : ℕ+∞ → ℕ+∞ → ℕ+∞ ∞ + m = ∞ fin n + ∞ = ∞ fin n + fin m = fin (n ℕ.+ m) infixl 7 _·_ _·_ : ℕ+∞ → ℕ+∞ → ℕ+∞ fin m · fin n = fin (m ℕ.· n) ∞ · fin ℕ.zero = zero fin ℕ.zero · ∞ = zero ∞ · ∞ = ∞ ∞ · fin (ℕ.suc _) = ∞ fin (ℕ.suc _) · ∞ = ∞
{ "alphanum_fraction": 0.4501246883, "avg_line_length": 21.6756756757, "ext": "agda", "hexsha": "e152f6f8a2c6c2aabe1a040afe6302e7a820a943", "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/Data/InfNat/Base.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Data/InfNat/Base.agda", "max_line_length": 67, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Data/InfNat/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 356, "size": 802 }
module MissingTypeSignatureInMutual where data Nat : Set where zero : Nat suc : Nat -> Nat mutual pred zero = zero pred (suc n) = n
{ "alphanum_fraction": 0.6554054054, "avg_line_length": 12.3333333333, "ext": "agda", "hexsha": "0207caca9915b226a5bb425dad0be424c2d4c55a", "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/MissingTypeSignatureInMutual.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/MissingTypeSignatureInMutual.agda", "max_line_length": 41, "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/MissingTypeSignatureInMutual.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": 49, "size": 148 }
------------------------------------------------------------------------ -- "Basic" infinite grammars ------------------------------------------------------------------------ -- For a larger and possibly more convenient, but equivalent, grammar -- interface, see Grammar.Infinite. {-# OPTIONS --guardedness #-} module Grammar.Infinite.Basic where open import Algebra open import Category.Monad open import Codata.Musical.Notation open import Data.Bool hiding (_≤_) open import Data.Char hiding (_≤_) open import Data.Empty open import Data.List as List import Data.List.Categorical open import Data.List.Membership.Propositional import Data.List.Membership.Propositional.Properties as ∈ open import Data.List.Properties import Data.List.Relation.Unary.Any as Any open import Data.List.Relation.Unary.Any.Properties open import Data.Nat open import Data.Nat.Properties as NatP open import Data.Product as Prod import Data.Product.Function.Dependent.Propositional as Σ open import Data.Product.Function.NonDependent.Propositional open import Data.Sum open import Data.Unit using (tt) open import Function.Base open import Function.Equality using (_⟨$⟩_) open import Function.Inverse as Inv using (_↔_; module Inverse) import Function.Related as Related open import Function.Related.TypeIsomorphisms import Level open import Relation.Binary.PropositionalEquality as P using (_≡_; refl) import Relation.Binary.PropositionalEquality.WithK as P open import Relation.Nullary private module LMi {A : Set} = Monoid (++-monoid A) module LMa = RawMonad (Data.List.Categorical.monad {ℓ = Level.zero}) open Any.Any ------------------------------------------------------------------------ -- Simple, potentially infinite grammars -- These grammars are very general: they can represent every -- recursively enumerable language (see Grammars.Infinite.expressive). -- In practice one may want to restrict attention to languages that -- can be parsed. I use general grammars to illustrate that this -- approach to pretty-printing is not restricted to a small class of -- languages. infixl 15 _>>=_ infixl 10 _∣_ data Grammar : Set → Set₁ where -- The empty string. return : ∀ {A} → A → Grammar A -- A single, arbitrary token. token : Grammar Char -- Monadic sequencing. _>>=_ : ∀ {A B} → ∞ (Grammar A) → (A → ∞ (Grammar B)) → Grammar B -- Symmetric choice. _∣_ : ∀ {A} → ∞ (Grammar A) → ∞ (Grammar A) → Grammar A -- Semantics of grammars (parse trees). Here x ∈ g · s means that the -- value x and string s are generated by the grammar g. infix 4 _∈_·_ data _∈_·_ : ∀ {A} → A → Grammar A → List Char → Set₁ where return-sem : ∀ {A} {x : A} → x ∈ return x · [] token-sem : ∀ {t} → t ∈ token · [ t ] >>=-sem : ∀ {A B x y s₁ s₂} {g₁ : ∞ (Grammar A)} {g₂ : A → ∞ (Grammar B)} → x ∈ ♭ g₁ · s₁ → y ∈ ♭ (g₂ x) · s₂ → y ∈ g₁ >>= g₂ · s₁ ++ s₂ left-sem : ∀ {A} {g₁ g₂ : ∞ (Grammar A)} {x s} → x ∈ ♭ g₁ · s → x ∈ g₁ ∣ g₂ · s right-sem : ∀ {A} {g₁ g₂ : ∞ (Grammar A)} {x s} → x ∈ ♭ g₂ · s → x ∈ g₁ ∣ g₂ · s ---------------------------------------------------------------------- -- Some grammar combinators -- Failure. fail : ∀ {A} → Grammar A fail = ♯ fail ∣ ♯ fail -- Map. infixl 20 _<$>_ _<$_ _<$>_ : ∀ {A B} → (A → B) → Grammar A → Grammar B f <$> g = ♯ g >>= λ x → ♯ return (f x) _<$_ : ∀ {A B} → A → Grammar B → Grammar A x <$ g = const x <$> g -- The empty string if the argument is true, otherwise failure. if-true : (b : Bool) → Grammar (T b) if-true true = return tt if-true false = fail -- A token satisfying a given predicate. sat : (p : Char → Bool) → Grammar (∃ λ t → T (p t)) sat p = ♯ token >>= λ t → ♯ (_,_ t <$> if-true (p t)) -- A specific token. tok : Char → Grammar Char tok t = t <$ sat (λ t′ → t == t′) ------------------------------------------------------------------------ -- Some semantics combinators -- Cast lemma. cast : ∀ {A} {g : Grammar A} {x s₁ s₂} → s₁ ≡ s₂ → x ∈ g · s₁ → x ∈ g · s₂ cast refl = id fail-sem⁻¹ : ∀ {A} {x : A} {s} → ¬ (x ∈ fail · s) fail-sem⁻¹ (left-sem ∈fail) = fail-sem⁻¹ ∈fail fail-sem⁻¹ (right-sem ∈fail) = fail-sem⁻¹ ∈fail <$>-sem : ∀ {A B} {f : A → B} {g : Grammar A} {y s} → y ∈ f <$> g · s ↔ ∃ λ x → x ∈ g · s × y ≡ f x <$>-sem {A} {B} {f} {g} = record { to = P.→-to-⟶ to ; from = P.→-to-⟶ from ; inverse-of = record { left-inverse-of = from∘to ; right-inverse-of = to∘from } } where lemma : ∀ s → s ++ [] ≡ s lemma s = proj₂ LMi.identity s to : ∀ {s g y} → y ∈ f <$> g · s → ∃ λ x → x ∈ g · s × y ≡ f x to (>>=-sem x∈ return-sem) = _ , cast (P.sym $ lemma _) x∈ , refl from : ∀ {s y g} → (∃ λ x → x ∈ g · s × y ≡ f x) → y ∈ f <$> g · s from (x , x∈ , refl) = cast (lemma _) (>>=-sem x∈ return-sem) >>=-cast : ∀ {x y s₁ s₂ s} {g₁ : ∞ (Grammar A)} {g₂ : A → ∞ (Grammar B)} (eq : s₁ ≡ s₂) (x∈ : x ∈ ♭ g₁ · s₁) (y∈ : y ∈ ♭ (g₂ x) · s) → >>=-sem {g₁ = g₁} {g₂ = g₂} (cast eq x∈) y∈ ≡ cast (P.cong (λ s′ → s′ ++ s) eq) (>>=-sem x∈ y∈) >>=-cast refl _ _ = refl cast-cast : ∀ {A g s₁ s₂} {z : A} {z∈ : z ∈ g · s₂} (eq₁ : s₁ ≡ s₂) (eq₂ : s₂ ≡ s₁) → cast eq₁ (cast eq₂ z∈) ≡ z∈ cast-cast refl refl = refl from∘to : ∀ {s g y} (y∈ : y ∈ f <$> g · s) → from (to y∈) ≡ y∈ from∘to (>>=-sem {s₁ = s} x∈ return-sem) = begin cast (lemma (s ++ [])) (>>=-sem (cast (P.sym $ lemma s) x∈) return-sem) ≡⟨ P.cong (cast (lemma (s ++ []))) $ >>=-cast (P.sym (lemma s)) x∈ return-sem ⟩ cast (lemma (s ++ [])) (cast (P.cong (λ s → s ++ []) (P.sym $ lemma s)) (>>=-sem x∈ return-sem)) ≡⟨ cast-cast (lemma (s ++ [])) (P.cong (λ s → s ++ []) (P.sym $ lemma s)) ⟩ >>=-sem x∈ return-sem ∎ where open P.≡-Reasoning to-cast : ∀ {s₁ s₂ y g} (eq : s₁ ≡ s₂) (y∈ : y ∈ f <$> g · s₁) → to (cast eq y∈) ≡ P.subst (λ s → ∃ λ x → x ∈ g · s × y ≡ f x) eq (to y∈) to-cast refl y∈ = refl to∘from : ∀ {s y g} (x∈ : ∃ λ x → x ∈ g · s × y ≡ f x) → to (from x∈) ≡ x∈ to∘from {s} (x , x∈ , refl) rewrite to-cast (lemma s) (>>=-sem x∈ return-sem) | lemma s = refl if-true-sem : ∀ {b} x {s} → x ∈ if-true b · s ↔ s ≡ [] if-true-sem x = record { to = P.→-to-⟶ (to _) ; from = P.→-to-⟶ (from _ _) ; inverse-of = record { left-inverse-of = from∘to _ ; right-inverse-of = to∘from _ x } } where to : ∀ b {x s} → x ∈ if-true b · s → s ≡ [] to true return-sem = refl to false ∈fail = ⊥-elim $ fail-sem⁻¹ ∈fail from : ∀ b x {s} → s ≡ [] → x ∈ if-true b · s from true _ refl = return-sem from false () refl from∘to : ∀ b {x s} (x∈ : x ∈ if-true b · s) → from b x (to b x∈) ≡ x∈ from∘to true return-sem = refl from∘to false ∈fail = ⊥-elim $ fail-sem⁻¹ ∈fail to∘from : ∀ b x {s} (eq : s ≡ []) → to b (from b x eq) ≡ eq to∘from true _ refl = refl to∘from false () refl sat-sem : ∀ {p : Char → Bool} {t pt s} → (t , pt) ∈ sat p · s ↔ s ≡ [ t ] sat-sem {p} {t} {pt} = record { to = P.→-to-⟶ to ; from = P.→-to-⟶ from ; inverse-of = record { left-inverse-of = from∘to ; right-inverse-of = to∘from } } where to : ∀ {s} → (t , pt) ∈ sat p · s → s ≡ [ t ] to (>>=-sem token-sem (>>=-sem tt∈ return-sem)) = P.cong (λ s → t ∷ s ++ []) (Inverse.to (if-true-sem pt) ⟨$⟩ tt∈) from : ∀ {s} → s ≡ [ t ] → (t , pt) ∈ sat p · s from refl = >>=-sem token-sem (>>=-sem (Inverse.from (if-true-sem pt) ⟨$⟩ refl) return-sem) from∘to : ∀ {s} (t∈ : (t , pt) ∈ sat p · s) → from (to t∈) ≡ t∈ from∘to (>>=-sem token-sem (>>=-sem tt∈ return-sem)) with Inverse.to (if-true-sem pt) ⟨$⟩ tt∈ | Inverse.left-inverse-of (if-true-sem pt) tt∈ from∘to (>>=-sem token-sem (>>=-sem .(Inverse.from (if-true-sem pt) ⟨$⟩ refl) return-sem)) | refl | refl = refl to∘from : ∀ {s} (eq : s ≡ [ t ]) → to (from eq) ≡ eq to∘from refl rewrite Inverse.right-inverse-of (if-true-sem pt) refl = refl abstract -- Grammar.Infinite requires a lot more memory to type-check if this -- definition is made concrete (at the time of writing). tok-sem : ∀ {t′ t s} → t′ ∈ tok t · s ↔ (t ≡ t′ × s ≡ [ t ]) tok-sem {t′} {t} {s} = t′ ∈ tok t · s ↔⟨ <$>-sem ⟩ (∃ λ p → p ∈ sat (λ t′ → t == t′) · s × t′ ≡ t) ↔⟨ Σ.cong Inv.id (sat-sem ×-cong Inv.id) ⟩ (∃ λ p → s ≡ [ proj₁ p ] × t′ ≡ t) ↔⟨ Σ-assoc ⟩ (∃ λ t″ → T (t == t″) × s ≡ [ t″ ] × t′ ≡ t) ↔⟨ Σ.cong Inv.id (True↔ _ P.≡-irrelevant ×-cong Inv.id) ⟩ (∃ λ t″ → t ≡ t″ × s ≡ [ t″ ] × t′ ≡ t) ↔⟨ lemma ⟩ (t ≡ t′ × s ≡ [ t ]) ∎ where open Related.EquationalReasoning lemma : (∃ λ t″ → t ≡ t″ × s ≡ [ t″ ] × t′ ≡ t) ↔ (t ≡ t′ × s ≡ [ t ]) lemma = record { to = P.→-to-⟶ to ; from = P.→-to-⟶ from ; inverse-of = record { left-inverse-of = from∘to ; right-inverse-of = to∘from } } where to : ∀ {t′ t : Char} {s} → (∃ λ t″ → t ≡ t″ × s ≡ [ t″ ] × t′ ≡ t) → t ≡ t′ × s ≡ [ t ] to (_ , refl , refl , refl) = (refl , refl) from : ∀ {t′ t : Char} {s} → t ≡ t′ × s ≡ [ t ] → ∃ λ t″ → t ≡ t″ × s ≡ [ t″ ] × t′ ≡ t from (refl , refl) = (_ , refl , refl , refl) from∘to : ∀ {t′ t : Char} {s} (eqs : ∃ λ t″ → t ≡ t″ × s ≡ [ t″ ] × t′ ≡ t) → from (to eqs) ≡ eqs from∘to (_ , refl , refl , refl) = refl to∘from : ∀ {t′ t : Char} {s} (eqs : t ≡ t′ × s ≡ [ t ]) → to (from eqs) ≡ eqs to∘from (refl , refl) = refl ------------------------------------------------------------------------ -- An aside: An inductive version of the grammar type above wouldn't -- be very useful (assuming that Char is finite) module Aside (finite-number-of-tokens : ∃ λ (ts : List Char) → ∀ t → t ∈ ts) where open ≤-Reasoning infixl 15 _>>=_ infixl 10 _∣_ data GrammarI : Set → Set₁ where return : ∀ {A} → A → GrammarI A token : GrammarI Char _>>=_ : ∀ {A B} → GrammarI A → (A → GrammarI B) → GrammarI B _∣_ : ∀ {A} → GrammarI A → GrammarI A → GrammarI A infix 4 _∈I_·_ data _∈I_·_ : ∀ {A} → A → GrammarI A → List Char → Set₁ where return-sem : ∀ {A} {x : A} → x ∈I return x · [] token-sem : ∀ {t} → t ∈I token · [ t ] >>=-sem : ∀ {A B x y s₁ s₂} {g₁ : GrammarI A} {g₂ : A → GrammarI B} → x ∈I g₁ · s₁ → y ∈I g₂ x · s₂ → y ∈I g₁ >>= g₂ · s₁ ++ s₂ left-sem : ∀ {A} {g₁ g₂ : GrammarI A} {x s} → x ∈I g₁ · s → x ∈I g₁ ∣ g₂ · s right-sem : ∀ {A} {g₁ g₂ : GrammarI A} {x s} → x ∈I g₂ · s → x ∈I g₁ ∣ g₂ · s -- A kind of parser for the inductive grammars, used to prove -- finite-number-of-results. Note that the "parser" is not quite -- correct when seen as a parser: it sometimes returns too many -- results. (The derivative of return x should be a failing -- grammar.) initial-bag : ∀ {A} (g : GrammarI A) → ∃ λ xs → ∀ {x} → x ∈I g · [] → x ∈ xs derivative : ∀ {A} (g : GrammarI A) t → ∃ λ g′ → ∀ {x s} → x ∈I g · t ∷ s → x ∈I g′ · s parse : ∀ {A} (g : GrammarI A) s → ∃ λ xs → ∀ {x} → x ∈I g · s → x ∈ xs parse g [] = initial-bag g parse g (t ∷ s) with derivative g t ... | g′ , ok₁ with parse g′ s ... | xs , ok₂ = xs , ok₂ ∘ ok₁ initial-bag (return x) = [ x ] , λ { .{x = x} return-sem → here refl } initial-bag token = [] , λ () initial-bag (g₁ ∣ g₂) = Prod.zip _++_ (λ {xs} i₁ i₂ → λ { (left-sem ∈g₁) → Inverse.to ++↔ ⟨$⟩ inj₁ (i₁ ∈g₁) ; (right-sem ∈g₂) → Inverse.to (++↔ {xs = xs}) ⟨$⟩ inj₂ (i₂ ∈g₂) }) (initial-bag g₁) (initial-bag g₂) initial-bag (_>>=_ {A = A} {B = B} g₁ g₂) with initial-bag g₁ ... | xs , xs-ok = ys xs , λ ∈g₁>>=g₂ → lemma₁ ∈g₁>>=g₂ refl where ys : List A → List B ys xs = xs LMa.>>= λ x → proj₁ (initial-bag (g₂ x)) lemma₂ : ∀ {x y} xs → x ∈ xs → y ∈I g₂ x · [] → y ∈ ys xs lemma₂ (x ∷ xs) (here refl) ∈g₂ = Inverse.to ++↔ ⟨$⟩ inj₁ (proj₂ (initial-bag (g₂ x)) ∈g₂) lemma₂ (z ∷ xs) (there x∈) ∈g₂ = Inverse.to (++↔ {xs = proj₁ (initial-bag (g₂ z))}) ⟨$⟩ inj₂ (lemma₂ xs x∈ ∈g₂) lemma₁ : ∀ {x s} → x ∈I g₁ >>= g₂ · s → s ≡ [] → x ∈ ys xs lemma₁ (>>=-sem {s₁ = []} ∈g₁ ∈g₂) refl = lemma₂ xs (xs-ok ∈g₁) ∈g₂ lemma₁ (>>=-sem {s₁ = _ ∷ _} ∈g₁ ∈g₂) () derivative (return x) t = return x , λ () derivative token t = return t , λ { .{s = []} token-sem → return-sem } derivative (g₁ ∣ g₂) t = Prod.zip _∣_ (λ {g₁′ g₂′} ok₁ ok₂ → λ { (left-sem ∈g₁) → left-sem (ok₁ ∈g₁) ; (right-sem ∈g₂) → right-sem (ok₂ ∈g₂) }) (derivative g₁ t) (derivative g₂ t) derivative (_>>=_ {A = A} {B = B} g₁ g₂) t with derivative g₁ t | initial-bag g₁ ... | g₁′ , g₁′-ok | xs , xs-ok = g′ xs , λ ∈g₁>>=g₂ → lemma₁ ∈g₁>>=g₂ refl where g′ : List A → GrammarI B g′ [] = g₁′ >>= g₂ g′ (x ∷ xs) = return x >>= (λ x → proj₁ (derivative (g₂ x) t)) ∣ g′ xs lemma₂ : ∀ {x y s} xs → x ∈ xs → y ∈I g₂ x · t ∷ s → y ∈I g′ xs · s lemma₂ (x ∷ xs) (here refl) ∈g₂ = left-sem (>>=-sem return-sem (proj₂ (derivative (g₂ x) t) ∈g₂)) lemma₂ (z ∷ xs) (there x∈) ∈g₂ = right-sem (lemma₂ xs x∈ ∈g₂) lemma₃ : ∀ {x y s₁ s₂} xs → x ∈I g₁′ · s₁ → y ∈I g₂ x · s₂ → y ∈I g′ xs · s₁ ++ s₂ lemma₃ [] ∈g₁′ ∈g₂ = >>=-sem ∈g₁′ ∈g₂ lemma₃ (x ∷ xs) ∈g₁′ ∈g₂ = right-sem (lemma₃ xs ∈g₁′ ∈g₂) lemma₁ : ∀ {y s s′} → y ∈I g₁ >>= g₂ · s → s ≡ t ∷ s′ → y ∈I g′ xs · s′ lemma₁ (>>=-sem {s₁ = []} ∈g₁ ∈g₂) refl = lemma₂ xs (xs-ok ∈g₁) ∈g₂ lemma₁ (>>=-sem {s₁ = .t ∷ _} ∈g₁ ∈g₂) refl = lemma₃ xs (g₁′-ok ∈g₁) ∈g₂ -- If strings are restricted to have a given maximum length, then an -- inductive grammar generates a finite number of distinct results. finite-number-of-results : ∀ {A} (g : GrammarI A) n → ∃ λ xs → ∀ {x s} → length s ≤ n → x ∈I g · s → x ∈ xs finite-number-of-results g n = (all-strings n LMa.>>= proj₁ ∘ parse g) , λ {_} {s} ≤n ∈g → Inverse.to ∈.>>=-∈↔ ⟨$⟩ (_ , all-strings-ok s n ≤n , proj₂ (parse g s) ∈g) where all-strings : ℕ → List (List Char) all-strings 0 = [ [] ] all-strings (suc n) = all-strings n ++ (proj₁ finite-number-of-tokens LMa.>>= λ t → List.map (_∷_ t) (all-strings n)) all-strings-ok : ∀ s n → length s ≤ n → s ∈ all-strings n all-strings-ok [] zero z≤n = here refl all-strings-ok [] (suc n) z≤n = Inverse.to ++↔ ⟨$⟩ inj₁ (all-strings-ok [] n z≤n) all-strings-ok (t ∷ s) (suc n) (s≤s ≤n) = Inverse.to (++↔ {xs = all-strings n}) ⟨$⟩ inj₂ (Inverse.to ∈.>>=-∈↔ ⟨$⟩ (_ , proj₂ finite-number-of-tokens t , Inverse.to (∈.map-∈↔ _) ⟨$⟩ (_ , all-strings-ok s n ≤n , refl))) -- No inductive grammar can generate strings of unbounded length. bounded-length : ∀ {A} (g : GrammarI A) → ∃ λ n → ∀ {x s} → x ∈I g · s → length s ≤ n bounded-length (return x) = 0 , λ { .{s = []} return-sem → z≤n } bounded-length token = 1 , λ { .{s = [ _ ]} token-sem → s≤s z≤n } bounded-length (g₁ ∣ g₂) = Prod.zip _+_ (λ {n₁ n₂} b₁ b₂ → λ { {s = s} (left-sem ∈g₁) → begin length s ≤⟨ b₁ ∈g₁ ⟩ n₁ ≤⟨ m≤m+n _ _ ⟩ n₁ + n₂ ∎ ; {s = s} (right-sem ∈g₂) → begin length s ≤⟨ b₂ ∈g₂ ⟩ n₂ ≤⟨ m≤n+m _ n₁ ⟩ n₁ + n₂ ∎ }) (bounded-length g₁) (bounded-length g₂) bounded-length (_>>=_ {A = A} g₁ g₂) with bounded-length g₁ ... | n₁ , b₁ with finite-number-of-results g₁ n₁ ... | xs , xs-ok = n₁ + n₂ xs , λ { .{s = _} (>>=-sem {s₁ = s₁} {s₂ = s₂} ∈g₁ ∈g₂) → begin length (s₁ ++ s₂) ≡⟨ length-++ s₁ ⟩ length s₁ + length s₂ ≤⟨ +-mono-≤ (b₁ ∈g₁) (lemma xs (xs-ok (b₁ ∈g₁) ∈g₁) ∈g₂) ⟩ n₁ + n₂ xs ∎ } where n₂ : List A → ℕ n₂ = foldr _⊔_ 0 ∘ List.map (λ x → proj₁ (bounded-length (g₂ x))) lemma : ∀ {x y s} xs → x ∈ xs → y ∈I g₂ x · s → length s ≤ n₂ xs lemma {s = s} (x ∷ xs) (here refl) y∈ = begin length s ≤⟨ proj₂ (bounded-length (g₂ x)) y∈ ⟩ proj₁ (bounded-length (g₂ x)) ≤⟨ m≤m⊔n _ _ ⟩ proj₁ (bounded-length (g₂ x)) ⊔ n₂ xs ∎ lemma {s = s} (z ∷ xs) (there x∈) y∈ = begin length s ≤⟨ lemma xs x∈ y∈ ⟩ n₂ xs ≤⟨ m≤m⊔n _ _ ⟩ n₂ xs ⊔ proj₁ (bounded-length (g₂ z)) ≡⟨ ∧-comm (n₂ xs) _ ⟩ proj₁ (bounded-length (g₂ z)) ⊔ n₂ xs ∎ where open DistributiveLattice NatP.⊓-⊔-distributiveLattice
{ "alphanum_fraction": 0.4616383447, "avg_line_length": 35.9290060852, "ext": "agda", "hexsha": "6c2c278965736a29a6569880c6314a4af1d77829", "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": "Grammar/Infinite/Basic.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": "Grammar/Infinite/Basic.agda", "max_line_length": 116, "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": "Grammar/Infinite/Basic.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6613, "size": 17713 }
open import Mockingbird.Forest using (Forest) -- The Forest Without a Name module Mockingbird.Problems.Chapter16 {b ℓ} (forest : Forest {b} {ℓ}) where open import Data.Product using (_×_; _,_; ∃-syntax) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Function using (_$_; _⇔_; Equivalence) open import Relation.Binary using (_Respects_) open import Relation.Nullary using (¬_) open import Relation.Unary using (Pred) open Forest forest import Mockingbird.Problems.Chapter14 forest as Chapter₁₄ open import Mockingbird.Problems.Chapter15 forest using (⇔-¬) module _ {s} (Sings : Pred Bird s) (respects : Sings Respects _≈_) (LEM : ∀ x → Sings x ⊎ ¬ Sings x) (e : Bird) (law₁ : ∀ {x y} → Sings (e ∙ x ∙ y) → Sings y) (law₂ : ∀ {x y} → Sings (e ∙ x ∙ y) ⇔ (¬ Sings x)) (law₃ : ∀ {x y} → Sings (e ∙ x ∙ y) ⇔ (¬ Sings x × Sings y)) (law₄ : ∀ x → ∃[ y ] Sings y ⇔ Sings (e ∙ y ∙ x)) where IsSilent : Pred Bird s IsSilent x = ¬ Sings x private respects′ : IsSilent Respects _≈_ respects′ x≈y ¬x-sings y-sings = ¬x-sings $ respects (sym x≈y) y-sings LEM′ : ∀ x → IsSilent x ⊎ ¬ IsSilent x LEM′ x with LEM x ... | inj₁ x-sings = inj₂ λ ¬x-sings → ¬x-sings x-sings ... | inj₂ ¬x-sings = inj₁ ¬x-sings law₁′ : ∀ {x y} → IsSilent y → IsSilent (e ∙ x ∙ y) law₁′ ¬y-sings exy-sings = ¬y-sings $ law₁ exy-sings law₂′ : ∀ {x y} → ¬ IsSilent x → IsSilent (e ∙ x ∙ y) law₂′ = Equivalence.g $ ⇔-¬ law₂ law₃′ : ∀ {x y} → IsSilent x → IsSilent (e ∙ x ∙ y) → IsSilent y law₃′ {x} {y} ¬x-sings ¬exy-sings y-sings = Equivalence.f (⇔-¬ law₃) ¬exy-sings (¬x-sings , y-sings) law₄′ : ∀ x → ∃[ y ] IsSilent y ⇔ IsSilent (e ∙ y ∙ x) law₄′ x = let (y , y-sings⇔eyx-sings) = law₄ x in (y , ⇔-¬ y-sings⇔eyx-sings) problem : ∀ x → ¬ Sings x problem = Chapter₁₄.problem₁ IsSilent respects′ LEM′ e law₁′ law₂′ law₃′ law₄′
{ "alphanum_fraction": 0.5869676757, "avg_line_length": 36.0925925926, "ext": "agda", "hexsha": "dcd747dceedd66ca4526fc84dc327dc7d89bcc3d", "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": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "splintah/combinatory-logic", "max_forks_repo_path": "Mockingbird/Problems/Chapter16.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "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": "splintah/combinatory-logic", "max_issues_repo_path": "Mockingbird/Problems/Chapter16.agda", "max_line_length": 104, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "splintah/combinatory-logic", "max_stars_repo_path": "Mockingbird/Problems/Chapter16.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T23:44:42.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-28T23:44:42.000Z", "num_tokens": 780, "size": 1949 }
module Effect where open import Data.List open import Data.List.All open import Data.List.Any open import Level open import Relation.Binary.PropositionalEquality hiding ([_]) open import Function open import Category.Monad open import Data.Product open import EffectUtil open import Membership-equality hiding (_⊆_; set) Effect : ∀ f → Set (suc f) Effect f = (result : Set f) (i : Set f) (o : result → Set f) → Set f record EFFECT (f : Level) : Set (suc f) where constructor mkEff field S : Set f E : Effect f updateResTy : ∀ {f A E i o} → (val : A) → (es : List (EFFECT f)) → (prf : (mkEff i E) ∈ es) → (eff : E A i o) → List (EFFECT f) updateResTy {o = o} val (mkEff i e ∷ es) (here px) eff = mkEff (o val) e ∷ es updateResTy val (e ∷ es) (there prf) eff = e ∷ updateResTy val es prf eff updateWith : ∀ {f ys} (ys' : List (EFFECT f)) → (xs : List (EFFECT f)) → (ys ⊆ xs) → List (EFFECT f) updateWith [] xs inc = xs updateWith (y' ∷ ys') xs [] = xs updateWith (y' ∷ ys') (_ ∷ xs) (keep inc) = y' ∷ updateWith ys' xs inc updateWith (y' ∷ ys') (x ∷ xs) (skip inc) = x ∷ updateWith (y' ∷ ys') xs inc Handler : ∀ {f} → (Set f → Set f) → Effect f → Set (suc f) Handler M e = ∀ {A a o res} → (r : res) → (eff : e A res o) → (k : ((x : A) → o x → M a)) → M a -- @ A The return type of the result -- @ es The list of allowed side-effects -- @ ce The function to compute a new list of allowed side-effects data EffM {f : Level} (m : Set f → Set f) : (A : Set f) → (es : List (EFFECT f)) → (ce : A → List (EFFECT f)) → Set (suc f) where return : ∀ {A ce} (val : A) → EffM m A (ce val) ce _>>=_ : ∀ {A B es ce₁ ce₂} → EffM m A es ce₁ → (∀ x → EffM m B (ce₁ x) ce₂) → EffM m B es ce₂ effect : ∀ {A E i es o} (prf : (mkEff i E) ∈ es) → (eff : E A i o) → EffM m A es (λ v → updateResTy v es prf eff) -- use to invoke sub-programs that use some or all of the available effects lift : ∀ {A ys ys' xs} → (inc : ys ⊆ xs) → EffM m A ys ys' → EffM m A xs (λ v → updateWith (ys' v) xs inc) new : ∀ {A es} → (e : EFFECT f) → (val : EFFECT.S e) → Handler m (EFFECT.E e) → EffM {f} m A (e ∷ es) (λ v → e ∷ es) → EffM m A es (λ v → es) pure : ∀ {l m A es} → A → EffM {l} m A es (λ v → es) pure = return _<*>_ : ∀ {l m A B es} → EffM {l} m (A → B) es (λ v → es) → EffM {l} m A es (λ v → es) → EffM {l} m B es (λ v → es) _<*>_ prog v = prog >>= λ fn → v >>= λ arg → pure (fn arg) _<$>_ : ∀ {l m A B es} → (f : A → B) → EffM {l} m A es (λ v → es) → EffM {l} m B es (λ v → es) _<$>_ f m = pure f <*> m data Env {f : Level} : (m : Set f → Set f) → List (EFFECT f) → Set (suc f) where [] : ∀ {m} → Env m [] _∷_ : ∀ {m eff es a} → (el : Handler m eff × a) → Env m es → Env m (mkEff a eff ∷ es) execEff : ∀ {f m A es E i} {o : A → Set f} {B} → Env {f} m es → (prf : (mkEff i E) ∈ es) → (eff : E A i o) → ((v : A) → Env {f} m (updateResTy v es prf eff) → m B) → m B execEff {m = m} {A = A} {o = o} {B = B} ((handle , val) ∷ env) (here refl) eff k = handle val eff cont where cont : (v : A) → o v → m B cont v res = k v ((handle , res) ∷ env) execEff (e ∷ env) (there prf) eff k = execEff env prf eff λ v → λ env' → k v (e ∷ env') dropEnv : ∀ {f m ys xs} → Env {f} m ys → xs ⊆ ys → Env m xs dropEnv [] [] = [] dropEnv (el ∷ env) [] = [] dropEnv (el ∷ env) (keep sub) = el ∷ (dropEnv env sub) dropEnv (el ∷ env) (skip sub) = dropEnv env sub rebuildEnv : ∀ {f m ys' ys xs} → Env {f} m ys' → (prf : ys ⊆ xs) → Env m xs → Env m (updateWith ys' xs prf) rebuildEnv [] [] env = env rebuildEnv (_ ∷ _) [] env = env rebuildEnv [] (keep prf) env = env rebuildEnv (el ∷ els) (keep prf) (_ ∷ env) = el ∷ rebuildEnv els prf env rebuildEnv [] (skip prf) env = env rebuildEnv (el ∷ els) (skip prf) (en ∷ env) = en ∷ rebuildEnv (el ∷ els) prf env eff : ∀ {f m es A B ce} → Env {f} m es → EffM m A es ce → ((v : A) → Env m (ce v) → m B) → m B eff env (return val) k = k val env eff env (effM >>= c) k = eff env effM λ p' → λ env' → eff env' ((c p')) k eff env (effect prf effP) k = execEff env prf effP k eff env (lift inc effM) k = eff env' effM λ p' → λ envk → k p' (rebuildEnv envk inc env) where env' = dropEnv env inc eff {f} {m} {es} {A} {B} env (new e val handler effM) k = eff ((handler , val) ∷ env) effM cont where cont : (v : A) → Env {f} m (e ∷ es) → m B cont v (val ∷ envk) = k v envk run : ∀ {f a xs xs'} → ∀ m → (mon : RawMonad m) → (prog : EffM {f} m a xs xs') → Env m xs → m a run m mon prog env = eff env prog λ r → λ env' → RawMonad.return mon r
{ "alphanum_fraction": 0.5240697919, "avg_line_length": 39.3140495868, "ext": "agda", "hexsha": "506683638b448eaa7db2639625f20acdf257c007", "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": "ae541df13d069df4eb1464f29fbaa9804aad439f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Zalastax/singly-typed-actors", "max_forks_repo_path": "unused/Effect.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f", "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": "Zalastax/singly-typed-actors", "max_issues_repo_path": "unused/Effect.agda", "max_line_length": 102, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Zalastax/thesis", "max_stars_repo_path": "unused/Effect.agda", "max_stars_repo_stars_event_max_datetime": "2018-02-02T16:44:43.000Z", "max_stars_repo_stars_event_min_datetime": "2018-02-02T16:44:43.000Z", "num_tokens": 1866, "size": 4757 }
-- Andreas, 2021-05-07, issue #5358 reported by ecavallo -- Do not expand clauses with tactics attached to the target type! open import Agda.Builtin.Unit open import Agda.Builtin.Bool open import Agda.Builtin.Reflection renaming (bindTC to _>>=_) defaultTo : {A : Set} (x : A) → Term → TC ⊤ defaultTo x goal = do `x ← quoteTC x unify goal `x record Class : Set where constructor con field x : Bool → Bool @(tactic defaultTo x) {y} : Bool → Bool open Class {- Correctly succeeds -} testA : Class testA = con (λ b → b) {- WAS: Incorrectly fails with: Bool → Bool !=< Bool when checking that the inferred type of an application Bool → Bool matches the expected type Bool What is happening here? - The coverage checker detects a missing clause testB .y : @(tactic defaultTo x) {Bool → Bool}. - It expands this to testB .y b : @(tactic defaultTo x) {Bool}, eliminating the function type. - It then runs the tactic at the wrong type. A fix is to not expand the clause if there is a tactic attached to the projections. -} testB : Class testB .x = λ b → b -- Should succeed
{ "alphanum_fraction": 0.6850533808, "avg_line_length": 22.9387755102, "ext": "agda", "hexsha": "87e12e49101e8a965038b59afb623ba9372375c1", "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/Issue5358.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/Issue5358.agda", "max_line_length": 83, "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/Issue5358.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": 323, "size": 1124 }
-- Errors should precede warnings in info buffer -- Reported by nad 2018-11-27 module Issue3416 where A : Set A = A B : Set B = Set
{ "alphanum_fraction": 0.7014925373, "avg_line_length": 13.4, "ext": "agda", "hexsha": "45386b4f27083b3c2a68979d3496b48711590969", "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/Issue3416.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/Issue3416.agda", "max_line_length": 48, "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/Issue3416.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": 44, "size": 134 }
module ModuleMacro where record ⊤ : Set where module M where module N where postulate A : Set B : Set module O = M module P = M module Q = P module R (x : ⊤) = N using (A) module S = N renaming ( A to A' ; B to B' ) y : ⊤ y = record {O} C : ⊤ → Set C = R.A D : Set D = S.B'
{ "alphanum_fraction": 0.4540389972, "avg_line_length": 6.1896551724, "ext": "agda", "hexsha": "3b827bb55c0f1dff9c234869bfc33061f70373bb", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-01T16:38:14.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-01T16:38:14.000Z", "max_forks_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "msuperdock/agda-unused", "max_forks_repo_path": "data/declaration/ModuleMacro.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "msuperdock/agda-unused", "max_issues_repo_path": "data/declaration/ModuleMacro.agda", "max_line_length": 24, "max_stars_count": 6, "max_stars_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "msuperdock/agda-unused", "max_stars_repo_path": "data/declaration/ModuleMacro.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-01T16:38:05.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-29T09:38:43.000Z", "num_tokens": 156, "size": 359 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties of operations on the Colist type ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe --sized-types #-} module Codata.Colist.Properties where open import Level using (Level) open import Size open import Codata.Thunk as Thunk using (Thunk; force) open import Codata.Colist open import Codata.Colist.Bisimilarity open import Codata.Conat open import Codata.Conat.Bisimilarity as coℕᵇ using (zero; suc) import Codata.Conat.Properties as coℕₚ open import Codata.Cowriter as Cowriter using ([_]; _∷_) open import Codata.Cowriter.Bisimilarity as coWriterᵇ using ([_]; _∷_) open import Codata.Stream as Stream using (Stream; _∷_) open import Data.Vec.Bounded as Vec≤ using (Vec≤) open import Data.List.Base as List using (List; []; _∷_) open import Data.List.NonEmpty as List⁺ using (List⁺; _∷_) open import Data.List.Relation.Binary.Equality.Propositional using (≋-refl) open import Data.Maybe.Base as Maybe using (Maybe; nothing; just) import Data.Maybe.Properties as Maybeₚ open import Data.Maybe.Relation.Unary.All using (All; nothing; just) open import Data.Nat.Base as ℕ using (zero; suc; z≤n; s≤s) open import Data.Product as Prod using (_×_; _,_; uncurry) open import Data.These.Base as These using (These; this; that; these) open import Data.Vec.Base as Vec using (Vec; []; _∷_) open import Function.Base open import Relation.Binary.PropositionalEquality as Eq using (_≡_; [_]) private variable a b c d : Level A : Set a B : Set b C : Set c D : Set d i : Size ------------------------------------------------------------------------ -- Functor laws map-identity : ∀ (as : Colist A ∞) → i ⊢ map id as ≈ as map-identity [] = [] map-identity (a ∷ as) = Eq.refl ∷ λ where .force → map-identity (as .force) map-map-fusion : ∀ (f : A → B) (g : B → C) as {i} → i ⊢ map g (map f as) ≈ map (g ∘ f) as map-map-fusion f g [] = [] map-map-fusion f g (a ∷ as) = Eq.refl ∷ λ where .force → map-map-fusion f g (as .force) ------------------------------------------------------------------------ -- Relation to Cowriter fromCowriter∘toCowriter≗id : ∀ (as : Colist A ∞) → i ⊢ fromCowriter (toCowriter as) ≈ as fromCowriter∘toCowriter≗id [] = [] fromCowriter∘toCowriter≗id (a ∷ as) = Eq.refl ∷ λ where .force → fromCowriter∘toCowriter≗id (as .force) ------------------------------------------------------------------------ -- Properties of length length-∷ : ∀ (a : A) as → i coℕᵇ.⊢ length (a ∷ as) ≈ 1 ℕ+ length (as .force) length-∷ a as = suc (λ where .force → coℕᵇ.refl) length-replicate : ∀ n (a : A) → i coℕᵇ.⊢ length (replicate n a) ≈ n length-replicate zero a = zero length-replicate (suc n) a = suc λ where .force → length-replicate (n .force) a length-++ : (as bs : Colist A ∞) → i coℕᵇ.⊢ length (as ++ bs) ≈ length as + length bs length-++ [] bs = coℕᵇ.refl length-++ (a ∷ as) bs = suc λ where .force → length-++ (as .force) bs length-map : ∀ (f : A → B) as → i coℕᵇ.⊢ length (map f as) ≈ length as length-map f [] = zero length-map f (a ∷ as) = suc λ where .force → length-map f (as .force) ------------------------------------------------------------------------ -- Properties of replicate replicate-+ : ∀ m n (a : A) → i ⊢ replicate (m + n) a ≈ replicate m a ++ replicate n a replicate-+ zero n a = refl replicate-+ (suc m) n a = Eq.refl ∷ λ where .force → replicate-+ (m .force) n a map-replicate : ∀ (f : A → B) n a → i ⊢ map f (replicate n a) ≈ replicate n (f a) map-replicate f zero a = [] map-replicate f (suc n) a = Eq.refl ∷ λ where .force → map-replicate f (n .force) a lookup-replicate : ∀ k n (a : A) → All (a ≡_) (lookup k (replicate n a)) lookup-replicate k zero a = nothing lookup-replicate zero (suc n) a = just Eq.refl lookup-replicate (suc k) (suc n) a = lookup-replicate k (n .force) a ------------------------------------------------------------------------ -- Properties of unfold map-unfold : ∀ (f : B → C) (alg : A → Maybe (A × B)) a → i ⊢ map f (unfold alg a) ≈ unfold (Maybe.map (Prod.map₂ f) ∘ alg) a map-unfold f alg a with alg a ... | nothing = [] ... | just (a′ , b) = Eq.refl ∷ λ where .force → map-unfold f alg a′ module _ {alg : A → Maybe (A × B)} {a} where unfold-nothing : alg a ≡ nothing → unfold alg a ≡ [] unfold-nothing eq with alg a ... | nothing = Eq.refl unfold-just : ∀ {a′ b} → alg a ≡ just (a′ , b) → i ⊢ unfold alg a ≈ b ∷ λ where .force → unfold alg a′ unfold-just eq with alg a unfold-just Eq.refl | just (a′ , b) = Eq.refl ∷ λ where .force → refl ------------------------------------------------------------------------ -- Properties of scanl length-scanl : ∀ (c : B → A → B) n as → i coℕᵇ.⊢ length (scanl c n as) ≈ 1 ℕ+ length as length-scanl c n [] = suc λ where .force → zero length-scanl c n (a ∷ as) = suc λ { .force → begin length (scanl c (c n a) (as .force)) ≈⟨ length-scanl c (c n a) (as .force) ⟩ 1 ℕ+ length (as .force) ≈˘⟨ length-∷ a as ⟩ length (a ∷ as) ∎ } where open coℕᵇ.≈-Reasoning module _ (cons : C → B → C) (alg : A → Maybe (A × B)) where private alg′ : (A × C) → Maybe ((A × C) × C) alg′ (a , c) = Maybe.map (uncurry step) (alg a) where step = λ a′ b → let b′ = cons c b in (a′ , b′) , b′ scanl-unfold : ∀ nil a → i ⊢ scanl cons nil (unfold alg a) ≈ nil ∷ (λ where .force → unfold alg′ (a , nil)) scanl-unfold nil a with alg a | Eq.inspect alg a ... | nothing | [ eq ] = Eq.refl ∷ λ { .force → sym (fromEq (unfold-nothing (Maybeₚ.map-nothing eq))) } ... | just (a′ , b) | [ eq ] = Eq.refl ∷ λ { .force → begin scanl cons (cons nil b) (unfold alg a′) ≈⟨ scanl-unfold (cons nil b) a′ ⟩ (cons nil b ∷ _) ≈⟨ Eq.refl ∷ (λ where .force → refl) ⟩ (cons nil b ∷ _) ≈˘⟨ unfold-just (Maybeₚ.map-just eq) ⟩ unfold alg′ (a , nil) ∎ } where open ≈-Reasoning ------------------------------------------------------------------------ -- Properties of alignwith map-alignWith : ∀ (f : C → D) (al : These A B → C) as bs → i ⊢ map f (alignWith al as bs) ≈ alignWith (f ∘ al) as bs map-alignWith f al [] bs = map-map-fusion (al ∘′ that) f bs map-alignWith f al as@(_ ∷ _) [] = map-map-fusion (al ∘′ this) f as map-alignWith f al (a ∷ as) (b ∷ bs) = Eq.refl ∷ λ where .force → map-alignWith f al (as .force) (bs .force) length-alignWith : ∀ (al : These A B → C) as bs → i coℕᵇ.⊢ length (alignWith al as bs) ≈ length as ⊔ length bs length-alignWith al [] bs = length-map (al ∘ that) bs length-alignWith al as@(_ ∷ _) [] = length-map (al ∘ this) as length-alignWith al (a ∷ as) (b ∷ bs) = suc λ where .force → length-alignWith al (as .force) (bs .force) ------------------------------------------------------------------------ -- Properties of zipwith map-zipWith : ∀ (f : C → D) (zp : A → B → C) as bs → i ⊢ map f (zipWith zp as bs) ≈ zipWith (λ a → f ∘ zp a) as bs map-zipWith f zp [] _ = [] map-zipWith f zp (_ ∷ _) [] = [] map-zipWith f zp (a ∷ as) (b ∷ bs) = Eq.refl ∷ λ where .force → map-zipWith f zp (as .force) (bs .force) length-zipWith : ∀ (zp : A → B → C) as bs → i coℕᵇ.⊢ length (zipWith zp as bs) ≈ length as ⊓ length bs length-zipWith zp [] bs = zero length-zipWith zp as@(_ ∷ _) [] = zero length-zipWith zp (a ∷ as) (b ∷ bs) = suc λ where .force → length-zipWith zp (as .force) (bs .force) ------------------------------------------------------------------------ -- Properties of drop drop-nil : ∀ m → i ⊢ drop {A = A} m [] ≈ [] drop-nil zero = [] drop-nil (suc m) = [] drop-drop-fusion : ∀ m n (as : Colist A ∞) → i ⊢ drop n (drop m as) ≈ drop (m ℕ.+ n) as drop-drop-fusion zero n as = refl drop-drop-fusion (suc m) n [] = drop-nil n drop-drop-fusion (suc m) n (a ∷ as) = drop-drop-fusion m n (as .force) map-drop : ∀ (f : A → B) m as → i ⊢ map f (drop m as) ≈ drop m (map f as) map-drop f zero as = refl map-drop f (suc m) [] = [] map-drop f (suc m) (a ∷ as) = map-drop f m (as .force) length-drop : ∀ m (as : Colist A ∞) → i coℕᵇ.⊢ length (drop m as) ≈ length as ∸ m length-drop zero as = coℕᵇ.refl length-drop (suc m) [] = coℕᵇ.sym (coℕₚ.0∸m≈0 m) length-drop (suc m) (a ∷ as) = length-drop m (as .force) drop-fromList-++-identity : ∀ (as : List A) bs → drop (List.length as) (fromList as ++ bs) ≡ bs drop-fromList-++-identity [] bs = Eq.refl drop-fromList-++-identity (a ∷ as) bs = drop-fromList-++-identity as bs drop-fromList-++-≤ : ∀ (as : List A) bs {m} → m ℕ.≤ List.length as → drop m (fromList as ++ bs) ≡ fromList (List.drop m as) ++ bs drop-fromList-++-≤ [] bs z≤n = Eq.refl drop-fromList-++-≤ (a ∷ as) bs z≤n = Eq.refl drop-fromList-++-≤ (a ∷ as) bs (s≤s p) = drop-fromList-++-≤ as bs p drop-fromList-++-≥ : ∀ (as : List A) bs {m} → m ℕ.≥ List.length as → drop m (fromList as ++ bs) ≡ drop (m ℕ.∸ List.length as) bs drop-fromList-++-≥ [] bs z≤n = Eq.refl drop-fromList-++-≥ (a ∷ as) bs (s≤s p) = drop-fromList-++-≥ as bs p drop-⁺++-identity : ∀ (as : List⁺ A) bs → drop (List⁺.length as) (as ⁺++ bs) ≡ bs .force drop-⁺++-identity (a ∷ as) bs = drop-fromList-++-identity as (bs .force) ------------------------------------------------------------------------ -- Properties of cotake length-cotake : ∀ n (as : Stream A ∞) → i coℕᵇ.⊢ length (cotake n as) ≈ n length-cotake zero as = zero length-cotake (suc n) (a ∷ as) = suc λ where .force → length-cotake (n .force) (as .force) map-cotake : ∀ (f : A → B) n as → i ⊢ map f (cotake n as) ≈ cotake n (Stream.map f as) map-cotake f zero as = [] map-cotake f (suc n) (a ∷ as) = Eq.refl ∷ λ where .force → map-cotake f (n .force) (as .force) ------------------------------------------------------------------------ -- Properties of chunksOf module Map-ChunksOf (f : A → B) n where open ChunksOf n using (chunksOfAcc) map-chunksOf : ∀ as → i coWriterᵇ.⊢ Cowriter.map (Vec.map f) (Vec≤.map f) (chunksOf n as) ≈ chunksOf n (map f as) map-chunksOfAcc : ∀ m as {k≤ k≡ k≤′ k≡′} → (∀ vs → Vec≤.map f (k≤ vs) ≡ k≤′ (Vec≤.map f vs)) → (∀ vs → Vec.map f (k≡ vs) ≡ k≡′ (Vec.map f vs)) → i coWriterᵇ.⊢ Cowriter.map (Vec.map f) (Vec≤.map f) (chunksOfAcc m k≤ k≡ as) ≈ chunksOfAcc m k≤′ k≡′ (map f as) map-chunksOf as = map-chunksOfAcc n as (λ vs → Eq.refl) (λ vs → Eq.refl) map-chunksOfAcc zero as eq-≤ eq-≡ = eq-≡ [] ∷ λ where .force → map-chunksOf as map-chunksOfAcc (suc m) [] eq-≤ eq-≡ = coWriterᵇ.[ eq-≤ Vec≤.[] ] map-chunksOfAcc (suc m) (a ∷ as) eq-≤ eq-≡ = map-chunksOfAcc m (as .force) (eq-≤ ∘ (a Vec≤.∷_)) (eq-≡ ∘ (a Vec.∷_)) open Map-ChunksOf using (map-chunksOf) public ------------------------------------------------------------------------ -- Properties of fromList fromList-++ : (as bs : List A) → i ⊢ fromList (as List.++ bs) ≈ fromList as ++ fromList bs fromList-++ [] bs = refl fromList-++ (a ∷ as) bs = Eq.refl ∷ λ where .force → fromList-++ as bs fromList-scanl : ∀ (c : B → A → B) n as → i ⊢ fromList (List.scanl c n as) ≈ scanl c n (fromList as) fromList-scanl c n [] = Eq.refl ∷ λ where .force → refl fromList-scanl c n (a ∷ as) = Eq.refl ∷ λ where .force → fromList-scanl c (c n a) as map-fromList : ∀ (f : A → B) as → i ⊢ map f (fromList as) ≈ fromList (List.map f as) map-fromList f [] = [] map-fromList f (a ∷ as) = Eq.refl ∷ λ where .force → map-fromList f as length-fromList : (as : List A) → i coℕᵇ.⊢ length (fromList as) ≈ fromℕ (List.length as) length-fromList [] = zero length-fromList (a ∷ as) = suc (λ where .force → length-fromList as) ------------------------------------------------------------------------ -- Properties of fromStream fromStream-++ : ∀ (as : List A) bs → i ⊢ fromStream (as Stream.++ bs) ≈ fromList as ++ fromStream bs fromStream-++ [] bs = refl fromStream-++ (a ∷ as) bs = Eq.refl ∷ λ where .force → fromStream-++ as bs fromStream-⁺++ : ∀ (as : List⁺ A) bs → i ⊢ fromStream (as Stream.⁺++ bs) ≈ fromList⁺ as ++ fromStream (bs .force) fromStream-⁺++ (a ∷ as) bs = Eq.refl ∷ λ where .force → fromStream-++ as (bs .force) fromStream-concat : (ass : Stream (List⁺ A) ∞) → i ⊢ concat (fromStream ass) ≈ fromStream (Stream.concat ass) fromStream-concat (as@(a ∷ _) ∷ ass) = begin concat (fromStream (as ∷ ass)) ≈⟨ Eq.refl ∷ (λ { .force → ++⁺ ≋-refl (fromStream-concat (ass .force))}) ⟩ a ∷ _ ≈⟨ sym (fromStream-⁺++ as _) ⟩ fromStream (Stream.concat (as ∷ ass)) ∎ where open ≈-Reasoning fromStream-scanl : ∀ (c : B → A → B) n as → i ⊢ scanl c n (fromStream as) ≈ fromStream (Stream.scanl c n as) fromStream-scanl c n (a ∷ as) = Eq.refl ∷ λ where .force → fromStream-scanl c (c n a) (as .force) map-fromStream : ∀ (f : A → B) as → i ⊢ map f (fromStream as) ≈ fromStream (Stream.map f as) map-fromStream f (a ∷ as) = Eq.refl ∷ λ where .force → map-fromStream f (as .force)
{ "alphanum_fraction": 0.5186267348, "avg_line_length": 40.9880239521, "ext": "agda", "hexsha": "f2c67525ee6ecda567b9b4fe7b4ce0415ce68d23", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Codata/Colist/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Codata/Colist/Properties.agda", "max_line_length": 81, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Codata/Colist/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 4721, "size": 13690 }
module Cats.Category.Constructions.Epi where open import Level open import Cats.Category.Base module Build {lo la l≈} (Cat : Category lo la l≈) where private open module Cat = Category Cat open Cat.≈-Reasoning IsEpi : ∀ {A B} → A ⇒ B → Set (lo ⊔ la ⊔ l≈) IsEpi {A} {B} f = ∀ {C} {g h : B ⇒ C} → g ∘ f ≈ h ∘ f → g ≈ h
{ "alphanum_fraction": 0.6042296073, "avg_line_length": 22.0666666667, "ext": "agda", "hexsha": "1ec8f02d230f320306ad828c4785110dfc2c0f9b", "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/Constructions/Epi.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/Constructions/Epi.agda", "max_line_length": 63, "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/Constructions/Epi.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 127, "size": 331 }
------------------------------------------------------------------------ -- A library for working with dependently typed syntax -- Nils Anders Danielsson ------------------------------------------------------------------------ -- This library is leaning heavily on two of Conor McBride's papers: -- -- * Type-Preserving Renaming and Substitution. -- -- * Outrageous but Meaningful Coincidences: Dependent type-safe -- syntax and evaluation. -- This module gives a brief overview of the modules in the library. module README where ------------------------------------------------------------------------ -- The library -- Contexts, variables, context morphisms, context extensions, etc. import deBruijn.Context -- Parallel substitutions (defined using an inductive family). import deBruijn.Substitution.Data.Basics -- A map function for the substitutions. import deBruijn.Substitution.Data.Map -- Some simple substitution combinators. (Given a term type which -- supports weakening and transformation of variables to terms various -- substitutions are defined and various lemmas proved.) import deBruijn.Substitution.Data.Simple -- Given an operation which applies a substitution to a term, -- satisfying some properties, more operations and lemmas are -- defined/proved. -- -- (This module reexports various other modules.) import deBruijn.Substitution.Data.Application -- A module which repackages (and reexports) the development under -- deBruijn.Substitution.Data. import deBruijn.Substitution.Data -- Some modules mirroring the development under -- deBruijn.Substitution.Data, but using substitutions defined as -- functions rather than data. -- -- The functional version of substitutions is in some respects easier -- to work with than the one based on data, but in other respects more -- awkward. I maintain both developments so that they can be compared. import deBruijn.Substitution.Function.Basics import deBruijn.Substitution.Function.Map import deBruijn.Substitution.Function.Simple -- The two definitions of substitutions are isomorphic (assuming -- extensionality). import deBruijn.Substitution.Isomorphic ------------------------------------------------------------------------ -- An example showing how the library can be used -- A well-typed representation of a dependently typed language. import README.DependentlyTyped.Term -- Normal and neutral terms. import README.DependentlyTyped.NormalForm -- Instantiation of deBruijn.Substitution.Data for terms. import README.DependentlyTyped.Term.Substitution -- Instantiation of deBruijn.Substitution.Data for normal and neutral -- terms. import README.DependentlyTyped.NormalForm.Substitution -- Normalisation by evaluation. import README.DependentlyTyped.NBE -- Various equality checkers (some complete, all sound). import README.DependentlyTyped.Equality-checker -- Raw terms. import README.DependentlyTyped.Raw-term -- A type-checker (sound). import README.DependentlyTyped.Type-checker -- A definability result: A "closed value" is the semantics of a -- closed term if and only if it satisfies all "Kripke predicates". import README.DependentlyTyped.Definability -- An observation: There is a term without a corresponding syntactic -- type (given some assumptions). import README.DependentlyTyped.Term-without-type -- Another observation: If the "Outrageous but Meaningful -- Coincidences" approach is used to formalise a language, then you -- can end up with an extensional type theory (with equality -- reflection). import README.DependentlyTyped.Extensional-type-theory -- Inductively defined beta-eta-equality. import README.DependentlyTyped.Beta-Eta -- TODO: Add an untyped example.
{ "alphanum_fraction": 0.7296056186, "avg_line_length": 29.380952381, "ext": "agda", "hexsha": "1ab7ef005ad76d30967e51bf2afc5d0b7ba32ca6", "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": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/dependently-typed-syntax", "max_forks_repo_path": "README.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "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/dependently-typed-syntax", "max_issues_repo_path": "README.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/dependently-typed-syntax", "max_stars_repo_path": "README.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-08T22:51:36.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T12:14:44.000Z", "num_tokens": 757, "size": 3702 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties that are related to pointwise lifting of binary -- relations to sigma types and make use of heterogeneous equality ------------------------------------------------------------------------ {-# OPTIONS --with-K --safe #-} module Data.Product.Relation.Binary.Pointwise.Dependent.WithK where open import Data.Product open import Data.Product.Relation.Binary.Pointwise.Dependent open import Function open import Function.Inverse using (Inverse) open import Relation.Binary using (_⇒_) open import Relation.Binary.HeterogeneousEquality as H using (_≅_) open import Relation.Binary.Indexed.Heterogeneous using (IndexedSetoid) open import Relation.Binary.PropositionalEquality as P using (_≡_) ------------------------------------------------------------------------ -- The propositional equality setoid over sigma types can be -- decomposed using Pointwise module _ {a b} {A : Set a} {B : A → Set b} where Pointwise-≡⇒≡ : Pointwise B _≡_ (λ x y → x ≅ y) ⇒ _≡_ Pointwise-≡⇒≡ (P.refl , H.refl) = P.refl ≡⇒Pointwise-≡ : _≡_ ⇒ Pointwise B _≡_ (λ x y → x ≅ y) ≡⇒Pointwise-≡ P.refl = (P.refl , H.refl) Pointwise-≡↔≡ : Inverse (setoid (P.setoid A) (H.indexedSetoid B)) (P.setoid (Σ A B)) Pointwise-≡↔≡ = record { to = record { _⟨$⟩_ = id; cong = Pointwise-≡⇒≡ } ; from = record { _⟨$⟩_ = id; cong = ≡⇒Pointwise-≡ } ; inverse-of = record { left-inverse-of = uncurry (λ _ _ → (P.refl , H.refl)) ; right-inverse-of = λ _ → P.refl } }
{ "alphanum_fraction": 0.5705483672, "avg_line_length": 37.7441860465, "ext": "agda", "hexsha": "4e29b027677b5dc8bab1aa81f9239654bd5b83c7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Relation/Binary/Pointwise/Dependent/WithK.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Relation/Binary/Pointwise/Dependent/WithK.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Relation/Binary/Pointwise/Dependent/WithK.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 467, "size": 1623 }
{-# OPTIONS --rewriting --confluence-check #-} open import Agda.Builtin.Bool open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Rewrite variable A : Set postulate f : (A → A) → Bool f-id : f {A} (λ x → x) ≡ true f-const : (c : A) → f (λ x → c) ≡ false {-# REWRITE f-id #-} {-# REWRITE f-const #-}
{ "alphanum_fraction": 0.5843023256, "avg_line_length": 21.5, "ext": "agda", "hexsha": "33530c19c903f7f07fcafc28f8acd4ce6dea6c08", "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/NonConfluentBecauseOfEta.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/NonConfluentBecauseOfEta.agda", "max_line_length": 46, "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/NonConfluentBecauseOfEta.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": 115, "size": 344 }
module ShouldBePi where data One : Set where one : One err1 : One err1 = \x -> x err2 : One err2 = one one err3 : One err3 x = x
{ "alphanum_fraction": 0.6204379562, "avg_line_length": 8.5625, "ext": "agda", "hexsha": "bda49c9947ffe2233a40c6e38802f87817769e53", "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/ShouldBePi.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/ShouldBePi.agda", "max_line_length": 23, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/ShouldBePi.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": 53, "size": 137 }
module Numeral.Natural.Oper.Modulo.Proofs.Algorithm where import Lvl open import Logic open import Numeral.Natural open import Numeral.Natural.Oper open import Numeral.Natural.Oper.Modulo open import Numeral.Natural.Oper.Proofs open import Numeral.Natural.Oper.Proofs.Order open import Numeral.Natural.Relation open import Numeral.Natural.Relation.Order open import Numeral.Natural.Relation.Order.Proofs open import Relator.Equals open import Relator.Equals.Proofs open import Structure.Function open import Structure.Operator.Properties open import Structure.Relator.Properties open import Syntax.Function open import Syntax.Transitivity open import Type -- The many steps variant of: `[ r , b ] 𝐒(a') mod' 𝐒(b') = [ 𝐒(r) , b ] a' mod' b'` from the definition. mod'-ind-step : ∀{r b' a b c} → [ r , b' ] (a + c) mod' (b + c) ≡ [ (r + c) , b' ] a mod' b mod'-ind-step {_}{_} {_}{_}{𝟎} = [≡]-intro mod'-ind-step {r}{b'}{a}{b}{𝐒 c} = mod'-ind-step {𝐒 r}{b'}{a}{b}{c = c} -- The many steps variant of: `[ r , b ] 𝐒(a') mod' 𝐒(b') = [ 𝐒(r) , b ] a' mod' b'` from the definition when the dividend is greater than the modulus. mod'-ind-step-modulo : ∀{r m' a m} → [ r , m' ] (a + m) mod' m ≡ [ (r + m) , m' ] a mod' 𝟎 mod'-ind-step-modulo {r}{m'}{a}{𝟎} = [ r , m' ] (a + 𝟎) mod' 𝟎 🝖[ _≡_ ]-[] [ (r + 𝟎) , m' ] a mod' 𝟎 🝖-end mod'-ind-step-modulo {r}{m'}{a}{𝐒 m} = [ r , m' ] (a + 𝐒(m)) mod' 𝐒(m) 🝖[ _≡_ ]-[] [ r , m' ] 𝐒(a + m) mod' 𝐒(m) 🝖[ _≡_ ]-[] [ 𝐒(r) , m' ] (a + m) mod' m 🝖[ _≡_ ]-[ mod'-ind-step-modulo {𝐒 r}{m'}{a}{m} ] [ 𝐒(r + m) , m' ] a mod' 𝟎 🝖[ _≡_ ]-[] [ (r + 𝐒(m)) , m' ] a mod' 𝟎 🝖-end -- When states and modulus is zero, the result is zero. mod'-zero-all-except-dividend : ∀{a} → ([ 0 , 0 ] a mod' 0 ≡ 0) mod'-zero-all-except-dividend {𝟎} = [≡]-intro mod'-zero-all-except-dividend {𝐒(a)} = mod'-zero-all-except-dividend {a} mod'-greater-dividend : ∀{r b' a b} → (a > b) → ([ r , b' ] a mod' b ≡ [ 𝟎 , b' ] (a −₀ 𝐒(b)) mod' b') mod'-greater-dividend {r} {b'} {.(𝐒 _)} {𝟎} (succ ab) = [≡]-intro mod'-greater-dividend {r} {b'} {.(𝐒 _)} {𝐒 b} (succ ab) = mod'-greater-dividend ab mod'-zero-modulo-greater-dividend : ∀{r a b} → (a > b) → ([ r , 𝟎 ] a mod' b ≡ 𝟎) mod'-zero-modulo-greater-dividend {r} {.𝟏} {𝟎} (succ {y = 𝟎} ab) = [≡]-intro mod'-zero-modulo-greater-dividend {r} {.(𝐒 (𝐒 a))} {𝟎} (succ {y = 𝐒 a} ab) = mod'-zero-all-except-dividend {a} mod'-zero-modulo-greater-dividend {r} {.(𝐒 _)} {𝐒 b} (succ ab) = mod'-zero-modulo-greater-dividend ab mod'-lesser-dividend : ∀{r b' a b} → (a ≤ b) → ([ r , b' ] a mod' b ≡ r + a) mod'-lesser-dividend {r} {b'} min = [≡]-intro mod'-lesser-dividend {r} {b'} (succ ab) = mod'-lesser-dividend {𝐒 r} {b'} ab -- When the number is the temporary modulus, the result is zero. mod'-equal-dividend : ∀{r b' b} → ([ r , b' ] 𝐒(b) mod' b) ≡ 𝟎 mod'-equal-dividend {r}{b'}{b} = mod'-greater-dividend {r}{b'} (reflexivity(_≤_) {𝐒 b}) mod'-sumᵣ-modulo : ∀{r b' a b} → ([ r , b' ] (a + 𝐒(b)) mod' b) ≡ ([ 𝟎 , b' ] a mod' b') mod'-sumᵣ-modulo {r}{b'}{a}{b} = mod'-greater-dividend {r}{b'}{a + 𝐒(b)}{b} (succ([≤]-of-[+]ᵣ {a}{b})) 🝖 congruence₁(a ↦ [ 𝟎 , b' ] a mod' b') (inverseOperᵣ(_+_)(_−₀_) {a}{b}) -- When the mod'-sumₗ-modulo : ∀{r b' a b} → ([ r , b' ] (𝐒(b) + a) mod' b) ≡ ([ 𝟎 , b' ] a mod' b') mod'-sumₗ-modulo {r}{b'}{a}{b} = congruence₁(a ↦ [ r , b' ] a mod' b) (commutativity(_+_) {𝐒(b)}{a}) 🝖 mod'-sumᵣ-modulo {r}{b'}{a}{b} mod'-maxᵣ : ∀{r b a b'} → ⦃ _ : (b' ≤ b) ⦄ → (([ r , r + b ] a mod' b') ≤ r + b) mod'-maxᵣ {r} {b} {𝟎} {b'} ⦃ b'b ⦄ = [≤]-of-[+]ₗ mod'-maxᵣ {r} {𝟎} {𝐒 a} {.0} ⦃ min ⦄ = mod'-maxᵣ {𝟎} {r} {a} {r} ⦃ reflexivity(_≤_) ⦄ mod'-maxᵣ {r} {𝐒 b} {𝐒 a} {.0} ⦃ min ⦄ = mod'-maxᵣ {𝟎} {𝐒(r + b)} {a} {𝐒(r + b)} ⦃ reflexivity(_≤_) ⦄ mod'-maxᵣ {r} {𝐒 b} {𝐒 a} {𝐒 b'} ⦃ succ {b'} p ⦄ = mod'-maxᵣ {𝐒 r} {b} {a} {b'} ⦃ p ⦄ mod'-maxₗ : ∀{r b a b'} → (([ r , b ] a mod' b') ≤ r + a) mod'-maxₗ {𝟎} {_} {𝟎} {_} = min mod'-maxₗ {𝐒 r}{b} {𝟎} {𝐒 b'} = mod'-maxₗ {𝐒 r}{𝟎}{𝟎}{b'} mod'-maxₗ {𝐒 r}{𝐒 b}{𝟎} {b'} = mod'-maxₗ {𝐒 r}{b}{𝟎}{b'} mod'-maxₗ {𝐒 r}{b} {𝐒 a}{𝟎} = mod'-maxₗ {𝟎} {b} {a} {b} 🝖 [≤]-successor ([≤]-successor ([≤]-of-[+]ᵣ {r})) mod'-maxₗ {r} {b} {𝐒 a}{𝐒 b'} = mod'-maxₗ {𝐒 r} {b} {a} {b'} mod'-maxₗ {𝟎} {𝟎} {𝐒 a}{𝟎} = [≤]-successor(mod'-maxₗ {𝟎} {𝟎} {a} {𝟎}) mod'-maxₗ {𝟎} {𝐒 b}{𝐒 a}{𝟎} = [≤]-successor(mod'-maxₗ {0} {𝐒 b} {a} {𝐒 b}) mod'-maxₗ {𝐒 r}{𝟎} {𝟎} {𝟎} = succ(mod'-maxₗ {r}{𝟎}{𝟎}{𝟎})
{ "alphanum_fraction": 0.5196989819, "avg_line_length": 54.4337349398, "ext": "agda", "hexsha": "0dbb6bb5aefee298f23f4b438814dc9404f7e283", "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/Oper/Modulo/Proofs/Algorithm.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/Oper/Modulo/Proofs/Algorithm.agda", "max_line_length": 175, "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/Oper/Modulo/Proofs/Algorithm.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": 2280, "size": 4518 }
{-# OPTIONS --without-K --safe #-} module Categories.Adjoint.Relative where -- Relative Adjoints, in their biased, level-restricted version -- In other words, this uses the Hom-Setoid equivalent variant -- of the adjoint formulation because relative adjoints don't -- have a natural unit/counit formulation. -- We use the Altenkirch-Chapman-Uustalu formulation, which means -- that what is adjoint is a Functor and a Category. open import Level open import Data.Product using (_,_; _×_) open import Function using (_$_) renaming (_∘_ to _∙_) open import Function.Equality using (Π; _⟶_; _⟨$⟩_) open import Relation.Binary using (Setoid) -- be explicit in imports to 'see' where the information comes from open import Categories.Adjoint open import Categories.Category.Core using (Category) open import Categories.Category.Product using (Product; _⁂_) open import Categories.Category.Instance.Setoids open import Categories.Functor using (Functor; _∘F_) renaming (id to idF) open import Categories.Functor.Bifunctor using (Bifunctor) open import Categories.Functor.Hom using (Hom[_][-,-]) open import Categories.NaturalTransformation using (NaturalTransformation; ntHelper) open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism) import Categories.Morphism.Reasoning as MR open import Categories.Monad.Relative renaming (Monad to RMonad) private variable o o′ ℓ ℓ′ e e′ : Level E : Category o ℓ e record RelativeAdjoint {C : Category o ℓ e} (D : Category o ℓ e) (J : Functor E C) : Set (levelOfTerm D ⊔ levelOfTerm J) where field L : Functor E D R : Functor D C private module C = Category C module D = Category D module E = Category E module L = Functor L module R = Functor R module J = Functor J Hom[L-,-] : Bifunctor E.op D (Setoids _ _) Hom[L-,-] = Hom[ D ][-,-] ∘F (L.op ⁂ idF) Hom[J-,R-] : Bifunctor E.op D (Setoids _ _) Hom[J-,R-] = Hom[ C ][-,-] ∘F (J.op ⁂ R) module Hom[L-,-] = Functor Hom[L-,-] module Hom[J-,R-] = Functor Hom[J-,R-] field Hom-NI : NaturalIsomorphism Hom[J-,R-] Hom[L-,-] RA⇒RMonad : {C D : Category o ℓ e} {E : Category o′ ℓ′ e′} {J : Functor E C} → RelativeAdjoint D J → RMonad J RA⇒RMonad {C = C} {D} {E} {J} RA = record { F₀ = F₀ (R ∘F L) ; unit = λ {c} → ⇐.η (c , F₀ L c) ⟨$⟩ D.id {F₀ L c} ; extend = λ {X} {Y} k → F₁ R (⇒.η (X , F₀ L Y) ⟨$⟩ k) ; identityʳ = idʳ ; identityˡ = R.F-resp-≈ (iso.isoʳ _ D.Equiv.refl) ○ R.identity ; assoc = a ; extend-≈ = λ k≈h → F-resp-≈ R (Π.cong (⇒.η _) k≈h) } where open RelativeAdjoint RA open Functor open NaturalIsomorphism Hom-NI module D = Category D module E = Category E module J = Functor J module L = Functor L module R = Functor R open Category C open HomReasoning open MR C idʳ : {x y : E.Obj} {k : J.₀ x ⇒ F₀ (R ∘F L) y} → R.₁ (⇒.η (x , L.₀ y) ⟨$⟩ k) ∘ (⇐.η (x , L.₀ x) ⟨$⟩ D.id) ≈ k idʳ {x} {y} {k} = begin R.₁ (⇒.η (x , L.₀ y) ⟨$⟩ k) ∘ (⇐.η (x , L.₀ x) ⟨$⟩ D.id) ≈⟨ introʳ J.identity ⟩ (R.₁ (⇒.η (x , L.₀ y) ⟨$⟩ k) ∘ (⇐.η (x , L.₀ x) ⟨$⟩ D.id)) ∘ J.₁ E.id ≈⟨ assoc ⟩ R.₁ (⇒.η (x , L.₀ y) ⟨$⟩ k) ∘ (⇐.η (x , L.₀ x) ⟨$⟩ D.id) ∘ J.₁ E.id ≈⟨ ⇐.sym-commute (E.id , ⇒.η (x , L.₀ y) ⟨$⟩ k) (D.Equiv.refl) ⟩ ⇐.η (x , L.₀ y) ⟨$⟩ ((⇒.η (x , L.₀ y) ⟨$⟩ k) D.∘ D.id D.∘ L.F₁ E.id) ≈⟨ Π.cong (⇐.η _) (MR.elimʳ D (MR.elimʳ D L.identity)) ⟩ ⇐.η (x , L.₀ y) ⟨$⟩ (⇒.η (x , L.₀ y) ⟨$⟩ k) ≈⟨ iso.isoˡ (x , _) Equiv.refl ⟩ k ∎ a : {x y z : E.Obj} {k : J.₀ x ⇒ R.₀ (L.₀ y)} {l : J.₀ y ⇒ R.₀ (L.₀ z)} → R.₁ (⇒.η (x , L.₀ z) ⟨$⟩ R.₁ (⇒.η (y , L.₀ z) ⟨$⟩ l) ∘ k) ≈ R.₁ (⇒.η (y , L.₀ z) ⟨$⟩ l) ∘ R.₁ (⇒.η (x , L.₀ y) ⟨$⟩ k) a {x} {y} {z} {k} {l} = begin R.₁ (⇒.η (x , L.₀ z) ⟨$⟩ (R.₁ (⇒.η (y , L.₀ z) ⟨$⟩ l) ∘ k)) ≈⟨ R.F-resp-≈ lemma ⟩ R.₁ ((⇒.η (y , L.₀ z) ⟨$⟩ l) D.∘ (⇒.η (x , L.₀ y) ⟨$⟩ k)) ≈⟨ R.homomorphism ⟩ R.₁ (⇒.η (y , L.₀ z) ⟨$⟩ l) ∘ R.₁ (⇒.η (x , L.₀ y) ⟨$⟩ k) ∎ where xz = (x , L.₀ z) yz = (y , L.₀ z) xy = (x , L.₀ y) module DR = D.HomReasoning lemma : ⇒.η xz ⟨$⟩ R.₁ (⇒.η yz ⟨$⟩ l) ∘ k D.≈ (⇒.η yz ⟨$⟩ l) D.∘ (⇒.η xy ⟨$⟩ k) lemma = DR.begin ⇒.η xz ⟨$⟩ R.₁ (⇒.η yz ⟨$⟩ l) ∘ k DR.≈⟨ Π.cong (⇒.η xz) (refl⟩∘⟨ introʳ J.identity ) ⟩ ⇒.η xz ⟨$⟩ R.₁ (⇒.η yz ⟨$⟩ l) ∘ (k ∘ J.₁ E.id) DR.≈⟨ ⇒.commute (E.id , ⇒.η yz ⟨$⟩ l) Equiv.refl ⟩ (⇒.η yz ⟨$⟩ l) D.∘ (⇒.η xy ⟨$⟩ k) D.∘ L.₁ E.id DR.≈⟨ D.sym-assoc ⟩ ((⇒.η yz ⟨$⟩ l) D.∘ (⇒.η xy ⟨$⟩ k)) D.∘ L.₁ E.id DR.≈⟨ MR.elimʳ D L.identity ⟩ (⇒.η yz ⟨$⟩ l) D.∘ (⇒.η xy ⟨$⟩ k) DR.∎ ⊣⇒RAdjoint : {C D : Category o ℓ e} {E : Category o′ ℓ′ e′} (L : Functor C D) (R : Functor D C) (J : Functor E C) → L ⊣ R → RelativeAdjoint D J ⊣⇒RAdjoint {C = C} {D} L R J A = record { L = L ∘F J ; R = R ; Hom-NI = record { F⇒G = ntHelper record { η = λ _ → record { _⟨$⟩_ = Radjunct ; cong = ∘-resp-≈ʳ ∙ L.F-resp-≈ } ; commute = λ _ x≈y → Radjunct-comm x≈y } ; F⇐G = ntHelper record { η = λ _ → record { _⟨$⟩_ = Ladjunct ; cong = C.∘-resp-≈ˡ ∙ R.F-resp-≈ } ; commute = λ _ x≈y → Ladjunct-comm x≈y } ; iso = λ X → record { isoˡ = λ eq → LRadjunct≈id ○ eq ; isoʳ = Equiv.trans RLadjunct≈id } } } where open Adjoint A open Category D module C = Category C module L = Functor L module R = Functor R module J = Functor J open C.HomReasoning
{ "alphanum_fraction": 0.5387568556, "avg_line_length": 39.0714285714, "ext": "agda", "hexsha": "ab924da1e3b24c115ed8d89b9f41534d9325c27b", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Adjoint/Relative.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Adjoint/Relative.agda", "max_line_length": 143, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Adjoint/Relative.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 2474, "size": 5470 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Setoids.Setoids open import Functions.Definition open import Sets.EquivalenceRelations open import Rings.Definition module Rings.Divisible.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) where open Setoid S open Equivalence eq open Ring R _∣_ : Rel A a ∣ b = Sg A (λ c → (a * c) ∼ b) divisibleWellDefined : {x y a b : A} → (x ∼ y) → (a ∼ b) → x ∣ a → y ∣ b divisibleWellDefined x=y a=b (c , xc=a) = c , transitive (*WellDefined (symmetric x=y) reflexive) (transitive xc=a a=b)
{ "alphanum_fraction": 0.6554487179, "avg_line_length": 31.2, "ext": "agda", "hexsha": "3447436857ce4dbfc13a814955593c1da6b90190", "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": "Rings/Divisible/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": "Rings/Divisible/Definition.agda", "max_line_length": 127, "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": "Rings/Divisible/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": 219, "size": 624 }
module Scratch.Subset where open import Level renaming (zero to lzero; suc to lsuc) open import Relation.Unary using (Pred; Satisfiable) renaming (Decidable to Dec₁) open import Relation.Binary renaming (Decidable to Dec₂) open import Relation.Binary.PropositionalEquality as Eq using (_≡_ ; _≢_; refl; cong; sym; trans; subst₂) open Eq.≡-Reasoning open import Data.Empty using (⊥-elim) open import Data.Nat.Base as ℕ using (ℕ;_+_;_∸_;suc;zero; _<_) open import Data.Bool using (not; Bool) open import Data.Bool.Properties hiding (_≟_) open import Data.Product open import Data.Sum renaming ([_,_] to _⊞_) open import Data.Vec hiding (allFin) open import Data.Vec.Properties open import Data.Fin.Properties using (∃-toSum) open import Data.Fin hiding (fold; _+_; _<_) renaming (zero to fzero ; suc to fsuc) hiding (_≟_) open import Relation.Nullary.Negation using (contradiction) open import Data.Fin.Properties using (suc-injective) open import Data.Fin.Subset open import Data.Fin.Subset.Properties open import Data.Maybe open import Data.List.Base renaming (tabulate to tab ; foldr to fold; [] to <>; [_] to <_>; map to lmap; lookup to llookup) hiding (tail; any) open import Data.List.Properties open import Data.List.Membership.Propositional renaming (_∈_ to _∈ℓ_) open import Data.List.Membership.Propositional.Properties open import Data.List.Relation.Unary.Any as Any hiding (tail) open import Data.List.Relation.Unary.Any.Properties open import Data.List.Relation.Unary.All as All open import Data.List.Relation.Unary.AllPairs as AllPairs open import Data.List.Relation.Unary.AllPairs.Properties open import Function.Base open import Relation.Nullary open import Data.Nat.Properties using (_≟_; m+n∸m≡n; +-∸-assoc; +-∸-comm; +-comm; +-identityʳ; 0∸n≡0; n≤0⇒n≡0; n≢0⇒n>0; +-0-commutativeMonoid) open import Algebra.Core import Algebra.Properties.BooleanAlgebra _\\_ : ∀ {n} → Op₂ (Subset n) S \\ T = S ∩ (∁ T) s\\⊥≡s : ∀ {n : ℕ} → (S : Subset n) → (S \\ ⊥) ≡ S s\\⊥≡s {n} S = begin S ∩ (∁ ⊥) ≡⟨ cong (S ∩_) ⊥≉⊤ ⟩ S ∩ ⊤ ≡⟨ ∩-identityʳ _ ⟩ S ∎ where open Algebra.Properties.BooleanAlgebra (∪-∩-booleanAlgebra n) Disj : ∀ {n} → Subset n → Subset n → Set Disj S T = S ∩ T ≡ ⊥ Disj-sym : ∀ {n} → Symmetric (Disj {n = n}) Disj-sym {n} {S} {T} S∩T≡⊥ = begin T ∩ S ≡⟨ ∩-comm T S ⟩ S ∩ T ≡⟨ S∩T≡⊥ ⟩ ⊥ ∎ ∩-⊆-stable : ∀ {n} → ∀ {p q} → (r : Subset n) → p ⊆ q → (p ∩ r) ⊆ (q ∩ r) ∩-⊆-stable {_} {p} {q} r p⊆q x∈p∩r = let x∈p = proj₁ (x∈p∩q⁻ p r x∈p∩r) x∈r = proj₂ (x∈p∩q⁻ p r x∈p∩r) in x∈p∩q⁺ ( p⊆q x∈p , x∈r ) idʳ⇒⊆ : ∀ {n} → (S T : Subset n) → (S ∪ T) ≡ T → S ⊆ T idʳ⇒⊆ {n} S T sut≡t = subst₂ _⊆_ refl sut≡t (p⊆p∪q T) p∩∁p≡⊥ : ∀ {n} → (p : Subset n) → p ∩ ∁ p ≡ ⊥ p∩∁p≡⊥ [] = refl p∩∁p≡⊥ (outside ∷ p) = cong (outside ∷_) (p∩∁p≡⊥ p) p∩∁p≡⊥ (inside ∷ p) = cong (outside ∷_) (p∩∁p≡⊥ p) p⊆q⇒p∩∁q≡⊥ : ∀ {n} → {S T : Subset n} → S ⊆ T → S ∩ (∁ T) ≡ ⊥ p⊆q⇒p∩∁q≡⊥ {_} {S} {T} s⊆t = let a = p∩∁p≡⊥ _ b : S ∩ (∁ T) ⊆ T ∩ (∁ T) b = ∩-⊆-stable (∁ T) s⊆t c = subst₂ _⊆_ refl a b in ⊆-antisym c (⊆-min _) p⊆q⇒p∩q≡p : ∀ {n} → (S T : Subset n) → S ⊆ T → S ∩ T ≡ S p⊆q⇒p∩q≡p S T s⊆t = sym (begin S ≡˘⟨ ∩-identityʳ _ ⟩ S ∩ ⊤ ≡˘⟨ cong (_ ∩_) (p∪∁p≡⊤ _) ⟩ S ∩ (T ∪ (∁ T)) ≡⟨ ∩-distribˡ-∪ _ _ _ ⟩ (S ∩ T) ∪ (S ∩ (∁ T)) ≡⟨ cong ((S ∩ T) ∪_) (p⊆q⇒p∩∁q≡⊥ s⊆t) ⟩ (S ∩ T) ∪ ⊥ ≡⟨ ∪-identityʳ _ ⟩ S ∩ T ∎) disj⇒⊆∁ : ∀ {n} → {S T : Subset n} → Disj S T → S ⊆ (∁ T) disj⇒⊆∁ {n} {S} {T} dst = let ct≡suct = begin ∁ T ≡˘⟨ ∪-identityˡ _ ⟩ ⊥ ∪ (∁ T) ≡˘⟨ cong (_∪ (∁ T)) dst ⟩ (S ∩ T) ∪ (∁ T) ≡⟨ ∪-distribʳ-∩ _ _ _ ⟩ (S ∪ (∁ T)) ∩ (T ∪ (∁ T)) ≡⟨ cong ((S ∪ (∁ T)) ∩_) (p∪∁p≡⊤ T) ⟩ (S ∪ (∁ T)) ∩ ⊤ ≡⟨ ∩-identityʳ _ ⟩ S ∪ (∁ T) ∎ in idʳ⇒⊆ S (∁ T) (sym ct≡suct) ⊆∁⇒disj : ∀ {n} → {S T : Subset n} → S ⊆ (∁ T) → Disj S T ⊆∁⇒disj {n} {S} {T} s⊆∁t = begin S ∩ T ≡˘⟨ cong (S ∩_) (¬-involutive T ) ⟩ S ∩ (∁ (∁ T)) ≡⟨ p⊆q⇒p∩∁q≡⊥ s⊆∁t ⟩ ⊥ ∎ where open Algebra.Properties.BooleanAlgebra (∪-∩-booleanAlgebra n) p⊆r×q⊆r⇒p∪q⊆r : ∀ {n} → { p q r : Subset n} → (p ⊆ r) × (q ⊆ r) → (p ∪ q) ⊆ r p⊆r×q⊆r⇒p∪q⊆r {n} {p} {q} {r} (p⊆r , q⊆r) x∈p∪q = let y = x∈p∪q⁻ {n} p q x∈p∪q in (p⊆r ⊞ q⊆r) y pᵢ⊆q⇒⋃pᵢ⊆q : ∀ {n m} → (S : Subset n) → (ϕ : Fin m → Subset n) → (∀ i → (ϕ i) ⊆ S) → (⋃ (tab ϕ) ⊆ S) pᵢ⊆q⇒⋃pᵢ⊆q {_} {zero} S _ _ = ⊆-min S pᵢ⊆q⇒⋃pᵢ⊆q {n} {suc m} S ϕ Δ = let y : ((ϕ fzero) ∪ (⋃(tab (ϕ ∘ fsuc)))) ⊆ S y = p⊆r×q⊆r⇒p∪q⊆r ( Δ fzero , pᵢ⊆q⇒⋃pᵢ⊆q S (λ z → ϕ (fsuc z)) (λ i → Δ (fsuc i)) ) in subst₂ _⊆_ refl refl y pᵢ⊆q⇒⋃pᵢ⊆q-list : ∀ {n} → ∀ S → ∀ (L : List (Subset n)) → All (_⊆ S) L → (⋃ L) ⊆ S pᵢ⊆q⇒⋃pᵢ⊆q-list S <> _ = ⊆-min S pᵢ⊆q⇒⋃pᵢ⊆q-list S (x ∷ xs) (h ∷ t) = subst₂ _⊆_ refl refl (p⊆r×q⊆r⇒p∪q⊆r ( h , pᵢ⊆q⇒⋃pᵢ⊆q-list S xs t )) -- obvious but exposes S for computation later drop-outside : ∀ {n} → (S : Subset n) → ∣ outside ∷ S ∣ ≡ ∣ S ∣ drop-outside S = refl drop-disj : ∀ {n} → {x y : Side} → {p q : Subset n} → Disj (x ∷ p) (y ∷ q) → Disj p q drop-disj {zero} {_} {_} {[]} {[]} _ = refl drop-disj d = cong Data.Vec.tail d ∣p⊍q∣≡∣p∣+∣q∣ : ∀ {n} → ∀ (p q : Subset n) → Disj p q → ∣ p ∪ q ∣ ≡ ∣ p ∣ + ∣ q ∣ ∣p⊍q∣≡∣p∣+∣q∣ {zero} [] [] d = refl ∣p⊍q∣≡∣p∣+∣q∣ {suc n} (outside ∷ p) (outside ∷ q) d = begin -- ∣ (outside ∷ p) ∪ (outside ∷ q) ∣ ≡⟨⟩ ∣ p ∪ q ∣ ≡⟨ ∣p⊍q∣≡∣p∣+∣q∣ {_} p q (drop-disj {n} {outside} {outside} d) ⟩ -- ∣ p ∣ + ∣ q ∣ ≡⟨⟩ ∣ (outside ∷ p) ∣ + ∣ (outside ∷ q) ∣ ∎ ∣p⊍q∣≡∣p∣+∣q∣ {suc n} (inside ∷ p) (outside ∷ q) d = begin -- {! !} -- begin ∣ (inside ∷ p) ∪ (outside ∷ q) ∣ ≡⟨ refl ⟩ -- cong suc refl ⟩ -- suc ∣ (inside ∷ p) ∪ (outside ∷ q) ∣ ≡⟨ cong suc {! !} ⟩ -- cong suc refl ⟩ suc ∣ p ∪ q ∣ ≡⟨ cong suc (∣p⊍q∣≡∣p∣+∣q∣ {_} p q (drop-disj {n} {inside} {outside} d)) ⟩ suc (∣ p ∣ + ∣ q ∣) ≡⟨⟩ (suc ∣ p ∣) + ∣ q ∣ ≡⟨⟩ ∣ (inside ∷ p) ∣ + ∣ (outside ∷ q) ∣ ∎ ∣p⊍q∣≡∣p∣+∣q∣ {suc n} (outside ∷ p) (inside ∷ q) d = begin ∣ (outside ∷ p) ∪ (inside ∷ q) ∣ ≡⟨ refl ⟩ suc ∣ p ∪ q ∣ ≡⟨ cong suc (∣p⊍q∣≡∣p∣+∣q∣ {_} p q (drop-disj {n} {outside} {inside} d)) ⟩ suc (∣ p ∣ + ∣ q ∣) ≡⟨ cong suc (+-comm ∣ p ∣ ∣ q ∣) ⟩ suc (∣ q ∣ + ∣ p ∣) ≡⟨ refl ⟩ (suc ∣ q ∣) + ∣ p ∣ ≡⟨⟩ ∣ (inside ∷ q) ∣ + ∣ (outside ∷ p) ∣ ≡⟨ +-comm ∣ (inside ∷ q) ∣ ∣ (outside ∷ p) ∣ ⟩ ∣ (outside ∷ p) ∣ + ∣ (inside ∷ q) ∣ ∎ -- why can't we use fold fusion here? ∣⋃ᵢpᵢ∣≡Σᵢ∣pᵢ∣ : ∀ {n m} → (ϕ : Fin m → Subset n) → (∀ i j → (i ≢ j) → Disj (ϕ i) (ϕ j)) → ∣ ⋃ (tab ϕ) ∣ ≡ fold _+_ 0 (tab (∣_∣ ∘ ϕ)) ∣⋃ᵢpᵢ∣≡Σᵢ∣pᵢ∣ {n} {zero} ϕ _ = begin ∣ ⋃ {n} <> ∣ ≡⟨⟩ -- ∣ fold (_∪_ {n}) ⊥ <> ∣ ≡⟨⟩ ∣ ⊥ {n} ∣ ≡⟨ ∣⊥∣≡0 n ⟩ 0 ≡⟨⟩ fold _+_ 0 <> ∎ ∣⋃ᵢpᵢ∣≡Σᵢ∣pᵢ∣ {n} {suc m} ϕ Δ = begin ∣ ⋃ (tab ϕ) ∣ ≡⟨⟩ ∣ (ϕ fzero) ∪ (⋃ (tab (ϕ ∘ fsuc))) ∣ ≡⟨ ∣p⊍q∣≡∣p∣+∣q∣ (ϕ fzero) (⋃ (tab (ϕ ∘ fsuc))) d ⟩ ∣ (ϕ fzero) ∣ + ∣ ⋃ (tab (ϕ ∘ fsuc)) ∣ ≡⟨ cong (∣ (ϕ fzero) ∣ +_) (∣⋃ᵢpᵢ∣≡Σᵢ∣pᵢ∣ {_} {m} (ϕ ∘ fsuc) λ i j i≢j → Δ (fsuc i) (fsuc j) (i≢j ∘ suc-injective) ) ⟩ ∣ (ϕ fzero) ∣ + (fold _+_ 0 (tab (∣_∣ ∘ (ϕ ∘ fsuc)))) ≡⟨⟩ fold _+_ 0 (tab (∣_∣ ∘ ϕ)) ∎ where a : ∀ (i : Fin m) → Disj (ϕ (fsuc i)) (ϕ fzero) a = λ i → Δ (fsuc i) fzero (λ ()) b : ∀ (i : Fin m) → (ϕ (fsuc i) ⊆ ∁ (ϕ fzero)) b = disj⇒⊆∁ ∘ a c : ⋃ (tab (ϕ ∘ fsuc)) ⊆ ∁ (ϕ fzero) c = pᵢ⊆q⇒⋃pᵢ⊆q (∁ (ϕ fzero)) (ϕ ∘ fsuc) b e : Disj (⋃ (tab (ϕ ∘ fsuc))) (ϕ fzero) e = ⊆∁⇒disj c d : Disj (ϕ fzero) (⋃ (tab (ϕ ∘ fsuc))) d = begin (ϕ fzero) ∩ (⋃ (tab (ϕ ∘ fsuc))) ≡⟨ ∩-comm _ _ ⟩ (⋃ (tab (ϕ ∘ fsuc))) ∩ (ϕ fzero) ≡⟨ e ⟩ ⊥ ∎ ∣⋃ᵢpᵢ∣≡Σᵢ∣pᵢ∣-list : ∀ {n} (C : List (Subset n)) → AllPairs Disj C → ∣ ⋃ C ∣ ≡ fold _+_ 0 (lmap ∣_∣ C) ∣⋃ᵢpᵢ∣≡Σᵢ∣pᵢ∣-list {n} <> Δℓ = begin ∣ ⋃ {n} <> ∣ ≡⟨⟩ -- ∣ fold (_∪_ {n}) ⊥ <> ∣ ≡⟨⟩ ∣ ⊥ {n} ∣ ≡⟨ ∣⊥∣≡0 n ⟩ 0 ≡⟨⟩ fold _+_ 0 <> ∎ ∣⋃ᵢpᵢ∣≡Σᵢ∣pᵢ∣-list {n} (s ∷ C) (h ∷ t) = begin ∣ ⋃ (s ∷ C) ∣ ≡⟨⟩ ∣ s ∪ (⋃ C) ∣ ≡⟨ ∣p⊍q∣≡∣p∣+∣q∣ s (⋃ C) DisjsUC ⟩ ∣ s ∣ + ∣ ⋃ C ∣ ≡⟨ cong (∣ s ∣ +_) (∣⋃ᵢpᵢ∣≡Σᵢ∣pᵢ∣-list {n} C t ) ⟩ ∣ s ∣ + (fold _+_ 0 (lmap ∣_∣ C)) ≡⟨⟩ fold _+_ 0 (lmap ∣_∣ (s ∷ C)) ∎ where a : All (λ x → x ⊆ ∁ s) C a = All.map (disj⇒⊆∁ ∘ Disj-sym) h c : ⋃ C ⊆ ∁ s c = pᵢ⊆q⇒⋃pᵢ⊆q-list (∁ s) C a e : Disj (⋃ C) s e = ⊆∁⇒disj c DisjsUC : Disj s (⋃ C) DisjsUC = Disj-sym e ⋃-remove : ∀ {n} {L : List (Subset n)} → ∀ s → (s∈L : s ∈ℓ L) → (⋃ L) ≡ s ∪ ⋃ (L Any.─ s∈L) ⋃-remove {n} {<>} _ = λ () ⋃-remove {n} {x ∷ xs} s (here px) = begin ⋃ (x ∷ xs) ≡⟨ refl ⟩ x ∪ (⋃ xs) ≡˘⟨ cong (_∪ _) px ⟩ s ∪ (⋃ xs) ≡⟨ cong (_ ∪_) refl ⟩ s ∪ ⋃ ((x ∷ xs) Data.List.Base.─ fzero ) ≡⟨ cong (_ ∪_) refl ⟩ s ∪ ⋃ ((x ∷ xs) Any.─ (here {P = P} px)) ∎ where P : Pred (Subset n) lzero P = s ≡_ ⋃-remove {n} {x ∷ xs} s (there s∈L) = begin x ∪ (⋃ xs) ≡⟨ cong (x ∪_) (⋃-remove {L = xs} s s∈L) ⟩ x ∪ (s ∪ ⋃ (xs Any.─ s∈L)) ≡˘⟨ ∪-assoc _ _ _ ⟩ -- TODO: -- use solver (x ∪ s) ∪ ⋃ (xs Any.─ s∈L) ≡⟨ cong (_∪ _) (∪-comm x s) ⟩ (s ∪ x) ∪ ⋃ (xs Any.─ s∈L) ≡⟨ ∪-assoc _ _ _ ⟩ s ∪ (x ∪ ⋃ (xs Any.─ s∈L)) ≡⟨ refl ⟩ s ∪ ⋃ ((x ∷ xs) Any.─ (there s∈L)) ∎ cover-⊤ : ∀ {n} → (L : List (Subset n)) → (∀ (x : Fin n) → Any (x ∈_) L ) → ⊤ {n} ≡ ⋃ L cover-⊤ {n} L ∃lx∈l = ⊆-antisym ⊤⊆⋃L (⊆-max (⋃ L)) where ⊤⊆⋃L : ⊤ ⊆ (⋃ L) ⊤⊆⋃L {x} _ = let (l , l∈ℓL , x∈l) = find {P = x ∈_} (∃lx∈l x) l⊆l∪* = p⊆p∪q {p = l} (⋃ (L Any.─ l∈ℓL)) x∈l∪* = l⊆l∪* {x} x∈l in subst₂ _∈_ refl (sym (⋃-remove l l∈ℓL)) x∈l∪* -- 👇 not essential |s\\t| : ∀ {n : ℕ} → ∀ {S T : Subset n} → T ⊆ S → ∣ S \\ T ∣ ≡ ∣ S ∣ ∸ ∣ T ∣ |s\\t| {.0} {[]} {T} t⊆s = begin ∣ [] \\ T ∣ ≡⟨ n≤0⇒n≡0 (∣p∩q∣≤∣p∣ [] (∁ T)) ⟩ 0 ≡˘⟨ 0∸n≡0 ∣ T ∣ ⟩ ∣ [] ∣ ∸ ∣ T ∣ ∎ |s\\t| {.(suc _)} {inside ∷ S} {inside ∷ T} t⊆s = |s\\t| {_} {S} {T} (drop-∷-⊆ t⊆s) |s\\t| {.(suc _)} {outside ∷ S} {outside ∷ T} t⊆s = |s\\t| {_} {S} {T} (drop-∷-⊆ t⊆s) |s\\t| {.(suc _)} {outside ∷ S} {inside ∷ T} t⊆s = let z = (t⊆s here) y = []=⇒lookup z w = not-¬ y in ⊥-elim (w refl) |s\\t| {(suc n)} {inside ∷ S} {outside ∷ T} t⊆s = sym (begin ∣ inside ∷ S ∣ ∸ ∣ outside ∷ T ∣ ≡⟨ refl ⟩ (suc ∣ S ∣) ∸ ∣ outside ∷ T ∣ ≡⟨ cong ((suc ∣ S ∣) ∸_) (drop-outside T) ⟩ (1 + ∣ S ∣) ∸ ∣ T ∣ ≡⟨ cong (_∸ ∣ T ∣) (Data.Nat.Properties.+-comm _ ∣ S ∣)⟩ (∣ S ∣ + 1) ∸ ∣ T ∣ ≡⟨ +-∸-comm 1 (p⊆q⇒∣p∣≤∣q∣ (drop-∷-⊆ {n} {_} {_} {T} {S} t⊆s)) ⟩ (∣ S ∣ ∸ ∣ T ∣) + 1 ≡⟨ Data.Nat.Properties.+-comm (∣ S ∣ ∸ ∣ T ∣) _ ⟩ (suc (∣ S ∣ ∸ ∣ T ∣)) ≡˘⟨ cong suc (|s\\t| {n} {S} {T} (drop-∷-⊆ {n} t⊆s))⟩ (suc ∣ S \\ T ∣) ≡⟨ refl ⟩ ∣ (inside ∷ S) \\ (outside ∷ T) ∣ ∎) fst : ∀ {n} → (s : Subset n) → Nonempty s → Fin n fst {suc n} (x ∷ rest) ne with (∃-toSum ne) ... | inj₁ _ = fzero ... | inj₂ b = let w = drop-there (proj₂ b) z = (proj₁ b , w) in fsuc (fst rest z) record Partition (n : ℕ) : Set where field Carrier : Subset n size : ℕ -- try parts as Data.Vec.Functional -- or try parts as List (Subset n) for ease of updates parts : Fin size → Subset n -- nne : 0 ℕ.< m nnd : ∀ i → Nonempty (parts i) all-⊆ : ∀ i → (parts i) ⊆ Carrier disj : ∀ i j → i ≢ j → Disj (parts i) (parts j) cover : Carrier ≡ ⋃ (tab parts) traversal : Vec (Fin n) size traversal = Data.Vec.tabulate λ i → fst (parts i) (nnd i) _P∈ : (j : Fin n) → Dec ( j ∈ Carrier ) j P∈ = (j ∈? Carrier) -- open import Data.Vec.Relation.Unary.Any {0ℓ} {Fin n} -- anyRel : {_≈_ : Rel (Fin n) 0ℓ } → Dec₂ _≈_ → (j : Fin n) → Dec (Any (j ≈_) traversal) -- anyRel _≈?_ j = any (j ≈?_) traversal -- do I need this for counting arguments? respects : Rel (Fin n) 0ℓ → Set _ respects _≈_ = ∀ x y → x ≈ y → ∃ λ i → (x ∈ parts i) × (y ∈ parts i) -- proj i = index (proof anyRel ≈ j) -- ∀ i → tabulate (i ≈?_) ≡ proj i ⊥P : ∀ {n} → Partition n ⊥P {n} = record { Carrier = ⊥ {n} ; size = 0 ; parts = λ () ; all-⊆ = λ () ; nnd = λ () ; disj = λ i () ; cover = refl } ------ has holes -- add : ∀ {n} {≈ : Rel (Fin n) 0ℓ } → Partition n → (Dec₂ ≈) → Fin n → Partition n -- add P ≈ j with (j P∈) where open Partition P -- ... | yes _ = P -- ... | no j∉P with (anyRel ≈ j) where open Partition P -- ... | yes p = {! !} -- ... | no ¬p = record { Carrier = Carrier ∪ ⁅ j ⁆ ; -- size = suc size ; -- parts = λ { fzero → ⁅ j ⁆ ; -- (fsuc k) → parts k } ; -- nnd = {! !} ; -- all-⊆ = {! !} ; -- disj = {! !} ; -- cover = {! !} -- } where open Partition P ----junk👇-------------------------------------------------------- -- ↓ : ∀ {n m : ℕ} → ∀ {S : Subset n} → ( 0 < m ) → -- (P : Partition S (suc m)) → Partition (S \\ Partition.p P fzero) m -- ↓ {_} {m} {S} 0<m P = record { p = p∘fsuc; -- nne = 0<m ; -- nnd = λ i → Partition.nnd P (fsuc i) ; -- all-⊆ = all-⊆' ; -- disj = disj' ; -- cover = c } where -- open Partition P -- p∘fsuc : _ -- p∘fsuc = p ∘ fsuc -- -- all-⊆' : ∀ (i : Fin m) → (p (fsuc i)) ⊆ (S \\ (p fzero)) -- all-⊆' i x∈pfsuci = let -- x : _ -- x = all-⊆ (fsuc i) -- y : Disj (p (fsuc i)) (p fzero) -- y = disj (fsuc i) fzero λ () -- -- x ∈ (S \\ p fzero) -- r : _ -- r = disj⇒⊆∁ {_} {p (fsuc i)} {p fzero} y -- s : _ -- s = Partition.all-⊆ P (fsuc i) x∈pfsuci -- t : _ -- t = r x∈pfsuci -- in x∈p∩q⁺ ( s , t ) -- -- disj' : _ -- disj' i j i≢j = disj (fsuc i) (fsuc j) (i≢j ∘ suc-injective) -- -- c : _ -- c = let -- a : _ -- a = cover -- b : _ -- b = S ≡ (p fzero) ∪ (⋃ (tab p∘fsuc)) -- S₀ = (p fzero) -- d = begin -- S \\ S₀ ≡⟨ cong (_\\ S₀) (Partition.cover P) ⟩ -- (⋃ (S₀ ∷ (tab p∘fsuc))) \\ S₀ ≡⟨ cong (_\\ S₀) refl ⟩ -- (S₀ ∪ (⋃ (tab p∘fsuc))) \\ S₀ ≡⟨ refl ⟩ -- (S₀ ∪ (⋃ (tab p∘fsuc))) ∩ (∁ S₀) ≡⟨ ∩-distribʳ-∪ _ _ _ ⟩ -- (S₀ ∩ (∁ S₀)) ∪ ((⋃ (tab p∘fsuc)) ∩ (∁ S₀)) ≡⟨ cong (_∪ ((⋃ (tab p∘fsuc)) ∩ (∁ S₀))) (p∩∁p≡⊥ _) ⟩ -- ⊥ ∪ ((⋃ (tab p∘fsuc)) ∩ (∁ S₀)) ≡⟨ ∪-identityˡ _ ⟩ -- (⋃ (tab p∘fsuc)) ∩ (∁ S₀) ≡⟨ {! !} ⟩ -- (⋃ (tab p∘fsuc)) -- ≡⟨ ? ⟩ -- ∎ -- t = {! !} -- in t -- -- this seems pretty obvious but helps rule out case with a single set below -- tab0 : ∀ {m : ℕ} → ∀ {B : Set} → {ϕ : Fin (suc m) → B} → (m ≡ ℕ.zero) → (tab ϕ) ≡ < ϕ fzero > -- tab0 {zero} m≡0 = refl -- -- would follow trivially from a kind of guarded (dependent) -- fold fusion with h = ∣_∣ f = _∪_ and g = _+c_ -- cc : ∀ {n m : ℕ} → {S : Subset n} → -- ∀ (P : Partition S m) → (card P) ≡ ∣ S ∣ -- cc {n} {m = suc m'} {S} P with m' ≟ 0 -- ... | yes m'≡0 = begin -- (card P) ≡⟨ refl ⟩ -- fold _+c_ 0 (tab p) ≡⟨ cong (fold _+c_ 0) (tab0 {m'} {Subset n} {p} m'≡0) ⟩ -- fold _+c_ 0 < p fzero > ≡⟨ refl ⟩ -- (p fzero) +c 0 ≡⟨ refl ⟩ -- -- (p fzero) +c (fold _+c_ 0 <>) ≡⟨ refl ⟩ -- -- fold _+c_ 0 ((p fzero) ∷ <>) ≡⟨ refl ⟩ -- ∣ (p fzero) ∣ + 0 ≡⟨ +-identityʳ _ ⟩ -- ∣ (p fzero) ∣ ≡˘⟨ cong ∣_∣ (∪-identityʳ (p fzero)) ⟩ -- ∣ (p fzero) ∪ ⊥ ∣ ≡˘⟨ refl ⟩ -- ∣ ⋃ < (p fzero) > ∣ ≡˘⟨ cong ∣_∣ (cong ⋃ (tab0 {m'} {Subset n} {p} m'≡0)) ⟩ -- ∣ ⋃ (tab p) ∣ ≡˘⟨ cong ∣_∣ cover ⟩ -- ∣ S ∣ ∎ where -- open Partition P -- -- ... | no ¬m'≡0 = begin -- (card P) ≡⟨⟩ -- fold _+c_ 0 ((p fzero) ∷ tab (p ∘ fsuc)) ≡⟨⟩ -- (p fzero) +c (fold _+c_ 0 (tab (p ∘ fsuc))) ≡⟨⟩ -- ∣ (p fzero) ∣ + (fold _+c_ 0 (tab (p ∘ fsuc))) ≡˘⟨ cong (∣ (p fzero) ∣ +_) refl ⟩ -- ∣ (p fzero) ∣ + card (↓ r P) ≡⟨ cong (_ +_) (cc (↓ r P)) ⟩ -- ∣ (p fzero) ∣ + ∣ S \\ (p fzero) ∣ ≡⟨ cong (_ +_) (|s\\t| (all-⊆ fzero)) ⟩ -- ∣ (p fzero) ∣ + ( ∣ S ∣ ∸ ∣ (p fzero) ∣ ) ≡˘⟨ +-∸-assoc ∣ (p fzero) ∣ (p⊆q⇒∣p∣≤∣q∣ (all-⊆ fzero)) ⟩ -- (∣ (p fzero) ∣ + ∣ S ∣) ∸ ∣ (p fzero) ∣ ≡⟨ m+n∸m≡n ∣ (p fzero) ∣ ∣ S ∣ ⟩ -- ∣ S ∣ ∎ where -- open Partition P -- r = (n≢0⇒n>0 ¬m'≡0)
{ "alphanum_fraction": 0.3130289933, "avg_line_length": 50.9449541284, "ext": "agda", "hexsha": "a804d9a866b0628521dd94d1eb4d8fc3fb033864", "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": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "zampino/ggt", "max_forks_repo_path": "src/scratch/Subset.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af", "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": "zampino/ggt", "max_issues_repo_path": "src/scratch/Subset.agda", "max_line_length": 191, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "zampino/ggt", "max_stars_repo_path": "src/scratch/Subset.agda", "max_stars_repo_stars_event_max_datetime": "2020-11-28T05:48:39.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-17T11:10:00.000Z", "num_tokens": 9023, "size": 22212 }
{-# OPTIONS --without-K --safe #-} module Definition.Typed.Consequences.Inversion where open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.Consequences.Syntactic open import Definition.Typed.Consequences.Substitution open import Tools.Product -- Inversion of natural number type. inversion-ℕ : ∀ {Γ C} → Γ ⊢ ℕ ∷ C → Γ ⊢ C ≡ U inversion-ℕ (ℕⱼ x) = refl (Uⱼ x) inversion-ℕ (conv x x₁) = trans (sym x₁) (inversion-ℕ x) -- Inversion of Π-types. inversion-Π : ∀ {F G Γ C} → Γ ⊢ Π F ▹ G ∷ C → Γ ⊢ F ∷ U × Γ ∙ F ⊢ G ∷ U × Γ ⊢ C ≡ U inversion-Π (Πⱼ x ▹ x₁) = x , x₁ , refl (Uⱼ (wfTerm x)) inversion-Π (conv x x₁) = let a , b , c = inversion-Π x in a , b , trans (sym x₁) c -- Inversion of zero. inversion-zero : ∀ {Γ C} → Γ ⊢ zero ∷ C → Γ ⊢ C ≡ ℕ inversion-zero (zeroⱼ x) = refl (ℕⱼ x) inversion-zero (conv x x₁) = trans (sym x₁) (inversion-zero x) -- Inversion of successor. inversion-suc : ∀ {Γ t C} → Γ ⊢ suc t ∷ C → Γ ⊢ t ∷ ℕ × Γ ⊢ C ≡ ℕ inversion-suc (sucⱼ x) = x , refl (ℕⱼ (wfTerm x)) inversion-suc (conv x x₁) = let a , b = inversion-suc x in a , trans (sym x₁) b -- Inversion of natural recursion. inversion-natrec : ∀ {Γ c g n A C} → Γ ⊢ natrec C c g n ∷ A → (Γ ∙ ℕ ⊢ C) × Γ ⊢ c ∷ C [ zero ] × Γ ⊢ g ∷ Π ℕ ▹ (C ▹▹ C [ suc (var 0) ]↑) × Γ ⊢ n ∷ ℕ × Γ ⊢ A ≡ C [ n ] inversion-natrec (natrecⱼ x d d₁ n) = x , d , d₁ , n , refl (substType x n) inversion-natrec (conv d x) = let a , b , c , d , e = inversion-natrec d in a , b , c , d , trans (sym x) e -- Inversion of application. inversion-app : ∀ {Γ f a A} → Γ ⊢ (f ∘ a) ∷ A → ∃₂ λ F G → Γ ⊢ f ∷ Π F ▹ G × Γ ⊢ a ∷ F × Γ ⊢ A ≡ G [ a ] inversion-app (d ∘ⱼ d₁) = _ , _ , d , d₁ , refl (substTypeΠ (syntacticTerm d) d₁) inversion-app (conv d x) = let a , b , c , d , e = inversion-app d in a , b , c , d , trans (sym x) e -- Inversion of lambda. inversion-lam : ∀ {t A Γ} → Γ ⊢ lam t ∷ A → ∃₂ λ F G → Γ ⊢ F × (Γ ∙ F ⊢ t ∷ G × Γ ⊢ A ≡ Π F ▹ G) inversion-lam (lamⱼ x x₁) = _ , _ , x , x₁ , refl (Πⱼ x ▹ (syntacticTerm x₁)) inversion-lam (conv x x₁) = let a , b , c , d , e = inversion-lam x in a , b , c , d , trans (sym x₁) e
{ "alphanum_fraction": 0.5441941075, "avg_line_length": 36.6349206349, "ext": "agda", "hexsha": "b4cbcaa7f7e6c9498ce5256d7d4c29cfe655797b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "loic-p/logrel-mltt", "max_forks_repo_path": "Definition/Typed/Consequences/Inversion.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "loic-p/logrel-mltt", "max_issues_repo_path": "Definition/Typed/Consequences/Inversion.agda", "max_line_length": 81, "max_stars_count": null, "max_stars_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "loic-p/logrel-mltt", "max_stars_repo_path": "Definition/Typed/Consequences/Inversion.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 964, "size": 2308 }
------------------------------------------------------------------------------ -- Totality properties for Tree ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Program.Mirror.Tree.TotalityATP where open import FOTC.Base open import FOTC.Base.List open import FOTC.Data.List open import FOTC.Program.Mirror.Forest.TotalityATP open import FOTC.Program.Mirror.Mirror open import FOTC.Program.Mirror.Type ------------------------------------------------------------------------------ mirror-Tree : ∀ {t} → Tree t → Tree (mirror · t) mirror-Tree = Tree-mutual-ind {A} {B} hA B[] hB where A : D → Set A t = Tree (mirror · t) {-# ATP definition A #-} B : D → Set B ts = Forest (map mirror ts) {-# ATP definition B #-} postulate hA : ∀ d {ts} → Forest ts → B ts → A (node d ts) B[] : B [] hB : ∀ {t ts} → Tree t → A t → Forest ts → B ts → B (t ∷ ts) {-# ATP prove hA reverse-Forest #-} {-# ATP prove B[] #-} {-# ATP prove hB #-}
{ "alphanum_fraction": 0.4711375212, "avg_line_length": 30.2051282051, "ext": "agda", "hexsha": "2a8b360553313e49672d3773307419a397b7dc0c", "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/Mirror/Tree/TotalityATP.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/Mirror/Tree/TotalityATP.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/FOTC/Program/Mirror/Tree/TotalityATP.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": 299, "size": 1178 }
------------------------------------------------------------------------ -- A universe for stream programs ------------------------------------------------------------------------ module Stream.Programs where open import Codata.Musical.Notation renaming (∞ to ∞_) import Stream as S open S using (Stream; _≈_; _≺_; head; tail) open import Relation.Binary.PropositionalEquality open import Data.Vec using (Vec; []; _∷_) ------------------------------------------------------------------------ -- Stream programs infix 8 _∞ infixr 7 _·_ infix 6 _⟨_⟩_ infixr 5 _≺_ _⋎_ _≺≺_ data Prog (A : Set) : Set1 where _≺_ : (x : A) (xs : ∞ (Prog A)) → Prog A _∞ : (x : A) → Prog A _·_ : ∀ {B} (f : B → A) (xs : Prog B) → Prog A _⟨_⟩_ : ∀ {B C} (xs : Prog B) (_∙_ : B → C → A) (ys : Prog C) → Prog A _⋎_ : (xs ys : Prog A) → Prog A iterate : (f : A → A) (x : A) → Prog A _≺≺_ : ∀ {n} (xs : Vec A n) (ys : Prog A) → Prog A data WHNF A : Set1 where _≺_ : (x : A) (xs : Prog A) → WHNF A ------------------------------------------------------------------------ -- Conversion whnf : ∀ {A} → Prog A → WHNF A whnf (x ≺ xs) = x ≺ ♭ xs whnf (x ∞) = x ≺ x ∞ whnf (f · xs) with whnf xs whnf (f · xs) | x ≺ xs′ = f x ≺ f · xs′ whnf (xs ⟨ _∙_ ⟩ ys) with whnf xs | whnf ys whnf (xs ⟨ _∙_ ⟩ ys) | x ≺ xs′ | y ≺ ys′ = (x ∙ y) ≺ xs′ ⟨ _∙_ ⟩ ys′ whnf (xs ⋎ ys) with whnf xs whnf (xs ⋎ ys) | x ≺ xs′ = x ≺ ys ⋎ xs′ whnf (iterate f x) = x ≺ iterate f (f x) whnf ([] ≺≺ ys) = whnf ys whnf ((x ∷ xs) ≺≺ ys) = x ≺ xs ≺≺ ys mutual value : ∀ {A} → WHNF A → Stream A value (x ≺ xs) = x ≺ ♯ ⟦ xs ⟧ ⟦_⟧ : ∀ {A} → Prog A → Stream A ⟦ xs ⟧ = value (whnf xs) fromStream : ∀ {A} → Stream A → Prog A fromStream (x ≺ xs) = x ≺ ♯ fromStream (♭ xs) lift : ∀ {A} → (Prog A → Prog A) → Stream A → Stream A lift f xs = ⟦ f (fromStream xs) ⟧ ------------------------------------------------------------------------ -- Some abbreviations infixr 5 _≺♯_ _≺♯_ : ∀ {A} → A → Prog A → Prog A x ≺♯ xs = x ≺ ♯ xs headP : ∀ {A} → Prog A → A headP xs = head ⟦ xs ⟧ tailP : ∀ {A} → Prog A → Prog A tailP xs with whnf xs tailP xs | x ≺ xs′ = xs′
{ "alphanum_fraction": 0.4172304917, "avg_line_length": 28.4230769231, "ext": "agda", "hexsha": "56f304b28f53403ae724d5af6cc5cd09dbd842a6", "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": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/codata", "max_forks_repo_path": "Stream/Programs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "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/codata", "max_issues_repo_path": "Stream/Programs.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/codata", "max_stars_repo_path": "Stream/Programs.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z", "num_tokens": 889, "size": 2217 }
{- Examples by Twan van Laarhoven -} {-# OPTIONS --rewriting #-} module _ where open import Agda.Builtin.Equality {-# BUILTIN REWRITE _≡_ #-} const : ∀ {a b} {A : Set a} {B : Set b} → A → B → A const x _ = x _∘_ : ∀ {a b c} {A : Set a} {B : A → Set b} {C : {x : A} → B x → Set c} → (f : ∀ {x} (y : B x) → C y) (g : (x : A) → B x) → (x : A) → C (g x) (f ∘ g) x = f (g x) postulate M : Set → Set postulate pure : ∀ {A} → A → M A postulate _>>=_ : ∀ {A B} → M A → (A → M B) → M B postulate bind-assoc : ∀ {A B C mx} {my : A → M B} {mz : B → M C} → (mx >>= my) >>= mz ≡ mx >>= \x → my x >>= mz {-# REWRITE bind-assoc #-} _<*>_ : ∀ {A B} → M (A → B) → M A → M B mf <*> mx = mf >>= \f → mx >>= (pure ∘ f) -- Agda was comparing inferred relevances here, causing the rewrite rule -- to fail. shouldWork : ∀ {A B} (mx : M A) (my : M B) → (mx >>= (pure ∘ const)) <*> my ≡ (mx >>= (pure ∘ const)) >>= (\f → my >>= (pure ∘ f)) shouldWork mx my = refl shouldAlsoWork : ∀ {A B} (mx : M A) (my : M B) → (mx >>= (pure ∘ const)) <*> my ≡ (mx >>= (pure ∘ \x _ → x)) >>= (\f → my >>= (pure ∘ f)) shouldAlsoWork mx my = refl shouldAlsoWork2 : ∀ {A B} (mx : M A) (my : M B) → (mx >>= (pure ∘ const)) >>= (\f → my >>= (pure ∘ f)) ≡ (mx >>= (pure ∘ \x _ → x)) >>= (\f → my >>= (pure ∘ f)) shouldAlsoWork2 mx my = refl
{ "alphanum_fraction": 0.4600903614, "avg_line_length": 31.619047619, "ext": "agda", "hexsha": "2ee549468110be39c995b1a121777a1bbda0d23d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/Issue2328.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Succeed/Issue2328.agda", "max_line_length": 114, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/Issue2328.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": 554, "size": 1328 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.PtdAdjoint module homotopy.SuspAdjointLoopLadder where import homotopy.SuspAdjointLoop as A step : ∀ {i} {X Y Z : Ptd i} (f : Y ⊙→ Z) → CommSquareEquiv ((f ⊙∘_) :> ((⊙Susp X ⊙→ Y) → (⊙Susp X ⊙→ Z))) (⊙Ω-fmap f ⊙∘_) (–> (A.eq X Y)) (–> (A.eq X Z)) step f = comm-sqr (! ∘ A.nat-cod _ f) , snd (A.eq _ _) , snd (A.eq _ _) rail : ∀ {i} {X Y : Ptd i} n → (⊙Susp^ n X ⊙→ Y) → (X ⊙→ ⊙Ω^' n Y) rail O = idf _ rail (S n) = rail n ∘ –> (A.eq _ _) ladder : ∀ {i} {X Y Z : Ptd i} n (f : Y ⊙→ Z) → CommSquareEquiv ((f ⊙∘_) :> ((⊙Susp^ n X ⊙→ Y) → (⊙Susp^ n X ⊙→ Z))) (⊙Ω^'-fmap n f ⊙∘_) (rail n) (rail n) ladder O _ = (comm-sqr λ _ → idp) , idf-is-equiv _ , idf-is-equiv _ ladder (S n) f = CommSquareEquiv-∘v (ladder n (⊙Ω-fmap f)) (step f)
{ "alphanum_fraction": 0.4791208791, "avg_line_length": 28.4375, "ext": "agda", "hexsha": "711c1a7981d648d01192866e5ddb973358741d3c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/SuspAdjointLoopLadder.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/SuspAdjointLoopLadder.agda", "max_line_length": 69, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/SuspAdjointLoopLadder.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 416, "size": 910 }
{-# OPTIONS --rewriting --without-K #-} open import Agda.Primitive open import Prelude open import GSeTT.Syntax open import GSeTT.Rules open import GSeTT.CwF-structure open import GSeTT.Uniqueness-Derivations {- Typed syntax for type theory for globular sets -} module GSeTT.Typed-Syntax where Ctx : Set₁ Ctx = Σ Pre-Ctx (λ Γ → Γ ⊢C) Ty : Ctx → Set₁ Ty (Γ , _) = Σ Pre-Ty (λ A → Γ ⊢T A) Tm : ∀ (Γ : Ctx) → Ty Γ → Set₁ Tm (Γ , _) (A , _) = Σ Pre-Tm (λ t → Γ ⊢t t # A) Sub : ∀ (Δ : Ctx) (Γ : Ctx) → Set₁ Sub (Δ , _) (Γ , _) = Σ Pre-Sub (λ γ → Δ ⊢S γ > Γ) eqC : ∀ (Γ Δ : Ctx) → fst Γ == fst Δ → Γ == Δ eqC (Γ , Γ⊢) (.Γ , Γ⊢') idp = Σ= idp (has-all-paths-⊢C _ _) eqT : ∀ {Γ} (A B : Ty Γ) → fst A == fst B → A == B eqT (A , Γ⊢A) (.A , Γ⊢'A) idp = Σ= idp (has-all-paths-⊢T _ _) eqt : ∀ {Γ A} (t u : Tm Γ A) → fst t == fst u → t == u eqt (t , Γ⊢t:A) (.t , Γ⊢':A) idp = Σ= idp (has-all-paths-⊢t _ _) eqS : ∀ {Γ Δ} (γ δ : Sub Γ Δ) → fst γ == fst δ → γ == δ eqS (γ , Γ⊢γ:Δ) (.γ , Γ⊢'γ:Δ) idp = Σ= idp (has-all-paths-⊢S _ _) trS : ∀ {Γ Δ Θ : Ctx} → (p : Δ == Θ) → {γ : Sub Γ Δ} → {δ : Sub Γ Θ} → fst γ == fst δ → transport p γ == δ trS {Γ} {Δ} {Θ} idp {γ} {δ} x = eqS {Γ} {Θ} γ δ x eqdec-Ty : ∀ Γ → eqdec (Ty Γ) eqdec-Ty Γ (A , Γ⊢A) (B , Γ⊢B) with eqdec-PreTy A B ... | inl idp = inl (eqT {Γ} (A , Γ⊢A) (B , Γ⊢B) idp) ... | inr A≠B = inr λ p → A≠B (fst-is-inj p) is-set-Ty : ∀ Γ → is-set (Ty Γ) is-set-Ty Γ = eqdec-is-set (eqdec-Ty Γ)
{ "alphanum_fraction": 0.4993261456, "avg_line_length": 32.2608695652, "ext": "agda", "hexsha": "067a652df04367267bc7303c5c5d3faa62df2f68", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thibautbenjamin/catt-formalization", "max_forks_repo_path": "GSeTT/Typed-Syntax.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thibautbenjamin/catt-formalization", "max_issues_repo_path": "GSeTT/Typed-Syntax.agda", "max_line_length": 108, "max_stars_count": null, "max_stars_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thibautbenjamin/catt-formalization", "max_stars_repo_path": "GSeTT/Typed-Syntax.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 764, "size": 1484 }
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module Issue15 where infix 7 _≡_ infixr 5 _∧_ infix 5 ∃ infixr 4 _∨_ data _∨_ (A B : Set) : Set where inj₁ : A → A ∨ B inj₂ : B → A ∨ B data _∧_ (A B : Set) : Set where _,_ : A → B → A ∧ B postulate D : Set _·_ : D → D → D succ : D → D zero : D data ∃ (A : D → Set) : Set where _,_ : (t : D) → A t → ∃ A syntax ∃ (λ x → e) = ∃[ x ] e data _≡_ (x : D) : D → Set where refl : x ≡ x postulate Conat : D → Set postulate Conat-out : ∀ {n} → Conat n → n ≡ zero ∨ (∃[ n' ] n ≡ succ n' ∧ Conat n') {-# ATP axiom Conat-out #-} postulate Conat-coind : (A : D → Set) → -- A is post-fixed point of NatF. (∀ {n} → A n → n ≡ zero ∨ (∃[ n' ] n ≡ succ n' ∧ A n')) → -- Conat is greater than A. ∀ {n} → A n → Conat n -- See Issue #81. A : D → Set A n = n ≡ zero ∨ (∃[ n' ] n ≡ succ n' ∧ Conat n') {-# ATP definition A #-} Conat-in : ∀ {n} → n ≡ zero ∨ (∃[ n' ] n ≡ succ n' ∧ Conat n') → Conat n Conat-in h = Conat-coind A h' h where postulate h' : ∀ {n} → A n → n ≡ zero ∨ (∃[ n' ] n ≡ succ n' ∧ A n') {-# ATP prove h' #-}
{ "alphanum_fraction": 0.4625098658, "avg_line_length": 21.1166666667, "ext": "agda", "hexsha": "17b82cac96d153aa452bd030caba0d3afbf7a868", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z", "max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/apia", "max_forks_repo_path": "test/Succeed/fol-theorems/Issue15.agda", "max_issues_count": 121, "max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/apia", "max_issues_repo_path": "test/Succeed/fol-theorems/Issue15.agda", "max_line_length": 75, "max_stars_count": 10, "max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/apia", "max_stars_repo_path": "test/Succeed/fol-theorems/Issue15.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z", "num_tokens": 528, "size": 1267 }
module Category.Comma where open import Level open import Data.Product open import Category.Core open import Relation.Binary as B using () open import Relation.Binary.Indexed open import Relation.Binary.Indexed.Extra open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; refl) _/_ : ∀ {𝒸 ℓ} → (C : Category 𝒸 ℓ) → (b : Category.Object C) → Category 𝒸 ℓ _/_ {𝒸} {ℓ} C b = record { Objects = SliceObjectSetoid ; Morphisms = SliceMorphismStructure } where open Category C module ObjEq = B.IsEquivalence (B.Setoid.isEquivalence Objects) module MorphEq = IsEquivalence (MorphismStructure.isEquivalence Morphisms) SliceObject-≈ : B.Rel hom[-, b ] ℓ SliceObject-≈ (x , x→b) (y , y→b) = Σ[ x≈y ∈ x ≈o y ] x→b ≈ y→b SliceObject-≈-Symmetric : B.Symmetric SliceObject-≈ SliceObject-≈-Symmetric (≈src , f≈g) = (ObjEq.sym ≈src) , MorphEq.sym f≈g SliceObject-≈-Transitive : B.Transitive SliceObject-≈ SliceObject-≈-Transitive (≈src₁ , f≈g) (≈src₂ , g≈h) = (ObjEq.trans ≈src₁ ≈src₂) , (MorphEq.trans f≈g g≈h) SliceObject-≈-IsEquivalence : B.IsEquivalence SliceObject-≈ SliceObject-≈-IsEquivalence = record { refl = ObjEq.refl , MorphEq.refl ; sym = SliceObject-≈-Symmetric ; trans = SliceObject-≈-Transitive } SliceObjectSetoid : B.Setoid 𝒸 ℓ SliceObjectSetoid = record { Carrier = hom[-, b ] ; _≈_ = SliceObject-≈ ; isEquivalence = SliceObject-≈-IsEquivalence } record SliceMorphism (src tar : hom[-, b ]) : Set 𝒸 where source : Object source = proj₁ src target : Object target = proj₁ tar field morphism : source ⇒ target SliceMorphism-≈ : Rel (uncurry SliceMorphism) ℓ SliceMorphism-≈ {f-src , f-tar} {g-src , g-tar} f g = Σ[ source-≈ ∈ SliceObject-≈ f-src g-src ] Σ[ target-≈ ∈ SliceObject-≈ f-tar g-tar ] morphism f ≈ morphism g where open SliceMorphism module SliceObjectEq = B.IsEquivalence SliceObject-≈-IsEquivalence SliceMorphism-≈-Symmetric : Symmetric (uncurry SliceMorphism) SliceMorphism-≈ -- Symmetric SliceMorphism-≈ ? SliceMorphism-≈-Symmetric (≈src₁ , ≈src₂ , f≈g) = SliceObjectEq.sym ≈src₁ , SliceObjectEq.sym ≈src₂ , MorphEq.sym f≈g SliceMorphism-≈-Transitive : Transitive (uncurry SliceMorphism) SliceMorphism-≈ -- Symmetric SliceMorphism-≈ ? SliceMorphism-≈-Transitive (≈src₁ , ≈src₂ , f≈g) (≈src₃ , ≈src₄ , g≈h) = SliceObjectEq.trans ≈src₁ ≈src₃ , SliceObjectEq.trans ≈src₂ ≈src₄ , MorphEq.trans f≈g g≈h SliceMorphism-≈-IsEquivalence : IsEquivalence (uncurry SliceMorphism) SliceMorphism-≈ SliceMorphism-≈-IsEquivalence = record { refl = SliceObjectEq.refl , SliceObjectEq.refl , MorphEq.refl ; sym = λ {i} {j} {f} {g} → SliceMorphism-≈-Symmetric {i} {j} {f} {g} ; trans = λ {i} {j} {k} {f} {g} {h} → SliceMorphism-≈-Transitive {i} {j} {k} {f} {g} {h} -- } Slice-∘ : ∀ {a b c} → SliceMorphism b c → SliceMorphism a b → SliceMorphism a c Slice-∘ f g = record { morphism = morphism f ∘ morphism g } where open SliceMorphism Slice-id : ∀ a → SliceMorphism a a Slice-id (a , _) = record { morphism = id a } SliceMorphismIsMorphism : IsMorphism SliceMorphism-≈ Slice-∘ Slice-id SliceMorphismIsMorphism = record { assoc = λ f g h → SliceObjectEq.refl , SliceObjectEq.refl , assoc (morphism f) (morphism g) (morphism h) ; left-identity = λ f → SliceObjectEq.refl , SliceObjectEq.refl , left-identity (morphism f) ; right-identity = λ f → SliceObjectEq.refl , SliceObjectEq.refl , right-identity (morphism f) ; cong = λ {x} {y} {u} {v} x≈y u≈v → proj₁ u≈v , proj₁ (proj₂ x≈y) , cong (proj₂ (proj₂ x≈y)) (proj₂ (proj₂ u≈v)) } where open IsMorphism isMorphism open SliceMorphism open import Relation.Binary.Indexed.SetoidReasoning SliceMorphismStructure : MorphismStructure 𝒸 ℓ hom[-, b ] SliceMorphismStructure = record { Carrier = uncurry SliceMorphism ; _≈_ = SliceMorphism-≈ ; isEquivalence = SliceMorphism-≈-IsEquivalence ; _∘_ = Slice-∘ ; id = Slice-id ; isMorphism = SliceMorphismIsMorphism } module Comma {𝒸₀ ℓ₀ 𝒸₁ ℓ₁ 𝒸₂ ℓ₂ : Level} {C : Category 𝒸₀ ℓ₀} {D : Category 𝒸₁ ℓ₁} {E : Category 𝒸₂ ℓ₂} (S : Functor C E) (T : Functor D E) where module C = Category C module D = Category D module S = Functor S module T = Functor T open Category E module ObjEq = B.IsEquivalence (B.Setoid.isEquivalence Objects) module MorphEq = IsEquivalence (MorphismStructure.isEquivalence Morphisms) record CommaObject : Set (𝒸₀ ⊔ 𝒸₁ ⊔ 𝒸₂ ⊔ ℓ₂) where field source : C.Object target : D.Object morphism : S.mapObject source ⇒ T.mapObject target open CommaObject CommaObject-≈ : B.Rel CommaObject ℓ₂ CommaObject-≈ f g = Σ[ source-≈ ∈ S.mapObject (source f) ≈o S.mapObject (source g) ] Σ[ target-≈ ∈ T.mapObject (target f) ≈o T.mapObject (target g) ] morphism f ≈ morphism g CommaObject-≈-Symmetric : B.Symmetric CommaObject-≈ CommaObject-≈-Symmetric (source-≈ , target-≈ , f≈g) = (ObjEq.sym source-≈) , (ObjEq.sym target-≈) , (MorphEq.sym f≈g) CommaObject-≈-Transitive : B.Transitive CommaObject-≈ CommaObject-≈-Transitive (source-≈₁ , target-≈₁ , f≈g) (source-≈₂ , target-≈₂ , g≈h) = (ObjEq.trans source-≈₁ source-≈₂) , (ObjEq.trans target-≈₁ target-≈₂) , (MorphEq.trans f≈g g≈h) CommaObject-≈-IsEquivalence : B.IsEquivalence CommaObject-≈ CommaObject-≈-IsEquivalence = record { refl = ObjEq.refl , ObjEq.refl , MorphEq.refl ; sym = λ {i} {f} → CommaObject-≈-Symmetric {i} {f} ; trans = λ {f} {g} {h} → CommaObject-≈-Transitive {f} {g} {h} } CommaObjects : B.Setoid (𝒸₀ ⊔ 𝒸₁ ⊔ 𝒸₂ ⊔ ℓ₂) ℓ₂ CommaObjects = record { Carrier = CommaObject ; _≈_ = CommaObject-≈ ; isEquivalence = CommaObject-≈-IsEquivalence } record CommaMorphism (src : CommaObject) (tar : CommaObject) : Set (𝒸₀ ⊔ 𝒸₁ ⊔ 𝒸₂ ⊔ ℓ₂) where module SRC = CommaObject src module TAR = CommaObject tar field morphismBetweenSources : S.mapObject SRC.source ⇒ S.mapObject TAR.source morphismBetweenTargets : T.mapObject SRC.target ⇒ T.mapObject TAR.target commutes : TAR.morphism ∘ morphismBetweenSources ≈ morphismBetweenTargets ∘ SRC.morphism open CommaMorphism public CommaMorphism-≈ : Rel (uncurry CommaMorphism) ℓ₂ CommaMorphism-≈ f g = (morphismBetweenSources f ≈ morphismBetweenSources g) × (morphismBetweenTargets f ≈ morphismBetweenTargets g) CommaMorphism-≈-Symmetric : Symmetric (uncurry CommaMorphism) CommaMorphism-≈ CommaMorphism-≈-Symmetric (source-≈ , target-≈) = (MorphEq.sym source-≈) , (MorphEq.sym target-≈) CommaMorphism-≈-Transitive : Transitive (uncurry CommaMorphism) CommaMorphism-≈ CommaMorphism-≈-Transitive (source₁-≈ , target₁-≈) (source₂-≈ , target₂-≈) = (MorphEq.trans source₁-≈ source₂-≈) , (MorphEq.trans target₁-≈ target₂-≈) CommaMorphism-≈-IsEquivalence : IsEquivalence (uncurry CommaMorphism) CommaMorphism-≈ CommaMorphism-≈-IsEquivalence = record { refl = MorphEq.refl , MorphEq.refl ; sym = λ {i} {j} {f} {g} → CommaMorphism-≈-Symmetric {i} {j} {f} {g} ; trans = λ {i} {j} {k} {f} {g} {h} → CommaMorphism-≈-Transitive {i} {j} {k} {f} {g} {h} } Comma-∘ : ∀ {a b c} → CommaMorphism b c → CommaMorphism a b → CommaMorphism a c Comma-∘ {a} {b} {c} f g = record { morphismBetweenSources = morphismBetweenSources f ∘ morphismBetweenSources g ; morphismBetweenTargets = morphismBetweenTargets f ∘ morphismBetweenTargets g ; commutes = begin⟨ setoid ⟩ morphism c ∘ (morphismBetweenSources f ∘ morphismBetweenSources g) ≈⟨ sym (assoc (morphismBetweenSources g) (morphismBetweenSources f) (morphism c)) ⟩ (morphism c ∘ morphismBetweenSources f) ∘ morphismBetweenSources g ≈⟨ cong (commutes f) MorphEq.refl ⟩ (morphismBetweenTargets f ∘ morphism b) ∘ morphismBetweenSources g ≈⟨ assoc (morphismBetweenSources g) (morphism b) (morphismBetweenTargets f) ⟩ morphismBetweenTargets f ∘ (morphism b ∘ morphismBetweenSources g) ≈⟨ cong MorphEq.refl (commutes g) ⟩ morphismBetweenTargets f ∘ (morphismBetweenTargets g ∘ morphism a) ≈⟨ sym (assoc (morphism a) (morphismBetweenTargets g) (morphismBetweenTargets f)) ⟩ (morphismBetweenTargets f ∘ morphismBetweenTargets g) ∘ morphism a ∎ } where open CommaMorphism open import Relation.Binary.Indexed.SetoidReasoning open IsMorphism isMorphism open IsEquivalence (MorphismStructure.isEquivalence Morphisms) Comma-id : ∀ a → CommaMorphism a a Comma-id a = record { morphismBetweenSources = id (S.mapObject (source a)) ; morphismBetweenTargets = id (T.mapObject (target a)) ; commutes = begin⟨ setoid ⟩ morphism a ∘ id (S.mapObject (source a)) ≈⟨ right-identity (morphism a) ⟩ morphism a ≈⟨ sym (left-identity (morphism a)) ⟩ id (T.mapObject (target a)) ∘ morphism a ∎ } where open IsMorphism isMorphism open import Relation.Binary.Indexed.SetoidReasoning open IsEquivalence (MorphismStructure.isEquivalence Morphisms) CommaMorphismIsMorphism : IsMorphism CommaMorphism-≈ Comma-∘ Comma-id CommaMorphismIsMorphism = record { assoc = λ f g h → assoc (morphismBetweenSources f) (morphismBetweenSources g) (morphismBetweenSources h) , assoc (morphismBetweenTargets f) (morphismBetweenTargets g) (morphismBetweenTargets h) ; left-identity = λ f → (left-identity (morphismBetweenSources f)) , (left-identity (morphismBetweenTargets f)) ; right-identity = λ f → (right-identity (morphismBetweenSources f)) , (right-identity (morphismBetweenTargets f)) ; cong = λ x≈y u≈v → (cong (proj₁ x≈y) (proj₁ u≈v)) , (cong (proj₂ x≈y) (proj₂ u≈v)) } where open IsMorphism isMorphism CommaMorphisms : MorphismStructure (𝒸₀ ⊔ 𝒸₁ ⊔ 𝒸₂ ⊔ ℓ₂) ℓ₂ CommaObject CommaMorphisms = record { Carrier = uncurry CommaMorphism ; _≈_ = CommaMorphism-≈ ; isEquivalence = CommaMorphism-≈-IsEquivalence ; _∘_ = Comma-∘ ; id = Comma-id ; isMorphism = CommaMorphismIsMorphism } -- S T -- C --> E <-- D -- _↓_ : {𝒸₀ ℓ₀ 𝒸₁ ℓ₁ 𝒸₂ ℓ₂ : Level} {C : Category 𝒸₀ ℓ₀} {D : Category 𝒸₁ ℓ₁} {E : Category 𝒸₂ ℓ₂} → (S : Functor C E) → (T : Functor D E) → Category (𝒸₀ ⊔ 𝒸₁ ⊔ 𝒸₂ ⊔ ℓ₂) ℓ₂ S ↓ T = record { Objects = Comma'.CommaObjects ; Morphisms = Comma'.CommaMorphisms } where module Comma' = Comma S T
{ "alphanum_fraction": 0.6021772673, "avg_line_length": 41.964028777, "ext": "agda", "hexsha": "6ebd03b637f27e8728ccd7a114d7aa5ecd64cdd9", "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": "9f6d933b227aecab338ecaef1d86566a54fdac68", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/categories", "max_forks_repo_path": "src/Category/Comma.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9f6d933b227aecab338ecaef1d86566a54fdac68", "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/categories", "max_issues_repo_path": "src/Category/Comma.agda", "max_line_length": 125, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9f6d933b227aecab338ecaef1d86566a54fdac68", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/categories", "max_stars_repo_path": "src/Category/Comma.agda", "max_stars_repo_stars_event_max_datetime": "2018-01-04T23:19:30.000Z", "max_stars_repo_stars_event_min_datetime": "2018-01-04T23:19:30.000Z", "num_tokens": 3865, "size": 11666 }
{-# OPTIONS --cubical --no-import-sorts #-} module Utils where -- thing that currently do not belong anywhere and do not have many dependencies open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero) private variable ℓ ℓ' ℓ'' : Level open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Relation.Nullary.Base -- ¬_ open import Cubical.Relation.Binary.Base open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_) open import Cubical.Data.Sigma.Base renaming (_×_ to infixr 4 _×_) open import Cubical.Data.Empty renaming (elim to ⊥-elim) -- `⊥` and `elim` ⊎-swap : ∀{x : Type ℓ} {y : Type ℓ'} → x ⊎ y → y ⊎ x ⊎-swap (inl x) = inr x ⊎-swap (inr x) = inl x swap : ∀{x : Type ℓ} {y : Type ℓ'} → x × y → y × x swap (x , y) = (y , x) curry : ∀{ℓ ℓ' ℓ''} {A : Type ℓ} {B : A → Type ℓ'} {C : (a : A) → (b : B a) → Type ℓ''} → ((p : Σ A B) → C (fst p) (snd p)) → ((x : A) → (y : B x) → C x y) curry f x y = f (x , y) -- NOTE: this is non-hProp logic -- contraposition : {P : Type ℓ} {Q : Type ℓ'} → (P → Q) → ¬ Q → ¬ P -- contraposition f ¬q p = ⊥-elim (¬q (f p)) deMorgan₂' : {P : Type ℓ} {Q : Type ℓ'} → ¬(P ⊎ Q) → (¬ P) × (¬ Q) deMorgan₂' {P = P} {Q = Q} ¬[p⊎q] = (λ p → ⊥-elim (¬[p⊎q] (inl p))) , λ q → ⊥-elim (¬[p⊎q] (inr q)) deMorgan₂-back' : {P : Type ℓ} {Q : Type ℓ'} → (¬ P) × (¬ Q) → ¬(P ⊎ Q) deMorgan₂-back' (¬p , ¬q) (inl p) = ¬p p deMorgan₂-back' (¬p , ¬q) (inr q) = ¬q q -- hPropRel : ∀ {ℓ} (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ')) -- hPropRel A B ℓ' = A → B → hProp ℓ' {- NOTE: there is also `Relation.Binary.PropositionalEquality` where they write: -- Inspect can be used when you want to pattern match on the result r -- of some expression e, and you also need to "remember" that r ≡ e. -- See README.Inspect for an explanation of how/why to use this. record Reveal_·_is_ {A : Set a} {B : A → Set b} (f : (x : A) → B x) (x : A) (y : B x) : Set (a ⊔ b) where constructor [_] field eq : f x ≡ y inspect : ∀ {A : Set a} {B : A → Set b} (f : (x : A) → B x) (x : A) → Reveal f · x is f x inspect f x = [ refl ] -} {- NOTE: an example is plus-eq-with : ∀ m n → Plus-eq m n (m + n) plus-eq-with m n with m + n | inspect (m +_) n ... | zero | [ m+n≡0 ] = m+n≡0⇒m≡0 m m+n≡0 , m+n≡0⇒n≡0 m m+n≡0 ... | suc p | [ m+n≡1+p ] = m+n≡1+p -} -- so this looks like a mechanism for "@-pattern-disribution over `with` cases" record !_ {ℓ} (X : Type ℓ) : Type ℓ where inductive constructor !!_ -- map "into" `!!_ : X → ! X` field !!!_ : X -- map "out of" `!!!_ : ! X → X` infix 1 !!!_ open !_ public -- brings !!!_ into scope infix 1 !!_ infix 1 !_ !-iso : ∀{ℓ} {X : Type ℓ} → Iso (! X) X Iso.fun !-iso = !!!_ Iso.inv !-iso = !!_ Iso.rightInv !-iso = λ x → refl Iso.leftInv !-iso = λ{ (!! x) → refl } !-≡ : ∀{ℓ} {X : Type ℓ} → (! X) ≡ X !-≡ {X = X} = isoToPath !-iso !-equiv : ∀{ℓ} {X : Type ℓ} → (! X) ≃ X !-equiv = !!!_ , λ where .equiv-proof x → ((!! x) , refl) , λ{ ((!! y) , p) → λ i → (!! p (~ i)) , (λ j → p (~ i ∨ j)) } -- `A unfold refl to B` checks `A` and `B` to be definitionally equal (with `refl`) and then uses `B` -- this allows for a nicer Goal/Have at the very beginning of implementing and when using something unfold' : ∀{ℓ A} → (x y : A) → _≡_ {ℓ} x y → _ unfold' x y p = y infix -8 unfold' syntax unfold' x y p = x unfold p to y {-# DISPLAY unfold' x y p = p #-}
{ "alphanum_fraction": 0.5353276353, "avg_line_length": 34.4117647059, "ext": "agda", "hexsha": "04fac9552d42599d28b21558390cccad1403351d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "agda/Utils.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mchristianl/synthetic-reals", "max_issues_repo_path": "agda/Utils.agda", "max_line_length": 120, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "agda/Utils.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 1453, "size": 3510 }
{-# OPTIONS --allow-unsolved-metas #-} module _ where open import Agda.Builtin.Nat open import Agda.Builtin.List open import Agda.Builtin.Unit open import Agda.Builtin.Sigma _×_ : Set → Set → Set A × B = Σ A λ _ → B data Vec (A : Set) : Nat → Set where [] : Vec A 0 _∷_ : ∀ {n} → A → Vec A n → Vec A (suc n) data All {A : Set} (P : A → Set) : List A → Set where [] : All P [] _∷_ : ∀ {x xs} → P x → All P xs → All P (x ∷ xs) data Ty : Set where module Code where Schema : List Nat → Set Schema = All (λ k → Vec Ty k × Ty) data Binder : Set where bound unbound : Binder Shape : Nat → Set Shape n = List (Vec Binder n) data Code : Set₁ where sg : (A : Set) → (A → Code) → Code node : (n : Nat) (shape : Shape n) (wt : Vec Ty n → All (λ _ → Ty) shape → Ty → Set) → Code module Ctx where infixr 4 _,_ data Ctx : Set where ∅ : Ctx _,_ : Ctx → Ty → Ctx _<><_ : Ctx → List Ty → Ctx Γ <>< [] = Γ Γ <>< (t ∷ ts) = (Γ , t) <>< ts module Typed (code : Code.Code) where open Code open Ctx visible : ∀ {n} → Vec Binder n → Vec Ty n → List Ty visible [] [] = [] visible (bound ∷ bs) (t ∷ ts) = t ∷ visible bs ts visible (unbound ∷ bs) (_ ∷ ts) = visible bs ts mutual data Tm (Γ : Ctx) : Ty → Set where data Con (Γ : Ctx) (t : Ty) : Code → Set where sg : ∀ {A c} x → Con Γ t (c x) → Con Γ t (sg A c) node : ∀ {n shape wt} (ts₀ : Vec Ty n) {ts : All (λ _ → Ty) shape} (es : Children Γ ts₀ ts) → {{_ : wt ts₀ ts t}} → Con Γ t (node n shape wt) data Children (Γ : Ctx) {n : Nat} (ts₀ : Vec Ty n) : {sh : Shape n} → All (λ _ → Ty) sh → Set where [] : Children Γ ts₀ [] _∷_ : ∀ {bs sh t ts} → Tm (Γ <>< visible bs ts₀) t → Children Γ ts₀ {sh} ts → Children Γ ts₀ {bs ∷ sh} (t ∷ ts) module Sem₀ (P : Ctx → Ty → Set) where children : ∀ {n} (Γ : Ctx) (ts₀ : Vec Ty n) (shape : List (Vec Binder n)) (ts : All (λ _ → Ty) shape) → Set children Γ ts₀ [] [] = ⊤ children Γ ts₀ (bs ∷ bss) (t ∷ ts) = P (Γ <>< visible bs ts₀ ) t × children Γ ts₀ bss ts aux : Code → Set aux (sg A k) = (x : A) → aux (k x) aux (node n shape wt) = ∀ {Γ t} {ts₀ ts} → children Γ ts₀ shape ts → wt ts₀ ts t → P Γ t Sem : (P : Ctx → Ty → Set) → Set Sem P = Sem₀.aux P code open Code data Phase : Set where input : Phase data `STLC : Phase → Set where `let : `STLC input STLC : Phase → Code STLC p = sg (`STLC p) aux where aux : `STLC p → Code aux `let = node 1 ((bound ∷ []) ∷ []) λ { (t₀ ∷ _) (t₁ ∷ _) t → ⊤ } open Ctx open Typed (STLC input) using (Sem) ap : Sem λ Γ t → Nat ap = λ where `let → {!!}
{ "alphanum_fraction": 0.5271493213, "avg_line_length": 26.2574257426, "ext": "agda", "hexsha": "945e574caf43c6f4e75042d7cdca1d8b6feaffb4", "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/Issue2883.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/Issue2883.agda", "max_line_length": 117, "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/Issue2883.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": 1035, "size": 2652 }
postulate A : Set record R : Set where field a : A b : A b = a open R test : A test = b
{ "alphanum_fraction": 0.5294117647, "avg_line_length": 7.8461538462, "ext": "agda", "hexsha": "f068ff656d78817cd0ab5e2985d0ecd8a610dfb7", "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/Issue3566-2.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/Issue3566-2.agda", "max_line_length": 20, "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/Issue3566-2.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": 43, "size": 102 }
module IsFormula where open import Formula data IsFormula : Formula → Set where ⟨_⟩ : (φ : Formula) → IsFormula φ
{ "alphanum_fraction": 0.7, "avg_line_length": 13.3333333333, "ext": "agda", "hexsha": "c79a2641e82bcc87f26ecec553b3a629d36939fe", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-1/IsFormula.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-1/IsFormula.agda", "max_line_length": 35, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-1/IsFormula.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 35, "size": 120 }
module LC.Parallel where open import LC.Base open import LC.Subst open import LC.Reduction open import Data.Nat open import Relation.Binary.Construct.Closure.ReflexiveTransitive -- parallel β-reduction infix 3 _β⇒_ data _β⇒_ : Term → Term → Set where β-var : {n : ℕ} → var n β⇒ var n β-ƛ : ∀ {M M'} → (M⇒M' : M β⇒ M') → ƛ M β⇒ ƛ M' β-∙ : ∀ {M M' N N'} → (M⇒M' : M β⇒ M') → (N⇒N' : N β⇒ N') → M ∙ N β⇒ M' ∙ N' β-ƛ-∙ : ∀ {M M' N N'} → (M⇒M' : M β⇒ M') → (N⇒N' : N β⇒ N') → (ƛ M) ∙ N β⇒ M' [ N' ] -- properties β⇒identity : ∀ {M} → M β⇒ M β⇒identity {var x} = β-var β⇒identity {ƛ M} = β-ƛ β⇒identity β⇒identity {M ∙ N} = β-∙ β⇒identity β⇒identity to-parallel : ∀ {M N} → M β→ N → M β⇒ N to-parallel β-ƛ-∙ = β-ƛ-∙ β⇒identity β⇒identity to-parallel (β-ƛ M→N) = β-ƛ (to-parallel M→N) to-parallel (β-∙-l M→N) = β-∙ (to-parallel M→N) β⇒identity to-parallel (β-∙-r M→N) = β-∙ β⇒identity (to-parallel M→N) from-parallel : ∀ {M N} → M β⇒ N → M β→* N from-parallel β-var = ε from-parallel (β-ƛ M⇒N) = cong-ƛ (from-parallel M⇒N) from-parallel (β-∙ M⇒M' N⇒N') = cong-∙ (from-parallel M⇒M') (from-parallel N⇒N') from-parallel (β-ƛ-∙ M⇒M' N⇒N') = return β-ƛ-∙ ◅◅ cong-[] (from-parallel M⇒M') (from-parallel N⇒N') open import Relation.Binary.PropositionalEquality hiding ([_]; preorder) ≡⇒β⇒ : ∀ {M N} → M ≡ N → M β⇒ N ≡⇒β⇒ refl = β⇒identity module Cong where open import LC.Subst.Term open import LC.Subst.Var β⇒cong-lift-ƛ : ∀ {n i M M' N N'} → M β⇒ M' → N β⇒ N' → (ƛ lift (suc n) i M) ∙ lift n i N β⇒ lift n i (M' [ N' ]) β⇒cong-lift-ƛ β-var N→N' = {! !} β⇒cong-lift-ƛ (β-ƛ M→M') N→N' = {! !} β⇒cong-lift-ƛ (β-∙ M→M' M→M'') N→N' = {! !} β⇒cong-lift-ƛ (β-ƛ-∙ M→M' M→M'') N→N' = {! !} β⇒cong-lift : ∀ {n i M N} → M β⇒ N → lift n i M β⇒ lift n i N β⇒cong-lift β-var = β-var β⇒cong-lift (β-ƛ M→N) = β-ƛ (β⇒cong-lift M→N) β⇒cong-lift (β-∙ M→M' N→N') = β-∙ (β⇒cong-lift M→M') (β⇒cong-lift N→N') β⇒cong-lift (β-ƛ-∙ M→M' N→N') = β⇒cong-lift-ƛ M→M' N→N' β⇒cong-subst-var-match : ∀ {n i M N} → M β⇒ N → subst-var (match n i) M β⇒ subst-var (match n i) N β⇒cong-subst-var-match {n} {i} M→N with match n i ... | Under n<i = β-var ... | Exact n≡i = β⇒cong-lift M→N ... | Above v v≥i = β-var open import Relation.Binary.PropositionalEquality hiding ([_]; preorder) module Temp where lemma-1 : ∀ i m n o → (ƛ subst-var (match m (suc i)) (var n)) ∙ subst-var (match o i) (var n) ≡ (var m) [ var o ] [ var n / i ] lemma-1 i m n o with match m (suc i) ... | Under m<i+1 = {! !} ... | Exact m≡i+1 = {! !} ... | Above v v≥i+1 = {! !} lemma-1-1 : ∀ i m n → subst-var (match m (suc i)) (var n) β⇒ {! !} lemma-1-1 i m n = {! !} β⇒cong-[]-ƛ-∙ : ∀ {i M M' N N' O O'} → M β⇒ M' → N β⇒ N' → O β⇒ O' → (ƛ M [ O / suc i ]) ∙ N [ O / i ] β⇒ (M' [ N' ]) [ O' / i ] β⇒cong-[]-ƛ-∙ {zero} (β-var {n}) (β-var {m}) (β-var {o}) = {! !} β⇒cong-[]-ƛ-∙ {suc i} (β-var {n}) (β-var {m}) (β-var {o}) = {! !} β⇒cong-[]-ƛ-∙ β-var β-var (β-ƛ O→O') = {! !} β⇒cong-[]-ƛ-∙ β-var β-var (β-∙ O→O' O→O'') = {! !} β⇒cong-[]-ƛ-∙ β-var β-var (β-ƛ-∙ O→O' O→O'') = {! !} β⇒cong-[]-ƛ-∙ β-var (β-ƛ N→N') β-var = {! !} β⇒cong-[]-ƛ-∙ β-var (β-ƛ N→N') (β-ƛ O→O') = {! !} β⇒cong-[]-ƛ-∙ β-var (β-ƛ N→N') (β-∙ O→O' O→O'') = {! !} β⇒cong-[]-ƛ-∙ β-var (β-ƛ N→N') (β-ƛ-∙ O→O' O→O'') = {! !} β⇒cong-[]-ƛ-∙ β-var (β-∙ N→N' N→N'') β-var = {! !} β⇒cong-[]-ƛ-∙ β-var (β-∙ N→N' N→N'') (β-ƛ O→O') = {! !} β⇒cong-[]-ƛ-∙ β-var (β-∙ N→N' N→N'') (β-∙ O→O' O→O'') = {! !} β⇒cong-[]-ƛ-∙ β-var (β-∙ N→N' N→N'') (β-ƛ-∙ O→O' O→O'') = {! !} β⇒cong-[]-ƛ-∙ β-var (β-ƛ-∙ N→N' N→N'') β-var = {! !} β⇒cong-[]-ƛ-∙ β-var (β-ƛ-∙ N→N' N→N'') (β-ƛ O→O') = {! !} β⇒cong-[]-ƛ-∙ β-var (β-ƛ-∙ N→N' N→N'') (β-∙ O→O' O→O'') = {! !} β⇒cong-[]-ƛ-∙ β-var (β-ƛ-∙ N→N' N→N'') (β-ƛ-∙ O→O' O→O'') = {! !} β⇒cong-[]-ƛ-∙ (β-ƛ M→M') N→N' O→O' = {! !} β⇒cong-[]-ƛ-∙ (β-∙ M→M' M→M'') N→N' O→O' = {! !} β⇒cong-[]-ƛ-∙ (β-ƛ-∙ M→M' M→M'') N→N' O→O' = {! !} β⇒cong-[] : ∀ {i M M' N N'} → M β⇒ M' → N β⇒ N' → M [ N / i ] β⇒ M' [ N' / i ] β⇒cong-[] {i} (β-var {n}) N→N' = β⇒cong-subst-var-match {n} {i} N→N' β⇒cong-[] (β-ƛ M→M') N→N' = β-ƛ (β⇒cong-[] M→M' N→N') β⇒cong-[] (β-∙ M→M' M→M'') N→N' = β-∙ (β⇒cong-[] M→M' N→N') (β⇒cong-[] M→M'' N→N') β⇒cong-[] (β-ƛ-∙ M→M' M→M'') N→N' = {! !} -- β⇒cong-[]-ƛ-∙ M→M' M→M'' N→N' -- β-∙ {! !} {! !} -- (ƛ M [ N₁ / suc i ]) ∙ N [ N₁ / i ] β⇒ M' [ N' ] [ N'' / i ] -- ((ƛ M) ∙ N) → M' [ N' ] -- ((ƛ M) ∙ N) [ N₁ / i ] β⇒ M' [ N' ] [ N'' / i ] -- M→M' N→N' !} (β⇒cong-[] M→M'' N→N') -- β⇒cong-[] {i} {var x} {.(var x)} {var y} {.(var y)} β-var β-var with match x i -- ... | Under x<i = β-var -- ... | Exact x≡i = β-var -- ... | Above v v≥i = β-var -- β⇒cong-[] {i} {var x} {.(var x)} {ƛ N} {.(ƛ _)} β-var (β-ƛ N→N') with match x i -- ... | Under x<i = β-var -- ... | Exact x≡i = β-ƛ (β⇒cong-lift N→N') -- ... | Above v v≥i = β-var -- β⇒cong-[] {i} {var x} {.(var x)} {N ∙ O} {N'} β-var N→N' with match x i -- ... | Under x<i = β-var -- ... | Exact x≡i = {! !} -- ... | Above v v≥i = β-var -- β⇒cong-[] {i} {ƛ M} {M'} {N} {N'} M→M' N→N' = {! !} -- β⇒cong-[] {i} {M ∙ K} {M'} {N} {N'} M→M' N→N' = {! !} β⇒cong-[] : ∀ {M M' N N'} → M β⇒ M' → N β⇒ N' → M [ N ] β⇒ M' [ N' ] β⇒cong-[] = Cong.β⇒cong-[]
{ "alphanum_fraction": 0.4322878229, "avg_line_length": 39.8529411765, "ext": "agda", "hexsha": "85a5c1ca43c0c411d67b949faa9c974fc68ccb20", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/bidirectional", "max_forks_repo_path": "LC/Parallel.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "banacorn/bidirectional", "max_issues_repo_path": "LC/Parallel.agda", "max_line_length": 131, "max_stars_count": 2, "max_stars_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/bidirectional", "max_stars_repo_path": "LC/Parallel.agda", "max_stars_repo_stars_event_max_datetime": "2020-08-25T14:05:01.000Z", "max_stars_repo_stars_event_min_datetime": "2020-08-25T07:34:40.000Z", "num_tokens": 3194, "size": 5420 }
------------------------------------------------------------------------------ -- Conversion functions i, j and k. ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.IJK where open import FOTC.Base open import FOTC.Data.Nat.Type ------------------------------------------------------------------------------ data ℕ : Set where z : ℕ s : ℕ → ℕ -- Conversion functions from/to ℕ and N. i : ℕ → D i z = zero i (s n) = succ₁ (i n) j : (n : ℕ) → N (i n) j z = nzero j (s n) = nsucc (j n) k : {n : D} → N n → ℕ k nzero = z k (nsucc Nn) = s (k Nn) _+_ : ℕ → ℕ → ℕ z + n = n s m + n = s (m + n)
{ "alphanum_fraction": 0.3586040915, "avg_line_length": 22.4594594595, "ext": "agda", "hexsha": "a236e49035f2c0b2adbc159511b989ee167c106d", "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/IJK.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/IJK.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/IJK.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": 218, "size": 831 }