Search is not available for this dataset
text
string | meta
dict |
---|---|
{-# OPTIONS --safe #-}
{-
Builds bismulation for the cumulative hierarchy and shows that it
is equivalent to equality though it lives in a lower universe.
-}
module Cubical.HITs.CumulativeHierarchy.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Function
open import Cubical.Foundations.Transport
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Structure
open import Cubical.Functions.Embedding
open import Cubical.Functions.Logic as L
open import Cubical.Data.Sigma
open import Cubical.HITs.PropositionalTruncation as P hiding (elim; elim2)
open import Cubical.HITs.SetQuotients as Q using (_/_; setQuotUniversal; eq/; squash/)
open import Cubical.HITs.CumulativeHierarchy.Base
renaming (elim to elimInternal)
import Cubical.HITs.PropositionalTruncation.Monad as PropMonad
private
variable
ℓ ℓ' : Level
X Y : Type ℓ
a b : V ℓ
infix 4 _≊_
infix 7 _∈ₛ_ _⊆_ _⊆ₛ_
------------
-- "bisimulation"
-----------
-- bisimulation is needed to define a quotient in the correct universe when
-- implementing the map : V ℓ → Σ[ X : Type ℓ ] (X → V ℓ)
-- Quotienting by Path (V ℓ) or via eqImage would lead to X : Type (ℓ-suc ℓ)
_∼_ : (s t : V ℓ) → hProp ℓ
_∼_ = elim2 eliminator where
goalProp : (X : Type ℓ) (ix : X → V ℓ)
→ (Y : Type ℓ) (iy : Y → V ℓ)
→ (rec : X → Y → hProp ℓ)
→ hProp ℓ
goalProp X ix Y iy rec = (∀[ a ∶ X ] ∃[ b ∶ Y ] rec a b) ⊓ (∀[ b ∶ Y ] ∃[ a ∶ X ] rec a b)
⇔-swap : X ⊓′ Y → Y ⊓′ X
⇔-swap (p , q) = (q , p)
open PropMonad
lemma : {X₁ X₂ Y : Type ℓ} {ix₁ : X₁ → V ℓ} {ix₂ : X₂ → V ℓ} (iy : Y → V ℓ)
→ {rec₁ : X₁ → Y → hProp ℓ} {rec₂ : X₂ → Y → hProp ℓ}
→ (rec₁→₂ : (x₁ : X₁) → ∃[ (x₂ , p) ∈ fiber ix₂ (ix₁ x₁) ] rec₂ x₂ ≡ rec₁ x₁)
→ (rec₂→₁ : (x₂ : X₂) → ∃[ (x₁ , p) ∈ fiber ix₁ (ix₂ x₂) ] rec₁ x₁ ≡ rec₂ x₂)
→ ⟨ goalProp X₁ ix₁ Y iy rec₁ ⇒ goalProp X₂ ix₂ Y iy rec₂ ⟩
lemma _ rec₁→₂ rec₂→₁ (X₁→Y , Y→X₁) =
(λ x₂ → do ((x₁ , c_) , xr₁) ← rec₂→₁ x₂
(y , yr) ← X₁→Y x₁
∣ y , subst fst (λ i → xr₁ i y) yr ∣₁
) ,
(λ y → do (x₁ , xr₁) ← Y→X₁ y
((x₂ , _) , xr₂) ← rec₁→₂ x₁
∣ x₂ , subst fst (λ i → xr₂ (~ i) y) xr₁ ∣₁
)
open Elim2Set
eliminator : Elim2Set (λ _ _ → isSetHProp)
ElimSett2 eliminator = goalProp
ElimEqSnd eliminator X ix Y₁ Y₂ iy₁ iy₂ eq rec₁ rec₂ rec₁→₂ rec₂→₁ =
⇔toPath (⇔-swap ∘ lemma ix rec₁→₂ rec₂→₁ ∘ ⇔-swap)
(⇔-swap ∘ lemma ix rec₂→₁ rec₁→₂ ∘ ⇔-swap)
ElimEqFst eliminator X₁ X₂ ix₁ ix₂ eq Y iy rec₁ rec₂ rec₁→₂ rec₂→₁ =
⇔toPath (lemma iy rec₁→₂ rec₂→₁)
(lemma iy rec₂→₁ rec₁→₂)
_≊_ : (s t : V ℓ) → Type ℓ
s ≊ t = ⟨ s ∼ t ⟩
∼refl : (a : V ℓ) → a ≊ a
∼refl = elimProp (λ a → isProp⟨⟩ (a ∼ a))
(λ X ix rec → (λ x → ∣ x , rec x ∣₁) , (λ x → ∣ x , rec x ∣₁))
-- keep in mind that the left and right side here live in different universes
identityPrinciple : (a ≊ b) ≃ (a ≡ b)
identityPrinciple {a = a} {b = b} =
isoToEquiv (iso from into (λ _ → setIsSet _ _ _ _) (λ _ → isProp⟨⟩ (a ∼ b) _ _))
where
open PropMonad
eqImageXY : {X Y : Type ℓ} {ix : X → V ℓ} {iy : Y → V ℓ} → (∀ x y → ⟨ ix x ∼ iy y ⟩ → ix x ≡ iy y)
→ ⟨ sett X ix ∼ sett Y iy ⟩ → eqImage ix iy
eqImageXY rec rel = (λ x → do (y , y∼x) ← fst rel x ; ∣ y , sym (rec _ _ y∼x) ∣₁)
, (λ y → do (x , x∼y) ← snd rel y ; ∣ x , rec _ _ x∼y ∣₁)
from : a ≊ b → a ≡ b
from = elimProp propB eliminator a b where
prop∼ : {a : V ℓ} → ∀ b → isProp (a ≊ b → a ≡ b)
prop∼ {a = a} b = isPropΠ λ _ → setIsSet a b
propB : (a : V ℓ) → isProp (∀ b → a ≊ b → a ≡ b)
propB a = isPropΠ prop∼
eliminator :
∀ (X : Type _) (ix : X → V _)
→ ((x : X) (b₁ : V _) → ix x ≊ b₁ → ix x ≡ b₁)
→ (b₁ : V _) → sett X ix ≊ b₁ → sett X ix ≡ b₁
eliminator X ix rec =
elimProp prop∼ λ Y iy _ → seteq X Y ix iy ∘ eqImageXY (λ x y → rec x (iy y))
into : a ≡ b → a ≊ b
into = J (λ b _ → a ≊ b) (∼refl a)
------------
-- Monic presentation of sets
-----------
-- like fiber, but in a lower universe
repFiber : (f : X → V ℓ) (b : V ℓ) → Type _
repFiber f b = Σ[ a ∈ _ ] f a ≊ b
repFiber≃fiber : (f : X → V ℓ) (b : V ℓ) → repFiber f b ≃ fiber f b
repFiber≃fiber f b = Σ-cong-equiv (idEquiv _) (λ _ → identityPrinciple)
-- projecting out a representing type together with the embedding
MonicPresentation : (a : V ℓ) → Type (ℓ-suc ℓ)
MonicPresentation {ℓ} a = Σ[ (X , ix , _) ∈ Embedding (V ℓ) ℓ ] (a ≡ sett X ix)
isPropMonicPresentation : (a : V ℓ) → isProp (MonicPresentation a)
isPropMonicPresentation a ((X₁ , ix₁ , isEmb₁) , p) ((X₂ , ix₂ , isEmb₂) , q) =
ΣPathP ( equivFun (EmbeddingIP _ _) (fiberwise1 , fiberwise2)
, isProp→PathP (λ i → setIsSet a _) p q)
where
open PropMonad
fiberwise1 : ∀ b → fiber ix₁ b → fiber ix₂ b
fiberwise1 b fbx₁ =
proof (_ , isEmbedding→hasPropFibers isEmb₂ b)
by subst (λ A → ⟨ b ∈ A ⟩) (sym p ∙ q) ∣ fbx₁ ∣₁
fiberwise2 : ∀ b → fiber ix₂ b → fiber ix₁ b
fiberwise2 b fbx₂ =
proof (_ , isEmbedding→hasPropFibers isEmb₁ b)
by subst (λ A → ⟨ b ∈ A ⟩) (sym q ∙ p) ∣ fbx₂ ∣₁
sett-repr : (X : Type ℓ) (ix : X → V ℓ) → MonicPresentation (sett X ix)
sett-repr {ℓ} X ix = (Rep , ixRep , isEmbIxRep) , seteq X Rep ix ixRep eqImIxRep where
Kernel : X → X → Type ℓ
Kernel x y = ix x ≊ ix y
Rep : Type ℓ
Rep = X / Kernel
ixRep : Rep → V ℓ
ixRep = invEq (setQuotUniversal setIsSet) (ix , λ _ _ → equivFun identityPrinciple)
isEmbIxRep : isEmbedding ixRep
isEmbIxRep = hasPropFibers→isEmbedding propFibers where
propFibers : ∀ y → (a b : Σ[ p ∈ Rep ] (ixRep p ≡ y)) → a ≡ b
propFibers y (p₁ , m) (p₂ , n) =
ΣPathP {B = λ _ p → ixRep p ≡ y} (goal , isProp→PathP (λ _ → setIsSet _ _) _ _)
where
lemma : ∀ {p₁ p₂} → (p : ixRep Q.[ p₁ ] ≡ y) (q : ixRep Q.[ p₂ ] ≡ y) → Kernel p₁ p₂
lemma m n = invEquiv identityPrinciple .fst (m ∙ sym n)
prop₁ : ∀ p₁ → isProp ((ixRep p₁ ≡ y) → p₁ ≡ p₂)
prop₁ p₁ = isPropΠ λ eq → squash/ p₁ p₂
prop₂ : ∀ {p₁} p₂ → isProp ((ixRep p₂ ≡ y) → Q.[ p₁ ] ≡ p₂)
prop₂ {p₁} p₂ = isPropΠ λ eq → squash/ Q.[ p₁ ] p₂
goal : p₁ ≡ p₂
goal = Q.elimProp prop₁ (λ p₁ m → Q.elimProp prop₂ (λ p₂ n → eq/ p₁ p₂ (lemma m n)) p₂ n) p₁ m
eqImIxRep : eqImage ix ixRep
eqImIxRep = (λ x → ∣ Q.[ x ] , refl ∣₁) , Q.elimProp (λ _ → P.squash₁) (λ b → ∣ b , refl ∣₁)
data DeepMonicPresentation (a : V ℓ) : Type (ℓ-suc ℓ) where
dmp : (mp@((_ , ix , _) , _) : MonicPresentation a)
→ (rec : ∀ x → DeepMonicPresentation (ix x))
→ DeepMonicPresentation a
isPropDeepMonicPresentation : (a : V ℓ) → isProp (DeepMonicPresentation a)
isPropDeepMonicPresentation a (dmp mx rx) (dmp my ry) i = dmp (mx≡my i) (recprop i) where
mx≡my : mx ≡ my
mx≡my = isPropMonicPresentation a mx my
recprop : PathP (λ i → (x : mx≡my i .fst .fst) → DeepMonicPresentation (mx≡my i .fst .snd .fst x)) rx ry
recprop = toPathP (funExt λ x → isPropDeepMonicPresentation _ _ _)
V-deeprepr : (a : V ℓ) → DeepMonicPresentation a
V-deeprepr = elimProp isPropDeepMonicPresentation λ X ix rec → dmp (sett-repr X ix) (Q.elimProp (λ _ → isPropDeepMonicPresentation _) rec)
V-repr : (a : V ℓ) → MonicPresentation a
-- "Cannot eliminate fibrant type DeepMonicPresentation a
-- unless target type is also fibrant"
-- V-repr = let (dmp mp _) = (V-deeprepr a) in mp
V-repr a = case (V-deeprepr a) return (λ _ → MonicPresentation a) of λ { (dmp mp _) → mp }
private
MonicDataF : Type (ℓ-suc ℓ) → Type (ℓ-suc ℓ)
MonicDataF {ℓ} T = Embedding T ℓ
V-fixpoint : V ℓ ≃ MonicDataF (V ℓ)
V-fixpoint {ℓ} =
V ℓ ≃⟨ invEquiv (Σ-contractSnd λ a → inhProp→isContr (V-repr a) (isPropMonicPresentation a)) ⟩
(Σ[ a ∈ V ℓ ] MonicPresentation a) ≃⟨ boringswap ⟩
(Σ[ (X , ix , _) ∈ MonicDataF (V ℓ) ] singl (sett X ix)) ≃⟨ Σ-contractSnd (λ _ → isContrSingl _) ⟩
MonicDataF (V ℓ) ■ where
boringswap : (Σ[ a ∈ V ℓ ] MonicPresentation a) ≃ (Σ[ (X , ix , _) ∈ MonicDataF (V ℓ) ] singl (sett X ix))
boringswap = isoToEquiv (iso
(λ (a , (X , ix , emb) , p) → (X , ix , emb) , a , sym p)
(λ ((X , ix , emb) , a , p) → a , (X , ix , emb) , sym p)
(λ _ → refl)
λ _ → refl)
-- note the problem of making this a datatype directly: MonicDataF is *not* strictly positive!
-- an elimination principle based on the monic presentation
elim : (B : V ℓ → Type ℓ')
→ ((X : Type ℓ) (ix : X → V ℓ) (emb : isEmbedding ix) (rec : ∀ x → B (ix x)) → B (sett X ix))
→ (a : V ℓ) → B a
elim B alg = elimDMP ∘ V-deeprepr where
elimDMP : ∀ {a} → DeepMonicPresentation a → B a
elimDMP (dmp ((X , ix , emb) , p) rec) = subst B (sym p) (alg X ix emb (λ x → elimDMP (rec x)))
⟪_⟫ : (s : V ℓ) → Type ℓ
⟪ X ⟫ = V-repr X .fst .fst
⟪_⟫↪ : (s : V ℓ) → ⟪ s ⟫ → V ℓ
⟪ X ⟫↪ = V-repr X .fst .snd .fst
isEmb⟪_⟫↪ : (s : V ℓ) → isEmbedding ⟪ s ⟫↪
isEmb⟪ X ⟫↪ = V-repr X .fst .snd .snd
⟪_⟫-represents : (s : V ℓ) → s ≡ sett ⟪ s ⟫ ⟪ s ⟫↪
⟪ X ⟫-represents = V-repr X .snd
isPropRepFiber : (a b : V ℓ) → isProp (repFiber ⟪ a ⟫↪ b)
isPropRepFiber a b =
Embedding-into-isProp→isProp
(Equiv→Embedding (repFiber≃fiber ⟪ a ⟫↪ b))
(isEmbedding→hasPropFibers isEmb⟪ a ⟫↪ b)
-- while ∈ is hProp (ℓ-suc ℓ), ∈ₛ is in ℓ
_∈ₛ_ : (a b : V ℓ) → hProp ℓ
a ∈ₛ b = repFiber ⟪ b ⟫↪ a , isPropRepFiber b a
∈-asFiber : {a b : V ℓ} → ⟨ a ∈ b ⟩ → fiber ⟪ b ⟫↪ a
∈-asFiber {a = a} {b = b} =
subst (λ br → ⟨ a ∈ br ⟩ → fiber ⟪ b ⟫↪ a) (sym ⟪ b ⟫-represents) asRep
where
asRep : ⟨ a ∈ sett ⟪ b ⟫ ⟪ b ⟫↪ ⟩ → fiber ⟪ b ⟫↪ a
asRep = P.propTruncIdempotent≃ (isEmbedding→hasPropFibers isEmb⟪ b ⟫↪ a) .fst
∈-fromFiber : {a b : V ℓ} → fiber ⟪ b ⟫↪ a → ⟨ a ∈ b ⟩
∈-fromFiber {a = a} {b = b} = subst (λ br → ⟨ a ∈ br ⟩) (sym ⟪ b ⟫-represents) ∘ ∣_∣₁
∈∈ₛ : {a b : V ℓ} → ⟨ a ∈ b ⇔ a ∈ₛ b ⟩
∈∈ₛ {a = a} {b = b} = leftToRight , rightToLeft where
repEquiv : repFiber ⟪ b ⟫↪ a ≃ fiber ⟪ b ⟫↪ a
repEquiv = repFiber≃fiber ⟪ b ⟫↪ a
leftToRight : ⟨ (a ∈ b) ⇒ a ∈ₛ b ⟩
leftToRight a∈b = invEq repEquiv (∈-asFiber {b = b} a∈b)
rightToLeft : ⟨ a ∈ₛ b ⇒ (a ∈ b) ⟩
rightToLeft a∈ₛb = ∈-fromFiber {b = b} (equivFun repEquiv a∈ₛb)
ix∈ₛ : {X : Type ℓ} {ix : X → V ℓ}
→ (x : X) → ⟨ ix x ∈ₛ sett X ix ⟩
ix∈ₛ {X = X} {ix = ix} x = ∈∈ₛ {a = ix x} {b = sett X ix} .fst ∣ x , refl ∣₁
∈ₛ⟪_⟫↪_ : (a : V ℓ) (ix : ⟪ a ⟫) → ⟨ ⟪ a ⟫↪ ix ∈ₛ a ⟩
∈ₛ⟪ a ⟫↪ ix = ix , ∼refl (⟪ a ⟫↪ ix)
-- also here, the left side is in level (ℓ-suc ℓ) while the right is in ℓ
presentation : (a : V ℓ) → (Σ[ v ∈ V ℓ ] ⟨ v ∈ₛ a ⟩) ≃ ⟪ a ⟫
presentation a = isoToEquiv (iso into from (λ _ → refl) retr) where
into : Σ[ v ∈ V _ ] ⟨ v ∈ₛ a ⟩ → ⟪ a ⟫
into = fst ∘ snd
from : ⟪ a ⟫ → Σ[ v ∈ V _ ] ⟨ v ∈ₛ a ⟩
from ⟪a⟫ = ⟪ a ⟫↪ ⟪a⟫ , ∈ₛ⟪ a ⟫↪ ⟪a⟫
retr : retract into from
retr s = Σ≡Prop (λ v → (v ∈ₛ a) .snd) (equivFun identityPrinciple (s .snd .snd))
-- subset relation, once in level (ℓ-suc ℓ) and once in ℓ
_⊆_ : (a b : V ℓ) → hProp (ℓ-suc ℓ)
a ⊆ b = ∀[ x ] x ∈ₛ a ⇒ x ∈ₛ b
⊆-refl : (a : V ℓ) → ⟨ a ⊆ a ⟩
⊆-refl a = λ _ xa → xa
_⊆ₛ_ : (a b : V ℓ) → hProp ℓ
a ⊆ₛ b = ∀[ x ] ⟪ a ⟫↪ x ∈ₛ b
⊆⇔⊆ₛ : (a b : V ℓ) → ⟨ a ⊆ b ⇔ a ⊆ₛ b ⟩
⊆⇔⊆ₛ a b =
(λ s → invEq curryEquiv s ∘ invEq (presentation a))
, (λ s x xa → subst (λ x → ⟨ x ∈ₛ b ⟩) (equivFun identityPrinciple (xa .snd)) (s (xa .fst)))
-- the homotopy definition of equality as an hProp, we know this is equivalent to bisimulation
infix 4 _≡ₕ_
_≡ₕ_ : (a b : V ℓ) → hProp (ℓ-suc ℓ)
_≡ₕ_ a b = (a ≡ b) , setIsSet a b
-- extensionality
extensionality : ⟨ ∀[ a ∶ V ℓ ] ∀[ b ] (a ⊆ b) ⊓ (b ⊆ a) ⇒ (a ≡ₕ b) ⟩
extensionality {ℓ = ℓ} a b imeq = ⟪ a ⟫-represents ∙∙ settab ∙∙ sym ⟪ b ⟫-represents where
abpth : Path (Embedding _ _) (⟪ a ⟫ , ⟪ a ⟫↪ , isEmb⟪ a ⟫↪) (⟪ b ⟫ , ⟪ b ⟫↪ , isEmb⟪ b ⟫↪)
abpth = equivFun (EmbeddingIP _ _)
( (λ p → equivFun (repFiber≃fiber ⟪ b ⟫↪ p) ∘ imeq .fst p ∘ invEq (repFiber≃fiber ⟪ a ⟫↪ p))
, (λ p → equivFun (repFiber≃fiber ⟪ a ⟫↪ p) ∘ imeq .snd p ∘ invEq (repFiber≃fiber ⟪ b ⟫↪ p))
)
settab : sett ⟪ a ⟫ ⟪ a ⟫↪ ≡ sett ⟪ b ⟫ ⟪ b ⟫↪
settab i = sett (abpth i .fst) (abpth i .snd .fst)
extInverse : ⟨ ∀[ a ∶ V ℓ ] ∀[ b ] (a ≡ₕ b) ⇒ (a ⊆ b) ⊓ (b ⊆ a) ⟩
extInverse a b a≡b = subst (λ b → ⟨ (a ⊆ b) ⊓ (b ⊆ a) ⟩) a≡b (⊆-refl a , ⊆-refl a)
set≡-characterization : {a b : V ℓ} → (a ≡ₕ b) ≡ (a ⊆ b) ⊓ (b ⊆ a)
set≡-characterization = ⇔toPath (extInverse _ _) (extensionality _ _)
| {
"alphanum_fraction": 0.5608318062,
"avg_line_length": 39.9713375796,
"ext": "agda",
"hexsha": "65e3585c36767889a9acbb33114c166212fc67bd",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/HITs/CumulativeHierarchy/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/HITs/CumulativeHierarchy/Properties.agda",
"max_line_length": 138,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/HITs/CumulativeHierarchy/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z",
"num_tokens": 5606,
"size": 12551
} |
module PiFrac.Properties where
open import Data.Empty
open import Data.Unit hiding (_≟_)
open import Data.Sum
open import Data.Product
open import Relation.Binary.Core
open import Relation.Binary
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
open import Data.Maybe
open import PiFrac.Syntax
open import PiFrac.Opsem
open import PiFrac.AuxLemmas
open import PiFrac.NoRepeat
open import PiFrac.Eval
open import PiFrac.Interp
open import PiFrac.Invariants
-- Forward evaluator is reversible
evalIsRev : ∀ {A B} → (c : A ↔ B) (v₁ : ⟦ A ⟧) (v₂ : ⟦ B ⟧)
→ eval c v₁ ≡ (just v₂) → evalᵣₑᵥ c v₂ ≡ (just v₁)
evalIsRev c v₁ v₂ eq with ev {κ = ☐} c v₁
evalIsRev c v₁ v₂ refl | inj₁ (v₂ , rs) with evᵣₑᵥ {κ = ☐} c v₂
... | inj₁ (v₁' , rs') with deterministicᵣₑᵥ* rs' (Rev↦ rs) (λ ()) (λ ()) (λ ())
... | refl = refl
evalIsRev c v₁ v₂ refl | inj₁ (v₂ , rs) | inj₂ (_ , v , _ , _ , neq , rs') with deterministicᵣₑᵥ* rs' (Rev↦ rs) (λ ()) (Lemma₆ neq) (λ ())
... | ()
-- Backward evaluator is reversible
evalᵣₑᵥIsRev : ∀ {A B} → (c : A ↔ B) (v₁ : ⟦ B ⟧) (v₂ : ⟦ A ⟧)
→ evalᵣₑᵥ c v₁ ≡ (just v₂) → eval c v₂ ≡ (just v₁)
evalᵣₑᵥIsRev c v₁ v₂ eq with evᵣₑᵥ {κ = ☐} c v₁
evalᵣₑᵥIsRev c v₁ v₂ refl | inj₁ (v₂ , rs) with ev {κ = ☐} c v₂
... | inj₁ (_ , rs') with deterministic* rs' (Rev↦ᵣₑᵥ rs) (λ ()) (λ ())
... | refl = refl
evalᵣₑᵥIsRev c v₁ v₂ refl | inj₁ (v₂ , rs) | inj₂ rs' with deterministic* rs' (Rev↦ᵣₑᵥ rs) (λ ()) (λ ())
... | ()
-- The abstract machine semantics is equivalent to the big-step semantics
eval≡interp : ∀ {A B} → (c : A ↔ B) → (v : ⟦ A ⟧) → eval c v ≡ interp c v
eval≡interp uniti₊l v = refl
eval≡interp unite₊l (inj₂ v) = refl
eval≡interp swap₊ (inj₁ x) = refl
eval≡interp swap₊ (inj₂ y) = refl
eval≡interp assocl₊ (inj₁ x) = refl
eval≡interp assocl₊ (inj₂ (inj₁ y)) = refl
eval≡interp assocl₊ (inj₂ (inj₂ z)) = refl
eval≡interp assocr₊ (inj₁ (inj₁ x)) = refl
eval≡interp assocr₊ (inj₁ (inj₂ y)) = refl
eval≡interp assocr₊ (inj₂ z) = refl
eval≡interp unite⋆l (tt , v) = refl
eval≡interp uniti⋆l v = refl
eval≡interp swap⋆ (x , y) = refl
eval≡interp assocl⋆ (x , (y , z)) = refl
eval≡interp assocr⋆ ((x , y) , z) = refl
eval≡interp dist (inj₁ x , z) = refl
eval≡interp dist (inj₂ y , z) = refl
eval≡interp factor (inj₁ (x , z)) = refl
eval≡interp factor (inj₂ (y , z)) = refl
eval≡interp id↔ v = refl
eval≡interp (c₁ ⨾ c₂) v with ev {κ = ☐} c₁ v | inspect (ev {κ = ☐} c₁) v
eval≡interp (c₁ ⨾ c₂) v | inj₁ (v' , rs) | [ eq ] with ev {κ = ☐} c₂ v' | inspect (ev {κ = ☐} c₂) v'
eval≡interp (c₁ ⨾ c₂) v | inj₁ (v' , rs) | [ eq ] | inj₁ (v'' , rs') | [ eq' ] with ev {κ = ☐} (c₁ ⨾ c₂) v | inspect (ev {κ = ☐} (c₁ ⨾ c₂)) v
eval≡interp (c₁ ⨾ c₂) v | inj₁ (v' , rs) | [ eq ] | inj₁ (v'' , rs') | [ eq' ] | inj₁ (u , rs'') | [ eq'' ] rewrite (sym (eval≡interp c₁ v)) | eq | (sym (eval≡interp c₂ v')) | eq' with deterministic* ((↦₃ ∷ ◾) ++↦ appendκ↦* rs (λ ()) (λ ()) refl (☐⨾ c₂ • ☐) ++↦ (↦₇ ∷ ◾) ++↦ appendκ↦* rs' (λ ()) (λ ()) refl (c₁ ⨾☐• ☐) ++↦ (↦₁₀ ∷ ◾)) rs'' (λ ()) (λ ())
... | refl = refl
eval≡interp (c₁ ⨾ c₂) v | inj₁ (v' , rs) | [ eq ] | inj₁ (v'' , rs') | [ eq' ] | inj₂ rs'' | [ eq'' ] rewrite (sym (eval≡interp c₁ v)) | eq | (sym (eval≡interp c₂ v')) | eq' with deterministic* ((↦₃ ∷ ◾) ++↦ appendκ↦* rs (λ ()) (λ ()) refl (☐⨾ c₂ • ☐) ++↦ (↦₇ ∷ ◾) ++↦ appendκ↦* rs' (λ ()) (λ ()) refl (c₁ ⨾☐• ☐) ++↦ (↦₁₀ ∷ ◾)) rs'' (λ ()) (λ ())
... | ()
eval≡interp (c₁ ⨾ c₂) v | inj₁ (v' , rs) | [ eq ] | inj₂ rs' | [ eq' ] with ev {κ = ☐} (c₁ ⨾ c₂) v | inspect (ev {κ = ☐} (c₁ ⨾ c₂)) v
eval≡interp (c₁ ⨾ c₂) v | inj₁ (v' , rs) | [ eq ] | inj₂ rs' | [ eq' ] | inj₁ (u , rs'') | [ eq'' ] rewrite (sym (eval≡interp c₁ v)) | eq | (sym (eval≡interp c₂ v')) | eq' with deterministic* ((↦₃ ∷ ◾) ++↦ appendκ↦* rs (λ ()) (λ ()) refl (☐⨾ c₂ • ☐) ++↦ (↦₇ ∷ ◾) ++↦ appendκ↦*⊠ rs' (λ ()) (c₁ ⨾☐• ☐)) rs'' (λ ()) (λ ())
... | ()
eval≡interp (c₁ ⨾ c₂) v | inj₁ (v' , rs) | [ eq ] | inj₂ rs' | [ eq' ] | inj₂ rs'' | [ eq'' ] rewrite (sym (eval≡interp c₁ v)) | eq | (sym (eval≡interp c₂ v')) | eq' = refl
eval≡interp (c₁ ⨾ c₂) v | inj₂ rs | [ eq ] with ev {κ = ☐} (c₁ ⨾ c₂) v | inspect (ev {κ = ☐} (c₁ ⨾ c₂)) v
eval≡interp (c₁ ⨾ c₂) v | inj₂ rs | [ eq ] | inj₁ (v'' , rs') | [ eq' ] with deterministic* ((↦₃ ∷ ◾) ++↦ appendκ↦*⊠ rs (λ ()) (☐⨾ c₂ • ☐)) rs' (λ ()) (λ ())
... | ()
eval≡interp (c₁ ⨾ c₂) v | inj₂ rs | [ eq ] | inj₂ rs' | [ eq' ] rewrite (sym (eval≡interp c₁ v)) | eq = refl
eval≡interp (c₁ ⊕ c₂) (inj₁ x) with ev {κ = ☐} c₁ x | inspect (ev {κ = ☐} c₁) x
eval≡interp (c₁ ⊕ c₂) (inj₁ x) | inj₁ (x' , rs) | [ eq ] with ev {κ = ☐} (c₁ ⊕ c₂) (inj₁ x) | inspect (ev {κ = ☐} (c₁ ⊕ c₂)) (inj₁ x)
eval≡interp (c₁ ⊕ c₂) (inj₁ x) | inj₁ (x' , rs) | [ eq ] | inj₁ (x'' , rs') | [ eq' ] rewrite (sym (eval≡interp c₁ x)) | eq with deterministic* ((↦₄ ∷ ◾) ++↦ appendκ↦* rs (λ ()) (λ ()) refl (☐⊕ c₂ • ☐) ++↦ (↦₁₁ ∷ ◾)) rs' (λ ()) (λ ())
... | refl = refl
eval≡interp (c₁ ⊕ c₂) (inj₁ x) | inj₁ (x' , rs) | [ eq ] | inj₂ rs' | [ eq' ] rewrite (sym (eval≡interp c₁ x)) | eq with deterministic* ((↦₄ ∷ ◾) ++↦ appendκ↦* rs (λ ()) (λ ()) refl (☐⊕ c₂ • ☐) ++↦ (↦₁₁ ∷ ◾)) rs' (λ ()) (λ ())
... | ()
eval≡interp (c₁ ⊕ c₂) (inj₁ x) | inj₂ rs | [ eq ] with ev {κ = ☐} (c₁ ⊕ c₂) (inj₁ x) | inspect (ev {κ = ☐} (c₁ ⊕ c₂)) (inj₁ x)
eval≡interp (c₁ ⊕ c₂) (inj₁ x) | inj₂ rs | [ eq ] | inj₁ (x'' , rs') | [ eq' ] rewrite (sym (eval≡interp c₁ x)) | eq with deterministic* ((↦₄ ∷ ◾) ++↦ appendκ↦*⊠ rs (λ ()) (☐⊕ c₂ • ☐)) rs' (λ ()) (λ ())
... | ()
eval≡interp (c₁ ⊕ c₂) (inj₁ x) | inj₂ rs | [ eq ] | inj₂ rs' | [ eq' ] rewrite (sym (eval≡interp c₁ x)) | eq = refl
eval≡interp (c₁ ⊕ c₂) (inj₂ y) with ev {κ = ☐} c₂ y | inspect (ev {κ = ☐} c₂) y
eval≡interp (c₁ ⊕ c₂) (inj₂ y) | inj₁ (y' , rs) | [ eq ] with ev {κ = ☐} (c₁ ⊕ c₂) (inj₂ y) | inspect (ev {κ = ☐} (c₁ ⊕ c₂)) (inj₂ y)
eval≡interp (c₁ ⊕ c₂) (inj₂ y) | inj₁ (y' , rs) | [ eq ] | inj₁ (y'' , rs') | [ eq' ] rewrite (sym (eval≡interp c₂ y)) | eq with deterministic* ((↦₅ ∷ ◾) ++↦ appendκ↦* rs (λ ()) (λ ()) refl (c₁ ⊕☐• ☐) ++↦ (↦₁₂ ∷ ◾)) rs' (λ ()) (λ ())
... | refl = refl
eval≡interp (c₁ ⊕ c₂) (inj₂ y) | inj₁ (y' , rs) | [ eq ] | inj₂ rs' | [ eq' ] rewrite (sym (eval≡interp c₂ y)) | eq with deterministic* ((↦₅ ∷ ◾) ++↦ appendκ↦* rs (λ ()) (λ ()) refl (c₁ ⊕☐• ☐) ++↦ (↦₁₂ ∷ ◾)) rs' (λ ()) (λ ())
... | ()
eval≡interp (c₁ ⊕ c₂) (inj₂ y) | inj₂ rs | [ eq ] with ev {κ = ☐} (c₁ ⊕ c₂) (inj₂ y) | inspect (ev {κ = ☐} (c₁ ⊕ c₂)) (inj₂ y)
eval≡interp (c₁ ⊕ c₂) (inj₂ y) | inj₂ rs | [ eq ] | inj₁ (y'' , rs') | [ eq' ] rewrite (sym (eval≡interp c₂ y)) | eq with deterministic* ((↦₅ ∷ ◾) ++↦ appendκ↦*⊠ rs (λ ()) (c₁ ⊕☐• ☐)) rs' (λ ()) (λ ())
... | ()
eval≡interp (c₁ ⊕ c₂) (inj₂ y) | inj₂ rs | [ eq ] | inj₂ rs' | [ eq' ] rewrite (sym (eval≡interp c₂ y)) | eq = refl
eval≡interp (c₁ ⊗ c₂) (x , y) with ev {κ = ☐} c₁ x | inspect (ev {κ = ☐} c₁) x
eval≡interp (c₁ ⊗ c₂) (x , y) | inj₁ (x' , rs) | [ eq ] with ev {κ = ☐} c₂ y | inspect (ev {κ = ☐} c₂) y
eval≡interp (c₁ ⊗ c₂) (x , y) | inj₁ (x' , rs) | [ eq ] | inj₁ (y' , rs') | [ eq' ] with ev {κ = ☐} (c₁ ⊗ c₂) (x , y) | inspect (ev {κ = ☐} (c₁ ⊗ c₂)) (x , y)
eval≡interp (c₁ ⊗ c₂) (x , y) | inj₁ (x' , rs) | [ eq ] | inj₁ (y' , rs') | [ eq' ] | inj₁ (_ , rs'') | [ eq'' ] rewrite (sym (eval≡interp c₁ x)) | eq | (sym (eval≡interp c₂ y)) | eq' with deterministic* (((↦₆ ∷ ◾) ++↦ appendκ↦* rs (λ ()) (λ ()) refl (☐⊗[ c₂ , y ]• ☐)) ++↦ (↦₈ ∷ ◾) ++↦ appendκ↦* rs' (λ ()) (λ ()) refl ([ c₁ , x' ]⊗☐• ☐) ++↦ (↦₉ ∷ ◾)) rs'' (λ ()) (λ ())
... | refl = refl
eval≡interp (c₁ ⊗ c₂) (x , y) | inj₁ (x' , rs) | [ eq ] | inj₁ (y' , rs') | [ eq' ] | inj₂ rs'' | [ eq'' ] rewrite (sym (eval≡interp c₁ x)) | eq | (sym (eval≡interp c₂ y)) | eq' with deterministic* (((↦₆ ∷ ◾) ++↦ appendκ↦* rs (λ ()) (λ ()) refl (☐⊗[ c₂ , y ]• ☐)) ++↦ (↦₈ ∷ ◾) ++↦ appendκ↦* rs' (λ ()) (λ ()) refl ([ c₁ , x' ]⊗☐• ☐) ++↦ (↦₉ ∷ ◾)) rs'' (λ ()) (λ ())
... | ()
eval≡interp (c₁ ⊗ c₂) (x , y) | inj₁ (x' , rs) | [ eq ] | inj₂ rs' | [ eq' ] with ev {κ = ☐} (c₁ ⊗ c₂) (x , y) | inspect (ev {κ = ☐} (c₁ ⊗ c₂)) (x , y)
eval≡interp (c₁ ⊗ c₂) (x , y) | inj₁ (x' , rs) | [ eq ] | inj₂ rs' | [ eq' ] | inj₁ (y' , rs'') | [ eq'' ] rewrite (sym (eval≡interp c₁ x)) | eq | (sym (eval≡interp c₂ y)) | eq' with deterministic* (((↦₆ ∷ ◾) ++↦ appendκ↦* rs (λ ()) (λ ()) refl (☐⊗[ c₂ , y ]• ☐)) ++↦ (↦₈ ∷ ◾) ++↦ appendκ↦*⊠ rs' (λ ()) ([ c₁ , x' ]⊗☐• ☐)) rs'' (λ ()) (λ ())
... | ()
eval≡interp (c₁ ⊗ c₂) (x , y) | inj₁ (x' , rs) | [ eq ] | inj₂ rs' | [ eq' ] | inj₂ rs'' | [ eq'' ] rewrite (sym (eval≡interp c₁ x)) | eq | (sym (eval≡interp c₂ y)) | eq' = refl
eval≡interp (c₁ ⊗ c₂) (x , y) | inj₂ rs | [ eq ] with ev {κ = ☐} (c₁ ⊗ c₂) (x , y) | inspect (ev {κ = ☐} (c₁ ⊗ c₂)) (x , y)
eval≡interp (c₁ ⊗ c₂) (x , y) | inj₂ rs | [ eq ] | inj₁ (_ , rs') | [ eq' ] rewrite (sym (eval≡interp c₁ x)) | eq with deterministic* ((↦₆ ∷ ◾) ++↦ appendκ↦*⊠ rs (λ ()) (☐⊗[ c₂ , y ]• ☐)) rs' (λ ()) (λ ())
... | ()
eval≡interp (c₁ ⊗ c₂) (x , y) | inj₂ rs | [ eq ] | inj₂ rs'' | [ eq' ] rewrite (sym (eval≡interp c₁ x)) | eq = refl
eval≡interp (ηₓ v) tt = refl
eval≡interp (εₓ v) (v' , ↻) with v ≟ v'
... | yes refl = refl
... | no _ = refl
-- !c is the inverse computation of c
interp! : ∀ {A B} (c : A ↔ B) (a : ⟦ A ⟧) (b : ⟦ B ⟧) → interp c a ≡ just b → interp (! c) b ≡ just a
interp! unite₊l (inj₂ y) .y refl = refl
interp! uniti₊l y .(inj₂ y) refl = refl
interp! swap₊ (inj₁ x) .(inj₂ x) refl = refl
interp! swap₊ (inj₂ y) .(inj₁ y) refl = refl
interp! assocl₊ (inj₁ x) .(inj₁ (inj₁ x)) refl = refl
interp! assocl₊ (inj₂ (inj₁ y)) .(inj₁ (inj₂ y)) refl = refl
interp! assocl₊ (inj₂ (inj₂ z)) .(inj₂ z) refl = refl
interp! assocr₊ (inj₁ (inj₁ x)) .(inj₁ x) refl = refl
interp! assocr₊ (inj₁ (inj₂ y)) .(inj₂ (inj₁ y)) refl = refl
interp! assocr₊ (inj₂ z) .(inj₂ (inj₂ z)) refl = refl
interp! unite⋆l (tt , v) .v refl = refl
interp! uniti⋆l v .(tt , v) refl = refl
interp! swap⋆ (x , y) .(y , x) refl = refl
interp! assocl⋆ (x , y , z) .((x , y) , z) refl = refl
interp! assocr⋆ ((x , y) , z) .(x , y , z) refl = refl
interp! dist (inj₁ x , z) .(inj₁ (x , z)) refl = refl
interp! dist (inj₂ y , z) .(inj₂ (y , z)) refl = refl
interp! factor (inj₁ (x , z)) .(inj₁ x , z) refl = refl
interp! factor (inj₂ (y , z)) .(inj₂ y , z) refl = refl
interp! id↔ v .v refl = refl
interp! (c₁ ⨾ c₂) a c eq with interp c₁ a | inspect (interp c₁) a
... | just b | [ eq₁ ] with interp c₂ b | inspect (interp c₂) b
... | just c' | [ eq₂ ] with eq
... | refl rewrite interp! c₂ b c eq₂ | interp! c₁ a b eq₁ = refl
interp! (c₁ ⊕ c₂) (inj₁ x) b eq with interp c₁ x | inspect (interp c₁) x
... | just x' | [ eqx ] with b
... | inj₁ _ with eq
... | refl rewrite interp! c₁ x x' eqx = refl
interp! (c₁ ⊕ c₂) (inj₂ y) b eq with interp c₂ y | inspect (interp c₂) y
... | just y' | [ eqy ] with b
... | inj₂ _ with eq
... | refl rewrite interp! c₂ y y' eqy = refl
interp! (c₁ ⊗ c₂) (x , y) (x' , y') eq with interp c₁ x | inspect (interp c₁) x | interp c₂ y | inspect (interp c₂) y
... | just x'' | [ eqx ] | just y'' | [ eqy ] with eq
... | refl rewrite interp! c₁ x x' eqx | interp! c₂ y y' eqy = refl
interp! (ηₓ v) tt .(v , ↻) refl with v ≟ v
... | yes refl = refl
... | no neq = ⊥-elim (neq refl)
interp! (εₓ v) (v' , ↻) b eq with v ≟ v'
... | yes refl = refl
interp! (εₓ _) (v' , ↻) b () | no neq
| {
"alphanum_fraction": 0.5031762837,
"avg_line_length": 71.2830188679,
"ext": "agda",
"hexsha": "28fb6be8fd981e9e8f86b6a2af3eb1c46edb64f6",
"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": "PiFrac/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": "PiFrac/Properties.agda",
"max_line_length": 371,
"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": "PiFrac/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": 5488,
"size": 11334
} |
{-# OPTIONS --no-irrelevant-projections #-}
module ScopeIrrelevantRecordField where
record Bla : Set1 where
constructor mkBla
field
.bla0 bla1 .{bla2 bla3} {bla4 .bla5} : Set
bla0' : Bla -> Set
bla0' = Bla.bla0 -- should fail with bla0 not in scope
| {
"alphanum_fraction": 0.7,
"avg_line_length": 23.6363636364,
"ext": "agda",
"hexsha": "38b632d0a9230175bc9df6b176f685800d8ff9df",
"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/fail/ScopeIrrelevantRecordField.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/ScopeIrrelevantRecordField.agda",
"max_line_length": 55,
"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/Fail/ScopeIrrelevantRecordField.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": 87,
"size": 260
} |
open import FRP.JS.Behaviour using ( Beh ; [_] ; map )
open import FRP.JS.Event using ( Evt ; tag )
open import FRP.JS.DOM using
( DOM ; click ; element ; text ; _++_ ; element+ ; text+ ; listen+ ; _+++_ )
open import FRP.JS.RSet using ( RSet ; ⟦_⟧ ; ⟨_⟩ ; _⇒_ )
open import FRP.JS.Product using ( _∧_ ; _,_ )
open import FRP.JS.Demo.Calculator.Model using
( Button ; State ; digit ; op ; clear ; eq ; plus ; minus ; times ; button$ ; state$ ; model )
module FRP.JS.Demo.Calculator.View where
button : ∀ {w} → Button → ⟦ Beh (DOM w) ∧ Evt ⟨ Button ⟩ ⟧
button b = listen+ click (λ _ → b) (element+ "button" (text+ [ button$ b ]))
keypad : ∀ {w} → ⟦ Beh (DOM w) ∧ Evt ⟨ Button ⟩ ⟧
keypad =
element+ "div" (button (digit 7) +++ button (digit 8) +++ button (digit 9) ) +++
element+ "div" (button (digit 4) +++ button (digit 5) +++ button (digit 6) ) +++
element+ "div" (button (digit 1) +++ button (digit 2) +++ button (digit 3) ) +++
element+ "div" (button (op eq) +++ button (digit 0) +++ button clear ) +++
element+ "div" (button (op plus) +++ button (op minus) +++ button (op times))
display : ∀ {w} → ⟦ Beh ⟨ State ⟩ ⇒ Beh (DOM w) ⟧
display σ = element "div" (text (map state$ σ))
view : ∀ {w} → ⟦ Beh (DOM w) ⟧
view with keypad
... | (dom , evt) = display (model evt) ++ dom | {
"alphanum_fraction": 0.5796324655,
"avg_line_length": 46.6428571429,
"ext": "agda",
"hexsha": "2e3bba34d44f53febf0871225ea9fdc81d83dcf3",
"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": "demo/agda/FRP/JS/Demo/Calculator/View.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": "demo/agda/FRP/JS/Demo/Calculator/View.agda",
"max_line_length": 96,
"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": "demo/agda/FRP/JS/Demo/Calculator/View.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": 469,
"size": 1306
} |
{-# OPTIONS --without-K --safe #-}
----------------------------------------------------------------------
-- Gaps
----------------------------------------------------------------------
-- Polynomials can be represented as lists of their coefficients,
-- stored in increasing powers of x:
--
-- 3 + 2x² + 4x⁵ + 2x⁷
-- ≡⟨ making the missing xs explicit ⟩
-- 3x⁰ + 0x¹ + 2x² + 0x³ + 0x⁴ + 4x⁵ + 0x⁶ + 2x⁷
-- ≡⟨ in list notation ⟩
-- [3,0,2,0,0,4,0,2]
--
-- This approach is wasteful with space. Instead, we will pair each
-- coefficient with the size of the preceding gap, meaning that the
-- above expression is instead written as:
--
-- [(3,0),(2,1),(4,2),(2,1)]
--
-- Which can be thought of as a representation of the expression:
--
-- x⁰ * (3 + x * x¹ * (2 + x * x² * (4 + x * x¹ * (2 + x * 0))))
--
-- To add multiple variables to a polynomial, you can *nest* them,
-- making the coefficients of the outer polynomial polynomials
-- themselves. However, this is *also* wasteful, in a similar way to
-- above: the constant polynomial, for instance, will be represented
-- as many nestings of constant polynomials around a final variable.
-- However, this approach presents a difficulty: the polynomial will
-- have the kind ℕ → Set (...). In other words, it's indexed by the
-- number of variables it contains. The gap we store, then, has to
-- be accomanied with some information about how it relates to that
-- index.
--
-- The first approach I tried was to forget about storing the gaps,
-- and instead store the number of variables in the nested coefficient,
-- along with a proof that the number was smaller than the outer. The
-- proof was _≤_ from Data.Nat:
--
-- data _≤_ : Rel ℕ 0ℓ where
-- z≤n : ∀ {n} → zero ≤ n
-- s≤s : ∀ {m n} (m≤n : m ≤ n) → suc m ≤ suc n
--
-- While this worked, this will actually give you a worse complexity
-- than the naive encoding without gaps.
--
-- For any of the binary operations, you need to be able to "line up"
-- the two arguments in terms of the gaps. For addition, for instance,
-- the argument with fewer variables should be added to the constant
-- term of the argument with more. To do this, you need to compare the
-- gaps.
--
-- To see why that's a problem, consider the following sequence of
-- nestings:
--
-- (5 ≤ 6), (4 ≤ 5), (3 ≤ 4), (1 ≤ 3), (0 ≤ 1)
--
-- The outer polynomial has 6 variables, but it has a gap to its inner
-- polynomial of 5, and so on. What we compare in this case is the
-- number of variables in the tail: like repeatedly taking the length of
-- the tail of a list, it's quadratic.
--
-- The second approach was to try and mimic the powers structure
-- (which only compared the gaps, which is linear), and store the gaps
-- in a proof like the following:
--
-- record _≤″_ (m n : ℕ) : Set where
-- constructor less-than-or-equal
-- field
-- {k} : ℕ
-- proof : m + k ≡ n
--
-- Here, k is the size of the gap. The problem of this approach was
-- twofold: it was difficult to show that comparisons on the k
-- corresponded to comparisons on the m, and working with ≡ instead of
-- some inductive structure was messy. However, it had the advantage
-- of being erasable: both proofs of the correspondence and the
-- equality proof itself. That said, I'm not very familiar with the
-- soundness of erasure, and in particular how it interacts with axiom
-- K (which I'd managed to avoid up until this point, but started to
-- creep in).
--
-- I may have had more luck if I swapped the arguments too +:
--
-- record _≤″_ (m n : ℕ) : Set where
-- constructor less-than-or-equal
-- field
-- {k} : ℕ
-- proof : k + m ≡ n
--
-- But I did not try it. The solution I ended up with was superior,
-- regardless:
--
-- infix 4 _≤_
-- data _≤_ (m : ℕ) : ℕ → Set where
-- m≤m : m ≤ m
-- ≤-s : ∀ {n} → (m≤n : m ≤ n) → m ≤ suc n
--
-- (This is a rewritten version of _≤′_ from Data.Nat.Base).
--
-- While this structure stores the same information as ≤, it does so
-- by induction on the *gap*. This became apparent when I realised you
-- could use it to write a comparison function which was linear in the
-- size of the gap (even though it was comparing the length of the
-- tail):
-- data Ordering : ℕ → ℕ → Set where
-- less : ∀ {n m} → n ≤ m → Ordering n (suc m)
-- greater : ∀ {n m} → m ≤ n → Ordering (suc n) m
-- equal : ∀ {n} → Ordering n n
-- ≤-compare : ∀ {i j n}
-- → (i≤n : i ≤ n)
-- → (j≤n : j ≤ n)
-- → Ordering i j
-- ≤-compare m≤m m≤m = equal
-- ≤-compare m≤m (≤-s m≤n) = greater m≤n
-- ≤-compare (≤-s m≤n) m≤m = less m≤n
-- ≤-compare (≤-s i≤n) (≤-s j≤n) = ≤-compare i≤n j≤n
--
-- A few things to note here:
--
-- 1. The ≤-compare function is one of those reassuring ones for which
-- Agda can completely fill in the type for me.
-- 2. This function looks somewhat similar to the one for comparing ℕ
-- in Data.Nat, and as a result, the "matching" logic for degree
-- and number of variables began too look similar.
--
-- While this approach allowed me too write all the functions I
-- needed, I hit another roadblock when it came time to prove the
-- ring homomorphism. The first thing I realised I needed to prove was
-- basically the following:
--
-- ∀ {i j n}
-- → (i≤n : i ≤ n)
-- → (j≤n : j ≤ n)
-- → ∀ xs Ρ
-- → Σ⟦ xs ⟧ (drop-1 i≤n Ρ) ≈ Σ⟦ xs ⟧ (drop-1 j≤n Ρ)
--
-- In effect, if the inequalities are over the same numbers, then
-- they'll behave the same way when used in evaluation.
--
-- The above is really just a consequence of ≤ being irrelevant:
--
-- ∀ {i n}
-- → (x : i ≤ n)
-- → (y : i ≤ n)
-- → x ≡ y
--
-- Trying to prove this convinced me that it might not even be possible
-- without K. On top of that, I also noticed that I would need to
-- prove things like:
--
-- ∀ {i j n}
-- → (i≤j : i ≤ j)
-- → (j≤n : j ≤ n)
-- → (x : FlatPoly i)
-- → (Ρ : Vec Carrier n)
-- → ⟦ x Π (i≤j ⟨ ≤′-trans ⟩ j≤n) ⟧ Ρ ≈ ⟦ x Π i≤j ⟧ (drop j≤n Ρ)
--
-- Effectively, I needed to prove that transitivity was a
-- homomorphism.
--
-- I realised that I had not run into these difficulties with the
-- comparison function I was using for the exponent gaps: why? Well
-- that function provides a proof about its *arguments* whereas the
-- one I wrote above only provides a proof about the i and j.
--
-- data Ordering : Rel ℕ 0ℓ where
-- less : ∀ m k → Ordering m (suc (m + k))
-- equal : ∀ m → Ordering m m
-- greater : ∀ m k → Ordering (suc (m + k)) m
--
-- If I tried to mimick the above as closely as possible, I would also
-- need an analogue to +: of course this was ≤′-trans, so I was going
-- to get my transitivity proof as well as everything else. The result
-- is as follows.
module Polynomial.NormalForm.InjectionIndex where
open import Data.Nat as ℕ using (ℕ; suc; zero)
open import Data.Nat using (_≤′_; ≤′-refl; ≤′-step; _<′_) public
open import Data.Nat.Properties using (≤′-trans) public
open import Function
data InjectionOrdering {n : ℕ} : ∀ {i j}
→ (i≤n : i ≤′ n)
→ (j≤n : j ≤′ n)
→ Set
where
inj-lt : ∀ {i j-1}
→ (i≤j-1 : i ≤′ j-1)
→ (j≤n : suc j-1 ≤′ n)
→ InjectionOrdering (≤′-step i≤j-1 ⟨ ≤′-trans ⟩ j≤n) j≤n
inj-gt : ∀ {i-1 j}
→ (i≤n : suc i-1 ≤′ n)
→ (j≤i-1 : j ≤′ i-1)
→ InjectionOrdering i≤n (≤′-step j≤i-1 ⟨ ≤′-trans ⟩ i≤n)
inj-eq : ∀ {i} → (i≤n : i ≤′ n) → InjectionOrdering i≤n i≤n
inj-compare : ∀ {i j n}
→ (x : i ≤′ n)
→ (y : j ≤′ n)
→ InjectionOrdering x y
inj-compare ≤′-refl ≤′-refl = inj-eq ≤′-refl
inj-compare ≤′-refl (≤′-step y) = inj-gt ≤′-refl y
inj-compare (≤′-step x) ≤′-refl = inj-lt x ≤′-refl
inj-compare (≤′-step x) (≤′-step y) = case inj-compare x y of
λ { (inj-lt i≤j-1 .y) → inj-lt i≤j-1 (≤′-step y)
; (inj-gt .x j≤i-1) → inj-gt (≤′-step x) j≤i-1
; (inj-eq .x) → inj-eq (≤′-step x)
}
open import Data.Fin as Fin using (Fin)
space : ∀ {n} → Fin n → ℕ
space f = suc (go f)
where
go : ∀ {n} → Fin n → ℕ
go {suc n} Fin.zero = n
go (Fin.suc x) = go x
Fin⇒≤ : ∀ {n} (x : Fin n) → space x ≤′ n
Fin⇒≤ Fin.zero = ≤′-refl
Fin⇒≤ (Fin.suc x) = ≤′-step (Fin⇒≤ x)
| {
"alphanum_fraction": 0.5974437005,
"avg_line_length": 36.1894273128,
"ext": "agda",
"hexsha": "f02f0c23dc9b55143fc6015fb3c2e5f7757e61c5",
"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/NormalForm/InjectionIndex.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/NormalForm/InjectionIndex.agda",
"max_line_length": 72,
"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/NormalForm/InjectionIndex.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": 2751,
"size": 8215
} |
open import cedille-types
import spans
open import ctxt
import cedille-options
open import general-util
module type-inf
(options : cedille-options.options)
{mF : Set → Set}
⦃ _ : monad mF ⦄
(check-term : ctxt → ex-tm → (T? : maybe type) →
spans.spanM options {mF} (spans.check-ret options {mF} T? term))
(check-type : ctxt → ex-tp → (k? : maybe kind) →
spans.spanM options {mF} (spans.check-ret options {mF} k? type))
where
open import spans options {mF}
open import rename
open import syntax-util
open import type-util
open import meta-vars options {mF}
open import resugar
open import subst
open import conversion
open import free-vars
open import constants
record spine-data : Set where
constructor mk-spine-data
field
spine-mvars : meta-vars
spine-type : decortype
spine-locale : ℕ
spine-elab : meta-vars → term
check-term-spine-elim : ctxt → spine-data → term × type
check-term-spine-elim Γ (mk-spine-data Xs dt locl f~) =
f~ Xs , meta-vars-subst-type' ff Γ Xs (decortype-to-type dt)
-- elim-pair (maybe-else' (meta-vars-to-args Xs) ([] , Hole pi-gen) f~) recompose-apps ,
-- meta-vars-subst-type' ff Γ Xs (decortype-to-type dt)
check-term-spine : ctxt → ex-tm → (m : prototype) → 𝔹 → spanM (maybe spine-data)
check-term-spine-return : meta-vars → decortype → ℕ → (meta-vars → term) → spanM (maybe spine-data)
check-term-spine-return Xs dt locl f~ = return (just (mk-spine-data Xs dt locl f~))
-- a flag indicating how aggresively we should be unfolding during matching.
-- "both" is the backtracking flag. We will attempt "both" matches, which means
-- first matching without unfolding, then if that fails unfolding the type once
-- and continue matching the subexpresions with "both"
data match-unfolding-state : Set where
match-unfolding-both match-unfolding-approx match-unfolding-hnf : match-unfolding-state
-- main matching definitions
-- --------------------------------------------------
-- NOTE: these functions don't actually ever emit spans
match-types : ctxt → meta-vars → local-vars → match-unfolding-state → (tpₓ tp : type) → spanM $ match-error-t meta-vars
match-kinds : ctxt → meta-vars → local-vars → match-unfolding-state → (kₓ k : kind) → spanM $ match-error-t meta-vars
match-tpkds : ctxt → meta-vars → local-vars → match-unfolding-state → (tkₓ tk : tpkd) → spanM $ match-error-t meta-vars
record match-prototype-data : Set where
constructor mk-match-prototype-data
field
match-proto-mvars : meta-vars
match-proto-dectp : decortype
match-proto-error : 𝔹
open match-prototype-data
match-prototype : ctxt → (Xs : meta-vars) (is-hnf : 𝔹) (tp : type) (pt : prototype) → spanM match-prototype-data
-- substitutions used during matching
-- --------------------------------------------------
-- These have to be in the spanM monad because substitution can unlock a `stuck`
-- decoration, causing another round of prototype matching (which invokes type matching)
substh-decortype : ctxt → renamectxt → trie (Σi exprd ⟦_⟧) → decortype → spanM decortype
substh-decortype Γ ρ σ (decor-type tp) = return $ decor-type (substh Γ ρ σ tp)
substh-decortype Γ ρ σ (decor-arrow e? dom cod) =
substh-decortype Γ ρ σ cod
>>= λ cod → return $ decor-arrow e? (substh Γ ρ σ dom) cod
substh-decortype Γ ρ σ (decor-decor e? x tk sol dt) =
let x' = subst-rename-var-if Γ ρ x σ (decortype-to-type dt)
Γ' = ctxt-var-decl x' Γ
ρ' = renamectxt-insert ρ x x'
in substh-decortype Γ' ρ' σ dt
>>= λ dt' → return $ decor-decor e? x' (substh Γ ρ σ -tk tk) (substh-meta-var-sort Γ ρ σ sol) dt'
substh-decortype Γ ρ σ (decor-stuck tp pt) =
match-prototype Γ meta-vars-empty ff (substh Γ ρ σ tp) pt
-- NOTE: its an invariant that if you start with no meta-variables,
-- prototype matching produces no meta-variables as output
>>= λ ret → return (match-proto-dectp ret)
substh-decortype Γ ρ σ (decor-error tp pt) =
return $ decor-error (substh Γ ρ σ tp) pt
subst-decortype : {ed : exprd} → ctxt → ⟦ ed ⟧ → var → decortype → spanM decortype
subst-decortype Γ s x dt = substh-decortype Γ empty-renamectxt (trie-single x (, s)) dt
meta-vars-subst-decortype' : (unfold : 𝔹) → ctxt → meta-vars → decortype → spanM decortype
meta-vars-subst-decortype' uf Γ Xs dt =
substh-decortype Γ empty-renamectxt (meta-vars-get-sub Xs) dt
>>= λ dt' → return $
if uf then hnf-decortype Γ unfold-head-elab dt' tt else dt'
meta-vars-subst-decortype : ctxt → meta-vars → decortype → spanM decortype
meta-vars-subst-decortype = meta-vars-subst-decortype' tt
-- unfolding a decorated type to reveal a term / type abstraction
-- --------------------------------------------------
{-# TERMINATING #-}
meta-vars-peel' : ctxt → span-location → meta-vars → decortype → spanM (𝕃 meta-var × decortype)
meta-vars-peel' Γ sl Xs (decor-decor e? x _ (meta-var-tp k mtp) dt) =
let Y = meta-var-fresh-tp Xs x sl (k , mtp)
Xs' = meta-vars-add Xs Y
in subst-decortype Γ (meta-var-to-type-unsafe Y) x dt
>>= λ dt' → meta-vars-peel' Γ sl Xs' dt'
>>= λ ret → let Ys = fst ret ; rdt = snd ret
in return $ Y :: Ys , rdt
meta-vars-peel' Γ sl Xs dt@(decor-decor e? x _ (meta-var-tm _ _) _) = return $ [] , dt
meta-vars-peel' Γ sl Xs dt@(decor-arrow _ _ _) = return $ [] , dt
-- NOTE: vv The clause below will later generate a type error vv
meta-vars-peel' Γ sl Xs dt@(decor-stuck _ _) = return $ [] , dt
-- NOTE: vv The clause below is an internal error, if reached vv
meta-vars-peel' Γ sl Xs dt@(decor-type _) = return $ [] , dt
meta-vars-peel' Γ sl Xs dt@(decor-error _ _) = return $ [] , dt
meta-vars-unfold-tmapp' : ctxt → span-location → meta-vars → decortype → spanM (𝕃 meta-var × is-tmabsd?)
meta-vars-unfold-tmapp' Γ sl Xs dt =
meta-vars-subst-decortype Γ Xs dt
>>= λ dt' → meta-vars-peel' Γ sl Xs dt'
>>= λ where
(Ys , dt'@(decor-arrow e? dom cod)) →
return $ Ys , yes-tmabsd dt' e? ignored-var dom ff cod
(Ys , dt'@(decor-decor e? x _ (meta-var-tm dom _) cod)) →
return $ Ys , yes-tmabsd dt' e? x dom (is-free-in x (decortype-to-type cod)) cod
(Ys , dt@(decor-decor _ _ _ (meta-var-tp _ _) _)) →
return $ Ys , not-tmabsd dt
-- NOTE: vv this is a type error vv
(Ys , dt@(decor-stuck _ _)) →
return $ Ys , not-tmabsd dt
-- NOTE: vv this is an internal error, if reached vv
(Ys , dt@(decor-type _)) →
return $ Ys , not-tmabsd dt
(Ys , dt@(decor-error _ _)) →
return $ Ys , not-tmabsd dt
meta-vars-unfold-tpapp' : ctxt → meta-vars → decortype → spanM is-tpabsd?
meta-vars-unfold-tpapp' Γ Xs dt =
meta-vars-subst-decortype Γ Xs dt
>>= λ where
(dt″@(decor-decor e? x _ (meta-var-tp k mtp) dt')) →
return $ yes-tpabsd dt″ e? x k (flip maybe-map mtp meta-var-sol.sol) dt'
(dt″@(decor-decor _ _ _ (meta-var-tm _ _) _)) →
return $ not-tpabsd dt″
(dt″@(decor-arrow _ _ _)) → return $ not-tpabsd dt″
(dt″@(decor-stuck _ _)) → return $ not-tpabsd dt″
(dt″@(decor-type _)) → return $ not-tpabsd dt″
(dt″@(decor-error _ _)) → return $ not-tpabsd dt″
-- errors
-- --------------------------------------------------
-- general type errors for applications
module check-term-app-tm-errors
{A : Set} (t₁ t₂ : ex-tm) (htp : type) (Xs : meta-vars) (is-locale : 𝔹) (m : checking-mode) (Γ : ctxt)
where
inapplicable : erased? → decortype → prototype → spanM (maybe A)
inapplicable e? dt pt =
spanM-add
(App-span is-locale (term-start-pos t₁) (term-end-pos t₂) m
(head-type Γ (meta-vars-subst-type Γ Xs htp)
-- :: decortype-data Γ dt
-- :: prototype-data Γ pt
:: meta-vars-data-all Γ Xs)
(just $ "The type of the head does not allow the head to be applied to "
^ h e? ^ " argument"))
>> return nothing
where h : erased? → string
h Erased = "an erased term"
h NotErased = "a term"
bad-erasure : erased? → spanM (maybe A)
bad-erasure e? =
spanM-add
(App-span is-locale (term-start-pos t₁) (term-end-pos t₂) m
(head-type Γ (meta-vars-subst-type Γ Xs htp) :: meta-vars-data-all Γ Xs)
(just (msg e?)))
>> return nothing
where
msg : erased? → string
msg Erased =
"The type computed for the head requires an explicit (non-erased) argument,"
^ " but the application is marked as erased"
msg NotErased =
"The type computed for the head requires an implicit (erased) argument,"
^ " but the application is marked as not erased"
unmatchable : (tpₓ tp : type) (msg : string) → 𝕃 tagged-val → spanM (maybe A)
unmatchable tpₓ tp msg tvs =
spanM-add
(App-span is-locale (term-start-pos t₁) (term-end-pos t₂) m
(arg-exp-type Γ tpₓ :: arg-type Γ tp :: tvs ++ meta-vars-data-all Γ Xs)
(just msg))
>> return nothing
unsolved-meta-vars : type → 𝕃 tagged-val → spanM (maybe A)
unsolved-meta-vars tp tvs =
spanM-add
(App-span tt (term-start-pos t₁) (term-end-pos t₂) m
(type-data Γ tp :: meta-vars-data-all Γ Xs ++ tvs)
(just "There are unsolved meta-variables in this maximal application"))
>> return nothing
module check-term-app-tp-errors
{A : Set} (t : ex-tm) (tp : ex-tp) (htp : type) (Xs : meta-vars) (m : checking-mode) (Γ : ctxt)
where
inapplicable : decortype → spanM (maybe A)
inapplicable dt =
spanM-add
(AppTp-span tt (term-start-pos t) (type-end-pos tp) synthesizing
(head-type Γ (meta-vars-subst-type Γ Xs htp)
-- :: decortype-data Γ dt
:: meta-vars-data-all Γ Xs)
(just "The type of the head does not allow the head to be applied to a type argument"))
>> return nothing
ctai-disagree : (ctai-sol : type) → spanM (maybe A)
ctai-disagree ctai-sol =
spanM-add (AppTp-span tt (term-start-pos t) (type-end-pos tp) m
(head-type Γ (meta-vars-subst-type Γ Xs htp)
:: contextual-type-argument Γ ctai-sol
:: meta-vars-data-all Γ Xs)
(just "The given and contextually inferred type argument differ"))
>> return nothing
-- meta-variable locality
-- --------------------------------------------------
-- for debugging -- prepend to the tvs returned by check-spine-locality if you're having trouble
private
locale-tag : ℕ → tagged-val
locale-tag n = "locale n" , [[ ℕ-to-string n ]] , []
private
is-locale : (max : 𝔹) → (locl : maybe ℕ) → 𝔹
is-locale max locl = max || maybe-else' locl ff iszero
check-spine-locality : ctxt → meta-vars → type → (max : 𝔹) → (locl : ℕ)
→ spanM (maybe (meta-vars × ℕ × 𝔹))
check-spine-locality Γ Xs tp max locl =
let new-locl = if iszero locl then num-arrows-in-type Γ tp else locl
new-Xs = if iszero locl then meta-vars-empty else Xs
left-locl = is-locale max (just locl)
in if left-locl && (~ meta-vars-solved? Xs)
then return nothing
else return (just (new-Xs , new-locl , left-locl))
-- main definition
--------------------------------------------------
data check-term-app-ret : Set where
check-term-app-return : (t~ : term) (Xs : meta-vars) (cod : decortype) (arg-mode : checking-mode) → (tvs : 𝕃 tagged-val) → check-term-app-ret
check-term-app : ctxt → (Xs : meta-vars) (Ys : 𝕃 meta-var) → (t₁ t₂ : ex-tm) → is-tmabsd → 𝔹 → spanM (maybe check-term-app-ret)
check-term-spine Γ t'@(ExApp t₁ e? t₂) pt max =
-- 1) type the applicand, extending the prototype
let pt' = proto-arrow e? pt in
check-term-spine Γ t₁ pt' ff
on-fail handleApplicandTypeError
-- 2) make sure the applicand type reveals an arrow (term abstraction)
>>=m λ ret → let mk-spine-data Xs dt locl fₕ~ = ret in
-- the meta-vars need to know the span they were introduced in
let sloc = span-loc $ ctxt.fn Γ in
-- see if the decorated type of the head `dt` reveals an arrow
meta-vars-unfold-tmapp' Γ sloc Xs dt
>>=c λ Ys tm-arrow? →
return tm-arrow? on-fail (λ _ → genInapplicableError Xs dt pt' locl)
-- if so, get the (plain, undecorated) type of the head `htp`
>>=s λ arr → let htp = decortype-to-type ∘ is-tmabsd-dt $ arr in
-- 3) make sure erasures of the applicand type + syntax of application match
checkErasuresMatch e? (is-tmabsd-e? arr) htp Xs locl
-- 4) type the application, filling in missing type arguments with meta-variables
>>=m λ _ → check-term-app Γ Xs Ys t₁ t₂ arr (islocl locl)
-- 5) check no unsolved mvars, if the application is maximal (or a locality)
>>=m λ {(check-term-app-return t₂~ Xs' rtp' arg-mode tvs) →
let rtp = decortype-to-type rtp' in
checkLocality Γ Xs' htp rtp max (pred locl) tvs
>>=m uncurry₂ λ Xs'' locl' is-loc →
-- 6) generate span
genAppSpan Γ Xs Xs' Ys pt rtp is-loc tvs
>> check-term-spine-return Xs'' rtp' locl'
-- 7) fill in solutions to meta-vars introduced here and return the rest
λ sols →
let sols = if max then Xs' else sols
-- num-sols-here = length Ys
-- sols-here = take num-sols-here sols
-- sols-rest = drop num-sols-here sols
-- as = maybe-else' (meta-vars-to-args (meta-vars-from-list sols-here)) [] id
-- tₕ~ = recompose-apps as tₕₓ~
tₕ~ = foldl (λ X t → maybe-else' (meta-vars-lookup sols (meta-var.name X)) t
λ {(meta-var-mk X' (meta-var-tp k T?) _) →
maybe-else' T? t (AppTp t ∘ meta-var-sol.sol);
(meta-var-mk X' (meta-var-tm T t?) _) →
maybe-else' t? t (AppEr t ∘ meta-var-sol.sol)})
(fₕ~ sols) Ys
app = if e? then AppEr else App in
app tₕ~ t₂~
}
where
mode = prototype-to-checking pt
expected-type-if-pt : ctxt → prototype → 𝕃 tagged-val
expected-type-if-pt Γ pt = case pt of λ where
(proto-maybe mt) → maybe-else [] (λ tp → [ expected-type Γ tp ]) mt
(proto-arrow _ _) → []
span-loc : (fn : string) → span-location
span-loc fn = fn , term-start-pos t₁ , term-end-pos t₂
islocl : ℕ → 𝔹
islocl locl = is-locale max (just $ pred locl)
handleApplicandTypeError : spanM (maybe _)
handleApplicandTypeError =
spanM-add (App-span max (term-start-pos t₁) (term-end-pos t₂) mode (expected-type-if-pt Γ pt) nothing)
>> check-term Γ t₂ nothing
>>= (const $ return nothing)
genInapplicableError : meta-vars → decortype → prototype → (locl : ℕ) → spanM (maybe _)
genInapplicableError Xs dt pt locl =
check-term-app-tm-errors.inapplicable
t₁ t₂ (decortype-to-type dt) Xs (islocl locl) mode Γ e? dt (proto-arrow e? pt)
checkErasuresMatch : (e?₁ e?₂ : erased?) → type → meta-vars → (locl : ℕ) → spanM (maybe ⊤)
checkErasuresMatch e?₁ e?₂ htp Xs locl =
if e?₁ xor e?₂
then check-term-app-tm-errors.bad-erasure t₁ t₂ htp Xs (islocl locl) mode Γ e?₁
else (return ∘ just $ triv)
checkLocality : ctxt → meta-vars → (htp rtp : type) → (max : 𝔹) (locl : ℕ) → 𝕃 tagged-val → spanM ∘ maybe $ _
checkLocality Γ Xs htp rtp max locl tvs =
check-spine-locality Γ Xs rtp max locl
on-fail check-term-app-tm-errors.unsolved-meta-vars
t₁ t₂ htp Xs (islocl locl) mode Γ rtp tvs
>>=m (return ∘ just)
genAppSpan : ctxt → (Xs Xs' : meta-vars) → (Ys : 𝕃 meta-var) → prototype → type → (is-locl : 𝔹) → 𝕃 tagged-val → spanM ⊤
genAppSpan Γ Xs Xs' Ys pt rtp is-loc tvs =
spanM-add $ elim-pair
(meta-vars-check-type-mismatch-if (prototype-to-maybe pt) Γ "synthesized" meta-vars-empty rtp)
λ tvs' → App-span is-loc (term-start-pos t₁) (term-end-pos t₂) mode
(tvs' ++ meta-vars-intro-data Γ (meta-vars-from-list Ys)
++ meta-vars-sol-data Γ Xs Xs' ++ tvs)
check-term-spine Γ t'@(ExAppTp t tp) pt max =
-- 1) type the applicand `t`
check-term-spine Γ t pt max
on-fail handleApplicandTypeError
-- 1a) Xs: spine meta-variables; dt: decorated type of t ; htp: plain type of `t`
>>=m λ ret → let mk-spine-data Xs dt locl fₕ~ = ret ; htp = decortype-to-type dt in
-- 2) make sure it reveals a type abstraction
meta-vars-unfold-tpapp' Γ Xs dt
on-fail (λ _ → genInapplicableError Xs htp dt)
-- 3) ensure the type argument has the expected kind,
-- but don't compare with the contextually infered type argument (for now)
>>=s λ ret → let mk-tpabsd dt' e? x k sol rdt = ret in
check-type Γ tp (just (meta-vars-subst-kind Γ Xs k))
-- 4) produce the result type of the application
>>= λ tp~ → subst-decortype-if Γ tp~ Xs x k sol rdt
>>= λ ret → let Xs = fst ret ; rdt = snd ret ; rtp = decortype-to-type rdt in
-- 5) generate span data
genAppTpSpan Γ Xs pt rtp htp
>> check-term-spine-return Xs rdt locl
-- 7) fill in solutions to meta-vars introduced here and return the rest
λ sols → AppTp (fₕ~ sols) tp~
--(map-snd (λ tₕ~ → AppE tₕ~ (Ttp tp~)) ∘ fₕ~)
where
mode = prototype-to-checking pt
span-loc : ctxt → span-location
span-loc Γ = (ctxt.fn Γ) , term-start-pos t , type-end-pos tp
handleApplicandTypeError : spanM ∘ maybe $ spine-data
handleApplicandTypeError =
[- AppTp-span tt (term-start-pos t) (type-end-pos tp) synthesizing [] nothing -]
check-type Γ tp nothing >>= λ _ → return nothing
genInapplicableError : meta-vars → type → decortype → spanM ∘ maybe $ spine-data
genInapplicableError Xs htp dt =
check-term-app-tp-errors.inapplicable t tp htp Xs mode Γ dt
subst-decortype-if : ctxt → type → meta-vars → var → kind → maybe type → decortype → spanM (meta-vars × decortype)
subst-decortype-if Γ tp Xs x k sol rdt =
if ~ is-hole tp
then subst-decortype Γ tp x rdt >>= (λ res → return (Xs , res))
else let sol = maybe-map (λ t → mk-meta-var-sol t checking) sol
Y = meta-var-fresh-tp Xs x (span-loc Γ) (k , sol)
Xs' = meta-vars-add Xs Y
in subst-decortype Γ (meta-var-to-type-unsafe Y) x rdt >>= λ rdt' → return (Xs' , rdt')
genAppTpSpan : ctxt → meta-vars → prototype → (ret-tp head-tp : type) → spanM ⊤
genAppTpSpan Γ Xs pt ret-tp head-tp = spanM-add ∘ elim-pair
-- check for a type mismatch, if there even is an expected type
(meta-vars-check-type-mismatch-if (prototype-to-maybe pt) Γ "synthesizing" Xs ret-tp) $
-- then take the generated 𝕃 tagged-val and add to the span
λ tvs → AppTp-span ff (term-start-pos t) (type-end-pos tp) mode $
tvs {- ++ [ head-type Γ head-tp ] -}
++ meta-vars-data-all Γ Xs
{- ++ (prototype-data Γ tp :: [ decortype-data Γ dt ]) -}
check-term-spine Γ (ExParens _ t _) pt max =
check-term-spine Γ t pt max
check-term-spine Γ t pt max =
check-term Γ t nothing >>=c λ t~ htp →
let locl = num-arrows-in-type Γ htp
in match-prototype Γ meta-vars-empty ff htp pt
-- NOTE: it is an invariant that the variables solved in the
-- solution set of the fst of this are a subset of the variables given
-- to match-* -- that is, for (σ , W) = match-prototype ...
-- we have dom(σ) = ∅
>>= λ ret → let dt = match-proto-dectp ret in
check-term-spine-return meta-vars-empty dt locl λ _ → t~
-- check-term-app
-- --------------------------------------------------
--
-- If `dom` has unsolved meta-vars in it, synthesize argument t₂ and try to solve for them.
-- Otherwise, check t₂ against a fully known expected type
check-term-app Γ Xs Zs t₁ t₂ (mk-tmabsd dt e? x dom occurs cod) is-locl =
let Xs' = meta-vars-add* Xs Zs ; tp = decortype-to-type dt in
-- 1) either synth or check arg type, depending on available info
-- checking "exits early", as well as failure
checkArgWithMetas Xs' tp (genAppRetType Γ)
on-fail return
-- 2) match *synthesized* type with expected (partial) type
>>=s uncurry₂ λ rdt t₂~ atp → match-types Γ Xs' empty-trie match-unfolding-both dom atp
>>= (handleMatchResult Xs' t₂~ atp tp rdt)
where
mode = synthesizing
genAppRetType : ctxt → term → spanM decortype
genAppRetType Γ t₂~ = if occurs then subst-decortype Γ t₂~ x cod else return cod
genAppRetTypeHole : ctxt → spanM decortype
genAppRetTypeHole Γ = if occurs then subst-decortype Γ (Hole posinfo-gen) x cod else return cod
checkArgWithMetas : meta-vars → type → (term → spanM decortype) → spanM (maybe check-term-app-ret ∨ (decortype × term × type))
checkArgWithMetas Xs' tp rdt-f =
-- check arg against fully known type
if ~ meta-vars-are-free-in-type Xs' dom
then (check-term Γ t₂ (just dom) >>= λ t₂~ →
rdt-f t₂~ >>= λ rdt →
return (inj₁ (just $ check-term-app-return t₂~ Xs' rdt mode [])))
-- synthesize type for the argument
else (check-term Γ t₂ nothing >>=c λ t tp →
rdt-f t >>= λ rdt →
return (inj₂ $ rdt , t , tp))
handleMatchResult : meta-vars → (t₂~ : term) → (atp tp : type) → decortype → match-error-t meta-vars → spanM ∘ maybe $ check-term-app-ret
handleMatchResult Xs' t₂~ atp tp rdt (match-error (msg , tvs)) =
check-term-app-tm-errors.unmatchable
t₁ t₂ tp Xs' is-locl mode Γ dom atp msg tvs
handleMatchResult Xs' t₂~ atp tp rdt (match-ok Xs) =
meta-vars-subst-decortype' ff Γ Xs rdt
>>= λ rdt → return ∘ just $ check-term-app-return t₂~ Xs rdt mode []
match-unfolding-next : match-unfolding-state → match-unfolding-state
match-unfolding-next match-unfolding-both = match-unfolding-both
match-unfolding-next match-unfolding-approx = match-unfolding-approx
match-unfolding-next match-unfolding-hnf = match-unfolding-both
module m-err = meta-vars-match-errors
check-type-for-match : ctxt → type → spanM $ match-error-t kind
check-type-for-match Γ tp =
(with-clear-error $
check-type (qualified-ctxt Γ) (resugar tp) nothing >>=c λ _ k → return (match-ok $ k)) >>=spand return
-- match-types
-- --------------------------------------------------
match-types-ok : meta-vars → spanM $ match-error-t meta-vars
match-types-ok = return ∘ match-ok
match-types-error : match-error-data → spanM $ match-error-t meta-vars
match-types-error = return ∘ match-error
match-types Γ Xs Ls match-unfolding-both tpₓ tp =
match-types Γ Xs Ls match-unfolding-approx tpₓ tp
>>= λ where
(match-ok Xs) → match-types-ok Xs
(match-error msg) →
match-types Γ Xs Ls match-unfolding-hnf
(hnf Γ unfold-head-elab tpₓ)
(hnf Γ unfold-head-elab tp)
match-types Γ Xs Ls unf tpₓ@(TpVar x) tp =
-- check that x is a meta-var
maybe-else' (meta-vars-lookup-with-kind Xs x)
-- if not, make sure the two variables are the same
-- TODO: above assumes no term meta-variables
(return (err⊎-guard (~ conv-type Γ tpₓ tp) m-err.e-match-failure
>> match-ok Xs))
-- scope check the solution
λ ret → let X = fst ret ; kₓ = snd ret in
if are-free-in Ls tp then
match-types-error $ m-err.e-meta-scope Γ tpₓ tp
else (check-type-for-match Γ tp
>>=s λ k → match-kinds Γ Xs empty-trie match-unfolding-both kₓ k
on-fail (λ _ → return ∘ match-error $ m-err.e-bad-sol-kind Γ x tp)
>>=s λ Xs → return (meta-vars-solve-tp Γ Xs x tp synthesizing)
>>=s λ Xs → match-types-ok $ meta-vars-update-kinds Γ Xs Xs)
match-types Γ Xs Ls unf (TpApp tpₓ₁ (Ttp tpₓ₂)) (TpApp tp₁ (Ttp tp₂)) =
match-types Γ Xs Ls unf tpₓ₁ tp₁
>>=s λ Xs' → match-types Γ Xs' Ls (match-unfolding-next unf) tpₓ₂ tp₂
match-types Γ Xs Ls unf (TpApp tpₓ (Ttm tmₓ)) (TpApp tp (Ttm tm)) =
match-types Γ Xs Ls unf tpₓ tp
>>=s λ Xs' →
return $ if ~ conv-term Γ tmₓ tm
then (match-error m-err.e-match-failure) else
match-ok Xs'
match-types Γ Xs Ls unf tpₓ'@(TpAbs bₓ xₓ tkₓ tpₓ) tp'@(TpAbs b x tk tp) =
if bₓ xor b
then (match-types-error m-err.e-match-failure)
else (match-tpkds Γ Xs Ls (match-unfolding-next unf) tkₓ tk >>=s λ Xs' →
match-types (Γ→Γ' Γ) Xs' Ls' (match-unfolding-next unf) tpₓ tp)
where
Γ→Γ' : ctxt → ctxt
Γ→Γ' Γ = ctxt-rename xₓ x (ctxt-var-decl-if x Γ)
Ls' = stringset-insert Ls x
match-types Γ Xs Ls unf (TpIota xₓ mₓ tpₓ) (TpIota x m tp) =
match-types Γ Xs Ls (match-unfolding-next unf) mₓ m
>>=s λ Xs →
match-types (Γ→Γ' Γ) Xs Ls' (match-unfolding-next unf) tpₓ tp
where
Γ→Γ' : ctxt → ctxt
Γ→Γ' Γ = ctxt-rename xₓ x (ctxt-var-decl-if x Γ)
Ls' = stringset-insert Ls x
match-types Γ Xs Ls unf (TpEq t₁ₓ t₂ₓ) (TpEq t₁ t₂) =
if ~ conv-term Γ t₁ₓ t₁
then match-types-error $ m-err.e-match-failure else
if ~ conv-term Γ t₂ₓ t₂
then match-types-error $ m-err.e-match-failure else
match-types-ok Xs
match-types Γ Xs Ls unf (TpLam xₓ atkₓ tpₓ) (TpLam x atk tp) =
match-tpkds Γ Xs Ls (match-unfolding-next unf) atkₓ atk >>=s λ Xs →
match-types (Γ→Γ' Γ) Xs Ls' (match-unfolding-next unf) tpₓ tp
where
Γ→Γ' : ctxt → ctxt
Γ→Γ' Γ = ctxt-rename xₓ x (ctxt-var-decl-if x Γ)
Ls' = stringset-insert Ls x
match-types Γ Xs Ls unf tpₓ tp =
match-types-error m-err.e-match-failure
-- match-kinds
-- --------------------------------------------------
-- match-kinds-norm: match already normalized kinds
match-kinds-norm : ctxt → meta-vars → local-vars → match-unfolding-state → (kₓ k : kind) → spanM $ match-error-t meta-vars
-- kind pi
match-kinds-norm Γ Xs Ls uf (KdAbs xₓ tkₓ kₓ) (KdAbs x tk k) =
match-tpkds Γ Xs Ls uf tkₓ tk >>=s λ Xs →
match-kinds (Γ→Γ' Γ) Xs Ls' uf kₓ k
where
Γ→Γ' = ctxt-rename xₓ x ∘ ctxt-var-decl-if x
Ls' = stringset-insert Ls x
match-kinds-norm Γ Xs Ls uf KdStar KdStar =
match-types-ok $ Xs
match-kinds-norm Γ Xs Ls uf kₓ k =
match-types-error $ m-err.e-matchk-failure -- m-err.e-kind-ineq Γ kₓ k
match-kinds Γ Xs Ls uf kₓ k =
match-kinds-norm Γ Xs Ls uf
(hnf Γ unfold-head-elab kₓ)
(hnf Γ unfold-head-elab k)
-- match-tk
-- --------------------------------------------------
match-tpkds Γ Xs Ls uf (Tkk kₓ) (Tkk k) = match-kinds Γ Xs Ls uf kₓ k
match-tpkds Γ Xs Ls uf (Tkt tpₓ) (Tkt tp) = match-types Γ Xs Ls uf tpₓ tp
match-tpkds Γ Xs Ls uf tkₓ tk =
match-types-error m-err.e-matchk-failure -- m-err.e-tk-ineq Γ tkₓ tk
-- match-prototype
-- --------------------------------------------------
match-prototype-err : type → prototype → spanM match-prototype-data
match-prototype-err tp pt = return $ mk-match-prototype-data meta-vars-empty (decor-error tp pt) tt
{-
--------------------
Xs ⊢? T ≔ ⁇ ⇒ (∅ , T)
-}
match-prototype Γ Xs uf tp (proto-maybe nothing) =
return $ mk-match-prototype-data Xs (decor-type tp) ff
{-
Xs ⊢= T ≔ S ⇒ σ
--------------------
Xs ⊢? T ≔ S ⇒ (σ , T)
-}
match-prototype Γ Xs uf tp pt@(proto-maybe (just tp')) =
match-types Γ Xs empty-trie match-unfolding-both tp tp'
on-fail (λ _ → return $ mk-match-prototype-data Xs (decor-error tp pt) tt)
>>=s λ Xs' → return $ mk-match-prototype-data Xs' (decor-type tp) ff
{-
Xs,X ⊢? T ≔ ⁇ → P ⇒ (σ , W)
-----------------------------------------------
Xs ⊢? ∀ X . T ≔ ⁇ → P ⇒ (σ - X , ∀ X = σ(X) . W)
-}
match-prototype Γ Xs uf (TpAbs bₓ x (Tkk k) tp) pt'@(proto-arrow e? pt) =
-- 1) generate a fresh meta-var Y, add it to the meta-vars, and rename
-- occurences of x in tp to Y
let ret = meta-vars-add-from-tpabs Γ missing-span-location Xs Erased x k tp
Y = fst ret ; Xs' = snd ret ; tp' = subst Γ (meta-var-to-type-unsafe Y) x tp
-- 2) match the body against the original prototype to generate a decorated type
-- and find some solutions
in match-prototype Γ Xs' ff tp' pt'
>>= λ ret →
let mk-match-prototype-data Xs' dt err = ret
Y' = maybe-else' (meta-vars-lookup Xs' (meta-var-name Y)) Y λ Y → Y
x' = subst-rename-var-if{TYPE} Γ empty-renamectxt x empty-trie tp'
-- 3) replace the meta-vars with the bound type variable
in subst-decortype (ctxt-var-decl x' Γ) (TpVar x') (meta-var-name Y) dt
-- 4) leave behind the solution for Y as a decoration and drop Y from Xs
>>= λ dt' →
let sort' = meta-var.sort (meta-var-set-src Y' checking)
dt″ = decor-decor Erased x (Tkk k) sort' dt' in
return $ mk-match-prototype-data (meta-vars-remove Xs' Y) dt″ err
{-
Xs ⊢? T ≔ P ⇒ (σ , P)
-----------------------------
Xs ⊢? S → T ≔ ⁇ → P ⇒ (σ , P)
-}
match-prototype Γ Xs uf (TpAbs b x (Tkt dom) cod) (proto-arrow e? pt) =
match-prototype Γ Xs ff cod pt
>>= λ ret →
let mk-match-prototype-data Xs dt err = ret
dt' = decor-decor b x (Tkt dom) (meta-var-tm dom nothing) dt
in return $ if b xor e?
then mk-match-prototype-data meta-vars-empty dt' tt
else mk-match-prototype-data Xs dt' err
{-
X ∈ Xs
-----------------------------------
Xs ⊢? X ≔ ⁇ → P ⇒ (σ , (X , ⁇ → P))
-}
match-prototype Γ Xs tt tp@(TpVar x) pt@(proto-arrow _ _) =
return $ mk-match-prototype-data Xs (decor-stuck tp pt) ff
-- everything else...
-- Types for which we should keep digging
match-prototype Γ Xs ff tp@(TpVar x) pt@(proto-arrow _ _) =
match-prototype Γ Xs tt (hnf Γ unfold-head-elab tp) pt
match-prototype Γ Xs ff tp@(TpApp _ _) pt@(proto-arrow _ _) =
match-prototype Γ Xs tt (hnf Γ unfold-head-elab tp) pt
-- types for which we should suspend disbelief
match-prototype Γ Xs tt tp@(TpApp _ _) pt@(proto-arrow _ _) =
return $ mk-match-prototype-data Xs (decor-stuck tp pt) ff
-- types which clearly do not match the prototype
match-prototype Γ Xs uf tp@(TpEq _ _) pt@(proto-arrow _ _) =
match-prototype-err tp pt
match-prototype Γ Xs uf tp@(TpHole _) pt@(proto-arrow _ _) =
match-prototype-err tp pt
match-prototype Γ Xs uf tp@(TpLam _ _ _) pt@(proto-arrow _ _) =
match-prototype-err tp pt
match-prototype Γ Xs uf tp@(TpIota _ _ _) pt@(proto-arrow _ _) =
match-prototype-err tp pt
| {
"alphanum_fraction": 0.6303430438,
"avg_line_length": 42.2791366906,
"ext": "agda",
"hexsha": "67117f87cb0bc3917d5606c9b0c448ed58673c58",
"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": "bf62d3d338809a30bc21a1affed07936b1ac60ac",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "ice1k/cedille",
"max_forks_repo_path": "src/type-inf.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "bf62d3d338809a30bc21a1affed07936b1ac60ac",
"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": "ice1k/cedille",
"max_issues_repo_path": "src/type-inf.agda",
"max_line_length": 143,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "bf62d3d338809a30bc21a1affed07936b1ac60ac",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "ice1k/cedille",
"max_stars_repo_path": "src/type-inf.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 9683,
"size": 29384
} |
module LocalChoice where
open import IO using (run; putStrLn; mapM′; _>>_)
open import Coinduction using (♯_)
open import Data.Nat as ℕ using (ℕ; suc; zero)
open import Data.Pos as ℕ⁺ using (ℕ⁺; suc)
open import Data.String using (String)
open import Data.List using (List; []; _∷_; map)
open import Data.Colist using (fromList)
open import Function using (_$_; _∘_)
open import Data.Environment
open import nodcap.Base
open import nodcap.Typing
open import nodcap.LocalChoice
open import nodcap.Norm
open import nodcap.Show renaming (showTerm to show)
open import nodcap.NF.Show renaming (showTerm to showNF)
Bit : Type
Bit = 𝟏 ⊕ 𝟏
bit₁ bit₂ : ⊢ Bit ∷ []
bit₁ = sel₁ halt
bit₂ = sel₂ halt
randomBit : ⊢ Bit ∷ []
randomBit = bit₁ or bit₂
main = run (mapM′ putStrLn (fromList strs))
where
strs = "Process:"
∷ show randomBit
∷ "Result:"
∷ map showNF (nfND randomBit)
-- -}
-- -}
-- -}
-- -}
-- -}
| {
"alphanum_fraction": 0.6802139037,
"avg_line_length": 22.2619047619,
"ext": "agda",
"hexsha": "bb832466507c9d6cc468d790ec3de6d4996270f3",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2018-09-05T08:58:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-05T08:58:13.000Z",
"max_forks_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "pepijnkokke/nodcap",
"max_forks_repo_path": "src/cpnd1/LocalChoice.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2",
"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": "pepijnkokke/nodcap",
"max_issues_repo_path": "src/cpnd1/LocalChoice.agda",
"max_line_length": 56,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "wenkokke/nodcap",
"max_stars_repo_path": "src/cpnd1/LocalChoice.agda",
"max_stars_repo_stars_event_max_datetime": "2019-09-24T20:16:35.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-09-05T08:58:11.000Z",
"num_tokens": 291,
"size": 935
} |
module SN where
open import Library
open import Syntax
open import RenamingAndSubstitution
-- Reduction
data _↦_ {Γ} : ∀{a} (t t' : Tm Γ a) → Set where
β : ∀{a b} {t : Tm (Γ , a) b} {u} → app (abs t) u ↦ sub0 t u
abs : ∀{a b} {t t' : Tm (Γ , a) b} (r : t ↦ t') → abs t ↦ abs t'
appl : ∀{a b} {t t' : Tm Γ (a ⇒ b)} {u} (r : t ↦ t') → app t u ↦ app t' u
appr : ∀{a b} {t : Tm Γ (a ⇒ b)} {u u'} (r : u ↦ u') → app t u ↦ app t u'
ren↦ : ∀{Γ Δ a} (ρ : Ren Γ Δ) {t t' : Tm Δ a} (r : t ↦ t') → ren ρ t ↦ ren ρ t'
-- ren↦ {Γ} {Δ} {a} ρ {t} {t'} r = {!r!}
ren↦ {Γ} {Δ} ρ β = {!!}
ren↦ {Γ} {Δ} ρ (abs r) = abs (ren↦ (liftr ρ) r)
ren↦ {Γ} {Δ} ρ (appl r) = {!!}
ren↦ {Γ} {Δ} ρ (appr r) = {!!}
ren↦inv : ∀{Γ Δ a} (ρ : Ren Γ Δ) (t : Tm Δ a) {t' : Tm Γ a} (r : ren ρ t ↦ t') →
∃ λ (u : Tm Δ a) → (t ↦ u) × (t' ≡ ren ρ u)
ren↦inv ρ (var x) ()
ren↦inv ρ (app (abs t) t₁) β = sub0 t t₁ , β , {!refl!}
ren↦inv ρ (abs t) (abs r) with ren↦inv (liftr ρ) t r
ren↦inv ρ (abs t) (abs r) | u , r' , e = abs u , abs r' , cong abs e
ren↦inv ρ (app t t₁) (appl r) with ren↦inv ρ t r
ren↦inv ρ (app t t₁) (appl r) | u , r' , refl = app u t₁ , appl r' , refl
ren↦inv ρ (app t t₁) (appr r) with ren↦inv ρ t₁ r
... | u , r' , refl = app t u , appr r' , refl
-- Strongly normalizing terms
data SN {Γ : Cxt} {a : Ty} (t : Tm Γ a) : Set where
sn : (∀ t' (r : t ↦ t') → SN t') → SN t
-- SN is closed under renaming
renSN : ∀{Γ Δ a} (ρ : Ren Γ Δ) {t : Tm Δ a} (s : SN t) → SN (ren ρ t)
renSN ρ (sn f) = sn λ _ r → case ren↦inv ρ _ r of
λ{ (t'' , r' , refl) → renSN ρ (f t'' r') }
-- Strong head reduction (weak head reduction that preserves SN under expansion)
data _s↦_ {Γ} : ∀{a} (t t' : Tm Γ a) → Set where
β : ∀{a b} {t : Tm (Γ , a) b} {u} (s : SN u) → app (abs t) u s↦ sub0 t u
appl : ∀{a b} {t t' : Tm Γ (a ⇒ b)} {u} (r : t s↦ t') → app t u s↦ app t' u
-- Strong head reduction is closed under renaming
rens↦ : ∀{Γ Δ a} (ρ : Ren Γ Δ) {t t' : Tm Δ a} (r : t s↦ t') → ren ρ t s↦ ren ρ t'
rens↦ ρ (β s) = {!β!}
-- Need lemma:
-- app (abs (ren (liftr ρ) .t)) (ren ρ .u) s↦
-- ren ρ (sub (subId , .u) .t)rens↦ ρ (appl r) = appl (rens↦ ρ r)
-- SN is closed under strong head expansion
s↦SN : ∀{Γ a}{t t' : Tm Γ a} (r : t s↦ t') (s : SN t') → SN t
-- s↦SN r s = sn λ t' → λ{ β → {!!} ; (abs r') → {!!} ; (appl r') → {!!} ; (appr r') → {!!}}
s↦SN (β s') s = sn (λ t' → λ{ β → s ; (appl (abs r)) → {!!} ; (appr r) → {!!}})
s↦SN (appl r) s = {!!}
-- Reducibility: Kripke logical predicate
Red : (a : Ty) {Γ : Cxt} (t : Tm Γ a) → Set
Red ★ {Γ} t = SN t
Red (a ⇒ b) {Γ} t = ∀{Γ'}(ρ : Ren Γ' Γ) u (s : Red a u) → Red b (app (ren ρ t) u)
-- Reducibility is closed under renaming
renRed : ∀{Γ Δ a} (ρ : Ren Γ Δ) {t : Tm Δ a} (p : Red a t) → Red a (ren ρ t)
renRed {Γ} {Δ} {★} ρ {t} p = renSN ρ p
renRed {Γ} {Δ} {a ⇒ b} ρ {t} p = λ ρ₁ u s →
subst (λ z → Red b (app z u)) (rencomp ρ₁ ρ t)
(p (renComp ρ₁ ρ) u s)
-- Reducibility is closed under strong head expansion
expRed : ∀{Γ a} {t t' : Tm Γ a} (r : t s↦ t') (p : Red a t') → Red a t
expRed {Γ} {★} {t} {t'} r p = s↦SN r p
expRed {Γ} {a ⇒ b} {t} {t'} r p ρ u s = expRed (appl {!!}) (p ρ u s)
| {
"alphanum_fraction": 0.4732872407,
"avg_line_length": 37.880952381,
"ext": "agda",
"hexsha": "346bdc0ed962f3f6f891116411ec811d770ffff1",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2018-02-23T18:22:17.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-11-10T16:44:52.000Z",
"max_forks_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "ryanakca/strong-normalization",
"max_forks_repo_path": "agda/SN.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2",
"max_issues_repo_issues_event_max_datetime": "2018-02-20T14:54:18.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-02-14T16:42:36.000Z",
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "ryanakca/strong-normalization",
"max_issues_repo_path": "agda/SN.agda",
"max_line_length": 92,
"max_stars_count": 32,
"max_stars_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "ryanakca/strong-normalization",
"max_stars_repo_path": "agda/SN.agda",
"max_stars_repo_stars_event_max_datetime": "2021-03-05T12:12:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-05-22T14:33:27.000Z",
"num_tokens": 1601,
"size": 3182
} |
{-# OPTIONS --two-level --cubical-compatible #-}
open import Agda.Primitive
data D₁ : SSet → SSet (lsuc lzero) where
c : (@0 A : SSet) → A → D₁ A
data D₂ : Set → SSet (lsuc lzero) where
c : (@0 A : Set) → A → D₂ A
| {
"alphanum_fraction": 0.592760181,
"avg_line_length": 22.1,
"ext": "agda",
"hexsha": "ad73ec5a8958ff1c660d07a10b03842f62cbd08d",
"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/Issue5434.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/Issue5434.agda",
"max_line_length": 48,
"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/Succeed/Issue5434.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 84,
"size": 221
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import Haskell.Modules.RWS.RustAnyHow
open import LibraBFT.Base.Types
open import LibraBFT.Impl.Consensus.EpochManagerTypes
import LibraBFT.Impl.OBM.ECP-LBFT-OBM-Diff.ECP-LBFT-OBM-Diff-0 as ECP-LBFT-OBM-Diff-0
open import LibraBFT.Impl.OBM.Logging.Logging
import LibraBFT.Impl.Storage.DiemDB.DiemDB as DiemDB
import LibraBFT.Impl.Types.EpochChangeProof as EpochChangeProof
open import LibraBFT.ImplShared.Consensus.Types
open import LibraBFT.ImplShared.Interface.Output
open import LibraBFT.ImplShared.Util.Dijkstra.All
open import Optics.All
open import Util.Prelude
------------------------------------------------------------------------------
open import Data.String using (String)
module LibraBFT.Impl.OBM.ECP-LBFT-OBM-Diff.ECP-LBFT-OBM-Diff-1 where
------------------------------------------------------------------------------
postulate -- TODO-1 : nub (remove duplicates)
nub : ∀ {A : Set} → List A → List A
------------------------------------------------------------------------------
amIMemberOfCurrentEpoch : Author → List Author → Bool
amIMemberOfCurrentEpochM : LBFT Bool
------------------------------------------------------------------------------
e_SyncManager_insertQuorumCertM_commit : LedgerInfoWithSignatures → LBFT (Either ErrLog Unit)
e_SyncManager_insertQuorumCertM_commit liws =
ifD (not ECP-LBFT-OBM-Diff-0.enabled)
then (do
rcvrs ← use (lRoundManager ∙ rmObmAllAuthors)
--act (BroadcastEpochChangeProof (EpochChangeProof∙new (liws ∷ []) false) rcvrs) -- TODO-1
ok unit)
else do
{-
LBFT-OBM-DIFF
A SyncInfo is sent BEFORE an EpochChangeProof.
Only sent to members of current epoch (not the one the EpochChangeProof will transition to).
This is needed since the highest committed QC from the initial committer/leader of
the EPOCHCHANGE transaction needs to be given to followers so they will also
commit the EPOCHCHANGE transaction.
Note: This is similar to how the QC is carried in a ProposalMsg.
-}
rcvrs ← use (lRoundManager ∙ rmObmAllAuthors)
syncInfo ← SyncInfo∙new <$> use (lBlockStore ∙ bsHighestQuorumCert)
<*> use (lBlockStore ∙ bsHighestCommitCert)
<*> use (lBlockStore ∙ bsHighestTimeoutCert)
act (BroadcastSyncInfo syncInfo rcvrs)
-- LBFT-OBM-DIFF : PUSH: when sending an ECP when committing an epoch change,
-- send all epoch ending ledger info (not just the current one)
-- so the receiver will be up-to-date.
-- TODO : optimize: let receiver PULL its gaps.
db ← use (lBlockStore ∙ bsStorage ∙ msObmDiemDB)
maybeSD (liws ^∙ liwsLedgerInfo ∙ liNextEpochState) (bail fakeErr {-"liNextEpochState" ∷ "Nothing" ∷ []-}) $ λ es → do
let newRcvrs = es ^∙ esVerifier ∙ vvObmAuthors
allRcvrs = nub (rcvrs ++ newRcvrs)
eitherS (DiemDB.getEpochEndingLedgerInfos db ({-Epoch-} 1) (liws ^∙ liwsEpoch + 1))
bail
(λ (liwss , b) -> do
-- act (BroadcastEpochChangeProof lEC (EpochChangeProof.new liwss b) allRcvrs) -- TODO-1
ok unit)
where
here' : List String → List String
here' t = "e_SyncManager_InsertQuorumCertM_commit" ∷ t
------------------------------------------------------------------------------
e_RoundState_processLocalTimeoutM : Epoch → Round → LBFT Bool
e_RoundState_processLocalTimeoutM e r =
ifD not ECP-LBFT-OBM-Diff-0.enabled
then yes'
else
-- LBFT-OBM-DIFF : do not broadcast timeouts if not member of epoch
ifMD amIMemberOfCurrentEpochM
yes'
(do
logInfo fakeInfo -- ["not a member of Epoch", "ignoring timeout", lsE e, lsR r]
pure false)
where
yes' : LBFT Bool
yes' = do
logInfo fakeInfo -- InfoRoundTimeout e r
pure true
------------------------------------------------------------------------------
-- TODO-1 : use EitherD
e_EpochManager_doECP_waitForRlec : EpochManager → EpochChangeProof → Either ErrLog Bool
e_EpochManager_doECP_waitForRlec self ecp =
if not ECP-LBFT-OBM-Diff-0.enabled
then pure true
else do
rm ← self ^∙ emObmRoundManager
e ← self ^∙ emEpoch
maybeS (rm ^∙ rmObmMe)
(Left fakeErr {-["e_EpochManager_doECP_waitForRlec", "rmObmMe", "Nothing"]-})
$ λ me → let m = amIMemberOfCurrentEpoch me (rm ^∙ rmObmAllAuthors)
in pure (m ∧ (EpochChangeProof.obmLastEpoch ecp == e))
------------------------------------------------------------------------------
module e_EpochManager_startNewEpoch where
VariantFor : ∀ {ℓ} EL → EL-func {ℓ} EL
VariantFor EL =
EpochManager → EpochChangeProof
→ EL ErrLog EpochManager
step₀ : VariantFor EitherD
step₀ self ecp =
ifD not ECP-LBFT-OBM-Diff-0.enabled
then pure self
else do
-- LBFT-OBM-DIFF: store all the epoch ending LedgerInfos sent in ECP
-- (to avoid gaps -- from when a node is not a member).
db ← (foldM) (\db l → DiemDB.saveTransactions db (just l))
(self ^∙ emStorage ∙ msObmDiemDB)
(ecp ^∙ ecpLedgerInfoWithSigs)
pure (self & emStorage ∙ msObmDiemDB ∙~ db)
e_EpochManager_startNewEpoch : e_EpochManager_startNewEpoch.VariantFor Either
e_EpochManager_startNewEpoch em = toEither ∘ e_EpochManager_startNewEpoch.step₀ em
e_EpochManager_startNewEpoch-D : e_EpochManager_startNewEpoch.VariantFor EitherD
e_EpochManager_startNewEpoch-D em = fromEither ∘ e_EpochManager_startNewEpoch em
------------------------------------------------------------------------------
-- TODO-1 : use EitherD
e_EpochManager_checkEpc : EpochManager → EpochChangeProof → Either ErrLog Unit
e_EpochManager_checkEpc self ecp =
if (not ECP-LBFT-OBM-Diff-0.enabled)
then checkEpcNot
else checkEpcEnable
where
here' : List String → List String
checkEpcNot : Either ErrLog Unit
checkEpcNot = case EpochChangeProof.epoch ecp of λ where
(Left e) → Left (withErrCtx (here' []) e)
(Right msgEpoch) → do
e ← self ^∙ emEpoch
if msgEpoch == e
then pure unit
else Left fakeErr
--(ErrInfo (lEC, InfoL (here ["unexpected epoch proof", lsE msgEpoch, lsE e])))
-- LBFT-OBM-DIFF : ignore it if it doesn't help
checkEpcEnable : Either ErrLog Unit
checkEpcEnable = do
epoch ← self ^∙ emEpoch
if-dec (EpochChangeProof.obmLastEpoch ecp <? epoch)
then Left fakeErr
--(ErrInfo (lEC, InfoL (here [ "ecp last", lsE (EpochChangeProof.obmLastEpoch ecp)
-- , "< ours" , lsE epoch ])))
else pure unit
here' t = "e_EpochManager_checkEpc" ∷ t
------------------------------------------------------------------------------
-- TODO-1 : use EitherD
e_EpochManager_processMessage_ISyncInfo : EpochManager → SyncInfo → Either ErrLog Unit
e_EpochManager_processMessage_ISyncInfo self si = do
e ← self ^∙ emEpoch
grd‖ not ECP-LBFT-OBM-Diff-0.enabled ≔ pure unit
‖ si ^∙ siEpoch == e ≔ pure unit
‖ otherwise≔
Left fakeErr
-- ["si epoch", lsE (si^.siEpoch), "/=", "ours", lsE e]
------------------------------------------------------------------------------
amIMemberOfCurrentEpochM =
use (lRoundManager ∙ rmObmMe) >>= λ where
nothing → do
logErr fakeErr -- no identity
pure false
(just me) →
amIMemberOfCurrentEpoch <$> pure me <*> use (lRoundManager ∙ rmObmAllAuthors)
amIMemberOfCurrentEpoch = elem
| {
"alphanum_fraction": 0.6114674192,
"avg_line_length": 40.6041666667,
"ext": "agda",
"hexsha": "cfea9cfd0b66a5dbcf4ebb1ae9a9ca7b32891348",
"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/OBM/ECP-LBFT-OBM-Diff/ECP-LBFT-OBM-Diff-1.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/OBM/ECP-LBFT-OBM-Diff/ECP-LBFT-OBM-Diff-1.agda",
"max_line_length": 122,
"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/OBM/ECP-LBFT-OBM-Diff/ECP-LBFT-OBM-Diff-1.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2163,
"size": 7796
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Data.Sum.Base where
open import Cubical.Relation.Nullary
open import Cubical.Core.Everything
private
variable
ℓ ℓ' : Level
A B C D : Type ℓ
data _⊎_ (A : Type ℓ)(B : Type ℓ') : Type (ℓ-max ℓ ℓ') where
inl : A → A ⊎ B
inr : B → A ⊎ B
rec : {C : Type ℓ} → (A → C) → (B → C) → A ⊎ B → C
rec f _ (inl x) = f x
rec _ g (inr y) = g y
elim : {C : A ⊎ B → Type ℓ} → ((a : A) → C (inl a)) → ((b : B) → C (inr b))
→ (x : A ⊎ B) → C x
elim f _ (inl x) = f x
elim _ g (inr y) = g y
map : (A → C) → (B → D) → A ⊎ B → C ⊎ D
map f _ (inl x) = inl (f x)
map _ g (inr y) = inr (g y)
_⊎?_ : {P Q : Type ℓ} → Dec P → Dec Q → Dec (P ⊎ Q)
P? ⊎? Q? with P? | Q?
... | yes p | _ = yes (inl p)
... | no _ | yes q = yes (inr q)
... | no ¬p | no ¬q = no λ
{ (inl p) → ¬p p
; (inr q) → ¬q q
}
| {
"alphanum_fraction": 0.4689655172,
"avg_line_length": 22.8947368421,
"ext": "agda",
"hexsha": "33b5fb021693171e147b35fbf486f42d4d35c2f6",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Data/Sum/Base.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Data/Sum/Base.agda",
"max_line_length": 76,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/Data/Sum/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 414,
"size": 870
} |
-- Generated by src/templates/TemplatesCompiler
module templates where
open import cedille-types
{-# FOREIGN GHC import qualified Templates #-}
-- src/templates/Mendler.ced
postulate
templateMendler : start
{-# COMPILE GHC templateMendler = Templates.templateMendler #-}
-- src/templates/MendlerSimple.ced
postulate
templateMendlerSimple : start
{-# COMPILE GHC templateMendlerSimple = Templates.templateMendlerSimple #-}
| {
"alphanum_fraction": 0.7906976744,
"avg_line_length": 25.2941176471,
"ext": "agda",
"hexsha": "c27474c4b1f4c782ae5c42931e7628132ea337f4",
"lang": "Agda",
"max_forks_count": 34,
"max_forks_repo_forks_event_max_datetime": "2022-02-20T18:33:16.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-17T11:51:36.000Z",
"max_forks_repo_head_hexsha": "75f72bf2e41ac4042efc3128fa9958d4cd69b947",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mudathirmahgoub/cedille",
"max_forks_repo_path": "src/templates.agda",
"max_issues_count": 123,
"max_issues_repo_head_hexsha": "75f72bf2e41ac4042efc3128fa9958d4cd69b947",
"max_issues_repo_issues_event_max_datetime": "2022-01-12T03:51:28.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-09-17T10:53:20.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mudathirmahgoub/cedille",
"max_issues_repo_path": "src/templates.agda",
"max_line_length": 75,
"max_stars_count": 328,
"max_stars_repo_head_hexsha": "75f72bf2e41ac4042efc3128fa9958d4cd69b947",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mudathirmahgoub/cedille",
"max_stars_repo_path": "src/templates.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-26T10:33:07.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-09-14T20:06:09.000Z",
"num_tokens": 103,
"size": 430
} |
module Relation.Ternary.Separation.Monad.Reader where
open import Level
open import Function using (_∘_; case_of_)
open import Relation.Binary.PropositionalEquality using (refl)
open import Relation.Unary
open import Relation.Unary.PredicateTransformer using (PT)
open import Relation.Ternary.Separation
open import Relation.Ternary.Separation.Morphisms
open import Relation.Ternary.Separation.Monad
open import Relation.Ternary.Separation.Allstar
open import Data.Product
open import Data.List hiding (concat; lookup)
open import Data.Unit
private
variable
ℓv : Level
A : Set ℓv
Γ Γ₁ Γ₂ Γ₃ : List A
{- Something not unlike a indexed relative monad transformer in a bicartesian closed category -}
module ReaderTransformer {ℓ}
-- types
{T : Set ℓ}
-- runtime resource
{C : Set ℓ} {{rc : RawSep C}} {u} {{sc : IsUnitalSep rc u}} {{cc : IsConcattative rc}}
--
{B : Set ℓ} {{rb : RawSep B}}
(j : Morphism C B) {{sb : IsUnitalSep rb (Morphism.j j u)}}
(V : T → Pred C ℓ) -- values
(M : PT C B ℓ ℓ)
{{monad : Monads.Monad {{jm = j}} ⊤ ℓ (λ _ _ → M) }}
where
open Morphism j hiding (j) public
open Monads {{jm = j}} using (Monad; str; typed-str)
open import Relation.Ternary.Separation.Construct.List T
module _ where
open Monad monad
variable
P Q R : Pred C ℓ
Reader : ∀ (Γ₁ Γ₂ : List T) (P : Pred C ℓ) → Pred B ℓ
Reader Γ₁ Γ₂ P = J (Allstar V Γ₁) ─✴ M (P ✴ Allstar V Γ₂)
instance
reader-monad : Monad (List T) _ Reader
app (Monad.return reader-monad px) (inj e) s = return px &⟨ s ⟩ e
app (app (Monad.bind reader-monad f) mp σ₁) env σ₂ =
let _ , σ₃ , σ₄ = ⊎-assoc σ₁ σ₂ in
app (bind (wand λ where
(px ×⟨ σ₅ ⟩ env') σ₆ →
let _ , τ₁ , τ₂ = ⊎-unassoc σ₆ (j-⊎ σ₅) in
app (app f px τ₁) (inj env') τ₂)) (app mp env σ₄) σ₃
frame : Γ₁ ⊎ Γ₃ ≣ Γ₂ → ∀[ Reader Γ₁ ε P ⇒ Reader Γ₂ Γ₃ P ]
app (frame sep c) (inj env) σ = do
let E₁ ×⟨ σ₁ ⟩ E₂ = repartition sep env
let Φ , σ₂ , σ₃ = ⊎-unassoc σ (j-⊎ σ₁)
(v ×⟨ σ₄ ⟩ nil) ×⟨ σ₅ ⟩ E₃ ← app c (inj E₁) σ₂ &⟨ Allstar _ _ ∥ σ₃ ⟩ E₂
case ⊎-id⁻ʳ σ₄ of λ where
refl → return (v ×⟨ σ₅ ⟩ E₃)
ask : ε[ Reader Γ ε (Allstar V Γ) ]
app ask (inj env) σ with ⊎-id⁻ˡ σ
... | refl = return (env ×⟨ ⊎-idʳ ⟩ nil)
prepend : ∀[ Allstar V Γ₁ ⇒ⱼ Reader Γ₂ (Γ₁ ∙ Γ₂) Emp ]
app (prepend env₁) (inj env₂) s with j-⊎⁻ s
... | _ , refl , s' = return (empty ×⟨ ⊎-idˡ ⟩ (concat (env₁ ×⟨ s' ⟩ env₂)))
append : ∀[ Allstar V Γ₁ ⇒ⱼ Reader Γ₂ (Γ₂ ∙ Γ₁) Emp ]
app (append env₁) (inj env₂) s with j-⊎⁻ s
... | _ , refl , s' = return (empty ×⟨ ⊎-idˡ ⟩ (concat (✴-swap (env₁ ×⟨ s' ⟩ env₂))))
liftM : ∀[ M P ⇒ Reader Γ Γ P ]
app (liftM mp) (inj env) σ = do
mp &⟨ σ ⟩ env
runReader : ∀[ Allstar V Γ ⇒ⱼ Reader Γ ε P ─✴ M P ]
app (runReader env) mp σ = do
px ×⟨ σ ⟩ nil ← app mp (inj env) (⊎-comm σ)
case ⊎-id⁻ʳ σ of λ where
refl → return px
module _ where
open Monad reader-monad
lookup : ∀ {a} → ε[ Reader [ a ] [] (V a) ]
lookup = do
v :⟨ σ ⟩: nil ← ask
case ⊎-id⁻ʳ σ of λ where
refl → return v
module ReaderMonad {ℓ}
-- types
{T : Set ℓ}
-- runtime resource
{C : Set ℓ} {{rc : RawSep C}} {u} {{sc : IsUnitalSep rc u}} {{cc : IsConcattative rc}}
-- values
(V : T → Pred C ℓ)
where
open import Relation.Ternary.Separation.Monad.Identity
open ReaderTransformer id-morph V Identity.Id {{ monad = Identity.id-monad }} public
| {
"alphanum_fraction": 0.5862263618,
"avg_line_length": 32.2090909091,
"ext": "agda",
"hexsha": "b68f49e29e1984caebf792ee1b8c476e4fac4a38",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2020-05-23T00:34:36.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-01-30T14:15:14.000Z",
"max_forks_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "laMudri/linear.agda",
"max_forks_repo_path": "src/Relation/Ternary/Separation/Monad/Reader.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "laMudri/linear.agda",
"max_issues_repo_path": "src/Relation/Ternary/Separation/Monad/Reader.agda",
"max_line_length": 96,
"max_stars_count": 34,
"max_stars_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "laMudri/linear.agda",
"max_stars_repo_path": "src/Relation/Ternary/Separation/Monad/Reader.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-03T15:22:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-12-20T13:57:50.000Z",
"num_tokens": 1367,
"size": 3543
} |
{-# OPTIONS --safe --without-K #-}
open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; trans; sym; cong)
open import Relation.Nullary using (_because_; ofʸ; ofⁿ)
open import Data.Unit using (⊤; tt)
open import Data.Empty using (⊥; ⊥-elim)
open import Data.Nat.Base
open import Data.Bool.Base using (false; true)
open import Data.Product using (_×_; _,_; ∃-syntax)
import Data.Fin as Fin
import Data.Nat.Properties as ℕₚ
import Data.Fin.Properties as Finₚ
open Fin using (Fin ; zero ; suc; #_)
open import PiCalculus.Syntax
open Scoped
module PiCalculus.Semantics where
private
variable
name namex namey : Name
n : ℕ
P P' Q R : Scoped n
x y : Fin n
Unused : ∀ {n} → Fin n → Scoped n → Set
Unused i 𝟘 = ⊤
Unused i (ν P) = Unused (suc i) P
Unused i (P ∥ Q) = Unused i P × Unused i Q
Unused i (x ⦅⦆ P) = i ≢ x × Unused (suc i) P
Unused i (x ⟨ y ⟩ P) = i ≢ x × i ≢ y × Unused i P
lift : (i : Fin (suc n)) → Scoped n → Scoped (suc n)
lift i 𝟘 = 𝟘
lift i (ν P) = ν (lift (suc i) P)
lift i (P ∥ Q) = lift i P ∥ lift i Q
lift i (x ⦅⦆ P) = Fin.punchIn i x ⦅⦆ lift (suc i) P
lift i (x ⟨ y ⟩ P) = Fin.punchIn i x ⟨ Fin.punchIn i y ⟩ lift i P
lower : (i : Fin (suc n)) (P : Scoped (suc n)) → Unused i P → Scoped n
lower i 𝟘 uP = 𝟘
lower i (ν P) uP = ν (lower (suc i) P uP)
lower i (P ∥ Q) (uP , uQ) = lower i P uP ∥ lower i Q uQ
lower i (x ⦅⦆ P) (i≢x , uP) = Fin.punchOut i≢x ⦅⦆ lower (suc i) P uP
lower i (x ⟨ y ⟩ P) (i≢x , (i≢y , uP)) = Fin.punchOut i≢x ⟨ Fin.punchOut i≢y ⟩ lower i P uP
notMax : (i : Fin n) (x : Fin (suc n)) → Fin.inject₁ i ≡ x → n ≢ Fin.toℕ x
notMax i x p n≡x = Finₚ.toℕ-inject₁-≢ i (trans n≡x (sym (cong Fin.toℕ p)))
exchangeFin : Fin n → Fin (suc n) → Fin (suc n)
exchangeFin i x with Fin.inject₁ i Fin.≟ x
exchangeFin i x | true because ofʸ p = suc (Fin.lower₁ x (notMax i x p))
exchangeFin i x | false because _ with (suc i) Fin.≟ x
exchangeFin i x | false because _ | true because _ = Fin.inject₁ i
exchangeFin i x | false because _ | false because _ = x
exchange : Fin n → Scoped (suc n) → Scoped (suc n)
exchange i 𝟘 = 𝟘
exchange i (ν P) = ν (exchange (suc i) P)
exchange i (P ∥ Q) = exchange i P ∥ exchange i Q
exchange i (x ⦅⦆ P) = exchangeFin i x ⦅⦆ exchange (suc i) P
exchange i (x ⟨ y ⟩ P) = exchangeFin i x ⟨ exchangeFin i y ⟩ exchange i P
infixl 10 _≈_
data _≈_ : Scoped n → Scoped n → Set where
comp-assoc : P ∥ (Q ∥ R) ≈ (P ∥ Q) ∥ R
comp-symm : P ∥ Q ≈ Q ∥ P
comp-end : P ∥ 𝟘 ≈ P
scope-end : _≈_ {n} (ν 𝟘 ⦃ name ⦄) 𝟘
scope-ext : (u : Unused zero P)
→ ν (P ∥ Q) ⦃ name ⦄ ≈ lower zero P u ∥ (ν Q) ⦃ name ⦄
scope-scope-comm : ν (ν P ⦃ namey ⦄) ⦃ namex ⦄ ≈ ν (ν (exchange zero P) ⦃ namex ⦄) ⦃ namey ⦄
data RecTree : Set where
zero : RecTree
one : RecTree → RecTree
two : RecTree → RecTree → RecTree
private
variable
r p : RecTree
-- TODO: change names as per paper
infixl 5 _≅⟨_⟩_
data _≅⟨_⟩_ : Scoped n → RecTree → Scoped n → Set where
stop_ : P ≈ Q → P ≅⟨ zero ⟩ Q
-- Equivalence relation
cong-refl : P ≅⟨ zero ⟩ P
cong-symm_ : P ≅⟨ r ⟩ Q → Q ≅⟨ one r ⟩ P
cong-trans : P ≅⟨ r ⟩ Q → Q ≅⟨ p ⟩ R → P ≅⟨ two r p ⟩ R
-- Congruent relation
ν-cong_ : P ≅⟨ r ⟩ P' → ν P ⦃ name ⦄ ≅⟨ one r ⟩ ν P' ⦃ name ⦄
comp-cong_ : P ≅⟨ r ⟩ P' → P ∥ Q ≅⟨ one r ⟩ P' ∥ Q
input-cong_ : P ≅⟨ r ⟩ P' → (x ⦅⦆ P) ⦃ name ⦄ ≅⟨ one r ⟩ (x ⦅⦆ P') ⦃ name ⦄
output-cong_ : P ≅⟨ r ⟩ P' → x ⟨ y ⟩ P ≅⟨ one r ⟩ x ⟨ y ⟩ P'
_≅_ : Scoped n → Scoped n → Set
P ≅ Q = ∃[ r ] (P ≅⟨ r ⟩ Q)
_[_↦_]' : Fin n → Fin n → Fin n → Fin n
x [ i ↦ j ]' with i Finₚ.≟ x
x [ i ↦ j ]' | true because _ = j
x [ i ↦ j ]' | false because _ = x
_[_↦_] : Scoped n → (i j : Fin n) → Scoped n
𝟘 [ i ↦ j ] = 𝟘
(ν P) [ i ↦ j ] = ν (P [ suc i ↦ suc j ])
(P ∥ Q) [ i ↦ j ] = (P [ i ↦ j ]) ∥ (Q [ i ↦ j ])
(x ⦅⦆ P) [ i ↦ j ] = (x [ i ↦ j ]') ⦅⦆ (P [ suc i ↦ suc j ])
(x ⟨ y ⟩ P) [ i ↦ j ] = (x [ i ↦ j ]') ⟨ y [ i ↦ j ]' ⟩ (P [ i ↦ j ])
substFin-unused : ∀ {i j} (x : Fin (suc n)) → i ≢ j → i ≢ x [ i ↦ j ]'
substFin-unused {i = i} x i≢j with i Finₚ.≟ x
substFin-unused {i = i} x i≢j | true because _ = i≢j
substFin-unused {i = i} x i≢j | false because ofⁿ ¬p = ¬p
subst-unused : {i j : Fin (suc n)}
→ i ≢ j
→ (P : Scoped (suc n))
→ Unused i (P [ i ↦ j ])
subst-unused i≢j 𝟘 = tt
subst-unused i≢j (ν P) = subst-unused (λ i≡j → i≢j (Finₚ.suc-injective i≡j)) P
subst-unused i≢j (P ∥ Q) = subst-unused i≢j P , subst-unused i≢j Q
subst-unused i≢j (x ⦅⦆ P) = substFin-unused x i≢j , subst-unused (λ i≡j → i≢j (Finₚ.suc-injective i≡j)) P
subst-unused i≢j (x ⟨ y ⟩ P) = substFin-unused x i≢j , substFin-unused y i≢j , subst-unused i≢j P
data Channel : ℕ → Set where
internal : ∀ {n} → Channel n
external : ∀ {n} → Fin n → Channel n
dec : Channel (suc n) → Channel n
dec internal = internal
dec (external zero) = internal
dec (external (suc i)) = external i
maybe : ∀ {a} {A : Set a} → A → (Fin n → A) → Channel n → A
maybe b f internal = b
maybe b f (external x) = f x
infixl 5 _=[_]⇒_
data _=[_]⇒_ : Scoped n → Channel n → Scoped n → Set where
comm : {P : Scoped (1 + n)} {Q : Scoped n} {i j : Fin n}
→ let uP' = subst-unused (λ ()) P
in ((i ⦅⦆ P) ⦃ name ⦄) ∥ (i ⟨ j ⟩ Q) =[ external i ]⇒ lower zero (P [ zero ↦ suc j ]) uP' ∥ Q
par_ : ∀ {c} {P P' Q : Scoped n}
→ P =[ c ]⇒ P'
→ P ∥ Q =[ c ]⇒ P' ∥ Q
res_ : ∀ {c} {P Q : Scoped (1 + n)}
→ P =[ c ]⇒ Q
→ ν P ⦃ name ⦄ =[ dec c ]⇒ ν Q ⦃ name ⦄
struct : ∀ {c} {P P' Q' Q : Scoped n}
→ P ≅⟨ r ⟩ P'
→ P' =[ c ]⇒ Q'
→ Q' ≅⟨ r ⟩ Q
→ P =[ c ]⇒ Q
_⇒_ : Scoped n → Scoped n → Set
P ⇒ Q = ∃[ c ] (P =[ c ]⇒ Q)
| {
"alphanum_fraction": 0.5093073956,
"avg_line_length": 34.2701149425,
"ext": "agda",
"hexsha": "da22d67718e8ed9e50a7adf8db2d3e0f7411b8f7",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T16:24:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-01-25T13:57:13.000Z",
"max_forks_repo_head_hexsha": "0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "guilhermehas/typing-linear-pi",
"max_forks_repo_path": "src/PiCalculus/Semantics.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a",
"max_issues_repo_issues_event_max_datetime": "2022-03-15T09:16:14.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-15T09:16:14.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "guilhermehas/typing-linear-pi",
"max_issues_repo_path": "src/PiCalculus/Semantics.agda",
"max_line_length": 107,
"max_stars_count": 26,
"max_stars_repo_head_hexsha": "0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "guilhermehas/typing-linear-pi",
"max_stars_repo_path": "src/PiCalculus/Semantics.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-14T15:18:23.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-02T23:32:11.000Z",
"num_tokens": 2664,
"size": 5963
} |
module datatypes where
open import bool public
open import bool-to-string public
open import char public
open import integer public
open import list public
open import list-to-string public
open import level public
open import maybe public
open import nat public
open import nat-division public
open import nat-to-string public
open import nat-log public
open import product public
open import string public
open import sum public
open import tree public
open import trie public
open import unit public
open import vector public
| {
"alphanum_fraction": 0.8339622642,
"avg_line_length": 24.0909090909,
"ext": "agda",
"hexsha": "84aff94261b400faa3d34e45b16cf4b45ac879ec",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "heades/AUGL",
"max_forks_repo_path": "datatypes.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "heades/AUGL",
"max_issues_repo_path": "datatypes.agda",
"max_line_length": 33,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "heades/AUGL",
"max_stars_repo_path": "datatypes.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 109,
"size": 530
} |
-- Andreas, 2014-05-03 Test case by Andrea Vezzosi
data Two : Set where
a b : Two
-- This example of varying arity crashed Epic before.
f : Two → {eq : Two} → Two
f a {x} = a
f b = b
postulate
IO : Set → Set
{-# COMPILED_TYPE IO IO #-}
postulate
return : ∀ {A} → A → IO A
{-# COMPILED_EPIC return (u1 : Unit, a : Any) -> Any = ioreturn(a) #-}
main : IO Two
main = return a
| {
"alphanum_fraction": 0.5924050633,
"avg_line_length": 17.1739130435,
"ext": "agda",
"hexsha": "34a822317240261b1dfed11552c813c3d214b5b4",
"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/EpicVaryingArity.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/EpicVaryingArity.agda",
"max_line_length": 70,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/Succeed/EpicVaryingArity.agda",
"max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z",
"num_tokens": 139,
"size": 395
} |
{-# OPTIONS --type-in-type #-}
module poly0 where
open import prelude
open import functors
open import poly.core public
variable
A B C X Y : ∫
I A⁺ B⁺ C⁺ X⁺ Y⁺ : Set
A⁻ : A⁺ → Set
B⁻ : B⁺ → Set
C⁻ : C⁺ → Set
X⁻ : X⁺ → Set
Y⁻ : Y⁺ → Set
∃⊤ ∃⊥ ⊤∫ ∫∫ : Set → ∫
∃⊤ a = a , λ _ → ⊤
∃⊥ a = a , λ _ → ⊥
⊤∫ a = ⊤ , λ _ → a
∫∫ a = a , λ _ → a
𝒴 𝟘 : ∫
𝒴 = ⊤ , λ _ → ⊤
𝟘 = ⊥ , λ _ → ⊥
module _ {A@(A⁺ , A⁻) B@(B⁺ , B⁻) : ∫} where
infixl 5 _★_
-- infix notatjon for get
_★_ : A⁺ → (l : ∫[ A , B ]) → B⁺
σa ★ l = get l σa
infixr 4 _#_←_
-- Infix notatjon for set
_#_←_ : (a⁺ : A⁺) → (A↝B : ∫[ A , B ]) → B⁻ (a⁺ ★ A↝B) → A⁻ a⁺
a⁺ # l ← b⁻ = π₂ (l a⁺) b⁻
_↕_ : (get : A⁺ → B⁺) → (set : (a⁺ : A⁺) → B⁻ (get a⁺) → A⁻ a⁺) → ∫[ A , B ]
g ↕ s = λ a⁺ → (g a⁺) , (s a⁺)
module _ {A@(A⁺ , A⁻) C@(C⁺ , C⁻) : ∫} (l : ∫[ A , C ]) where
-- vertical and cartesian factorization
Factor : Σ[ B ∈ ∫ ] (∫[ A , B ]) × (∫[ B , C ])
Factor = (A⁺ , C⁻ ∘ get l)
, id ↕ set l
, get l ↕ λ _ → id
module lenses (f : A⁺ → B⁺) where
constant : ∫[ ∃⊥ A⁺ , ∃⊥ B⁺ ]
emitter : ∫[ ∃⊤ A⁺ , ∃⊤ B⁺ ]
sensor : ∫[ ⊤∫ B⁺ , ⊤∫ A⁺ ]
constant a⁺ = f a⁺ , id
emitter a⁺ = f a⁺ , λ _ → tt
sensor _ = tt , f
open lenses public
enclose : ((a⁺ : A⁺) → B⁻ a⁺) → ∫[ (A⁺ , B⁻) , 𝒴 ]
enclose f a⁺ = tt , λ _ → f a⁺
auto : ∫[ ∃⊤ A⁺ , 𝒴 ]
auto = enclose λ _ → tt
{-
lift∫ : (f : Set → Set) → ∫ → ∫
lift∫ f (A⁺ , A⁻) = A⁺ , f ∘ A⁻
liftLens : ∀ {A B} (f : Set → Set) → ∫[ A , B ] → ∫[ lift∫ f A , lift∫ f B ]
liftLens f l a⁺ with l a⁺
... | b⁺ , setb = b⁺ , φ setb
-}
{-
module lift_comonad (f : Set → Set) {A : ∫} ⦃ f_monad : Monad f ⦄ where
extract : lift∫ f A ↝ A
extract a⁺ = a⁺ , η f_monad
-- id ↕ λ _ → η
duplicate : lift∫ f A ↝ lift∫ f (lift∫ f A)
duplicate a⁺ = a⁺ , μ
-}
module poly-ops where
infixl 6 _⊗_
infixl 5 _⊕_
_⊕_ _⊗_ _⊠_ _⊚_ : ∫ → ∫ → ∫
(A⁺ , A⁻) ⊕ (B⁺ , B⁻) = (A⁺ ⊎ B⁺) , (A⁻ ⨄ B⁻) -- coproduct
(A⁺ , A⁻) ⊗ (B⁺ , B⁻) = (A⁺ × B⁺) , (A⁻ ⨃ B⁻) -- product
(A⁺ , A⁻) ⊠ (B⁺ , B⁻) = (A⁺ × B⁺) , (A⁻ ⨉ B⁻) -- juxtapose
(A⁺ , A⁻) ⊚ (B⁺ , B⁻) = (Σ[ a⁺ ∈ A⁺ ](A⁻ a⁺ → B⁺)) -- compose
, λ (_ , bs) → ∃ (B⁻ ∘ bs)
-- N-ary
Σ⊕ : (I → ∫) → ∫
Σ⊕ {I = I} A = Σ I (π₁ ∘ A) , λ (i , a⁺) → π₂ (A i) a⁺
Π⊗ : (I → ∫) → ∫
Π⊗ {I = I} a = ((i : I) → π₁ (a i))
, λ a⁺ → Σ[ i ∈ I ](π₂ (a i) (a⁺ i))
Π⊠ : (I → ∫) → ∫
Π⊠ {I = I} a = ((i : I) → π₁ (a i))
, (λ a⁺ → (i : I) -> π₂ (a i) (a⁺ i))
_ᵒ_ : ∫ → ℕ → ∫
_ ᵒ ℕz = 𝒴
a ᵒ ℕs n = a ⊚ (a ᵒ n)
open poly-ops public
module lens-ops where
_⟦+⟧_ : ∀ {a b x y} → ∫[ a , b ] → ∫[ x , y ] → ∫[ a ⊕ x , b ⊕ y ] -- coproduct
_⟦|⟧_ : ∀ {a b x } → ∫[ a , x ] → ∫[ b , x ] → ∫[ a ⊕ b , x ] -- copair
_⟦⊗⟧_ : ∀ {a b x y} → ∫[ a , b ] → ∫[ x , y ] → ∫[ a ⊗ x , b ⊗ y ] -- product
_⟦×⟧_ : ∀ {x a b } → ∫[ x , a ] → ∫[ x , b ] → ∫[ x , a ⊗ b ] -- pair
_⟦⊠⟧_ : ∀ {a b x y} → ∫[ a , b ] → ∫[ x , y ] → ∫[ a ⊠ x , b ⊠ y ] -- juxtaposition
_⟦⊚⟧_ : ∀ {a b x y} → ∫[ a , b ] → ∫[ x , y ] → ∫[ a ⊚ x , b ⊚ y ] -- composition
(a↝b ⟦+⟧ x↝y) = λ{(Σ₁ a⁺) → let b⁺ , setb = a↝b a⁺ in Σ₁ b⁺ , setb
;(Σ₂ x⁺) → let y⁺ , sety = x↝y x⁺ in Σ₂ y⁺ , sety}
(a↝x ⟦|⟧ b↝x) = λ{(Σ₁ a⁺) → a↝x a⁺
;(Σ₂ b⁺) → b↝x b⁺}
(a↝b ⟦⊗⟧ x↝y) (a⁺ , x⁺) with a↝b a⁺ | x↝y x⁺
... | b⁺ , setb | y⁺ , sety = (b⁺ , y⁺)
, λ{(Σ₁ b⁻) → Σ₁ (setb b⁻)
;(Σ₂ y⁻) → Σ₂ (sety y⁻)}
_⟦×⟧_ x↝a x↝b x⁺ with x↝a x⁺ | x↝b x⁺
... | a⁺ , seta | b⁺ , setb = (a⁺ , b⁺) , λ{(Σ₁ a⁻) → seta a⁻
;(Σ₂ b⁻) → setb b⁻}
_⟦⊠⟧_ a↝b x↝y (a⁺ , x⁺) = ((a⁺ ★ a↝b) , (x⁺ ★ x↝y))
, λ (b⁻ , y⁻) → (a⁺ # a↝b ← b⁻) , (x⁺ # x↝y ← y⁻)
(a↝b ⟦⊚⟧ x↝y) (a⁺ , a⁻→x⁺) with a↝b a⁺
... | b⁺ , setb = (b⁺ , get x↝y ∘ a⁻→x⁺ ∘ setb)
, λ (b⁻ , y⁻) → let a⁻ = setb b⁻
in a⁻ , (a⁻→x⁺ a⁻ # x↝y ← y⁻)
-- N-ary
Π⟦⊠⟧ : {as bs : I → ∫}
→ ((i : I) → (∫[ as i , bs i ]))
→ ∫[ Π⊠ as , Π⊠ bs ]
Π⟦⊠⟧ ls as⁺ = (λ i → as⁺ i ★ ls i)
, (λ dbs i → as⁺ i # ls i ← dbs i)
_⟦ᵒ⟧_ : ∫[ A , B ] → (n : ℕ) → ∫[ A ᵒ n , B ᵒ n ]
_⟦ᵒ⟧_ {a} {b} l = go where
go : (n : ℕ) → ∫[ a ᵒ n , b ᵒ n ]
go ℕz = 𝒾 {x = 𝒴}
go (ℕs n) = l ⟦⊚⟧ (go n)
open lens-ops public
| {
"alphanum_fraction": 0.3360599864,
"avg_line_length": 30.5625,
"ext": "agda",
"hexsha": "1016ec3d6ec0ecd030fa6650055c9e276ce319bc",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2022-01-30T11:45:57.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-07-10T17:19:37.000Z",
"max_forks_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dspivak/poly",
"max_forks_repo_path": "code-examples/agda/poly0.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea",
"max_issues_repo_issues_event_max_datetime": "2022-01-12T10:06:32.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-09-02T02:29:39.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dspivak/poly",
"max_issues_repo_path": "code-examples/agda/poly0.agda",
"max_line_length": 85,
"max_stars_count": 53,
"max_stars_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mstone/poly",
"max_stars_repo_path": "code-examples/agda/poly0.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T23:08:27.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-02-18T16:31:04.000Z",
"num_tokens": 2674,
"size": 4401
} |
module Prelude.Monad where
open import Agda.Primitive
open import Prelude.Function
open import Prelude.Functor
open import Prelude.Unit
open import Prelude.Applicative
open import Prelude.Monad.Indexed {I = ⊤} as Indexed
Monad : ∀ {a b} (M : Set a → Set b) → Set (lsuc a ⊔ b)
Monad M = Indexed.IMonad (λ _ _ → M)
Monad′ : ∀ {a b} (M : ∀ {a} → Set a → Set a) → Set (lsuc (a ⊔ b))
Monad′ {a} {b} M = Indexed.IMonad′ {a = a} {b = b} (λ _ _ → M)
open Indexed public hiding (IMonad; IMonad′)
monadAp : ∀ {a b} {A B : Set a} {M : Set a → Set b}
{{_ : Functor M}} →
(M (A → B) → ((A → B) → M B) → M B) →
M (A → B) → M A → M B
monadAp _>>=_ mf mx = mf >>= λ f → fmap f mx
monadAp′ : ∀ {a b} {A : Set a} {B : Set b} {M : ∀ {a} → Set a → Set a}
{{_ : Functor′ {a} {b} M}} →
(M (A → B) → ((A → B) → M B) → M B) →
M (A → B) → M A → M B
monadAp′ _>>=_ mf mx = mf >>= λ f → fmap′ f mx
infixr 0 caseM_of_
caseM_of_ = _>>=_
| {
"alphanum_fraction": 0.5060606061,
"avg_line_length": 29.1176470588,
"ext": "agda",
"hexsha": "54aaaf16a645ccd4adf71d44014bed7e37d07af0",
"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/Monad.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/Monad.agda",
"max_line_length": 70,
"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/Monad.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": 388,
"size": 990
} |
{-# OPTIONS --without-K #-}
open import Type
open import Type.Identities
open import Level.NP
open import Explore.Core
open import Explore.Properties
open import Explore.Explorable
open import Data.Zero
open import Function.NP
open import Function.Extensionality
open import Data.Product
open import Relation.Binary.PropositionalEquality.NP using (_≡_; refl; _∙_; !_)
open import HoTT
open Equivalences
import Explore.Monad
open import Explore.Isomorphism
module Explore.Zero where
module _ {ℓ} where
𝟘ᵉ : Explore ℓ 𝟘
𝟘ᵉ = empty-explore
{- or
𝟘ᵉ ε _ _ = ε
-}
𝟘ⁱ : ∀ {p} → ExploreInd p 𝟘ᵉ
𝟘ⁱ = empty-explore-ind
{- or
𝟘ⁱ _ Pε _ _ = Pε
-}
module _ {ℓ₁ ℓ₂ ℓᵣ} {R : 𝟘 → 𝟘 → ★₀} where
⟦𝟘ᵉ⟧ : ⟦Explore⟧ {ℓ₁} {ℓ₂} ℓᵣ R 𝟘ᵉ 𝟘ᵉ
⟦𝟘ᵉ⟧ _ εᵣ _ _ = εᵣ
module 𝟘ⁱ = FromExploreInd 𝟘ⁱ
open 𝟘ⁱ public using ()
renaming (sum to 𝟘ˢ
;product to 𝟘ᵖ
;reify to 𝟘ʳ
;unfocus to 𝟘ᵘ
)
module _ {ℓ} where
𝟘ˡ : Lookup {ℓ} 𝟘ᵉ
𝟘ˡ _ ()
𝟘ᶠ : Focus {ℓ} 𝟘ᵉ
𝟘ᶠ ((), _)
module _ {{_ : UA}} where
Σᵉ𝟘-ok : Adequate-Σ {ℓ} (Σᵉ 𝟘ᵉ)
Σᵉ𝟘-ok _ = ! Σ𝟘-lift∘fst
module _ {{_ : UA}}{{_ : FunExt}} where
Πᵉ𝟘-ok : Adequate-Π {ℓ} (Πᵉ 𝟘ᵉ)
Πᵉ𝟘-ok _ = ! Π𝟘-uniq _
open Adequacy _≡_
module _ {{_ : UA}} where
𝟘ˢ-ok : Adequate-sum 𝟘ˢ
𝟘ˢ-ok _ = Fin0≡𝟘 ∙ ! Σ𝟘-fst
adequate-sum𝟘 = 𝟘ˢ-ok
module _ {{_ : UA}}{{_ : FunExt}} where
𝟘ᵖ-ok : Adequate-product 𝟘ᵖ
𝟘ᵖ-ok _ = Fin1≡𝟙 ∙ ! (Π𝟘-uniq₀ _)
adequate-product𝟘 = 𝟘ᵖ-ok
explore𝟘 = 𝟘ᵉ
explore𝟘-ind = 𝟘ⁱ
lookup𝟘 = 𝟘ˡ
reify𝟘 = 𝟘ʳ
focus𝟘 = 𝟘ᶠ
unfocus𝟘 = 𝟘ᵘ
sum𝟘 = 𝟘ˢ
product𝟘 = 𝟘ᵖ
Lift𝟘ᵉ : ∀ {m} → Explore m (Lift 𝟘)
Lift𝟘ᵉ = explore-iso (≃-sym Lift≃id) 𝟘ᵉ
ΣᵉLift𝟘-ok : ∀ {{_ : UA}}{{_ : FunExt}}{m} → Adequate-Σ {m} (Σᵉ Lift𝟘ᵉ)
ΣᵉLift𝟘-ok = Σ-iso-ok (≃-sym Lift≃id) {Aᵉ = 𝟘ᵉ} Σᵉ𝟘-ok
-- -}
| {
"alphanum_fraction": 0.5731895223,
"avg_line_length": 20.935483871,
"ext": "agda",
"hexsha": "1fb9eba379e7e401139a13fa2492001344590bc3",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "crypto-agda/explore",
"max_forks_repo_path": "lib/Explore/Zero.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "crypto-agda/explore",
"max_issues_repo_path": "lib/Explore/Zero.agda",
"max_line_length": 79,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "crypto-agda/explore",
"max_stars_repo_path": "lib/Explore/Zero.agda",
"max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z",
"num_tokens": 1056,
"size": 1947
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Conat Literals
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe --sized-types #-}
module Codata.Cofin.Literals where
open import Data.Nat
open import Agda.Builtin.FromNat
open import Codata.Conat
open import Codata.Conat.Properties
open import Codata.Cofin
open import Relation.Nullary.Decidable
number : ∀ n → Number (Cofin n)
number n = record
{ Constraint = λ k → True (suc k ℕ≤? n)
; fromNat = λ n {{p}} → fromℕ< (toWitness p)
}
| {
"alphanum_fraction": 0.5327868852,
"avg_line_length": 25.4166666667,
"ext": "agda",
"hexsha": "ea145c0559ab435f71bd93038ae968e81ec7c52a",
"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/Codata/Cofin/Literals.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/Codata/Cofin/Literals.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/Codata/Cofin/Literals.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 144,
"size": 610
} |
open import Data.Product
open import Relation.Binary.PropositionalEquality hiding ([_] ; Extensionality)
open import Relation.Nullary
open import Relation.Nullary.Negation
open import EffectAnnotations
module Types where
-- BASE AND GROUND TYPES
postulate BType : Set -- set of base types
postulate dec-bty : (B B' : BType) → Dec (B ≡ B')
GType = BType
-- VALUE AND COMPUTATION TYPES
mutual
data VType : Set where
`` : GType → VType
_⇒_ : VType → CType → VType
⟨_⟩ : VType → VType
data CType : Set where
_!_ : VType → O × I → CType
infix 30 _⇒_
infix 30 _!_
-- PROCESS TYPES
data PTypeShape : Set where
_!_ : VType → I → PTypeShape
_∥_ : PTypeShape → PTypeShape → PTypeShape
data PType : O → Set where
_‼_,_ : (X : VType) →
(o : O) →
(i : I) →
---------------
PType o
_∥_ : {o o' : O} →
(PP : PType o) →
(QQ : PType o') →
---------------------------
PType (o ∪ₒ o')
-- ACTION OF INTERRUPTS ON PROCESS TYPES
_↓ₚₚ_ : (op : Σₛ) → {o : O} →
PType o → Σ[ o' ∈ O ] PType o'
op ↓ₚₚ (X ‼ o , i) with op ↓ₑ (o , i)
... | (o' , i') =
o' , (X ‼ o' , i')
op ↓ₚₚ (PP ∥ QQ) with op ↓ₚₚ PP | op ↓ₚₚ QQ
... | (o'' , PP') | (o''' , QQ') =
(o'' ∪ₒ o''') , (PP' ∥ QQ')
_↓ₚ_ : (op : Σₛ) → {o : O} →
(PP : PType o) → PType (proj₁ (op ↓ₚₚ PP))
op ↓ₚ PP = proj₂ (op ↓ₚₚ PP)
-- ACTION OF INTERRUPTS ON PROCESS TYPES PRESERVES SIGNAL ANNOTATIONS
{- LEMMA 4.1 -}
↓ₚₚ-⊑ₒ : {op : Σₛ}
{o : O} →
(PP : PType o) →
----------------------
o ⊑ₒ proj₁ (op ↓ₚₚ PP)
↓ₚₚ-⊑ₒ (X ‼ o , i) =
↓ₑ-⊑ₒ
↓ₚₚ-⊑ₒ (PP ∥ QQ) =
∪ₒ-fun (↓ₚₚ-⊑ₒ PP) (↓ₚₚ-⊑ₒ QQ)
| {
"alphanum_fraction": 0.4970657277,
"avg_line_length": 19.1460674157,
"ext": "agda",
"hexsha": "d5a572f03b40ab6b451351a905c2fd2ecba60fcb",
"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": "71ebed9f90a3eb37ae6cd209457bae23a4d122d1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "danelahman/aeff-agda",
"max_forks_repo_path": "Types.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "71ebed9f90a3eb37ae6cd209457bae23a4d122d1",
"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": "danelahman/aeff-agda",
"max_issues_repo_path": "Types.agda",
"max_line_length": 79,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "71ebed9f90a3eb37ae6cd209457bae23a4d122d1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "danelahman/aeff-agda",
"max_stars_repo_path": "Types.agda",
"max_stars_repo_stars_event_max_datetime": "2021-03-22T22:48:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-17T00:15:00.000Z",
"num_tokens": 715,
"size": 1704
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
module Categories.Diagram.Coequalizer {o ℓ e} (C : Category o ℓ e) where
open Category C
open HomReasoning
open import Level
private
variable
A B : Obj
h i : A ⇒ B
record Coequalizer (f g : A ⇒ B) : Set (o ⊔ ℓ ⊔ e) where
field
{obj} : Obj
arr : B ⇒ obj
equality : arr ∘ f ≈ arr ∘ g
coequalize : h ∘ f ≈ h ∘ g → obj ⇒ cod h
universal : ∀ {eq : h ∘ f ≈ h ∘ g} → h ≈ coequalize eq ∘ arr
unique : ∀ {eq : h ∘ f ≈ h ∘ g} → h ≈ i ∘ arr → i ≈ coequalize eq
| {
"alphanum_fraction": 0.5571177504,
"avg_line_length": 21.8846153846,
"ext": "agda",
"hexsha": "c8ed381a9b4e155bdbfc11ae4b10a61bb7eea946",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MirceaS/agda-categories",
"max_forks_repo_path": "src/Categories/Diagram/Coequalizer.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "MirceaS/agda-categories",
"max_issues_repo_path": "src/Categories/Diagram/Coequalizer.agda",
"max_line_length": 73,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MirceaS/agda-categories",
"max_stars_repo_path": "src/Categories/Diagram/Coequalizer.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 217,
"size": 569
} |
-- {-# OPTIONS --without-K #-}
module F2a where
open import Agda.Prim
open import Data.Unit
open import Data.Nat hiding (_⊔_)
open import Data.Sum
open import Data.Product
open import Function
open import Relation.Binary.PropositionalEquality
open import Paths
open import Evaluator
------------------------------------------------------------------------------
--
-- General structure and idea
--
-- We have pointed types (Paths.agda)
-- We have paths between pointed types (Paths.agda)
-- We have functions between pointed types (that use ≡ to make sure the
-- basepoint is respected) (F2a.agda)
-- Then we use univalence to connect these two independently developed
-- notions (F2a.agda)
-- Because our paths are richer than just refl and our functions are
-- more restricted than arbitrary functions, and in fact because our
-- path constructors are sound and complete for the class of functions
-- we consider, we hope to _prove_ univalence
--
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Equivalences between raw functions and types
-- This is generalized below to pointed types
-- Two functions are ∼ is they map each argument to related results
_∼_ : ∀ {ℓ ℓ'} → {A : Set ℓ} {P : A → Set ℓ'} →
(f g : (x : A) → P x) → Set (ℓ ⊔ ℓ')
_∼_ {ℓ} {ℓ'} {A} {P} f g = (x : A) → f x ≡ g x
-- quasi-inverses
record qinv {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B) :
Set (ℓ ⊔ ℓ') where
constructor mkqinv
field
g : B → A
α : (f ∘ g) ∼ id
β : (g ∘ f) ∼ id
idqinv : ∀ {ℓ} → {A : Set ℓ} → qinv {ℓ} {ℓ} {A} {A} id
idqinv = record {
g = id ;
α = λ b → refl ;
β = λ a → refl
}
-- equivalences
record isequiv {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B) :
Set (ℓ ⊔ ℓ') where
constructor mkisequiv
field
g : B → A
α : (f ∘ g) ∼ id
h : B → A
β : (h ∘ f) ∼ id
equiv₁ : ∀ {ℓ ℓ'} → {A : Set ℓ} {B : Set ℓ'} {f : A → B} → qinv f → isequiv f
equiv₁ (mkqinv qg qα qβ) = mkisequiv qg qα qg qβ
_≃_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Set (ℓ ⊔ ℓ')
A ≃ B = Σ (A → B) isequiv
idequiv : ∀ {ℓ} {A : Set ℓ} → A ≃ A
idequiv = (id , equiv₁ idqinv)
-- Function extensionality
{--
happly : ∀ {ℓ} {A B : Set ℓ} {f g : A → B} → (Path f g) → (f ∼ g)
happly {ℓ} {A} {B} {f} {g} p =
(pathInd
(λ _ → f ∼ g) -- f ∼ g
(λ {AA} a x → {!!}) {!!}
{!!} {!!} {!!} {!!} {!!} {!!}
{!!} {!!} (λ a b x → {!cong (evalB p) (eval-resp-• (p))!})
{!!} {!!} {!!} {!!} {!!} {!!}
(λ a x → {!!}) (λ p₁ q x x₁ x₂ → x x₂)
(λ p₁ q x x₁ x₂ → x x₂) (λ p₁ q x x₁ x₂ → x x₂) (λ p₁ q x x₁ x₂ → x₁ x₂))
{A → B} {A → B} {f} {g} p
postulate
funextP : {A B : Set} {f g : A → B} →
isequiv {A = Path f g} {B = f ∼ g} happly
funext : {A B : Set} {f g : A → B} → (f ∼ g) → (Path f g)
funext = isequiv.g funextP
-- Universes; univalence
idtoeqv : {A B : Set} → (Path A B) → (A ≃ B)
idtoeqv {A} {B} p = {!!}
{--
(pathInd
(λ {S₁} {S₂} {A} {B} p → {!!})
{!!} {!!}
{!!} {!!} {!!} {!!} {!!} {!!}
{!!} {!!} {!!}
{!!} {!!} {!!} {!!} {!!} {!!}
{!!} {!!} {!!} {!!} {!!})
{Set} {Set} {A} {B} p
--}
postulate
univalence : {ℓ : Level} {A B : Set ℓ} → (Path A B) ≃ (A ≃ B)
--}
path2fun : {ℓ : Level} {A B : Set ℓ} → (Path A B) → (A ≃ B)
path2fun p = ( {!!} , {!!})
------------------------------------------------------------------------------
-- Functions and equivalences between pointed types
-- Univalence as a postulate for now but hopefully we can actually prove it
-- since the pi-combinators are sound and complete for isomorphisms between
-- finite types
--postulate
-- univalence• : {ℓ : Level} {A• B• : Set• {ℓ}} → (Path A• B•) ≃• (A• ≃• B•)
{--
record isequiv• {ℓ} {A B : Set} {A• B• : Set• {ℓ}} (f• : A• →• B•) :
Set (lsuc ℓ) where
constructor mkisequiv•
field
equi : isequiv (fun f•)
path' : Path (• A•) (• B•)
_≈•_ : ∀ {ℓ} {A B : Set} (A• B• : Set• {ℓ}) → Set (lsuc ℓ)
_≈•_ {_} {A} {B} A• B• = Σ (A• →• B•) (isequiv• {_} {A} {B})
--}
------------------------------------------------------------------------------
-- Univalence for pointed types
eval• : {ℓ : Level} {A• B• : Set• {ℓ}} → A• ⇛ B• → (A• →• B•)
eval• c = record { fun = eval c ; resp• = eval-resp-• c }
evalB• : {ℓ : Level} {A• B• : Set• {ℓ}} → A• ⇛ B• → (B• →• A•)
evalB• c = record { fun = evalB c ; resp• = evalB-resp-• c }
-- This is at the wrong level... We need to define equivalences ≃ between
-- pointed sets too...
{--
path2iso : {ℓ : Level} {A• B• : Set• {ℓ}} → A• ⇛ B• → ∣ A• ∣ ≃ ∣ B• ∣
path2iso {ℓ} {a} {b} p = (eval p ,
mkisequiv (evalB p) (λ x → {!!}) (evalB p) (λ x → {!eval∘evalB p!}))
--}
------------------------------------------------------------------------------
--}
| {
"alphanum_fraction": 0.4552162328,
"avg_line_length": 28.8698224852,
"ext": "agda",
"hexsha": "343f4442654fe18a6fced8c3ee6d39e91c812aba",
"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": "F2a.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": "F2a.agda",
"max_line_length": 78,
"max_stars_count": 14,
"max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "JacquesCarette/pi-dual",
"max_stars_repo_path": "F2a.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": 1837,
"size": 4879
} |
postulate
A : Set
P : A → Set
a : A
T : Set → Set
proj : (X : Set) → T X → X
t : T (∀ {x} → P x)
-- Checking target types first would prematurely solve the underscore
-- with `P a` instead of the correct `∀ {x} → P x`
fail : P a
fail = proj _ t
| {
"alphanum_fraction": 0.545112782,
"avg_line_length": 17.7333333333,
"ext": "agda",
"hexsha": "7b67601c4dbd5fd827fc6c413100fd6f3f149d84",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/Issue1431.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/Issue1431.agda",
"max_line_length": 69,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue1431.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": 99,
"size": 266
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- First generalizes the idea that an element is the first in a list to
-- satisfy a predicate.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Relation.Unary.First {a} {A : Set a} where
open import Level using (_⊔_)
open import Data.Empty
open import Data.Fin as Fin using (Fin; zero; suc)
open import Data.List.Base as List using (List; []; _∷_)
open import Data.List.Relation.Unary.All as All using (All; []; _∷_)
open import Data.List.Relation.Unary.Any as Any using (Any; here; there)
open import Data.Product as Prod using (∃; -,_; _,_)
open import Data.Sum as Sum using (_⊎_; inj₁; inj₂)
open import Function
open import Relation.Unary
open import Relation.Nullary
-----------------------------------------------------------------------
-- Basic type.
module _ {p q} (P : Pred A p) (Q : Pred A q) where
data First : Pred (List A) (a ⊔ p ⊔ q) where
[_] : ∀ {x xs} → Q x → First (x ∷ xs)
_∷_ : ∀ {x xs} → P x → First xs → First (x ∷ xs)
data FirstView : Pred (List A) (a ⊔ p ⊔ q) where
_++_∷_ : ∀ {xs y} → All P xs → Q y → ∀ ys → FirstView (xs List.++ y ∷ ys)
------------------------------------------------------------------------
-- map
module _ {p q r s} {P : Pred A p} {Q : Pred A q} {R : Pred A r} {S : Pred A s} where
map : P ⊆ R → Q ⊆ S → First P Q ⊆ First R S
map p⇒r q⇒r [ qx ] = [ q⇒r qx ]
map p⇒r q⇒r (px ∷ pqxs) = p⇒r px ∷ map p⇒r q⇒r pqxs
module _ {p q r} {P : Pred A p} {Q : Pred A q} {R : Pred A r} where
map₁ : P ⊆ R → First P Q ⊆ First R Q
map₁ p⇒r = map p⇒r id
map₂ : Q ⊆ R → First P Q ⊆ First P R
map₂ = map id
refine : P ⊆ Q ∪ R → First P Q ⊆ First R Q
refine f [ qx ] = [ qx ]
refine f (px ∷ pqxs) with f px
... | inj₁ qx = [ qx ]
... | inj₂ rx = rx ∷ refine f pqxs
module _ {p q} {P : Pred A p} {Q : Pred A q} where
------------------------------------------------------------------------
-- Operations
empty : ¬ First P Q []
empty ()
tail : ∀ {x xs} → ¬ Q x → First P Q (x ∷ xs) → First P Q xs
tail ¬qx [ qx ] = ⊥-elim (¬qx qx)
tail ¬qx (px ∷ pqxs) = pqxs
index : First P Q ⊆ (Fin ∘′ List.length)
index [ qx ] = zero
index (_ ∷ pqxs) = suc (index pqxs)
index-satisfied : ∀ {xs} (pqxs : First P Q xs) → Q (List.lookup xs (index pqxs))
index-satisfied [ qx ] = qx
index-satisfied (_ ∷ pqxs) = index-satisfied pqxs
satisfied : ∀ {xs} → First P Q xs → ∃ Q
satisfied pqxs = -, index-satisfied pqxs
satisfiable : Satisfiable Q → Satisfiable (First P Q)
satisfiable (x , qx) = List.[ x ] , [ qx ]
------------------------------------------------------------------------
-- Decidability results
first : Π[ P ∪ Q ] → Π[ First P Q ∪ All P ]
first p⊎q [] = inj₂ []
first p⊎q (x ∷ xs) with p⊎q x
... | inj₁ px = Sum.map (px ∷_) (px ∷_) (first p⊎q xs)
... | inj₂ qx = inj₁ [ qx ]
------------------------------------------------------------------------
-- Relationship with Any
module _ {q} {Q : Pred A q} where
fromAny : Any Q ⊆ First U Q
fromAny (here qx) = [ qx ]
fromAny (there any) = _ ∷ fromAny any
toAny : ∀ {p} {P : Pred A p} → First P Q ⊆ Any Q
toAny [ qx ] = here qx
toAny (_ ∷ pqxs) = there (toAny pqxs)
| {
"alphanum_fraction": 0.4809115123,
"avg_line_length": 31.8773584906,
"ext": "agda",
"hexsha": "e680bcc48708f3cf1f30493f8046a71829b225b7",
"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/List/Relation/Unary/First.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/List/Relation/Unary/First.agda",
"max_line_length": 84,
"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/List/Relation/Unary/First.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1113,
"size": 3379
} |
-- {-# OPTIONS -v tc.meta.assign:15 #-}
-- Ulf, 2011-10-04
-- I still don't quite believe in irrelevant levels. In part because I just proved ⊥:
module IrrelevantLevelHurkens where
open import Imports.Level
data _≡_ {a}{A : Set a}(x : A) : A → Set where
refl : x ≡ x
data Irr .(i : Level)(A : Set i) : Set where
irr : Irr i A
data Unit : Set where
unit : Unit
unirr : ∀ .i (A : Set i) → Irr i A → Unit
unirr i A irr = unit
↓_ : ∀ .{i} → Set i → Set
foo : ∀ .{i}{A : Set i}(x : Irr i A) → unirr i A x ≡ unirr zero (↓ A) _
↓ A = _
foo xs = refl
{- Andreas, 2011-10-04 Irrelevant Levels do not harmonize with solving
type of meta = .{.i : Level} (A : Set .i) → Set
solving _39 := λ {.i} A → A
term _38 xs := xs
passed occursCheck
type of meta = ..{i : Level} {A : Set i} (x : Irr .(i) A) →
Irr .(zero) (↓ A)
solving _38 := λ {i} {A} x → x
The solutions x and A for the two holes do not type check, if entered manually.
The solver would need to re-type-check to make sure solutions are correct.
For now, just do not supply --experimental-irrelevance flag.
-}
⊥′ : Set
⊥′ = ↓ ((A : Set) → A)
¬_ : Set → Set
¬ A = A → ⊥′
P : Set → Set
P A = ↓ (A → Set)
U : Set
U = ↓ ((X : Set) → (P (P X) → X) → P (P X))
τ : P (P U) → U
τ t = λ X f p → t λ x → p (f (x X f))
σ : U → P (P U)
σ s pu = s U (λ t → τ t) pu
Δ : P U
Δ = λ y → ¬ ((p : P U) → σ y p → p (τ (σ y)))
Ω : U
Ω X t px = τ (λ p → (x : U) → σ x p → p x) X t px
D : Set
D = (p : P U) → σ Ω p → p (τ (σ Ω))
lem₁ : (p : P U) → ((x : U) → σ x p → p x) → p Ω
lem₁ p H1 = H1 Ω λ x → H1 (τ (σ x))
lem₂ : ¬ D
lem₂ d A = lem₁ Δ (λ x H2 H3 → H3 Δ H2 λ p → H3 λ y → p (τ (σ y))) d A
lem₃ : D
lem₃ p = lem₁ λ y → p (τ (σ y))
loop : ⊥′
loop = λ A → lem₂ lem₃ A
data ⊥ : Set where
false : ⊥
false = loop ⊥
| {
"alphanum_fraction": 0.5257270694,
"avg_line_length": 21.2857142857,
"ext": "agda",
"hexsha": "f4e24f492522ee8c73c0a736699b99e10df39ff0",
"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": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "np/agda-git-experiment",
"max_forks_repo_path": "test/fail/IrrelevantLevelHurkens.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"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": "np/agda-git-experiment",
"max_issues_repo_path": "test/fail/IrrelevantLevelHurkens.agda",
"max_line_length": 85,
"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/fail/IrrelevantLevelHurkens.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": 760,
"size": 1788
} |
------------------------------------------------------------------------------
-- Streams properties
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Data.Stream.PropertiesATP where
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Data.Conat
open import FOTC.Data.Conat.Equality.Type
open import FOTC.Data.List
open import FOTC.Data.Stream
------------------------------------------------------------------------------
-- Because a greatest post-fixed point is a fixed-point, then the
-- Stream predicate is also a pre-fixed point of the functional
-- StreamF, i.e.
--
-- StreamF Stream ≤ Stream (see FOTC.Data.Stream.Type).
-- See Issue https://github.com/asr/apia/issues/81 .
Stream-inA : D → Set
Stream-inA xs = ∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ Stream xs'
{-# ATP definition Stream-inA #-}
Stream-in : ∀ {xs} →
∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ Stream xs' →
Stream xs
Stream-in h = Stream-coind Stream-inA h' h
where
postulate h' : ∀ {xs} → Stream-inA xs →
∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ Stream-inA xs'
{-# ATP prove h' #-}
-- See Issue https://github.com/asr/apia/issues/81 .
zeros-StreamA : D → Set
zeros-StreamA xs = xs ≡ zeros
{-# ATP definition zeros-StreamA #-}
zeros-Stream : Stream zeros
zeros-Stream = Stream-coind zeros-StreamA h refl
where
postulate h : ∀ {xs} → zeros-StreamA xs →
∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ zeros-StreamA xs'
{-# ATP prove h #-}
-- See Issue https://github.com/asr/apia/issues/81 .
ones-StreamA : D → Set
ones-StreamA xs = xs ≡ ones
{-# ATP definition ones-StreamA #-}
ones-Stream : Stream ones
ones-Stream = Stream-coind ones-StreamA h refl
where
postulate h : ∀ {xs} → ones-StreamA xs →
∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ ones-StreamA xs'
{-# ATP prove h #-}
postulate ∷-Stream : ∀ {x xs} → Stream (x ∷ xs) → Stream xs
{-# ATP prove ∷-Stream #-}
-- Adapted from (Sander 1992, p. 59).
-- See Issue https://github.com/asr/apia/issues/81 .
streamLengthR : D → D → Set
streamLengthR m n = ∃[ xs ] Stream xs ∧ m ≡ length xs ∧ n ≡ ∞
{-# ATP definition streamLengthR #-}
streamLength : ∀ {xs} → Stream xs → length xs ≈ ∞
streamLength {xs} Sxs = ≈-coind streamLengthR h₁ h₂
where
postulate
h₁ : ∀ {m n} → streamLengthR m n →
m ≡ zero ∧ n ≡ zero
∨ (∃[ m' ] ∃[ n' ] m ≡ succ₁ m' ∧ n ≡ succ₁ n' ∧ streamLengthR m' n')
{-# ATP prove h₁ #-}
postulate h₂ : streamLengthR (length xs) ∞
{-# ATP prove h₂ #-}
------------------------------------------------------------------------------
-- References
--
-- Sander, Herbert P. (1992). A Logic of Functional Programs with an
-- Application to Concurrency. PhD thesis. Department of Computer
-- Sciences: Chalmers University of Technology and University of
-- Gothenburg.
| {
"alphanum_fraction": 0.5447909754,
"avg_line_length": 32.4086021505,
"ext": "agda",
"hexsha": "4631183a85938487769fe36747458b61dc951c0c",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "src/fot/FOTC/Data/Stream/PropertiesATP.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "src/fot/FOTC/Data/Stream/PropertiesATP.agda",
"max_line_length": 80,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "src/fot/FOTC/Data/Stream/PropertiesATP.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": 873,
"size": 3014
} |
open import Agda.Primitive public using (lzero)
{-# BUILTIN LEVELZERO lzero #-}
| {
"alphanum_fraction": 0.7317073171,
"avg_line_length": 16.4,
"ext": "agda",
"hexsha": "5cbd0ec9d8f88bf2e79a4683889c1ccb09c54e8a",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Fail/Issue3483.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Fail/Issue3483.agda",
"max_line_length": 47,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Issue3483.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": 82
} |
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary
module Algorithms.List.Sort.Common
{c l₁ l₂} (DTO : DecTotalOrder c l₁ l₂)
where
-- agda-stdlib
open import Data.List
import Data.List.Relation.Binary.Equality.Setoid as ListSetoidEquality
open import Data.List.Relation.Unary.AllPairs
open import Data.List.Relation.Unary.Linked
import Data.List.Relation.Unary.Linked.Properties as Linkedₚ
-- agda-misc
open import Experiment.ListRelationProperties using (Linked-resp-≋)
open DecTotalOrder DTO
open ListSetoidEquality Eq.setoid
Sorted : List Carrier → Set _
Sorted = Linked _≤_
toAllPairs : ∀ {xs} → Sorted xs → AllPairs _≤_ xs
toAllPairs = Linkedₚ.Linked⇒AllPairs trans
Sorted-resp-≋ : ∀ {xs ys} → xs ≋ ys → Sorted xs → Sorted ys
Sorted-resp-≋ = Linked-resp-≋ Eq.setoid ≤-resp-≈
| {
"alphanum_fraction": 0.7527950311,
"avg_line_length": 26.8333333333,
"ext": "agda",
"hexsha": "d84a596ffc5356d84ab13f6059d13dc91c3622b6",
"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": "37200ea91d34a6603d395d8ac81294068303f577",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "rei1024/agda-misc",
"max_forks_repo_path": "Algorithms/List/Sort/Common.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"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": "rei1024/agda-misc",
"max_issues_repo_path": "Algorithms/List/Sort/Common.agda",
"max_line_length": 70,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "rei1024/agda-misc",
"max_stars_repo_path": "Algorithms/List/Sort/Common.agda",
"max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z",
"num_tokens": 236,
"size": 805
} |
------------------------------------------------------------------------------
-- First-order logic base
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOL.Base where
infix 2 ⋀
infixr 1 _⇒_
infixr 0 _⇔_
------------------------------------------------------------------------------
-- First-order logic (without equality).
open import Common.FOL.FOL public
------------------------------------------------------------------------------
-- We added extra symbols for the implication, the biconditional and
-- the universal quantification (see module Common.FOL.FOL).
-- The implication data type.
data _⇒_ (A B : Set) : Set where
fun : (A → B) → A ⇒ B
app : {A B : Set} → A ⇒ B → A → B
app (fun f) a = f a
-- Biconditional.
_⇔_ : Set → Set → Set
A ⇔ B = (A ⇒ B) ∧ (B ⇒ A)
-- The universal quantifier type on D.
data ⋀ (A : D → Set) : Set where
dfun : ((t : D) → A t) → ⋀ A
-- Sugar syntax for the universal quantifier.
syntax ⋀ (λ x → e) = ⋀[ x ] e
dapp : {A : D → Set}(t : D) → ⋀ A → A t
dapp t (dfun f) = f t
------------------------------------------------------------------------------
-- In first-order logic it is assumed that the universe of discourse
-- is non-empty.
postulate D≢∅ : D
------------------------------------------------------------------------------
-- The ATPs work in classical logic, therefore we add the principle of
-- the exclude middle for prove some non-intuitionistic theorems. Note
-- that we do not need to add the postulate as an ATP axiom.
-- The principle of the excluded middle.
postulate pem : ∀ {A} → A ∨ ¬ A
| {
"alphanum_fraction": 0.4530635188,
"avg_line_length": 31.2105263158,
"ext": "agda",
"hexsha": "a60291d58ebf8ad0156e12de7733ed77d3f4f0cc",
"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/FOL/Base.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/FOL/Base.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/FOL/Base.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": 436,
"size": 1779
} |
module Thesis.RelateToValidity where
open import Relation.Binary.PropositionalEquality public hiding ([_])
open import Thesis.Changes
open import Thesis.Lang
module _ {A : Set} {{CA : ChangeStructure A}} where
fromto→valid fromto→valid-2 : ∀ da (a1 a2 : A) (daa : ch da from a1 to a2) → valid a1 da
fromto→valid da a1 a2 daa rewrite fromto→⊕ da a1 _ daa = daa
fromto→valid-2 da a1 a2 daa = subst (ch da from a1 to_) (sym (fromto→⊕ da a1 a2 daa)) daa
-- The "inverse" is so trivial to not be worth calling, hence commented out:
-- valid→fromto : ∀ da (a : A) → (valid a da) → ch da from a to (a ⊕ da)
-- valid→fromto _ _ daa = daa
module _
{A : Set} {B : Set} {{CA : ChangeStructure A}} {{CB : ChangeStructure B}} where
WellDefinedFunChangePoint : ∀ (f : A → B) → (df : Ch (A → B)) → ∀ a da → Set
WellDefinedFunChangePoint f df a da = (f ⊕ df) (a ⊕ da) ≡ f a ⊕ df a da
WellDefinedFunChangeFromTo′ : ∀ (f1 : A → B) → (df : Ch (A → B)) → Set
WellDefinedFunChangeFromTo′ f1 df = ∀ da a → valid a da → WellDefinedFunChangePoint f1 df a da
open ≡-Reasoning
open import Function
fromto-incrementalization : ∀ {f1 f2 : A → B} {df} → ch df from f1 to f2 →
∀ {da a} → valid a da →
f1 a ⊕ df a da ≡ f2 (a ⊕ da)
fromto-incrementalization {f1 = f1} {f2} {df} dff {da} {a} daa = fromto→⊕ _ _ _ (dff da a _ daa)
fromto→valid-fun : ∀ {f1 f2 : A → B} {df : Ch (A → B)} → ch df from f1 to f2 → ∀ {a da} (daa : valid a da) → valid (f1 a) (df a da)
fromto→valid-fun {f1} {f2} {df} dff {a} {da} daa = fromto→valid (df a da) (f1 a) _ (dff da a _ daa)
fromto→WellDefined′ : ∀ {f1 f2 df} → ch df from f1 to f2 →
WellDefinedFunChangeFromTo′ f1 df
fromto→WellDefined′ {f1 = f1} {f2} {df} dff da a daa =
begin
(f1 ⊕ df) (a ⊕ da)
≡⟨ cong (_$ (a ⊕ da)) (fromto→⊕ df f1 f2 dff)⟩
f2 (a ⊕ da)
≡⟨ sym (fromto-incrementalization dff daa) ⟩
f1 a ⊕ df a da
∎
-- Δ f is similar to function changes in PLDI'14, but PLDI'14 function changes
-- need not be defined on invalid changes; instead, if (df, dff) : Δ f, then
-- df is a function change that is also defined on invalid changes.
--
-- Next we define fΔ. It is closer to the PLDI'14 definition of function
-- changes; but it is not defined recursively, so it still produces new-style
-- function changes.
--
-- Hence this is sort of bigger than Δ f, though not really.
fΔ : (A → B) → Set
fΔ f = (a : A) → Δ₁ a → Δ₁ (f a)
-- We can indeed map Δ f into fΔ f, via valid-functions-map-Δ. If this mapping
-- were an injection, we could say that fΔ f is bigger than Δ f. But we'd need
-- first to quotient Δ f to turn valid-functions-map-Δ into an injection:
--
-- 1. We need to quotient Δ f by extensional equivalence of functions.
-- Luckily, we can just postulate it.
--
-- 2. We need to quotient Δ f by identifying functions that only differ by
-- behavior on invalid changes; such functions can't be distinguished after
-- being injected into fΔ f.
valid-functions-map-Δ : ∀ (f : A → B) (df : Δ₁ f) → fΔ f
valid-functions-map-Δ f (df , dff) a (da , daa) = df a da , valid-res
where
valid-res : ch df a da from f a to (f a ⊕ df a da)
valid-res rewrite sym (fromto→WellDefined′ dff da a daa) = dff da a (a ⊕ da) daa
-- Two alternative proofs
fromto-functions-map-Δ-1 fromto-functions-map-Δ-2 : ∀ (f1 f2 : A → B) (df : Ch (A → B)) → ch df from f1 to f2 → fΔ f1
fromto-functions-map-Δ-1 f1 f2 df dff a (da , daa) = valid-functions-map-Δ f1 (df , fromto→valid df f1 f2 dff) a (da , daa)
fromto-functions-map-Δ-2 f1 f2 df dff a (da , daa) = df a da , fromto→valid-fun dff daa
open import Thesis.LangChanges
fromto→WellDefined′Lang : ∀ {σ τ f1 f2 df} → [ σ ⇒ τ ]τ df from f1 to f2 →
WellDefinedFunChangeFromTo′ f1 df
fromto→WellDefined′Lang {f1 = f1} {f2} {df} dff da a daa =
fromto→WellDefined′ dff da a daa
| {
"alphanum_fraction": 0.6324961558,
"avg_line_length": 44.3409090909,
"ext": "agda",
"hexsha": "cdbf54ff6b05b3fef316bf7adfadb5d06ceb6ad3",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "inc-lc/ilc-agda",
"max_forks_repo_path": "Thesis/RelateToValidity.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "inc-lc/ilc-agda",
"max_issues_repo_path": "Thesis/RelateToValidity.agda",
"max_line_length": 133,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "inc-lc/ilc-agda",
"max_stars_repo_path": "Thesis/RelateToValidity.agda",
"max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z",
"num_tokens": 1462,
"size": 3902
} |
module Issue553a where
data D : Set where
d₁ d₂ : D
data E : Set where
module M (A : Set) where
data B : Set where
b : D → B
T : B → Set
T (b d₁) = E
T (b d₂) = E
open M E
g : (d : D) → T (b d) → D
g d t with d₁
g d t | d′ = d′ -- Unsolved meta-variable, no constraints.
| {
"alphanum_fraction": 0.5392491468,
"avg_line_length": 13.3181818182,
"ext": "agda",
"hexsha": "5d1d1184631adafe86be937b42b929e1a8d83d6f",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/Issue553a.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/Issue553a.agda",
"max_line_length": 59,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue553a.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": 122,
"size": 293
} |
module Data.Tuple.Raise where
open import Data.Tuple.Raiseᵣ public
| {
"alphanum_fraction": 0.8235294118,
"avg_line_length": 17,
"ext": "agda",
"hexsha": "efdee1d997ce32edb0c850ed0f733ceb1ed298c4",
"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/Raise.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/Raise.agda",
"max_line_length": 36,
"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/Raise.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": 18,
"size": 68
} |
------------------------------------------------------------------------
-- Some counterexamples
------------------------------------------------------------------------
{-# OPTIONS --sized-types #-}
module Bisimilarity.Up-to.Counterexamples where
open import Equality.Propositional
open import Logical-equivalence using (_⇔_)
open import Prelude
open import Prelude.Size
open import Bijection equality-with-J using (_↔_)
open import Equality.Decision-procedures equality-with-J
open import Fin equality-with-J
open import Function-universe equality-with-J hiding (id; _∘_)
open import Surjection equality-with-J using (_↠_)
open import Indexed-container using (Container; ν; ⟦_⟧; force)
open import Labelled-transition-system
import Up-to
import Bisimilarity
import Bisimilarity.Classical
open import Bisimilarity.Comparison
import Bisimilarity.Equational-reasoning-instances
import Bisimilarity.Step
import Bisimilarity.Up-to
open import Equational-reasoning
open import Relation
private
-- A combination of some parametrised modules.
module Combination {ℓ} (lts : LTS ℓ) where
open Bisimilarity lts public
open Bisimilarity.Classical lts public using (Progression)
open Bisimilarity.Up-to lts public
open LTS lts public hiding (_[_]⟶_)
private
module S =
Bisimilarity.Step lts (LTS._[_]⟶_ lts) (LTS._[_]⟶_ lts)
open S public using (Step; Step↔StepC) hiding (module Step)
module Step where
open S public using (⟨_,_⟩)
open S.Step public
-- There is a size-preserving relation transformer that is neither
-- monotone nor extensive.
∃size-preserving׬[monotone⊎extensive] :
∃ λ (lts : LTS lzero) →
let open Combination lts in
∃ λ (F : Trans₂ (# 0) Proc) →
Size-preserving F × ¬ (Monotone F ⊎ Extensive F)
∃size-preserving׬[monotone⊎extensive] =
one-loop , F , F-pres , [ ¬-F-mono , ¬-F-extensive ]
where
open Combination one-loop
F : Trans₂ (# 0) Proc
F R = ¬_ ∘ R
¬-F-mono : ¬ Monotone F
¬-F-mono =
Monotone F ↝⟨ (λ mono → mono {_}) ⟩
((λ _ → ⊥) ⊆ (λ _ → ↑ _ ⊤) → F (λ _ → ⊥) ⊆ F (λ _ → ↑ _ ⊤)) ↔⟨⟩
((λ _ → ⊥) ⊆ (λ _ → ↑ _ ⊤) → (λ _ → ¬ ⊥) ⊆ (λ _ → ¬ ↑ _ ⊤)) ↝⟨ _$ _ ⟩
(λ _ → ¬ ⊥) ⊆ (λ _ → ¬ ↑ _ ⊤) ↝⟨ (λ hyp → hyp {tt}) ⟩
(¬ ⊥ → ¬ ↑ _ ⊤) ↝⟨ _$ ⊥-elim ⟩
¬ ↑ _ ⊤ ↝⟨ _$ _ ⟩□
⊥ □
¬-F-extensive : ¬ Extensive F
¬-F-extensive =
Extensive F ↝⟨ (λ hyp → hyp _) ⟩
(↑ _ ⊤ → ¬ ↑ _ ⊤) ↝⟨ (_$ _) ∘ (_$ _) ⟩□
⊥ □
total : ∀ {i x y} → [ i ] x ∼ y
total = reflexive
F-pres : Size-preserving F
F-pres _ _ = total
-- A slight strengthening of the previous result, with a somewhat more
-- complicated proof: There are (at least two) size-preserving
-- relation transformers that are neither monotone nor extensive.
∃-2-size-preserving׬[monotone⊎extensive] :
∃ λ (lts : LTS lzero) →
let open Combination lts in
∃ λ (F : Trans₂ (# 0) Proc) →
∃ λ (G : Trans₂ (# 0) Proc) →
Size-preserving F × ¬ (Monotone F ⊎ Extensive F) ×
Size-preserving G × ¬ (Monotone G ⊎ Extensive G) ×
F ≢ G
∃-2-size-preserving׬[monotone⊎extensive] =
lts
, F ⊤ , F ⊥
, F-pres , [ ¬-F-mono , ¬-F-extensive ]
, F-pres , [ ¬-F-mono , ¬-F-extensive ]
, F⊤≢F⊥
where
lts : LTS lzero
lts = record
{ Proc = Bool
; Label = ⊥
; _[_]⟶_ = λ _ ()
; is-silent = λ ()
}
open Combination lts
F : Type → Trans₂ (# 0) Bool
F A R p@(true , false) = R p × A
F A R p@(false , true) = R p
F A R p = ¬ R p
¬-F-mono : ∀ {A} → ¬ Monotone (F A)
¬-F-mono {A} =
Monotone (F A) ↝⟨ (λ mono → mono {_}) ⟩
((λ _ → ⊥) ⊆ (λ _ → ↑ _ ⊤) → F A (λ _ → ⊥) ⊆ F A (λ _ → ↑ _ ⊤)) ↝⟨ (λ hyp {p} → hyp _ {p}) ⟩
F A (λ _ → ⊥) ⊆ F A (λ _ → ↑ _ ⊤) ↝⟨ (λ hyp → hyp {true , true}) ⟩
(¬ ⊥ → ¬ ↑ _ ⊤) ↝⟨ _$ ⊥-elim ⟩
¬ ↑ _ ⊤ ↝⟨ _$ _ ⟩□
⊥ □
¬-F-extensive : ∀ {A} → ¬ Extensive (F A)
¬-F-extensive {A} =
Extensive (F A) ↝⟨ (λ hyp → hyp (λ _ → ↑ _ ⊤) {true , true}) ⟩
(↑ _ ⊤ → ¬ ↑ _ ⊤) ↝⟨ (_$ _) ∘ (_$ _) ⟩□
⊥ □
F-pres : ∀ {A} → Size-preserving (F A)
F-pres R⊆∼i {true , false} = R⊆∼i ∘ proj₁
F-pres R⊆∼i {false , true} = R⊆∼i
F-pres _ {true , true} = λ _ → true ■
F-pres _ {false , false} = λ _ → false ■
F⊤≢F⊥ : F ⊤ ≢ F ⊥
F⊤≢F⊥ =
F ⊤ ≡ F ⊥ ↝⟨ subst (λ F → F (λ _ → ⊤) (true , false)) ⟩
(F ⊤ (λ _ → ⊤) (true , false) → F ⊥ (λ _ → ⊤) (true , false)) ↔⟨⟩
(⊤ × ⊤ → ⊤ × ⊥) ↝⟨ proj₂ ∘ (_$ _) ⟩□
⊥ □
-- There is a container C such that there are (at least two) relation
-- transformers satisfying λ F → ∀ {i} → F (ν C i) ⊆ ν C i that are
-- not up-to techniques with respect to C.
∃special-case-of-size-preserving׬up-to :
∃ λ (I : Type) →
∃ λ (C : Container I I) →
∃ λ (F : Trans (# 0) I) →
∃ λ (G : Trans (# 0) I) →
(∀ {i} → F (ν C i) ⊆ ν C i) × ¬ Up-to.Up-to-technique C F ×
(∀ {i} → G (ν C i) ⊆ ν C i) × ¬ Up-to.Up-to-technique C G ×
F ≢ G
∃special-case-of-size-preserving׬up-to =
(Proc × Proc)
, StepC
, G ⊤ , G ⊥
, bisimilarity-pre-fixpoint
, ¬-up-to
, bisimilarity-pre-fixpoint
, ¬-up-to
, G⊤≢G⊥
where
data Proc : Type where
p q r : Proc
data _⟶_ : Proc → Proc → Type where
p : p ⟶ p
q : q ⟶ r
lts = record
{ Proc = Proc
; Label = ⊤
; _[_]⟶_ = λ p _ q → p ⟶ q
; is-silent = λ _ → false
}
open Combination lts hiding (Proc)
G : Type → Trans₂ (# 0) Proc
G A R x = R (r , r) → ¬ R (p , r) → R x × A
p≁r : ∀ {i} → ¬ Bisimilarity i (p , r)
p≁r hyp with left-to-right hyp p
... | _ , () , _
bisimilarity-pre-fixpoint :
∀ {A i} → G A (Bisimilarity i) ⊆ Bisimilarity i
bisimilarity-pre-fixpoint hyp = proj₁ (hyp reflexive p≁r)
data S : Rel₂ (# 0) Proc where
pq : S (p , q)
S⊆StepGS : ∀ {A} → S ⊆ Step (G A S)
Step.left-to-right (S⊆StepGS pq) p = r , q , λ ()
Step.right-to-left (S⊆StepGS pq) q = p , p , λ ()
p≁q : ¬ Bisimilarity ∞ (p , q)
p≁q hyp with left-to-right hyp p
... | r , q , p∼r = p≁r (force p∼r)
¬-up-to : ∀ {A} → ¬ Up-to-technique (G A)
¬-up-to {A} =
Up-to-technique (G A) ↝⟨ (λ up-to → up-to) ⟩
(S ⊆ ⟦ StepC ⟧ (G A S) → S ⊆ Bisimilarity ∞) ↝⟨ (λ hyp below → hyp (Step↔StepC _ ∘ below)) ⟩
(S ⊆ Step (G A S) → S ⊆ Bisimilarity ∞) ↝⟨ _$ S⊆StepGS ⟩
S ⊆ Bisimilarity ∞ ↝⟨ _$ pq ⟩
Bisimilarity ∞ (p , q) ↝⟨ p≁q ⟩□
⊥ □
G⊤≢G⊥ : G ⊤ ≢ G ⊥
G⊤≢G⊥ =
G ⊤ ≡ G ⊥ ↝⟨ subst (λ G → G (uncurry _≡_) (q , q)) ⟩
(G ⊤ (uncurry _≡_) (q , q) → G ⊥ (uncurry _≡_) (q , q)) ↔⟨⟩
((r ≡ r → p ≢ r → q ≡ q × ⊤) → (r ≡ r → p ≢ r → q ≡ q × ⊥)) ↝⟨ _$ (λ _ _ → refl , _) ⟩
(r ≡ r → p ≢ r → q ≡ q × ⊥) ↝⟨ proj₂ ∘ (_$ λ ()) ∘ (_$ refl) ⟩□
⊥ □
-- There is a container C such that there are (at least two) relation
-- transformers satisfying λ F → ∀ {i} → F (ν C i) ⊆ ν C i that are
-- not size-preserving with respect to C.
∃special-case-of-size-preserving׬size-preserving :
∃ λ (I : Type) →
∃ λ (C : Container I I) →
∃ λ (F : Trans (# 0) I) →
∃ λ (G : Trans (# 0) I) →
(∀ {i} → F (ν C i) ⊆ ν C i) × ¬ Up-to.Size-preserving C F ×
(∀ {i} → G (ν C i) ⊆ ν C i) × ¬ Up-to.Size-preserving C G ×
F ≢ G
∃special-case-of-size-preserving׬size-preserving =
Σ-map id (Σ-map id (Σ-map id (Σ-map id (Σ-map id
(Σ-map (_∘ Up-to.size-preserving→up-to _) (Σ-map id
(Σ-map (_∘ Up-to.size-preserving→up-to _) id)))))))
∃special-case-of-size-preserving׬up-to
-- There is a monotone, extensive and size-preserving relation
-- transformer that is not compatible.
∃monotone×extensive×size-preserving׬compatible :
∃ λ (lts : LTS lzero) →
let open Combination lts in
∃ λ (F : Trans₂ (# 0) Proc) →
Monotone F × Extensive F × Size-preserving F × ¬ Compatible F
∃monotone×extensive×size-preserving׬compatible =
one-transition
, F
, mono
, extensive
, pres
, ¬comp
where
-- An LTS with two distinct processes and one transition from one to
-- the other.
one-transition : LTS lzero
one-transition = record
{ Proc = Bool
; Label = ⊤
; _[_]⟶_ = λ x _ y → T (x ∧ not y)
; is-silent = λ _ → false
}
open Combination one-transition
-- A relation transformer.
F : Trans₂ (# 0) Proc
F R (true , true) = R (false , false) ⊎ R (true , true)
F R = R
-- F is monotone.
mono : Monotone F
mono R⊆S {true , true} = ⊎-map R⊆S R⊆S
mono R⊆S {true , false} = R⊆S
mono R⊆S {false , true} = R⊆S
mono R⊆S {false , false} = R⊆S
-- F is extensive.
extensive : Extensive F
extensive R {true , true} = inj₂
extensive R {true , false} = id
extensive R {false , true} = id
extensive R {false , false} = id
-- Bisimilarity of size i is a pre-fixpoint of F.
pre : ∀ {i} → F (Bisimilarity i) ⊆ Bisimilarity i
pre {x = true , true} = λ _ → true ■
pre {x = true , false} = id
pre {x = false , true} = id
pre {x = false , false} = id
-- F is size-preserving.
pres : Size-preserving F
pres = _⇔_.from (monotone→⇔ mono) (λ {_ x} → pre {x = x})
-- A relation.
R : Rel₂ (# 0) Proc
R _ = ⊥
-- A lemma.
StepRff : Step R (false , false)
Step.left-to-right StepRff ()
Step.right-to-left StepRff ()
-- F is not compatible.
¬comp : ¬ Compatible F
¬comp =
Compatible F ↝⟨ (λ comp {x} → comp {x = x}) ⟩
F (⟦ StepC ⟧ R) ⊆ ⟦ StepC ⟧ (F R) ↝⟨ (λ le → le {true , true}) ⟩
(F (⟦ StepC ⟧ R) (true , true) → ⟦ StepC ⟧ (F R) (true , true)) ↔⟨⟩
(⟦ StepC ⟧ R (false , false) ⊎ ⟦ StepC ⟧ R (true , true) →
⟦ StepC ⟧ (F R) (true , true)) ↝⟨ _$ inj₁ (_⇔_.to (Step↔StepC _) StepRff) ⟩
⟦ StepC ⟧ (F R) (true , true) ↝⟨ (λ step → StepC.left-to-right {p = true} {q = true} step {p′ = false} _ ) ⟩
(∃ λ y → T (not y) × F R (false , y)) ↔⟨⟩
(∃ λ y → T (not y) × ⊥) ↝⟨ proj₂ ∘ proj₂ ⟩□
⊥ □
-- An LTS used in a couple of lemmas below, along with some
-- properties.
module PQR where
-- An LTS with two sets of processes, three "to the left", and three
-- "to the right".
Side : Type
Side = Bool
pattern left = true
pattern right = false
data Process : Type where
p q r : Side → Process
data Label : Type where
pq pr : Label
qq rr : Side → Label
infix 4 _[_]⟶_
data _[_]⟶_ : Process → Label → Process → Type where
pq : ∀ {s} → p s [ pq ]⟶ q s
pr : ∀ {s} → p s [ pr ]⟶ r s
qq : ∀ {s} → q s [ qq s ]⟶ q s
rr : ∀ {s} → r s [ rr s ]⟶ r s
lts : LTS lzero
lts = record
{ Proc = Process
; Label = Label
; _[_]⟶_ = _[_]⟶_
; is-silent = λ _ → false
}
open Combination lts public hiding (Label)
-- Two relation transformers: F and G both add (at most) one pair to
-- the underlying relation.
data F (R : Rel₂ (# 0) Proc) : Rel₂ (# 0) Proc where
qq : F R (q left , q right)
[_] : ∀ {x} → R x → F R x
data G (R : Rel₂ (# 0) Proc) : Rel₂ (# 0) Proc where
rr : G R (r left , r right)
[_] : ∀ {x} → R x → G R x
-- A relation that adds one pair to reflexivity.
data S : Rel₂ (# 0) Proc where
pp : S (p left , p right)
refl : ∀ {x} → S (x , x)
-- S progresses to F (G S).
S-prog : Progression S (F (G S))
S-prog pp = Step.⟨ (λ where
pq → _ , pq , qq
pr → _ , pr , [ rr ])
, (λ where
pq → _ , pq , qq
pr → _ , pr , [ rr ])
⟩
S-prog refl = Step.⟨ (λ where
pq → _ , pq , [ [ refl ] ]
pr → _ , pr , [ [ refl ] ]
qq → _ , qq , [ [ refl ] ]
rr → _ , rr , [ [ refl ] ])
, (λ where
pq → _ , pq , [ [ refl ] ]
pr → _ , pr , [ [ refl ] ]
qq → _ , qq , [ [ refl ] ]
rr → _ , rr , [ [ refl ] ])
⟩
S-prog′ : S ⊆ ⟦ StepC ⟧ (F (G S))
S-prog′ Sx = _⇔_.to (Step↔StepC _) (S-prog Sx)
-- The two processes q left and q right are not bisimilar.
q≁q : ¬ q left ∼ q right
q≁q =
q left ∼ q right ↝⟨ (λ rel → StepC.left-to-right rel qq) ⟩
(∃ λ y → q right [ qq left ]⟶ y × q left ∼′ y) ↝⟨ (λ { (_ , () , _) }) ⟩□
⊥ □
-- The two processes r left and r right are not bisimilar.
r≁r : ¬ r left ∼ r right
r≁r =
r left ∼ r right ↝⟨ (λ rel → StepC.left-to-right rel rr) ⟩
(∃ λ y → r right [ rr left ]⟶ y × r left ∼′ y) ↝⟨ (λ { (_ , () , _) }) ⟩□
⊥ □
-- F ∘ G is not an up-to technique.
¬-F∘G-up-to : ¬ Up-to-technique (F ∘ G)
¬-F∘G-up-to =
Up-to-technique (F ∘ G) ↝⟨ (λ up-to → up-to S-prog′) ⟩
S ⊆ Bisimilarity ∞ ↝⟨ (λ le → le pp) ⟩
p left ∼ p right ↝⟨ (λ rel → StepC.left-to-right rel pq) ⟩
(∃ λ y → p right [ pq ]⟶ y × q left ∼′ y) ↝⟨ (λ { (.(q right) , pq , rel) → rel }) ⟩
q left ∼′ q right ↝⟨ (λ rel → q≁q (force rel)) ⟩
⊥ □
-- F is not equal to G.
F≢G : F ≢ G
F≢G =
F ≡ G ↝⟨ subst (λ F → F (λ _ → ⊥) (q left , q right)) ⟩
(F (λ _ → ⊥) (q left , q right) → G (λ _ → ⊥) (q left , q right)) ↝⟨ _$ qq ⟩
G (λ _ → ⊥) (q left , q right) ↝⟨ (λ { [ () ] }) ⟩□
⊥ □
module F-lemmas where
-- F is monotone.
mono : Monotone F
mono R⊆S qq = qq
mono R⊆S [ Rxy ] = [ R⊆S Rxy ]
-- F is extensive.
ext : Extensive F
ext = λ _ → [_]
-- F is not size-preserving.
¬-pres : ¬ Size-preserving F
¬-pres =
Size-preserving F ↝⟨ (λ pres → _⇔_.to (monotone→⇔ mono) pres) ⟩
F (Bisimilarity ∞) ⊆ Bisimilarity ∞ ↝⟨ _$ qq ⟩
q left ∼ q right ↝⟨ q≁q ⟩□
⊥ □
-- F is an up-to technique.
module _ {R} (R-prog′ : R ⊆ ⟦ StepC ⟧ (F R)) where
R-prog : Progression R (F R)
R-prog Rx = _⇔_.from (Step↔StepC _) (R-prog′ Rx)
¬rr : ∀ {s} → ¬ R (r s , r (not s))
¬rr rel with Progression.left-to-right R-prog rel rr
¬rr {true} _ | _ , () , _
¬rr {false} _ | _ , () , _
¬qq : ∀ {s} → ¬ R (q s , q (not s))
¬qq rel with Progression.left-to-right R-prog rel qq
¬qq {true} _ | _ , () , _
¬qq {false} _ | _ , () , _
¬pp : ∀ {s} → ¬ R (p s , p (not s))
¬pp rel with Progression.left-to-right R-prog rel pr
... | .(r _) , pr , [ rel′ ] = ¬rr rel′
¬pq : ∀ {s₁ s₂} → ¬ R (p s₁ , q s₂)
¬pq rel with Progression.left-to-right R-prog rel pq
... | _ , () , _
¬qp : ∀ {s₁ s₂} → ¬ R (q s₁ , p s₂)
¬qp rel with Progression.right-to-left R-prog rel pq
... | _ , () , _
¬pr : ∀ {s₁ s₂} → ¬ R (p s₁ , r s₂)
¬pr rel with Progression.left-to-right R-prog rel pq
... | _ , () , _
¬rp : ∀ {s₁ s₂} → ¬ R (r s₁ , p s₂)
¬rp rel with Progression.right-to-left R-prog rel pq
... | _ , () , _
¬qr : ∀ {s₁ s₂} → ¬ R (q s₁ , r s₂)
¬qr rel with Progression.right-to-left R-prog rel rr
... | _ , () , _
¬rq : ∀ {s₁ s₂} → ¬ R (r s₁ , q s₂)
¬rq rel with Progression.left-to-right R-prog rel rr
... | _ , () , _
up-to : R ⊆ Bisimilarity ∞
up-to {p left , p left} rel = reflexive
up-to {p left , p right} rel = ⊥-elim (¬pp rel)
up-to {p right , p left} rel = ⊥-elim (¬pp rel)
up-to {p right , p right} rel = reflexive
up-to {p _ , q _} rel = ⊥-elim (¬pq rel)
up-to {p _ , r _} rel = ⊥-elim (¬pr rel)
up-to {q _ , p _} rel = ⊥-elim (¬qp rel)
up-to {q left , q left} rel = reflexive
up-to {q left , q right} rel = ⊥-elim (¬qq rel)
up-to {q right , q left} rel = ⊥-elim (¬qq rel)
up-to {q right , q right} rel = reflexive
up-to {q _ , r _} rel = ⊥-elim (¬qr rel)
up-to {r _ , p _} rel = ⊥-elim (¬rp rel)
up-to {r _ , q _} rel = ⊥-elim (¬rq rel)
up-to {r left , r left} rel = reflexive
up-to {r left , r right} rel = ⊥-elim (¬rr rel)
up-to {r right , r left} rel = ⊥-elim (¬rr rel)
up-to {r right , r right} rel = reflexive
module G-lemmas where
-- G is monotone.
mono : Monotone G
mono R⊆S rr = rr
mono R⊆S [ Rxy ] = [ R⊆S Rxy ]
-- G is extensive.
ext : Extensive G
ext = λ _ → [_]
-- G is not size-preserving.
¬-pres : ¬ Size-preserving G
¬-pres =
Size-preserving G ↝⟨ (λ pres → _⇔_.to (monotone→⇔ mono) pres) ⟩
G (Bisimilarity ∞) ⊆ Bisimilarity ∞ ↝⟨ _$ rr ⟩
r left ∼ r right ↝⟨ r≁r ⟩□
⊥ □
-- G is an up-to technique.
module _ {R} (R-prog′ : R ⊆ ⟦ StepC ⟧ (G R)) where
R-prog : Progression R (G R)
R-prog Rx = _⇔_.from (Step↔StepC _) (R-prog′ Rx)
¬rr : ∀ {s} → ¬ R (r s , r (not s))
¬rr rel with Progression.left-to-right R-prog rel rr
¬rr {true} _ | _ , () , _
¬rr {false} _ | _ , () , _
¬qq : ∀ {s} → ¬ R (q s , q (not s))
¬qq rel with Progression.left-to-right R-prog rel qq
¬qq {true} _ | _ , () , _
¬qq {false} _ | _ , () , _
¬pp : ∀ {s} → ¬ R (p s , p (not s))
¬pp rel with Progression.left-to-right R-prog rel pq
... | .(q _) , pq , [ rel′ ] = ¬qq rel′
¬pq : ∀ {s₁ s₂} → ¬ R (p s₁ , q s₂)
¬pq rel with Progression.left-to-right R-prog rel pq
... | _ , () , _
¬qp : ∀ {s₁ s₂} → ¬ R (q s₁ , p s₂)
¬qp rel with Progression.right-to-left R-prog rel pq
... | _ , () , _
¬pr : ∀ {s₁ s₂} → ¬ R (p s₁ , r s₂)
¬pr rel with Progression.left-to-right R-prog rel pq
... | _ , () , _
¬rp : ∀ {s₁ s₂} → ¬ R (r s₁ , p s₂)
¬rp rel with Progression.right-to-left R-prog rel pq
... | _ , () , _
¬qr : ∀ {s₁ s₂} → ¬ R (q s₁ , r s₂)
¬qr rel with Progression.right-to-left R-prog rel rr
... | _ , () , _
¬rq : ∀ {s₁ s₂} → ¬ R (r s₁ , q s₂)
¬rq rel with Progression.left-to-right R-prog rel rr
... | _ , () , _
up-to : R ⊆ Bisimilarity ∞
up-to {p left , p left} rel = reflexive
up-to {p left , p right} rel = ⊥-elim (¬pp rel)
up-to {p right , p left} rel = ⊥-elim (¬pp rel)
up-to {p right , p right} rel = reflexive
up-to {p _ , q _} rel = ⊥-elim (¬pq rel)
up-to {p _ , r _} rel = ⊥-elim (¬pr rel)
up-to {q _ , p _} rel = ⊥-elim (¬qp rel)
up-to {q left , q left} rel = reflexive
up-to {q left , q right} rel = ⊥-elim (¬qq rel)
up-to {q right , q left} rel = ⊥-elim (¬qq rel)
up-to {q right , q right} rel = reflexive
up-to {q _ , r _} rel = ⊥-elim (¬qr rel)
up-to {r _ , p _} rel = ⊥-elim (¬rp rel)
up-to {r _ , q _} rel = ⊥-elim (¬rq rel)
up-to {r left , r left} rel = reflexive
up-to {r left , r right} rel = ⊥-elim (¬rr rel)
up-to {r right , r left} rel = ⊥-elim (¬rr rel)
up-to {r right , r right} rel = reflexive
-- There are monotone and extensive up-to techniques F and G such
-- that F ∘ G is not an up-to-technique.
--
-- Pous and Sangiorgi discuss another instance of this property in
-- Section 6.5.4 of "Enhancements of the bisimulation proof method".
∃[monotone×extensive×up-to]²×¬∘-up-to :
∃ λ (lts : LTS lzero) →
let open Combination lts in
∃ λ (F : Trans₂ (# 0) Proc) →
∃ λ (G : Trans₂ (# 0) Proc) →
Monotone F × Extensive F × Up-to-technique F ×
Monotone G × Extensive G × Up-to-technique G ×
¬ Up-to-technique (F ∘ G)
∃[monotone×extensive×up-to]²×¬∘-up-to =
lts
, F
, G
, F-lemmas.mono
, F-lemmas.ext
, F-lemmas.up-to
, G-lemmas.mono
, G-lemmas.ext
, G-lemmas.up-to
, ¬-F∘G-up-to
where
open PQR
-- It is not the case that every monotone and extensive up-to
-- technique is size-preserving.
¬monotone×extensive×up-to→size-preserving :
∃ λ (lts : LTS lzero) →
let open Combination lts in
¬ (∀ {F} → Monotone F → Extensive F → Up-to-technique F →
Size-preserving F)
¬monotone×extensive×up-to→size-preserving =
lts
, λ up-to→pres →
¬-F∘G-up-to $
size-preserving→up-to $
∘-closure (up-to→pres F-lemmas.mono F-lemmas.ext F-lemmas.up-to)
(up-to→pres G-lemmas.mono G-lemmas.ext G-lemmas.up-to)
where
open PQR
-- Up-to-technique is not closed under composition, not even for
-- monotone and extensive relation transformers.
¬-∘-closure :
∃ λ (lts : LTS lzero) →
let open Combination lts in
¬ ({F G : Trans₂ (# 0) Proc} →
Monotone F → Extensive F →
Monotone G → Extensive G →
Up-to-technique F →
Up-to-technique G →
Up-to-technique (F ∘ G))
¬-∘-closure =
lts
, λ ∘-closure →
¬-F∘G-up-to (∘-closure F-lemmas.mono F-lemmas.ext
G-lemmas.mono G-lemmas.ext
F-lemmas.up-to G-lemmas.up-to)
where
open PQR
-- There are (at least two) monotone and extensive up-to techniques
-- that are not size-preserving.
∃monotone×extensive×up-to׬size-preserving :
∃ λ (lts : LTS lzero) →
let open Combination lts in
∃ λ (F : Trans₂ (# 0) Proc) →
∃ λ (G : Trans₂ (# 0) Proc) →
Monotone F × Extensive F × Up-to-technique F × ¬ Size-preserving F ×
Monotone G × Extensive G × Up-to-technique G × ¬ Size-preserving G ×
F ≢ G
∃monotone×extensive×up-to׬size-preserving =
lts
, F , G
, F-lemmas.mono
, F-lemmas.ext
, F-lemmas.up-to
, F-lemmas.¬-pres
, G-lemmas.mono
, G-lemmas.ext
, G-lemmas.up-to
, G-lemmas.¬-pres
, F≢G
where
open PQR
| {
"alphanum_fraction": 0.4632103432,
"avg_line_length": 31.8481532148,
"ext": "agda",
"hexsha": "11783e699013502c0400723d13d50aa92f4910a6",
"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": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/up-to",
"max_forks_repo_path": "src/Bisimilarity/Up-to/Counterexamples.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"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/up-to",
"max_issues_repo_path": "src/Bisimilarity/Up-to/Counterexamples.agda",
"max_line_length": 147,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/up-to",
"max_stars_repo_path": "src/Bisimilarity/Up-to/Counterexamples.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 8591,
"size": 23281
} |
-- Copyright: (c) 2016 Ertugrul Söylemez
-- License: BSD3
-- Maintainer: Ertugrul Söylemez <[email protected]>
module Classes where
record Plus {a} (A : Set a) : Set a where
field
_+_ : A → A → A
infixl 6 _+_
open Plus {{...}} public
record Times {a} (A : Set a) : Set a where
field
{{plus}} : Plus A
_*_ : A → A → A
infixl 7 _*_
open Times {{...}} public
| {
"alphanum_fraction": 0.5792207792,
"avg_line_length": 15.4,
"ext": "agda",
"hexsha": "eb8eac7c901a4a32c6e009c5614ec17934bab6dd",
"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": "d9245e5a8b2e902781736de09bd17e81022f6f13",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "esoeylemez/agda-simple",
"max_forks_repo_path": "Classes.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d9245e5a8b2e902781736de09bd17e81022f6f13",
"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": "esoeylemez/agda-simple",
"max_issues_repo_path": "Classes.agda",
"max_line_length": 48,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "d9245e5a8b2e902781736de09bd17e81022f6f13",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "esoeylemez/agda-simple",
"max_stars_repo_path": "Classes.agda",
"max_stars_repo_stars_event_max_datetime": "2019-10-07T17:36:42.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-10-07T17:36:42.000Z",
"num_tokens": 147,
"size": 385
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Groups.Lemmas
open import Groups.Definition
open import Setoids.Setoids
open import Rings.Definition
open import Sets.EquivalenceRelations
open import Rings.IntegralDomains.Definition
module Rings.IntegralDomains.Lemmas {m n : _} {A : Set n} {S : Setoid {n} {m} A} {_+_ _*_ : A → A → A} {R : Ring S _+_ _*_} (I : IntegralDomain R) where
open Setoid S
open Equivalence eq
open Ring R
cancelIntDom : {a b c : A} → (a * b) ∼ (a * c) → ((a ∼ (Ring.0R R)) → False) → (b ∼ c)
cancelIntDom {a} {b} {c} ab=ac a!=0 = transferToRight (Ring.additiveGroup R) t3
where
t1 : (a * b) + Group.inverse (Ring.additiveGroup R) (a * c) ∼ Ring.0R R
t1 = transferToRight'' (Ring.additiveGroup R) ab=ac
t2 : a * (b + Group.inverse (Ring.additiveGroup R) c) ∼ Ring.0R R
t2 = transitive (transitive (Ring.*DistributesOver+ R) (Group.+WellDefined (Ring.additiveGroup R) reflexive (transferToRight' (Ring.additiveGroup R) (transitive (symmetric (Ring.*DistributesOver+ R)) (transitive (Ring.*WellDefined R reflexive (Group.invLeft (Ring.additiveGroup R))) (Ring.timesZero R)))))) t1
t3 : (b + Group.inverse (Ring.additiveGroup R) c) ∼ Ring.0R R
t3 = IntegralDomain.intDom I t2 a!=0
cancelIntDom' : {a b c : A} → (a * c) ∼ (b * c) → (c ∼ Ring.0R R → False) → a ∼ b
cancelIntDom' pr n = cancelIntDom (transitive *Commutative (transitive pr *Commutative)) n
| {
"alphanum_fraction": 0.6793103448,
"avg_line_length": 50,
"ext": "agda",
"hexsha": "e7f9d142bbca0054788d800ec582598319216613",
"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/IntegralDomains/Lemmas.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Rings/IntegralDomains/Lemmas.agda",
"max_line_length": 313,
"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/IntegralDomains/Lemmas.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z",
"num_tokens": 504,
"size": 1450
} |
------------------------------------------------------------------------
-- INCREMENTAL λ-CALCULUS
--
-- Reexport Data.List.All from the standard library.
--
-- At one point, we reinvented Data.List.All from the Agda
-- standard library, under the name dependent list. We later
-- replaced our reinvention by this adapter module that just
-- exports the standard library's version with partly different
-- names.
------------------------------------------------------------------------
module Base.Data.DependentList where
open import Data.List.All public
using
( head
; tail
; map
; tabulate
)
renaming
( All to DependentList
; _∷_ to _•_
; [] to ∅
)
-- Maps a binary function over two dependent lists.
-- Should this be in the Agda standard library?
zipWith : ∀ {a p q r} {A : Set a} {P : A → Set p} {Q : A → Set q} {R : A → Set r} →
(f : {a : A} → P a → Q a → R a) →
∀ {xs} → DependentList P xs → DependentList Q xs → DependentList R xs
zipWith f ∅ ∅ = ∅
zipWith f (p • ps) (q • qs) = f p q • zipWith f ps qs
| {
"alphanum_fraction": 0.5486307838,
"avg_line_length": 30.2571428571,
"ext": "agda",
"hexsha": "1eee78bff8ec411aee192e49b1aaca2df5beaaac",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "inc-lc/ilc-agda",
"max_forks_repo_path": "Base/Data/DependentList.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "inc-lc/ilc-agda",
"max_issues_repo_path": "Base/Data/DependentList.agda",
"max_line_length": 83,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "inc-lc/ilc-agda",
"max_stars_repo_path": "Base/Data/DependentList.agda",
"max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z",
"num_tokens": 294,
"size": 1059
} |
{-# OPTIONS --without-K --exact-split --safe #-}
open import Fragment.Algebra.Signature
module Fragment.Algebra.Free.Properties (Σ : Signature) where
open import Level using (Level)
open import Function using (_∘_)
open import Fragment.Algebra.Algebra Σ
open import Fragment.Algebra.Free.Base Σ
open import Fragment.Algebra.Free.Evaluation Σ
open import Fragment.Algebra.Free.Monad Σ
open import Fragment.Algebra.Homomorphism Σ
open import Fragment.Algebra.Quotient Σ
open import Fragment.Setoid.Morphism as M
hiding (∣_∣; ∣_∣-cong; id; _≗_)
open import Data.Fin using (Fin)
open import Data.Vec using (Vec; []; _∷_; map)
open import Data.Vec.Properties using (map-∘)
open import Data.Vec.Relation.Binary.Pointwise.Inductive as PW
using (Pointwise; Pointwise-≡⇒≡; []; _∷_)
import Relation.Binary.Reasoning.Setoid as Reasoning
open import Relation.Binary using (Setoid; Rel; IsEquivalence)
open import Relation.Binary.PropositionalEquality as PE using (_≡_)
private
variable
a b c ℓ₁ ℓ₂ ℓ₃ : Level
module _
{A : Algebra {a} {ℓ₁}}
(h : Free ∥ A ∥/≈ ⟿ A)
(inj : ∣ h ∣⃗ · unit M.≗ M.id)
where
open Setoid ∥ A ∥/≈
open Reasoning ∥ A ∥/≈
mutual
map-∣eval∣-universal : ∀ {n} {xs : Vec (Term ∥ A ∥) n}
→ Pointwise (≈[ A ]) (map ∣ h ∣ xs)
(map ∣ eval A ∣ xs)
map-∣eval∣-universal {_} {[]} = []
map-∣eval∣-universal {_} {x ∷ xs} =
eval-universal {x} ∷ map-∣eval∣-universal {_} {xs}
eval-universal : h ≗ eval A
eval-universal {atom x} = inj
eval-universal {term f xs} = begin
∣ h ∣ (term f xs)
≈⟨ sym (∣ h ∣-hom f xs) ⟩
A ⟦ f ⟧ (map ∣ h ∣ xs)
≈⟨ (A ⟦ f ⟧-cong) map-∣eval∣-universal ⟩
A ⟦ f ⟧ (map ∣ eval A ∣ xs)
≈⟨ ∣ eval A ∣-hom f xs ⟩
∣ eval A ∣ (term f xs)
∎
module _
{A : Setoid a ℓ₁}
{B : Setoid b ℓ₂}
(f : A ↝ Herbrand B)
where
bind-unitₗ : ∣ bind f ∣⃗ · unit M.≗ f
bind-unitₗ = Setoid.refl (Herbrand B)
module _ {A : Setoid a ℓ₁} where
open Setoid ∥ Free A ∥/≈
open Reasoning ∥ Free A ∥/≈
mutual
map-∣bind∣-unitʳ : ∀ {n} → {xs : Vec ∥ Free A ∥ n}
→ Pointwise ≈[ Free A ] (map ∣ bind {B = A} unit ∣ xs) xs
map-∣bind∣-unitʳ {xs = []} = []
map-∣bind∣-unitʳ {xs = x ∷ xs} = bind-unitʳ ∷ map-∣bind∣-unitʳ
bind-unitʳ : bind {B = A} unit ≗ id
bind-unitʳ {atom _} = Setoid.refl (Herbrand A)
bind-unitʳ {term f xs} = begin
∣ bind {B = A} unit ∣ (term f xs)
≈⟨ sym (∣ bind unit ∣-hom f xs) ⟩
term f (map ∣ bind {B = A} unit ∣ xs)
≈⟨ term map-∣bind∣-unitʳ ⟩
term f xs
∎
module _
{A : Setoid a ℓ₁}
{B : Setoid b ℓ₂}
{C : Setoid c ℓ₃}
(g : B ↝ Herbrand C)
(f : A ↝ Herbrand B)
where
open Setoid ∥ Free C ∥/≈
open Reasoning ∥ Free C ∥/≈
mutual
map-∣bind∣-assoc : ∀ {n} → {xs : Vec ∥ Free A ∥ n}
→ Pointwise (≈[ Free C ])
(map (∣ bind g ∣ ∘ ∣ bind f ∣) xs)
(map ∣ bind (∣ bind g ∣⃗ · f) ∣ xs)
map-∣bind∣-assoc {xs = []} = []
map-∣bind∣-assoc {xs = x ∷ xs} = bind-assoc {x} ∷ map-∣bind∣-assoc
bind-assoc : bind g ⊙ bind f ≗ bind (∣ bind g ∣⃗ · f)
bind-assoc {atom _} = refl
bind-assoc {term op xs} = begin
∣ bind g ∣ (∣ bind f ∣ (term op xs))
≈⟨ sym (∣ bind g ∣-cong (∣ bind f ∣-hom op xs)) ⟩
∣ bind g ∣ (term op (map ∣ bind f ∣ xs))
≈⟨ sym (∣ bind g ∣-hom op (map ∣ bind f ∣ xs)) ⟩
term op (map ∣ bind g ∣ (map ∣ bind f ∣ xs))
≈⟨ sym (term (PW.map reflexive (PW.≡⇒Pointwise-≡ (map-∘ ∣ bind g ∣ ∣ bind f ∣ xs)))) ⟩
term op (map (∣ bind g ∣ ∘ ∣ bind f ∣) xs)
≈⟨ term map-∣bind∣-assoc ⟩
term op (map ∣ bind (∣ bind g ∣⃗ · f) ∣ xs)
≈⟨ ∣ bind (∣ bind g ∣⃗ · f) ∣-hom op xs ⟩
∣ bind (∣ bind g ∣⃗ · f) ∣ (term op xs)
∎
fmap-id : ∀ {A : Setoid a ℓ₁} → fmap M.id ≗ id
fmap-id {A = A} = bind-unitʳ {A = A}
module _ {n}
(A : Algebra {a} {ℓ₁})
(θ : Env A n)
where
IsInstantiation : F n ⟿ A → Set _
IsInstantiation f = ∀ x → ∣ f ∣ (atom (dyn x)) ≡ θ x
inst-isInstantiation : IsInstantiation (inst A θ)
inst-isInstantiation x = PE.refl
mutual
map-∣inst∣-universal : ∀ {h m} → IsInstantiation h
→ {xs : Vec ∥ F n ∥ m}
→ Pointwise ≈[ A ] (map ∣ h ∣ xs)
(map ∣ inst A θ ∣ xs)
map-∣inst∣-universal p {xs = []} = []
map-∣inst∣-universal {h = h} p {xs = x ∷ xs} =
inst-universal {h = h} p ∷ map-∣inst∣-universal {h = h} p
inst-universal : ∀ {h} → IsInstantiation h → h ≗ (inst A θ)
inst-universal {h} p {x = atom (dyn x)} = Setoid.reflexive ∥ A ∥/≈ (p x)
inst-universal {h} p {x = term f xs} = begin
∣ h ∣ (term f xs)
≈⟨ Setoid.sym ∥ A ∥/≈ (∣ h ∣-hom f xs) ⟩
A ⟦ f ⟧ (map ∣ h ∣ xs)
≈⟨ (A ⟦ f ⟧-cong) (map-∣inst∣-universal {h = h} p {xs = xs}) ⟩
A ⟦ f ⟧ (map ∣ inst A θ ∣ xs)
≈⟨ ∣ inst A θ ∣-hom f xs ⟩
∣ inst A θ ∣ (term f xs)
∎
where open Reasoning ∥ A ∥/≈
module _
{B : Algebra {b} {ℓ₂}}
(h : A ⟿ B)
where
mutual
map-∣inst∣-assoc : ∀ {m} {xs : Vec ∥ F n ∥ m}
→ Pointwise ≈[ B ]
(map ∣ h ⊙ inst A θ ∣ xs)
(map ∣ inst B (∣ h ∣ ∘ θ) ∣ xs)
map-∣inst∣-assoc {xs = []} = []
map-∣inst∣-assoc {xs = x ∷ xs} = inst-assoc {x = x} ∷ map-∣inst∣-assoc
inst-assoc : h ⊙ inst A θ ≗ inst B (∣ h ∣ ∘ θ)
inst-assoc {atom (dyn _)} = Setoid.refl ∥ B ∥/≈
inst-assoc {term f xs} = begin
∣ h ⊙ inst A θ ∣ (term f xs)
≈⟨ sym (∣ h ⊙ inst A θ ∣-hom f xs) ⟩
B ⟦ f ⟧ (map ∣ h ⊙ inst A θ ∣ xs)
≈⟨ (B ⟦ f ⟧-cong) map-∣inst∣-assoc ⟩
B ⟦ f ⟧ (map ∣ inst B (∣ h ∣ ∘ θ) ∣ xs)
≈⟨ ∣ inst B (∣ h ∣ ∘ θ) ∣-hom f xs ⟩
∣ inst B (∣ h ∣ ∘ θ) ∣ (term f xs)
∎
where open Setoid ∥ B ∥/≈
open Reasoning ∥ B ∥/≈
| {
"alphanum_fraction": 0.4853203569,
"avg_line_length": 32.4473684211,
"ext": "agda",
"hexsha": "d85d716c43f6f4e0d81761353c4b9b77282f218b",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z",
"max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "yallop/agda-fragment",
"max_forks_repo_path": "src/Fragment/Algebra/Free/Properties.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496",
"max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "yallop/agda-fragment",
"max_issues_repo_path": "src/Fragment/Algebra/Free/Properties.agda",
"max_line_length": 92,
"max_stars_count": 18,
"max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "yallop/agda-fragment",
"max_stars_repo_path": "src/Fragment/Algebra/Free/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z",
"num_tokens": 2531,
"size": 6165
} |
{-# OPTIONS --copatterns #-}
module Issue906 where
{- Globular types as a coinductive record -}
record Glob : Set1 where
coinductive
field
Ob : Set
Hom : (a b : Ob) → Glob
open Glob public
record Unit : Set where
data _==_ {A : Set} (a : A) : A → Set where
refl : a == a
{- The terminal globular type -}
Unit-glob : Glob
Ob Unit-glob = Unit
Hom Unit-glob _ _ = Unit-glob
{- The tower of identity types -}
Id-glob : (A : Set) → Glob
Ob (Id-glob A) = A
Hom (Id-glob A) a b = Id-glob (a == b)
-- should termination check
| {
"alphanum_fraction": 0.6270871985,
"avg_line_length": 18.5862068966,
"ext": "agda",
"hexsha": "8d7d7b0a1fd62cd57bac1c779c4479cf8b7a3e29",
"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/Issue906.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/Issue906.agda",
"max_line_length": 44,
"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/Issue906.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": 178,
"size": 539
} |
open import Agda.Builtin.Nat
data Vec (A : Set) : Nat → Set where
variable
A : Set
x : A
n : Nat
xs : Vec A n
postulate
IsHead : A → Vec A (suc n) → Set
-- The `n` should be generalized over since the generalizable n in the type of xs
-- is solved with suc n.
foo : IsHead {n = _} x xs → Nat
foo h = 0
check-foo : {A : Set} {x : A} {n : Nat} {xs : Vec A (suc n)} → IsHead x xs → Nat
check-foo = foo
-- Should work also if the meta is created in an extended context
bar : (X : Set) → IsHead x xs → Nat
bar X h = 0
check-bar : {A : Set} {x : A} {n : Nat} {xs : Vec A (suc n)} → (X : Set) → IsHead x xs → Nat
check-bar = bar
| {
"alphanum_fraction": 0.5909797823,
"avg_line_length": 22.1724137931,
"ext": "agda",
"hexsha": "57290a35e33bc5bdf9039e2b23495893884b3cb3",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/Issue3274.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/Issue3274.agda",
"max_line_length": 92,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue3274.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": 242,
"size": 643
} |
module Pi-.Interp where
open import Data.Empty
open import Data.Unit
open import Data.Sum
open import Data.Product
open import Pi-.Syntax
open import Pi-.Opsem
open import Pi-.Eval
{-# TERMINATING #-}
mutual
interp : {A B : 𝕌} → (A ↔ B) → Val A B → Val B A
-- Forward
interp unite₊l (inj₂ y ⃗) = y ⃗
interp uniti₊l (v ⃗) = inj₂ v ⃗
interp swap₊ (inj₁ x ⃗) = inj₂ x ⃗
interp swap₊ (inj₂ y ⃗) = inj₁ y ⃗
interp assocl₊ (inj₁ x ⃗) = inj₁ (inj₁ x) ⃗
interp assocl₊ (inj₂ (inj₁ y) ⃗) = inj₁ (inj₂ y) ⃗
interp assocl₊ (inj₂ (inj₂ z) ⃗) = inj₂ z ⃗
interp assocr₊ (inj₁ (inj₁ x) ⃗) = inj₁ x ⃗
interp assocr₊ (inj₁ (inj₂ y) ⃗) = inj₂ (inj₁ y) ⃗
interp assocr₊ (inj₂ z ⃗) = inj₂ (inj₂ z) ⃗
interp unite⋆l ((tt , v) ⃗) = v ⃗
interp uniti⋆l (v ⃗) = (tt , v) ⃗
interp swap⋆ ((x , y) ⃗) = (y , x) ⃗
interp assocl⋆ ((x , (y , z)) ⃗) = ((x , y) , z) ⃗
interp assocr⋆ (((x , y) , z) ⃗) = (x , y , z) ⃗
interp dist ((inj₁ x , z) ⃗) = inj₁ (x , z) ⃗
interp dist ((inj₂ y , z) ⃗) = inj₂ (y , z) ⃗
interp factor (inj₁ (x , z) ⃗) = (inj₁ x , z) ⃗
interp factor (inj₂ (y , z) ⃗) = (inj₂ y , z) ⃗
interp id↔ (v ⃗) = v ⃗
interp (c₁ ⨾ c₂) (v ⃗) with interp c₁ (v ⃗)
interp (c₁ ⨾ c₂) (v ⃗) | (v' ⃖) = v' ⃖
interp (c₁ ⨾ c₂) (v ⃗) | (v' ⃗) = c₁ ⨾[ v' ⃗]⨾ c₂
interp (c₁ ⊕ c₂) (inj₁ x ⃗) with interp c₁ (x ⃗)
interp (c₁ ⊕ c₂) (inj₁ x ⃗) | (x' ⃗) = inj₁ x' ⃗
interp (c₁ ⊕ c₂) (inj₁ x ⃗) | (x' ⃖) = inj₁ x' ⃖
interp (c₁ ⊕ c₂) (inj₂ y ⃗) with interp c₂ (y ⃗)
interp (c₁ ⊕ c₂) (inj₂ y ⃗) | (y' ⃗) = inj₂ y' ⃗
interp (c₁ ⊕ c₂) (inj₂ y ⃗) | (y' ⃖) = inj₂ y' ⃖
interp (c₁ ⊗ c₂) ((x , y) ⃗) with interp c₁ (x ⃗)
interp (c₁ ⊗ c₂) ((x , y) ⃗) | (x' ⃖) = (x' , y) ⃖
interp (c₁ ⊗ c₂) ((x , y) ⃗) | (x' ⃗) with interp c₂ (y ⃗)
interp (c₁ ⊗ c₂) ((x , y) ⃗) | (x' ⃗) | (y' ⃗) = (x' , y') ⃗
interp (c₁ ⊗ c₂) ((x , y) ⃗) | (x' ⃗) | (y' ⃖) = (x , y') ⃖
interp ε₊ (inj₁ v ⃗) = inj₂ (- v) ⃖
interp ε₊ (inj₂ (- v) ⃗) = inj₁ v ⃖
-- Backward
interp unite₊l (v ⃖) = inj₂ v ⃖
interp uniti₊l (inj₂ v ⃖) = v ⃖
interp swap₊ (inj₁ x ⃖) = inj₂ x ⃖
interp swap₊ (inj₂ y ⃖) = inj₁ y ⃖
interp assocl₊ (inj₁ (inj₁ x) ⃖) = inj₁ x ⃖
interp assocl₊ (inj₁ (inj₂ y) ⃖) = inj₂ (inj₁ y) ⃖
interp assocl₊ (inj₂ z ⃖) = inj₂ (inj₂ z) ⃖
interp assocr₊ (inj₁ x ⃖) = inj₁ (inj₁ x) ⃖
interp assocr₊ (inj₂ (inj₁ y) ⃖) = inj₁ (inj₂ y) ⃖
interp assocr₊ (inj₂ (inj₂ z) ⃖) = inj₂ z ⃖
interp unite⋆l (v ⃖) = (tt , v) ⃖
interp uniti⋆l ((tt , v) ⃖) = v ⃖
interp swap⋆ ((x , y) ⃖) = (y , x) ⃖
interp assocl⋆ (((x , y) , z) ⃖) = (x , (y , z)) ⃖
interp assocr⋆ ((x , (y , z)) ⃖) = ((x , y) , z) ⃖
interp dist (inj₁ (x , z) ⃖) = (inj₁ x , z) ⃖
interp dist (inj₂ (y , z) ⃖) = (inj₂ y , z) ⃖
interp factor ((inj₁ x , z) ⃖) = inj₁ (x , z) ⃖
interp factor ((inj₂ y , z) ⃖) = inj₂ (y , z) ⃖
interp id↔ (v ⃖) = v ⃖
interp (c₁ ⨾ c₂) (v ⃖) with interp c₂ (v ⃖)
interp (c₁ ⨾ c₂) (v ⃖) | v' ⃗ = v' ⃗
interp (c₁ ⨾ c₂) (v ⃖) | v' ⃖ = c₁ ⨾[ v' ⃖]⨾ c₂
interp (c₁ ⊕ c₂) (inj₁ x ⃖) with interp c₁ (x ⃖)
interp (c₁ ⊕ c₂) (inj₁ x ⃖) | (x' ⃖) = inj₁ x' ⃖
interp (c₁ ⊕ c₂) (inj₁ x ⃖) | (x' ⃗) = inj₁ x' ⃗
interp (c₁ ⊕ c₂) (inj₂ y ⃖) with interp c₂ (y ⃖)
interp (c₁ ⊕ c₂) (inj₂ y ⃖) | (y' ⃖) = inj₂ y' ⃖
interp (c₁ ⊕ c₂) (inj₂ y ⃖) | (y' ⃗) = inj₂ y' ⃗
interp (c₁ ⊗ c₂) ((x , y) ⃖) with interp c₂ (y ⃖)
interp (c₁ ⊗ c₂) ((x , y) ⃖) | (y' ⃗) = (x , y') ⃗
interp (c₁ ⊗ c₂) ((x , y) ⃖) | (y' ⃖) with interp c₁ (x ⃖)
interp (c₁ ⊗ c₂) ((x , y) ⃖) | (y' ⃖) | (x' ⃖) = (x' , y') ⃖
interp (c₁ ⊗ c₂) ((x , y) ⃖) | (y' ⃖) | (x' ⃗) = (x' , y) ⃗
interp η₊ (inj₁ v ⃖) = inj₂ (- v) ⃗
interp η₊ (inj₂ (- v) ⃖) = inj₁ v ⃗
_⨾[_⃗]⨾_ : ∀ {A B C} → (A ↔ B) → ⟦ B ⟧ → (B ↔ C) → Val C A
c₁ ⨾[ b ⃗]⨾ c₂ with interp c₂ (b ⃗)
c₁ ⨾[ b ⃗]⨾ c₂ | c ⃗ = c ⃗
c₁ ⨾[ b ⃗]⨾ c₂ | b' ⃖ = c₁ ⨾[ b' ⃖]⨾ c₂
_⨾[_⃖]⨾_ : ∀ {A B C} → (A ↔ B) → ⟦ B ⟧ → (B ↔ C) → Val C A
c₁ ⨾[ b ⃖]⨾ c₂ with interp c₁ (b ⃖)
c₁ ⨾[ b ⃖]⨾ c₂ | a ⃖ = a ⃖
c₁ ⨾[ b ⃖]⨾ c₂ | b' ⃗ = c₁ ⨾[ b' ⃗]⨾ c₂
| {
"alphanum_fraction": 0.4303797468,
"avg_line_length": 43.1649484536,
"ext": "agda",
"hexsha": "ef9dd58b5d007921464f4231b041f7ccdd577662",
"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": "Pi-/Interp.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": "Pi-/Interp.agda",
"max_line_length": 62,
"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": "Pi-/Interp.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": 2562,
"size": 4187
} |
{-# OPTIONS --without-K --safe #-}
module Dodo.Unary where
open import Dodo.Unary.Dec public
open import Dodo.Unary.Disjoint public
open import Dodo.Unary.Empty public
open import Dodo.Unary.Equality public
open import Dodo.Unary.Intersection public
open import Dodo.Unary.Union public
open import Dodo.Unary.Unique public
open import Dodo.Unary.XOpt public
open ⊆₁-Reasoning public
open ⇔₁-Reasoning public
| {
"alphanum_fraction": 0.802919708,
"avg_line_length": 25.6875,
"ext": "agda",
"hexsha": "629063170ede07b226403c9b7073dda4c7777614",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "sourcedennis/agda-dodo",
"max_forks_repo_path": "src/Dodo/Unary.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "sourcedennis/agda-dodo",
"max_issues_repo_path": "src/Dodo/Unary.agda",
"max_line_length": 42,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "sourcedennis/agda-dodo",
"max_stars_repo_path": "src/Dodo/Unary.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 110,
"size": 411
} |
module Properties.Dec where
open import Properties.Contradiction using (¬)
data Dec(A : Set) : Set where
yes : A → Dec A
no : ¬ A → Dec A
| {
"alphanum_fraction": 0.6666666667,
"avg_line_length": 18,
"ext": "agda",
"hexsha": "c61f23659cda676b70907361b7e7f71a0e7aae64",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "XanderYZZ/luau",
"max_forks_repo_path": "prototyping/Properties/Dec.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "XanderYZZ/luau",
"max_issues_repo_path": "prototyping/Properties/Dec.agda",
"max_line_length": 46,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "TheGreatSageEqualToHeaven/luau",
"max_stars_repo_path": "prototyping/Properties/Dec.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-05T21:53:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-12-05T21:53:03.000Z",
"num_tokens": 42,
"size": 144
} |
{-# OPTIONS --rewriting #-}
-- 2014-05-27 Jesper and Andreas
postulate
A B : Set
R : A → B → Set
{-# BUILTIN REWRITE R #-}
-- Expected error:
-- R does not have the right type for a rewriting relation
-- because the types of the last two arguments are different
-- when checking the pragma BUILTIN REWRITE R
| {
"alphanum_fraction": 0.6802507837,
"avg_line_length": 21.2666666667,
"ext": "agda",
"hexsha": "5cfcaae1cbcde294b273ed52a25373c1f62034d4",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "test/Fail/RewriteRelationNotHomogeneous.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "redfish64/autonomic-agda",
"max_issues_repo_path": "test/Fail/RewriteRelationNotHomogeneous.agda",
"max_line_length": 60,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/Fail/RewriteRelationNotHomogeneous.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 86,
"size": 319
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.JoinComm
open import homotopy.JoinAssocCubical
module homotopy.JoinSusp where
module _ {i} (A : Type i) where
private
module Into = JoinRec {A = Bool} {B = A}
{C = Susp A}
(Bool-rec north south)
(λ _ → south)
(λ {true a → merid a;
false a → idp})
into = Into.f
module Out = SuspRec {C = Bool * A}
(left true)
(left false)
(λ a → jglue true a ∙ ! (jglue false a))
out = Out.f
into-out : ∀ σ → into (out σ) == σ
into-out = Susp-elim
idp
idp
(λ a → ↓-∘=idf-from-square into out $ vert-degen-square $
ap (ap into) (Out.merid-β a)
∙ ap-∙ into (jglue true a) (! (jglue false a))
∙ (Into.glue-β true a
∙2 (ap-! into (jglue false a)
∙ ap ! (Into.glue-β false a)))
∙ ∙-unit-r _)
out-into : ∀ j → out (into j) == j
out-into = Join-elim
(Bool-elim idp idp)
(λ a → jglue false a)
(λ{true a → ↓-∘=idf-from-square out into $
(ap (ap out) (Into.glue-β true a) ∙ Out.merid-β a)
∙v⊡ (vid-square {p = jglue true a}
⊡h rt-square (jglue false a))
⊡v∙ ∙-unit-r _;
false a → ↓-∘=idf-from-square out into $
ap (ap out) (Into.glue-β false a) ∙v⊡ connection})
*-Bool-l : Bool * A ≃ Susp A
*-Bool-l = equiv into out into-out out-into
module _ {i} (X : Ptd i) where
⊙*-Bool-l : ⊙Bool ⊙* X ⊙≃ ⊙Susp X
⊙*-Bool-l = ≃-to-⊙≃ (*-Bool-l (de⊙ X)) idp
module _ {i j} (A : Type i) (B : Type j) where
*-Susp-l : Susp A * B ≃ Susp (A * B)
*-Susp-l = *-Bool-l (A * B) ∘e *-assoc Bool A B ∘e *-emap (*-Bool-l A) (ide B) ⁻¹
module _ {i j} (X : Ptd i) (Y : Ptd j) where
⊙*-Susp-l : ⊙Susp X ⊙* Y ⊙≃ ⊙Susp (X ⊙* Y)
⊙*-Susp-l = ≃-to-⊙≃ (*-Susp-l (de⊙ X) (de⊙ Y)) idp
module _ {i} where
⊙*-Sphere-l : (m : ℕ) (X : Ptd i) → ⊙Sphere m ⊙* X ⊙≃ ⊙Susp^ (S m) X
⊙*-Sphere-l O X = ⊙*-Bool-l X
⊙*-Sphere-l (S m) X = ⊙Susp-emap (⊙*-Sphere-l m X) ⊙∘e ⊙*-Susp-l (⊙Sphere m) X
| {
"alphanum_fraction": 0.4812933025,
"avg_line_length": 28.4868421053,
"ext": "agda",
"hexsha": "8c6d8393d04c98ad8e66abc3338d451d0fc26391",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "theorems/homotopy/JoinSusp.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "theorems/homotopy/JoinSusp.agda",
"max_line_length": 83,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "theorems/homotopy/JoinSusp.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 861,
"size": 2165
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
open import Categories.Category.Monoidal
open import Categories.Category.Monoidal.Closed
module Categories.Category.Monoidal.Closed.IsClosed.Diagonal
{o ℓ e} {C : Category o ℓ e} {M : Monoidal C} (Cl : Closed M) where
open import Data.Product using (Σ; _,_)
open import Function using (_$_) renaming (_∘_ to _∙_)
open import Function.Equality as Π using (Π)
open import Categories.Category.Product
open import Categories.Category.Monoidal.Properties M
open import Categories.Morphism C
open import Categories.Morphism.Properties C
open import Categories.Morphism.Reasoning C
open import Categories.Functor renaming (id to idF)
open import Categories.Functor.Bifunctor
open import Categories.Functor.Bifunctor.Properties
open import Categories.NaturalTransformation hiding (id)
open import Categories.NaturalTransformation.Dinatural hiding (_∘ʳ_)
open import Categories.NaturalTransformation.NaturalIsomorphism as NI hiding (refl)
import Categories.Category.Closed as Cls
open Closed Cl
private
open Category C
module ℱ = Functor
module ⊗ = Functor ⊗
α⇒ = associator.from
α⇐ = associator.to
λ⇒ = unitorˡ.from
λ⇐ = unitorˡ.to
ρ⇒ = unitorʳ.from
ρ⇐ = unitorʳ.to
open HomReasoning
open Π.Π
open adjoint renaming (unit to η; counit to ε; Ladjunct to 𝕃; Ladjunct-comm′ to 𝕃-comm′;
Ladjunct-resp-≈ to 𝕃-resp-≈)
open import Categories.Category.Monoidal.Closed.IsClosed.Identity Cl -- defines diagonal
open import Categories.Category.Monoidal.Closed.IsClosed.L Cl
Lj≈j : ∀ {X Y} → L X Y Y ∘ diagonal.α Y ≈ diagonal.α [ X , Y ]₀
Lj≈j {X} {Y} = begin
L X Y Y ∘ 𝕃 λ⇒ ≈˘⟨ 𝕃-comm′ ⟩
𝕃 (𝕃 (ε.η Y ∘ id ⊗₁ ε.η Y ∘ α⇒) ∘ 𝕃 λ⇒ ⊗₁ id) ≈˘⟨ 𝕃-resp-≈ 𝕃-comm′ ⟩
𝕃 (𝕃 $ (ε.η Y ∘ id ⊗₁ ε.η Y ∘ α⇒) ∘ (𝕃 λ⇒ ⊗₁ id) ⊗₁ id) ≈⟨ 𝕃-resp-≈ $ 𝕃-resp-≈ $ absorb-λ⇒ ⟩
𝕃 (𝕃 (Radjunct λ⇒)) ≈⟨ 𝕃-resp-≈ LRadjunct≈id ⟩
diagonal.α [ X , Y ]₀ ∎
where
absorb-λ⇒ : (ε.η Y ∘ id ⊗₁ ε.η {X} Y ∘ α⇒) ∘ (𝕃 λ⇒ ⊗₁ id) ⊗₁ id ≈ Radjunct λ⇒
absorb-λ⇒ = begin
(ε.η Y ∘ id ⊗₁ ε.η Y ∘ α⇒) ∘ (𝕃 λ⇒ ⊗₁ id) ⊗₁ id ≈⟨ pull-last assoc-commute-from ⟩
ε.η Y ∘ id ⊗₁ ε.η Y ∘ 𝕃 λ⇒ ⊗₁ id ⊗₁ id ∘ α⇒ ≈˘⟨ assoc ⟩
(ε.η Y ∘ id ⊗₁ ε.η Y) ∘ 𝕃 λ⇒ ⊗₁ id ⊗₁ id ∘ α⇒ ≈⟨ refl⟩∘⟨ ⊗.F-resp-≈ (refl , ⊗.identity) ⟩∘⟨refl ⟩
(ε.η Y ∘ id ⊗₁ ε.η Y) ∘ 𝕃 λ⇒ ⊗₁ id ∘ α⇒ ≈⟨ center [ ⊗ ]-commute ⟩
ε.η Y ∘ (𝕃 λ⇒ ⊗₁ id ∘ id ⊗₁ ε.η Y) ∘ α⇒ ≈⟨ pull-first RLadjunct≈id ⟩
λ⇒ ∘ id ⊗₁ ε.η Y ∘ α⇒ ≈⟨ pullˡ unitorˡ-commute-from ⟩
(ε.η Y ∘ λ⇒) ∘ α⇒ ≈⟨ pullʳ coherence₁ ⟩
Radjunct λ⇒ ∎
jL≈i : {X Y : Obj} → [ diagonal.α X , id ]₁ ∘ L X X Y ≈ identity.⇒.η [ X , Y ]₀
jL≈i {X} {Y} = begin
[ Δ X , id ]₁ ∘ L X X Y ≈˘⟨ pushˡ [ [-,-] ]-commute ⟩
([ id , 𝕃 inner ]₁ ∘ [ Δ X , id ]₁) ∘ η.η XY ≈˘⟨ pushʳ (mate.commute₁ (diagonal.α X)) ⟩
[ id , 𝕃 inner ]₁ ∘ [ id , id ⊗₁ Δ X ]₁ ∘ η.η XY ≈˘⟨ pushˡ (ℱ.homomorphism [ unit ,-]) ⟩
𝕃 (𝕃 inner ∘ id ⊗₁ Δ X) ≈˘⟨ 𝕃-resp-≈ $ 𝕃-comm′ ⟩
𝕃 (𝕃 $ inner ∘ (id ⊗₁ Δ X) ⊗₁ id) ≈⟨ 𝕃-resp-≈ $ 𝕃-resp-≈ inner∘diag⇒ℝρ ⟩
𝕃 (𝕃 $ Radjunct ρ⇒) ≈⟨ 𝕃-resp-≈ $ LRadjunct≈id ⟩
𝕃 ρ⇒ ≈˘⟨ identityˡ ⟩
id ∘ 𝕃 ρ⇒ ∎
where
XY = [ X , Y ]₀
inner = ε.η Y ∘ id ⊗₁ ε.η X ∘ α⇒
Δ = diagonal.α
inner∘diag⇒ℝρ : inner ∘ (id ⊗₁ Δ X) ⊗₁ id ≈ Radjunct ρ⇒
inner∘diag⇒ℝρ = begin
inner ∘ (id ⊗₁ Δ X) ⊗₁ id ≈⟨ pull-last assoc-commute-from ○ ⟺ assoc ⟩
(ε.η Y ∘ id ⊗₁ ε.η X) ∘ id ⊗₁ Δ X ⊗₁ id ∘ α⇒ ≈⟨ center (⟺ (ℱ.homomorphism (XY ⊗-))) ⟩
ε.η Y ∘ id ⊗₁ (ε.η X ∘ 𝕃 λ⇒ ⊗₁ id) ∘ α⇒ ≈⟨ refl⟩∘⟨ ℱ.F-resp-≈ (XY ⊗-) RLadjunct≈id ⟩∘⟨refl ⟩
ε.η Y ∘ id ⊗₁ λ⇒ ∘ α⇒ ≈⟨ refl⟩∘⟨ triangle ⟩
Radjunct ρ⇒ ∎
private
i-η = identity.⇒.η
-- Not about diagonal, but it feels like a waste to start another file just for this
iL≈i : {Y Z : Obj} → [ i-η Y , id ]₁ ∘ L unit Y Z ≈ [ id , i-η Z ]₁
iL≈i {Y} {Z} = begin
[ i-η Y , id ]₁ ∘ L unit Y Z ≈˘⟨ pushˡ [ [-,-] ]-commute ⟩
([ id , 𝕃 inner ]₁ ∘ [ i-η Y , id ]₁) ∘ η.η YZ ≈⟨ ( refl⟩∘⟨ (ℱ.F-resp-≈ [-, YZ ⊗₀ [ unit , Y ]₀ ] identityˡ)) ⟩∘⟨refl ⟩
([ id , 𝕃 inner ]₁ ∘ [ 𝕃 ρ⇒ , id ]₁) ∘ η.η YZ ≈˘⟨ pushʳ (mate.commute₁ (𝕃 ρ⇒)) ⟩
[ id , 𝕃 inner ]₁ ∘ [ id , id ⊗₁ 𝕃 ρ⇒ ]₁ ∘ η.η YZ ≈˘⟨ pushˡ (ℱ.homomorphism [ Y ,-]) ⟩
𝕃 (𝕃 inner ∘ id ⊗₁ 𝕃 ρ⇒) ≈˘⟨ 𝕃-resp-≈ 𝕃-comm′ ⟩
𝕃 (𝕃 $ inner ∘ (id ⊗₁ 𝕃 ρ⇒) ⊗₁ id) ≈⟨ 𝕃-resp-≈ $ 𝕃-resp-≈ absorb ⟩
𝕃 (𝕃 $ ε.η Z ∘ ρ⇒) ≈⟨ 𝕃-resp-≈ $ ∘-resp-≈ˡ (ℱ.homomorphism [ unit ,-])
○ (assoc ○ ∘-resp-≈ʳ (⟺ identityˡ)) ⟩
𝕃 ([ id , ε.η Z ]₁ ∘ i-η (YZ ⊗₀ Y)) ≈˘⟨ 𝕃-resp-≈ $ identity.⇒.commute (ε.η Z) ⟩
𝕃 (i-η Z ∘ ε.η Z) ≈˘⟨ 𝕃-resp-≈ $ ε.commute (i-η Z) ⟩
𝕃 (Radjunct [ id , i-η Z ]₁) ≈⟨ LRadjunct≈id ⟩
[ id , i-η Z ]₁ ∎
where
YZ = [ Y , Z ]₀
inner = ε.η Z ∘ id ⊗₁ ε.η Y ∘ α⇒
absorb : inner ∘ (id ⊗₁ 𝕃 ρ⇒) ⊗₁ id ≈ ε.η Z ∘ ρ⇒
absorb = begin
inner ∘ (id ⊗₁ 𝕃 ρ⇒) ⊗₁ id ≈⟨ pull-last assoc-commute-from ○ ⟺ assoc ⟩
(ε.η Z ∘ id ⊗₁ ε.η Y) ∘ id ⊗₁ 𝕃 ρ⇒ ⊗₁ id ∘ α⇒ ≈⟨ center (⟺ (ℱ.homomorphism (YZ ⊗-))) ⟩
ε.η Z ∘ id ⊗₁ (ε.η Y ∘ 𝕃 ρ⇒ ⊗₁ id) ∘ α⇒ ≈⟨ refl⟩∘⟨ ℱ.F-resp-≈ (YZ ⊗-) RLadjunct≈id ⟩∘⟨refl ⟩
ε.η Z ∘ id ⊗₁ ρ⇒ ∘ α⇒ ≈⟨ refl⟩∘⟨ coherence₂ ⟩
ε.η Z ∘ ρ⇒ ∎
| {
"alphanum_fraction": 0.4906940337,
"avg_line_length": 49.1367521368,
"ext": "agda",
"hexsha": "f62a9b6ff4923880654f8c8f23dc707e2fc3dbc0",
"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": "6ebc1349ee79669c5c496dcadd551d5bbefd1972",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Taneb/agda-categories",
"max_forks_repo_path": "Categories/Category/Monoidal/Closed/IsClosed/Diagonal.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Taneb/agda-categories",
"max_issues_repo_path": "Categories/Category/Monoidal/Closed/IsClosed/Diagonal.agda",
"max_line_length": 125,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Taneb/agda-categories",
"max_stars_repo_path": "Categories/Category/Monoidal/Closed/IsClosed/Diagonal.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2825,
"size": 5749
} |
{- Type class for monads. -}
module CategoryTheory.Monad where
open import CategoryTheory.Categories
open import CategoryTheory.Functor
open import CategoryTheory.NatTrans
-- A monad on a category
record Monad {n} (ℂ : Category n) : Set (lsuc n) where
open Category ℂ
field
-- Underlying endofunctor
T : Endofunctor ℂ
open Functor T
field
-- || Definitions
-- Unit / return
η : I ⟹ T
-- Multiplication / join
μ : (T ²) ⟹ T
module η = _⟹_ η
module μ = _⟹_ μ
field
-- || Laws
-- Unit on both sides is cancelled by multiplication (unit)
η-unit1 : ∀ {A : obj} -> (μ.at A) ∘ (η.at (omap A)) ≈ id
η-unit2 : ∀ {A : obj} -> (μ.at A) ∘ (fmap (η.at A)) ≈ id
-- Multiplication can be performed on both sides (associativity)
μ-assoc : ∀ {A : obj} -> (μ.at A) ∘ (μ.at (omap A))
≈ (μ.at A) ∘ (fmap (μ.at A))
| {
"alphanum_fraction": 0.5410176532,
"avg_line_length": 27.5142857143,
"ext": "agda",
"hexsha": "889ea43334a1d5a7cdf1eefcb19eae3f56186937",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DimaSamoz/temporal-type-systems",
"max_forks_repo_path": "src/CategoryTheory/Monad.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DimaSamoz/temporal-type-systems",
"max_issues_repo_path": "src/CategoryTheory/Monad.agda",
"max_line_length": 72,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DimaSamoz/temporal-type-systems",
"max_stars_repo_path": "src/CategoryTheory/Monad.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z",
"num_tokens": 306,
"size": 963
} |
-- Andreas, 2015-03-16
-- Andreas, 2020-10-26 removed loop during injectivity check
open import Agda.Builtin.Size
-- Note: the assumption of pred is absurd,
-- but still should not make Agda loop.
module _ (pred : ∀ i → Size< i) where
data ⊥ : Set where
data SizeLt (i : Size) : Set where
wrap : (j : Size< i) → SizeLt i
loop : (d : ∀ i → SizeLt i) → ∀ i → SizeLt i → ⊥
loop d i (wrap j) = loop d j (d j)
-- -- Loops during injectivity check:
-- loop : ∀ i → SizeLt i → ⊥
-- loop i (wrap j) = loop j (wrap (pred j))
d : ∀ i → SizeLt i
d i = wrap (pred i)
absurd : ⊥
absurd = loop d ∞ (d ∞)
_ = FIXME
-- Testcase temporarily mutilated, original error:
--
-- -Issue1428a.agda:..
-- -Functions may not return sizes, thus, function type
-- -(i : Size) → Size< i is illegal
-- -when checking that the expression ∀ i → Size< i is a type
--
-- +Issue1428a.agda:...
-- +Not in scope:
-- + FIXME at Issue1428a.agda:...
-- +when scope checking FIXME
| {
"alphanum_fraction": 0.6226415094,
"avg_line_length": 22.7142857143,
"ext": "agda",
"hexsha": "53e83c384eea708540d310c3b58e1c4c1919936b",
"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": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "test/Fail/Issue1428a.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"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": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue1428a.agda",
"max_line_length": 61,
"max_stars_count": null,
"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/Issue1428a.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 320,
"size": 954
} |
--
-- open import Relation.Binary using (Rel; Setoid; IsEquivalence)
-- open import Level as Lvl using ()
module Structures
{G F : Set}
(_≈G_ : G → G → Set)
(_≈F_ : F → F → Set)
where
-- import M as M’
open import Algebra.Structures _≈G_
using (IsAbelianGroup)
open import Algebra.Structures _≈F_
using (IsCommutativeRing)
open import Relation.Nullary
open import Algebra.FunctionProperties _≈F_ using (Inverse)
record IsField (+ * : F → F → F) (𝟘 𝟙 : F) (- : F → F) (⁻¹ : (a : F) → ¬ (a ≈F 𝟘) → F) : Set where
field
isCommutativeRing : IsCommutativeRing + * - 𝟘 𝟙
*-inverse : Inverse {! !} {! ⁻¹ !} {! !}
record IsVectorSpace
(+ᵍ : G → G → G)
(𝟘ᵍ : G)
(-ᵍ : G → G)
: Set where
-- module G =
field
G-isAbelianGroup : IsAbelianGroup +ᵍ 𝟘ᵍ -ᵍ
F-isField : {! Rel !}
-- IsAbelianGroup {! +G !} {! !} {! !} {! !}
| {
"alphanum_fraction": 0.570781427,
"avg_line_length": 20.5348837209,
"ext": "agda",
"hexsha": "5c9cbc43a1afb17387f9210cd460f4ac46ae0a38",
"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": "217c63f308e6142e3fa4abd93b12bf0f3ccdc6df",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/linear-algebra",
"max_forks_repo_path": "Structures.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "217c63f308e6142e3fa4abd93b12bf0f3ccdc6df",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "banacorn/linear-algebra",
"max_issues_repo_path": "Structures.agda",
"max_line_length": 98,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "217c63f308e6142e3fa4abd93b12bf0f3ccdc6df",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/linear-algebra",
"max_stars_repo_path": "Structures.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-05T13:17:44.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-05T13:17:44.000Z",
"num_tokens": 349,
"size": 883
} |
module OlderBasicILP.Direct.Gentzen where
open import Common.Context public
-- Propositions of intuitionistic logic of proofs, without ∨, ⊥, or +.
mutual
infixr 10 _⦂_
infixl 9 _∧_
infixr 7 _▻_
data Ty : Set where
α_ : Atom → Ty
_▻_ : Ty → Ty → Ty
_⦂_ : Box → Ty → Ty
_∧_ : Ty → Ty → Ty
⊤ : Ty
record Box : Set where
inductive
constructor [_]
field
{/A} : Ty
t : ∅ ⊢ /A
_⦂⋆_ : ∀ {n} → VCx Box n → VCx Ty n → Cx Ty
∅ ⦂⋆ ∅ = ∅
(ts , t) ⦂⋆ (Ξ , A) = (ts ⦂⋆ Ξ) , (t ⦂ A)
-- Derivations, as Gentzen-style natural deduction trees.
infix 3 _⊢_
data _⊢_ (Γ : Cx Ty) : Ty → Set where
var : ∀ {A} → A ∈ Γ → Γ ⊢ A
lam : ∀ {A B} → Γ , A ⊢ B → Γ ⊢ A ▻ B
app : ∀ {A B} → Γ ⊢ A ▻ B → Γ ⊢ A → Γ ⊢ B
-- multibox : ∀ {n A} {[ss] : VCx Box n} {Ξ : VCx Ty n}
-- → Γ ⊢⋆ [ss] ⦂⋆ Ξ → (u : [ss] ⦂⋆ Ξ ⊢ A)
-- → Γ ⊢ [ u ] ⦂ A
down : ∀ {A} {t : ∅ ⊢ A} → Γ ⊢ [ t ] ⦂ A → Γ ⊢ A
pair : ∀ {A B} → Γ ⊢ A → Γ ⊢ B → Γ ⊢ A ∧ B
fst : ∀ {A B} → Γ ⊢ A ∧ B → Γ ⊢ A
snd : ∀ {A B} → Γ ⊢ A ∧ B → Γ ⊢ B
unit : Γ ⊢ ⊤
infix 3 _⊢⋆_
_⊢⋆_ : Cx Ty → Cx Ty → Set
Γ ⊢⋆ ∅ = 𝟙
Γ ⊢⋆ Ξ , A = Γ ⊢⋆ Ξ × Γ ⊢ A
infix 7 _▻◅_
_▻◅_ : Ty → Ty → Ty
A ▻◅ B = (A ▻ B) ∧ (B ▻ A)
-- Monotonicity with respect to context inclusion.
mutual
mono⊢ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢ A → Γ′ ⊢ A
mono⊢ η (var i) = var (mono∈ η i)
mono⊢ η (lam t) = lam (mono⊢ (keep η) t)
mono⊢ η (app t u) = app (mono⊢ η t) (mono⊢ η u)
-- mono⊢ η (multibox ts u) = multibox (mono⊢⋆ η ts) u
mono⊢ η (down t) = down (mono⊢ η t)
mono⊢ η (pair t u) = pair (mono⊢ η t) (mono⊢ η u)
mono⊢ η (fst t) = fst (mono⊢ η t)
mono⊢ η (snd t) = snd (mono⊢ η t)
mono⊢ η unit = unit
mono⊢⋆ : ∀ {Ξ Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢⋆ Ξ → Γ′ ⊢⋆ Ξ
mono⊢⋆ {∅} η ∙ = ∙
mono⊢⋆ {Ξ , A} η (ts , t) = mono⊢⋆ η ts , mono⊢ η t
-- Shorthand for variables.
v₀ : ∀ {A Γ} → Γ , A ⊢ A
v₀ = var i₀
v₁ : ∀ {A B Γ} → (Γ , A) , B ⊢ A
v₁ = var i₁
v₂ : ∀ {A B C Γ} → ((Γ , A) , B) , C ⊢ A
v₂ = var i₂
-- Reflexivity.
refl⊢⋆ : ∀ {Γ} → Γ ⊢⋆ Γ
refl⊢⋆ {∅} = ∙
refl⊢⋆ {Γ , A} = mono⊢⋆ weak⊆ refl⊢⋆ , v₀
-- Deduction theorem is built-in.
-- Detachment theorem.
det : ∀ {A B Γ} → Γ ⊢ A ▻ B → Γ , A ⊢ B
det t = app (mono⊢ weak⊆ t) v₀
-- Cut and multicut.
cut : ∀ {A B Γ} → Γ ⊢ A → Γ , A ⊢ B → Γ ⊢ B
cut t u = app (lam u) t
multicut : ∀ {Ξ A Γ} → Γ ⊢⋆ Ξ → Ξ ⊢ A → Γ ⊢ A
multicut {∅} ∙ u = mono⊢ bot⊆ u
multicut {Ξ , B} (ts , t) u = app (multicut ts (lam u)) t
-- Transitivity.
trans⊢⋆ : ∀ {Γ″ Γ′ Γ} → Γ ⊢⋆ Γ′ → Γ′ ⊢⋆ Γ″ → Γ ⊢⋆ Γ″
trans⊢⋆ {∅} ts ∙ = ∙
trans⊢⋆ {Γ″ , A} ts (us , u) = trans⊢⋆ ts us , multicut ts u
-- Contraction.
ccont : ∀ {A B Γ} → Γ ⊢ (A ▻ A ▻ B) ▻ A ▻ B
ccont = lam (lam (app (app v₁ v₀) v₀))
cont : ∀ {A B Γ} → Γ , A , A ⊢ B → Γ , A ⊢ B
cont t = det (app ccont (lam (lam t)))
-- Exchange, or Schönfinkel’s C combinator.
cexch : ∀ {A B C Γ} → Γ ⊢ (A ▻ B ▻ C) ▻ B ▻ A ▻ C
cexch = lam (lam (lam (app (app v₂ v₀) v₁)))
exch : ∀ {A B C Γ} → Γ , A , B ⊢ C → Γ , B , A ⊢ C
exch t = det (det (app cexch (lam (lam t))))
-- Composition, or Schönfinkel’s B combinator.
ccomp : ∀ {A B C Γ} → Γ ⊢ (B ▻ C) ▻ (A ▻ B) ▻ A ▻ C
ccomp = lam (lam (lam (app v₂ (app v₁ v₀))))
comp : ∀ {A B C Γ} → Γ , B ⊢ C → Γ , A ⊢ B → Γ , A ⊢ C
comp t u = det (app (app ccomp (lam t)) (lam u))
-- Useful theorems in functional form.
-- dist : ∀ {A B Ψ Γ} {t : Ψ ⊢ A ▻ B} {u : Ψ ⊢ A}
-- → Γ ⊢ [ t ] ⦂ (A ▻ B) → Γ ⊢ [ u ] ⦂ A
-- → Γ ⊢ [ app (down v₁) (down v₀) ] ⦂ B
-- dist t u = multibox ((∙ , t) , u) (app (down v₁) (down v₀))
--
-- up : ∀ {A Ψ Γ} {t : Ψ ⊢ A}
-- → Γ ⊢ [ t ] ⦂ A
-- → Γ ⊢ [ v₀ ] ⦂ [ t ] ⦂ A
-- up t = multibox (∙ , t) v₀
--
-- distup : ∀ {A B Ψ Γ} {u : Ψ ⊢ A} {t : ∅ , [ u ] ⦂ A ⊢ [ u ] ⦂ A ▻ B}
-- → Γ ⊢ [ t ] ⦂ ([ u ] ⦂ A ▻ B) → Γ ⊢ [ u ] ⦂ A
-- → Γ ⊢ [ app (down v₁) (down v₀) ] ⦂ B
-- distup t u = dist t (up u)
--
-- box : ∀ {A Γ}
-- → (t : ∅ ⊢ A)
-- → Γ ⊢ [ t ] ⦂ A
-- box t = multibox ∙ t
unbox : ∀ {A C Γ} {t : ∅ ⊢ A} {u : ∅ ⊢ C}
→ Γ ⊢ [ t ] ⦂ A → Γ , [ t ] ⦂ A ⊢ [ u ] ⦂ C
→ Γ ⊢ [ u ] ⦂ C
unbox t u = app (lam u) t
-- Useful theorems in combinatory form.
ci : ∀ {A Γ} → Γ ⊢ A ▻ A
ci = lam v₀
ck : ∀ {A B Γ} → Γ ⊢ A ▻ B ▻ A
ck = lam (lam v₁)
cs : ∀ {A B C Γ} → Γ ⊢ (A ▻ B ▻ C) ▻ (A ▻ B) ▻ A ▻ C
cs = lam (lam (lam (app (app v₂ v₀) (app v₁ v₀))))
-- cdist : ∀ {A B Ψ Γ} {t : Ψ ⊢ A ▻ B} {u : Ψ ⊢ A}
-- → Γ ⊢ [ t ] ⦂ (A ▻ B) ▻ [ u ] ⦂ A ▻ [ app (down v₁) (down v₀) ] ⦂ B
-- cdist = lam (lam (dist v₁ v₀))
--
-- cup : ∀ {A Ψ Γ} {t : Ψ ⊢ A} → Γ ⊢ [ t ] ⦂ A ▻ [ v₀ ] ⦂ [ t ] ⦂ A
-- cup = lam (up v₀)
cdown : ∀ {A Γ} {t : ∅ ⊢ A} → Γ ⊢ [ t ] ⦂ A ▻ A
cdown = lam (down v₀)
-- cdistup : ∀ {A B Ψ Γ} {u : Ψ ⊢ A} {t : ∅ , [ u ] ⦂ A ⊢ [ u ] ⦂ A ▻ B}
-- → Γ ⊢ [ t ] ⦂ ([ u ] ⦂ A ▻ B) ▻ [ u ] ⦂ A ▻ [ app (down v₁) (down v₀) ] ⦂ B
-- cdistup = lam (lam (dist v₁ (up v₀)))
cunbox : ∀ {A C Γ} {t : ∅ ⊢ A} {u : ∅ ⊢ C}
→ Γ ⊢ [ t ] ⦂ A ▻ ([ t ] ⦂ A ▻ C) ▻ C
cunbox = lam (lam (app v₀ v₁))
cpair : ∀ {A B Γ} → Γ ⊢ A ▻ B ▻ A ∧ B
cpair = lam (lam (pair v₁ v₀))
cfst : ∀ {A B Γ} → Γ ⊢ A ∧ B ▻ A
cfst = lam (fst v₀)
csnd : ∀ {A B Γ} → Γ ⊢ A ∧ B ▻ B
csnd = lam (snd v₀)
-- Closure under context concatenation.
concat : ∀ {A B Γ} Γ′ → Γ , A ⊢ B → Γ′ ⊢ A → Γ ⧺ Γ′ ⊢ B
concat Γ′ t u = app (mono⊢ (weak⊆⧺₁ Γ′) (lam t)) (mono⊢ weak⊆⧺₂ u)
-- Substitution.
mutual
[_≔_]_ : ∀ {A B Γ} → (i : A ∈ Γ) → Γ ∖ i ⊢ A → Γ ⊢ B → Γ ∖ i ⊢ B
[ i ≔ s ] var j with i ≟∈ j
[ i ≔ s ] var .i | same = s
[ i ≔ s ] var ._ | diff j = var j
[ i ≔ s ] lam t = lam ([ pop i ≔ mono⊢ weak⊆ s ] t)
[ i ≔ s ] app t u = app ([ i ≔ s ] t) ([ i ≔ s ] u)
-- [ i ≔ s ] multibox ts u = multibox ([ i ≔ s ]⋆ ts) u
[ i ≔ s ] down t = down ([ i ≔ s ] t)
[ i ≔ s ] pair t u = pair ([ i ≔ s ] t) ([ i ≔ s ] u)
[ i ≔ s ] fst t = fst ([ i ≔ s ] t)
[ i ≔ s ] snd t = snd ([ i ≔ s ] t)
[ i ≔ s ] unit = unit
[_≔_]⋆_ : ∀ {Ξ A Γ} → (i : A ∈ Γ) → Γ ∖ i ⊢ A → Γ ⊢⋆ Ξ → Γ ∖ i ⊢⋆ Ξ
[_≔_]⋆_ {∅} i s ∙ = ∙
[_≔_]⋆_ {Ξ , B} i s (ts , t) = [ i ≔ s ]⋆ ts , [ i ≔ s ] t
| {
"alphanum_fraction": 0.3869001094,
"avg_line_length": 26.7656903766,
"ext": "agda",
"hexsha": "c5f5a8314747cd2b18659d97b1c596daa117d90d",
"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": "OlderBasicILP/Direct/Gentzen.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/hilbert-gentzen",
"max_issues_repo_path": "OlderBasicILP/Direct/Gentzen.agda",
"max_line_length": 88,
"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": "OlderBasicILP/Direct/Gentzen.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z",
"num_tokens": 3322,
"size": 6397
} |
------------------------------------------------------------------------
-- "Equational" reasoning combinator setup
------------------------------------------------------------------------
{-# OPTIONS --sized-types #-}
open import Labelled-transition-system
module Expansion.Equational-reasoning-instances {ℓ} {lts : LTS ℓ} where
open import Prelude
open import Bisimilarity lts
import Bisimilarity.Equational-reasoning-instances
open import Equational-reasoning
open import Expansion lts
instance
reflexive≳ : ∀ {i} → Reflexive [ i ]_≳_
reflexive≳ = is-reflexive reflexive-≳
reflexive≳′ : ∀ {i} → Reflexive [ i ]_≳′_
reflexive≳′ = is-reflexive reflexive-≳′
convert≳≳ : ∀ {i} → Convertible [ i ]_≳_ [ i ]_≳_
convert≳≳ = is-convertible id
convert≳′≳ : ∀ {i} → Convertible _≳′_ [ i ]_≳_
convert≳′≳ = is-convertible λ p≳′q → force p≳′q
convert≳≳′ : ∀ {i} → Convertible [ i ]_≳_ [ i ]_≳′_
convert≳≳′ = is-convertible lemma
where
lemma : ∀ {i p q} → [ i ] p ≳ q → [ i ] p ≳′ q
force (lemma p≳q) = p≳q
convert≳′≳′ : ∀ {i} → Convertible [ i ]_≳′_ [ i ]_≳′_
convert≳′≳′ = is-convertible id
convert∼≳ : ∀ {i} → Convertible [ i ]_∼_ [ i ]_≳_
convert∼≳ = is-convertible ∼⇒≳
convert∼′≳ : ∀ {i} → Convertible _∼′_ [ i ]_≳_
convert∼′≳ = is-convertible (convert ∘ ∼⇒≳′)
convert∼≳′ : ∀ {i} → Convertible [ i ]_∼_ [ i ]_≳′_
convert∼≳′ {i} = is-convertible lemma
where
lemma : ∀ {p q} → [ i ] p ∼ q → [ i ] p ≳′ q
force (lemma p∼q) = ∼⇒≳ p∼q
convert∼′≳′ : ∀ {i} → Convertible [ i ]_∼′_ [ i ]_≳′_
convert∼′≳′ = is-convertible ∼⇒≳′
trans≳≳ : ∀ {i} → Transitive _≳_ [ i ]_≳_
trans≳≳ = is-transitive transitive-≳
trans≳′≳ : ∀ {i} → Transitive _≳′_ [ i ]_≳_
trans≳′≳ = is-transitive λ p≳′q → transitive (force p≳′q)
trans≳′≳′ : ∀ {i} → Transitive _≳′_ [ i ]_≳′_
trans≳′≳′ = is-transitive transitive-≳′
trans≳≳′ : ∀ {i} → Transitive _≳_ [ i ]_≳′_
trans≳≳′ = is-transitive lemma
where
lemma : ∀ {i p q r} → p ≳ q → [ i ] q ≳′ r → [ i ] p ≳′ r
force (lemma p≳q q≳′r) = transitive-≳ p≳q (force q≳′r)
trans∼≳ : ∀ {i} → Transitive _∼_ [ i ]_≳_
trans∼≳ = is-transitive transitive-∼≳
-- The occurrences of {a = ℓ} below can perhaps be removed if
-- Issue #2780 on the Agda bug tracker is fixed.
trans∼′≳ : ∀ {i} → Transitive _∼′_ [ i ]_≳_
trans∼′≳ = is-transitive (transitive-∼≳ ∘ convert {a = ℓ})
trans∼′≳′ : ∀ {i} → Transitive _∼′_ [ i ]_≳′_
trans∼′≳′ {i} = is-transitive lemma
where
lemma : ∀ {p q r} → p ∼′ q → [ i ] q ≳′ r → [ i ] p ≳′ r
force (lemma p∼′q q≳′r) =
transitive-∼≳ (convert {a = ℓ} p∼′q) (force q≳′r)
trans∼≳′ : ∀ {i} → Transitive _∼_ [ i ]_≳′_
trans∼≳′ {i} = is-transitive lemma
where
lemma : ∀ {p q r} → p ∼ q → [ i ] q ≳′ r → [ i ] p ≳′ r
force (lemma p∼q q≳′r) = transitive-∼≳ p∼q (force q≳′r)
trans≳∼ : ∀ {i} → Transitive′ [ i ]_≳_ _∼_
trans≳∼ = is-transitive transitive-≳∼
trans≳∼′ : ∀ {i} → Transitive′ [ i ]_≳_ _∼′_
trans≳∼′ = is-transitive (λ p≳q q∼′r →
transitive-≳∼ p≳q (convert {a = ℓ} q∼′r))
trans≳′∼′ : ∀ {i} → Transitive′ [ i ]_≳′_ _∼′_
trans≳′∼′ = is-transitive transitive-≳∼′
trans≳′∼ : ∀ {i} → Transitive′ [ i ]_≳′_ _∼_
trans≳′∼ = is-transitive λ p≳′q q∼r →
transitive-≳∼′ p≳′q (convert {a = ℓ} q∼r)
| {
"alphanum_fraction": 0.5193939394,
"avg_line_length": 31.1320754717,
"ext": "agda",
"hexsha": "c9cfdf852a6b97e5d933ec3eaffb76b619891eaa",
"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": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/up-to",
"max_forks_repo_path": "src/Expansion/Equational-reasoning-instances.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"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/up-to",
"max_issues_repo_path": "src/Expansion/Equational-reasoning-instances.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/up-to",
"max_stars_repo_path": "src/Expansion/Equational-reasoning-instances.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1530,
"size": 3300
} |
module Structure.Numeral.Integer where
import Lvl
open import Structure.Setoid
open import Structure.Operator.Properties
open import Structure.Operator.Ring
open import Structure.OrderedField
open import Structure.Relator
open import Type
private variable ℓₒ ℓₗ ℓₑ ℓₗ₁ ℓₗ₂ : Lvl.Level
private variable Z : Type{ℓₒ}
record Integer ⦃ equiv : Equiv{ℓₑ}(Z) ⦄ (_+_ : Z → Z → Z) (_⋅_ : Z → Z → Z) (_≤_ : Z → Z → Type{ℓₗ}) : Typeω where
constructor intro
field
⦃ ring ⦄ : Ring(_+_)(_⋅_)
⦃ ordered ⦄ : Ordered(_+_)(_⋅_)(_≤_)
open Ring(ring) public
open Ordered(ordered) public
𝐒 : Z → Z
𝐒 = _+ 𝟏
𝐏 : Z → Z
𝐏 = _− 𝟏
field
⦃ distinct-identities ⦄ : DistinctIdentities
positive-induction : ∀{ℓ}{P : Z → Type{ℓ}} ⦃ rel-p : UnaryRelator(P) ⦄ → P(𝟎) → (∀{n} → (𝟎 ≤ n) → P(n) → P(𝐒(n))) → (∀{n} → (𝟎 ≤ n) → P(n))
| {
"alphanum_fraction": 0.6062355658,
"avg_line_length": 27.935483871,
"ext": "agda",
"hexsha": "a42b6ca3026323ec059dbb5befc72776bf0a6708",
"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/Numeral/Integer.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/Numeral/Integer.agda",
"max_line_length": 143,
"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/Numeral/Integer.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": 359,
"size": 866
} |
-- Datatype modules weren't added as sections properly.
module Issue263b where
module M (A : Set) where
data D : Set where
postulate A : Set
open M.D A
-- The module M.D is not parameterized, but is being applied to
-- arguments
-- when checking the module application module _ = M.D A
| {
"alphanum_fraction": 0.7260273973,
"avg_line_length": 20.8571428571,
"ext": "agda",
"hexsha": "1be353f53c465574a7319ddb00b2b6a70ce4b4b2",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/Issue263b.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/Issue263b.agda",
"max_line_length": 63,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue263b.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": 76,
"size": 292
} |
{-# OPTIONS --cubical --safe #-}
module Control.Monad.Weighted.Functor.TypeDef where
open import Level
data 𝔚-F {r w a p} (R : Type r) (W : Type w) (A : Type a) (P : W → Type p) : Type (r ℓ⊔ a ℓ⊔ p ℓ⊔ w) where
[] : 𝔚-F R W A P
_◃_∷_⟨_⟩ : ∀ (w : R) (x : A) (xs : W) (P⟨xs⟩ : P xs) → 𝔚-F R W A P
| {
"alphanum_fraction": 0.5249169435,
"avg_line_length": 30.1,
"ext": "agda",
"hexsha": "dd4cef990f96d02047efa8795d408a29ba23e054",
"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": "Control/Monad/Weighted/Functor/TypeDef.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": "Control/Monad/Weighted/Functor/TypeDef.agda",
"max_line_length": 106,
"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": "Control/Monad/Weighted/Functor/TypeDef.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": 148,
"size": 301
} |
module examplesPaperJFP.Equality where
infix 4 _≡_
data _≡_ {a} {A : Set a} (x : A) : A → Set a where
refl : x ≡ x
-- obsolete, now in Agda.Builtin.Equality: {-# BUILTIN EQUALITY _≡_ #-}
-- No longer exists in Agda: {-# BUILTIN REFL refl #-}
| {
"alphanum_fraction": 0.6330645161,
"avg_line_length": 24.8,
"ext": "agda",
"hexsha": "13a911209d16576207eb474cebfd04eaa25e5c02",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z",
"max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/ooAgda",
"max_forks_repo_path": "examples/examplesPaperJFP/Equality.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/ooAgda",
"max_issues_repo_path": "examples/examplesPaperJFP/Equality.agda",
"max_line_length": 71,
"max_stars_count": 23,
"max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/ooAgda",
"max_stars_repo_path": "examples/examplesPaperJFP/Equality.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": 91,
"size": 248
} |
-- {-# OPTIONS -v tc.inj:100 -v tc.reduce:100 #-}
module Issue801 where
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
data _≡_ {A : Set}(x : A) : A → Set where
refl : x ≡ x
cong : ∀ {A : Set} {B : Set}
(f : A → B) {x y} → x ≡ y → f x ≡ f y
cong f refl = refl
lem : (n : ℕ) → n ≡ n
lem zero = refl
lem (suc n) = cong (λ x → x) (lem (suc n))
-- Andreas: this made the injectivity checker loop.
-- Now it should just report a termination error.
| {
"alphanum_fraction": 0.5470459519,
"avg_line_length": 22.85,
"ext": "agda",
"hexsha": "8941343d0f0aee3c4c0efd0df57ae2f36fcfcfe7",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Fail/Issue801.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Fail/Issue801.agda",
"max_line_length": 51,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Issue801.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": 177,
"size": 457
} |
------------------------------------------------------------------------
-- Partial functions, computability
------------------------------------------------------------------------
open import Atom
module Computability (atoms : χ-atoms) where
open import Equality.Propositional.Cubical
open import Logical-equivalence using (_⇔_)
open import Prelude as P hiding (_∘_; Decidable)
open import Tactic.By.Propositional
open import Bool equality-with-J
open import Bijection equality-with-J using (_↔_)
open import Double-negation equality-with-J
open import Equality.Decision-procedures equality-with-J
import Equivalence equality-with-J as Eq
open import Function-universe equality-with-J hiding (id; _∘_)
open import H-level equality-with-J as H-level
open import H-level.Closure equality-with-J
open import H-level.Truncation.Propositional equality-with-paths
as Trunc
open import Injection equality-with-J using (Injective)
open import Monad equality-with-J
open import Chi atoms
open import Coding atoms
import Coding.Instances atoms as Dummy
open import Deterministic atoms
open import Free-variables atoms
open import Propositional atoms
open import Reasoning atoms
open import Values atoms
-- Partial functions for which the relation defining the partial
-- function must be propositional.
record _⇀_ {a b} (A : Type a) (B : Type b) : Type (lsuc (a ⊔ b)) where
infix 4 _[_]=_
field
-- The relation defining the partial function.
_[_]=_ : A → B → Type (a ⊔ b)
-- The relation must be deterministic and propositional.
deterministic : ∀ {a b₁ b₂} → _[_]=_ a b₁ → _[_]=_ a b₂ → b₁ ≡ b₂
propositional : ∀ {a b} → Is-proposition (_[_]=_ a b)
-- A simple lemma.
∃[]=-propositional :
∀ {a} →
Is-proposition (∃ (_[_]=_ a))
∃[]=-propositional (b₁ , [a]=b₁) (b₂ , [a]=b₂) =
Σ-≡,≡→≡ (deterministic [a]=b₁ [a]=b₂)
(propositional _ _)
open _⇀_ public using (_[_]=_)
-- Totality. The definition is parametrised by something which could
-- be a modality.
Total : ∀ {a b} {A : Type a} {B : Type b} →
(Type (a ⊔ b) → Type (a ⊔ b)) →
A ⇀ B → Type (a ⊔ b)
Total P f = ∀ a → P (∃ λ b → f [ a ]= b)
-- Totality with ∥_∥ as the modality implies totality with the
-- identity function as the modality.
total-with-∥∥→total :
∀ {a b} {A : Type a} {B : Type b} (f : A ⇀ B) →
Total ∥_∥ f →
Total id f
total-with-∥∥→total f total a =
Trunc.rec
(_⇀_.∃[]=-propositional f)
id
(total a)
-- If the codomain of a function is a set, then the function can be
-- turned into a partial function.
as-partial : ∀ {a b} {A : Type a} {B : Type b} →
Is-set B → (A → B) → A ⇀ B
as-partial {ℓa} B-set f = record
{ _[_]=_ = λ a b → ↑ ℓa (f a ≡ b)
; deterministic = λ {a b₁ b₂} fa≡b₁ fa≡b₂ →
b₁ ≡⟨ sym (lower fa≡b₁) ⟩
f a ≡⟨ lower fa≡b₂ ⟩∎
b₂ ∎
; propositional = ↑-closure 1 (+⇒≡ {n = 1} B-set)
}
-- Composition of partial functions.
infixr 9 _∘_
_∘_ : ∀ {ℓ c} {A B : Type ℓ} {C : Type c} →
B ⇀ C → A ⇀ B → A ⇀ C
f ∘ g = record
{ _[_]=_ = λ a c → ∃ λ b → g [ a ]= b × f [ b ]= c
; deterministic = λ where
(b₁ , g[a]=b₁ , f[b₁]=c₁) (b₂ , g[a]=b₂ , f[b₂]=c₂) →
_⇀_.deterministic f
(subst (f [_]= _) (_⇀_.deterministic g g[a]=b₁ g[a]=b₂) f[b₁]=c₁)
f[b₂]=c₂
; propositional = λ {a c} → $⟨ Σ-closure 1 (_⇀_.∃[]=-propositional g) (λ _ → _⇀_.propositional f) ⟩
Is-proposition (∃ λ (p : ∃ λ b → g [ a ]= b) → f [ proj₁ p ]= c) ↝⟨ H-level.respects-surjection (_↔_.surjection $ inverse Σ-assoc) 1 ⟩□
Is-proposition (∃ λ b → g [ a ]= b × f [ b ]= c) □
}
-- If f is a partial function, g a function whose domain is a set, and
-- f (g a) = c, then (f ∘ g) a = c.
pre-apply : ∀ {ℓ c} {A B : Type ℓ} {C : Type c}
(f : B ⇀ C) {g : A → B} {a c}
(B-set : Is-set B) →
f [ g a ]= c → f ∘ as-partial B-set g [ a ]= c
pre-apply _ _ f[ga]=b = _ , lift refl , f[ga]=b
-- If f is a function whose domain is a set, g a partial function, and
-- g a = b, then (f ∘ g) a = f b.
post-apply : ∀ {ℓ c} {A B : Type ℓ} {C : Type c}
{f : B → C} (g : A ⇀ B) {a b}
(C-set : Is-set C) →
g [ a ]= b → as-partial C-set f ∘ g [ a ]= f b
post-apply _ _ g[a]=b = _ , g[a]=b , lift refl
-- Implements P p f means that p is an implementation of f. The
-- definition is parametrised by P, which could be a modality.
Implements :
∀ {a b} {A : Type a} {B : Type b}
⦃ rA : Rep A Consts ⦄ ⦃ rB : Rep B Consts ⦄ →
(Type (a ⊔ b) → Type (a ⊔ b)) →
Exp → A ⇀ B → Type (a ⊔ b)
Implements P p f =
Closed p
×
(∀ x y → f [ x ]= y → apply p ⌜ x ⌝ ⇓ ⌜ y ⌝)
×
(∀ x y → apply p ⌜ x ⌝ ⇓ y →
P (∃ λ y′ → f [ x ]= y′ × y ≡ ⌜ y′ ⌝))
-- If P maps propositions to propositions, then Implements P p f is a
-- proposition.
Implements-propositional :
∀ {a b} {A : Type a} {B : Type b}
⦃ rA : Rep A Consts ⦄ ⦃ rB : Rep B Consts ⦄ →
{P : Type (a ⊔ b) → Type (a ⊔ b)} {p : Exp}
(f : A ⇀ B) →
(∀ {A} → Is-proposition A → Is-proposition (P A)) →
Is-proposition (Implements P p f)
Implements-propositional f pres =
×-closure 1 Closed-propositional $
×-closure 1 (Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
⇓-propositional)
(Π-closure ext 1 λ x →
Π-closure ext 1 λ y →
Π-closure ext 1 λ _ →
pres $
H-level.respects-surjection
(_↔_.surjection $ inverse Σ-assoc) 1
(Σ-closure 1 (_⇀_.∃[]=-propositional f) λ _ →
Exp-set))
-- Computability. The definition is parametrised by something which
-- could be a modality.
Computable′ :
∀ {a b} {A : Type a} {B : Type b}
⦃ rA : Rep A Consts ⦄ ⦃ rB : Rep B Consts ⦄ →
(Type (a ⊔ b) → Type (a ⊔ b)) →
A ⇀ B → Type (a ⊔ b)
Computable′ P f = ∃ λ p → Implements P p f
-- Computability.
Computable :
∀ {a b} {A : Type a} {B : Type b}
⦃ rA : Rep A Consts ⦄ ⦃ rB : Rep B Consts ⦄ →
A ⇀ B → Type (a ⊔ b)
Computable = Computable′ id
-- If the partial function is total, then one part of the proof of
-- computability can be omitted.
total→almost-computable→computable :
∀ {a b} {A : Type a} {B : Type b}
⦃ rA : Rep A Consts ⦄ ⦃ rB : Rep B Consts ⦄
(P : Type (a ⊔ b) → Type (a ⊔ b)) →
(∀ {X Y} → (X → Y) → P X → P Y) →
(f : A ⇀ B) →
Total P f →
(∃ λ p →
Closed p
×
(∀ x y → f [ x ]= y → apply p ⌜ x ⌝ ⇓ ⌜ y ⌝)) →
Computable′ P f
total→almost-computable→computable P map f total (p , cl-p , hyp) =
p
, cl-p
, hyp
, λ x y px⇓y →
flip map (total x) λ where
(y′ , f[x]=y′) →
y′ , f[x]=y′ , ⇓-deterministic px⇓y (hyp x y′ f[x]=y′)
-- The semantics of χ as a partial function.
semantics : Closed-exp ⇀ Closed-exp
semantics = record
{ _[_]=_ = _⇓_ on proj₁
; deterministic = λ e⇓v₁ e⇓v₂ →
closed-equal-if-expressions-equal (⇓-deterministic e⇓v₁ e⇓v₂)
; propositional = ⇓-propositional
}
-- Another definition of computability.
Computable″ :
∀ {ℓ} {A B : Type ℓ}
⦃ rA : Rep A Consts ⦄ ⦃ rB : Rep B Consts ⦄ →
A ⇀ B → Type ℓ
Computable″ f =
∃ λ (p : Closed-exp) → ∀ a →
∀ q → semantics [ apply-cl p ⌜ a ⌝ ]= q
⇔
as-partial Closed-exp-set ⌜_⌝ ∘ f [ a ]= q
-- The two definitions of computability are logically equivalent.
Computable⇔Computable″ :
∀ {ℓ} {A B : Type ℓ} ⦃ rA : Rep A Consts ⦄ ⦃ rB : Rep B Consts ⦄ →
(f : A ⇀ B) →
Computable f ⇔ Computable″ f
Computable⇔Computable″ f = record { to = to; from = from }
where
to : Computable f → Computable″ f
to (p , cl , hyp₁ , hyp₂) =
(p , cl) , λ { a (q , cl-q) → record
{ to = Σ-map id (Σ-map id (lift P.∘
closed-equal-if-expressions-equal P.∘
sym))
P.∘
hyp₂ a q
; from = λ { (b , f[a]=b , ⌜b⌝≡q) →
apply p ⌜ a ⌝ ⇓⟨ hyp₁ a b f[a]=b ⟩
⌜ b ⌝ ≡⟨ cong proj₁ (lower ⌜b⌝≡q) ⟩⟶
q ■⟨ subst Value (cong proj₁ (lower ⌜b⌝≡q)) (rep-value b) ⟩ }
} }
from : Computable″ f → Computable f
from ((p , cl) , hyp) =
p , cl ,
(λ a b f[a]=b →
apply p ⌜ a ⌝ ⇓⟨ _⇔_.from (hyp a ⌜ b ⌝) (post-apply f Closed-exp-set f[a]=b) ⟩■
⌜ b ⌝) ,
λ a q p⌜a⌝⇓q →
let cl-q : Closed q
cl-q = closed⇓closed p⌜a⌝⇓q
(Closed′-closed-under-apply
(Closed→Closed′ cl)
(Closed→Closed′ (rep-closed a)))
in
Σ-map id (Σ-map id (cong proj₁ P.∘ sym P.∘ lower))
(_⇔_.to (hyp a (q , cl-q)) p⌜a⌝⇓q)
-- Yet another definition of computability.
Computable‴ :
∀ {a b} {A : Type a} {B : Type b}
⦃ rA : Rep A Consts ⦄ ⦃ rB : Rep B Consts ⦄ →
A ⇀ B → Type (a ⊔ b)
Computable‴ f =
∃ λ (p : Closed-exp) →
∀ a →
∃ λ b →
apply (proj₁ p) ⌜ a ⌝ ⇓ ⌜ b ⌝
×
f [ a ]= b
-- If a partial function is computable by the last definition of
-- computability above, then it is also computable by the first one.
Computable‴→Computable :
∀ {a b} {A : Type a} {B : Type b}
⦃ rA : Rep A Consts ⦄ ⦃ rB : Rep B Consts ⦄ →
(f : A ⇀ B) →
Computable‴ f → Computable f
Computable‴→Computable f ((p , cl-p) , hyp) =
p
, cl-p
, (λ a b f[a]=b → case hyp a of λ where
(b′ , p⌜a⌝⇓⌜b′⌝ , f[a]=b′) →
apply p ⌜ a ⌝ ⇓⟨ p⌜a⌝⇓⌜b′⌝ ⟩
⌜ b′ ⌝ ≡⟨ by (_⇀_.deterministic f f[a]=b f[a]=b′) ⟩⟶
⌜ b ⌝ ■⟨ rep-value b ⟩)
, (λ a v p⌜a⌝⇓v → case hyp a of λ where
(b , p⌜a⌝⇓⌜b⌝ , f[a]=b) →
b
, f[a]=b
, ⇓-deterministic p⌜a⌝⇓v p⌜a⌝⇓⌜b⌝)
module _ {a b c d} {A : Type a} {B : Type b} {C : Type c} {D : Type d}
⦃ rA : Rep A Consts ⦄ ⦃ rB : Rep B Consts ⦄
⦃ rC : Rep C Consts ⦄ ⦃ rD : Rep D Consts ⦄ where
-- Reductions.
Reduction : A ⇀ B → C ⇀ D → Type (a ⊔ b ⊔ c ⊔ d)
Reduction f g = Computable g → Computable f
-- If f can be reduced to g, and f is not computable, then g is not
-- computable.
Reduction→¬Computable→¬Computable :
(f : A ⇀ B) (g : C ⇀ D) →
Reduction f g → ¬ Computable f → ¬ Computable g
Reduction→¬Computable→¬Computable _ _ red ¬f g = ¬f (red g)
-- Total partial functions to the booleans. Note that totality is
-- defined using the double-negation modality.
_→Bool : ∀ {ℓ} → Type ℓ → Type (lsuc ℓ)
A →Bool = ∃ λ (f : A ⇀ Bool) → Total (λ A → ¬¬ A) f
-- One way to view a predicate as a total partial function to the
-- booleans.
as-function-to-Bool₁ : ∀ {a} {A : Type a} → (A → Type a) → A →Bool
as-function-to-Bool₁ P =
(record
{ _[_]=_ = λ a b →
(P a → b ≡ true)
×
(¬ P a → b ≡ false)
; deterministic = λ where
{b₁ = true} {b₂ = true} _ _ → refl
{b₁ = false} {b₂ = false} _ _ → refl
{b₁ = true} {b₂ = false} f₁ f₂ →
proj₂ f₁ (Bool.true≢false P.∘ sym P.∘ proj₁ f₂)
{b₁ = false} {b₂ = true} f₁ f₂ →
sym (proj₂ f₂ (Bool.true≢false P.∘ sym P.∘ proj₁ f₁))
; propositional = ×-closure 1
(Π-closure ext 1 λ _ →
Bool-set)
(Π-closure ext 1 λ _ →
Bool-set)
})
, λ a →
[ (λ p → true , (λ _ → refl) , ⊥-elim P.∘ (_$ p))
, (λ ¬p → false , ⊥-elim P.∘ ¬p , (λ _ → refl))
] ⟨$⟩ excluded-middle
-- Another way to view a predicate as a total partial function to the
-- booleans.
as-function-to-Bool₂ :
∀ {a} {A : Type a} →
(P : A → Type a) →
(∀ {a} → Is-proposition (P a)) →
A →Bool
as-function-to-Bool₂ P P-prop =
(record
{ _[_]=_ = λ a b →
P a × b ≡ true
⊎
¬ P a × b ≡ false
; deterministic = λ where
(inj₁ (_ , refl)) (inj₁ (_ , refl)) → refl
(inj₁ (p , _)) (inj₂ (¬p , _)) → ⊥-elim (¬p p)
(inj₂ (¬p , _)) (inj₁ (p , _)) → ⊥-elim (¬p p)
(inj₂ (_ , refl)) (inj₂ (_ , refl)) → refl
; propositional = λ {_ b} →
⊎-closure-propositional
(λ { (_ , b≡true) (_ , b≡false) →
Bool.true≢false (
true ≡⟨ sym b≡true ⟩
b ≡⟨ b≡false ⟩∎
false ∎) })
(×-closure 1 P-prop Bool-set)
(×-closure 1 (¬-propositional ext) Bool-set)
})
, λ a →
[ (λ p → true , inj₁ (p , refl))
, (λ ¬p → false , inj₂ (¬p , refl))
] ⟨$⟩ excluded-middle
-- If a is mapped to b by as-function-to-Bool₂ P P-prop, then a is
-- also mapped to b by as-function-to-Bool₁ P.
to-Bool₂→to-Bool₁ :
∀ {a} {A : Type a} ⦃ rA : Rep A Consts ⦄
(P : A → Type a) (P-prop : ∀ {a} → Is-proposition (P a)) {a b} →
proj₁ (as-function-to-Bool₂ P P-prop) [ a ]= b →
proj₁ (as-function-to-Bool₁ P) [ a ]= b
to-Bool₂→to-Bool₁ _ _ = λ where
(inj₁ (Pa , refl)) → (λ _ → refl) , ⊥-elim P.∘ (_$ Pa)
(inj₂ (¬Pa , refl)) → ⊥-elim P.∘ ¬Pa , λ _ → refl
-- If a is mapped to b by as-function-to-Bool₁ P, then a is not not
-- mapped to b by as-function-to-Bool₂ P P-prop.
to-Bool₁→to-Bool₂ :
∀ {a} {A : Type a} ⦃ rA : Rep A Consts ⦄
(P : A → Type a) (P-prop : ∀ {a} → Is-proposition (P a)) {a b} →
proj₁ (as-function-to-Bool₁ P) [ a ]= b →
¬¬ proj₁ (as-function-to-Bool₂ P P-prop) [ a ]= b
to-Bool₁→to-Bool₂ _ _ (Pa→b≡true , ¬Pa→b≡false) =
⊎-map (λ Pa → Pa , Pa→b≡true Pa) (λ ¬Pa → ¬Pa , ¬Pa→b≡false ¬Pa) ⟨$⟩
excluded-middle
-- If as-function-to-Bool₁ P is ¬¬-computable, then
-- as-function-to-Bool₂ P P-prop is also ¬¬-computable.
to-Bool₁-computable→to-Bool₂-computable :
∀ {a} {A : Type a} ⦃ rA : Rep A Consts ⦄
(P : A → Type a) (P-prop : ∀ {a} → Is-proposition (P a)) →
Computable′ (λ A → ¬¬ A) (proj₁ (as-function-to-Bool₁ P)) →
Computable′ (λ A → ¬¬ A) (proj₁ (as-function-to-Bool₂ P P-prop))
to-Bool₁-computable→to-Bool₂-computable
P P-prop (p , cl-p , hyp₁ , hyp₂) =
p
, cl-p
, (λ a b →
proj₁ (as-function-to-Bool₂ P P-prop) [ a ]= b ↝⟨ to-Bool₂→to-Bool₁ P P-prop ⟩
proj₁ (as-function-to-Bool₁ P) [ a ]= b ↝⟨ hyp₁ a b ⟩□
apply p ⌜ a ⌝ ⇓ ⌜ b ⌝ □)
, λ a e →
apply p ⌜ a ⌝ ⇓ e ↝⟨ hyp₂ a e ⟩
¬¬ (∃ λ b → proj₁ (as-function-to-Bool₁ P) [ a ]= b ×
e ≡ ⌜ b ⌝) ↝⟨ _>>= (λ { (b , =b , ≡⌜b⌝) →
to-Bool₁→to-Bool₂ P P-prop =b >>= λ =b →
return (b , =b , ≡⌜b⌝) }) ⟩□
¬¬ (∃ λ b → proj₁ (as-function-to-Bool₂ P P-prop) [ a ]= b ×
e ≡ ⌜ b ⌝) □
-- A lemma related to as-function-to-Bool₂.
×≡true⊎¬×≡false⇔⇔T :
∀ {a} {A : Type a} (P : A → Type a) →
∀ {a b} → P a × b ≡ true ⊎ ¬ P a × b ≡ false ⇔ (P a ⇔ T b)
×≡true⊎¬×≡false⇔⇔T P {a} {b} = record
{ to = λ where
(inj₁ (p , refl)) → record { from = λ _ → p }
(inj₂ (¬p , refl)) → record { to = ¬p; from = ⊥-elim }
; from = helper b
}
where
helper : ∀ b → P a ⇔ T b → P a × b ≡ true ⊎ ¬ P a × b ≡ false
helper true hyp = inj₁ (_⇔_.from hyp _ , refl)
helper false hyp = inj₂ (_⇔_.to hyp , refl)
-- One way to view a predicate as a partial function to the booleans.
as-partial-function-to-Bool₁ :
∀ {a} {A : Type a} → (A → Type a) → A ⇀ Bool
as-partial-function-to-Bool₁ P = record
{ _[_]=_ = λ a b →
(P a → b ≡ true)
×
¬ ¬ P a
; deterministic = λ where
{b₁ = true} {b₂ = true} _ _ → refl
{b₁ = false} {b₂ = false} _ _ → refl
{b₁ = true} {b₂ = false} _ f →
⊥-elim $ proj₂ f (Bool.true≢false P.∘ sym P.∘ proj₁ f)
{b₁ = false} {b₂ = true} f _ →
⊥-elim $ proj₂ f (Bool.true≢false P.∘ sym P.∘ proj₁ f)
; propositional = ×-closure 1
(Π-closure ext 1 λ _ →
Bool-set)
(¬-propositional ext)
}
-- Another way to view a predicate as a partial function to the
-- booleans.
as-partial-function-to-Bool₂ :
∀ {a} {A : Type a} →
(P : A → Type a) →
(∀ {a} → Is-proposition (P a)) →
A ⇀ Bool
as-partial-function-to-Bool₂ P P-prop = record
{ _[_]=_ = λ a b → P a × b ≡ true
; deterministic = λ { (_ , refl) (_ , refl) → refl }
; propositional = ×-closure 1 P-prop Bool-set
}
-- One definition of what it means for a total partial function to the
-- booleans to be decidable.
Decidable :
∀ {a} {A : Type a} ⦃ rA : Rep A Consts ⦄ →
A →Bool → Type a
Decidable = Computable P.∘ proj₁
-- Another definition of what it means for a total partial function to
-- the booleans to be decidable.
Decidable′ :
∀ {a} {A : Type a} ⦃ rA : Rep A Consts ⦄ →
A →Bool → Type a
Decidable′ = Computable‴ P.∘ proj₁
-- Computable functions from a type to a set.
record Computable-function
{a b} (A : Type a) (B : Type b) (B-set : Is-set B)
⦃ rA : Rep A Consts ⦄ ⦃ rB : Rep B Consts ⦄ :
Type (a ⊔ b) where
field
function : A → B
computable : Computable (as-partial B-set function)
open Computable-function
-- An unfolding lemma for Computable-function.
Computable-function↔ :
∀ {a b} {A : Type a} {B : Type b} {B-set : Is-set B}
⦃ rA : Rep A Consts ⦄ ⦃ rB : Rep B Consts ⦄ →
Computable-function A B B-set ↔
∃ λ (f : A → B) → Computable (as-partial B-set f)
Computable-function↔ = record
{ surjection = record
{ logical-equivalence = record
{ to = λ f → function f , computable f
}
; right-inverse-of = λ _ → refl
}
; left-inverse-of = λ _ → refl
}
-- If two computable functions have equal implementations, then they
-- are equal.
equal-implementations→equal :
∀ {a b} {A : Type a} {B : Type b} {B-set : Is-set B}
⦃ rA : Rep A Consts ⦄ ⦃ rB : Rep B Consts ⦄
(f g : Computable-function A B B-set) →
proj₁ (computable f) ≡ proj₁ (computable g) →
function f ≡ function g
equal-implementations→equal f g hyp = ⟨ext⟩ λ x → $⟨ proj₁ (proj₂ (proj₂ (computable f))) x (function f x) (lift refl)
, proj₁ (proj₂ (proj₂ (computable g))) x (function g x) (lift refl) ⟩
apply (proj₁ (computable f)) ⌜ x ⌝ ⇓ ⌜ function f x ⌝ ×
apply (proj₁ (computable g)) ⌜ x ⌝ ⇓ ⌜ function g x ⌝ ↝⟨ Σ-map id (subst (λ e → apply e _ ⇓ _) (sym hyp)) ⟩
apply (proj₁ (computable f)) ⌜ x ⌝ ⇓ ⌜ function f x ⌝ ×
apply (proj₁ (computable f)) ⌜ x ⌝ ⇓ ⌜ function g x ⌝ ↝⟨ uncurry ⇓-deterministic ⟩
⌜ function f x ⌝ ≡ ⌜ function g x ⌝ ↝⟨ rep-injective ⟩□
function f x ≡ function g x □
instance
-- Representation functions for computable functions.
rep-Computable-function :
∀ {a b} {A : Type a} {B : Type b} {B-set : Is-set B}
⦃ rA : Rep A Consts ⦄ ⦃ rB : Rep B Consts ⦄ →
Rep (Computable-function A B B-set) Consts
rep-Computable-function {A = A} {B = B} {B-set = B-set} = record
{ ⌜_⌝ = ⌜_⌝ P.∘ proj₁ P.∘ computable
; rep-injective = injective
}
where
abstract
injective :
Injective {A = Computable-function A B B-set} {B = Consts}
(⌜_⌝ P.∘ proj₁ P.∘ computable)
injective {f} {g} =
⌜ proj₁ (computable f) ⌝ ≡ ⌜ proj₁ (computable g) ⌝ ↝⟨ rep-injective ⟩
proj₁ (computable f) ≡ proj₁ (computable g) ↝⟨ (λ hyp → cong₂ _,_ (equal-implementations→equal f g hyp) hyp) ⟩
(function f , proj₁ (computable f)) ≡
(function g , proj₁ (computable g)) ↔⟨ ignore-propositional-component $
Implements-propositional (as-partial B-set (function g)) id ⟩
((function f , proj₁ (computable f)) , proj₂ (computable f)) ≡
((function g , proj₁ (computable g)) , proj₂ (computable g)) ↔⟨ Eq.≃-≡ (Eq.↔⇒≃ Σ-assoc) ⟩
(function f , computable f) ≡ (function g , computable g) ↔⟨ Eq.≃-≡ (Eq.↔⇒≃ Computable-function↔) ⟩□
f ≡ g □
| {
"alphanum_fraction": 0.4980221901,
"avg_line_length": 34.898989899,
"ext": "agda",
"hexsha": "294d3ce4371c56df7e4c233e254fd710f08deb16",
"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": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/chi",
"max_forks_repo_path": "src/Computability.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1",
"max_issues_repo_issues_event_max_datetime": "2020-06-08T11:08:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-05-21T23:29:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/chi",
"max_issues_repo_path": "src/Computability.agda",
"max_line_length": 143,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/chi",
"max_stars_repo_path": "src/Computability.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-20T16:27:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:07.000Z",
"num_tokens": 7846,
"size": 20730
} |
open import Oscar.Prelude
open import Oscar.Class
open import Oscar.Class.Symmetry
module Oscar.Class.Symmetry.ToSym where
private
test-class :
⦃ _ : ∀ {𝔬} {𝔒 : Ø 𝔬} {𝔯} {_∼_ : 𝔒 → 𝔒 → Ø 𝔯} → Symmetry.class _∼_ ⦄
→ ∀ {𝔬} {𝔒 : Ø 𝔬} {𝔯} {_∼_ : 𝔒 → 𝔒 → Ø 𝔯} → Symmetry.class _∼_
test-class = !
test-class' :
∀ {𝔬} {𝔒 : Ø 𝔬} {x : 𝔒} {𝔯} {F : (𝔒 → 𝔒 → Ø 𝔯) → 𝔒 → 𝔒 → Ø 𝔯}
⦃ _ : ∀ {S : 𝔒 → 𝔒 → 𝔒 → Ø 𝔯} → Symmetry.class (F (S x)) ⦄
→ ∀ {S : 𝔒 → 𝔒 → 𝔒 → Ø 𝔯} → Symmetry.class (F (S x))
test-class' ⦃ ⌶ ⦄ {S} = ⌶ {S} -- FIXME _S _x ≟ _S' _x
test-class'' :
∀ {𝔬} {𝔒 : Ø 𝔬} {x : 𝔒} {𝔯} {F : (𝔒 → 𝔒 → 𝔒 → Ø 𝔯) → 𝔒 → 𝔒 → 𝔒 → Ø 𝔯}
⦃ _ : ∀ {S : 𝔒 → 𝔒 → 𝔒 → Ø 𝔯} → Symmetry.class (F S x) ⦄
→ ∀ {S : 𝔒 → 𝔒 → 𝔒 → Ø 𝔯} → Symmetry.class (F S x)
test-class'' = !
test-class''' :
∀ {𝔬} {𝔒 : Ø 𝔬} {𝔯} {F : (𝔒 → 𝔒 → 𝔒 → Ø 𝔯) → 𝔒 → 𝔒 → Ø 𝔯}
⦃ _ : ∀ {S : 𝔒 → 𝔒 → 𝔒 → Ø 𝔯} → Symmetry.class (F S) ⦄
→ ∀ {S : 𝔒 → 𝔒 → 𝔒 → Ø 𝔯} → Symmetry.class (F S)
test-class''' = !
test-method-sym : ∀
{𝔬} {𝔒 : Ø 𝔬}
{𝔯} {_∼_ : 𝔒 → 𝔒 → Ø 𝔯}
⦃ _ : Symmetry.class _∼_ ⦄
→ _
test-method-sym {_∼_ = _∼_} = λ {x} {y} → Symmetry.method _∼_ {x} {y}
test-method-symmetry : ∀
{𝔬} {𝔒 : Ø 𝔬}
{𝔯} {_∼_ : 𝔒 → 𝔒 → Ø 𝔯}
⦃ _ : Symmetry.class _∼_ ⦄
→ _
test-method-symmetry {_∼_ = _∼_} = λ {x} {y} → symmetry[ _∼_ ] {x} {y}
| {
"alphanum_fraction": 0.4336734694,
"avg_line_length": 29.8260869565,
"ext": "agda",
"hexsha": "573c8b7125689eb0891f09d6a658c17f7e1aad2e",
"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/Symmetry/ToSym.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/Symmetry/ToSym.agda",
"max_line_length": 73,
"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/Symmetry/ToSym.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 824,
"size": 1372
} |
{-# OPTIONS --universe-polymorphism #-}
module RawFunctor where
open import Common.Level
postulate RawFunctor : ∀ {ℓ} (F : Set ℓ → Set ℓ) → Set (lsuc ℓ)
-- Broken occurs check for levels made this not infer properly
postulate
sequence⁻¹ : ∀ {F}{A} {P : A → Set} → RawFunctor F →
F (∀ i → P i) → ∀ i → F (P i)
| {
"alphanum_fraction": 0.6024096386,
"avg_line_length": 25.5384615385,
"ext": "agda",
"hexsha": "ec38948013de86cbdff9429882bbb5455af3ef57",
"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/RawFunctor.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/RawFunctor.agda",
"max_line_length": 63,
"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/RawFunctor.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": 109,
"size": 332
} |
module ImportWarningsB where
-- all of the following files have warnings, which should be displayed
-- when loading this file
import Issue1988
import Issue2243
import Issue708quote
import OldCompilerPragmas
import RewritingEmptyPragma
import Unreachable
-- this warning will be ignored
{-# REWRITE #-}
| {
"alphanum_fraction": 0.8131147541,
"avg_line_length": 20.3333333333,
"ext": "agda",
"hexsha": "a046c360236665c65ed61735e1d71121e7750e08",
"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": "f77b563d328513138d6c88bf0a3e350a9b91f8ed",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "bennn/agda",
"max_forks_repo_path": "test/Succeed/ImportWarningsB.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f77b563d328513138d6c88bf0a3e350a9b91f8ed",
"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": "bennn/agda",
"max_issues_repo_path": "test/Succeed/ImportWarningsB.agda",
"max_line_length": 70,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f77b563d328513138d6c88bf0a3e350a9b91f8ed",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "bennn/agda",
"max_stars_repo_path": "test/Succeed/ImportWarningsB.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 69,
"size": 305
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of fresh lists and functions acting on them
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Fresh.Properties where
open import Level using (Level; _⊔_; Lift)
open import Data.Product using (_,_)
open import Relation.Nullary
open import Relation.Unary as U using (Pred)
open import Relation.Binary as B using (Rel)
open import Data.List.Fresh
private
variable
a b e p r : Level
A : Set a
B : Set b
------------------------------------------------------------------------
-- Fresh congruence
module _ {R : Rel A r} {_≈_ : Rel A e} (R≈ : R B.Respectsˡ _≈_) where
fresh-respectsˡ : ∀ {x y} {xs : List# A R} → x ≈ y → x # xs → y # xs
fresh-respectsˡ {xs = []} x≈y x#xs = _
fresh-respectsˡ {xs = x ∷# xs} x≈y (r , x#xs) =
R≈ x≈y r , fresh-respectsˡ x≈y x#xs
------------------------------------------------------------------------
-- Empty and NotEmpty
Empty⇒¬NonEmpty : {R : Rel A r} {xs : List# A R} → Empty xs → ¬ (NonEmpty xs)
Empty⇒¬NonEmpty [] ()
NonEmpty⇒¬Empty : {R : Rel A r} {xs : List# A R} → NonEmpty xs → ¬ (Empty xs)
NonEmpty⇒¬Empty () []
empty? : {R : Rel A r} (xs : List# A R) → Dec (Empty xs)
empty? [] = yes []
empty? (_ ∷# _) = no (λ ())
nonEmpty? : {R : Rel A r} (xs : List# A R) → Dec (NonEmpty xs)
nonEmpty? [] = no (λ ())
nonEmpty? (cons x xs pr) = yes (cons x xs pr)
| {
"alphanum_fraction": 0.4789915966,
"avg_line_length": 30.3333333333,
"ext": "agda",
"hexsha": "a4908e90bd96893fb820582b3bf9516cb78fdffe",
"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/List/Fresh/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/List/Fresh/Properties.agda",
"max_line_length": 77,
"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/List/Fresh/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": 459,
"size": 1547
} |
{-
Definition of a homogeneous pointed type, and proofs that pi, product, path, and discrete types are homogeneous
Portions of this file adapted from Nicolai Kraus' code here:
https://bitbucket.org/nicolaikraus/agda/src/e30d70c72c6af8e62b72eefabcc57623dd921f04/trunc-inverse.lagda
-}
{-# OPTIONS --cubical --safe #-}
module Cubical.Foundations.Pointed.Homogeneous where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Path
open import Cubical.Data.Prod
open import Cubical.Data.Empty
open import Cubical.Relation.Nullary
open import Cubical.Foundations.Pointed.Base
open import Cubical.Foundations.Pointed.Properties
isHomogeneous : ∀ {ℓ} → Pointed ℓ → Type (ℓ-suc ℓ)
isHomogeneous {ℓ} (A , x) = ∀ y → Path (Pointed ℓ) (A , x) (A , y)
isHomogeneousPi : ∀ {ℓ ℓ'} {A : Type ℓ} {B∙ : A → Pointed ℓ'}
→ (∀ a → isHomogeneous (B∙ a)) → isHomogeneous (Π∙ A B∙)
isHomogeneousPi h f i = (∀ a → typ (h a (f a) i)) , (λ a → pt (h a (f a) i))
isHomogeneousProd : ∀ {ℓ ℓ'} {A∙ : Pointed ℓ} {B∙ : Pointed ℓ'}
→ isHomogeneous A∙ → isHomogeneous B∙ → isHomogeneous (A∙ ×∙ B∙)
isHomogeneousProd hA hB (a , b) i = (typ (hA a i)) × (typ (hB b i)) , (pt (hA a i) , pt (hB b i))
isHomogeneousPath : ∀ {ℓ} (A : Type ℓ) {x y : A} (p : x ≡ y) → isHomogeneous ((x ≡ y) , p)
isHomogeneousPath A {x} {y} p q i
= ua eqv i , ua-gluePath eqv (compPathr-cancel p q) i
where eqv : (x ≡ y) ≃ (x ≡ y)
eqv = ((q ∙ sym p) ∙_) , compPathl-isEquiv (q ∙ sym p)
module HomogeneousDiscrete {ℓ} {A∙ : Pointed ℓ} (dA : Discrete (typ A∙)) (y : typ A∙) where
-- switches pt A∙ with y
switch : typ A∙ → typ A∙
switch x with dA x (pt A∙)
... | yes _ = y
... | no _ with dA x y
... | yes _ = pt A∙
... | no _ = x
switch-ptA∙ : switch (pt A∙) ≡ y
switch-ptA∙ with dA (pt A∙) (pt A∙)
... | yes _ = refl
... | no ¬p = ⊥-elim (¬p refl)
switch-idp : ∀ x → switch (switch x) ≡ x
switch-idp x with dA x (pt A∙)
switch-idp x | yes p with dA y (pt A∙)
switch-idp x | yes p | yes q = q ∙ sym p
switch-idp x | yes p | no _ with dA y y
switch-idp x | yes p | no _ | yes _ = sym p
switch-idp x | yes p | no _ | no ¬p = ⊥-elim (¬p refl)
switch-idp x | no ¬p with dA x y
switch-idp x | no ¬p | yes p with dA y (pt A∙)
switch-idp x | no ¬p | yes p | yes q = ⊥-elim (¬p (p ∙ q))
switch-idp x | no ¬p | yes p | no _ with dA (pt A∙) (pt A∙)
switch-idp x | no ¬p | yes p | no _ | yes _ = sym p
switch-idp x | no ¬p | yes p | no _ | no ¬q = ⊥-elim (¬q refl)
switch-idp x | no ¬p | no ¬q with dA x (pt A∙)
switch-idp x | no ¬p | no ¬q | yes p = ⊥-elim (¬p p)
switch-idp x | no ¬p | no ¬q | no _ with dA x y
switch-idp x | no ¬p | no ¬q | no _ | yes q = ⊥-elim (¬q q)
switch-idp x | no ¬p | no ¬q | no _ | no _ = refl
switch-eqv : typ A∙ ≃ typ A∙
switch-eqv = isoToEquiv (iso switch switch switch-idp switch-idp)
isHomogeneousDiscrete : ∀ {ℓ} {A∙ : Pointed ℓ} (dA : Discrete (typ A∙)) → isHomogeneous A∙
isHomogeneousDiscrete {ℓ} {A∙} dA y i
= ua switch-eqv i , ua-gluePath switch-eqv switch-ptA∙ i
where open HomogeneousDiscrete {ℓ} {A∙} dA y
| {
"alphanum_fraction": 0.5944728147,
"avg_line_length": 40.1084337349,
"ext": "agda",
"hexsha": "71507124dca797d91f3d4f010818102a81665eb7",
"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": "a01973ef7264f9454a40697313a2073c51a6b77a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/cubical",
"max_forks_repo_path": "Cubical/Foundations/Pointed/Homogeneous.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a01973ef7264f9454a40697313a2073c51a6b77a",
"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/cubical",
"max_issues_repo_path": "Cubical/Foundations/Pointed/Homogeneous.agda",
"max_line_length": 111,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a01973ef7264f9454a40697313a2073c51a6b77a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/cubical",
"max_stars_repo_path": "Cubical/Foundations/Pointed/Homogeneous.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1331,
"size": 3329
} |
module Data.Bin.Bijection where
open import Relation.Binary.PropositionalEquality as PropEq hiding (inspect)
open import Function.Inverse renaming (_∘_ to _∙_)
import Function.Surjection
open Function.Surjection using (module Surjection; module Surjective)
open import Function.Equality using (_⟶_)
open import Data.Nat using (ℕ; _*_; _+_)
open import Data.Bin using (toℕ; Bin; fromBits; 2+_; 0b; 1b)
open import Data.Product
open import Data.Digit using (Bit; toDigits; fromDigits)
ℕ-setoid = PropEq.setoid ℕ
Bin-setoid = PropEq.setoid Bin
import Data.Fin
pattern 1+ x = Data.Nat.suc x
fromℕ : ℕ → Bin
fromℕ x = fromBits (proj₁ (toDigits 2 x))
-- hard to prove now
-- fromℕeq' : {n : ℕ} → fromℕ n ≡ fromℕ' n
-- fromℕeq' {x} with toDigits 2 x
-- fromℕeq' .{fromDigits d} | d , refl = {!!}
fromℕ⟶ : ℕ-setoid ⟶ Bin-setoid
fromℕ⟶ = record
{ _⟨$⟩_ = fromℕ
; cong = PropEq.cong fromℕ
}
toℕ⟶ : Bin-setoid ⟶ ℕ-setoid
toℕ⟶ = record
{ _⟨$⟩_ = toℕ
; cong = PropEq.cong toℕ
}
open import Data.Digit using(Bit)
open import Data.Bin using (fromBits; toBits; _1#; 0#; 0b; 1b)
open import Data.List using (_∷_; []; _++_)
open import Data.Fin using (suc; zero) renaming (toℕ to bitToℕ)
open import Data.Bin.BitListBijection
using (_≈_; All-zero; module All-zero; All-zero-respects-equivalence)
renaming (setoid to bits-setoid; bijection-to-ℕ to Bits-bijection-ℕ)
open _≈_
open All-zero
open import Relation.Binary using (module Setoid)
module Bits = Setoid bits-setoid
open import Data.Product using (_,_; proj₂; proj₁)
open import Function using (_∘_)
open Data.List using(List)
fromBits-zero : ∀ {l} → All-zero l → fromBits l ≡ 0#
fromBits-zero [] = PropEq.refl
fromBits-zero (All-zero.cons {t} z) with fromBits t | fromBits-zero z
fromBits-zero (All-zero.cons z) | .0# | refl = PropEq.refl
fromBitsCong : ∀ {i j} → i ≈ j → fromBits i ≡ fromBits j
fromBitsCong (both-zero a-zero b-zero) =
PropEq.trans (fromBits-zero a-zero)
(PropEq.sym (fromBits-zero b-zero))
fromBitsCong (heads-match h at bt eq) with fromBits at | fromBits bt | fromBitsCong eq
fromBitsCong (heads-match Data.Bin.0b at bt eq) | 0# | .0# | refl = PropEq.refl
fromBitsCong (heads-match Data.Bin.1b at bt eq) | 0# | .0# | refl = PropEq.refl
fromBitsCong (heads-match (Data.Bin.2+ ()) at bt eq) | 0# | .0# | refl
fromBitsCong (heads-match h at bt eq) | bs 1# | .(bs 1#) | refl = PropEq.refl
fromBits⟶ : bits-setoid ⟶ Bin-setoid
fromBits⟶ = record
{ _⟨$⟩_ = fromBits
; cong = fromBitsCong
}
toBits⟶ : Bin-setoid ⟶ bits-setoid
toBits⟶ = record
{ _⟨$⟩_ = toBits
; cong = λ { {i} .{_} PropEq.refl → Bits.refl }
}
open import Data.Product using (_×_)
#1-inj : ∀ {a b} → a 1# ≡ b 1# → a ≡ b
#1-inj refl = refl
fromToBits-inverse : ∀ a → fromBits (toBits a) ≡ a
fromToBits-inverse 0# = refl
fromToBits-inverse ([] 1#) = refl
fromToBits-inverse ((h ∷ t) 1#) with fromBits (toBits (t 1#)) | fromToBits-inverse (t 1#)
... | 0# | ()
... | l 1# | eq = PropEq.cong (λ x → (h ∷ x) 1#) (#1-inj eq)
qqq : ∀ {xs} → (0b ∷ []) ≈ xs → [] ≈ xs
qqq (both-zero a-zero b-zero) = both-zero [] b-zero
qqq (heads-match .0b .[] bt x) = both-zero [] (cons (All-zero-respects-equivalence x []))
toFromBits-inverse : ∀ a → (toBits (fromBits a)) ≈ a
toFromBits-inverse [] = both-zero (cons []) []
toFromBits-inverse (x ∷ xs) with fromBits xs | toFromBits-inverse xs
toFromBits-inverse (0b ∷ xs) | 0# | w =
heads-match 0b [] xs (qqq w)
toFromBits-inverse (1b ∷ xs) | 0# | w =
heads-match 1b [] xs (qqq w)
toFromBits-inverse ((2+ ()) ∷ xs) | 0# | w
toFromBits-inverse (x ∷ xs) | bs 1# | w =
heads-match x (bs ++ suc 0b ∷ []) xs w
fromBits-inj : ∀ {x y} → fromBits x ≡ fromBits y → x ≈ y
fromBits-inj eq =
Bits.trans (Bits.sym (toFromBits-inverse _))
(Bits.trans (Setoid.reflexive bits-setoid (cong toBits eq)) (toFromBits-inverse _))
open import Function.Inverse using (Inverse; _InverseOf_)
inverseFB : toBits⟶ InverseOf fromBits⟶
inverseFB = record
{
left-inverse-of = toFromBits-inverse;
right-inverse-of = fromToBits-inverse
}
Bits-inverse-Bin : Inverse bits-setoid Bin-setoid
Bits-inverse-Bin = record
{ inverse-of = inverseFB
}
fromℕ-inverse : Inverse ℕ-setoid Bin-setoid
fromℕ-inverse =
Bits-inverse-Bin
∙ Function.Inverse.sym (Function.Inverse.fromBijection Bits-bijection-ℕ)
bijection-is-reasonable1 :
Function.Equality._⟨$⟩_ (Inverse.to fromℕ-inverse) ≡ fromℕ
bijection-is-reasonable1 = PropEq.refl
bijection-is-reasonable2 :
Function.Equality._⟨$⟩_ (Inverse.from fromℕ-inverse) ≡ toℕ
bijection-is-reasonable2 = PropEq.refl
toℕ-inverse = Function.Inverse.sym fromℕ-inverse
toℕ-bijection = Inverse.bijection toℕ-inverse
fromℕ-bijection = Inverse.bijection fromℕ-inverse
toℕ-inj = Inverse.injective toℕ-inverse
fromℕ-inj = Inverse.injective fromℕ-inverse
fromToℕ-inverse = Inverse.left-inverse-of toℕ-inverse
toFromℕ-inverse = Inverse.right-inverse-of toℕ-inverse
| {
"alphanum_fraction": 0.6541236108,
"avg_line_length": 33.522875817,
"ext": "agda",
"hexsha": "98043f12fbc8085f3c2338888920cfdd94706699",
"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": "09cc5104421e88da82f9fead5a43f0028f77810d",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "Rotsor/BinDivMod",
"max_forks_repo_path": "Data/Bin/Bijection.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "09cc5104421e88da82f9fead5a43f0028f77810d",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "Rotsor/BinDivMod",
"max_issues_repo_path": "Data/Bin/Bijection.agda",
"max_line_length": 91,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "09cc5104421e88da82f9fead5a43f0028f77810d",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "Rotsor/BinDivMod",
"max_stars_repo_path": "Data/Bin/Bijection.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-18T13:58:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-18T13:58:14.000Z",
"num_tokens": 1829,
"size": 5129
} |
module Issue690a where
data ℕ : Set where
zero : ℕ
succ : ℕ → ℕ
-- A negative type.
data T : Set → Set where
c : T (T ℕ)
-- From Andreas (2012-09-07) message on Agda mailing list "Forget
-- Hurken's paradox ..."
--
-- Trying to make sense of T in terms of inductive types, explaining
-- indices via equalities, one arrives at
--
-- data T (X : Set) : Set where
-- c : (X ≡ T ℕ) → T X
--
-- which has a non-positive occurrence of T in (X ≡ T ℕ).
--
-- An argument for the existence of T would have to argue for the
-- existence this least fixed point:
--
-- lfp \lambda T X → (X ≡ T ℕ)
-- ASR (14 August 2014): In Coq'Art, § 14.1.2.1, the type T is
-- rejected due to the head type constrains.
| {
"alphanum_fraction": 0.634696756,
"avg_line_length": 23.6333333333,
"ext": "agda",
"hexsha": "3176c89c379feab32995354a595adab0d08108b9",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Fail/Issue690a.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Fail/Issue690a.agda",
"max_line_length": 68,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Issue690a.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": 226,
"size": 709
} |
open import Common.IO
header = putStrLn "foo"
main : IO _
main = putStrLn "42"
| {
"alphanum_fraction": 0.6913580247,
"avg_line_length": 11.5714285714,
"ext": "agda",
"hexsha": "ff60a6fa6705c1b1800621426b5173f0287deef0",
"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/Compiler/simple/Issue2222.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/Compiler/simple/Issue2222.agda",
"max_line_length": 23,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Compiler/simple/Issue2222.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": 21,
"size": 81
} |
{-# OPTIONS --cubical --no-import-sorts #-}
module Hit where
-- open import Cubical.Core.Everything
open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ)
-- open import Cubical.Foundations.Equiv.HalfAdjoint
-- open import Cubical.Data.Sigma.Properties
-- https://en.wikipedia.org/wiki/Inductive_type#Higher_inductive_types
-- private
-- ℓ : Level
_ : (A B : Type₀) → Type₁
_ = λ a b → a ≡ b
-- https://www.youtube.com/watch?v=AZ8wMIar-_c
-- List becomes a normal form of this
data FreeMonoid' (A : Type₀) : Type₀ where
[_]' : A → FreeMonoid' A
ε' : FreeMonoid' A
_*'_ : FreeMonoid' A → FreeMonoid' A → FreeMonoid' A
assoc' : ∀ x y z → x *' (y *' z) ≡ (x *' y) *' z
data List (A : Type) : Type where
[] : List A
_∷_ : A → List A → List A
-- debug fonts
-- see which fonts are "in effect" with
-- fc-match --verbose
-- https://wiki.archlinux.org/index.php/X_Logical_Font_Description
-- Two different font systems are used by X11:
-- - the older or core X Logical Font Description, XLFD,
-- - and the newer X FreeType, Xft, systems (see An Xft Tutorial for font names format).
-- https://keithp.com/~keithp/render/Xft.tutorial
-- λ-calculus
-- Cockx 2019 - Hack your type theory with rewrite rules
-- https://jesper.sikanda.be/posts/hack-your-type-theory.html
-- email thread from Georgi Lyubenov (24.03.20, 23:28 ff) about sized lambdas "How can I implement naive sized lambdas?"
-- email thread from Joey Eremondi (22.04.20, 06:07 ff) about variable binding "What do you use for variable binding in 2020?"
-- literate agda markdown -> latex
-- https://lists.chalmers.se/pipermail/agda/2019/011286.html
-- https://stackoverflow.com/questions/58339725/literate-agda-in-markdown-format-to-latex-via-pandoc
-- https://jesper.sikanda.be/posts/literate-agda.html
-- Jesper Cockx' mail from 09.07.19, 18:35
-- an example file/paper that shows how to use cubical:
-- /home/christianl/agda/cubical/Cubical/Papers/Synthetic.agda
-- Cubical synthetic homotopy theory
-- Mörtberg and Pujet, „Cubical synthetic homotopy theory“.
-- https://dl.acm.org/doi/abs/10.1145/3372885.3373825
-- the github repository recommends
-- Vezzosi 2019 - Cubical Agda: A Dependently Typed ProgrammingLanguage with Univalence and Higher Inductive Types
-- https://dl.acm.org/doi/pdf/10.1145/3341691
-- there is also the very comprehensive
-- https://arxiv.org/pdf/1911.00580.pdf
-- Martín Hötzel Escardó 2020 - Introduction to Univalent Foundations of Mathematics with Agda
-- clickable html version: https://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html
-- https://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html#sns
-- A structure identity principle for a standard notion of structure
-- some useful, recent stuff from the mailing list:
-- https://ncatlab.org/nlab/show/archimedean+field
-- An archimedean field is an ordered field in which every element is bounded above by a natural number.
-- Q: why refl {x} and refl {_} {_} {x} behave differently according to context
-- A: (U. Norell 01.05.20, 23:08)
-- pattern reflpv x = refl {x = x}
-- you are not allowed to pattern match on datatype parameters, since they are not stored in the constructor. In a right-hand side you can give the parameters to guide the type checker, but they are thrown out during elaboration.
-- Andreas Nuyts 26.04.20, 22:34
-- a case in a pattern matching definition gets a light grey background when it doesn't hold as a definitional equation, typically because it is a fallthrough case and further matching of the arguments is necessary to establish that none of the prior cases apply
-- Q: what do I assume/not assume when using --cubical?
-- A: (Andreas Abel 24.04.20, 15:04) That is a long story. One thing is that in --cubical, the identity type is a primitive (not a data), and you cannot match on refl.
-- https://agda.readthedocs.io/en/v2.6.1/tools/command-line-options.html?highlight=infective#consistency-checking-of-options-used
-- An infective option is an option that if used in one module, must be used in all modules that depend on this module.
-- A coinfective option is an option that if used in one module, must be used in all modules that this module depends on.
-- (Orestis Melkonian 22.12.19, 21:11) inspect MAlonzo haskell code's variable names with https://github.com/agda/agda-ghc-names
-- (James Wood 22.12.19, 21:28)
-- Note that record field names can also overlap if they are applied directly to a record value.
-- The theory behind this is in bidirectional type checking, and how a term having its type checked (rather than inferred) may be ambiguous without the information from the type.
-- The same mechanism allows λ to be reused for dimension abstraction in cubical Agda (because it is a constructor).
-- In short, overloading is fine in the following cases:
-- - Everything being overloaded is a constructor, and there is an obvious type to check the resulting construction against.
-- - Everything being overloaded is a field, and there is an obvious record type that the field is destructing.
-- Outside of these cases, overloading fails.
-- You might notice also that the agda2-infer-type command will usually fail to infer the type of a construction of which the head is an overloaded constructor.
-- This is because Agda really wants to check the construction, rather than inferring a type for it.
-- It just happens that when the constructor is not overloaded, it's easier to make progress, because that gives just enough to check the construction against.
-- Q: Copattern match in emacs
-- A: (James Wood 05.11.19, 22:41) If I understand the question correctly, it's the usual C-c C-c for case-splitting, but on an empty hole and followed immediately by RET, rather than entering a variable name. The intermediate prompt is “pattern variables to case (empty for split on result)”. It's splitting on the result that you want.
-- Constructor names can overlap; the right one will be chosen on usage depending on the expected type.
-- Note that other kind of names cannot overlap (e.g. definition names, etc..).
-- the cubical std-lib is described in a blog post from Andreas Mörtberg
-- https://homotopytypetheory.org/2018/12/06/cubical-agda/
-- isomorphisms are equivalences (i.e. have contractible fibers)
-- Hedberg’s theorem (types with decidable equality are sets)
-- The main things that the CCHM cubical type theory extends dependent type theory with are:
-- 1. An interval pretype
-- 2. Kan operations
-- 3. Glue types
-- 4. Cubical identity types
open import Cubical.Structures.CommRing
open import Cubical.Relation.Nullary.Base -- ¬_
open import Cubical.Relation.Binary.Base
-- open import Cubical.Data.Prod.Base renaming (_×_ to _×'_)
-- NOTE: Cubical.Core.Sigma uses Agda.Builtin.Sigma
-- open import Agda.Builtin.Sigma renaming (_×_ to _×ᵇ_)
open import Cubical.Data.Sum.Base
open import Cubical.Data.Sigma.Base -- Σ-types are defined in Core/Primitives as they are needed for Glue types.
-- PathP : ∀ {ℓ} (A : I → Set ℓ) → A i0 → A i1 → Set ℓ
--
-- We have a variable name in `(λ i → A)` as a hint for case splitting.
--
-- Path : ∀ {ℓ} (A : Set ℓ) → A → A → Set ℓ
-- Path A a b = PathP (λ _ → A) a b
--
-- _≡_ : ∀ {ℓ} {A : Set ℓ} → A → A → Set ℓ
-- _≡_ {A = A} = PathP (λ i → A)
-- Cubical.Foundations.Id
--
-- transport : ∀ (B : A → Type ℓ') {x y : A} → x ≡ y → B x → B y
-- transport B {x} p b = J (λ y p → B y) b p
--
-- _⁻¹ : {x y : A} → x ≡ y → y ≡ x
-- _⁻¹ {x = x} p = J (λ z _ → z ≡ x) refl p
--
-- ap : ∀ {B : Type ℓ'} (f : A → B) → ∀ {x y : A} → x ≡ y → f x ≡ f y
-- ap f {x} = J (λ z _ → f x ≡ f z) refl
--
-- _∙_ : ∀ {x y z : A} → x ≡ y → y ≡ z → x ≡ z
-- _∙_ {x = x} p = J (λ y _ → x ≡ y) p
refl1 : ∀ {ℓ} {A : Type ℓ} {x : A} → Path A x x
refl1 {x = x} = λ i → x
refl2 : ∀ {ℓ} {A : Type ℓ} {x : A} → PathP (λ _ → A) x x
refl2 {x = x} = λ i → x
refl3 : ∀{ℓ} {A : Type ℓ} {x : A} → PathP (λ _ → A) x x
refl3 {x = x} = λ _ → x
sym1 : ∀ {ℓ} {A : Type ℓ} {x y : A} → x ≡ y → y ≡ x
sym1 p = λ i → p (~ i)
cong1 : ∀ {ℓ} {A : Type ℓ} {x y : A} {B : A → Type ℓ}
(f : (a : A) → B a)
(p : x ≡ y)
--------------------------------------------
→ PathP (λ i → B (p i)) (f x) (f y)
cong1 f p i = f (p i)
cong2 : ∀ {ℓ} {A : Type ℓ} {x y : A} {B : A → Type ℓ}
(f : (a : A) → B a)
(p : PathP (λ i → A ) x y )
----------------------------------------------
→ ( PathP (λ i → B (p i)) (f x) (f y))
cong2 f p i = f (p i)
-- see "Propositional truncation" https://homotopytypetheory.org/2018/12/06/cubical-agda for
-- data ∥_∥ {ℓ} (A : Set ℓ) : Set ℓ where
-- ∣_∣ : A → ∥ A ∥
-- squash : ∀ (x y : ∥ A ∥) → x ≡ y
-- see https://planetmath.org/37propositionaltruncation
open import Cubical.HITs.PropositionalTruncation -- for `|_|` and `squash`
test1 : {Carrier : Type} -> ∃[ x ∈ Carrier ] x ≡ x → Carrier
test1 ∣ x , x≡x ∣ = x
-- Goal: Carrier
-- ———— Boundary ——————————————————————————————————————————————
-- i = i0 ⊢ test1 x
-- i = i1 ⊢ test1 y
-- ———— Constraints ———————————————————————————————————————————
-- test1 x = ?0 (i = i0) : Carrier
-- test1 y = ?0 (i = i1) : Carrier
test1 (squash x y i) = {! test1 x!}
test2 : {A : Type} → (x y : A) → x ≡ y → A
-- test2 x y x≡y = {! x≡y!}
test2 x y p = p i0
-- test4 : I → Type
-- test4 i = {!!}
test5a : {A : Type} {P : A → Type} → (x y : A) → x ≡ y → P x → P y
test5a {A} {P} x y p px = transport (λ i → P (p i)) px
test5b : {A : Type}
→ {P : A → Type}
→ (x y : A)
→ PathP (λ _ → A) x y -- x ≡ y
→ P x
--------------------------
→ P y
test5b {A} {P} x y x≡y Px = transport {A = P x} Px≡Py Px where
-- transport gives us `P x → P y`, but we need to feed it `P x ≡ P y`
Px≡Py : P x ≡ P y
Px≡Py = cong P x≡y
-- this is almost what `isProp P` would give us
-- isProp : ∀ {ℓ} → Type ℓ → Type ℓ
-- isProp A = (x y : A) → x ≡ y
-- but we need something like `∀(x y : A) → P x ≡ P y`
-- well, no. `cong P x≡y` gives us `P x ≡ P y`
-- it is different from non-cubical agda, where `x ≡ y` was sufficient, no matter what P is
-- there, we could just pattern match on refl and "change" the goal to `P x` instead of `P y`
-- well, in some sense we are already changing the goal as this approach could be "at the end" of a sequence of equational reasoning
-- ... just without pattern matching
test5c : {A : Type}
→ {P : A → Type}
→ (x y : A)
→ PathP (λ _ → A) x y -- x ≡ y
→ P x
--------------------------
→ P y
test5c {A} {P} x y x≡y Px = transport {A = P x} Px≡Py Px where
-- once again, without `cong`
Px≡Py : P x ≡ P y
-- we need to build a path that is `P x` at i0 and `P y` at i1
-- with `x≡y` we have given a path that is `x` at i0 and `y` at i1
-- therefore `x≡y(i)` behaves in the correct way and we just plug this into `P`
Px≡Py i = P (x≡y i)
-- the short version, collapsing all intermediates
test5f : ∀{ℓ ℓ'} {A : Type ℓ} {P : A → Type ℓ'} {x y : A} → (x ≡ y) → (P x) → P y
test5f {P = P} p px = transport (λ i → P (p i)) px
--primitive
-- transp : ∀ {ℓ} (A : (i : I) → Set (ℓ i)) (φ : I) (a : A i0) → A i1
transport1 : ∀{ℓ} {A B : Type ℓ} → A ≡ B → A → B
transport1 p a = transp (λ i → p i) i0 a
test5d : {A : Type} {P : A → Type} → (x y : A) → x ≡ y → P x → P y
test5d {A} {P} x y x≡y Px = transport (cong P x≡y) Px
module Utils where
private
variable
ℓ ℓ' : Level
A : Type ℓ
B : A → Type ℓ
C : (a : A) → B a → Type ℓ
D : (a : A) → (b : B a) → C a b → Type ℓ
cong₁ : ∀ (f : (a : A) → B a)
→ {x : A} {y : A} (p : PathP (λ i → A) x y) -- (p : x ≡ y)
----------------------------------
→ PathP (λ i → B (p i)) (f x) (f y)
cong₁ f p i = f (p i)
{-# INLINE cong₁ #-}
cong₂' : ∀ {F : (a : A) → (b : B a) → Type ℓ}
→ (f : (a : A) → (b : B a) → F a b)
→ {x : A } {y : A } (p : PathP (λ i → A ) x y) -- (p : x ≡ y)
→ {u : B x } {v : B y } (q : PathP (λ i → B (p i) ) u v) -- ? u ≡ v given x ≡ y ?
---------------------------------------------
→ PathP (λ i → F (p i) (q i)) (f x u) (f y v)
cong₂' f p q i = f (p i) (q i)
{-# INLINE cong₂' #-}
cong₃ : ∀{F : (a : A) → (b : B a) → (c : C a b) → Type ℓ}
→ (f : (a : A) → (b : B a) → (c : C a b) → F a b c)
→ {x : A } {y : A } (p : PathP (λ i → A ) x y) -- (p : x ≡ y)
→ {u : B x } {v : B y } (q : PathP (λ i → B (p i) ) u v) -- ? u ≡ v given x ≡ y ?
→ {m : C x u} {n : C y v} (r : PathP (λ i → C (p i) (q i)) m n) -- ? m ≡ n given x ≡ y and u ≡ v ?
--------------------------------------------
→ PathP (λ i → F (p i) (q i) (r i)) (f x u m) (f y v n)
cong₃ f p q r i = f (p i) (q i) (r i)
{-# INLINE cong₃ #-}
cong₄ : ∀{F : (a : A) → (b : B a) → (c : C a b) → (d : D a b c) → Type ℓ}
→ (f : (a : A) → (b : B a) → (c : C a b) → (d : D a b c) → F a b c d)
→ {x : A } {y : A } (p : PathP (λ i → A ) x y) -- (p : x ≡ y)
→ {u : B x } {v : B y } (q : PathP (λ i → B (p i) ) u v) -- ? u ≡ v given x ≡ y ?
→ {m : C x u } {n : C y v } (r : PathP (λ i → C (p i) (q i) ) m n) -- ? m ≡ n given x ≡ y and u ≡ v ?
→ {k : D x u m} {l : D y v n} (s : PathP (λ i → D (p i) (q i) (r i)) k l) -- ? k ≡ l given x ≡ y and u ≡ v and m ≡ n?
--------------------------------------------
→ PathP (λ i → F (p i) (q i) (r i) (s i)) (f x u m k) (f y v n l)
cong₄ f p q r s i = f (p i) (q i) (r i) (s i)
{-# INLINE cong₄ #-}
open Utils using (cong₃; cong₄)
-- slide 18 of http://www.cse.chalmers.se/~abela/esslli2016/talkESSLLI3.pdf
fullelim : (A : Type)
→ (C : (x y : A) → (p : x ≡ y) → Type)
→ (M N : A)
→ (P : M ≡ N)
→ (O : (z : A) → C z z refl)
------------------------
→ C M N P
fullelim A C M N P O = transport along (O M) where
along : C M M refl ≡ C M N P
-- the "obvious" idea would be to show equality on every argument
-- and then use a brute force `cong₃` to apply these equalities
along = cong₃ C (refl {x = M}) P refl≡P where
-- the first two arguments are easy, and the hole of the third argument rewards us with a signature to implement:
refl≡P : PathP (λ i → M ≡ (P i)) refl P
-- here, we need to build a path that is refl on i0 and P on i1 just with the things we have given
-- refl : ∀{ℓ} {A : Type ℓ} {x : A} x ≡ x
-- refl {x = x} = λ _ → x
-- _≡_ : ∀ {ℓ} {A : Set ℓ} → A → A → Set ℓ
-- _≡_ {A = A} = PathP (λ i → A)
-- therefore, we have
-- refl : ∀{ℓ} {A : Type ℓ} {x : A} → PathP (λ i → A) M M
-- refl {x = x} = λ _ → x
-- P : PathP (λ i → A) M N
-- Goal: M ≡ P i
-- Goal: PathP (λ j → A) M (P i)
refl≡P i = λ j → P (i ∧ j)
-- I could not come up with the solution myself, but I was able to pick it off ...
-- ... of `J` under "Kan operations" at https://homotopytypetheory.org/2018/12/06/cubical-agda/
-- so, how does this work? These are the cases:
-- i | j | i∧j | P(i∧j) | λ j → P(i∧j) | λ i → λ j → P(i∧j)
-- i0 | i0 | i0 | M : A | M≡M : M ≡ M | p : (M≡M) ≡ (M≡N)
-- i0 | i1 | i0 | M : A | | which is "like"
-- i1 | i0 | i0 | M : A | M≡N : M ≡ N | p : refl ≡ P
-- i1 | i1 | i1 | N : A | |
-- and indeed, they work out
-- we could not write `refl ≡ P` but instead have `PathP _ refl P`
fullelim2 : (A : Type)
→ (C : (x y : A) → (p : x ≡ y) → Type)
→ (M N : A)
→ (P : M ≡ N)
→ (O : (z : A) → C z z refl)
------------------------
→ C M N P
-- we can unfold `transport` as in the blog post
-- transport : {A B : Type ℓ} → A ≡ B → A → B
-- transport p a = transp (λ i → p i) i0 a
fullelim2 A C M N P O = transp (λ i → along i) i0 (O M) where
-- and we can directly "set up" the path without using `cong₃`
along : C M M refl ≡ C M N P
along i = C (refl {x = M} i) (P i) (λ j → P (i ∧ j) )
--
-- see favonia: [Agda] Equational Reasoning
-- https://favonia.org/courses/hdtt2020/agda/agda-0305-eqreasoning.agda
-- Kraus 2013 - Generalizations of Hedberg’s Theorem
-- https://www.cs.bham.ac.uk/~mhe/papers/hedberg.pdf
-- Although the identity types in Martin-Löf type theory (MLTT) are defined byone constructor refl and by one eliminator J that matches the constructor, the statement that every identity type has at most one inhabitant is not provable [9].
-- Thus,uniqueness of identity proofs(UIP), or, equivalently, Streicher’s axiom K are principles that have to be assumed, and have often been assumed, as additional rules of MLTT.
-- ...
-- we do not assume the principle of unique identity proofs.
-- However, certain types do satisfy it naturally, and such types are often called h-sets.
-- A sufficient condition for a type to be an h-set, given by Hedberg [8], isthat it has decidable propositional equality.
-- In Section 3, we analyze Hedberg’s original argument, which consists of two steps:
-- 1. A type X is an h-set iff for all x, y : X there is a constant map x = y → x = y.
-- 2. If X has decidable equality then such constant endomaps exist
-- Decidable equality means that, for all x and y, we have (x = y) + (x ≠ y).
-- Thus, a natural weakening is ¬¬-separated equality, ¬¬(x = y) → x = y, which occurs often in constructive mathematics.
-- In this case we say that the type X is separated.
-- For example, going beyond MLTT, the reals and the Cantorspace in Bishop mathematics and topos theory are separated.
-- In MLTT, the Cantortype of functions from natural numbers to booleans is separated under the assumption of functional extensionality,
-- ∀ f g : X → Y, (∀ x : X, f x = g x) → f = g.
-- We observe that under functional extensionality, a separated type X is an h-set, because there is always a constant map x = y → x = y.
-- In order to obtain a further characterization of the notion of h-set, we consider truncations
-- (also known as bracket or squash types), written ‖X‖in accordance with recent HoTT notation.
-- The idea is to collapse all inhabitants of X so that ‖X‖ has at most one inhabitant.
-- We refer the reader to the technical development for a precise definition.
-- cites
-- Altenkirch 2012 - On h-Propositional Reflection and Hedberg’s Theorem
-- https://homotopytypetheory.org/2012/11/27/on-h-propositional-reflection-and-hedbergs-theorem/
-- Bracket-Type https://ncatlab.org/nlab/show/bracket+type
-- By contrast, in the paradigm that may be called propositions as some types, every proposition is a type, but not every type is a proposition.
-- The types which are propositions are generally those which “have at most one inhabitant” — in homotopy type theory this is called being of h-level 1 or being a (-1)-type.
-- ...
-- For A a type, the support of A denoted supp(A) or isInhab(A) or τ₋₁ A or ‖A‖₋₁ or ‖A‖ or, lastly, [A],
-- is the higher inductive type defined by the two constructors
-- a : A ⊢ isinhab(a) : supp(A)
-- x : supp(A), y : supp(A) ⊢ inpath(x,y) : (x = y),
-- where in the last sequent on the right we have the identity type.
-- https://github.com/agda/cubical/issues/286
-- It could also be a good idea to axiomatize the notion of a Caucy-complete Archimedean ordered field, as in Auke Booij's thesis, and show that Dedekind reals are an instance. The HoTT reals are then another instance. (Can cubical Agda handle the HoTT reals as a HIIT yet?)
-- https://www.cs.bham.ac.uk/~abb538/thesis-first_submission.pdf
-- Booij 2020 - Analysis in Univalent Type Theory
-- 4.1 Algebraic structure of numbers
--
-- Fields have the property that nonzero numbers have a multiplicative inverse, or more precisely, that
-- (∀ x : F) x ≠ 0 ⇒ (∃ y : F) x · y = 1.
--
-- Remark 4.1.1.
-- If we require the collection of numbers to form a set in the sense of Definition 2.5.4, and satisfy the ring axioms, then multiplicative inverses are unique, so that the above is equivalent to the proposition
-- (Π x : F) x ≠ 0 ⇒ (Σ y : F) x · y = 1.
--
-- Definition 4.1.2.
-- A classical field is a set F with points 0, 1 : F, operations +, · : F → F → F, which is a commutative ring with unit, such that
-- (∀ x : F) x ≠ 0 ⇒ (∃ y : F) x · y = 1.
private
variable
ℓ ℓ' ℓ'' : Level
module ClassicalFieldModule where -- NOTE: one might want to put this into another file to omit the name-clashing
record IsClassicalField {F : Type ℓ}
(0f : F) (1f : F) (_+_ : F → F → F) (_·_ : F → F → F) (-_ : F → F) (_⁻¹ᶠ : (x : F) → {{¬(x ≡ 0f)}} → F) : Type ℓ where
constructor isclassicalfield
field
isCommRing : IsCommRing 0f 1f _+_ _·_ -_
·-rinv : (x : F) → (p : ¬(x ≡ 0f)) → x · (_⁻¹ᶠ x {{p}}) ≡ 1f
·-linv : (x : F) → (p : ¬(x ≡ 0f)) → (_⁻¹ᶠ x {{p}}) · x ≡ 1f
open IsCommRing {0r = 0f} {1r = 1f} isCommRing public
record ClassicalField : Type (ℓ-suc ℓ) where
field
Carrier : Type ℓ
0f : Carrier
1f : Carrier
_+_ : Carrier → Carrier → Carrier
_·_ : Carrier → Carrier → Carrier
-_ : Carrier → Carrier
_⁻¹ᶠ : (x : Carrier) → {{¬(x ≡ 0f)}} → Carrier
isClassicalField : IsClassicalField 0f 1f _+_ _·_ -_ _⁻¹ᶠ
infix 9 _⁻¹ᶠ
infix 8 -_
infixl 7 _·_
infixl 6 _+_
open IsClassicalField isClassicalField public
-- Remark 4.1.3.
-- As in the classical case, by proving that additive and multiplicative inverses are unique, we also obtain the negation and division operations.
--
-- For the reals, the assumption x ≠ 0 does not give us any information allowing us to bound x away from 0, which we would like in order to compute multiplicative inverses.
-- Hence, we give a variation on the denition of fields in which the underlying set comes equipped with an apartness relation #, which satises x # y ⇒ x ≠ y, although the converse implication may not hold.
-- This apartness relation allows us to make appropriate error bounds and compute multiplicative inverses based on the assumption x # 0.
--
-- Definition 4.1.4.
-- - An apartness relation, denoted by #, is an irreflexive symmetric cotransitive relation.
-- - A strict partial order, denoted by <, is an irreflexive transitive cotransitive relation.
IsIrrefl : {ℓ ℓ' : Level} {A : Type ℓ} → (R : Rel A A ℓ') → Type (ℓ-max ℓ ℓ')
IsIrrefl {A = A} R = (a b : A) → R a b → ¬(R b a)
IsCotrans : {ℓ ℓ' : Level} {A : Type ℓ} → (R : Rel A A ℓ') → Type (ℓ-max ℓ ℓ')
IsCotrans {A = A} R = (a b : A) → R a b → (∀(x : A) → (R a x) ⊎ (R x b))
-- NOTE: these `IsX` definitions are in the style of the standard library and do not make `a` and `b` to be implicit arguments
-- when using them, we can just use `_` as in `isIrrefl _ _ a#b`
-- NOTE: module parameters "add" to the contained function's arguments
-- see https://agda.readthedocs.io/en/v2.6.0.1/language/module-system.html#parameterised-modules
-- IsApartnessRel : {ℓ ℓ' : Level} {A : Type ℓ} → (R : Rel A A ℓ') → Type (ℓ-max ℓ ℓ')
-- IsApartnessRel R = IsIrrefl R × BinaryRelation.isSym R × IsCotrans R
record IsApartnessRel {ℓ ℓ' : Level} {A : Type ℓ} (R : Rel A A ℓ') : Type (ℓ-max ℓ ℓ') where
field
isIrrefl : IsIrrefl R
isSym : BinaryRelation.isSym R
isCotrans : IsCotrans R
-- IsStrictPartialOrder : {ℓ ℓ' : Level} {A : Type ℓ} → (R : Rel A A ℓ') → Type (ℓ-max ℓ ℓ')
-- IsStrictPartialOrder R = IsIrrefl R × BinaryRelation.isTrans R × IsCotrans R
record IsStrictPartialOrder {ℓ ℓ' : Level} {A : Type ℓ} (R : Rel A A ℓ') : Type (ℓ-max ℓ ℓ') where
field
isIrrefl : IsIrrefl R
isTrans : BinaryRelation.isTrans R
isCotrans : IsCotrans R
-- Definition 4.1.5.
-- A constructive field is a set F with points 0, 1 : F, binary operations +, · : F → F → F, and a binary relation # such that
-- 1. (F, 0, 1, +, ·) is a commutative ring with unit;
-- 2. x : F has a multiplicative inverse iff x # 0;
-- 3. + is #-extensional, that is, for all w, x, y, z : F
-- w + x # y + z ⇒ w # y ∨ x # z.
{- NOTE: about naming in the standard library
with `isCommRing : IsCommRing 0f 1f _+_ _·_ -_` we import
is-set : (x y : Carrier) (x₁ y₁ : x ≡ y) → x₁ ≡ y₁ -- NOTE: this is imported from +-isAbGroup and explicitly hidden from ·-isMonoid
isCommRing : IsCommRing 0f 1f _+_ _·_ -_
isRing : IsRing 0f 1f _+_ _·_ -_
+-isAbGroup : IsAbGroup 0f _+_ -_
+-assoc : (x y z : Carrier) → x + (y + z) ≡ x + y + z
+-identity : (x : Carrier) → (x + 0f ≡ x) × (0f + x ≡ x)
+-rid : (x : Carrier) → x + 0f ≡ x
+-lid : (x : Carrier) → 0f + x ≡ x
+-inv : (x : Carrier) → (x + - x ≡ 0f) × (- x + x ≡ 0f)
+-linv : (x : Carrier) → - x + x ≡ 0f
+-rinv : (x : Carrier) → x + - x ≡ 0f
+-comm : (x y : Carrier) → x + y ≡ y + x
+-isSemigroup : IsSemigroup _+_
+-isMonoid : IsMonoid 0f _+_
+-isGroup : IsGroup 0f _+_ -_
·-isSemigroup : IsSemigroup _·_
·-isMonoid : IsMonoid 1f _·_
·-comm : (x y : Carrier) → x · y ≡ y · x
·-assoc : (x y z : Carrier) → x + (y + z) ≡ x + y + z
·-identity : (x : Carrier) → (x · 1f ≡ x) × (1f · x ≡ x)
·-lid : (x : Carrier) → 1f · x ≡ x
·-rid : (x : Carrier) → x · 1f ≡ x
dist : (x y z : Carrier) → (x · (y + z) ≡ x · y + x · z) × ((x + y) · z ≡ x · z + y · z)
·-rdist-+ : (x y z : Carrier) → x · (y + z) ≡ x · y + x · z
·-ldist-+ : (x y z : Carrier) → (x + y) · z ≡ x · z + y · z
there is
module GroupLemmas (G : Group {ℓ}) where
record MonoidEquiv (M N : Monoid {ℓ}) : Type ℓ where
module SemigroupΣTheory {ℓ} where
module CommRingΣTheory {ℓ} where
module MonoidΣTheory {ℓ} where
module MonoidTheory {ℓ} (M' : Monoid {ℓ}) where
module GroupΣTheory {ℓ} where
module AbGroupΣTheory {ℓ} where
module RingΣTheory {ℓ} where
module Theory (R' : Ring {ℓ}) where
module PosetReasoning (P : Poset ℓ₀ ℓ₁) where
there is a syntax for https://agda.readthedocs.io/en/latest/language/module-system.html?highlight=module#parameterised-modules
module SortNat = Sort Nat leqNat
the non-cubical standard library has a lot of machinery that is missing in the cubical-stdlib
module Function.Base where
-- Binary application
_⟨_⟩_ : A → (A → B → C) → B → C
x ⟨ f ⟩ y = f x y
-- Composition of a binary function with a unary function
_on_ : (B → B → C) → (A → B) → (A → A → C)
_*_ on f = λ x y → f x * f y
-- Flipped application (aka pipe-forward)
_|>_ : ∀ {A : Set a} {B : A → Set b} → (a : A) → (∀ a → B a) → B a
-- Construct an element of the given type by instance search.
it : {A : Set a} → {{A}} → A
it {{x}} = x
module Relation.Binary.Core where
infix 4 _⇒_ _⇔_ _=[_]⇒_
-- Implication/containment - could also be written _⊆_.
-- and corresponding notion of equivalence
_⇒_ : REL A B ℓ₁ → REL A B ℓ₂ → Set _
P ⇒ Q = ∀ {x y} → P x y → Q x y
_⇔_ : REL A B ℓ₁ → REL A B ℓ₂ → Set _
P ⇔ Q = P ⇒ Q × Q ⇒ P
-- Generalised implication - if P ≡ Q it can be read as "f preserves P".
_=[_]⇒_ : Rel A ℓ₁ → (A → B) → Rel B ℓ₂ → Set _
P =[ f ]⇒ Q = P ⇒ (Q on f)
-- A synonym for _=[_]⇒_.
_Preserves_⟶_ : (A → B) → Rel A ℓ₁ → Rel B ℓ₂ → Set _
f Preserves P ⟶ Q = P =[ f ]⇒ Q
-- A binary variant of _Preserves_⟶_.
_Preserves₂_⟶_⟶_ : (A → B → C) → Rel A ℓ₁ → Rel B ℓ₂ → Rel C ℓ₃ → Set _
_∙_ Preserves₂ P ⟶ Q ⟶ R = ∀ {x y u v} → P x y → Q u v → R (x ∙ u) (y ∙ v)
module Algebra.Definitions
Congruent₁ : Op₁ A → Set _
Congruent₁ f = f Preserves _≈_ ⟶ _≈_
Congruent₂ : Op₂ A → Set _
Congruent₂ ∙ = ∙ Preserves₂ _≈_ ⟶ _≈_ ⟶ _≈_
LeftCongruent : Op₂ A → Set _
LeftCongruent _∙_ = ∀ {x} → (x ∙_) Preserves _≈_ ⟶ _≈_
RightCongruent : Op₂ A → Set _
RightCongruent _∙_ = ∀ {x} → (_∙ x) Preserves _≈_ ⟶ _≈_
the non-cubical standard library makes more use of unicode, e.g. in invˡ and invʳ
for the inverse, we have in the non-cubical standard library
inverseˡ : LeftInverse ε _⁻¹ _∙_
inverseˡ = proj₁ inverse
inverseʳ : RightInverse ε _⁻¹ _∙_
inverseʳ = proj₂ inverse
uniqueˡ-⁻¹ : ∀ x y → (x ∙ y) ≈ ε → x ≈ (y ⁻¹)
uniqueˡ-⁻¹ = Consequences.assoc+id+invʳ⇒invˡ-unique
setoid ∙-cong assoc identity inverseʳ
uniqueʳ-⁻¹ : ∀ x y → (x ∙ y) ≈ ε → y ≈ (x ⁻¹)
uniqueʳ-⁻¹ = Consequences.assoc+id+invˡ⇒invʳ-unique
setoid ∙-cong assoc identity inverseˡ
interestingly, this follows from just one field `inverse : Inverse ε _⁻¹ _∙_`
there is `module Algebra.Consequences.Setoid` for such results ("consequences")
there are open pull requests which might have some more information about the "intended" style
https://github.com/agda/cubical/pull/331
Algebras and modules #331
https://github.com/agda/cubical/pull/365
Mayer-Vietoris and some cohomology groups #365
https://github.com/agda/cubical/pull/325
Denial field #325
A denial field is a commutative ring where every non-zero element has an inverse. See #301 for a discussion of other notions of 'field' in constructive algebra.
https://github.com/felixwellen/cubical/tree/denial-field
https://github.com/agda/cubical/issues/301
Add Field to Cubical.Structures #301
In the style of Ring, etc. from #284. I think it would be good to have this so we could show ℚ is a field.
https://github.com/agda/cubical/pull/284
Newstructures #284
Adding some new structures (semigroups, groups, abelian groups and rngs) and a new folder of Algebra, in order to produce results about these new Algebraic structures.
https://github.com/agda/cubical/commit/8cf91aeb49ebf26d4cf4e6795e8b56041e28c7a1
Rewrite Group, AbGroup, Ring and CommRing to be records instead of nested Sigma types
https://github.com/agda/cubical/pull/324
Ideals and quotient rings #324
- define (left-, right- and two-sided) ideals
- define quotient by a two-sided ideal
- construct the ring structure on the quotient
-}
record IsConstructiveField {F : Type ℓ}
(0f : F) (1f : F) (_+_ : F → F → F) (_·_ : F → F → F) (-_ : F → F) (_#_ : Rel F F ℓ') (_⁻¹ᶠ : (x : F) → {{x # 0f}} → F) : Type (ℓ-max ℓ ℓ') where
constructor isconstructivefield
field
isCommRing : IsCommRing 0f 1f _+_ _·_ -_
·-rinv : (x : F) → (p : x # 0f) → x · (_⁻¹ᶠ x {{p}}) ≡ 1f
·-linv : (x : F) → (p : x # 0f) → (_⁻¹ᶠ x {{p}}) · x ≡ 1f
-- ·-inv : (x : F) → (p : x # 0f) → x · (let instance p = p in (x ⁻¹ᶠ)) ≡ 1f -- this does also work
-- ·-inv : (x : F) → ({{p}} : x # 0f) → x · (x ⁻¹ᶠ) ≡ 1f -- this does not do the right thing
-- ·-inv-back : (x : F) → ∃[ y ∈ F ] (x · y ≡ 1f) → x # 0f
·-inv-back : (x y : F) → (x · y ≡ 1f) → x # 0f × y # 0f
+-#-extensional : (w x y z : F) → (w + x) # (y + z) → (w # y) ⊎ (x # z)
isApartnessRel : IsApartnessRel _#_
open IsCommRing {0r = 0f} {1r = 1f} isCommRing public
open IsApartnessRel isApartnessRel public
renaming
( isIrrefl to #-irrefl
; isSym to #-sym
; isCotrans to #-cotrans )
_ = {!!}
record ConstructiveField : Type (ℓ-suc (ℓ-max ℓ ℓ')) where
field
Carrier : Type ℓ
0f : Carrier
1f : Carrier
_+_ : Carrier → Carrier → Carrier
_·_ : Carrier → Carrier → Carrier
-_ : Carrier → Carrier
_#_ : Rel Carrier Carrier ℓ'
_⁻¹ᶠ : (x : Carrier) → {{x # 0f}} → Carrier
isConstructiveField : IsConstructiveField 0f 1f _+_ _·_ -_ _#_ _⁻¹ᶠ
infix 9 _⁻¹ᶠ
infixl 7 _·_
infix 6 -_
infixl 5 _+_
infixl 4 _#_
open IsConstructiveField isConstructiveField public
open import Cubical.Data.Empty renaming (elim to ⊥-elim) -- `⊥` and `elim`
-- Lemma 4.1.6.
-- For a constructive field (F, 0, 1, +, ·, #), the following hold.
-- 1. 1 # 0.
-- 2. Addition + is #-compatible in the sense that for all x, y, z : F
-- x # y ⇔ x + z # y + z.
-- 3. Multiplication · is #-extensional in the sense that for all w, x, y, z : F
-- w · x # y · z ⇒ w # y ∨ x # z.
module Lemmas-4-6-1 {{F : ConstructiveField {ℓ} {ℓ'}}} where
--open ConstructiveField {{...}} public -- creates additional `ConstructiveField.foo F` in the "Goal/Have-previews"
open ConstructiveField F -- works
open import Cubical.Structures.Ring
-- NOTE: this also creates additional `Ring.Carrier (makeRing ...)` in the "Goal/Have-previews", except when using C-u C-u C-... then these get normalized fine
-- can we do something with pragmas here? https://agda.readthedocs.io/en/latest/language/pragmas.html?highlight=INLINE#the-inline-and-noinline-pragmas
-- or maybe with macros? https://github.com/alhassy/gentle-intro-to-reflection
-- using this `R` makes it a little better
R = (makeRing 0f 1f _+_ _·_ -_ is-set +-assoc +-rid +-rinv +-comm ·-assoc ·-rid ·-lid ·-rdist-+ ·-ldist-+)
open Cubical.Structures.Ring.Theory R
-- 0-rightNullifies
-- open Ring {{...}} public
{-
module ReflectionTest where
open import Data.Nat as Nat hiding (_⊓_)
open import Data.List as List
open import Data.Char as Char
open import Data.String as String
open import Reflection hiding (name; Type)
open import Reflection.Term as Term public hiding (Type)
test06 = (quoteTC 0-rightNullifies)
test07 : _
unquoteDef test07 = defineFun test07
[ clause
( [] ) -- hidden arguments `{x}`
( [] ) -- visible arguments `{y}`
(quoteTerm 0f) -- the "Term" at the right hand side of the `=`
]
-- {-# INLINE test07 #-}
-- {-# NOINLINE test07 #-}
proof07 : test07 ≡ 0f
proof07 = {!!}
-}
{-
-- NOTE: it might be possible with --overlapping-instances to resolve this "Goal/Have-preview" issue
-- but it is mentioned that this "might lead to an exponential slowdown in instance resolution and possibly (apparent) looping behaviour"
-- also the OPTION pragma to apply --overlapping-instances can only be set per file (and not per module)
-- so it might be a good idea to have a separate "Theory.agda" or "Properties.agda" (as it is called in the standard library)
-- well, in a test with --overlapping instances, I got the issue that -_ is defined multiple times
-- to be fair, the result we have implemented might fit better in a more general Ring context
-- so one might think about this and until then, I guess, the best solution is to just omit multiple instances
module InstanceTest where
-- taken from https://agda.readthedocs.io/en/latest/language/instance-arguments.html#defining-type-classes
-- open import Algebra
open import Agda.Builtin.Nat
open import Data.List renaming (List to BList)
record Monoid {a} (A : Type a) : Type a where
field
mempty : A
_<>_ : A → A → A
open Monoid {{...}} public
instance
ListMonoid : ∀ {a} {A : Type a} → Monoid (BList A)
-- normal: provide "implementation" in a single term
-- ListMonoid = record { mempty = []; _<>_ = _++_ }
-- with copatterns: provide "implementation" with patterns
mempty {{ListMonoid}} = []
_<>_ {{ListMonoid}} xs ys = xs ++ ys
mconcat : ∀ {a} {A : Type a} → {{Monoid A}} → BList A → A
mconcat [] = mempty
mconcat (x ∷ xs) = x <> mconcat xs
sum1 : BList Nat → Nat
sum1 xs =
let instance -- NOTE: IMPORTANT: the instance-block needs to be more indented (!) than the `instance` keyword
NatMonoid : Monoid Nat
NatMonoid = record { mempty = 0; _<>_ = Agda.Builtin.Nat._+_ }
in mconcat xs
itest2 =
let
instance
rr = R
in {! 0-rightNullifies!}
-- To restrict an instance to the current module, you can mark it as private. For instance,
-- https://agda.readthedocs.io/en/latest/language/instance-arguments.html#restricting-instance-search
-}
{-
https://agda.readthedocs.io/en/latest/language/abstract-definitions.html
Abstract definitions
Definitions can be marked as abstract, for the purpose of hiding implementation details, or to speed up type-checking of other parts. In essence, abstract definitions behave like postulates, thus, do not reduce/compute. For instance, proofs whose content does not matter could be marked abstract, to prevent Agda from unfolding them (which might slow down type-checking).
-}
-- anonymous modules `module _ params where` automatically open themselves
-- they are not well documented but there is this usage example
-- Anonymous modules or sections #735
-- https://github.com/agda/agda/issues/735
-- I often want to use something like sections in Coq. I usually use parametrized modules but this has at least two issues that Coq does not have:
-- 1) I need to give a name to the module, and there is often no meaningful name to be given
-- 2) It exports the module, so I cannot define a module in another file with the same name
-- the following code
-- module _ params where
-- declarations
-- would be translated to:
-- private
-- module Fresh params where
-- declarations
-- open Fresh public
-- where Fresh is a new name.
-- NOTE: this gives a hint on the use of "sections" in mathematical writing
-- it suggests, that these introduce variable-but-fixed parameter dependencies to all definitions (in the way the `variable` keyword does)
-- the difference between an anonymous module and a variable seems to be that the module adds all parameters, where `variable` only adds parameters when used
-- also, in the module we have more flexibility with opening other modules and hiding names with the `private` keyword, etc.
-- and there is
-- https://github.com/agda/agda/issues/1145
-- Allow multiple layout keywords on the same line #1145
-- NOTE: IMPORTANT: when in a hole, with C-c C-o one can list "module contents"
-- if given `F` here, we can see the contents of F
-- I guess, since every inherited member is included with `open ... public`,
-- we can continue with just `isConstructiveField`
-- and even `isCommRing`
-- and even `isRing`
-- this greatly helps to investigate available
{-
test3 : ∃[ x ∈ Carrier ] x · x ≡ x → Carrier
test3 ∥_∥.∣ Σx-x·x≡x ∣ = {!!}
--test ∥_∥.∣ x , x·x≡x ∣ = x
test3 (∥_∥.squash Σx-x·x≡x₁ Σx-x·x≡x₂ i) = {!!}
test3b : {A : Type} → ∃[ x ∈ A ] ∃[ y ∈ A ] x ≡ y → A
test3b ∥_∥.∣ fst₁ , ∥_∥.∣ fst₂ , snd₁ ∣ ∣ = {!!}
test3b ∥_∥.∣ fst₁ , ∥_∥.squash snd₁ ∥_∥.∣ x ∣ i ∣ = {!!}
test3b ∥_∥.∣ fst₁ , ∥_∥.squash snd₁ (∥_∥.squash snd₂ ∥_∥.∣ x ∣ i₁) i ∣ = {!!}
test3b ∥_∥.∣ fst₁ , ∥_∥.squash snd₁ (∥_∥.squash snd₂ (∥_∥.squash snd₃ snd₄ i₂) i₁) i ∣ = {!!}
test3b (∥_∥.squash ∥_∥.∣ x ∣ ∥_∥.∣ x₁ ∣ i) = {!!}
test3b (∥_∥.squash ∥_∥.∣ x ∣ (∥_∥.squash x₁ x₂ i₁) i) = {!!}
test3b (∥_∥.squash (∥_∥.squash x x₂ i₁) x₁ i) = {!!}
-}
-- ∃ : ∀ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') → Type (ℓ-max ℓ ℓ')
-- ∃ A B = ∥ Σ A B ∥
-- infix 2 ∃-syntax
-- ∃-syntax : ∀ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') → Type (ℓ-max ℓ ℓ')
-- ∃-syntax = ∃
-- syntax ∃-syntax A (λ x → B) = ∃[ x ∈ A ] B
-- Lemma 4.1.6.1
1f#0f : 1f # 0f
1f#0f with ·-identity 1f
-- 1f#0f | 1·1≡1 , _ = ·-inv-back 1f ∣ (1f , 1·1≡1) ∣ -- need additional ∣_∣ resp. \|_\| around the tuple
1f#0f | 1·1≡1 , _ = fst (·-inv-back _ _ 1·1≡1)
_ = Cubical.Data.Sigma.Base._×_ -- fst and snd
a+b-b≡a : ∀ a b → a ≡ (a + b) - b
-- NOTE: about workflow
-- one can investigate some single term in the hole (C-c C-.), but not a second one
-- therefore, we can move a term temporarily into a let-clause and work on another term in the hole
-- ... is there equational reasoning in --cubical ?
-- NOTE: Yes! it is in Cubical.Foundations.Id
a+b-b≡a a b = let P = sym (fst (+-inv b))
Q = sym (fst (+-identity a))
R = transport (λ i → a ≡ a + P i) Q
S = transport (λ i → a ≡ (+-assoc a b (- b)) i ) R
in S
+-preserves-≡ : ∀{a b} → ∀ c → a ≡ b → a + c ≡ b + c
+-preserves-≡ c a≡b i = a≡b i + c
+-preserves-≡-l : ∀{a b} → ∀ c → a ≡ b → c + a ≡ c + b
+-preserves-≡-l c a≡b i = c + a≡b i
a+b≡0→a≡-b : ∀{a b} → a + b ≡ 0f → a ≡ - b
a+b≡0→a≡-b {a} {b} a+b≡0 = transport
(λ i →
let RHS = snd (+-identity (- b))
LHS₁ : a + (b + - b) ≡ a + 0f
LHS₁ = +-preserves-≡-l a (fst (+-inv b))
LHS₂ : (a + b) - b ≡ a
LHS₂ = transport (λ j → (+-assoc a b (- b)) j ≡ fst (+-identity a) j) LHS₁
in LHS₂ i ≡ RHS i
) (+-preserves-≡ (- b) a+b≡0)
a·-b≡-a·b : ∀ a b → a · (- b) ≡ - a · b
a·-b≡-a·b a b =
let P : a · 0f ≡ 0f
P = 0-rightNullifies a
Q : a · (- b + b) ≡ 0f
Q = transport (λ i → a · snd (+-inv b) (~ i) ≡ 0f) P
R : a · (- b) + a · b ≡ 0f
R = transport (λ i → ·-rdist-+ a (- b) b i ≡ 0f) Q
in a+b≡0→a≡-b R
a·b-a·c≡a·[b-c] : ∀ a b c → a · b - a · c ≡ a · (b - c)
a·b-a·c≡a·[b-c] a b c =
let P : a · b + a · (- c) ≡ a · (b + - c)
P = sym (·-rdist-+ a b (- c))
Q : a · b - a · c ≡ a · (b + - c)
Q = transport (λ i → a · b + a·-b≡-a·b a c i ≡ a · (b + - c) ) P
in Q
-- Lemma 4.1.6.2
-- For #-compatibility of +, suppose x # y, that is, (x +z) −z # (y +z) −z.
-- Then #-extensionality gives (x + z # y + z) ∨ (−z # −z), where the latter case is excluded by irreflexivity of #.
+-#-compatible : ∀(x y z : Carrier) → x # y → x + z # y + z
+-#-compatible x y z x#y with
let P = transport (λ i → a+b-b≡a x z i # a+b-b≡a y z i ) x#y
in +-#-extensional _ _ _ _ P
... | inl x+z#y+z = x+z#y+z
... | inr -z#-z = ⊥-elim (#-irrefl _ _ -z#-z -z#-z)
-- The other direction is similar.
+-#-compatible-inv : ∀(x y z : Carrier) → x + z # y + z → x # y
+-#-compatible-inv _ _ _ x+z#y+z with +-#-extensional _ _ _ _ x+z#y+z
... | inl x#y = x#y
... | inr z#z = ⊥-elim (#-irrefl _ _ z#z z#z)
-- _ = {!!} ≃⟨ {!!} ⟩ {!!} ■
-- open import
-- _ = {!!} ≡[ i ]⟨ {!!} ⟩ {!!} ∎
--_≡⟨_⟩_ : (x : A) → x ≡ y → y ≡ z → x ≡ z
--_ ≡⟨ x≡y ⟩ y≡z = x≡y ∙ y≡z
-- for a list of unicode symbols in agda, see https://people.inf.elte.hu/divip/AgdaTutorial/Symbols.html
infix 3 _◼
infixr 2 _⇒⟨_⟩_
_⇒⟨_⟩_ : ∀{ℓ ℓ' ℓ''} {Q : Type ℓ'} {R : Type ℓ''} → (P : Type ℓ) → (P → Q) → (Q → R) → (P → R)
_ ⇒⟨ pq ⟩ qr = qr ∘ pq
_◼ : ∀{ℓ} (A : Type ℓ) → A → A
_ ◼ = λ x → x
f : Carrier → Carrier
f x with +-inv x
... | fst₁ , snd₁ = {!!}
-- see https://agda.readthedocs.io/en/latest/language/instance-arguments.html
it : ∀ {a} {A : Type a} → {{A}} → A
it {{x}} = x -- instance search
-- Lemma 4.1.6.3
-- TODO: there is equational resoning in Cubical.Foundations.Id, use this
-- P = _ ≡⟨ _ ⟩ _ ∎
-- P = _ ≡[ i ] _ ∎
-- syntax ≡⟨⟩-syntax x (λ i → B) y = x ≡[ i ]⟨ B ⟩ y
-- in general this module offers a lot of useful equational machinery
-- it already makes use of path concatenation with ∙ and ∙∙
-- there is also Cubical.Foundations.Equiv
-- P = _ ≃⟨ _ ⟩ _ ■
·-#-extensional-case1 : ∀(w x y z : Carrier) → w · x # y · z → w · x # w · z → x # z
·-#-extensional-case1 w x y z w·x#y·z w·x#w·z =
let P : w · x + - w · x # w · z + - w · x
P = +-#-compatible _ _ (- (w · x)) w·x#w·z
Q : 0f # w · (z + - x)
Q = transport (λ i → (fst (+-inv (w · x)) i) # a·b-a·c≡a·[b-c] w z x i) P
instance -- NOTE: this allows to use ⁻¹ᶠ without an instance argument
q = #-sym _ _ Q
-- see https://agda.readthedocs.io/en/latest/language/instance-arguments.html
it : ∀ {a} {A : Type a} → {{A}} → A
it {{x}} = x -- instance search
R : w · (z - x) · (w · (z - x)) ⁻¹ᶠ ≡ 1f
R = ·-rinv (w · (z - x)) it -- (#-sym _ _ Q)
S : (z + - x) · w · (w · (z + - x)) ⁻¹ᶠ ≡ 1f
S = transport (λ i → ·-comm w (z - x) i · (w · (z - x)) ⁻¹ᶠ ≡ 1f) R
T : (z + - x) · (w · (w · (z + - x)) ⁻¹ᶠ) ≡ 1f
T = transport (λ i → ·-assoc (z + - x) w ((w · (z + - x)) ⁻¹ᶠ) (~ i) ≡ 1f) S
U : z - x # 0f
U = fst (·-inv-back _ _ T)
V : z - x + x # 0f + x
V = (+-#-compatible _ _ x) (fst (·-inv-back _ _ T)) -- (+-#-compatible _ _ x U)
-- workflow:
-- start with `transport (λ i → z - x + x # 0f + x) V` in the hole (i.e. a constant transport)
-- and then fiddle with the path and look what comes out
W : z + (- x + x) # x
W = transport (λ i → +-assoc z (- x) x (~ i) # snd (+-identity x) i) V
X : z + 0f # x
X = transport (λ i → z + snd (+-inv x) i # x) W
in (#-sym _ _ (transport (λ i → fst (+-identity z) i # x) X))
·-#-extensional : ∀(w x y z : Carrier) → w · x # y · z → (w # y) ⊎ (x # z)
·-#-extensional w x y z w·x#y·z with #-cotrans _ _ w·x#y·z (w · z)
... | inl w·x#w·z = inr (·-#-extensional-case1 w x y z w·x#y·z w·x#w·z) -- first case
... | inr w·z#y·z = let z·w≡z·y = (transport (λ i → ·-comm w z i # ·-comm y z i) w·z#y·z)
in inl (·-#-extensional-case1 _ _ _ _ z·w≡z·y z·w≡z·y) -- second case reduced to first case
-- for an example to use equational reasoning in this topic, see https://github.com/felixwellen/cubical/blob/field/Cubical/Structures/Field.agda
-- we do not do equational reasoning here but "implicational" reasoning instead
-- the special syntax should make it more readable and omit giving names to every intermediate step
-- but giving names to intermediates in a `let` or `where` clause might just be the way it's done
-- c.f. with more elaborate proofs e.g. in https://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html#combining-structures
-- also see the elaborate proof in https://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html#381519
-- which uses equational reasoning, but still names the single steps i, ii, iii, iv, v, vi, ... and resolves them in a `where` clause
-- also see https://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html#391417
-- "We consider rings without unit, called rngs, and with unit, called rings."
-- this work of Martín Escardó was prepared for the
-- Midlands Graduate School in the Foundations of Computing Science (University of Birmingham, UK, 14 - 18 April, 2019)
-- http://events.cs.bham.ac.uk/mgs2019/
-- Introductory Courses:
-- - Lambda Calculus (course notes) by Venanzio Capretta (University of Nottingham)
-- - Category Theory (course notes) by Thorsten Altenkirch (University of Nottingham)
-- - Univalent Type Theory in Agda (course notes) by Martín Escardó (University of Birmingham)
·-#-extensional-case1' : ∀(w x y z : Carrier) → w · x # y · z → w · x # w · z → x # z
·-#-extensional-case1' w x y z w·x#y·z w·x#w·z =
let
instance -- this allows to use ⁻¹ᶠ without an instance argument
w·[z-x]#0f =
( w · x # w · z ⇒⟨ +-#-compatible _ _ (- (w · x)) ⟩
w · x - w · x # w · z - w · x ⇒⟨ transport (λ i → (fst (+-inv (w · x)) i) # a·b-a·c≡a·[b-c] w z x i) ⟩
0f # w · (z - x) ⇒⟨ #-sym _ _ ⟩
w · (z - x) # 0f ◼) w·x#w·z
in ( w · (z - x) # 0f ⇒⟨ (λ _ → ·-rinv (w · (z - x)) it ) ⟩ -- NOTE: "plugging in" the instance did not work, ∴ `it`
w · (z - x) · (w · (z - x)) ⁻¹ᶠ ≡ 1f ⇒⟨ transport (λ i → ·-comm w (z - x) i · (w · (z - x)) ⁻¹ᶠ ≡ 1f) ⟩
(z - x) · w · (w · (z - x)) ⁻¹ᶠ ≡ 1f ⇒⟨ transport (λ i → ·-assoc (z - x) w ((w · (z - x)) ⁻¹ᶠ) (~ i) ≡ 1f) ⟩
(z - x) · (w · (w · (z - x)) ⁻¹ᶠ) ≡ 1f ⇒⟨ fst ∘ (·-inv-back _ _) ⟩
z - x # 0f ⇒⟨ +-#-compatible _ _ x ⟩
(z - x) + x # 0f + x ⇒⟨ transport (λ i → +-assoc z (- x) x (~ i) # snd (+-identity x) i) ⟩
z + (- x + x) # x ⇒⟨ transport (λ i → z + snd (+-inv x) i # x) ⟩
z + 0f # x ⇒⟨ transport (λ i → fst (+-identity z) i # x) ⟩
z # x ⇒⟨ #-sym _ _ ⟩
x # z ◼) it -- conceptually we would plug `w·[z-x]#0f` in, but this breaks the very first step
--
-- Lemma 4.1.7.
-- Given a strict partial order < on a set X:
-- 1. we have an apartness relation defined by
-- x # y := (x < y) ∨ (y < x), and
-- 2. we have a preorder defined by
-- x ≤ y := ¬(y < x).
--
-- Definition 4.1.8.
-- Let (A, ≤) be a partial order, and let min, max : A → A → A be binary operators on A. We say that (A, ≤, min, max) is a lattice if min computes greatest lower bounds in the sense that for every x, y, z : A, we have
-- z ≤ min(x,y) ⇔ z ≤ x ∧ z ≤ y,
-- and max computes least upper bounds in the sense that for every x, y, z : A, we have
-- max(x,y) ≤ z ⇔ x ≤ z ∧ y ≤ z.
--
-- Remark 4.1.9.
-- 1. From the fact that (A, ≤, min, max) is a lattice, it does not follow that for every x and y, min(x,y) = x ∨ min(x,y) = y. However, we can characterize min as
-- z < min(x,y) ⇔ z < x ∨ z < y
-- and similarly for max, see Lemma 6.7.1.
-- 2. In a partial order, for two fixed elements a and b, all joins and meets of a, b are equal, so that Lemma 2.6.20 the type of joins and the type of meets are propositions. Hence, providing the maps min and max as in the above definition is equivalent to the showing the existenceof all binary joins and meets.
--
-- The following definition is modified from on The Univalent Foundations Program [89, Definition 11.2.7].
--
-- Definition 4.1.10.
-- An ordered field is a set F together with constants 0, 1, operations +, ·, min, max, and a binary relation < such that:
-- 1. (F, 0, 1, +, ·) is a commutative ring with unit;
-- 2. < is a strict order;
-- 3. x : F has a multiplicative inverse iff x # 0, recalling that # is defined as in Lemma 4.1.7;
-- 4. ≤, as in Lemma 4.1.7, is antisymmetric, so that (F, ≤) is a partial order;
-- 5. (F, ≤, min, max) is a lattice.
-- 6. for all x, y, z, w : F:
-- x + y < z + w ⇒ x < z ∨ y < w, (†)
-- 0 < z ∧ x < y ⇒ x z < y z. (∗)
-- Our notion of ordered fields coincides with The Univalent Foundations Program [89, Definition 11.2.7].
--
-- Lemma 4.1.11.
-- In the presence of the first five axioms of Definition 4.1.10, conditions (†) and (∗) are together equivalent to the condition that for all x, y, z : F,
-- 1. x ≤ y ⇔ ¬(y < x),
-- 2. x # y ⇔ (x < y) ∨ (y < x)
-- 3. x ≤ y ⇔ x + z ≤ y + z,
-- 4. x < y ⇔ x + z < y + z,
-- 5. 0 < x + y ⇒ 0 < x ∨ 0 < y,
-- 6. x < y ≤ z ⇒ x < z,
-- 7. x ≤ y < z ⇒ x < z,
-- 8. x ≤ y ∧ 0 ≤ z ⇒ x z ≤ y z,
-- 9. 0 < z ⇒ (x < y ⇔ x z < y z),
-- 10. 0 < 1.
-- we have in cubical
-- import Cubical.HITs.Rationals.HITQ
-- ℚ as a higher inductive type
-- import Cubical.HITs.Rationals.QuoQ
-- ℚ as a set quotient of ℤ × ℕ₊₁ (as in the HoTT book)
-- import Cubical.HITs.Rationals.SigmaQ
-- ℚ as the set of coprime pairs in ℤ × ℕ₊₁
| {
"alphanum_fraction": 0.5742266439,
"avg_line_length": 49.24784689,
"ext": "agda",
"hexsha": "2293081f33f40677c4540163cac255dfc828037e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mchristianl/synthetic-reals",
"max_forks_repo_path": "test/Hit.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mchristianl/synthetic-reals",
"max_issues_repo_path": "test/Hit.agda",
"max_line_length": 375,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mchristianl/synthetic-reals",
"max_stars_repo_path": "test/Hit.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z",
"num_tokens": 18705,
"size": 51464
} |
open import Relation.Nullary using (yes; no; ¬_)
open import Relation.Nullary.Decidable using (True; False)
open import Relation.Nullary.Negation using (contradiction)
open import Relation.Binary using (Antisymmetric; Irrelevant; Decidable)
open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; sym; cong; cong₂; module ≡-Reasoning)
open import Relation.Binary.PropositionalEquality.WithK using (≡-irrelevant)
open ≡-Reasoning
open import Function using (_$_)
module AKS.Nat.GCD where
open import AKS.Nat.Base using (ℕ; _+_; _*_; zero; suc; _<_; _≤_; lte; _≟_; _∸_)
open import AKS.Nat.Properties using (≢⇒¬≟; ≤-antisym; <⇒≱)
open import Data.Nat.Properties using (*-distribʳ-∸; m+n∸n≡m)
open import AKS.Nat.Divisibility
using (modₕ; _/_; _%_; n%m<m; m≡m%n+[m/n]*n; m%n≡m∸m/n*n; /-cancelʳ; Euclidean✓)
renaming (_div_ to _ediv_)
open import Data.Nat.Properties using (*-+-commutativeSemiring; *-zeroʳ; +-comm; *-comm; *-assoc)
open import AKS.Algebra.Structures ℕ _≡_ using (module Modulus)
open import AKS.Algebra.Divisibility *-+-commutativeSemiring public
open import AKS.Unsafe using (≢-irrelevant)
auto-∣ : ∀ {d a} {{ d≢0 : False (d ≟ 0) }} {{ pf : True (a ≟ (a / d) {d≢0} * d)}} → d ∣ a
auto-∣ {d} {a} {{ d≢0 }} with a ≟ (a / d) {d≢0} * d
... | yes pf = divides (a / d) pf
∣-antisym : Antisymmetric _≡_ _∣_
∣-antisym {x} {y} (divides zero refl) (divides q₂ refl) = *-zeroʳ q₂
∣-antisym {x} {y} (divides (suc q₁) refl) (divides zero refl) = sym (*-zeroʳ (suc q₁))
∣-antisym {x} {y} (divides (suc q₁) refl) (divides (suc q₂) pf₂) = ≤-antisym (lte (q₁ * x) refl) (lte (q₂ * y) (sym pf₂))
-- The euclidean norm is just the identity function on ℕ
∣_∣ : ∀ n {n≉0 : n ≢ 0} → ℕ
∣ n ∣ = n
_div_ : ∀ (n m : ℕ) {m≢0 : m ≢ 0} → ℕ
(n div m) {m≢0} = (n / m) {≢⇒¬≟ m≢0}
_mod_ : ∀ (n m : ℕ) {m≢0 : m ≢ 0} → ℕ
(n mod m) {m≢0} = (n % m) {≢⇒¬≟ m≢0}
division : ∀ n m {m≢0 : m ≢ 0} → n ≡ m * (n div m) {m≢0} + (n mod m) {m≢0}
division n m {m≢0} = begin
n ≡⟨ m≡m%n+[m/n]*n n m {≢⇒¬≟ m≢0} ⟩
(n % m) + (n / m) * m ≡⟨ +-comm (n % m) (n / m * m) ⟩
(n / m) * m + (n % m) ≡⟨ cong (λ t → t + (n % m) {≢⇒¬≟ m≢0}) (*-comm (n / m) m) ⟩
m * (n div m) {m≢0} + (n mod m) {m≢0} ∎
open Modulus 0 ∣_∣ _mod_
modulus : ∀ n m {m≢0} → Remainder n m {m≢0}
modulus n m {m≢0} with (n mod m) {m≢0} ≟ 0
... | yes r≡0 = 0≈ r≡0
... | no r≢0 = 0≉ r≢0 (n%m<m n m)
mod-cong : ∀ {x₁ x₂} {y₁ y₂} → x₁ ≡ x₂ → y₁ ≡ y₂ → ∀ {y₁≉0 y₂≉0} → (x₁ mod y₁) {y₁≉0} ≡ (x₂ mod y₂) {y₂≉0}
mod-cong refl refl {y₁≢0} {y₂≢0} rewrite ≢-irrelevant y₁≢0 y₂≢0 = refl
mod-distribʳ-* : ∀ c a b {b≢0} {b*c≢0} → ((a * c) mod (b * c)) {b*c≢0} ≡ (a mod b) {b≢0} * c
mod-distribʳ-* c a b {b≢0} {b*c≢0} = begin
(a * c) mod (b * c) ≡⟨ m%n≡m∸m/n*n (a * c) (b * c) ⟩
(a * c) ∸ ((a * c) / (b * c)) * (b * c) ≡⟨ cong (λ x → a * c ∸ x) (sym (*-assoc ((a * c) / (b * c)) b c)) ⟩
(a * c) ∸ (((a * c) / (b * c)) * b) * c ≡⟨ sym (*-distribʳ-∸ c a (((a * c) / (b * c)) * b)) ⟩
(a ∸ ((a * c) / (b * c)) * b) * c ≡⟨ cong (λ x → (a ∸ x * b) * c) (/-cancelʳ c a b) ⟩
(a ∸ (a / b) * b) * c ≡⟨ cong (λ x → x * c) (sym (m%n≡m∸m/n*n a b)) ⟩
a mod b * c ∎
open Euclidean (λ n → n) _div_ _mod_ _≟_ ≡-irrelevant ≢-irrelevant division modulus mod-cong mod-distribʳ-*
using (gcdₕ; gcd; gcd-isGCD; Identity; +ʳ; +ˡ; Bézout; lemma; bézout) public
open IsGCD gcd-isGCD public
open GCD gcd-isGCD ∣-antisym
using
( _⊥_; ⊥-sym; ⊥-respˡ; ⊥-respʳ
) public
renaming
( gcd[a,1]≈1 to gcd[a,1]≡1
; gcd[1,a]≈1 to gcd[1,a]≡1
; a≉0⇒gcd[a,b]≉0 to a≢0⇒gcd[a,b]≢0
; b≉0⇒gcd[a,b]≉0 to b≢0⇒gcd[a,b]≢0
; gcd[0,a]≈a to gcd[0,a]≡a
; gcd[a,0]≈a to gcd[a,0]≡a
; gcd[0,a]≈1⇒a≈1 to gcd[0,a]≡1⇒a≡1
; gcd[a,0]≈1⇒a≈1 to gcd[a,0]≡1⇒a≡1
) public
∣n+m∣m⇒∣n : ∀ {i n m} → i ∣ n + m → i ∣ m → i ∣ n
∣n+m∣m⇒∣n {i} {n} {m} (divides q₁ n+m≡q₁*i) (divides q₂ m≡q₂*i) =
divides (q₁ ∸ q₂) $ begin
n ≡⟨ sym (m+n∸n≡m n m) ⟩
(n + m) ∸ m ≡⟨ cong₂ (λ x y → x ∸ y) n+m≡q₁*i m≡q₂*i ⟩
q₁ * i ∸ q₂ * i ≡⟨ sym (*-distribʳ-∸ i q₁ q₂) ⟩
(q₁ ∸ q₂) * i ∎
∣⇒≤ : ∀ {m n} {n≢0 : False (n ≟ 0)} → m ∣ n → m ≤ n
∣⇒≤ {m} {suc n} (divides (suc q) 1+n≡m+q*m) = lte (q * m) (sym 1+n≡m+q*m)
_∣?_ : Decidable _∣_
d ∣? a with d ≟ 0
d ∣? a | yes refl with a ≟ 0
d ∣? a | yes refl | yes refl = yes ∣-refl
d ∣? a | yes refl | no a≢0 = no λ 0∣a → contradiction (0∣n⇒n≈0 0∣a) a≢0
d ∣? a | no d≢0 with (a ediv d) {≢⇒¬≟ d≢0}
d ∣? a | no d≢0 | Euclidean✓ q r pf r<d with r ≟ 0
d ∣? a | no d≢0 | Euclidean✓ q r pf r<d | yes refl =
yes $ divides q $ begin
a ≡⟨ pf ⟩
0 + d * q ≡⟨⟩
d * q ≡⟨ *-comm d q ⟩
q * d ∎
d ∣? a | no d≢0 | Euclidean✓ q r pf r<d | no r≢0 = no ¬d∣a
where
¬d∣a : ¬ (d ∣ a)
¬d∣a d∣a = contradiction d≤r (<⇒≱ r<d)
where
d∣r+d*q : d ∣ r + d * q
d∣r+d*q = ∣-respʳ pf d∣a
d∣r : d ∣ r
d∣r = ∣n+m∣m⇒∣n d∣r+d*q (∣n⇒∣n*m _ _ _ ∣-refl)
d≤r : d ≤ r
d≤r = ∣⇒≤ {n≢0 = ≢⇒¬≟ r≢0} d∣r
| {
"alphanum_fraction": 0.4984170954,
"avg_line_length": 40.1111111111,
"ext": "agda",
"hexsha": "0518b96eb3961bc958666a8bc100fd5125c10a6a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mckeankylej/thesis",
"max_forks_repo_path": "proofs/AKS/Nat/GCD.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mckeankylej/thesis",
"max_issues_repo_path": "proofs/AKS/Nat/GCD.agda",
"max_line_length": 121,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mckeankylej/thesis",
"max_stars_repo_path": "proofs/AKS/Nat/GCD.agda",
"max_stars_repo_stars_event_max_datetime": "2020-12-01T22:38:27.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-12-01T22:38:27.000Z",
"num_tokens": 2698,
"size": 5054
} |
-- Andreas, 2016-09-12 issue #2172
--
-- Instance search should succeed also when instance meta is supplied by the user.
--
-- This test case is not minimal, but illustrates the point.
-- {-# OPTIONS -v tc.term.args:30 -v tc.term.args.ifs:15 -v tc.meta.new:50 -v tc.meta.name:100 -v tc.term.args.named:75 #-}
module Issue2172 where
postulate
id : {t : Set} → t → t
_≡_ : {t : Set} → t → t → Set
⊤ : Set
record FunctorOp (F : Set → Set) : Set₁ where
field
map : ∀{A B} → (A → B) → F A → F B
record FunctorLaws (F : Set → Set) {{O : FunctorOp F}} : Set₁ where
field
map-id : ∀{A : Set} → FunctorOp.map O (id {A}) ≡ (id {F A})
record ApplyOp (A : Set → Set) {{O : FunctorOp A}} {{L : FunctorLaws A}} : Set₁ where
field
iapply : ∀ {t₁ t₂} → A (t₁ → t₂) → A t₁ → A t₂
record ApplyLaws (A : Set → Set) {{O : FunctorOp A}} {{L : FunctorLaws A}} {{i : ApplyOp A}} : Set₁ where
open ApplyOp {{...}}
field
works : ∀ (f : A (⊤ → ⊤)) → (x : A ⊤) → (iapply f x) ≡ x
test2 : ∀ (f : A (⊤ → ⊤)) → (x : A ⊤) → (iapply {_} {{_}} f x) ≡ x
test1 : ∀ (f : A (⊤ → ⊤)) → (x : A ⊤) → (iapply {A₁ = _} {{_}} {{L₁ = _}} f x) ≡ x
test0 : ∀ (f : A (⊤ → ⊤)) → (x : A ⊤) → (iapply {{L₁ = _}} f x) ≡ x
test : ∀ (f : A (⊤ → ⊤)) → (x : A ⊤) → (iapply {{L₁ = {!L!}}} f x) ≡ x
| {
"alphanum_fraction": 0.5042340262,
"avg_line_length": 35.1081081081,
"ext": "agda",
"hexsha": "71b3120353d94fe2855a7d8744328c527a049211",
"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": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pthariensflame/agda",
"max_forks_repo_path": "test/interaction/Issue2172.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"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": "pthariensflame/agda",
"max_issues_repo_path": "test/interaction/Issue2172.agda",
"max_line_length": 123,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pthariensflame/agda",
"max_stars_repo_path": "test/interaction/Issue2172.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 550,
"size": 1299
} |
id : {A : Set} → A → A
id x = x
syntax id {A} x = x ∈ A
data Nat : Set where
zero : Nat
suc : Nat → Nat
data Fin : Nat → Set where
zero : Fin zero
suc : ∀ {n} → Fin n → Fin (suc n)
z = zero ∈ Fin zero
postulate
hiddenFun : ∀ {f : Nat → Nat} {n} → Fin (f n)
syntax hiddenFun {λ x → y} = hide[ x ] y
z′ : Fin (suc zero)
z′ = hide[ x ] suc x
| {
"alphanum_fraction": 0.5208913649,
"avg_line_length": 14.9583333333,
"ext": "agda",
"hexsha": "78b705926e90709c985ba304e483b21d08e2ffba",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/Issue400.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/Issue400.agda",
"max_line_length": 47,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue400.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": 146,
"size": 359
} |
-- New NO_POSITIVITY_CHECK pragma for data definitions and mutual
-- blocks
-- Skipping a new-style mutual block: Anywhere before the declaration
-- or the definition of a data type in the block (case: before first
-- declaration).
{-# NO_POSITIVITY_CHECK #-}
data Cheat₁ : Set
data Oops₁ : Set
data Cheat₁ where
cheat₁ : Oops₁ → Cheat₁
data Oops₁ where
oops₁ : (Cheat₁ → Cheat₁) → Oops₁
-- Skipping a new-style mutual block: Anywhere before the declaration
-- or the definition of a data type in the block (case: before some
-- definition).
data Cheat₂ : Set
data Oops₂ : Set
data Cheat₂ where
cheat₂ : Oops₂ → Cheat₂
{-# NO_POSITIVITY_CHECK #-}
data Oops₂ where
oops₂ : (Cheat₂ → Cheat₂) → Oops₂
| {
"alphanum_fraction": 0.7248603352,
"avg_line_length": 23.0967741935,
"ext": "agda",
"hexsha": "963babbe1220279bbc3097f2882c145b70da15cb",
"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/Issue1614d.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/Issue1614d.agda",
"max_line_length": 69,
"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/Issue1614d.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": 199,
"size": 716
} |
module DuplicateFields where
postulate X : Set
record D : Set where
field x : X
d : X -> X -> D
d x y = record {x = x; x = y}
| {
"alphanum_fraction": 0.5864661654,
"avg_line_length": 11.0833333333,
"ext": "agda",
"hexsha": "d8e8e5906f9a47c939fc09f9d5e02e8e4f4157cf",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/DuplicateFields.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/Fail/DuplicateFields.agda",
"max_line_length": 29,
"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/Fail/DuplicateFields.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": 46,
"size": 133
} |
-- Andreas, 2018-10-23, issue #3309 reported by G. Brunerie
--
-- Check that we can use irrelevant record fields in copattern matching.
--
-- (A refactoring broke the correct relevances of pattern variables
-- after matching on an irrelevant projection pattern.)
record Σ (A : Set) (B : A → Set) : Set where
constructor _,_
field
fst : A
.snd : B fst
open Σ
pair : {A : Set} {B : A → Set} (a : A) .(b : B a) → Σ A B
pair a b .fst = a
pair a b .snd = b
f : {A : Set} {B : A → Set} (a : A) .(b : B a) → Σ A B
fst (f a b) = a
snd (f a b) = b
-- Should work.
| {
"alphanum_fraction": 0.5971978984,
"avg_line_length": 23.7916666667,
"ext": "agda",
"hexsha": "4a3d747c0b5042bb5b4d2044473d1c144eb0f055",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/Issue3309.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/Issue3309.agda",
"max_line_length": 72,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue3309.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": 205,
"size": 571
} |
------------------------------------------------------------------------------
-- Axiomatic Peano arithmetic using Agsy
------------------------------------------------------------------------------
{-# OPTIONS --allow-unsolved-metas #-}
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOT.Agsy.AxiomaticPA where
open import Common.FOL.FOL public renaming ( D to ℕ )
infixl 10 _*_
infix 7 _≐_
infixl 9 _+_
------------------------------------------------------------------------------
-- Non-logical constants
postulate
zero : ℕ
succ : ℕ → ℕ
_+_ : ℕ → ℕ → ℕ
_*_ : ℕ → ℕ → ℕ
_≐_ : ℕ → ℕ → Set
-- Proper axioms
-- (From Elliott Mendelson. Introduction to mathematical
-- logic. Chapman & Hall, 4th edition, 1997, p. 155)
-- N.B. We make the recursion in the first argument for _+_ and _*_.
-- S₁. m = n → m = o → n = o
-- S₂. m = n → succ m = succ n
-- S₃. 0 ≠ succ n
-- S₄. succ m = succ n → m = n
-- S₅. 0 + n = n
-- S₆. succ m + n = succ (m + n)
-- S₇. 0 * n = 0
-- S₈. succ m * n = (m * n) + m
-- S₉. P(0) → (∀n.P(n) → P(succ n)) → ∀n.P(n), for any wf P(n) of PA.
postulate
S₁ : {m n o : ℕ} → m ≐ n → m ≐ o → n ≐ o
S₂ : ∀ {m n} → m ≐ n → succ m ≐ succ n
S₃ : ∀ {n} → ¬ (zero ≐ succ n)
S₄ : ∀ {m n} → succ m ≐ succ n → m ≐ n
S₅ : ∀ n → zero + n ≐ n
S₆ : ∀ m n → succ m + n ≐ succ (m + n)
S₇ : ∀ n → zero * n ≐ zero
S₈ : ∀ m n → succ m * n ≐ n + m * n
S₉ : (A : ℕ → Set) → A zero → (∀ n → A n → A (succ n)) → ∀ n → A n
-- Properties
refl : ∀ {n} → n ≐ n
refl {n} = S₁ (S₅ n) (S₅ n) -- Via Agsy {-m}
sym : ∀ {m n} → m ≐ n → n ≐ m
sym h = S₁ h refl -- Via Agsy {-m}
trans : ∀ {m n o} → m ≐ n → n ≐ o → m ≐ o
trans h₁ h₂ = S₁ (sym h₁) h₂ -- Via Agsy {-m}
+-rightIdentity : ∀ n → n + zero ≐ n
+-rightIdentity n = {!-t 20 -m!} -- Agsy fails
| {
"alphanum_fraction": 0.4303469705,
"avg_line_length": 27.9855072464,
"ext": "agda",
"hexsha": "956fd17f16c6c5c558ae5887efed46d9af8e917b",
"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/Agsy/AxiomaticPA.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/Agsy/AxiomaticPA.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/Agsy/AxiomaticPA.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": 738,
"size": 1931
} |
module LinkedList where
open import Data.Unit using (⊤; tt)
open import Data.Empty using (⊥)
open import Data.Nat
import Data.Fin as Fin
open import Data.Fin
using (Fin)
renaming (zero to Fzero; suc to Fsuc)
open import Relation.Binary.PropositionalEquality as PropEq
using (_≡_; refl; cong)
open import Relation.Nullary using (¬_)
open import Relation.Nullary using (Dec; yes; no; ¬_)
open import Relation.Nullary.Decidable using (False)
data LinkedList (A : Set) : Set where
[] : LinkedList A
_∷_ : A → LinkedList A → LinkedList A
--------------------------------------------------------------------------------
-- to ℕ
⟦_⟧ : ∀ {A} → LinkedList A → ℕ
⟦ [] ⟧ = zero
⟦ x ∷ xs ⟧ = suc ⟦ xs ⟧
--------------------------------------------------------------------------------
-- predicates
null : ∀ {A} → LinkedList A → Set
null [] = ⊤
null (_ ∷ _) = ⊥
null? : ∀ {A} → (xs : LinkedList A) → Dec (null xs)
null? [] = yes tt
null? (x ∷ xs) = no (λ z → z)
--------------------------------------------------------------------------------
-- operations
incr : ∀ {A} → A → LinkedList A → LinkedList A
incr = _∷_
decr : ∀ {A} → (xs : LinkedList A) → False (null? xs) → LinkedList A
decr [] ()
decr (x ∷ xs) p = xs
_++_ : ∀ {A} → LinkedList A → LinkedList A → LinkedList A
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ (xs ++ ys)
elemAt : ∀ {A} → (xs : LinkedList A) → Fin ⟦ xs ⟧ → A
elemAt [] ()
elemAt (x ∷ xs) Fzero = x
elemAt (x ∷ xs) (Fsuc i) = elemAt xs i
| {
"alphanum_fraction": 0.4903397735,
"avg_line_length": 26.3333333333,
"ext": "agda",
"hexsha": "cc65a4438b8f93ef3392d01f5d356ff5ff42d22c",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/numeral",
"max_forks_repo_path": "legacy/LinkedList.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "banacorn/numeral",
"max_issues_repo_path": "legacy/LinkedList.agda",
"max_line_length": 80,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/numeral",
"max_stars_repo_path": "legacy/LinkedList.agda",
"max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z",
"num_tokens": 446,
"size": 1501
} |
{-# OPTIONS --without-K #-}
open import HoTT.Base
open import HoTT.Identity
open import HoTT.Equivalence
open import HoTT.Identity.Sigma
module HoTT.Equivalence.Sigma where
open variables
Σ-equiv₁ : ((f , _) : A ≃ B) → Σ A (P ∘ f) ≃ Σ B P
Σ-equiv₁ {A = A} {B} {P = P} (f , e) = iso→eqv iso
where
open ishae (qinv→ishae (isequiv→qinv e))
iso : Iso _ _
Iso.f iso (a , b) = f a , b
Iso.g iso (a' , b) = g a' , transport P (ε a' ⁻¹) b
Iso.η iso (a , b) = pair⁼ (η a , (
transport (P ∘ f) (η a) (transport P (ε (f a) ⁻¹) b) =⟨ transport-ap P f (η a) _ ⁻¹ ⟩
transport P (ap f (η a)) (transport P (ε (f a) ⁻¹) b) =⟨ transport-∙ P (ε (f a) ⁻¹) (ap f (η a)) b ⁻¹ ⟩
transport P (ε (f a) ⁻¹ ∙ ap f (η a)) b =⟨ ap (λ p → transport P p b) (ε (f a) ⁻¹ ∙ₗ τ a) ⟩
transport P (ε (f a) ⁻¹ ∙ ε (f a)) b =⟨ ap (λ p → transport P p b) (invₗ {p = ε (f a)}) ⟩
b ∎))
where open =-Reasoning
Iso.ε iso (a' , b) rewrite ε a' = refl
Σ-equiv₂ : ((x : A) → P x ≃ Q x) → Σ A P ≃ Σ A Q
Σ-equiv₂ {A = A} {P = P} {Q = Q} e = iso→eqv iso
where
iso : Iso (Σ A P) (Σ A Q)
Iso.f iso x = let (a , b) = x in a , pr₁ (e a) b
Iso.g iso (a , b') = a , g b'
where open qinv (isequiv→qinv (pr₂ (e a)))
Iso.η iso (a , b) = pair⁼ (refl , η b)
where open qinv (isequiv→qinv (pr₂ (e a)))
Iso.ε iso (a , b') = pair⁼ (refl , ε b')
where open qinv (isequiv→qinv (pr₂ (e a)))
Σ-equiv : ((f , _) : A ≃ B) → ((x : A) → P x ≃ Q (f x)) → Σ A P ≃ Σ B Q
Σ-equiv e₁ e₂ = Σ-equiv₂ e₂ ∙ₑ Σ-equiv₁ e₁
Σ-assoc : {C : Σ A P → 𝒰 i} →
Σ[ x ∶ A ] Σ[ y ∶ P x ] C (x , y) ≃ Σ[ p ∶ Σ A P ] C p
Σ-assoc = let open Iso in iso→eqv λ where
.f ( x , y , z) → (x , y) , z
.g ((x , y) , z) → x , y , z
.η ( _ , _ , _) → refl
.ε ((_ , _) , _) → refl
Σ-comm : {P : A → B → 𝒰 i} →
Σ[ x ∶ A ] Σ[ y ∶ B ] (P x y) ≃ Σ[ y ∶ B ] Σ[ x ∶ A ] (P x y)
Σ-comm = let open Iso in iso→eqv λ where
.f (a , b , p) → (b , a , p)
.g (b , a , p) → (a , b , p)
.η (a , b , p) → refl
.ε (b , a , p) → refl
| {
"alphanum_fraction": 0.4672531769,
"avg_line_length": 35.8947368421,
"ext": "agda",
"hexsha": "83976f60e843fb65060abc70955ae82b942b0e02",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508",
"max_forks_repo_licenses": [
"0BSD"
],
"max_forks_repo_name": "michaelforney/hott",
"max_forks_repo_path": "HoTT/Equivalence/Sigma.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"0BSD"
],
"max_issues_repo_name": "michaelforney/hott",
"max_issues_repo_path": "HoTT/Equivalence/Sigma.agda",
"max_line_length": 110,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508",
"max_stars_repo_licenses": [
"0BSD"
],
"max_stars_repo_name": "michaelforney/hott",
"max_stars_repo_path": "HoTT/Equivalence/Sigma.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 994,
"size": 2046
} |
module MGU where
--open import Agda.Builtin.Nat using () renaming (Nat to ℕ)
open import Agda.Primitive
open import Agda.Builtin.Equality
open import Prelude.Product using (Σ; _,_; fst; snd; _×_; curry; uncurry)
open import Prelude.Equality using (_≡_; eqReasoningStep; _∎; sym; trans; cong)
open import Prelude.Function using (_∘_)
open import Prelude.Empty using (⊥)
open import Prelude.Sum using () renaming (Either to _⊎_)
open import Prelude.Maybe using (Maybe; just; nothing)
∃ : ∀ {a b} {A : Set a} (B : A → Set b) → Set (a ⊔ b)
∃ = Σ _
open import Prelude using (_$_)
open import Relation.Binary
open import Algebra
open import Category.Applicative.Predicate
open import Prolegomenon
--record IsTermSubstitution {ℓᵗ} {ℓ⁼ᵗ} {ℓˢ} {ℓ⁼ˢ}
record IsSetoid {c} {ℓ} {Carrier : Set c} (_≈_ : Rel Carrier ℓ) : Set (c ⊔ ℓ) where
field
isEquivalence : IsEquivalence _≈_
setoid : Setoid c ℓ
setoid = record { Carrier = Carrier ; _≈_ = _≈_ ; isEquivalence = isEquivalence }
open Setoid setoid public
open IsSetoid ⦃ … ⦄
open import Algebra.Structures
--open IsMonoid ⦃ … ⦄
record IsTermSubstitution {ℓᵗ} {ℓ⁼ᵗ} {ℓˢ} {ℓ⁼ˢ}
(Term : Setoid ℓᵗ ℓ⁼ᵗ)
(Substitution : Monoid ℓˢ ℓ⁼ˢ)
: Set (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ) where
open Setoid Term public using () renaming
(Carrier to T
;_≈_ to _=ᵗ_)
open Monoid Substitution public using () renaming
(Carrier to S
;_≈_ to _=ˢ_
;_∙_ to _∙_
;ε to ∅)
infixl 6 _▹_
field
_▹_ : T → S → T
▹-=ˢ-to-ᵗ : ∀ {s s′} → s =ˢ s′ → (t : T) → (t ▹ s) =ᵗ (t ▹ s′)
▹-=ᵗ-to-=ˢ : ∀ {s s′} → ((t : T) → t ▹ s =ᵗ t ▹ s′) → s =ˢ s′
▹-extracts-∙ : (t : T) (s₁ s₂ : S) → t ▹ s₁ ∙ s₂ =ᵗ t ▹ s₁ ▹ s₂
open IsTermSubstitution ⦃ … ⦄
record TermSubstitution ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ : Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where
field
Term : Setoid ℓᵗ ℓ⁼ᵗ
Substitution : Monoid ℓˢ ℓ⁼ˢ
isTermSubstitution : IsTermSubstitution Term Substitution
open IsTermSubstitution isTermSubstitution public
open import Relation.Unary
import Relation.Binary.Indexed as I
open import Relation.Nullary
record 𝓩ero (A : Set) : Set where
field
𝓩 : A
open 𝓩ero ⦃ … ⦄
instance 𝓩eroLevel : 𝓩ero Level
𝓩ero.𝓩 𝓩eroLevel = lzero
open import Agda.Builtin.Nat
instance 𝓩eroNat : 𝓩ero Nat
𝓩ero.𝓩 𝓩eroNat = zero
record IsSeparableInto {sx s x} (SX : Set sx) (S : Set s) (X : Set x) : Set (s ⊔ x ⊔ sx) where
field
break : SX → S × X
combine : S → X → SX
iso : ∀ sx → uncurry combine (break sx) ≡ sx
record Separableoid sx s x : Set (lsuc (sx ⊔ s ⊔ x)) where
field
SX : Set sx
S : Set s
X : Set x
separable : IsSeparableInto SX S X
_AND_ = _×_
NOT_ = ¬_
_NAND_ : ∀ {a b} (A : Set a) (B : Set b) → Set ((a ⊔ b))
_NAND_ A B = (NOT A) × (NOT B)
_OR_ : ∀ {a b} (A : Set a) (B : Set b) → Set ((a ⊔ b))
_OR_ A B = NOT (A NAND B)
_XOR_ : ∀ {a b} (A : Set a) (B : Set b) → Set ((a ⊔ b))
_XOR_ A B = (A OR B) AND (NOT (A AND B))
asdf : (A B : Set) → Dec A → A XOR B → Prelude.Either A (¬ ¬ B)
asdf A B x (¬[¬A׬B] , ¬[A×B]) with x
asdf A B x (¬[¬A׬B] , ¬[A×B]) | yes p = _⊎_.left p
asdf A B x (¬[¬A׬B] , ¬[A×B]) | no ¬p = _⊎_.right (λ {x₁ → ¬[¬A׬B] (¬p , x₁)})
import Data.Empty
frf : Dec Data.Empty.⊥
frf = no (λ x → x)
{-
record LAW (A : Set) (B : Set) (E : EITHER A B) : Set where
open import Data.Empty
open EITHER E
¬A→B : ¬ A → ¬ ¬ B
¬A→B ¬a ¬b with e
... | ei = ei (λ {(a , ¬b) → ¬a a})
-}
record FiniteMembership : Set where
open import Data.List
module _ {ℓ} {A : Set ℓ} where
listMembers : List A → Pred A ℓ
listMembers [] x₁ = Prelude.⊥′
listMembers (x ∷ xs) y = (y ≡ x) OR (listMembers xs y)
_∈L_ : A → List A → Set ℓ
x ∈L xs = x ∈ listMembers xs
data _inL_ (y : A) : List A → Set where
[] : ∀ {xs} → y inL (y ∷ xs)
_∷_ : ∀ {x xs} → (ys : y inL xs) → y inL (x ∷ xs)
ListMembers : List A → Pred A lzero
ListMembers xs = _inL xs
_∈LL_ : A → List A → Set
x ∈LL xs = x ∈ ListMembers xs
toLL : (y : A) (xs : List A) → y ∈L xs → y ∈LL xs
toLL y [] x = Prelude.⊥′-elim x
toLL y (x ∷ xs) y∈Lxxs = {!!} -- toLL y xs x₁
record Boolean (True : Set) (False : Set) : Set where
field
bool : True XOR False
{-
record L {ℓ} (A : Set ℓ) : Set ℓ where
inductive
field
EMPTY : Set
empty : L A
head : A XOR ⊥
tail : {!!}
-}
{-
head : A XOR Prelude.⊥
tail :
empty : Prelude.⊥′
list : EITHER Prelude.⊥′ (L A)
-}
record FreeVariableoid ℓᵛ∈ᵗ ℓᵛ∈ˢ⁺ ℓᵛ∈ˢ⁻ ℓᵛ ℓ⁼ᵛ ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ
⦃ termSubstitution : TermSubstitution ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ ⦄
: Set (lsuc (ℓᵛ∈ᵗ ⊔ ℓᵛ∈ˢ⁺ ⊔ ℓᵛ∈ˢ⁻ ⊔ ℓᵛ ⊔ ℓ⁼ᵛ ⊔ ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where
-- open TermSubstitution termSubstitution
field
Variable : Setoid ℓᵛ ℓ⁼ᵛ
TermStructure : Set
open Setoid Variable public using () renaming
(Carrier to V
;_≈_ to _=ᵛ_)
field
termVariables : T → Pred V ℓᵛ∈ᵗ
termStructure : T → Set
substitutionSourceVariables : S → Pred V ℓᵛ∈ˢ⁺
substitutionTargetVariables : S → Pred V ℓᵛ∈ˢ⁻
_ᵛ∈ᵗ_ : V → T → Set ℓᵛ∈ᵗ
_ᵛ∈ᵗ_ v t = v ∈ termVariables t
field
termNumberOfVariables : (t : T) → ∃ λ (vs : List V) → (∀ v → (v ∈L vs → v ᵛ∈ᵗ t) × (v ᵛ∈ᵗ t → v ∈L vs))
elementsDefineVariables : (t : T) → V
_ᵛ∈ˢ⁺_ : V → S → Set ℓᵛ∈ˢ⁺
_ᵛ∈ˢ⁺_ v s = v ∈ substitutionSourceVariables s
_ᵛ∈ˢ⁻_ : V → S → Set ℓᵛ∈ˢ⁻
_ᵛ∈ˢ⁻_ v s = v ∈ substitutionTargetVariables s
field
foo : ∀ {v t s} → v ᵛ∈ᵗ t → ¬ v ᵛ∈ˢ⁺ s → v ᵛ∈ᵗ (t ▹ s)
isSep : IsSeparableInto T TermStructure V
record CorrectTermSubstitution ℓᵛ∈ᵗ ℓᵛ∈ˢ⁺ ℓᵛ∈ˢ⁻ ℓᵛ ℓ⁼ᵛ ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ
⦃ termSubstitution : TermSubstitution ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ ⦄
: Set (lsuc (ℓᵛ∈ᵗ ⊔ ℓᵛ∈ˢ⁺ ⊔ ℓᵛ∈ˢ⁻ ⊔ ℓᵛ ⊔ ℓ⁼ᵛ ⊔ ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where
-- open TermSubstitution termSubstitution
field
Variable : Setoid ℓᵛ ℓ⁼ᵛ
open Setoid Variable public using () renaming
(Carrier to V
;_≈_ to _=ᵛ_)
field
termVariables : T → Pred V ℓᵛ∈ᵗ
substitutionSourceVariables : S → Pred V ℓᵛ∈ˢ⁺
substitutionTargetVariables : S → Pred V ℓᵛ∈ˢ⁻
_ᵛ∈ᵗ_ : V → T → Set ℓᵛ∈ᵗ
_ᵛ∈ᵗ_ v t = v ∈ termVariables t
_ᵛ∈ˢ⁺_ : V → S → Set ℓᵛ∈ˢ⁺
_ᵛ∈ˢ⁺_ v s = v ∈ substitutionSourceVariables s
_ᵛ∈ˢ⁻_ : V → S → Set ℓᵛ∈ˢ⁻
_ᵛ∈ˢ⁻_ v s = v ∈ substitutionTargetVariables s
field
foo : ∀ {v t s} → v ᵛ∈ᵗ t → ¬ v ᵛ∈ˢ⁺ s → v ᵛ∈ᵗ (t ▹ s)
data D : Set where
data IsRight {a b} {A : Set a} {B : Set b} (e : _⊎_ A B) : Set (a ⊔ b) where
right : B → IsRight e
module MostGeneralMGU where
record Unificationoid {ℓᵗ} {ℓ⁼ᵗ} {ℓˢ} {ℓ⁼ˢ}
⦃ termSubstitution : TermSubstitution ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ ⦄
: Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where
-- open TermSubstitution termSubstitution
Property : ∀ {ℓ} → Set (ℓˢ ⊔ lsuc ℓ)
Property {ℓ} = S → Set ℓ
Nothing : ∀ {ℓ} → (P : Property {ℓ}) → Set (ℓ ⊔ ℓˢ)
Nothing P = ∀ s → P s → ⊥
IsUnifier : (t₁ t₂ : T) → Property
IsUnifier t₁ t₂ s = t₁ ▹ s =ᵗ t₂ ▹ s
field
unify : (t₁ t₂ : T) → Nothing (IsUnifier t₁ t₂) ⊎ ∃ (IsUnifier t₁ t₂)
unifier : (t₁ t₂ : T) → Maybe S
unifier t₁ t₂ with unify t₁ t₂
unifier t₁ t₂ | _⊎_.left x = nothing
unifier t₁ t₂ | _⊎_.right (x , _) = just x
unifier-is-correct : (t₁ t₂ : T) → Nothing (IsUnifier t₁ t₂) → unifier t₁ t₂ ≡ nothing
unifier-is-correct = {!!}
record IsMostGeneralUnification ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ
⦃ termSubstitution : TermSubstitution ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ ⦄
(unificationoid : Unificationoid ⦃ termSubstitution ⦄)
: Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where
--open TermSubstitution termSubstitution
open Unificationoid unificationoid
_≤_ : (s₋ : S) (s₊ : S) → Set (ℓˢ ⊔ ℓ⁼ˢ)
_≤_ s₋ s₊ = ∃ λ s → s ∙ s₊ =ˢ s₋
MostGenerally : ∀ {ℓ} (P : Property {ℓ}) → Property
MostGenerally P s₊ = ∀ s₋ → P s₋ → s₋ ≤ s₊
field
isMguIfUnifier : (t₁ t₂ : T) → (ru : IsRight (unify t₁ t₂)) →
Prelude.case ru of λ {((right (u , _))) → MostGenerally (IsUnifier t₁ t₂) u}
--mgu : (t₁ t₂ : T) → Nothing (IsUnifier t₁ t₂) ⊎ ∃ (MostGenerally $ IsUnifier t₁ t₂)
mgu : (t₁ t₂ : T) → Maybe S
mgu = unifier
record MostGeneralUnificationoid ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ
⦃ termSubstitution : TermSubstitution ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ ⦄
: Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where
-- open TermSubstitution termSubstitution
Property : ∀ {ℓ} → Set (ℓˢ ⊔ lsuc ℓ)
Property {ℓ} = S → Set ℓ
Nothing : ∀ {ℓ} → (P : Property {ℓ}) → Set (ℓ ⊔ ℓˢ)
Nothing P = ∀ s → P s → ⊥
IsUnifier : (t₁ t₂ : T) → Property
IsUnifier t₁ t₂ s = t₁ ▹ s =ᵗ t₂ ▹ s
_≤_ : (s₋ : S) (s₊ : S) → Set (ℓˢ ⊔ ℓ⁼ˢ)
_≤_ s₋ s₊ = ∃ λ s → s ∙ s₊ =ˢ s₋
MostGenerally : ∀ {ℓ} (P : Property {ℓ}) → Property
MostGenerally P s₊ = P s₊ × ∀ s₋ → P s₋ → s₋ ≤ s₊
field
mgu : (t₁ t₂ : T) → Nothing (IsUnifier t₁ t₂) ⊎ ∃ (MostGenerally $ IsUnifier t₁ t₂)
-- record PairUnification ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ
-- ⦃ termSubstitution : TermSubstitution ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ ⦄
-- : Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where
-- --open TermSubstitution termSubstitution
-- Property : ∀ {ℓ} → Set (ℓˢ ⊔ lsuc ℓ)
-- Property {ℓ} = S × S → Set ℓ
-- Nothing : ∀ {ℓ} → (P : Property {ℓ}) → Set (ℓ ⊔ ℓˢ)
-- Nothing P = ∀ u → P u → ⊥
-- IsUnifier : (t₁ t₂ : T) → Property
-- IsUnifier t₁ t₂ u = let (s₁ , s₂) = u in t₁ ▹ s₁ =ᵗ t₂ ▹ s₂
-- infix 4 _≤_
-- _≤_ : (s₋ : S × S) (s₊ : S × S) → Set (ℓˢ ⊔ ℓ⁼ˢ)
-- _≤_ u₋ u₊ =
-- let s₋₁ , s₋₂ = u₋
-- s₊₁ , s₊₂ = u₊ in
-- ∃ λ s → s ∙ s₊₁ =ˢ s₋₁ × s ∙ s₊₂ =ˢ s₋₂
-- MostGenerally : ∀ {ℓ} (P : Property {ℓ}) → Property
-- MostGenerally P u₊ = P u₊ × ∀ u₋ → P u₋ → u₋ ≤ u₊
-- {-
-- mgu f(x,y) f(y,x)
-- x → w , y → z || x → z , y → w
-- mgu f(x,y) f(g(y),x)
-- x → g(z) || y → z , x → y
-- mgu f(x,y) f(y,z)
-- x → y , y → z || ∅ ≥₂
-- x → w , y → z || y → w ≥₂
-- x → w , y → v || y → w , z → v ≥₂
-- y → v || y → x , z → v ≥₂
-- ∅ || y → x , z → y
-- x → w , y → v , z → v || y → w , z → v
-- x → y , y → f(z) || z → f(z)
-- f(x , g(x,y) ,w)
-- x → g(z)
-- w →? v
-- f(g(z), g(g(z),y) ,v)
-- v →? w
-- possible unifers:
-- x → g(z) , w → v ||
-- x → g(h(a)) , w → v || z → h(a)
-- x → g(z) || z → h(y) , v → w
-- -}
-- field
-- mgu : (t₁ t₂ : T)
-- → Nothing (IsUnifier t₁ t₂) ⊎ ∃ (MostGenerally (IsUnifier t₁ t₂))
-- -- record Something ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ : Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where
-- -- field
-- -- Terminus : Setoid ℓᵗ ℓ⁼ᵗ
-- -- Simplex : Monoid ℓˢ ℓ⁼ˢ
-- -- open Setoid Terminus public using () renaming
-- -- (Carrier to T
-- -- ;_≈_ to _=T=_)
-- -- open Monoid Simplex public using () renaming
-- -- (Carrier to S
-- -- ;_≈_ to _=S=_
-- -- ;_∙_ to _∙_
-- -- ;ε to ∅)
-- -- infixl 6 _▹_
-- -- field
-- -- _▹_ : T → S → T
-- -- -- equivalence of S implies substitutivity in (T,▹)
-- -- ▹-=S=-to-=T= : ∀ {s s′} → s =S= s′ → (t : T) → t ▹ s =T= t ▹ s′
-- -- -- applications of simplexi are equivalent across all termini only when the simplexi are equivalent
-- -- -- that is, equivalence of S is as compact is it can be while still respecting equivalence in (T,▹)
-- -- ▹-=T=-to-=S= : ∀ {s s′} → ((t : T) → t ▹ s =T= t ▹ s′) → s =S= s′
-- -- -- S extracts to ▹ in (T,∙)
-- -- ▹-∙-compositional : (t : T) (s₁ s₂ : S) → t ▹ s₁ ∙ s₂ =T= t ▹ s₁ ▹ s₂
-- -- -- module NotIndexed where
-- -- -- record MGU ℓᵗ ℓ⁼ᵗ ℓˢ ℓ⁼ˢ : Set (lsuc (ℓᵗ ⊔ ℓ⁼ᵗ ⊔ ℓˢ ⊔ ℓ⁼ˢ)) where
-- -- -- infixr 8 _◃_
-- -- -- --infixr 9 _◇_
-- -- -- field
-- -- -- 𝓣erm : Setoid ℓᵗ ℓ⁼ᵗ
-- -- -- open Setoid 𝓣erm public using () renaming (Carrier to 𝓣; _≈_ to _=ᵗ_)
-- -- -- field
-- -- -- 𝓢ubstition : Semigroup ℓˢ ℓ⁼ˢ -- TODO Monoid?
-- -- -- open Semigroup 𝓢ubstition public using () renaming
-- -- -- (Carrier to 𝓢
-- -- -- ;_≈_ to _=ˢ_
-- -- -- ; _∙_ to _◇_)
-- -- -- --field
-- -- -- -- 𝓼ubstitute : RawPApplicative (λ x x₁ → {!!})
-- -- -- _◃'_ : 𝓢 → 𝓣 → 𝓣
-- -- -- _◃'_ = {!!}
-- -- -- field
-- -- -- _◃_ : 𝓢 → 𝓣 → 𝓣
-- -- -- ◃-=ˢ-to-=ᵗ : ∀ {𝒮 𝒮′} → 𝒮 =ˢ 𝒮′ → (𝒯 : 𝓣) → 𝒮 ◃ 𝒯 =ᵗ 𝒮′ ◃ 𝒯
-- -- -- ◃-=ᵗ-to-=ˢ : ∀ {𝒮 𝒮′} → ((𝒯 : 𝓣) → 𝒮 ◃ 𝒯 =ᵗ 𝒮′ ◃ 𝒯) → 𝒮 =ˢ 𝒮′
-- -- -- field
-- -- -- --_◇_ : 𝓢 → 𝓢 → 𝓢
-- -- -- ◇-compositional : (𝒯 : 𝓣) (𝒮₁ 𝒮₂ : 𝓢) → (𝒮₂ ◇ 𝒮₁) ◃ 𝒯 =ᵗ 𝒮₂ ◃ 𝒮₁ ◃ 𝒯
-- -- -- ◇-associative : (𝒮₁ 𝒮₂ 𝒮₃ : 𝓢) → 𝒮₃ ◇ (𝒮₂ ◇ 𝒮₁) =ˢ (𝒮₃ ◇ 𝒮₂) ◇ 𝒮₁
-- -- -- ◇-associative 𝒮₁ 𝒮₂ 𝒮₃ = {!!}
-- -- -- Property : ∀ {ℓ} → Set (ℓˢ ⊔ lsuc ℓ)
-- -- -- Property {ℓ} = 𝓢 → Set ℓ
-- -- -- Nothing : ∀ {ℓ} → (P : Property {ℓ}) → Set (ℓ ⊔ ℓˢ)
-- -- -- Nothing P = ∀ 𝒮 → P 𝒮 → ⊥
-- -- -- Unifies : (𝒯₁ 𝒯₂ : 𝓣) → Property
-- -- -- Unifies 𝒯₁ 𝒯₂ 𝒮 = 𝒮 ◃ 𝒯₁ ≡ 𝒮 ◃ 𝒯₂
-- -- -- _≤_ : (σ₋ : 𝓢) (σ₊ : 𝓢) → Set (ℓˢ ⊔ ℓ⁼ˢ)
-- -- -- _≤_ σ₋ σ₊ = ∃ λ σ → σ ◇ σ₊ =ˢ σ₋
-- -- -- Max : ∀ {ℓ} (P : Property {ℓ}) → Property
-- -- -- Max P σ₊ = P σ₊ × ∀ σ₋ → P σ₋ → σ₋ ≤ σ₊
-- -- -- field
-- -- -- mgu : (𝒯₁ 𝒯₂ : 𝓣) → Nothing (Unifies 𝒯₁ 𝒯₂) ⊎ ∃ λ (σ : 𝓢) → Max (Unifies 𝒯₁ 𝒯₂) σ
-- -- -- -- module Indexed where
-- -- -- -- record MGU ℓⁱ ℓᵛ ℓᵗ ℓˢ : Set (lsuc (ℓⁱ ⊔ ℓᵛ ⊔ ℓᵗ ⊔ ℓˢ)) where
-- -- -- -- field
-- -- -- -- 𝓲 : Set ℓⁱ
-- -- -- -- 𝓥 : 𝓲 → Set ℓᵛ
-- -- -- -- 𝓣 : 𝓲 → Set ℓᵗ
-- -- -- -- _↦_ : (s t : 𝓲) → Set (ℓᵛ ⊔ ℓᵗ)
-- -- -- -- _↦_ s t = 𝓥 s → 𝓣 t
-- -- -- -- infix 14 _≐_
-- -- -- -- _≐_ : {s t : 𝓲} → s ↦ t → s ↦ t → Set (ℓᵛ ⊔ ℓᵗ)
-- -- -- -- _≐_ σ σ′ = ∀ x → σ x ≡ σ′ x
-- -- -- -- field
-- -- -- -- _◃_ : ∀ {s t} → s ↦ t → 𝓣 s → 𝓣 t
-- -- -- -- ≐-◃-identity : {!!}
-- -- -- -- _◇_ : ∀ {r s t : 𝓲} → (σ₂ : s ↦ t) (σ₁ : r ↦ s) → r ↦ t
-- -- -- -- _◇_ σ₂ σ₁ = (σ₂ ◃_) ∘ σ₁
-- -- -- -- field
-- -- -- -- 𝓢 : 𝓲 → 𝓲 → Set ℓˢ
-- -- -- -- sub : ∀ {s t} → 𝓢 s t → s ↦ t
-- -- -- -- -- Property : ∀ {ℓ} → 𝓲 → Set (lsuc ℓ ⊔ ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- Property {ℓ} s = ∀ {t} → s ↦ t → Set ℓ
-- -- -- -- -- Nothing : ∀ {ℓ m} → (P : Property {ℓ} m) → Set (ℓ ⊔ ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- Nothing P = ∀ {n} f → P {n} f → ⊥
-- -- -- -- -- Unifies : ∀ {i} (t₁ t₂ : 𝓣 i) → Property i
-- -- -- -- -- Unifies t₁ t₂ f = f ◃ t₁ ≡ f ◃ t₂
-- -- -- -- -- _≤_ : ∀ {m n n'} (f : m ↦ n) (g : m ↦ n') → Set (ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- _≤_ f g = ∃ λ f' → f ≐ (f' ◇ g)
-- -- -- -- -- Max : ∀ {ℓ m} (P : Property {ℓ} m) → Property m
-- -- -- -- -- Max P = (λ f → P f × (∀ {n} f' → P {n} f' → f' ≤ f))
-- -- -- -- -- field
-- -- -- -- -- mgu : ∀ {m} (t₁ t₂ : 𝓣 m) →
-- -- -- -- -- Nothing (Unifies t₁ t₂) ⊎ (∃ λ n → ∃ λ (σ : 𝓢 m n) → (Max (Unifies t₁ t₂)) (sub σ))
-- -- -- -- -- -- -- -- open import Prelude.Function
-- -- -- -- -- -- -- -- open import Relation.Binary.HeterogeneousEquality.Core as H using (_≅_ ; ≅-to-≡)
-- -- -- -- -- -- -- -- open import Prelude.Equality
-- -- -- -- -- -- -- -- record MGU-addIndex-to-noIndex* {ℓⁱ ℓⱽ ℓᵀ ℓˢ}
-- -- -- -- -- -- -- -- (m : MGU-addIndex ℓⁱ ℓⱽ ℓᵀ ℓˢ) : Set (lsuc (ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)) where
-- -- -- -- -- -- -- -- open MGU-addIndex m
-- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- 𝓥ᵢ : Set (ℓⁱ ⊔ ℓⱽ)
-- -- -- -- -- -- -- -- 𝓣ᵢ : Set (ℓⁱ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- 𝓼ᵢ : Set (ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- to∃𝓥 : 𝓥ᵢ → ∃ 𝓥
-- -- -- -- -- -- -- -- to∃𝓣 : 𝓣ᵢ → ∃ 𝓣
-- -- -- -- -- -- -- -- to𝓥ᵢ : ∃ 𝓥 → 𝓥ᵢ
-- -- -- -- -- -- -- -- to𝓣ᵢ : ∃ 𝓣 → 𝓣ᵢ
-- -- -- -- -- -- -- -- iso∃𝓥 : (∃𝒱 : ∃ 𝓥) → to∃𝓥 (to𝓥ᵢ ∃𝒱) ≡ ∃𝒱
-- -- -- -- -- -- -- -- iso𝓥ᵢ : (𝒱ᵢ : 𝓥ᵢ) → to𝓥ᵢ (to∃𝓥 𝒱ᵢ) ≡ 𝒱ᵢ
-- -- -- -- -- -- -- -- iso∃𝓣 : (∃𝒯 : ∃ 𝓣) → to∃𝓣 (to𝓣ᵢ ∃𝒯) ≡ ∃𝒯
-- -- -- -- -- -- -- -- iso𝓣ᵢ : (𝒯ᵢ : 𝓣ᵢ) → to𝓣ᵢ (to∃𝓣 𝒯ᵢ) ≡ 𝒯ᵢ
-- -- -- -- -- -- -- -- inj𝓥 : ∀ {a b} → 𝓥 a ≡ 𝓥 b → a ≡ b
-- -- -- -- -- -- -- -- inj𝓣 : ∀ {a b} → 𝓣 a ≡ 𝓣 b → a ≡ b
-- -- -- -- -- -- -- -- mag : (𝓥ᵢ → 𝓣ᵢ) → ∀ {s} t → 𝓥 s → 𝓣 t
-- -- -- -- -- -- -- -- to∃𝓣𝓣 : 𝓣ᵢ → 𝓣ᵢ → ∃ λ i → 𝓣 i × 𝓣 i
-- -- -- -- -- -- -- -- max𝓣ᵢ : ∀ {m} n → (tm : 𝓣 m) → (((𝓣 n → 𝓣 m) × (𝓥 n → 𝓥 m)) ⊎ 𝓣 n)
-- -- -- -- -- -- -- -- max𝓲 : ∀ m n → ((𝓣 n → 𝓣 m) × (𝓥 n → 𝓥 m)) ⊎ ((𝓣 m → 𝓣 n) × (𝓥 m → 𝓥 n))
-- -- -- -- -- -- -- -- apply𝓼 : 𝓣ᵢ → (𝓥ᵢ → 𝓣ᵢ) → ∃ λ s → ∃ λ t → (𝓥 s → 𝓣 t) × 𝓣 s
-- -- -- -- -- -- -- -- to𝓼 : 𝓼ᵢ → ∃ λ s → ∃ λ t → 𝓥 s → 𝓣 t
-- -- -- -- -- -- -- -- to𝓼' : 𝓼ᵢ → 𝓣ᵢ → ∃ λ s → ∃ λ t → (𝓥 s → 𝓣 t) × 𝓣 s
-- -- -- -- -- -- -- -- to◇ : 𝓼ᵢ → 𝓼ᵢ → ∃ λ r → ∃ λ s → ∃ λ t → (𝓥 s → 𝓣 t) × (𝓥 r → 𝓣 s)
-- -- -- -- -- -- -- -- to= : 𝓼ᵢ → 𝓼ᵢ → ∃ λ s → ∃ λ t → (𝓥 s → 𝓣 t) × (𝓥 s → 𝓣 t)
-- -- -- -- -- -- -- -- to𝓼ᵢ : ∀ {r t} → (𝓥 r → 𝓣 t) → 𝓼ᵢ
-- -- -- -- -- -- -- -- {{ eqi }} : Eq 𝓲
-- -- -- -- -- -- -- -- to-noIndex : MGU-noIndex* (ℓⁱ ⊔ ℓⱽ) (ℓⁱ ⊔ ℓᵀ) (ℓⁱ ⊔ ℓˢ)
-- -- -- -- -- -- -- -- to-noIndex = go where
-- -- -- -- -- -- -- -- go : MGU-noIndex* _ _ _
-- -- -- -- -- -- -- -- MGU-noIndex*.𝓥 go = 𝓥ᵢ
-- -- -- -- -- -- -- -- MGU-noIndex*.𝓣 go = 𝓣ᵢ
-- -- -- -- -- -- -- -- MGU-noIndex*.𝓼 go = 𝓼ᵢ -- ∃ λ s → ∃ λ t → s ↦ t
-- -- -- -- -- -- -- -- MGU-noIndex*._≐_ go s1 s2 with to= s1 s2
-- -- -- -- -- -- -- -- ... | (s , t , vstt1 , vstt2) = {!_≐_ vstt1 vstt2!}
-- -- -- -- -- -- -- -- MGU-noIndex*._◃_ go f x with to𝓼' f x
-- -- -- -- -- -- -- -- MGU-noIndex*._◃_ go _ _ | (s , t , f , term) = to𝓣ᵢ $ _ , f ◃ term
-- -- -- -- -- -- -- -- MGU-noIndex*._◇_ go s1 s2 with to◇ s1 s2
-- -- -- -- -- -- -- -- ... | (r , s , t , vstt , vrts) = to𝓼ᵢ $ vstt ◇ vrts
-- -- -- -- -- -- -- -- MGU-noIndex*.mgu go = {!!}
-- -- -- -- -- -- -- -- -- MGU-noIndex*.𝓥 go = {!𝓥ᵢ!}
-- -- -- -- -- -- -- -- -- MGU-noIndex*.𝓣 go = 𝓣ᵢ
-- -- -- -- -- -- -- -- -- MGU-noIndex*.𝓼 go = {!!} -- ∃ λ s → ∃ λ t → s ↦ t -- ∃ λ s → ∃ λ t → 𝓥 s → 𝓣 t
-- -- -- -- -- -- -- -- -- MGU-noIndex*._≐_ go (s₁ , t₁ , f₁) (s₂ , t₂ , f₂) = {!!} -- ∃ λ (s-refl : s₁ ≡ s₂) → ∃ λ (t-refl : t₁ ≡ t₂) → (∀ x → f₁ x ≡ (Prelude.transport (λ i → 𝓥 s₂ → 𝓣 i) (sym t-refl) f₂) (Prelude.transport _ s-refl x))
-- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- MGU-noIndex*._◃_ go (s , t , f) 𝒯 = {!_◃_ f!}
-- -- -- -- -- -- -- -- -- ∀ s t → 𝓣ᵢ → (𝓣 s → 𝓣 t) → 𝓣 s
-- -- -- -- -- -- -- -- -- ∀ s t → 𝓣ᵢ → (𝓣 s → 𝓣 t) → 𝓣ᵢ
-- -- -- -- -- -- -- -- -- 𝓣 s
-- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- MGU-noIndex*._◃_ go (s , t , f) 𝒯 with to∃𝓣 𝒯
-- -- -- -- -- -- -- -- -- MGU-noIndex*._◃_ go (s , t , f) 𝒯 | (s2 , ttt) with s == s2
-- -- -- -- -- -- -- -- -- (go MGU-noIndex*.◃ (.s , t , f)) 𝒯 | s , 𝒯s | (Prelude.yes refl) = to𝓣ᵢ (_ , _◃_ {s} {t} f 𝒯s)
-- -- -- -- -- -- -- -- -- (go MGU-noIndex*.◃ (s , t , f)) 𝒯 | s2 , ttt | (Prelude.no x) = 𝒯
-- -- -- -- -- -- -- -- -- MGU-noIndex*._◇_ go (s , t , f) (p , r , g) with max𝓲 r s
-- -- -- -- -- -- -- -- -- MGU-noIndex*._◇_ go (s , t , f) (p , r , g) | _⊎_.left (T , V) = {!!}
-- -- -- -- -- -- -- -- -- MGU-noIndex*._◇_ go (s , t , f) (p , r , g) | _⊎_.right (T , V) = _ , _ , f ◇ (T ∘ g) -- f ◃_ ∘ (T ∘ g)
-- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- = _ , _ , f ◃_ ∘ (λ x → {!max𝓣ᵢ s₁ (g x)!}) -- _ , _ , f ◃_ ∘ (λ x → {!g x!})
-- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- MGU-noIndex*._◇_ go (s₁ , t₁ , f) (s₂ , t₂ , g) with t₂ == s₁
-- -- -- -- -- -- -- -- -- MGU-noIndex*._◇_ go (s₁ , t₁ , f) (s₂ , t₂ , g) | (Prelude.yes refl) = s₂ , t₁ , f ◃_ ∘ g
-- -- -- -- -- -- -- -- -- MGU-noIndex*._◇_ go (s₁ , t₁ , f) (s₂ , t₂ , g) | (Prelude.no x) = s₂ , t₂ , g
-- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- -- = s₂ , t₁ , {!(f ◃_)!}
-- -- -- -- -- -- -- -- -- MGU-noIndex*.mgu go t₁ t₂ with to∃𝓣𝓣 t₁ t₂
-- -- -- -- -- -- -- -- -- … | i , tt₁ , tt₂ with mgu tt₁ tt₂
-- -- -- -- -- -- -- -- -- MGU-noIndex*.mgu go t₁ t₂ | i , tt₁ , tt₂ | (_⊎_.left x) = {!!}
-- -- -- -- -- -- -- -- -- MGU-noIndex*.mgu go t₁ t₂ | i , tt₁ , tt₂ | (_⊎_.right (i₂ , σ , subσ-refl , ff)) with to∃𝓣 t₁ | to∃𝓣 t₂
-- -- -- -- -- -- -- -- -- MGU-noIndex*.mgu go t₁ t₂ | i , tt₁ , tt₂ | (_⊎_.right (i₂ , σ , subσ-refl , ff)) | (fst₁ , snd₁) | (fst₂ , snd₂) = _⊎_.right ((_ , _ , sub σ) , {!!} , {!!}) -- _⊎_.right ((i , i₂ , sub σ) , {!subσ-refl!} , {!!})
-- -- -- -- -- -- -- -- -- record MGU-noIndex-to-addIndex {ℓⁱ ℓⱽ ℓᵀ ℓˢ}
-- -- -- -- -- -- -- -- -- (m : MGU-noIndex ℓⱽ ℓᵀ ℓˢ) : Set (lsuc (ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)) where
-- -- -- -- -- -- -- -- -- open MGU-noIndex m
-- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- 𝓲 : Set ℓⁱ
-- -- -- -- -- -- -- -- -- 𝓥ᵢ : 𝓲 → Set ℓⱽ
-- -- -- -- -- -- -- -- -- 𝓣ᵢ : 𝓲 → Set ℓᵀ
-- -- -- -- -- -- -- -- -- to𝓥 : ∃ 𝓥ᵢ → 𝓥
-- -- -- -- -- -- -- -- -- to𝓣 : ∃ 𝓣ᵢ → 𝓣
-- -- -- -- -- -- -- -- -- to∃𝓥ᵢ : 𝓥 → ∃ 𝓥ᵢ
-- -- -- -- -- -- -- -- -- to∃𝓣ᵢ : 𝓣 → ∃ 𝓣ᵢ
-- -- -- -- -- -- -- -- -- inj𝓥 : ∀ {a b} → 𝓥ᵢ a ≡ 𝓥ᵢ b → a ≡ b
-- -- -- -- -- -- -- -- -- inj𝓣 : ∀ {a b} → 𝓣ᵢ a ≡ 𝓣ᵢ b → a ≡ b
-- -- -- -- -- -- -- -- -- mag : ∀ {s t} → (𝓥ᵢ s → 𝓣ᵢ t) → 𝓥 → 𝓣
-- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- iso∃𝓥 : (∃𝒱 : ∃ 𝓥) → to∃𝓥 (to𝓥ᵢ ∃𝒱) ≡ ∃𝒱
-- -- -- -- -- -- -- -- -- iso𝓥ᵢ : (𝒱ᵢ : 𝓥ᵢ) → to𝓥ᵢ (to∃𝓥 𝒱ᵢ) ≡ 𝒱ᵢ
-- -- -- -- -- -- -- -- -- iso∃𝓣 : (∃𝒯 : ∃ 𝓣) → to∃𝓣 (to𝓣ᵢ ∃𝒯) ≡ ∃𝒯
-- -- -- -- -- -- -- -- -- iso𝓣ᵢ : (𝒯ᵢ : 𝓣ᵢ) → to𝓣ᵢ (to∃𝓣 𝒯ᵢ) ≡ 𝒯ᵢ
-- -- -- -- -- -- -- -- -- mag : (𝓥ᵢ → 𝓣ᵢ) → ∀ {s} t → 𝓥 s → 𝓣 t
-- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- to-addIndex : MGU-addIndex ℓⁱ ℓⱽ ℓᵀ ℓˢ
-- -- -- -- -- -- -- -- -- to-addIndex = go where
-- -- -- -- -- -- -- -- -- go : MGU-addIndex ℓⁱ ℓⱽ ℓᵀ ℓˢ
-- -- -- -- -- -- -- -- -- MGU-addIndex.𝓲 go = 𝓲
-- -- -- -- -- -- -- -- -- MGU-addIndex.𝓥 go = 𝓥ᵢ
-- -- -- -- -- -- -- -- -- MGU-addIndex.𝓣 go = 𝓣ᵢ
-- -- -- -- -- -- -- -- -- MGU-addIndex._◃_ go {s} {t} f x = Prelude.transport 𝓣ᵢ {!!} $ snd ∘ to∃𝓣ᵢ $ _◃_ (λ v → to𝓣 (t , f (Prelude.transport 𝓥ᵢ (inj𝓥 {_} {_} {!!}) (snd $ to∃𝓥ᵢ v)))) (to𝓣 (s , x)) -- let Ti , Tit = to∃𝓣ᵢ $ _◃_ (λ v → to𝓣 (t , f {!!})) (to𝓣 (s , x)) in {!!}
-- -- -- -- -- -- -- -- -- MGU-addIndex.𝓢 go = {!!}
-- -- -- -- -- -- -- -- -- MGU-addIndex.sub go = {!!}
-- -- -- -- -- -- -- -- -- MGU-addIndex.mgu go = {!!}
-- -- -- -- -- -- -- -- -- record MGU-addIndex-to-noIndex {ℓⁱ ℓⱽ ℓᵀ ℓˢ}
-- -- -- -- -- -- -- -- -- (m : MGU-addIndex ℓⁱ ℓⱽ ℓᵀ ℓˢ) : Set (lsuc (ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)) where
-- -- -- -- -- -- -- -- -- open MGU-addIndex m
-- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- 𝓥ᵢ : Set (ℓⁱ ⊔ ℓⱽ)
-- -- -- -- -- -- -- -- -- 𝓣ᵢ : Set (ℓⁱ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- to∃𝓥 : 𝓥ᵢ → ∃ 𝓥
-- -- -- -- -- -- -- -- -- to∃𝓣 : 𝓣ᵢ → ∃ 𝓣
-- -- -- -- -- -- -- -- -- to𝓥ᵢ : ∃ 𝓥 → 𝓥ᵢ
-- -- -- -- -- -- -- -- -- to𝓣ᵢ : ∃ 𝓣 → 𝓣ᵢ
-- -- -- -- -- -- -- -- -- iso∃𝓥 : (∃𝒱 : ∃ 𝓥) → to∃𝓥 (to𝓥ᵢ ∃𝒱) ≡ ∃𝒱
-- -- -- -- -- -- -- -- -- iso𝓥ᵢ : (𝒱ᵢ : 𝓥ᵢ) → to𝓥ᵢ (to∃𝓥 𝒱ᵢ) ≡ 𝒱ᵢ
-- -- -- -- -- -- -- -- -- iso∃𝓣 : (∃𝒯 : ∃ 𝓣) → to∃𝓣 (to𝓣ᵢ ∃𝒯) ≡ ∃𝒯
-- -- -- -- -- -- -- -- -- iso𝓣ᵢ : (𝒯ᵢ : 𝓣ᵢ) → to𝓣ᵢ (to∃𝓣 𝒯ᵢ) ≡ 𝒯ᵢ
-- -- -- -- -- -- -- -- -- inj𝓥 : ∀ {a b} → 𝓥 a ≡ 𝓥 b → a ≡ b
-- -- -- -- -- -- -- -- -- inj𝓣 : ∀ {a b} → 𝓣 a ≡ 𝓣 b → a ≡ b
-- -- -- -- -- -- -- -- -- mag : (𝓥ᵢ → 𝓣ᵢ) → ∀ {s} t → 𝓥 s → 𝓣 t
-- -- -- -- -- -- -- -- -- to-noIndex : MGU-noIndex (ℓⁱ ⊔ ℓⱽ) (ℓⁱ ⊔ ℓᵀ) ℓˢ
-- -- -- -- -- -- -- -- -- to-noIndex = go where
-- -- -- -- -- -- -- -- -- go : MGU-noIndex _ _ _
-- -- -- -- -- -- -- -- -- MGU-noIndex.𝓥 go = 𝓥ᵢ
-- -- -- -- -- -- -- -- -- MGU-noIndex.𝓣 go = 𝓣ᵢ
-- -- -- -- -- -- -- -- -- MGU-noIndex._◃_ go 𝓈 𝒯ᵢ with to∃𝓣 𝒯ᵢ | Prelude.graphAt to∃𝓣 𝒯ᵢ | (Prelude.curry $ snd ∘ to∃𝓣 ∘ 𝓈 ∘ to𝓥ᵢ) (fst $ to∃𝓣 𝒯ᵢ) | Prelude.graphAt (Prelude.curry $ snd ∘ to∃𝓣 ∘ 𝓈 ∘ to𝓥ᵢ) (fst $ to∃𝓣 𝒯ᵢ)
-- -- -- -- -- -- -- -- -- … | s , 𝒯s | Prelude.ingraph eq | 𝓈' | Prelude.ingraph refl with cong fst eq
-- -- -- -- -- -- -- -- -- (go MGU-noIndex.◃ 𝓈) 𝒯ᵢ | .(fst (to∃𝓣 𝒯ᵢ)) , 𝒯s | (Prelude.ingraph eq) | _ | (Prelude.ingraph refl) | refl with cong fst eq
-- -- -- -- -- -- -- -- -- (go MGU-noIndex.◃ 𝓈) 𝒯ᵢ | .(fst (to∃𝓣 _ 𝒯ᵢ)) , 𝒯s | (Prelude.ingraph eq) | 𝓈' | (Prelude.ingraph refl) | refl | refl rewrite Prelude.sym eq with _◃_ {_} {{!!}} (λ v → 𝓈' (Prelude.transport 𝓥 (cong fst (sym eq)) {!!})) (snd ∘ to∃𝓣 $ 𝒯ᵢ)
-- -- -- -- -- -- -- -- -- … | dfsf = to𝓣ᵢ (_ , dfsf)
-- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- … | s , 𝒯s | Prelude.ingraph eq | 𝓈' | Prelude.ingraph refl with _◃_ {fst (to∃𝓣 𝒯ᵢ)} {s} (λ v → Prelude.transport 𝓣 {!!} (𝓈' (Prelude.transport 𝓥 (cong fst eq) v))) (snd ∘ to∃𝓣 $ 𝒯ᵢ)
-- -- -- -- -- -- -- -- -- … | dd = to𝓣ᵢ (_ , dd)
-- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- MGU-noIndex.𝓢 go = {!!}
-- -- -- -- -- -- -- -- -- MGU-noIndex.sub go = {!!}
-- -- -- -- -- -- -- -- -- MGU-noIndex.mgu go = {!!}
-- -- -- -- -- -- -- -- -- -- MGU-addIndex-to-noIndex : ∀ {ℓⁱ ℓⱽ ℓᵀ ℓˢ} →
-- -- -- -- -- -- -- -- -- -- (m : MGU-addIndex ℓⁱ ℓⱽ ℓᵀ ℓˢ)
-- -- -- -- -- -- -- -- -- -- (open MGU-addIndex m)
-- -- -- -- -- -- -- -- -- -- (𝓥ᵢ : Set (ℓⁱ ⊔ ℓⱽ))
-- -- -- -- -- -- -- -- -- -- (𝓣ᵢ : Set (ℓⁱ ⊔ ℓᵀ))
-- -- -- -- -- -- -- -- -- -- (to∃𝓥 : 𝓥ᵢ → ∃ 𝓥)
-- -- -- -- -- -- -- -- -- -- (to∃𝓣 : 𝓣ᵢ → ∃ 𝓣)
-- -- -- -- -- -- -- -- -- -- (to𝓥ᵢ : ∃ 𝓥 → 𝓥ᵢ)
-- -- -- -- -- -- -- -- -- -- (to𝓣ᵢ : ∃ 𝓣 → 𝓣ᵢ)
-- -- -- -- -- -- -- -- -- -- (iso∃𝓥 : (∃𝒱 : ∃ 𝓥) → to∃𝓥 (to𝓥ᵢ ∃𝒱) ≡ ∃𝒱)
-- -- -- -- -- -- -- -- -- -- (iso𝓥ᵢ : (𝒱ᵢ : 𝓥ᵢ) → to𝓥ᵢ (to∃𝓥 𝒱ᵢ) ≡ 𝒱ᵢ)
-- -- -- -- -- -- -- -- -- -- (iso∃𝓣 : (∃𝒯 : ∃ 𝓣) → to∃𝓣 (to𝓣ᵢ ∃𝒯) ≡ ∃𝒯)
-- -- -- -- -- -- -- -- -- -- (iso𝓣ᵢ : (𝒯ᵢ : 𝓣ᵢ) → to𝓣ᵢ (to∃𝓣 𝒯ᵢ) ≡ 𝒯ᵢ)
-- -- -- -- -- -- -- -- -- -- → MGU-noIndex (ℓⁱ ⊔ ℓⱽ) (ℓⁱ ⊔ ℓᵀ) ℓˢ
-- -- -- -- -- -- -- -- -- -- MGU-addIndex-to-noIndex {ℓⁱ} {ℓⱽ} {ℓᵀ} {ℓˢ} m = go where
-- -- -- -- -- -- -- -- -- -- open MGU-addIndex m
-- -- -- -- -- -- -- -- -- -- go : MGU-noIndex _ _ _
-- -- -- -- -- -- -- -- -- -- go = {!!}
-- -- -- -- -- -- -- -- -- -- -- open import Relation.Binary.HeterogeneousEquality.Core as H using (_≅_ ; ≅-to-≡)
-- -- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- -- 𝓼 = ∃ 𝓥 → ∃ 𝓣
-- -- -- -- -- -- -- -- -- -- _∶_↦_ : 𝓼 → 𝓲 → 𝓲 → Set (ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- _∶_↦_ 𝓈 s t = ((𝒱ₛ : 𝓥 s) → ∃ λ (𝒯ₜ : 𝓣 t) → 𝓈 (s , 𝒱ₛ) ≡ (t , 𝒯ₜ))
-- -- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- -- -- go : MGU-noIndex _ _ _
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.𝓥 go = ∃ 𝓥
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.𝓣 go = ∃ 𝓣
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex._≐_ go f g = (𝒾 : 𝓲) (𝒱 : 𝓥 𝒾) → f (𝒾 , 𝒱) ≡ g (𝒾 , 𝒱)
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex._◃_ go 𝓈 (𝒾 , 𝒯) = 𝒾 , _◃_ {𝒾} {𝒾} (λ v → (Prelude.transport _ (≅-to-≡ $ snd (mag (fst (𝓈 (𝒾 , v))) (( (𝒾 ))) (snd (𝓈 (𝒾 , v))))) $
-- -- -- -- -- -- -- -- -- -- -- snd (𝓈 (𝒾 , v)))
-- -- -- -- -- -- -- -- -- -- -- {!!}) {!!}
-- -- -- -- -- -- -- -- -- -- -- -- (snd ∘ (λ (𝒱 : 𝓥 𝒾) → 𝓈 (𝒾 , 𝒱)))
-- -- -- -- -- -- -- -- -- -- -- -- fst (𝓈 (s , {!!})) , _◃_ {s} {fst (𝓈 (s , _))} (λ v → {!𝓈 (s , v)!}) {!𝒯ₛ!}
-- -- -- -- -- -- -- -- -- -- -- -- Have: {s t : 𝓲} → (𝓥 s → 𝓣 t) → 𝓣 s → 𝓣 t
-- -- -- -- -- -- -- -- -- -- -- -- λ (𝒱 : 𝓥 𝒾) → 𝓈 (𝒾 , 𝒱)
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.𝓢 go = {!!}
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.sub go = {!sub {s} {t}!}
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.mgu go = {!!}
-- -- -- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.𝓥 (MGU-addIndex-to-noIndex m) = let open MGU-addIndex m in ∃ 𝓥
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.𝓣 (MGU-addIndex-to-noIndex m) = let open MGU-addIndex m in ∃ 𝓣
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex._≐_ (MGU-addIndex-to-noIndex m) f g = {!let open MGU-addIndex m in ∀ (s t : 𝓲) → (𝒯ₜ : 𝓣 fst (f (s , 𝓥 s)) ≡ t → ≡ g → Set !} -- ∀ {s t} → (f g : s ↦ t) → f ≐ g
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex._◃_ (MGU-addIndex-to-noIndex m) = {!let open MGU-addIndex m in _◃_!}
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.𝓢 (MGU-addIndex-to-noIndex m) = {!!}
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.sub (MGU-addIndex-to-noIndex m) = {!!}
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.mgu (MGU-addIndex-to-noIndex m) = {!!}
-- -- -- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.𝓥 (MGU-addIndex-to-noIndex record { 𝓲 = 𝓲 ; 𝓥 = 𝓥 ; 𝓣 = 𝓣 ; _◃_ = _◃_ ; ◃ext = ◃ext ; 𝓢 = 𝓢 ; sub = sub ; mgu = mgu }) = ∃ 𝓥
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.𝓣 (MGU-addIndex-to-noIndex record { 𝓲 = 𝓲 ; 𝓥 = 𝓥 ; 𝓣 = 𝓣 ; _◃_ = _◃_ ; ◃ext = ◃ext ; 𝓢 = 𝓢 ; sub = sub ; mgu = mgu }) = ∃ 𝓣
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex._≐_ (MGU-addIndex-to-noIndex m@(record { 𝓲 = 𝓲 ; 𝓥 = 𝓥 ; 𝓣 = 𝓣 ; _◃_ = _◃_ ; ◃ext = ◃ext ; 𝓢 = 𝓢 ; sub = sub ; mgu = mgu })) f g = {!!} -- (i : 𝓲) → MGU-addIndex._≐_ m (λ v → {!snd $ f (i , v)!}) (λ v → {!!})
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex._◃_ (MGU-addIndex-to-noIndex record { 𝓲 = 𝓲 ; 𝓥 = 𝓥 ; 𝓣 = 𝓣 ; _◃_ = _◃_ ; ◃ext = ◃ext ; 𝓢 = 𝓢 ; sub = sub ; mgu = mgu }) = {!!}
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.𝓢 (MGU-addIndex-to-noIndex record { 𝓲 = 𝓲 ; 𝓥 = 𝓥 ; 𝓣 = 𝓣 ; _◃_ = _◃_ ; ◃ext = ◃ext ; 𝓢 = 𝓢 ; sub = sub ; mgu = mgu }) = {!!}
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.sub (MGU-addIndex-to-noIndex record { 𝓲 = 𝓲 ; 𝓥 = 𝓥 ; 𝓣 = 𝓣 ; _◃_ = _◃_ ; ◃ext = ◃ext ; 𝓢 = 𝓢 ; sub = sub ; mgu = mgu }) = {!!}
-- -- -- -- -- -- -- -- -- -- -- MGU-noIndex.mgu (MGU-addIndex-to-noIndex record { 𝓲 = 𝓲 ; 𝓥 = 𝓥 ; 𝓣 = 𝓣 ; _◃_ = _◃_ ; ◃ext = ◃ext ; 𝓢 = 𝓢 ; sub = sub ; mgu = mgu }) = {!!}
-- -- -- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- -- -- record MGU⋆ ℓⁱ ℓⱽ ℓᵀ ℓˢ : Set (lsuc (ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ ⊔ ℓˢ)) where
-- -- -- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- -- -- 𝓲
-- -- -- -- -- -- -- -- -- -- -- : Set ℓⁱ
-- -- -- -- -- -- -- -- -- -- -- 𝓥 -- variables
-- -- -- -- -- -- -- -- -- -- -- : 𝓲 → Set ℓⱽ
-- -- -- -- -- -- -- -- -- -- -- 𝓣 -- terms
-- -- -- -- -- -- -- -- -- -- -- : 𝓲 → Set ℓᵀ
-- -- -- -- -- -- -- -- -- -- -- -- substitution
-- -- -- -- -- -- -- -- -- -- -- _↦_ : (s t : 𝓲) → Set (ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- _↦_ s t = 𝓥 s → 𝓣 t
-- -- -- -- -- -- -- -- -- -- -- infix 14 _≐_
-- -- -- -- -- -- -- -- -- -- -- _≐_ : {s t : 𝓲} → s ↦ t → s ↦ t → Set (ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- _≐_ f g = ∀ x → f x ≡ g x
-- -- -- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- -- -- -- substitution applied to a term
-- -- -- -- -- -- -- -- -- -- -- _◃_ : ∀ {s t} → s ↦ t → 𝓣 s → 𝓣 t
-- -- -- -- -- -- -- -- -- -- -- -- applying extentionally-equal subsitutions preserves equality of terms
-- -- -- -- -- -- -- -- -- -- -- ◃ext : ∀ {s t} {f g : s ↦ t} → f ≐ g → ∀ t → f ◃ t ≡ g ◃ t
-- -- -- -- -- -- -- -- -- -- -- _◇_ : ∀ {r s t : 𝓲} → (f : s ↦ t) (g : r ↦ s) → r ↦ t
-- -- -- -- -- -- -- -- -- -- -- _◇_ f g = (f ◃_) ∘ g
-- -- -- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- -- -- 𝓢 : 𝓲 → 𝓲 → Set ℓˢ
-- -- -- -- -- -- -- -- -- -- -- sub : ∀ {s t} → 𝓢 s t → s ↦ t
-- -- -- -- -- -- -- -- -- -- -- Property : ∀ {ℓ} → 𝓲 → Set (lsuc ℓ ⊔ ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- Property {ℓ} s = ∀ {t} → s ↦ t → Set ℓ
-- -- -- -- -- -- -- -- -- -- -- Nothing : ∀ {ℓ m} → (P : Property {ℓ} m) → Set (ℓ ⊔ ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- Nothing P = ∀ {n} f → P {n} f → ⊥
-- -- -- -- -- -- -- -- -- -- -- Unifies : ∀ {i} (t₁ t₂ : 𝓣 i) → Property i
-- -- -- -- -- -- -- -- -- -- -- Unifies t₁ t₂ f = f ◃ t₁ ≡ f ◃ t₂
-- -- -- -- -- -- -- -- -- -- -- _≤_ : ∀ {m n n'} (f : m ↦ n) (g : m ↦ n') → Set (ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- _≤_ f g = ∃ λ f' → f ≐ (f' ◇ g)
-- -- -- -- -- -- -- -- -- -- -- Max : ∀ {ℓ m} (P : Property {ℓ} m) → Property m
-- -- -- -- -- -- -- -- -- -- -- Max P = (λ f → P f × (∀ {n} f' → P {n} f' → f' ≤ f))
-- -- -- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- -- -- mgu : ∀ {m} (t₁ t₂ : 𝓣 m) →
-- -- -- -- -- -- -- -- -- -- -- Nothing (Unifies t₁ t₂) ⊎ (∃ λ n → ∃ λ (σ : 𝓢 m n) → (Max (Unifies t₁ t₂)) (sub σ))
-- -- -- -- -- -- -- -- -- -- -- record MGU ℓⁱ ℓⱽ ℓᵀ ℓˢ : Set (lsuc (ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ ⊔ ℓˢ)) where
-- -- -- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- -- -- 𝓲
-- -- -- -- -- -- -- -- -- -- -- : Set ℓⁱ
-- -- -- -- -- -- -- -- -- -- -- 𝓥 -- variables
-- -- -- -- -- -- -- -- -- -- -- : 𝓲 → Set ℓⱽ
-- -- -- -- -- -- -- -- -- -- -- 𝓣 -- terms
-- -- -- -- -- -- -- -- -- -- -- : 𝓲 → Set ℓᵀ
-- -- -- -- -- -- -- -- -- -- -- -- substitution
-- -- -- -- -- -- -- -- -- -- -- _↦_ : (s t : 𝓲) → Set (ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- _↦_ s t = 𝓥 s → 𝓣 t
-- -- -- -- -- -- -- -- -- -- -- infix 14 _≐_
-- -- -- -- -- -- -- -- -- -- -- _≐_ : {s t : 𝓲} → s ↦ t → s ↦ t → Set (ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- _≐_ f g = ∀ x → f x ≡ g x
-- -- -- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- -- -- -- substitution applied to a term
-- -- -- -- -- -- -- -- -- -- -- _◃_ : ∀ {s t} → s ↦ t → 𝓣 s → 𝓣 t
-- -- -- -- -- -- -- -- -- -- -- -- applying extentionally-equal subsitutions preserves equality of terms
-- -- -- -- -- -- -- -- -- -- -- ◃ext : ∀ {s t} {f g : s ↦ t} → f ≐ g → ∀ t → f ◃ t ≡ g ◃ t
-- -- -- -- -- -- -- -- -- -- -- _◇_ : ∀ {r s t : 𝓲} → (f : s ↦ t) (g : r ↦ s) → r ↦ t
-- -- -- -- -- -- -- -- -- -- -- _◇_ f g = (f ◃_) ∘ g
-- -- -- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- -- -- 𝓢 : 𝓲 → 𝓲 → Set ℓˢ
-- -- -- -- -- -- -- -- -- -- -- sub : ∀ {s t} → 𝓢 s t → s ↦ t
-- -- -- -- -- -- -- -- -- -- -- mgu : ∀ {m} → (s t : 𝓣 m) → Maybe (∃ (𝓢 m))
-- -- -- -- -- -- -- -- -- -- -- Property⋆ : ∀ {ℓ} → 𝓲 → Set (lsuc ℓ ⊔ ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- Property⋆ {ℓ} s = ∀ {t} → s ↦ t → Set ℓ
-- -- -- -- -- -- -- -- -- -- -- Property : ∀ {ℓ} → 𝓲 → Set (lsuc ℓ ⊔ ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- Property {ℓ} s = Σ (Property⋆ {ℓ} s) λ P → ∀ {s f g} → f ≐ g → P {s} f → P g
-- -- -- -- -- -- -- -- -- -- -- Nothing : ∀ {ℓ m} → (P : Property {ℓ} m) → Set (ℓ ⊔ ℓⁱ ⊔ ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- Nothing P = ∀ {n} f → fst P {n} f → ⊥
-- -- -- -- -- -- -- -- -- -- -- Unifies : ∀ {i} (t₁ t₂ : 𝓣 i) → Property i
-- -- -- -- -- -- -- -- -- -- -- Unifies t₁ t₂ = (λ {_} f → f ◃ t₁ ≡ f ◃ t₂) , λ {_} {f} {g} f≐g f◃t₁=f◃t₂ →
-- -- -- -- -- -- -- -- -- -- -- g ◃ t₁
-- -- -- -- -- -- -- -- -- -- -- ≡⟨ sym (◃ext f≐g t₁) ⟩
-- -- -- -- -- -- -- -- -- -- -- f ◃ t₁
-- -- -- -- -- -- -- -- -- -- -- ≡⟨ f◃t₁=f◃t₂ ⟩
-- -- -- -- -- -- -- -- -- -- -- f ◃ t₂
-- -- -- -- -- -- -- -- -- -- -- ≡⟨ ◃ext f≐g t₂ ⟩
-- -- -- -- -- -- -- -- -- -- -- g ◃ t₂
-- -- -- -- -- -- -- -- -- -- -- ∎
-- -- -- -- -- -- -- -- -- -- -- _≤_ : ∀ {m n n'} (f : m ↦ n) (g : m ↦ n') → Set (ℓⱽ ⊔ ℓᵀ)
-- -- -- -- -- -- -- -- -- -- -- _≤_ f g = ∃ λ f' → f ≐ (f' ◇ g)
-- -- -- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- -- -- Max : ∀ {ℓ m} (P : Property {ℓ} m) → Property m
-- -- -- -- -- -- -- -- -- -- -- Max P' =
-- -- -- -- -- -- -- -- -- -- -- let open Σ P' using () renaming (fst to P; snd to Peq) in
-- -- -- -- -- -- -- -- -- -- -- let lemma1 : {m : 𝓲} {f : _ ↦ m} {g : _ ↦ m} →
-- -- -- -- -- -- -- -- -- -- -- f ≐ g →
-- -- -- -- -- -- -- -- -- -- -- P f × ({n : 𝓲} (f' : _ ↦ n) → P f' → f' ≤ f) →
-- -- -- -- -- -- -- -- -- -- -- P g × ({n : 𝓲} (f' : _ ↦ n) → P f' → f' ≤ g)
-- -- -- -- -- -- -- -- -- -- -- lemma1 {_} {_} {g} f≐g = λ { (Pf , MaxPf) →
-- -- -- -- -- -- -- -- -- -- -- Peq f≐g Pf , λ {_} →
-- -- -- -- -- -- -- -- -- -- -- let lemma2 : ∀ {n} f' → P {n} f' → ∃ λ f0 → f' ≐ (f0 ◇ g)
-- -- -- -- -- -- -- -- -- -- -- lemma2 f' Pf' =
-- -- -- -- -- -- -- -- -- -- -- let f0 = fst (MaxPf f' Pf')
-- -- -- -- -- -- -- -- -- -- -- f'≐f0◇f = snd (MaxPf f' Pf') in
-- -- -- -- -- -- -- -- -- -- -- f0 , λ x → trans (f'≐f0◇f x) (cong (f0 ◃_) (f≐g x)) in
-- -- -- -- -- -- -- -- -- -- -- lemma2 } in
-- -- -- -- -- -- -- -- -- -- -- --(λ {_} f → P f × (∀ {n} f' → P {n} f' → f' ≤ f)) , λ {_} {_} {_} → lemma1
-- -- -- -- -- -- -- -- -- -- -- (λ f → P f × (∀ {n} f' → P {n} f' → f' ≤ f)) , lemma1
-- -- -- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- -- -- Max : ∀ {ℓ m} (P : Property {ℓ} m) → Property⋆ m
-- -- -- -- -- -- -- -- -- -- -- Max P' =
-- -- -- -- -- -- -- -- -- -- -- let open Σ P' using () renaming (fst to P) in
-- -- -- -- -- -- -- -- -- -- -- (λ f → P f × (∀ {n} f' → P {n} f' → f' ≤ f))
-- -- -- -- -- -- -- -- -- -- -- field
-- -- -- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- -- -- mgu-c : ∀ {m} (t₁ t₂ : 𝓣 m) →
-- -- -- -- -- -- -- -- -- -- -- (∃ λ n → ∃ λ σ → fst (Max (Unifies t₁ t₂)) (sub σ) × mgu t₁ t₂ ≡ just (n , σ))
-- -- -- -- -- -- -- -- -- -- -- ⊎ (Nothing (Unifies t₁ t₂) × mgu t₁ t₂ ≡ nothing)
-- -- -- -- -- -- -- -- -- -- -- -}
-- -- -- -- -- -- -- -- -- -- -- mgu-c : ∀ {m} (t₁ t₂ : 𝓣 m) →
-- -- -- -- -- -- -- -- -- -- -- (∃ λ n → ∃ λ σ → (Max (Unifies t₁ t₂)) (sub σ) × mgu t₁ t₂ ≡ just (n , σ))
-- -- -- -- -- -- -- -- -- -- -- ⊎ (Nothing (Unifies t₁ t₂) × mgu t₁ t₂ ≡ nothing)
-- -- -- -- -- -- -- -- -- -- -- {-
-- -- -- -- -- -- -- -- -- -- -- -- trivial substitution
-- -- -- -- -- -- -- -- -- -- -- -- ▹ : ∀ {s t} → (𝓥 s → 𝓥 t) → s ↦ t
-- -- -- -- -- -- -- -- -- -- -- ≐-cong : ∀ {m n o} {f : m ↦ n} {g} (h : _ ↦ o) → f ≐ g → (h ◇ f) ≐ (h ◇ g)
-- -- -- -- -- -- -- -- -- -- -- ≐-cong h f≐g t = cong (h ◃_) (f≐g t)
-- -- -- -- -- -- -- -- -- -- -- ≐-sym : ∀ {m n} {f : m ↦ n} {g} → f ≐ g → g ≐ f
-- -- -- -- -- -- -- -- -- -- -- ≐-sym f≐g = sym ∘ f≐g
-- -- -- -- -- -- -- -- -- -- -- -}
| {
"alphanum_fraction": 0.3473290323,
"avg_line_length": 44.1343963554,
"ext": "agda",
"hexsha": "cbc568e0dc48a1a4c67220165c6e4b77e5d5ceab",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-1/MGU.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-1/MGU.agda",
"max_line_length": 280,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-1/MGU.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 19490,
"size": 38750
} |
{-# OPTIONS --without-K --safe #-}
module Experiment.ListConstruction where
open import Level renaming (zero to lzero; suc to lsuc)
data ⊥ : Set where
record ⊤ : Set where
constructor tt
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
module Inductive where
data List (A : Set) : Set where
[] : List A
_∷_ : A → List A → List A
data Bool : Set where
true false : Bool
record Σ {a b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where
constructor _,_
field
fst : A
snd : B fst
∃ : ∀ {a b} {A : Set a} (B : A → Set b) → Set (a ⊔ b)
∃ {a} {b} {A} B = Σ A B
if : ∀ {p} {P : Bool → Set p} → ∀ b → P true → P false → P b
if true t e = t
if false t e = e
_⊎_ : (A B : Set) → Set
A ⊎ B = ∃ λ b → if b A B
inj₁ : {A B : Set} → A → A ⊎ B
inj₁ x = true , x
inj₂ : {A B : Set} → B → A ⊎ B
inj₂ x = false , x
⊎-elim : ∀ {p} {A B : Set} {P : A ⊎ B → Set p} →
(∀ x → P (inj₁ x)) → (∀ y → P (inj₂ y)) → ∀ s → P s
⊎-elim x y (true , snd) = x snd
⊎-elim x y (false , snd) = y snd
_×_ : (A B : Set) → Set
A × B = ∀ b → if b A B
proj₁ : {A B : Set} → A × B → A
proj₁ x = x true
proj₂ : {A B : Set} → A × B → B
proj₂ x = x false
Fin : ℕ → Set
Fin zero = ⊥
Fin (suc n) = ⊤ ⊎ Fin n
Vec : Set → ℕ → Set
Vec A n = Fin n → A
module VecList where
List : Set → Set
List A = ∃ λ n → Vec A n
| {
"alphanum_fraction": 0.5041888804,
"avg_line_length": 18.7571428571,
"ext": "agda",
"hexsha": "193575727fdad34b4b2885adb10305a1a8334162",
"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": "37200ea91d34a6603d395d8ac81294068303f577",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "rei1024/agda-misc",
"max_forks_repo_path": "Experiment/ListConstruction.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"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": "rei1024/agda-misc",
"max_issues_repo_path": "Experiment/ListConstruction.agda",
"max_line_length": 62,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "rei1024/agda-misc",
"max_stars_repo_path": "Experiment/ListConstruction.agda",
"max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z",
"num_tokens": 571,
"size": 1313
} |
module Cats.Ditrans where
open import Level using (Level ; _⊔_)
open import Cats.Category
open import Cats.Category.Setoids using (Setoids)
open import Cats.Profunctor
module _ {lo la l≈ lo′ la′ l≈′}
{C : Category lo la l≈} {D : Category lo′ la′ l≈′}
where
private
module C = Category C
open Category D
record Ditrans (F G : Profunctor C C D) : Set (lo ⊔ la ⊔ la′ ⊔ l≈′)
where
field
dicomponent : ∀ c → pobj F c c ⇒ pobj G c c
dinatural : ∀ {a b} (f : a C.⇒ b)
→ pmap₂ G f ∘ dicomponent a ∘ pmap₁ F f
≈ pmap₁ G f ∘ dicomponent b ∘ pmap₂ F f
| {
"alphanum_fraction": 0.605,
"avg_line_length": 23.0769230769,
"ext": "agda",
"hexsha": "c9e7cb4c12dfda89a22849a94c214857f5952a5b",
"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/Ditrans.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/Ditrans.agda",
"max_line_length": 69,
"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/Ditrans.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 225,
"size": 600
} |
-- {-# OPTIONS --sized-types #-} -- no longer necessary
-- {-# OPTIONS --termination-depth=2 #-} -- not necessary!
-- {-# OPTIONS -v tc.size.solve:60 --show-implicit #-}
-- {-# OPTIONS -v term:5 #-}
module Issue709 where
open import Common.Size
data Bool : Set where true false : Bool
postulate
A : Set
_<=_ : A → A → Bool
data List {i : Size} : Set where
[] : List
cons : (j : Size< i) → A → List {j} → List {i}
module If where
if_then_else_ : {A : Set} → Bool → A → A → A
if true then t else e = t
if false then t else e = e
merge : ∀ {i j} → List {i} → List {j} → List -- {∞}
merge {i} {j} [] ys = ys
merge {i} {j} (cons i' x xs) [] = cons _ x xs
merge {i} {j} (cons i' x xs) (cons j' y ys) =
if x <= y
then cons _ x (merge xs (cons _ y ys))
else cons _ y (merge (cons _ x xs) ys)
module Succeeds where
merge : ∀ {i j} → List {i} → List {j} → List
merge [] ys = ys
merge (cons i' x xs) [] = cons _ x xs
merge {i} {j} (cons i' x xs) (cons j' y ys) with x <= y
... | true = cons _ x (merge {i'} {j} -- removing this implicit application makes it not termination check
xs (cons _ y ys))
... | false = cons _ y (merge (cons _ x xs) ys)
module NeedsTerminationDepthTwo where
merge : ∀ {i j} → List {i} → List {j} → List
merge [] ys = ys
merge (cons j x xs) [] = cons _ x xs
merge {i} {i'} (cons j x xs) (cons j' y ys) with x <= y
... | true = cons _ x (merge xs (cons _ y ys))
... | false = cons _ y (merge (cons _ x xs) ys)
| {
"alphanum_fraction": 0.5171339564,
"avg_line_length": 30.8653846154,
"ext": "agda",
"hexsha": "4c7897b7a31eb39f8a126d81e44be51f9e83a518",
"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/Issue709.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue709.agda",
"max_line_length": 109,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue709.agda",
"max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z",
"num_tokens": 554,
"size": 1605
} |
-- Andreas and James, Nov 2011 and Oct 2012
-- {-# OPTIONS --no-coverage-check #-}
-- {-# OPTIONS -v tc.lhs:20 -v tc.cover.top:20 #-}
module FlexInterpreter where
open import Common.MAlonzo
data Ty : Set where
nat : Ty
arr : Ty -> Ty -> Ty
data Exp : Ty -> Set where
zero : Exp nat
suc : Exp (arr nat nat)
pred : Exp (arr nat nat)
app : {a b : Ty} -> Exp (arr a b) -> Exp a -> Exp b
data Nat : Set where
zero : Nat
suc : Nat -> Nat
Sem : Ty -> Set
Sem nat = Nat
Sem (arr a b) = Sem a -> Sem b
eval' : (a : Ty) -> Exp a -> Sem a
eval' ._ zero = zero
eval' ._ suc = suc
eval' b (app f e) = eval' _ f (eval' _ e)
eval' .(arr nat nat) pred zero = zero
eval' ._ pred (suc n) = n
eval : {a : Ty} -> Exp a -> Sem a
eval zero = zero
eval suc = suc
eval pred zero = zero
eval pred (suc n) = n
eval (app f e) = eval f (eval e)
main = mainDefault
| {
"alphanum_fraction": 0.5682074408,
"avg_line_length": 21.6341463415,
"ext": "agda",
"hexsha": "ebc7131ef1467f6280aa0ed5c92a45a12cc57f96",
"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/features/FlexInterpreter.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/features/FlexInterpreter.agda",
"max_line_length": 54,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "test/features/FlexInterpreter.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": 313,
"size": 887
} |
{-# OPTIONS --allow-unsolved-metas #-}
-- The option is supplied to force a real error to pass the regression test.
module MetaOccursInItself where
data List (A : Set) : Set where
nil : List A
_::_ : A -> List A -> List A
data One : Set where one : One
postulate
f : (A : Set) -> (A -> List A) -> One
err : One
err = f _ (\x -> x)
| {
"alphanum_fraction": 0.6151603499,
"avg_line_length": 20.1764705882,
"ext": "agda",
"hexsha": "95da253f5599f8e4af613877f0b6835db381a341",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dagit/agda",
"max_forks_repo_path": "test/fail/MetaOccursInItself.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dagit/agda",
"max_issues_repo_path": "test/fail/MetaOccursInItself.agda",
"max_line_length": 76,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dagit/agda",
"max_stars_repo_path": "test/fail/MetaOccursInItself.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T07:26:06.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T07:26:06.000Z",
"num_tokens": 107,
"size": 343
} |
module HelloWorldPrim where
open import IO.Primitive
open import Data.String
main = putStrLn (toCostring "Hello World!")
| {
"alphanum_fraction": 0.7967479675,
"avg_line_length": 17.5714285714,
"ext": "agda",
"hexsha": "c4257d6dc1c0777a3755927737fa1df31eb14919",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "test/Compiler/with-stdlib/HelloWorldPrim.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "redfish64/autonomic-agda",
"max_issues_repo_path": "test/Compiler/with-stdlib/HelloWorldPrim.agda",
"max_line_length": 43,
"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/Compiler/with-stdlib/HelloWorldPrim.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": 27,
"size": 123
} |
module Category.Monad.Either {i}(Exc : Set i)(I : Set i) where
open import Level hiding (lift)
open import Data.Sum
open import Category.Monad
open import Category.Monad.Predicate
open import Relation.Unary
open import Relation.Unary.PredicateTransformer
pattern left x = inj₁ x
pattern right x = inj₂ x
EitherT : Pt I i → Pt I i
EitherT M P = M (λ i → Exc ⊎ P i)
module EitherT {M : Pt I i}(Mon : RawPMonad {ℓ = i} M) where
private module Mon = RawPMonad Mon
-- right-biased sum
open RawPMonad
monad : RawPMonad {ℓ = i} (EitherT M)
return? monad px = Mon.return? (right px)
_=<?_ monad {P}{Q} f px = g Mon.=<? px
where
g : (λ i → Exc ⊎ P i) ⊆ EitherT M Q
g (left x) = Mon.return? (left x)
g (right y) = f y
_recoverWith_ : ∀ {P i} → EitherT M P i → (∀ {i} → Exc → EitherT M P i) → EitherT M P i
_recoverWith_ {P} c f = g Mon.=<? c
where
g : (λ i → Exc ⊎ P i) ⊆ EitherT M P
g (left x) = f x
g (right y) = Mon.return? (right y)
lift : ∀ {P} → M P ⊆ EitherT M P
lift x = (λ z → Mon.return? (right z)) Mon.=<? x
| {
"alphanum_fraction": 0.6020313943,
"avg_line_length": 26.4146341463,
"ext": "agda",
"hexsha": "53de0083cdd5203819b9c885bddd5d1d9603b3a2",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "metaborg/mj.agda",
"max_forks_repo_path": "src/Category/Monad/Either.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z",
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "metaborg/mj.agda",
"max_issues_repo_path": "src/Category/Monad/Either.agda",
"max_line_length": 89,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "metaborg/mj.agda",
"max_stars_repo_path": "src/Category/Monad/Either.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z",
"num_tokens": 392,
"size": 1083
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Kan.Duality where
open import Level
open import Categories.Category
open import Categories.Functor
open import Categories.NaturalTransformation
open import Categories.Kan
private
variable
o ℓ e : Level
C D E : Category o ℓ e
F G : Functor C D
module _ {F : Functor C D} {G : Functor C E} where
private
module F = Functor F
module G = Functor G
coLan⇒Ran : Lan F.op G.op → Ran F G
coLan⇒Ran lan = record
{ R = L.op
; ε = η.op
; δ = λ M α → NaturalTransformation.op (σ (Functor.op M) (NaturalTransformation.op α))
; δ-unique = λ δ′ eq → σ-unique (NaturalTransformation.op δ′) eq
; commutes = λ M α → commutes (Functor.op M) (NaturalTransformation.op α)
}
where open Lan lan
coRan⇒Lan : Ran F.op G.op → Lan F G
coRan⇒Lan ran = record
{ L = R.op
; η = ε.op
; σ = λ M α → NaturalTransformation.op (δ (Functor.op M) (NaturalTransformation.op α))
; σ-unique = λ σ′ eq → δ-unique (NaturalTransformation.op σ′) eq
; commutes = λ M α → commutes (Functor.op M) (NaturalTransformation.op α)
}
where open Ran ran
| {
"alphanum_fraction": 0.6243697479,
"avg_line_length": 28.3333333333,
"ext": "agda",
"hexsha": "9a113827d60576986f2e44e117cd9fb8bc33cbd7",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MirceaS/agda-categories",
"max_forks_repo_path": "src/Categories/Kan/Duality.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "MirceaS/agda-categories",
"max_issues_repo_path": "src/Categories/Kan/Duality.agda",
"max_line_length": 97,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MirceaS/agda-categories",
"max_stars_repo_path": "src/Categories/Kan/Duality.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 372,
"size": 1190
} |
open import Type
module Relator.ReflexiveTransitiveClosure {ℓ₁ ℓ₂} {T : Type{ℓ₁}} (_▫_ : T → T → Type{ℓ₂}) where
open import Graph.Walk
open import Graph.Walk.Proofs
import Lvl
open import Logic
open import Logic.Propositional
import Structure.Relator.Names as Names
open import Structure.Relator.Properties
open import Syntax.Function
-- Reflexive closure of a relation.
-- Constructs a reflexive relation from an existing relation.
-- Sometimes also notated ((_▫_) ∪ (_▫⁰_)) for a relation (_▫_).
data ReflexiveClosure : T → T → Type{ℓ₁ Lvl.⊔ ℓ₂} where
super : Names.Subrelation(_▫_)(ReflexiveClosure)
refl : Names.Reflexivity(ReflexiveClosure)
-- Symmetric closure of a relation.
-- Constructs a symmetric relation from an existing relation.
-- Sometimes also notated (_▫⁻¹_) or (Converse(_▫_) ∪ (_▫_)) for a relation (_▫_).
SymmetricClosure : T → T → Type{ℓ₂}
SymmetricClosure a b = (b ▫ a) ∨ (a ▫ b)
-- Reflexive-transitive closure of a relation.
-- Constructs a reflexive and transitive relation from an existing relation.
-- Sometimes also notated (_▫*_) for a relation (_▫_).
data ReflexiveTransitiveClosure : T → T → Type{ℓ₁ Lvl.⊔ ℓ₂} where
super : Names.Subrelation(_▫_)(ReflexiveTransitiveClosure)
refl : Names.Reflexivity(ReflexiveTransitiveClosure)
trans : Names.Transitivity(ReflexiveTransitiveClosure)
infixl 1000 trans
-- Transitive closure of a relation.
-- Constructs a transitive relation from an existing relation.
-- Sometimes also notated (_▫⁺_) for a relation (_▫_).
data TransitiveClosure : T → T → Type{ℓ₁ Lvl.⊔ ℓ₂} where
super : Names.Subrelation(_▫_)(TransitiveClosure)
trans : Names.Transitivity(TransitiveClosure)
module _ where
open import Numeral.Natural
-- Sometimes also notated (_▫ⁿ_) for a relation (_▫_).
data FiniteTransitiveClosure : ℕ → T → T → Type{ℓ₁ Lvl.⊔ ℓ₂} where
base : ∀{a} → (a ▫ a) → (FiniteTransitiveClosure 𝟎 a a)
step : ∀{a b c} → (a ▫ b) → ∀{n} → (FiniteTransitiveClosure n b c) → (FiniteTransitiveClosure (𝐒(n)) a c)
instance
ReflexiveTransitiveClosure-reflexivity : Reflexivity(ReflexiveTransitiveClosure)
ReflexiveTransitiveClosure-reflexivity = intro refl
instance
ReflexiveTransitiveClosure-transitivity : Transitivity(ReflexiveTransitiveClosure)
ReflexiveTransitiveClosure-transitivity = intro trans
-- The "prepend"-property of reflexive-transitive closure
ReflexiveTransitiveClosure-prepend : ∀{a b c} → (a ▫ b) → ReflexiveTransitiveClosure b c → ReflexiveTransitiveClosure a c
ReflexiveTransitiveClosure-prepend ab bc = trans (super ab) bc
-- A reflexive-transitive closure is the same as a path.
ReflexiveTransitiveClosure-Path-equivalence : ∀{a b} → (ReflexiveTransitiveClosure a b) ↔ (Walk(_▫_) a b)
ReflexiveTransitiveClosure-Path-equivalence = [↔]-intro l r where
r : ∀{a b} → ReflexiveTransitiveClosure a b → Walk(_▫_) a b
r ReflexiveTransitiveClosure.refl = reflexivity(Walk(_▫_))
r (ReflexiveTransitiveClosure.super ab) = sub₂(_▫_)(Walk(_▫_)) ab
r (ReflexiveTransitiveClosure.trans rab1 rb1b) = transitivity(Walk(_▫_)) (r rab1) (r rb1b)
l : ∀{a b} → Walk(_▫_) a b → ReflexiveTransitiveClosure a b
l Walk.at = ReflexiveTransitiveClosure.refl
l (Walk.prepend ab1 sb1b) = ReflexiveTransitiveClosure-prepend ab1 (l sb1b)
| {
"alphanum_fraction": 0.7381386861,
"avg_line_length": 44.4324324324,
"ext": "agda",
"hexsha": "6939d31b0c1d41cd0094013c1c942b7f22758744",
"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": "Relator/ReflexiveTransitiveClosure.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": "Relator/ReflexiveTransitiveClosure.agda",
"max_line_length": 121,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Relator/ReflexiveTransitiveClosure.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": 1019,
"size": 3288
} |
{-# OPTIONS --without-K #-}
open import HoTT
module homotopy.AnyUniversalCoverIsPathSet {i} (A : Type i)
-- (A-conn : is-connected 0 A)
where
open Cover
module _
(a₁ : A)
-- A universal covering (defined as being simply connected).
{j} (univ-cov : Cover A j)
(univ-cov-univ : is-universal univ-cov)
(a⇑₁ : Fiber univ-cov a₁)
where
private
-- One-to-one mapping between the universal cover
-- and the truncated path spaces from one point.
[path] : ∀ (a⇑₁ a⇑₂ : TotalSpace univ-cov) → a⇑₁ =₀ a⇑₂
[path] a⇑₁ a⇑₂ = –> (Trunc=-equiv [ a⇑₁ ] [ a⇑₂ ])
(contr-has-all-paths univ-cov-univ [ a⇑₁ ] [ a⇑₂ ])
[path]-has-all-paths :
∀ {a⇑₁ a⇑₂ : TotalSpace univ-cov}
→ has-all-paths (a⇑₁ =₀ a⇑₂)
[path]-has-all-paths {a⇑₁} {a⇑₂} =
coe (ap has-all-paths $ ua (Trunc=-equiv [ a⇑₁ ] [ a⇑₂ ]))
$ contr-has-all-paths (raise-level -2 univ-cov-univ [ a⇑₁ ] [ a⇑₂ ])
to : ∀ {a₂} → Fiber univ-cov a₂ → a₁ =₀ a₂
to {a₂} a⇑₂ = ap₀ fst ([path] (a₁ , a⇑₁) (a₂ , a⇑₂))
from : ∀ {a₂} → a₁ =₀ a₂ → Fiber univ-cov a₂
from p = cover-trace univ-cov a⇑₁ p
to-from : ∀ {a₂} (p : a₁ =₀ a₂) → to (from p) == p
to-from = Trunc-elim
(λ _ → =-preserves-set Trunc-level)
(λ p → lemma p)
where
lemma : ∀ {a₂} (p : a₁ == a₂) → to (from [ p ]) == [ p ]
lemma idp =
ap₀ fst ([path] (a₁ , a⇑₁) (a₁ , a⇑₁))
=⟨ ap (ap₀ fst)
$ [path]-has-all-paths
([path] (a₁ , a⇑₁) (a₁ , a⇑₁))
(idp₀ :> ((a₁ , a⇑₁) =₀ (a₁ , a⇑₁))) ⟩
(idp₀ :> (a₁ =₀ a₁))
∎
from-to : ∀ {a₂} (a⇑₂ : Fiber univ-cov a₂) → from (to a⇑₂) == a⇑₂
from-to {a₂} a⇑₂ = Trunc-elim
(λ p → =-preserves-set
{x = from (ap₀ fst p)}
{y = a⇑₂}
(Fiber-level univ-cov a₂))
(λ p → to-transp $ snd= p)
([path] (a₁ , a⇑₁) (a₂ , a⇑₂))
theorem : ∀ a₂ → Fiber univ-cov a₂ ≃ (a₁ =₀ a₂)
theorem a₂ = to , is-eq _ from to-from from-to
| {
"alphanum_fraction": 0.4688816097,
"avg_line_length": 32.3787878788,
"ext": "agda",
"hexsha": "179dd850c42e5b8458411f4467a35d22e41b6de1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cmknapp/HoTT-Agda",
"max_forks_repo_path": "theorems/homotopy/AnyUniversalCoverIsPathSet.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cmknapp/HoTT-Agda",
"max_issues_repo_path": "theorems/homotopy/AnyUniversalCoverIsPathSet.agda",
"max_line_length": 76,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cmknapp/HoTT-Agda",
"max_stars_repo_path": "theorems/homotopy/AnyUniversalCoverIsPathSet.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 887,
"size": 2137
} |
open import Nat
open import Prelude
open import core
open import contexts
open import synth-unicity
open import lemmas-matching
module elaboration-unicity where
mutual
elaboration-unicity-synth : {Γ : tctx} {e : hexp} {τ1 τ2 : htyp} {d1 d2 : ihexp} {Δ1 Δ2 : hctx} →
Γ ⊢ e ⇒ τ1 ~> d1 ⊣ Δ1 →
Γ ⊢ e ⇒ τ2 ~> d2 ⊣ Δ2 →
τ1 == τ2 × d1 == d2 × Δ1 == Δ2
elaboration-unicity-synth ESConst ESConst = refl , refl , refl
elaboration-unicity-synth (ESVar {Γ = Γ} x₁) (ESVar x₂) = ctxunicity {Γ = Γ} x₁ x₂ , refl , refl
elaboration-unicity-synth (ESLam apt1 d1) (ESLam apt2 d2)
with elaboration-unicity-synth d1 d2
... | ih1 , ih2 , ih3 = ap1 _ ih1 , ap1 _ ih2 , ih3
elaboration-unicity-synth (ESAp _ _ x x₁ x₂ x₃) (ESAp _ _ x₄ x₅ x₆ x₇)
with synthunicity x x₄
... | refl with match-unicity x₁ x₅
... | refl with elaboration-unicity-ana x₂ x₆
... | refl , refl , refl with elaboration-unicity-ana x₃ x₇
... | refl , refl , refl = refl , refl , refl
elaboration-unicity-synth ESEHole ESEHole = refl , refl , refl
elaboration-unicity-synth (ESNEHole _ d1) (ESNEHole _ d2)
with elaboration-unicity-synth d1 d2
... | ih1 , ih2 , ih3 = refl , ap1 _ ih2 , ap1 _ ih3
elaboration-unicity-synth (ESAsc x) (ESAsc x₁)
with elaboration-unicity-ana x x₁
... | refl , refl , refl = refl , refl , refl
elaboration-unicity-ana : {Γ : tctx} {e : hexp} {τ τ1 τ2 : htyp} {d1 d2 : ihexp} {Δ1 Δ2 : hctx} →
Γ ⊢ e ⇐ τ ~> d1 :: τ1 ⊣ Δ1 →
Γ ⊢ e ⇐ τ ~> d2 :: τ2 ⊣ Δ2 →
d1 == d2 × τ1 == τ2 × Δ1 == Δ2
elaboration-unicity-ana (EALam x₁ m D1) (EALam x₂ m2 D2)
with match-unicity m m2
... | refl with elaboration-unicity-ana D1 D2
... | refl , refl , refl = refl , refl , refl
elaboration-unicity-ana (EALam x₁ m D1) (EASubsume x₂ x₃ () x₅)
elaboration-unicity-ana (EASubsume x₁ x₂ () x₄) (EALam x₅ m D2)
elaboration-unicity-ana (EASubsume x x₁ x₂ x₃) (EASubsume x₄ x₅ x₆ x₇)
with elaboration-unicity-synth x₂ x₆
... | refl , refl , refl = refl , refl , refl
elaboration-unicity-ana (EASubsume x x₁ x₂ x₃) EAEHole = abort (x _ refl)
elaboration-unicity-ana (EASubsume x x₁ x₂ x₃) (EANEHole _ x₄) = abort (x₁ _ _ refl)
elaboration-unicity-ana EAEHole (EASubsume x x₁ x₂ x₃) = abort (x _ refl)
elaboration-unicity-ana EAEHole EAEHole = refl , refl , refl
elaboration-unicity-ana (EANEHole _ x) (EASubsume x₁ x₂ x₃ x₄) = abort (x₂ _ _ refl)
elaboration-unicity-ana (EANEHole _ x) (EANEHole _ x₁)
with elaboration-unicity-synth x x₁
... | refl , refl , refl = refl , refl , refl
| {
"alphanum_fraction": 0.5996376812,
"avg_line_length": 51.1111111111,
"ext": "agda",
"hexsha": "be64eee865a33af4e90c09a9b07c6cd4a4c9f505",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-09-13T18:20:02.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-09-13T18:20:02.000Z",
"max_forks_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hazelgrove/hazelnut-dynamics-agda",
"max_forks_repo_path": "elaboration-unicity.agda",
"max_issues_count": 54,
"max_issues_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c",
"max_issues_repo_issues_event_max_datetime": "2018-11-29T16:32:40.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-06-29T20:53:34.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "hazelgrove/hazelnut-dynamics-agda",
"max_issues_repo_path": "elaboration-unicity.agda",
"max_line_length": 101,
"max_stars_count": 16,
"max_stars_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hazelgrove/hazelnut-dynamics-agda",
"max_stars_repo_path": "elaboration-unicity.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-19T02:50:23.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-03-12T14:32:03.000Z",
"num_tokens": 1079,
"size": 2760
} |
module Esterel.Lang where
open import Esterel.Environment as Env
using (Env)
open import Esterel.Variable.Signal as Signal
using (Signal)
open import Esterel.Variable.Shared as SharedVar
using (SharedVar)
open import Esterel.Variable.Sequential as SeqVar
using (SeqVar)
open import Data.List
using (List)
open import Data.Nat as Nat
using (ℕ)
data s/l : Set where
num : ℕ → s/l
seq-ref : (x : SeqVar) → s/l
shr-ref : (s : SharedVar) → s/l
data Expr : Set where
plus : List s/l → Expr
data Ctrl : Set where
GO : Ctrl
WAIT : Ctrl
data Term : Set where
nothin : Term
pause : Term
signl : (S : Signal) → (p : Term) → Term
present_∣⇒_∣⇒_ : (S : Signal) → (p : Term) → (q : Term) → Term
emit : (S : Signal) → Term
_∥_ : (p : Term) → (q : Term) → Term
loop : (p : Term) → Term
loopˢ : (p : Term) → (q : Term) → Term
_>>_ : (p : Term) → (q : Term) → Term
suspend : (p : Term) → (S : Signal) → Term
trap : (p : Term) → Term
exit : (n : ℕ) → Term
shared_≔_in:_ : (s : SharedVar) → (e : Expr) → (p : Term) → Term
_⇐_ : (s : SharedVar) → (e : Expr) → Term
var_≔_in:_ : (x : SeqVar) → (e : Expr) → (p : Term) → Term
_≔_ : (x : SeqVar) → (e : Expr) → Term
if_∣⇒_∣⇒_ : (x : SeqVar) → (p : Term) → (q : Term) → Term
ρ⟨_,_⟩·_ : (θ : Env) → (A : Ctrl) → (p : Term) → Term
infix 20 _⇐_
infix 20 _≔_
infix 17 if_∣⇒_∣⇒_
infixr 15 _>>_
infixr 13 _∥_
infix 11 present_∣⇒_∣⇒_
infix 10 shared_≔_in:_
infix 10 var_≔_in:_
infix 6 ρ⟨_,_⟩·_
| {
"alphanum_fraction": 0.5303867403,
"avg_line_length": 28.0862068966,
"ext": "agda",
"hexsha": "936163ba05c7aaa7049d888e418eadf7abc594ee",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z",
"max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "florence/esterel-calculus",
"max_forks_repo_path": "agda/Esterel/Lang.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "florence/esterel-calculus",
"max_issues_repo_path": "agda/Esterel/Lang.agda",
"max_line_length": 67,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "florence/esterel-calculus",
"max_stars_repo_path": "agda/Esterel/Lang.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z",
"num_tokens": 660,
"size": 1629
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Lists where every pair of elements are related (symmetrically)
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary using (Rel)
module Data.List.Relation.Unary.AllPairs
{a ℓ} {A : Set a} {R : Rel A ℓ} where
open import Data.List.Base using (List; []; _∷_)
open import Data.List.Relation.Unary.All as All using (All; []; _∷_)
open import Data.Product as Prod using (_,_; _×_; uncurry; <_,_>)
open import Function using (id; _∘_)
open import Level using (_⊔_)
open import Relation.Binary as B using (Rel; _⇒_)
open import Relation.Binary.Construct.Intersection renaming (_∩_ to _∩ᵇ_)
open import Relation.Binary.PropositionalEquality
open import Relation.Unary as U renaming (_∩_ to _∩ᵘ_) hiding (_⇒_)
open import Relation.Nullary using (yes; no)
import Relation.Nullary.Decidable as Dec
open import Relation.Nullary.Product using (_×-dec_)
------------------------------------------------------------------------
-- Definition
open import Data.List.Relation.Unary.AllPairs.Core public
------------------------------------------------------------------------
-- Operations
head : ∀ {x xs} → AllPairs R (x ∷ xs) → All (R x) xs
head (px ∷ pxs) = px
tail : ∀ {x xs} → AllPairs R (x ∷ xs) → AllPairs R xs
tail (px ∷ pxs) = pxs
uncons : ∀ {x xs} → AllPairs R (x ∷ xs) → All (R x) xs × AllPairs R xs
uncons = < head , tail >
module _ {q} {S : Rel A q} where
map : R ⇒ S → AllPairs R ⊆ AllPairs S
map ~₁⇒~₂ [] = []
map ~₁⇒~₂ (x~xs ∷ pxs) = All.map ~₁⇒~₂ x~xs ∷ (map ~₁⇒~₂ pxs)
module _ {s t} {S : Rel A s} {T : Rel A t} where
zipWith : R ∩ᵇ S ⇒ T → AllPairs R ∩ᵘ AllPairs S ⊆ AllPairs T
zipWith f ([] , []) = []
zipWith f (px ∷ pxs , qx ∷ qxs) = All.zipWith f (px , qx) ∷ zipWith f (pxs , qxs)
unzipWith : T ⇒ R ∩ᵇ S → AllPairs T ⊆ AllPairs R ∩ᵘ AllPairs S
unzipWith f [] = [] , []
unzipWith f (rx ∷ rxs) = Prod.zip _∷_ _∷_ (All.unzipWith f rx) (unzipWith f rxs)
module _ {s} {S : Rel A s} where
zip : AllPairs R ∩ᵘ AllPairs S ⊆ AllPairs (R ∩ᵇ S)
zip = zipWith id
unzip : AllPairs (R ∩ᵇ S) ⊆ AllPairs R ∩ᵘ AllPairs S
unzip = unzipWith id
------------------------------------------------------------------------
-- Properties of predicates preserved by AllPairs
allPairs? : B.Decidable R → U.Decidable (AllPairs R)
allPairs? R? [] = yes []
allPairs? R? (x ∷ xs) =
Dec.map′ (uncurry _∷_) uncons (All.all (R? x) xs ×-dec allPairs? R? xs)
irrelevant : B.Irrelevant R → U.Irrelevant (AllPairs R)
irrelevant irr [] [] = refl
irrelevant irr (px₁ ∷ pxs₁) (px₂ ∷ pxs₂) =
cong₂ _∷_ (All.irrelevant irr px₁ px₂) (irrelevant irr pxs₁ pxs₂)
satisfiable : U.Satisfiable (AllPairs R)
satisfiable = [] , []
| {
"alphanum_fraction": 0.5566365532,
"avg_line_length": 34.6746987952,
"ext": "agda",
"hexsha": "31d0b7fb9d7a9680187d82108ac74af9cbca9a60",
"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/List/Relation/Unary/AllPairs.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/List/Relation/Unary/AllPairs.agda",
"max_line_length": 83,
"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/List/Relation/Unary/AllPairs.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": 917,
"size": 2878
} |
------------------------------------------------------------------------------
-- From inductive PA to standard axiomatic PA
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- From the definition of PA using Agda data types and primitive
-- recursive functions for addition and multiplication, we can prove
-- the following axioms (see (Machover 1996, p. 263) and (Hájek and
-- Pudlák 1998, p. 28)):
-- PA₁. 0 ≠ n'
-- PA₂. m' = n' → m = n
-- PA₃. 0 + n = n
-- PA₄. m' + n = (m + n)'
-- PA₅. 0 * n = 0
-- PA₆. m' * n = n + (m * n)
-- Axiom of induction:
-- φ(0) → (∀n.φ(n) → φ(succ n)) → ∀n.φ(n), for any formulae φ
module PA.Inductive2Standard where
open import PA.Inductive.Base
------------------------------------------------------------------------------
PA₁ : ∀ {n} → zero ≢ succ n
PA₁ ()
PA₂ : ∀ {m n} → succ m ≡ succ n → m ≡ n
PA₂ refl = refl
PA₃ : ∀ n → zero + n ≡ n
PA₃ n = refl
PA₄ : ∀ m n → succ m + n ≡ succ (m + n)
PA₄ m n = refl
PA₅ : ∀ n → zero * n ≡ zero
PA₅ n = refl
PA₆ : ∀ m n → succ m * n ≡ n + m * n
PA₆ m n = refl
------------------------------------------------------------------------------
-- References
--
-- Machover, Moshé (1996). Set theory, Logic and their
-- Limitations. Cambridge University Press.
-- Hájek, Petr and Pudlák, Pavel (1998). Metamathematics of
-- First-Order Arithmetic. 2nd printing. Springer.
| {
"alphanum_fraction": 0.4637588198,
"avg_line_length": 27.8392857143,
"ext": "agda",
"hexsha": "0e4db7bc658d94b562b4637c43e8c90711b2cefe",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "src/fot/PA/Inductive2Standard.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "src/fot/PA/Inductive2Standard.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "src/fot/PA/Inductive2Standard.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": 466,
"size": 1559
} |
{-# OPTIONS --without-K --safe #-}
open import Level
open import Categories.Category using (Category)
module Categories.NaturalTransformation.Hom {o ℓ e : Level} (C : Category o ℓ e) where
-- open import Function using (_$_; Inverse) -- else there's a conflict with the import below
-- open import Function.Equality using (Π; _⟨$⟩_; cong)
-- open import Relation.Binary using (module Setoid)
-- import Relation.Binary.Reasoning.Setoid as SetoidR
-- open import Data.Product using (_,_; Σ)
-- open import Categories.Category.Product
-- open import Categories.Category.Construction.Presheaves
-- open import Categories.Category.Construction.Functors
open import Categories.Category.Instance.Setoids
-- open import Categories.Functor renaming (id to idF)
open import Categories.Functor.Hom using (module Hom; Hom[_][-,_]; Hom[_][-,-])
-- open import Categories.Functor.Bifunctor
-- open import Categories.Functor.Presheaf
-- open import Categories.Functor.Construction.LiftSetoids
open import Categories.NaturalTransformation using (NaturalTransformation; ntHelper) renaming (id to idN)
-- open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism)
-- import Categories.Morphism as Mor
import Categories.Morphism.Reasoning as MR
open Category C
open HomReasoning
open MR C
open NaturalTransformation
private
module CE = Category.Equiv C
module C = Category C
Hom[A,C]⇒Hom[B,C] : {A B : Obj} → (A ⇒ B) → NaturalTransformation Hom[ C ][-, A ] Hom[ C ][-, B ]
Hom[A,C]⇒Hom[B,C] {A} A⇒B = ntHelper record
{ η = λ X → record { _⟨$⟩_ = λ X⇒A → A⇒B ∘ X⇒A ; cong = ∘-resp-≈ʳ }
; commute = λ f {g} {h} g≈h → begin
A⇒B ∘ id ∘ g ∘ f ≈˘⟨ assoc ⟩
(A⇒B ∘ id) ∘ g ∘ f ≈⟨ id-comm ⟩∘⟨ g≈h ⟩∘⟨refl ⟩
(id ∘ A⇒B) ∘ h ∘ f ≈⟨ assoc ○ ⟺ (∘-resp-≈ʳ assoc) ⟩ -- TODO: MR.Reassociate
id ∘ (A⇒B ∘ h) ∘ f ∎
}
| {
"alphanum_fraction": 0.6942949408,
"avg_line_length": 41.2888888889,
"ext": "agda",
"hexsha": "c664f5fe73f7ad53cbcf741495ab446a8d6ee5d3",
"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": "6ebc1349ee79669c5c496dcadd551d5bbefd1972",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Taneb/agda-categories",
"max_forks_repo_path": "Categories/NaturalTransformation/Hom.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Taneb/agda-categories",
"max_issues_repo_path": "Categories/NaturalTransformation/Hom.agda",
"max_line_length": 105,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Taneb/agda-categories",
"max_stars_repo_path": "Categories/NaturalTransformation/Hom.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 603,
"size": 1858
} |
open import Relation.Binary.Core
module BBHeap.Push.Properties {A : Set}
(_≤_ : A → A → Set)
(tot≤ : Total _≤_)
(trans≤ : Transitive _≤_) where
open import BBHeap _≤_
open import BBHeap.Equality.Properties _≤_
open import BBHeap.Push _≤_ tot≤ trans≤
open import Bound.Lower A
open import Bound.Lower.Order _≤_
open import Data.Nat
open import Data.List
open import Data.Sum
open import List.Permutation.Base A
open import List.Permutation.Base.Concatenation A
open import List.Permutation.Base.Equivalence A
open import Order.Total _≤_ tot≤
mutual
lemma-push⋘# : {b : Bound}{x y : A}{l r : BBHeap (val y)}(b≤x : LeB b (val x))(b≤y : LeB b (val y))(l⋘r : l ⋘ r) → # (push⋘ b≤x b≤y l⋘r) ≡ suc (# l + # r)
lemma-push⋘# b≤x _ lf⋘ = refl
lemma-push⋘# {x = x} b≤x b≤y (ll⋘ {x = y₁} {x' = y₂} y≤y₁ y≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂)
with tot≤ y₁ y₂ | tot≤ x y₁ | tot≤ x y₂
... | inj₁ y₁≤y₂ | inj₁ x≤y₁ | _ = refl
... | inj₂ y₂≤y₁ | _ | inj₁ x≤y₂ = refl
... | inj₁ y₁≤y₂ | inj₂ y₁≤x | _
with # (push⋘ (lexy y₁≤x) (lexy refl≤) l₁⋘r₁) | lemma-push⋘# (lexy y₁≤x) (lexy refl≤) l₁⋘r₁
... | ._ | refl = refl
lemma-push⋘# b≤x b≤y (ll⋘ y≤y₁ y≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂) | inj₂ y₂≤y₁ | _ | inj₂ y₂≤x
with # (push⋘ (lexy y₂≤x) (lexy refl≤) l₂⋘r₂) | lemma-push⋘# (lexy y₂≤x) (lexy refl≤) l₂⋘r₂
... | ._ | refl = refl
lemma-push⋘# {x = x} b≤x b≤y (lr⋘ {x = y₁} {x' = y₂} y≤y₁ y≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂)
with tot≤ y₁ y₂ | tot≤ x y₁ | tot≤ x y₂
... | inj₁ y₁≤y₂ | inj₁ x≤y₁ | _ = refl
... | inj₂ y₂≤y₁ | _ | inj₁ x≤y₂ = refl
... | inj₁ y₁≤y₂ | inj₂ y₁≤x | _
with # (push⋙ (lexy y₁≤x) (lexy refl≤) l₁⋙r₁) | lemma-push⋙# (lexy y₁≤x) (lexy refl≤) l₁⋙r₁
... | ._ | refl = refl
lemma-push⋘# b≤x b≤y (lr⋘ y≤y₁ y≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂) | inj₂ y₂≤y₁ | _ | inj₂ y₂≤x
with # (push⋘ (lexy y₂≤x) (lexy refl≤) l₂⋘r₂) | lemma-push⋘# (lexy y₂≤x) (lexy refl≤) l₂⋘r₂
... | ._ | refl = refl
lemma-push⋙# : {b : Bound}{x y : A}{l r : BBHeap (val y)}(b≤x : LeB b (val x))(b≤y : LeB b (val y))(l⋙r : l ⋙ r) → # (push⋙ b≤x b≤y l⋙r) ≡ suc (# l + # r)
lemma-push⋙# {x = x} b≤x b≤y (⋙lf {x = z} y≤z)
with tot≤ x z
... | inj₁ x≤z = refl
... | inj₂ z≤x = refl
lemma-push⋙# {x = x} b≤x b≤y (⋙rl {x = y₁} {x' = y₂} y≤y₁ y≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂)
with tot≤ y₁ y₂ | tot≤ x y₁ | tot≤ x y₂
... | inj₁ y₁≤y₂ | inj₁ x≤y₁ | _ = refl
... | inj₂ y₂≤y₁ | _ | inj₁ x≤y₂ = refl
... | inj₁ y₁≤y₂ | inj₂ y₁≤x | _
with # (push⋘ (lexy y₁≤x) (lexy refl≤) l₁⋘r₁) | lemma-push⋘# (lexy y₁≤x) (lexy refl≤) l₁⋘r₁
... | ._ | refl = refl
lemma-push⋙# b≤x b≤y (⋙rl y≤y₁ y≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂) | inj₂ y₂≤y₁ | _ | inj₂ y₂≤x
with # (push⋘ (lexy y₂≤x) (lexy refl≤) l₂⋘r₂) | lemma-push⋘# (lexy y₂≤x) (lexy refl≤) l₂⋘r₂
... | ._ | refl = refl
lemma-push⋙# {x = x} b≤x b≤y (⋙rr {x = y₁} {x' = y₂} y≤y₁ y≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂)
with tot≤ y₁ y₂ | tot≤ x y₁ | tot≤ x y₂
... | inj₁ y₁≤y₂ | inj₁ x≤y₁ | _ = refl
... | inj₂ y₂≤y₁ | _ | inj₁ x≤y₂ = refl
... | inj₁ y₁≤y₂ | inj₂ y₁≤x | _
with # (push⋘ (lexy y₁≤x) (lexy refl≤) l₁⋘r₁) | lemma-push⋘# (lexy y₁≤x) (lexy refl≤) l₁⋘r₁
... | ._ | refl = refl
lemma-push⋙# b≤x b≤y (⋙rr y≤y₁ y≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂) | inj₂ y₂≤y₁ | _ | inj₂ y₂≤x
with # (push⋙ (lexy y₂≤x) (lexy refl≤) l₂⋙r₂) | lemma-push⋙# (lexy y₂≤x) (lexy refl≤) l₂⋙r₂
... | ._ | refl = refl
lemma-push# : {b : Bound}{x : A}(b≤x : LeB b (val x))(h : BBHeap b) → # (push b≤x h) ≡ # h
lemma-push# b≤x leaf = refl
lemma-push# b≤x (left b≤y l⋘r) = lemma-push⋘# b≤x b≤y l⋘r
lemma-push# b≤x (right b≤y l⋙r) = lemma-push⋙# b≤x b≤y l⋙r
mutual
lemma-push⋘∼ : {b : Bound}{x y : A}{l r : BBHeap (val y)}(b≤x : LeB b (val x))(b≤y : LeB b (val y))(l⋘r : l ⋘ r) → flatten (push⋘ b≤x b≤y l⋘r) ∼ (x ∷ (flatten l ++ flatten r))
lemma-push⋘∼ b≤x _ lf⋘ = ∼x /head /head ∼[]
lemma-push⋘∼ {x = x} b≤x b≤y (ll⋘ {x = y₁} {x' = y₂} y≤y₁ y≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂)
with tot≤ y₁ y₂ | tot≤ x y₁ | tot≤ x y₂
... | inj₁ y₁≤y₂ | inj₁ x≤y₁ | _ = refl∼
... | inj₁ y₁≤y₂ | inj₂ y₁≤x | _ =
let pl'∼xfl₁fr₁ = lemma-push⋘∼ (lexy y₁≤x) (lexy refl≤) l₁⋘r₁ ;
fpl'fr'∼xfl₁fr₁fr' = lemma++∼r pl'∼xfl₁fr₁
in ∼x /head (/tail /head) fpl'fr'∼xfl₁fr₁fr'
... | inj₂ y₂≤y₁ | _ | inj₁ x≤y₂ = refl∼
... | inj₂ y₂≤y₁ | _ | inj₂ y₂≤x =
let pr'∼xfl₂fr₂ = lemma-push⋘∼ (lexy y₂≤x) (lexy refl≤) l₂⋘r₂ ;
fl' = flatten (left (lexy y₂≤y₁) l₁⋘r₁) ;
fl'fpr'∼fl'xfl₂fr₂ = lemma++∼l {xs = fl'} pr'∼xfl₂fr₂ ;
xfl'fr'/y₂⟶xfl'fl₂fr₂ = lemma++/l {xs = x ∷ fl'} /head ;
fl'xfl₂fr₂/x⟶fl'fl₂fr₂ = lemma++/ {xs = fl'};
fl'xfl₂fr₂∼xfl'fl₂fr₂ = ∼x fl'xfl₂fr₂/x⟶fl'fl₂fr₂ /head refl∼ ;
fl'fpr'∼xfl'fl₂fr₂ = trans∼ fl'fpr'∼fl'xfl₂fr₂ fl'xfl₂fr₂∼xfl'fl₂fr₂
in ∼x /head xfl'fr'/y₂⟶xfl'fl₂fr₂ fl'fpr'∼xfl'fl₂fr₂
lemma-push⋘∼ {x = x} b≤x b≤y (lr⋘ {x = y₁} {x' = y₂} y≤y₁ y≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂)
with tot≤ y₁ y₂ | tot≤ x y₁ | tot≤ x y₂
... | inj₁ y₁≤y₂ | inj₁ x≤y₁ | _ = refl∼
... | inj₁ y₁≤y₂ | inj₂ y₁≤x | _ =
let pl'∼xfl₁fr₁ = lemma-push⋙∼ (lexy y₁≤x) (lexy refl≤) l₁⋙r₁ ;
fpl'fr'∼xfl₁fr₁fr' = lemma++∼r pl'∼xfl₁fr₁
in ∼x /head (/tail /head) fpl'fr'∼xfl₁fr₁fr'
... | inj₂ y₂≤y₁ | _ | inj₁ x≤y₂ = refl∼
... | inj₂ y₂≤y₁ | _ | inj₂ y₂≤x =
let pr'∼xfl₂fr₂ = lemma-push⋘∼ (lexy y₂≤x) (lexy refl≤) l₂⋘r₂ ;
fl' = flatten (right (lexy y₂≤y₁) l₁⋙r₁) ;
fl'fpr'∼fl'xfl₂fr₂ = lemma++∼l {xs = fl'} pr'∼xfl₂fr₂ ;
xfl'fr'/y₂⟶xfl'fl₂fr₂ = lemma++/l {xs = x ∷ fl'} /head ;
fl'xfl₂fr₂/x⟶fl'fl₂fr₂ = lemma++/ {xs = fl'};
fl'xfl₂fr₂∼xfl'fl₂fr₂ = ∼x fl'xfl₂fr₂/x⟶fl'fl₂fr₂ /head refl∼ ;
fl'fpr'∼xfl'fl₂fr₂ = trans∼ fl'fpr'∼fl'xfl₂fr₂ fl'xfl₂fr₂∼xfl'fl₂fr₂
in ∼x /head xfl'fr'/y₂⟶xfl'fl₂fr₂ fl'fpr'∼xfl'fl₂fr₂
lemma-push⋙∼ : {b : Bound}{x y : A}{l r : BBHeap (val y)}(b≤x : LeB b (val x))(b≤y : LeB b (val y))(l⋙r : l ⋙ r) → flatten (push⋙ b≤x b≤y l⋙r) ∼ (x ∷ (flatten l ++ flatten r))
lemma-push⋙∼ {x = x} b≤x b≤y (⋙lf {x = z} y≤z)
with tot≤ x z
... | inj₁ x≤z = ∼x /head /head (∼x /head /head ∼[])
... | inj₂ z≤x = ∼x (/tail /head) /head (∼x /head /head ∼[])
lemma-push⋙∼ {x = x} b≤x b≤y (⋙rl {x = y₁} {x' = y₂} y≤y₁ y≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂)
with tot≤ y₁ y₂ | tot≤ x y₁ | tot≤ x y₂
... | inj₁ y₁≤y₂ | inj₁ x≤y₁ | _ = refl∼
... | inj₁ y₁≤y₂ | inj₂ y₁≤x | _ =
let pl'∼xfl₁fr₁ = lemma-push⋘∼ (lexy y₁≤x) (lexy refl≤) l₁⋘r₁ ;
fpl'fr'∼xfl₁fr₁fr' = lemma++∼r pl'∼xfl₁fr₁
in ∼x /head (/tail /head) fpl'fr'∼xfl₁fr₁fr'
... | inj₂ y₂≤y₁ | _ | inj₁ x≤y₂ = refl∼
... | inj₂ y₂≤y₁ | _ | inj₂ y₂≤x =
let pr'∼xfl₂fr₂ = lemma-push⋘∼ (lexy y₂≤x) (lexy refl≤) l₂⋘r₂ ;
fl' = flatten (left (lexy y₂≤y₁) l₁⋘r₁) ;
fl'fpr'∼fl'xfl₂fr₂ = lemma++∼l {xs = fl'} pr'∼xfl₂fr₂ ;
xfl'fr'/y₂⟶xfl'fl₂fr₂ = lemma++/l {xs = x ∷ fl'} /head ;
fl'xfl₂fr₂/x⟶fl'fl₂fr₂ = lemma++/ {xs = fl'};
fl'xfl₂fr₂∼xfl'fl₂fr₂ = ∼x fl'xfl₂fr₂/x⟶fl'fl₂fr₂ /head refl∼ ;
fl'fpr'∼xfl'fl₂fr₂ = trans∼ fl'fpr'∼fl'xfl₂fr₂ fl'xfl₂fr₂∼xfl'fl₂fr₂
in ∼x /head xfl'fr'/y₂⟶xfl'fl₂fr₂ fl'fpr'∼xfl'fl₂fr₂
lemma-push⋙∼ {x = x} b≤x b≤y (⋙rr {x = y₁} {x' = y₂} y≤y₁ y≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂)
with tot≤ y₁ y₂ | tot≤ x y₁ | tot≤ x y₂
... | inj₁ y₁≤y₂ | inj₁ x≤y₁ | _ = refl∼
... | inj₁ y₁≤y₂ | inj₂ y₁≤x | _ =
let pl'∼xfl₁fr₁ = lemma-push⋘∼ (lexy y₁≤x) (lexy refl≤) l₁⋘r₁ ;
fpl'fr'∼xfl₁fr₁fr' = lemma++∼r pl'∼xfl₁fr₁
in ∼x /head (/tail /head) fpl'fr'∼xfl₁fr₁fr'
... | inj₂ y₂≤y₁ | _ | inj₁ x≤y₂ = refl∼
... | inj₂ y₂≤y₁ | _ | inj₂ y₂≤x =
let pr'∼xfl₂fr₂ = lemma-push⋙∼ (lexy y₂≤x) (lexy refl≤) l₂⋙r₂ ;
fl' = flatten (left (lexy y₂≤y₁) l₁⋘r₁) ;
fl'fpr'∼fl'xfl₂fr₂ = lemma++∼l {xs = fl'} pr'∼xfl₂fr₂ ;
xfl'fr'/y₂⟶xfl'fl₂fr₂ = lemma++/l {xs = x ∷ fl'} /head ;
fl'xfl₂fr₂/x⟶fl'fl₂fr₂ = lemma++/ {xs = fl'};
fl'xfl₂fr₂∼xfl'fl₂fr₂ = ∼x fl'xfl₂fr₂/x⟶fl'fl₂fr₂ /head refl∼ ;
fl'fpr'∼xfl'fl₂fr₂ = trans∼ fl'fpr'∼fl'xfl₂fr₂ fl'xfl₂fr₂∼xfl'fl₂fr₂
in ∼x /head xfl'fr'/y₂⟶xfl'fl₂fr₂ fl'fpr'∼xfl'fl₂fr₂
| {
"alphanum_fraction": 0.4932417211,
"avg_line_length": 58.0261437908,
"ext": "agda",
"hexsha": "8dbbde121c2314fec1e5e7b176c2737c6294b7a9",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bgbianchi/sorting",
"max_forks_repo_path": "agda/BBHeap/Push/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bgbianchi/sorting",
"max_issues_repo_path": "agda/BBHeap/Push/Properties.agda",
"max_line_length": 177,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bgbianchi/sorting",
"max_stars_repo_path": "agda/BBHeap/Push/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z",
"num_tokens": 4855,
"size": 8878
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020, 2021 Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Prelude
open import LibraBFT.Lemmas
open import LibraBFT.Abstract.Types.EpochConfig
open WithAbsVote
-- Here we establish the properties necessary to achieve consensus
-- just like we see them on paper: stating facts about the state of
-- the system and reasoning about which QC's exist in the system.
-- This module is a stepping stone to the properties we want;
-- you should probably not be importing it directly, see 'LibraBFT.Abstract.Properties'
-- instead.
--
-- The module 'LibraBFT.Abstract.Properties' proves that the invariants
-- presented here can be obtained from reasoning about sent votes,
-- which provides a much easier-to-prove interface to an implementation.
module LibraBFT.Abstract.RecordChain.Assumptions
(UID : Set)
(_≟UID_ : (u₀ u₁ : UID) → Dec (u₀ ≡ u₁))
(NodeId : Set)
(𝓔 : EpochConfig UID NodeId)
(𝓥 : VoteEvidence UID NodeId 𝓔)
where
open import LibraBFT.Abstract.Types UID NodeId 𝓔
open import LibraBFT.Abstract.System UID _≟UID_ NodeId 𝓔 𝓥
open import LibraBFT.Abstract.Records UID _≟UID_ NodeId 𝓔 𝓥
open import LibraBFT.Abstract.Records.Extends UID _≟UID_ NodeId 𝓔 𝓥
open import LibraBFT.Abstract.RecordChain UID _≟UID_ NodeId 𝓔 𝓥
open EpochConfig 𝓔
module _ {ℓ}(InSys : Record → Set ℓ) where
-- Another important predicate of a "valid" RecordStoreState is the fact
-- that α's n-th vote is always the same.
VotesOnlyOnceRule : Set ℓ
VotesOnlyOnceRule
-- Given an honest α
= (α : Member) → Meta-Honest-Member α
-- For all system states where q and q' exist,
→ ∀{q q'} → (q∈𝓢 : InSys (Q q)) → (q'∈𝓢 : InSys (Q q'))
-- such that α voted for q and q'; if α says it's the same vote, then it's the same vote.
→ (v : α ∈QC q)(v' : α ∈QC q')
→ abs-vRound (∈QC-Vote q v) ≡ abs-vRound (∈QC-Vote q' v')
-----------------
→ ∈QC-Vote q v ≡ ∈QC-Vote q' v'
module _ {ℓ}(InSys : Record → Set ℓ) where
-- The preferred-round rule (aka locked-round-rule) is a critical
-- aspect of LibraBFT's correctness. It states that an honest node α will cast
-- votes for blocks b only if prevRound(b) ≥ preferred_round(α), where preferred_round(α)
-- is defined as $max { round b | b is the head of a 2-chain }$.
--
-- Operationally, α can ensure it obeys this rule as follows: it keeps a counter
-- preferred_round, initialized at 0 and, whenever α receives a QC q that forms a
-- 2-chain:
--
-- Fig1
--
-- I ← ⋯ ← b₁ ← q₁ ← b ← q
-- ⌞₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋⌟
-- 2-chain
--
-- it checks whether round(b₁) , which is the head of the 2-chain above,
-- is greater than its previously known preferred_round; if so, α updates
-- it. Note that α doesn't need to cast a vote in q, above, to have its
-- preferred_round updated. All that matters is that α has seen q.
--
-- We are encoding the rules governing Libra nodes as invariants in the
-- state of other nodes. Hence, the PreferredRoundRule below states an invariant
-- on the state of β, if α respects the preferred-round-rule.
--
-- Let the state of β be as below, such that α did cast votes for q
-- and q' in that order (α is honest here!):
--
--
-- Fig2
-- 3-chain
-- ⌜⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⌝
-- | 2-chain | α knows of the 2-chain because
-- ⌜⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⌝ | it voted at the 3-chain.
-- I ← ⋯ ← b₂ ← q₂ ← b₁ ← q₁ ← b ← q
-- ↖
-- ⋯ ← b₁' ← q₁' ← b' ← q'
--
-- Then, since α is honest and follows the preferred-round rule, we know that
-- round(b₂) ≤ round(b₁') because, by seeing that α voted on q, we know that α
-- has seen the 2-chain above, hence, α's preferred_round was at least round(b₂) at
-- the time α cast its vote for b.
--
-- After casting a vote for b, α cast a vote for b', which means that α must have
-- checked that round(b₂) ≤ prevRound(b'), as stated by the preferred round rule.
--
-- The invariant below states that, since α is honest, we can trust that these
-- checks have been performed and we can infer this information solely
-- by seeing α has knowledge of the 2-chain in Fig2 above.
--
PreferredRoundRule : Set ℓ
PreferredRoundRule
= ∀(α : Member) → Meta-Honest-Member α
→ ∀{q q'}(q∈𝓢 : InSys (Q q))(q'∈𝓢 : InSys (Q q'))
→ {rc : RecordChain (Q q)}{n : ℕ}(c3 : 𝕂-chain Contig (3 + n) rc)
→ (v : α ∈QC q) -- α knows of the 2-chain because it voted on the tail of the 3-chain!
→ (rc' : RecordChain (Q q'))
→ (v' : α ∈QC q')
→ abs-vRound (∈QC-Vote q v) < abs-vRound (∈QC-Vote q' v')
→ NonInjective-≡ bId ⊎ (getRound (kchainBlock (suc (suc zero)) c3) ≤ prevRound rc')
| {
"alphanum_fraction": 0.6190383492,
"avg_line_length": 44.6695652174,
"ext": "agda",
"hexsha": "915cbc5da34fa76a16962e2dec4420037060b3ad",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "cwjnkins/bft-consensus-agda",
"max_forks_repo_path": "LibraBFT/Abstract/RecordChain/Assumptions.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "cwjnkins/bft-consensus-agda",
"max_issues_repo_path": "LibraBFT/Abstract/RecordChain/Assumptions.agda",
"max_line_length": 111,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "cwjnkins/bft-consensus-agda",
"max_stars_repo_path": "LibraBFT/Abstract/RecordChain/Assumptions.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1673,
"size": 5137
} |
{-# OPTIONS --allow-unsolved-metas #-}
open import Agda.Primitive
infixr 5 _,_
record Pair
{a} (A : Set a) {b} (B : Set b)
: Set (a ⊔ b) where
constructor _,_
field
fst : A
snd : B
data Constraint
{a} {A : Set a} (x : A)
: Set where
instance _ : Constraint x
record Outer
l {a} {A : Set a} (x : A)
: Set (lsuc l) where
constructor #
field type : Set l
record Inner
{l} {a} {A : Set a} (x : A) {{_ : Constraint x}} (outer : Outer l x)
: Set l where
field value : Outer.type outer
module Class
{l} {a} {A : Set a} (x : A) (C : Set l)
where
class = Inner x (# C)
method : {{_ : class}} → C
method {{INSTANCE}} = Inner.value INSTANCE
module Beekeeper
{i} {I : Set i}
(A : I -> Set)
(B : I -> Set)
(x : I)
= Class (x , A , B)
(A x -> B x)
module Indexed
{a b b?} {I : Set}
{A : I -> Set a}
(mkA : ∀ {x} -> A x)
(B : I -> Set b)
(toB : ∀ {x} -> A x -> B x)
(B? : ∀ {x} -> B x -> Set b?)
= Class ((λ {x} -> toB {x}) , (λ {x} -> B? {x}))
(∀ {x} -> B? (toB (mkA {x})))
module Unindexed
{a b}
{A : Set a}
(mkA : A)
{B : Set b}
(toB : A -> B)
(B? : B -> Set)
= Class (mkA , toB , B?)
(B? (toB mkA))
module _
{a b} {I : Set}
{A : I -> Set a}
{mkA : ∀ {x} -> A x}
{B : I -> Set b}
{toB : ∀ {x} -> A x -> B x}
{B? : ∀ {x} -> B x -> Set}
{{_ : Indexed.class mkA B toB B?}}
where
postulate
instance iToUnindexed : ∀ {x} -> Unindexed.class (mkA {x}) toB B?
postulate
I : Set
data A
a (x : I)
: Set a where
mkA : A a x
record B
b (x : I)
: Set (lsuc b) where
field ?? : Set b
open B public
postulate
toB : ∀ {a b x} -> A a x -> B b x
instance
iIndexedAB : ∀ {a b} -> Indexed.class (mkA {a}) (B b) toB (B.??)
b : Level
x : I
myB : B b x
error : myB .??
error = {!Beekeeper.method _ _ _ _ _!}
-- Location of the error: src/full/Agda/TypeChecking/Substitute.hs:98
| {
"alphanum_fraction": 0.4875130073,
"avg_line_length": 18.8431372549,
"ext": "agda",
"hexsha": "ed2b1706cd0ecb75c7b215074ea92406a0469312",
"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/AgdaSubstitute98Bug.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/AgdaSubstitute98Bug.agda",
"max_line_length": 70,
"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/AgdaSubstitute98Bug.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 794,
"size": 1922
} |
module FRP.LTL.ISet where
open import FRP.LTL.ISet.Core public using ( ISet ; ⟨_⟩ ; ⟦_⟧ )
-- Propositional logic
open import FRP.LTL.ISet.Unit public using ( T )
open import FRP.LTL.ISet.Empty public using ( F )
open import FRP.LTL.ISet.Product public using ( _∧_ ; fst ; snd ; _&&&_ )
open import FRP.LTL.ISet.Sum public using ( _∨_ )
open import FRP.LTL.ISet.Stateless public using ( _⇒_ )
-- LTL
open import FRP.LTL.ISet.Next public using ( ○ )
open import FRP.LTL.ISet.Future public using ( ◇ )
open import FRP.LTL.ISet.Globally public using ( □ ; [_] )
open import FRP.LTL.ISet.Until public using ( _U_ )
open import FRP.LTL.ISet.Causal public using ( _⊵_ ; arr ; identity ; _⋙_ )
open import FRP.LTL.ISet.Decoupled public using ( _▹_ )
| {
"alphanum_fraction": 0.7054886212,
"avg_line_length": 35.5714285714,
"ext": "agda",
"hexsha": "e68f9638222c5f1094287808d999c8d5a2e18b53",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z",
"max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/agda-frp-ltl",
"max_forks_repo_path": "src/FRP/LTL/ISet.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5",
"max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/agda-frp-ltl",
"max_issues_repo_path": "src/FRP/LTL/ISet.agda",
"max_line_length": 75,
"max_stars_count": 21,
"max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/agda-frp-ltl",
"max_stars_repo_path": "src/FRP/LTL/ISet.agda",
"max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z",
"num_tokens": 248,
"size": 747
} |
------------------------------------------------------------------------
-- Propositional equality, with some extra bells and whistles
-- definable in Cubical Agda
------------------------------------------------------------------------
{-# OPTIONS --erased-cubical --safe #-}
module Equality.Propositional.Cubical where
import Equality.Path as P
open import Equality.Propositional
open Equality.Propositional public using (refl; equivalence-relation⁺)
-- A family of implementations of P.Equality-with-paths.
private
equality-with-paths′ :
∀ {a p} → P.Equality-with-paths a p equivalence-relation⁺
equality-with-paths′ =
P.Equality-with-J⇒Equality-with-paths equality-with-J
-- A family of implementations of P.Equality-with-paths.
--
-- The definition has been expanded in order to ensure that it does
-- not reduce (unless a projection is applied to it).
equality-with-paths :
∀ {a p} → P.Equality-with-paths a p equivalence-relation⁺
equality-with-paths .P.Equality-with-paths.equality-with-J = equality-with-paths′ .P.Equality-with-paths.equality-with-J
equality-with-paths {p = p} .P.Equality-with-paths.to-path = equality-with-paths′ {p = p} .P.Equality-with-paths.to-path
equality-with-paths {p = p} .P.Equality-with-paths.from-path = equality-with-paths′ {p = p} .P.Equality-with-paths.from-path
equality-with-paths {p = p} .P.Equality-with-paths.to-path∘from-path = equality-with-paths′ {p = p} .P.Equality-with-paths.to-path∘from-path
equality-with-paths {p = p} .P.Equality-with-paths.from-path∘to-path = equality-with-paths′ {p = p} .P.Equality-with-paths.from-path∘to-path
equality-with-paths {p = p} .P.Equality-with-paths.to-path-refl = equality-with-paths′ {p = p} .P.Equality-with-paths.to-path-refl
equality-with-paths {p = p} .P.Equality-with-paths.from-path-refl = equality-with-paths′ {p = p} .P.Equality-with-paths.from-path-refl
open P.Derived-definitions-and-properties equality-with-paths public
hiding (refl)
open import Equality.Path.Isomorphisms equality-with-paths public
| {
"alphanum_fraction": 0.6769527483,
"avg_line_length": 47.1363636364,
"ext": "agda",
"hexsha": "72e98e4604a81a0a63d4adb1f7045526f2d1dab7",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/equality",
"max_forks_repo_path": "src/Equality/Propositional/Cubical.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/equality",
"max_issues_repo_path": "src/Equality/Propositional/Cubical.agda",
"max_line_length": 140,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/equality",
"max_stars_repo_path": "src/Equality/Propositional/Cubical.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z",
"num_tokens": 543,
"size": 2074
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Finite.Fin where
open import Level
open import Data.Nat using (ℕ)
open import Data.Vec as Vec using (Vec)
open import Data.List
open import Data.Fin
open import Data.Fin.Properties
open import Axiom.UniquenessOfIdentityProofs
open import Relation.Binary using (Rel ; Decidable)
open import Relation.Binary.PropositionalEquality as ≡
open import Categories.Category
record Arrow (n : ℕ) (∣_⇒_∣ : Fin n → Fin n → ℕ) : Set where
field
dom : Fin n
cod : Fin n
arr : Fin ∣ dom ⇒ cod ∣
-- a hasShape of a finite catgegory
--
-- Classically, a finite category has a finite number of objects and a finite number
-- of morphisms. However, in this library, we cannot conveniently count the number of
-- objects and morphisms, because morphisms are identified up to the underlying
-- equivalence and objects have no general notion of identity. As a result, the
-- classical definition fails.
--
-- Nevetheless, if we know precisely what the objects and morphisms are, then we might
-- be able to count them. As a result, finite categories are just adjoint equivalent
-- to some category with a finite hasShape. Motivated by this idea, we can consider a
-- category with both objects and morphisms represented by Fin. We know Fin has
-- decidable equality and consequently also UIP. This allows us to operate
-- classically. We additionally require categorical axioms and thus ensure all shapes
-- form categories.
record HasFinCatShape (n : ℕ) (∣_⇒_∣ : Fin n → Fin n → ℕ) : Set where
infix 4 _⇒_
infixr 9 _∘_
_⇒_ : Rel (Fin n) 0ℓ
a ⇒ b = Fin ∣ a ⇒ b ∣
field
id : ∀ {a} → a ⇒ a
_∘_ : ∀ {a b c} → b ⇒ c → a ⇒ b → a ⇒ c
field
assoc : ∀ {a b c d} {f : a ⇒ b} {g : b ⇒ c} {h : c ⇒ d} → (h ∘ g) ∘ f ≡ h ∘ (g ∘ f)
identityˡ : ∀ {a b} {f : a ⇒ b} → id ∘ f ≡ f
identityʳ : ∀ {a b} {f : a ⇒ b} → f ∘ id ≡ f
objects : List (Fin n)
objects = allFin n
wrap-arr : ∀ {d c} (f : Fin ∣ d ⇒ c ∣) → Arrow n ∣_⇒_∣
wrap-arr f = record { arr = f }
morphisms : List (Arrow n ∣_⇒_∣)
morphisms = concatMap (λ d → concatMap (λ c → tabulate (wrap-arr {d} {c})) objects) objects
Obj-≟ : Decidable {A = Fin n} _≡_
Obj-≟ = _≟_
objects-vec : Vec (Fin n) n
objects-vec = Vec.allFin n
⇒-≟ : ∀ {a b} → Decidable {A = a ⇒ b} _≡_
⇒-≟ = _≟_
Obj-UIP : UIP (Fin n)
Obj-UIP = Decidable⇒UIP.≡-irrelevant Obj-≟
⇒-UIP : ∀ {a b} → UIP (a ⇒ b)
⇒-UIP = Decidable⇒UIP.≡-irrelevant ⇒-≟
record FinCatShape : Set where
infix 9 ∣_⇒_∣
field
size : ℕ
∣_⇒_∣ : Fin size → Fin size → ℕ
hasShape : HasFinCatShape size ∣_⇒_∣
open HasFinCatShape hasShape public
FinCategory : FinCatShape → Category 0ℓ 0ℓ 0ℓ
FinCategory s = record
{ Obj = Fin size
; _⇒_ = _⇒_
; _≈_ = _≡_
; id = id
; _∘_ = _∘_
; assoc = assoc
; sym-assoc = sym assoc
; identityˡ = identityˡ
; identityʳ = identityʳ
; identity² = identityˡ
; equiv = ≡.isEquivalence
; ∘-resp-≈ = cong₂ _∘_
}
where open FinCatShape s
| {
"alphanum_fraction": 0.6287854119,
"avg_line_length": 29.5288461538,
"ext": "agda",
"hexsha": "db600598233bac3c5be37f6c919dc1339800c07a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MirceaS/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Finite/Fin.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "MirceaS/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Finite/Fin.agda",
"max_line_length": 93,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MirceaS/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Finite/Fin.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1109,
"size": 3071
} |
postulate
T : Set → Set
X : Set
Class : Set → Set
member : ∀ {A} {{C : Class A}} → A → A
iX : Class X
iT : ∀ {A} {{CA : Class A}} → Class (T A)
-- Should get type Class (T X),
-- not {{_ : Class X}} → Class (T X)
iTX = iT {A = X}
-- Fails if not expanding instance argument in iTX
f : T X → T X
f = member
| {
"alphanum_fraction": 0.5232198142,
"avg_line_length": 17,
"ext": "agda",
"hexsha": "8543128a42fcefd57f15594af3720cf886245b84",
"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/Issue1184.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/Issue1184.agda",
"max_line_length": 50,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "test/succeed/Issue1184.agda",
"max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z",
"num_tokens": 123,
"size": 323
} |
{-# OPTIONS --safe #-}
module Cubical.Data.NatPlusOne.MoreNats.AssocNat.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Data.Empty
open import Cubical.Data.Unit
open import Cubical.Data.Nat hiding (_+_)
infixl 6 _+₁_
data ℕ₊₁ : Type where
one : ℕ₊₁
_+₁_ : ℕ₊₁ → ℕ₊₁ → ℕ₊₁
assoc : (a b c : ℕ₊₁) → a +₁ (b +₁ c) ≡ a +₁ b +₁ c
trunc : isSet ℕ₊₁
module Elim {ℓ'} {B : ℕ₊₁ → Type ℓ'}
(one* : B one) (_+₁*_ : {m n : ℕ₊₁} → B m → B n → B (m +₁ n))
(assoc* : {x y z : ℕ₊₁} (x' : B x) (y' : B y) (z' : B z)
→ PathP (λ i → B (assoc x y z i))
(x' +₁* (y' +₁* z')) ((x' +₁* y') +₁* z'))
(trunc* : (n : ℕ₊₁) → isSet (B n)) where
f : (n : ℕ₊₁) → B n
f one = one*
f (m +₁ n) = f m +₁* f n
f (assoc x y z i) = assoc* (f x) (f y) (f z) i
f (trunc m n p q i j) =
isOfHLevel→isOfHLevelDep 2 trunc* (f m) (f n)
(cong f p) (cong f q) (trunc m n p q) i j
module ElimProp {ℓ'} {B : ℕ₊₁ → Type ℓ'} (BProp : {n : ℕ₊₁} → isProp (B n))
(one* : B one) (_+₁*_ : {m n : ℕ₊₁} → B m → B n → B (m +₁ n)) where
f : (n : ℕ₊₁) → B n
f = Elim.f {B = B} one* _+₁*_
(λ {x} {y} {z} x' y' z' →
toPathP (BProp (transport (λ i → B (assoc x y z i))
(x' +₁* (y' +₁* z'))) ((x' +₁* y') +₁* z')))
λ n → isProp→isSet BProp
module Rec {ℓ'} {B : Type ℓ'} (BType : isSet B)
(one* : B) (_+₁*_ : B → B → B)
(assoc* : (a b c : B) → a +₁* (b +₁* c) ≡ (a +₁* b) +₁* c) where
f : ℕ₊₁ → B
f = Elim.f one* (λ m n → m +₁* n) assoc* λ _ → BType
private
constraintNumber : ℕ → Type
constraintNumber zero = ⊥
constraintNumber (suc _) = Unit
fromNat' : (n : ℕ) ⦃ _ : constraintNumber n ⦄ → ℕ₊₁
fromNat' zero ⦃ () ⦄
fromNat' (suc zero) = one
fromNat' (suc (suc n)) = fromNat' (suc n) +₁ one
instance
NumN : HasFromNat ℕ₊₁
NumN = record { Constraint = constraintNumber ; fromNat = fromNat' }
| {
"alphanum_fraction": 0.5106382979,
"avg_line_length": 30.109375,
"ext": "agda",
"hexsha": "1790953d309132aedc61155008e4c8705b3a9249",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/Data/NatPlusOne/MoreNats/AssocNat/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/Data/NatPlusOne/MoreNats/AssocNat/Base.agda",
"max_line_length": 75,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/Data/NatPlusOne/MoreNats/AssocNat/Base.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z",
"num_tokens": 880,
"size": 1927
} |
open import Common.Prelude
data Wrap (A : Set) : Set where wrap : A → Wrap A
appWrap : ∀ {A B : Set} → (A → B) → Wrap A → B
appWrap f (wrap a) = f a
app : ∀ {A B : Set} → (A → B) → A → B
app f a = appWrap f (wrap a)
works : Nat
works = (λ _ → 42) ((λ _ → tt) 13)
-- (λ _ → tt) is erased but `app` tries to apply it
buggy : Nat
buggy = app (λ _ → 42) (app (λ _ → tt) 13)
main : IO ⊤
main = printNat buggy
| {
"alphanum_fraction": 0.5474452555,
"avg_line_length": 19.5714285714,
"ext": "agda",
"hexsha": "3a74139eb8188293b0c5228408359e04cdfb2ba1",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Compiler/simple/Issue3380.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Compiler/simple/Issue3380.agda",
"max_line_length": 51,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Compiler/simple/Issue3380.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": 167,
"size": 411
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.