Search is not available for this dataset
text
string | meta
dict |
---|---|
-- Andreas, 2014-04-12, Order of declaration mattered in the presence
-- of meta variables involving sizes
-- {-# OPTIONS -v tc.meta:10 -v tc.meta.assign:10 #-}
-- Error persists without option sized-types
{-# OPTIONS --sized-types #-}
module _ where
open import Common.Size
-- different error if we do not use the built-ins (Size vs Size<)
module Works where
mutual
data Colist' i : Set where
inn : (xs : Colist i) → Colist' i
record Colist i : Set where
coinductive
field out : ∀ {j : Size< i} → Colist' j
module Fails where
mutual
record Colist i : Set where
coinductive
field out : ∀ {j : Size< i} → Colist' j
data Colist' i : Set where
inn : (xs : Colist i) → Colist' i
-- Error: Issue1087.agda:21,45-46
-- Cannot instantiate the metavariable _20 to solution (Size< i) since
-- it contains the variable i which is not in scope of the
-- metavariable or irrelevant in the metavariable but relevant in the
-- solution
-- when checking that the expression j has type _20
-- Works now.
|
{
"alphanum_fraction": 0.6710900474,
"avg_line_length": 26.375,
"ext": "agda",
"hexsha": "dcd62faa00e1629a8b45c893a4f9a177455bafb0",
"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/Issue1087.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/Issue1087.agda",
"max_line_length": 70,
"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/Issue1087.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": 297,
"size": 1055
}
|
module Luau.OpSem where
open import Agda.Builtin.Equality using (_≡_)
open import FFI.Data.Maybe using (just)
open import Luau.Heap using (Heap; _≡_⊕_↦_; lookup; function_⟨_⟩_end)
open import Luau.Substitution using (_[_/_]ᴮ)
open import Luau.Syntax using (Expr; Stat; Block; nil; addr; var; function⟨_⟩_end; _$_; block_is_end; local_←_; _∙_; done; function_⟨_⟩_end; return)
open import Luau.Value using (addr; val)
data _⊢_⟶ᴮ_⊣_ : Heap → Block → Block → Heap → Set
data _⊢_⟶ᴱ_⊣_ : Heap → Expr → Expr → Heap → Set
data _⊢_⟶ᴱ_⊣_ where
nil : ∀ {H} →
-------------------
H ⊢ nil ⟶ᴱ nil ⊣ H
function : ∀ {H H′ a x B} →
H′ ≡ H ⊕ a ↦ (function "anon" ⟨ x ⟩ B end) →
-------------------------------------------
H ⊢ (function⟨ x ⟩ B end) ⟶ᴱ (addr a) ⊣ H′
app : ∀ {H H′ M M′ N} →
H ⊢ M ⟶ᴱ M′ ⊣ H′ →
-----------------------------
H ⊢ (M $ N) ⟶ᴱ (M′ $ N) ⊣ H′
beta : ∀ {H M a f x B} →
(lookup H a) ≡ just(function f ⟨ x ⟩ B end) →
-----------------------------------------------------
H ⊢ (addr a $ M) ⟶ᴱ (block f is local x ← M ∙ B end) ⊣ H
block : ∀ {H H′ B B′ b} →
H ⊢ B ⟶ᴮ B′ ⊣ H′ →
----------------------------------------------------
H ⊢ (block b is B end) ⟶ᴱ (block b is B′ end) ⊣ H′
return : ∀ {H V B b} →
--------------------------------------------------------
H ⊢ (block b is return (val V) ∙ B end) ⟶ᴱ (val V) ⊣ H
done : ∀ {H b} →
---------------------------------
H ⊢ (block b is done end) ⟶ᴱ nil ⊣ H
data _⊢_⟶ᴮ_⊣_ where
local : ∀ {H H′ x M M′ B} →
H ⊢ M ⟶ᴱ M′ ⊣ H′ →
-------------------------------------------------
H ⊢ (local x ← M ∙ B) ⟶ᴮ (local x ← M′ ∙ B) ⊣ H′
subst : ∀ {H x v B} →
-------------------------------------------------
H ⊢ (local x ← val v ∙ B) ⟶ᴮ (B [ v / x ]ᴮ) ⊣ H
function : ∀ {H H′ a f x B C} →
H′ ≡ H ⊕ a ↦ (function f ⟨ x ⟩ C end) →
--------------------------------------------------------------
H ⊢ (function f ⟨ x ⟩ C end ∙ B) ⟶ᴮ (B [ addr a / f ]ᴮ) ⊣ H′
return : ∀ {H H′ M M′ B} →
H ⊢ M ⟶ᴱ M′ ⊣ H′ →
--------------------------------------------
H ⊢ (return M ∙ B) ⟶ᴮ (return M′ ∙ B) ⊣ H′
data _⊢_⟶*_⊣_ : Heap → Block → Block → Heap → Set where
refl : ∀ {H B} →
----------------
H ⊢ B ⟶* B ⊣ H
step : ∀ {H H′ H″ B B′ B″} →
H ⊢ B ⟶ᴮ B′ ⊣ H′ →
H′ ⊢ B′ ⟶* B″ ⊣ H″ →
------------------
H ⊢ B ⟶* B″ ⊣ H″
|
{
"alphanum_fraction": 0.3587755102,
"avg_line_length": 26.3440860215,
"ext": "agda",
"hexsha": "dcd474bf834f389f776539f848f3a78ff5a73950",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "FreakingBarbarians/luau",
"max_forks_repo_path": "prototyping/Luau/OpSem.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "FreakingBarbarians/luau",
"max_issues_repo_path": "prototyping/Luau/OpSem.agda",
"max_line_length": 148,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "FreakingBarbarians/luau",
"max_stars_repo_path": "prototyping/Luau/OpSem.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-11T21:30:17.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-02-11T21:30:17.000Z",
"num_tokens": 1001,
"size": 2450
}
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Groups.Definition
open import Numbers.Naturals.Definition
open import Numbers.Naturals.Order
open import Setoids.Setoids
open import Sets.EquivalenceRelations
open import Rings.Definition
open import Rings.IntegralDomains.Definition
open import Orders.Total.Definition
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
module Rings.EuclideanDomains.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) where
open import Rings.Divisible.Definition R
open Setoid S
open Equivalence eq
open Ring R
open Group additiveGroup
record DivisionAlgorithmResult (norm : {a : A} → ((a ∼ 0R) → False) → ℕ) {x y : A} (x!=0 : (x ∼ 0R) → False) (y!=0 : (y ∼ 0R) → False) : Set (a ⊔ b) where
field
quotient : A
rem : A
remSmall : (rem ∼ 0R) || Sg ((rem ∼ 0R) → False) (λ rem!=0 → (norm rem!=0) <N (norm y!=0))
divAlg : x ∼ ((quotient * y) + rem)
record DivisionAlgorithmResult' (norm : (a : A) → ℕ) (x y : A) : Set (a ⊔ b) where
field
quotient : A
rem : A
remSmall : (rem ∼ 0R) || ((norm rem) <N (norm y))
divAlg : x ∼ ((quotient * y) + rem)
record EuclideanDomain : Set (a ⊔ lsuc b) where
field
isIntegralDomain : IntegralDomain R
norm : {a : A} → ((a ∼ 0R) → False) → ℕ
normSize : {a b : A} → (a!=0 : (a ∼ 0R) → False) → (b!=0 : (b ∼ 0R) → False) → (c : A) → b ∼ (a * c) → (norm a!=0) ≤N (norm b!=0)
divisionAlg : {a b : A} → (a!=0 : (a ∼ 0R) → False) → (b!=0 : (b ∼ 0R) → False) → DivisionAlgorithmResult norm a!=0 b!=0
normWellDefined : {a : A} → (p1 p2 : (a ∼ 0R) → False) → norm p1 ≡ norm p2
normWellDefined {a} p1 p2 with normSize p1 p2 1R (symmetric (transitive *Commutative identIsIdent))
normWellDefined {a} p1 p2 | inl n1<n2 with normSize p2 p1 1R (symmetric (transitive *Commutative identIsIdent))
normWellDefined {a} p1 p2 | inl n1<n2 | inl n2<n1 = exFalso (TotalOrder.irreflexive ℕTotalOrder (TotalOrder.<Transitive ℕTotalOrder n1<n2 n2<n1))
normWellDefined {a} p1 p2 | inl n1<n2 | inr n2=n1 = equalityCommutative n2=n1
normWellDefined {a} p1 p2 | inr n1=n2 = n1=n2
normWellDefined' : {a b : A} → (a ∼ b) → (a!=0 : (a ∼ 0R) → False) → (b!=0 : (b ∼ 0R) → False) → norm a!=0 ≡ norm b!=0
normWellDefined' a=b a!=0 b!=0 with normSize a!=0 b!=0 1R (symmetric (transitive *Commutative (transitive identIsIdent a=b)))
normWellDefined' a=b a!=0 b!=0 | inl a<b with normSize b!=0 a!=0 1R (symmetric (transitive *Commutative (transitive identIsIdent (symmetric a=b))))
normWellDefined' a=b a!=0 b!=0 | inl a<b | inl b<a = exFalso (TotalOrder.irreflexive ℕTotalOrder (TotalOrder.<Transitive ℕTotalOrder a<b b<a))
normWellDefined' a=b a!=0 b!=0 | inl a<b | inr n= = equalityCommutative n=
normWellDefined' a=b a!=0 b!=0 | inr n= = n=
record EuclideanDomain' : Set (a ⊔ lsuc b) where
field
isIntegralDomain : IntegralDomain R
norm : A → ℕ
normWellDefined : {a b : A} → (a ∼ b) → norm a ≡ norm b
normSize : (a b : A) → (a ∣ b) → ((b ∼ 0R) → False) → norm a ≤N (norm b)
divisionAlg : (a b : A) → ((b ∼ 0R) → False) → DivisionAlgorithmResult' norm a b
normEquiv : (e : EuclideanDomain) (decidableZero : (a : A) → (a ∼ 0R) || ((a ∼ 0R) → False)) → A → ℕ
normEquiv e decidableZero a with decidableZero a
... | inl a=0 = 0
... | inr a!=0 = EuclideanDomain.norm e a!=0
normSizeEquiv : (e : EuclideanDomain) (decidableZero : (a : A) → (a ∼ 0R) || ((a ∼ 0R) → False)) (a b : A) → (a ∣ b) → ((b ∼ 0R) → False) → normEquiv e decidableZero a ≤N normEquiv e decidableZero b
normSizeEquiv e decidableZero a b (c , ac=b) b!=0 = ans
where
abstract
a!=0 : (a ∼ 0R) → False
a!=0 a=0 = b!=0 (transitive (symmetric ac=b) (transitive (*WellDefined a=0 reflexive) (transitive *Commutative timesZero)))
normIs : normEquiv e decidableZero a ≡ EuclideanDomain.norm e a!=0
normIs with decidableZero a
normIs | inl a=0 = exFalso (a!=0 a=0)
normIs | inr a!=0' = EuclideanDomain.normWellDefined e a!=0' a!=0
normIs' : normEquiv e decidableZero b ≡ EuclideanDomain.norm e b!=0
normIs' with decidableZero b
normIs' | inl b=0 = exFalso (b!=0 b=0)
normIs' | inr b!=0' = EuclideanDomain.normWellDefined e b!=0' b!=0
ans : (normEquiv e decidableZero a) ≤N (normEquiv e decidableZero b)
ans with EuclideanDomain.normSize e a!=0 b!=0 c (symmetric ac=b)
ans | inl n<Nn = inl (identityOfIndiscernablesLeft _<N_ (identityOfIndiscernablesRight _<N_ n<Nn (equalityCommutative normIs')) (equalityCommutative normIs))
ans | inr n=n = inr (transitivity normIs (transitivity n=n (equalityCommutative normIs')))
divisionAlgEquiv : (e : EuclideanDomain) (decidableZero : (a : A) → (a ∼ 0R) || ((a ∼ 0R) → False)) → (a b : A) → ((b ∼ 0R) → False) → DivisionAlgorithmResult' (normEquiv e decidableZero) a b
divisionAlgEquiv e decidableZero a b b!=0 with decidableZero a
divisionAlgEquiv e decidableZero a b b!=0 | inl a=0 = record { quotient = 0R ; rem = 0R ; remSmall = inl reflexive ; divAlg = transitive a=0 (transitive (symmetric identLeft) (+WellDefined (symmetric (transitive *Commutative timesZero)) reflexive)) }
divisionAlgEquiv e decidableZero a b b!=0 | inr a!=0 with EuclideanDomain.divisionAlg e a!=0 b!=0
divisionAlgEquiv e decidableZero a b b!=0 | inr a!=0 | record { quotient = quotient ; rem = rem ; remSmall = inl x ; divAlg = divAlg } = record { quotient = quotient ; rem = rem ; remSmall = inl x ; divAlg = divAlg }
divisionAlgEquiv e decidableZero a b b!=0 | inr a!=0 | record { quotient = quotient ; rem = rem ; remSmall = inr (rem!=0 , pr) ; divAlg = divAlg } = record { quotient = quotient ; rem = rem ; remSmall = inr (identityOfIndiscernablesLeft _<N_ (identityOfIndiscernablesRight _<N_ pr (equalityCommutative normIs')) (equalityCommutative normIs)) ; divAlg = divAlg }
where
normIs : normEquiv e decidableZero rem ≡ EuclideanDomain.norm e rem!=0
normIs with decidableZero rem
normIs | inl rem=0 = exFalso (rem!=0 rem=0)
normIs | inr rem!=0' = EuclideanDomain.normWellDefined e rem!=0' rem!=0
normIs' : normEquiv e decidableZero b ≡ EuclideanDomain.norm e b!=0
normIs' with decidableZero b
normIs' | inl b=0 = exFalso (b!=0 b=0)
normIs' | inr b!=0' = EuclideanDomain.normWellDefined e b!=0' b!=0
normWellDefined : (e : EuclideanDomain) (decidableZero : (a : A) → (a ∼ 0R) || ((a ∼ 0R) → False)) {a b : A} (a=b : a ∼ b) → normEquiv e decidableZero a ≡ normEquiv e decidableZero b
normWellDefined e decidableZero {a} {b} a=b with decidableZero a
normWellDefined e decidableZero {a} {b} a=b | inl a=0 with decidableZero b
normWellDefined e decidableZero {a} {b} a=b | inl a=0 | inl b=0 = refl
normWellDefined e decidableZero {a} {b} a=b | inl a=0 | inr b!=0 = exFalso (b!=0 (transitive (symmetric a=b) a=0))
normWellDefined e decidableZero {a} {b} a=b | inr a!=0 with decidableZero b
normWellDefined e decidableZero {a} {b} a=b | inr a!=0 | inl b=0 = exFalso (a!=0 (transitive a=b b=0))
normWellDefined e decidableZero {a} {b} a=b | inr a!=0 | inr b!=0 = EuclideanDomain.normWellDefined' e a=b a!=0 b!=0
eucDomsEquiv : (decidableZero : (a : A) → (a ∼ 0R) || ((a ∼ 0R) → False)) → EuclideanDomain → EuclideanDomain'
eucDomsEquiv decidableZero e = record { isIntegralDomain = EuclideanDomain.isIntegralDomain e ; norm = normEquiv e decidableZero ; normSize = normSizeEquiv e decidableZero ; divisionAlg = divisionAlgEquiv e decidableZero ; normWellDefined = normWellDefined e decidableZero }
|
{
"alphanum_fraction": 0.663292488,
"avg_line_length": 65.2869565217,
"ext": "agda",
"hexsha": "6a15b3b16e98783312c3632cb25ff2e994898414",
"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/EuclideanDomains/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/EuclideanDomains/Definition.agda",
"max_line_length": 361,
"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/EuclideanDomains/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": 2772,
"size": 7508
}
|
module Logic.Classical.Propositional where
open import Boolean
open import Data
open import Functional
import Lvl
-- Propositional logic. Working with propositions and their truth (whether they are true or false).
module ProofSystems {ℓ₁} {ℓ₂} {Proposition : Set(ℓ₁)} {Formula : Set(ℓ₁) → Set(ℓ₂)} (symbols : Syntax.Symbols Proposition Formula) where
open Syntax.Symbols(symbols)
module TruthTables where
-- The "proofs" that results by these postulates are very much alike the classical notation of natural deduction proofs in written as trees.
-- A function that has the type (Node(A) → Node(B)) is a proof of (A ⊢ B) (A is the assumption, B is the single conclusion)
-- A function that has the type (Node(A₁) → Node(A₂) → Node(A₃) → .. → Node(B)) is a proof of ({A₁,A₂,A₃,..} ⊢ B) (Aᵢ is the assumptions, B is the single result)
-- A function's function body is the "tree proof"
-- • The inner most (deepest) expression is at the top of a normal tree
-- • The outer most (shallow) expression is at the bottom of a normal tree that should result in a construction of the conclusion
-- One difference is that one cannot introduce assumptions however one wants. There are however rules that allows one to to this by using a function, and can be written as a lambda abstraction if one want it to look similar to the tree proofs.
module NaturalDeduction where
-- Intro rules are like constructors of formulas
-- Elimination rules are like deconstructors of formulas
record Rules : Set(Lvl.𝐒(ℓ₁ Lvl.⊔ ℓ₂)) where
field
{Node} : Formula(Proposition) → Set(ℓ₁ Lvl.⊔ ℓ₂)
field
[⊤]-intro : Node(⊤)
[⊥]-intro : ∀{φ : Formula(Proposition)} → Node(φ) → Node(¬ φ) → Node(⊥)
[¬]-intro : ∀{φ : Formula(Proposition)} → (Node(φ) → Node(⊥)) → Node(¬ φ)
[¬]-elim : ∀{φ : Formula(Proposition)} → (Node(¬ φ) → Node(⊥)) → Node(φ)
[∧]-intro : ∀{φ₁ φ₂ : Formula(Proposition)} → Node(φ₁) → Node(φ₂) → Node(φ₁ ∧ φ₂)
[∧]-elimₗ : ∀{φ₁ φ₂ : Formula(Proposition)} → Node(φ₁ ∧ φ₂) → Node(φ₁)
[∧]-elimᵣ : ∀{φ₁ φ₂ : Formula(Proposition)} → Node(φ₁ ∧ φ₂) → Node(φ₂)
[∨]-introₗ : ∀{φ₁ φ₂ : Formula(Proposition)} → Node(φ₁) → Node(φ₁ ∨ φ₂)
[∨]-introᵣ : ∀{φ₁ φ₂ : Formula(Proposition)} → Node(φ₂) → Node(φ₁ ∨ φ₂)
[∨]-elim : ∀{φ₁ φ₂ φ₃ : Formula(Proposition)} → (Node(φ₁) → Node(φ₃)) → (Node(φ₂) → Node(φ₃)) → Node(φ₁ ∨ φ₂) → Node(φ₃)
[⇒]-intro : ∀{φ₁ φ₂ : Formula(Proposition)} → (Node(φ₁) → Node(φ₂)) → Node(φ₁ ⇒ φ₂)
[⇒]-elim : ∀{φ₁ φ₂ : Formula(Proposition)} → Node(φ₁ ⇒ φ₂) → Node(φ₁) → Node(φ₂)
[⇐]-intro : ∀{φ₁ φ₂ : Formula(Proposition)} → (Node(φ₂) → Node(φ₁)) → Node(φ₁ ⇐ φ₂)
[⇐]-elim : ∀{φ₁ φ₂ : Formula(Proposition)} → Node(φ₁ ⇐ φ₂) → Node(φ₂) → Node(φ₁)
[⇔]-intro : ∀{φ₁ φ₂ : Formula(Proposition)} → (Node(φ₂) → Node(φ₁)) → (Node(φ₁) → Node(φ₂)) → Node(φ₁ ⇔ φ₂)
[⇔]-elimₗ : ∀{φ₁ φ₂ : Formula(Proposition)} → Node(φ₁ ⇔ φ₂) → Node(φ₂) → Node(φ₁)
[⇔]-elimᵣ : ∀{φ₁ φ₂ : Formula(Proposition)} → Node(φ₁ ⇔ φ₂) → Node(φ₁) → Node(φ₂)
-- Double negated proposition is positive
[¬¬]-elim : ∀{φ : Formula(Proposition)} → Node(¬ (¬ φ)) → Node(φ)
[¬¬]-elim nna = [¬]-elim(na ↦ [⊥]-intro na nna)
[⊥]-elim : ∀{φ : Formula(Proposition)} → Node(⊥) → Node(φ)
[⊥]-elim bottom = [¬]-elim(_ ↦ bottom)
module Meta(rules : Rules) (meta-symbols : Syntax.Symbols (Set(ℓ₁ Lvl.⊔ ℓ₂)) id) where
open import Data.List
open Rules(rules)
open Syntax.Symbols(meta-symbols)
renaming (
•_ to ◦_ ;
⊤ to ⊤ₘ ;
⊥ to ⊥ₘ ;
¬_ to ¬ₘ_ ;
_∧_ to _∧ₘ_ ;
_∨_ to _∨ₘ_ ;
_⇒_ to _⇒ₘ_ )
module Theorems where
open import Data.List.Proofs{ℓ₁}{ℓ₂}
import List.Theorems
open Data.List.Relation.Membership
open Data.List.Relation.Membership.Relators
open import Relator.Equals{ℓ₁}{ℓ₂}
open import Relator.Equals.Proofs{ℓ₁}{ℓ₂}
-- [⊢]-subset : (Γ₁ ⊆ Γ₂) → (Γ₁ ⊢ φ) → (Γ₂ ⊢ φ)
-- [⊢]-subset proof =
-- [⊢]-subset : ∀{T}{L₁ L₂ : List(Stmt)} → (L₁ ⊆ L₂) → ∀{X} → (f(L₁) → X) → (f(L₂) → X)
[⊢]-id : ∀{φ} → ([ φ ] ⊢ φ)
[⊢]-id = id
-- [⊢]-lhs-commutativity : ∀{Γ₁ Γ₂}{φ} → ((Γ₁ ++ Γ₂) ⊢ φ) → ((Γ₂ ++ Γ₁) ⊢ φ)
-- [⊢]-lhs-commutativity = id
-- [⊢]-test : ∀{φ₁ φ₂ φ₃} → ([ φ₁ ⊰ φ₂ ⊰ φ₃ ] ⊢ φ₁) → (Node(φ₁) ⨯ (Node(φ₂) ⨯ Node(φ₃)) → Node(φ₁))
-- [⊢]-test = id
[⊢]-weakening : ∀{Γ}{φ₁} → (Γ ⊢ φ₁) → ∀{φ₂} → ((φ₂ ⊰ Γ) ⊢ φ₁)
[⊢]-weakening {∅} (⊢φ₁) (φ₂) = (⊢φ₁)
[⊢]-weakening {_ ⊰ _} (Γ⊢φ₁) (φ₂ , Γ) = (Γ⊢φ₁) (Γ)
-- [⊢]-weakening₂ : ∀{Γ₁}{φ₁} → (Γ₁ ⊢ φ₁) → ∀{Γ₂} → ((Γ₁ ++ Γ₂) ⊢ φ₁)
-- [⊢]-weakening₂ {Γ₁}{φ₁} (Γ⊢φ₁) {∅} = [≡]-elimᵣ {_}{_}{_} [++]-identityₗ {expr ↦ (expr ⊢ φ₁)} Γ⊢φ₁
-- [⊢]-weakening₂ {Γ₁}{φ₁} (Γ₁⊢φ₁) {φ₂ ⊰ Γ₂} = [⊢]-weakening₂ {Γ₁}{φ₁} ([⊢]-weakening{Γ₁}{φ₁} (Γ₁⊢φ₁) {φ₂}) {Γ₂}
[⊢]-compose : ∀{Γ}{φ₁ φ₂} → (Γ ⊢ φ₁) → ([ φ₁ ] ⊢ φ₂) → (Γ ⊢ φ₂)
[⊢]-compose {∅} (φ₁) (φ₁⊢φ₂) = (φ₁⊢φ₂) (φ₁)
[⊢]-compose {_ ⊰ _} (Γ⊢φ₁) (φ₁⊢φ₂) (Γ) = (φ₁⊢φ₂) ((Γ⊢φ₁) (Γ))
[⊢]-compose₂ : ∀{Γ}{φ₁ φ₂} → (Γ ⊢ φ₁) → ((φ₁ ⊰ Γ) ⊢ φ₂) → (Γ ⊢ φ₂)
[⊢]-compose₂ {∅} (φ₁) (φ₁⊢φ₂) = (φ₁⊢φ₂)(φ₁)
[⊢]-compose₂ {_ ⊰ _} (Γ⊢φ₁) (φ₁Γ⊢φ₂) (Γ) = (φ₁Γ⊢φ₂) ((Γ⊢φ₁) (Γ) , (Γ))
-- [⊢]-test : ∀{φ₁ φ₂ γ₁ γ₂} → ([ γ₁ ⊰ γ₂ ] ⊢ φ₁) → ([ φ₁ ⊰ γ₁ ⊰ γ₂ ] ⊢ φ₂) → ([ γ₁ ⊰ γ₂ ] ⊢ φ₂)
-- [⊢]-test (Γ⊢φ₁) (φ₁Γ⊢φ₂) (Γ) = (φ₁Γ⊢φ₂) ((Γ⊢φ₁) (Γ) , (Γ))
-- [⊢]-compose₃ : ∀{Γ₁ Γ₂}{φ₁ φ₂} → (Γ₁ ⊢ φ₁) → ((φ₁ ⊰ Γ₂) ⊢ φ₂) → ((Γ₁ ++ Γ₂) ⊢ φ₂)
-- [⊢]-compose₃ {∅} {∅} (φ₁) (φ₁⊢φ₂) = (φ₁⊢φ₂) (φ₁)
-- [⊢]-compose₃ {_ ⊰ _}{∅} = [⊢]-compose
-- [⊢]-compose₃ {∅}{∅} (φ₁) (φ₁⊢φ₂) = (φ₁⊢φ₂) (φ₁)
-- [⊢]-compose₃ {Γ}{∅} = [≡]-elimᵣ [++]-identityₗ [⊢]-compose{Γ}
-- [⊢]-compose₃ {∅}{Γ} = [⊢]-compose₂{Γ}
-- [⊢]-compose₃ {_ ⊰ _}{_ ⊰ _} = [⊢]-compose₂
-- olt-9-17 : ∀{Γ}{φ} → (Γ ⊢ φ) → ((φ ⊰ Γ) ⊢ ⊥) → (inconsistent Γ)
-- olt-9-17 Γ⊢φ Γφ⊢⊥ = (Γ ↦ [⊥]-intro (Γ⊢φ Γ) ([⊥]-elim(Γφ⊢⊥ Γ)))
module Theorems(rules : Rules) where
open Rules(rules)
-- Ensures that a certain proof is a certain proposition
-- (Like type ascription, ensures that a certain expression has a certain type)
-- Example:
-- (A :with: a) where a : Node(A)
-- ((A ∧ B) :with: [∧]-intro a b) where a : Node(A), b : Node(B)
_:with:_ : ∀(φ : Formula(Proposition)) → Node(φ) → Node(φ)
_:with:_ _ x = x
infixl 100 _:with:_
-- The ability to derive anything from a contradiction
ex-falso-quodlibet : ∀{A : Formula(Proposition)} → Node(⊥) → Node(A)
ex-falso-quodlibet = [⊥]-elim
[∧]-symmetry : ∀{A B : Formula(Proposition)} → Node(A ∧ B) → Node(B ∧ A)
[∧]-symmetry {A} {B} A∧B =
((B ∧ A) :with: [∧]-intro
(B :with: [∧]-elimᵣ(A∧B))
(A :with: [∧]-elimₗ(A∧B))
)
[∨]-symmetry : ∀{A B : Formula(Proposition)} → Node(A ∨ B) → Node(B ∨ A)
[∨]-symmetry {A} {B} A∨B =
((B ∨ A) :with: [∨]-elim
[∨]-introᵣ
[∨]-introₗ
A∨B
)
contrapositive : ∀{A B : Formula(Proposition)} → Node(A ⇒ B) → Node((¬ B) ⇒ (¬ A))
contrapositive {A} {B} A→B =
((¬ B) ⇒ (¬ A)) :with: [⇒]-intro(nb ↦
(¬ A) :with: [¬]-intro(a ↦
⊥ :with: [⊥]-intro
(B :with: [⇒]-elim (A→B) a)
((¬ B) :with: nb)
)
)
[⇒]-syllogism : ∀{A B C : Formula(Proposition)} → Node(A ⇒ B) → Node(B ⇒ C) → Node(A ⇒ C)
[⇒]-syllogism {A} {B} {C} A→B B→C =
([⇒]-intro(a ↦
([⇒]-elim
B→C
([⇒]-elim A→B a)
)
))
[∨]-syllogism : ∀{A B : Formula(Proposition)} → Node(A ∨ B) → Node((¬ A) ⇒ B)
[∨]-syllogism {A} {B} A∨B =
([∨]-elim
(a ↦ ((¬ A) ⇒ B) :with: [⇒]-syllogism
(((¬ A) ⇒ (¬ (¬ B))) :with: contrapositive
(((¬ B) ⇒ A) :with: [⇒]-intro(_ ↦ a))
)
(((¬ (¬ B)) ⇒ B) :with: [⇒]-intro [¬¬]-elim)
)
(b ↦ ((¬ A) ⇒ B) :with: [⇒]-intro(_ ↦ b))
A∨B
)
-- Currying
[∧]→[⇒]-in-assumption : {X Y Z : Formula(Proposition)} → Node((X ∧ Y) ⇒ Z) → Node(X ⇒ (Y ⇒ Z))
[∧]→[⇒]-in-assumption x∧y→z =
([⇒]-intro(x ↦
([⇒]-intro(y ↦
([⇒]-elim
(x∧y→z)
([∧]-intro x y)
)
))
))
-- Uncurrying
[∧]←[⇒]-in-assumption : {X Y Z : Formula(Proposition)} → Node(X ⇒ (Y ⇒ Z)) → Node((X ∧ Y) ⇒ Z)
[∧]←[⇒]-in-assumption x→y→z =
([⇒]-intro(x∧y ↦
([⇒]-elim
([⇒]-elim
(x→y→z)
([∧]-elimₗ x∧y)
)
([∧]-elimᵣ x∧y)
)
))
-- It is either that a proposition is true or its negation is true.
-- A proposition is either true or false.
-- There is no other truth values than true and false.
excluded-middle : ∀{A : Formula(Proposition)} → Node(A ∨ (¬ A))
excluded-middle {A} =
([¬]-elim(¬[a∨¬a] ↦
(⊥ :with: [⊥]-intro
((A ∨ (¬ A)) :with: [∨]-introᵣ
((¬ A) :with: [¬]-intro(a ↦
(⊥ :with: [⊥]-intro
((A ∨ (¬ A)) :with: [∨]-introₗ(a))
((¬(A ∨ (¬ A))) :with: ¬[a∨¬a])
)
))
)
(¬[a∨¬a])
)
))
-- It cannot be that a proposition is true and its negation is true at the same time.
-- A proposition cannot be true and false at the same time.
non-contradiction : ∀{A : Formula(Proposition)} → Node(¬ (A ∧ (¬ A)))
non-contradiction {A} =
([¬]-intro(a∧¬a ↦
(⊥ :with: [⊥]-intro
(A :with: [∧]-elimₗ a∧¬a)
((¬ A) :with: [∧]-elimᵣ a∧¬a)
)
))
-- TODO: Mix of excluded middle and non-contradiction: (A ⊕ (¬ A))
-- The standard proof technic: Assume the opposite of the conclusion and prove that it leads to a contradiction
proof-by-contradiction : ∀{A B : Formula(Proposition)} → (Node(¬ A) → Node(B)) → (Node(¬ A) → Node(¬ B)) → Node(A)
proof-by-contradiction {A} {B} ¬a→b ¬a→¬b =
(A :with: [¬]-elim(¬a ↦
(⊥ :with: [⊥]-intro
(B :with: ¬a→b(¬a))
((¬ B) :with: ¬a→¬b(¬a))
)
))
peirce : ∀{A B : Formula(Proposition)} → Node((A ⇒ B) ⇒ A) → Node(A)
peirce {A} {B} [A→B]→A =
(A :with: [¬]-elim(¬a ↦
([⊥]-intro
(A :with: [⇒]-elim
[A→B]→A
((A ⇒ B) :with: [⇒]-intro(a ↦
(B :with: [⊥]-elim
([⊥]-intro
a
¬a
)
)
))
)
((¬ A) :with: ¬a)
)
))
skip-[⇒]-assumption : ∀{A B : Formula(Proposition)} → (Node(A ⇒ B) → Node(A)) → Node(A)
skip-[⇒]-assumption A⇒B→A =
(peirce
([⇒]-intro
(A⇒B→A)
)
)
{-
data □ : Formula(Proposition) → Set where
Initial : ∀{φ} → □(φ)
[∧]-intro : ∀{φ₁ φ₂} → □(φ₁) → □(φ₂) → □(φ₁ ∧ φ₂)
[∧]-elimₗ : ∀{φ₁ φ₂} → □(φ₁ ∧ φ₂) → □(φ₁)
[∧]-elimᵣ : ∀{φ₁ φ₂} → □(φ₁ ∧ φ₂) → □(φ₂)
[∨]-introₗ : ∀{φ₁ φ₂} → □(φ₁) → □(φ₁ ∨ φ₂)
[∨]-introᵣ : ∀{φ₁ φ₂} → □(φ₁) → □(φ₁ ∨ φ₂)
[∨]-elim : ∀{φ₁ φ₂ φ₃} → (□(φ₁) → □(φ₃)) → (□(φ₂) → □(φ₃)) → □(φ₃)
[⇒]-intro : ∀{φ₁ φ₂} → (□(φ₁) → □(φ₂)) → □(φ₁ ⇒ φ₂)
[⇒]-elim : ∀{φ₁ φ₂} → □(φ₁ ⇒ φ₂) → □(φ₁) → □(φ₂)
[¬]-intro : ∀{φ} → (□(φ) → □(⊥)) → □(¬ φ)
[¬]-elim : ∀{φ} → (□(¬ φ) → □(⊥)) → □(φ)
data □ : Formula(Proposition) → Set where
Initial : ∀{φ} → □(φ)
[∧]-intro : ∀{φ₁ φ₂} → □(φ₁) → □(φ₂) → □(φ₁ ∧ φ₂)
[∧]-elimₗ : ∀{φ₁ φ₂} → □(φ₁ ∧ φ₂) → □(φ₁)
[∧]-elimᵣ : ∀{φ₁ φ₂} → □(φ₁ ∧ φ₂) → □(φ₂)
[∨]-introₗ : ∀{φ₁ φ₂} → □(φ₁) → □(φ₁ ∨ φ₂)
[∨]-introᵣ : ∀{φ₁ φ₂} → □(φ₁) → □(φ₁ ∨ φ₂)
[∨]-elim : ∀{φ₁ φ₂ φ₃} → (□(φ₁) → □(φ₃)) → (□(φ₂) → □(φ₃)) → □(φ₃)
[⇒]-intro : ∀{φ₁ φ₂} → (□(φ₁) → □(φ₂)) → □(φ₁ ⇒ φ₂)
[⇒]-elim : ∀{φ₁ φ₂} → □(φ₁ ⇒ φ₂) → □(φ₁) → □(φ₂)
[¬]-intro : ∀{φ} → (□(φ) → □(⊥)) → □(¬ φ)
[¬¬]-elim : ∀{φ} → □(¬(¬ φ)) → □(φ)
-}
|
{
"alphanum_fraction": 0.4427542034,
"avg_line_length": 40.1607717042,
"ext": "agda",
"hexsha": "a22ee359b405fc97684cc7b8587cb3186ab7108f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "old/Metalogic/OLD_Propositional.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "old/Metalogic/OLD_Propositional.agda",
"max_line_length": 245,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "old/Metalogic/OLD_Propositional.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": 5567,
"size": 12490
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Coprimality
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
-- Disabled to prevent warnings from deprecated names
{-# OPTIONS --warn=noUserWarning #-}
module Data.Nat.Coprimality where
open import Data.Empty
open import Data.Fin.Base using (toℕ; fromℕ<)
open import Data.Fin.Properties using (toℕ-fromℕ<)
open import Data.Nat.Base
open import Data.Nat.Divisibility
open import Data.Nat.GCD
open import Data.Nat.GCD.Lemmas
open import Data.Nat.Primality
open import Data.Nat.Properties
open import Data.Nat.DivMod
open import Data.Product as Prod
open import Function
open import Level using (0ℓ)
open import Relation.Binary.PropositionalEquality as P
using (_≡_; _≢_; refl; cong; subst; module ≡-Reasoning)
open import Relation.Nullary
open import Relation.Nullary.Negation using (contradiction)
open import Relation.Binary
open ≤-Reasoning
------------------------------------------------------------------------
-- Definition
--
-- Coprime m n is inhabited iff m and n are coprime (relatively
-- prime), i.e. if their only common divisor is 1.
Coprime : Rel ℕ 0ℓ
Coprime m n = ∀ {i} → i ∣ m × i ∣ n → i ≡ 1
------------------------------------------------------------------------
-- Relationship between GCD and coprimality
coprime⇒GCD≡1 : ∀ {m n} → Coprime m n → GCD m n 1
coprime⇒GCD≡1 {m} {n} c = GCD.is (1∣ m , 1∣ n) (∣-reflexive ∘ c)
GCD≡1⇒coprime : ∀ {m n} → GCD m n 1 → Coprime m n
GCD≡1⇒coprime g cd with GCD.greatest g cd
... | divides q eq = m*n≡1⇒n≡1 q _ (P.sym eq)
coprime⇒gcd≡1 : ∀ {m n} → Coprime m n → gcd m n ≡ 1
coprime⇒gcd≡1 coprime = GCD.unique (gcd-GCD _ _) (coprime⇒GCD≡1 coprime)
gcd≡1⇒coprime : ∀ {m n} → gcd m n ≡ 1 → Coprime m n
gcd≡1⇒coprime gcd≡1 = GCD≡1⇒coprime (subst (GCD _ _) gcd≡1 (gcd-GCD _ _))
coprime-/gcd : ∀ m n {gcd≢0} →
Coprime ((m / gcd m n) {gcd≢0}) ((n / gcd m n) {gcd≢0})
coprime-/gcd m n {gcd≢0} = GCD≡1⇒coprime (GCD-/gcd m n {gcd≢0})
------------------------------------------------------------------------
-- Relational properties of Coprime
sym : Symmetric Coprime
sym c = c ∘ swap
private
0≢1 : 0 ≢ 1
0≢1 ()
2+≢1 : ∀ {n} → suc (suc n) ≢ 1
2+≢1 ()
coprime? : Decidable Coprime
coprime? i j with mkGCD i j
... | (0 , g) = no (0≢1 ∘ GCD.unique g ∘ coprime⇒GCD≡1)
... | (1 , g) = yes (GCD≡1⇒coprime g)
... | (suc (suc d) , g) = no (2+≢1 ∘ GCD.unique g ∘ coprime⇒GCD≡1)
------------------------------------------------------------------------
-- Other basic properties
-- Everything is coprime to 1.
1-coprimeTo : ∀ m → Coprime 1 m
1-coprimeTo m = ∣1⇒≡1 ∘ proj₁
-- Nothing except for 1 is coprime to 0.
0-coprimeTo-m⇒m≡1 : ∀ {m} → Coprime 0 m → m ≡ 1
0-coprimeTo-m⇒m≡1 {m} c = c (m ∣0 , ∣-refl)
-- If m and n are coprime, then n + m and n are also coprime.
coprime-+ : ∀ {m n} → Coprime m n → Coprime (n + m) n
coprime-+ c (d₁ , d₂) = c (∣m+n∣m⇒∣n d₁ d₂ , d₂)
------------------------------------------------------------------------
-- Relationship with Bezout's lemma
-- If the "gcd" in Bézout's identity is non-zero, then the "other"
-- divisors are coprime.
Bézout-coprime : ∀ {i j d} →
Bézout.Identity (suc d) (i * suc d) (j * suc d) →
Coprime i j
Bézout-coprime (Bézout.+- x y eq) (divides q₁ refl , divides q₂ refl) =
lem₁₀ y q₂ x q₁ eq
Bézout-coprime (Bézout.-+ x y eq) (divides q₁ refl , divides q₂ refl) =
lem₁₀ x q₁ y q₂ eq
-- Coprime numbers satisfy Bézout's identity.
coprime-Bézout : ∀ {i j} → Coprime i j → Bézout.Identity 1 i j
coprime-Bézout = Bézout.identity ∘ coprime⇒GCD≡1
-- If i divides jk and is coprime to j, then it divides k.
coprime-divisor : ∀ {k i j} → Coprime i j → i ∣ j * k → i ∣ k
coprime-divisor {k} c (divides q eq′) with coprime-Bézout c
... | Bézout.+- x y eq = divides (x * k ∸ y * q) (lem₈ x y eq eq′)
... | Bézout.-+ x y eq = divides (y * q ∸ x * k) (lem₉ x y eq eq′)
-- If d is a common divisor of mk and nk, and m and n are coprime,
-- then d divides k.
coprime-factors : ∀ {d m n k} →
Coprime m n → d ∣ m * k × d ∣ n * k → d ∣ k
coprime-factors c (divides q₁ eq₁ , divides q₂ eq₂) with coprime-Bézout c
... | Bézout.+- x y eq = divides (x * q₁ ∸ y * q₂) (lem₁₁ x y eq eq₁ eq₂)
... | Bézout.-+ x y eq = divides (y * q₂ ∸ x * q₁) (lem₁₁ y x eq eq₂ eq₁)
------------------------------------------------------------------------
-- Primality implies coprimality.
prime⇒coprime : ∀ m → Prime m →
∀ n → 0 < n → n < m → Coprime m n
prime⇒coprime (suc (suc m)) _ _ _ _ {1} _ = refl
prime⇒coprime (suc (suc m)) p _ _ _ {0} (divides q 2+m≡q*0 , _) =
⊥-elim $ m+1+n≢m 0 (begin-equality
2 + m ≡⟨ 2+m≡q*0 ⟩
q * 0 ≡⟨ *-zeroʳ q ⟩
0 ∎)
prime⇒coprime (suc (suc m)) p (suc n) _ 1+n<2+m {suc (suc i)}
(2+i∣2+m , 2+i∣1+n) =
⊥-elim (p _ 2+i′∣2+m)
where
i<m : i < m
i<m = +-cancelˡ-< 2 (begin-strict
2 + i ≤⟨ ∣⇒≤ 2+i∣1+n ⟩
1 + n <⟨ 1+n<2+m ⟩
2 + m ∎)
2+i′∣2+m : 2 + toℕ (fromℕ< i<m) ∣ 2 + m
2+i′∣2+m = subst (_∣ 2 + m)
(P.sym (cong (2 +_) (toℕ-fromℕ< i<m)))
2+i∣2+m
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use GCD from `Data.Nat.GCD` as continued support for the
-- proofs below is not guaranteed.
-- Version 1.1.
data GCD′ : ℕ → ℕ → ℕ → Set where
gcd-* : ∀ {d} q₁ q₂ (c : Coprime q₁ q₂) →
GCD′ (q₁ * d) (q₂ * d) d
{-# WARNING_ON_USAGE GCD′
"Warning: GCD′ was deprecated in v1.1."
#-}
gcd-gcd′ : ∀ {d m n} → GCD m n d → GCD′ m n d
gcd-gcd′ g with GCD.commonDivisor g
gcd-gcd′ {zero} g | (divides q₁ refl , divides q₂ refl)
with q₁ * 0 | *-comm 0 q₁ | q₂ * 0 | *-comm 0 q₂
... | .0 | refl | .0 | refl = gcd-* 1 1 (1-coprimeTo 1)
gcd-gcd′ {suc d} g | (divides q₁ refl , divides q₂ refl) =
gcd-* q₁ q₂ (Bézout-coprime (Bézout.identity g))
{-# WARNING_ON_USAGE gcd-gcd′
"Warning: gcd-gcd′ was deprecated in v1.1."
#-}
gcd′-gcd : ∀ {m n d} → GCD′ m n d → GCD m n d
gcd′-gcd (gcd-* q₁ q₂ c) = GCD.is (n∣m*n q₁ , n∣m*n q₂) (coprime-factors c)
{-# WARNING_ON_USAGE gcd′-gcd
"Warning: gcd′-gcd was deprecated in v1.1."
#-}
mkGCD′ : ∀ m n → ∃ λ d → GCD′ m n d
mkGCD′ m n = Prod.map id gcd-gcd′ (mkGCD m n)
{-# WARNING_ON_USAGE mkGCD′
"Warning: mkGCD′ was deprecated in v1.1."
#-}
-- Version 1.2
coprime-gcd = coprime⇒GCD≡1
{-# WARNING_ON_USAGE coprime-gcd
"Warning: coprime-gcd was deprecated in v1.2.
Please use coprime⇒GCD≡1 instead."
#-}
gcd-coprime = GCD≡1⇒coprime
{-# WARNING_ON_USAGE gcd-coprime
"Warning: gcd-coprime was deprecated in v1.2.
Please use GCD≡1⇒coprime instead."
#-}
|
{
"alphanum_fraction": 0.5375036625,
"avg_line_length": 32.5047619048,
"ext": "agda",
"hexsha": "896b401c071e3ed525cc8a32dcd7131ffd197bf9",
"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/Nat/Coprimality.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/Nat/Coprimality.agda",
"max_line_length": 75,
"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/Nat/Coprimality.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": 2707,
"size": 6826
}
|
{- 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.ImplShared.Base.Types
open import LibraBFT.Abstract.Types.EpochConfig UID NodeId
open import LibraBFT.Concrete.System
open import LibraBFT.Concrete.System.Parameters
open import LibraBFT.ImplShared.Base.Types
open import LibraBFT.ImplShared.Consensus.Types
open import LibraBFT.ImplShared.Consensus.Types.EpochDep
open import LibraBFT.ImplShared.Util.Crypto
open import Optics.All
open import Util.KVMap
open import Util.Lemmas
open import Util.PKCS
open import Util.Prelude
open import Yasm.Base
open EpochConfig
-- In this module, we define two "implementation obligations"
-- (ImplObligationᵢ for i ∈ {1 , 2}), which are predicates over
-- reachable states of a system defined by
-- 'LibraBFT.Concrete.System.Parameters'. These two properties relate
-- votes sent by the same sender, ensuring that if they are for the
-- same epoch and round, then they vote for the same blockID; the
-- first relates a vote output by the handler to a vote sent
-- previously, and the second relates two votes both sent by the
-- handler.
--
-- We then prove that, if an implementation satisfies these two
-- semantic obligations, along with a structural one about messages
-- sent by honest peers in the implementation, then the implemenation
-- satisfies the LibraBFT.Abstract.Properties.VotesOnce invariant.
-- It is not actually necessary to provide an EpochConfig to define
-- these implementation obligations, but it is needed below to state
-- the goal of the proof (voo). In contrast, the PreferredRound rule
-- requires and EpochConfig to state the obligations, because they
-- are defined in terms of abstract Records, which are defined for an
-- EpochConfig. We introduce the EpochConfig at the top of this
-- module for consistency with the PreferredRound rule so that the
-- order of parameters to invoke the respective proofs is consistent.
module LibraBFT.Concrete.Properties.VotesOnce (iiah : SystemInitAndHandlers ℓ-RoundManager ConcSysParms) (𝓔 : EpochConfig) where
open SystemTypeParameters ConcSysParms
open SystemInitAndHandlers iiah
open ParamsWithInitAndHandlers iiah
open import LibraBFT.Concrete.Properties.Common iiah 𝓔
open import LibraBFT.ImplShared.Util.HashCollisions iiah
open import Yasm.Yasm ℓ-RoundManager ℓ-VSFP ConcSysParms iiah PeerCanSignForPK PeerCanSignForPK-stable
-- TODO-3: This may not be the best way to state the implementation obligation. Why not reduce
-- this as much as possible before giving the obligation to the implementation? For example, this
-- will still require the implementation to deal with hash collisons (v and v' could be different,
-- but yield the same bytestring and therefore same signature). Also, avoid the need for the
-- implementation to reason about messages sent by step-cheat, or give it something to make this
-- case easy to eliminate.
ImplObligation₂ : Set (ℓ+1 ℓ-RoundManager)
ImplObligation₂ =
∀{pid s' outs pk}{pre : SystemState}
→ ReachableSystemState pre
-- For any honest call to /handle/ or /init/,
→ (sps : StepPeerState pid (msgPool pre) (initialised pre) (peerStates pre pid) (s' , outs))
→ ∀{v m v' m'}
→ Meta-Honest-PK pk
-- For every vote v represented in a message output by the call
→ v ⊂Msg m → send m ∈ outs
→ (sig : WithVerSig pk v) → ¬ (∈BootstrapInfo bootstrapInfo (ver-signature sig))
→ ¬ (MsgWithSig∈ pk (ver-signature sig) (msgPool pre))
→ PeerCanSignForPK (StepPeer-post {pre = pre} (step-honest sps)) v pid pk
-- And if there exists another v' that is also new and valid
→ v' ⊂Msg m' → send m' ∈ outs
→ (sig' : WithVerSig pk v') → ¬ (∈BootstrapInfo bootstrapInfo (ver-signature sig'))
→ ¬ (MsgWithSig∈ pk (ver-signature sig') (msgPool pre))
→ PeerCanSignForPK (StepPeer-post {pre = pre} (step-honest sps)) v' pid pk
-- If v and v' share the same epoch and round
→ v ^∙ vEpoch ≡ v' ^∙ vEpoch
→ v ^∙ vRound ≡ v' ^∙ vRound
----------------------------------------------------------
-- Then, an honest implemenation promises v and v' vote for the same blockId.
→ v ^∙ vProposedId ≡ v' ^∙ vProposedId
-- Next, we prove that, given the necessary obligations,
module Proof
(sps-corr : StepPeerState-AllValidParts)
(Impl-bsvc : ImplObl-bootstrapVotesConsistent)
(Impl-bsvr : ImplObl-bootstrapVotesRound≡0)
(Impl-nvr≢0 : ImplObl-NewVoteRound≢0)
(Impl-∈BI? : (sig : Signature) → Dec (∈BootstrapInfo bootstrapInfo sig))
(Impl-IRO : IncreasingRoundObligation)
(Impl-VO2 : ImplObligation₂)
where
-- Any reachable state satisfies the VO rule for any epoch in the system.
module _ {st : SystemState}(r : ReachableSystemState st) where
open Structural sps-corr
-- Bring in intSystemState
open PerEpoch 𝓔
open PerState st
open PerReachableState r
open ConcreteCommonProperties st r sps-corr Impl-bsvr Impl-nvr≢0
open WithEC
open import LibraBFT.Concrete.Obligations.VotesOnce 𝓔 (ConcreteVoteEvidence 𝓔) as VO
-- The VO proof is done by induction on the execution trace leading to 'st'. In
-- Agda, this is 'r : RechableSystemState st' above.
private
-- From this point onwards, it might be easier to read this proof starting at 'voo'
-- at the end of the file. Next, we provide an overview the proof.
--
-- We wish to prove that, for any two votes v and v' cast by an honest α in the message
-- pool of a state st, if v and v' have equal rounds and epochs, then they vote for the
-- same block.
--
-- The base case and the case for a new epoch in the system are trivial. For the base case
-- we get to a contradiction because it's not possible to have any message in the msgpool.
--
-- Regarding the PeerStep case. The induction hypothesis tells us that the property holds
-- in the pre-state. Next, we reason about the post-state. We start by analyzing whether
-- v and v' have been sent as outputs of the PeerStep under scrutiny or were already in
-- the pool before.
--
-- There are four possibilities:
--
-- i) v and v' were aleady present in the msgPool before: use induction hypothesis.
-- ii) v and v' are both in the output produced by the PeerStep under scrutiny.
-- iii) v was present before, but v' is new.
-- iv) v' was present before, but v is new.
--
-- In order to obtain this four possiblities we invoke newMsg⊎msgSent4 lemma, which
-- receives proof that some vote is in a message that is in the msgPool of the post state
-- and returns evidence that either the vote is new or that some message with the same
-- signature was sent before.
--
-- Case (i) is trivial; cases (iii) and (iv) are symmetric and reduce to an implementation
-- obligation (Impl-VO1) and case (ii) reduces to a different implementation obligation
-- (Impl-VO2).
VotesOnceProof :
∀ {pk round epoch blockId₁ blockId₂} {st : SystemState}
→ ReachableSystemState st
→ Meta-Honest-PK pk
→ (m₁ : VoteForRound∈ pk round epoch blockId₁ (msgPool st))
→ (m₂ : VoteForRound∈ pk round epoch blockId₂ (msgPool st))
→ blockId₁ ≡ blockId₂
VotesOnceProof step-0 _ m₁ = ⊥-elim (¬Any[] (msg∈pool m₁))
VotesOnceProof step@(step-s r theStep) pkH m₁ m₂
with msgRound≡ m₁ | msgEpoch≡ m₁ | msgBId≡ m₁
| msgRound≡ m₂ | msgEpoch≡ m₂ | msgBId≡ m₂
...| refl | refl | refl | refl | refl | refl
with Impl-∈BI? (_vSignature (msgVote m₁)) | Impl-∈BI? (_vSignature (msgVote m₂))
...| yes init₁ | yes init₂ = Impl-bsvc (msgVote m₁) (msgVote m₂) init₁ init₂
...| yes init₁ | no ¬init₂ = ⊥-elim (NewVoteRound≢0 step pkH m₂ ¬init₂ (Impl-bsvr (msgSigned m₁) init₁))
...| no ¬init₁ | yes init₂ = ⊥-elim (NewVoteRound≢0 step pkH m₁ ¬init₁ (Impl-bsvr (msgSigned m₂) init₂))
...| no ¬init₁ | no ¬init₂
with theStep
...| step-peer cheat@(step-cheat c)
= let m₁sb4 = ¬cheatForgeNewSig r cheat unit pkH (msgSigned m₁) (msg⊆ m₁) (msg∈pool m₁) ¬init₁
m₂sb4 = ¬cheatForgeNewSig r cheat unit pkH (msgSigned m₂) (msg⊆ m₂) (msg∈pool m₂) ¬init₂
v₁sb4 = msgSentB4⇒VoteRound∈ (msgSigned m₁) m₁sb4
v₂sb4 = msgSentB4⇒VoteRound∈ (msgSigned m₂) m₂sb4
in VotesOnceProof r pkH (proj₁ v₁sb4) (proj₁ v₂sb4)
...| step-peer (step-honest stP)
with ⊎-map₂ (msgSentB4⇒VoteRound∈ (msgSigned m₁))
(newMsg⊎msgSentB4 r stP pkH (msgSigned m₁) ¬init₁ (msg⊆ m₁) (msg∈pool m₁))
| ⊎-map₂ (msgSentB4⇒VoteRound∈ (msgSigned m₂))
(newMsg⊎msgSentB4 r stP pkH (msgSigned m₂) ¬init₂ (msg⊆ m₂) (msg∈pool m₂))
...| inj₂ (v₁sb4 , refl) | inj₂ (v₂sb4 , refl)
= VotesOnceProof r pkH v₁sb4 v₂sb4
...| inj₁ (m₁∈outs , v₁pk , v₁New) | inj₁ (m₂∈outs , v₂pk , v₂New)
= Impl-VO2 r stP pkH (msg⊆ m₁) m₁∈outs (msgSigned m₁) ¬init₁ v₁New v₁pk
(msg⊆ m₂) m₂∈outs (msgSigned m₂) ¬init₂ v₂New v₂pk refl refl
...| inj₁ (m₁∈outs , v₁pk , v₁New) | inj₂ (v₂sb4 , refl)
= let round≡ = trans (msgRound≡ v₂sb4) (msgRound≡ m₂)
¬bootstrapV₂ = ¬Bootstrap∧Round≡⇒¬Bootstrap step pkH m₂ ¬init₂ (msgSigned v₂sb4) round≡
epoch≡ = sym (msgEpoch≡ v₂sb4)
in either (λ v₂<v₁ → ⊥-elim (<⇒≢ v₂<v₁ (msgRound≡ v₂sb4)))
(λ v₁sb4 → VotesOnceProof r pkH v₁sb4 v₂sb4)
(Impl-IRO r stP pkH (msg⊆ m₁) m₁∈outs (msgSigned m₁) ¬init₁ v₁New v₁pk
(msg⊆ v₂sb4) (msg∈pool v₂sb4) (msgSigned v₂sb4) ¬bootstrapV₂ epoch≡)
...| inj₂ (v₁sb4 , refl) | inj₁ (m₂∈outs , v₂pk , v₂New)
= let round≡ = trans (msgRound≡ v₁sb4) (msgRound≡ m₁)
¬bootstrapV₁ = ¬Bootstrap∧Round≡⇒¬Bootstrap step pkH m₁ ¬init₁ (msgSigned v₁sb4) round≡
in either (λ v₁<v₂ → ⊥-elim (<⇒≢ v₁<v₂ (msgRound≡ v₁sb4)))
(λ v₂sb4 → VotesOnceProof r pkH v₁sb4 v₂sb4)
(Impl-IRO r stP pkH (msg⊆ m₂) m₂∈outs (msgSigned m₂) ¬init₂ v₂New v₂pk
(msg⊆ v₁sb4) (msg∈pool v₁sb4) (msgSigned v₁sb4) ¬bootstrapV₁
(sym (msgEpoch≡ v₁sb4)))
voo : VO.Type intSystemState
voo hpk refl sv refl sv' refl
with vmsg≈v (vmFor sv) | vmsg≈v (vmFor sv')
...| refl | refl
with vmsgEpoch (vmFor sv) | vmsgEpoch (vmFor sv')
...| refl | refl
= let vfr = mkVoteForRound∈ (nm (vmFor sv)) (cv ((vmFor sv))) (cv∈nm (vmFor sv))
(vmSender sv) (nmSentByAuth sv) (vmsgSigned (vmFor sv))
(vmsgEpoch (vmFor sv)) refl refl
vfr' = mkVoteForRound∈ (nm (vmFor sv')) (cv (vmFor sv')) (cv∈nm (vmFor sv'))
(vmSender sv') (nmSentByAuth sv') (vmsgSigned (vmFor sv'))
(vmsgEpoch (vmFor sv')) refl refl
in VotesOnceProof r hpk vfr vfr'
|
{
"alphanum_fraction": 0.6610636784,
"avg_line_length": 52.2976744186,
"ext": "agda",
"hexsha": "2551eb3001dfad95ea58b0b6b00662a3ecdd026c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_forks_repo_path": "src/LibraBFT/Concrete/Properties/VotesOnce.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_issues_repo_path": "src/LibraBFT/Concrete/Properties/VotesOnce.agda",
"max_line_length": 128,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_stars_repo_path": "src/LibraBFT/Concrete/Properties/VotesOnce.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3489,
"size": 11244
}
|
open import Data.Product using ( _×_ ; _,_ )
open import Data.Sum using ( _⊎_ )
open import Relation.Unary using ( _∈_ ; _∉_ )
open import Web.Semantic.DL.FOL using ( Formula ; true ; false ; _∧_ ; _∈₁_ ; _∈₁_⇒_ ; _∈₂_ ; _∈₂_⇒_ ; _∼_ ; _∼_⇒_ ; ∀₁ )
open import Web.Semantic.DL.Signature using ( Signature )
open import Web.Semantic.DL.TBox.Interp using ( Interp ; Δ ; _⊨_≈_ ; con ; rol )
open import Web.Semantic.Util using ( True ; False )
module Web.Semantic.DL.FOL.Model {Σ : Signature} where
_⊨f_ : (I : Interp Σ) → Formula Σ (Δ I) → Set
I ⊨f true = True
I ⊨f false = False
I ⊨f (F ∧ G) = (I ⊨f F) × (I ⊨f G)
I ⊨f (x ∈₁ c) = x ∈ (con I c)
I ⊨f (x ∈₁ c ⇒ F) = (x ∈ (con I c)) → (I ⊨f F)
I ⊨f ((x , y) ∈₂ r) = (x , y) ∈ (rol I r)
I ⊨f ((x , y) ∈₂ r ⇒ F) = ((x , y) ∈ (rol I r)) → (I ⊨f F)
I ⊨f (x ∼ y) = I ⊨ x ≈ y
I ⊨f (x ∼ y ⇒ F) = (I ⊨ x ≈ y) → (I ⊨f F)
I ⊨f ∀₁ F = ∀ x → (I ⊨f F x)
|
{
"alphanum_fraction": 0.5337078652,
"avg_line_length": 40.4545454545,
"ext": "agda",
"hexsha": "3df87eec09adbde9903af55126972876b6924daf",
"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": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bblfish/agda-web-semantic",
"max_forks_repo_path": "src/Web/Semantic/DL/FOL/Model.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057",
"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": "bblfish/agda-web-semantic",
"max_issues_repo_path": "src/Web/Semantic/DL/FOL/Model.agda",
"max_line_length": 122,
"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/FOL/Model.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": 435,
"size": 890
}
|
data Cx (U : Set) : Set where
∅ : Cx U
_,_ : Cx U → U → Cx U
data _∈_ {U : Set} (A : U) : Cx U → Set where
top : ∀ {Γ} → A ∈ (Γ , A)
pop : ∀ {B Γ} → A ∈ Γ → A ∈ (Γ , B)
infixr 3 _⇒_
data Ty : Set where
ι : Ty
_⇒_ : Ty → Ty → Ty
□_ : Ty → Ty
infix 1 _⊢_
data _⊢_ : Cx Ty → Ty → Set where
var : ∀ {Γ A} → A ∈ Γ → Γ ⊢ A
app : ∀ {Γ A B} → Γ ⊢ A ⇒ B → Γ ⊢ A → Γ ⊢ B
nec : ∀ {A} → ∅ ⊢ A → ∅ ⊢ □ A
kcom : ∀ {Γ A B} → Γ ⊢ A ⇒ B ⇒ A
scom : ∀ {Γ A B C} → Γ ⊢ (A ⇒ B ⇒ C) ⇒ (A ⇒ B) ⇒ A ⇒ C
dist : ∀ {Γ A B} → Γ ⊢ □ (A ⇒ B) ⇒ □ A ⇒ □ B
down : ∀ {Γ A} → Γ ⊢ □ A ⇒ A
up : ∀ {Γ A} → Γ ⊢ □ A ⇒ □ □ A
icom : ∀ {A Γ} → Γ ⊢ A ⇒ A
icom {A} = app (app (scom {A = A} {B = A ⇒ A} {C = A}) kcom) kcom
ded : ∀ {A B Γ} → Γ , A ⊢ B → Γ ⊢ A ⇒ B
ded (var top) = icom
ded (var (pop i)) = app kcom (var i)
ded (app t u) = app (app scom (ded t)) (ded u)
ded (nec t) = ?
ded kcom = app kcom kcom
ded scom = app kcom scom
ded dist = app kcom dist
ded down = app kcom down
ded up = app kcom up
|
{
"alphanum_fraction": 0.3889908257,
"avg_line_length": 27.25,
"ext": "agda",
"hexsha": "c3c1825ed6ea54e78f171618a64675bae54913bc",
"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/Issue2079.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/Issue2079.agda",
"max_line_length": 65,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue2079.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": 551,
"size": 1090
}
|
module Numeral.Integer.Relation.Divisibility where
open import Functional
open import Logic.Propositional
import Numeral.Natural.Relation.Divisibility as ℕ
open import Numeral.Integer
open import Type
_∣_ = (ℕ._∣_) on₂ absₙ
_∤_ = (¬_) ∘₂ (_∣_)
|
{
"alphanum_fraction": 0.764940239,
"avg_line_length": 22.8181818182,
"ext": "agda",
"hexsha": "3046b3c89b9f5a35e41fe8288a32800f4cd2c5dc",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Numeral/Integer/Relation/Divisibility.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Numeral/Integer/Relation/Divisibility.agda",
"max_line_length": 54,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Numeral/Integer/Relation/Divisibility.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": 79,
"size": 251
}
|
module Oscar.Data.Product where
open import Data.Product public using (Σ; _,_; proj₁; proj₂; ∃; ∃₂; _×_)
|
{
"alphanum_fraction": 0.7009345794,
"avg_line_length": 21.4,
"ext": "agda",
"hexsha": "81b6f6a1b431aa265f9b255c4aea92af5f92252c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-2/Oscar/Data/Product.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-2/Oscar/Data/Product.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-2/Oscar/Data/Product.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 35,
"size": 107
}
|
module BasicIPC.Metatheory.Gentzen-TarskiGluedClosedImplicit where
open import BasicIPC.Syntax.Gentzen public
open import BasicIPC.Semantics.TarskiGluedClosedImplicit public
open ImplicitSyntax (∅ ⊢_) public
-- Completeness with respect to a particular model.
module _ {{_ : Model}} where
reify : ∀ {A} → ⊩ A → ∅ ⊢ A
reify {α P} s = syn s
reify {A ▻ B} s = syn s
reify {A ∧ B} s = pair (reify (π₁ s)) (reify (π₂ s))
reify {⊤} s = unit
reify⋆ : ∀ {Ξ} → ⊩⋆ Ξ → ∅ ⊢⋆ Ξ
reify⋆ {∅} ∙ = ∙
reify⋆ {Ξ , A} (ts , t) = reify⋆ ts , reify t
-- Soundness with respect to all models, or evaluation.
eval : ∀ {A Γ} → Γ ⊢ A → Γ ⊨ A
eval (var i) γ = lookup i γ
eval (lam t) γ = multicut (reify⋆ γ) (lam t) ⅋ λ a →
eval t (γ , a)
eval (app t u) γ = eval t γ ⟪$⟫ eval u γ
eval (pair t u) γ = eval t γ , eval u γ
eval (fst t) γ = π₁ (eval t γ)
eval (snd t) γ = π₂ (eval t γ)
eval unit γ = ∙
-- TODO: Correctness of evaluation with respect to conversion.
-- The canonical model.
private
instance
canon : Model
canon = record
{ ⊩ᵅ_ = λ P → ∅ ⊢ α P
}
-- Completeness with respect to all models, or quotation, for closed terms only.
quot₀ : ∀ {A} → ∅ ⊨ A → ∅ ⊢ A
quot₀ t = reify (t ∙)
-- Normalisation by evaluation, for closed terms only.
norm₀ : ∀ {A} → ∅ ⊢ A → ∅ ⊢ A
norm₀ = quot₀ ∘ eval
-- TODO: Correctness of normalisation with respect to conversion.
|
{
"alphanum_fraction": 0.5862068966,
"avg_line_length": 23.3870967742,
"ext": "agda",
"hexsha": "77aaf9099cce31f6147e1b1d630eba7f27929e0c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/hilbert-gentzen",
"max_forks_repo_path": "BasicIPC/Metatheory/Gentzen-TarskiGluedClosedImplicit.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/hilbert-gentzen",
"max_issues_repo_path": "BasicIPC/Metatheory/Gentzen-TarskiGluedClosedImplicit.agda",
"max_line_length": 80,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/hilbert-gentzen",
"max_stars_repo_path": "BasicIPC/Metatheory/Gentzen-TarskiGluedClosedImplicit.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z",
"num_tokens": 546,
"size": 1450
}
|
------------------------------------------------------------------------
-- Operations on and properties of decidable relations
------------------------------------------------------------------------
module Relation.Nullary.Decidable where
open import Data.Empty
open import Data.Function
open import Data.Bool
open import Data.Product hiding (map)
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
decToBool : ∀ {P} → Dec P → Bool
decToBool (yes _) = true
decToBool (no _) = false
True : ∀ {P} → Dec P → Set
True Q = T (decToBool Q)
False : ∀ {P} → Dec P → Set
False Q = T (not (decToBool Q))
witnessToTruth : ∀ {P} {Q : Dec P} → True Q → P
witnessToTruth {Q = yes p} _ = p
witnessToTruth {Q = no _} ()
map : ∀ {P Q} → P ⇔ Q → Dec P → Dec Q
map eq (yes p) = yes (proj₁ eq p)
map eq (no ¬p) = no (¬p ∘ proj₂ eq)
fromYes : ∀ {P} → P → Dec P → P
fromYes _ (yes p) = p
fromYes p (no ¬p) = ⊥-elim (¬p p)
fromYes-map-commute :
∀ {P Q p q} (eq : P ⇔ Q) (d : Dec P) →
fromYes q (map eq d) ≡ proj₁ eq (fromYes p d)
fromYes-map-commute _ (yes p) = refl
fromYes-map-commute {p = p} _ (no ¬p) = ⊥-elim (¬p p)
|
{
"alphanum_fraction": 0.5460069444,
"avg_line_length": 28.0975609756,
"ext": "agda",
"hexsha": "67bdbb7341d11a1fe122ceeb9b587ce4cf1691e1",
"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/Relation/Nullary/Decidable.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/Relation/Nullary/Decidable.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/Relation/Nullary/Decidable.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": 371,
"size": 1152
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Induction.WellFounded where
open import Cubical.Foundations.Everything
Rel : ∀{ℓ} → Type ℓ → ∀ ℓ' → Type _
Rel A ℓ = A → A → Type ℓ
module _ {ℓ ℓ'} {A : Type ℓ} (_<_ : A → A → Type ℓ') where
WFRec : ∀{ℓ''} → (A → Type ℓ'') → A → Type _
WFRec P x = ∀ y → y < x → P y
data Acc (x : A) : Type (ℓ-max ℓ ℓ') where
acc : WFRec Acc x → Acc x
WellFounded : Type _
WellFounded = ∀ x → Acc x
module _ {ℓ ℓ'} {A : Type ℓ} {_<_ : A → A → Type ℓ'} where
isPropAcc : ∀ x → isProp (Acc _<_ x)
isPropAcc x (acc p) (acc q)
= λ i → acc (λ y y<x → isPropAcc y (p y y<x) (q y y<x) i)
access : ∀{x} → Acc _<_ x → WFRec _<_ (Acc _<_) x
access (acc r) = r
private
wfi : ∀{ℓ''} {P : A → Type ℓ''}
→ ∀ x → (wf : Acc _<_ x)
→ (∀ x → (∀ y → y < x → P y) → P x)
→ P x
wfi x (acc p) e = e x λ y y<x → wfi y (p y y<x) e
module WFI (wf : WellFounded _<_) where
module _ {ℓ''} {P : A → Type ℓ''} (e : ∀ x → (∀ y → y < x → P y) → P x) where
private
wfi-compute : ∀ x ax → wfi x ax e ≡ e x (λ y _ → wfi y (wf y) e)
wfi-compute x (acc p)
= λ i → e x (λ y y<x → wfi y (isPropAcc y (p y y<x) (wf y) i) e)
induction : ∀ x → P x
induction x = wfi x (wf x) e
induction-compute : ∀ x → induction x ≡ (e x λ y _ → induction y)
induction-compute x = wfi-compute x (wf x)
|
{
"alphanum_fraction": 0.4944055944,
"avg_line_length": 29.7916666667,
"ext": "agda",
"hexsha": "a442f007cf5eb7d8f5facd7f2b508d3488f590d0",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Induction/WellFounded.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/Induction/WellFounded.agda",
"max_line_length": 81,
"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/Induction/WellFounded.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 590,
"size": 1430
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
open import Cubical.Core.Everything
open import Cubical.Algebra.Monoid
module Cubical.Algebra.Monoid.Construct.Opposite {ℓ} (M : Monoid ℓ) where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Prod using (_,_)
open Monoid M
import Cubical.Algebra.Semigroup.Construct.Opposite semigroup as OpSemigroup
open OpSemigroup public hiding (Op-isSemigroup; Sᵒᵖ)
•ᵒᵖ-identityˡ : LeftIdentity ε _•ᵒᵖ_
•ᵒᵖ-identityˡ _ = identityʳ _
•ᵒᵖ-identityʳ : RightIdentity ε _•ᵒᵖ_
•ᵒᵖ-identityʳ _ = identityˡ _
•ᵒᵖ-identity : Identity ε _•ᵒᵖ_
•ᵒᵖ-identity = •ᵒᵖ-identityˡ , •ᵒᵖ-identityʳ
Op-isMonoid : IsMonoid Carrier _•ᵒᵖ_ ε
Op-isMonoid = record
{ isSemigroup = OpSemigroup.Op-isSemigroup
; identity = •ᵒᵖ-identity
}
Mᵒᵖ : Monoid ℓ
Mᵒᵖ = record { isMonoid = Op-isMonoid }
|
{
"alphanum_fraction": 0.75,
"avg_line_length": 24.7058823529,
"ext": "agda",
"hexsha": "9e237d62d498a014f226a2e59b365c9cf9859d3b",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bijan2005/univalent-foundations",
"max_forks_repo_path": "Cubical/Algebra/Monoid/Construct/Opposite.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bijan2005/univalent-foundations",
"max_issues_repo_path": "Cubical/Algebra/Monoid/Construct/Opposite.agda",
"max_line_length": 76,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bijan2005/univalent-foundations",
"max_stars_repo_path": "Cubical/Algebra/Monoid/Construct/Opposite.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 351,
"size": 840
}
|
module Structure.Operator.Vector.LinearMap.Equiv where
open import Functional
open import Function.Proofs
open import Logic.Predicate
import Lvl
open import Structure.Category
open import Structure.Function
open import Structure.Function.Multi
open import Structure.Operator.Properties
open import Structure.Operator.Vector.LinearMap
open import Structure.Operator.Vector.LinearMaps
open import Structure.Operator.Vector.Proofs
open import Structure.Operator.Vector
open import Structure.Relator.Properties
open import Structure.Setoid
open import Syntax.Transitivity
open import Type
private variable ℓ ℓᵥ ℓᵥₗ ℓᵥᵣ ℓᵥ₁ ℓᵥ₂ ℓᵥ₃ ℓₛ ℓᵥₑ ℓᵥₑₗ ℓᵥₑᵣ ℓᵥₑ₁ ℓᵥₑ₂ ℓᵥₑ₃ ℓₛₑ : Lvl.Level
private variable V Vₗ Vᵣ V₁ V₂ V₃ S : Type{ℓ}
private variable _+ᵥ_ _+ᵥₗ_ _+ᵥᵣ_ _+ᵥ₁_ _+ᵥ₂_ _+ᵥ₃_ : V → V → V
private variable _⋅ₛᵥ_ _⋅ₛᵥₗ_ _⋅ₛᵥᵣ_ _⋅ₛᵥ₁_ _⋅ₛᵥ₂_ _⋅ₛᵥ₃_ : S → V → V
private variable _+ₛ_ _⋅ₛ_ : S → S → S
private variable f g : Vₗ → Vᵣ
open VectorSpace ⦃ … ⦄
module _ ⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄ where
private variable A B : VectorSpaceVObject {ℓᵥ}{_}{ℓᵥₑ}{ℓₛₑ} ⦃ equiv-S ⦄ (_+ₛ_)(_⋅ₛ_)
[_→ˡⁱⁿᵉᵃʳᵐᵃᵖ_]-equiv : Equiv(A →ˡⁱⁿᵉᵃʳᵐᵃᵖ B)
Equiv._≡_ [_→ˡⁱⁿᵉᵃʳᵐᵃᵖ_]-equiv ([∃]-intro f) ([∃]-intro g) = {!!}
Equiv.equivalence [_→ˡⁱⁿᵉᵃʳᵐᵃᵖ_]-equiv = {!!}
|
{
"alphanum_fraction": 0.7505995204,
"avg_line_length": 35.7428571429,
"ext": "agda",
"hexsha": "1381f7b8dcc22b2247e7adfe82169e2dd7df4754",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Structure/Operator/Vector/Equiv.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Structure/Operator/Vector/Equiv.agda",
"max_line_length": 89,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Structure/Operator/Vector/Equiv.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": 643,
"size": 1251
}
|
data D (X : Set) : Set
data D (X : Set) where
-- Should complain about repeated type signature for X
|
{
"alphanum_fraction": 0.6730769231,
"avg_line_length": 14.8571428571,
"ext": "agda",
"hexsha": "c61eae3f5236cc970e1f0e97cee4907b25d3768f",
"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/Issue1886.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/Issue1886.agda",
"max_line_length": 54,
"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/Issue1886.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": 30,
"size": 104
}
|
------------------------------------------------------------------------
-- Streams
------------------------------------------------------------------------
module Stream where
open import Codata.Musical.Stream public renaming (_∷_ to _≺_)
|
{
"alphanum_fraction": 0.3016528926,
"avg_line_length": 30.25,
"ext": "agda",
"hexsha": "bf7182a271a88226a2581733884b0838d5955ec5",
"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.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.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.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": 30,
"size": 242
}
|
open import Data.Product using ( _×_ ; _,_ )
open import Relation.Unary using ( _∈_ )
open import Web.Semantic.DL.ABox using ( ABox ; ε ; _,_ ; _∼_ ; _∈₁_ ; _∈₂_ )
open import Web.Semantic.DL.ABox.Interp using ( ⌊_⌋ ; ind )
open import Web.Semantic.DL.ABox.Model using ( _⊨a_ )
open import Web.Semantic.DL.Concept.Model using ( ⟦⟧₁-resp-≈ )
open import Web.Semantic.DL.Concept.Skolemization using ( CSkolems ; cskolem ; cskolem-sound )
open import Web.Semantic.DL.FOL using ( Formula ; true ; _∧_ ; _∈₁_ ; _∈₂_ ; _∼_ )
open import Web.Semantic.DL.FOL.Model using ( _⊨f_ )
open import Web.Semantic.DL.Role.Skolemization using ( rskolem ; rskolem-sound )
open import Web.Semantic.DL.Role.Model using ( ⟦⟧₂-resp-≈ )
open import Web.Semantic.DL.Signature using ( Signature )
open import Web.Semantic.Util using ( True ; tt )
module Web.Semantic.DL.ABox.Skolemization {Σ : Signature} {X : Set} where
askolem : ∀ {Δ} → (X → Δ) → ABox Σ X → Formula Σ Δ
askolem i ε = true
askolem i (A , B) = (askolem i A) ∧ (askolem i B)
askolem i (x ∼ y) = i x ∼ i y
askolem i (x ∈₁ c) = i x ∈₁ c
askolem i ((x , y) ∈₂ r) = (i x , i y) ∈₂ r
askolem-sound : ∀ I A → (⌊ I ⌋ ⊨f askolem (ind I) A) → (I ⊨a A)
askolem-sound I ε _ = tt
askolem-sound I (A , B) (I⊨A , I⊨B) = (askolem-sound I A I⊨A , askolem-sound I B I⊨B)
askolem-sound I (x ∼ y) I⊨x∼y = I⊨x∼y
askolem-sound I (x ∈₁ c) I⊨x∈c = I⊨x∈c
askolem-sound I ((x , y) ∈₂ r) I⊨xy∈r = I⊨xy∈r
|
{
"alphanum_fraction": 0.6490857947,
"avg_line_length": 47.4,
"ext": "agda",
"hexsha": "f62b76fd7a8fd6734497adf5db0b29185b2a0437",
"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": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bblfish/agda-web-semantic",
"max_forks_repo_path": "src/Web/Semantic/DL/ABox/Skolemization.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057",
"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": "bblfish/agda-web-semantic",
"max_issues_repo_path": "src/Web/Semantic/DL/ABox/Skolemization.agda",
"max_line_length": 94,
"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/ABox/Skolemization.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": 618,
"size": 1422
}
|
module Control.Monad.Transformer where
open import Prelude
record Transformer {a b} (T : (Set a → Set b) → (Set a → Set b)) : Set (lsuc a ⊔ lsuc b) where
field
lift : {M : Set a → Set b} {{_ : Monad M}} {A : Set a} → M A → T M A
open Transformer {{...}} public
|
{
"alphanum_fraction": 0.594095941,
"avg_line_length": 24.6363636364,
"ext": "agda",
"hexsha": "b115b753d9a1fcf67a6f86984ef718e2cc58d241",
"lang": "Agda",
"max_forks_count": 24,
"max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z",
"max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "L-TChen/agda-prelude",
"max_forks_repo_path": "src/Control/Monad/Transformer.agda",
"max_issues_count": 59,
"max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "L-TChen/agda-prelude",
"max_issues_repo_path": "src/Control/Monad/Transformer.agda",
"max_line_length": 94,
"max_stars_count": 111,
"max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "L-TChen/agda-prelude",
"max_stars_repo_path": "src/Control/Monad/Transformer.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z",
"num_tokens": 92,
"size": 271
}
|
{-# OPTIONS --without-K #-}
module Computability.Enumeration.Base where
open import Computability.Prelude
open import Computability.Function
record Enumerable (A : Set) : Set where
field
enum : ℕ → A
bijective : Bijective enum
open Enumerable
ℕ-Enumerable : Enumerable ℕ
enum ℕ-Enumerable n = n
proj₁ (bijective ℕ-Enumerable) eq = eq
proj₁ (proj₂ (bijective ℕ-Enumerable) y) = y
proj₂ (proj₂ (bijective ℕ-Enumerable) y) = refl
|
{
"alphanum_fraction": 0.7352941176,
"avg_line_length": 22.1,
"ext": "agda",
"hexsha": "0a5e6919971f177efdc10af089193744353d26d7",
"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": "1b5cf338eb0adb90c1897383e05251ddd954efff",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "jesyspa/computability-in-agda",
"max_forks_repo_path": "Computability/Enumeration/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b5cf338eb0adb90c1897383e05251ddd954efff",
"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": "jesyspa/computability-in-agda",
"max_issues_repo_path": "Computability/Enumeration/Base.agda",
"max_line_length": 47,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "1b5cf338eb0adb90c1897383e05251ddd954efff",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "jesyspa/computability-in-agda",
"max_stars_repo_path": "Computability/Enumeration/Base.agda",
"max_stars_repo_stars_event_max_datetime": "2021-04-30T11:15:51.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-19T15:51:22.000Z",
"num_tokens": 122,
"size": 442
}
|
{-# OPTIONS --rewriting #-}
open import Common.Prelude
open import Common.Equality
{-# BUILTIN REWRITE _≡_ #-}
postulate
f g : Nat → Nat
f-zero : f zero ≡ g zero
f-suc : ∀ n → f n ≡ g n → f (suc n) ≡ g (suc n)
r : (n : Nat) → f n ≡ g n
r zero = f-zero
r (suc n) = f-suc n refl
where
rn : f n ≡ g n
rn = r n
{-# REWRITE rn #-}
|
{
"alphanum_fraction": 0.5282485876,
"avg_line_length": 17.7,
"ext": "agda",
"hexsha": "cead70498540bf95616158f76e2643756cac4eb9",
"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/RewritingRuleInWhereBlock.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/RewritingRuleInWhereBlock.agda",
"max_line_length": 50,
"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/RewritingRuleInWhereBlock.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": 141,
"size": 354
}
|
{-# OPTIONS --cubical-compatible #-}
module Common.Equality where
open import Agda.Builtin.Equality public
open import Common.Level
subst : ∀ {a p}{A : Set a}(P : A → Set p){x y : A} → x ≡ y → P x → P y
subst P refl t = t
cong : ∀ {a b}{A : Set a}{B : Set b}(f : A → B){x y : A} → x ≡ y → f x ≡ f y
cong f refl = refl
sym : ∀ {a}{A : Set a}{x y : A} → x ≡ y → y ≡ x
sym refl = refl
trans : ∀ {a}{A : Set a}{x y z : A} → x ≡ y → y ≡ z → x ≡ z
trans refl refl = refl
|
{
"alphanum_fraction": 0.5319148936,
"avg_line_length": 26.1111111111,
"ext": "agda",
"hexsha": "c05635fb1ccd42746e7ba5cf2a0442e54f405c3c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "KDr2/agda",
"max_forks_repo_path": "test/Common/Equality.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "KDr2/agda",
"max_issues_repo_path": "test/Common/Equality.agda",
"max_line_length": 76,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "KDr2/agda",
"max_stars_repo_path": "test/Common/Equality.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 192,
"size": 470
}
|
module _ {T : Type{ℓₒ}} ⦃ equiv : Equiv{ℓₑ}(T) ⦄ where
instance
PredSet-setLike : SetLike{C = PredSet{ℓ}(T) ⦃ equiv ⦄} (_∈_)
SetLike._⊆_ PredSet-setLike = _⊆_
SetLike._≡_ PredSet-setLike = _≡_
SetLike.[⊆]-membership PredSet-setLike = [↔]-intro intro _⊆_.proof
SetLike.[≡]-membership PredSet-setLike = [↔]-intro intro _≡_.proof
instance
PredSet-emptySet : SetLike.EmptySet{C = PredSet{ℓ}(T) ⦃ equiv ⦄} (_∈_)
SetLike.EmptySet.∅ PredSet-emptySet = ∅
SetLike.EmptySet.membership PredSet-emptySet ()
instance
PredSet-universalSet : SetLike.UniversalSet{C = PredSet{ℓ}(T) ⦃ equiv ⦄} (_∈_)
SetLike.UniversalSet.𝐔 PredSet-universalSet = 𝐔
SetLike.UniversalSet.membership PredSet-universalSet = record {}
instance
PredSet-unionOperator : SetLike.UnionOperator{C = PredSet{ℓ}(T) ⦃ equiv ⦄} (_∈_)
SetLike.UnionOperator._∪_ PredSet-unionOperator = _∪_
SetLike.UnionOperator.membership PredSet-unionOperator = [↔]-intro id id
instance
PredSet-intersectionOperator : SetLike.IntersectionOperator{C = PredSet{ℓ}(T) ⦃ equiv ⦄} (_∈_)
SetLike.IntersectionOperator._∩_ PredSet-intersectionOperator = _∩_
SetLike.IntersectionOperator.membership PredSet-intersectionOperator = [↔]-intro id id
instance
PredSet-complementOperator : SetLike.ComplementOperator{C = PredSet{ℓ}(T) ⦃ equiv ⦄} (_∈_)
SetLike.ComplementOperator.∁ PredSet-complementOperator = ∁_
SetLike.ComplementOperator.membership PredSet-complementOperator = [↔]-intro id id
module _ {T : Type{ℓ}} ⦃ equiv : Equiv{ℓ}(T) ⦄ where -- TODO: Levels in SetLike
instance
PredSet-mapFunction : SetLike.MapFunction{C₁ = PredSet{ℓ}(T) ⦃ equiv ⦄}{C₂ = PredSet{ℓ}(T) ⦃ equiv ⦄} (_∈_)(_∈_)
SetLike.MapFunction.map PredSet-mapFunction f = map f
SetLike.MapFunction.membership PredSet-mapFunction = [↔]-intro id id
instance
PredSet-unmapFunction : SetLike.UnmapFunction{C₁ = PredSet{ℓ}(T) ⦃ equiv ⦄}{C₂ = PredSet{ℓ}(T) ⦃ equiv ⦄} (_∈_)(_∈_)
SetLike.UnmapFunction.unmap PredSet-unmapFunction = unmap
SetLike.UnmapFunction.membership PredSet-unmapFunction = [↔]-intro id id
instance
PredSet-unapplyFunction : SetLike.UnapplyFunction{C = PredSet{ℓ}(T) ⦃ equiv ⦄} (_∈_) {O = T}
SetLike.UnapplyFunction.unapply PredSet-unapplyFunction = unapply
SetLike.UnapplyFunction.membership PredSet-unapplyFunction = [↔]-intro id id
instance
PredSet-filterFunction : SetLike.FilterFunction{C = PredSet{ℓ}(T) ⦃ equiv ⦄} (_∈_) {ℓ}{ℓ}
SetLike.FilterFunction.filter PredSet-filterFunction = filter
SetLike.FilterFunction.membership PredSet-filterFunction = [↔]-intro id id
{- TODO: SetLike is not general enough
module _ {T : Type{ℓ}} ⦃ equiv : Equiv{ℓ}(T) ⦄ where
instance
-- PredSet-bigUnionOperator : SetLike.BigUnionOperator{Cₒ = PredSet(PredSet(T) ⦃ {!!} ⦄) ⦃ {!!} ⦄} {Cᵢ = PredSet(T) ⦃ {!!} ⦄} (_∈_)(_∈_)
SetLike.BigUnionOperator.⋃ PredSet-bigUnionOperator = {!⋃!}
SetLike.BigUnionOperator.membership PredSet-bigUnionOperator = {!!}
-}
|
{
"alphanum_fraction": 0.6862871928,
"avg_line_length": 49.0793650794,
"ext": "agda",
"hexsha": "f86be87d64f01fd85ffe37d3b4e13bd083de6d1f",
"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": "Sets/ExtensionalPredicateSet/SetLike.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": "Sets/ExtensionalPredicateSet/SetLike.agda",
"max_line_length": 140,
"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": "Sets/ExtensionalPredicateSet/SetLike.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": 1080,
"size": 3092
}
|
{-# OPTIONS --cubical --safe #-}
module Cubical.Structures.CommRing where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Data.Sigma
open import Cubical.Foundations.SIP renaming (SNS-PathP to SNS)
open import Cubical.Structures.NAryOp
open import Cubical.Structures.Pointed
open import Cubical.Structures.Ring hiding (⟨_⟩)
private
variable
ℓ ℓ' : Level
comm-ring-axioms : (X : Type ℓ) (s : raw-ring-structure X) → Type ℓ
comm-ring-axioms X (_+_ , ₁ , _·_) = (ring-axioms X (_+_ , ₁ , _·_)) ×
((x y : X) → x · y ≡ y · x)
comm-ring-structure : Type ℓ → Type ℓ
comm-ring-structure = add-to-structure raw-ring-structure comm-ring-axioms
CommRing : Type (ℓ-suc ℓ)
CommRing {ℓ} = TypeWithStr ℓ comm-ring-structure
comm-ring-iso : StrIso comm-ring-structure ℓ
comm-ring-iso = add-to-iso (join-iso (nAryFunIso 2) (join-iso pointed-iso (nAryFunIso 2))) comm-ring-axioms
comm-ring-axioms-isProp : (X : Type ℓ) (s : raw-ring-structure X) → isProp (comm-ring-axioms X s)
comm-ring-axioms-isProp X (_·_ , ₀ , _+_) = isPropΣ (ring-axioms-isProp X (_·_ , ₀ , _+_))
λ ((((isSetX , _) , _) , _) , _) → isPropΠ2 λ _ _ → isSetX _ _
comm-ring-is-SNS : SNS {ℓ} comm-ring-structure comm-ring-iso
comm-ring-is-SNS = add-axioms-SNS _ comm-ring-axioms-isProp raw-ring-is-SNS
CommRingPath : (M N : CommRing {ℓ}) → (M ≃[ comm-ring-iso ] N) ≃ (M ≡ N)
CommRingPath = SIP comm-ring-is-SNS
-- CommRing is Ring
CommRing→Ring : CommRing {ℓ} → Ring
CommRing→Ring (R , str , isRing , ·comm) = R , str , isRing
-- CommRing Extractors
⟨_⟩ : CommRing {ℓ} → Type ℓ
⟨ R , _ ⟩ = R
module _ (R : CommRing {ℓ}) where
commring+-operation = ring+-operation (CommRing→Ring R)
commring-is-set = ring-is-set (CommRing→Ring R)
commring+-assoc = ring+-assoc (CommRing→Ring R)
commring+-id = ring+-id (CommRing→Ring R)
commring+-rid = ring+-rid (CommRing→Ring R)
commring+-lid = ring+-lid (CommRing→Ring R)
commring+-inv = ring+-inv (CommRing→Ring R)
commring+-rinv = ring+-rinv (CommRing→Ring R)
commring+-linv = ring+-linv (CommRing→Ring R)
commring+-comm = ring+-comm (CommRing→Ring R)
commring·-operation = ring·-operation (CommRing→Ring R)
commring·-assoc = ring·-assoc (CommRing→Ring R)
commring·-id = ring·-id (CommRing→Ring R)
commring·-rid = ring·-rid (CommRing→Ring R)
commring·-lid = ring·-lid (CommRing→Ring R)
commring-ldist = ring-ldist (CommRing→Ring R)
commring-rdist = ring-rdist (CommRing→Ring R)
module commring-operation-syntax where
commring+-operation-syntax : (R : CommRing {ℓ}) → ⟨ R ⟩ → ⟨ R ⟩ → ⟨ R ⟩
commring+-operation-syntax R = commring+-operation R
infixr 14 commring+-operation-syntax
syntax commring+-operation-syntax G x y = x +⟨ G ⟩ y
commring·-operation-syntax : (R : CommRing {ℓ}) → ⟨ R ⟩ → ⟨ R ⟩ → ⟨ R ⟩
commring·-operation-syntax R = commring·-operation R
infixr 18 commring·-operation-syntax
syntax commring·-operation-syntax G x y = x ·⟨ G ⟩ y
open commring-operation-syntax
commring-comm : (R : CommRing {ℓ}) (x y : ⟨ R ⟩) → x ·⟨ R ⟩ y ≡ y ·⟨ R ⟩ x
commring-comm (_ , _ , _ , P) = P
-- CommRing ·syntax
module commring-·syntax (R : CommRing {ℓ}) where
open ring-·syntax (CommRing→Ring R) public
|
{
"alphanum_fraction": 0.6587183308,
"avg_line_length": 30.5,
"ext": "agda",
"hexsha": "2350c23187375564eeae15a99e0d83beec363005",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cmester0/cubical",
"max_forks_repo_path": "Cubical/Structures/CommRing.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cmester0/cubical",
"max_issues_repo_path": "Cubical/Structures/CommRing.agda",
"max_line_length": 107,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cmester0/cubical",
"max_stars_repo_path": "Cubical/Structures/CommRing.agda",
"max_stars_repo_stars_event_max_datetime": "2020-03-23T23:52:11.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-03-23T23:52:11.000Z",
"num_tokens": 1163,
"size": 3355
}
|
{-# OPTIONS --cubical #-}
open import Cubical.Core.Glue
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.Nat
open import Cubical.Data.Empty
open import Cubical.Data.Unit
open import Cubical.Data.Prod
open import Cubical.Data.BinNat
open import Cubical.Data.Bool
open import Cubical.Relation.Nullary
open import Direction
module NNat where
-- much of this is based directly on the
-- BinNat module in the Cubical Agda library
data BNat : Type₀ where
b0 : BNat
b1 : BNat
x0 : BNat → BNat
x1 : BNat → BNat
sucBNat : BNat → BNat
sucBNat b0 = b1
sucBNat b1 = x0 b1
sucBNat (x0 bs) = x1 bs
sucBNat (x1 bs) = x0 (sucBNat bs)
BNat→ℕ : BNat → ℕ
BNat→ℕ b0 = 0
BNat→ℕ b1 = 1
BNat→ℕ (x0 x) = doubleℕ (BNat→ℕ x)
BNat→ℕ (x1 x) = suc (doubleℕ (BNat→ℕ x))
-- BNat→Binℕ : BNat → Binℕ
-- BNat→Binℕ pos0 = binℕ0
-- BNat→Binℕ pos1 = binℕpos pos1
-- BNat→Binℕ (x0 x) = {!binℕpos (x0 binℕpos (BNat→Binℕ x))!}
-- BNat→Binℕ (x1 x) = {!!}
BNat→ℕsucBNat : (b : BNat) → BNat→ℕ (sucBNat b) ≡ suc (BNat→ℕ b)
BNat→ℕsucBNat b0 = refl
BNat→ℕsucBNat b1 = refl
BNat→ℕsucBNat (x0 b) = refl
BNat→ℕsucBNat (x1 b) = λ i → doubleℕ (BNat→ℕsucBNat b i)
ℕ→BNat : ℕ → BNat
ℕ→BNat zero = b0
ℕ→BNat (suc zero) = b1
ℕ→BNat (suc (suc n)) = sucBNat (ℕ→BNat (suc n))
ℕ→BNatSuc : ∀ n → ℕ→BNat (suc n) ≡ sucBNat (ℕ→BNat n)
ℕ→BNatSuc zero = refl
ℕ→BNatSuc (suc n) = refl
bNatInd : {P : BNat → Type₀} → P b0 → ((b : BNat) → P b → P (sucBNat b)) → (b : BNat) → P b
-- prove later...
BNat→ℕ→BNat : (b : BNat) → ℕ→BNat (BNat→ℕ b) ≡ b
BNat→ℕ→BNat b = bNatInd refl hs b
where
hs : (b : BNat) → ℕ→BNat (BNat→ℕ b) ≡ b → ℕ→BNat (BNat→ℕ (sucBNat b)) ≡ sucBNat b
hs b hb =
ℕ→BNat (BNat→ℕ (sucBNat b))
≡⟨ cong ℕ→BNat (BNat→ℕsucBNat b) ⟩
ℕ→BNat (suc (BNat→ℕ b))
≡⟨ ℕ→BNatSuc (BNat→ℕ b) ⟩
sucBNat (ℕ→BNat (BNat→ℕ b))
≡⟨ cong sucBNat hb ⟩
sucBNat b
∎
ℕ→BNat→ℕ : (n : ℕ) → BNat→ℕ (ℕ→BNat n) ≡ n
ℕ→BNat→ℕ zero = refl
ℕ→BNat→ℕ (suc n) =
BNat→ℕ (ℕ→BNat (suc n))
≡⟨ cong BNat→ℕ (ℕ→BNatSuc n) ⟩
BNat→ℕ (sucBNat (ℕ→BNat n))
≡⟨ BNat→ℕsucBNat (ℕ→BNat n) ⟩
suc (BNat→ℕ (ℕ→BNat n))
≡⟨ cong suc (ℕ→BNat→ℕ n) ⟩
suc n
∎
BNat≃ℕ : BNat ≃ ℕ
BNat≃ℕ = isoToEquiv (iso BNat→ℕ ℕ→BNat ℕ→BNat→ℕ BNat→ℕ→BNat)
BNat≡ℕ : BNat ≡ ℕ
BNat≡ℕ = ua BNat≃ℕ
open NatImpl
NatImplBNat : NatImpl BNat
z NatImplBNat = b0
s NatImplBNat = sucBNat
--
data np (r : ℕ) : Type₀ where
bp : DirNum r → np r
zp : ∀ (d d′ : DirNum r) → bp d ≡ bp d′
xp : DirNum r → np r → np r
sucnp : ∀ {r} → np r → np r
sucnp {zero} (bp tt) = xp tt (bp tt)
sucnp {zero} (zp tt tt i) = xp tt (bp tt)
sucnp {zero} (xp tt n) = xp tt (sucnp n)
sucnp {suc r} (bp d) = xp (one-n (suc r)) (bp d)
sucnp {suc r} (zp d d′ i) = xp (one-n (suc r)) (zp d d′ i)
sucnp {suc r} (xp d n) with max? d
... | no _ = xp (next d) n
... | yes _ = xp (zero-n (suc r)) (sucnp n)
np→ℕ : (r : ℕ) (x : np r) → ℕ
np→ℕ r (bp x) = 0
np→ℕ r (zp d d′ i) = 0
np→ℕ zero (xp x x₁) = suc (np→ℕ zero x₁)
np→ℕ (suc r) (xp x x₁) = sucn (DirNum→ℕ x) (doublesℕ (suc r) (np→ℕ (suc r) x₁))
ℕ→np : (r : ℕ) → (n : ℕ) → np r
ℕ→np r zero = bp (zero-n r)
ℕ→np zero (suc n) = xp tt (ℕ→np zero n)
ℕ→np (suc r) (suc n) = sucnp (ℕ→np (suc r) n)
---- generalize bnat:
data N (r : ℕ) : Type₀ where
bn : DirNum r → N r
xr : DirNum r → N r → N r
-- should define induction principle for N r
-- we have 2ⁿ "unary" constructors, analogous to BNat with 2¹ (b0 and b1)
-- rename n to r
-- this likely introduces inefficiencies compared
-- to BinNat, with the max? check etc.
sucN : ∀ {n} → N n → N n
sucN {zero} (bn tt) = xr tt (bn tt)
sucN {zero} (xr tt x) = xr tt (sucN x)
sucN {suc n} (bn (↓ , ds)) = (bn (↑ , ds))
sucN {suc n} (bn (↑ , ds)) with max? ds
... | no _ = (bn (↓ , next ds))
... | yes _ = xr (zero-n (suc n)) (bn (one-n (suc n)))
sucN {suc n} (xr d x) with max? d
... | no _ = xr (next d) x
... | yes _ = xr (zero-n (suc n)) (sucN x)
sucnN : {r : ℕ} → (n : ℕ) → (N r → N r)
sucnN n = iter n sucN
doubleN : (r : ℕ) → N r → N r
doubleN zero (bn tt) = bn tt
doubleN zero (xr d x) = sucN (sucN (doubleN zero x))
doubleN (suc r) (bn x) with zero-n? x
... | yes _ = bn x
-- bad:
... | no _ = caseBool (bn (doubleDirNum (suc r) x)) (xr (zero-n (suc r)) (bn x)) (doubleable-n? x)
-- ... | no _ | doubleable = {!bn (doubleDirNum x)!}
-- ... | no _ | notdoubleable = xr (zero-n (suc r)) (bn x)
doubleN (suc r) (xr x x₁) = sucN (sucN (doubleN (suc r) x₁))
doublesN : (r : ℕ) → ℕ → N r → N r
doublesN r zero m = m
doublesN r (suc n) m = doublesN r n (doubleN r m)
N→ℕ : (r : ℕ) (x : N r) → ℕ
N→ℕ zero (bn tt) = zero
N→ℕ zero (xr tt x) = suc (N→ℕ zero x)
N→ℕ (suc r) (bn x) = DirNum→ℕ x
N→ℕ (suc r) (xr d x) = sucn (DirNum→ℕ d) (doublesℕ (suc r) (N→ℕ (suc r) x))
N→ℕsucN : (r : ℕ) (x : N r) → N→ℕ r (sucN x) ≡ suc (N→ℕ r x)
N→ℕsucN zero (bn tt) = refl
N→ℕsucN zero (xr tt x) =
suc (N→ℕ zero (sucN x))
≡⟨ cong suc (N→ℕsucN zero x) ⟩
suc (suc (N→ℕ zero x))
∎
N→ℕsucN (suc r) (bn (↓ , d)) = refl
N→ℕsucN (suc r) (bn (↑ , d)) with max? d
... | no d≠max =
doubleℕ (DirNum→ℕ (next d))
≡⟨ cong doubleℕ (next≡suc r d d≠max) ⟩
doubleℕ (suc (DirNum→ℕ d))
∎
... | yes d≡max = -- this can probably be shortened by not reducing down to zero
sucn (doubleℕ (DirNum→ℕ (zero-n r)))
(doublesℕ r (suc (suc (doubleℕ (doubleℕ (DirNum→ℕ (zero-n r)))))))
≡⟨ cong (λ x → sucn (doubleℕ x) (doublesℕ r (suc (suc (doubleℕ (doubleℕ x)))))) (zero-n→0 {r}) ⟩
sucn (doubleℕ zero) (doublesℕ r (suc (suc (doubleℕ (doubleℕ zero)))))
≡⟨ refl ⟩
doublesℕ (suc r) (suc zero) -- 2^(r+1)
≡⟨ sym (doubleDoubles r 1) ⟩
doubleℕ (doublesℕ r (suc zero)) --2*2^r
≡⟨ sym (sucPred (doubleℕ (doublesℕ r (suc zero))) (doubleDoublesOne≠0 r)) ⟩
suc (predℕ (doubleℕ (doublesℕ r (suc zero))))
≡⟨ cong suc (sym (sucPred (predℕ (doubleℕ (doublesℕ r (suc zero)))) (predDoubleDoublesOne≠0 r))) ⟩
suc (suc (predℕ (predℕ (doubleℕ (doublesℕ r (suc zero))))))
≡⟨ cong (λ x → suc (suc x)) (sym (doublePred (doublesℕ r (suc zero)))) ⟩
suc (suc (doubleℕ (predℕ (doublesℕ r (suc zero)))))
≡⟨ cong (λ x → suc (suc (doubleℕ x))) (sym (maxr≡pred2ʳ r d d≡max)) ⟩
suc (suc (doubleℕ (DirNum→ℕ d))) -- 2*(2^r - 1) + 2 = 2^(r+1) - 2 + 2 = 2^(r+1)
∎
N→ℕsucN (suc r) (xr (↓ , d) x) = refl
N→ℕsucN (suc r) (xr (↑ , d) x) with max? d
... | no d≠max =
sucn (doubleℕ (DirNum→ℕ (next d)))
(doublesℕ r (doubleℕ (N→ℕ (suc r) x)))
≡⟨ cong (λ y → sucn (doubleℕ y) (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))) (next≡suc r d d≠max) ⟩
sucn (doubleℕ (suc (DirNum→ℕ d)))
(doublesℕ r (doubleℕ (N→ℕ (suc r) x)))
≡⟨ refl ⟩
suc
(suc
(iter (doubleℕ (DirNum→ℕ d)) suc
(doublesℕ r (doubleℕ (N→ℕ (suc r) x)))))
∎
... | yes d≡max =
sucn (doubleℕ (DirNum→ℕ (zero-n r)))
(doublesℕ r (doubleℕ (N→ℕ (suc r) (sucN x))))
≡⟨ cong (λ z → sucn (doubleℕ z) (doublesℕ r (doubleℕ (N→ℕ (suc r) (sucN x))))) (zero-n≡0 {r}) ⟩
sucn (doubleℕ zero)
(doublesℕ r (doubleℕ (N→ℕ (suc r) (sucN x))))
≡⟨ refl ⟩
doublesℕ r (doubleℕ (N→ℕ (suc r) (sucN x)))
≡⟨ cong (λ x → doublesℕ r (doubleℕ x)) (N→ℕsucN (suc r) x) ⟩
doublesℕ r (doubleℕ (suc (N→ℕ (suc r) x)))
≡⟨ refl ⟩
doublesℕ r (suc (suc (doubleℕ (N→ℕ (suc r) x)))) -- 2^r * (2x + 2) = 2^(r+1)x + 2^(r+1)
≡⟨ doublesSucSuc r (doubleℕ (N→ℕ (suc r) x)) ⟩
sucn (doublesℕ (suc r) 1) -- _ + 2^(r+1)
(doublesℕ (suc r) (N→ℕ (suc r) x)) -- 2^(r+1)x + 2^(r+1)
≡⟨ H r (doublesℕ (suc r) (N→ℕ (suc r) x)) ⟩
suc
(suc
(sucn (doubleℕ (predℕ (doublesℕ r 1))) -- _ + 2(2^r - 1) + 2
(doublesℕ (suc r) (N→ℕ (suc r) x))))
≡⟨ refl ⟩
suc
(suc
(sucn (doubleℕ (predℕ (doublesℕ r 1)))
(doublesℕ r (doubleℕ (N→ℕ (suc r) x)))))
≡⟨ cong (λ z → suc (suc (sucn (doubleℕ z) (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))))) (sym (max→ℕ r)) ⟩
suc
(suc
(sucn (doubleℕ (DirNum→ℕ (max-n r)))
(doublesℕ r (doubleℕ (N→ℕ (suc r) x)))))
≡⟨ cong (λ z → suc (suc (sucn (doubleℕ (DirNum→ℕ z)) (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))))) (sym (d≡max)) ⟩
suc
(suc
(sucn (doubleℕ (DirNum→ℕ d))
(doublesℕ r (doubleℕ (N→ℕ (suc r) x))))) -- (2^r*2x + (2*(2^r - 1))) + 2 = 2^(r+1)x + 2^(r+1)
∎
where
H : (n m : ℕ) → sucn (doublesℕ (suc n) 1) m ≡ suc (suc (sucn (doubleℕ (predℕ (doublesℕ n 1))) m))
H zero m = refl
H (suc n) m =
sucn (doublesℕ n 4) m
≡⟨ cong (λ z → sucn z m) (doublesSucSuc n 2) ⟩
sucn (sucn (doublesℕ (suc n) 1) (doublesℕ n 2)) m
≡⟨ refl ⟩
sucn (sucn (doublesℕ n 2) (doublesℕ n 2)) m
≡⟨ {!!} ⟩
sucn (doubleℕ (doublesℕ n 2)) m
≡⟨ {!!} ⟩ {!!}
ℕ→N : (r : ℕ) → (n : ℕ) → N r
ℕ→N r zero = bn (zero-n r)
ℕ→N zero (suc n) = xr tt (ℕ→N zero n)
ℕ→N (suc r) (suc n) = sucN (ℕ→N (suc r) n)
ℕ→Nsuc : (r : ℕ) (n : ℕ) → ℕ→N r (suc n) ≡ sucN (ℕ→N r n)
ℕ→Nsuc r n = {!!}
ℕ→Nsucn : (r : ℕ) (n m : ℕ) → ℕ→N r (sucn n m) ≡ sucnN n (ℕ→N r m)
ℕ→Nsucn r n m = {!!}
-- NℕNlemma is actually a pretty important fact;
-- this is what allows the direct isomorphism of N and ℕ to go
-- without the need for an extra datatype, e.g. Pos for BinNat,
-- since each ℕ < 2^r maps to its "numeral" in N r.
-- should rename and move elsewhere.
numeral-next : (r : ℕ) (d : DirNum r) → N (suc r)
numeral-next r d = bn (embed-next r d)
--
NℕNlemma : (r : ℕ) (d : DirNum r) → ℕ→N r (DirNum→ℕ d) ≡ bn d
NℕNlemma zero tt = refl
NℕNlemma (suc r) (↓ , ds) =
ℕ→N (suc r) (doubleℕ (DirNum→ℕ ds))
≡⟨ {!!} ⟩ {!!}
NℕNlemma (suc r) (↑ , ds) = {!!}
N→ℕ→N : (r : ℕ) → (x : N r) → ℕ→N r (N→ℕ r x) ≡ x
N→ℕ→N zero (bn tt) = refl
N→ℕ→N zero (xr tt x) = cong (xr tt) (N→ℕ→N zero x)
N→ℕ→N (suc r) (bn (↓ , ds)) =
ℕ→N (suc r) (doubleℕ (DirNum→ℕ ds))
≡⟨ cong (λ x → ℕ→N (suc r) x) (double-lemma ds) ⟩
ℕ→N (suc r) (DirNum→ℕ {suc r} (↓ , ds))
≡⟨ NℕNlemma (suc r) (↓ , ds) ⟩
bn (↓ , ds)
∎
N→ℕ→N (suc r) (bn (↑ , ds)) =
sucN (ℕ→N (suc r) (doubleℕ (DirNum→ℕ ds)))
≡⟨ cong (λ x → sucN (ℕ→N (suc r) x)) (double-lemma ds) ⟩
sucN (ℕ→N (suc r) (DirNum→ℕ {suc r} (↓ , ds)))
≡⟨ cong sucN (NℕNlemma (suc r) (↓ , ds)) ⟩
sucN (bn (↓ , ds))
≡⟨ refl ⟩
bn (↑ , ds)
∎
N→ℕ→N (suc r) (xr (↓ , ds) x) =
ℕ→N (suc r)
(sucn (doubleℕ (DirNum→ℕ ds))
(doublesℕ r (doubleℕ (N→ℕ (suc r) x))))
≡⟨ cong (λ z → ℕ→N (suc r) (sucn z (doublesℕ r (doubleℕ (N→ℕ (suc r) x))))) (double-lemma ds) ⟩
ℕ→N (suc r)
(sucn (DirNum→ℕ {suc r} (↓ , ds))
(doublesℕ r (doubleℕ (N→ℕ (suc r) x))))
≡⟨ refl ⟩
ℕ→N (suc r)
(sucn (DirNum→ℕ {suc r} (↓ , ds))
(doublesℕ (suc r) (N→ℕ (suc r) x)))
≡⟨ ℕ→Nsucn (suc r) (DirNum→ℕ {suc r} (↓ , ds)) (doublesℕ (suc r) (N→ℕ (suc r) x)) ⟩
sucnN (DirNum→ℕ {suc r} (↓ , ds))
(ℕ→N (suc r) (doublesℕ (suc r) (N→ℕ (suc r) x)))
≡⟨ cong (λ z → sucnN (DirNum→ℕ {suc r} (↓ , ds)) z) (H (suc r) (suc r) (N→ℕ (suc r) x)) ⟩
sucnN (DirNum→ℕ {suc r} (↓ , ds))
(doublesN (suc r) (suc r) (ℕ→N (suc r) (N→ℕ (suc r) x)))
≡⟨ cong (λ z → sucnN (DirNum→ℕ {suc r} (↓ , ds)) (doublesN (suc r) (suc r) z)) (N→ℕ→N (suc r) x) ⟩
sucnN (DirNum→ℕ {suc r} (↓ , ds))
(doublesN (suc r) (suc r) x)
≡⟨ G (suc r) (↓ , ds) x snotz ⟩
xr (↓ , ds) x ∎
where
H : (r m n : ℕ) → ℕ→N r (doublesℕ m n) ≡ doublesN r m (ℕ→N r n)
H r m n = {!!}
G : (r : ℕ) (d : DirNum r) (x : N r) → ¬ (r ≡ 0) → sucnN (DirNum→ℕ {r} d) (doublesN r r x) ≡ xr d x
G zero d x 0≠0 = ⊥-elim (0≠0 refl)
G (suc r) d (bn x) r≠0 = {!!}
G (suc r) d (xr x x₁) r≠0 = {!!}
N→ℕ→N (suc r) (xr (↑ , ds) x) with max? ds
... | no ds≠max =
sucN
(ℕ→N (suc r)
(sucn (doubleℕ (DirNum→ℕ ds))
(doublesℕ r (doubleℕ (N→ℕ (suc r) x)))))
≡⟨ sym (ℕ→Nsuc (suc r)
(sucn (doubleℕ (DirNum→ℕ ds)) (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))))
⟩
ℕ→N (suc r)
(suc (sucn (doubleℕ (DirNum→ℕ ds)) (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))))
≡⟨ refl ⟩
ℕ→N (suc r)
(suc (sucn (doubleℕ (DirNum→ℕ ds)) (doublesℕ (suc r) (N→ℕ (suc r) x))))
≡⟨ cong (λ z → ℕ→N (suc r) z)
(sym (sucnsuc (doubleℕ (DirNum→ℕ ds)) (doublesℕ (suc r) (N→ℕ (suc r) x))))
⟩
ℕ→N (suc r)
(sucn (doubleℕ (DirNum→ℕ ds)) (suc (doublesℕ (suc r) (N→ℕ (suc r) x))))
≡⟨ ℕ→Nsucn (suc r) (doubleℕ (DirNum→ℕ ds)) (suc (doublesℕ (suc r) (N→ℕ (suc r) x))) ⟩
sucnN (doubleℕ (DirNum→ℕ ds)) (ℕ→N (suc r) (suc (doublesℕ (suc r) (N→ℕ (suc r) x))))
≡⟨ cong (λ z → sucnN (doubleℕ (DirNum→ℕ ds)) z)
(ℕ→Nsuc (suc r) (doublesℕ (suc r) (N→ℕ (suc r) x)))
⟩
-- (2^(r+1)*x + 1) + 2*ds
-- = 2*(2^r*x + ds) + 1
-- = 2*(
sucnN (doubleℕ (DirNum→ℕ ds)) (sucN (ℕ→N (suc r) (doublesℕ (suc r) (N→ℕ (suc r) x))))
≡⟨ {!!} ⟩ {!!}
... | yes ds≡max = {!!}
ℕ→N→ℕ : (r : ℕ) → (n : ℕ) → N→ℕ r (ℕ→N r n) ≡ n
ℕ→N→ℕ zero zero = refl
ℕ→N→ℕ (suc r) zero =
doubleℕ (DirNum→ℕ (zero-n r))
≡⟨ cong doubleℕ (zero-n≡0 {r}) ⟩
doubleℕ zero
≡⟨ refl ⟩
zero
∎
ℕ→N→ℕ zero (suc n) = cong suc (ℕ→N→ℕ zero n)
ℕ→N→ℕ (suc r) (suc n) =
N→ℕ (suc r) (sucN (ℕ→N (suc r) n))
≡⟨ N→ℕsucN (suc r) (ℕ→N (suc r) n) ⟩
suc (N→ℕ (suc r) (ℕ→N (suc r) n))
≡⟨ cong suc (ℕ→N→ℕ (suc r) n) ⟩
suc n
∎
N≃ℕ : (r : ℕ) → N r ≃ ℕ
N≃ℕ r = isoToEquiv (iso (N→ℕ r) (ℕ→N r) (ℕ→N→ℕ r) (N→ℕ→N r))
N≡ℕ : (r : ℕ) → N r ≡ ℕ
N≡ℕ r = ua (N≃ℕ r)
---- pos approach:
data NPos (n : ℕ) : Type₀ where
npos1 : NPos n
x⇀ : DirNum n → NPos n → NPos n
sucNPos : ∀ {n} → NPos n → NPos n
sucNPos {zero} npos1 = x⇀ tt npos1
sucNPos {zero} (x⇀ tt x) = x⇀ tt (sucNPos x)
sucNPos {suc n} npos1 = x⇀ (next (one-n (suc n))) npos1
sucNPos {suc n} (x⇀ d x) with (max? d)
... | (no _) = x⇀ (next d) x
... | (yes _) = x⇀ (zero-n (suc n)) (sucNPos x)
-- some examples for sanity check
2₂ : NPos 1
2₂ = x⇀ (↓ , tt) npos1
3₂ : NPos 1
3₂ = x⇀ (↑ , tt) npos1
4₂ : NPos 1
4₂ = x⇀ (↓ , tt) (x⇀ (↓ , tt) npos1)
2₄ : NPos 2
2₄ = x⇀ (↓ , (↑ , tt)) npos1 -- how does this make sense?
3₄ : NPos 2
3₄ = x⇀ (↑ , (↑ , tt)) npos1 -- how does this make sense?
-- sucnpos1≡x⇀one-n : ∀ {r} → sucNPos npos1 ≡ x⇀ (one-n r) npos1
-- sucnpos1≡x⇀one-n {zero} = refl
-- sucnpos1≡x⇀one-n {suc r} = {!!}
-- sucnposx⇀zero-n≡x⇀one-n : ∀ {r} {p} → sucNPos (x⇀ (zero-n r) p) ≡ x⇀ (one-n r) p
-- sucnposx⇀zero-n≡x⇀one-n {zero} {npos1} = {!!}
-- sucnposx⇀zero-n≡x⇀one-n {zero} {x⇀ x p} = {!!}
-- sucnposx⇀zero-n≡x⇀one-n {suc r} {p} = refl
nPosInd : ∀ {r} {P : NPos r → Type₀} →
P npos1 →
((p : NPos r) → P p → P (sucNPos p)) →
(p : NPos r) →
P p
nPosInd {r} {P} h1 hs ps = f ps
where
H : (p : NPos r) → P (x⇀ (zero-n r) p) → P (x⇀ (zero-n r) (sucNPos p))
--H p hx0p = hs (x⇀ (one-n r) p) (hs (x⇀ (zero-n r) p) hx0p)
f : (ps : NPos r) → P ps
f npos1 = h1
f (x⇀ d ps) with (max? d)
... | (no _) = {!nPosInd (hs npos1 h1) H ps!}
... | (yes _) = {!hs (x⇀ (zero-n r) ps) (nPosInd (hs npos1 h1) H ps)!}
-- nPosInd {zero} {P} h1 hs ps = f ps
-- where
-- H : (p : NPos zero) → P (x⇀ (zero-n zero) p) → P (x⇀ (zero-n zero) (sucNPos p))
-- H p hx0p = hs (x⇀ tt (x⇀ (zero-n zero) p)) (hs (x⇀ (zero-n zero) p) hx0p)
-- f : (ps : NPos zero) → P ps
-- f npos1 = h1
-- f (x⇀ tt ps) = nPosInd (hs npos1 h1) H ps
-- nPosInd {suc r} {P} h1 hs ps = f ps
-- where
-- H : (p : NPos (suc r)) → P (x⇀ (zero-n (suc r)) p) → P (x⇀ (zero-n (suc r)) (sucNPos p))
-- --H p hx0p = hs (x⇀ (one-n r) p) (hs (x⇀ (zero-n r) p) hx0p)
-- f : (ps : NPos (suc r)) → P ps
-- f npos1 = h1
-- f (x⇀ d ps) = {!!}
NPos→ℕ : ∀ r → NPos r → ℕ
NPos→ℕ zero npos1 = suc zero
NPos→ℕ zero (x⇀ tt x) = suc (NPos→ℕ zero x)
NPos→ℕ (suc r) npos1 = suc zero
NPos→ℕ (suc r) (x⇀ d x) with max? d
... | no _ = sucn (DirNum→ℕ (next d)) (doublesℕ (suc r) (NPos→ℕ (suc r) x))
... | yes _ = sucn (DirNum→ℕ (next d)) (doublesℕ (suc r) (suc (NPos→ℕ (suc r) x)))
-- NPos→ℕ (suc r) (x⇀ d x) =
-- sucn (DirNum→ℕ d) (doublesℕ (suc r) (NPos→ℕ (suc r) x))
NPos→ℕsucNPos : ∀ r → (p : NPos r) → NPos→ℕ r (sucNPos p) ≡ suc (NPos→ℕ r p)
NPos→ℕsucNPos zero npos1 = refl
NPos→ℕsucNPos zero (x⇀ d p) = cong suc (NPos→ℕsucNPos zero p)
NPos→ℕsucNPos (suc r) npos1 = {!!}
sucn (doubleℕ (DirNum→ℕ (zero-n r))) (doublesℕ r 2)
≡⟨ cong (λ y → sucn y (doublesℕ r 2)) (zero-n→0) ⟩
sucn (doubleℕ zero) (doublesℕ r 2)
≡⟨ refl ⟩
doublesℕ r 2
≡⟨ {!!} ⟩ {!!}
NPos→ℕsucNPos (suc r) (x⇀ d p) with max? d
... | no _ = {!!}
... | yes _ = {!!}
-- zero≠NPos→ℕ : ∀ {r} → (p : NPos r) → ¬ (zero ≡ NPos→ℕ r p)
-- zero≠NPos→ℕ {r} p = {!!}
ℕ→NPos : ∀ r → ℕ → NPos r
ℕ→NPos zero zero = npos1
ℕ→NPos zero (suc zero) = npos1
ℕ→NPos zero (suc (suc n)) = sucNPos (ℕ→NPos zero (suc n))
ℕ→NPos (suc r) zero = npos1
ℕ→NPos (suc r) (suc zero) = npos1
ℕ→NPos (suc r) (suc (suc n)) = sucNPos (ℕ→NPos (suc r) (suc n))
lemma : ∀ {r} → (ℕ→NPos r (NPos→ℕ r npos1)) ≡ npos1
lemma {zero} = refl
lemma {suc r} = refl
NPos→ℕ→NPos : ∀ r → (p : NPos r) → ℕ→NPos r (NPos→ℕ r p) ≡ p
NPos→ℕ→NPos r p = nPosInd lemma hs p
where
hs : (p : NPos r) → ℕ→NPos r (NPos→ℕ r p) ≡ p → ℕ→NPos r (NPos→ℕ r (sucNPos p)) ≡ (sucNPos p)
hs p hp =
ℕ→NPos r (NPos→ℕ r (sucNPos p))
≡⟨ {!!} ⟩
ℕ→NPos r (suc (NPos→ℕ r p))
≡⟨ {!!} ⟩
sucNPos (ℕ→NPos r (NPos→ℕ r p))
≡⟨ cong sucNPos hp ⟩
sucNPos p
∎
-- note: the cases for zero and suc r are almost identical
-- (why) does this need to split?
ℕ→NPos→ℕ : ∀ r → (n : ℕ) → NPos→ℕ r (ℕ→NPos r (suc n)) ≡ (suc n)
ℕ→NPos→ℕ zero zero = refl
ℕ→NPos→ℕ zero (suc n) =
NPos→ℕ zero (sucNPos (ℕ→NPos zero (suc n)))
≡⟨ {!!} ⟩
suc (NPos→ℕ zero (ℕ→NPos zero (suc n)))
≡⟨ cong suc (ℕ→NPos→ℕ zero n) ⟩
suc (suc n)
∎
ℕ→NPos→ℕ (suc r) zero = refl
ℕ→NPos→ℕ (suc r) (suc n) =
NPos→ℕ (suc r) (sucNPos (ℕ→NPos (suc r) (suc n)))
≡⟨ {!!} ⟩
suc (NPos→ℕ (suc r) (ℕ→NPos (suc r) (suc n)))
≡⟨ cong suc (ℕ→NPos→ℕ (suc r) n) ⟩
suc (suc n)
∎
|
{
"alphanum_fraction": 0.5038930355,
"avg_line_length": 33.0195035461,
"ext": "agda",
"hexsha": "123aba03793af34365f2ff689c791296871a7ce8",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "55709dd950e319c4a105ace33ddaf8b955354add",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "wrrnhttn/agda-cubical-multidimensional",
"max_forks_repo_path": "Multidimensional/NNat.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "55709dd950e319c4a105ace33ddaf8b955354add",
"max_issues_repo_issues_event_max_datetime": "2019-07-02T16:24:01.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-19T20:40:07.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "wrrnhttn/agda-cubical-multidimensional",
"max_issues_repo_path": "Multidimensional/NNat.agda",
"max_line_length": 116,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "55709dd950e319c4a105ace33ddaf8b955354add",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "wrrnhttn/agda-cubical-multidimensional",
"max_stars_repo_path": "Multidimensional/NNat.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 9496,
"size": 18623
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- This module is DEPRECATED. Please use `Data.Vec.Functional` instead.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
-- Disabled to prevent warnings from other Table modules
{-# OPTIONS --warn=noUserWarning #-}
module Data.Table.Properties where
{-# WARNING_ON_IMPORT
"Data.Table.Properties was deprecated in v1.2.
Use Data.Vec.Functional.Properties instead."
#-}
open import Data.Table
open import Data.Table.Relation.Binary.Equality
open import Data.Bool.Base using (true; false; if_then_else_)
open import Data.Nat.Base using (zero; suc)
open import Data.Empty using (⊥-elim)
open import Data.Fin using (Fin; suc; zero; _≟_; punchIn)
import Data.Fin.Properties as FP
open import Data.Fin.Permutation as Perm using (Permutation; _⟨$⟩ʳ_; _⟨$⟩ˡ_)
open import Data.List.Base as L using (List; _∷_; [])
open import Data.List.Relation.Unary.Any using (here; there; index)
open import Data.List.Membership.Propositional using (_∈_)
open import Data.Product as Product using (Σ; ∃; _,_; proj₁; proj₂)
open import Data.Vec.Base as V using (Vec; _∷_; [])
import Data.Vec.Properties as VP
open import Level using (Level)
open import Function.Base using (_∘_; flip)
open import Function.Inverse using (Inverse)
open import Relation.Binary.PropositionalEquality as P
using (_≡_; _≢_; refl; sym; cong)
open import Relation.Nullary using (does)
open import Relation.Nullary.Decidable using (dec-true; dec-false)
open import Relation.Nullary.Negation using (contradiction)
private
variable
a : Level
A : Set a
------------------------------------------------------------------------
-- select
-- Selecting from any table is the same as selecting from a constant table.
select-const : ∀ {n} (z : A) (i : Fin n) t →
select z i t ≗ select z i (replicate (lookup t i))
select-const z i t j with does (j ≟ i)
... | true = refl
... | false = refl
-- Selecting an element from a table then looking it up is the same as looking
-- up the index in the original table
select-lookup : ∀ {n x i} (t : Table A n) →
lookup (select x i t) i ≡ lookup t i
select-lookup {i = i} t rewrite dec-true (i ≟ i) refl = refl
-- Selecting an element from a table then removing the same element produces a
-- constant table
select-remove : ∀ {n x} i (t : Table A (suc n)) →
remove i (select x i t) ≗ replicate {n = n} x
select-remove i t j rewrite dec-false (punchIn i j ≟ i) (FP.punchInᵢ≢i _ _)
= refl
------------------------------------------------------------------------
-- permute
-- Removing an index 'i' from a table permuted with 'π' is the same as
-- removing the element, then permuting with 'π' minus 'i'.
remove-permute : ∀ {m n} (π : Permutation (suc m) (suc n))
i (t : Table A (suc n)) →
remove (π ⟨$⟩ˡ i) (permute π t)
≗ permute (Perm.remove (π ⟨$⟩ˡ i) π) (remove i t)
remove-permute π i t j = P.cong (lookup t) (Perm.punchIn-permute′ π i j)
------------------------------------------------------------------------
-- fromList
fromList-∈ : ∀ {xs : List A} (i : Fin (L.length xs)) → lookup (fromList xs) i ∈ xs
fromList-∈ {xs = x ∷ xs} zero = here refl
fromList-∈ {xs = x ∷ xs} (suc i) = there (fromList-∈ i)
index-fromList-∈ : ∀ {xs : List A} {i} → index (fromList-∈ {xs = xs} i) ≡ i
index-fromList-∈ {xs = x ∷ xs} {zero} = refl
index-fromList-∈ {xs = x ∷ xs} {suc i} = cong suc index-fromList-∈
fromList-index : ∀ {xs} {x : A} (x∈xs : x ∈ xs) → lookup (fromList xs) (index x∈xs) ≡ x
fromList-index (here px) = sym px
fromList-index (there x∈xs) = fromList-index x∈xs
------------------------------------------------------------------------
-- There exists an isomorphism between tables and vectors.
↔Vec : ∀ {n} → Inverse (≡-setoid A n) (P.setoid (Vec A n))
↔Vec = record
{ to = record { _⟨$⟩_ = toVec ; cong = VP.tabulate-cong }
; from = P.→-to-⟶ fromVec
; inverse-of = record
{ left-inverse-of = VP.lookup∘tabulate ∘ lookup
; right-inverse-of = VP.tabulate∘lookup
}
}
------------------------------------------------------------------------
-- Other
lookup∈ : ∀ {xs : List A} (i : Fin (L.length xs)) → ∃ λ x → x ∈ xs
lookup∈ i = _ , fromList-∈ i
|
{
"alphanum_fraction": 0.5739051095,
"avg_line_length": 36.5333333333,
"ext": "agda",
"hexsha": "0df7e54ada19c7540acb374a912dfbaf5a15d55e",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/Table/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/Table/Properties.agda",
"max_line_length": 87,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/Table/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": 1250,
"size": 4384
}
|
open import Oscar.Prelude
open import Oscar.Class
open import Oscar.Class.Unit
open import Oscar.Class.Leftunit
module Oscar.Class.Leftunit.ToUnit where
module _
{𝔞} {𝔄 : Ø 𝔞} {𝔢} {𝔈 : Ø 𝔢} {ℓ}
{_↦_ : 𝔄 → 𝔄 → Ø ℓ} (let _↦_ = _↦_; infix 4 _↦_)
{ε : 𝔈}
{_◃_ : 𝔈 → 𝔄 → 𝔄} (let _◃_ = _◃_; infix 16 _◃_)
{x : 𝔄}
⦃ _ : Leftunit.class _↦_ ε _◃_ x ⦄
where
instance
Leftunit--Unit : Unit.class (ε ◃ x ↦ x)
Leftunit--Unit .⋆ = leftunit
|
{
"alphanum_fraction": 0.591611479,
"avg_line_length": 22.65,
"ext": "agda",
"hexsha": "63d5229bd40dd7197d984bfcb7328b3c91fb4f5d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Leftunit/ToUnit.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Leftunit/ToUnit.agda",
"max_line_length": 50,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Leftunit/ToUnit.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 212,
"size": 453
}
|
module Lectures.One where
-- Check background color
-- Check fontsize
-- Ask questions at *any* time
data ⊤ : Set where
tt : ⊤
data ⊥ : Set where
absurd : ⊥ → {P : Set} → P
absurd ()
-- Introduce most common key bindings
-- C-c C-l load
-- C-c C-, show context
-- C-c C-. show context + type
-- C-c C-SPACE input
-- C-c C-A auto
-- C-c C-r refine
-- C-c C-d type inference
-- C-c C-c pattern match
-- Briefly introduce syntax
-- Introduce Set 0
modus-ponens : {P Q : Set} → P → (P → Q) → Q
modus-ponens p f = f p
-- Introduce misfix operators
¬_ : Set → Set
¬ P = P → ⊥
contra-elim : {P : Set} → P → ¬ P → ⊥
contra-elim = modus-ponens
-- no-dne : {P : Set} → ¬ ¬ P → P
-- no-dne ¬¬P = {!!}
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
{-# BUILTIN NATURAL ℕ #-}
_+_ : ℕ → ℕ → ℕ
zero + n = n
suc m + n = suc (m + n)
_isEven : ℕ → Set
zero isEven = ⊤
suc zero isEven = ⊥
suc (suc n) isEven = n isEven
half : (n : ℕ) → n isEven → ℕ
half zero tt = zero
half (suc (suc n)) p = suc (half n p)
_ : ℕ
_ = half 8 tt
-- Comment on termination checking
-- brexit : ⊥
-- brexit = brexit
|
{
"alphanum_fraction": 0.5592163847,
"avg_line_length": 16.5147058824,
"ext": "agda",
"hexsha": "6e928a760818091fa9fc63baab1d3b6465d509a3",
"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": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "UoG-Agda/Agda101",
"max_forks_repo_path": "Lectures/One.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff",
"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": "UoG-Agda/Agda101",
"max_issues_repo_path": "Lectures/One.agda",
"max_line_length": 44,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "UoG-Agda/Agda101",
"max_stars_repo_path": "Lectures/One.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 421,
"size": 1123
}
|
{-# OPTIONS --without-K --exact-split --allow-unsolved-metas #-}
module 13-propositional-truncation where
import 12-univalence
open 12-univalence public
-- Section 13 Propositional truncations, the image of a map, and the replacement axiom
-- Section 13.1 Propositional truncations
-- Definition 13.1.1
type-hom-Prop :
{ l1 l2 : Level} (P : UU-Prop l1) (Q : UU-Prop l2) → UU (l1 ⊔ l2)
type-hom-Prop P Q = type-Prop P → type-Prop Q
hom-Prop :
{ l1 l2 : Level} → UU-Prop l1 → UU-Prop l2 → UU-Prop (l1 ⊔ l2)
hom-Prop P Q =
pair
( type-hom-Prop P Q)
( is-prop-function-type (type-Prop P) (type-Prop Q) (is-prop-type-Prop Q))
is-prop-type-hom-Prop :
{ l1 l2 : Level} (P : UU-Prop l1) (Q : UU-Prop l2) → is-prop (type-hom-Prop P Q)
is-prop-type-hom-Prop P Q =
is-prop-function-type
( type-Prop P)
( type-Prop Q)
( is-prop-type-Prop Q)
equiv-Prop :
{ l1 l2 : Level} (P : UU-Prop l1) (Q : UU-Prop l2) → UU (l1 ⊔ l2)
equiv-Prop P Q = (type-Prop P) ≃ (type-Prop Q)
precomp-Prop :
{ l1 l2 l3 : Level} {A : UU l1} (P : UU-Prop l2) →
(A → type-Prop P) → (Q : UU-Prop l3) →
(type-hom-Prop P Q) → (A → type-Prop Q)
precomp-Prop P f Q g = g ∘ f
is-propositional-truncation :
( l : Level) {l1 l2 : Level} {A : UU l1} (P : UU-Prop l2) →
( A → type-Prop P) → UU (lsuc l ⊔ l1 ⊔ l2)
is-propositional-truncation l P f =
(Q : UU-Prop l) → is-equiv (precomp-Prop P f Q)
universal-property-propositional-truncation :
( l : Level) {l1 l2 : Level} {A : UU l1}
(P : UU-Prop l2) (f : A → type-Prop P) → UU (lsuc l ⊔ l1 ⊔ l2)
universal-property-propositional-truncation l {A = A} P f =
(Q : UU-Prop l) (g : A → type-Prop Q) →
is-contr (Σ (type-hom-Prop P Q) (λ h → (h ∘ f) ~ g))
-- Some unnumbered remarks after Definition 13.1.3
universal-property-is-propositional-truncation :
(l : Level) {l1 l2 : Level} {A : UU l1}
(P : UU-Prop l2) (f : A → type-Prop P) →
is-propositional-truncation l P f →
universal-property-propositional-truncation l P f
universal-property-is-propositional-truncation l P f is-ptr-f Q g =
is-contr-equiv'
( Σ (type-hom-Prop P Q) (λ h → Id (h ∘ f) g))
( equiv-tot (λ h → equiv-funext))
( is-contr-map-is-equiv (is-ptr-f Q) g)
map-is-propositional-truncation :
{l1 l2 l3 : Level} {A : UU l1} (P : UU-Prop l2) (f : A → type-Prop P) →
({l : Level} → is-propositional-truncation l P f) →
(Q : UU-Prop l3) (g : A → type-Prop Q) → type-hom-Prop P Q
map-is-propositional-truncation P f is-ptr-f Q g =
pr1
( center
( universal-property-is-propositional-truncation _ P f is-ptr-f Q g))
htpy-is-propositional-truncation :
{l1 l2 l3 : Level} {A : UU l1} (P : UU-Prop l2) (f : A → type-Prop P) →
(is-ptr-f : {l : Level} → is-propositional-truncation l P f) →
(Q : UU-Prop l3) (g : A → type-Prop Q) →
((map-is-propositional-truncation P f is-ptr-f Q g) ∘ f) ~ g
htpy-is-propositional-truncation P f is-ptr-f Q g =
pr2
( center
( universal-property-is-propositional-truncation _ P f is-ptr-f Q g))
is-propositional-truncation-universal-property :
(l : Level) {l1 l2 : Level} {A : UU l1}
(P : UU-Prop l2) (f : A → type-Prop P) →
universal-property-propositional-truncation l P f →
is-propositional-truncation l P f
is-propositional-truncation-universal-property l P f up-f Q =
is-equiv-is-contr-map
( λ g → is-contr-equiv
( Σ (type-hom-Prop P Q) (λ h → (h ∘ f) ~ g))
( equiv-tot (λ h → equiv-funext))
( up-f Q g))
-- Remark 13.1.2
is-propositional-truncation' :
( l : Level) {l1 l2 : Level} {A : UU l1} (P : UU-Prop l2) →
( A → type-Prop P) → UU (lsuc l ⊔ l1 ⊔ l2)
is-propositional-truncation' l {A = A} P f =
(Q : UU-Prop l) → (A → type-Prop Q) → (type-hom-Prop P Q)
is-propositional-truncation-simpl :
{ l1 l2 : Level} {A : UU l1} (P : UU-Prop l2)
( f : A → type-Prop P) →
( (l : Level) → is-propositional-truncation' l P f) →
( (l : Level) → is-propositional-truncation l P f)
is-propositional-truncation-simpl P f up-P l Q =
is-equiv-is-prop
( is-prop-Π (λ x → is-prop-type-Prop Q))
( is-prop-Π (λ x → is-prop-type-Prop Q))
( up-P l Q)
-- Example 13.1.3
is-propositional-truncation-const-star :
{ l1 : Level} (A : UU-pt l1)
( l : Level) → is-propositional-truncation l unit-Prop (const (type-UU-pt A) unit star)
is-propositional-truncation-const-star A =
is-propositional-truncation-simpl
( unit-Prop)
( const (type-UU-pt A) unit star)
( λ l P f → const unit (type-Prop P) (f (pt-UU-pt A)))
-- Example 13.1.4
is-propositional-truncation-id :
{ l1 : Level} (P : UU-Prop l1) →
( l : Level) → is-propositional-truncation l P id
is-propositional-truncation-id P l Q =
is-equiv-id (type-hom-Prop P Q)
-- Proposition 13.1.5
abstract
is-equiv-is-equiv-precomp-Prop :
{l1 l2 : Level} (P : UU-Prop l1) (Q : UU-Prop l2) (f : type-hom-Prop P Q) →
((l : Level) (R : UU-Prop l) →
is-equiv (precomp-Prop Q f R)) → is-equiv f
is-equiv-is-equiv-precomp-Prop P Q f is-equiv-precomp-f =
is-equiv-is-equiv-precomp-subuniverse id (λ l → is-prop) P Q f
is-equiv-precomp-f
triangle-3-for-2-is-ptruncation :
{l1 l2 l3 : Level} {A : UU l1} (P : UU-Prop l2) (P' : UU-Prop l3)
(f : A → type-Prop P) (f' : A → type-Prop P')
(h : type-hom-Prop P P') (H : (h ∘ f) ~ f') →
{l : Level} (Q : UU-Prop l) →
( precomp-Prop P' f' Q) ~
( (precomp-Prop P f Q) ∘ (precomp h (type-Prop Q)))
triangle-3-for-2-is-ptruncation P P' f f' h H Q g =
eq-htpy (λ p → inv (ap g (H p)))
is-equiv-is-ptruncation-is-ptruncation :
{l1 l2 l3 : Level} {A : UU l1} (P : UU-Prop l2) (P' : UU-Prop l3)
(f : A → type-Prop P) (f' : A → type-Prop P')
(h : type-hom-Prop P P') (H : (h ∘ f) ~ f') →
((l : Level) → is-propositional-truncation l P f) →
((l : Level) → is-propositional-truncation l P' f') →
is-equiv h
is-equiv-is-ptruncation-is-ptruncation P P' f f' h H is-ptr-P is-ptr-P' =
is-equiv-is-equiv-precomp-Prop P P' h
( λ l Q →
is-equiv-right-factor
( precomp-Prop P' f' Q)
( precomp-Prop P f Q)
( precomp h (type-Prop Q))
( triangle-3-for-2-is-ptruncation P P' f f' h H Q)
( is-ptr-P l Q)
( is-ptr-P' l Q))
is-ptruncation-is-ptruncation-is-equiv :
{l1 l2 l3 : Level} {A : UU l1} (P : UU-Prop l2) (P' : UU-Prop l3)
(f : A → type-Prop P) (f' : A → type-Prop P')
(h : type-hom-Prop P P') (H : (h ∘ f) ~ f') →
is-equiv h →
((l : Level) → is-propositional-truncation l P f) →
((l : Level) → is-propositional-truncation l P' f')
is-ptruncation-is-ptruncation-is-equiv P P' f f' h H is-equiv-h is-ptr-f l Q =
is-equiv-comp
( precomp-Prop P' f' Q)
( precomp-Prop P f Q)
( precomp h (type-Prop Q))
( triangle-3-for-2-is-ptruncation P P' f f' h H Q)
( is-equiv-precomp-is-equiv h is-equiv-h (type-Prop Q))
( is-ptr-f l Q)
is-ptruncation-is-equiv-is-ptruncation :
{l1 l2 l3 : Level} {A : UU l1} (P : UU-Prop l2) (P' : UU-Prop l3)
(f : A → type-Prop P) (f' : A → type-Prop P')
(h : type-hom-Prop P P') (H : (h ∘ f) ~ f') →
((l : Level) → is-propositional-truncation l P' f') →
is-equiv h →
((l : Level) → is-propositional-truncation l P f)
is-ptruncation-is-equiv-is-ptruncation P P' f f' h H is-ptr-f' is-equiv-h l Q =
is-equiv-left-factor
( precomp-Prop P' f' Q)
( precomp-Prop P f Q)
( precomp h (type-Prop Q))
( triangle-3-for-2-is-ptruncation P P' f f' h H Q)
( is-ptr-f' l Q)
( is-equiv-precomp-is-equiv h is-equiv-h (type-Prop Q))
-- Corollary 13.1.6
is-uniquely-unique-propositional-truncation :
{l1 l2 l3 : Level} {A : UU l1} (P : UU-Prop l2) (P' : UU-Prop l3)
(f : A → type-Prop P) (f' : A → type-Prop P') →
({l : Level} → is-propositional-truncation l P f) →
({l : Level} → is-propositional-truncation l P' f') →
is-contr (Σ (equiv-Prop P P') (λ e → (map-equiv e ∘ f) ~ f'))
is-uniquely-unique-propositional-truncation P P' f f' is-ptr-f is-ptr-f' =
is-contr-total-Eq-substructure
( universal-property-is-propositional-truncation _ P f is-ptr-f P' f')
( is-subtype-is-equiv)
( map-is-propositional-truncation P f is-ptr-f P' f')
( htpy-is-propositional-truncation P f is-ptr-f P' f')
( is-equiv-is-ptruncation-is-ptruncation P P' f f'
( map-is-propositional-truncation P f is-ptr-f P' f')
( htpy-is-propositional-truncation P f is-ptr-f P' f')
( λ l → is-ptr-f)
( λ l → is-ptr-f'))
-- Axiom 13.1.8
postulate trunc-Prop : {l : Level} → UU l → UU-Prop l
type-trunc-Prop : {l : Level} → UU l → UU l
type-trunc-Prop A = pr1 (trunc-Prop A)
is-prop-type-trunc-Prop : {l : Level} (A : UU l) → is-prop (type-trunc-Prop A)
is-prop-type-trunc-Prop A = pr2 (trunc-Prop A)
postulate unit-trunc-Prop : {l : Level} (A : UU l) → A → type-Prop (trunc-Prop A)
postulate is-propositional-truncation-trunc-Prop : {l1 l2 : Level} (A : UU l1) → is-propositional-truncation l2 (trunc-Prop A) (unit-trunc-Prop A)
universal-property-trunc-Prop : {l1 l2 : Level} (A : UU l1) →
universal-property-propositional-truncation l2
( trunc-Prop A)
( unit-trunc-Prop A)
universal-property-trunc-Prop A =
universal-property-is-propositional-truncation _
( trunc-Prop A)
( unit-trunc-Prop A)
( is-propositional-truncation-trunc-Prop A)
map-universal-property-trunc-Prop :
{l1 l2 : Level} {A : UU l1} (P : UU-Prop l2) →
(A → type-Prop P) → type-hom-Prop (trunc-Prop A) P
map-universal-property-trunc-Prop {A = A} P f =
map-is-propositional-truncation
( trunc-Prop A)
( unit-trunc-Prop A)
( is-propositional-truncation-trunc-Prop A)
( P)
( f)
-- Proposition 13.1.9
unique-functor-trunc-Prop :
{l1 l2 : Level} {A : UU l1} {B : UU l2} (f : A → B) →
is-contr
( Σ ( type-hom-Prop (trunc-Prop A) (trunc-Prop B))
( λ h → (h ∘ (unit-trunc-Prop A)) ~ ((unit-trunc-Prop B) ∘ f)))
unique-functor-trunc-Prop {l1} {l2} {A} {B} f =
universal-property-trunc-Prop A (trunc-Prop B) ((unit-trunc-Prop B) ∘ f)
functor-trunc-Prop :
{l1 l2 : Level} {A : UU l1} {B : UU l2} →
(A → B) → type-hom-Prop (trunc-Prop A) (trunc-Prop B)
functor-trunc-Prop f =
pr1 (center (unique-functor-trunc-Prop f))
htpy-functor-trunc-Prop :
{ l1 l2 : Level} {A : UU l1} {B : UU l2} (f : A → B) →
( (functor-trunc-Prop f) ∘ (unit-trunc-Prop A)) ~ ((unit-trunc-Prop B) ∘ f)
htpy-functor-trunc-Prop f =
pr2 (center (unique-functor-trunc-Prop f))
htpy-uniqueness-functor-trunc-Prop :
{ l1 l2 : Level} {A : UU l1} {B : UU l2} (f : A → B) →
( h : type-hom-Prop (trunc-Prop A) (trunc-Prop B)) →
( ( h ∘ (unit-trunc-Prop A)) ~ ((unit-trunc-Prop B) ∘ f)) →
(functor-trunc-Prop f) ~ h
htpy-uniqueness-functor-trunc-Prop f h H =
htpy-eq (ap pr1 (contraction (unique-functor-trunc-Prop f) (pair h H)))
id-functor-trunc-Prop :
{ l1 : Level} {A : UU l1} → functor-trunc-Prop (id {A = A}) ~ id
id-functor-trunc-Prop {l1} {A} =
htpy-uniqueness-functor-trunc-Prop id id refl-htpy
comp-functor-trunc-Prop :
{ l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {C : UU l3}
( g : B → C) (f : A → B) →
( functor-trunc-Prop (g ∘ f)) ~
( (functor-trunc-Prop g) ∘ (functor-trunc-Prop f))
comp-functor-trunc-Prop g f =
htpy-uniqueness-functor-trunc-Prop
( g ∘ f)
( (functor-trunc-Prop g) ∘ (functor-trunc-Prop f))
( ( (functor-trunc-Prop g) ·l (htpy-functor-trunc-Prop f)) ∙h
( ( htpy-functor-trunc-Prop g) ·r f))
-- Section 13.2 Propositional truncations as higher inductive types
-- Definition 13.2.1
case-paths-induction-principle-propositional-truncation :
{ l : Level} {l1 l2 : Level} {A : UU l1}
( P : UU-Prop l2) (α : (p q : type-Prop P) → Id p q) (f : A → type-Prop P) →
( B : type-Prop P → UU l) → UU (l ⊔ l2)
case-paths-induction-principle-propositional-truncation P α f B =
(p q : type-Prop P) (x : B p) (y : B q) → Id (tr B (α p q) x) y
induction-principle-propositional-truncation :
(l : Level) {l1 l2 : Level} {A : UU l1}
(P : UU-Prop l2) (α : (p q : type-Prop P) → Id p q) (f : A → type-Prop P) →
UU (lsuc l ⊔ l1 ⊔ l2)
induction-principle-propositional-truncation l {l1} {l2} {A} P α f =
( B : type-Prop P → UU l) →
( g : (x : A) → (B (f x))) →
( β : case-paths-induction-principle-propositional-truncation P α f B) →
Σ ((p : type-Prop P) → B p) (λ h → (x : A) → Id (h (f x)) (g x))
-- Lemma 13.2.2
is-prop-case-paths-induction-principle-propositional-truncation :
{ l : Level} {l1 l2 : Level} {A : UU l1}
( P : UU-Prop l2) (α : (p q : type-Prop P) → Id p q) (f : A → type-Prop P) →
( B : type-Prop P → UU l) →
case-paths-induction-principle-propositional-truncation P α f B →
( p : type-Prop P) → is-prop (B p)
is-prop-case-paths-induction-principle-propositional-truncation P α f B β p =
is-prop-is-contr-if-inh (λ x → pair (tr B (α p p) x) (β p p x))
case-paths-induction-principle-propositional-truncation-is-prop :
{ l : Level} {l1 l2 : Level} {A : UU l1}
( P : UU-Prop l2) (α : (p q : type-Prop P) → Id p q) (f : A → type-Prop P) →
( B : type-Prop P → UU l) →
( (p : type-Prop P) → is-prop (B p)) →
case-paths-induction-principle-propositional-truncation P α f B
case-paths-induction-principle-propositional-truncation-is-prop
P α f B is-prop-B p q x y =
is-prop'-is-prop (is-prop-B q) (tr B (α p q) x) y
-- Definition 13.2.3
dependent-universal-property-propositional-truncation :
( l : Level) {l1 l2 : Level} {A : UU l1}
( P : UU-Prop l2) (f : A → type-Prop P) → UU (lsuc l ⊔ l1 ⊔ l2)
dependent-universal-property-propositional-truncation l {l1} {l2} {A} P f =
( Q : type-Prop P → UU-Prop l) → is-equiv (precomp-Π f (type-Prop ∘ Q))
-- Theorem 13.2.4
abstract
dependent-universal-property-is-propositional-truncation :
{ l1 l2 : Level} {A : UU l1} (P : UU-Prop l2) (f : A → type-Prop P) →
( {l : Level} → is-propositional-truncation l P f) →
( {l : Level} → dependent-universal-property-propositional-truncation l P f)
dependent-universal-property-is-propositional-truncation
{l1} {l2} {A} P f is-ptr-f Q =
is-fiberwise-equiv-is-equiv-toto-is-equiv-base-map
( λ (g : A → type-Prop P) → (x : A) → type-Prop (Q (g x)))
( precomp f (type-Prop P))
( λ h → precomp-Π f (λ p → type-Prop (Q (h p))))
( is-ptr-f P)
( is-equiv-top-is-equiv-bottom-square
( inv-choice-∞
{ C = λ (x : type-Prop P) (p : type-Prop P) → type-Prop (Q p)})
( inv-choice-∞
{ C = λ (x : A) (p : type-Prop P) → type-Prop (Q p)})
( toto
( λ (g : A → type-Prop P) → (x : A) → type-Prop (Q (g x)))
( precomp f (type-Prop P))
( λ h → precomp-Π f (λ p → type-Prop (Q (h p)))))
( precomp f (Σ (type-Prop P) (λ p → type-Prop (Q p))))
( ind-Σ (λ h h' → refl))
( is-equiv-inv-choice-∞)
( is-equiv-inv-choice-∞)
( is-ptr-f (Σ-Prop P Q)))
( id {A = type-Prop P})
dependent-universal-property-trunc-Prop :
{l l1 : Level} (A : UU l1) →
dependent-universal-property-propositional-truncation l
( trunc-Prop A)
( unit-trunc-Prop A)
dependent-universal-property-trunc-Prop A =
dependent-universal-property-is-propositional-truncation
( trunc-Prop A)
( unit-trunc-Prop A)
( is-propositional-truncation-trunc-Prop A)
abstract
is-propositional-truncation-dependent-universal-property :
{ l1 l2 : Level} {A : UU l1} (P : UU-Prop l2) (f : A → type-Prop P) →
( {l : Level} →
dependent-universal-property-propositional-truncation l P f) →
( {l : Level} → is-propositional-truncation l P f)
is-propositional-truncation-dependent-universal-property P f dup-f Q =
dup-f (λ p → Q)
abstract
induction-principle-dependent-universal-property-propositional-truncation :
{ l1 l2 : Level} {A : UU l1} (P : UU-Prop l2) (f : A → type-Prop P) →
( {l : Level} →
dependent-universal-property-propositional-truncation l P f) →
( {l : Level} → induction-principle-propositional-truncation l P
( is-prop'-is-prop (is-prop-type-Prop P)) f)
induction-principle-dependent-universal-property-propositional-truncation
P f dup-f B g α =
tot
( λ h → htpy-eq)
( center
( is-contr-map-is-equiv
( dup-f
( λ p →
pair
( B p)
( is-prop-case-paths-induction-principle-propositional-truncation
( P)
( is-prop'-is-prop (is-prop-type-Prop P))
f B α p)))
( g)))
abstract
dependent-universal-property-induction-principle-propositional-truncation :
{ l1 l2 : Level} {A : UU l1} (P : UU-Prop l2) (f : A → type-Prop P) →
( {l : Level} → induction-principle-propositional-truncation l P
( is-prop'-is-prop (is-prop-type-Prop P)) f) →
( {l : Level} → dependent-universal-property-propositional-truncation l P f)
dependent-universal-property-induction-principle-propositional-truncation
P f ind-f Q =
is-equiv-is-prop
( is-prop-Π (λ p → is-prop-type-Prop (Q p)))
( is-prop-Π (λ a → is-prop-type-Prop (Q (f a))))
( λ g →
pr1
( ind-f
( λ p → type-Prop (Q p))
( g)
( case-paths-induction-principle-propositional-truncation-is-prop
( P)
( is-prop'-is-prop (is-prop-type-Prop P))
( f)
( λ p → type-Prop (Q p))
( λ p → is-prop-type-Prop (Q p)))))
-- Exercises
-- Exercise 13.1
is-propositional-truncation-retract :
{l l1 l2 : Level} {A : UU l1} (P : UU-Prop l2) →
(R : (type-Prop P) retract-of A) →
is-propositional-truncation l P (retraction-retract-of R)
is-propositional-truncation-retract {A = A} P R Q =
is-equiv-is-prop
( is-prop-function-type
( type-Prop P)
( type-Prop Q)
( is-prop-type-Prop Q))
( is-prop-function-type
( A)
( type-Prop Q)
( is-prop-type-Prop Q))
( λ g → g ∘ (section-retract-of R))
-- Exercise 13.2
is-propositional-truncation-prod :
{l1 l2 l3 l4 : Level}
{A : UU l1} (P : UU-Prop l2) (f : A → type-Prop P)
{A' : UU l3} (P' : UU-Prop l4) (f' : A' → type-Prop P') →
({l : Level} → is-propositional-truncation l P f) →
({l : Level} → is-propositional-truncation l P' f') →
{l : Level} → is-propositional-truncation l (prod-Prop P P') (functor-prod f f')
is-propositional-truncation-prod P f P' f' is-ptr-f is-ptr-f' Q =
is-equiv-top-is-equiv-bottom-square
( ev-pair)
( ev-pair)
( precomp (functor-prod f f') (type-Prop Q))
( λ h a a' → h (f a) (f' a'))
( refl-htpy)
( is-equiv-ev-pair)
( is-equiv-ev-pair)
( is-equiv-comp'
( λ h a a' → h a (f' a'))
( λ h a p' → h (f a) p')
( is-ptr-f (pair (type-hom-Prop P' Q) (is-prop-type-hom-Prop P' Q)))
( is-equiv-postcomp-Π
( λ a g a' → g (f' a'))
( λ a → is-ptr-f' Q)))
equiv-prod-trunc-Prop :
{l1 l2 : Level} (A : UU l1) (A' : UU l2) →
equiv-Prop (trunc-Prop (A × A')) (prod-Prop (trunc-Prop A) (trunc-Prop A'))
equiv-prod-trunc-Prop A A' =
pr1
( center
( is-uniquely-unique-propositional-truncation
( trunc-Prop (A × A'))
( prod-Prop (trunc-Prop A) (trunc-Prop A'))
( unit-trunc-Prop (A × A'))
( functor-prod (unit-trunc-Prop A) (unit-trunc-Prop A'))
( is-propositional-truncation-trunc-Prop (A × A'))
( is-propositional-truncation-prod
( trunc-Prop A)
( unit-trunc-Prop A)
( trunc-Prop A')
( unit-trunc-Prop A')
( is-propositional-truncation-trunc-Prop A)
( is-propositional-truncation-trunc-Prop A'))))
-- Exercise 13.3
-- Exercise 13.3(a)
conj-Prop = prod-Prop
disj-Prop :
{l1 l2 : Level} → UU-Prop l1 → UU-Prop l2 → UU-Prop (l1 ⊔ l2)
disj-Prop P Q = trunc-Prop (coprod (type-Prop P) (type-Prop Q))
inl-disj-Prop :
{l1 l2 : Level} (P : UU-Prop l1) (Q : UU-Prop l2) →
type-hom-Prop P (disj-Prop P Q)
inl-disj-Prop P Q =
(unit-trunc-Prop (coprod (type-Prop P) (type-Prop Q))) ∘ inl
inr-disj-Prop :
{l1 l2 : Level} (P : UU-Prop l1) (Q : UU-Prop l2) →
type-hom-Prop Q (disj-Prop P Q)
inr-disj-Prop P Q =
(unit-trunc-Prop (coprod (type-Prop P) (type-Prop Q))) ∘ inr
-- Exercise 13.3(b)
ev-disj-Prop :
{l1 l2 l3 : Level} (P : UU-Prop l1) (Q : UU-Prop l2) (R : UU-Prop l3) →
type-hom-Prop
( hom-Prop (disj-Prop P Q) R)
( conj-Prop (hom-Prop P R) (hom-Prop Q R))
ev-disj-Prop P Q R h =
pair (h ∘ (inl-disj-Prop P Q)) (h ∘ (inr-disj-Prop P Q))
inv-ev-disj-Prop :
{l1 l2 l3 : Level} (P : UU-Prop l1) (Q : UU-Prop l2) (R : UU-Prop l3) →
type-hom-Prop
( conj-Prop (hom-Prop P R) (hom-Prop Q R))
( hom-Prop (disj-Prop P Q) R)
inv-ev-disj-Prop P Q R (pair f g) =
map-universal-property-trunc-Prop R (ind-coprod (λ t → type-Prop R) f g)
is-equiv-ev-disj-Prop :
{l1 l2 l3 : Level} (P : UU-Prop l1) (Q : UU-Prop l2) (R : UU-Prop l3) →
is-equiv (ev-disj-Prop P Q R)
is-equiv-ev-disj-Prop P Q R =
is-equiv-is-prop
( is-prop-type-Prop (hom-Prop (disj-Prop P Q) R))
( is-prop-type-Prop (conj-Prop (hom-Prop P R) (hom-Prop Q R)))
( inv-ev-disj-Prop P Q R)
-- Exercise 13.5
{-
impredicative-trunc-Prop :
{l : Level} → UU l → UU-Prop (lsuc l)
impredicative-trunc-Prop {l} A =
(P : UU-Prop l) → (A → type-Prop P) → type-Prop P
-}
|
{
"alphanum_fraction": 0.5925559482,
"avg_line_length": 36.5318416523,
"ext": "agda",
"hexsha": "eae7466b26daa73b65319b6c65be12695976f95d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "hemangandhi/HoTT-Intro",
"max_forks_repo_path": "Agda/13-propositional-truncation.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "hemangandhi/HoTT-Intro",
"max_issues_repo_path": "Agda/13-propositional-truncation.agda",
"max_line_length": 146,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "hemangandhi/HoTT-Intro",
"max_stars_repo_path": "Agda/13-propositional-truncation.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 8268,
"size": 21225
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Convenient syntax for reasoning with a partial setoid
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary
module Relation.Binary.Reasoning.PartialSetoid
{s₁ s₂} (S : PartialSetoid s₁ s₂) where
open PartialSetoid S
import Relation.Binary.Reasoning.Base.Partial _≈_ trans as Base
------------------------------------------------------------------------
-- Re-export the contents of the base module
open Base public
hiding (step-∼)
------------------------------------------------------------------------
-- Additional reasoning combinators
infixr 2 step-≈ step-≈˘
-- A step using an equality
step-≈ = Base.step-∼
syntax step-≈ x y≈z x≈y = x ≈⟨ x≈y ⟩ y≈z
-- A step using a symmetric equality
step-≈˘ : ∀ x {y z} → y IsRelatedTo z → y ≈ x → x IsRelatedTo z
step-≈˘ x y∼z y≈x = x ≈⟨ sym y≈x ⟩ y∼z
syntax step-≈˘ x y≈z y≈x = x ≈˘⟨ y≈x ⟩ y≈z
|
{
"alphanum_fraction": 0.4851390221,
"avg_line_length": 27.4473684211,
"ext": "agda",
"hexsha": "be686b19ea8b4f1eda398dab940dd037d9d6fae8",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Relation/Binary/Reasoning/PartialSetoid.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Relation/Binary/Reasoning/PartialSetoid.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/Relation/Binary/Reasoning/PartialSetoid.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": 294,
"size": 1043
}
|
module Issue1232.Fin where
data Fin : Set where
zero : Fin
|
{
"alphanum_fraction": 0.7142857143,
"avg_line_length": 10.5,
"ext": "agda",
"hexsha": "c695f54820524ed503c04495227ff19c089b738e",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/interaction/Issue1232/Fin.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/interaction/Issue1232/Fin.agda",
"max_line_length": 26,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/interaction/Issue1232/Fin.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": 20,
"size": 63
}
|
{- 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
-}
import LibraBFT.Impl.Consensus.ConsensusTypes.Vote as Vote
import LibraBFT.Impl.Consensus.ConsensusTypes.TimeoutCertificate as TimeoutCertificate
open import LibraBFT.Impl.OBM.Rust.RustTypes
import LibraBFT.Impl.Types.CryptoProxies as CryptoProxies
import LibraBFT.Impl.Types.LedgerInfoWithSignatures as LedgerInfoWithSignatures
import LibraBFT.Impl.Types.ValidatorVerifier as ValidatorVerifier
open import LibraBFT.ImplShared.Consensus.Types
open import LibraBFT.ImplShared.Util.Crypto
open import LibraBFT.ImplShared.Util.Dijkstra.All
open import Optics.All
open import Util.Hash
import Util.KVMap as Map
open import Util.Prelude
module LibraBFT.Impl.Consensus.PendingVotes where
insertVoteM : Vote → ValidatorVerifier → LBFT VoteReceptionResult
insertVoteM vote vv = do
let liDigest = hashLI (vote ^∙ vLedgerInfo)
atv ← use (lPendingVotes ∙ pvAuthorToVote)
caseMD Map.lookup (vote ^∙ vAuthor) atv of λ where
(just previouslySeenVote) →
ifD liDigest ≟Hash (hashLI (previouslySeenVote ^∙ vLedgerInfo))
then (do
let newTimeoutVote = Vote.isTimeout vote ∧ not (Vote.isTimeout previouslySeenVote)
if not newTimeoutVote
then pure DuplicateVote
else continue1 liDigest)
else
pure EquivocateVote
nothing →
continue1 liDigest
where
continue2 : U64 → LBFT VoteReceptionResult
continue1 : HashValue → LBFT VoteReceptionResult
continue1 liDigest = do
pv ← use lPendingVotes
lPendingVotes ∙ pvAuthorToVote %= Map.kvm-insert-Haskell (vote ^∙ vAuthor) vote
let liWithSig = CryptoProxies.addToLi (vote ^∙ vAuthor) (vote ^∙ vSignature)
(fromMaybe (LedgerInfoWithSignatures∙new (vote ^∙ vLedgerInfo) Map.empty)
(Map.lookup liDigest (pv ^∙ pvLiDigestToVotes)))
lPendingVotes ∙ pvLiDigestToVotes %= Map.kvm-insert-Haskell liDigest liWithSig
case⊎D ValidatorVerifier.checkVotingPower vv (Map.kvm-keys (liWithSig ^∙ liwsSignatures)) of λ where
(Right unit) →
pure (NewQuorumCertificate (QuorumCert∙new (vote ^∙ vVoteData) liWithSig))
(Left (ErrVerify (TooLittleVotingPower votingPower _))) →
continue2 votingPower
(Left _) →
pure VRR_TODO
continue2 qcVotingPower =
caseMD vote ^∙ vTimeoutSignature of λ where
(just timeoutSignature) → do
pv ← use lPendingVotes
let partialTc = TimeoutCertificate.addSignature (vote ^∙ vAuthor) timeoutSignature
(fromMaybe (TimeoutCertificate∙new (Vote.timeout vote))
(pv ^∙ pvMaybePartialTC))
lPendingVotes ∙ pvMaybePartialTC %= const (just partialTc)
case⊎D ValidatorVerifier.checkVotingPower vv (Map.kvm-keys (partialTc ^∙ tcSignatures)) of λ where
(Right unit) →
pure (NewTimeoutCertificate partialTc)
(Left (ErrVerify (TooLittleVotingPower votingPower _))) →
pure (TCVoteAdded votingPower)
(Left _) →
pure VRR_TODO
nothing →
pure (QCVoteAdded qcVotingPower)
|
{
"alphanum_fraction": 0.674,
"avg_line_length": 43.75,
"ext": "agda",
"hexsha": "5f36e103fb40f85d852a77237559651122f50cde",
"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/PendingVotes.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/PendingVotes.agda",
"max_line_length": 111,
"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/PendingVotes.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 914,
"size": 3500
}
|
{-# OPTIONS --without-K --safe #-}
module Polynomial.Simple.AlmostCommutativeRing where
import Algebra.Solver.Ring.AlmostCommutativeRing as Complex
open import Level
open import Relation.Binary
open import Algebra
open import Algebra.Structures
open import Algebra.FunctionProperties
import Algebra.Morphism as Morphism
open import Function
open import Level
open import Data.Maybe as Maybe using (Maybe; just; nothing)
record IsAlmostCommutativeRing
{a ℓ} {A : Set a} (_≈_ : Rel A ℓ)
(_+_ _*_ : A → A → A) (-_ : A → A) (0# 1# : A) : Set (a ⊔ ℓ) where
field
isCommutativeSemiring : IsCommutativeSemiring _≈_ _+_ _*_ 0# 1#
-‿cong : -_ Preserves _≈_ ⟶ _≈_
-‿*-distribˡ : ∀ x y → ((- x) * y) ≈ (- (x * y))
-‿+-comm : ∀ x y → ((- x) + (- y)) ≈ (- (x + y))
open IsCommutativeSemiring isCommutativeSemiring public
import Polynomial.Exponentiation as Exp
record AlmostCommutativeRing c ℓ : Set (suc (c ⊔ ℓ)) where
infix 8 -_
infixl 7 _*_
infixl 6 _+_
infix 4 _≈_
infixr 8 _^_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ
_+_ : Op₂ Carrier
_*_ : Op₂ Carrier
-_ : Op₁ Carrier
0# : Carrier
0≟_ : (x : Carrier) → Maybe (0# ≈ x)
1# : Carrier
isAlmostCommutativeRing :
IsAlmostCommutativeRing _≈_ _+_ _*_ -_ 0# 1#
open IsAlmostCommutativeRing isAlmostCommutativeRing hiding (refl) public
open import Data.Nat as ℕ using (ℕ)
commutativeSemiring : CommutativeSemiring _ _
commutativeSemiring =
record { isCommutativeSemiring = isCommutativeSemiring }
open CommutativeSemiring commutativeSemiring public
using ( +-semigroup; +-monoid; +-commutativeMonoid
; *-semigroup; *-monoid; *-commutativeMonoid
; semiring
)
rawRing : RawRing _ _
rawRing = record
{ Carrier = Carrier
; _≈_ = _≈_
; _+_ = _+_
; _*_ = _*_
; -_ = -_
; 0# = 0#
; 1# = 1#
}
_^_ : Carrier → ℕ → Carrier
_^_ = Exp._^_ rawRing
{-# NOINLINE _^_ #-}
refl : ∀ {x} → x ≈ x
refl = IsAlmostCommutativeRing.refl isAlmostCommutativeRing
flipped : ∀ {c ℓ} → AlmostCommutativeRing c ℓ → AlmostCommutativeRing c ℓ
flipped rng = record
{ Carrier = Carrier
; _≈_ = _≈_
; _+_ = flip _+_
; _*_ = flip _*_
; -_ = -_
; 0# = 0#
; 0≟_ = 0≟_
; 1# = 1#
; isAlmostCommutativeRing = record
{ -‿cong = -‿cong
; -‿*-distribˡ = λ x y → *-comm y (- x) ⟨ trans ⟩ (-‿*-distribˡ x y ⟨ trans ⟩ -‿cong (*-comm x y))
; -‿+-comm = λ x y → -‿+-comm y x
; isCommutativeSemiring = record
{ +-isCommutativeMonoid = record
{ isSemigroup = record
{ isMagma = record
{ isEquivalence = isEquivalence
; ∙-cong = flip (+-cong )
}
; assoc = λ x y z → sym (+-assoc z y x)
}
; identityˡ = +-identityʳ
; comm = λ x y → +-comm y x
}
; *-isCommutativeMonoid = record
{ isSemigroup = record
{ isMagma = record
{ isEquivalence = isEquivalence
; ∙-cong = flip (*-cong )
}
; assoc = λ x y z → sym (*-assoc z y x)
}
; identityˡ = *-identityʳ
; comm = λ x y → *-comm y x
}
; distribʳ = λ x y z → distribˡ _ _ _
; zeroˡ = zeroʳ
}
}
} where open AlmostCommutativeRing rng
record _-Raw-AlmostCommutative⟶_
{c r₁ r₂ r₃}
(From : RawRing c r₁)
(To : AlmostCommutativeRing r₂ r₃) : Set (c ⊔ r₁ ⊔ r₂ ⊔ r₃) where
private
module F = RawRing From
module T = AlmostCommutativeRing To
open Morphism.Definitions F.Carrier T.Carrier T._≈_
field
⟦_⟧ : Morphism
+-homo : Homomorphic₂ ⟦_⟧ F._+_ T._+_
*-homo : Homomorphic₂ ⟦_⟧ F._*_ T._*_
-‿homo : Homomorphic₁ ⟦_⟧ F.-_ T.-_
0-homo : Homomorphic₀ ⟦_⟧ F.0# T.0#
1-homo : Homomorphic₀ ⟦_⟧ F.1# T.1#
-raw-almostCommutative⟶
: ∀ {r₁ r₂} (R : AlmostCommutativeRing r₁ r₂) →
AlmostCommutativeRing.rawRing R -Raw-AlmostCommutative⟶ R
-raw-almostCommutative⟶ R = record
{ ⟦_⟧ = id
; +-homo = λ _ _ → refl
; *-homo = λ _ _ → refl
; -‿homo = λ _ → refl
; 0-homo = refl
; 1-homo = refl
}
where open AlmostCommutativeRing R
-- A homomorphism induces a notion of equivalence on the raw ring.
Induced-equivalence :
∀ {c₁ c₂ ℓ₁ ℓ₂} {Coeff : RawRing c₁ ℓ₁} {R : AlmostCommutativeRing c₂ ℓ₂} →
Coeff -Raw-AlmostCommutative⟶ R → Rel (RawRing.Carrier Coeff) ℓ₂
Induced-equivalence {R = R} morphism a b = ⟦ a ⟧ ≈ ⟦ b ⟧
where
open AlmostCommutativeRing R
open _-Raw-AlmostCommutative⟶_ morphism
------------------------------------------------------------------------
-- Conversions
-- Commutative rings are almost commutative rings.
fromCommutativeRing : ∀ {r₁ r₂} → (CR : CommutativeRing r₁ r₂) → (∀ x → Maybe ((CommutativeRing._≈_ CR) (CommutativeRing.0# CR) x)) → AlmostCommutativeRing _ _
fromCommutativeRing CR 0≟_ = record
{ isAlmostCommutativeRing = record
{ isCommutativeSemiring = isCommutativeSemiring
; -‿cong = -‿cong
; -‿*-distribˡ = -‿*-distribˡ
; -‿+-comm = ⁻¹-∙-comm
}
; 0≟_ = 0≟_
}
where
open CommutativeRing CR
import Algebra.Properties.Ring as R; open R ring
import Algebra.Properties.AbelianGroup as AG; open AG +-abelianGroup
fromCommutativeSemiring : ∀ {r₁ r₂} → (CS : CommutativeSemiring r₁ r₂) → (∀ x → Maybe ((CommutativeSemiring._≈_ CS) (CommutativeSemiring.0# CS) x)) → AlmostCommutativeRing _ _
fromCommutativeSemiring CS 0≟_ = record
{ -_ = id
; isAlmostCommutativeRing = record
{ isCommutativeSemiring = isCommutativeSemiring
; -‿cong = id
; -‿*-distribˡ = λ _ _ → refl
; -‿+-comm = λ _ _ → refl
}
; 0≟_ = 0≟_
}
where open CommutativeSemiring CS
|
{
"alphanum_fraction": 0.5651170458,
"avg_line_length": 31.2680412371,
"ext": "agda",
"hexsha": "d59c338f2d76f54cb6b62965347243610dd4cca9",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2022-01-20T07:07:11.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-04-16T02:23:16.000Z",
"max_forks_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mckeankylej/agda-ring-solver",
"max_forks_repo_path": "src/Polynomial/Simple/AlmostCommutativeRing.agda",
"max_issues_count": 5,
"max_issues_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T01:55:42.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-17T20:48:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mckeankylej/agda-ring-solver",
"max_issues_repo_path": "src/Polynomial/Simple/AlmostCommutativeRing.agda",
"max_line_length": 175,
"max_stars_count": 36,
"max_stars_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mckeankylej/agda-ring-solver",
"max_stars_repo_path": "src/Polynomial/Simple/AlmostCommutativeRing.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-15T00:57:55.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-01-25T16:40:52.000Z",
"num_tokens": 2146,
"size": 6066
}
|
{-# OPTIONS --without-K --rewriting #-}
open import lib.Basics
open import lib.NType2
open import lib.types.Bool
open import lib.types.Empty
open import lib.types.Paths
open import lib.types.Pi
open import lib.types.Sigma
{-
This file contains various lemmas that rely on lib.types.Paths or
functional extensionality for pointed maps.
-}
module lib.types.Pointed where
{- Sequences of pointed maps and paths between their compositions -}
infixr 80 _◃⊙∘_
data ⊙FunctionSeq {i} : Ptd i → Ptd i → Type (lsucc i) where
⊙idf-seq : {X : Ptd i} → ⊙FunctionSeq X X
_◃⊙∘_ : {X Y Z : Ptd i} (g : Y ⊙→ Z) (fs : ⊙FunctionSeq X Y) → ⊙FunctionSeq X Z
infix 30 _⊙–→_
_⊙–→_ = ⊙FunctionSeq
infix 90 _◃⊙idf
_◃⊙idf : ∀ {i} {X Y : Ptd i} → (X ⊙→ Y) → X ⊙–→ Y
_◃⊙idf fs = fs ◃⊙∘ ⊙idf-seq
⊙compose : ∀ {i} {X Y : Ptd i} → (X ⊙–→ Y) → X ⊙→ Y
⊙compose ⊙idf-seq = ⊙idf _
⊙compose (g ◃⊙∘ fs) = g ⊙∘ ⊙compose fs
record _=⊙∘_ {i} {X Y : Ptd i} (fs gs : X ⊙–→ Y) : Type i where
constructor =⊙∘-in
field
=⊙∘-out : ⊙compose fs == ⊙compose gs
open _=⊙∘_ public
{- Pointed maps -}
⊙→-level : ∀ {i j} (X : Ptd i) (Y : Ptd j)
{n : ℕ₋₂}
→ has-level n (de⊙ Y)
→ has-level n (X ⊙→ Y)
⊙→-level X Y Y-level =
Σ-level
(Π-level (λ _ → Y-level))
(λ f' → =-preserves-level Y-level)
⊙app= : ∀ {i j} {X : Ptd i} {Y : Ptd j} {f g : X ⊙→ Y}
→ f == g → f ⊙∼ g
⊙app= {X = X} {Y = Y} p =
app= (fst= p) , ↓-ap-in (_== pt Y) (λ u → u (pt X)) (snd= p)
-- function extensionality for pointed maps
⊙λ= : ∀ {i j} {X : Ptd i} {Y : Ptd j} {f g : X ⊙→ Y}
→ f ⊙∼ g → f == g
⊙λ= {g = g} (p , α) = pair= (λ= p)
(↓-app=cst-in (↓-idf=cst-out α ∙ ap (_∙ snd g) (! (app=-β p _))))
⊙λ=' : ∀ {i j} {X : Ptd i} {Y : Ptd j} {f g : X ⊙→ Y}
(p : fst f ∼ fst g)
(α : snd f == snd g [ (λ y → y == pt Y) ↓ p (pt X) ])
→ f == g
⊙λ=' {g = g} = curry ⊙λ=
-- associativity of pointed maps
⊙∘-assoc-pt : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k}
{a₁ a₂ : A} (f : A → B) {b : B} (g : B → C) {c : C}
(p : a₁ == a₂) (q : f a₂ == b) (r : g b == c)
→ ⊙∘-pt (g ∘ f) p (⊙∘-pt g q r) == ⊙∘-pt g (⊙∘-pt f p q) r
⊙∘-assoc-pt _ _ idp _ _ = idp
⊙∘-assoc : ∀ {i j k l} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} {W : Ptd l}
(h : Z ⊙→ W) (g : Y ⊙→ Z) (f : X ⊙→ Y)
→ ((h ⊙∘ g) ⊙∘ f) ⊙∼ (h ⊙∘ (g ⊙∘ f))
⊙∘-assoc (h , hpt) (g , gpt) (f , fpt) = (λ _ → idp) , ⊙∘-assoc-pt g h fpt gpt hpt
⊙∘-cst-l : ∀ {i j k} {X : Ptd i} {Y : Ptd j} {Z : Ptd k}
→ (f : X ⊙→ Y) → (⊙cst :> (Y ⊙→ Z)) ⊙∘ f ⊙∼ ⊙cst
⊙∘-cst-l {Z = Z} f = (λ _ → idp) , ap (_∙ idp) (ap-cst (pt Z) (snd f))
⊙∘-cst-r : ∀ {i j k} {X : Ptd i} {Y : Ptd j} {Z : Ptd k}
→ (f : Y ⊙→ Z) → f ⊙∘ (⊙cst :> (X ⊙→ Y)) ⊙∼ ⊙cst
⊙∘-cst-r {X = X} f = (λ _ → snd f) , ↓-idf=cst-in' idp
private
⊙coe-pt : ∀ {i} {X Y : Ptd i} (p : X == Y)
→ coe (ap de⊙ p) (pt X) == pt Y
⊙coe-pt idp = idp
⊙coe : ∀ {i} {X Y : Ptd i}
→ X == Y → X ⊙→ Y
⊙coe p = coe (ap de⊙ p) , ⊙coe-pt p
⊙coe-equiv : ∀ {i} {X Y : Ptd i}
→ X == Y → X ⊙≃ Y
⊙coe-equiv p = ⊙coe p , snd (coe-equiv (ap de⊙ p))
transport-post⊙∘ : ∀ {i} {j} (X : Ptd i) {Y Z : Ptd j} (p : Y == Z)
(f : X ⊙→ Y)
→ transport (X ⊙→_) p f == ⊙coe p ⊙∘ f
transport-post⊙∘ X p@idp f = ! (⊙λ= (⊙∘-unit-l f))
⊙coe-∙ : ∀ {i} {X Y Z : Ptd i} (p : X == Y) (q : Y == Z)
→ ⊙coe (p ∙ q) ◃⊙idf =⊙∘ ⊙coe q ◃⊙∘ ⊙coe p ◃⊙idf
⊙coe-∙ p@idp q = =⊙∘-in idp
private
⊙coe'-pt : ∀ {i} {X Y : Ptd i} (p : de⊙ X == de⊙ Y) (q : pt X == pt Y [ idf _ ↓ p ])
→ coe p (pt X) == pt Y
⊙coe'-pt p@idp q = q
⊙coe' : ∀ {i} {X Y : Ptd i} (p : de⊙ X == de⊙ Y) (q : pt X == pt Y [ idf _ ↓ p ])
→ X ⊙→ Y
⊙coe' p q = coe p , ⊙coe'-pt p q
private
⊙transport-pt : ∀ {i j} {A : Type i} (B : A → Ptd j) {x y : A} (p : x == y)
→ transport (de⊙ ∘ B) p (pt (B x)) == pt (B y)
⊙transport-pt B idp = idp
⊙transport : ∀ {i j} {A : Type i} (B : A → Ptd j) {x y : A} (p : x == y)
→ (B x ⊙→ B y)
⊙transport B p = transport (de⊙ ∘ B) p , ⊙transport-pt B p
⊙transport-∙ : ∀ {i j} {A : Type i} (B : A → Ptd j)
{x y z : A} (p : x == y) (q : y == z)
→ ⊙transport B (p ∙ q) ◃⊙idf =⊙∘ ⊙transport B q ◃⊙∘ ⊙transport B p ◃⊙idf
⊙transport-∙ B p@idp q = =⊙∘-in idp
⊙transport-⊙coe : ∀ {i j} {A : Type i} (B : A → Ptd j) {x y : A} (p : x == y)
→ ⊙transport B p == ⊙coe (ap B p)
⊙transport-⊙coe B p@idp = idp
⊙transport-natural : ∀ {i j k} {A : Type i} {B : A → Ptd j} {C : A → Ptd k}
{x y : A} (p : x == y)
(h : ∀ a → B a ⊙→ C a)
→ h y ⊙∘ ⊙transport B p == ⊙transport C p ⊙∘ h x
⊙transport-natural p@idp h = ! (⊙λ= (⊙∘-unit-l (h _)))
{- This requires that B and C have the same universe level -}
⊙transport-natural-=⊙∘ : ∀ {i j} {A : Type i} {B C : A → Ptd j}
{x y : A} (p : x == y)
(h : ∀ a → B a ⊙→ C a)
→ h y ◃⊙∘ ⊙transport B p ◃⊙idf =⊙∘ ⊙transport C p ◃⊙∘ h x ◃⊙idf
⊙transport-natural-=⊙∘ p h = =⊙∘-in (⊙transport-natural p h)
{- Pointed equivalences -}
-- Extracting data from an pointed equivalence
module _ {i j} {X : Ptd i} {Y : Ptd j} (⊙e : X ⊙≃ Y) where
⊙≃-to-≃ : de⊙ X ≃ de⊙ Y
⊙≃-to-≃ = fst (fst ⊙e) , snd ⊙e
⊙–> : X ⊙→ Y
⊙–> = fst ⊙e
⊙–>-pt = snd ⊙–>
⊙<– : Y ⊙→ X
⊙<– = is-equiv.g (snd ⊙e) , lemma ⊙e where
lemma : {Y : Ptd j} (⊙e : X ⊙≃ Y) → is-equiv.g (snd ⊙e) (pt Y) == pt X
lemma ((f , idp) , f-ise) = is-equiv.g-f f-ise (pt X)
⊙<–-pt = snd ⊙<–
infix 120 _⊙⁻¹
_⊙⁻¹ : Y ⊙≃ X
_⊙⁻¹ = ⊙<– , is-equiv-inverse (snd ⊙e)
module _ {i j} {X : Ptd i} {Y : Ptd j} where
⊙<–-inv-l : (⊙e : X ⊙≃ Y) → ⊙<– ⊙e ⊙∘ ⊙–> ⊙e == ⊙idf _
⊙<–-inv-l ⊙e = ⊙λ= (<–-inv-l (⊙≃-to-≃ ⊙e) , ↓-idf=cst-in' (lemma ⊙e)) where
lemma : {Y : Ptd j} (⊙e : X ⊙≃ Y)
→ snd (⊙<– ⊙e ⊙∘ ⊙–> ⊙e) == is-equiv.g-f (snd ⊙e) (pt X)
lemma ((f , idp) , f-ise) = idp
⊙<–-inv-r : (⊙e : X ⊙≃ Y) → ⊙–> ⊙e ⊙∘ ⊙<– ⊙e == ⊙idf _
⊙<–-inv-r ⊙e = ⊙λ= (<–-inv-r (⊙≃-to-≃ ⊙e) , ↓-idf=cst-in' (lemma ⊙e)) where
lemma : {Y : Ptd j} (⊙e : X ⊙≃ Y)
→ snd (⊙–> ⊙e ⊙∘ ⊙<– ⊙e) == is-equiv.f-g (snd ⊙e) (pt Y)
lemma ((f , idp) , f-ise) = ∙-unit-r _ ∙ is-equiv.adj f-ise (pt X)
module _ {i} {X Y : Ptd i} where
⊙<–-inv-l-=⊙∘ : (⊙e : X ⊙≃ Y) → ⊙<– ⊙e ◃⊙∘ ⊙–> ⊙e ◃⊙idf =⊙∘ ⊙idf-seq
⊙<–-inv-l-=⊙∘ ⊙e = =⊙∘-in (⊙<–-inv-l ⊙e)
⊙<–-inv-r-=⊙∘ : (⊙e : X ⊙≃ Y) → ⊙–> ⊙e ◃⊙∘ ⊙<– ⊙e ◃⊙idf =⊙∘ ⊙idf-seq
⊙<–-inv-r-=⊙∘ ⊙e = =⊙∘-in (⊙<–-inv-r ⊙e)
module _ {i j k} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} (⊙e : X ⊙≃ Y) where
post⊙∘-is-equiv : is-equiv (λ (k : Z ⊙→ X) → ⊙–> ⊙e ⊙∘ k)
post⊙∘-is-equiv = is-eq (⊙–> ⊙e ⊙∘_) (⊙<– ⊙e ⊙∘_) (to-from ⊙e) (from-to ⊙e) where
abstract
to-from : ∀ {Y} (⊙e : X ⊙≃ Y) (k : Z ⊙→ Y) → ⊙–> ⊙e ⊙∘ (⊙<– ⊙e ⊙∘ k) == k
to-from ((f , idp) , f-ise) (k , k-pt) = ⊙λ=' (f.f-g ∘ k) (↓-idf=cst-in' $ lemma k-pt)
where
module f = is-equiv f-ise
lemma : ∀ {y₀} (k-pt : y₀ == f (pt X))
→ ⊙∘-pt f (⊙∘-pt f.g k-pt (f.g-f _)) idp == f.f-g y₀ ∙' k-pt
lemma idp = ∙-unit-r _ ∙ f.adj _
from-to : ∀ {Y} (⊙e : X ⊙≃ Y) (k : Z ⊙→ X) → ⊙<– ⊙e ⊙∘ (⊙–> ⊙e ⊙∘ k) == k
from-to ((f , idp) , f-ise) (k , idp) = ⊙λ=' (f.g-f ∘ k) $ ↓-idf=cst-in' idp
where module f = is-equiv f-ise
post⊙∘-equiv : (Z ⊙→ X) ≃ (Z ⊙→ Y)
post⊙∘-equiv = _ , post⊙∘-is-equiv
pre⊙∘-is-equiv : is-equiv (λ (k : Y ⊙→ Z) → k ⊙∘ ⊙–> ⊙e)
pre⊙∘-is-equiv = is-eq (_⊙∘ ⊙–> ⊙e) (_⊙∘ ⊙<– ⊙e) (to-from ⊙e) (from-to ⊙e) where
abstract
to-from : ∀ {Z} (⊙e : X ⊙≃ Y) (k : X ⊙→ Z) → (k ⊙∘ ⊙<– ⊙e) ⊙∘ ⊙–> ⊙e == k
to-from ((f , idp) , f-ise) (k , idp) = ⊙λ=' (ap k ∘ f.g-f) $ ↓-idf=cst-in' $ ∙-unit-r _
where module f = is-equiv f-ise
from-to : ∀ {Z} (⊙e : X ⊙≃ Y) (k : Y ⊙→ Z) → (k ⊙∘ ⊙–> ⊙e) ⊙∘ ⊙<– ⊙e == k
from-to ((f , idp) , f-ise) (k , idp) = ⊙λ=' (ap k ∘ f.f-g) $ ↓-idf=cst-in' $
∙-unit-r _ ∙ ap-∘ k f (f.g-f (pt X)) ∙ ap (ap k) (f.adj (pt X))
where module f = is-equiv f-ise
pre⊙∘-equiv : (Y ⊙→ Z) ≃ (X ⊙→ Z)
pre⊙∘-equiv = _ , pre⊙∘-is-equiv
{- Pointed maps out of bool -}
-- intuition : [f true] is fixed and the only changable part is [f false].
⊙Bool→-to-idf : ∀ {i} {X : Ptd i}
→ ⊙Bool ⊙→ X → de⊙ X
⊙Bool→-to-idf (h , _) = h false
⊙Bool→-equiv-idf : ∀ {i} (X : Ptd i)
→ (⊙Bool ⊙→ X) ≃ de⊙ X
⊙Bool→-equiv-idf {i} X = equiv ⊙Bool→-to-idf g f-g g-f
where
g : de⊙ X → ⊙Bool ⊙→ X
g x = Bool-rec (pt X) x , idp
abstract
f-g : ∀ x → ⊙Bool→-to-idf (g x) == x
f-g x = idp
g-f : ∀ H → g (⊙Bool→-to-idf H) == H
g-f (h , hpt) = pair=
(λ= lemma)
(↓-app=cst-in $
idp
=⟨ ! (!-inv-l hpt) ⟩
! hpt ∙ hpt
=⟨ ! (app=-β lemma true) |in-ctx (λ w → w ∙ hpt) ⟩
app= (λ= lemma) true ∙ hpt
=∎)
where lemma : ∀ b → fst (g (h false)) b == h b
lemma true = ! hpt
lemma false = idp
⊙Bool→-equiv-idf-nat : ∀ {i j} {X : Ptd i} {Y : Ptd j} (F : X ⊙→ Y)
→ CommSquareEquiv
(F ⊙∘_)
(fst F)
⊙Bool→-to-idf
⊙Bool→-to-idf
⊙Bool→-equiv-idf-nat F = (comm-sqr λ _ → idp) ,
snd (⊙Bool→-equiv-idf _) , snd (⊙Bool→-equiv-idf _)
|
{
"alphanum_fraction": 0.438290254,
"avg_line_length": 32.6167883212,
"ext": "agda",
"hexsha": "86ef4538d0b91c50d083a070efd14d4084919bfe",
"lang": "Agda",
"max_forks_count": 50,
"max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z",
"max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "AntoineAllioux/HoTT-Agda",
"max_forks_repo_path": "core/lib/types/Pointed.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "AntoineAllioux/HoTT-Agda",
"max_issues_repo_path": "core/lib/types/Pointed.agda",
"max_line_length": 94,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "AntoineAllioux/HoTT-Agda",
"max_stars_repo_path": "core/lib/types/Pointed.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z",
"num_tokens": 4928,
"size": 8937
}
|
open import Signature
-- | One signature for terms and one for predicates.
module Logic (Σ Δ : Sig) (V : Set) where
open import Data.Empty renaming (⊥ to Ø)
open import Data.Unit
open import Data.Sum
open import Data.Product renaming (Σ to ∐)
open import Data.Nat
open import Data.Fin
FinSet : Set → Set
FinSet X = ∃ λ n → (Fin n → X)
dom : ∀{X} → FinSet X → Set
dom (n , _) = Fin n
get : ∀{X} (F : FinSet X) → dom F → X
get (_ , f) k = f k
drop : ∀{X} (F : FinSet
domEmpty : ∀{X} → FinSet X → Set
domEmpty (zero , _) = ⊤
domEmpty (suc _ , _) = Ø
open import Terms Σ
Term : Set
Term = T V
-- | An atom is either a predicate on terms or bottom.
Atom : Set
Atom = ⟪ Δ ⟫ Term -- ⊎ ⊤
{-
⊥ : Atom
⊥ = inj₂ tt
-}
Formula : Set
Formula = Atom
Sentence : Set
Sentence = FinSet Formula
data Parity : Set where
ind : Parity
coind : Parity
record Clause : Set where
constructor _⊢[_]_
field
head : Sentence
par : Parity
concl : Formula
open Clause public
Program : Set
Program = FinSet Clause
indClauses : Program → Program
indClauses (zero , P) = zero , λ ()
indClauses (suc n , P) = {!!}
|
{
"alphanum_fraction": 0.6318141197,
"avg_line_length": 16.7014925373,
"ext": "agda",
"hexsha": "bca5438b8a2ccaa4cef75fbbc93790cdd8354fa0",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hbasold/Sandbox",
"max_forks_repo_path": "LP/Logic.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "hbasold/Sandbox",
"max_issues_repo_path": "LP/Logic.agda",
"max_line_length": 54,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hbasold/Sandbox",
"max_stars_repo_path": "LP/Logic.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 382,
"size": 1119
}
|
-- Andreas, 2017-01-24, issue #2429
-- Respect subtyping also for irrelevant lambdas!
-- Subtyping: (.A → B) ≤ (A → B)
-- Where a function is expected, we can put one which does not use its argument.
id : ∀{A B : Set} → (.A → B) → A → B
id f = f
test : ∀{A B : Set} → (.A → B) → A → B
test f = λ .a → f a
-- Should work!
-- The eta-expansion should not change anything!
|
{
"alphanum_fraction": 0.5962566845,
"avg_line_length": 24.9333333333,
"ext": "agda",
"hexsha": "1dd1c054a64bc2094ce3cb55a002c843a24916ba",
"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/Issue2429-subtyping.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"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": "hborum/agda",
"max_issues_repo_path": "test/Succeed/Issue2429-subtyping.agda",
"max_line_length": 80,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "hborum/agda",
"max_stars_repo_path": "test/Succeed/Issue2429-subtyping.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": 128,
"size": 374
}
|
{-# OPTIONS --cubical --safe #-}
module Data.Empty.Properties where
open import Data.Empty.Base
open import Level
open import HLevels
isProp⊥ : isProp ⊥
isProp⊥ ()
isProp¬ : (A : Type a) → isProp (¬ A)
isProp¬ _ f g i x = isProp⊥ (f x) (g x) i
|
{
"alphanum_fraction": 0.6506024096,
"avg_line_length": 16.6,
"ext": "agda",
"hexsha": "249a09694759c91090725e8e72779e179524dcd6",
"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/Empty/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-playground",
"max_issues_repo_path": "Data/Empty/Properties.agda",
"max_line_length": 41,
"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/Empty/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z",
"num_tokens": 88,
"size": 249
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- The type for booleans and some operations
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Bool.Base where
open import Data.Unit.Base using (⊤)
open import Data.Empty
open import Relation.Nullary
infixr 6 _∧_
infixr 5 _∨_ _xor_
infix 0 if_then_else_
------------------------------------------------------------------------
-- The boolean type
open import Agda.Builtin.Bool public
------------------------------------------------------------------------
-- Some operations
not : Bool → Bool
not true = false
not false = true
-- A function mapping true to an inhabited type and false to an empty
-- type.
T : Bool → Set
T true = ⊤
T false = ⊥
if_then_else_ : ∀ {a} {A : Set a} → Bool → A → A → A
if true then t else f = t
if false then t else f = f
_∧_ : Bool → Bool → Bool
true ∧ b = b
false ∧ b = false
_∨_ : Bool → Bool → Bool
true ∨ b = true
false ∨ b = b
_xor_ : Bool → Bool → Bool
true xor b = not b
false xor b = b
|
{
"alphanum_fraction": 0.4857142857,
"avg_line_length": 21.1320754717,
"ext": "agda",
"hexsha": "201ac71e304a024836603e6cf5326769f6145419",
"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/Bool/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Bool/Base.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/Bool/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 280,
"size": 1120
}
|
open import prelude
open import ch6 using (Term ; var ; fun ; _$_ ; two ; four)
-- A stack is a list of values
-- Values are either closures or errors
data Value : Set where
error : Value
closure : List(Value) → Term → Value
Stack = List(Value)
lookup : (s : Stack) → (x : Nat) → Value
lookup nil x = error
lookup (v :: s) zero = v
lookup (v :: s) (suc x) = lookup s x
-- Big step sematics
data _▷_⇓_ : Stack → Term → Value → Set where
E─Var : ∀ {s x} →
--------------------------
s ▷ (var x) ⇓ (lookup s x)
E─Fun : ∀ {s t} →
---------------------------
s ▷ (fun t) ⇓ (closure s t)
E─App : ∀ {s s′ t t′ u u′ v} →
s ▷ t ⇓ (closure s′ t′) →
s ▷ u ⇓ u′ →
(u′ :: s′) ▷ t′ ⇓ v →
-------------------
s ▷ (t $ u) ⇓ v
E─AppErr : ∀ {s t u} →
s ▷ t ⇓ error →
-------------------
s ▷ (t $ u) ⇓ error
-- An interpreter result
data Result : Stack → Term → Set where
result : ∀ {s t} →
(v : Value) →
(s ▷ t ⇓ v) →
-------------
Result s t
{-# NON_TERMINATING #-}
interpret : (s : Stack) → (t : Term) → Result s t
interpret s (var x) = result (lookup s x) E─Var
interpret s (fun t) = result (closure s t) E─Fun
interpret s (t₁ $ t₂) = helper₁ (interpret s t₁) where
helper₃ : ∀ {s′ t′ u′} → (s ▷ t₁ ⇓ (closure s′ t′)) → (s ▷ t₂ ⇓ u′) → Result (u′ :: s′) t′ → Result s (t₁ $ t₂)
helper₃ p q (result v r) = result v (E─App p q r)
helper₂ : ∀ {s′ t′} → (s ▷ t₁ ⇓ (closure s′ t′)) → Result s t₂ → Result s (t₁ $ t₂)
helper₂ {s′} {t′} p (result u′ q) = helper₃ p q (interpret (u′ :: s′) t′)
helper₁ : Result s t₁ → Result s (t₁ $ t₂)
helper₁ (result error p) = result error (E─AppErr p)
helper₁ (result (closure s′ t′) p) = helper₂ p (interpret s t₂)
-- Shorthand for starting from the empty stack
i = interpret nil
|
{
"alphanum_fraction": 0.4991807755,
"avg_line_length": 24.0921052632,
"ext": "agda",
"hexsha": "bd74f1b2671a5cdc933ccfabdd1af16db26bcd63",
"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": "de2ae6c24d001b85a5032c9e06cc731557dbc5e5",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "asajeffrey/tapl",
"max_forks_repo_path": "ch6-stack-machine.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "de2ae6c24d001b85a5032c9e06cc731557dbc5e5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "asajeffrey/tapl",
"max_issues_repo_path": "ch6-stack-machine.agda",
"max_line_length": 113,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "de2ae6c24d001b85a5032c9e06cc731557dbc5e5",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "asajeffrey/tapl",
"max_stars_repo_path": "ch6-stack-machine.agda",
"max_stars_repo_stars_event_max_datetime": "2021-03-15T12:09:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-03-12T22:44:19.000Z",
"num_tokens": 690,
"size": 1831
}
|
------------------------------------------------------------------------------
-- Agda-Prop Library.
-- Normal Forms.
------------------------------------------------------------------------------
open import Data.Nat using (ℕ)
module Data.PropFormula.NormalForms (n : ℕ) where
------------------------------------------------------------------------------
open import Data.Nat.Base public
open import Data.Fin using ( Fin; #_ )
open import Data.List using ( List; [_]; []; _++_; _∷_ ; concatMap; map )
open import Data.PropFormula.Properties n using ( subst )
open import Data.PropFormula.Syntax n
open import Data.PropFormula.Theorems n
open import Relation.Nullary using (yes; no)
open import Function using ( _∘_; _$_ )
open import Relation.Binary.PropositionalEquality using ( _≡_; sym )
------------------------------------------------------------------------------
data Literal : Set where
Var : Fin n → Literal
¬l_ : Literal → Literal
Clause : Set
Clause = List Literal
------------------------------------------------------------------------------
-- Conjunctive Normal Form (CNF)
------------------------------------------------------------------------------
Cnf : Set
Cnf = List Clause
varCnf_ : Literal → Cnf
varCnf l = [ [ l ] ]
_∧Cnf_ : (φ ψ : Cnf) → Cnf
φ ∧Cnf ψ = φ ++ ψ
_∨Cnf_ : (φ ψ : Cnf) → Cnf
[] ∨Cnf ψ = ψ
φ ∨Cnf [] = []
cls ∨Cnf (x ∷ ψ) = (cls ∨⋆ x) ∧Cnf (cls ∨Cnf ψ)
where
_∨⋆_ : Cnf → Clause → Cnf
xs ∨⋆ ys = concatMap (λ x → [ x ++ ys ]) xs
¬Cnf₀_ : Literal → Literal
¬Cnf₀ Var x = ¬l Var x
¬Cnf₀ (¬l lit) = lit
¬Cnf₁ : Clause → Cnf
¬Cnf₁ [] = [] -- ¬ ⊥ → ⊤
¬Cnf₁ cls = map (λ lit → [ ¬Cnf₀ lit ]) cls
¬Cnf : Cnf → Cnf
¬Cnf [] = [ [] ]
¬Cnf fm = concatMap (λ cl → ¬Cnf₁ cl) fm
_⊃Cnf_ : (φ ψ : Cnf) → Cnf
φ ⊃Cnf ψ = (¬Cnf φ) ∨Cnf ψ
_⇔Cnf_ : (φ ψ : Cnf) → Cnf
φ ⇔Cnf ψ = (φ ⊃Cnf ψ) ∧Cnf (ψ ⊃Cnf φ)
toCnf : PropFormula → Cnf
toCnf (Var x) = varCnf Var x
toCnf ⊤ = []
toCnf ⊥ = [ [] ]
toCnf (φ ∧ ψ) = toCnf φ ∧Cnf toCnf ψ
toCnf (φ ∨ ψ) = toCnf φ ∨Cnf toCnf ψ
toCnf (φ ⊃ ψ) = toCnf φ ⊃Cnf toCnf ψ
toCnf (φ ⇔ ψ) = toCnf φ ⇔Cnf toCnf ψ
toCnf (¬ φ) = ¬Cnf (toCnf φ)
toPropLiteral : Literal → PropFormula
toPropLiteral (Var x) = Var x
toPropLiteral (¬l lit) = ¬ toPropLiteral lit
toPropClause : Clause → PropFormula
toPropClause [] = ⊥
toPropClause (l ∷ []) = toPropLiteral l
toPropClause (l ∷ ls) = toPropLiteral l ∨ toPropClause ls
toProp : Cnf → PropFormula
toProp [] = ⊤
toProp (fm ∷ [] ) = toPropClause fm
toProp (fm ∷ fms) = toPropClause fm ∧ toProp fms
cnf : PropFormula → PropFormula
cnf = toProp ∘ toCnf
|
{
"alphanum_fraction": 0.4979031643,
"avg_line_length": 26.4949494949,
"ext": "agda",
"hexsha": "6498295209ca303935cf6de4b9e15c9d00c448a3",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2017-12-01T17:01:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-03-30T16:41:56.000Z",
"max_forks_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "jonaprieto/agda-prop",
"max_forks_repo_path": "notes/NormalForms.agda",
"max_issues_count": 18,
"max_issues_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae",
"max_issues_repo_issues_event_max_datetime": "2017-12-18T16:34:21.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-03-08T14:33:10.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "jonaprieto/agda-prop",
"max_issues_repo_path": "notes/NormalForms.agda",
"max_line_length": 78,
"max_stars_count": 13,
"max_stars_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "jonaprieto/agda-prop",
"max_stars_repo_path": "notes/NormalForms.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-17T03:33:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-05-01T16:45:41.000Z",
"num_tokens": 912,
"size": 2623
}
|
module Prelude.Equality.Inspect where
open import Prelude.Function using (id)
open import Prelude.Equality
open import Prelude.Product
module _ {a b} {A : Set a} {B : A → Set b} (f : ∀ x → B x) (x : A) where
-- The Graph idiom is more powerful than the old Inspect idiom
-- (defined in terms of Graph below), in that it lets you both
-- abstract over a term and keep the equation that the old term
-- equals the abstracted variable.
-- Use as follows:
-- example : Γ → T (f e)
-- example xs with f e | graphAt f e
-- ... | z | ingraph eq = ? -- eq : f e ≡ z, goal : T z
data Graph (y : B x) : Set b where
ingraph : f x ≡ y → Graph y
graphAt : Graph (f x)
graphAt = ingraph refl
{-# INLINE graphAt #-}
module _ {a} {A : Set a} where
Inspect : A → Set a
Inspect x = Σ _ λ y → Graph id x y
infix 4 _with≡_
pattern _with≡_ x eq = x , ingraph eq
inspect : ∀ x → Inspect x
inspect x = x , ingraph refl
{-# INLINE inspect #-}
|
{
"alphanum_fraction": 0.6159346272,
"avg_line_length": 25.7631578947,
"ext": "agda",
"hexsha": "563d36b35685ebbcc59c8064b791d3b66a0ef3fd",
"lang": "Agda",
"max_forks_count": 24,
"max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z",
"max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "L-TChen/agda-prelude",
"max_forks_repo_path": "src/Prelude/Equality/Inspect.agda",
"max_issues_count": 59,
"max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "L-TChen/agda-prelude",
"max_issues_repo_path": "src/Prelude/Equality/Inspect.agda",
"max_line_length": 72,
"max_stars_count": 111,
"max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "L-TChen/agda-prelude",
"max_stars_repo_path": "src/Prelude/Equality/Inspect.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z",
"num_tokens": 320,
"size": 979
}
|
module Issue2492 where
open import Agda.Builtin.Nat
infix 0 _!
data Singleton {A : Set} : A → Set where
_! : (a : A) → Singleton a
_ : Singleton 10
_ = {!!}
|
{
"alphanum_fraction": 0.6358024691,
"avg_line_length": 14.7272727273,
"ext": "agda",
"hexsha": "d8023e5120a9b74ffdff2dc82b7083bbbbec6a4f",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/interaction/Issue2492.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/interaction/Issue2492.agda",
"max_line_length": 40,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/interaction/Issue2492.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": 57,
"size": 162
}
|
------------------------------------------------------------------------
-- Application of substitutions
------------------------------------------------------------------------
open import Data.Universe.Indexed
module deBruijn.Substitution.Data.Application.Application
{i u e} {Uni : IndexedUniverse i u e} where
import deBruijn.Context; open deBruijn.Context Uni
open import deBruijn.Substitution.Data.Basics
open import deBruijn.Substitution.Data.Map
open import Level using (_⊔_)
import Relation.Binary.PropositionalEquality as P
-- Given an operation which applies substitutions to terms one can
-- define composition of substitutions.
record Application
{t₁} (T₁ : Term-like t₁)
{t₂} (T₂ : Term-like t₂) :
Set (i ⊔ u ⊔ e ⊔ t₁ ⊔ t₂) where
open Term-like T₂ renaming (_⊢_ to _⊢₂_; _≅-⊢_ to _≅-⊢₂_)
field
-- Application of substitutions to terms.
app : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} → Sub T₁ ρ̂ → [ T₂ ⟶ T₂ ] ρ̂
-- Post-application of substitutions to terms.
infixl 8 _/⊢_
_/⊢_ : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} → Γ ⊢₂ σ → Sub T₁ ρ̂ → Δ ⊢₂ σ /̂ ρ̂
t /⊢ ρ = app ρ · t
-- Reverse composition. (Fits well with post-application.)
infixl 9 _∘_
_∘_ : ∀ {Γ Δ Ε} {ρ̂₁ : Γ ⇨̂ Δ} {ρ̂₂ : Δ ⇨̂ Ε} →
Sub T₂ ρ̂₁ → Sub T₁ ρ̂₂ → Sub T₂ (ρ̂₁ ∘̂ ρ̂₂)
ρ₁ ∘ ρ₂ = map (app ρ₂) ρ₁
-- Application of multiple substitutions to terms.
app⋆ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} → Subs T₁ ρ̂ → [ T₂ ⟶ T₂ ] ρ̂
app⋆ = fold [ T₂ ⟶ T₂ ] [id] (λ f ρ → app ρ [∘] f)
infixl 8 _/⊢⋆_
_/⊢⋆_ : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} → Γ ⊢₂ σ → Subs T₁ ρ̂ → Δ ⊢₂ σ /̂ ρ̂
t /⊢⋆ ρs = app⋆ ρs · t
-- Some congruence lemmas.
app-cong : ∀ {Γ₁ Δ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρ₁ : Sub T₁ ρ̂₁}
{Γ₂ Δ₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρ₂ : Sub T₁ ρ̂₂} →
ρ₁ ≅-⇨ ρ₂ → app ρ₁ ≅-⟶ app ρ₂
app-cong P.refl = [ P.refl ]
/⊢-cong :
∀ {Γ₁ Δ₁ σ₁} {t₁ : Γ₁ ⊢₂ σ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρ₁ : Sub T₁ ρ̂₁}
{Γ₂ Δ₂ σ₂} {t₂ : Γ₂ ⊢₂ σ₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρ₂ : Sub T₁ ρ̂₂} →
t₁ ≅-⊢₂ t₂ → ρ₁ ≅-⇨ ρ₂ → t₁ /⊢ ρ₁ ≅-⊢₂ t₂ /⊢ ρ₂
/⊢-cong P.refl P.refl = P.refl
∘-cong :
∀ {Γ₁ Δ₁ Ε₁} {ρ̂₁₁ : Γ₁ ⇨̂ Δ₁} {ρ̂₂₁ : Δ₁ ⇨̂ Ε₁}
{ρ₁₁ : Sub T₂ ρ̂₁₁} {ρ₂₁ : Sub T₁ ρ̂₂₁}
{Γ₂ Δ₂ Ε₂} {ρ̂₁₂ : Γ₂ ⇨̂ Δ₂} {ρ̂₂₂ : Δ₂ ⇨̂ Ε₂}
{ρ₁₂ : Sub T₂ ρ̂₁₂} {ρ₂₂ : Sub T₁ ρ̂₂₂} →
ρ₁₁ ≅-⇨ ρ₁₂ → ρ₂₁ ≅-⇨ ρ₂₂ → ρ₁₁ ∘ ρ₂₁ ≅-⇨ ρ₁₂ ∘ ρ₂₂
∘-cong P.refl P.refl = P.refl
app⋆-cong : ∀ {Γ₁ Δ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρs₁ : Subs T₁ ρ̂₁}
{Γ₂ Δ₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρs₂ : Subs T₁ ρ̂₂} →
ρs₁ ≅-⇨⋆ ρs₂ → app⋆ ρs₁ ≅-⟶ app⋆ ρs₂
app⋆-cong P.refl = [ P.refl ]
/⊢⋆-cong :
∀ {Γ₁ Δ₁ σ₁} {t₁ : Γ₁ ⊢₂ σ₁} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρs₁ : Subs T₁ ρ̂₁}
{Γ₂ Δ₂ σ₂} {t₂ : Γ₂ ⊢₂ σ₂} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρs₂ : Subs T₁ ρ̂₂} →
t₁ ≅-⊢₂ t₂ → ρs₁ ≅-⇨⋆ ρs₂ → t₁ /⊢⋆ ρs₁ ≅-⊢₂ t₂ /⊢⋆ ρs₂
/⊢⋆-cong P.refl P.refl = P.refl
abstract
-- An unfolding lemma.
▻-∘ : ∀ {Γ Δ Ε} {ρ̂₁ : Γ ⇨̂ Δ} {ρ̂₂ : Δ ⇨̂ Ε} {σ}
(ρ₁ : Sub T₂ ρ̂₁) (t : Δ ⊢₂ σ / ρ₁) (ρ₂ : Sub T₁ ρ̂₂) →
(ρ₁ ▻⇨[ σ ] t) ∘ ρ₂ ≅-⇨ ρ₁ ∘ ρ₂ ▻⇨[ σ ] t /⊢ ρ₂
▻-∘ ρ₁ t ρ₂ = map-▻ (app ρ₂) ρ₁ t
-- Applying a composed substitution to a variable is equivalent to
-- applying one substitution and then the other.
/∋-∘ : ∀ {Γ Δ Ε σ} {ρ̂₁ : Γ ⇨̂ Δ} {ρ̂₂ : Δ ⇨̂ Ε}
(x : Γ ∋ σ) (ρ₁ : Sub T₂ ρ̂₁) (ρ₂ : Sub T₁ ρ̂₂) →
x /∋ ρ₁ ∘ ρ₂ ≅-⊢₂ x /∋ ρ₁ /⊢ ρ₂
/∋-∘ x ρ₁ ρ₂ = /∋-map x (app ρ₂) ρ₁
|
{
"alphanum_fraction": 0.4776825303,
"avg_line_length": 32.8446601942,
"ext": "agda",
"hexsha": "01dca6a90e4f668661fe76d4e5bfd46f2eb07b15",
"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": "deBruijn/Substitution/Data/Application/Application.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": "deBruijn/Substitution/Data/Application/Application.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": "deBruijn/Substitution/Data/Application/Application.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": 1907,
"size": 3383
}
|
-- Andreas, 2021-10-08, first test case for unsupported generalization
variable
X : Set
Y = X
-- Expected:
-- Generalizable variable GeneralizeRHS.X is not supported here
-- when scope checking X
|
{
"alphanum_fraction": 0.7412935323,
"avg_line_length": 18.2727272727,
"ext": "agda",
"hexsha": "73d615a71d2ad8eb44aad5c98d9cef1a739bffcb",
"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/GeneralizeRHS.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/GeneralizeRHS.agda",
"max_line_length": 70,
"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/GeneralizeRHS.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": 201
}
|
module Text.XML.Everything where
-- Imported packages
import Web.URI.Everything
|
{
"alphanum_fraction": 0.8048780488,
"avg_line_length": 13.6666666667,
"ext": "agda",
"hexsha": "8049889191a06130e01cb4ca53821ee9f03ba183",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:38:28.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:38:28.000Z",
"max_forks_repo_head_hexsha": "ebf33024374ad8adb72d9f41432fda1465ef5f5a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/agda-text-xml",
"max_forks_repo_path": "src/Text/XML/Everything.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ebf33024374ad8adb72d9f41432fda1465ef5f5a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/agda-text-xml",
"max_issues_repo_path": "src/Text/XML/Everything.agda",
"max_line_length": 32,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ebf33024374ad8adb72d9f41432fda1465ef5f5a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/agda-text-xml",
"max_stars_repo_path": "src/Text/XML/Everything.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 19,
"size": 82
}
|
open import bool
open import list
open import nat
_⇒_ : 𝕃 Set → Set → Set
[] ⇒ rettp = rettp
(x :: inputtps) ⇒ rettp = x → inputtps ⇒ rettp
_⇒𝕃_ : 𝕃 Set → Set → Set
inputtps ⇒𝕃 rettp = (map 𝕃 inputtps) ⇒ (𝕃 rettp)
eatInputs : {inputtps : 𝕃 Set}{rettp : Set} → inputtps ⇒𝕃 rettp
eatInputs {[]} {rettp₁} = []
eatInputs {x₁ :: inputtps₁} {rettp₁} _ = eatInputs{inputtps₁}{rettp₁}
zipWith : {inputtps : 𝕃 Set}{rettp : Set} → (inputtps ⇒ rettp) → inputtps ⇒𝕃 rettp
zipWith {[]} {rettp} a = [ a ]
zipWith {tp :: inputtps} {rettp} f [] = eatInputs {inputtps}{rettp}
zipWith {tp :: inputtps} {rettp} f (h :: t) =
helper{inputtps}{rettp} (f h) (zipWith{tp :: inputtps}{rettp} f t)
where helper : {inputtps : 𝕃 Set}{rettp : Set} →
inputtps ⇒ rettp →
inputtps ⇒𝕃 rettp →
inputtps ⇒𝕃 rettp
helper {[]} {rettp₁} f F = f :: F
helper {tp :: inputtps} {rettp} _ _ [] = eatInputs{inputtps}{rettp}
helper {tp :: inputtps} {rettp} f F (h :: t) = helper{inputtps}{rettp} (f h) (F t)
testTpList : 𝕃 Set
testTpList = (𝔹 :: ℕ :: ℕ :: [])
test = zipWith{testTpList}{ℕ} (λ b n m → if b then n else m) (tt :: tt :: ff :: []) (1 :: 2 :: 3 :: []) (10 :: 20 :: 30 :: 1000 :: [])
|
{
"alphanum_fraction": 0.5614886731,
"avg_line_length": 37.4545454545,
"ext": "agda",
"hexsha": "931c356a92dc16e02f6e189970c159a3da067913",
"lang": "Agda",
"max_forks_count": 17,
"max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z",
"max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "rfindler/ial",
"max_forks_repo_path": "list-zipWith.agda",
"max_issues_count": 8,
"max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6",
"max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "rfindler/ial",
"max_issues_repo_path": "list-zipWith.agda",
"max_line_length": 134,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "rfindler/ial",
"max_stars_repo_path": "list-zipWith.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z",
"num_tokens": 486,
"size": 1236
}
|
module Data.Tuple.Equiv where
import Lvl
open import Data.Tuple as Tuple using (_⨯_ ; _,_)
open import Structure.Function
open import Structure.Operator
open import Structure.Setoid
open import Type
private variable ℓ ℓₑ ℓₑ₁ ℓₑ₂ : Lvl.Level
private variable A B : Type{ℓ}
record Extensionality ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄ ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ (equiv : Equiv{ℓₑ}(A ⨯ B)) : Type{Lvl.of(A) Lvl.⊔ Lvl.of(B) Lvl.⊔ ℓₑ₁ Lvl.⊔ ℓₑ₂ Lvl.⊔ ℓₑ} where
constructor intro
private instance _ = equiv
field
⦃ [,]-function ⦄ : BinaryOperator(_,_)
⦃ left-function ⦄ : Function(Tuple.left)
⦃ right-function ⦄ : Function(Tuple.right)
|
{
"alphanum_fraction": 0.688751926,
"avg_line_length": 32.45,
"ext": "agda",
"hexsha": "d7ad47b6a4846949c3ac5a7a0662b6dc69efc153",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Data/Tuple/Equiv.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Data/Tuple/Equiv.agda",
"max_line_length": 173,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Data/Tuple/Equiv.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": 258,
"size": 649
}
|
module PosFunction where
data Functor : Set1 where
|Id| : Functor
|K| : Set -> Functor
_|+|_ : Functor -> Functor -> Functor
_|x|_ : Functor -> Functor -> Functor
data _⊕_ (A B : Set) : Set where
inl : A -> A ⊕ B
inr : B -> A ⊕ B
data _×_ (A B : Set) : Set where
_,_ : A -> B -> A × B
-- The positivity checker can see that [_] is positive in its second argument.
[_] : Functor -> Set -> Set
[ |Id| ] X = X
[ |K| A ] X = A
[ F |+| G ] X = [ F ] X ⊕ [ G ] X
[ F |x| G ] X = [ F ] X × [ G ] X
data μ_ (F : Functor) : Set where
<_> : [ F ] (μ F) -> μ F
|
{
"alphanum_fraction": 0.5008635579,
"avg_line_length": 23.16,
"ext": "agda",
"hexsha": "a666ed6cfba836d2b9065ca1c857ae36aa32b917",
"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/PosFunction.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/PosFunction.agda",
"max_line_length": 78,
"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/PosFunction.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": 230,
"size": 579
}
|
module UniDB.Subst.Star where
open import UniDB.Subst.Core
open import UniDB.Morph.Star
module _
{T : STX} {{vrT : Vr T}} {{apTT : Ap T T}}
{Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}}
where
instance
iLkStar : Lk T (Star Ξ)
lk {{iLkStar}} ε i = vr i
lk {{iLkStar}} (ξs ▻ ξ) i = ap {T} ξ (lk ξs i)
iLkIdmStar : LkIdm T (Star Ξ)
lk-idm {{iLkIdmStar}} i = refl
-- iLkCompApStar : {{apIdmT : ApIdm T T}} → LkCompAp T (Star Ξ)
-- lk-⊙-ap {{iLkCompApStar}} ξs ε i = sym (ap-idm T T (Star Ξ) (lk T (Star Ξ) ξs i))
-- lk-⊙-ap {{iLkCompApStar}} ξs (ζs ▻ ζ) i =
-- begin
-- ap T T Ξ ζ (lk T (Star Ξ) (ξs ⊙ ζs) i)
-- ≡⟨ cong (ap T T Ξ ζ) (lk-⊙-ap T (Star Ξ) ξs ζs i) ⟩
-- ap T T Ξ ζ (ap T T (Star Ξ) ζs (lk T (Star Ξ) ξs i))
-- ≡⟨ {!!} ⟩
-- ap T T (Star Ξ) (ζs ▻ ζ) (lk T (Star Ξ) ξs i)
-- ∎
|
{
"alphanum_fraction": 0.4859075536,
"avg_line_length": 29.5666666667,
"ext": "agda",
"hexsha": "835a76f5a30f03c099f4b6c03cbb22d845f83efa",
"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": "7ae52205db44ad4f463882ba7e5082120fb76349",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "skeuchel/unidb-agda",
"max_forks_repo_path": "UniDB/Subst/Star.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349",
"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": "skeuchel/unidb-agda",
"max_issues_repo_path": "UniDB/Subst/Star.agda",
"max_line_length": 95,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "skeuchel/unidb-agda",
"max_stars_repo_path": "UniDB/Subst/Star.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 456,
"size": 887
}
|
module Formalization.RecursiveFunction where
import Lvl
open import Data
open import Data.ListSized
open import Numeral.Finite
open import Numeral.Natural
open import Syntax.Number
open import Type{Lvl.𝟎}
-- Function(n) is a syntactic representation of recursive functions of type (ℕⁿ → ℕ).
-- The syntax
data Function : ℕ → Type where
-- Base cases
Base : Function(0)
Successor : Function(1)
Projection : ∀{n : ℕ} → (i : 𝕟(n)) → Function(n)
-- Inductive cases
Composition : ∀{m n : ℕ} → Function(n) → List(Function(m))(n) → Function(m)
Recursion : ∀{n : ℕ} → Function(n) → Function(𝐒(𝐒(n))) → Function(𝐒(n))
Minimization : ∀{n : ℕ} → Function(𝐒(n)) → Function(n)
Primitive : Type
Primitive = ℕ
module _ where
open import Data.ListSized.Functions
open import Functional
open import Logic.Predicate
open import Numeral.Natural.Relation.Order
private variable m n : ℕ
private variable i : 𝕟(n)
private variable x v : Primitive
private variable xs vs : List(Primitive)(n)
private variable f g : Function(m)
private variable fs gs : List(Function(m))(n)
-- The operational semantics.
data _$_⟹_ : ∀{m n} → List(Function(m))(n) → List(Primitive)(m) → List(Primitive)(n) → Type
data _$_⟶_ : ∀{n} → Function(n) → List(Primitive)(n) → ℕ → Type where
zero : (Base $ ∅ ⟶ 𝟎)
succ : (Successor $ singleton(n) ⟶ 𝐒(n))
proj : (Projection{n}(i) $ xs ⟶ index(i)(xs))
comp : (f $ vs ⟶ v) → (gs $ xs ⟹ vs) → (Composition{m}{n} f gs $ xs ⟶ v)
rec𝟎 : (f $ xs ⟶ v) → (Recursion f g $ (𝟎 ⊰ xs) ⟶ v)
rec𝐒 : (Recursion f g $ (n ⊰ xs) ⟶ x) → (g $ (n ⊰ x ⊰ xs) ⟶ v) → (Recursion f g $ (𝐒(n) ⊰ xs) ⟶ v)
min : (f $ (n ⊰ xs) ⟶ 𝟎) → ∃{Obj = ℕ → ℕ}(k ↦ ∀{m} → (m < n) → (f $ (m ⊰ xs) ⟶ 𝐒(k(m)))) → (Minimization f $ xs ⟶ n)
data _$_⟹_ where
base : (∅ $ xs ⟹ ∅)
step : (f $ xs ⟶ v) → (fs $ xs ⟹ vs) → ((f ⊰ fs) $ xs ⟹ (v ⊰ vs))
-- TODO: The denotational semantics should use partial functions, but even if that was used, one needs to decide whether there is a 0 in an arbitrary function's range. This is not possible, I guess?
open import Logic.Propositional
open import Numeral.Natural.Relation.Order.Proofs
open import Relator.Equals
open import Relator.Equals.Proofs
open import Structure.Operator
open import Structure.Setoid.Uniqueness
[$⟹]-deterministic : Unique(fs $ xs ⟹_)
[$⟶]-deterministic : Unique(f $ xs ⟶_)
[$⟶]-deterministic zero zero = [≡]-intro
[$⟶]-deterministic succ succ = [≡]-intro
[$⟶]-deterministic proj proj = [≡]-intro
[$⟶]-deterministic (comp p₁ p₂) (comp q₁ q₂) rewrite [$⟹]-deterministic p₂ q₂ = [$⟶]-deterministic p₁ q₁
[$⟶]-deterministic (rec𝟎 p) (rec𝟎 q) = [$⟶]-deterministic p q
[$⟶]-deterministic (rec𝐒 p₁ p₂) (rec𝐒 q₁ q₂) rewrite [$⟶]-deterministic p₁ q₁ = [$⟶]-deterministic p₂ q₂
[$⟶]-deterministic {x = x}{y = y} (min p₁ ([∃]-intro k₁ ⦃ p₂ ⦄)) (min q₁ ([∃]-intro k₂ ⦃ q₂ ⦄)) with [<]-trichotomy {x}{y}
... | [∨]-introₗ ([∨]-introₗ lt) with () ← [$⟶]-deterministic p₁ (q₂ lt)
... | [∨]-introₗ ([∨]-introᵣ eq) = eq
... | [∨]-introᵣ gt with () ← [$⟶]-deterministic q₁ (p₂ gt)
[$⟹]-deterministic base base = [≡]-intro
[$⟹]-deterministic (step p pl) (step q ql) = congruence₂(_⊰_) ([$⟶]-deterministic p q) ([$⟹]-deterministic pl ql)
[$⟶]-not-total : ∃{Obj = Function(n)}(f ↦ ∀{xs} → ¬ ∃(f $ xs ⟶_))
∃.witness [$⟶]-not-total = Minimization (Composition Successor (singleton (Projection 0)))
∃.proof [$⟶]-not-total ([∃]-intro _ ⦃ min (comp () _) _ ⦄)
|
{
"alphanum_fraction": 0.5991573034,
"avg_line_length": 42.8915662651,
"ext": "agda",
"hexsha": "cce368c228d1c66c7854325c0b38d288661b12b5",
"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": "Formalization/RecursiveFunction.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": "Formalization/RecursiveFunction.agda",
"max_line_length": 200,
"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": "Formalization/RecursiveFunction.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": 1347,
"size": 3560
}
|
{-# OPTIONS --without-K #-}
module FinEquiv where
-- The goal is to establish that finite sets and equivalences form a
-- commutative semiring.
import Level using (zero)
open import Data.Empty using (⊥; ⊥-elim)
open import Data.Unit using (⊤; tt)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Data.Product using (_,_; _×_; proj₁; proj₂)
open import Data.Nat
using (ℕ; zero; suc; _+_; _*_; ≤-pred; _<_; _≤_; _≥_; _≤?_;
module ≤-Reasoning)
open import Data.Nat.DivMod using (_divMod_; result)
open import Data.Nat.Properties using (≰⇒>; 1+n≰n; m≤m+n; ¬i+1+j≤i)
open import Data.Nat.Properties.Simple
using (+-right-identity; +-assoc; +-suc; +-comm; *-right-zero)
open import Data.Fin
using (Fin; zero; suc; inject+; raise; toℕ; fromℕ≤; reduce≥)
open import Data.Fin.Properties
using (bounded; inject+-lemma; toℕ-raise; toℕ-injective; toℕ-fromℕ≤)
open import Algebra using (CommutativeSemiring)
open import Algebra.Structures
using (IsSemigroup; IsCommutativeMonoid; IsCommutativeSemiring)
open import Function using (_∘_; id; case_of_)
open import Relation.Nullary using (yes; no)
open import Relation.Binary using (IsEquivalence)
open import Relation.Binary.PropositionalEquality
using (_≡_; refl; sym; trans; cong; cong₂; subst;
module ≡-Reasoning; inspect; [_])
--
open import Equiv
using (_∼_; _≃_; id≃; sym≃; trans≃; _●_;
qinv; module isqinv; _⊎≃_; _×≃_)
open import TypeEquiv
using (assocl₊equiv; unite₊′equiv;
unite₊equiv; swap₊equiv;
unite⋆equiv; unite⋆′equiv; swap⋆equiv; assocl⋆equiv;
distzequiv; distzrequiv; distequiv; distlequiv)
open import Proofs using (
-- LeqLemmas
_<?_; cong+r≤; cong+l≤; cong*r≤;
-- FinNatLemmas
inj₁-≡; inj₂-≡; inject+-injective; raise-injective; addMul-lemma
)
------------------------------------------------------------------------------
-- This is the relation we are interested in showing is a commutative
-- semiring.
_fin≃_ : (m n : ℕ) → Set
m fin≃ n = Fin m ≃ Fin n
-- Additive unit and multiplicative unit are Fin 0 and Fin 1 which are
-- equivalent to ⊥ and ⊤
abstract
Fin0-⊥ : Fin 0 → ⊥
Fin0-⊥ ()
F0≃⊥ : Fin 0 ≃ ⊥
F0≃⊥ = f , qinv g α β
where
f : Fin 0 → ⊥
f ()
g : ⊥ → Fin 0
g ()
α : f ∘ g ∼ id
α ()
β : g ∘ f ∼ id
β ()
Fin1≃⊤ : Fin 1 ≃ ⊤
Fin1≃⊤ = f , qinv g α β
where
f : Fin 1 → ⊤
f zero = tt
f (suc ())
g : ⊤ → Fin 1
g tt = zero
α : f ∘ g ∼ id
α tt = refl
β : g ∘ f ∼ id
β zero = refl
β (suc ())
------------------------------------------------------------------------------
-- Additive monoid
module Plus where
infix 9 _+F_
-- Main goal is to show (Fin m ⊎ Fin n) ≃ Fin (m + n) It is then
-- fairly easy to show that ⊎ satisfies the commutative monoid
-- axioms
fwd : {m n : ℕ} → (Fin m ⊎ Fin n) → Fin (m + n)
fwd {m} {n} (inj₁ x) = inject+ n x
fwd {m} {n} (inj₂ y) = raise m y
bwd : {m n : ℕ} → Fin (m + n) → (Fin m ⊎ Fin n)
bwd {m} {n} = λ i → case (toℕ i <? m) of λ
{ (yes p) → inj₁ (fromℕ≤ p)
; (no ¬p) → inj₂ (reduce≥ i (≤-pred (≰⇒> ¬p)))
}
fwd∘bwd~id : {m n : ℕ} → fwd {m} {n} ∘ bwd ∼ id
fwd∘bwd~id {m} i with toℕ i <? m
fwd∘bwd~id i | yes p = sym (inj₁-≡ i p)
fwd∘bwd~id i | no ¬p = sym (inj₂-≡ i (≤-pred (≰⇒> ¬p)))
bwd∘fwd~id : {m n : ℕ} → bwd {m} {n} ∘ fwd ∼ id
bwd∘fwd~id {m} {n} (inj₁ x) with toℕ (inject+ n x) <? m
bwd∘fwd~id {n = n} (inj₁ x) | yes p =
cong inj₁
(inject+-injective (fromℕ≤ p) x (sym (inj₁-≡ (inject+ n x) p)))
bwd∘fwd~id {m} {n} (inj₁ x) | no ¬p = ⊥-elim (1+n≰n pf)
where
open ≤-Reasoning
pf : suc (toℕ x) ≤ toℕ x
pf = let q = (≤-pred (≰⇒> ¬p)) in
begin (
suc (toℕ x)
≤⟨ bounded x ⟩
m
≤⟨ q ⟩
toℕ (inject+ n x)
≡⟨ sym (inject+-lemma n x) ⟩
toℕ x ∎ )
bwd∘fwd~id {m} {n} (inj₂ y) with toℕ (raise m y) <? m
bwd∘fwd~id {m} {n} (inj₂ y) | yes p = ⊥-elim (1+n≰n pf)
where
open ≤-Reasoning
pf : suc m ≤ m
pf = begin (
suc m
≤⟨ m≤m+n (suc m) (toℕ y) ⟩
suc (m + toℕ y)
≡⟨ cong suc (sym (toℕ-raise m y)) ⟩
suc (toℕ (raise m y))
≤⟨ p ⟩
m ∎)
bwd∘fwd~id {m} {n} (inj₂ y) | no ¬p =
cong inj₂
(raise-injective {m}
(reduce≥ (raise m y) (≤-pred (≰⇒> ¬p)))
y
(sym (inj₂-≡ (raise m y) (≤-pred (≰⇒> ¬p)))))
-- the main equivalence
fwd-iso : {m n : ℕ} → (Fin m ⊎ Fin n) ≃ Fin (m + n)
fwd-iso {m} {n} = fwd , qinv bwd (fwd∘bwd~id {m}) (bwd∘fwd~id {m})
-- aliases for the above which are more convenient
⊎≃+ : {m n : ℕ} → (Fin m ⊎ Fin n) ≃ Fin (m + n)
⊎≃+ = fwd-iso
+≃⊎ : {m n : ℕ} → Fin (m + n) ≃ (Fin m ⊎ Fin n)
+≃⊎ = sym≃ fwd-iso
-- additive monoid equivalences
-- unite+
unite+ : {m : ℕ} → Fin (0 + m) ≃ Fin m
unite+ = unite₊equiv ● F0≃⊥ ⊎≃ id≃ ● +≃⊎
-- and on the other side as well
unite+r : {m : ℕ} → Fin (m + 0) ≃ Fin m
unite+r = unite₊′equiv ● id≃ ⊎≃ F0≃⊥ ● +≃⊎
-- uniti+
uniti+ : {m : ℕ} → Fin m ≃ Fin (0 + m)
uniti+ = sym≃ unite+
uniti+r : {m : ℕ} → Fin m ≃ Fin (m + 0)
uniti+r = sym≃ unite+r
-- swap₊
swap+ : {m n : ℕ} → Fin (m + n) ≃ Fin (n + m)
swap+ {m} = ⊎≃+ ● swap₊equiv ● +≃⊎ {m}
-- associativity
assocl+ : {m n o : ℕ} → Fin (m + (n + o)) ≃ Fin ((m + n) + o)
assocl+ {m} = ⊎≃+ ● ⊎≃+ ⊎≃ id≃ ● assocl₊equiv ● id≃ ⊎≃ +≃⊎ ● +≃⊎ {m}
assocr+ : {m n o : ℕ} → Fin ((m + n) + o) ≃ Fin (m + (n + o))
assocr+ {m} = sym≃ (assocl+ {m})
-- congruence
_+F_ : {m n o p : ℕ} → (Fin m ≃ Fin n) → (Fin o ≃ Fin p) →
Fin (m + o) ≃ Fin (n + p)
Fm≃Fn +F Fo≃Fp = ⊎≃+ ● Fm≃Fn ⊎≃ Fo≃Fp ● +≃⊎
-----------------------------------------------------------------------------
-- Multiplicative monoid
module Times where
infixl 7 _*F_
-- main goal is to show (Fin m × Fin n) ≃ Fin (m * n) It is then
-- fairly easy to show that × satisfies the commutative monoid
-- axioms
fwd : {m n : ℕ} → (Fin m × Fin n) → Fin (m * n)
fwd {suc m} {n} (zero , k) = inject+ (m * n) k
fwd {n = n} (suc i , k) = raise n (fwd (i , k))
private
soundness : ∀ {m n} (i : Fin m) (j : Fin n) →
toℕ (fwd (i , j)) ≡ toℕ i * n + toℕ j
soundness {suc m} {n} zero j = sym (inject+-lemma (m * n) j)
soundness {n = n} (suc i) j
rewrite toℕ-raise n (fwd (i , j)) | soundness i j
= sym (+-assoc n (toℕ i * n) (toℕ j))
absurd-quotient : (m n q : ℕ) (r : Fin (suc n)) (k : Fin (m * suc n))
(k≡r+q*sn : toℕ k ≡ toℕ r + q * suc n) (p : m ≤ q) → ⊥
absurd-quotient m n q r k k≡r+q*sn p = ¬i+1+j≤i (toℕ k) {toℕ r} k≥k+sr
where k≥k+sr : toℕ k ≥ toℕ k + suc (toℕ r)
k≥k+sr = begin (toℕ k + suc (toℕ r)
≡⟨ +-suc (toℕ k) (toℕ r) ⟩
suc (toℕ k) + toℕ r
≤⟨ cong+r≤ (bounded k) (toℕ r) ⟩
(m * suc n) + toℕ r
≡⟨ +-comm (m * suc n) (toℕ r) ⟩
toℕ r + (m * suc n)
≡⟨ refl ⟩
toℕ r + m * suc n
≤⟨ cong+l≤ (cong*r≤ p (suc n)) (toℕ r) ⟩
toℕ r + q * suc n
≡⟨ sym k≡r+q*sn ⟩
toℕ k ∎)
where open ≤-Reasoning
elim-right-zero : ∀ {ℓ} {Whatever : Set ℓ}
(m : ℕ) → Fin (m * 0) → Whatever
elim-right-zero m i = ⊥-elim (Fin0-⊥ (subst Fin (*-right-zero m) i))
bwd : {m n : ℕ} → Fin (m * n) → (Fin m × Fin n)
bwd {m} {0} k = elim-right-zero m k
bwd {m} {suc n} k with (toℕ k) divMod (suc n)
... | result q r k≡r+q*sn = (fromℕ≤ {q} {m} (q<m) , r)
where
q<m : q < m
q<m with suc q ≤? m
... | no ¬p = ⊥-elim
(absurd-quotient m n q r k k≡r+q*sn
(≤-pred (≰⇒> ¬p)))
... | yes p = p
fwd∘bwd~id : {m n : ℕ} → fwd {m} {n} ∘ bwd ∼ id
fwd∘bwd~id {m} {zero} i = elim-right-zero m i
fwd∘bwd~id {m} {suc n} i with (toℕ i) divMod (suc n)
... | result q r k≡r+q*sn with suc q ≤? m
... | yes p = toℕ-injective (
begin (
toℕ (fwd (fromℕ≤ p , r))
≡⟨ soundness (fromℕ≤ p) r ⟩
toℕ (fromℕ≤ p) * (suc n) + toℕ r
≡⟨ cong (λ x → x * (suc n) + toℕ r) (toℕ-fromℕ≤ p) ⟩
q * (suc n) + toℕ r
≡⟨ +-comm _ (toℕ r) ⟩
toℕ r + q * (suc n)
≡⟨ sym (k≡r+q*sn) ⟩
toℕ i ∎))
where open ≡-Reasoning
... | no ¬p = ⊥-elim (absurd-quotient m n q r i k≡r+q*sn (≤-pred (≰⇒> ¬p)))
bwd∘fwd~id : {m n : ℕ} → bwd {m} {n} ∘ fwd ∼ id
bwd∘fwd~id {n = zero} (b , ())
bwd∘fwd~id {m} {suc n} (b , d) with fwd (b , d) | inspect fwd (b , d)
... | k | [ eq ] with (toℕ k) divMod (suc n)
... | result q r pf with q <? m
... | no ¬p = ⊥-elim (absurd-quotient m n q r k pf (≤-pred (≰⇒> ¬p)))
... | yes p = cong₂ _,_ pf₁ (proj₁ same-quot)
where
open ≡-Reasoning
eq' : toℕ d + toℕ b * suc n ≡ toℕ r + q * suc n
eq' = begin (
toℕ d + toℕ b * suc n
≡⟨ +-comm (toℕ d) _ ⟩
toℕ b * suc n + toℕ d
≡⟨ trans (sym (soundness b d)) (cong toℕ eq) ⟩
toℕ k
≡⟨ pf ⟩
toℕ r + q * suc n ∎ )
same-quot : (r ≡ d) × (q ≡ toℕ b)
same-quot = addMul-lemma q (toℕ b) n r d ( sym eq' )
pf₁ = (toℕ-injective (trans (toℕ-fromℕ≤ p) (proj₂ same-quot)))
fwd-iso : {m n : ℕ} → (Fin m × Fin n) ≃ Fin (m * n)
fwd-iso {m} {n} = fwd , qinv bwd (fwd∘bwd~id {m}) (bwd∘fwd~id {m})
-- convenient aliases
×≃* : {m n : ℕ} → (Fin m × Fin n) ≃ Fin (m * n)
×≃* = fwd-iso
*≃× : {m n : ℕ} → Fin (m * n) ≃ (Fin m × Fin n)
*≃× = sym≃ ×≃*
-- multiplicative monoid equivalences
-- unite*
unite* : {m : ℕ} → Fin (1 * m) ≃ Fin m
unite* {m} = unite⋆equiv ● Fin1≃⊤ ×≃ id≃ ● *≃×
-- uniti*
uniti* : {m : ℕ} → Fin m ≃ Fin (1 * m)
uniti* = sym≃ unite*
-- unite*r
unite*r : {m : ℕ} → Fin (m * 1) ≃ Fin m
unite*r {m} = unite⋆′equiv ● id≃ ×≃ Fin1≃⊤ ● *≃×
-- uniti*r
uniti*r : {m : ℕ} → Fin m ≃ Fin (m * 1)
uniti*r = sym≃ unite*r
-- swap*
swap* : {m n : ℕ} → Fin (m * n) ≃ Fin (n * m)
swap* {m} {n} = ×≃* ● swap⋆equiv ● *≃× {m}
-- associativity
assocl* : {m n o : ℕ} → Fin (m * (n * o)) ≃ Fin ((m * n) * o)
assocl* {m} {n} {o} = ×≃* ● ×≃* ×≃ id≃ ● assocl⋆equiv ● id≃ ×≃ *≃× ● *≃× {m}
assocr* : {m n o : ℕ} → Fin ((m * n) * o) ≃ Fin (m * (n * o))
assocr* {m} {n} {o} = sym≃ (assocl* {m})
-- congruence
_*F_ : {m n o p : ℕ} → Fin m ≃ Fin n → Fin o ≃ Fin p →
Fin (m * o) ≃ Fin (n * p)
Fm≃Fn *F Fo≃Fp = ×≃* ● Fm≃Fn ×≃ Fo≃Fp ● *≃×
------------------------------------------------------------------------------
-- Distributivity of multiplication over addition
module PlusTimes where
-- now that we have two monoids, we need to check distributivity
-- note that the sequence below is "logically right", *but* could be
-- replaced by id≃ !
distz : {m : ℕ} → Fin (0 * m) ≃ Fin 0
distz {m} = sym≃ F0≃⊥ ● distzequiv ● F0≃⊥ ×≃ id≃ ● *≃× {0} {m}
where open Times
factorz : {m : ℕ} → Fin 0 ≃ Fin (0 * m)
factorz {m} = sym≃ (distz {m})
distzr : {m : ℕ} → Fin (m * 0) ≃ Fin 0
distzr {m} = sym≃ F0≃⊥ ● distzrequiv ● id≃ ×≃ F0≃⊥ ● *≃× {m} {0}
where open Times
factorzr : {n : ℕ} → Fin 0 ≃ Fin (n * 0)
factorzr {n} = sym≃ (distzr {n})
dist : {m n o : ℕ} → Fin ((m + n) * o) ≃ Fin ((m * o) + (n * o))
dist {m} {n} {o} = ⊎≃+ {m * o} {n * o} ● ×≃* {m} ⊎≃ ×≃* ● distequiv ● +≃⊎ ×≃ id≃ ● *≃×
where open Times
open Plus
factor : {m n o : ℕ} → Fin ((m * o) + (n * o)) ≃ Fin ((m + n) * o)
factor {m} = sym≃ (dist {m})
distl : {m n o : ℕ} → Fin (m * (n + o)) ≃ Fin ((m * n) + (m * o))
distl {m} {n} {o} = ⊎≃+ {m * n} {m * o} ● ×≃* {m} ⊎≃ ×≃* ● distlequiv ● id≃ ×≃ +≃⊎ ● *≃×
where open Plus
open Times
factorl : {m n o : ℕ} → Fin ((m * n) + (m * o)) ≃ Fin (m * (n + o))
factorl {m} = sym≃ (distl {m})
------------------------------------------------------------------------------
-- Summarizing... we have a commutative semiring structure
fin≃IsEquiv : IsEquivalence _fin≃_
fin≃IsEquiv = record {
refl = id≃ ;
sym = sym≃ ;
trans = trans≃
}
finPlusIsSG : IsSemigroup _fin≃_ _+_
finPlusIsSG = record {
isEquivalence = fin≃IsEquiv ;
assoc = λ m n o → Plus.assocr+ {m} {n} {o} ;
∙-cong = Plus._+F_
}
finTimesIsSG : IsSemigroup _fin≃_ _*_
finTimesIsSG = record {
isEquivalence = fin≃IsEquiv ;
assoc = λ m n o → Times.assocr* {m} {n} {o} ;
∙-cong = Times._*F_
}
finPlusIsCM : IsCommutativeMonoid _fin≃_ _+_ 0
finPlusIsCM = record {
isSemigroup = finPlusIsSG ;
identityˡ = λ m → id≃ ;
comm = λ m n → Plus.swap+ {m} {n}
}
finTimesIsCM : IsCommutativeMonoid _fin≃_ _*_ 1
finTimesIsCM = record {
isSemigroup = finTimesIsSG ;
identityˡ = λ m → Times.unite* {m} ;
comm = λ m n → Times.swap* {m} {n}
}
finIsCSR : IsCommutativeSemiring _fin≃_ _+_ _*_ 0 1
finIsCSR = record {
+-isCommutativeMonoid = finPlusIsCM ;
*-isCommutativeMonoid = finTimesIsCM ;
distribʳ = λ o m n → PlusTimes.dist {m} {n} {o} ;
zeroˡ = λ m → PlusTimes.distz {m}
}
finCSR : CommutativeSemiring Level.zero Level.zero
finCSR = record {
Carrier = ℕ ;
_≈_ = _fin≃_ ;
_+_ = _+_ ;
_*_ = _*_ ;
0# = 0 ;
1# = 1 ;
isCommutativeSemiring = finIsCSR
}
------------------------------------------------------------------------------
|
{
"alphanum_fraction": 0.4668234257,
"avg_line_length": 29.7139737991,
"ext": "agda",
"hexsha": "e30cb2c35f26aa6cf27f80be9add1cb5da78c804",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z",
"max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "JacquesCarette/pi-dual",
"max_forks_repo_path": "Univalence/Obsolete/FinEquiv.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "JacquesCarette/pi-dual",
"max_issues_repo_path": "Univalence/Obsolete/FinEquiv.agda",
"max_line_length": 90,
"max_stars_count": 14,
"max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "JacquesCarette/pi-dual",
"max_stars_repo_path": "Univalence/Obsolete/FinEquiv.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z",
"num_tokens": 5908,
"size": 13609
}
|
-- {-# OPTIONS -v tc.meta:30 --show-irrelevant #-}
-- Andreas, 2013-10-29 submitted by sanzhiyan
-- Documents need for different treating of DontCare in
-- linearity analysis of Miller unification.
-- Now, there can be DontCares stemming from irrelevant projections.
module Issue927 where
import Common.Level
module Fails where
postulate
Σ : (B : Set) (C : B → Set) → Set
<_,_> : {A : Set} {B : A → Set} {C : ∀ x → B x → Set}
(f : (x : A) → B x) →
(g : (x : A) → C x (f x)) →
((x : A) → Σ (B x) (C x))
record _⟶_ (A B : Set) : Set where
field
.app : A → B
open _⟶_ public
.⟪_,_⟫ : ∀ (A B C : Set) → (A ⟶ B) → (A ⟶ C) → A → Σ B (\ _ → C)
⟪_,_⟫ A B C f₁ f₂ = < app f₁ , app f₂ >
-- Using darcs Agda, the following code triggers an
-- internal error at src/full/Agda/TypeChecking/MetaVars.hs:897
|
{
"alphanum_fraction": 0.5591647332,
"avg_line_length": 26.1212121212,
"ext": "agda",
"hexsha": "00a4a67ea1bf824af4538ccad2ee3544a3aa6b93",
"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": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/succeed/Issue927.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/succeed/Issue927.agda",
"max_line_length": 68,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/Succeed/Issue927.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": 317,
"size": 862
}
|
module Issue630 where
Test = (A : Set) → A → A
g : Test
g = λ _ x → {!!}
-- the goal should be displayed as ?1 : A
-- not ?1 : _
|
{
"alphanum_fraction": 0.5378787879,
"avg_line_length": 13.2,
"ext": "agda",
"hexsha": "6bb5fd4a4e03d660c72f18c8584949e112ae291e",
"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/Issue630.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/Issue630.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/interaction/Issue630.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 47,
"size": 132
}
|
-- Here is a smaller test case. The error message is produced using
-- the latest (at the time of writing) development version of Agda.
module Issue183 where
postulate A : Set
T : Set
T = A → A
data L (A : Set) : Set where
data E (x : T) : T → Set where
e : E x x
foo : (f : A → A) → L (E f (λ x → f x))
foo = λ _ → e
-- Previously:
-- An internal error has occurred. Please report this as a bug.
-- Location of the error: src/full/Agda/Syntax/Translation/AbstractToConcrete.hs:705
-- Should now give a proper error message.
|
{
"alphanum_fraction": 0.669793621,
"avg_line_length": 24.2272727273,
"ext": "agda",
"hexsha": "92175fa2df68aab9defb7ab186b746f4b7f50028",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/agda-kanso",
"max_forks_repo_path": "test/fail/Issue183.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/agda-kanso",
"max_issues_repo_path": "test/fail/Issue183.agda",
"max_line_length": 84,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/fail/Issue183.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 160,
"size": 533
}
|
{-# OPTIONS --cubical --postfix-projections --safe #-}
open import Relation.Binary
open import Prelude hiding (tt)
module Data.List.Sort.Sorted {e} {E : Type e} {r₁ r₂} (totalOrder : TotalOrder E r₁ r₂) where
open import Relation.Binary.Construct.LowerBound totalOrder
open TotalOrder totalOrder renaming (refl to refl-≤)
open TotalOrder lb-ord renaming (≤-trans to ⌊trans⌋) using ()
open import Data.List
open import Data.Unit.UniversePolymorphic as Poly using (tt)
open import Data.List.Relation.Binary.Permutation
open import Function.Isomorphism
open import Data.Fin
open import Data.List.Membership
private variable lb : ⌊∙⌋
Sorted-cons : E → (⌊∙⌋ → Type (r₁ ℓ⊔ r₂)) → ⌊∙⌋ → Type (r₁ ℓ⊔ r₂)
Sorted-cons x xs lb = (lb ⌊≤⌋ ⌊ x ⌋) × xs ⌊ x ⌋
SortedFrom : ⌊∙⌋ → List E → Type _
SortedFrom = flip (foldr Sorted-cons (const Poly.⊤))
Sorted : List E → Type _
Sorted = SortedFrom ⌊⊥⌋
ord-in : ∀ x xs → SortedFrom lb xs → x ∈ xs → lb ⌊≤⌋ ⌊ x ⌋
ord-in {lb = lb} x (x₁ ∷ xs) p (f0 , x∈xs) = subst (λ z → lb ⌊≤⌋ ⌊ z ⌋) x∈xs (p .fst)
ord-in {lb} x (y ∷ xs) p (fs n , x∈xs) = ⌊trans⌋ {lb} (p .fst) (ord-in x xs (p .snd) (n , x∈xs))
perm-head : ∀ {lbˣ lbʸ} x xs y ys → SortedFrom lbˣ (x ∷ xs) → SortedFrom lbʸ (y ∷ ys) → (x ∷ xs ↭ y ∷ ys) → x ≡ y
perm-head x xs y ys Sxs Sys xs⇔ys with xs⇔ys _ .inv (f0 , refl)
... | f0 , y∈xs = y∈xs
... | fs n , y∈xs with xs⇔ys _ .fun (f0 , refl)
... | f0 , x∈ys = sym x∈ys
... | fs m , x∈ys = antisym (ord-in y xs (Sxs .snd) (n , y∈xs)) (ord-in x ys (Sys .snd) (m , x∈ys))
perm-same : ∀ {lbˣ lbʸ} xs ys → SortedFrom lbˣ xs → SortedFrom lbʸ ys → xs ↭ ys → xs ≡ ys
perm-same [] [] Sxs Sys xs⇔ys = refl
perm-same [] (y ∷ ys) Sxs Sys xs⇔ys = ⊥-elim (xs⇔ys _ .inv (f0 , refl) .fst)
perm-same (x ∷ xs) [] Sxs Sys xs⇔ys = ⊥-elim (xs⇔ys _ .fun (f0 , refl) .fst)
perm-same {lbˣ} {lbʸ} (x ∷ xs) (y ∷ ys) Sxs Sys xs⇔ys =
let h = perm-head {lbˣ} {lbʸ} x xs y ys Sxs Sys xs⇔ys
in cong₂ _∷_ h
(perm-same xs ys (Sxs .snd) (Sys .snd) (tailₚ x xs ys (subst (λ y′ → x ∷ xs ↭ y′ ∷ ys) (sym h) xs⇔ys)))
sorted-perm-eq : ∀ xs ys → Sorted xs → Sorted ys → xs ↭ ys → xs ≡ ys
sorted-perm-eq = perm-same
|
{
"alphanum_fraction": 0.6037558685,
"avg_line_length": 40.1886792453,
"ext": "agda",
"hexsha": "14f631ea51de80e437be7fd96b9f149f681efa54",
"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/List/Sort/Sorted.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/List/Sort/Sorted.agda",
"max_line_length": 113,
"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/List/Sort/Sorted.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": 954,
"size": 2130
}
|
module Holey where
open import Basics
open import Ix
open import All
open import Cutting
open import Interior
open import Recutter
open import Mask
module HOLEY {I}(C : I |> I) where
open _|>_ C
open INTERIOR C
open RECUTTER C
open MASK C
data Holey {I : Set}(P : I -> Set)(i : I) : Set where
hole : Holey P i
fill : P i -> Holey P i
module SUPERIMPOSE {P}(pc : CutKit P)(rec : Recutter) where
cutHole : CutKit (Holey P)
cutHole i c hole = allPu (\ i -> hole) (inners c)
cutHole i c (fill p) = all (\ _ -> fill) (inners c) (pc i c p)
open CHOP cutHole rec
superimpose : [ Interior (Holey P) -:> Interior (Holey P) -:> Interior (Holey P) ]
superimpose = mask \
{ i hole y -> y
; i (fill x) y -> tile (fill x)
}
|
{
"alphanum_fraction": 0.5942211055,
"avg_line_length": 21.5135135135,
"ext": "agda",
"hexsha": "8a3031fe7e87adb929c3bcf61073dc45d5f39099",
"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": "454cdd18f56db0b0d1643a1fcf36951b5ece395c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pigworker/InteriorDesign",
"max_forks_repo_path": "Holey.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "454cdd18f56db0b0d1643a1fcf36951b5ece395c",
"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": "pigworker/InteriorDesign",
"max_issues_repo_path": "Holey.agda",
"max_line_length": 86,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "454cdd18f56db0b0d1643a1fcf36951b5ece395c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pigworker/InteriorDesign",
"max_stars_repo_path": "Holey.agda",
"max_stars_repo_stars_event_max_datetime": "2018-07-31T02:00:13.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-06-18T15:25:39.000Z",
"num_tokens": 270,
"size": 796
}
|
-- Andreas, 2019-10-13, issue 4125
-- Avoid unnecessary normalization in type checker.
-- Print to the user what they wrote, not its expanded form.
-- {-# OPTIONS -v tc:25 #-}
postulate
We-do-not-want-to : Set → Set
see-this-in-the-output : Set
A = We-do-not-want-to see-this-in-the-output
postulate
P : A → Set
test : ∀{a} → P a → P a
test p = {!!} -- C-c C-,
-- Expected to see
-- a : A
-- in the context, not the expanded monster of A.
-- Testing that the etaExpandVar strategy of the unifier
-- does not reduce the context.
record ⊤ : Set where
data D : ⊤ → Set where
c : ∀{x} → D x
etaExp : ∀{a} → D record{} → P a
etaExp c = {!!} -- C-c C-,
-- WAS (2.5.x-2.6.0):
-- a : We-do-not-want-to see-this-in-the-output (not in scope)
-- EXPECTED
-- a : A
|
{
"alphanum_fraction": 0.6071887035,
"avg_line_length": 21.0540540541,
"ext": "agda",
"hexsha": "c64ed12173839a00ee4ff07f64942f2f923537bf",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/interaction/Issue4125.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/interaction/Issue4125.agda",
"max_line_length": 65,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/interaction/Issue4125.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": 263,
"size": 779
}
|
module Numeric.Rational.Properties where
open import Prelude
open import Numeric.Rational
open import Numeric.Nat.Properties
open import Numeric.Nat.Divide
open import Numeric.Nat.Divide.Properties
open import Numeric.Nat.Prime
open import Numeric.Nat.Prime.Properties
open import Numeric.Nat.GCD
open import Numeric.Nat.GCD.Properties
open import Tactic.Nat
open import Tactic.Nat.Coprime
-- Correctness proofs for the efficient arithmetic operations -------
private
lem-coprime : ∀ n₁ n₂ s′ d₁′ d₂′ g g₁ →
s′ * g₁ ≡ n₁ * d₂′ + n₂ * d₁′ →
Coprime n₁ (d₁′ * g) →
Coprime d₁′ d₂′ →
Coprime s′ d₁′
lem-coprime n₁ n₂ s′ d₁′ d₂′ g g₁ s′g₁=s n₁⊥d₁ d₁′⊥d₂′ =
coprimeByPrimes s′ d₁′ λ p isP p|s′ p|d₁′ →
let s = n₁ * d₂′ + n₂ * d₁′
d₁ = d₁′ * g
p|d₁ : p Divides d₁
p|d₁ = divides-mul-l g p|d₁′
p|s : p Divides s
p|s = transport (p Divides_) s′g₁=s (divides-mul-l g₁ p|s′)
p|n₁d₂′ : p Divides (n₁ * d₂′)
p|n₁d₂′ = divides-sub-r p|s (divides-mul-r n₂ p|d₁′)
p∤n₁ : ¬ (p Divides n₁)
p∤n₁ p|n₁ = prime-divide-coprime p n₁ d₁ isP n₁⊥d₁ p|n₁ p|d₁
p|d₂′ : p Divides d₂′
p|d₂′ = case prime-split n₁ d₂′ isP p|n₁d₂′ of λ where
(left p|n₁) → ⊥-elim (p∤n₁ p|n₁)
(right p|d₂′) → p|d₂′
in divide-coprime p d₁′ d₂′ d₁′⊥d₂′ p|d₁′ p|d₂′
addQ-sound : ∀ x y → x + y ≡ slowAddQ x y
addQ-sound (ratio n₁ d₁ n₁⊥d₁) (ratio n₂ d₂ n₂⊥d₂)
with gcd (n₁ * d₂ + n₂ * d₁) (d₁ * d₂) | gcd d₁ d₂
... | gcd-res g₀ g₀-gcd@(is-gcd (factor p pg₀=n₀) (factor q qg₀=d₀) _)
| gcd-res g isgcd-dd@(is-gcd (factor! d₁′) (factor! d₂′) _)
with gcd (n₁ * d₂′ + n₂ * d₁′) g
... | gcd-res g₁ isgcd-sg@(is-gcd (factor s′ s′g₁=s) (factor! g′) _) =
let n₀ = n₁ * d₂ + n₂ * d₁
d₀ = d₁ * d₂
s = n₁ * d₂′ + n₂ * d₁′
instance
nz-g₀ = nonzero-is-gcd-r ⦃ mul-nonzero d₁ d₂ ⦄ g₀-gcd
nz-g = nonzero-is-gcd-l isgcd-dd
nz-g₁ = nonzero-is-gcd-r isgcd-sg
nz-gg₁ = mul-nonzero g g₁
s′gg₁=n₀ : s′ * (g * g₁) ≡ n₀
s′gg₁=n₀ =
s′ * (g * g₁)
≡⟨ auto ⟩
s′ * g₁ * g
≡⟨ _* g $≡ s′g₁=s ⟩
(n₁ * d₂′ + n₂ * d₁′) * g
≡⟨ auto ⟩
n₀ ∎
ddg′gg₁=d₀ : d₁′ * d₂′ * g′ * (g * g₁) ≡ d₀
ddg′gg₁=d₀ = auto
s′⊥ddg : Coprime s′ (d₁′ * d₂′ * g′)
s′⊥ddg =
let[ _ := is-gcd-factors-coprime isgcd-dd ]
let[ _ := lem-coprime n₁ n₂ s′ d₁′ d₂′ g g₁ s′g₁=s n₁⊥d₁ auto-coprime ]
let[ _ := lem-coprime n₂ n₁ s′ d₂′ d₁′ g g₁ (s′g₁=s ⟨≡⟩ auto) n₂⊥d₂ auto-coprime ]
let[ _ := is-gcd-factors-coprime isgcd-sg ]
auto-coprime
gg₁-gcd : IsGCD (g * g₁) n₀ d₀
gg₁-gcd = is-gcd-by-coprime-factors (g * g₁) n₀ d₀
(factor s′ s′gg₁=n₀) (factor (d₁′ * d₂′ * g′) ddg′gg₁=d₀)
s′⊥ddg
gg₁=g₀ : g * g₁ ≡ g₀
gg₁=g₀ = is-gcd-unique (g * g₁) g₀ gg₁-gcd g₀-gcd
s′g₀=n₀ : s′ * g₀ ≡ n₀
s′g₀=n₀ = s′ *_ $≡ sym gg₁=g₀ ⟨≡⟩ s′gg₁=n₀
ddgg₀=d₀ : d₁′ * d₂′ * g′ * g₀ ≡ d₀
ddgg₀=d₀ = d₁′ * d₂′ * g′ *_ $≡ sym gg₁=g₀ ⟨≡⟩ ddg′gg₁=d₀
s′=p : s′ ≡ p
s′=p = mul-inj₁ s′ p g₀ (s′g₀=n₀ ⟨≡⟩ʳ pg₀=n₀)
ddg=q : d₁′ * d₂′ * g′ ≡ q
ddg=q = mul-inj₁ _ q g₀ (ddgg₀=d₀ ⟨≡⟩ʳ qg₀=d₀)
in cong-ratio s′=p ddg=q
mulQ-sound : ∀ x y → x * y ≡ slowMulQ x y
mulQ-sound (ratio n₁ d₁ n₁⊥d₁) (ratio n₂ d₂ n₂⊥d₂)
with gcd n₁ d₂ | gcd n₂ d₁ | gcd (n₁ * n₂) (d₁ * d₂)
... | gcd-res g₁ gcd₁₂@(is-gcd (factor! n₁′) (factor! d₂′) _)
| gcd-res g₂ gcd₂₁@(is-gcd (factor! n₂′) (factor! d₁′) _)
| gcd-res g gcdnd@(is-gcd (factor n′ n′g=n) (factor d′ d′g=d) _) =
let instance _ = nonzero-is-gcd-r gcd₁₂
_ = nonzero-is-gcd-r gcd₂₁
_ = mul-nonzero g₁ g₂
g=gg : g ≡ g₁ * g₂
g=gg = is-gcd-unique _ _ gcdnd $
is-gcd-by-coprime-factors _ _ _ (factor (n₁′ * n₂′) auto)
(factor (d₁′ * d₂′) auto) $
let[ _ := is-gcd-factors-coprime gcd₁₂ ]
let[ _ := is-gcd-factors-coprime gcd₂₁ ]
auto-coprime
neq : n₁′ * n₂′ ≡ n′
neq = case g=gg of λ where
refl → mul-inj₁ (n₁′ * n₂′) n′ (g₁ * g₂) (by n′g=n)
deq : d₁′ * d₂′ ≡ d′
deq = case g=gg of λ where
refl → mul-inj₁ (d₁′ * d₂′) d′ (g₁ * g₂) (by d′g=d)
in cong-ratio neq deq
|
{
"alphanum_fraction": 0.4994492179,
"avg_line_length": 34.1278195489,
"ext": "agda",
"hexsha": "136b2d98ae041b5745e2d5a820d3a5355e19ad71",
"lang": "Agda",
"max_forks_count": 24,
"max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z",
"max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "L-TChen/agda-prelude",
"max_forks_repo_path": "src/Numeric/Rational/Properties.agda",
"max_issues_count": 59,
"max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "L-TChen/agda-prelude",
"max_issues_repo_path": "src/Numeric/Rational/Properties.agda",
"max_line_length": 90,
"max_stars_count": 111,
"max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "L-TChen/agda-prelude",
"max_stars_repo_path": "src/Numeric/Rational/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z",
"num_tokens": 2009,
"size": 4539
}
|
-- BEGIN prelude.agda
-- the Haskell $ and .
($) (A::Set) (B::Set) (f :: A -> B) (a :: A) :: B
= f a
compose (B,C,A::Set)(f :: B -> C)(g :: A -> B) :: A -> C
= \ (x::A) -> f (g x)
{- hardwired into Agda
Integer :: Set
= ?
Bool :: Set
= data True | False
-}
not (b::Bool) :: Bool
= case b of {
(True) -> False; -- Agda does not require @_ for built-in constructors
(False) -> True;}
(||) (b1::Bool)(b2::Bool) :: Bool
= case b1 of {
(True) -> True@_;
(False) ->
case b2 of {
(True) -> True@_;
(False) -> False@_;};}
(&&) (b1::Bool)(b2::Bool) :: Bool
= case b1 of {
(True) ->
case b2 of {
(True) -> False@_;
(False) -> True@_;};
(False) -> False@_;}
Pair (a::Set)(b::Set) :: Set
= data Pair (x::a) (y::b)
Triple (a::Set)(b::Set)(c::Set) :: Set
= data Triple (x::a) (y::b) (z::c)
flip (a::Set)(b::Set)(c::Set)(f::a -> b -> c)(x::b)(y::a) :: c
= f y x
{- hardwired into Agda:
List (a::Set) :: Set
= data Nil | (:) (x::a) (xs::List a)
-}
foldl (a::Set)(b::Set)(f::a -> b -> a)(acc::a)(l::List b) :: a
= case l of {
(Nil) -> acc;
(x:xs) -> foldl a b f (f acc x) xs;}
reverse (a::Set)(l::List a) :: List a
= foldl (List a) a
(flip a (List a) (List a) (\(h::a) -> \(h'::List a) -> (:)@_ h h'))
Nil@_
l
append (a::Set)(l1::List a)(l2::List a) :: List a
= case l1 of {
(Nil) -> l2;
(x:xs) -> x : (append a xs l2);}
null (a::Set)(l::List a) :: Bool
= case l of {
(Nil) -> True@_;
(x:xs) -> False@_;}
map (a,b::Set)(f::a -> b)(l::List a) :: List b
= case l of
(Nil) -> Nil
(x:xs) -> f x : map a b f xs
Maybe (a::Set) :: Set
= data Nothing | Just (x::a)
-- Should not be here - temporary addition to provide an "interesting" type
-- data Simple = A | B | C -gone
-- Properties
-- naive implementation of Property.hs
-- from SET.alfa
Rel (X::Set) :: Type
= X -> X -> Set
Id (X::Set) :: Rel X
= idata ref (x::X) :: _ x x
Zero :: Set
= data
whenZero (X::Set)(z::Zero) :: X
= case z of { }
Unit :: Set
= data tt
Sum (X::Set)(Y::X -> Set) :: Set
= sig{fst :: X;
snd :: Y fst;}
Plus (X::Set)(Y::Set) :: Set
= data inl (x::X) | inr (y::Y)
package Property where
Prop :: Type
= Set
(===) (A :: Set) (a :: A) (b :: A) :: Prop
= Id A a b
-- translate forAll into a dependent function type
forAll (A :: Set) (f :: A -> Prop) :: Prop
= (x :: A) -> f x
exists (A :: Set) (f :: A -> Prop) :: Prop
= sig { witness :: A;
prop :: f witness; }
(/\) (A,B :: Prop) :: Prop
= Sum A (\(a::A) -> B)
(\/) (A,B :: Prop) :: Prop
= Plus A B
(<=>) (A,B :: Prop) :: Prop
= (A -> B) /\ (B -> A)
(==>) (A,B :: Prop) :: Prop
= (A -> B)
true :: Prop
= Unit
false :: Prop
= Zero
nt (A :: Prop) :: Prop
= A -> false
-- cannot do the naive using because of universe conflict
-- List cannot have a parameter which is not a set, and Prop is a type
--using (L :: List Prop) (A :: Prop) :: Prop
-- = A
holds (b::Bool) :: Prop
= if b then true else false
holdsNot (b::Bool) :: Prop
= if b then false else true
-- Class of inhabited types
class Inhabited (a::Set) :: Set exports
arbitrary :: a
error (a::Set)(|ia::Inhabited a)(msg::String) :: a
= arbitrary
-- Prelude types are inhabited
instance iBool :: Inhabited Bool where
arbitrary = True
instance iString :: Inhabited String where
arbitrary = "I AM ARBITRARY"
instance iInteger :: Inhabited Integer where
arbitrary = 123456789
{- Syntax error:
instance iRational :: Inhabited Rational where
arbitrary = 0.123456789
-}
instance iList (|a::Set) :: Inhabited (List a) where
arbitrary = Nil
-- instance iList (a::Set)(ia::Inhabited a) :: Inhabited (List a) where
-- END prelude.agda
|
{
"alphanum_fraction": 0.4980784012,
"avg_line_length": 20.5421052632,
"ext": "agda",
"hexsha": "ed87c2d855d98deb56efdd1524456133d0e1996e",
"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": "4172bef9f4eede7e45dc002a70bf8c6dd9a56b5c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "siddharthist/hs2agda",
"max_forks_repo_path": "lib/prelude.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "4172bef9f4eede7e45dc002a70bf8c6dd9a56b5c",
"max_issues_repo_issues_event_max_datetime": "2016-10-25T17:50:18.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-25T02:27:55.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "siddharthist/CoverTranslator",
"max_issues_repo_path": "lib/prelude.agda",
"max_line_length": 77,
"max_stars_count": 17,
"max_stars_repo_head_hexsha": "4172bef9f4eede7e45dc002a70bf8c6dd9a56b5c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "siddharthist/hs2agda",
"max_stars_repo_path": "lib/prelude.agda",
"max_stars_repo_stars_event_max_datetime": "2016-10-25T19:54:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-10-25T10:07:49.000Z",
"num_tokens": 1424,
"size": 3903
}
|
------------------------------------------------------------------------------
-- Addition as a function constant
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.AddConstant where
------------------------------------------------------------------------------
-- We add 3 to the fixities of the Agda standard library 0.8.1 (see
-- Algebra.agda and Relation/Binary/Core.agda).
infixl 9 _·_
infix 7 _≡_
postulate
D : Set
_·_ : D → D → D
true false if : D
zero succ pred iszero : D
_≡_ : D → D → Set
postulate
if-true : ∀ t {t'} → if · true · t · t' ≡ t
if-false : ∀ {t} t' → if · false · t · t' ≡ t'
pred-0 : pred · zero ≡ zero
pred-S : ∀ n → pred · (succ · n) ≡ n
iszero-0 : iszero · zero ≡ true
iszero-S : ∀ n → iszero · (succ · n) ≡ false
{-# ATP axioms if-true if-false pred-0 pred-S iszero-0 iszero-S #-}
postulate
+ : D
+-eq : ∀ m n → + · m · n ≡
if · (iszero · m) · n · (succ · (+ · (pred · m) · n))
{-# ATP axiom +-eq #-}
postulate
+-0x : ∀ n → + · zero · n ≡ n
+-Sx : ∀ m n → + · (succ · m) · n ≡ succ · (+ · m · n)
{-# ATP prove +-0x #-}
{-# ATP prove +-Sx #-}
-- $ cd fotc/notes/thesis
-- $ agda -i. -i ~/fot FOTC/AddConstant.agda
-- $ apia -i. -i ~/fot FOTC/AddConstant.agda
-- Proving the conjecture in /tmp/FOTC/AddConstant/37-43-0x.tptp ...
-- Vampire 0.6 (revision 903) proved the conjecture
-- Proving the conjecture in /tmp/FOTC/AddConstant/38-43-Sx.tptp ...
-- Vampire 0.6 (revision 903) proved the conjecture
|
{
"alphanum_fraction": 0.4589700057,
"avg_line_length": 33.3396226415,
"ext": "agda",
"hexsha": "f925817b7b0d83b28d5471ec26449ec041b4c46e",
"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/thesis/report/FOTC/AddConstant.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/thesis/report/FOTC/AddConstant.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/thesis/report/FOTC/AddConstant.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": 548,
"size": 1767
}
|
module sv20.assign2.SetTheory.Algebra where
open import sv20.assign2.SetTheory.Subset
open import sv20.assign2.SetTheory.Logic
open import sv20.assign2.SetTheory.ZAxioms
infix 6 _∪_
infix 6 _-_
infix 6 _∩_
-- Properties involving operations between sets, algebra of sets.
-- In this module some properties involving union, difference
-- and intersection of set are proved.
-- First, some properties of the union between sets, justified by the
-- union axiom.
_∪_ : 𝓢 → 𝓢 → 𝓢
x ∪ y = proj₁ (union x y)
-- {-# ATP definition _∪_ #-}
-- Theorem 20, p. 27 (Suppes 1960)
∪-d : (x y : 𝓢) → ∀ {z} → z ∈ x ∪ y ⇔ z ∈ x ∨ z ∈ y
∪-d x y = proj₂ _ (union x y)
-- ∧-projections of past theorem for convenience.
∪-d₁ : (A B : 𝓢) → ∀ {x} → x ∈ (A ∪ B) → x ∈ A ∨ x ∈ B
∪-d₁ A B = ∧-proj₁ (∪-d A B)
∪-d₂ : (A B : 𝓢) → ∀ {x} → x ∈ A ∨ x ∈ B → x ∈ (A ∪ B)
∪-d₂ A B = ∧-proj₂ (∪-d A B)
-- Theorem 21, p. 27 (Suppes 1960)
A∪B≡B∪A : (A B : 𝓢) → A ∪ B ≡ B ∪ A
A∪B≡B∪A A B = equalitySubset (A ∪ B) (B ∪ A) (p₁ , p₂)
where
p₁ : (x : 𝓢) → x ∈ (A ∪ B) → x ∈ (B ∪ A)
p₁ x x₁ = ∪-d₂ B A (∨-sym _ _ (∪-d₁ A B x₁))
p₂ : (x : 𝓢) → x ∈ (B ∪ A) → x ∈ (A ∪ B)
p₂ x x₁ = ∪-d₂ A B (∨-sym _ _ (∪-d₁ B A x₁))
-- Theorem 23, p. 27 (Suppes 1960)
A∪A≡A : (A : 𝓢) → A ∪ A ≡ A
A∪A≡A A = equalitySubset (A ∪ A) A (p₁ , p₂)
where
p₁ : (x : 𝓢) → x ∈ (A ∪ A) → x ∈ A
p₁ x x₁ = ∨-idem _ (∪-d₁ A A x₁)
p₂ : (x : 𝓢) → x ∈ A → x ∈ (A ∪ A)
p₂ x x₁ = ∪-d₂ A A (inj₁ x₁)
-- Theorem 25, p. 27 (Suppes 1960)
∪-prop : (A B : 𝓢) → A ⊆ A ∪ B
∪-prop A B t x = ∪-d₂ _ _ (inj₁ x)
⊆∪ : (x A B : 𝓢) → x ⊆ A ∧ x ⊆ B → x ⊆ A ∪ B
⊆∪ x A B (x₁ , x₂) t x₃ = trans-⊆ _ _ _ (x₁ , (∪-prop _ _)) _ x₃
∪-prop₂ : (x A B : 𝓢) → x ⊆ A ∨ x ⊆ B → x ⊆ A ∪ B
∪-prop₂ x A B (inj₁ x₁) t x₂ = ∪-d₂ _ _ (inj₁ (x₁ _ x₂))
∪-prop₂ x A B (inj₂ x₁) t x₂ = ∪-d₂ _ _ (inj₂ (x₁ _ x₂))
∪-prop₃ : (A B : 𝓢) → B ⊆ A ∪ B
∪-prop₃ A B t x = ∪-d₂ _ _ (inj₂ x)
-- Theorem 27, p. 27 (Suppes 1960)
∪-prop₄ : (x y A : 𝓢) → x ⊆ A → y ⊆ A → x ∪ y ⊆ A
∪-prop₄ x y A x⊆A y⊆A t t∈x∪y = ∨-idem _ p₂
where
p₁ : t ∈ x ∨ t ∈ y
p₁ = ∪-d₁ _ _ t∈x∪y
p₂ : t ∈ A ∨ t ∈ A
p₂ = ∨-prop₅ p₁ (x⊆A _) (y⊆A _)
-- Properties about the intersection opertaion. Its existence is justified
-- as an axiom derived from the sub axiom schema.
_∩_ : 𝓢 → 𝓢 → 𝓢
x ∩ y = proj₁ (sub (λ z → z ∈ y) x)
-- Instantiation of the subset axiom schema needed for justifiying
-- the operation.
sub₂ : (x y : 𝓢) → ∃ (λ B → {z : 𝓢} → (z ∈ B ⇔ z ∈ x ∧ z ∈ y))
sub₂ x y = sub (λ z → z ∈ y) x
-- Theorem 12, p.25 (Suppes 1960)
∩-def : (x y : 𝓢) → ∀ {z} → z ∈ x ∩ y ⇔ z ∈ x ∧ z ∈ y
∩-def x y = proj₂ _ (sub₂ x y)
-- Projections of ∩-def, useful for avoiding repeating this
-- projections later.
∩-d₁ : (x A B : 𝓢) → x ∈ (A ∩ B) → x ∈ A ∧ x ∈ B
∩-d₁ x A B = ∧-proj₁ (∩-def A B)
∩-d₂ : (x A B : 𝓢) → x ∈ A ∧ x ∈ B → x ∈ (A ∩ B)
∩-d₂ x A B = ∧-proj₂ (∩-def A B)
-- Theorem 13, p.26 (Suppes 1960)
∩-sym : (A B : 𝓢) → A ∩ B ≡ B ∩ A
∩-sym A B = equalitySubset (A ∩ B) (B ∩ A) (p₁ , p₂)
where
p₁ : (x : 𝓢) → x ∈ A ∩ B → x ∈ B ∩ A
p₁ x x∈A∩B = ∩-d₂ x B A (x∈B , x∈A)
where
x∈A : x ∈ A
x∈A = ∧-proj₁ (∩-d₁ x A B x∈A∩B)
x∈B : x ∈ B
x∈B = ∧-proj₂ (∩-d₁ x A B x∈A∩B)
p₂ : (x : 𝓢) → x ∈ B ∩ A → x ∈ A ∩ B
p₂ x x∈B∩A = ∩-d₂ x A B (x∈A , x∈B)
where
x∈A : x ∈ A
x∈A = ∧-proj₂ (∩-d₁ x B A x∈B∩A)
x∈B : x ∈ B
x∈B = ∧-proj₁ (∩-d₁ x B A x∈B∩A)
-- Theorem 14, p. 26 (Suppes 1960).
∩-dist : (A B C : 𝓢) → (A ∩ B) ∩ C ≡ A ∩ (B ∩ C)
∩-dist A B C = equalitySubset ((A ∩ B) ∩ C) (A ∩ (B ∩ C)) (p₁ , p₂)
where
p₁ : (x : 𝓢) → x ∈ (A ∩ B) ∩ C → x ∈ A ∩ (B ∩ C)
p₁ x x₁ = ∩-d₂ x A (B ∩ C) (x∈A , x∈B∩C)
where
x∈B∩C : x ∈ B ∩ C
x∈B∩C = ∩-d₂ x B C (x∈B , x∈C)
where
x∈A∩B : x ∈ A ∩ B
x∈A∩B = ∧-proj₁ (∩-d₁ x (A ∩ B) _ x₁)
x∈B : x ∈ B
x∈B = ∧-proj₂ (∩-d₁ x _ B x∈A∩B)
x∈C : x ∈ C
x∈C = ∧-proj₂ (∩-d₁ x _ C x₁)
x∈A : x ∈ A
x∈A = ∧-proj₁ (∩-d₁ x A _ x∈A∩B)
where
x∈A∩B : x ∈ A ∩ B
x∈A∩B = ∧-proj₁ (∩-d₁ x (A ∩ B) _ x₁)
p₂ : (x : 𝓢) → x ∈ A ∩ (B ∩ C) → x ∈ (A ∩ B) ∩ C
p₂ x x₁ = ∩-d₂ x (A ∩ B) C (x∈A∩B , x∈C)
where
x∈A∩B : x ∈ A ∩ B
x∈A∩B = ∩-d₂ x A B (x∈A , x∈B)
where
x∈A : x ∈ A
x∈A = ∧-proj₁ (∩-d₁ x A _ x₁)
x∈B∩C : x ∈ B ∩ C
x∈B∩C = ∧-proj₂ (∩-d₁ x _ (B ∩ C) x₁)
x∈B : x ∈ B
x∈B = ∧-proj₁ (∩-d₁ x B _ x∈B∩C)
x∈C : x ∈ C
x∈C = ∧-proj₂ (∩-d₁ x _ C x∈B∩C)
where
x∈B∩C : x ∈ B ∩ C
x∈B∩C = ∧-proj₂ (∩-d₁ x _ (B ∩ C) x₁)
-- Theorem 15, p. 26 (Suppes).
∩-itself : (A : 𝓢) → A ∩ A ≡ A
∩-itself A = equalitySubset (A ∩ A) A (p₁ , p₂)
where
p₁ : (x : 𝓢) → x ∈ A ∩ A → x ∈ A
p₁ x x₁ = ∧-proj₁ (∩-d₁ _ A _ x₁)
p₂ : (x : 𝓢) → x ∈ A → x ∈ A ∩ A
p₂ x x₁ = ∩-d₂ _ A A (x₁ , x₁)
-- Theorem 17, p. 26 (Suppes 1960).
A∩B⊆A : (A B : 𝓢) → A ∩ B ⊆ A
A∩B⊆A A B _ p = ∧-proj₁ (∩-d₁ _ A _ p)
-- Properties involving the difference between sets. The existence of this
-- sets is also justified as an instance of the subset axiom schema.
-- Instantiation of the subset schema that will justify the operation
-- of difference between sets.
sub₃ : (x y : 𝓢) → ∃ (λ B → {z : 𝓢} → (z ∈ B ⇔ z ∈ x ∧ z ∉ y))
sub₃ x y = sub (λ z → z ∉ y) x
_-_ : 𝓢 → 𝓢 → 𝓢
x - y = proj₁ (sub₃ x y)
-- Theorem 31, p.28 (Suppes 1960).
dif-def : (x y : 𝓢) → ∀ {z} → z ∈ (x - y) ⇔ z ∈ x ∧ z ∉ y
dif-def x y = proj₂ _ (sub₃ x y)
-- Again both ∧-projections of the past theorem.
dif-d₁ : (A B z : 𝓢) → z ∈ A - B → z ∈ A ∧ z ∉ B
dif-d₁ A B z = ∧-proj₁ (dif-def A B)
dif-d₂ : (A B z : 𝓢) → z ∈ A ∧ z ∉ B → z ∈ A - B
dif-d₂ A B z = ∧-proj₂ (dif-def A B)
-- Theorem 33, p. 29 (Suppes 1960).
∩- : (A B : 𝓢) → A ∩ (A - B) ≡ A - B
∩- A B = equalitySubset (A ∩ (A - B)) (A - B) (p₁ , p₂)
where
p₁ : (x : 𝓢) → x ∈ A ∩ (A - B) → x ∈ A - B
p₁ x x∈∩- = dif-d₂ A B x (x∈A , x∉B)
where
x∈A : x ∈ A
x∈A = ∧-proj₁ (∩-d₁ x A _ x∈∩-)
x∈A-B : x ∈ A - B
x∈A-B = ∧-proj₂ (∩-d₁ x _ (A - B) x∈∩-)
x∉B : x ∉ B
x∉B = ∧-proj₂ (dif-d₁ A B x x∈A-B)
p₂ : (x : 𝓢) → x ∈ A - B → x ∈ A ∩ (A - B)
p₂ x x∈A-B = ∩-d₂ x A (A - B) ((∧-proj₁ (dif-d₁ A B x x∈A-B)) , x∈A-B)
-- References
--
-- Suppes, Patrick (1960). Axiomatic Set Theory.
-- The University Series in Undergraduate Mathematics.
-- D. Van Nostrand Company, inc.
--
-- Enderton, Herbert B. (1977). Elements of Set Theory.
-- Academic Press Inc.
|
{
"alphanum_fraction": 0.4677849193,
"avg_line_length": 27.9780701754,
"ext": "agda",
"hexsha": "746943b7b5e27be44e7ac0e5992c69fca182c0bf",
"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": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "helq/old_code",
"max_forks_repo_path": "proglangs-learning/Agda/sv20/assign2/SetTheory/Algebra.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z",
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "helq/old_code",
"max_issues_repo_path": "proglangs-learning/Agda/sv20/assign2/SetTheory/Algebra.agda",
"max_line_length": 74,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "helq/old_code",
"max_stars_repo_path": "proglangs-learning/Agda/sv20/assign2/SetTheory/Algebra.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3477,
"size": 6379
}
|
{-# OPTIONS --without-K #-}
module Types where
open import Level
using (_⊔_; Lift; lift; lower)
public
infix 1 _≡_
infixr 1 _⊎_
infixr 2 _×_
infix 3 ¬_
infixr 4 _,_
infixr 9 _∘_
-- The negative fragment.
Π : ∀ {a b} (A : Set a) → (A → Set b) → Set _
Π A B = (x : A) → B x
record Σ {a b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where
constructor _,_
field
π₁ : A
π₂ : B π₁
open Σ public
-- Projections are defined automatically.
_×_ : ∀ {a b} → Set a → Set b → Set _
A × B = Σ A λ _ → B
-- Unit type with definitional η.
record ⊤ : Set where
constructor tt
id : ∀ {a} {A : Set a} → A → A
id x = x
_∘_ : ∀ {a b c} {A : Set a} {B : A → Set b} {C : ∀ a → B a → Set c}
(f : ∀ {a} (b : B a) → C a b)
(g : ∀ a → B a) →
∀ x → C x (g x)
(f ∘ g) x = f (g x)
-- The positive fragment.
data ⊥ : Set where
-- Ex falso quodlibet.
0-elim : ∀ {p} {P : Set p} → ⊥ → P
0-elim ()
¬_ : ∀ {a} → Set a → Set a
¬ A = A → ⊥
-- Unit type without definitional η.
data Unit : Set where
tt : Unit
1-elim : ∀ {p} (P : Unit → Set p) → P tt →
∀ z → P z
1-elim P c tt = c
data _⊎_ {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where
inl : A → A ⊎ B
inr : B → A ⊎ B
-- Case analysis.
case : ∀ {a b p} {A : Set a} {B : Set b} (P : A ⊎ B → Set p)
(f : ∀ a → P (inl a)) (g : ∀ b → P (inr b)) → ∀ z → P z
case P f g (inl a) = f a
case P f g (inr b) = g b
-- Simga as a positive type.
data Σ′ {a b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where
_,_ : (a : A) → B a → Σ′ A B
split : ∀ {a b p} {A : Set a} {B : A → Set b} (P : Σ′ A B → Set p)
(f : (a : A) (b : B a) → P (a , b)) → ∀ z → P z
split P f (a , b) = f a b
-- Natural numbers.
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
{-# BUILTIN NATURAL ℕ #-}
ind : ∀ {p} (P : ℕ → Set p)
(s : ∀ n → P n → P (suc n))
(z : P zero) →
∀ z → P z
ind P s z zero = z
ind P s z (suc n) = s n (ind P s z n)
-- Identity type.
data _≡_ {a} {A : Set a} (x : A) : A → Set a where
refl : x ≡ x
-- When the type cannot be infered.
Id : ∀ {a} (A : Set a) (x y : A) → Set _
Id _ x y = x ≡ y
-- Path induction.
J : ∀ {a p} {A : Set a} (P : ∀ (x : A) y → x ≡ y → Set p)
(f : ∀ x → P x x refl) → ∀ x y → (p : x ≡ y) → P x y p
J P f x .x refl = f x
|
{
"alphanum_fraction": 0.4726862302,
"avg_line_length": 20.8962264151,
"ext": "agda",
"hexsha": "e274e27d6392fbf886f2beb3a48af74c485f6f9a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "vituscze/HoTT-lectures",
"max_forks_repo_path": "src/Types.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "vituscze/HoTT-lectures",
"max_issues_repo_path": "src/Types.agda",
"max_line_length": 67,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "vituscze/HoTT-lectures",
"max_stars_repo_path": "src/Types.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1016,
"size": 2215
}
|
-- notes-04-thursday.agda
open import mylib
{-
Infinite datastructure
- streams, Stream A
0 ,1 , 2 ,3 ,4, ... : Stream ℕ
1, 1 , 2, 3 ,5 ,..
2, 3, 5, 7, 11,..
duality, categorical mirror
_×_ (products) and _⊎_ (coproducts, sums)
Inductive datatypes: finite datastructures
Coinductive datatypes: Streams, ℕ∞ (conatural numbers)
-}
record Stream (A : Set) : Set where
constructor _∷_
coinductive
field
head : A
tail : Stream A
open Stream
{-
_∷S_ : A → Stream A → Stream A
head (a ∷S as) = a
tail (a ∷S as) = as
-}
from : ℕ → Stream ℕ
head (from n) = n
tail (from n) = from (suc n)
-- from is productive because it is guarded
mapS : (A → B) → Stream A → Stream B
head (mapS f as) = f (head as)
tail (mapS f as) = mapS f (tail as)
{-
filterS : (A → Bool) → Stream A → Stream A
head (filterS f as) = if f (head as) then (head as) else {!!}
tail (filterS f as) = {!!} -- no guarded definition of filter
-}
-- Conatural numbers
data Maybe (A : Set) : Set where
nothing : Maybe A
just : A → Maybe A
-- Maybe A = 1 ⊎ A
pred : ℕ → Maybe ℕ
pred zero = nothing
pred (suc n) = just n
zero-suc : Maybe ℕ → ℕ
zero-suc nothing = zero
zero-suc (just n) = suc n
-- Lambek's lemma, initial algebras
record ℕ∞ : Set where
coinductive
field
pred∞ : Maybe ℕ∞
-- terminal coalgebra
-- emb : ℕ → ℕ∞ -- 2 ways
-- f : ℕ∞ → ℕ -- no way, cons local continuity
open ℕ∞
zero∞ : ℕ∞
pred∞ zero∞ = nothing
suc∞ : ℕ∞ → ℕ∞
pred∞ (suc∞ n) = just n
∞ : ℕ∞
pred∞ ∞ = just ∞
{-
_+_ : ℕ → ℕ → ℕ
zero + n = n
suc m + n = suc (m + n)
-}
_+∞_ : ℕ∞ → ℕ∞ → ℕ∞
pred∞ (m +∞ n) with pred∞ m
... | nothing = pred∞ n
... | just m' = just (m' +∞ n)
{-
Dependent types (families)
A dependent type is a function whose codomain is Set.
List : Set → Set
Not proper?
Vec : Set → ℕ → Set
Vec A n = tuple of n as
{ as | length as = n} -- type theoretic of comprehension
Fin : ℕ → Set
Fin n = a set with n elements
{0 , 1, .. , n-1}
Function type
A B : Set
A → B : Set
Dependent function type (Π-type)
A : Set
B : A → Set
(x : A) → B x
{x : A} → B x -- hidden arguments
zeros : (n : ℕ) → Vec ℕ n
-}
data Vec (A : Set) : ℕ → Set where
[] : Vec A 0
_∷_ : {n : ℕ} → A → Vec A n → Vec A (suc n)
zeros : (n : ℕ) → Vec ℕ n
zeros zero = []
zeros (suc n) = 0 ∷ zeros n
{-
_++_ : List A → List A → List A
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ (xs ++ ys)
-}
_++v_ : {m n : ℕ} → Vec A m → Vec A n → Vec A (m + n)
[] ++v ys = ys
(x ∷ xs) ++v ys = x ∷ (xs ++v ys)
data Fin : ℕ → Set where
zero : {n : ℕ} → Fin (suc n)
suc : {n : ℕ} → Fin n → Fin (suc n)
{-
Fin 0 = {}
Fin 1 = { zero{0} }
Fin 2 = { zero{1} , suc{1} (zero{0}) }
...
-}
_!!_ : {n : ℕ} → Vec A n → Fin n → A -- safe lookup function
(a ∷ as) !! zero = a
(a ∷ as) !! suc n = as !! n
|
{
"alphanum_fraction": 0.5387610619,
"avg_line_length": 17.7672955975,
"ext": "agda",
"hexsha": "282ed7936cb9b3962cd1c3f96a7820510fec60d5",
"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": "f328e596d98a7d052b34144447dd14de0f57e534",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "FoxySeta/mgs-2021",
"max_forks_repo_path": "Type Theory/notes-04-thursday.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534",
"max_issues_repo_issues_event_max_datetime": "2021-07-14T20:35:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-07-14T20:34:53.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "FoxySeta/mgs-2021",
"max_issues_repo_path": "Type Theory/notes-04-thursday.agda",
"max_line_length": 63,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "FoxySeta/mgs-2021",
"max_stars_repo_path": "Type Theory/notes-04-thursday.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1149,
"size": 2825
}
|
{-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.types.Pi
open import lib.types.Pointed
module lib.types.Span where
record Span {i j k : ULevel} : Type (lsucc (lmax (lmax i j) k)) where
constructor span
field
A : Type i
B : Type j
C : Type k
f : C → A
g : C → B
private
span=-raw : ∀ {i j k} {A A' : Type i} (p : A == A')
{B B' : Type j} (q : B == B') {C C' : Type k} (r : C == C')
{f : C → A} {f' : C' → A'}
(s : f == f' [ (λ CA → fst CA → snd CA) ↓ pair×= r p ])
{g : C → B} {g' : C' → B'}
(t : g == g' [ (λ CB → fst CB → snd CB) ↓ pair×= r q ])
→ (span A B C f g) == (span A' B' C' f' g')
span=-raw idp idp idp idp idp = idp
abstract
span= : ∀ {i j k} {A A' : Type i} (p : A ≃ A')
{B B' : Type j} (q : B ≃ B') {C C' : Type k} (r : C ≃ C')
{f : C → A} {f' : C' → A'} (s : (a : C) → (–> p) (f a) == f' (–> r a))
{g : C → B} {g' : C' → B'} (t : (b : C) → (–> q) (g b) == g' (–> r b))
→ (span A B C f g) == (span A' B' C' f' g')
span= p q r {f} {f'} s {g} {g'} t = span=-raw
(ua p)
(ua q)
(ua r)
(↓-→-in (λ α → ↓-snd×-in (ua r) (ua p) (↓-idf-ua-in p (
s _
∙ ap f' (↓-idf-ua-out r (↓-fst×-out (ua r) (ua p) α))))))
(↓-→-in (λ β → ↓-snd×-in (ua r) (ua q) (↓-idf-ua-in q (
t _
∙ ap g' (↓-idf-ua-out r (↓-fst×-out (ua r) (ua q) β))))))
record ⊙Span {i j k : ULevel} : Type (lsucc (lmax (lmax i j) k)) where
constructor ⊙span
field
X : Ptd i
Y : Ptd j
Z : Ptd k
f : fst (Z ⊙→ X)
g : fst (Z ⊙→ Y)
⊙span-out : ∀ {i j k} → ⊙Span {i} {j} {k} → Span {i} {j} {k}
⊙span-out (⊙span X Y Z f g) = span (fst X) (fst Y) (fst Z) (fst f) (fst g)
{- Helper for path induction on pointed spans -}
⊙span-J : ∀ {i j k l} (P : ⊙Span {i} {j} {k} → Type l)
→ ({A : Type i} {B : Type j} {Z : Ptd k} (f : fst Z → A) (g : fst Z → B)
→ P (⊙span (A , f (snd Z)) (B , g (snd Z)) Z (f , idp) (g , idp)))
→ Π ⊙Span P
⊙span-J P t (⊙span (A , ._) (B , ._) Z (f , idp) (g , idp)) = t f g
|
{
"alphanum_fraction": 0.4135772749,
"avg_line_length": 32.9682539683,
"ext": "agda",
"hexsha": "8b2bc41cf9f1d0cbedbddd083332139e699a3f7d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nicolaikraus/HoTT-Agda",
"max_forks_repo_path": "lib/types/Span.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nicolaikraus/HoTT-Agda",
"max_issues_repo_path": "lib/types/Span.agda",
"max_line_length": 76,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda",
"max_stars_repo_path": "lib/types/Span.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z",
"num_tokens": 956,
"size": 2077
}
|
module Data.Real.Order where
open import Assume
open import Data.Real.Base
open import Data.Bool using (T; T?)
open import Data.Unit using (⊤; tt)
open import Relation.Nullary using (Dec; yes; no; ¬_)
open import Relation.Binary.PropositionalEquality using (_≡_)
open import Relation.Binary
open import Level using (0ℓ)
-- TODO
-- should this move to Data.Real.Equality?
_≉_ : Rel ℝ 0ℓ
x ≉ y = ¬ x ≈ y
≉-isApartnessRelation : IsApartnessRelation _≈_ _≉_
≉-isApartnessRelation = assume
≉-apartnessRelation : ApartnessRelation 0ℓ 0ℓ 0ℓ
≉-apartnessRelation = record { isApartnessRelation = ≉-isApartnessRelation }
_≤_ : ℝ → ℝ → Set
x ≤ y = T (x ≤ᵇ y)
open import Relation.Binary.Construct.NonStrictToStrict _≈_ _≤_ public
using (_<_; <-isStrictTotalOrder₁)
_≤?_ : ∀ x y → Dec (x ≤ y)
x ≤? y = T? (x ≤ᵇ y)
≤-isTotalOrder : IsTotalOrder _≈_ _≤_
≤-isTotalOrder = assume
≤-isDecTotalOrder : IsDecTotalOrder _≈_ _≤_
≤-isDecTotalOrder = record { isTotalOrder = ≤-isTotalOrder ; _≟_ = _≈?_ ; _≤?_ = _≤?_ }
≤-decTotalOrder : DecTotalOrder 0ℓ 0ℓ 0ℓ
≤-decTotalOrder = record { isDecTotalOrder = ≤-isDecTotalOrder }
<-isStrictTotalOrder : IsStrictTotalOrder _≈_ _<_
<-isStrictTotalOrder = <-isStrictTotalOrder₁ _≈?_ ≤-isTotalOrder
abs : ℝ → ℝ
abs x = if does (0.0 ≤? x) then x else - x
where
open import Data.Bool using (if_then_else_)
open import Relation.Nullary using (does)
|
{
"alphanum_fraction": 0.7105831533,
"avg_line_length": 27.78,
"ext": "agda",
"hexsha": "7d122b80ccab36f3579aeb297ee459b95127f604",
"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": "a193aeebf1326f960975b19d3e31b46fddbbfaa2",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "cspollard/reals",
"max_forks_repo_path": "src/Data/Real/Order.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a193aeebf1326f960975b19d3e31b46fddbbfaa2",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "cspollard/reals",
"max_issues_repo_path": "src/Data/Real/Order.agda",
"max_line_length": 87,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a193aeebf1326f960975b19d3e31b46fddbbfaa2",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "cspollard/reals",
"max_stars_repo_path": "src/Data/Real/Order.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 503,
"size": 1389
}
|
------------------------------------------------------------------------
-- Various definitions of "true infinitely often", and some proofs
-- showing that this property commutes with binary sums (in the
-- double-negation monad, and sometimes with extra assumptions)
------------------------------------------------------------------------
module InfinitelyOften where
open import Algebra
open import Axiom.ExcludedMiddle
open import Category.Monad
open import Codata.Musical.Notation
open import Data.Empty
open import Data.Nat
import Data.Nat.Properties as NatProp
open import Data.Product as Prod hiding (map)
open import Data.Sum hiding (map)
open import Data.Unit using (tt)
open import Function.Base
open import Function.Equality using (_⟨$⟩_)
open import Function.Equivalence
using (_⇔_; equivalence; module Equivalence)
import Function.Related as Related
open import Level using (Lift; lift; lower)
open import Relation.Binary hiding (_⇒_; _⇔_)
open import Relation.Nullary
open import Relation.Nullary.Negation
import Relation.Nullary.Universe as Univ
open import Relation.Unary hiding (_⇒_)
private
open module M {f} = RawMonad {f = f} ¬¬-Monad
module NatOrder = DecTotalOrder NatProp.≤-decTotalOrder
module NatLattice = DistributiveLattice
NatProp.⊓-⊔-distributiveLattice
------------------------------------------------------------------------
-- Above
module Above where
-- P Above i holds if P holds somewhere above i (perhaps at i
-- itself).
infix 4 _Above_
_Above_ : (ℕ → Set) → (ℕ → Set)
P Above i = ∃ λ j → i ≤ j × P j
-- Conversion lemma.
move-suc : ∀ {P i} → P Above suc i ⇔ (P ∘ suc) Above i
move-suc {P} {i} = equivalence ⇒ ⇐
where
⇒ : P Above suc i → (P ∘ suc) Above i
⇒ (.(1 + j) , s≤s {n = j} i≤j , P[1+j]) = (j , i≤j , P[1+j])
⇐ : (P ∘ suc) Above i → P Above suc i
⇐ (j , i≤j , P[1+j]) = (1 + j , s≤s i≤j , P[1+j])
-- A closure lemma.
stable-up :
∀ {P} →
(∀ i → Stable (P Above i)) → (∀ i → Stable ((P ∘ suc) Above i))
stable-up stable i ¬¬P∘suc⇑i =
Equivalence.to move-suc ⟨$⟩
stable (1 + i) (_⟨$⟩_ (Equivalence.from move-suc) <$> ¬¬P∘suc⇑i)
------------------------------------------------------------------------
-- Has upper bound
module Has-upper-bound where
open Above using (_Above_)
-- P Has-upper-bound i means that P does not hold for any j ≥ i.
infix 4 _Has-upper-bound_
_Has-upper-bound_ : (ℕ → Set) → (ℕ → Set)
P Has-upper-bound i = ∀ j → i ≤ j → ¬ P j
-- A closure lemma.
up : ∀ {P i} → P Has-upper-bound i → (P ∘ suc) Has-upper-bound i
up ¬p = λ j i≤j → ¬p (suc j) (NatProp.≤-step i≤j)
-- A conversion lemma.
move-suc : ∀ {P i} →
P Has-upper-bound suc i ⇔ (P ∘ suc) Has-upper-bound i
move-suc {P} {i} = equivalence ⇒ ⇐
where
⇒ : P Has-upper-bound suc i → (P ∘ suc) Has-upper-bound i
⇒ P↯[1+i] j i≤j P[1+j] = P↯[1+i] (1 + j) (s≤s i≤j) P[1+j]
⇐ : (P ∘ suc) Has-upper-bound i → P Has-upper-bound suc i
⇐ P∘suc↯i .(1 + j) (s≤s {n = j} i≤j) Pj = P∘suc↯i j i≤j Pj
-- _Has-upper-bound_ and _Above_ are mutually inconsistent.
mutually-inconsistent :
∀ {P i} → P Has-upper-bound i ⇔ (¬ (P Above i))
mutually-inconsistent {P} {i} = equivalence ⇒ ⇐
where
⇒ : P Has-upper-bound i → ¬ (P Above i)
⇒ P↯i (j , i≤j , Pj) = P↯i j i≤j Pj
⇐ : ¬ (P Above i) → P Has-upper-bound i
⇐ ¬P⇑i j i≤j Pj = ¬P⇑i (j , i≤j , Pj)
------------------------------------------------------------------------
-- Below
module Below where
open Above using (_Above_)
-- P Below i holds if P holds everywhere below i (including at i).
infix 4 _Below_
_Below_ : (ℕ → Set) → (ℕ → Set)
P Below i = ∀ j → j ≤ i → P j
-- _Below_ P has a comonadic structure (at least if morphism
-- equality is trivial).
map : ∀ {P Q} → P ⊆ Q → _Below_ P ⊆ _Below_ Q
map P⊆Q P⇓i j j≤i = P⊆Q (P⇓i j j≤i)
counit : ∀ {P} → _Below_ P ⊆ P
counit P⇓i = P⇓i _ NatOrder.refl
cojoin : ∀ {P} → _Below_ P ⊆ _Below_ (_Below_ P)
cojoin P⇓i = λ j j≤i k k≤j → P⇓i _ (NatOrder.trans k≤j j≤i)
-- _Above_ (_Below_ P) is pointwise equivalent to _Below_ P.
⇑⇓⇔⇓ : ∀ {P} i → (_Below_ P) Above i ⇔ P Below i
⇑⇓⇔⇓ {P} i = equivalence ⇒ ⇐
where
⇒ : (_Below_ P) Above i → P Below i
⇒ (j , i≤j , P⇓j) k k≤i = P⇓j k (NatOrder.trans k≤i i≤j)
⇐ : P Below i → (_Below_ P) Above i
⇐ P⇓i = (i , NatOrder.refl , P⇓i)
------------------------------------------------------------------------
-- Mixed inductive/coinductive definition of "true infinitely often"
module Mixed where
open Above using (_Above_)
-- Inf P means that P is true for infinitely many natural numbers.
data Inf (P : ℕ → Set) : Set where
now : (p : P 0) (inf : ∞ (Inf (P ∘ suc))) → Inf P
skip : (inf : Inf (P ∘ suc) ) → Inf P
-- Inf commutes with binary sums in the double-negation monad if one
-- of the predicates satisfies a certain stability condition.
up : ∀ {P} → Inf P → Inf (P ∘ suc)
up (now p inf) = ♭ inf
up (skip inf) = inf
filter₁ : ∀ {P Q} → Inf (P ∪ Q) → ¬ ∃ Q → Inf P
filter₁ (now (inj₁ p) inf) ¬q = now p (♯ filter₁ (♭ inf) (¬q ∘ Prod.map suc id))
filter₁ (now (inj₂ q) inf) ¬q = ⊥-elim (¬q (0 , q))
filter₁ (skip inf) ¬q = skip (filter₁ inf (¬q ∘ Prod.map suc id))
filter₂ : ∀ {P Q} → (∀ i → Stable (Q Above i)) →
Inf (P ∪ Q) → ¬ Inf P → Inf Q
filter₂ {P} {Q} stable p∪q ¬p = helper witness stable p∪q ¬p
where
open Related.EquationalReasoning
witness : ∃ Q
witness = Prod.map id proj₂ $ stable 0 (
¬ (Q Above 0) ∼⟨ contraposition (Prod.map id (_,_ z≤n)) ⟩
¬ ∃ Q ∼⟨ filter₁ p∪q ⟩
Inf P ∼⟨ ¬p ⟩
⊥ ∎)
helper : ∀ {P Q} →
∃ Q → (∀ i → Stable (Q Above i)) →
Inf (P ∪ Q) → ¬ Inf P → Inf Q
helper (zero , q) stable p∪q ¬p = now q (♯ filter₂ (Above.stable-up stable) (up p∪q) (¬p ∘ skip))
helper (suc i , q) stable p∪q ¬p = skip (helper (i , q) (Above.stable-up stable) (up p∪q) (¬p ∘ skip))
commutes : ∀ {P Q} → (∀ i → Stable (Q Above i)) →
Inf (P ∪ Q) → ¬ ¬ (Inf P ⊎ Inf Q)
commutes stable p∪q =
call/cc λ ¬[p⊎q] →
return $ inj₂ $ filter₂ stable p∪q (¬[p⊎q] ∘ inj₁)
------------------------------------------------------------------------
-- Alternative inductive/coinductive definition of "true infinitely
-- often"
module Alternative where
open Mixed using (now; skip)
-- Always P means that P holds for every natural number.
data Always (P : ℕ → Set) : Set where
now : (p : P 0) (next : ∞ (Always (P ∘ suc))) → Always P
-- Eventually P means that P holds for some natural number.
data Eventually (P : ℕ → Set) : Set where
now : (p : P 0) → Eventually P
later : (p : Eventually (P ∘ suc)) → Eventually P
-- Inf P means that P is true for infinitely many natural numbers.
Inf : (ℕ → Set) → Set
Inf P = Always (λ n → Eventually (P ∘ _+_ n))
-- This definition is equivalent to the previous one.
up : ∀ P → Inf P → Inf (P ∘ suc)
up _ (now _ inf) = ♭ inf
equivalent : ∀ {P} → Inf P ⇔ Mixed.Inf P
equivalent = equivalence ⇒ ⇐
where
⇒ : ∀ {P} → Inf P → Mixed.Inf P
⇒ (now p inf) = ⇒′ p (♭ inf)
where
⇒′ : ∀ {P} → Eventually P → Inf (P ∘ suc) → Mixed.Inf P
⇒′ (now p) inf = now p (♯ ⇒ inf)
⇒′ {P} (later p) inf = skip (⇒′ p (up (P ∘ suc) inf))
⇐ : ∀ {P} → Mixed.Inf P → Inf P
⇐ inf = now (eventually inf) (♯ ⇐ (Mixed.up inf))
where
eventually : ∀ {P} → Mixed.Inf P → Eventually P
eventually (now p _) = now p
eventually (skip inf) = later (eventually inf)
------------------------------------------------------------------------
-- Functional/inductive definition of "true infinitely often"
module Functional where
open Mixed using (now; skip)
open Above using (_Above_)
-- Inf P means that P is true for infinitely many natural numbers.
Inf : (ℕ → Set) → Set
Inf P = ∀ i → P Above i
-- This definition is equivalent to the ones above.
up : ∀ {P} → Inf P → Inf (P ∘ suc)
up ∀iP⇑i i = Equivalence.to Above.move-suc ⟨$⟩ ∀iP⇑i (suc i)
equivalent : ∀ {P} → Inf P ⇔ Mixed.Inf P
equivalent = equivalence ⇒ ⇐
where
⇒ : ∀ {P} → Inf P → Mixed.Inf P
⇒ {P} inf with inf 0
... | (j , _ , p) = helper inf j p
where
helper : ∀ {P} → Inf P → ∀ j → P j → Mixed.Inf P
helper inf zero p = now p (♯ ⇒ (up inf))
helper inf (suc n) p = skip (helper (up inf) n p)
⇐ : ∀ {P} → Mixed.Inf P → Inf P
⇐ (now p inf) zero = (0 , z≤n , p)
⇐ (skip inf) zero = Prod.map suc (Prod.map (const z≤n) id) $ ⇐ inf zero
⇐ inf (suc i) = Prod.map suc (Prod.map s≤s id) $
⇐ (Mixed.up inf) i
-- Inf is a functor (at least if morphism equality is trivial).
map : ∀ {P₁ P₂} → P₁ ⊆ P₂ → Inf P₁ → Inf P₂
map P₁⊆P₂ inf = λ i → Prod.map id (Prod.map id P₁⊆P₂) (inf i)
------------------------------------------------------------------------
-- Definition of "only true finitely often"
module Fin where
open Mixed using (now; skip)
open Has-upper-bound using (_Has-upper-bound_)
-- Fin P means that P is only true for finitely many natural
-- numbers.
Fin : (ℕ → Set) → Set
Fin P = ∃ λ i → P Has-upper-bound i
-- Fin implies the negation of Mixed.Inf.
⇐ : ∀ {P} → Fin P → ¬ Mixed.Inf P
⇐ = uncurry ⇐′
where
⇐′ : ∀ {P} i → P Has-upper-bound i → ¬ Mixed.Inf P
⇐′ zero fin (now p inf) = fin 0 z≤n p
⇐′ zero fin (skip inf) = ⇐′ zero (λ j i≤j → fin (suc j) z≤n) inf
⇐′ (suc i) fin inf =
⇐′ i (Equivalence.to Has-upper-bound.move-suc ⟨$⟩ fin)
(Mixed.up inf)
-- The other direction (with a double-negated conclusion) implies
-- that Mixed.Inf commutes with binary sums (in the double-negation
-- monad).
filter : ∀ {P Q} → Mixed.Inf (P ∪ Q) → Fin P → Mixed.Inf Q
filter inf (i , fin) = filter′ inf i fin
where
filter′ : ∀ {P Q} →
Mixed.Inf (P ∪ Q) →
∀ i → P Has-upper-bound i → Mixed.Inf Q
filter′ (now (inj₁ p) inf) 0 fin = ⊥-elim (fin 0 z≤n p)
filter′ (now (inj₁ p) inf) (suc i) fin = skip (filter′ (♭ inf) i (Equivalence.to Has-upper-bound.move-suc ⟨$⟩ fin))
filter′ (now (inj₂ q) inf) i fin = now q (♯ filter′ (♭ inf) i (Has-upper-bound.up fin))
filter′ (skip inf) i fin = skip (filter′ inf i (Has-upper-bound.up fin))
commutes : ∀ {P Q} → (¬ Mixed.Inf P → ¬ ¬ Fin P) →
Mixed.Inf (P ∪ Q) → ¬ ¬ (Mixed.Inf P ⊎ Mixed.Inf Q)
commutes ⇒ p∪q =
call/cc λ ¬[p⊎q] →
⇒ (¬[p⊎q] ∘ inj₁) >>= λ fin →
return $ inj₂ (filter p∪q fin)
-- Fin is preserved by binary sums.
∪-preserves : ∀ {P Q} → Fin P → Fin Q → Fin (P ∪ Q)
∪-preserves {P} {Q} (i , ¬p) (j , ¬q) = (i ⊔ j , helper)
where
open NatProp.≤-Reasoning
helper : ∀ k → i ⊔ j ≤ k → ¬ (P ∪ Q) k
helper k i⊔j≤k (inj₁ p) = ¬p k (begin
i ≤⟨ NatProp.m≤m⊔n i j ⟩
i ⊔ j ≤⟨ i⊔j≤k ⟩
k ∎) p
helper k i⊔j≤k (inj₂ q) = ¬q k (begin
j ≤⟨ NatProp.m≤m⊔n j i ⟩
j ⊔ i ≡⟨ NatLattice.∧-comm j i ⟩
i ⊔ j ≤⟨ i⊔j≤k ⟩
k ∎) q
------------------------------------------------------------------------
-- Double-negation shift lemmas
module Double-negation-shift where
open Below using (_Below_)
-- General double-negation shift property.
DNS : (ℕ → Set) → Set
DNS P = (∀ i → ¬ ¬ P i) → ¬ ¬ (∀ i → P i)
-- DNS holds for stable predicates.
Stable⇒DNS : ∀ {P} → (∀ i → Stable (P i)) → DNS P
Stable⇒DNS stable ∀¬¬P = λ ¬∀P → ¬∀P (λ i → stable i (∀¬¬P i))
-- DNS follows from excluded middle.
EM⇒DNS : ∀ {P} → ExcludedMiddle Level.zero → DNS P
EM⇒DNS {P} em hyp = return hyp′
where
hyp′ : ∀ i → P i
hyp′ i = decidable-stable em (hyp i)
-- DNS follows from the double-negation of excluded middle.
¬¬EM⇒DNS : ∀ {P} → ¬ ¬ ExcludedMiddle Level.zero → DNS P
¬¬EM⇒DNS em hyp =
¬¬-map lower (em >>= λ em → ¬¬-map lift (EM⇒DNS em hyp))
-- DNS respects predicate equivalence.
respects : ∀ {P₁ P₂} → (∀ i → P₁ i ⇔ P₂ i) → DNS P₁ → DNS P₂
respects P₁⇔P₂ dns ∀i¬¬P₂i ¬∀iP₂i =
dns (λ i ¬P₁i → ∀i¬¬P₂i i (λ P₂i →
¬P₁i (Equivalence.from (P₁⇔P₂ i) ⟨$⟩ P₂i)))
(λ ∀iP₁i → ¬∀iP₂i (λ i → Equivalence.to (P₁⇔P₂ i) ⟨$⟩ ∀iP₁i i))
-- Double-negation shift property restricted to predicates which are
-- downwards closed.
DNS⇓ : (ℕ → Set) → Set
DNS⇓ P =
(∀ {i j} → i ≥ j → P i → P j) →
(∀ i → ¬ ¬ P i) → ¬ ¬ (∀ i → P i)
-- Certain instances of DNS imply other instances of DNS⇓, and vice
-- versa.
DNS⇒DNS⇓ : ∀ {P} → DNS (_Below_ P) → DNS⇓ P
DNS⇒DNS⇓ {P} shift downwards-closed ∀i¬¬Pi =
_∘_ Below.counit <$> shift (λ i → unit <$> ∀i¬¬Pi i)
where
unit : P ⊆ _Below_ P
unit Pi j j≤i = downwards-closed j≤i Pi
-- The following lemma is due to Thierry Coquand (but the proof,
-- including any inelegance, is due to me).
DNS⇓⇒DNS : ∀ {P} → DNS⇓ (_Below_ P) → DNS P
DNS⇓⇒DNS {P} shift ∀¬¬P = _∘_ Below.counit <$> ¬¬∀P⇓
where
P⇓-downwards-closed : ∀ {i j} → i ≥ j → P Below i → P Below j
P⇓-downwards-closed i≥j P⇓i = λ j′ j′≤j →
P⇓i j′ (NatOrder.trans j′≤j i≥j)
Q : ℕ → Set
Q i = ∀ {j} → j ≤′ i → P j
q-zero : P 0 → Q 0
q-zero P0 ≤′-refl = P0
q-suc : ∀ {i} → P (suc i) → Q i → Q (suc i)
q-suc P1+i Qi ≤′-refl = P1+i
q-suc P1+i Qi (≤′-step j≤i) = Qi j≤i
∀¬¬Q : ∀ i → ¬ ¬ Q i
∀¬¬Q zero = q-zero <$> ∀¬¬P zero
∀¬¬Q (suc i) = q-suc <$> ∀¬¬P (suc i) ⊛ ∀¬¬Q i
∀¬¬P⇓ : ∀ i → ¬ ¬ (P Below i)
∀¬¬P⇓ i = (λ Qi j j≤i → Qi (NatProp.≤⇒≤′ j≤i)) <$> ∀¬¬Q i
¬¬∀P⇓ : ¬ ¬ (∀ i → P Below i)
¬¬∀P⇓ = shift P⇓-downwards-closed ∀¬¬P⇓
------------------------------------------------------------------------
-- "Non-constructive" definition of "true infinitely often"
module NonConstructive where
open Fin using (Fin)
open Above using (_Above_)
open Below using (_Below_)
open Has-upper-bound using (_Has-upper-bound_)
open Double-negation-shift using (DNS; DNS⇓)
-- Inf P means that P is true for infinitely many natural numbers.
Inf : (ℕ → Set) → Set
Inf P = ¬ Fin P
-- Inf commutes with binary sums (in the double-negation monad).
commutes : ∀ {P Q} → Inf (P ∪ Q) → ¬ ¬ (Inf P ⊎ Inf Q)
commutes p∪q =
call/cc λ ¬[p⊎q] →
(λ ¬p ¬q → ⊥-elim (p∪q $ Fin.∪-preserves ¬p ¬q))
<$> ¬[p⊎q] ∘ inj₁ ⊛ ¬[p⊎q] ∘ inj₂
-- Inf is a functor (at least if morphism equality is trivial).
map : ∀ {P₁ P₂} → P₁ ⊆ P₂ → Inf P₁ → Inf P₂
map P₁⊆P₂ ¬fin = λ fin →
¬fin (Prod.map id (λ never j i≤j P₁j → never j i≤j (P₁⊆P₂ P₁j)) fin)
-- If we have a constructive proof of "true infinitely often", then
-- we get a "non-constructive" proof as well.
⇒ : ∀ {P} → Functional.Inf P → Inf P
⇒ inf (i , fin) with inf i
... | (j , i≤j , p) = fin j i≤j p
-- The other direction can be proved iff we have a double-negation
-- shift lemma.
Other-direction : (ℕ → Set) → Set
Other-direction P = Inf P → ¬ ¬ Functional.Inf P
equivalent₁ : ∀ {P} → Other-direction P ⇔ DNS (_Above_ P)
equivalent₁ = equivalence ⇒shift shift⇒
where
shift⇒ : ∀ {P} → DNS (_Above_ P) → Other-direction P
shift⇒ shift ¬fin =
shift (λ i ¬p →
¬fin (i , Equivalence.from
Has-upper-bound.mutually-inconsistent ⟨$⟩ ¬p))
⇒shift : ∀ {P} → Other-direction P → DNS (_Above_ P)
⇒shift hyp p =
hyp (uncurry (λ i fin →
p i (Equivalence.to
Has-upper-bound.mutually-inconsistent ⟨$⟩ fin)))
equivalent₂ : ∀ {P} → Other-direction (_Below_ P) ⇔ DNS P
equivalent₂ {P} = equivalence ⇒shift shift⇒
where
shift⇒ : DNS P → Other-direction (_Below_ P)
shift⇒ shift inf ¬inf =
shift (λ i ¬Pi →
inf (i , λ j i≤j ∀k≤j[Pk] → ¬Pi (∀k≤j[Pk] i i≤j)))
(λ ∀iPi → ¬inf (λ i → i , NatOrder.refl , λ j j≤i → ∀iPi j))
⇒shift : ∀ {P} → Other-direction (_Below_ P) → DNS P
⇒shift {P} =
Other-direction (_Below_ P) ∼⟨ (λ other₁ →
Inf (_Below_ (_Below_ P)) ∼⟨ map Below.counit ⟩
Inf (_Below_ P) ∼⟨ other₁ ⟩
¬ ¬ Functional.Inf (_Below_ P) ∼⟨ _<$>_ (Functional.map Below.cojoin) ⟩
(¬ ¬ Functional.Inf (_Below_ (_Below_ P))) ∎) ⟩
Other-direction (_Below_ (_Below_ P)) ∼⟨ _⟨$⟩_ (Equivalence.to equivalent₁) ⟩
DNS (_Above_ (_Below_ (_Below_ P))) ∼⟨ Double-negation-shift.respects Below.⇑⇓⇔⇓ ⟩
DNS (_Below_ (_Below_ P)) ∼⟨ Double-negation-shift.DNS⇒DNS⇓ ⟩
DNS⇓ (_Below_ P) ∼⟨ Double-negation-shift.DNS⇓⇒DNS ⟩
DNS P ∎
where open Related.EquationalReasoning
equivalent : (∀ P → Other-direction P) ⇔ (∀ P → DNS P)
equivalent =
equivalence (λ other P → _⟨$⟩_ (Equivalence.to equivalent₂)
(other (_Below_ P)))
(λ shift P → _⟨$⟩_ (Equivalence.from equivalent₁)
(shift (_Above_ P)))
-- Some lemmas used below.
up : ∀ {P} → Inf P → Inf (P ∘ suc)
up =
contraposition
(Prod.map suc (_⟨$⟩_ (Equivalence.from Has-upper-bound.move-suc)))
witness : ∀ {P} → Inf P → ¬ ¬ ∃ P
witness ¬fin ¬p = ¬fin (0 , λ i _ Pi → ¬p (i , Pi))
------------------------------------------------------------------------
-- Definition of "true infinitely often" which uses double-negation
module DoubleNegated where
open Fin using (Fin)
open Has-upper-bound using (_Has-upper-bound_)
infixl 4 _⟪$⟫_
mutual
-- Inf P means that P is true for infinitely many natural numbers.
data Inf (P : ℕ → Set) : Set₁ where
now : (p : P 0) (inf : ∞ (¬¬Inf (P ∘ suc))) → Inf P
skip : (inf : Inf (P ∘ suc) ) → Inf P
data ¬¬Inf (P : ℕ → Set) : Set₁ where
_⟪$⟫_ : {A : Set} (f : A → Inf P) (m : ¬ ¬ A) → ¬¬Inf P
-- ¬¬Inf is equivalent to the non-constructive definition given
-- above.
expand : ∀ {P} → ¬¬Inf P → ¬ ¬ Inf P
expand (f ⟪$⟫ m) = λ ¬inf → m (¬inf ∘ f)
¬¬equivalent : ∀ {P} → NonConstructive.Inf P ⇔ ¬¬Inf P
¬¬equivalent = equivalence ⇒ ⇐
where
⇒ : ∀ {P} → NonConstructive.Inf P → ¬¬Inf P
⇒ ¬fin = helper ¬fin ⟪$⟫ NonConstructive.witness ¬fin
where
helper : ∀ {P} → NonConstructive.Inf P → ∃ P → Inf P
helper ¬fin (zero , p) = now p (♯ ⇒ (NonConstructive.up ¬fin))
helper ¬fin (suc i , p) =
skip (helper (NonConstructive.up ¬fin) (i , p))
⇐ : ∀ {P} → ¬¬Inf P → NonConstructive.Inf P
⇐ ¬¬inf (i , fin) = ⇐′ ¬¬inf i fin
where
mutual
⇐′ : ∀ {P} → ¬¬Inf P → ∀ i → ¬ P Has-upper-bound i
⇐′ ¬¬inf i fin = ¬¬-map (helper i fin) (expand ¬¬inf) id
helper : ∀ {P} → ∀ i → P Has-upper-bound i → ¬ Inf P
helper i ¬p (skip inf) = helper i (Has-upper-bound.up ¬p) inf
helper zero ¬p (now p inf) = ¬p 0 z≤n p
helper (suc i) ¬p (now p ¬¬inf) =
⇐′ (♭ ¬¬inf) i (λ j i≤j → ¬p (suc j) (s≤s i≤j))
-- Inf is equivalent to the non-constructive definition given above
-- (in the double-negation monad).
⇐ : ∀ {P} → Inf P → NonConstructive.Inf P
⇐ {P} =
Inf P ∼⟨ (λ inf → const inf ⟪$⟫ return tt) ⟩
¬¬Inf P ∼⟨ _⟨$⟩_ (Equivalence.from ¬¬equivalent) ⟩
NonConstructive.Inf P ∎
where open Related.EquationalReasoning
⇒ : ∀ {P} → NonConstructive.Inf P → ¬ ¬ Inf P
⇒ {P} =
NonConstructive.Inf P ∼⟨ _⟨$⟩_ (Equivalence.to ¬¬equivalent) ⟩
¬¬Inf P ∼⟨ expand ⟩
(¬ ¬ Inf P) ∎
where open Related.EquationalReasoning
equivalent : ∀ {P} → ¬ ¬ (NonConstructive.Inf P ⇔ Inf P)
equivalent {P} =
(λ ⇒′ → equivalence (⇒′ ∘ lift) ⇐) <$>
Univ.¬¬-pull (Univ._⇒_ _ Univ.Id) (λ inf → ⇒ (lower inf))
-- Inf commutes with binary sums (in the double-negation monad).
commutes : ∀ {P Q} → Inf (P ∪ Q) → ¬ ¬ (Inf P ⊎ Inf Q)
commutes {P} {Q} p∪q =
negated-stable $ ¬¬-map helper $ NonConstructive.commutes (⇐ p∪q)
where
helper : NonConstructive.Inf P ⊎ NonConstructive.Inf Q →
¬ ¬ (Inf P ⊎ Inf Q)
helper (inj₁ p) = λ ¬p∪q → ⇒ p (¬p∪q ∘ inj₁)
helper (inj₂ q) = λ ¬p∪q → ⇒ q (¬p∪q ∘ inj₂)
-- You may wonder why double-negation is introduced in a roundabout
-- way in ¬¬Inf above. The reason is that the more direct definition,
-- used in DoubleNegated₂ below, is not strictly positive. Furthermore
-- DoubleNegated₂.equivalent is not accepted by the termination
-- checker.
{-
module DoubleNegated₂ where
open DoubleNegated using (now; skip; _⟪$⟫_)
data Inf (P : ℕ → Set) : Set where
now : (p : P 0) (inf : ∞ (¬ ¬ Inf (P ∘ suc))) → Inf P
skip : (inf : Inf (P ∘ suc) ) → Inf P
equivalent : ∀ {P} → DoubleNegated.Inf P ⇔ Inf P
equivalent = equivalence ⇒ ⇐
where
⇐ : ∀ {P} → Inf P → DoubleNegated.Inf P
⇐ (now p inf) = now p (♯ (⇐ ⟪$⟫ ♭ inf))
⇐ (skip inf) = skip (⇐ inf)
⇒ : ∀ {P} → DoubleNegated.Inf P → Inf P
⇒ (now p inf) with ♭ inf
... | f ⟪$⟫ m = now p (♯ λ ¬inf → m (λ x → ¬inf (⇒ (f x))))
⇒ (skip inf) = skip (⇒ inf)
-}
|
{
"alphanum_fraction": 0.5207205525,
"avg_line_length": 33.1190108192,
"ext": "agda",
"hexsha": "36c9979dd2ee40cdf2a75bd554cf439fb515eb4b",
"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": "InfinitelyOften.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": "InfinitelyOften.agda",
"max_line_length": 119,
"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": "InfinitelyOften.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": 7827,
"size": 21428
}
|
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; subst₂; cong)
open import Data.Nat.Base
open import Data.Fin hiding (_+_; #_)
open import Data.Product using (∃; _×_; _,_; ∃-syntax)
open import DeBruijn
open import Substitution using (rename-subst-commute; subst-commute)
open import Beta
infix 3 _⇉_
data _⇉_ : ∀ {n} → Term n → Term n → Set where
⇉-c : ∀ {n} {x : Fin n}
---------
→ # x ⇉ # x
⇉-ƛ : ∀ {n} {M M′ : Term (suc n)}
→ M ⇉ M′
----------
→ ƛ M ⇉ ƛ M′
⇉-ξ : ∀ {n} {M M′ N N′ : Term n}
→ M ⇉ M′
→ N ⇉ N′
---------------
→ M · N ⇉ M′ · N′
⇉-β : ∀ {n} {M M′ : Term (suc n)} {N N′ : Term n}
→ M ⇉ M′
→ N ⇉ N′
---------------------
→ (ƛ M) · N ⇉ M′ [ N′ ]
par-subst : ∀ {n m} → Subst n m → Subst n m → Set
par-subst σ σ′ = ∀ {x} → σ x ⇉ σ′ x
par-rename : ∀ {n m} {ρ : Rename n m} {M M′ : Term n}
→ M ⇉ M′
------------------------
→ rename ρ M ⇉ rename ρ M′
par-rename ⇉-c = ⇉-c
par-rename (⇉-ƛ p) = ⇉-ƛ (par-rename p)
par-rename (⇉-ξ p₁ p₂) = ⇉-ξ (par-rename p₁) (par-rename p₂)
par-rename {n}{m}{ρ} (⇉-β {n}{N}{N′}{M}{M′} p₁ p₂)
with ⇉-β (par-rename {ρ = ext ρ} p₁) (par-rename {ρ = ρ} p₂)
... | G rewrite rename-subst-commute {n}{m}{N′}{M′}{ρ} = G
par-subst-exts : ∀ {n m} {σ σ′ : Subst n m}
→ par-subst σ σ′
---------------------------
→ par-subst (exts σ) (exts σ′)
par-subst-exts s {x = zero} = ⇉-c
par-subst-exts s {x = suc x} = par-rename s
subst-par : ∀ {n m} {σ σ′ : Subst n m} {M M′ : Term n}
→ par-subst σ σ′
→ M ⇉ M′
----------------------
→ subst σ M ⇉ subst σ′ M′
subst-par {M = # x} s ⇉-c = s
subst-par {n}{m}{σ}{σ′} {ƛ N} s (⇉-ƛ p) =
⇉-ƛ (subst-par {σ = exts σ}{σ′ = exts σ′}
(λ {x} → par-subst-exts s {x = x}) p)
subst-par {M = L · M} s (⇉-ξ p₁ p₂) =
⇉-ξ (subst-par s p₁) (subst-par s p₂)
subst-par {n}{m}{σ}{σ′} {(ƛ N) · M} s (⇉-β {M′ = M′}{N′ = N′} p₁ p₂)
with ⇉-β (subst-par {σ = exts σ}{σ′ = exts σ′}{M = N}
(λ {x} → par-subst-exts s {x = x}) p₁)
(subst-par {σ = σ} s p₂)
... | G rewrite subst-commute {N = M′}{M = N′}{σ = σ′} = G
par-subst-zero : ∀ {n} {M M′ : Term n}
→ M ⇉ M′
----------------------------------------
→ par-subst (subst-zero M) (subst-zero M′)
par-subst-zero M⇉M′ {zero} = M⇉M′
par-subst-zero M⇉M′ {suc x} = ⇉-c
sub-par : ∀ {n} {M M′ : Term (suc n)} {N N′ : Term n}
→ M ⇉ M′
→ N ⇉ N′
-------------------
→ M [ N ] ⇉ M′ [ N′ ]
sub-par M⇉M′ N⇉N′ = subst-par (par-subst-zero N⇉N′) M⇉M′
par-refl : ∀ {n} {M : Term n}
-----
→ M ⇉ M
par-refl {M = # x} = ⇉-c
par-refl {M = ƛ N} = ⇉-ƛ par-refl
par-refl {M = L · M} = ⇉-ξ par-refl par-refl
beta-par : ∀ {n} {M N : Term n}
→ M —→ N
------
→ M ⇉ N
beta-par {M = L · M} (—→-ξₗ r) = ⇉-ξ (beta-par {M = L} r) par-refl
beta-par {M = L · M} (—→-ξᵣ r) = ⇉-ξ par-refl (beta-par {M = M} r)
beta-par {M = ƛ N} (—→-ƛ r) = ⇉-ƛ (beta-par r)
beta-par {M = (ƛ N) · M} —→-β = ⇉-β par-refl par-refl
par-betas : ∀ {n} {M N : Term n}
→ M ⇉ N
------
→ M —↠ N
par-betas {M = # _} (⇉-c {x = x}) = # x ∎
par-betas {M = ƛ M} (⇉-ƛ p) = —↠-cong-ƛ (par-betas p)
par-betas {M = M · N} (⇉-ξ p₁ p₂) = —↠-cong (par-betas p₁) (par-betas p₂)
par-betas {M = (ƛ M) · N} (⇉-β {M′ = M′}{N′ = N′} p₁ p₂) =
let a : (ƛ M) · N —↠ (ƛ M′) · N
a = —↠-congₗ (—↠-cong-ƛ (par-betas p₁))
b : (ƛ M′) · N —↠ (ƛ M′) · N′
b = —↠-congᵣ (par-betas p₂)
c = (ƛ M′) · N′ —→⟨ —→-β ⟩ M′ [ N′ ] ∎ in
—↠-trans (—↠-trans a b) c
infix 3 _⇉*_
infixr 3 _⇉⟨_⟩_
infix 4 _∎
data _⇉*_ : ∀ {n} → Term n → Term n → Set where
_∎ : ∀ {n} (M : Term n)
------
→ M ⇉* M
_⇉⟨_⟩_ : ∀ {n} {L N : Term n} (M : Term n)
→ M ⇉ L
→ L ⇉* N
------
→ M ⇉* N
betas-pars : ∀ {n} {M N : Term n}
→ M —↠ N
------
→ M ⇉* N
betas-pars (M ∎) = M ∎
betas-pars (M —→⟨ b ⟩ bs) = M ⇉⟨ beta-par b ⟩ betas-pars bs
pars-betas : ∀ {n} {M N : Term n}
→ M ⇉* N
------
→ M —↠ N
pars-betas (M ∎) = M ∎
pars-betas (M ⇉⟨ p ⟩ ps) = —↠-trans (par-betas p) (pars-betas ps)
|
{
"alphanum_fraction": 0.4237909135,
"avg_line_length": 25.4285714286,
"ext": "agda",
"hexsha": "e0c889abe0eb61835084519b9e17cb3ffe49370a",
"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": "2fa17f7738cc7da967375be928137adc4be38696",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "iwilare/church-rosser",
"max_forks_repo_path": "Parallel.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2fa17f7738cc7da967375be928137adc4be38696",
"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": "iwilare/church-rosser",
"max_issues_repo_path": "Parallel.agda",
"max_line_length": 73,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "2fa17f7738cc7da967375be928137adc4be38696",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "iwilare/church-rosser",
"max_stars_repo_path": "Parallel.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-22T01:43:09.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-06-02T07:27:54.000Z",
"num_tokens": 2022,
"size": 4094
}
|
-- Basic intuitionistic propositional calculus, without ∨ or ⊥.
-- Hilbert-style formalisation of closed syntax.
-- Sequences of terms.
module BasicIPC.Syntax.ClosedHilbertSequential where
open import BasicIPC.Syntax.Common public
-- Derivations.
infix 3 ⊦⊢_
data ⊦⊢_ : Cx Ty → Set where
nil : ⊦⊢ ∅
mp : ∀ {Ξ A B} → A ▻ B ∈ Ξ → A ∈ Ξ → ⊦⊢ Ξ → ⊦⊢ Ξ , B
ci : ∀ {Ξ A} → ⊦⊢ Ξ → ⊦⊢ Ξ , A ▻ A
ck : ∀ {Ξ A B} → ⊦⊢ Ξ → ⊦⊢ Ξ , A ▻ B ▻ A
cs : ∀ {Ξ A B C} → ⊦⊢ Ξ → ⊦⊢ Ξ , (A ▻ B ▻ C) ▻ (A ▻ B) ▻ A ▻ C
cpair : ∀ {Ξ A B} → ⊦⊢ Ξ → ⊦⊢ Ξ , A ▻ B ▻ A ∧ B
cfst : ∀ {Ξ A B} → ⊦⊢ Ξ → ⊦⊢ Ξ , A ∧ B ▻ A
csnd : ∀ {Ξ A B} → ⊦⊢ Ξ → ⊦⊢ Ξ , A ∧ B ▻ B
unit : ∀ {Ξ} → ⊦⊢ Ξ → ⊦⊢ Ξ , ⊤
infix 3 ⊢_
⊢_ : Ty → Set
⊢ A = ∃ (λ Ξ → ⊦⊢ Ξ , A)
-- Concatenation of derivations.
_⧺⊦_ : ∀ {Ξ Ξ′} → ⊦⊢ Ξ → ⊦⊢ Ξ′ → ⊦⊢ Ξ ⧺ Ξ′
us ⧺⊦ nil = us
us ⧺⊦ mp i j ts = mp (mono∈ weak⊆⧺₂ i) (mono∈ weak⊆⧺₂ j) (us ⧺⊦ ts)
us ⧺⊦ ci ts = ci (us ⧺⊦ ts)
us ⧺⊦ ck ts = ck (us ⧺⊦ ts)
us ⧺⊦ cs ts = cs (us ⧺⊦ ts)
us ⧺⊦ cpair ts = cpair (us ⧺⊦ ts)
us ⧺⊦ cfst ts = cfst (us ⧺⊦ ts)
us ⧺⊦ csnd ts = csnd (us ⧺⊦ ts)
us ⧺⊦ unit ts = unit (us ⧺⊦ ts)
-- Modus ponens in expanded form.
app : ∀ {A B} → ⊢ A ▻ B → ⊢ A → ⊢ B
app {A} {B} (Ξ , ts) (Ξ′ , us) = Ξ″ , vs
where Ξ″ = (Ξ′ , A) ⧺ (Ξ , A ▻ B)
vs = mp top (mono∈ (weak⊆⧺₁ (Ξ , A ▻ B)) top) (us ⧺⊦ ts)
|
{
"alphanum_fraction": 0.431670282,
"avg_line_length": 28.2244897959,
"ext": "agda",
"hexsha": "ae48238040d048f6016629c4e1570b2dad8ca64a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/hilbert-gentzen",
"max_forks_repo_path": "BasicIPC/Syntax/ClosedHilbertSequential.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/hilbert-gentzen",
"max_issues_repo_path": "BasicIPC/Syntax/ClosedHilbertSequential.agda",
"max_line_length": 67,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/hilbert-gentzen",
"max_stars_repo_path": "BasicIPC/Syntax/ClosedHilbertSequential.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z",
"num_tokens": 843,
"size": 1383
}
|
{-# OPTIONS --safe #-}
module Cubical.Algebra.Semigroup.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.SIP
open import Cubical.Data.Sigma
open import Cubical.Reflection.RecordEquiv
open import Cubical.Displayed.Base
open import Cubical.Displayed.Auto
open import Cubical.Displayed.Record
open import Cubical.Displayed.Universe
open Iso
private
variable
ℓ : Level
-- Semigroups as a record, inspired by the Agda standard library:
--
-- https://github.com/agda/agda-stdlib/blob/master/src/Algebra/Bundles.agda#L48
-- https://github.com/agda/agda-stdlib/blob/master/src/Algebra/Structures.agda#L50
--
-- Note that as we are using Path for all equations the IsMagma record
-- would only contain isSet A if we had it.
record IsSemigroup {A : Type ℓ} (_·_ : A → A → A) : Type ℓ where
no-eta-equality
constructor issemigroup
field
is-set : isSet A
·Assoc : (x y z : A) → x · (y · z) ≡ (x · y) · z
unquoteDecl IsSemigroupIsoΣ = declareRecordIsoΣ IsSemigroupIsoΣ (quote IsSemigroup)
record SemigroupStr (A : Type ℓ) : Type ℓ where
constructor semigroupstr
field
_·_ : A → A → A
isSemigroup : IsSemigroup _·_
infixl 7 _·_
open IsSemigroup isSemigroup public
Semigroup : ∀ ℓ → Type (ℓ-suc ℓ)
Semigroup ℓ = TypeWithStr ℓ SemigroupStr
module _ (A : Type ℓ) (_·_ : A → A → A) (h : IsSemigroup _·_) where
semigroup : Semigroup ℓ
semigroup .fst = A
semigroup .snd .SemigroupStr._·_ = _·_
semigroup .snd .SemigroupStr.isSemigroup = h
record IsSemigroupEquiv {A : Type ℓ} {B : Type ℓ}
(M : SemigroupStr A) (e : A ≃ B) (N : SemigroupStr B)
: Type ℓ
where
-- Shorter qualified names
private
module M = SemigroupStr M
module N = SemigroupStr N
field
isHom : (x y : A) → equivFun e (x M.· y) ≡ equivFun e x N.· equivFun e y
open SemigroupStr
open IsSemigroup
open IsSemigroupEquiv
SemigroupEquiv : (M N : Semigroup ℓ) → Type ℓ
SemigroupEquiv M N = Σ[ e ∈ ⟨ M ⟩ ≃ ⟨ N ⟩ ] IsSemigroupEquiv (M .snd) e (N .snd)
isPropIsSemigroup : {A : Type ℓ} (_·_ : A → A → A) → isProp (IsSemigroup _·_)
isPropIsSemigroup _·_ =
isOfHLevelRetractFromIso 1 IsSemigroupIsoΣ
(isPropΣ
isPropIsSet
(λ isSetA → isPropΠ3 λ _ _ _ → isSetA _ _))
𝒮ᴰ-Semigroup : DUARel (𝒮-Univ ℓ) SemigroupStr ℓ
𝒮ᴰ-Semigroup =
𝒮ᴰ-Record (𝒮-Univ _) IsSemigroupEquiv
(fields:
data[ _·_ ∣ autoDUARel _ _ ∣ isHom ]
prop[ isSemigroup ∣ (λ _ _ → isPropIsSemigroup _) ])
SemigroupPath : (M N : Semigroup ℓ) → SemigroupEquiv M N ≃ (M ≡ N)
SemigroupPath = ∫ 𝒮ᴰ-Semigroup .UARel.ua
|
{
"alphanum_fraction": 0.6968911917,
"avg_line_length": 27.02,
"ext": "agda",
"hexsha": "7ec2bd84c08bc49d6c249ffa41100e1ab40e26f7",
"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/Semigroup/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/Algebra/Semigroup/Base.agda",
"max_line_length": 83,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/Algebra/Semigroup/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 958,
"size": 2702
}
|
{-# OPTIONS --copatterns --show-implicit #-}
module Issue940 where
module _ (A : Set) where
record Box : Set where
constructor box
field
unbox : A
open Box
postulate x : A
ex : Box
ex = box x -- works
ex' : Box
unbox ex' = x
-- Error WAS:
-- An internal error has occurred. Please report this as a bug.
-- Location of the error: src/full/Agda/TypeChecking/Substitute.hs:326
postulate
A : Set
ok : Box A
Box.unbox ok = x A -- works
|
{
"alphanum_fraction": 0.629707113,
"avg_line_length": 14.9375,
"ext": "agda",
"hexsha": "ce696363bf9d2224ce7b063bca76258ac2323b42",
"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/Issue940.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/Issue940.agda",
"max_line_length": 72,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue940.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": 148,
"size": 478
}
|
module Issue558b where
data Nat : Set where
Z : Nat
S : Nat → Nat
data _≡_ {A : Set} (a : A) : A → Set where
Refl : a ≡ a
plus : Nat → Nat → Nat
plus Z n = n
plus (S n) m = S (plus n m)
data Addable (τ : Set) : Set where
addable : (τ → τ → τ) → Addable τ
plus' : {τ : Set} → Addable τ → τ → τ → τ
plus' (addable p) = p
record ⊤ : Set where
module AddableM {τ : Set} {a : ⊤} (a : Addable τ) where
_+_ : τ → τ → τ
_+_ = plus' a
-- record Addable (τ : Set) : Set where
-- constructor addable
-- field
-- _+_ : τ → τ → τ
open module AddableIFS {t : Set} {a : ⊤} {{r : Addable t}} = AddableM {t} r
data CommAddable (τ : Set) {a : ⊤} : Set where
commAddable : (addable : Addable τ) → ((a b : τ) → (a + b) ≡ (b + a)) → CommAddable τ
private
addableCA' : {τ : Set} (ca : CommAddable τ) → Addable τ
addableCA' (commAddable a _) = a
comm' : {τ : Set} (ca : CommAddable τ) →
let a = addableCA' ca in (a b : τ) → (a + b) ≡ (b + a)
comm' (commAddable _ c) = c
module CommAddableM {τ : Set} {a : ⊤} (ca : CommAddable τ) where
addableCA : Addable τ
addableCA = addableCA' ca
comm : (a b : τ) → (a + b) ≡ (b + a)
comm = comm' ca
natAdd : Addable Nat
natAdd = addable plus
postulate commPlus : (a b : Nat) → plus a b ≡ plus b a
commNatAdd : CommAddable Nat
commNatAdd = commAddable natAdd commPlus
open CommAddableM {{...}}
test : (Z + Z) ≡ Z
test = comm Z Z
a : {x y : Nat} → (S (S Z) + (x + y)) ≡ ((x + y) + S (S Z))
a {x}{y} = comm (S (S Z)) (x + y)
|
{
"alphanum_fraction": 0.5503669113,
"avg_line_length": 22.7121212121,
"ext": "agda",
"hexsha": "6d00062b19a8ba60bcd102b75a50a158fc967e82",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/succeed/Issue558b.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/succeed/Issue558b.agda",
"max_line_length": 86,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/succeed/Issue558b.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": 620,
"size": 1499
}
|
-- Andreas, 2017-01-01, issue 2372, reported by m0davis
-- This file is imported by Issue2372ImportInst.
module Issue2372Inst where
postulate D : Set
record R : Set₁ where
field
r : Set
open R {{ ... }} public
instance iR = record { r = D }
|
{
"alphanum_fraction": 0.6758893281,
"avg_line_length": 15.8125,
"ext": "agda",
"hexsha": "e6623e78fb7afa74494bc73c9c63b6b1a7535507",
"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/Issue2372Inst.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/Issue2372Inst.agda",
"max_line_length": 55,
"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/Issue2372Inst.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": 80,
"size": 253
}
|
{-# OPTIONS --rewriting #-}
module Examples.Run where
open import Agda.Builtin.Equality using (_≡_; refl)
open import Luau.Syntax using (nil; var; _$_; function_⟨_⟩_end; return; _∙_; done)
open import Luau.Value using (nil)
open import Luau.Run using (run; return)
open import Luau.Heap using (emp; lookup-next; next-emp; lookup-next-emp)
import Agda.Builtin.Equality.Rewrite
{-# REWRITE lookup-next next-emp lookup-next-emp #-}
x = var "x"
id = var "id"
ex1 : (run (function "id" ⟨ "x" ⟩ return x ∙ done end ∙ return (id $ nil) ∙ done) ≡ return nil _)
ex1 = refl
|
{
"alphanum_fraction": 0.6942003515,
"avg_line_length": 29.9473684211,
"ext": "agda",
"hexsha": "bfa798394b51c7eae61ddc47d5b97a42e9a4043e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "FreakingBarbarians/luau",
"max_forks_repo_path": "prototyping/Examples/Run.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "FreakingBarbarians/luau",
"max_issues_repo_path": "prototyping/Examples/Run.agda",
"max_line_length": 97,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "FreakingBarbarians/luau",
"max_stars_repo_path": "prototyping/Examples/Run.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-11T21:30:17.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-02-11T21:30:17.000Z",
"num_tokens": 180,
"size": 569
}
|
module Issue5563 where
F : (@0 A : Set) → A → A
F A x =
let
y : A
y = x
in y
|
{
"alphanum_fraction": 0.4555555556,
"avg_line_length": 10,
"ext": "agda",
"hexsha": "d66baf84240999c8e41fd7d78ff7de666c2ba8d3",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "KDr2/agda",
"max_forks_repo_path": "test/Succeed/Issue5563.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "KDr2/agda",
"max_issues_repo_path": "test/Succeed/Issue5563.agda",
"max_line_length": 24,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "KDr2/agda",
"max_stars_repo_path": "test/Succeed/Issue5563.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-05T00:25:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-03-05T00:25:14.000Z",
"num_tokens": 40,
"size": 90
}
|
module Cats.Category.Fun.Facts where
open import Cats.Category
open import Cats.Category.Cat using (_≈_)
open import Cats.Category.Fun using (Trans ; Fun ; ≈-intro ; ≈-elim)
open import Cats.Functor using (Functor)
open import Cats.Trans.Iso using (NatIso ; iso ; forth-natural ; back-natural)
open import Level using (_⊔_)
open Functor
open Trans
open Category._≅_
module _ {lo la l≈ lo′ la′ l≈′}
{C : Category lo la l≈}
{D : Category lo′ la′ l≈′}
{F G : Functor C D}
where
private
module C = Category C
module D = Category D
open D.≈-Reasoning
open Category (Fun C D) using (_≅_)
NatIso→≅ : NatIso F G → F ≅ G
NatIso→≅ i = record
{ forth = Forth i
; back = Back i
; back-forth = ≈-intro (back-forth (iso i))
; forth-back = ≈-intro (forth-back (iso i))
}
where
open NatIso
≅→NatIso : F ≅ G → NatIso F G
≅→NatIso i = record
{ iso = λ {c} → record
{ forth = component (forth i) c
; back = component (back i) c
; back-forth = ≈-elim (back-forth i)
; forth-back = ≈-elim (forth-back i)
}
; forth-natural = natural (forth i)
}
≈→≅ : F ≈ G → F ≅ G
≈→≅ eq = NatIso→≅ eq
≅→≈ : F ≅ G → F ≈ G
≅→≈ i = ≅→NatIso i
|
{
"alphanum_fraction": 0.5627466456,
"avg_line_length": 21.8448275862,
"ext": "agda",
"hexsha": "0611058d4dba5379ad330dbf7deec75b6b811f6f",
"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/Fun/Facts.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "alessio-b-zak/cats",
"max_issues_repo_path": "Cats/Category/Fun/Facts.agda",
"max_line_length": 78,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "alessio-b-zak/cats",
"max_stars_repo_path": "Cats/Category/Fun/Facts.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 452,
"size": 1267
}
|
{-# OPTIONS --without-K --rewriting #-}
module Classifying where
open import Basics
open import Flat
open import lib.types.Sigma
open import lib.Equivalence2
open import lib.types.Truncation
BAut : ∀ {i} {X : Type i} (x : X) → Type i
BAut {X = X} x = Σ X $ (\y → ∥ x == y ∥)
♭-commutes-with-BAut : {@♭ i : ULevel } (@♭ X : Type i) (@♭ x : X)
→ (♭ (BAut x)) ≃ BAut (x ^♭)
♭-commutes-with-BAut X x = ♭ (BAut x)
≃⟨ ♭-commutes-with-Σ ⟩
Σ (♭ X) (\u → let♭ y ^♭:= u in♭ (♭ ∥ x == y ∥))
≃⟨ Σ-emap-r lemma₂ ⟩
Σ (♭ X) (\u → let♭ y ^♭:= u in♭ ∥ ♭ (x == y) ∥)
≃⟨ Σ-emap-r lemma₁ ⟩
BAut (x ^♭)
≃∎
where
lemma₁ : (z : ♭ X) → (let♭ y ^♭:= z in♭ ∥ ♭ (x == y) ∥) ≃ ∥ (x ^♭) == z ∥
lemma₁ (z ^♭) = Trunc-emap (♭-identity-eq x z)
lemma₂ : (z : ♭ X) → (let♭ y ^♭:= z in♭ (♭ ∥ x == y ∥)) ≃ (let♭ y ^♭:= z in♭ ∥ ♭ (x == y) ∥)
lemma₂ (z ^♭) = (♭-Trunc-eq (x == z)) ⁻¹
_is-locally-crisply-discrete : {@♭ i : ULevel} (@♭ X : Type i) → Type i
_is-locally-crisply-discrete X = (@♭ x y : X) → (x == y) is-discrete
|
{
"alphanum_fraction": 0.38359375,
"avg_line_length": 36.5714285714,
"ext": "agda",
"hexsha": "6f6edcd152c8764376c0add3142c1754f01e5ac1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "glangmead/formalization",
"max_forks_repo_path": "cohesion/david_jaz_261/Classifying.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "glangmead/formalization",
"max_issues_repo_path": "cohesion/david_jaz_261/Classifying.agda",
"max_line_length": 99,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "glangmead/formalization",
"max_stars_repo_path": "cohesion/david_jaz_261/Classifying.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-13T05:51:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-06T17:39:22.000Z",
"num_tokens": 539,
"size": 1280
}
|
module Section8 where
open import Section7 public
-- 8. Correctness of conversion between terms
-- ==========================================
--
-- The conversion rules for terms are sound:
-- Theorem 9.
postulate
thm₉ : ∀ {Γ A t₀ t₁} →
(M N : Γ ⊢ A) → t₀ 𝒟 M → t₁ 𝒟 N → Γ ⊢ t₀ ≊ t₁ ∷ A →
M ≅ N
-- Proof: The proof is by induction on the proof of `Γ ⊢ t₀ ≊ t₁ ∷ A`. We illustrate the proof
-- with the reflexivity case. In this case we have that `t₀` and `t₁` are the same, hence by Corollary 3
-- we get `M ≅ N`.
--
-- To prove that the conversion rules are complete
-- is straightforward by induction on the proof of `M ≅ N`.
-- Theorem 10.
postulate
thm₁₀ : ∀ {Γ A} →
(M N : Γ ⊢ A) → M ≅ N →
Γ ⊢ M ⁻ ≊ N ⁻ ∷ A
|
{
"alphanum_fraction": 0.5499351492,
"avg_line_length": 26.5862068966,
"ext": "agda",
"hexsha": "c6b791c9d08037cd69736c4682e8914bd43cac5f",
"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": "7c000654c4f97024d2939c412702f64dc821d4ec",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/coquand",
"max_forks_repo_path": "src/Section8.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/coquand",
"max_issues_repo_path": "src/Section8.agda",
"max_line_length": 105,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/coquand",
"max_stars_repo_path": "src/Section8.agda",
"max_stars_repo_stars_event_max_datetime": "2017-09-07T12:44:40.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-03-27T01:29:58.000Z",
"num_tokens": 265,
"size": 771
}
|
open import Agda.Primitive using (lzero; lsuc; _⊔_)
import SecondOrder.Arity
import SecondOrder.Signature
import SecondOrder.Metavariable
import SecondOrder.Renaming
import SecondOrder.Term
module SecondOrder.Theory
{ℓ}
{𝔸 : SecondOrder.Arity.Arity}
(Σ : SecondOrder.Signature.Signature ℓ 𝔸)
where
open SecondOrder.Metavariable Σ public
open SecondOrder.Term Σ public
open SecondOrder.Signature.Signature Σ public
open SecondOrder.Renaming Σ
record Axiom : Set ℓ where
constructor make-ax
field
ax-mv-ctx : MContext -- metavariable context of an equation
ax-sort : sort -- sort of an equation
ax-lhs : Term ax-mv-ctx ctx-empty ax-sort -- left-hand side
ax-rhs : Term ax-mv-ctx ctx-empty ax-sort -- right-hand side
record Theory ℓa : Set (lsuc (ℓ ⊔ ℓa)) where
field
ax : Set ℓa -- the axioms
ax-eq : ax → Axiom -- each axiom has a corresponding Axiom
ax-mv-ctx : ax → MContext -- the meta-context of each axiom
ax-mv-ctx ε = Axiom.ax-mv-ctx (ax-eq ε)
ax-sort : ax → sort -- the sort of each axiom
ax-sort ε = Axiom.ax-sort (ax-eq ε)
-- the left- and right-hand side of each axiom s ≈ t, promoted to any context
ax-lhs : ∀ (ε : ax) {Γ} → Term (ax-mv-ctx ε) Γ (ax-sort ε)
ax-lhs ε = [ inʳ ]ʳ Axiom.ax-lhs (ax-eq ε)
ax-rhs : ∀ (ε : ax) {Γ} → Term (ax-mv-ctx ε) Γ (ax-sort ε)
ax-rhs ε = [ inʳ ]ʳ Axiom.ax-rhs (ax-eq ε)
|
{
"alphanum_fraction": 0.6610644258,
"avg_line_length": 31.7333333333,
"ext": "agda",
"hexsha": "3dcc87295a3375740a6258e9e4522eb4f081ff11",
"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": "2aaf850bb1a262681c5a232cdefae312f921b9d4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "andrejbauer/formaltt",
"max_forks_repo_path": "src/SecondOrder/Theory.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "andrejbauer/formaltt",
"max_issues_repo_path": "src/SecondOrder/Theory.agda",
"max_line_length": 81,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "andrejbauer/formal",
"max_stars_repo_path": "src/SecondOrder/Theory.agda",
"max_stars_repo_stars_event_max_datetime": "2021-04-18T18:21:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-04-18T18:21:00.000Z",
"num_tokens": 490,
"size": 1428
}
|
------------------------------------------------------------------------------
-- Properties for the bisimilarity relation
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOT.FOTC.Relation.Binary.Bisimilarity.PropertiesI where
open import Common.FOL.Relation.Binary.EqReasoning
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Base.List.PropertiesI
open import FOTC.Relation.Binary.Bisimilarity.Type
------------------------------------------------------------------------------
{-# TERMINATING #-}
≈→≡ : ∀ {xs ys} → xs ≈ ys → xs ≡ ys
≈→≡ {xs} {ys} h with ≈-out h
... | x' , xs' , ys' , prf₁ , prf₂ , prf₃ =
xs ≡⟨ prf₁ ⟩
x' ∷ xs' ≡⟨ ∷-rightCong (≈→≡ prf₃) ⟩
x' ∷ ys' ≡⟨ sym prf₂ ⟩
ys ∎
|
{
"alphanum_fraction": 0.4462193823,
"avg_line_length": 32.3793103448,
"ext": "agda",
"hexsha": "092646cea8a8a63b7b12b043754606cf7dc070f4",
"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/Relation/Binary/Bisimilarity/PropertiesI.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "notes/FOT/FOTC/Relation/Binary/Bisimilarity/PropertiesI.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/Relation/Binary/Bisimilarity/PropertiesI.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z",
"num_tokens": 252,
"size": 939
}
|
{-# OPTIONS --cubical --safe #-}
module Data.Binary.PerformanceTests.Multiplication where
open import Prelude
open import Data.Binary.Definition
open import Data.Binary.Addition using (_+_)
open import Data.Binary.Multiplication using (_*_)
open import Data.Binary.Increment using (inc)
one-thousand : 𝔹
one-thousand = 2ᵇ 1ᵇ 1ᵇ 2ᵇ 1ᵇ 2ᵇ 2ᵇ 2ᵇ 2ᵇ 0ᵇ
pow-r : 𝔹 → ℕ → 𝔹
pow-r x zero = 1ᵇ 0ᵇ
pow-r x (suc n) = x * pow-r (inc x) n
pow-l : 𝔹 → ℕ → 𝔹
pow-l x zero = 1ᵇ 0ᵇ
pow-l x (suc n) = pow-l (inc x) n * x
n : ℕ
n = 6
f : 𝔹
f = one-thousand
-- The actual performance test (uncomment and time how long it takes to type-check)
-- _ : pow-r f n ≡ pow-l f n
-- _ = refl
|
{
"alphanum_fraction": 0.6661742984,
"avg_line_length": 21.8387096774,
"ext": "agda",
"hexsha": "deada951a851702fe0e8897e46371392347f01a4",
"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/Multiplication.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/Multiplication.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/Multiplication.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": 281,
"size": 677
}
|
{-# OPTIONS --without-K #-}
module Data.Tuple.Base where
open import Level using (_⊔_)
-- non-dependent pair; failed to reuse _×_
record Pair {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where
constructor _,_
field
fst : A
snd : B
{-# FOREIGN GHC type AgdaPair a b c d = (c , d) #-}
-- {-# COMPILE GHC Pair = type MAlonzo.Code.Data.Tuple.AgdaPair #-}
{-# COMPILE GHC Pair = data MAlonzo.Code.Data.Tuple.AgdaPair ((,)) #-}
infixl 5 _∥_
_∥_ = Pair
|
{
"alphanum_fraction": 0.6168831169,
"avg_line_length": 23.1,
"ext": "agda",
"hexsha": "dbead0787f0fa9e7993e2c2977bc28c6db1f814e",
"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": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "semenov-vladyslav/bytes-agda",
"max_forks_repo_path": "src/Data/Tuple/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626",
"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": "semenov-vladyslav/bytes-agda",
"max_issues_repo_path": "src/Data/Tuple/Base.agda",
"max_line_length": 70,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "semenov-vladyslav/bytes-agda",
"max_stars_repo_path": "src/Data/Tuple/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 156,
"size": 462
}
|
------------------------------------------------------------------------------
-- Group theory
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module GroupTheory.README where
------------------------------------------------------------------------------
-- Description
-- Theory of groups using Agda postulates for the group axioms.
------------------------------------------------------------------------------
-- The axioms
open import GroupTheory.Base
-- Basic properties
open import GroupTheory.PropertiesATP
open import GroupTheory.PropertiesI
-- Commutator properties
open import GroupTheory.Commutator.PropertiesATP
open import GroupTheory.Commutator.PropertiesI
-- Abelian groups
open import GroupTheory.AbelianGroup.PropertiesATP
|
{
"alphanum_fraction": 0.4842105263,
"avg_line_length": 30.6451612903,
"ext": "agda",
"hexsha": "e0b1f8f26908170399b51590794299821ab9028d",
"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/GroupTheory/README.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "src/fot/GroupTheory/README.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "src/fot/GroupTheory/README.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z",
"num_tokens": 143,
"size": 950
}
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import Setoids.Setoids
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Numbers.Naturals.Semiring
open import Sets.Cardinality.Finite.Definition
open import Groups.Definition
module Groups.FiniteGroups.Definition where
record FiniteGroup {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_·_ : A → A → A} (G : Group S _·_) {c : _} (quotientSet : Set c) : Set (a ⊔ b ⊔ c) where
field
toSet : SetoidToSet S quotientSet
finite : FiniteSet quotientSet
groupOrder : {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_·_ : A → A → A} {underG : Group S _·_} {c : _} {quotientSet : Set c} (G : FiniteGroup underG quotientSet) → ℕ
groupOrder record { toSet = toSet ; finite = record { size = size ; mapping = mapping ; bij = bij } } = size
|
{
"alphanum_fraction": 0.6601226994,
"avg_line_length": 45.2777777778,
"ext": "agda",
"hexsha": "6c2e43e99a4bcc0d10457f23d891fd7c64d50ea2",
"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/FiniteGroups/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/FiniteGroups/Definition.agda",
"max_line_length": 169,
"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/FiniteGroups/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": 274,
"size": 815
}
|
------------------------------------------------------------------------
-- A tiny library of derived combinators
------------------------------------------------------------------------
module TotalRecognisers.LeftRecursion.Lib (Tok : Set) where
open import Codata.Musical.Notation
open import Data.Bool hiding (_∧_; _≤_)
open import Data.Bool.Properties
open import Function hiding (_∋_)
open import Function.Equality using (_⟨$⟩_)
open import Function.Equivalence using (module Equivalence)
open import Data.List
open import Data.Nat using (ℕ; zero; suc)
open import Data.Product as Prod
open import Relation.Binary
open import Relation.Binary.PropositionalEquality hiding ([_])
open import Relation.Nullary.Decidable
import TotalRecognisers.LeftRecursion
open TotalRecognisers.LeftRecursion Tok
------------------------------------------------------------------------
-- Kleene star
-- The intended semantics of the Kleene star.
infixr 5 _∷_
infix 4 _∈[_]⋆
data _∈[_]⋆ {n} : List Tok → P n → Set where
[] : ∀ {p} → [] ∈[ p ]⋆
_∷_ : ∀ {s₁ s₂ p} → s₁ ∈ p → s₂ ∈[ p ]⋆ → s₁ ++ s₂ ∈[ p ]⋆
module KleeneStar₁ where
infix 15 _⋆ _+
-- This definition requires that the argument recognisers are not
-- nullable.
mutual
_⋆ : P false → P true
p ⋆ = empty ∣ p +
_+ : P false → P false
p + = p · ♯ (p ⋆)
-- The definition of _⋆ above is correct.
⋆-sound : ∀ {s p} → s ∈ p ⋆ → s ∈[ p ]⋆
⋆-sound (∣-left empty) = []
⋆-sound (∣-right (pr₁ · pr₂)) = pr₁ ∷ ⋆-sound pr₂
⋆-complete : ∀ {s p} → s ∈[ p ]⋆ → s ∈ p ⋆
⋆-complete [] = ∣-left empty
⋆-complete (_∷_ {[]} pr₁ pr₂) = ⋆-complete pr₂
⋆-complete (_∷_ {_ ∷ _} pr₁ pr₂) =
∣-right {n₁ = true} (pr₁ · ⋆-complete pr₂)
module KleeneStar₂ where
infix 15 _⋆
-- This definition works for any argument recogniser.
_⋆ : ∀ {n} → P n → P true
_⋆ = KleeneStar₁._⋆ ∘ nonempty
-- The definition of _⋆ above is correct.
⋆-sound : ∀ {s n} {p : P n} → s ∈ p ⋆ → s ∈[ p ]⋆
⋆-sound (∣-left empty) = []
⋆-sound (∣-right (nonempty pr₁ · pr₂)) = pr₁ ∷ ⋆-sound pr₂
⋆-complete : ∀ {s n} {p : P n} → s ∈[ p ]⋆ → s ∈ p ⋆
⋆-complete [] = ∣-left empty
⋆-complete (_∷_ {[]} pr₁ pr₂) = ⋆-complete pr₂
⋆-complete (_∷_ {_ ∷ _} pr₁ pr₂) =
∣-right {n₁ = true} (nonempty pr₁ · ⋆-complete pr₂)
-- Note, however, that for actual parsing the corresponding
-- definition would not be correct. The reason is that p would give
-- a result also when the empty string was accepted, and these
-- results are ignored by the definition above. In the case of
-- actual parsing the result of p ⋆, when p is nullable, should be a
-- stream and not a finite list.
------------------------------------------------------------------------
-- A simplified sequencing operator
infixl 10 _⊙_
_⊙_ : ∀ {n₁ n₂} → P n₁ → P n₂ → P (n₁ ∧ n₂)
_⊙_ {n₁ = n₁} p₁ p₂ = ♯? p₁ · ♯? {b = n₁} p₂
module ⊙ where
complete : ∀ {n₁ n₂ s₁ s₂} {p₁ : P n₁} {p₂ : P n₂} →
s₁ ∈ p₁ → s₂ ∈ p₂ → s₁ ++ s₂ ∈ p₁ ⊙ p₂
complete {n₁} {n₂} s₁∈p₁ s₂∈p₂ = add-♭♯ n₂ s₁∈p₁ · add-♭♯ n₁ s₂∈p₂
infixl 10 _⊙′_
infix 4 _⊙_∋_
data _⊙_∋_ {n₁ n₂} (p₁ : P n₁) (p₂ : P n₂) : List Tok → Set where
_⊙′_ : ∀ {s₁ s₂} (s₁∈p₁ : s₁ ∈ p₁) (s₂∈p₂ : s₂ ∈ p₂) →
p₁ ⊙ p₂ ∋ s₁ ++ s₂
sound : ∀ {n₁} n₂ {s} {p₁ : P n₁} {p₂ : P n₂} →
s ∈ p₁ ⊙ p₂ → p₁ ⊙ p₂ ∋ s
sound {n₁} n₂ (s₁∈p₁ · s₂∈p₂) = drop-♭♯ n₂ s₁∈p₁ ⊙′ drop-♭♯ n₁ s₂∈p₂
------------------------------------------------------------------------
-- A combinator which repeats a recogniser a fixed number of times
⟨_^_⟩-nullable : Bool → ℕ → Bool
⟨ n ^ zero ⟩-nullable = true
⟨ n ^ suc i ⟩-nullable = n ∧ ⟨ n ^ i ⟩-nullable
infixl 15 _^_
_^_ : ∀ {n} → P n → (i : ℕ) → P ⟨ n ^ i ⟩-nullable
p ^ 0 = empty
p ^ suc i = p ⊙ p ^ i
-- Some lemmas relating _^_ to _⋆.
open KleeneStar₂
^≤⋆ : ∀ {n} {p : P n} i → p ^ i ≤ p ⋆
^≤⋆ {n} {p} i s∈ = ⋆-complete $ helper i s∈
where
helper : ∀ i {s} → s ∈ p ^ i → s ∈[ p ]⋆
helper zero empty = []
helper (suc i) (s₁∈p · s₂∈pⁱ) =
drop-♭♯ ⟨ n ^ i ⟩-nullable s₁∈p ∷ helper i (drop-♭♯ n s₂∈pⁱ)
⋆≤^ : ∀ {n} {p : P n} {s} → s ∈ p ⋆ → ∃ λ i → s ∈ p ^ i
⋆≤^ {n} {p} s∈p⋆ = helper (⋆-sound s∈p⋆)
where
helper : ∀ {s} → s ∈[ p ]⋆ → ∃ λ i → s ∈ p ^ i
helper [] = (0 , empty)
helper (s₁∈p ∷ s₂∈p⋆) =
Prod.map suc (λ {i} s₂∈pⁱ → add-♭♯ ⟨ n ^ i ⟩-nullable s₁∈p ·
add-♭♯ n s₂∈pⁱ)
(helper s₂∈p⋆)
------------------------------------------------------------------------
-- A recogniser which only accepts a given token
module Tok (dec : Decidable (_≡_ {A = Tok})) where
tok : Tok → P false
tok t = sat (⌊_⌋ ∘ dec t)
sound : ∀ {s t} → s ∈ tok t → s ≡ [ t ]
sound (sat ok) = cong [_] $ sym $ toWitness ok
complete : ∀ {t} → [ t ] ∈ tok t
complete = sat (fromWitness refl)
------------------------------------------------------------------------
-- A recogniser which accepts the empty string iff the argument is
-- true (and never accepts non-empty strings)
accept-if-true : ∀ b → P b
accept-if-true true = empty
accept-if-true false = fail
module AcceptIfTrue where
sound : ∀ b {s} → s ∈ accept-if-true b → s ≡ [] × T b
sound true empty = (refl , _)
sound false ()
complete : ∀ {b} → T b → [] ∈ accept-if-true b
complete ok with Equivalence.to T-≡ ⟨$⟩ ok
... | refl = empty
|
{
"alphanum_fraction": 0.4996345029,
"avg_line_length": 30.2320441989,
"ext": "agda",
"hexsha": "4758e64f1d01d01d672ab3c969d16dcdb1accde7",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/parser-combinators",
"max_forks_repo_path": "TotalRecognisers/LeftRecursion/Lib.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/parser-combinators",
"max_issues_repo_path": "TotalRecognisers/LeftRecursion/Lib.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/parser-combinators",
"max_stars_repo_path": "TotalRecognisers/LeftRecursion/Lib.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z",
"num_tokens": 2128,
"size": 5472
}
|
-- Andreas, 2016-06-08 issue #2006 (actually #289)
open import Common.Reflection
open import Common.Prelude
bla : Term → Term
bla = {!!} -- Splitting here should be fine
macro
comp : Term → Term → TC ⊤
comp x t = bindTC (quoteTC (bla x)) (λ y → unify t y)
foo : Term
foo = comp Set
|
{
"alphanum_fraction": 0.6563573883,
"avg_line_length": 19.4,
"ext": "agda",
"hexsha": "bb5c6b118854fcd066e5223708e5c1e275fce922",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/interaction/Issue2006.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/interaction/Issue2006.agda",
"max_line_length": 55,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/interaction/Issue2006.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 93,
"size": 291
}
|
{-# OPTIONS --rewriting #-}
module Luau.StrictMode where
open import Agda.Builtin.Equality using (_≡_)
open import FFI.Data.Maybe using (just; nothing)
open import Luau.Syntax using (Expr; Stat; Block; BinaryOperator; yes; nil; addr; var; binexp; var_∈_; _⟨_⟩∈_; function_is_end; _$_; block_is_end; local_←_; _∙_; done; return; name; +; -; *; /; <; >; <=; >=; ··)
open import Luau.Type using (Type; nil; number; string; boolean; _⇒_; _∪_; _∩_; src; tgt)
open import Luau.Subtyping using (_≮:_)
open import Luau.Heap using (Heap; function_is_end) renaming (_[_] to _[_]ᴴ)
open import Luau.VarCtxt using (VarCtxt; ∅; _⋒_; _↦_; _⊕_↦_; _⊝_) renaming (_[_] to _[_]ⱽ)
open import Luau.TypeCheck using (_⊢ᴮ_∈_; _⊢ᴱ_∈_; ⊢ᴴ_; ⊢ᴼ_; _⊢ᴴᴱ_▷_∈_; _⊢ᴴᴮ_▷_∈_; var; addr; app; binexp; block; return; local; function; srcBinOp)
open import Properties.Contradiction using (¬)
open import Properties.TypeCheck using (typeCheckᴮ)
open import Properties.Product using (_,_)
data Warningᴱ (H : Heap yes) {Γ} : ∀ {M T} → (Γ ⊢ᴱ M ∈ T) → Set
data Warningᴮ (H : Heap yes) {Γ} : ∀ {B T} → (Γ ⊢ᴮ B ∈ T) → Set
data Warningᴱ H {Γ} where
UnallocatedAddress : ∀ {a T} →
(H [ a ]ᴴ ≡ nothing) →
---------------------
Warningᴱ H (addr {a} T)
UnboundVariable : ∀ {x T p} →
(Γ [ x ]ⱽ ≡ nothing) →
------------------------
Warningᴱ H (var {x} {T} p)
FunctionCallMismatch : ∀ {M N T U} {D₁ : Γ ⊢ᴱ M ∈ T} {D₂ : Γ ⊢ᴱ N ∈ U} →
(U ≮: src T) →
-----------------
Warningᴱ H (app D₁ D₂)
app₁ : ∀ {M N T U} {D₁ : Γ ⊢ᴱ M ∈ T} {D₂ : Γ ⊢ᴱ N ∈ U} →
Warningᴱ H D₁ →
-----------------
Warningᴱ H (app D₁ D₂)
app₂ : ∀ {M N T U} {D₁ : Γ ⊢ᴱ M ∈ T} {D₂ : Γ ⊢ᴱ N ∈ U} →
Warningᴱ H D₂ →
-----------------
Warningᴱ H (app D₁ D₂)
BinOpMismatch₁ : ∀ {op M N T U} {D₁ : Γ ⊢ᴱ M ∈ T} {D₂ : Γ ⊢ᴱ N ∈ U} →
(T ≮: srcBinOp op) →
------------------------------
Warningᴱ H (binexp {op} D₁ D₂)
BinOpMismatch₂ : ∀ {op M N T U} {D₁ : Γ ⊢ᴱ M ∈ T} {D₂ : Γ ⊢ᴱ N ∈ U} →
(U ≮: srcBinOp op) →
------------------------------
Warningᴱ H (binexp {op} D₁ D₂)
bin₁ : ∀ {op M N T U} {D₁ : Γ ⊢ᴱ M ∈ T} {D₂ : Γ ⊢ᴱ N ∈ U} →
Warningᴱ H D₁ →
------------------------------
Warningᴱ H (binexp {op} D₁ D₂)
bin₂ : ∀ {op M N T U} {D₁ : Γ ⊢ᴱ M ∈ T} {D₂ : Γ ⊢ᴱ N ∈ U} →
Warningᴱ H D₂ →
------------------------------
Warningᴱ H (binexp {op} D₁ D₂)
FunctionDefnMismatch : ∀ {f x B T U V} {D : (Γ ⊕ x ↦ T) ⊢ᴮ B ∈ V} →
(V ≮: U) →
-------------------------
Warningᴱ H (function {f} {U = U} D)
function₁ : ∀ {f x B T U V} {D : (Γ ⊕ x ↦ T) ⊢ᴮ B ∈ V} →
Warningᴮ H D →
-------------------------
Warningᴱ H (function {f} {U = U} D)
BlockMismatch : ∀ {b B T U} {D : Γ ⊢ᴮ B ∈ U} →
(U ≮: T) →
------------------------------
Warningᴱ H (block {b} {T = T} D)
block₁ : ∀ {b B T U} {D : Γ ⊢ᴮ B ∈ U} →
Warningᴮ H D →
------------------------------
Warningᴱ H (block {b} {T = T} D)
data Warningᴮ H {Γ} where
return : ∀ {M B T U} {D₁ : Γ ⊢ᴱ M ∈ T} {D₂ : Γ ⊢ᴮ B ∈ U} →
Warningᴱ H D₁ →
------------------
Warningᴮ H (return D₁ D₂)
LocalVarMismatch : ∀ {x M B T U V} {D₁ : Γ ⊢ᴱ M ∈ U} {D₂ : (Γ ⊕ x ↦ T) ⊢ᴮ B ∈ V} →
(U ≮: T) →
--------------------
Warningᴮ H (local D₁ D₂)
local₁ : ∀ {x M B T U V} {D₁ : Γ ⊢ᴱ M ∈ U} {D₂ : (Γ ⊕ x ↦ T) ⊢ᴮ B ∈ V} →
Warningᴱ H D₁ →
--------------------
Warningᴮ H (local D₁ D₂)
local₂ : ∀ {x M B T U V} {D₁ : Γ ⊢ᴱ M ∈ U} {D₂ : (Γ ⊕ x ↦ T) ⊢ᴮ B ∈ V} →
Warningᴮ H D₂ →
--------------------
Warningᴮ H (local D₁ D₂)
FunctionDefnMismatch : ∀ {f x B C T U V W} {D₁ : (Γ ⊕ x ↦ T) ⊢ᴮ C ∈ V} {D₂ : (Γ ⊕ f ↦ (T ⇒ U)) ⊢ᴮ B ∈ W} →
(V ≮: U) →
-------------------------------------
Warningᴮ H (function D₁ D₂)
function₁ : ∀ {f x B C T U V W} {D₁ : (Γ ⊕ x ↦ T) ⊢ᴮ C ∈ V} {D₂ : (Γ ⊕ f ↦ (T ⇒ U)) ⊢ᴮ B ∈ W} →
Warningᴮ H D₁ →
--------------------
Warningᴮ H (function D₁ D₂)
function₂ : ∀ {f x B C T U V W} {D₁ : (Γ ⊕ x ↦ T) ⊢ᴮ C ∈ V} {D₂ : (Γ ⊕ f ↦ (T ⇒ U)) ⊢ᴮ B ∈ W} →
Warningᴮ H D₂ →
--------------------
Warningᴮ H (function D₁ D₂)
data Warningᴼ (H : Heap yes) : ∀ {V} → (⊢ᴼ V) → Set where
FunctionDefnMismatch : ∀ {f x B T U V} {D : (x ↦ T) ⊢ᴮ B ∈ V} →
(V ≮: U) →
---------------------------------
Warningᴼ H (function {f} {U = U} D)
function₁ : ∀ {f x B T U V} {D : (x ↦ T) ⊢ᴮ B ∈ V} →
Warningᴮ H D →
---------------------------------
Warningᴼ H (function {f} {U = U} D)
data Warningᴴ H (D : ⊢ᴴ H) : Set where
addr : ∀ a {O} →
(p : H [ a ]ᴴ ≡ O) →
Warningᴼ H (D a p) →
---------------
Warningᴴ H D
data Warningᴴᴱ H {Γ M T} : (Γ ⊢ᴴᴱ H ▷ M ∈ T) → Set where
heap : ∀ {D₁ : ⊢ᴴ H} {D₂ : Γ ⊢ᴱ M ∈ T} →
Warningᴴ H D₁ →
-----------------
Warningᴴᴱ H (D₁ , D₂)
expr : ∀ {D₁ : ⊢ᴴ H} {D₂ : Γ ⊢ᴱ M ∈ T} →
Warningᴱ H D₂ →
---------------------
Warningᴴᴱ H (D₁ , D₂)
data Warningᴴᴮ H {Γ B T} : (Γ ⊢ᴴᴮ H ▷ B ∈ T) → Set where
heap : ∀ {D₁ : ⊢ᴴ H} {D₂ : Γ ⊢ᴮ B ∈ T} →
Warningᴴ H D₁ →
-----------------
Warningᴴᴮ H (D₁ , D₂)
block : ∀ {D₁ : ⊢ᴴ H} {D₂ : Γ ⊢ᴮ B ∈ T} →
Warningᴮ H D₂ →
---------------------
Warningᴴᴮ H (D₁ , D₂)
|
{
"alphanum_fraction": 0.4303076339,
"avg_line_length": 27.1443298969,
"ext": "agda",
"hexsha": "1b0280427b861381b4e19af707ee83599f900707",
"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": "5bb9f379b07e378db0a170e7c4030e3a943b2f14",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MeltzDev/luau",
"max_forks_repo_path": "prototyping/Luau/StrictMode.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5bb9f379b07e378db0a170e7c4030e3a943b2f14",
"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": "MeltzDev/luau",
"max_issues_repo_path": "prototyping/Luau/StrictMode.agda",
"max_line_length": 211,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "5bb9f379b07e378db0a170e7c4030e3a943b2f14",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MeltzDev/luau",
"max_stars_repo_path": "prototyping/Luau/StrictMode.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2411,
"size": 5266
}
|
open import FRP.JS.RSet using ( RSet ; _⇒_ ; ⟦_⟧ ; ⟨_⟩ )
module FRP.JS.Event where
infixr 4 _∪_
postulate
Evt : RSet → RSet
map : ∀ {A B} → ⟦ A ⇒ B ⟧ → ⟦ Evt A ⇒ Evt B ⟧
∅ : ∀ {A} → ⟦ Evt A ⟧
_∪_ : ∀ {A} → ⟦ Evt A ⇒ Evt A ⇒ Evt A ⟧
accumBy : ∀ {A B} → ⟦ ⟨ B ⟩ ⇒ A ⇒ ⟨ B ⟩ ⟧ → B → ⟦ Evt A ⇒ Evt ⟨ B ⟩ ⟧
{-# COMPILED_JS map function(A) { return function(B) {
return function(f) { return function(s) { return function(e) {
return e.map(function (t,v) { return f(t)(v); });
}; }; };
}; } #-}
{-# COMPILED_JS ∅ function(A) { return require("agda.frp.signal").zero; } #-}
{-# COMPILED_JS _∪_ function(A) { return function(s) {
return function(x) { return function(y) { return x.merge(y); }; };
}; } #-}
{-# COMPILED_JS accumBy function(A) { return function(B) { return function(f) {
return function(b) { return function(s) { return function(e) {
return e.accumBy(function(t,b,a) { return f(t)(b)(a); },b);
}; }; };
}; }; } #-}
tag : ∀ {A B} → ⟦ B ⟧ → ⟦ Evt A ⇒ Evt B ⟧
tag b = map (λ _ → b)
|
{
"alphanum_fraction": 0.5272373541,
"avg_line_length": 31.1515151515,
"ext": "agda",
"hexsha": "ed4d3e6072dc13d3a8a40c1255f7d32f38e5ffbf",
"lang": "Agda",
"max_forks_count": 7,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z",
"max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_forks_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_forks_repo_name": "agda/agda-frp-js",
"max_forks_repo_path": "src/agda/FRP/JS/Event.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_issues_repo_name": "agda/agda-frp-js",
"max_issues_repo_path": "src/agda/FRP/JS/Event.agda",
"max_line_length": 80,
"max_stars_count": 63,
"max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_stars_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_stars_repo_name": "agda/agda-frp-js",
"max_stars_repo_path": "src/agda/FRP/JS/Event.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z",
"num_tokens": 408,
"size": 1028
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
open import Cubical.Core.Everything
open import Cubical.Relation.Binary.Raw
module Cubical.Relation.Binary.Raw.Construct.NonStrictToStrict
{a ℓ} {A : Type a} (_≤_ : RawRel A ℓ) where
open import Cubical.Relation.Binary.Raw.Properties
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Data.Sigma
open import Cubical.Data.Sum.Base using (inl; inr)
open import Cubical.Data.Empty hiding (rec)
open import Cubical.Foundations.Function using (_∘_; flip)
open import Cubical.Relation.Nullary
open import Cubical.HITs.PropositionalTruncation hiding (elim)
private
_≢_ : RawRel A a
x ≢ y = ¬ (x ≡ y)
------------------------------------------------------------------------
-- _≤_ can be turned into _<_ as follows:
_<_ : RawRel A _
x < y = x ≤ y × x ≢ y
------------------------------------------------------------------------
-- Relationship between relations
<⇒≤ : _<_ ⇒ _≤_
<⇒≤ = fst
<⇒≢ : _<_ ⇒ _≢_
<⇒≢ = snd
≤∧≢⇒< : ∀ {x y} → x ≤ y → x ≢ y → x < y
≤∧≢⇒< = _,_
<⇒≱ : Antisymmetric _≤_ → ∀ {x y} → x < y → ¬ (y ≤ x)
<⇒≱ antisym (x≤y , x≢y) y≤x = x≢y (antisym x≤y y≤x)
≤⇒≯ : Antisymmetric _≤_ → ∀ {x y} → x ≤ y → ¬ (y < x)
≤⇒≯ antisym x≤y y<x = <⇒≱ antisym y<x x≤y
≰⇒> : Reflexive _≤_ → Total _≤_ →
∀ {x y} → ¬ (x ≤ y) → y < x
≰⇒> rfl total {x} {y} x≰y with total x y
... | inl x≤y = elim (x≰y x≤y)
... | inr y≤x = y≤x , x≰y ∘ reflx→fromeq _≤_ rfl ∘ sym
≮⇒≥ : Discrete A → Reflexive _≤_ → Total _≤_ →
∀ {x y} → ¬ (x < y) → y ≤ x
≮⇒≥ _≟_ ≤-refl _≤?_ {x} {y} x≮y with x ≟ y
... | yes x≈y = reflx→fromeq _≤_ ≤-refl (sym x≈y)
... | no x≢y with y ≤? x
... | inl y≤x = y≤x
... | inr x≤y = elim (x≮y (x≤y , x≢y))
------------------------------------------------------------------------
-- Relational properties
<-isPropValued : isPropValued _≤_ → isPropValued _<_
<-isPropValued propv x y = isProp× (propv x y) (isPropΠ λ _ → isProp⊥)
<-toNotEq : ToNotEq _<_
<-toNotEq (_ , x≢y) x≡y = x≢y x≡y
<-irrefl : Irreflexive _<_
<-irrefl = tonoteq→irrefl _<_ <-toNotEq
<-transitive : IsPartialOrder _≤_ → Transitive _<_
<-transitive po (x≤y , x≢y) (y≤z , y≉z) =
(transitive x≤y y≤z , x≢y ∘ antisym x≤y ∘ transitive y≤z ∘ fromEq ∘ sym)
where open IsPartialOrder po
<-≤-trans : Transitive _≤_ → Antisymmetric _≤_ →
Trans _<_ _≤_ _<_
<-≤-trans transitive antisym (x≤y , x≢y) y≤z =
transitive x≤y y≤z , (λ x≡z → x≢y (antisym x≤y (Respectsʳ≡ _≤_ (sym x≡z) y≤z)))
≤-<-trans : Transitive _≤_ → Antisymmetric _≤_ →
Trans _≤_ _<_ _<_
≤-<-trans trans antisym x≤y (y≤z , y≢z) =
trans x≤y y≤z , (λ x≡z → y≢z (antisym y≤z (Respectsˡ≡ _≤_ x≡z x≤y)))
<-asym : Antisymmetric _≤_ → Asymmetric _<_
<-asym antisym (x≤y , x≢y) (y≤x , _) = x≢y (antisym x≤y y≤x)
<-decidable : Discrete A → Decidable _≤_ → Decidable _<_
<-decidable _≟_ _≤?_ x y with x ≤? y
... | no ¬p = no (¬p ∘ fst)
... | yes p with x ≟ y
... | yes q = no (λ x<y → snd x<y q)
... | no ¬q = yes (p , ¬q)
------------------------------------------------------------------------
-- Structures
isStrictPartialOrder : IsPartialOrder _≤_ → IsStrictPartialOrder _<_
isStrictPartialOrder po = record
{ irrefl = <-irrefl
; transitive = <-transitive po
} where open IsPartialOrder po
|
{
"alphanum_fraction": 0.5398122919,
"avg_line_length": 30.8691588785,
"ext": "agda",
"hexsha": "591500a3823eaa9d0c6aa4187f74899d78d8dd88",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bijan2005/univalent-foundations",
"max_forks_repo_path": "Cubical/Relation/Binary/Raw/Construct/NonStrictToStrict.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bijan2005/univalent-foundations",
"max_issues_repo_path": "Cubical/Relation/Binary/Raw/Construct/NonStrictToStrict.agda",
"max_line_length": 81,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bijan2005/univalent-foundations",
"max_stars_repo_path": "Cubical/Relation/Binary/Raw/Construct/NonStrictToStrict.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1402,
"size": 3303
}
|
{-# OPTIONS --erased-cubical #-}
module Common.Path where
open import Agda.Builtin.Cubical.Path public
open import Agda.Builtin.Cubical.HCompU
open import Agda.Primitive.Cubical renaming (primINeg to ~_; primIMax to _∨_; primIMin to _∧_;
primHComp to hcomp; primTransp to transp; primComp to comp;
itIsOne to 1=1)
public
open import Agda.Builtin.Cubical.Sub renaming (Sub to _[_↦_]; primSubOut to outS; inc to inS) public
open Helpers public
|
{
"alphanum_fraction": 0.6063268893,
"avg_line_length": 43.7692307692,
"ext": "agda",
"hexsha": "3dc81348b7bf9daefbe1898adb01448bc7e17943",
"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/Common/Path.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/Common/Path.agda",
"max_line_length": 104,
"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/Common/Path.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": 143,
"size": 569
}
|
open import Agda.Primitive using (lzero; lsuc; _⊔_)
import SecondOrder.Arity
import SecondOrder.VContext
module SecondOrder.Signature
ℓ
(𝔸 : SecondOrder.Arity.Arity)
where
open SecondOrder.Arity.Arity 𝔸
-- a second-order algebraic signature
record Signature : Set (lsuc ℓ) where
-- a signature consists of a set of sorts and a set of operations
-- e.g. sorts A, B, C, ... and operations f, g, h
field
sort : Set ℓ -- sorts
oper : Set ℓ -- operations
open SecondOrder.VContext sort public
-- each operation has arity and a sort (the sort of its codomain)
field
oper-arity : oper → arity -- the arity of an operation
oper-sort : oper → sort -- the operation sort
arg-sort : ∀ (f : oper) → arg (oper-arity f) → sort -- the sorts of arguments
-- a second order operation can bind some free variables that occur as its arguments
-- e.g. the lambda operation binds one type and one term
arg-bind : ∀ (f : oper) → arg (oper-arity f) → VContext -- the argument bindings
-- the arguments of an operation
oper-arg : oper → Set
oper-arg f = arg (oper-arity f)
|
{
"alphanum_fraction": 0.6626192541,
"avg_line_length": 32.0277777778,
"ext": "agda",
"hexsha": "8d98d97760e982b95cb011a72d57e581c255c98c",
"lang": "Agda",
"max_forks_count": 6,
"max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z",
"max_forks_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "andrejbauer/formaltt",
"max_forks_repo_path": "src/SecondOrder/Signature.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4",
"max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "andrejbauer/formaltt",
"max_issues_repo_path": "src/SecondOrder/Signature.agda",
"max_line_length": 90,
"max_stars_count": 21,
"max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cilinder/formaltt",
"max_stars_repo_path": "src/SecondOrder/Signature.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-19T15:50:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-02-16T14:07:06.000Z",
"num_tokens": 320,
"size": 1153
}
|
--------------------------------------------------------------------------------
-- This is part of Agda Inference Systems
open import Agda.Builtin.Equality
open import Data.Product
open import Level
open import Relation.Unary using (_⊆_)
module is-lib.InfSys.Induction {𝓁} where
private
variable
U : Set 𝓁
open import is-lib.InfSys.Base {𝓁}
open MetaRule
open IS
{- Inductive Interpretation -}
data Ind⟦_⟧ {𝓁c 𝓁p 𝓁n : Level} (is : IS {𝓁c} {𝓁p} {𝓁n} U) : U → Set (𝓁 ⊔ 𝓁c ⊔ 𝓁p ⊔ 𝓁n) where
fold : ∀{u} → ISF[ is ] Ind⟦ is ⟧ u → Ind⟦ is ⟧ u
{- Induction Principle -}
ind[_] : ∀{𝓁c 𝓁p 𝓁n 𝓁'}
→ (is : IS {𝓁c} {𝓁p} {𝓁n} U) -- IS
→ (S : U → Set 𝓁') -- specification
→ ISClosed is S -- S is closed
→ Ind⟦ is ⟧ ⊆ S
ind[ is ] S cl (fold (rn , c , refl , pr)) = cl rn c λ i → ind[ is ] S cl (pr i)
{- Apply Rule -}
apply-ind : ∀{𝓁c 𝓁p 𝓁n}{is : IS {𝓁c} {𝓁p} {𝓁n} U} → (rn : is .Names) → RClosed (is .rules rn) Ind⟦ is ⟧
apply-ind {is = is} rn = prefix⇒closed (is .rules rn) {P = Ind⟦ _ ⟧} λ{(c , refl , pr) → fold (rn , c , refl , pr)}
{- Postfix - Prefix -}
ind-postfix : ∀{𝓁c 𝓁p 𝓁n}{is : IS {𝓁c} {𝓁p} {𝓁n} U} → Ind⟦ is ⟧ ⊆ ISF[ is ] Ind⟦ is ⟧
ind-postfix (fold x) = x
ind-prefix : ∀{𝓁c 𝓁p 𝓁n}{is : IS {𝓁c} {𝓁p} {𝓁n} U} → ISF[ is ] Ind⟦ is ⟧ ⊆ Ind⟦ is ⟧
ind-prefix x = fold x
|
{
"alphanum_fraction": 0.5014492754,
"avg_line_length": 31.3636363636,
"ext": "agda",
"hexsha": "debdce851227252ed2ec6fd6d2ad630049b75d88",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "boystrange/FairSubtypingAgda",
"max_forks_repo_path": "src/is-lib/InfSys/Induction.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "boystrange/FairSubtypingAgda",
"max_issues_repo_path": "src/is-lib/InfSys/Induction.agda",
"max_line_length": 117,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "boystrange/FairSubtypingAgda",
"max_stars_repo_path": "src/is-lib/InfSys/Induction.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-24T14:38:47.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-07-29T14:32:30.000Z",
"num_tokens": 621,
"size": 1380
}
|
module SizedPolyIO.ConsoleObject where
open import Size
open import Level using (_⊔_) renaming (suc to lsuc)
open import SizedPolyIO.Console
open import SizedPolyIO.Object
open import SizedPolyIO.IOObject
-- A console object is an IO object for the IO interface of console
ConsoleObject : ∀{μ ρ}(i : Size) → (iface : Interface μ ρ) → Set (μ ⊔ ρ)
ConsoleObject i iface = IOObject consoleI iface i
|
{
"alphanum_fraction": 0.7593052109,
"avg_line_length": 26.8666666667,
"ext": "agda",
"hexsha": "898f941f8d4a91efbcd461a567c1585bc3c55bbd",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z",
"max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/ooAgda",
"max_forks_repo_path": "src/SizedPolyIO/ConsoleObject.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/ooAgda",
"max_issues_repo_path": "src/SizedPolyIO/ConsoleObject.agda",
"max_line_length": 73,
"max_stars_count": 23,
"max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/ooAgda",
"max_stars_repo_path": "src/SizedPolyIO/ConsoleObject.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z",
"num_tokens": 111,
"size": 403
}
|
module _ where
open import Common.Equality
postulate
_def_ _more_ _less_ : Set → Set → Set
X : Set
infix 21 _more_
-- default fixity should be 20
infix 19 _less_
test : (X more X def X less X) ≡ _less_ (_def_ (_more_ X X) X) X
test = refl
module NoFix where
data NoFix : Set₁ where
_+_ : Set → Set → NoFix
module YesFix where
data YesFix : Set₁ where
_+_ : Set → Set → YesFix
infix 10 _+_
open NoFix
open YesFix
-- overloaded _+_ should get fixity 10
test₂ : X less X + X ≡ NoFix._+_ (_less_ X X) X
test₂ = refl
|
{
"alphanum_fraction": 0.6722222222,
"avg_line_length": 16.3636363636,
"ext": "agda",
"hexsha": "cd9f241c334b9a2aa1bfd69c4dd644e281df4e7b",
"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/DefaultFixity.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/DefaultFixity.agda",
"max_line_length": 64,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/DefaultFixity.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": 540
}
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Setoids.Setoids
open import Rings.Definition
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
module Rings.Units.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) where
open Setoid S
open Ring R
Unit : A → Set (a ⊔ b)
Unit r = Sg A (λ s → (r * s) ∼ 1R)
|
{
"alphanum_fraction": 0.6348039216,
"avg_line_length": 25.5,
"ext": "agda",
"hexsha": "ae5edb50e4c8c2bf843c9c5a09c5a90b8b28fa15",
"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/Units/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/Units/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": "Rings/Units/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": 148,
"size": 408
}
|
------------------------------------------------------------------------------
-- Properties of the iter₀ function
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOT.FOTC.Program.Iter0.PropertiesI where
open import Common.FOL.Relation.Binary.EqReasoning
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Base.PropertiesI
open import FOTC.Data.List.PropertiesI
open import FOTC.Data.Nat.Type
open import FOTC.Data.Nat.List.Type
open import FOTC.Program.Iter0.Iter0
open import FOTC.Program.Iter0.PropertiesI
------------------------------------------------------------------------------
{-# TERMINATING #-}
iter₀-ListN : ∀ f {n} → N n → (∀ {n} → N n → N (f · n)) → ListN (iter₀ f n)
iter₀-ListN f nzero h = subst ListN (sym (iter₀-0 f)) lnnil
iter₀-ListN f (nsucc {n} Nn) h =
subst ListN
(sym prf)
(lncons (nsucc Nn) (iter₀-ListN f (h (nsucc Nn)) h))
where
prf : iter₀ f (succ₁ n) ≡ succ₁ n ∷ iter₀ f (f · (succ₁ n))
prf = iter₀ f (succ₁ n)
≡⟨ iter₀-eq f (succ₁ n) ⟩
(if (iszero₁ (succ₁ n)) then [] else (succ₁ n ∷ iter₀ f (f · (succ₁ n))))
≡⟨ ifCong₁ (iszero-S n) ⟩
(if false then [] else (succ₁ n ∷ iter₀ f (f · (succ₁ n))))
≡⟨ if-false (succ₁ n ∷ iter₀ f (f · (succ₁ n))) ⟩
succ₁ n ∷ iter₀ f (f · (succ₁ n)) ∎
|
{
"alphanum_fraction": 0.508864084,
"avg_line_length": 37.1463414634,
"ext": "agda",
"hexsha": "3295e030250342640898c1d48f483f65a9b376a4",
"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/Iter0/PropertiesI.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "notes/FOT/FOTC/Program/Iter0/PropertiesI.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/Iter0/PropertiesI.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z",
"num_tokens": 457,
"size": 1523
}
|
module Common where
open import Data.Bool
open import Data.Maybe
open import Data.Sum
open import Data.Product
BoolQ : Set₁
BoolQ = (A : Set) -> A -> A -> A
unBoolQ : {A : Set} -> A -> A -> BoolQ -> A
unBoolQ a a' q = q _ a a'
trueQ : BoolQ
trueQ = \_ a a' -> a
falseQ : BoolQ
falseQ = \_ a a' -> a'
fromBoolQ : BoolQ -> Bool
fromBoolQ q = unBoolQ true false q
toBoolQ : Bool -> BoolQ
toBoolQ true = trueQ
toBoolQ false = falseQ
MaybeQ : Set -> Set₁
MaybeQ A = (B : Set) -> (A -> B) -> B -> B
unMaybeQ : {A B : Set} -> (A -> B) -> B -> MaybeQ A -> B
unMaybeQ f b q = q _ f b
justQ : {A : Set} -> A -> MaybeQ A
justQ a = \_ f b -> f a
nothingQ : {A : Set} -> MaybeQ A
nothingQ = \_ f b -> b
fromMaybeQ : {A : Set} -> MaybeQ A -> Maybe A
fromMaybeQ q = unMaybeQ just nothing q
toMaybeQ : {A : Set} -> Maybe A -> MaybeQ A
toMaybeQ (just a) = justQ a
toMaybeQ nothing = nothingQ
EitherQ : Set -> Set -> Set₁
EitherQ A B = (C : Set) -> (A -> C) -> (B -> C) -> C
unEitherQ : {A B C : Set} -> (A -> C) -> (B -> C) -> EitherQ A B -> C
unEitherQ f g q = q _ f g
leftQ : {A B : Set} -> A -> EitherQ A B
leftQ a = \_ f g -> f a
rightQ : {A B : Set} -> B -> EitherQ A B
rightQ b = \_ f g -> g b
fromEitherQ : {A B : Set} -> EitherQ A B -> A ⊎ B
fromEitherQ q = unEitherQ inj₁ inj₂ q
toEitherQ : {A B : Set} -> A ⊎ B -> EitherQ A B
toEitherQ (inj₁ a) = leftQ a
toEitherQ (inj₂ b) = rightQ b
PairQ : Set -> Set -> Set₁
PairQ A B = (C : Set) -> (A -> B -> C) -> C
unPairQ : {A B C : Set} -> (A -> B -> C) -> PairQ A B -> C
unPairQ f q = q _ f
pairQ : {A B : Set} -> A -> B -> PairQ A B
pairQ a b = \_ f -> f a b
fromPairQ : {A B : Set} -> PairQ A B -> A × B
fromPairQ q = unPairQ (\a b -> (a , b)) q
toPairQ : {A B : Set} -> A × B -> PairQ A B
toPairQ (a , b) = pairQ a b
fstQ : {A B : Set} -> PairQ A B -> A
fstQ q = unPairQ (\a b -> a) q
sndQ : {A B : Set} -> PairQ A B -> B
sndQ q = unPairQ (\a b -> b) q
|
{
"alphanum_fraction": 0.5423376623,
"avg_line_length": 21.6292134831,
"ext": "agda",
"hexsha": "7a77f33f5fdcb611d02fbb5e2907c604feb9f072",
"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": "14e819383dd8730e1c3cbd9c2ce53335bd95188b",
"max_forks_repo_licenses": [
"X11",
"MIT"
],
"max_forks_repo_name": "mietek/scott-encoding",
"max_forks_repo_path": "agda-explicit/Common.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "14e819383dd8730e1c3cbd9c2ce53335bd95188b",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"X11",
"MIT"
],
"max_issues_repo_name": "mietek/scott-encoding",
"max_issues_repo_path": "agda-explicit/Common.agda",
"max_line_length": 69,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "14e819383dd8730e1c3cbd9c2ce53335bd95188b",
"max_stars_repo_licenses": [
"X11",
"MIT"
],
"max_stars_repo_name": "mietek/scott-encoding",
"max_stars_repo_path": "agda-explicit/Common.agda",
"max_stars_repo_stars_event_max_datetime": "2019-08-08T16:31:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-27T19:33:52.000Z",
"num_tokens": 797,
"size": 1925
}
|
{-# OPTIONS --without-K #-}
module Music where
open import Data.Nat using (ℕ; zero; suc; _+_; _*_)
open import Data.Integer using (ℤ; +_)
open import Data.List using (List; foldr; []; _∷_; reverse)
open import Data.Product using (_×_; _,_)
open import Data.Vec using (Vec; []; _∷_; replicate; concat; map; zipWith; toList; _++_; sum; foldr₁)
open import Function using (_∘_)
open import Note
open import Pitch
open import Interval
-- A point in the music grid, which can either be a tone,
-- a continuation of a previous tone, or a rest.
data Point : Set where
tone : Pitch → Point
hold : Pitch → Point
rest : Point
data Melody (n : ℕ) : Set where
melody : Vec Point n → Melody n
unmelody : {n : ℕ} → Melody n → Vec Point n
unmelody (melody ps) = ps
note→melody : (n : Note) → Melody (noteDuration n)
note→melody (tone (duration zero) p) = melody []
note→melody (tone (duration (suc d)) p) = melody (tone p ∷ replicate (hold p))
note→melody (rest _) = melody (replicate rest)
-- Assumes melody is well-formed in that a held note has the
-- same pitch as the note before it.
-- Does not consolidate rests.
melody→notes : {n : ℕ} → Melody n → List Note
melody→notes (melody m) = (reverse ∘ mn 0 ∘ reverse ∘ toList) m
where mn : ℕ → List Point → List Note -- c is the number of held points
mn c [] = []
mn c (tone p ∷ ps) = tone (duration (suc c)) p ∷ mn 0 ps
mn c (hold _ ∷ ps) = mn (suc c) ps
mn c (rest ∷ ps) = rest (duration 1) ∷ mn 0 ps
pitches→melody : {n : ℕ} → (d : Duration) → (ps : Vec Pitch n) → Melody (n * unduration d)
pitches→melody d ps = melody (concat (map (unmelody ∘ note→melody ∘ tone d) ps))
transposePoint : ℤ → Point → Point
transposePoint k (tone p) = tone (transposePitch k p)
transposePoint k (hold p) = hold (transposePitch k p)
transposePoint k rest = rest
transposeMelody : {n : ℕ} → ℤ → Melody n → Melody n
transposeMelody k = melody ∘ map (transposePoint k) ∘ unmelody
data Chord (n : ℕ) : Set where
chord : Vec Point n → Chord n
unchord : {n : ℕ} → Chord n → Vec Point n
unchord (chord ps) = ps
-- We represent music as a v × d grid where v is the number of voices and d is the duration.
-- The primary representation is as parallel melodies (counterpoint).
data Counterpoint (v : ℕ) (d : ℕ): Set where
cp : Vec (Melody d) v → Counterpoint v d
uncp : {v d : ℕ} → Counterpoint v d → Vec (Melody d) v
uncp (cp m) = m
-- An alternative representation of music is as a series of chords (harmonic progression).
data Harmony (v : ℕ) (d : ℕ): Set where
harmony : Vec (Chord v) d → Harmony v d
unharmony : {v d : ℕ} → Harmony v d → Vec (Chord v) d
unharmony (harmony h) = h
pitches→harmony : {n : ℕ} (d : Duration) → (ps : Vec Pitch n) → Harmony n (unduration d)
pitches→harmony (duration zero) ps = harmony []
pitches→harmony (duration (suc d)) ps = harmony (chord (map tone ps) ∷ replicate (chord (map hold ps)))
pitchPair→Harmony : (d : Duration) → PitchPair → Harmony 2 (unduration d)
pitchPair→Harmony d (p , q) = pitches→harmony d (p ∷ q ∷ [])
pitchInterval→Harmony : (d : Duration) → PitchInterval → Harmony 2 (unduration d)
pitchInterval→Harmony d = pitchPair→Harmony d ∘ pitchIntervalToPitchPair
{-
pitchIntervalsToCounterpoint : PitchInterval → Counterpoint
pitchIntervalsToCounterpoint = pitchPairToCounterpoint ∘ pitchIntervalToPitchPair
-}
addEmptyVoice : {v d : ℕ} → Harmony v d → Harmony (suc v) d
addEmptyVoice (harmony h) = harmony (map (chord ∘ (rest ∷_) ∘ unchord) h)
infixl 5 _+H+_
_+H+_ : {v d d' : ℕ} → Harmony v d → Harmony v d' → Harmony v (d + d')
h +H+ h' = harmony (unharmony h ++ unharmony h')
foldIntoHarmony : {k n : ℕ} (ds : Vec Duration (suc k)) → (pss : Vec (Vec Pitch n) (suc k)) → Harmony n (foldr₁ _+_ (map unduration ds))
foldIntoHarmony (d ∷ []) (ps ∷ []) = pitches→harmony d ps
foldIntoHarmony (d ∷ d' ∷ ds) (ps ∷ ps' ∷ pss) = (pitches→harmony d ps) +H+ (foldIntoHarmony (d' ∷ ds) (ps' ∷ pss))
-- matrix transposition
mtranspose : {A : Set}{m n : ℕ} → Vec (Vec A n) m → Vec (Vec A m) n
mtranspose [] = replicate []
mtranspose (xs ∷ xss) = zipWith _∷_ xs (mtranspose xss)
counterpoint→harmony : {v d : ℕ} → Counterpoint v d → Harmony v d
counterpoint→harmony = harmony ∘ map chord ∘ mtranspose ∘ map unmelody ∘ uncp
harmony→counterpoint : {v d : ℕ} → Harmony v d → Counterpoint v d
harmony→counterpoint = cp ∘ map melody ∘ mtranspose ∘ map unchord ∘ unharmony
|
{
"alphanum_fraction": 0.6533989267,
"avg_line_length": 39.5752212389,
"ext": "agda",
"hexsha": "68902f7332436083664bdad4d60b40e6a8eed398",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2020-11-10T04:04:40.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-01-12T17:02:36.000Z",
"max_forks_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "halfaya/MusicTools",
"max_forks_repo_path": "doc/icfp20/code/Music.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_issues_repo_issues_event_max_datetime": "2020-11-17T00:58:55.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-11-13T01:26:20.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "halfaya/MusicTools",
"max_issues_repo_path": "doc/icfp20/code/Music.agda",
"max_line_length": 136,
"max_stars_count": 28,
"max_stars_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "halfaya/MusicTools",
"max_stars_repo_path": "doc/icfp20/code/Music.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-04T18:04:07.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-04-21T09:08:52.000Z",
"num_tokens": 1481,
"size": 4472
}
|
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Inverse where
open import Level using (Level; suc; _⊔_)
open import Categories.Category
open import Data.Product
import Categories.Morphism
record pseudo-iso {o ℓ e} (C : Category o ℓ e) : Set (o ⊔ ℓ ⊔ e) where
open Category C
open Definitions C
open Categories.Morphism C
infix 10 _⁻¹
field
_⁻¹ : ∀ {A B} → (f : A ⇒ B) → B ⇒ A
pseudo-iso₁ : ∀ {A B} {f : A ⇒ B} → f ∘ f ⁻¹ ∘ f ≈ f
pseudo-iso₂ : ∀ {A B} {f : A ⇒ B} → f ⁻¹ ∘ f ∘ f ⁻¹ ≈ f ⁻¹
record Inverse {o ℓ e} (C : Category o ℓ e) : Set (o ⊔ ℓ ⊔ e) where
open Category C
open Definitions C
open Categories.Morphism C
open pseudo-iso
field
piso : pseudo-iso C
unique : ∀ {p : pseudo-iso C} {A B} → (f : A ⇒ B) → _⁻¹ piso f ≈ _⁻¹ p f
|
{
"alphanum_fraction": 0.5944584383,
"avg_line_length": 25.6129032258,
"ext": "agda",
"hexsha": "9421634b05b98c8964baa9f60b2f782b47054e46",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Inverse.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Inverse.agda",
"max_line_length": 76,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Inverse.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": 311,
"size": 794
}
|
module Human.Char where
open import Human.Nat
open import Human.Bool
postulate Char : Set
{-# BUILTIN CHAR Char #-}
primitive
primIsLower : Char → Bool
primIsDigit : Char → Bool
primIsAlpha : Char → Bool
primIsSpace : Char → Bool
primIsAscii : Char → Bool
primIsLatin1 : Char → Bool
primIsPrint : Char → Bool
primIsHexDigit : Char → Bool
primToUpper primToLower : Char → Char
primCharToNat : Char → Nat
primNatToChar : Nat → Char
primCharEquality : Char → Char → Bool
-- {-# COMPILE JS primCharToNat = function(c) { return c.charCodeAt(0); } #-}
-- {-# COMPILE JS primNatToChar = function(c) { return JSON.stringify(c); } #-}
-- {-# COMPILE JS primCharEquality = function(c) { return function(d) { return c === d; }; } #-}
|
{
"alphanum_fraction": 0.583908046,
"avg_line_length": 33.4615384615,
"ext": "agda",
"hexsha": "7a30e1fc8f840c1d2174593c83026ac6aadade3e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MaisaMilena/JuiceMaker",
"max_forks_repo_path": "src/Human/Char.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "MaisaMilena/JuiceMaker",
"max_issues_repo_path": "src/Human/Char.agda",
"max_line_length": 96,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MaisaMilena/JuiceMaker",
"max_stars_repo_path": "src/Human/Char.agda",
"max_stars_repo_stars_event_max_datetime": "2020-11-28T05:46:27.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-03-29T17:35:20.000Z",
"num_tokens": 228,
"size": 870
}
|
-- Andreas, 2019-12-03, issue #4200 reported and testcase by nad
open import Agda.Builtin.Bool
data D : Set where
c₁ : D
@0 c₂ : D
f : D → Bool
f c₁ = true
f c₂ = false
@0 _ : D
_ = c₂ -- OK.
_ : D
_ = c₂ -- Not allowed.
-- Expected error:
-- Identifier c₂ is declared erased, so it cannot be used here
-- when checking that the expression c₂ has type D
|
{
"alphanum_fraction": 0.6457765668,
"avg_line_length": 15.9565217391,
"ext": "agda",
"hexsha": "e3354b32677cbf95f5f9c1c1a57dd4cf673caa0f",
"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/Issue4200.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/Issue4200.agda",
"max_line_length": 64,
"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/Issue4200.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": 367
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.