Search is not available for this dataset
text
string | meta
dict |
---|---|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties satisfied by bounded meet semilattices
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary.Lattice
module Relation.Binary.Properties.BoundedMeetSemilattice
{c ℓ₁ ℓ₂} (M : BoundedMeetSemilattice c ℓ₁ ℓ₂) where
open BoundedMeetSemilattice M
import Algebra.FunctionProperties as P; open P _≈_
open import Data.Product
open import Function using (_∘_; flip)
open import Relation.Binary
open import Relation.Binary.Properties.Poset poset
import Relation.Binary.Properties.BoundedJoinSemilattice as J
-- The dual construction is a bounded join semilattice.
dualIsBoundedJoinSemilattice : IsBoundedJoinSemilattice _≈_ (flip _≤_) _∧_ ⊤
dualIsBoundedJoinSemilattice = record
{ isJoinSemilattice = record
{ isPartialOrder = invIsPartialOrder
; supremum = infimum
}
; minimum = maximum
}
dualBoundedJoinSemilattice : BoundedJoinSemilattice c ℓ₁ ℓ₂
dualBoundedJoinSemilattice = record
{ ⊥ = ⊤
; isBoundedJoinSemilattice = dualIsBoundedJoinSemilattice
}
open J dualBoundedJoinSemilattice
hiding (dualIsBoundedMeetSemilattice; dualBoundedMeetSemilattice) public
| {
"alphanum_fraction": 0.6802106847,
"avg_line_length": 31.6428571429,
"ext": "agda",
"hexsha": "13344eb6dc059353d990d4b98628b9b81e013083",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Properties/BoundedMeetSemilattice.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Properties/BoundedMeetSemilattice.agda",
"max_line_length": 76,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Properties/BoundedMeetSemilattice.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 340,
"size": 1329
} |
-- Andreas, 2018-04-16, issue #3033, reported by Christian Sattler
-- The DotPatternCtx was not used inside dot patterns in ConcreteToAbstract.
postulate
A : Set
B : Set
a : A
f : A → B
data C : B → Set where
c : C (f a)
foo : (b : B) → C b → Set
foo .{!f a!} c = A -- give "f a" here
-- WAS: foo .f a c = A
-- NOW: foo .(f a) c = A
| {
"alphanum_fraction": 0.5730659026,
"avg_line_length": 18.3684210526,
"ext": "agda",
"hexsha": "b3225b3af12d617be18b9b99f3d0b7bb7848c0ce",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/interaction/Issue3033.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/interaction/Issue3033.agda",
"max_line_length": 76,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/interaction/Issue3033.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 137,
"size": 349
} |
module Tactic.Monoid where
open import Prelude
open import Tactic.Reflection
open import Tactic.Reflection.Quote
open import Tactic.Monoid.Exp
open import Tactic.Monoid.Reflect
open import Tactic.Monoid.Proofs
monoidTactic : ∀ {a} {A : Set a} {{_ : Monoid/Laws A}} → Tactic
monoidTactic {A = A} {{laws}} hole = do
goal ← inferNormalisedType hole
`A ← quoteTC A
unify goal (def (quote _≡_) (hArg unknown ∷ hArg `A ∷ vArg unknown ∷ vArg unknown ∷ []))
<|> do typeErrorFmt "Goal is not an equality: %t" goal
goal ← normalise goal
ensureNoMetas goal
match ← monoidMatcher (Monoid/Laws.super laws)
`dict ← quoteTC (Monoid/Laws.super laws)
`laws ← quoteTC laws
ensureNoMetas `dict
debugPrintFmt "tactic.monoid" 20 "monoidTactic %t, dict = %t" goal `dict
(lhs , rhs) , env ← parseGoal match goal
unify hole (def (quote proof) (iArg `dict ∷ iArg `laws ∷ vArg (` lhs) ∷ vArg (` rhs) ∷
vArg (quoteEnv `dict env) ∷ vArg (con (quote refl) []) ∷ []))
<|> do typeErrorFmt "Can't prove %t == %t because %t /= %t"
(` lhs) (` rhs) (` (flatten lhs)) (` (flatten rhs))
macro
auto-monoid : ∀ {a} {A : Set a} {{Laws : Monoid/Laws A}} → Tactic
auto-monoid {{Laws}} = monoidTactic {{Laws}}
| {
"alphanum_fraction": 0.6285266458,
"avg_line_length": 37.5294117647,
"ext": "agda",
"hexsha": "49a2e93caf1e52c42d941310ba1be8623a94eb0a",
"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/Tactic/Monoid.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/Tactic/Monoid.agda",
"max_line_length": 94,
"max_stars_count": 111,
"max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "L-TChen/agda-prelude",
"max_stars_repo_path": "src/Tactic/Monoid.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": 423,
"size": 1276
} |
module MetaId where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
expr = (\ (a : Set) (x : a) -> x) _ zero
| {
"alphanum_fraction": 0.512,
"avg_line_length": 15.625,
"ext": "agda",
"hexsha": "def9c7e99cecae7c0a21812857e65297c016aef3",
"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": "dc333ed142584cf52cc885644eed34b356967d8b",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "andrejtokarcik/agda-semantics",
"max_forks_repo_path": "tests/covered/MetaId.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b",
"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": "andrejtokarcik/agda-semantics",
"max_issues_repo_path": "tests/covered/MetaId.agda",
"max_line_length": 42,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "andrejtokarcik/agda-semantics",
"max_stars_repo_path": "tests/covered/MetaId.agda",
"max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z",
"num_tokens": 45,
"size": 125
} |
{-# OPTIONS --cubical --no-import-sorts #-}
module MoreLogic.Definitions where -- hProp logic
open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc)
open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_)
open import Cubical.Relation.Nullary.Base renaming (¬_ to ¬ᵗ_)
open import Cubical.Foundations.Logic renaming (inl to inlᵖ; inr to inrᵖ)
open import Cubical.Data.Empty renaming (elim to ⊥-elim) renaming (⊥ to ⊥⊥) -- `⊥` and `elim`
import Cubical.Data.Empty as Empty
open import Cubical.Data.Unit.Base
open import MoreLogic.Reasoning
open import Utils
-- lifted versions of ⊥ and ⊤
hPropRel : ∀ {ℓ} (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))
hPropRel A B ℓ' = A → B → hProp ℓ'
isSetIsProp : ∀{ℓ} {A : Type ℓ} → isProp (isSet A)
isSetIsProp is-set₀ is-set₁ = funExt (λ x → funExt λ y → isPropIsProp (is-set₀ x y) (is-set₁ x y))
isSetᵖ : ∀{ℓ} (A : Type ℓ) → hProp ℓ
isSetᵖ A = isSet A , isSetIsProp
-- hProp-syntax for Σ types of hProps to omit propositional truncation
-- this should be equivalent to ∃! from the standard library but ∃! is not an hProp
-- proof sketch:
-- `∃! A B = isContr (Σ A B) = Σ[ x ∈ Σ A B ] ∀( y : Σ A B) → x ≡ y`
-- `Σᵖ[]-syntax A B ≈ Σ[ c ∈ Σ A B ] ∀(x y : Σ A B) → x ≡ y`
-- NOTE: we also have isProp→Iso in `Cubical.Foundations.Isomorphism`
Σᵖ[]-syntax : ∀{ℓ ℓ'} → {A : hProp ℓ'} → ([ A ] → hProp ℓ) → hProp _
Σᵖ[]-syntax {A = A} P = Σ [ A ] ([_] ∘ P) , isPropΣ (isProp[] A) (isProp[] ∘ P)
syntax Σᵖ[]-syntax (λ x → P) = Σᵖ[ x ] P
infix 2 Σᵖ[]-syntax
Σᵖ[∶]-syntax : ∀{ℓ ℓ'} → {A : hProp ℓ'} → ([ A ] → hProp ℓ) → hProp _
Σᵖ[∶]-syntax {A = A} P = Σ [ A ] ([_] ∘ P) , isPropΣ (isProp[] A) (isProp[] ∘ P)
syntax Σᵖ[∶]-syntax {A = A} (λ x → P) = Σᵖ[ x ∶ A ] P
infix 2 Σᵖ[∶]-syntax
isProp⊎ˡ : ∀{ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → isProp A → isProp B → (A → ¬ᵗ B) → isProp (A ⊎ B)
isProp⊎ˡ pA pB A⇒¬B (inl x) (inl y) = cong inl (pA x y)
isProp⊎ˡ pA pB A⇒¬B (inr x) (inr y) = cong inr (pB x y)
isProp⊎ˡ pA pB A⇒¬B (inl x) (inr y) = ⊥-elim (A⇒¬B x y)
isProp⊎ˡ pA pB A⇒¬B (inr x) (inl y) = ⊥-elim (A⇒¬B y x)
-- hProp-syntax for disjoint unions to omit propositional truncation
⊎ᵖ-syntax : ∀{ℓ ℓ'} (P : hProp ℓ) (Q : hProp ℓ') → {[ P ] → ¬ᵗ [ Q ]} → hProp _
⊎ᵖ-syntax P Q {P⇒¬Q} = ([ P ] ⊎ [ Q ]) , isProp⊎ˡ (isProp[] P) (isProp[] Q) P⇒¬Q
syntax ⊎ᵖ-syntax P Q {P⇒¬Q} = [ P⇒¬Q ] P ⊎ᵖ Q
{-# DISPLAY ⊎ᵖ-syntax a b = a ⊎ b #-}
-- hProp-syntax for equality on sets to omit propositional truncation
≡ˢ-syntax : {ℓ : Level} {A : Type ℓ} → A → A → {isset : isSet A} → hProp ℓ
≡ˢ-syntax a b {isset} = (a ≡ b) , isset a b
syntax ≡ˢ-syntax a b {isset} = [ isset ] a ≡ˢ b
infix 1 ⊎ᵖ-syntax
infix 1 ≡ˢ-syntax
{-# DISPLAY ≡ˢ-syntax a b = a ≡ b #-}
-- pretty print ∀-syntax from cubical standard library
{-# DISPLAY ∀[]-syntax {A = A} P = P #-}
-- {-# DISPLAY ∀[]-syntax {A = A} P = ∃ P #-}
-- {-# DISPLAY ∀[]-syntax (λ a → P) = ∀[ a ] P #-}
-- {-# DISPLAY ∃[]-syntax (λ x → P) = ∃[ x ] P #-}
-- ∀-syntax to quantify over hProps (without needing to `[_]` them)
∀ᵖ[∶]-syntax : ∀{ℓ ℓ'} {A : hProp ℓ'} → ([ A ] → hProp ℓ) → hProp (ℓ-max ℓ ℓ')
∀ᵖ[∶]-syntax {A = A} P = (∀ x → [ P x ]) , isPropΠ (isProp[] ∘ P)
syntax ∀ᵖ[∶]-syntax {A = A} (λ a → P) = ∀ᵖ[ a ∶ A ] P
infix 2 ∀ᵖ[∶]-syntax
{-# DISPLAY ∀ᵖ[∶]-syntax {A = A} P = P #-}
-- isPropΠ for a function with an instance argument
isPropΠⁱ : ∀{ℓ ℓ'} {A : Type ℓ} {B : {{p : A}} → Type ℓ'} (h : (x : A) → isProp (B {{x}})) → isProp ({{x : A}} → B {{x}})
isPropΠⁱ h f g i {{x}} = (h x) (f {{x}}) (g {{x}}) i
-- ∀-syntax to quantify over hProps (without needing to `[_]` them) which produces an intance argument
∀ᵖ〚∶〛-syntax : ∀{ℓ ℓ'} {A : hProp ℓ'} → ([ A ] → hProp ℓ) → hProp (ℓ-max ℓ ℓ')
∀ᵖ〚∶〛-syntax {A = A} P = (∀ {{x}} → [ P x ]) , isPropΠⁱ (isProp[] ∘ P)
syntax ∀ᵖ〚∶〛-syntax {A = A} (λ a → P) = ∀ᵖ〚 a ∶ A 〛 P
infix 2 ∀ᵖ〚∶〛-syntax
!isProp : ∀{ℓ} {P : Type ℓ} → isProp P → isProp (! P)
!isProp is-prop (!! x) (!! y) = subst (λ z → (!! x) ≡ (!! z)) (is-prop x y) refl
∀ᵖ!〚∶〛-syntax : ∀{ℓ ℓ'} {A : hProp ℓ'} → (! [ A ] → hProp ℓ) → hProp (ℓ-max ℓ ℓ')
∀ᵖ!〚∶〛-syntax {A = A} P = (∀ {{x}} → [ P x ]) , isPropΠⁱ (λ p → isProp[] (P (p))) -- isPropΠⁱ (isProp[] ∘ P) -- isPropΠⁱ (!isProp ∘ isProp[] ∘ P) -- --
syntax ∀ᵖ!〚∶〛-syntax {A = A} (λ a → P) = ∀ᵖ!〚 a ∶ A 〛 P
infix 2 ∀ᵖ!〚∶〛-syntax
{-# DISPLAY ∀ᵖ[∶]-syntax {A = A} P = P #-}
-- ∀-syntax which produces an intance argument
∀〚∶〛-syntax : ∀{ℓ ℓ'} {A : Type ℓ'} → (A → hProp ℓ) → hProp _
∀〚∶〛-syntax {A = A} P = (∀ {{x}} → [ P x ]) , isPropΠⁱ (isProp[] ∘ P)
syntax ∀〚∶〛-syntax {A = A} (λ a → P) = ∀〚 a ∶ A 〛 P
infix 2 ∀〚∶〛-syntax
{-# DISPLAY ∀〚∶〛-syntax {A = A} P = P #-}
⊎⇒⊔ : ∀ {ℓ ℓ'} (P : hProp ℓ) (Q : hProp ℓ') → [ P ] ⊎ [ Q ] → [ P ⊔ Q ]
⊎⇒⊔ P Q (inl x) = inlᵖ x
⊎⇒⊔ P Q (inr x) = inrᵖ x
-- pretty `⊔-elim`
case[⊔]-syntaxᵈ : ∀ {ℓ ℓ' ℓ''} (P : hProp ℓ) (Q : hProp ℓ')
→ (z : [ P ⊔ Q ])
→ (R : [ P ⊔ Q ] → hProp ℓ'')
→ (S : (x : [ P ] ⊎ [ Q ]) → [ R (⊎⇒⊔ P Q x) ] )
→ [ R z ]
case[⊔]-syntaxᵈ P Q z R S = ⊔-elim P Q R (λ p → S (inl p)) (λ q → S (inr q)) z
syntax case[⊔]-syntaxᵈ P Q z (λ x → R) S = case z as x ∶ P ⊔ Q ⇒ R of S
case[⊔]-syntax : ∀ {ℓ ℓ' ℓ''} (P : hProp ℓ) (Q : hProp ℓ')
→ (z : [ P ⊔ Q ])
→ (R : hProp ℓ'')
→ (S : (x : [ P ] ⊎ [ Q ]) → [ R ] )
→ [ R ]
case[⊔]-syntax P Q z R S = ⊔-elim P Q (λ _ → R) (λ p → S (inl p)) (λ q → S (inr q)) z
syntax case[⊔]-syntax P Q z R S = case z as P ⊔ Q ⇒ R of S
-- {-# DISPLAY case[⊔]-syntax P Q z R S = case z of S #-}
-- for a function, to be an hProp, it suffices that the result is an hProp
-- so in principle we might inject any non-hProps as arguments with `_ᵗ⇒_`
_ᵗ⇒_ : ∀{ℓ ℓ'} (A : Type ℓ) → (B : hProp ℓ') → hProp _
A ᵗ⇒ B = (A → [ B ]) , isPropΠ λ _ → isProp[] B
infixr 6 _ᵗ⇒_
-- lifting of hProps to create "universe-homogeneous" pathes
-- this is not necessary when using _⇔_ which is universe-inhomogeneous
-- because `_⇔_` can "cross" universes, where `PathP` needs to stay in the same universe
Liftᵖ : ∀{i j : Level} → hProp i → hProp (ℓ-max i j)
Liftᵖ {i} {j} P = Lift {i} {j} [ P ] , λ{ (lift p) (lift q) → λ i → lift (isProp[] P p q i) }
liftᵖ : ∀{i j : Level} → (P : hProp i) → [ P ] → [ Liftᵖ {i} {j} P ]
liftᵖ P p = lift p
unliftᵖ : ∀{i j : Level} → (P : hProp i) → [ Liftᵖ {i} {j} P ] → [ P ]
unliftᵖ P (lift p) = p
⊥↑ : ∀{ℓ} → hProp ℓ
⊥↑ = Lift Empty.⊥ , λ ()
⊤↑ : ∀{ℓ} → hProp ℓ
⊤↑ = Lift Unit , isOfHLevelLift 1 (λ _ _ _ → tt)
infix 10 ¬↑_
¬↑_ : ∀{ℓ} → hProp ℓ → hProp ℓ
¬↑_ {ℓ} A = ([ A ] → Lift {j = ℓ} Empty.⊥) , isPropΠ λ _ → isOfHLevelLift 1 Empty.isProp⊥
-- negation with an instance argument
¬ⁱ_ : ∀{ℓ} → hProp ℓ → hProp ℓ
¬ⁱ A = ({{p : [ A ]}} → ⊥⊥) , isPropΠⁱ {A = [ A ]} λ _ → isProp⊥
¬'_ : ∀{ℓ} → Type ℓ → hProp ℓ
¬' A = (A → ⊥⊥) , isPropΠ λ _ → isProp⊥
¬-≡-¬ⁱ : ∀{ℓ} (P : hProp ℓ) → ¬ P ≡ ¬ⁱ P
¬-≡-¬ⁱ P =
⇒∶ (λ f {{p}} → f p )
⇐∶ (λ f p → f {{p}})
| {
"alphanum_fraction": 0.5118301026,
"avg_line_length": 38.1304347826,
"ext": "agda",
"hexsha": "e4697ede60d2ecbf78b7233314ba13d7830130f9",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mchristianl/synthetic-reals",
"max_forks_repo_path": "agda/MoreLogic/Definitions.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mchristianl/synthetic-reals",
"max_issues_repo_path": "agda/MoreLogic/Definitions.agda",
"max_line_length": 152,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mchristianl/synthetic-reals",
"max_stars_repo_path": "agda/MoreLogic/Definitions.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": 3456,
"size": 7016
} |
open import Nat
open import Prelude
module Hazelnut-core where
-- types
data τ̇ : Set where
num : τ̇
<||> : τ̇
_==>_ : τ̇ → τ̇ → τ̇
-- expressions, prefixed with a · to distinguish name clashes with agda
-- built-ins
data ė : Set where
_·:_ : ė → τ̇ → ė
X : Nat → ė
·λ : Nat → ė → ė
N : Nat → ė
_·+_ : ė → ė → ė
<||> : ė
<|_|> : ė → ė
_∘_ : ė → ė → ė
---- contexts and some operations on them
-- variables are named with naturals in ė. therefore we represent
-- contexts as functions from names for variables (nats) to possible
-- bindings.
·ctx : Set
·ctx = Nat → Maybe τ̇ -- todo: (Σ[ n : Nat ] (y : Nat) → y ∈ Γ → x > y)?
-- convenient shorthand for the (unique up to fun. ext.) empty context
∅ : ·ctx
∅ _ = None
-- add a new binding to the context, clobbering anything that might have
-- been there before.
_,,_ : ·ctx → (Nat × τ̇) → ·ctx
(Γ ,, (x , t)) y with natEQ x y
(Γ ,, (x , t)) .x | Inl refl = Some t
(Γ ,, (x , t)) y | Inr neq = Γ y
-- membership, or presence, in a context
-- todo: not sure if this should take a pair
_∈_ : (p : Nat × τ̇) → (Γ : ·ctx) → Set
(x , t) ∈ Γ = (Γ x) == Some t
-- apartness for contexts, so that we can follow barendregt's convention
_#_ : (n : Nat) → (Γ : ·ctx) → Set
x # Γ = (Γ x) == None
-- without: remove a variable from a context
_/_ : ·ctx → Nat → ·ctx
(Γ / x) y with natEQ x y
(Γ / x) .x | Inl refl = None
(Γ / x) y | Inr neq = Γ y
-- the type compatability judgement
data _~_ : (t1 : τ̇) → (t2 : τ̇) → Set where
TCRefl : {t : τ̇} → t ~ t
TCHole1 : {t : τ̇} → t ~ <||>
TCHole2 : {t : τ̇} → <||> ~ t
TCArr : {t1 t2 t1' t2' : τ̇} →
t1 ~ t1' →
t2 ~ t2' →
(t1 ==> t2) ~ (t1' ==> t2')
-- type incompatability. rather than enumerate the types which aren't
-- compatible, we encode this judgement immediately as the complement of
-- compatability. this simplifies a few proofs later.
_~̸_ : τ̇ → τ̇ → Set
t1 ~̸ t2 = (t1 ~ t2) → ⊥
-- bidirectional type checking judgements for ė
mutual
-- synthesis
data _⊢_=>_ : (Γ : ·ctx) → (e : ė) → (t : τ̇) → Set where
SAsc : {Γ : ·ctx} {e : ė} {t : τ̇} →
Γ ⊢ e <= t →
Γ ⊢ (e ·: t) => t
SVar : {Γ : ·ctx} {t : τ̇} {n : Nat} →
(n , t) ∈ Γ →
Γ ⊢ X n => t
SAp : {Γ : ·ctx} {e1 e2 : ė} {t t2 : τ̇} →
Γ ⊢ e1 => (t2 ==> t) →
Γ ⊢ e2 <= t2 →
Γ ⊢ (e1 ∘ e2) => t
SNum : {Γ : ·ctx} {n : Nat} →
Γ ⊢ N n => num
SPlus : {Γ : ·ctx} {e1 e2 : ė} →
Γ ⊢ e1 <= num →
Γ ⊢ e2 <= num →
Γ ⊢ (e1 ·+ e2) => num
SEHole : {Γ : ·ctx} → Γ ⊢ <||> => <||>
SFHole : {Γ : ·ctx} {e : ė} {t : τ̇} →
Γ ⊢ e => t →
Γ ⊢ <| e |> => <||>
SApHole : {Γ : ·ctx} {e1 e2 : ė} →
Γ ⊢ e1 => <||> →
Γ ⊢ e2 <= <||> →
Γ ⊢ (e1 ∘ e2) => <||>
-- analysis
data _⊢_<=_ : (Γ : ·ctx) → (e : ė) → (t : τ̇) → Set where
ASubsume : {Γ : ·ctx} {e : ė} {t t' : τ̇} →
Γ ⊢ e => t' →
t ~ t' →
Γ ⊢ e <= t
ALam : {Γ : ·ctx} {e : ė} {t1 t2 : τ̇} {n : Nat} →
n # Γ →
(Γ ,, (n , t1)) ⊢ e <= t2 →
Γ ⊢ (·λ n e) <= (t1 ==> t2)
----- a couple of exmaples to demonstrate how the encoding above works
-- the function (λx. x + 0) where x is named "0".
add0 : ė
add0 = ·λ 0 (X 0 ·+ N 0)
-- this is the derivation that fn has type num ==> num
ex1 : ∅ ⊢ ·λ 0 (X 0 ·+ N 0) <= (num ==> num)
ex1 = ALam refl
(ASubsume
(SPlus (ASubsume (SVar refl) TCRefl) (ASubsume SNum TCRefl))
TCRefl)
-- the derivation that when applied to the numeric argument 10 add0
-- produces a num.
ex2 : ∅ ⊢ (add0 ·: (num ==> num)) ∘ (N 10) => num
ex2 = SAp (SAsc ex1) (ASubsume SNum TCRefl)
-- the slightly longer derivation that argues that add0 applied to a
-- variable that's known to be a num produces a num
ex2b : (∅ ,, (1 , num)) ⊢ (add0 ·: (num ==> num)) ∘ (X 1) => num
ex2b = SAp (SAsc
(ALam refl
(ASubsume
(SPlus (ASubsume (SVar refl) TCRefl) (ASubsume SNum TCRefl))
TCRefl)))
(ASubsume (SVar refl) TCRefl)
-- eta-expanding addition to curry it gets num → num → num
ex3 : ∅ ⊢ ·λ 0 ( (·λ 1 (X 0 ·+ X 1)) ·: (num ==> num) )
<= (num ==> (num ==> num))
ex3 = ALam refl (ASubsume (SAsc (ALam refl
(ASubsume
(SPlus (ASubsume (SVar refl) TCRefl)
(ASubsume (SVar refl) TCRefl))
TCRefl))) TCRefl)
----- some theorems about the rules and judgement presented so far.
-- thrm: a variable is apart from any context from which it is removed
aar : (Γ : ·ctx) (x : Nat) → x # (Γ / x)
aar Γ x with natEQ x x
aar Γ x | Inl refl = refl
aar Γ x | Inr x≠x = abort (x≠x refl)
-- contexts give at most one binding for each variable
ctxunicity : {Γ : ·ctx} {n : Nat} {t t' : τ̇} →
(n , t) ∈ Γ →
(n , t') ∈ Γ →
t == t'
ctxunicity {n = n} p q with natEQ n n
ctxunicity p q | Inl refl = someinj (! p · q)
ctxunicity _ _ | Inr x≠x = abort (x≠x refl)
-- type compatablity is symmetric
~sym : {t1 t2 : τ̇} → t1 ~ t2 → t2 ~ t1
~sym TCRefl = TCRefl
~sym TCHole1 = TCHole2
~sym TCHole2 = TCHole1
~sym (TCArr p1 p2) = TCArr (~sym p1) (~sym p2)
-- if the domain or codomain of a pair of arrows isn't compatable, the
-- whole arrow isn't compatible.
lemarr1 : {t1 t2 t3 t4 : τ̇} → (t1 ~ t3 → ⊥) → (t1 ==> t2) ~ (t3 ==> t4) → ⊥
lemarr1 v TCRefl = v TCRefl
lemarr1 v (TCArr p _) = v p
lemarr2 : {t1 t2 t3 t4 : τ̇} → (t2 ~ t4 → ⊥) → (t1 ==> t2) ~ (t3 ==> t4) → ⊥
lemarr2 v TCRefl = v TCRefl
lemarr2 v (TCArr _ p) = v p
-- every pair of types is either compatable or not compatable
~dec : (t1 t2 : τ̇) → ((t1 ~ t2) + (t1 ~̸ t2))
-- this takes care of all hole cases, so we don't consider them below
~dec _ <||> = Inl TCHole1
~dec <||> _ = Inl TCHole2
-- num cases
~dec num num = Inl TCRefl
~dec num (t2 ==> t3) = Inr (λ ())
-- arrow cases
~dec (t1 ==> t2) num = Inr (λ ())
~dec (t1 ==> t2) (t3 ==> t4) with ~dec t1 t3 | ~dec t2 t4
... | Inl x | Inl y = Inl (TCArr x y)
... | Inl _ | Inr y = Inr (lemarr2 y)
... | Inr x | _ = Inr (lemarr1 x)
-- theorem: no pair of types is both compatable and not compatable. this
-- is immediate from our encoding of the ~̸ judgement in the formalism
-- here; in the exact mathematics presented in the paper, this would
-- require induction to relate the two judgements.
~apart : {t1 t2 : τ̇} → (t1 ~̸ t2) → (t1 ~ t2) → ⊥
~apart v p = v p
-- synthesis only produces equal types. note that there is no need for an
-- analagous theorem for analytic positions because we think of
-- the type as an input
synthunicity : {Γ : ·ctx} {e : ė} {t t' : τ̇} →
(Γ ⊢ e => t)
→ (Γ ⊢ e => t')
→ t == t'
synthunicity (SAsc _) (SAsc _) = refl
synthunicity {Γ = G} (SVar in1) (SVar in2) = ctxunicity {Γ = G} in1 in2
synthunicity (SAp D1 _) (SAp D2 _) with synthunicity D1 D2
... | refl = refl
synthunicity (SAp D1 _) (SApHole D2 _) with synthunicity D1 D2
... | ()
synthunicity SNum SNum = refl
synthunicity (SPlus _ _ ) (SPlus _ _ ) = refl
synthunicity SEHole SEHole = refl
synthunicity (SFHole _) (SFHole _) = refl
synthunicity (SApHole D1 _) (SAp D2 _) with synthunicity D1 D2
... | ()
synthunicity (SApHole _ _) (SApHole _ _) = refl
----- the zippered form of the forms above and the rules for actions on them
-- those types without holes anywhere
tcomplete : τ̇ → Set
tcomplete num = ⊤
tcomplete <||> = ⊥
tcomplete (t1 ==> t2) = (tcomplete t1) × (tcomplete t2)
-- similarly to the complete types, the complete expressions
ecomplete : ė → Set
ecomplete (e1 ·: t) = ecomplete e1 × tcomplete t
ecomplete (X _) = ⊤
ecomplete (·λ _ e1) = ecomplete e1
ecomplete (N x) = ⊤
ecomplete (e1 ·+ e2) = ecomplete e1 × ecomplete e2
ecomplete <||> = ⊥
ecomplete <| e1 |> = ⊥
ecomplete (e1 ∘ e2) = ecomplete e1 × ecomplete e2
-- zippered form of types
data τ̂ : Set where
▹_◃ : τ̇ → τ̂
_==>₁_ : τ̂ → τ̇ → τ̂
_==>₂_ : τ̇ → τ̂ → τ̂
-- zippered form of expressions
data ê : Set where
▹_◃ : ė → ê
_·:₁_ : ê → τ̇ → ê
_·:₂_ : ė → τ̂ → ê
·λ : Nat → ê → ê
_∘₁_ : ê → ė → ê
_∘₂_ : ė → ê → ê
_·+₁_ : ê → ė → ê
_·+₂_ : ė → ê → ê
<|_|> : ê → ê
--focus erasure for types
_◆t : τ̂ → τ̇
▹ t ◃ ◆t = t
(t1 ==>₁ t2) ◆t = (t1 ◆t) ==> t2
(t1 ==>₂ t2) ◆t = t1 ==> (t2 ◆t)
--focus erasure for expressions
_◆e : ê → ė
▹ x ◃ ◆e = x
(e ·:₁ t) ◆e = (e ◆e) ·: t
(e ·:₂ t) ◆e = e ·: (t ◆t)
·λ x e ◆e = ·λ x (e ◆e)
(e1 ∘₁ e2) ◆e = (e1 ◆e) ∘ e2
(e1 ∘₂ e2) ◆e = e1 ∘ (e2 ◆e)
(e1 ·+₁ e2) ◆e = (e1 ◆e) ·+ e2
(e1 ·+₂ e2) ◆e = e1 ·+ (e2 ◆e)
<| e |> ◆e = <| e ◆e |>
-- the three grammars that define actions
data direction : Set where
firstChild : direction
parent : direction
nextSib : direction
prevSib : direction
data shape : Set where
arrow : shape
num : shape
asc : shape
var : Nat → shape
lam : Nat → shape
ap : shape
arg : shape
numlit : Nat → shape
plus : shape
data action : Set where
move : direction → action
del : action
construct : shape → action
finish : action
-- type movement
data _+_+>_ : (t : τ̂) → (α : action) → (t' : τ̂) → Set where
TMFirstChild : {t1 t2 : τ̇} →
▹ t1 ==> t2 ◃ + move firstChild +> (▹ t1 ◃ ==>₁ t2)
TMParent1 : {t1 t2 : τ̇} →
(▹ t1 ◃ ==>₁ t2) + move parent +> ▹ t1 ==> t2 ◃
TMParent2 : {t1 t2 : τ̇} →
(t1 ==>₂ ▹ t2 ◃) + move parent +> ▹ t1 ==> t2 ◃
TMNextSib : {t1 t2 : τ̇} →
(▹ t1 ◃ ==>₁ t2) + move nextSib +> (t1 ==>₂ ▹ t2 ◃)
TMPrevSib : {t1 t2 : τ̇} →
(t1 ==>₂ ▹ t2 ◃) + move prevSib +> (▹ t1 ◃ ==>₁ t2)
TMDel : {t : τ̇} →
(▹ t ◃) + del +> (▹ <||> ◃)
TMConArrow : {t : τ̇} →
(▹ t ◃) + construct arrow +> (t ==>₂ ▹ <||> ◃)
TMConNum : (▹ <||> ◃) + construct num +> (▹ num ◃)
TMZip1 : {t1 t1' : τ̂} {t2 : τ̇} {α : action} →
(t1 + α +> t1') →
((t1 ==>₁ t2) + α +> (t1' ==>₁ t2))
TMZip2 : {t2 t2' : τ̂} {t1 : τ̇} {α : action} →
(t2 + α +> t2') →
((t1 ==>₂ t2) + α +> (t1 ==>₂ t2'))
-- expression movement
-- todo: want this action to be direction, since they're all move?
data _+_+>e_ : (e : ê) → (α : action) → (e' : ê) → Set where
-- rules for ascriptions
EMAscFirstChild : {e : ė} {t : τ̇} →
(▹ e ·: t ◃) + move firstChild +>e (▹ e ◃ ·:₁ t)
EMAscParent1 : {e : ė} {t : τ̇} →
(▹ e ◃ ·:₁ t) + move parent +>e (▹ e ·: t ◃)
EMAscParent2 : {e : ė} {t : τ̇} →
(e ·:₂ ▹ t ◃) + move parent +>e (▹ e ·: t ◃)
EMAscNextSib : {e : ė} {t : τ̇} →
(▹ e ◃ ·:₁ t) + move nextSib +>e (e ·:₂ ▹ t ◃)
EMAscPrevSib : {e : ė} {t : τ̇} →
(e ·:₂ ▹ t ◃) + move prevSib +>e (▹ e ◃ ·:₁ t)
-- rules for lambdas
EMLamFirstChild : {e : ė} {x : Nat} →
▹ (·λ x e) ◃ + move firstChild +>e ·λ x (▹ e ◃)
EMLamParent : {e : ė} {x : Nat} →
·λ x (▹ e ◃) + move parent +>e ▹ (·λ x e) ◃
-- rules for 2-ary constructors
EMPlusFirstChild : {e1 e2 : ė} →
(▹ e1 ·+ e2 ◃) + move firstChild +>e (▹ e1 ◃ ·+₁ e2)
EMPlusParent1 : {e1 e2 : ė} →
(▹ e1 ◃ ·+₁ e2) + move parent +>e (▹ e1 ·+ e2 ◃)
EMPlusParent2 : {e1 e2 : ė} →
(e1 ·+₂ ▹ e2 ◃) + move parent +>e (▹ e1 ·+ e2 ◃)
EMPlusNextSib : {e1 e2 : ė} →
(▹ e1 ◃ ·+₁ e2) + move nextSib +>e (e1 ·+₂ ▹ e2 ◃)
EMPlusPrevSib : {e1 e2 : ė} →
(e1 ·+₂ ▹ e2 ◃) + move prevSib +>e (▹ e1 ◃ ·+₁ e2)
EMApFirstChild : {e1 e2 : ė} →
(▹ e1 ∘ e2 ◃) + move firstChild +>e (▹ e1 ◃ ∘₁ e2)
EMApParent1 : {e1 e2 : ė} →
(▹ e1 ◃ ∘₁ e2) + move parent +>e (▹ e1 ∘ e2 ◃)
EMApParent2 : {e1 e2 : ė} →
(e1 ∘₂ ▹ e2 ◃) + move parent +>e (▹ e1 ∘ e2 ◃)
EMApNextSib : {e1 e2 : ė} →
(▹ e1 ◃ ∘₁ e2) + move nextSib +>e (e1 ∘₂ ▹ e2 ◃)
EMApPrevSib : {e1 e2 : ė} →
(e1 ∘₂ ▹ e2 ◃) + move prevSib +>e (▹ e1 ◃ ∘₁ e2)
-- rules for non-empty holes
EMFHoleFirstChild : {e : ė} →
(▹ <| e |> ◃) + move firstChild +>e <| ▹ e ◃ |>
EMFHoleParent : {e : ė} →
<| ▹ e ◃ |> + move parent +>e (▹ <| e |> ◃)
mutual
-- synthetic action expressions
data _⊢_=>_~_~>_=>_ : (Γ : ·ctx) → (e1 : ê) → (t1 : τ̇)
→ (α : action) → (e2 : ê) → (t2 : τ̇) → Set where
SAMove : {δ : direction} {e e' : ê} {Γ : ·ctx} {t : τ̇} →
(e + move δ +>e e') →
Γ ⊢ e => t ~ move δ ~> e' => t
SADel : {Γ : ·ctx} {e : ė} {t : τ̇} →
Γ ⊢ ▹ e ◃ => t ~ del ~> ▹ <||> ◃ => <||>
SAConAsc : {Γ : ·ctx} {e : ė} {t : τ̇} →
Γ ⊢ ▹ e ◃ => t ~ construct asc ~> (e ·:₂ ▹ t ◃ ) => t
SAConVar : {Γ : ·ctx} {x : Nat} {t : τ̇} →
(p : (x , t) ∈ Γ) → -- todo: is this right?
Γ ⊢ ▹ <||> ◃ => <||> ~ construct (var x) ~> ▹ X x ◃ => t
SAConLam : {Γ : ·ctx} {x : Nat} →
(x # Γ) → -- todo: i added this; it doesn't appear in the text
Γ ⊢ ▹ <||> ◃ => <||> ~ construct (lam x) ~>
((·λ x <||>) ·:₂ (▹ <||> ◃ ==>₁ <||>)) => (<||> ==> <||>)
SAConAp1 : {Γ : ·ctx} {t1 t2 : τ̇} {e : ė} →
Γ ⊢ ▹ e ◃ => (t1 ==> t2) ~ construct ap ~> e ∘₂ ▹ <||> ◃ => t2
SAConAp2 : {Γ : ·ctx} {e : ė} →
Γ ⊢ ▹ e ◃ => <||> ~ construct ap ~> e ∘₂ ▹ <||> ◃ => <||>
SAConAp3 : {Γ : ·ctx} {t : τ̇} {e : ė} →
(t ~̸ (<||> ==> <||>)) →
Γ ⊢ ▹ e ◃ => t ~ construct ap ~> <| e |> ∘₂ ▹ <||> ◃ => <||>
SAConArg : {Γ : ·ctx} {e : ė} {t : τ̇} →
Γ ⊢ ▹ e ◃ => t ~ construct arg ~> ▹ <||> ◃ ∘₁ e => <||>
SAConNumlit : {Γ : ·ctx} {e : ė} {n : Nat} →
Γ ⊢ ▹ <||> ◃ => <||> ~ construct (numlit n) ~> ▹ N n ◃ => num
-- todo: these ought to look like ap, no? why are there two here and
-- three there? probably because of the induced type
-- structure. otherwise i would try to abstract this..
SAConPlus1 : {Γ : ·ctx} {e : ė} {t : τ̇} →
(t ~ num) →
Γ ⊢ ▹ e ◃ => t ~ construct plus ~> e ·+₂ ▹ <||> ◃ => num
SAConPlus2 : {Γ : ·ctx} {e : ė} {t : τ̇} →
(t ~̸ num) →
Γ ⊢ ▹ e ◃ => t ~ construct plus ~> <| e |> ·+₂ ▹ <||> ◃ => num
SAFinish : {Γ : ·ctx} {e : ė} {t : τ̇} →
(Γ ⊢ e => t) →
Γ ⊢ ▹ <| e |> ◃ => <||> ~ finish ~> ▹ e ◃ => t
SAZipAsc1 : {Γ : ·ctx} {e e' : ê} {α : action} {t : τ̇} →
(Γ ⊢ e ~ α ~> e' ⇐ t) →
Γ ⊢ (e ·:₁ t) => t ~ α ~> (e' ·:₁ t) => t
SAZipAsc2 : {Γ : ·ctx} {e : ė} {α : action} {t t' : τ̂} →
(t + α +> t') →
(Γ ⊢ e <= (t' ◆t)) → -- todo: this rule seems weirdly asymmetrical
Γ ⊢ (e ·:₂ t) => (t ◆t) ~ α ~> (e ·:₂ t') => (t' ◆t)
SAZipAp1 : {Γ : ·ctx} {t1 t2 t3 t4 : τ̇} {α : action} {eh eh' : ê} {e : ė} →
(Γ ⊢ (eh ◆e) => t2) →
(Γ ⊢ eh => t2 ~ α ~> eh' => (t3 ==> t4)) →
(Γ ⊢ e <= t3) →
Γ ⊢ (eh ∘₁ e) => t1 ~ α ~> (eh' ∘₁ e) => t4
SAZipAp2 : {Γ : ·ctx} {t1 t2 : τ̇} {α : action} {eh eh' : ê} {e : ė} →
(Γ ⊢ (eh ◆e) => t2) →
(Γ ⊢ eh => t2 ~ α ~> eh' => <||>) →
(Γ ⊢ e <= <||>) →
Γ ⊢ (eh ∘₁ e) => t1 ~ α ~> (eh' ∘₁ e) => <||>
SAZipAp3 : {Γ : ·ctx} {t2 t : τ̇} {e : ė} {eh eh' : ê} {α : action} →
(Γ ⊢ e => (t2 ==> t)) →
(Γ ⊢ eh ~ α ~> eh' ⇐ t2) →
Γ ⊢ (e ∘₂ eh) => t ~ α ~> (e ∘₂ eh') => t
SAZipAp4 : {Γ : ·ctx} {e : ė} {eh eh' : ê} {α : action} →
(Γ ⊢ e => <||>) →
(Γ ⊢ eh ~ α ~> eh' ⇐ <||>) →
Γ ⊢ (e ∘₂ eh) => <||> ~ α ~> (e ∘₂ eh') => <||>
SAZipPlus1 : {Γ : ·ctx} {e : ė} {eh eh' : ê} {α : action} →
(Γ ⊢ eh ~ α ~> eh' ⇐ num) →
Γ ⊢ (eh ·+₁ e) => num ~ α ~> (eh' ·+₁ e) => num
SAZipPlus2 : {Γ : ·ctx} {e : ė} {eh eh' : ê} {α : action} →
(Γ ⊢ eh ~ α ~> eh' ⇐ num) →
Γ ⊢ (e ·+₂ eh) => num ~ α ~> (e ·+₂ eh') => num
SAZipHole1 : {Γ : ·ctx} {e e' : ê} {t t' : τ̇} {α : action} →
(Γ ⊢ (e ◆e) => t) →
(Γ ⊢ e => t ~ α ~> e' => t') →
((e' == ▹ <||> ◃) → ⊥) →
Γ ⊢ <| e |> => <||> ~ α ~> <| e' |> => <||>
SAZipHole2 : {Γ : ·ctx} {e : ê} {t : τ̇} {α : action} →
(Γ ⊢ (e ◆e) => t) →
(Γ ⊢ e => t ~ α ~> ▹ <||> ◃ => <||>) →
Γ ⊢ <| e |> => <||> ~ α ~> ▹ <||> ◃ => <||>
-- analytic action expressions
data _⊢_~_~>_⇐_ : (Γ : ·ctx) → (e : ê) → (α : action) →
(e' : ê) → (t : τ̇) → Set where
AASubsume : {Γ : ·ctx} {e e' : ê} {t t' t'' : τ̇} {α : action} → -- troublemaker
{p : (α == construct asc → ⊥) × -- cyrus's proposed fix for two cases
((x : Nat) → (α == construct (lam x) → ⊥))} →
(Γ ⊢ (e ◆e) => t') →
(Γ ⊢ e => t' ~ α ~> e' => t'') →
(t ~ t'') →
Γ ⊢ e ~ α ~> e' ⇐ t
AAMove : {e e' : ê} {δ : direction} {Γ : ·ctx} {t : τ̇} →
(e + move δ +>e e') →
Γ ⊢ e ~ move δ ~> e' ⇐ t
AADel : {e : ė} {Γ : ·ctx} {t : τ̇} →
Γ ⊢ ▹ e ◃ ~ del ~> ▹ <||> ◃ ⇐ t
AAConAsc : {Γ : ·ctx} {e : ė} {t : τ̇} →
Γ ⊢ ▹ e ◃ ~ construct asc ~> (e ·:₂ ▹ t ◃) ⇐ t
AAConVar : {Γ : ·ctx} {t t' : τ̇} {x : Nat} →
(t ~̸ t') → -- todo: i don't understand this
(p : (x , t') ∈ Γ) → -- todo: is this right?
Γ ⊢ ▹ <||> ◃ ~ construct (var x) ~> <| ▹ X x ◃ |> ⇐ t
AAConLam1 : {Γ : ·ctx} {x : Nat} {t1 t2 : τ̇} →
(x # Γ) → -- todo: i added this
Γ ⊢ ▹ <||> ◃ ~ construct (lam x) ~>
·λ x (▹ <||> ◃) ⇐ (t1 ==> t2)
AAConLam2 : {Γ : ·ctx} {x : Nat} {t : τ̇} →
(x # Γ) → -- todo: i added this
(t ~̸ (<||> ==> <||>)) →
Γ ⊢ ▹ <||> ◃ ~ construct (lam x) ~>
<| ·λ x <||> ·:₂ (▹ <||> ◃ ==>₁ <||>) |> ⇐ t
AAConNumlit : {Γ : ·ctx} {t : τ̇} {n : Nat} →
(t ~̸ num) →
Γ ⊢ ▹ <||> ◃ ~ construct (numlit n) ~> <| ▹ (N n) ◃ |> ⇐ t
AAFinish : {Γ : ·ctx} {e : ė} {t : τ̇} →
(Γ ⊢ e <= t) →
Γ ⊢ ▹ <| e |> ◃ ~ finish ~> ▹ e ◃ ⇐ t
AAZipLam : {Γ : ·ctx} {x : Nat} {t1 t2 : τ̇} {e e' : ê} {α : action} →
(x # Γ) →
((Γ ,, (x , t1)) ⊢ e ~ α ~> e' ⇐ t2) →
Γ ⊢ (·λ x e) ~ α ~> (·λ x e') ⇐ (t1 ==> t2)
| {
"alphanum_fraction": 0.3959909797,
"avg_line_length": 39.7509960159,
"ext": "agda",
"hexsha": "97a5c44508c1166181748673f44a7762b21549dd",
"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": "86a755ca6749e080f9a03287e34d1cda889f1edb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "ivoysey/agda-tfp16",
"max_forks_repo_path": "Hazelnut-core.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "86a755ca6749e080f9a03287e34d1cda889f1edb",
"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": "ivoysey/agda-tfp16",
"max_issues_repo_path": "Hazelnut-core.agda",
"max_line_length": 87,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "86a755ca6749e080f9a03287e34d1cda889f1edb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hazelgrove/agda-tfp16",
"max_stars_repo_path": "Hazelnut-core.agda",
"max_stars_repo_stars_event_max_datetime": "2016-06-10T04:35:42.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-10T04:35:39.000Z",
"num_tokens": 8558,
"size": 19955
} |
module Issue259b where
postulate
R : Set
T : R → Set
I : Set
I = {x : R} → T x -- The code type checks if this Π is explicit.
data P : Set where
c : I → P
data D : P → Set where
c : (i : I) → D (c i)
-- When pattern matching we do want to eta contract implicit lambdas.
Foo : (i : I) → D (c i) → Set₁
Foo i (c .i) = Set
postulate
A : Set
B : A → Set
b : ({x : A} → B x) → A
C : A → Set
d : {x : A} → B x
e : A
e = b (λ {x} → d {x})
F : C e → Set₁
F _ with Set
F _ | _ = Set
| {
"alphanum_fraction": 0.516064257,
"avg_line_length": 14.6470588235,
"ext": "agda",
"hexsha": "eab5261faf0ffc9fe1bb7121bfdb362eca52ab2b",
"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/Issue259b.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/Issue259b.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/Issue259b.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": 207,
"size": 498
} |
{-# OPTIONS --without-K --rewriting #-}
open import PathInduction
open import Pushout
module JamesContractibility {i} (A : Type i) (⋆A : A) where
open import JamesTwoMaps A ⋆A public
-- We do not prove the flattening lemma here, we only prove that the following pushout is contractible
T : Type i
T = Pushout (span JA JA (A × JA) snd (uncurry αJ))
⋆T : T
⋆T = inl εJ
T-contr-inl-ε : inl εJ == ⋆T
T-contr-inl-ε = idp
T-contr-inl-α : (a : A) (x : JA) → inl x == ⋆T → inl (αJ a x) == ⋆T
T-contr-inl-α a x y = push (⋆A , αJ a x) ∙ ! (ap inr (δJ (αJ a x))) ∙ ! (push (a , x)) ∙ y
T-contr-inl-δ : (x : JA) (y : inl x == ⋆T) → Square (ap inl (δJ x)) y (T-contr-inl-α ⋆A x y) idp
T-contr-inl-δ x y = & coh (ap-square inr (& cη (ηJ x))) (natural-square (λ z → push (⋆A , z)) (δJ x) idp (ap-∘ inr (αJ ⋆A) (δJ x))) where
coh : Coh ({A : Type i} {a b : A} {p : a == b} {c : A} {q q' : c == b} (q= : Square q q' idp idp)
{d : A} {r : d == c} {e : A} {s : d == e} {t : d == a} (sq : Square r t q p)
→ Square t s (p ∙ ! q' ∙ ! r ∙ s) idp)
coh = path-induction
cη : Coh ({A : Type i} {a b : A} {p : a == b} {c : A} {q : a == c} {r : b == c} (ηJ : ! p ∙ q == r) → Square p q r idp)
cη = path-induction
T-contr-inl : (x : JA) → inl x == ⋆T
T-contr-inl = JA-elim T-contr-inl-ε T-contr-inl-α (λ x y → ↓-='-from-square idp (ap-cst ⋆T (δJ x)) (square-symmetry (T-contr-inl-δ x y)))
T-contr-inr : (x : JA) → inr x == ⋆T
T-contr-inr x = ap inr (δJ x) ∙ ! (push (⋆A , x)) ∙ T-contr-inl x
T-contr-push : (a : A) (x : JA) → Square (T-contr-inl x) (push (a , x)) idp (T-contr-inr (αJ a x))
T-contr-push a x = & coh where
coh : Coh ({A : Type i} {a b : A} {r : a == b} {c : A} {p : c == b} {d : A} {q : d == c} {e : A} {y : d == e}
→ Square y q idp (p ∙ ! r ∙ (r ∙ ! p ∙ ! q ∙ y)))
coh = path-induction
T-contr : (x : T) → x == ⋆T
T-contr = Pushout-elim T-contr-inl T-contr-inr (λ {(a , x) → ↓-='-from-square (ap-idf (push (a , x))) (ap-cst ⋆T (push (a , x))) (T-contr-push a x)})
| {
"alphanum_fraction": 0.5067064083,
"avg_line_length": 40.26,
"ext": "agda",
"hexsha": "d1860b77087e5a7c0887b820d2c05d925633a6ca",
"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": "89fbc29473d2d1ed1a45c3c0e56288cdcf77050b",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "guillaumebrunerie/JamesConstruction",
"max_forks_repo_path": "JamesContractibility.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "89fbc29473d2d1ed1a45c3c0e56288cdcf77050b",
"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": "guillaumebrunerie/JamesConstruction",
"max_issues_repo_path": "JamesContractibility.agda",
"max_line_length": 149,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "89fbc29473d2d1ed1a45c3c0e56288cdcf77050b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "guillaumebrunerie/JamesConstruction",
"max_stars_repo_path": "JamesContractibility.agda",
"max_stars_repo_stars_event_max_datetime": "2018-11-16T22:10:16.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-12-07T04:34:52.000Z",
"num_tokens": 940,
"size": 2013
} |
module FFI.Data.Scientific where
open import Agda.Builtin.Float using (Float)
open import FFI.Data.String using (String)
open import FFI.Data.HaskellString using (HaskellString; pack; unpack)
{-# FOREIGN GHC import qualified Data.Scientific #-}
{-# FOREIGN GHC import qualified Text.Show #-}
postulate Scientific : Set
{-# COMPILE GHC Scientific = type Data.Scientific.Scientific #-}
postulate
showHaskell : Scientific → HaskellString
toFloat : Scientific → Float
{-# COMPILE GHC showHaskell = \x -> Text.Show.show x #-}
{-# COMPILE GHC toFloat = \x -> Data.Scientific.toRealFloat x #-}
show : Scientific → String
show x = pack (showHaskell x)
| {
"alphanum_fraction": 0.7385321101,
"avg_line_length": 29.7272727273,
"ext": "agda",
"hexsha": "772d33677602f9b1684937a0fba66c5c2709a33f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "XanderYZZ/luau",
"max_forks_repo_path": "prototyping/FFI/Data/Scientific.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "XanderYZZ/luau",
"max_issues_repo_path": "prototyping/FFI/Data/Scientific.agda",
"max_line_length": 70,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "TheGreatSageEqualToHeaven/luau",
"max_stars_repo_path": "prototyping/FFI/Data/Scientific.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": 159,
"size": 654
} |
{-
This file document and export the main primitives of Cubical Agda. It
also defines some basic derived operations (composition and filling).
-}
{-# OPTIONS --cubical --safe #-}
module Cubical.Core.Primitives where
open import Agda.Builtin.Cubical.Path public
open import Agda.Builtin.Cubical.Sub public
renaming ( inc to inS
; primSubOut to outS
)
open import Agda.Primitive.Cubical public
renaming ( primIMin to _∧_ -- I → I → I
; primIMax to _∨_ -- I → I → I
; primINeg to ~_ -- I → I
; isOneEmpty to empty
; primComp to comp
; primHComp to hcomp
; primTransp to transp
; itIsOne to 1=1 )
open import Agda.Primitive public
using ( Level )
renaming ( lzero to ℓ-zero
; lsuc to ℓ-suc
; _⊔_ to ℓ-max
; Setω to Typeω )
open import Agda.Builtin.Sigma public
Type : (ℓ : Level) → Set (ℓ-suc ℓ)
Type ℓ = Set ℓ
Type₀ : Type (ℓ-suc ℓ-zero)
Type₀ = Type ℓ-zero
Type₁ : Type (ℓ-suc (ℓ-suc ℓ-zero))
Type₁ = Type (ℓ-suc ℓ-zero)
-- This file document the Cubical Agda primitives. The primitives
-- themselves are bound by the Agda files imported above.
-- * The Interval
-- I : Typeω
-- Endpoints, Connections, Reversal
-- i0 i1 : I
-- _∧_ _∨_ : I → I → I
-- ~_ : I → I
-- * Dependent path type. (Path over Path)
-- Introduced with lambda abstraction and eliminated with application,
-- just like function types.
-- PathP : ∀ {ℓ} (A : I → Type ℓ) → A i0 → A i1 → Type ℓ
infix 4 _[_≡_]
_[_≡_] : ∀ {ℓ} (A : I → Type ℓ) → A i0 → A i1 → Type ℓ
_[_≡_] = PathP
-- Non dependent path types
Path : ∀ {ℓ} (A : Type ℓ) → A → A → Type ℓ
Path A a b = PathP (λ _ → A) a b
-- PathP (λ i → A) x y gets printed as x ≡ y when A does not mention i.
-- _≡_ : ∀ {ℓ} {A : Type ℓ} → A → A → Type ℓ
-- _≡_ {A = A} = PathP (λ _ → A)
-- * @IsOne r@ represents the constraint "r = i1".
-- Often we will use "φ" for elements of I, when we intend to use them
-- with IsOne (or Partial[P]).
-- IsOne : I → Typeω
-- i1 is indeed equal to i1.
-- 1=1 : IsOne i1
-- * Types of partial elements, and their dependent version.
-- "Partial φ A" is a special version of "IsOne φ → A" with a more
-- extensional judgmental equality.
-- "PartialP φ A" allows "A" to be defined only on "φ".
-- Partial : ∀ {ℓ} → I → Type ℓ → Typeω
-- PartialP : ∀ {ℓ} → (φ : I) → Partial φ (Type ℓ) → Typeω
-- Partial elements are introduced by pattern matching with (r = i0)
-- or (r = i1) constraints, like so:
private
sys : ∀ i → Partial (i ∨ ~ i) Type₁
sys i (i = i0) = Type₀
sys i (i = i1) = Type₀ → Type₀
-- It also works with pattern matching lambdas:
-- http://wiki.portal.chalmers.se/agda/pmwiki.php?n=ReferenceManual.PatternMatchingLambdas
sys' : ∀ i → Partial (i ∨ ~ i) Type₁
sys' i = λ { (i = i0) → Type₀
; (i = i1) → Type₀ → Type₀
}
-- When the cases overlap they must agree.
sys2 : ∀ i j → Partial (i ∨ (i ∧ j)) Type₁
sys2 i j = λ { (i = i1) → Type₀
; (i = i1) (j = i1) → Type₀
}
-- (i0 = i1) is actually absurd.
sys3 : Partial i0 Type₁
sys3 = λ { () }
-- * There are cubical subtypes as in CCHM. Note that these are not
-- fibrant (hence in Typeω):
_[_↦_] : ∀ {ℓ} (A : Type ℓ) (φ : I) (u : Partial φ A) → Typeω
A [ φ ↦ u ] = Sub A φ u
infix 4 _[_↦_]
-- Any element u : A can be seen as an element of A [ φ ↦ u ] which
-- agrees with u on φ:
-- inS : ∀ {ℓ} {A : Type ℓ} {φ} (u : A) → A [ φ ↦ (λ _ → u) ]
-- One can also forget that an element agrees with u on φ:
-- outS : ∀ {ℓ} {A : Type ℓ} {φ : I} {u : Partial φ A} → A [ φ ↦ u ] → A
-- * Composition operation according to [CCHM 18].
-- When calling "comp A φ u a" Agda makes sure that "a" agrees with "u i0" on "φ".
-- compCCHM : ∀ {ℓ} (A : (i : I) → Type ℓ) (φ : I) (u : ∀ i → Partial φ (A i)) (a : A i0) → A i1
-- Note: this is not recommended to use, instead use the CHM
-- primitives! The reason is that these work with HITs and produce
-- fewer empty systems.
-- * Generalized transport and homogeneous composition [CHM 18].
-- When calling "transp A φ a" Agda makes sure that "A" is constant on "φ".
-- transp : ∀ {ℓ} (A : I → Type ℓ) (φ : I) (a : A i0) → A i1
-- When calling "hcomp A φ u a" Agda makes sure that "a" agrees with "u i0" on "φ".
-- hcomp : ∀ {ℓ} {A : Type ℓ} {φ : I} (u : I → Partial φ A) (a : A) → A
private
variable
ℓ : Level
ℓ′ : I → Level
-- Homogeneous filling
hfill : {A : Type ℓ}
{φ : I}
(u : ∀ i → Partial φ A)
(u0 : A [ φ ↦ u i0 ])
-----------------------
(i : I) → A
hfill {φ = φ} u u0 i =
hcomp (λ j → λ { (φ = i1) → u (i ∧ j) 1=1
; (i = i0) → outS u0 })
(outS u0)
-- Heterogeneous composition can defined as in CHM, however we use the
-- builtin one as it doesn't require u0 to be a cubical subtype. This
-- reduces the number of inS's a lot.
-- comp : (A : ∀ i → Type (ℓ′ i))
-- {φ : I}
-- (u : ∀ i → Partial φ (A i))
-- (u0 : A i0 [ φ ↦ u i0 ])
-- → ---------------------------
-- A i1
-- comp A {φ = φ} u u0 =
-- hcomp (λ i → λ { (φ = i1) → transp (λ j → A (i ∨ j)) i (u _ 1=1) })
-- (transp A i0 (outS u0))
-- Heterogeneous filling defined using comp
fill : (A : ∀ i → Type (ℓ′ i))
{φ : I}
(u : ∀ i → Partial φ (A i))
(u0 : A i0 [ φ ↦ u i0 ])
---------------------------
(i : I) → A i
fill A {φ = φ} u u0 i =
comp (λ j → A (i ∧ j))
(λ j → λ { (φ = i1) → u (i ∧ j) 1=1
; (i = i0) → outS u0 })
(outS u0)
-- Σ-types
infix 2 Σ-syntax
Σ-syntax : ∀ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') → Type (ℓ-max ℓ ℓ')
Σ-syntax = Σ
syntax Σ-syntax A (λ x → B) = Σ[ x ∈ A ] B
| {
"alphanum_fraction": 0.5338590777,
"avg_line_length": 28.3155339806,
"ext": "agda",
"hexsha": "a07d80f7b3ebcf127574aaa317e86ef9a82f6f63",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "limemloh/cubical",
"max_forks_repo_path": "Cubical/Core/Primitives.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "limemloh/cubical",
"max_issues_repo_path": "Cubical/Core/Primitives.agda",
"max_line_length": 96,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "limemloh/cubical",
"max_stars_repo_path": "Cubical/Core/Primitives.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2123,
"size": 5833
} |
module lambda.system-f where
open import Data.Nat
open import Data.Fin hiding (lift)
open import lambda.vec
open import lambda.untyped hiding (lift; subst; ↑; subst₁)
infixr 22 _⇒_
infix 20 ∀'_
data type (n : ℕ) : Set where
var : Fin n → type n
∀'_ : type (suc n) → type n
_⇒_ : type n → type n → type n
type₀ : Set
type₀ = type 0
context : ℕ → ℕ → Set
context n = vec (type n)
lift : ∀ {n} → type n → type (suc n)
lift (var i) = var (suc i)
lift (∀' x) = ∀' (lift x)
lift (x ⇒ y) = lift x ⇒ lift y
↑ : ∀ {n m} → (Fin n → type m) → Fin (suc n) → type (suc m)
↑ ρ zero = var zero
↑ ρ (suc i) = lift (ρ i)
subst : ∀ {n m} → type n → (Fin n → type m) → type m
subst (var x) ρ = ρ x
subst (∀' x) ρ = ∀' (subst x (↑ ρ))
subst (x ⇒ y) ρ = (subst x ρ) ⇒ (subst y ρ)
idˢ : ∀ {n} → Fin n → type n
idˢ i = var i
_∘ˢ_ : ∀ {n m p} → (Fin m → type p) → (Fin n → type m) → (Fin n → type p)
(ρ ∘ˢ μ) i = subst (μ i) ρ
1ˢ : ∀ {n} → type n → Fin (suc n) → type n
1ˢ x zero = x
1ˢ x (suc i) = var i
_∷ˢ_ : ∀ {n m} → type m → (Fin n → type m) → Fin (suc n) → type m
(e ∷ˢ ρ) zero = e
(e ∷ˢ ρ) (suc i) = ρ i
subst₁ : ∀ {n} → type (suc n) → type n → type n
subst₁ x y = subst x (1ˢ y)
lift-c : ∀ {n m} → context n m → context (suc n) m
lift-c ε = ε
lift-c (Γ ▸ x) = lift-c Γ ▸ lift x
infix 10 _⊢_∶_
data _⊢_∶_ {n m : ℕ} (Γ : context n m) : term m → type n → Set where
ax : ∀ {i} → Γ ⊢ var i ∶ lookup i Γ
lam : ∀ {B x} → (A : type n) → Γ ▸ A ⊢ x ∶ B → Γ ⊢ lam x ∶ A ⇒ B
app : ∀ {A B x y} → Γ ⊢ x ∶ A ⇒ B → Γ ⊢ y ∶ A → Γ ⊢ app x y ∶ B
gen : ∀ {A x} → lift-c Γ ⊢ x ∶ A → Γ ⊢ x ∶ ∀' A
sub : ∀ {A x} → (B : type n) → Γ ⊢ x ∶ ∀' A → Γ ⊢ x ∶ subst₁ A B
⊢_∶_ : ∀ {n} → term 0 → type n → Set
⊢ x ∶ t = ε ⊢ x ∶ t
| {
"alphanum_fraction": 0.4976689977,
"avg_line_length": 24.8695652174,
"ext": "agda",
"hexsha": "72d2bb66d97013cf9c572fff18fad79ade4a5951",
"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": "09a231d9b3057d57b864070188ed9fe14a07eda2",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "Lapin0t/lambda",
"max_forks_repo_path": "lambda/system-f.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "09a231d9b3057d57b864070188ed9fe14a07eda2",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "Lapin0t/lambda",
"max_issues_repo_path": "lambda/system-f.agda",
"max_line_length": 73,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "09a231d9b3057d57b864070188ed9fe14a07eda2",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "Lapin0t/lambda",
"max_stars_repo_path": "lambda/system-f.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 826,
"size": 1716
} |
open import TypeTheory.Nat.Mono.Structure
module TypeTheory.Nat.Mono.Properties (nat : Nat) where
open import Level renaming (zero to lzero; suc to lsuc)
open import Data.Empty using (⊥)
open import Data.Product using (Σ; _×_; _,_)
open import Data.Sum
open import Relation.Binary using (Rel)
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary using (¬_)
open import Function.Base
open Nat nat
+-suc : ∀ m n → suc m + n ≡ suc (m + n)
+-suc m n = rec-suc _ _ _
+-identityˡ : ∀ n → zero + n ≡ n
+-identityˡ n = rec-zero _ _
+-identityʳ : ∀ n → n + zero ≡ n
+-identityʳ n = ind (λ k → k + zero ≡ k) (+-identityˡ zero)
(λ k k+z≡k → trans (+-suc k zero) (cong suc k+z≡k) )
n
1N+n≡sn : ∀ n → 1N + n ≡ suc n
1N+n≡sn n = begin
suc zero + n ≡⟨ +-suc zero n ⟩
suc (zero + n) ≡⟨ cong suc (+-identityˡ n) ⟩
suc n ∎
where open ≡-Reasoning
+-suc-comm : ∀ m n → suc m + n ≡ m + suc n
+-suc-comm m n =
ind
(λ o → suc o + n ≡ o + suc n)
(begin
suc zero + n ≡⟨ 1N+n≡sn n ⟩
suc n ≡⟨ sym $ +-identityˡ (suc n) ⟩
zero + suc n ∎)
(λ o so+n≡o+sn → begin
suc (suc o) + n ≡⟨ +-suc (suc o) n ⟩
suc (suc o + n) ≡⟨ cong suc so+n≡o+sn ⟩
suc (o + suc n) ≡⟨ sym $ +-suc o (suc n) ⟩
suc o + suc n ∎)
m
where open ≡-Reasoning
z≤n : ∀ n → zero ≤ n
z≤n n = n , +-identityˡ n
≤-step : ∀ {m n} → m ≤ n → m ≤ suc n
≤-step {m} {n} (o , m+o≡n) = suc o , (begin
m + suc o ≡⟨ sym $ +-suc-comm m o ⟩
suc m + o ≡⟨ +-suc m o ⟩
suc (m + o) ≡⟨ cong suc m+o≡n ⟩
suc n ∎)
where open ≡-Reasoning
≤-refl : ∀ {n} → n ≤ n
≤-refl {n} = zero , +-identityʳ n
s≤s : ∀ {m n} → m ≤ n → suc m ≤ suc n
s≤s {m} {n} (o , m+o≡n) = o , trans (+-suc m o) (cong suc m+o≡n)
s<s : ∀ {m n} → m < n → suc m < suc n
s<s = s≤s
z<s : ∀ n → zero < suc n
z<s n = s≤s (z≤n n)
n<sn : ∀ n → n < suc n
n<sn n = ≤-refl {suc n}
≤⇒<∨≡ : ∀ {m n} → m ≤ n → m < n ⊎ m ≡ n
≤⇒<∨≡ {m} {n} (o , m+o≡n) =
ind (λ k → m + k ≡ n → m < n ⊎ m ≡ n)
(λ m+z≡n → inj₂ (trans (sym $ +-identityʳ m) m+z≡n))
(λ k _ m+sk≡n → inj₁ (k , (trans (+-suc-comm m k) m+sk≡n)))
o
m+o≡n
data Order (m n : N) : Set where
less : (m<n : m < n) → Order m n
equal : (m≡n : m ≡ n) → Order m n
greater : (m>n : m > n) → Order m n
order? : ∀ m n → Order m n
order? m₀ n₀ = ind (λ m → Order m n₀) order?-zero order?-suc m₀
where
order?-zero : Order zero n₀
order?-zero = ind (Order zero) (equal refl) (λ _ _ → less (z<s _)) n₀
order?-suc : ∀ m → Order m n₀ → Order (suc m) n₀
order?-suc m (less sm≤n) with ≤⇒<∨≡ sm≤n
... | inj₁ sm<n = less sm<n
... | inj₂ sm≡n = equal sm≡n
order?-suc m (equal refl) = greater (n<sn _)
order?-suc m (greater m>n) = greater (≤-step m>n)
-- indΔ :
module _ (P : N → N → Set) where
indΔ : P zero zero →
(∀ n → P zero (suc n)) →
(∀ m → P (suc m) zero) →
(∀ m n → P m n → P (suc m) (suc n)) →
∀ m n → P m n
indΔ Pzz Pzs Psz Pss m n with order? m n
... | less m<n = {! !}
... | equal m≡n = {! !}
... | greater m>n = {! !}
| {
"alphanum_fraction": 0.4912336627,
"avg_line_length": 27.7610619469,
"ext": "agda",
"hexsha": "5289f0cb2dc6365e3cf900f3773c6cf93c6878ef",
"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": "TypeTheory/Nat/Mono/Properties.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": "TypeTheory/Nat/Mono/Properties.agda",
"max_line_length": 72,
"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": "TypeTheory/Nat/Mono/Properties.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": 1420,
"size": 3137
} |
module _ where
infixr 5 _⇒_
infixl 6 _▻_
infix 3 _⊢_ _∈_
infixr 5 vs_
infixr 4 ƛ_
infixl 6 _·_
data Type : Set where
ι : Type
_⇒_ : Type → Type → Type
data Con : Set where
ε : Con
_▻_ : Con → Type → Con
data _∈_ σ : Con → Set where
vz : ∀ {Γ} → σ ∈ Γ ▻ σ
vs_ : ∀ {Γ τ} → σ ∈ Γ → σ ∈ Γ ▻ τ
data _⊢_ Γ : Type → Set where
var : ∀ {σ} → σ ∈ Γ → Γ ⊢ σ
ƛ_ : ∀ {σ τ} → Γ ▻ σ ⊢ τ → Γ ⊢ σ ⇒ τ
_·_ : ∀ {σ τ} → Γ ⊢ σ ⇒ τ → Γ ⊢ σ → Γ ⊢ τ
Term : Type → Set
Term σ = ε ⊢ σ
postulate
_extends_ : Con → Con → Set
instance
extends-stop : ∀ {Γ} → Γ extends Γ
extends-skip : ∀ {Γ Δ σ} {{_ : Δ extends Γ}} → (Δ ▻ σ) extends Γ
lam : ∀ {Γ σ τ} → ((∀ {Δ} {{_ : Δ extends (Γ ▻ σ)}} → Δ ⊢ σ) → Γ ▻ σ ⊢ τ) → Γ ⊢ σ ⇒ τ
I : Term (ι ⇒ ι)
I = lam λ x → x
K : Term (ι ⇒ ι ⇒ ι)
K = lam λ x → lam λ y → x
A : Term ((ι ⇒ ι) ⇒ ι ⇒ ι)
A = lam λ f → lam λ x → f {{extends-skip {{extends-stop}}}} · x
{{extends-stop}}
loop : Term ((ι ⇒ ι) ⇒ ι ⇒ ι)
loop = lam λ f → lam λ x → f · x
| {
"alphanum_fraction": 0.4490384615,
"avg_line_length": 20,
"ext": "agda",
"hexsha": "6f9f27a91b072d37069108df575e3daa20e81490",
"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/Issue1532.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/Issue1532.agda",
"max_line_length": 87,
"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/Issue1532.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": 497,
"size": 1040
} |
-- TODO: use StrictTotalOrder for QName representation
module Syntax (QName : Set) where
open import Data.Nat.Base
open import Data.Nat.Properties using (+-suc; +-identityʳ)
open import Data.List.Base hiding (_∷ʳ_)
open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong; sym; trans)
-- Well-scoped de Bruijn indices
-- n is the length of the context
data Var : ℕ → Set where
vzero : ∀{n} → Var (suc n)
vsuc : ∀{n} (x : Var n) → Var (suc n)
-- Example: in context x,y,z (so n = 3)
-- x is vsuc (vsuc vzero) : Var 3
-- y is vsuc vzero : Var 3
-- z is vzero : Var 3
-- Qualified names
DRName = QName -- datatype / record name
FuncName = QName -- function name
ProjName = QName -- projection name (overloaded)
ConsName = QName -- datatype / record constructor name (overloaded)
-- Data or record constructors
data ConHead : Set where
dataCon : DRName → ConHead
recCon : DRName → (fs : List ProjName) → ConHead
-- Sorts are Set₀, Set₁, ...
data Sort : Set where
uni : (ℓ : ℕ) → Sort
-- In the following definition of well-scoped syntax,
-- n is always the length of the context.
mutual
data Term (n : ℕ) : Set where
var : (x : Var n) (es : Elims n) → Term n
def : (f : FuncName) (es : Elims n) → Term n
con : (c : ConHead) (vs : Args n) → Term n -- Fully applied
lam : (v : Term (suc n)) → Term n
-- Types
dat : (d : DRName) (vs : Args n) → Term n -- Fully applied
sort : (s : Sort) → Term n
pi : (u : Term n) (v : Term (suc n)) → Term n
data Elim (n : ℕ) : Set where
apply : (u : Term n) → Elim n
proj : (π : ProjName) → Elim n
Elims : (n : ℕ) → Set
Elims n = List (Elim n)
Args : (n : ℕ) → Set
Args n = List (Term n)
-- Example: (A : Set) (x : A) → A
-- is represented by
exTyId : Term 0
exTyId = pi (sort (uni 0)) (pi (var vzero []) (var (vsuc vzero) []))
-- Looking up a field in a field-value collection
-- TODO: Do we want to ensure |fs| = |vs| ?
data LookupField {a} {A : Set a} : (fs : List ProjName) (vs : List A) (f : ProjName) (v : A) → Set where
here : ∀{f fs v vs}
→ LookupField (f ∷ fs) (v ∷ vs) f v
there : ∀{f f' fs v v' vs}
→ LookupField fs vs f v
→ LookupField (f' ∷ fs) (v' ∷ vs) f v
-- Renamings represented as functions
Renaming : (Γ Δ : ℕ) → Set
Renaming Γ Δ = Var Δ → Var Γ
weak : ∀{Γ} → Renaming (suc Γ) Γ
weak x = vsuc x
-- If Γ ⊢ ρ : Δ
-- then Γ,x ⊢ liftRen ρ : Δ,x.
liftRen : ∀{Γ Δ} → Renaming Γ Δ → Renaming (suc Γ) (suc Δ)
liftRen ρ vzero = vzero
liftRen ρ (vsuc x) = vsuc (ρ x)
-- We need sized types to show termination of rename.
{-# TERMINATING #-}
mutual
rename : ∀{Γ Δ} (ρ : Renaming Γ Δ) (t : Term Δ) → Term Γ
rename ρ (var x es) = var (ρ x) (map (renameElim ρ) es)
rename ρ (def f es) = def f (map (renameElim ρ) es)
rename ρ (con c vs) = con c (map (rename ρ) vs)
rename ρ (lam t) = lam (rename (liftRen ρ) t)
rename ρ (dat d vs) = dat d (map (rename ρ) vs)
rename ρ (sort s) = sort s
rename ρ (pi u v) = pi (rename ρ u) (rename (liftRen ρ) v)
renameElim : ∀{Γ Δ} (ρ : Renaming Γ Δ) (e : Elim Δ) → Elim Γ
renameElim ρ (apply u) = apply (rename ρ u)
renameElim ρ (proj π) = proj π
-- Substitutions represented as functions
-- σ : Subst Γ Δ applies to a term living in context Δ
-- and turns it into a term living in context Γ
Substitution : (Γ Δ : ℕ) → Set
Substitution Γ Δ = Var Δ → Term Γ
liftSub : ∀{Γ Δ} (σ : Substitution Γ Δ) → Substitution (suc Γ) (suc Δ)
liftSub σ vzero = var vzero []
liftSub σ (vsuc x) = rename weak (σ x)
-- Substitute for the last variable (vzero)
sg : ∀{Γ} (u : Term Γ) → Substitution Γ (suc Γ)
sg {Γ} u vzero = u
sg {Γ} u (vsuc x) = var x []
data All₂ {A B : Set} (R : A → B → Set) : List A → List B → Set where
nil : All₂ R [] []
cons : ∀{x y xs ys}
→ R x y
→ All₂ R xs ys
→ All₂ R (x ∷ xs) (y ∷ ys)
mutual
data Apply {Γ} : (t : Term Γ) (es : Elims Γ) (v : Term Γ) → Set where
empty : ∀{t}
→ Apply t [] t
var : ∀{x es es'}
→ Apply (var x es) es' (var x (es ++ es'))
def : ∀{f es es'}
→ Apply (def f es) es' (def f (es ++ es'))
proj : ∀{ c πs vs π es u v}
→ LookupField πs vs π u
→ Apply u es v
→ Apply (con (recCon c πs) vs) (proj π ∷ es) v
lam : ∀{t t' u v es}
→ SubstTerm (sg u) t t'
→ Apply t' es v
→ Apply (lam t) (apply u ∷ es) v
data SubstTerm {Γ Δ} (σ : Substitution Γ Δ) : Term Δ → Term Γ → Set where
var : ∀{x : Var Δ} {es : Elims Δ} {v : Term Γ} {es' : Elims Γ}
→ All₂ (SubstElim σ) es es'
→ Apply (σ x) es' v
→ SubstTerm σ (var x es) v
def : ∀{f : FuncName} {es : Elims Δ} {es' : Elims Γ}
→ All₂ (SubstElim σ) es es'
→ SubstTerm σ (def f es) (def f es')
con : ∀{c : ConHead} {vs : Args Δ} {vs' : Args Γ}
→ All₂ (SubstTerm σ) vs vs'
→ SubstTerm σ (con c vs) (con c vs')
lam : ∀{v : Term (suc Δ)} {v'}
→ SubstTerm (liftSub σ) v v'
→ SubstTerm σ (lam v) (lam v')
dat : ∀{d : DRName} {vs : Args Δ} {vs' : Args Γ}
→ All₂ (SubstTerm σ) vs vs'
→ SubstTerm σ (dat d vs) (dat d vs')
pi : ∀{U V U' V'}
→ SubstTerm σ U U'
→ SubstTerm (liftSub σ) V V'
→ SubstTerm σ (pi U V) (pi U' V')
sort : ∀{s : Sort}
→ SubstTerm σ (sort s) (sort s)
data SubstElim {Γ Δ} (σ : Substitution Γ Δ) : Elim Δ → Elim Γ → Set where
apply : ∀{u u'}
→ SubstTerm σ u u'
→ SubstElim σ (apply u) (apply u')
proj : ∀{π}
→ SubstElim σ (proj π) (proj π)
data FunctionApply {Γ} : (T : Term Γ) (us : Args Γ) (U : Term Γ) → Set where
empty : ∀{T}
→ FunctionApply T [] T
pi : ∀{u us T U V V'}
→ SubstTerm (sg u) V V'
→ FunctionApply V' us T
→ FunctionApply (pi U V) (u ∷ us) T
-- n is the length of the context
data Context : (n : ℕ) → Set where
[] : Context zero
_∷ʳ_ : ∀{n} → Context n → Term n → Context (suc n)
-- n is the size of the outer context; m is the size of the telescope
data Telescope (n : ℕ) : (m : ℕ) → Set where
[] : Telescope n zero
_∷_ : ∀{m} → Term n → Telescope (suc n) m → Telescope n (suc m)
telescopeSize : ∀{n m} → Telescope n m → ℕ
telescopeSize {m = m} _ = m
suc-move : (m n : ℕ) → m + suc n ≡ suc m + n
suc-move zero n = refl
suc-move (suc m) n = cong suc (+-suc m n)
-- Add a telescope to a compatible outer context.
addToContext : ∀{n m} → Context n → Telescope n m → Context (n + m)
addToContext {n} Γ [] rewrite +-identityʳ n = Γ
addToContext {n} {.(suc m)} Γ (_∷_ {m = m} x t) rewrite suc-move n m = addToContext (Γ ∷ʳ x) t
expandTelescope : ∀ {n m} → Telescope n m → Term (n + m) → Term n
expandTelescope {n} [] T rewrite +-identityʳ n = T
expandTelescope {n} {suc m} (U ∷ Δ) T rewrite suc-move n m =
pi U (expandTelescope Δ T)
data Pattern (n : ℕ) : Set where
pvariable : Var n → Pattern n
pconstructor : ConsName → List (Pattern n) → Pattern n
pinaccesssible : Term n → Pattern n
data Copattern (n : ℕ) : Set where
capply : Pattern n → Copattern n
cproj : ProjName → Copattern n
record ConsDeclaration (n : ℕ) : Set where
constructor mkConsDeclaration
field
consName : ConsName
consType : Term n
record ProjDeclaration (n : ℕ) : Set where
constructor mkProjDeclaration
field
projName : ProjName
projType : Term n
record DataSignature : Set where
constructor mkDataSignature
field
name : DRName
{numParams} : ℕ
{numIndices} : ℕ
params : Telescope zero numParams
indices : Telescope numParams numIndices
dsort : Sort
record DataDefinition : Set where
field
name : DRName
{numParams} : ℕ
params : Telescope zero numParams
constructors : List (ConsDeclaration numParams)
record RecordSignature : Set where
constructor mkRecordSignature
field
name : DRName
{numParams} : ℕ
params : Telescope zero numParams
dsort : Sort
record RecordDefinition : Set where
field
name : DRName
{numParams} : ℕ
params : Telescope zero numParams
fconstructor : ConsName
fields : List (ProjDeclaration numParams)
-- TODO: Update spec
record FuncClause : Set where
field
ctxSize : ℕ
ctx : Context ctxSize
name : FuncName
spine : List (Copattern ctxSize)
rhs : Term ctxSize
-- TODO: How to represent pattern variables?
data Declaration : Set where
typeSignature : FuncName → Term zero → Declaration
functionClause : FuncClause → Declaration
dataSignature : DataSignature → Declaration
dataDefinition : DataDefinition → Declaration
recordSignature : RecordSignature → Declaration
recordDefinition : RecordDefinition → Declaration
-- TODO: Update signature declarations
data SignatureDeclaration : Set where
dataSig : (D : DataSignature) → List (ConsDeclaration (DataSignature.numParams D)) →
SignatureDeclaration
recordSig : (R : RecordSignature) → ConsDeclaration (RecordSignature.numParams R) →
List (ProjDeclaration (RecordSignature.numParams R)) → SignatureDeclaration
functionSig : FuncName → Term zero → List FuncClause → SignatureDeclaration
Signature : Set
Signature = List SignatureDeclaration
data LookupSig : Signature → SignatureDeclaration → Set where
here : ∀{sd sds}
→ LookupSig (sd ∷ sds) sd
there : ∀{sd sd' sds}
→ LookupSig sds sd
→ LookupSig (sd' ∷ sds) sd
data LookupCons : ∀{m} → List (ConsDeclaration m) → ConsName → Term m → Set where
here : ∀{c m} {T : Term m} {cs : List (ConsDeclaration m)}
→ LookupCons {m} (mkConsDeclaration c T ∷ cs) c T
there : ∀{c c' m} {T : Term m} {T' : Term m} {cs : List (ConsDeclaration m)}
→ LookupCons cs c T
→ LookupCons (mkConsDeclaration c' T' ∷ cs) c T
data LookupProj : ∀{m} → List (ProjDeclaration m) → ProjName → Term m → Set where
here : ∀{π m} {T : Term m} {πs : List (ProjDeclaration m)}
→ LookupProj (mkProjDeclaration π T ∷ πs) π T
there : ∀ {π π' m} {πs : List (ProjDeclaration m)} {T : Term m} {T' : Term m}
→ LookupProj πs π T
→ LookupProj (mkProjDeclaration π' T' ∷ πs) π T
data SigLookup : ∀{m} → Signature → QName → Term m → Set where
func : ∀{Σ f T cls} → LookupSig Σ (functionSig f T cls) → SigLookup Σ f T
dat : ∀{Σ D m m' s cs} {Δ : Telescope zero m} {Δ' : Telescope m m'} →
LookupSig Σ (dataSig (mkDataSignature D {m} {m'} Δ Δ' s) cs) →
SigLookup Σ D (expandTelescope Δ (expandTelescope Δ' (sort s)))
con : ∀{Σ D m m' s cs c T} {Δ : Telescope zero m} {Δ' : Telescope m m'} →
LookupSig Σ (dataSig (mkDataSignature D {m} {m'} Δ Δ' s) cs) →
LookupCons cs c T →
SigLookup Σ c (expandTelescope Δ T)
rec : ∀{Σ R m s c ps} {Δ : Telescope zero m} →
LookupSig Σ (recordSig (mkRecordSignature R Δ s) c ps) →
SigLookup Σ R (expandTelescope Δ (sort s))
rcon : ∀{Σ R m s c T πs} {Δ : Telescope zero m} →
LookupSig Σ (recordSig (mkRecordSignature R Δ s) (mkConsDeclaration c T) πs) →
SigLookup Σ c (expandTelescope Δ T)
rproj : ∀{Σ R m s c π T πs} {Δ : Telescope zero m} →
LookupSig Σ (recordSig (mkRecordSignature R Δ s) (mkConsDeclaration c T) πs) →
LookupProj πs π T →
SigLookup Σ π (expandTelescope Δ T)
| {
"alphanum_fraction": 0.5933333333,
"avg_line_length": 30.8943089431,
"ext": "agda",
"hexsha": "cb9a12dafe1220a44931aa8fda459e474b29705f",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:50.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-05-11T10:44:08.000Z",
"max_forks_repo_head_hexsha": "7ef5f2fd8057b27fd3bc9d171283ccaeceec9c79",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "agda/agda-spec",
"max_forks_repo_path": "agda/Syntax.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "7ef5f2fd8057b27fd3bc9d171283ccaeceec9c79",
"max_issues_repo_issues_event_max_datetime": "2019-01-13T13:00:20.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-05-12T12:33:48.000Z",
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "agda/agda-spec",
"max_issues_repo_path": "agda/Syntax.agda",
"max_line_length": 104,
"max_stars_count": 24,
"max_stars_repo_head_hexsha": "7ef5f2fd8057b27fd3bc9d171283ccaeceec9c79",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "agda/agda-spec",
"max_stars_repo_path": "agda/Syntax.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-15T09:09:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-05-09T12:25:36.000Z",
"num_tokens": 3910,
"size": 11400
} |
open import Data.Product using ( _×_ ; _,_ )
open import Web.Semantic.DL.ABox.Model using ( _⊨a_ ; ⊨a-resp-≲ )
open import Web.Semantic.DL.ABox.Interp using ( Interp ; ⌊_⌋ )
open import Web.Semantic.DL.ABox.Interp.Morphism using ( _≃_ ; ≃⌊_⌋ ; ≃-impl-≲ )
open import Web.Semantic.DL.KB using ( KB ; tbox ; abox )
open import Web.Semantic.DL.Signature using ( Signature )
open import Web.Semantic.DL.TBox.Model using ( _⊨t_ ; ⊨t-resp-≃ )
module Web.Semantic.DL.KB.Model {Σ : Signature} {X : Set} where
infixr 2 _⊨_
_⊨_ : Interp Σ X → KB Σ X → Set
I ⊨ K = (⌊ I ⌋ ⊨t tbox K) × (I ⊨a abox K)
Interps : KB Σ X → Interp Σ X → Set
Interps K I = I ⊨ K
⊨-resp-≃ : ∀ {I J} → (I ≃ J) → ∀ K → (I ⊨ K) → (J ⊨ K)
⊨-resp-≃ I≃J K (I⊨T , I⊨A) =
(⊨t-resp-≃ ≃⌊ I≃J ⌋ (tbox K) I⊨T , ⊨a-resp-≲ (≃-impl-≲ I≃J) (abox K) I⊨A)
| {
"alphanum_fraction": 0.5933250927,
"avg_line_length": 36.7727272727,
"ext": "agda",
"hexsha": "7564333435284e1d48032a7952bc8359c698de06",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z",
"max_forks_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/agda-web-semantic",
"max_forks_repo_path": "src/Web/Semantic/DL/KB/Model.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
"max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/agda-web-semantic",
"max_issues_repo_path": "src/Web/Semantic/DL/KB/Model.agda",
"max_line_length": 80,
"max_stars_count": 9,
"max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/agda-web-semantic",
"max_stars_repo_path": "src/Web/Semantic/DL/KB/Model.agda",
"max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z",
"num_tokens": 407,
"size": 809
} |
{-# OPTIONS --without-K #-}
{- The type of all types in some universe with a fixed truncation level
behaves almost like a universe itself. In this utility module, we develop
some notation for efficiently working with this pseudo-universe.
It will lead to considerably more briefer and more comprehensible proofs. -}
module Universe.Utility.TruncUniverse where
open import lib.Basics
open import lib.NType2
open import lib.types.Pi
open import lib.types.Sigma
open import lib.types.TLevel
open import lib.types.Unit
open import Universe.Utility.General
module _ {n : ℕ₋₂} where
⟦_⟧ : ∀ {i} → n -Type i → Type i
⟦ (B , _) ⟧ = B
module _ {n : ℕ₋₂} where
Lift-≤ : ∀ {i j} → n -Type i → n -Type (i ⊔ j)
Lift-≤ {i} {j} (A , h) = (Lift {j = j} A , equiv-preserves-level (lift-equiv ⁻¹) h)
raise : ∀ {i} → n -Type i → S n -Type i
raise (A , h) = (A , raise-level n h)
raise-≤T : ∀ {i} {m n : ℕ₋₂} → m ≤T n → m -Type i → n -Type i
raise-≤T p (A , h) = (A , raise-level-≤T p h)
⊤-≤ : n -Type lzero
⊤-≤ = (⊤ , raise-level-≤T (-2≤T n) Unit-is-contr)
Π-≤ : ∀ {i j} (A : Type i) → (A → n -Type j) → n -Type (i ⊔ j)
Π-≤ A B = (Π A (fst ∘ B) , Π-level (snd ∘ B))
infixr 2 _→-≤_
_→-≤_ : ∀ {i j} → Type i → n -Type j → n -Type (i ⊔ j)
A →-≤ B = Π-≤ A (λ _ → B)
Σ-≤ : ∀ {i j} (A : n -Type i) → (⟦ A ⟧ → n -Type j) → n -Type (i ⊔ j)
Σ-≤ A B = (Σ ⟦ A ⟧ (λ a → ⟦ B a ⟧) , Σ-level (snd A) (snd ∘ B))
infixr 4 _×-≤_
_×-≤_ : ∀ {i j} → n -Type i → n -Type j → n -Type (i ⊔ j)
A ×-≤ B = Σ-≤ A (λ _ → B)
Path-< : ∀ {i} (A : S n -Type i) (x y : ⟦ A ⟧) → n -Type i
Path-< A x y = (x == y , snd A _ _)
Path-≤ : ∀ {i} (A : n -Type i) (x y : ⟦ A ⟧) → n -Type i
Path-≤ A x y = Path-< (raise A) x y
_≃-≤_ : ∀ {i j} (A : n -Type i) (B : n -Type j) → n -Type (i ⊔ j)
A ≃-≤ B = (⟦ A ⟧ ≃ ⟦ B ⟧ , ≃-level (snd A) (snd B))
_-Type-≤_ : (n : ℕ₋₂) (i : ULevel) → S n -Type lsucc i
n -Type-≤ i = (n -Type i , n -Type-level i)
| {
"alphanum_fraction": 0.5175930648,
"avg_line_length": 31.126984127,
"ext": "agda",
"hexsha": "63ea1361cf658eb9d4ab4e685fca8fc7d02f4765",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c8fb8da3354fc9e0c430ac14160161759b4c5b37",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "sattlerc/HoTT-Agda",
"max_forks_repo_path": "Universe/Utility/TruncUniverse.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c8fb8da3354fc9e0c430ac14160161759b4c5b37",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "sattlerc/HoTT-Agda",
"max_issues_repo_path": "Universe/Utility/TruncUniverse.agda",
"max_line_length": 85,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c8fb8da3354fc9e0c430ac14160161759b4c5b37",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "sattlerc/HoTT-Agda",
"max_stars_repo_path": "Universe/Utility/TruncUniverse.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 891,
"size": 1961
} |
module plfa-code.Induction where
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; cong; sym)
open Eq.≡-Reasoning using (begin_; _≡⟨⟩_)
open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_)
open import Function
open import plfa-code.Reasoning-legacy
_ : (3 + 4) + 5 ≡ 3 + (4 + 5)
_ =
begin
(3 + 4) + 5
≡⟨⟩
7 + 5
≡⟨⟩
12
≡⟨⟩
3 + 9
≡⟨⟩
3 + (4 + 5)
∎
+-assoc : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p)
+-assoc zero n p =
begin
(zero + n) + p
≡⟨⟩
n + p
≡⟨⟩
zero + (n + p)
∎
+-assoc (suc m) n p =
begin
(suc m + n) + p
≡⟨⟩
suc (m + n) + p
≡⟨⟩
suc ((m + n) + p)
≡⟨ cong suc (+-assoc m n p) ⟩
suc (m + (n + p))
≡⟨⟩
suc m + (n + p)
∎
+-identityʳ : ∀ (m : ℕ) → m + zero ≡ m
+-identityʳ zero =
begin
zero + zero
≡⟨⟩
zero
∎
+-identityʳ (suc m) =
begin
suc m + zero
≡⟨⟩
suc (m + zero)
≡⟨ cong suc (+-identityʳ m)⟩
suc m
∎
+-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n)
+-suc zero n =
begin
zero + suc n
≡⟨⟩
suc n
≡⟨⟩
suc (zero + n)
∎
+-suc (suc m) n =
begin
suc m + suc n
≡⟨⟩
suc (m + suc n)
≡⟨ cong suc (+-suc m n) ⟩
suc (suc (m + n))
≡⟨⟩
suc (suc m + n)
∎
+-comm : ∀ (m n : ℕ) → m + n ≡ n + m
+-comm zero n =
begin
zero + n
≡⟨⟩
n
≡⟨ sym (+-identityʳ n) ⟩
n + zero
∎
+-comm (suc m) n =
begin
suc m + n
≡⟨⟩
suc (m + n)
≡⟨ cong suc (+-comm m n) ⟩
suc (n + m)
≡⟨ sym (+-suc n m) ⟩
n + suc m
∎
+-rearrange : ∀ (m n p q : ℕ) → (m + n) + (p + q) ≡ m + (n + p) + q
+-rearrange m n p q =
begin
(m + n) + (p + q)
≡⟨ +-assoc m n (p + q) ⟩
m + (n + (p + q))
≡⟨ cong (m +_) (sym (+-assoc n p q)) ⟩
m + ((n + p) + q)
≡⟨ sym (+-assoc m (n + p) q) ⟩
(m + (n + p)) + q
∎
+-assoc′ : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p)
+-assoc′ zero n p = refl
+-assoc′ (suc m) n p rewrite +-assoc′ m n p = refl
-- practice
+-swap : ∀ (m n p : ℕ) → m + (n + p) ≡ n + (m + p)
+-swap m zero p = refl
+-swap m (suc n) p
rewrite +-suc m (n + p)
| sym (+-assoc m n p)
| +-comm m n
| +-assoc n m p = refl
*-distrib-+ : ∀ (m n p : ℕ) → (m + n) * p ≡ m * p + n * p
*-distrib-+ zero n p = refl
*-distrib-+ (suc m) n p rewrite *-distrib-+ m n p
| sym (+-assoc p (m * p) (n * p)) = refl
*-assoc : ∀ (m n p : ℕ) → (m * n) * p ≡ m * (n * p)
*-assoc zero n p = refl
*-assoc (suc m) n p rewrite *-distrib-+ n (m * n) p | *-assoc m n p = refl
*-zeroʳ : ∀ (n : ℕ) → n * zero ≡ zero
*-zeroʳ zero = refl
*-zeroʳ (suc n) rewrite *-zeroʳ n = refl
*-suc : ∀ (m n : ℕ) → m * suc n ≡ m * n + m
*-suc zero n = refl
*-suc (suc m) n =
begin
(suc m) * (suc n)
≡⟨⟩
(suc n) + m * (suc n)
≡⟨ cong ((suc n) +_) (*-suc m n) ⟩
suc n + (m * n + m)
≡⟨ +-swap (suc n) (m * n) m ⟩
m * n + (suc n + m)
≡⟨ cong ((m * n) +_) (sym (+-suc n m)) ⟩
m * n + (n + suc m)
≡⟨ sym (+-assoc (m * n) n (suc m)) ⟩
m * n + n + suc m
≡⟨ cong (_+ (suc m)) (+-comm (m * n) n) ⟩
(suc m) * n + (suc m)
∎
*-comm : ∀ (m n : ℕ) → m * n ≡ n * m
*-comm zero n rewrite *-zeroʳ n = refl
*-comm (suc m) n =
begin
suc m * n
≡⟨⟩
n + m * n
≡⟨ +-comm n (m * n) ⟩
m * n + n
≡⟨ cong (_+ n) (*-comm m n) ⟩
n * m + n
≡⟨ sym (*-suc n m) ⟩
n * suc m
∎
z∸n≡z : ∀ (n : ℕ) → zero ∸ n ≡ zero
z∸n≡z zero = refl
z∸n≡z (suc n) = refl
∸-+-assoc : ∀ (m n p : ℕ) → m ∸ n ∸ p ≡ m ∸ (n + p)
∸-+-assoc zero n p rewrite z∸n≡z n | z∸n≡z p | z∸n≡z (n + p) = refl
∸-+-assoc (suc m) zero p = refl
∸-+-assoc (suc m) (suc n) p rewrite ∸-+-assoc m n p = refl
---------- Bin ----------
data Bin : Set where
nil : Bin
x0_ : Bin → Bin
x1_ : Bin → Bin
inc : Bin → Bin
inc nil = x1 nil
inc (x0 t) = x1 t
inc (x1 t) = x0 (inc t)
to : ℕ → Bin
to zero = x0 nil
to (suc n) = inc (to n)
from : Bin → ℕ
from nil = 0
from (x0 t) = 2 * (from t)
from (x1 t) = suc (2 * (from t))
--------------------------------------
+1≡suc : ∀ {n : ℕ} → n + 1 ≡ suc n
+1≡suc {zero} = refl
+1≡suc {suc n} = cong suc +1≡suc
suc-from-inc : ∀ (x : Bin) → from (inc x) ≡ suc (from x)
suc-from-inc nil = refl
suc-from-inc (x0 x) rewrite +1≡suc {from x * 2} = refl
suc-from-inc (x1 x) rewrite suc-from-inc x | +-suc (from x) (from x + 0) = refl
-- t4 is ⊥ , because `to (from nil) ≡ x0 nil ≢ nil`
-- t4 : ∀ (x : Bin) → to (from x) ≡ x
from-to-const : ∀ (n : ℕ) → from (to n) ≡ n
from-to-const zero = refl
from-to-const (suc n) rewrite suc-from-inc (to n) | from-to-const n = refl
| {
"alphanum_fraction": 0.4209850107,
"avg_line_length": 21.036036036,
"ext": "agda",
"hexsha": "65e24d368b6d4c2688b807a97795e7974621f5e7",
"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": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "chirsz-ever/plfa-code",
"max_forks_repo_path": "src/plfa-code/Induction.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3",
"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": "chirsz-ever/plfa-code",
"max_issues_repo_path": "src/plfa-code/Induction.agda",
"max_line_length": 79,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "chirsz-ever/plfa-code",
"max_stars_repo_path": "src/plfa-code/Induction.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2235,
"size": 4670
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Category where
open import Level
-- The main definitions are in:
open import Categories.Category.Core public
-- Convenience functions for working over mupliple categories at once:
-- C [ x , y ] (for x y objects of C) - Hom_C(x , y)
-- C [ f ≈ g ] (for f g arrows of C) - that f and g are equivalent arrows
-- C [ f ∘ g ] (for f g composables arrows of C) - composition in C
infix 10 _[_,_] _[_≈_] _[_∘_]
_[_,_] : ∀ {o ℓ e} → (C : Category o ℓ e) → (X : Category.Obj C) → (Y : Category.Obj C) → Set ℓ
_[_,_] = Category._⇒_
_[_≈_] : ∀ {o ℓ e} → (C : Category o ℓ e) → ∀ {X Y} (f g : C [ X , Y ]) → Set e
_[_≈_] = Category._≈_
_[_∘_] : ∀ {o ℓ e} → (C : Category o ℓ e) → ∀ {X Y Z} (f : C [ Y , Z ]) → (g : C [ X , Y ]) → C [ X , Z ]
_[_∘_] = Category._∘_
| {
"alphanum_fraction": 0.5626535627,
"avg_line_length": 35.3913043478,
"ext": "agda",
"hexsha": "c59c45abdcf0725c2a4916c93210d4d8e8a71c54",
"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.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.agda",
"max_line_length": 105,
"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.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 309,
"size": 814
} |
module UselessPrivatePrivate where
private
private
postulate
A : Set
| {
"alphanum_fraction": 0.7195121951,
"avg_line_length": 11.7142857143,
"ext": "agda",
"hexsha": "9c360b9731edbe4e244992c5b7aebffd0e9d5ccc",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/UselessPrivatePrivate.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/UselessPrivatePrivate.agda",
"max_line_length": 34,
"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/UselessPrivatePrivate.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": 21,
"size": 82
} |
module NoBindingForBuiltin where
foo = 42
| {
"alphanum_fraction": 0.7954545455,
"avg_line_length": 8.8,
"ext": "agda",
"hexsha": "25321e10503d3d746bb4910d8b77ab8657d64c5b",
"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/NoBindingForBuiltin.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/NoBindingForBuiltin.agda",
"max_line_length": 32,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/NoBindingForBuiltin.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": 13,
"size": 44
} |
{-# OPTIONS --universe-polymorphism #-}
module TrustMe-with-doubly-indexed-equality where
open import Common.Level
infix 4 _≡_
data _≡_ {a} {A : Set a} : A → A → Set a where
refl : ∀ {x} → x ≡ x
{-# BUILTIN EQUALITY _≡_ #-}
{-# BUILTIN REFL refl #-}
sym : ∀ {a} {A : Set a} {x y : A} → x ≡ y → y ≡ x
sym refl = refl
primitive
primTrustMe : ∀ {a} {A : Set a} {x y : A} → x ≡ y
postulate
A : Set
x : A
eq : x ≡ x
eq = primTrustMe
evaluates-to-refl : sym (sym eq) ≡ eq
evaluates-to-refl = refl
| {
"alphanum_fraction": 0.5739299611,
"avg_line_length": 17.1333333333,
"ext": "agda",
"hexsha": "c2c3f9c6be00d8d08bdcc1fd75b90dab3a4eb3b4",
"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/Succeed/TrustMe-with-doubly-indexed-equality.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "redfish64/autonomic-agda",
"max_issues_repo_path": "test/Succeed/TrustMe-with-doubly-indexed-equality.agda",
"max_line_length": 51,
"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/Succeed/TrustMe-with-doubly-indexed-equality.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 202,
"size": 514
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Primality
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Nat.Primality where
open import Data.Empty using (⊥)
open import Data.Fin using (Fin; toℕ)
open import Data.Fin.Properties using (all?)
open import Data.Nat using (ℕ; suc; _+_)
open import Data.Nat.Divisibility using (_∤_; _∣?_)
open import Relation.Nullary using (yes; no)
open import Relation.Nullary.Decidable using (from-yes)
open import Relation.Nullary.Negation using (¬?)
open import Relation.Unary using (Decidable)
-- Definition of primality.
Prime : ℕ → Set
Prime 0 = ⊥
Prime 1 = ⊥
Prime (suc (suc n)) = (i : Fin n) → 2 + toℕ i ∤ 2 + n
-- Decision procedure for primality.
prime? : Decidable Prime
prime? 0 = no λ()
prime? 1 = no λ()
prime? (suc (suc n)) = all? (λ _ → ¬? (_ ∣? _))
private
-- Example: 2 is prime.
2-is-prime : Prime 2
2-is-prime = from-yes (prime? 2)
| {
"alphanum_fraction": 0.55,
"avg_line_length": 26.3414634146,
"ext": "agda",
"hexsha": "613d1950e259aa3f9b28b1a41b643c22ec4a7ee2",
"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/Nat/Primality.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/Nat/Primality.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Nat/Primality.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 299,
"size": 1080
} |
module TestNat where
import PreludeNatType
import AlonzoPrelude
import PreludeNat
import PreludeString
import PreludeShow
import RTP
import PreludeList
open AlonzoPrelude
open PreludeShow
open PreludeNatType
open PreludeString
open PreludeNat
open PreludeList hiding(_++_)
one = suc zero
two = suc one
lines : (List String) -> String
lines [] = ""
lines (l :: []) = l
lines (l :: ls) = l ++ "\n" ++ (lines ls)
mainS = (id ○ lines) ((showNat 42) :: (showBool (2007 == 2007)) :: [])
| {
"alphanum_fraction": 0.7128099174,
"avg_line_length": 19.36,
"ext": "agda",
"hexsha": "a84acdbd02e3e072fa2b003e31eb0f8cd66b4355",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/Alonzo/TestNat.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/Alonzo/TestNat.agda",
"max_line_length": 70,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "examples/outdated-and-incorrect/Alonzo/TestNat.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 144,
"size": 484
} |
{-# OPTIONS --without-K --safe #-}
-- Multicategories but over an 'index' type, rather than forcing Fin n
module Categories.Multi.Category.Indexed where
open import Level
open import Data.Fin.Base using (Fin)
open import Data.Product using (Σ; uncurry; curry; _×_; _,_; proj₁; proj₂)
open import Data.Product.Properties
open import Data.Unit.Polymorphic using (⊤; tt)
open import Data.Vec.Functional
open import Function.Base using (const) renaming (_∘_ to _●_; id to id→)
open import Function.Equality using (_⟨$⟩_)
-- note how this is Function.Inverse instead of the one from Function.
open import Function.Inverse as Inv renaming (id to id↔; _∘_ to trans)
open import Relation.Binary.Core using (Rel)
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
-- any point can be lifted to a function from ⊤
pointed : {s t : Level} {S : Set s} (x : S) → ⊤ {t} → S
pointed x _ = x
-- the standard library doesn't seem to have the 'right' version of these.
⊤×K↔K : {t k : Level} {K : Set k} → (⊤ {t} × K) ↔ K
⊤×K↔K = inverse proj₂ (tt ,_) (λ _ → refl) λ _ → refl
K×⊤↔K : {t k : Level} {K : Set k} → (K × ⊤ {t}) ↔ K
K×⊤↔K = inverse proj₁ (_, tt) (λ _ → refl) λ _ → refl
⊤×⊤↔⊤ : {t : Level} → (⊤ {t} × ⊤) ↔ ⊤
⊤×⊤↔⊤ = inverse proj₁ (λ x → x , x) (λ _ → refl) λ _ → refl
Σ-assoc : {a b c : Level} {I : Set a} {J : I → Set b} {K : Σ I J → Set c} →
Σ (Σ I J) K ↔ Σ I (λ i → Σ (J i) (curry K i))
Σ-assoc {I = I} {J} {K} = inverse g f (λ _ → refl) λ _ → refl
where
f : Σ I (λ i → Σ (J i) (λ j → K (i , j))) → Σ (Σ I J) K
f (i , j , k) = (i , j) , k
g : Σ (Σ I J) K → Σ I (λ i → Σ (J i) (λ j → K (i , j)))
g ((i , j) , k) = i , j , k
-- the ι level is for the 'index' (and to not steal 'i')
-- The important part is that in _∘_, there is no flattening of the
-- index set. But also _≈[_]_ builds in an explicit equivalence
-- that allows one to properly re-index things. The classical view
-- of MultiCategory sweeps all of that under the rug, which gives
-- Agda conniptions (and rightfully so). The advantage of doing it
-- this way makes it clear that the 3 laws are based on the underlying
-- 3 laws that hold for (dependent!) product.
-- The upshot is that this version of MultiCategory makes no finiteness
-- assumption whatsoever. The index sets involved could be huge,
-- without any issues.
-- Note that this still isn't Symmetric Multicategory. The renaming that
-- happens on indices say nothing about the relation to the contents
-- of the other Hom set.
record MultiCategory {o ℓ e ı : Level} : Set (suc (o ⊔ ℓ ⊔ e ⊔ ı)) where
infix 4 _≈[_]_
infixr 9 _∘_
field
Obj : Set o
Hom : {I : Set ı} → (I → Obj) → Obj → Set ℓ
id : (o : Obj) → Hom {⊤} (pointed o) o
_∘_ : {I : Set ı} {aₙ : I → Obj} {a : Obj} {J : I → Set ı}
{v : (i : I) → J i → Obj} {b : I → Obj} →
Hom {I} aₙ a → ((i : I) → Hom (v i) (b i)) → Hom {Σ I J} (uncurry v) a
_≈[_]_ : {I J : Set ı} {aₙ : I → Obj} {a : Obj} →
Hom {I} aₙ a → (σ : I ↔ J) → Hom {J} (aₙ ● ( Inverse.from σ ⟨$⟩_ )) a → Set e
identityˡ : {K : Set ı} {aₖ : K → Obj} {a : Obj} {f : Hom aₖ a} →
id a ∘ pointed f ≈[ ⊤×K↔K ] f
identityʳ : {K : Set ı} {aₖ : K → Obj} {a : Obj} {f : Hom aₖ a} →
f ∘ (id ● aₖ) ≈[ K×⊤↔K ] f
identity² : {a : Obj} → id a ∘ pointed (id a) ≈[ ⊤×⊤↔⊤ ] id a
assoc : -- the 3 index sets
{I : Set ı} {J : I → Set ı} {K : Σ I J → Set ı}
-- the 3 sets of (indexed) objects
{vh : I → Obj} {bh : Obj}
{vg : (i : I) → J i → Obj} {bg : I → Obj}
{vf : (h : Σ I J) → K h → Obj} {bf : Σ I J → Obj}
-- the 3 Homs
{h : Hom vh bh}
{g : (i : I) → Hom (vg i) (bg i)}
{f : (k : Σ I J) → Hom (vf k) (bf k)} →
-- and their relation under composition
(h ∘ g) ∘ f ≈[ Σ-assoc ] h ∘ (λ i → g i ∘ curry f i)
-- we also need that _≈[_]_ is, in an appropriate sense, an equivalence relation, which in this case
-- means that _≈[ id↔ ]_ is. In other words, we don't care when transport is over 'something else'.
refl≈ : {I : Set ı} {aₙ : I → Obj} {a : Obj} →
{h : Hom {I} aₙ a} → h ≈[ id↔ ] h
sym≈ : {I : Set ı} {aₙ : I → Obj} {a : Obj} →
{g h : Hom {I} aₙ a} → g ≈[ id↔ ] h → h ≈[ id↔ ] g
trans≈ : {I : Set ı} {aₙ : I → Obj} {a : Obj} →
{f g h : Hom {I} aₙ a} → f ≈[ id↔ ] g → g ≈[ id↔ ] h → f ≈[ id↔ ] h
-- we probably need ∘-resp-≈ too.
| {
"alphanum_fraction": 0.5383418537,
"avg_line_length": 43.6796116505,
"ext": "agda",
"hexsha": "a2dca716c45afc99e0e2afd45cf7b9ff69e34c8b",
"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": "5a49c6ac87cbb7e20511c28f28205163fe69f48f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "laMudri/agda-categories",
"max_forks_repo_path": "src/Categories/Multi/Category/Indexed.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5a49c6ac87cbb7e20511c28f28205163fe69f48f",
"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/agda-categories",
"max_issues_repo_path": "src/Categories/Multi/Category/Indexed.agda",
"max_line_length": 104,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "5a49c6ac87cbb7e20511c28f28205163fe69f48f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "laMudri/agda-categories",
"max_stars_repo_path": "src/Categories/Multi/Category/Indexed.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1784,
"size": 4499
} |
{-# OPTIONS --without-K #-}
open import HoTT
open import cohomology.FunctionOver
open import cohomology.FlipPushout
module cohomology.CofiberSequence {i} where
{- Lemma: pushing flip-susp through susp-fmap -}
⊙flip-susp-fmap : {X Y : Ptd i} (f : fst (X ⊙→ Y))
→ ⊙flip-susp Y ⊙∘ ⊙susp-fmap f == ⊙susp-fmap f ⊙∘ ⊙flip-susp X
⊙flip-susp-fmap {X = X} (f , idp) = ⊙λ= lemma-fst lemma-snd
where
lemma-fst : ∀ σ →
flip-susp (susp-fmap f σ) == susp-fmap f (flip-susp σ)
lemma-fst = Suspension-elim _ idp idp $ λ y → ↓-='-in $
ap-∘ (susp-fmap f) flip-susp (merid _ y)
∙ ap (ap (susp-fmap f)) (FlipSusp.glue-β y)
∙ ap-! (susp-fmap f) (merid _ y)
∙ ap ! (SuspFmap.glue-β f y)
∙ ! (FlipSusp.glue-β (f y))
∙ ! (ap (ap flip-susp) (SuspFmap.glue-β f y))
∙ ∘-ap flip-susp (susp-fmap f) (merid _ y)
lemma-snd :
! (merid _ (f (snd X))) == ap (susp-fmap f) (! (merid _ (snd X))) ∙ idp
lemma-snd =
ap ! (! (SuspFmap.glue-β f (snd X)))
∙ !-ap (susp-fmap f) (merid _ (snd X))
∙ ! (∙-unit-r _)
{- Useful abbreviations -}
module _ {X Y : Ptd i} (f : fst (X ⊙→ Y)) where
⊙Cof² = ⊙Cof (⊙cfcod f)
⊙cfcod² = ⊙cfcod (⊙cfcod f)
⊙Cof³ = ⊙Cof ⊙cfcod²
⊙cfcod³ = ⊙cfcod ⊙cfcod²
⊙Cof⁴ = ⊙Cof ⊙cfcod³
⊙cfcod⁴ = ⊙cfcod ⊙cfcod³
{- For [f : X → Y], the cofiber space [Cof(cfcod f)] is equivalent to
- [Suspension X]. This is essentially an application of the two pushouts
- lemma:
-
- f
- X ––––> Y ––––––––––––––> ∙
- | | |
- | |cfcod f |
- v v v
- ∙ ––> Cof f ––––––––––> Cof² f
- cfcod² f
-
- The map [cfcod² f : Cof f → Cof² f] becomes [ext-glue : Cof f → ΣX],
- and the map [ext-glue : Cof² f → ΣY] becomes [susp-fmap f : ΣX → ΣY].
-}
module Cof² {X Y : Ptd i} (f : fst (X ⊙→ Y)) where
module Equiv {X Y : Ptd i} (f : fst (X ⊙→ Y)) where
module Into = CofiberRec (cfcod (fst f)) {C = fst (⊙Susp X)}
(south _) ext-glue (λ _ → idp)
into = Into.f
module Out = SuspensionRec (fst X) {C = fst (⊙Cof² f)}
(cfcod _ (cfbase _)) (cfbase _)
(λ x → ap (cfcod _) (cfglue _ x) ∙ ! (cfglue _ (fst f x)))
out = Out.f
into-out : ∀ σ → into (out σ) == σ
into-out = Suspension-elim (fst X) idp idp
(λ x → ↓-∘=idf-in into out $
ap (ap into) (Out.glue-β x)
∙ ap-∙ into (ap (cfcod _) (cfglue _ x)) (! (cfglue _ (fst f x)))
∙ ap (λ w → ap into (ap (cfcod _) (cfglue _ x)) ∙ w)
(ap-! into (cfglue _ (fst f x)) ∙ ap ! (Into.glue-β (fst f x)))
∙ ∙-unit-r _
∙ ∘-ap into (cfcod _) (cfglue _ x) ∙ ExtGlue.glue-β x)
out-into : ∀ κ → out (into κ) == κ
out-into = Cofiber-elim (cfcod (fst f))
idp
(Cofiber-elim (fst f) idp (cfglue _)
(λ x → ↓-='-from-square $
(ap-∘ out ext-glue (cfglue _ x)
∙ ap (ap out) (ExtGlue.glue-β x) ∙ Out.glue-β x)
∙v⊡ (vid-square {p = ap (cfcod _) (cfglue _ x)}
⊡h rt-square (cfglue _ (fst f x)))
⊡v∙ ∙-unit-r _))
(λ y → ↓-∘=idf-from-square out into $
ap (ap out) (Into.glue-β y) ∙v⊡ connection)
eq = equiv into out into-out out-into
space-path : ⊙Cof² f == ⊙Susp X
space-path = ⊙ua eq (! (merid _ (snd X)))
cfcod²-over : ⊙cfcod² f == ⊙ext-glue
[ (λ U → fst (⊙Cof f ⊙→ U)) ↓ Equiv.space-path f ]
cfcod²-over = ind-lemma f
where
{- is there a better way to handle this? -}
ind-lemma : {X Y : Ptd i} (f : fst (X ⊙→ Y))
→ ⊙cfcod² f == ⊙ext-glue
[ (λ U → fst (⊙Cof f ⊙→ U)) ↓ Equiv.space-path f ]
ind-lemma {X = X} (f , idp) =
codomain-over-⊙equiv (⊙cfcod² (f , idp)) _ _
▹ pair= idp (l snd-lemma)
where
x₀ = snd X; y₀ = f (snd X); F = (f , idp {a = y₀})
snd-lemma : ap (Equiv.into F)
(ap (cfcod (cfcod f)) (! (! (cfglue _ x₀)))
∙ ! (cfglue _ y₀))
== merid _ x₀
snd-lemma =
ap (Equiv.into F)
(ap (cfcod (cfcod f)) (! (! (cfglue _ x₀))) ∙ ! (cfglue _ y₀))
=⟨ !-! (cfglue _ x₀) |in-ctx (λ w →
ap (Equiv.into F) (ap (cfcod (cfcod f)) w ∙ ! (cfglue _ y₀))) ⟩
ap (Equiv.into F)
(ap (cfcod (cfcod f)) (cfglue _ x₀) ∙ ! (cfglue _ y₀))
=⟨ ap-∙ (Equiv.into F)
(ap (cfcod (cfcod f)) (cfglue _ x₀)) (! (cfglue _ y₀)) ⟩
ap (Equiv.into F) (ap (cfcod (cfcod f)) (cfglue _ x₀))
∙ ap (Equiv.into F) (! (cfglue _ y₀))
=⟨ ∘-ap (Equiv.into F) (cfcod (cfcod f)) (cfglue _ x₀)
|in-ctx (λ w → w ∙ ap (Equiv.into F) (! (cfglue _ y₀))) ⟩
ap ext-glue (cfglue _ x₀) ∙ ap (Equiv.into F) (! (cfglue _ y₀))
=⟨ ExtGlue.glue-β x₀
|in-ctx (λ w → w ∙ ap (Equiv.into F) (! (cfglue _ y₀))) ⟩
merid _ x₀ ∙ ap (Equiv.into F) (! (cfglue _ y₀))
=⟨ ap-! (Equiv.into F) (cfglue _ y₀) |in-ctx (λ w → merid _ x₀ ∙ w) ⟩
merid _ x₀ ∙ ! (ap (Equiv.into F) (cfglue _ y₀))
=⟨ Equiv.Into.glue-β F y₀ |in-ctx (λ w → merid _ x₀ ∙ ! w) ⟩
merid _ x₀ ∙ idp
=⟨ ∙-unit-r _ ⟩
merid _ x₀ ∎
l : ∀ {i} {A : Type i} {x y : A} {p q : x == y}
→ p == q → p ∙ ! q == idp
l {p = p} {q = q} α = ap (λ r → r ∙ ! q) α ∙ !-inv-r q
cfcod³-over :
⊙ext-glue == ⊙flip-susp Y ⊙∘ ⊙susp-fmap f
[ (λ U → fst (U ⊙→ ⊙Susp Y)) ↓ Equiv.space-path f ]
cfcod³-over =
⊙λ= fst-lemma (l snd-lemma)
◃ domain-over-⊙equiv (⊙flip-susp Y ⊙∘ ⊙susp-fmap f) _ _
where
fst-lemma : (κ : fst (⊙Cof² f))
→ ext-glue κ == flip-pushout (susp-fmap (fst f) (Equiv.into f κ))
fst-lemma = Cofiber-elim (cfcod (fst f))
idp
(Cofiber-elim (fst f)
idp
(! ∘ merid (fst Y))
(λ x → ↓-='-from-square $
ap-cst (south _) (cfglue _ x) ∙v⊡
connection
⊡v∙ ! (ap-∘ (flip-pushout ∘ susp-fmap (fst f)) ext-glue (cfglue _ x)
∙ ap (ap (flip-pushout ∘ susp-fmap (fst f))) (ExtGlue.glue-β x)
∙ ap-∘ flip-pushout (susp-fmap (fst f)) (merid _ x)
∙ ap (ap flip-pushout) (SuspFmap.glue-β (fst f) x)
∙ FlipPushout.glue-β (fst f x))))
(λ y → ↓-='-from-square $
ExtGlue.glue-β y ∙v⊡
tr-square (merid _ y)
⊡v∙ ! (ap-∘ (flip-pushout ∘ susp-fmap (fst f)) (Equiv.into f)
(cfglue _ y)
∙ ap (ap (flip-pushout ∘ susp-fmap (fst f)))
(Equiv.Into.glue-β f y)))
snd-lemma : ap (flip-pushout ∘ susp-fmap (fst f)) (! (merid _ (snd X)))
== merid _ (snd Y)
snd-lemma =
ap (flip-pushout ∘ susp-fmap (fst f)) (! (merid _ (snd X)))
=⟨ ap-! (flip-pushout ∘ susp-fmap (fst f)) (merid _ (snd X)) ⟩
! (ap (flip-pushout ∘ susp-fmap (fst f)) (merid _ (snd X)))
=⟨ ap ! (ap-∘ flip-pushout (susp-fmap (fst f)) (merid _ (snd X))) ⟩
! (ap flip-pushout (ap (susp-fmap (fst f)) (merid _ (snd X))))
=⟨ ap (! ∘ ap flip-pushout) (SuspFmap.glue-β (fst f) (snd X)) ⟩
! (ap flip-pushout (merid _ (fst f (snd X))))
=⟨ ap ! (FlipPushout.glue-β (fst f (snd X))) ⟩
! (! (merid _ (fst f (snd X))))
=⟨ !-! (merid _ (fst f (snd X))) ⟩
merid _ (fst f (snd X))
=⟨ ap (merid _) (snd f) ⟩
merid _ (snd Y) ∎
l : ∀ {i} {A : Type i} {x y : A} {p q : x == y}
→ p == q → idp == p ∙ ! q
l {p = p} {q = q} α = ! (!-inv-r p) ∙ ap (λ w → p ∙ ! w) α
open Equiv f public
full-path : Path
{A = Σ (Ptd i) (λ U → fst (⊙Cof f ⊙→ U) × fst (U ⊙→ ⊙Susp Y))}
(_ , ⊙cfcod² f , ⊙ext-glue)
(_ , ⊙ext-glue , ⊙flip-susp Y ⊙∘ ⊙susp-fmap f)
full-path = pair= space-path (↓-×-in cfcod²-over cfcod³-over)
cofiber-sequence : {X Y : Ptd i} (f : fst (X ⊙→ Y)) → Path
{A = Σ (Ptd i × Ptd i × Ptd i)
(λ {(U , V , W) → fst (⊙Cof f ⊙→ U) × fst (U ⊙→ V) × fst (V ⊙→ W)})}
(_ , ⊙cfcod² f , ⊙cfcod³ f , ⊙cfcod⁴ f)
(_ , ⊙ext-glue , ⊙susp-fmap f , ⊙susp-fmap (⊙cfcod f))
cofiber-sequence {Y = Y} f =
ap (λ {(_ , g , _) → (_ , ⊙cfcod² f , ⊙cfcod³ f , g)})
(Cof².full-path (⊙cfcod² f))
∙ ap (λ {(_ , g , h) → (_ , ⊙cfcod² f , g , h)})
(Cof².full-path (⊙cfcod f))
∙ ap (λ {(_ , g , h) → (_ , g , h , ⊙flip-susp (⊙Cof f) ⊙∘
⊙susp-fmap (⊙cfcod f))})
(Cof².full-path f)
∙ ap (λ g → (_ , ⊙ext-glue , ⊙flip-susp Y ⊙∘ ⊙susp-fmap f , g))
(⊙flip-susp-fmap (⊙cfcod f))
∙ ap (λ {(_ , g , h) → (_ , ⊙ext-glue , g , h)})
(pair= (flip-⊙pushout-path (suspension-⊙span Y))
(↓-×-in (codomain-over-⊙equiv
(⊙flip-susp Y ⊙∘ ⊙susp-fmap f) _ _
▹ lemma)
(domain-over-⊙equiv (⊙susp-fmap (⊙cfcod f)) _ _)))
where
lemma : ⊙flip-susp Y ⊙∘ ⊙flip-susp Y ⊙∘ ⊙susp-fmap f
== ⊙susp-fmap f
lemma = ! (⊙∘-assoc (⊙flip-susp Y) (⊙flip-susp Y) (⊙susp-fmap f))
∙ ap (λ w → w ⊙∘ ⊙susp-fmap f)
(flip-⊙pushout-involutive (suspension-⊙span Y))
∙ ⊙∘-unit-l (⊙susp-fmap f)
suspend-cofiber : {X Y : Ptd i} (f : fst (X ⊙→ Y)) → Path
{A = Σ _ (λ {(U , V , W) → fst (U ⊙→ V) × fst (V ⊙→ W)})}
(_ , ⊙susp-fmap f , ⊙cfcod (⊙susp-fmap f))
(_ , ⊙susp-fmap f , ⊙susp-fmap (⊙cfcod f))
suspend-cofiber f =
ap (λ {((U , V , W) , _ , g , _) → ((U , V , ⊙Cof g) , g , ⊙cfcod g)})
(! (cofiber-sequence f))
∙ ap (λ {(_ , _ , g , h) → (_ , g , h)}) (cofiber-sequence f)
suspend^-cof= : {X Y Z : Ptd i} (m : ℕ) (f : fst (X ⊙→ Y)) (g : fst (Y ⊙→ Z))
(p : Path {A = Σ _ (λ U → fst (Y ⊙→ U))} (⊙Cof f , ⊙cfcod f) (Z , g))
→ Path {A = Σ _ (λ {(U , V , W) → fst (U ⊙→ V) × fst (V ⊙→ W)})}
(_ , ⊙susp^-fmap m f , ⊙cfcod (⊙susp^-fmap m f))
(_ , ⊙susp^-fmap m f , ⊙susp^-fmap m g)
suspend^-cof= O f g p = ap (λ {(_ , h) → (_ , f , h)}) p
suspend^-cof= (S m) f g p =
suspend-cofiber (⊙susp^-fmap m f)
∙ ap (λ {(_ , h , k) → (_ , ⊙susp-fmap h , ⊙susp-fmap k)})
(suspend^-cof= m f g p)
| {
"alphanum_fraction": 0.4693490415,
"avg_line_length": 39.5889328063,
"ext": "agda",
"hexsha": "0844ec012eeb96e54b0678170a6e2607f80005aa",
"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": "1695a7f3dc60177457855ae846bbd86fcd96983e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "danbornside/HoTT-Agda",
"max_forks_repo_path": "cohomology/CofiberSequence.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e",
"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": "danbornside/HoTT-Agda",
"max_issues_repo_path": "cohomology/CofiberSequence.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "danbornside/HoTT-Agda",
"max_stars_repo_path": "cohomology/CofiberSequence.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4414,
"size": 10016
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import Functions.Definition
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import LogicalFormulae
open import Setoids.Subset
open import Setoids.Setoids
open import Setoids.Orders.Partial.Definition
open import Fields.Fields
open import Rings.Orders.Total.Definition
open import Rings.Orders.Total.Lemmas
open import Rings.Orders.Partial.Definition
open import Rings.Definition
open import Fields.Orders.LeastUpperBounds.Definition
open import Fields.Orders.Total.Definition
module Numbers.ClassicalReals.RealField where
record RealField : Agda.Primitive.Setω where
field
a b c : _
A : Set a
S : Setoid {_} {b} A
_+_ : A → A → A
_*_ : A → A → A
R : Ring S _+_ _*_
F : Field R
_<_ : Rel {_} {c} A
pOrder : SetoidPartialOrder S _<_
pOrderedRing : PartiallyOrderedRing R pOrder
orderedRing : TotallyOrderedRing pOrderedRing
lub : {d : _} → {pred : A → Set d} → (sub : subset S pred) → (nonempty : Sg A pred) → (boundedAbove : Sg A (UpperBound pOrder sub)) → Sg A (LeastUpperBound pOrder sub)
open Setoid S
open Field F
charNot2 : (Ring.1R R + Ring.1R R) ∼ Ring.0R R → False
charNot2 = orderedImpliesCharNot2 orderedRing nontrivial
oField : TotallyOrderedField F pOrderedRing
oField = record { oRing = orderedRing }
| {
"alphanum_fraction": 0.7214814815,
"avg_line_length": 34.6153846154,
"ext": "agda",
"hexsha": "65656ab67c7acca4e2e9b935defe61c41d4641ed",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Numbers/ClassicalReals/RealField.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Numbers/ClassicalReals/RealField.agda",
"max_line_length": 171,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Numbers/ClassicalReals/RealField.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": 400,
"size": 1350
} |
{-# OPTIONS --cubical-compatible --show-implicit #-}
-- {-# OPTIONS -v tc.lhs.split.well-formed:100 #-}
-- Andreas, adapted from Andres Sicard, 2013-05-29
module WithoutKRestrictive where
open import Common.Level
open import Common.Equality
open import Common.Product
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
data _≤_ : ℕ → ℕ → Set where
z≤n : ∀ {n} → zero ≤ n
s≤s : ∀ {n m} → n ≤ m → suc n ≤ suc m
_<_ : ℕ → ℕ → Set
n < m = suc n ≤ m
refl≤ : ∀ (n : ℕ) → n ≤ n
refl≤ zero = z≤n
refl≤ (suc n) = s≤s (refl≤ n)
data List {a} (A : Set a) : Set a where
[] : List A
_∷_ : (x : A) (xs : List A) → List A
length : {A : Set} → List A → ℕ
length [] = zero
length (x ∷ xs) = suc (length xs)
P : {A : Set} → List A → List A → Set
P xs ys = Σ _ (λ x → ys ≡ (x ∷ xs))
Q : {A : Set} → List A → List A → Set
Q xs ys = (length xs) < (length ys)
helper : {A : Set}(y : A)(xs : List A) → (length xs) < (length (y ∷ xs))
helper y [] = s≤s z≤n
helper y (x ∷ xs) = s≤s (refl≤ _)
-- Why the --cubical-compatible option rejects the following proof
foo : {A : Set}(xs ys : List A) → P xs ys → Q xs ys
foo xs .(x ∷ xs) (x , refl) = helper x xs
-- if I can prove foo using only subst
foo' : {A : Set}(xs ys : List A) → P xs ys → Q xs ys
foo' xs ys (x , h) =
subst (λ ys' → length xs < length ys') (sym h) (helper x xs)
| {
"alphanum_fraction": 0.5516467066,
"avg_line_length": 25.2075471698,
"ext": "agda",
"hexsha": "27fb75ee61aef19a8b78ae58941daa49fe8a0b7a",
"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/WithoutKRestrictive.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/WithoutKRestrictive.agda",
"max_line_length": 72,
"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/WithoutKRestrictive.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 530,
"size": 1336
} |
-- Run this test case in safe mode
-- {-# OPTIONS --safe #-} -- does not parse (2012-03-12 Andreas)
module Issue586 where
Foo : Set1
Foo = Set
| {
"alphanum_fraction": 0.6597222222,
"avg_line_length": 20.5714285714,
"ext": "agda",
"hexsha": "4a5b428a85b4f35b4001459c4ae2c53eb170ddcb",
"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/Issue586.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/Issue586.agda",
"max_line_length": 64,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue586.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 44,
"size": 144
} |
{-# OPTIONS --cubical --safe #-}
open import Prelude
open import Algebra
module Data.FingerTree {ℓ} (mon : Monoid ℓ) where
open Monoid mon
record Measured {a} (A : Type a) : Type (a ℓ⊔ ℓ) where
constructor measured
field μ : A → 𝑆
open Measured ⦃ ... ⦄ public
data Digit {a} (A : Type a) : Type a where
D₁ : A → Digit A
D₂ : A → A → Digit A
D₃ : A → A → A → Digit A
data Node {a} (A : Type a) : Type a where
N₂ : A → A → Node A
N₃ : A → A → A → Node A
instance
measuredDigit : ⦃ _ : Measured A ⦄ → Measured (Digit A)
measuredDigit =
measured λ { (D₁ x) → μ x
; (D₂ x x₁) → μ x ∙ μ x₁
; (D₃ x x₁ x₂) → μ x ∙ μ x₁ ∙ μ x₂
}
instance
measuredNode : ⦃ _ : Measured A ⦄ → Measured (Node A)
measuredNode =
measured λ { (N₂ x x₁) → μ x ∙ μ x₁
; (N₃ x x₁ x₂) → μ x ∙ μ x₁ ∙ μ x₂
}
record ⟪_⟫ (A : Type a) ⦃ _ : Measured A ⦄ : Type (a ℓ⊔ ℓ) where
constructor recd
field
val : A
mem : 𝑆
prf : μ val ≡ mem
open ⟪_⟫ public
memo : ⦃ _ : Measured A ⦄ → A → ⟪ A ⟫
memo x = recd x (μ x) refl
instance
measuredMemo : ⦃ _ : Measured A ⦄ → Measured ⟪ A ⟫
measuredMemo = measured mem
mutual
record Deep {a} (A : Type a) ⦃ _ : Measured A ⦄ : Type (a ℓ⊔ ℓ) where
pattern
constructor more
inductive
field
lbuff : Digit A
tree : Tree ⟪ Node A ⟫
rbuff : Digit A
data Tree {a} (A : Type a) ⦃ _ : Measured A ⦄ : Type (a ℓ⊔ ℓ) where
empty : Tree A
single : A → Tree A
deep : ⟪ Deep A ⟫ → Tree A
μ-deep : ∀ {a} {A : Type a} ⦃ _ : Measured A ⦄ → Deep A → 𝑆
μ-deep (more l x r) = μ l ∙ (μ-tree x ∙ μ r)
μ-tree : ∀ {a} {A : Type a} ⦃ _ : Measured A ⦄ → Tree A → 𝑆
μ-tree empty = ε
μ-tree (single x) = μ x
μ-tree (deep xs) = xs .mem
instance
Measured-Deep : ∀ {a} {A : Type a} → ⦃ _ : Measured A ⦄ → Measured (Deep A)
Measured-Deep = measured μ-deep
instance
Measured-Tree : ∀ {a} {A : Type a} → ⦃ _ : Measured A ⦄ → Measured (Tree A)
Measured-Tree = measured μ-tree
open Deep
| {
"alphanum_fraction": 0.5357487923,
"avg_line_length": 24.0697674419,
"ext": "agda",
"hexsha": "06ded89befcffc8410d94fcecd5820712041111b",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-playground",
"max_forks_repo_path": "Data/FingerTree.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-playground",
"max_issues_repo_path": "Data/FingerTree.agda",
"max_line_length": 79,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-playground",
"max_stars_repo_path": "Data/FingerTree.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": 855,
"size": 2070
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020 Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Prelude
open import LibraBFT.Base.PKCS
open import LibraBFT.Abstract.Types
-- This module defines the types used to define a SystemModel.
module LibraBFT.Yasm.Base where
-- Our system is configured through a value of type
-- SystemParameters where we specify:
record SystemParameters : Set₁ where
constructor mkSysParms
field
PeerState : Set
Msg : Set
Part : Set -- Types of interest that can be represented in Msgs
-- The messages must be able to carry signatures
instance Part-sig : WithSig Part
-- A relation specifying what Parts are included in a Msg.
_⊂Msg_ : Part → Msg → Set
-- Finally, messages must carry an epoch id and might have an author
part-epoch : Part → EpochId
-- Initializes a potentially-empty state with an EpochConfig
init : NodeId → EpochConfig → Maybe PeerState → PeerState × List Msg
-- Handles a message on a previously initialized peer.
handle : NodeId → Msg → PeerState → PeerState × List Msg
-- TODO-3?: So far, handlers only produce messages to be sent.
-- It would be reasonable to generalize this to something like
--
-- data Action = Send Msg | Crash CrashMsg | Log LogMsg | ...
--
-- on the system level, and have the handlers return List Action,
-- rather than just ListMsg. For example, if an assertion fires, this
-- could "kill the process" and make it not send any messages in the future.
-- We could also then prove that the handlers do not crash, certain
-- messages are logged under certain circumstances, etc.
--
-- Alternatively, we could keep this outside the system model by
-- defining an application-specific peerState type, for example:
--
-- > libraHandle : Msg → Status × Log × LState → Status × LState × List Action
-- > libraHandle _ (Crashed , l , s) = Crashed , s , [] -- i.e., crashed peers never send messages
-- >
-- > handle = filter isSend ∘ libraHandle
-- We also require a standard key-value store interface, along with its
-- functionality and various properties about it. Most of the properties
-- are not currently used, but they are included here based on our
-- experience in other work, as we think many of them will be needed when
-- reasoning about an actual LibraBFT implementation.
-- Although we believe the assumptions here are reasonable, it is always
-- possible that we made a mistake in postulating one of the properties,
-- making it impossible to implement. Thus, it would a useful contribution
-- to:
--
-- TODO-1: construct an actual implementation and provide and prove the
-- necessary properties to satisfy the requirements of this module
--
-- Note that this would require some work, but should be relatively
-- straightforward and requires only "local" changes.
postulate
Map : Set → Set → Set
Map-empty : ∀{k v} → Map k v
Map-lookup : ∀{k v} → k → Map k v → Maybe v
Map-insert : ∀{k v} → k → v → Map k v → Map k v
Map-set : ∀{k v} → k → Maybe v → Map k v → Map k v
-- It must satisfy the following properties
Map-insert-correct : ∀ {K V : Set}{k : K}{v : V}{m : Map K V}
→ Map-lookup k (Map-insert k v m) ≡ just v
Map-insert-target-≢ : ∀ {K V : Set}{k k' : K}{v : V}{m}
→ k' ≢ k
→ Map-lookup k' m ≡ Map-lookup k' (Map-insert k v m)
Map-set-correct : ∀ {K V : Set}{k : K}{mv : Maybe V}{m : Map K V}
→ Map-lookup k (Map-set k mv m) ≡ mv
Map-set-target-≢ : ∀ {K V : Set}{k k' : K}{mv : Maybe V}{m}
→ k' ≢ k
→ Map-lookup k' m ≡ Map-lookup k' (Map-set k mv m)
Map-set-≡-correct : ∀ {K V : Set}{k : K}{m : Map K V}
→ Map-set k (Map-lookup k m) m ≡ m
| {
"alphanum_fraction": 0.640556369,
"avg_line_length": 41.3939393939,
"ext": "agda",
"hexsha": "302e6de6e8e181413a00e90c39a77e3667a99774",
"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": "b7dd98dd90d98fbb934ef8cb4f3314940986790d",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "lisandrasilva/bft-consensus-agda-1",
"max_forks_repo_path": "LibraBFT/Yasm/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b7dd98dd90d98fbb934ef8cb4f3314940986790d",
"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": "lisandrasilva/bft-consensus-agda-1",
"max_issues_repo_path": "LibraBFT/Yasm/Base.agda",
"max_line_length": 111,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b7dd98dd90d98fbb934ef8cb4f3314940986790d",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "lisandrasilva/bft-consensus-agda-1",
"max_stars_repo_path": "LibraBFT/Yasm/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1075,
"size": 4098
} |
{-# OPTIONS --universe-polymorphism #-}
open import Categories.Category
module Categories.Object.Products {o ℓ e} (C : Category o ℓ e) where
open Category C
open import Level
import Categories.Object.Terminal as Terminal
import Categories.Object.BinaryProducts as BinaryProducts
open Terminal C
open BinaryProducts C
-- this should really be 'FiniteProducts', no?
record Products : Set (o ⊔ ℓ ⊔ e) where
field
terminal : Terminal
binary : BinaryProducts
| {
"alphanum_fraction": 0.7579617834,
"avg_line_length": 21.4090909091,
"ext": "agda",
"hexsha": "e9706ccef2dac3f01e4a9cf519a6f22d2074fece",
"lang": "Agda",
"max_forks_count": 23,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z",
"max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "p-pavel/categories",
"max_forks_repo_path": "Categories/Object/Products.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "p-pavel/categories",
"max_issues_repo_path": "Categories/Object/Products.agda",
"max_line_length": 68,
"max_stars_count": 98,
"max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "copumpkin/categories",
"max_stars_repo_path": "Categories/Object/Products.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z",
"num_tokens": 110,
"size": 471
} |
{-# OPTIONS --without-K #-}
module Relation.Path.Operation where
open import Basics
open import Relation.Equality
open import Data.Product
infixr 4 _∙_
infix 9 _⁻¹
-- Path inversion
_⁻¹ : ∀ {a}{A : Set a}{x y : A} → (x ≡ y) → (y ≡ x)
_⁻¹ = ind₌ (λ x y _ → y ≡ x) (λ _ → refl) _ _
-- Composition of paths
_∙_ : ∀ {a}{A : Set a}{x y z : A} → (x ≡ y) → (y ≡ z) → (x ≡ z)
_∙_ {z = z} = ind₌ (λ x y _ → y ≡ z → x ≡ z) (λ _ p → p) _ _
-- Unit laws for Composition
rup : ∀ {i}{A : Set i}{a b : A} → (p : a ≡ b) → (p ∙ refl) ≡ p
rup = ind₌ (λ _ _ p → (p ∙ refl) ≡ p) (λ _ → refl) _ _
lup : ∀ {i}{A : Set i}{a b : A} → (p : a ≡ b) → (refl ∙ p) ≡ p
lup _ = refl
-- Associativity of path composition
assoc : ∀ {i}{A : Set i}{a b c d : A} → (p : a ≡ b) (q : b ≡ c) (r : c ≡ d) → (p ∙ (q ∙ r)) ≡ ((p ∙ q) ∙ r)
assoc {c = c} {d = d} = ind₌
(λ _ b p → (q : b ≡ c) (r : c ≡ d) → (p ∙ q ∙ r) ≡ ((p ∙ q) ∙ r))
(λ b → ind₌
(λ _ c q → (r : c ≡ d) → (refl ∙ q ∙ r) ≡ ((refl ∙ q) ∙ r))
(λ _ _ → refl) _ _)
_ _
-- It is a familiar fact in topology that when we concatenate a path p with the
-- reversed path p ⁻¹, we don’t literally obtain a constant path (which
-- corresponds to the equality refl in type theory) — instead we have a
-- homotopy, or higher path, from p ∙ p ⁻¹ to the constant path.
there-and-back-again : ∀ {i} {A : Set i}{x y : A}{p : x ≡ y} → (p ∙ p ⁻¹) ≡ refl
there-and-back-again {i} {A} {x}{y} {p} = ind₌ D d _ _ p where
D : (x y : A) → (x ≡ y) → Set i
D x y p = (p ∙ p ⁻¹) ≡ refl
d : (x₁ : A) → D x₁ x₁ refl
d = λ x → refl
back-and-there-again : ∀ {i}{A : Set i}{x y : A}{p : x ≡ y} → (p ⁻¹ ∙ p) ≡ refl
back-and-there-again {i} {A} {x}{y} {p} = ind₌ D d _ _ p where
D : (x y : A) → (p : x ≡ y) → Set i
D x y p = (p ⁻¹ ∙ p) ≡ refl
d : (x₁ : A) → D x₁ x₁ refl
d = λ x → refl
-- Paths are functor looking things.
ap : ∀ {i j} {A : Set i}{B : Set j}{x y : A}{f : A → B} → (x ≡ y) → (f x ≡ f y)
ap {i}{j} {A}{B} {x}{y}{f} p = ind₌ D d x y p where
D : (x y : A) → (p : x ≡ y) → Set j
D x y p = f x ≡ f y
d : (x : A) → D x x refl
d = λ x → refl
--
ap₂ : ∀ {i j k} {A : Set i}{B : Set j}{C : Set k}{x x′ : A}{y y′ : B}(f : A → B → C) → (x ≡ x′) → (y ≡ y′) → (f x y ≡ f x′ y′)
ap₂ f p q = ap {f = λ _ → f _ _} p ∙ ap {f = f _} q
-- The dependently typed version of `ap` takes a type family and relates its instantiations with p
transport : ∀ {i j} {A : Set i}{P : A → Set j}{x y : A} → (p : x ≡ y) → P x → P y
transport {i}{j} {A}{P} {x}{y} p = ind₌ D d x y p where
D : (x y : A) → (p : x ≡ y) → Set j
D x y p = P x → P y
d : (x : A) → D x x refl
d = λ x → id
2-11-2 : ∀ {i} {A : Set i} → (a : A) {x₁ x₂ : A} (p : x₁ ≡ x₂) (q : a ≡ x₁) → (transport p q) ≡ (q ∙ p)
2-11-2 a = ind₌
(λ x _ p → (q : a ≡ x) → (transport {P = (λ x → a ≡ x)} p q) ≡ (q ∙ p))
(λ _ q → rup q ⁻¹)
_ _
-- Basically, P respects equality
path-lifting : ∀ {a p}{A : Set a}{x y : A}{P : A → Set p} → (u : P x) → (p : x ≡ y) → (x , u) ≡ (y , u)
path-lifting u = cong (λ z → z , u)
-- Look, transport works in the "upper" space too!
apd : ∀ {i} {A : Set i}{P : A → Set i}{f : (x : A) → P x}{x y : A} → (p : x ≡ y) → (transport p (f x) ≡ f y)
apd {i} {A}{P} {f}{x}{y} p = ind₌ D d x y p where
D : (x y : A) → (p : x ≡ y) → Set i
D x y p = transport p (f x) ≡ f y
d : (x : A) → D x x refl
d = λ x → refl
-- We can also fix B and make transport work like fmap with equalities.
transportconst : ∀ {i} {A : Set i}{B : Set i}{P : A → B}{x y : A} → (p : x ≡ y) → (b : B) → transport p b ≡ b
transportconst {i} {A}{B}{P} {x}{y} p b = ind₌ D d x y p where
D : (x y : A) → (x ≡ y) → Set i
D x y p = transport p b ≡ b
d : (x : A) → D x x refl
d = λ x → refl
-- Path Structure for Product Types
split-path₌ : ∀ {a b}{A : Set a}{B : Set b} → (x y : (A × B)) → (x ≡ y) → (proj₁ x ≡ proj₁ y) × (proj₂ x ≡ proj₂ y)
split-path₌ xs ys p = ap {f = proj₁} p , ap {f = proj₂} p
{-
pair₌ : ∀ {a b}{A : Set a}{B : Set b} → (x y : (A × B)) → (proj₁ x ≡ proj₁ y) × (proj₂ x ≡ proj₂ y) → (x ≡ y)
pair₌ (a₁ , b₁) (a₂ , b₂) (p , q) = {!!}
-}
| {
"alphanum_fraction": 0.4655383861,
"avg_line_length": 35.452173913,
"ext": "agda",
"hexsha": "c6621658be12ad7c70cd62d984720c8444da78b2",
"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": "3411b253b0a49a5f9c3301df175ae8ecdc563b12",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "CodaFi/HoTT-Exercises",
"max_forks_repo_path": "Relation/Path/Operation.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12",
"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": "CodaFi/HoTT-Exercises",
"max_issues_repo_path": "Relation/Path/Operation.agda",
"max_line_length": 126,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "CodaFi/HoTT-Exercises",
"max_stars_repo_path": "Relation/Path/Operation.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1944,
"size": 4077
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- A solver for proving that one list is a sublist of the other for types
-- which enjoy decidable equalities.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary using (Decidable)
open import Agda.Builtin.Equality using (_≡_)
module Data.List.Relation.Binary.Sublist.DecPropositional.Solver
{a} {A : Set a} (_≟_ : Decidable {A = A} _≡_)
where
import Relation.Binary.PropositionalEquality as P
open import Data.List.Relation.Binary.Sublist.DecSetoid.Solver (P.decSetoid _≟_) public
| {
"alphanum_fraction": 0.5782608696,
"avg_line_length": 34.5,
"ext": "agda",
"hexsha": "05bb5a6c1f877717cf139337c9f68a3d9bc8a468",
"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": "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/Binary/Sublist/DecPropositional/Solver.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/Binary/Sublist/DecPropositional/Solver.agda",
"max_line_length": 87,
"max_stars_count": 5,
"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/Binary/Sublist/DecPropositional/Solver.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": 147,
"size": 690
} |
open import Agda.Primitive
record R (a : Level) : Set (lsuc a) where
field
A : Set a
_ : ∀ a → R {!a!} → Set a
_ = λ _ → R.A
| {
"alphanum_fraction": 0.5413533835,
"avg_line_length": 14.7777777778,
"ext": "agda",
"hexsha": "a1b3b41ff17c811c4f843efb74a7b79346d70bf1",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "cagix/agda",
"max_forks_repo_path": "test/interaction/Issue5392.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "cagix/agda",
"max_issues_repo_path": "test/interaction/Issue5392.agda",
"max_line_length": 41,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "cagix/agda",
"max_stars_repo_path": "test/interaction/Issue5392.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 54,
"size": 133
} |
{-# OPTIONS --cubical --no-import-sorts #-}
open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero)
module MoreNatProperties where
open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc)
open import Cubical.Data.Sigma.Base renaming (_×_ to infixr 4 _×_)
open import Cubical.Relation.Nullary.Base -- ¬_
open import Cubical.Data.Empty renaming (elim to ⊥-elim) -- `⊥` and `elim`
open import Function.Base using (_$_)
open import Cubical.Data.Nat hiding (min)
-- open import Cubical.Data.Nat.Properties hiding (min)
open import Cubical.Data.Nat.Order renaming (zero-≤ to z≤n; suc-≤-suc to s≤s)
min : ℕ → ℕ → ℕ
min a b with a ≟ b
... | lt a<b = a
... | eq a≡b = a
... | gt b<a = b
max : ℕ → ℕ → ℕ
max a b with a ≟ b
... | lt a<b = b
... | eq a≡b = a
... | gt b<a = a
-- to make use of `it` to find proofs for `Fin k`:
module FinInstances where
open import Function.Base using (it) public
instance
z≤n' : ∀ {n} → zero ≤ n
z≤n' {n} = z≤n
s≤s' : ∀ {m n} {{m≤n : m ≤ n}} → suc m ≤ suc n
s≤s' {m} {n} {{m≤n}} = s≤s m≤n
¬1<0 : ¬(1 < 0)
¬1<0 (k , p) = snotz (sym (+-suc k 1) ∙ p)
suc-preserves-< : ∀{x y} → x < y → suc x < suc y
suc-preserves-< {x} {y} p = s≤s p
suc-reflects-< : ∀{x y} → suc x < suc y → x < y
suc-reflects-< {x} {y} (k , p) = k , (injSuc (sym (+-suc k (suc x)) ∙ p))
¬[k+x<k] : ∀ k x → ¬(k + x < k)
¬[k+x<k] k x (z , p) = snotz $ sym $ inj-m+ {k} {0} (+-zero k ∙ sym p ∙ +-suc z (k + x) ∙ (λ i → suc (+-comm z (k + x) i)) ∙ (λ i → suc (+-assoc k x z (~ i))) ∙ sym (+-suc k (x + z)))
-- import MoreLogic
open import MoreLogic.Reasoning
<-asymʷ : ∀ a b → a < b → ¬(b < a)
<-asymʷ a b a<b = ¬m<m ∘ <-trans a<b
{-
<-asym : ∀ a b → a < b → ¬(b < a)
<-asym a b (k , p) (l , q) = snotz $ inj-m+ {a} ((sym γ ∙ transport (λ i → l + suc (p (~ i)) ≡ a) q) ∙ sym (+-zero a))
where
γ = (
l + suc (k + suc a) ≡⟨ ( λ i → l + suc (+-suc k a i)) ⟩
l + suc (suc (k + a)) ≡⟨ ( λ i → l + suc (suc (+-comm k a i)) ) ⟩
l + suc (suc (a + k)) ≡⟨ ( λ i → l + suc (+-suc a k (~ i))) ⟩
l + suc (a + suc k) ≡⟨ ( λ i → l + (+-suc a (suc k) (~ i))) ⟩
l + (a + suc (suc k)) ≡⟨ +-assoc l a (suc (suc k)) ⟩
(l + a) + suc (suc k) ≡⟨ (λ i → +-comm l a i + suc (suc k) ) ⟩
(a + l) + suc (suc k) ≡⟨ sym $ +-assoc a l (suc (suc k)) ⟩
a + (l + suc (suc k)) ≡⟨ (λ i → a + +-suc l (suc k) i) ⟩
a + suc (l + suc k) ∎)
-}
<>-implies-≡ : ∀ a b → a ≤ b → b ≤ a → a ≡ b
<>-implies-≡ a b (n , p) (m , q) with m+n≡0→m≡0×n≡0 {m} {n} (m+n≡n→m≡0 γ)
where γ = sym (+-assoc m n a) ∙ (λ i → m + p i) ∙ q
... | m≡0 , n≡0 = (λ i → n≡0 (~ i) + a) ∙ p
≟-sym : ∀ a b → Trichotomy a b → Trichotomy b a
≟-sym a b (lt x) = gt x
≟-sym a b (eq x) = eq (sym x)
≟-sym a b (gt x) = lt x
-- NOTE: this is an ingedience to disprove
-- isComplex ≤ₙₗ isRat
-- which normalizes to
-- Σ[ k ∈ ℕ ] k + 4 ≡ 2
-- and is the same as
-- 4 ≤ 2
-- so more elegantly would be
-- ∀ x k → x < x + suc k
-- and turn this into
-- ∀ x k → ¬ (x + suc k ≤ x)
k+x+sy≢x : ∀ k x y → ¬(k + (x + suc y) ≡ x)
k+x+sy≢x k x y p = snotz $ sym (+-suc k y) ∙ inj-m+ {x} (+-assoc x k (suc y) ∙ (λ i → (+-comm x k) i + (suc y)) ∙ sym (+-assoc k x (suc y)) ∙ p ∙ sym (+-zero x))
0≤x : ∀ x → 0 ≤ x
0≤x zero = 0 , refl
0≤x (suc x) = suc x , (λ i → suc (+-zero x i)) ∙ refl {x = suc x}
| {
"alphanum_fraction": 0.4762459924,
"avg_line_length": 35.0102040816,
"ext": "agda",
"hexsha": "d3d5be95eda2d6b0a60d4d1abde0f7068610b361",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mchristianl/synthetic-reals",
"max_forks_repo_path": "agda/MoreNatProperties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mchristianl/synthetic-reals",
"max_issues_repo_path": "agda/MoreNatProperties.agda",
"max_line_length": 183,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mchristianl/synthetic-reals",
"max_stars_repo_path": "agda/MoreNatProperties.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": 1593,
"size": 3431
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of operations on the Stream type
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe --sized-types #-}
module Codata.Stream.Properties where
open import Size
open import Codata.Thunk using (Thunk; force)
open import Codata.Stream
open import Codata.Stream.Bisimilarity
open import Data.Nat.Base
open import Data.Nat.GeneralisedArithmetic using (fold; fold-pull)
import Data.Vec as Vec
import Data.Product as Prod
open import Function
open import Relation.Binary.PropositionalEquality as Eq using (_≡_)
------------------------------------------------------------------------
-- repeat
module _ {a} {A : Set a} where
lookup-repeat-identity : (n : ℕ) (a : A) → lookup n (repeat a) ≡ a
lookup-repeat-identity zero a = Eq.refl
lookup-repeat-identity (suc n) a = lookup-repeat-identity n a
take-repeat-identity : (n : ℕ) (a : A) → take n (repeat a) ≡ Vec.replicate a
take-repeat-identity zero a = Eq.refl
take-repeat-identity (suc n) a = Eq.cong (a Vec.∷_) (take-repeat-identity n a)
module _ {a b} {A : Set a} {B : Set b} where
map-repeat-commute : ∀ (f : A → B) a {i} → i ⊢ map f (repeat a) ≈ repeat (f a)
map-repeat-commute f a = Eq.refl ∷ λ where .force → map-repeat-commute f a
repeat-ap-identity : ∀ (f : A → B) as {i} → i ⊢ ap (repeat f) as ≈ map f as
repeat-ap-identity f (a ∷ as) = Eq.refl ∷ λ where .force → repeat-ap-identity f (as .force)
ap-repeat-identity : ∀ (fs : Stream (A → B) ∞) (a : A) {i} → i ⊢ ap fs (repeat a) ≈ map (_$ a) fs
ap-repeat-identity (f ∷ fs) a = Eq.refl ∷ λ where .force → ap-repeat-identity (fs .force) a
ap-repeat-commute : ∀ (f : A → B) a {i} → i ⊢ ap (repeat f) (repeat a) ≈ repeat (f a)
ap-repeat-commute f a = Eq.refl ∷ λ where .force → ap-repeat-commute f a
------------------------------------------------------------------------
-- Functor laws
module _ {a} {A : Set a} where
map-identity : ∀ (as : Stream A ∞) {i} → i ⊢ map id as ≈ as
map-identity (a ∷ as) = Eq.refl ∷ λ where .force → map-identity (as .force)
module _ {a b c} {A : Set a} {B : Set b} {C : Set c} where
map-map-fusion : ∀ (f : A → B) (g : B → C) as {i} → i ⊢ map g (map f as) ≈ map (g ∘ f) as
map-map-fusion f g (a ∷ as) = Eq.refl ∷ λ where .force → map-map-fusion f g (as .force)
------------------------------------------------------------------------
-- splitAt
module _ {a b} {A : Set a} {B : Set b} where
splitAt-map : ∀ n (f : A → B) xs →
splitAt n (map f xs) ≡ Prod.map (Vec.map f) (map f) (splitAt n xs)
splitAt-map zero f xs = Eq.refl
splitAt-map (suc n) f (x ∷ xs) =
Eq.cong (Prod.map₁ (f x Vec.∷_)) (splitAt-map n f (xs .force))
------------------------------------------------------------------------
-- iterate
module _ {a} {A : Set a} where
lookup-iterate-identity : ∀ n f (a : A) → lookup n (iterate f a) ≡ fold a f n
lookup-iterate-identity zero f a = Eq.refl
lookup-iterate-identity (suc n) f a = begin
lookup (suc n) (iterate f a) ≡⟨⟩
lookup n (iterate f (f a)) ≡⟨ lookup-iterate-identity n f (f a) ⟩
fold (f a) f n ≡⟨ fold-pull (const ∘′ f) (f a) Eq.refl (λ _ → Eq.refl) n ⟩
f (fold a f n) ≡⟨⟩
fold a f (suc n) ∎ where open Eq.≡-Reasoning
| {
"alphanum_fraction": 0.5292553191,
"avg_line_length": 37.1868131868,
"ext": "agda",
"hexsha": "f1dd7dc3e2bdd58e765130ca7cc8a91d01c2e130",
"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/Stream/Properties.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/Stream/Properties.agda",
"max_line_length": 98,
"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/Stream/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1072,
"size": 3384
} |
------------------------------------------------------------------------------
-- Conversion rules for the division
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module LTC-PCF.Program.Division.ConversionRules where
open import Common.FOL.Relation.Binary.EqReasoning
open import LTC-PCF.Base
open import LTC-PCF.Data.Nat
open import LTC-PCF.Data.Nat.Inequalities
open import LTC-PCF.Program.Division.Division
------------------------------------------------------------------------------
-- Division properties
private
-- Before to prove some properties for div it is convenient
-- to have a proof for each possible execution step.
-- Initially, we define the possible states (div-s₁, div-s₂,
-- ...) and after that, we write down the proof for the execution
-- step from the state p to the state q, e.g.
--
-- proof₂₋₃ : ∀ i j → div-s₂ i j ≡ div-s₃ i j.
-- Initially, the conversion rule fix-eq is applied.
div-s₁ : D → D → D
div-s₁ i j = divh (fix divh) · i · j
-- First argument application.
div-s₂ : D → D → D
div-s₂ i j = fun · j
where
fun : D
fun = lam (λ j → if (lt i j)
then zero
else succ₁ (fix divh · (i ∸ j) · j))
-- Second argument application.
div-s₃ : D → D → D
div-s₃ i j = if (lt i j) then zero else succ₁ (fix divh · (i ∸ j) · j)
-- lt i j ≡ true.
div-s₄ : D → D → D
div-s₄ i j = if true then zero else succ₁ (fix divh · (i ∸ j) · j)
-- lt i j ≡ false.
div-s₅ : D → D → D
div-s₅ i j = if false then zero else succ₁ (fix divh · (i ∸ j) · j)
-- The conditional is true.
div-s₆ : D
div-s₆ = zero
-- The conditional is false.
div-s₇ : D → D → D
div-s₇ i j = succ₁ (fix divh · (i ∸ j) · j)
{-
To prove the execution steps, e.g.
proof₃₋₄ : ∀ i j → div-s₃ i j → divh_s₄ i j,
we usually need to prove that
... m ... ≡ ... n ... (1)
given that
m ≡ n, (2)
where (2) is a conversion rule usually.
We prove (1) using
subst : ∀ {x y} (A : D → Set) → x ≡ y → A x → A y
where
• P is given by \m → ... m ... ≡ ... n ...,
• x ≡ y is given n ≡ m (actually, we use ≡-sym (m ≡ n)) and
• P x is given by ... n ... ≡ ... n ... (i.e. ≡-refl)
-}
-- From div · i · j to div-s₁ using the conversion rule fix-eq.
proof₀₋₁ : ∀ i j → fix divh · i · j ≡ div-s₁ i j
proof₀₋₁ i j = subst (λ t → t · i · j ≡ divh (fix divh) · i · j)
(sym (fix-eq divh))
refl
-- From div-s₁ to div-s₂ using the conversion rule beta.
proof₁₋₂ : ∀ i j → div-s₁ i j ≡ div-s₂ i j
proof₁₋₂ i j =
subst (λ t → t · j ≡ fun i · j)
(sym (beta fun i))
refl
where
-- The function fun is the same that the fun part of div-s₂,
-- except that we need a fresh variable y to avoid the
-- clashing of the variable i in the application of the beta
-- rule.
fun : D → D
fun y = lam (λ j → if (lt y j)
then zero
else succ₁ (fix divh · (y ∸ j) · j))
-- From div-s₂ to div-s₃ using the conversion rule beta.
proof₂₋₃ : ∀ i j → div-s₂ i j ≡ div-s₃ i j
proof₂₋₃ i j = beta fun j
where
-- The function fun is the same that div-s₃, except that we
-- need a fresh variable y to avoid the clashing of the
-- variable j in the application of the beta rule.
fun : D → D
fun y = if (lt i y) then zero else succ₁ ((fix divh) · (i ∸ y) · y)
-- From div-s₃ to div-s₄ using the proof i<j.
proof₃_₄ : ∀ i j → i < j → div-s₃ i j ≡ div-s₄ i j
proof₃_₄ i j i<j =
subst (λ t → (if t then zero else succ₁ ((fix divh) · (i ∸ j) · j)) ≡
(if true then zero else succ₁ ((fix divh) · (i ∸ j) · j)))
(sym i<j)
refl
-- From div-s₃ to div-s₅ using the proof i≮j.
proof₃₋₅ : ∀ i j → i ≮ j → div-s₃ i j ≡ div-s₅ i j
proof₃₋₅ i j i≮j =
subst (λ t → (if t then zero else succ₁ ((fix divh) · (i ∸ j) · j)) ≡
(if false then zero else succ₁ ((fix divh) · (i ∸ j) · j)))
(sym i≮j)
refl
-- From div-s₄ to div-s₆ using the conversion rule if-true.
proof₄₋₆ : ∀ i j → div-s₄ i j ≡ div-s₆
proof₄₋₆ i j = if-true zero
-- From div-s₅ to div-s₇ using the conversion rule if-false.
proof₅₋₇ : ∀ i j → div-s₅ i j ≡ div-s₇ i j
proof₅₋₇ i j = if-false (succ₁ (fix divh · (i ∸ j) · j))
----------------------------------------------------------------------
-- The division result when the dividend is minor than the
-- the divisor.
div-x<y : ∀ {i j} → i < j → div i j ≡ zero
div-x<y {i} {j} i<j =
div i j ≡⟨ proof₀₋₁ i j ⟩
div-s₁ i j ≡⟨ proof₁₋₂ i j ⟩
div-s₂ i j ≡⟨ proof₂₋₃ i j ⟩
div-s₃ i j ≡⟨ proof₃_₄ i j i<j ⟩
div-s₄ i j ≡⟨ proof₄₋₆ i j ⟩
div-s₆ ∎
----------------------------------------------------------------------
-- The division result when the dividend is greater or equal than the
-- the divisor.
div-x≮y : ∀ {i j} → i ≮ j → div i j ≡ succ₁ (div (i ∸ j) j)
div-x≮y {i} {j} i≮j =
div i j ≡⟨ proof₀₋₁ i j ⟩
div-s₁ i j ≡⟨ proof₁₋₂ i j ⟩
div-s₂ i j ≡⟨ proof₂₋₃ i j ⟩
div-s₃ i j ≡⟨ proof₃₋₅ i j i≮j ⟩
div-s₅ i j ≡⟨ proof₅₋₇ i j ⟩
div-s₇ i j ∎
| {
"alphanum_fraction": 0.4805585012,
"avg_line_length": 33.4792899408,
"ext": "agda",
"hexsha": "162ac637943fa387db29630d5427436591cc490a",
"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/LTC-PCF/Program/Division/ConversionRules.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/LTC-PCF/Program/Division/ConversionRules.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/LTC-PCF/Program/Division/ConversionRules.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": 1920,
"size": 5658
} |
module Issue314 where
postulate A : Set
data _≡_ (x : A) : A → Set where
refl : x ≡ x
postulate lemma : (x y : A) → x ≡ y
Foo : A → Set₁
Foo x with lemma x _
Foo x | refl = Set
-- Bug.agda:12,9-13
-- Failed to solve the following constraints:
-- x == _23 x : A
-- when checking that the pattern refl has type x ≡ _23 x
| {
"alphanum_fraction": 0.6200607903,
"avg_line_length": 17.3157894737,
"ext": "agda",
"hexsha": "7ceb9cda8b223740655c664c41bb153b85bc76cc",
"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/Issue314.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/Issue314.agda",
"max_line_length": 57,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Issue314.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 117,
"size": 329
} |
{-# OPTIONS --cubical --safe #-}
module Cubical.Data.List.Properties where
open import Agda.Builtin.List
open import Cubical.Core.Everything
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Prelude
open import Cubical.Data.Empty
open import Cubical.Data.Nat
open import Cubical.Data.Prod
open import Cubical.Data.Unit
open import Cubical.Relation.Nullary
open import Cubical.Data.List.Base
module _ {ℓ} {A : Type ℓ} where
++-unit-r : (xs : List A) → xs ++ [] ≡ xs
++-unit-r [] = refl
++-unit-r (x ∷ xs) = cong (_∷_ x) (++-unit-r xs)
++-assoc : (xs ys zs : List A) → (xs ++ ys) ++ zs ≡ xs ++ ys ++ zs
++-assoc [] ys zs = refl
++-assoc (x ∷ xs) ys zs = cong (_∷_ x) (++-assoc xs ys zs)
rev-++ : (xs ys : List A) → rev (xs ++ ys) ≡ rev ys ++ rev xs
rev-++ [] ys = sym (++-unit-r (rev ys))
rev-++ (x ∷ xs) ys =
cong (λ zs → zs ++ [ x ]) (rev-++ xs ys)
∙ ++-assoc (rev ys) (rev xs) [ x ]
rev-rev : (xs : List A) → rev (rev xs) ≡ xs
rev-rev [] = refl
rev-rev (x ∷ xs) = rev-++ (rev xs) [ x ] ∙ cong (_∷_ x) (rev-rev xs)
-- Path space of list type
module ListPath {ℓ} {A : Type ℓ} where
Cover : List A → List A → Type ℓ
Cover [] [] = Lift Unit
Cover [] (_ ∷ _) = Lift ⊥
Cover (_ ∷ _) [] = Lift ⊥
Cover (x ∷ xs) (y ∷ ys) = (x ≡ y) × Cover xs ys
reflCode : ∀ xs → Cover xs xs
reflCode [] = lift tt
reflCode (_ ∷ xs) = refl , reflCode xs
encode : ∀ xs ys → (p : xs ≡ ys) → Cover xs ys
encode xs _ = J (λ ys _ → Cover xs ys) (reflCode xs)
encodeRefl : ∀ xs → encode xs xs refl ≡ reflCode xs
encodeRefl xs = JRefl (λ ys _ → Cover xs ys) (reflCode xs)
decode : ∀ xs ys → Cover xs ys → xs ≡ ys
decode [] [] _ = refl
decode [] (_ ∷ _) (lift ())
decode (x ∷ xs) [] (lift ())
decode (x ∷ xs) (y ∷ ys) (p , c) = cong₂ _∷_ p (decode xs ys c)
decodeRefl : ∀ xs → decode xs xs (reflCode xs) ≡ refl
decodeRefl [] = refl
decodeRefl (x ∷ xs) = cong (cong₂ _∷_ refl) (decodeRefl xs)
decodeEncode : ∀ xs ys → (p : xs ≡ ys) → decode xs ys (encode xs ys p) ≡ p
decodeEncode xs _ =
J (λ ys p → decode xs ys (encode xs ys p) ≡ p)
(cong (decode xs xs) (encodeRefl xs) ∙ decodeRefl xs)
isOfHLevelCover : (n : ℕ) (p : isOfHLevel (suc (suc n)) A)
(xs ys : List A) → isOfHLevel (suc n) (Cover xs ys)
isOfHLevelCover n p [] [] =
isOfHLevelLift (suc n)
(subst (λ m → isOfHLevel m Unit) (+-comm n 1)
(hLevelLift n isPropUnit))
isOfHLevelCover n p [] (y ∷ ys) =
isOfHLevelLift (suc n)
(subst (λ m → isOfHLevel m ⊥) (+-comm n 1)
(hLevelLift n isProp⊥))
isOfHLevelCover n p (x ∷ xs) [] =
isOfHLevelLift (suc n)
(subst (λ m → isOfHLevel m ⊥) (+-comm n 1)
(hLevelLift n isProp⊥))
isOfHLevelCover n p (x ∷ xs) (y ∷ ys) =
hLevelProd (suc n) (p x y) (isOfHLevelCover n p xs ys)
isOfHLevelList : ∀ {ℓ} (n : ℕ) {A : Type ℓ}
→ isOfHLevel (suc (suc n)) A → isOfHLevel (suc (suc n)) (List A)
isOfHLevelList n ofLevel xs ys =
retractIsOfHLevel (suc n)
(ListPath.encode xs ys)
(ListPath.decode xs ys)
(ListPath.decodeEncode xs ys)
(ListPath.isOfHLevelCover n ofLevel xs ys)
private
variable
ℓ : Level
A : Type ℓ
caseList : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → (n c : B) → List A → B
caseList n _ [] = n
caseList _ c (_ ∷ _) = c
safe-head : A → List A → A
safe-head x [] = x
safe-head _ (x ∷ _) = x
safe-tail : List A → List A
safe-tail [] = []
safe-tail (_ ∷ xs) = xs
cons-inj₁ : ∀ {x y : A} {xs ys} → x ∷ xs ≡ y ∷ ys → x ≡ y
cons-inj₁ {x = x} p = cong (safe-head x) p
cons-inj₂ : ∀ {x y : A} {xs ys} → x ∷ xs ≡ y ∷ ys → xs ≡ ys
cons-inj₂ = cong safe-tail
¬cons≡nil : ∀ {x : A} {xs} → ¬ (x ∷ xs ≡ [])
¬cons≡nil {A = A} p = lower (subst (caseList (Lift ⊥) (List A)) p [])
¬nil≡cons : ∀ {x : A} {xs} → ¬ ([] ≡ x ∷ xs)
¬nil≡cons {A = A} p = lower (subst (caseList (List A) (Lift ⊥)) p [])
¬snoc≡nil : ∀ {x : A} {xs} → ¬ (xs ∷ʳ x ≡ [])
¬snoc≡nil {xs = []} contra = ¬cons≡nil contra
¬snoc≡nil {xs = x ∷ xs} contra = ¬cons≡nil contra
¬nil≡snoc : ∀ {x : A} {xs} → ¬ ([] ≡ xs ∷ʳ x)
¬nil≡snoc contra = ¬snoc≡nil (sym contra)
cons≡rev-snoc : (x : A) → (xs : List A) → x ∷ rev xs ≡ rev (xs ∷ʳ x)
cons≡rev-snoc _ [] = refl
cons≡rev-snoc x (y ∷ ys) = λ i → cons≡rev-snoc x ys i ++ y ∷ []
nil≡nil-isContr : isContr (Path (List A) [] [])
nil≡nil-isContr = refl , ListPath.decodeEncode [] []
list≡nil-isProp : {xs : List A} → isProp (xs ≡ [])
list≡nil-isProp {xs = []} = hLevelSuc 0 _ nil≡nil-isContr
list≡nil-isProp {xs = x ∷ xs} = λ p _ → ⊥-elim (¬cons≡nil p)
discreteList : Discrete A → Discrete (List A)
discreteList eqA [] [] = yes refl
discreteList eqA [] (y ∷ ys) = no ¬nil≡cons
discreteList eqA (x ∷ xs) [] = no ¬cons≡nil
discreteList eqA (x ∷ xs) (y ∷ ys) with eqA x y | discreteList eqA xs ys
... | yes p | yes q = yes (λ i → p i ∷ q i)
... | yes _ | no ¬q = no (λ p → ¬q (cons-inj₂ p))
... | no ¬p | _ = no (λ q → ¬p (cons-inj₁ q))
| {
"alphanum_fraction": 0.5547298654,
"avg_line_length": 32.9735099338,
"ext": "agda",
"hexsha": "07293b01e1354f2a257f622ec2aa8fc895c4593a",
"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/Data/List/Properties.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/Data/List/Properties.agda",
"max_line_length": 76,
"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/Data/List/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2027,
"size": 4979
} |
module UnequalHiding where
data One : Set where one : One
f : ({A : Set} -> A -> A) -> One
f = \(id : (A : Set) -> A -> A) -> id One one
| {
"alphanum_fraction": 0.5142857143,
"avg_line_length": 17.5,
"ext": "agda",
"hexsha": "188b73cd1a4e0f12d03dc5f85b5b9a9944531f08",
"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/UnequalHiding.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/UnequalHiding.agda",
"max_line_length": 45,
"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/UnequalHiding.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": 52,
"size": 140
} |
data _≡_ {X : Set} : X → X → Set where
refl : {x : X} → x ≡ x
ap : {X Y : Set} (f : X → Y) {x x' : X} → x ≡ x' → f x ≡ f x'
ap f refl = refl
_∙_ : {X : Set} {x y z : X} → x ≡ y → y ≡ z → x ≡ z
p ∙ refl = p
f : {X : Set} {x : X} {A : X → Set} (η θ : (y : X) → x ≡ y → A y)
→ η x refl ≡ θ x refl → ∀ y p → η y p ≡ θ y p
f η θ q y refl = ap (λ a → a) q
succeeds : (X : Set) (z t : X) (r : z ≡ t)
→ (λ (x y : X) (p : x ≡ y) (q : y ≡ z) → (p ∙ q) ∙ r)
≡ (λ (x y : X) (p : x ≡ y) (q : y ≡ z) → p ∙ (q ∙ r))
succeeds X z = f -- {A = λ - → (x y : X) (p : x ≡ y) (q : y ≡ z) → x ≡ - }
(λ z r x y p q → (p ∙ q) ∙ r)
(λ z r x y p q → p ∙ (q ∙ r))
refl
fails : (X : Set) (z t : X) (r : z ≡ t)
→ (λ (x y : X) (p : x ≡ y) (q : y ≡ z) → (p ∙ q) ∙ r)
≡ (λ (x y : X) (p : x ≡ y) (q : y ≡ z) → p ∙ (q ∙ r))
fails X z t = f -- {A = λ - → (x y : X) (p : x ≡ y) (q : y ≡ z) → x ≡ - }
(λ z r x y p q → (p ∙ q) ∙ r)
(λ z r x y p q → p ∙ (q ∙ r))
refl
t
| {
"alphanum_fraction": 0.2903525046,
"avg_line_length": 34.7741935484,
"ext": "agda",
"hexsha": "c8c380aa3ed3f9829ef819efbb66deff8066557f",
"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/Issue3960i.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/Issue3960i.agda",
"max_line_length": 74,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue3960i.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": 561,
"size": 1078
} |
module Oscar.Data.Step {𝔣} (FunctionName : Set 𝔣) where
open import Data.Nat using (ℕ; suc; zero)
open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong₂; cong; sym; trans)
open import Function using (_∘_; flip)
open import Relation.Nullary using (¬_; Dec; yes; no)
open import Data.Product using (∃; _,_; _×_)
open import Data.Empty using (⊥-elim)
open import Data.Vec using (Vec; []; _∷_)
open import Oscar.Data.Fin
open import Data.Nat hiding (_≤_)
open import Relation.Binary.PropositionalEquality renaming ([_] to [[_]])
open import Function using (_∘_; id; case_of_; _$_; flip)
open import Relation.Nullary
open import Data.Product renaming (map to _***_)
open import Data.Empty
open import Data.Maybe
open import Category.Functor
open import Category.Monad
import Level
open RawMonad (Data.Maybe.monad {Level.zero})
open import Data.Sum
open import Data.Maybe using (maybe; maybe′; nothing; just; monad; Maybe)
open import Data.List renaming (_++_ to _++L_)
open ≡-Reasoning
open import Data.Vec using (Vec; []; _∷_) renaming (_++_ to _++V_; map to mapV)
open import Oscar.Data.Term FunctionName
data Step (n : ℕ) : Set 𝔣 where
left : Term n -> Step n
right : Term n -> Step n
function : FunctionName → ∀ {L} → Vec (Term n) L → ∀ {R} → Vec (Term n) R → Step n
fmapS : ∀ {n m} (f : Term n -> Term m) (s : Step n) -> Step m
fmapS f (left x) = left (f x)
fmapS f (right x) = right (f x)
fmapS f (function fn ls rs) = function fn (mapV f ls) (mapV f rs)
_⊹_ : ∀ {n} (ps : List (Step n)) (t : Term n) -> Term n
[] ⊹ t = t
(left r ∷ ps) ⊹ t = (ps ⊹ t) fork r
(right l ∷ ps) ⊹ t = l fork (ps ⊹ t)
(function fn ls rs ∷ ps) ⊹ t = function fn (ls ++V (ps ⊹ t) ∷ rs)
fork++ : ∀ {m} {s t : Term m} ps ->
(ps ⊹ (s fork t) ≡ (ps ++L [ left t ]) ⊹ s)
× (ps ⊹ (s fork t) ≡ (ps ++L [ right s ]) ⊹ t)
fork++ [] = refl , refl
fork++ (left y' ∷ xs') = (cong (λ a -> a fork y') *** cong (λ a -> a fork y')) (fork++ xs')
fork++ (right y' ∷ xs') = (cong (λ a -> y' fork a) *** cong (λ a -> y' fork a)) (fork++ xs')
fork++ {s = s} {t} (function fn ls rs ∷ xs') =
(cong (λ a → function fn (ls ++V a ∷ rs)) *** cong (λ a → function fn (ls ++V a ∷ rs))) (fork++ xs')
function++ : ∀ {m} {fn} {t : Term m} {L} {ls : Vec (Term m) L} {R} {rs : Vec (Term m) R} ps →
ps ⊹ (function fn (ls ++V t ∷ rs)) ≡ (ps ++L [ function fn ls rs ]) ⊹ t
function++ [] = refl
function++ (left x ∷ ps) = cong (_fork x) (function++ ps)
function++ (right x ∷ ps) = cong (x fork_) (function++ ps)
function++ (function fn ls rs ∷ ps) = cong (λ a → function fn (ls ++V a ∷ rs)) (function++ ps)
-- _◃S_ : ∀ {n m} (f : n ⊸ m) -> List (Step n) -> List (Step m)
-- _◃S_ f = Data.List.map (fmapS (f ◃_))
-- map-[] : ∀ {n m} (f : n ⊸ m) ps -> f ◃S ps ≡ [] -> ps ≡ []
-- map-[] f [] _ = refl
-- map-[] f (x ∷ xs) ()
-- module StepM where
-- lemma1 : ∀ {n} (x : Step n) xs t -> [ x ] ⊹ ( xs ⊹ t ) ≡ (x ∷ xs) ⊹ t
-- lemma1 (left y) xs t = refl
-- lemma1 (right y) xs t = refl
-- lemma1 (function fn ls rs) xs t = refl
-- lemma2 : ∀ {n} {r} {t} {xs} (x : Step n) -> xs ⊹ t ≡ r -> ((x ∷ xs) ⊹ t ) ≡ [ x ] ⊹ r
-- lemma2 (left y) eq = cong (λ t -> t fork y) eq
-- lemma2 (right y) eq = cong (λ t -> y fork t) eq
-- lemma2 (function fn ls rs) eq = cong (λ t → function fn (ls ++V t ∷ rs)) eq
-- fact1 : ∀ {n} ps qs (t : Term n) -> (ps ++L qs) ⊹ t ≡ ps ⊹ (qs ⊹ t)
-- fact1 [] qs t = refl
-- fact1 (p ∷ ps) qs t = begin (p ∷ (ps ++L qs)) ⊹ t ≡⟨ lemma2 p (fact1 ps qs t) ⟩
-- [ p ] ⊹ (ps ⊹ (qs ⊹ t)) ≡⟨ lemma1 p ps (qs ⊹ t) ⟩
-- (p ∷ ps) ⊹ (qs ⊹ t) ∎
-- ◃-fact1 : ∀ {m n} (f : m ⊸ n) {N} (rs : Vec (Term m) N) → f ◃s rs ≡ mapV (f ◃_) rs
-- ◃-fact1 f [] = refl
-- ◃-fact1 f (x ∷ rs) rewrite ◃-fact1 f rs = refl
-- ◃-fact2 : ∀ {m n} (f : m ⊸ n) {L} (ls : Vec (Term m) L) {R} (rs : Vec (Term m) R) → f ◃s (ls ++V rs) ≡ (f ◃s ls) ++V (f ◃s rs)
-- ◃-fact2 f [] rs = refl
-- ◃-fact2 f (l ∷ ls) rs = cong ((f ◃ l) ∷_) (◃-fact2 f ls rs)
-- fact2 : ∀ {m n} (f : m ⊸ n) t ps ->
-- f ◃ (ps ⊹ t) ≡ (f ◃S ps) ⊹ (f ◃ t)
-- fact2 f t [] = refl
-- fact2 f t (left y ∷ xs) = cong (λ t -> t fork (f ◃ y)) (fact2 f t xs)
-- fact2 f t (right y ∷ xs) = cong (λ t -> (f ◃ y) fork t) (fact2 f t xs)
-- fact2 f t (function fn ls rs ∷ xs) rewrite sym (◃-fact1 f ls) | sym (◃-fact1 f rs) = cong (function fn) (trans (◃-fact2 f ls ((xs ⊹ t) ∷ rs)) (cong ((f ◃s ls) ++V_) (cong (_∷ (f ◃s rs)) (fact2 f t xs))))
-- mutual
-- check-props : ∀ {m} (x : Fin (suc m)) {N} (ts : Vec (Term (suc m)) N) fn ->
-- (∃ λ (ts' : Vec (Term m) N) -> ts ≡ ▹ (thin x) ◃s ts' × check x ts ≡ just ts')
-- ⊎ (∃ λ ps -> function fn ts ≡ (ps ⊹ i x) × check x ts ≡ nothing)
-- check-props x [] fn = inj₁ ([] , refl , refl)
-- check-props x (t ∷ ts) fn with check-prop x t
-- … | inj₂ (ps , t=ps+ix , checkxt=no) rewrite t=ps+ix | checkxt=no = inj₂ (function fn [] ts ∷ ps , refl , refl)
-- … | inj₁ (t' , t=thinxt' , checkxt=t') rewrite checkxt=t' with check-props x ts fn
-- … | inj₁ (ts' , ts=thinxts' , checkxts=ts') rewrite t=thinxt' | ts=thinxts' | checkxts=ts' = inj₁ (_ , refl , refl)
-- … | inj₂ ([] , () , checkxts=no)
-- … | inj₂ (left _ ∷ ps , () , checkxts=no)
-- … | inj₂ (right _ ∷ ps , () , checkxts=no)
-- … | inj₂ (function fn' ls rs ∷ ps , ts=ps+ix , checkxts=no) with Term-function-inj-VecSize ts=ps+ix
-- … | refl with Term-function-inj-Vector ts=ps+ix
-- … | refl rewrite checkxts=no = inj₂ (function fn (t ∷ ls) rs ∷ ps , refl , refl)
-- check-prop : ∀ {m} (x : Fin (suc m)) t ->
-- (∃ λ t' -> t ≡ ▹ (thin x) ◃ t' × check x t ≡ just t')
-- ⊎ (∃ λ ps -> t ≡ (ps ⊹ i x) × check x t ≡ nothing)
-- check-prop x (i x') with checkfact1 x x' (check x x') refl
-- check-prop x (i .x) | inj₁ (refl , e) = inj₂ ([] , refl , cong (_<$>_ i) e)
-- ... | inj₂ (y , thinxy≡x' , thickxx'≡justy')
-- = inj₁ (i y
-- , cong i (sym (thinxy≡x'))
-- , cong (_<$>_ i) thickxx'≡justy' )
-- check-prop x leaf = inj₁ (leaf , (refl , refl))
-- check-prop x (s fork t)
-- with check-prop x s | check-prop x t
-- ... | inj₁ (s' , s≡thinxs' , checkxs≡s') | inj₁ (t' , t≡thinxt' , checkxt≡t')
-- = inj₁ (s' fork t' , cong₂ _fork_ s≡thinxs' t≡thinxt'
-- , cong₂ (λ a b -> _fork_ <$> a ⊛ b) checkxs≡s' checkxt≡t' )
-- ... | inj₂ (ps , s≡ps+ix , checkxs≡no ) | _
-- = inj₂ (left t ∷ ps , cong (λ s -> s fork t) s≡ps+ix
-- , cong (λ a -> _fork_ <$> a ⊛ check x t) checkxs≡no )
-- ... | _ | inj₂ (ps , s≡ps+ix , checkxs≡no )
-- = inj₂ (right s ∷ ps , cong (λ t -> s fork t) s≡ps+ix
-- , trans (cong (λ a -> _fork_ <$> check x s ⊛ a) checkxs≡no) (lemma (_fork_ <$> check x s)))
-- where
-- lemma : ∀ {a b : Set} {y : b} (x : Maybe a) -> maybe (λ _ → y) y x ≡ y
-- lemma (just x') = refl
-- lemma nothing = refl
-- check-prop x (function fn ts) with check-props x ts fn
-- … | inj₁ (t' , t=thinxt' , checkxt=t') rewrite checkxt=t' = inj₁ (function fn t' , cong (function fn) t=thinxt' , refl)
-- … | inj₂ (ps , t=ps+ix , checkxt=no) rewrite checkxt=no = inj₂ (ps , t=ps+ix , refl)
-- -- data SizedTerm (n : ℕ) : ℕ → Set where
-- -- i : (x : Fin n) -> SizedTerm n (suc zero)
-- -- leaf : SizedTerm n (suc zero)
-- -- _fork_ : (s : ∃ (SizedTerm n)) (t : ∃ (SizedTerm n)) -> SizedTerm n (suc (proj₁ s + proj₁ t))
-- -- function : FunctionName → ∀ {f} → (ts : Vec (∃ (SizedTerm n)) f) → SizedTerm n (suc (Data.Vec.sum (Data.Vec.map proj₁ ts)))
-- -- data SizedStep (n : ℕ) : Set where
-- -- left : ∃ (SizedTerm n) -> SizedStep n
-- -- right : ∃ (SizedTerm n) -> SizedStep n
-- -- function : FunctionName → ∀ {L} → Vec (∃ (SizedTerm n)) L → ∀ {R} → Vec (∃ (SizedTerm n)) R → SizedStep n
-- -- mutual
-- -- toSizedTerm : ∀ {n} → Term n → ∃ (SizedTerm n)
-- -- toSizedTerm (i x) = suc zero , i x
-- -- toSizedTerm leaf = suc zero , leaf
-- -- toSizedTerm (l fork r) with toSizedTerm l | toSizedTerm r
-- -- … | L , sl | R , sr = (suc (L + R)) , ((L , sl) fork (R , sr))
-- -- toSizedTerm (function fn ts) with toSizedTerms ts
-- -- … | sts = suc (Data.Vec.sum (Data.Vec.map proj₁ sts)) , SizedTerm.function fn sts
-- -- fromSizedTerm : ∀ {n} → ∃ (SizedTerm n) → Term n
-- -- fromSizedTerm (_ , i x) = i x
-- -- fromSizedTerm (_ , leaf) = leaf
-- -- fromSizedTerm (_ , (_fork_ t₁ t₂)) = (fromSizedTerm t₁ fork fromSizedTerm t₂)
-- -- fromSizedTerm (_ , function fn ts) = function fn (fromSizedTerms ts)
-- -- toSizedTerms : ∀ {n N} → Vec (Term n) N → Vec (∃ (SizedTerm n)) N
-- -- toSizedTerms [] = []
-- -- toSizedTerms (t ∷ ts) = toSizedTerm t ∷ toSizedTerms ts
-- -- fromSizedTerms : ∀ {n N} → Vec (∃ (SizedTerm n)) N → Vec (Term n) N
-- -- fromSizedTerms [] = []
-- -- fromSizedTerms (t ∷ ts) = fromSizedTerm t ∷ fromSizedTerms ts
-- -- mutual
-- -- isoSizedTerm : ∀ {n} → (st : ∃ (SizedTerm n)) → st ≡ toSizedTerm (fromSizedTerm st)
-- -- isoSizedTerm (._ , i x) = refl
-- -- isoSizedTerm (._ , leaf) = refl
-- -- isoSizedTerm (.(suc (proj₁ s + proj₁ t)) , (s fork t)) rewrite sym (isoSizedTerm s) | sym (isoSizedTerm t) = refl
-- -- isoSizedTerm (._ , function x ts) rewrite sym (isoSizedTerms ts) = refl
-- -- isoSizedTerms : ∀ {n N} → (st : Vec (∃ (SizedTerm n)) N) → st ≡ toSizedTerms (fromSizedTerms st)
-- -- isoSizedTerms [] = refl
-- -- isoSizedTerms (t ∷ ts) rewrite sym (isoSizedTerm t) | sym (isoSizedTerms ts) = refl
-- -- mutual
-- -- isoTerm : ∀ {n} → (t : Term n) → t ≡ fromSizedTerm (toSizedTerm t)
-- -- isoTerm (i x) = refl
-- -- isoTerm leaf = refl
-- -- isoTerm (s fork t) rewrite sym (isoTerm s) | sym (isoTerm t) = refl
-- -- isoTerm (function fn ts) rewrite sym (isoTerms ts) = refl
-- -- isoTerms : ∀ {n N} → (t : Vec (Term n) N) → t ≡ fromSizedTerms (toSizedTerms t)
-- -- isoTerms [] = refl
-- -- isoTerms (t ∷ ts) rewrite sym (isoTerm t) | sym (isoTerms ts) = refl
-- -- toSizedStep : ∀ {n} → Step n → SizedStep n
-- -- toSizedStep (left r) = left (toSizedTerm r)
-- -- toSizedStep (right l) = right (toSizedTerm l)
-- -- toSizedStep (function fn ls rs) = function fn (toSizedTerms ls) (toSizedTerms rs)
-- -- fromSizedStep : ∀ {n} → SizedStep n → Step n
-- -- fromSizedStep (left r) = left (fromSizedTerm r)
-- -- fromSizedStep (right l) = right (fromSizedTerm l)
-- -- fromSizedStep (function fn ls rs) = function fn (fromSizedTerms ls) (fromSizedTerms rs)
-- -- isoSizedStep : ∀ {n} → (ss : SizedStep n) → ss ≡ toSizedStep (fromSizedStep ss)
-- -- isoSizedStep (left r) rewrite sym (isoSizedTerm r) = refl
-- -- isoSizedStep (right l) rewrite sym (isoSizedTerm l) = refl
-- -- isoSizedStep (function fn ls rs) rewrite sym (isoSizedTerms ls) | sym (isoSizedTerms rs) = refl
-- -- isoStep : ∀ {n} → (s : Step n) → s ≡ fromSizedStep (toSizedStep s)
-- -- isoStep (left r) rewrite sym (isoTerm r) = refl
-- -- isoStep (right l) rewrite sym (isoTerm l) = refl
-- -- isoStep (function fn ls rs) rewrite sym (isoTerms ls) | sym (isoTerms rs) = refl
-- -- toSizedSteps : ∀ {n} → List (Step n) → List (SizedStep n)
-- -- toSizedSteps [] = []
-- -- toSizedSteps (s ∷ ss) = toSizedStep s ∷ toSizedSteps ss
-- -- fromSizedSteps : ∀ {n} → List (SizedStep n) → List (Step n)
-- -- fromSizedSteps [] = []
-- -- fromSizedSteps (s ∷ ss) = fromSizedStep s ∷ fromSizedSteps ss
-- -- isoSizedSteps : ∀ {n} → (ss : List (SizedStep n)) → ss ≡ toSizedSteps (fromSizedSteps ss)
-- -- isoSizedSteps [] = refl
-- -- isoSizedSteps (s ∷ ss) rewrite sym (isoSizedStep s) | sym (isoSizedSteps ss) = refl
-- -- isoSteps : ∀ {n} → (s : List (Step n)) → s ≡ fromSizedSteps (toSizedSteps s)
-- -- isoSteps [] = refl
-- -- isoSteps (s ∷ ss) rewrite sym (isoStep s) | sym (isoSteps ss) = refl
-- -- _Sized⊹_ : ∀ {n} (ps : List (SizedStep n)) (t : ∃ (SizedTerm n)) -> ∃ (SizedTerm n)
-- -- [] Sized⊹ t = t
-- -- (left r ∷ ps) Sized⊹ t = _ , (ps Sized⊹ t) SizedTerm.fork r
-- -- (right l ∷ ps) Sized⊹ t = _ , l SizedTerm.fork (ps Sized⊹ t)
-- -- (function fn ls rs ∷ ps) Sized⊹ t = _ , function fn (ls ++V (ps Sized⊹ t) ∷ rs)
-- -- fromSizedTerms-commute : ∀ {n} {L R} → (ls : Vec (∃ (SizedTerm n)) L) (rs : Vec (∃ (SizedTerm n)) R) → fromSizedTerms (ls ++V rs) ≡ fromSizedTerms ls ++V fromSizedTerms rs
-- -- fromSizedTerms-commute [] rs = refl
-- -- fromSizedTerms-commute (l ∷ ls) rs rewrite fromSizedTerms-commute ls rs = refl
-- -- toSizedTerms-commute : ∀ {n} {L R} → (ls : Vec (Term n) L) (rs : Vec (Term n) R) → toSizedTerms (ls ++V rs) ≡ toSizedTerms ls ++V toSizedTerms rs
-- -- toSizedTerms-commute [] rs = refl
-- -- toSizedTerms-commute (l ∷ ls) rs rewrite toSizedTerms-commute ls rs = refl
-- -- isoSized⊹ : ∀ {n} (ps : List (SizedStep n)) (t : ∃ (SizedTerm n)) → fromSizedTerm (ps Sized⊹ t) ≡ fromSizedSteps ps ⊹ fromSizedTerm t
-- -- isoSized⊹ [] t = refl
-- -- isoSized⊹ (left r ∷ ps) t rewrite isoSized⊹ ps t = refl
-- -- isoSized⊹ (right l ∷ ps) t rewrite isoSized⊹ ps t = refl
-- -- isoSized⊹ (function fn ls rs ∷ ps) t rewrite sym (isoSized⊹ ps t) | fromSizedTerms-commute ls ((ps Sized⊹ t) ∷ rs) = refl
-- -- iso⊹ : ∀ {n} (ps : List (Step n)) (t : Term n) → toSizedTerm (ps ⊹ t) ≡ toSizedSteps ps Sized⊹ toSizedTerm t
-- -- iso⊹ [] t = refl
-- -- iso⊹ (left r ∷ ps) t rewrite iso⊹ ps t = refl
-- -- iso⊹ (right l ∷ ps) t rewrite iso⊹ ps t = refl
-- -- iso⊹ (function fn ls rs ∷ ps) t rewrite sym (iso⊹ ps t) | toSizedTerms-commute ls ((ps ⊹ t) ∷ rs) = refl
-- -- import Data.Vec.Properties
-- -- import Relation.Binary.PropositionalEquality as PE
-- -- open Data.Vec.Properties.UsingVectorEquality (PE.setoid ℕ)
-- -- import Data.Vec.Equality
-- -- open Data.Vec.Equality.PropositionalEquality using (to-≡)
-- -- -- some equivalences needed to adapt Tactic.Nat to the standard library
-- -- module EquivalenceOf≤ where
-- -- open import Agda.Builtin.Equality
-- -- open import Agda.Builtin.Nat
-- -- open import Data.Nat using (less-than-or-equal) renaming (_≤_ to _≤s_)
-- -- open import Data.Nat.Properties using (≤⇒≤″; ≤″⇒≤)
-- -- open import Prelude using (diff; id) renaming (_≤_ to _≤p_)
-- -- open import Tactic.Nat.Generic (quote _≤p_) (quote Function.id) (quote Function.id) using (by)
-- -- ≤p→≤s : ∀ {a b} → a ≤p b → a ≤s b
-- -- ≤p→≤s (diff k b₊₁≡k₊₁+a) = ≤″⇒≤ (less-than-or-equal {k = k} (by b₊₁≡k₊₁+a))
-- -- ≤s→≤p : ∀ {a b} → a ≤s b → a ≤p b
-- -- ≤s→≤p a≤sb with ≤⇒≤″ a≤sb
-- -- ≤s→≤p _ | less-than-or-equal {k = k} a+k≡b = diff k (by a+k≡b)
-- -- module _ where
-- -- open EquivalenceOf≤
-- -- open import Data.Nat
-- -- open import Tactic.Nat.Generic (quote Data.Nat._≤_) (quote ≤s→≤p) (quote ≤p→≤s) public
-- -- growingSize : ∀ {m} (st : ∃ (SizedTerm m)) → (sp : SizedStep m) (sps : List (SizedStep m)) → proj₁ ((sp ∷ sps) Sized⊹ st) > proj₁ st
-- -- growingSize st (left r) [] = auto
-- -- growingSize st (right l) [] = auto
-- -- growingSize {m} st (function fn ls rs) [] rewrite to-≡ (map-++-commute proj₁ ls {ys = st ∷ rs}) | Data.Vec.Properties.sum-++-commute (mapV proj₁ ls) {ys = mapV proj₁ (st ∷ rs)} = auto
-- -- growingSize st (left x) (p₂ ∷ ps) = by (growingSize st p₂ ps)
-- -- growingSize st (right x) (p₂ ∷ ps) = by (growingSize st p₂ ps)
-- -- growingSize st (function fn ls rs) (p₂ ∷ ps) rewrite to-≡ (map-++-commute proj₁ ls {ys = ((p₂ ∷ ps) Sized⊹ st) ∷ rs}) | Data.Vec.Properties.sum-++-commute (mapV proj₁ ls) {ys = mapV proj₁ (((p₂ ∷ ps) Sized⊹ st) ∷ rs)} = by (growingSize st p₂ ps)
-- -- No-Cycle : ∀{m} (t : Term m) ps -> (eq : t ≡ ps ⊹ t) → ps ≡ []
-- -- No-Cycle t [] eq = refl
-- -- No-Cycle t (p ∷ ps) eq = refute (subst (λ v → v > proj₁ (toSizedTerm t)) (sym (trans same iso)) growth) where
-- -- same : proj₁ (toSizedTerm t) ≡ proj₁ (toSizedTerm ((p ∷ ps) ⊹ t))
-- -- growth : proj₁ ((toSizedStep p ∷ toSizedSteps ps) Sized⊹ toSizedTerm t) > proj₁ (toSizedTerm t)
-- -- iso : proj₁ (toSizedTerm ((p ∷ ps) ⊹ t)) ≡ proj₁ ((toSizedStep p ∷ toSizedSteps ps) Sized⊹ toSizedTerm t)
-- -- growth = growingSize (toSizedTerm t) (toSizedStep p) (toSizedSteps ps)
-- -- same = cong (proj₁ ∘ toSizedTerm) eq
-- -- iso = cong proj₁ (iso⊹ (p ∷ ps) t)
-- -- module Step2 where
-- -- fact : ∀{m} (x : Fin m) p ps -> Nothing (Unifies (i x) ((p ∷ ps) ⊹ i x))
-- -- fact x p ps f r with No-Cycle (f x) (f ◃S (p ∷ ps)) (trans r (StepM.fact2 f (i x) (p ∷ ps)))
-- -- ... | ()
-- -- NothingStep : ∀ {l} (x : Fin (suc l)) (t : Term (suc l)) →
-- -- i x ≢ t →
-- -- (ps : List (Step (suc l))) →
-- -- t ≡ (ps ⊹ i x) →
-- -- ∀ {n} (f : Fin (suc l) → Term n) → f x ≢ (f ◃ t)
-- -- NothingStep {l} x t ix≢t ps r = No-Unifier
-- -- where
-- -- No-Unifier : {n : ℕ} (f : Fin (suc l) → Term n) → f x ≢ f ◃ t
-- -- No-Unifier f fx≡f◃t = ix≢t (sym (trans r (cong (λ ps -> ps ⊹ i x) ps≡[])))
-- -- where
-- -- ps≡[] : ps ≡ []
-- -- ps≡[] = map-[] f ps (No-Cycle (f x) (f ◃S ps)
-- -- (begin f x ≡⟨ fx≡f◃t ⟩
-- -- f ◃ t ≡⟨ cong (f ◃_) r ⟩
-- -- f ◃ (ps ⊹ i x) ≡⟨ StepM.fact2 f (i x) ps ⟩
-- -- (f ◃S ps) ⊹ f x ∎))
| {
"alphanum_fraction": 0.5395538692,
"avg_line_length": 51.1588235294,
"ext": "agda",
"hexsha": "ef4c86ef078ac7a229b69bd9727170fdad835770",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-2/Oscar/Data/Step.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-2/Oscar/Data/Step.agda",
"max_line_length": 251,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-2/Oscar/Data/Step.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 6839,
"size": 17394
} |
{-# OPTIONS --cubical #-}
module Data.List.Permute where
open import Prelude
open import Data.Nat
open import Data.Nat.Properties using (_≤ᴮ_)
infixr 5 _∹_∷_
data Premuted {a} (A : Type a) : Type a where
[] : Premuted A
_∹_∷_ : ℕ → A → Premuted A → Premuted A
mutual
merge : Premuted A → Premuted A → Premuted A
merge [] = id
merge (n ∹ x ∷ xs) = mergeˡ n x (merge xs)
mergeˡ : ℕ → A → (Premuted A → Premuted A) → Premuted A → Premuted A
mergeˡ i x xs [] = i ∹ x ∷ xs []
mergeˡ i x xs (j ∹ y ∷ ys) = merge⁺ i x xs j y ys (i ≤ᴮ j)
merge⁺ : ℕ → A → (Premuted A → Premuted A) → ℕ → A → Premuted A → Bool → Premuted A
merge⁺ i x xs j y ys true = i ∹ x ∷ xs ((j ∸ i) ∹ y ∷ ys)
merge⁺ i x xs j y ys false = j ∹ y ∷ mergeˡ ((i ∸ j) ∸ 1) x xs ys
merge-idʳ : (xs : Premuted A) → merge xs [] ≡ xs
merge-idʳ [] = refl
merge-idʳ (i ∹ x ∷ xs) = cong (i ∹ x ∷_) (merge-idʳ xs)
open import Algebra
≤≡-trans : ∀ x y z → (x ≤ᴮ y) ≡ true → (y ≤ᴮ z) ≡ true → (x ≤ᴮ z) ≡ true
≤≡-trans zero y z p₁ p₂ = refl
≤≡-trans (suc x) zero z p₁ p₂ = ⊥-elim (subst (bool ⊤ ⊥) p₁ tt)
≤≡-trans (suc x) (suc y) zero p₁ p₂ = ⊥-elim (subst (bool ⊤ ⊥) p₂ tt)
≤≡-trans (suc x) (suc y) (suc z) p₁ p₂ = ≤≡-trans x y z p₁ p₂
<≡-trans : ∀ x y z → (x ≤ᴮ y) ≡ false → (y ≤ᴮ z) ≡ false → (x ≤ᴮ z) ≡ false
<≡-trans zero y z p₁ p₂ = ⊥-elim (subst (bool ⊥ ⊤) p₁ tt)
<≡-trans (suc x) zero z p₁ p₂ = ⊥-elim (subst (bool ⊥ ⊤) p₂ tt)
<≡-trans (suc x) (suc y) zero p₁ p₂ = p₂
<≡-trans (suc x) (suc y) (suc z) p₁ p₂ = <≡-trans x y z p₁ p₂
≤≡-sub : ∀ i j k → (j ≤ᴮ k) ≡ true → (j ∸ i ≤ᴮ k ∸ i) ≡ true
≤≡-sub zero j k p = p
≤≡-sub (suc i) zero k p = refl
≤≡-sub (suc i) (suc j) zero p = ⊥-elim (subst (bool ⊤ ⊥) p tt)
≤≡-sub (suc i) (suc j) (suc k) p = ≤≡-sub i j k p
≥≡-sub : ∀ i j k → (j ≤ᴮ k) ≡ false → (i ≤ᴮ k) ≡ true → (j ∸ i ≤ᴮ k ∸ i) ≡ false
≥≡-sub i zero k p _ = ⊥-elim (subst (bool ⊥ ⊤) p tt)
≥≡-sub zero (suc j) k p _ = p
≥≡-sub (suc i) (suc j) zero p p₂ = ⊥-elim (subst (bool ⊤ ⊥) p₂ tt)
≥≡-sub (suc i) (suc j) (suc k) p p₂ = ≥≡-sub i j k p p₂
<≡-sub : ∀ i j k → (i ≤ᴮ j) ≡ false → (j ≤ᴮ k) ≡ false → (i ∸ k ∸ 1 ≤ᴮ j ∸ k ∸ 1) ≡ false
<≡-sub zero j k p _ = ⊥-elim (subst (bool ⊥ ⊤) p tt)
<≡-sub (suc i) zero k p p₂ = ⊥-elim (subst (bool ⊥ ⊤) p₂ tt)
<≡-sub (suc i) (suc j) zero p p₂ = p
<≡-sub (suc i) (suc j) (suc k) p p₂ = <≡-sub i j k p p₂
>≡-sub : ∀ i j k → (i ≤ᴮ j) ≡ true → (j ≤ᴮ k) ≡ false → (i ≤ᴮ k) ≡ false → (i ∸ k ∸ 1 ≤ᴮ j ∸ k ∸ 1) ≡ true
>≡-sub i zero k p₁ p₂ p₃ = ⊥-elim (subst (bool ⊥ ⊤) p₂ tt)
>≡-sub zero (suc j) k p₁ p₂ p₃ = ⊥-elim (subst (bool ⊥ ⊤) p₃ tt)
>≡-sub (suc i) (suc j) zero p₁ p₂ p₃ = p₁
>≡-sub (suc i) (suc j) (suc k) p₁ p₂ p₃ = >≡-sub i j k p₁ p₂ p₃
zero-sub : ∀ n → zero ∸ n ≡ zero
zero-sub zero = refl
zero-sub (suc n) = refl
≤-sub-id : ∀ i j k → (i ≤ᴮ j) ≡ true → k ∸ i ∸ (j ∸ i) ≡ k ∸ j
≤-sub-id zero j k p = refl
≤-sub-id (suc i) zero k p = ⊥-elim (subst (bool ⊤ ⊥) p tt)
≤-sub-id (suc i) (suc j) zero p = zero-sub (j ∸ i)
≤-sub-id (suc i) (suc j) (suc k) p = ≤-sub-id i j k p
lemma₁ : ∀ i j k → (j ≤ᴮ k) ≡ false → i ∸ k ∸ 1 ∸ (j ∸ k ∸ 1) ∸ 1 ≡ i ∸ j ∸ 1
lemma₁ zero j k _ = cong (λ zk → zk ∸ 1 ∸ (j ∸ k ∸ 1) ∸ 1) (zero-sub k) ; cong (_∸ 1) (zero-sub (j ∸ k ∸ 1)) ; sym (cong (_∸ 1) (zero-sub j))
lemma₁ (suc i) zero k p₂ = ⊥-elim (subst (bool ⊥ ⊤) p₂ tt)
lemma₁ (suc i) (suc j) zero p₂ = refl
lemma₁ (suc i) (suc j) (suc k) p₂ = lemma₁ i j k p₂
lemma₂ : ∀ i j k → (i ≤ᴮ j) ≡ true → (j ≤ᴮ k) ≡ false → (i ≤ᴮ k) ≡ false → j ∸ i ≡ j ∸ k ∸ 1 ∸ (i ∸ k ∸ 1)
lemma₂ i zero k p₁ p₂ p₃ = ⊥-elim (subst (bool ⊥ ⊤) p₂ tt)
lemma₂ zero (suc j) k p₁ p₂ p₃ = ⊥-elim (subst (bool ⊥ ⊤) p₃ tt)
lemma₂ (suc i) (suc j) zero p₁ p₂ p₃ = refl
lemma₂ (suc i) (suc j) (suc k) p₁ p₂ p₃ = lemma₂ i j k p₁ p₂ p₃
{-# TERMINATING #-}
merge-assoc : Associative (merge {A = A})
merge-assoc [] ys zs = refl
merge-assoc (i ∹ x ∷ xs) [] zs = cong (flip merge zs) (merge-idʳ (i ∹ x ∷ xs))
merge-assoc (i ∹ x ∷ xs) (j ∹ y ∷ ys) [] = merge-idʳ (merge (i ∹ x ∷ xs) (j ∹ y ∷ ys)) ; sym (cong (merge (i ∹ x ∷ xs)) (merge-idʳ (j ∹ y ∷ ys)))
merge-assoc (i ∹ x ∷ xs) (j ∹ y ∷ ys) (k ∹ z ∷ zs) with merge-assoc xs (j ∸ i ∹ y ∷ ys) (k ∸ i ∹ z ∷ zs) | merge-assoc (i ∸ k ∸ 1 ∹ x ∷ xs) (j ∸ k ∸ 1 ∹ y ∷ ys) zs | (merge-assoc (i ∸ j ∸ 1 ∹ x ∷ xs) ys (k ∸ j ∹ z ∷ zs)) | i ≤ᴮ j | inspect (i ≤ᴮ_) j | j ≤ᴮ k | inspect (j ≤ᴮ_) k
merge-assoc (i ∹ x ∷ xs) (j ∹ y ∷ ys) (k ∹ z ∷ zs) | r | _ | _ | true | 〖 ij 〗 | true | 〖 jk 〗 = cong (merge⁺ i x (merge (merge xs (j ∸ i ∹ y ∷ ys))) k z zs) (≤≡-trans i j k ij jk) ;
cong (i ∹ x ∷_) (r ;
cong (merge xs) (cong (merge⁺ (j ∸ i) y (merge ys) (k ∸ i) z zs) (≤≡-sub i j k jk) ; cong (λ kij → j ∸ i ∹ y ∷ merge ys (kij ∹ z ∷ zs)) (≤-sub-id i j k ij))) ;
cong (merge⁺ i x (merge xs) j y (merge ys (k ∸ j ∹ z ∷ zs))) (sym ij)
merge-assoc (i ∹ x ∷ xs) (j ∹ y ∷ ys) (k ∹ z ∷ zs) | _ | r | _ | false | 〖 ij 〗 | false | 〖 jk 〗 = cong (merge⁺ j y (merge (mergeˡ (i ∸ j ∸ 1) x (merge xs) ys)) k z zs ) jk ;
cong (k ∹ z ∷_) (cong (λ s → mergeˡ (j ∸ k ∸ 1) y (merge (mergeˡ s x (merge xs) ys)) zs) (sym (lemma₁ i j k jk)) ;
cong (λ s → merge (merge⁺ (i ∸ k ∸ 1) x (merge xs) (j ∸ k ∸ 1) y ys s) zs) (sym (<≡-sub i j k ij jk)) ;
r) ;
cong (merge⁺ i x (merge xs) k z (mergeˡ (j ∸ k ∸ 1) y (merge ys) zs)) (sym (<≡-trans i j k ij jk))
merge-assoc (i ∹ x ∷ xs) (j ∹ y ∷ ys) (k ∹ z ∷ zs) | _ | _ | r | false | 〖 ij 〗 | true | 〖 jk 〗 = cong (merge⁺ j y (merge (mergeˡ (i ∸ j ∸ 1) x (merge xs) ys)) k z zs) jk ;
cong (j ∹ y ∷_) r ;
cong (merge⁺ i x (merge xs) j y (merge ys (k ∸ j ∹ z ∷ zs))) (sym ij)
merge-assoc (i ∹ x ∷ xs) (j ∹ y ∷ ys) (k ∹ z ∷ zs) | _ | _ | _ | true | ij | false | jk with i ≤ᴮ k | inspect (i ≤ᴮ_) k
merge-assoc (i ∹ x ∷ xs) (j ∹ y ∷ ys) (k ∹ z ∷ zs) | _ | r | _ | true | 〖 ij 〗 | false | 〖 jk 〗 | false | 〖 ik 〗 = cong (k ∹ z ∷_) ((cong (λ s → mergeˡ (i ∸ k ∸ 1) x (merge (merge xs (s ∹ y ∷ ys))) zs) (lemma₂ i j k ij jk ik) ;
cong (λ c → merge (merge⁺ (i ∸ k ∸ 1) x (merge xs) (j ∸ k ∸ 1) y ys c) zs) (sym (>≡-sub i j k ij jk ik ))) ;
r )
merge-assoc (i ∹ x ∷ xs) (j ∹ y ∷ ys) (k ∹ z ∷ zs) | r | _ | _ | true | 〖 ij 〗 | false | 〖 jk 〗 | true | 〖 ik 〗 = cong (i ∹ x ∷_) (r ;
cong (merge xs) (cong (merge⁺ (j ∸ i) y (merge ys) (k ∸ i) z zs) (≥≡-sub i j k jk ik) ;
cong (λ s → k ∸ i ∹ z ∷ mergeˡ s y (merge ys) zs) (cong (_∸ 1) (≤-sub-id i k j ik)) ))
open import Data.List
index : List ℕ → List A → List (Premuted A)
index _ [] = []
index [] (x ∷ xs) = (0 ∹ x ∷ []) ∷ index [] xs
index (i ∷ is) (x ∷ xs) = (i ∹ x ∷ []) ∷ index is xs
unindex : Premuted A → List A
unindex [] = []
unindex (_ ∹ x ∷ xs) = x ∷ unindex xs
open import TreeFold
shuffle : List ℕ → List A → List A
shuffle is = unindex ∘ treeFold merge [] ∘ index is
open import Data.List.Syntax
e : List ℕ
e = shuffle [ 0 , 1 , 0 ] [ 1 , 2 , 3 ]
| {
"alphanum_fraction": 0.4236206681,
"avg_line_length": 58.3430656934,
"ext": "agda",
"hexsha": "436170396f94e19be3baf0d60cec6ee4af88e65e",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-playground",
"max_forks_repo_path": "Data/List/Permute.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-playground",
"max_issues_repo_path": "Data/List/Permute.agda",
"max_line_length": 278,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-playground",
"max_stars_repo_path": "Data/List/Permute.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": 3622,
"size": 7993
} |
module Categories.Monoidal.Closed where
| {
"alphanum_fraction": 0.875,
"avg_line_length": 20,
"ext": "agda",
"hexsha": "91496f885dc86db61d213658f677606a52bdc2f6",
"lang": "Agda",
"max_forks_count": 23,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z",
"max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "p-pavel/categories",
"max_forks_repo_path": "Categories/Monoidal/Closed.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "p-pavel/categories",
"max_issues_repo_path": "Categories/Monoidal/Closed.agda",
"max_line_length": 39,
"max_stars_count": 98,
"max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "copumpkin/categories",
"max_stars_repo_path": "Categories/Monoidal/Closed.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z",
"num_tokens": 7,
"size": 40
} |
module Issue755 where
open import Common.Prelude renaming (Nat to ℕ)
open import Common.Equality
abstract
foo : ℕ → ℕ
foo x = zero
bar : foo zero ≡ foo (suc zero) → foo zero ≡ foo (suc zero)
bar refl = refl
-- 0 != 1 of type ℕ
-- when checking that the pattern refl has type
-- foo zero ≡ foo (suc zero)
| {
"alphanum_fraction": 0.6794871795,
"avg_line_length": 19.5,
"ext": "agda",
"hexsha": "d7e29f5663ba36c252516d7f19b7e0b793cb7d92",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/Issue755.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/Issue755.agda",
"max_line_length": 59,
"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/fail/Issue755.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": 97,
"size": 312
} |
{-# OPTIONS --without-K --rewriting #-}
open import lib.Basics
open import lib.NType2
open import lib.types.Empty
open import lib.types.Sigma
open import lib.types.Pi
open import lib.types.Group
open import lib.types.Nat
open import lib.types.List
open import lib.types.Word
open import lib.types.SetQuotient
open import lib.groups.Homomorphism
module lib.groups.FreeGroup {i} where
-- [qwr-sym] is not needed, but it seems more principled to
-- make [QuotWordRel] an equivalence relation.
data QuotWordRel {A : Type i} : Word A → Word A → Type i where
qwr-refl : ∀ {l₁ l₂} → l₁ == l₂ → QuotWordRel l₁ l₂
qwr-trans : ∀ {l₁ l₂ l₃} → QuotWordRel l₁ l₂ → QuotWordRel l₂ l₃ → QuotWordRel l₁ l₃
qwr-sym : ∀ {l₁ l₂} → QuotWordRel l₁ l₂ → QuotWordRel l₂ l₁
qwr-cons : ∀ x {l₁ l₂} → QuotWordRel l₁ l₂ → QuotWordRel (x :: l₁) (x :: l₂)
qwr-flip : ∀ x₁ l → QuotWordRel (x₁ :: flip x₁ :: l) l
-- The quotient
QuotWord : Type i → Type i
QuotWord A = SetQuot (QuotWordRel {A})
module _ {A : Type i} where
qw[_] : Word A → QuotWord A
qw[_] = q[_]
module QuotWordElim {k} {P : QuotWord A → Type k}
{{_ : {x : QuotWord A} → is-set (P x)}} (incl* : (a : Word A) → P qw[ a ])
(rel* : ∀ {a₁ a₂} (r : QuotWordRel a₁ a₂) → incl* a₁ == incl* a₂ [ P ↓ quot-rel r ])
= SetQuotElim incl* rel*
open QuotWordElim public renaming (f to QuotWord-elim) hiding (quot-rel-β)
module QuotWordRec {k} {B : Type k} {{_ : is-set B}} (incl* : Word A → B)
(rel* : ∀ {a₁ a₂} (r : QuotWordRel a₁ a₂) → incl* a₁ == incl* a₂)
= SetQuotRec incl* rel*
open QuotWordRec public renaming (f to QuotWord-rec)
module _ (A : Type i) where
private
abstract
QuotWordRel-cong-++-l :
∀ {l₁ l₁'} → QuotWordRel {A} l₁ l₁'
→ (l₂ : Word A)
→ QuotWordRel (l₁ ++ l₂) (l₁' ++ l₂)
QuotWordRel-cong-++-l (qwr-refl idp) l₂ = qwr-refl idp
QuotWordRel-cong-++-l (qwr-trans qwr₁ qwr₂) l₂ = qwr-trans (QuotWordRel-cong-++-l qwr₁ l₂) (QuotWordRel-cong-++-l qwr₂ l₂)
QuotWordRel-cong-++-l (qwr-sym qwr) l₂ = qwr-sym (QuotWordRel-cong-++-l qwr l₂)
QuotWordRel-cong-++-l (qwr-cons x qwr₁) l₂ = qwr-cons x (QuotWordRel-cong-++-l qwr₁ l₂)
QuotWordRel-cong-++-l (qwr-flip x₁ l₁) l₂ = qwr-flip x₁ (l₁ ++ l₂)
QuotWordRel-cong-++-r :
∀ (l₁ : Word A)
→ ∀ {l₂ l₂'} → QuotWordRel l₂ l₂'
→ QuotWordRel (l₁ ++ l₂) (l₁ ++ l₂')
QuotWordRel-cong-++-r nil qwr₂ = qwr₂
QuotWordRel-cong-++-r (x :: l₁) qwr₂ = qwr-cons x (QuotWordRel-cong-++-r l₁ qwr₂)
infixl 80 _⊞_
_⊞_ : QuotWord A → QuotWord A → QuotWord A
_⊞_ = QuotWord-rec
(λ l₁ → QuotWord-rec (λ l₂ → qw[ l₁ ++ l₂ ])
(λ r → quot-rel $ QuotWordRel-cong-++-r l₁ r))
(λ {l₁} {l₁'} r → λ= $ QuotWord-elim
(λ l₂ → quot-rel $ QuotWordRel-cong-++-l r l₂)
(λ _ → prop-has-all-paths-↓))
abstract
QuotWordRel-cong-flip : ∀ {l₁ l₂}
→ QuotWordRel {A} l₁ l₂ → QuotWordRel (Word-flip l₁) (Word-flip l₂)
QuotWordRel-cong-flip (qwr-refl idp) = qwr-refl idp
QuotWordRel-cong-flip (qwr-trans qwr₁ qwr₂) = qwr-trans (QuotWordRel-cong-flip qwr₁) (QuotWordRel-cong-flip qwr₂)
QuotWordRel-cong-flip (qwr-sym qwr) = qwr-sym (QuotWordRel-cong-flip qwr)
QuotWordRel-cong-flip (qwr-cons x qwr₁) = qwr-cons (flip x) (QuotWordRel-cong-flip qwr₁)
QuotWordRel-cong-flip (qwr-flip (inl x) l) = qwr-flip (inr x) (Word-flip l)
QuotWordRel-cong-flip (qwr-flip (inr x) l) = qwr-flip (inl x) (Word-flip l)
QuotWordRel-cong-reverse : ∀ {l₁ l₂}
→ QuotWordRel {A} l₁ l₂ → QuotWordRel (reverse l₁) (reverse l₂)
QuotWordRel-cong-reverse (qwr-refl x) = qwr-refl (ap reverse x)
QuotWordRel-cong-reverse (qwr-trans qwr qwr₁) = qwr-trans (QuotWordRel-cong-reverse qwr) (QuotWordRel-cong-reverse qwr₁)
QuotWordRel-cong-reverse (qwr-sym qwr) = qwr-sym (QuotWordRel-cong-reverse qwr)
QuotWordRel-cong-reverse (qwr-cons x qwr) = QuotWordRel-cong-++-l (QuotWordRel-cong-reverse qwr) (x :: nil)
QuotWordRel-cong-reverse (qwr-flip (inl x) l) =
qwr-trans (qwr-refl (++-assoc (reverse l) (inr x :: nil) (inl x :: nil))) $
qwr-trans (QuotWordRel-cong-++-r (reverse l) (qwr-flip (inr x) nil)) $
qwr-refl (++-unit-r (reverse l))
QuotWordRel-cong-reverse (qwr-flip (inr x) l) =
qwr-trans (qwr-refl (++-assoc (reverse l) (inl x :: nil) (inr x :: nil))) $
qwr-trans (QuotWordRel-cong-++-r (reverse l) (qwr-flip (inl x) nil)) $
qwr-refl (++-unit-r (reverse l))
⊟ : QuotWord A → QuotWord A
⊟ = QuotWord-rec (qw[_] ∘ reverse ∘ Word-flip)
(λ r → quot-rel $ QuotWordRel-cong-reverse $ QuotWordRel-cong-flip r)
⊞-unit : QuotWord A
⊞-unit = qw[ nil ]
abstract
⊞-unit-l : ∀ g → ⊞-unit ⊞ g == g
⊞-unit-l = QuotWord-elim
(λ _ → idp)
(λ _ → prop-has-all-paths-↓)
⊞-assoc : ∀ g₁ g₂ g₃ → (g₁ ⊞ g₂) ⊞ g₃ == g₁ ⊞ (g₂ ⊞ g₃)
⊞-assoc = QuotWord-elim
(λ l₁ → QuotWord-elim
(λ l₂ → QuotWord-elim
(λ l₃ → ap qw[_] $ ++-assoc l₁ l₂ l₃)
(λ _ → prop-has-all-paths-↓))
(λ _ → prop-has-all-paths-↓))
(λ _ → prop-has-all-paths-↓)
Word-inv-l : ∀ l → QuotWordRel {A} (reverse (Word-flip l) ++ l) nil
Word-inv-l nil = qwr-refl idp
Word-inv-l (inl x :: l) =
qwr-trans (qwr-refl (++-assoc (reverse (Word-flip l)) (inr x :: nil) (inl x :: l))) $
qwr-trans (QuotWordRel-cong-++-r (reverse (Word-flip l)) (qwr-flip (inr x) l)) $
Word-inv-l l
Word-inv-l (inr x :: l) =
qwr-trans (qwr-refl (++-assoc (reverse (Word-flip l)) (inl x :: nil) (inr x :: l))) $
qwr-trans (QuotWordRel-cong-++-r (reverse (Word-flip l)) (qwr-flip (inl x) l)) $
Word-inv-l l
⊟-inv-l : ∀ g → (⊟ g) ⊞ g == ⊞-unit
⊟-inv-l = QuotWord-elim
(λ l → quot-rel (Word-inv-l l))
(λ _ → prop-has-all-paths-↓)
QuotWord-group-structure : GroupStructure (QuotWord A)
QuotWord-group-structure = record
{ ident = ⊞-unit
; inv = ⊟
; comp = _⊞_
; unit-l = ⊞-unit-l
; assoc = ⊞-assoc
; inv-l = ⊟-inv-l
}
FreeGroup : Group i
FreeGroup = group _ QuotWord-group-structure
module FreeGroup = Group FreeGroup
-- freeness
module _ {A : Type i} {j} (G : Group j) where
private
module G = Group G
abstract
Word-extendᴳ-emap : ∀ f {l₁ l₂}
→ QuotWordRel {A} l₁ l₂
→ Word-extendᴳ G f l₁ == Word-extendᴳ G f l₂
Word-extendᴳ-emap f (qwr-refl idp) = idp
Word-extendᴳ-emap f (qwr-trans qwr qwr₁) = (Word-extendᴳ-emap f qwr) ∙ (Word-extendᴳ-emap f qwr₁)
Word-extendᴳ-emap f (qwr-sym qwr) = ! (Word-extendᴳ-emap f qwr)
Word-extendᴳ-emap f (qwr-cons x qwr) = ap (G.comp (PlusMinus-extendᴳ G f x)) (Word-extendᴳ-emap f qwr)
Word-extendᴳ-emap f (qwr-flip (inl x) l) =
! (G.assoc (f x) (G.inv (f x)) (Word-extendᴳ G f l))
∙ ap (λ g → G.comp g (Word-extendᴳ G f l)) (G.inv-r (f x)) ∙ G.unit-l _
Word-extendᴳ-emap f (qwr-flip (inr x) l) =
! (G.assoc (G.inv (f x)) (f x) (Word-extendᴳ G f l))
∙ ap (λ g → G.comp g (Word-extendᴳ G f l)) (G.inv-l (f x)) ∙ G.unit-l _
FreeGroup-extend : (A → G.El) → (FreeGroup A →ᴳ G)
FreeGroup-extend f' = record {M} where
module M where
f : QuotWord A → G.El
f = QuotWord-rec (Word-extendᴳ G f')
(λ r → Word-extendᴳ-emap f' r)
abstract
pres-comp : preserves-comp (FreeGroup.comp A) G.comp f
pres-comp =
QuotWord-elim
(λ l₁ → QuotWord-elim
(λ l₂ → Word-extendᴳ-++ G f' l₁ l₂)
(λ _ → prop-has-all-paths-↓))
(λ _ → prop-has-all-paths-↓)
private
module Lemma (hom : FreeGroup A →ᴳ G) where
open GroupHom hom
f* : A → G.El
f* a = f qw[ inl a :: nil ]
abstract
PlusMinus-extendᴳ-hom : ∀ x → PlusMinus-extendᴳ G f* x == f qw[ x :: nil ]
PlusMinus-extendᴳ-hom (inl x) = idp
PlusMinus-extendᴳ-hom (inr x) = ! $ pres-inv qw[ inl x :: nil ]
Word-extendᴳ-hom : ∀ l → Word-extendᴳ G f* l == f qw[ l ]
Word-extendᴳ-hom nil = ! pres-ident
Word-extendᴳ-hom (x :: l) = ap2 G.comp (PlusMinus-extendᴳ-hom x) (Word-extendᴳ-hom l) ∙ ! (pres-comp _ _)
open Lemma
FreeGroup-extend-is-equiv : is-equiv FreeGroup-extend
FreeGroup-extend-is-equiv = is-eq _ from to-from from-to where
to = FreeGroup-extend
from = f*
abstract
to-from : ∀ h → to (from h) == h
to-from h = group-hom= $ λ= $ QuotWord-elim
(λ l → Word-extendᴳ-hom h l)
(λ _ → prop-has-all-paths-↓)
from-to : ∀ f → from (to f) == f
from-to f = λ= λ a → G.unit-r (f a)
| {
"alphanum_fraction": 0.5774293236,
"avg_line_length": 40.0779816514,
"ext": "agda",
"hexsha": "8f1651e640f583849c9261a2e41db852582ffa77",
"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": "core/lib/groups/FreeGroup.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": "core/lib/groups/FreeGroup.agda",
"max_line_length": 128,
"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": "core/lib/groups/FreeGroup.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3482,
"size": 8737
} |
open import Data.Nat using (ℕ; _+_) renaming (_≤?_ to _≤?ₙ_)
open import Data.Bool using (Bool; not; _∧_)
open import Data.String using (String; _≟_)
open import Relation.Nullary using (yes; no)
open import Relation.Nullary.Decidable using (⌊_⌋)
open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym)
vname = String
val = ℕ
bool = Bool
state = vname → val
data aexp : Set where
N : ℕ → aexp
V : vname → aexp
Plus : aexp → aexp → aexp
_[_/_] : aexp → aexp → vname → aexp
N c [ a′ / X ] = N c
V Y [ a′ / X ] with Y ≟ X
... | yes _ = a′
... | no _ = V Y
Plus a b [ a′ / X ] = Plus (a [ a′ / X ]) (b [ a′ / X ])
_[_::=_] : state → vname → val → state
(s [ X ::= n ]) Y with Y ≟ X
... | yes _ = n
... | no _ = s Y
aval : aexp → state → val
aval (N c) s = c
aval (V v) s = s v
aval (Plus a b) s = aval a s + aval b s
substitution : ∀ a {X a′ s}
→ aval (a [ a′ / X ]) s ≡ aval a (s [ X ::= aval a′ s ])
substitution (N x) = refl
substitution (V Y) {X} with Y ≟ X
... | yes _ = refl
... | no _ = refl
substitution (Plus a b) {X}{a′}{s}
rewrite substitution a {X}{a′}{s}
| substitution b {X}{a′}{s} = refl
substitution-equiv : ∀{a a₁ a₂ X s}
→ aval a₁ s ≡ aval a₂ s
→ aval (a [ a₁ / X ]) s ≡ aval (a [ a₂ / X ]) s
substitution-equiv {a}{a₁}{a₂}{X}{s} hyp
rewrite substitution a {X}{a₁}{s}
| hyp
| sym (substitution a {X}{a₂}{s}) = refl
data bexp : Set where
Bc : Bool → bexp
Not : bexp → bexp
And : bexp → bexp → bexp
Less : aexp → aexp → bexp
_≤?_ : ℕ → ℕ → Bool
a ≤? b = ⌊ a ≤?ₙ b ⌋
bval : bexp → state → bool
bval (Bc x) s = x
bval (Not b) s = not (bval b s)
bval (And a b) s = bval a s ∧ bval b s
bval (Less a b) s = aval a s ≤? aval b s
data com : Set where
SKIP : com
_::=_ : String → aexp → com
_::_ : com → com → com
IF_THEN_ELSE_ : bexp → com → com → com
WHILE_DO_ : bexp → com → com
| {
"alphanum_fraction": 0.5412748171,
"avg_line_length": 25.8648648649,
"ext": "agda",
"hexsha": "d2c5d492781a0873f971918927a6f52bd8942a8e",
"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": "cb98e3b3b93362654b79152bfdf2c21eb4951fcc",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "iwilare/imp-semantics",
"max_forks_repo_path": "IMP.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "cb98e3b3b93362654b79152bfdf2c21eb4951fcc",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "iwilare/imp-semantics",
"max_issues_repo_path": "IMP.agda",
"max_line_length": 72,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "cb98e3b3b93362654b79152bfdf2c21eb4951fcc",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "iwilare/imp-semantics",
"max_stars_repo_path": "IMP.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-24T22:29:44.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-08T11:54:07.000Z",
"num_tokens": 776,
"size": 1914
} |
{-
There was a bug when partially instantiating a module containing
record projections.
-}
module Issue438 where
module M (A : Set) where
record R (a : A) : Set₁ where
field
S : Set
postulate
X : Set
x : X
r : M.R X x
module MX = M X
postulate
T : MX.R.S r → Set
y : M.R.S X r
t : T y
| {
"alphanum_fraction": 0.6006289308,
"avg_line_length": 13.25,
"ext": "agda",
"hexsha": "f29b503222d7e418ba6ce29d4353af04adb98a78",
"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/succeed/Issue438.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/succeed/Issue438.agda",
"max_line_length": 66,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/succeed/Issue438.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": 111,
"size": 318
} |
{-# OPTIONS --cubical --safe #-}
module Ctt where
open import Cubical.Core.Everything
open import Agda.Primitive.Cubical
using ( primComp )
-- Identity function.
id : ∀ {ℓ} {A : Set ℓ} (x : A) → A
id x = x
-- Funciton composition.
_∘_ : ∀ {ℓ} {A B C : Type ℓ} (g : B → C) (f : A → B) → A → C
g ∘ f = λ a → g (f a)
-- Equivalence is the path to `x` itself.
refl : ∀ {ℓ} {A : Type ℓ} {x : A} → Path A x x
refl {x = x} = λ i → x
-- A square in `A` is built out of 4 points and 4 lines.
square : ∀ {ℓ} {A : Type ℓ} {x0 x1 y0 y1 : A}
→ x0 ≡ x1 → y0 ≡ y1 → x0 ≡ y0 → x1 ≡ y1
→ Type ℓ
square p q r s = PathP (λ i → p i ≡ q i) r s
-- Symmetry.
sym : ∀ {ℓ} {A : Type ℓ} {x y : A} → x ≡ y → y ≡ x
sym p i = p (~ i)
-- sym p i = λ i → p (~ i)
-- Congruence.
cong : ∀ {ℓ} {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)
cong f p i = f (p i)
-- Symmetry inverse.
symInv : ∀ {ℓ} {A : Type ℓ} {x y : A} (p : x ≡ y) → sym (sym p) ≡ p
symInv p = refl
-- Congruence with identity function.
congId : ∀ {ℓ} {A : Type ℓ} {x y : A} (p : x ≡ y) → cong id p ≡ p
congId p = refl
-- Congruence with composition.
congComp : ∀ {ℓ} {A B C : Type ℓ}
(f : A → B) (g : B → C)
{x y : A} (p : x ≡ y)
→ cong (g ∘ f) p ≡ cong g (cong f p)
congComp f g p = refl
-- Function extensionality.
funExt : ∀ {ℓ} {A : Type ℓ} {B : A → Type ℓ} {f g : (x : A) → B x}
→ ((x : A) → f x ≡ g x) → f ≡ g
funExt p i x = p x i
-- `p` matches the 1st parameter,
-- `i` matches the dimension of the 1st parameter,
-- `x` matches `(x : A)`,
-- `funExt p i x = {!!}` the goal matches `B x`,
-- `(p x) i` is obvious.
-- Transitivity.
trans : ∀ {ℓ} {A : Type ℓ} {x y z : A}
→ x ≡ y → y ≡ z → x ≡ z
trans {y = y} p q i = primComp {!!} {!!} {!!}
-- Transport with composition.
transportComp : ∀ {ℓ} {A B C : Type ℓ}
→ A ≡ B → B ≡ C → A → C
transportComp p q a = {!!}
| {
"alphanum_fraction": 0.5002630195,
"avg_line_length": 26.4027777778,
"ext": "agda",
"hexsha": "d32a351fc6ad6c3185a872280eb9cd2ef852bbf5",
"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": "9576d5b76e6a868992dbe52930712ac67697bed2",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "anqurvanillapy/fpl",
"max_forks_repo_path": "agda/Ctt.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9576d5b76e6a868992dbe52930712ac67697bed2",
"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": "anqurvanillapy/fpl",
"max_issues_repo_path": "agda/Ctt.agda",
"max_line_length": 67,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9576d5b76e6a868992dbe52930712ac67697bed2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "anqurvanillapy/fpl",
"max_stars_repo_path": "agda/Ctt.agda",
"max_stars_repo_stars_event_max_datetime": "2019-08-24T22:47:47.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-24T22:47:47.000Z",
"num_tokens": 852,
"size": 1901
} |
module Monads.Identity where
open import Class.Functor
open import Class.Monad
open import Class.MonadTrans
open import Level
private
variable
a : Level
Id : Set a -> Set a
Id A = A
IdentityT : (Set a -> Set a) -> Set a -> Set a
IdentityT M A = M A
instance
Id-Monad : Monad (Id {a})
Id-Monad = record { _>>=_ = λ a f -> f a ; return = λ a -> a }
module _ (M : Set a -> Set a) {{_ : Monad M}} where
IdentityT-Monad : Monad (IdentityT M)
IdentityT-Monad = record { _>>=_ = _>>=_ ; return = return }
| {
"alphanum_fraction": 0.6274131274,
"avg_line_length": 20.72,
"ext": "agda",
"hexsha": "76bec021812e9f62dbc7782785a44ea31f68b70d",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z",
"max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "WhatisRT/meta-cedille",
"max_forks_repo_path": "stdlib-exts/Monads/Identity.agda",
"max_issues_count": 10,
"max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "WhatisRT/meta-cedille",
"max_issues_repo_path": "stdlib-exts/Monads/Identity.agda",
"max_line_length": 64,
"max_stars_count": 35,
"max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "WhatisRT/meta-cedille",
"max_stars_repo_path": "stdlib-exts/Monads/Identity.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z",
"num_tokens": 169,
"size": 518
} |
------------------------------------------------------------------------
-- Untyped hereditary substitution in Fω with interval kinds
------------------------------------------------------------------------
{-# OPTIONS --safe --exact-split --without-K #-}
module FOmegaInt.Syntax.SingleVariableSubstitution where
open import Data.Fin using (Fin; zero; suc; raise; lift)
open import Data.Fin.Substitution using (Sub; Subs; Lift; Application)
open import Data.Fin.Substitution.Lemmas using (AppLemmas)
renaming (module VarLemmas to V)
open import Data.Fin.Substitution.ExtraLemmas
using (TermLikeLemmas; LiftAppLemmas)
open import Data.Nat using (ℕ; zero; suc; _+_)
import Data.Vec as Vec
open import Data.Vec.Properties using (lookup-map)
open import Relation.Binary.Construct.Closure.ReflexiveTransitive using (ε; _◅_)
open import Relation.Binary.PropositionalEquality as P hiding ([_])
open import FOmegaInt.Syntax renaming (module Substitution to Sub)
----------------------------------------------------------------------
-- Untyped single-variable substitution.
open Syntax
open Sub using (weaken; weakenElim; weakenElim⋆; _Elim/Var_)
-- Suspended single-variable substitions.
--
-- Traditionally, a single-variable substitution [t/x] consists of two
-- data: the name x of the variable to be substituted and the
-- substitute t for the variable.
--
-- The following inductive definition is an alternative representation
-- of this data. Instead of specifying the variable name (i.e. the de
-- Bruijn index) to be substituted, we use two constructors: one for
-- substituting the zero-th variable (sub) and one for lifting the
-- substitution over an a new free variable (_↑). The advantage of
-- this representation is that it corresponds more closely to the
-- explicit substitution calculus and the inductive structure of both
-- de Bruijn indices and dependent contexts. Among other things, this
-- avoids green slime in the definition.
--
-- Since we are working with intrinsically well-scoped syntax, the
-- datatype is parametrized by the number of free variables in the
-- source and target context: a substitution |σ : SVSub m n|, when
-- applied to a term with at most m variables, yields a term with at
-- most n variables.
data SVSub : ℕ → ℕ → Set where
sub : ∀ {n} (a : Elim n) → SVSub (suc n) n
_↑ : ∀ {m n} (σ : SVSub m n) → SVSub (suc m) (suc n)
-- Repeated lifting.
_↑⋆_ : ∀ {m n} (σ : SVSub m n) k → SVSub (k + m) (k + n)
σ ↑⋆ zero = σ
σ ↑⋆ suc k = (σ ↑⋆ k) ↑
-- Turn a single-variable substitution into a multi-variable
-- substitution.
toSub : ∀ {m n} → SVSub m n → Sub Term m n
toSub (sub a) = Sub.sub ⌞ a ⌟
toSub (σ ↑) = (toSub σ) Sub.↑
-- The result of looking up a single-variable substitution.
data SVRes : ℕ → Set where
hit : ∀ {n} (a : Elim n) → SVRes n -- hit: looked up t at x in [t/x]
miss : ∀ {n} (y : Fin n) → SVRes n -- miss: looked up y ≠ x in [t/x]
toElim : ∀ {n} → SVRes n → Elim n
toElim (hit a) = a
toElim (miss y) = var∙ y
-- Renamings in single-variable substitutions and results.
infixl 8 _?/Var_
_?/Var_ : ∀ {m n} → SVRes m → Sub Fin m n → SVRes n
hit a ?/Var ρ = hit (a Elim/Var ρ)
miss y ?/Var ρ = miss (Vec.lookup ρ y)
-- Weakening of SV results.
weakenSVRes : ∀ {n} → SVRes n → SVRes (suc n)
weakenSVRes r = r ?/Var V.wk
-- Look up a variable in a single-variable substitution.
lookupSV : ∀ {m n} → SVSub m n → Fin m → SVRes n
lookupSV (sub a) zero = hit a
lookupSV (sub a) (suc x) = miss x
lookupSV (σ ↑) zero = miss zero
lookupSV (σ ↑) (suc x) = weakenSVRes (lookupSV σ x)
----------------------------------------------------------------------
-- Properties of single-variable substitution and results.
open P.≡-Reasoning
-- Lifting commutes with conversion of substitutions.
↑⋆-toSub : ∀ {m n} {σ : SVSub m n} k → toSub (σ ↑⋆ k) ≡ (toSub σ) Sub.↑⋆ k
↑⋆-toSub zero = refl
↑⋆-toSub (suc k) = cong Sub._↑ (↑⋆-toSub k)
-- Application of renamings commutes with conversion to terms.
toElim-/Var : ∀ {m n} r {ρ : Sub Fin m n} →
toElim (r ?/Var ρ) ≡ toElim r Elim/Var ρ
toElim-/Var (hit a) = refl
toElim-/Var (miss y) = refl
-- Lookup commutes with conversion of substitutions.
lookup-toSub : ∀ {m n} (σ : SVSub m n) (x : Fin m) →
Vec.lookup (toSub σ) x ≡ ⌞ toElim (lookupSV σ x) ⌟
lookup-toSub (sub a) zero = refl
lookup-toSub (sub a) (suc x) = Sub.lookup-id x
lookup-toSub (σ ↑) zero = refl
lookup-toSub (σ ↑) (suc x) = begin
Vec.lookup ((toSub σ) Sub.↑) (suc x) ≡⟨⟩
Vec.lookup (Vec.map weaken (toSub σ)) x ≡⟨ lookup-map x weaken (toSub σ) ⟩
weaken (Vec.lookup (toSub σ) x) ≡⟨ cong weaken (lookup-toSub σ x) ⟩
weaken ⌞ toElim σ[x] ⌟ ≡˘⟨ Sub.⌞⌟-/Var (toElim σ[x]) ⟩
⌞ weakenElim (toElim σ[x]) ⌟ ≡˘⟨ cong ⌞_⌟ (toElim-/Var σ[x]) ⟩
⌞ toElim (weakenSVRes σ[x]) ⌟ ≡⟨⟩
⌞ toElim (lookupSV (σ ↑) (suc x)) ⌟ ∎
where
open P.≡-Reasoning
σ[x] = lookupSV σ x
-- Lemmas about applications of renamings to SV results
open TermLikeLemmas Sub.termLikeLemmasElim using (varLiftAppLemmas)
open LiftAppLemmas varLiftAppLemmas using (id-vanishes; /-⊙; wk-commutes)
?/Var-id : ∀ {n} (r : SVRes n) → r ?/Var V.id ≡ r
?/Var-id (hit a) = cong hit (id-vanishes a)
?/Var-id (miss y) = cong miss (V.id-vanishes y)
?/Var-⊙ : ∀ {m n k} {ρ₁ : Sub Fin m n} {ρ₂ : Sub Fin n k} r →
r ?/Var ρ₁ V.⊙ ρ₂ ≡ r ?/Var ρ₁ ?/Var ρ₂
?/Var-⊙ (hit a) = cong hit (/-⊙ a)
?/Var-⊙ {ρ₁ = ρ₁} {ρ₂} (miss y) = cong miss (V./-⊙ {ρ₁ = ρ₁} {ρ₂} y)
resAppLemmas : AppLemmas SVRes Fin
resAppLemmas = record
{ application = record { _/_ = _?/Var_ }
; lemmas₄ = V.lemmas₄
; id-vanishes = ?/Var-id
; /-⊙ = ?/Var-⊙
}
module SVResAppLemmas = AppLemmas resAppLemmas
-- Lookup in a single-variable substitution commutes with renaming
lookup-sub-/Var-↑⋆ : ∀ {m n} a i x {ρ : Sub Fin m n} →
lookupSV (sub a ↑⋆ i) x ?/Var ρ V.↑⋆ i ≡
lookupSV (sub (a Elim/Var ρ) ↑⋆ i) (x V./ (ρ V.↑) V.↑⋆ i)
lookup-sub-/Var-↑⋆ a zero zero = refl
lookup-sub-/Var-↑⋆ a zero (suc x) {ρ} = begin
miss (Vec.lookup ρ x)
≡⟨⟩
lookupSV (sub (a Elim/Var ρ)) (suc (Vec.lookup ρ x))
≡˘⟨ cong (lookupSV (sub (a Elim/Var ρ))) (lookup-map x suc ρ) ⟩
lookupSV (sub (a Elim/Var ρ)) (Vec.lookup (Vec.map suc ρ) x)
≡⟨⟩
lookupSV (sub (a Elim/Var ρ)) (suc x V./ ρ V.↑)
∎
lookup-sub-/Var-↑⋆ a (suc i) zero = refl
lookup-sub-/Var-↑⋆ a (suc i) (suc x) {ρ} = begin
weakenSVRes (lookupSV (sub a ↑⋆ i) x) ?/Var (ρ V.↑⋆ i) V.↑
≡⟨⟩
lookupSV (sub a ↑⋆ i) x ?/Var V.wk ?/Var (ρ V.↑⋆ i) V.↑
≡˘⟨ SVResAppLemmas.wk-commutes (lookupSV (sub a ↑⋆ i) x) ⟩
lookupSV (sub a ↑⋆ i) x ?/Var (ρ V.↑⋆ i) ?/Var V.wk
≡⟨ cong (_?/Var V.wk) (lookup-sub-/Var-↑⋆ a i x) ⟩
lookupSV (sub (a Elim/Var ρ) ↑⋆ i) (x V./ ((ρ V.↑) V.↑⋆ i)) ?/Var V.wk
≡⟨⟩
lookupSV ((sub (a Elim/Var ρ) ↑⋆ i) ↑) (suc (x V./ (ρ V.↑) V.↑⋆ i))
≡˘⟨ cong (lookupSV ((sub (a Elim/Var ρ) ↑⋆ i) ↑))
(lookup-map x suc ((ρ V.↑) V.↑⋆ i)) ⟩
lookupSV ((sub (a Elim/Var ρ) ↑⋆ i) ↑)
(Vec.lookup (Vec.map suc ((ρ V.↑) V.↑⋆ i)) x)
≡⟨⟩
lookupSV ((sub (a Elim/Var ρ) ↑⋆ i) ↑) (suc x V./ ((ρ V.↑) V.↑⋆ i) V.↑)
∎
-- Lookup commutes with weakening
lookup-/Var-wk-↑⋆ : ∀ {m n} i x {σ : SVSub m n} →
lookupSV (σ ↑⋆ i) x ?/Var V.wk V.↑⋆ i ≡
lookupSV ((σ ↑) ↑⋆ i) (x V./ V.wk V.↑⋆ i)
lookup-/Var-wk-↑⋆ zero x {σ} = begin
lookupSV σ x ?/Var V.wk
≡⟨⟩
lookupSV (σ ↑) (suc x)
≡˘⟨ cong (lookupSV (σ ↑)) V./-wk ⟩
lookupSV (σ ↑) (x V./ V.wk)
∎
lookup-/Var-wk-↑⋆ (suc i) zero = refl
lookup-/Var-wk-↑⋆ (suc i) (suc x) {σ} = begin
lookupSV (σ ↑⋆ i) x ?/Var V.wk ?/Var (V.wk V.↑⋆ i) V.↑
≡˘⟨ SVResAppLemmas.wk-commutes (lookupSV (σ ↑⋆ i) x) ⟩
lookupSV (σ ↑⋆ i) x ?/Var V.wk V.↑⋆ i ?/Var V.wk
≡⟨ cong weakenSVRes (lookup-/Var-wk-↑⋆ i x) ⟩
lookupSV (((σ ↑) ↑⋆ i) ↑) (suc (Vec.lookup (V.wk V.↑⋆ i) x))
≡˘⟨ cong (lookupSV (((σ ↑) ↑⋆ i) ↑)) (lookup-map x suc (V.wk V.↑⋆ i)) ⟩
lookupSV (((σ ↑) ↑⋆ i) ↑) (Vec.lookup (Vec.map suc (V.wk V.↑⋆ i)) x)
≡⟨⟩
lookupSV (((σ ↑) ↑⋆ i) ↑) (suc x V./ V.wk V.↑⋆ suc i)
∎
----------------------------------------------------------------------
-- Predicates relating SV substitutions to variables.
data Hit : ∀ {m n} → SVSub m n → Fin m → Elim n → Set where
here : ∀ {n} {a : Elim n} → Hit (sub a) zero a
_↑ : ∀ {m n} {σ : SVSub m n} {x a} →
Hit σ x a → Hit (σ ↑) (suc x) (weakenElim a)
data Miss : ∀ {m n} → SVSub m n → Fin m → Fin n → Set where
over : ∀ {n} {a : Elim n} {y : Fin n} → Miss (sub a) (suc y) y
under : ∀ {m n} {σ : SVSub m n} → Miss (σ ↑) zero zero
_↑ : ∀ {m n} {σ : SVSub m n} {x y} →
Miss σ x y → Miss (σ ↑) (suc x) (suc y)
data Hit? {m n} (σ : SVSub m n) (x : Fin m) : Set where
hit : ∀ a → Hit σ x a → Hit? σ x
miss : ∀ y → Miss σ x y → Hit? σ x
toRes : ∀ {m n} {σ : SVSub m n} {x : Fin m} → Hit? σ x → SVRes n
toRes (hit a _) = hit a
toRes (miss y _) = miss y
-- A version of `lookupSV' that produces a more a more informative
-- result.
hit? : ∀ {m n} (σ : SVSub m n) (x : Fin m) → Hit? σ x
hit? (sub a) zero = hit a here
hit? (sub a) (suc x) = miss x over
hit? (σ ↑) zero = miss zero under
hit? (σ ↑) (suc x) with hit? σ x
... | hit a hitP = hit (weakenElim a) (hitP ↑)
... | miss y missP = miss (suc y) (missP ↑)
-- The two versions of lookup agree.
lookup-Hit : ∀ {m n} {σ : SVSub m n} {x : Fin m} {a : Elim n} →
Hit σ x a → lookupSV σ x ≡ hit a
lookup-Hit here = refl
lookup-Hit (hitP ↑) = cong weakenSVRes (lookup-Hit hitP)
lookup-Miss : ∀ {m n} {σ : SVSub m n} {x : Fin m} {y : Fin n} →
Miss σ x y → lookupSV σ x ≡ miss y
lookup-Miss over = refl
lookup-Miss under = refl
lookup-Miss {σ = σ ↑} {suc x} {suc y} (missP ↑) = begin
weakenSVRes (lookupSV σ x) ≡⟨ cong weakenSVRes (lookup-Miss missP) ⟩
miss (y V./ V.wk) ≡⟨ cong miss V./-wk ⟩
miss (suc y) ∎
hit?-lookup : ∀ {m n} (σ : SVSub m n) (x : Fin m) →
lookupSV σ x ≡ toRes (hit? σ x)
hit?-lookup σ x with hit? σ x
... | (hit a hitP) = lookup-Hit hitP
... | (miss y missP) = lookup-Miss missP
-- The Hit predicate is functional.
Hit-functional₁ : ∀ {m n} {σ : SVSub m n} {x y : Fin m} {a b : Elim n} →
Hit σ x a → Hit σ y b → x ≡ y
Hit-functional₁ here here = refl
Hit-functional₁ (hitP₁ ↑) (hitP₂ ↑) = cong suc (Hit-functional₁ hitP₁ hitP₂)
Hit-functional₂ : ∀ {m n} {σ : SVSub m n} {x y : Fin m} {a b : Elim n} →
Hit σ x a → Hit σ y b → a ≡ b
Hit-functional₂ here here = refl
Hit-functional₂ (hitP₁ ↑) (hitP₂ ↑) =
cong weakenElim (Hit-functional₂ hitP₁ hitP₂)
-- For a fixed σ, the Miss predicate is injective.
Miss-injective : ∀ {m n} {σ : SVSub m n} {x y : Fin m} {z : Fin n} →
Miss σ x z → Miss σ y z → x ≡ y
Miss-injective over over = refl
Miss-injective under under = refl
Miss-injective (hitP₁ ↑) (hitP₂ ↑) = cong suc (Miss-injective hitP₁ hitP₂)
-- Lifting preserves the predicates
Hit-↑⋆ : ∀ {m n} {σ : SVSub m n} {x : Fin m} {a : Elim n} i →
Hit σ x a → Hit (σ ↑⋆ i) (raise i x) (weakenElim⋆ i a)
Hit-↑⋆ zero hyp = hyp
Hit-↑⋆ (suc i) hyp = (Hit-↑⋆ i hyp) ↑
Miss-↑⋆ : ∀ {m n} {σ : SVSub m n} {x : Fin m} {y : Fin n} i →
Miss σ x y → Miss (σ ↑⋆ i) (raise i x) (raise i y)
Miss-↑⋆ zero hyp = hyp
Miss-↑⋆ (suc i) hyp = (Miss-↑⋆ i hyp) ↑
Hit-↑-↑⋆ : ∀ {m n} {σ : SVSub m n} i {x a} → Hit (σ ↑⋆ i) x a →
Hit ((σ ↑) ↑⋆ i) (lift i suc x) (a Elim/Var V.wk V.↑⋆ i)
Hit-↑-↑⋆ zero hyp = hyp ↑
Hit-↑-↑⋆ (suc i) (_↑ {a = a} hyp ) =
subst (Hit _ _) (wk-commutes a) (Hit-↑-↑⋆ i hyp ↑)
Miss-↑-↑⋆ : ∀ {m n} {σ : SVSub m n} i {x y} → Miss (σ ↑⋆ i) x y →
Miss ((σ ↑) ↑⋆ i) (lift i suc x) (lift i suc y)
Miss-↑-↑⋆ zero hyp = hyp ↑
Miss-↑-↑⋆ (suc i) under = under
Miss-↑-↑⋆ (suc i) (hyp ↑) = (Miss-↑-↑⋆ i hyp) ↑
-- Yet another way to characterize hits/misses of single-variable
-- substitutions.
Hit-sub-↑⋆ : ∀ {n} {a : Elim n} i →
Hit (sub a ↑⋆ i) (raise i zero) (weakenElim⋆ i a)
Hit-sub-↑⋆ i = Hit-↑⋆ i here
Hit-sub-↑⋆₁ : ∀ {n} {a : Elim n} i {x b} →
Hit (sub a ↑⋆ i) x b → x ≡ raise i zero
Hit-sub-↑⋆₁ i hyp = Hit-functional₁ hyp (Hit-sub-↑⋆ i)
Hit-sub-↑⋆₂ : ∀ {n} {a : Elim n} i {x b} →
Hit (sub a ↑⋆ i) x b → b ≡ weakenElim⋆ i a
Hit-sub-↑⋆₂ i hyp = Hit-functional₂ hyp (Hit-sub-↑⋆ i)
Miss-sub-↑⋆ : ∀ {n} {a : Elim n} i x → Miss (sub a ↑⋆ i) (lift i suc x) x
Miss-sub-↑⋆ zero x = over
Miss-sub-↑⋆ (suc i) zero = under
Miss-sub-↑⋆ (suc i) (suc x) = Miss-sub-↑⋆ i x ↑
Miss-sub-↑⋆′ : ∀ {n} {a : Elim n} i {x} y →
Miss (sub a ↑⋆ i) x y → x ≡ lift i suc y
Miss-sub-↑⋆′ i y hyp = Miss-injective hyp (Miss-sub-↑⋆ i y)
-- Looking up a sufficiently weakened variable will always miss.
lookup-sub-wk-↑⋆ : ∀ {n} i x {a : Elim n} →
lookupSV (sub a ↑⋆ i) (x V./ V.wk V.↑⋆ i) ≡ miss x
lookup-sub-wk-↑⋆ i x {a} = begin
lookupSV (sub a ↑⋆ i) (x V./ V.wk V.↑⋆ i)
≡⟨ cong (lookupSV (sub a ↑⋆ i)) (V.lookup-wk-↑⋆ i x) ⟩
lookupSV (sub a ↑⋆ i) (lift i suc x)
≡⟨ lookup-Miss (Miss-sub-↑⋆ i x) ⟩
miss x
∎
-- A predicate for comparing variable names to naturals.
--
-- Instances of |Eq? n x| are proofs that a natural number |n| is or
-- is not "equal" to a variable name |x|. Given two natural numbers
-- m, n and a "name" x in the interval { 0, ..., (n + 1 + m) }, "yes"
-- instances of the |Eq? n x| prove that "n = x", while "no" instances
-- prove that x is any one of the other names in the interval.
--
-- The predicate is useful for deciding whether a lookup of |x| in
-- some single-variable substitutions will lead to a hit or miss,
-- independently of the actual substitution.
--
-- NOTE. This predicate is only used in the proof of one lemma, namely
-- FOmegaInt.Kinding.Simple.EtaExpansion.Nf∈-[]-η-var. Maybe the
-- proof of the lemma could be rewritten so as to avoid the
-- introduction of this extra predicate, but this might reduce
-- clarity.
data Eq? {m : ℕ} (n : ℕ) (x : Fin (n + suc m)) : Set where
yes : raise n zero ≡ x → Eq? n x
no : ∀ y → lift n suc y ≡ x → Eq? n x
-- Eq? is stable w.r.t. increments.
suc-Eq? : ∀ {m n} {x : Fin (n + suc m)} → Eq? n x → Eq? (suc n) (suc x)
suc-Eq? (yes refl) = yes refl
suc-Eq? (no y refl) = no (suc y) refl
-- A decision procedure for Eq?.
compare : ∀ {m} n (x : Fin (n + suc m)) → Eq? n x
compare zero zero = yes refl
compare zero (suc x) = no x refl
compare (suc n) zero = no zero refl
compare (suc n) (suc x) = suc-Eq? (compare n x)
-- Turn Eq? instances into Hit? instances for a given substitution.
toHit? : ∀ {m n} {a : Elim m} {x} → Eq? n x → Hit? (sub a ↑⋆ n) x
toHit? {_} {n} (yes refl) = hit _ (Hit-sub-↑⋆ n)
toHit? {_} {n} (no y refl) = miss y (Miss-sub-↑⋆ n y)
| {
"alphanum_fraction": 0.5529053203,
"avg_line_length": 37.8270676692,
"ext": "agda",
"hexsha": "7f617833e90e271d27fc2055f88de96e4aa5bdcd",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-05-14T10:25:05.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-05-13T22:29:48.000Z",
"max_forks_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Blaisorblade/f-omega-int-agda",
"max_forks_repo_path": "src/FOmegaInt/Syntax/SingleVariableSubstitution.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_issues_repo_issues_event_max_datetime": "2021-05-14T08:54:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-05-14T08:09:40.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Blaisorblade/f-omega-int-agda",
"max_issues_repo_path": "src/FOmegaInt/Syntax/SingleVariableSubstitution.agda",
"max_line_length": 80,
"max_stars_count": 12,
"max_stars_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Blaisorblade/f-omega-int-agda",
"max_stars_repo_path": "src/FOmegaInt/Syntax/SingleVariableSubstitution.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-27T05:53:06.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-06-13T16:05:35.000Z",
"num_tokens": 5947,
"size": 15093
} |
open import Data.Nat as ℕ using (ℕ; suc; zero)
open import Data.Pos as ℕ⁺ using (ℕ⁺; suc; _+_)
open import Data.List as L using (List; []; _∷_; _++_)
open import Data.List.Any as LA using (Any; here; there)
open import Data.Product using (_,_)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Relation.Binary.PropositionalEquality as P using (_≡_)
open import Data.Environment
open import nodcap.Base
module nodcap.Typing where
-- Typing Rules.
infix 1 ⊢_
data ⊢_ : Environment → Set where
ax : {A : Type} →
--------------
⊢ A ∷ A ^ ∷ []
cut : {Γ Δ : Environment} {A : Type} →
⊢ A ∷ Γ → ⊢ A ^ ∷ Δ →
---------------------
⊢ Γ ++ Δ
send : {Γ Δ : Environment} {A B : Type} →
⊢ A ∷ Γ → ⊢ B ∷ Δ →
-------------------
⊢ A ⊗ B ∷ Γ ++ Δ
recv : {Γ : Environment} {A B : Type} →
⊢ A ∷ B ∷ Γ →
-------------
⊢ A ⅋ B ∷ Γ
sel₁ : {Γ : Environment} {A B : Type} →
⊢ A ∷ Γ →
-----------
⊢ A ⊕ B ∷ Γ
sel₂ : {Γ : Environment} {A B : Type} →
⊢ B ∷ Γ →
-----------
⊢ A ⊕ B ∷ Γ
case : {Γ : Environment} {A B : Type} →
⊢ A ∷ Γ → ⊢ B ∷ Γ →
-------------------
⊢ A & B ∷ Γ
halt :
--------
⊢ 𝟏 ∷ []
wait : {Γ : Environment} →
⊢ Γ →
-------
⊢ ⊥ ∷ Γ
loop : {Γ : Environment} →
-------
⊢ ⊤ ∷ Γ
mk?₁ : {Γ : Environment} {A : Type} →
⊢ A ∷ Γ →
--------------
⊢ ?[ 1 ] A ∷ Γ
mk!₁ : {Γ : Environment} {A : Type} →
⊢ A ∷ Γ →
--------------
⊢ ![ 1 ] A ∷ Γ
cont : {Γ : Environment} {A : Type} {m n : ℕ⁺} →
⊢ ?[ m ] A ∷ ?[ n ] A ∷ Γ →
------------------------------
⊢ ?[ m + n ] A ∷ Γ
pool : {Γ Δ : Environment} {A : Type} {m n : ℕ⁺} →
⊢ ![ m ] A ∷ Γ → ⊢ ![ n ] A ∷ Δ →
-------------------------------------
⊢ ![ m + n ] A ∷ Γ ++ Δ
exch : {Γ Δ : Environment} →
Γ ∼[ bag ] Δ → ⊢ Γ →
--------------------
⊢ Δ
cutIn : {Γ Δ : Environment} {A : Type} (i : A ∈ Γ) (j : A ^ ∈ Δ) →
⊢ Γ → ⊢ Δ →
----------------
⊢ Γ - i ++ Δ - j
cutIn {Γ} {Δ} {A} i j P Q with ∈→++ i | ∈→++ j
... | (Γ₁ , Γ₂ , P.refl , p) | (Δ₁ , Δ₂ , P.refl , q) rewrite p | q
= cut (exch (fwd [] Γ₁) P) (exch (fwd [] Δ₁) Q)
-- -}
-- -}
-- -}
-- -}
-- -}
| {
"alphanum_fraction": 0.3518204911,
"avg_line_length": 19.2032520325,
"ext": "agda",
"hexsha": "16afd41dce11bf1b5d1f1cdfba95839841bba73c",
"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/nodcap/Typing.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/nodcap/Typing.agda",
"max_line_length": 67,
"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/nodcap/Typing.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": 900,
"size": 2362
} |
{-# OPTIONS --cubical --safe #-}
module Cardinality.Finite.ManifestBishop.Inductive where
open import Data.List public
open import Data.List.Membership public
open import Prelude
ℬ : Type a → Type a
ℬ A = Σ[ xs ⦂ List A ] Π[ x ⦂ A ] x ∈! xs
| {
"alphanum_fraction": 0.7008196721,
"avg_line_length": 22.1818181818,
"ext": "agda",
"hexsha": "6e573603d1baef6de7f2f2af1cee1d3ac9ddedb4",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/combinatorics-paper",
"max_forks_repo_path": "agda/Cardinality/Finite/ManifestBishop/Inductive.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/combinatorics-paper",
"max_issues_repo_path": "agda/Cardinality/Finite/ManifestBishop/Inductive.agda",
"max_line_length": 56,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/combinatorics-paper",
"max_stars_repo_path": "agda/Cardinality/Finite/ManifestBishop/Inductive.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z",
"num_tokens": 75,
"size": 244
} |
-- Families with compatible monoid and coal
module SOAS.Coalgebraic.Monoid {T : Set} where
open import SOAS.Common
open import SOAS.Context {T}
open import SOAS.Variable
open import SOAS.Families.Core {T}
import SOAS.Families.Delta {T} as δ; open δ.Sorted
open import SOAS.Abstract.Hom {T}
import SOAS.Abstract.Box {T} as □ ; open □.Sorted
open import SOAS.Abstract.Monoid {T}
import SOAS.Abstract.Coalgebra {T} as →□ ; open →□.Sorted
open import SOAS.Coalgebraic.Map
open import SOAS.Coalgebraic.Strength
open import SOAS.Coalgebraic.Lift
private
variable
Γ Δ : Ctx
α β : T
-- Coalgebraic monoid: family with compatible coalgebra and monoid structure
record CoalgMon (𝒳 : Familyₛ) : Set where
field
ᴮ : Coalgₚ 𝒳
ᵐ : Mon 𝒳
open Coalgₚ ᴮ public renaming (η to ηᴮ)
open Mon ᵐ public hiding (ᵇ ; ᴮ ; r ; r∘η ; μᶜ) renaming (η to ηᵐ)
field
η-compat : {v : ℐ α Γ} → ηᴮ v ≡ ηᵐ v
μ-compat : {ρ : Γ ↝ Δ}{t : 𝒳 α Γ} → r t ρ ≡ μ t (ηᵐ ∘ ρ)
open Coalgₚ ᴮ using (r∘η) public
-- Multiplication of coalgebraic monoids is a pointed coalgebraic map
μᶜ : Coalgebraic ᴮ ᴮ ᴮ μ
μᶜ = record
{ r∘f = λ{ {σ = σ}{ϱ}{t} → begin
r (μ t σ) ϱ ≡⟨ μ-compat ⟩
μ (μ t σ) (ηᵐ ∘ ϱ) ≡⟨ assoc ⟩
μ t (λ v → μ (σ v) (ηᵐ ∘ ϱ)) ≡˘⟨ cong (μ t) (dext (λ _ → μ-compat)) ⟩
μ t (λ v → r (σ v) ϱ) ∎ }
; f∘r = λ{ {ρ = ρ}{ς}{t} → begin
μ (r t ρ) ς ≡⟨ cong (λ - → μ - ς) μ-compat ⟩
μ (μ t (ηᵐ ∘ ρ)) ς ≡⟨ assoc ⟩
μ t (λ v → μ (ηᵐ (ρ v)) ς) ≡⟨ cong (μ t) (dext (λ _ → lunit)) ⟩
μ t (ς ∘ ρ) ∎ }
; f∘η = trans (μ≈₂ η-compat) runit
} where open ≡-Reasoning
str-eq : (𝒴 : Familyₛ){F : Functor 𝔽amiliesₛ 𝔽amiliesₛ}(F:Str : Strength F)
(open Functor F)(open Strength F:Str)
(h : F₀ 〖 𝒳 , 𝒴 〗 α Γ)(σ : Γ ~[ 𝒳 ]↝ Δ)
→ str ᴮ 𝒴 h σ ≡ str (Mon.ᴮ ᵐ) 𝒴 h σ
str-eq 𝒴 {F} F:Str h σ = begin
str ᴮ 𝒴 h σ
≡⟨ str-nat₁ {f = id} (record { ᵇ⇒ = record { ⟨r⟩ = sym μ-compat }
; ⟨η⟩ = sym η-compat }) h σ ⟩
str (Mon.ᴮ ᵐ) 𝒴 (F₁ id h) σ
≡⟨ congr identity (λ - → str (Mon.ᴮ ᵐ) 𝒴 - σ) ⟩
str (Mon.ᴮ ᵐ) 𝒴 h σ
∎
where
open Functor F
open Strength F:Str
open ≡-Reasoning
lift-eq : {Ξ : Ctx}(t : 𝒳 β (Ξ ∔ Γ))(σ : Γ ~[ 𝒳 ]↝ Δ) →
μ t (lift ᴮ Ξ σ) ≡ μ t (lift (Mon.ᴮ ᵐ) Ξ σ)
lift-eq {Ξ = Ξ} t σ = str-eq 𝒳 (δ:Strength Ξ) (μ t) σ
| {
"alphanum_fraction": 0.5147579693,
"avg_line_length": 33.88,
"ext": "agda",
"hexsha": "22ff8b65e7ab6ded3292749b3da385eec416a077",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z",
"max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JoeyEremondi/agda-soas",
"max_forks_repo_path": "SOAS/Coalgebraic/Monoid.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JoeyEremondi/agda-soas",
"max_issues_repo_path": "SOAS/Coalgebraic/Monoid.agda",
"max_line_length": 83,
"max_stars_count": 39,
"max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JoeyEremondi/agda-soas",
"max_stars_repo_path": "SOAS/Coalgebraic/Monoid.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z",
"num_tokens": 1141,
"size": 2541
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.Bouquet
open import homotopy.SphereEndomorphism
open import groups.SphereEndomorphism
open import groups.CoefficientExtensionality
open import cw.CW
open import cw.WedgeOfCells
module cw.DegreeByProjection {i} where
module DegreeAboveOne {n : ℕ} (skel : Skeleton {i} (S (S n)))
(dec : has-cells-with-dec-eq skel)
-- the cells at the upper and lower dimensions
(upper : cells-last skel)
(lower : cells-last (cw-init skel))
where
private
lower-skel = cw-init skel
lower-cells = cells-nth lteS skel
lower-dec = cells-nth-has-dec-eq lteS skel dec
degree-map : Sphere (S n) → Sphere (S n)
degree-map = bwproj lower-dec lower
∘ <– (Bouquet-equiv-Xₙ/Xₙ₋₁ lower-skel)
∘ cfcod
∘ attaching-last skel upper
degree : ℤ
degree = Trunc-⊙SphereS-endo-degree n (Trunc-⊙SphereS-endo-in n [ degree-map ])
module DegreeAtOne (skel : Skeleton {i} 1)
(dec : has-cells-with-dec-eq skel)
-- the cells at the upper and lower dimensions
(line : cells-last skel)
(point : cells-last (cw-init skel)) where
private
points-dec-eq = cells-nth-has-dec-eq (inr ltS) skel dec
endpoint = attaching-last skel
-- When [true] matches, [true] will be sent to [false],
-- which is bad.
degree-true : ℤ
degree-true with points-dec-eq point (endpoint line true)
degree-true | inl _ = -1
degree-true | inr _ = 0
-- When [false] matches, [false] will be sent to [false],
-- which is good.
degree-false : ℤ
degree-false with points-dec-eq point (endpoint line false)
degree-false | inl _ = 1
degree-false | inr _ = 0
degree : ℤ
degree = degree-true ℤ+ degree-false
degree-last : ∀ {n} (skel : Skeleton {i} (S n))
→ has-cells-with-dec-eq skel
→ cells-last skel → cells-last (cw-init skel) → ℤ
degree-last {n = O} = DegreeAtOne.degree
degree-last {n = S _} = DegreeAboveOne.degree
degree-nth : ∀ {m n} (Sm≤n : S m ≤ n) (skel : Skeleton {i} n)
→ has-cells-with-dec-eq skel
→ cells-nth Sm≤n skel → cells-last (cw-init (cw-take Sm≤n skel)) → ℤ
degree-nth Sm≤n skel dec = degree-last (cw-take Sm≤n skel) (take-has-cells-with-dec-eq Sm≤n skel dec)
has-degrees-with-finite-support : ∀ {n} (skel : Skeleton {i} n)
→ has-cells-with-dec-eq skel → Type i
has-degrees-with-finite-support {n = O} _ _ = Lift ⊤
has-degrees-with-finite-support {n = S n} skel dec =
has-degrees-with-finite-support (cw-init skel) (init-has-cells-with-dec-eq skel dec) ×
∀ upper → has-finite-support (cells-nth-has-dec-eq (inr ltS) skel dec) (degree-last skel dec upper)
init-has-degrees-with-finite-support : ∀ {n} (skel : Skeleton {i} (S n)) dec
→ has-degrees-with-finite-support skel dec
→ has-degrees-with-finite-support (cw-init skel) (init-has-cells-with-dec-eq skel dec)
init-has-degrees-with-finite-support skel dec fin-sup = fst fin-sup
take-has-degrees-with-finite-support : ∀ {m n} (m≤n : m ≤ n) (skel : Skeleton {i} n) dec
→ has-degrees-with-finite-support skel dec
→ has-degrees-with-finite-support (cw-take m≤n skel) (take-has-cells-with-dec-eq m≤n skel dec)
take-has-degrees-with-finite-support (inl idp) skel dec fin-sup = fin-sup
take-has-degrees-with-finite-support (inr ltS) skel dec fin-sup =
init-has-degrees-with-finite-support skel dec fin-sup
take-has-degrees-with-finite-support (inr (ltSR lt)) skel dec fin-sup =
take-has-degrees-with-finite-support (inr lt) (cw-init skel)
(init-has-cells-with-dec-eq skel dec)
(init-has-degrees-with-finite-support skel dec fin-sup)
degree-last-has-finite-support : ∀ {n} (skel : Skeleton {i} (S n)) dec
→ has-degrees-with-finite-support skel dec
→ ∀ upper → has-finite-support
(cells-last-has-dec-eq (cw-init skel) (init-has-cells-with-dec-eq skel dec))
(degree-last skel dec upper)
degree-last-has-finite-support skel dec fin-sup = snd fin-sup
degree-nth-has-finite-support : ∀ {m n} (Sm≤n : S m ≤ n) (skel : Skeleton {i} n) dec
→ has-degrees-with-finite-support skel dec
→ ∀ upper → has-finite-support
(cells-last-has-dec-eq
(cw-init (cw-take Sm≤n skel))
(init-has-cells-with-dec-eq (cw-take Sm≤n skel) (take-has-cells-with-dec-eq Sm≤n skel dec)))
(degree-nth Sm≤n skel dec upper)
degree-nth-has-finite-support Sm≤n skel dec fin-sup =
degree-last-has-finite-support (cw-take Sm≤n skel)
(take-has-cells-with-dec-eq Sm≤n skel dec)
(take-has-degrees-with-finite-support Sm≤n skel dec fin-sup)
-- the following are named [boundary'] because it is not extended to the free groups
boundary'-last : ∀ {n} (skel : Skeleton {i} (S n)) dec
→ has-degrees-with-finite-support skel dec
→ cells-last skel → FreeAbGroup.El (cells-last (cw-init skel))
boundary'-last skel dec fin-sup upper = fst ((snd fin-sup) upper)
boundary-last : ∀ {n} (skel : Skeleton {i} (S n)) dec
→ has-degrees-with-finite-support skel dec
→ FreeAbGroup.grp (cells-last skel) →ᴳ FreeAbGroup.grp (cells-last (cw-init skel))
boundary-last skel dec fin-sup =
FreeAbGroup-extend (FreeAbGroup (cells-last (cw-init skel))) (boundary'-last skel dec fin-sup)
boundary'-nth : ∀ {m n} (Sm≤n : S m ≤ n) (skel : Skeleton {i} n) dec
→ has-degrees-with-finite-support skel dec
→ cells-nth Sm≤n skel → FreeAbGroup.El (cells-last (cw-init (cw-take Sm≤n skel)))
boundary'-nth Sm≤n skel dec fin-sup =
boundary'-last (cw-take Sm≤n skel)
(take-has-cells-with-dec-eq Sm≤n skel dec)
(take-has-degrees-with-finite-support Sm≤n skel dec fin-sup)
boundary-nth : ∀ {m n} (Sm≤n : S m ≤ n) (skel : Skeleton {i} n) dec
→ has-degrees-with-finite-support skel dec
→ FreeAbGroup.grp (cells-nth Sm≤n skel)
→ᴳ FreeAbGroup.grp (cells-last (cw-init (cw-take Sm≤n skel)))
boundary-nth Sm≤n skel dec fin-sup =
FreeAbGroup-extend
(FreeAbGroup (cells-last (cw-init (cw-take Sm≤n skel))))
(boundary'-nth Sm≤n skel dec fin-sup)
| {
"alphanum_fraction": 0.6553024094,
"avg_line_length": 42.6643356643,
"ext": "agda",
"hexsha": "3fe4b4160617a829882086902167c3fa13377ff9",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "theorems/cw/DegreeByProjection.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "theorems/cw/DegreeByProjection.agda",
"max_line_length": 103,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "theorems/cw/DegreeByProjection.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2052,
"size": 6101
} |
module tests.Forcing where
open import Prelude.IO
open import Prelude.Unit
open import Prelude.Vec
open import Prelude.Nat
len : {A : Set}{n : Nat} -> Vec A n -> Nat
len {A} .{Z} [] = Z
len {A} .{S n} (_::_ {n} x xs) = S n
len2 : {A : Set}{n : Nat} -> Vec A n -> Nat
len2 [] = 0
len2 (_::_ {n} x xs) = S (len2 {n = n} xs)
len3 : {A : Set}{n : Nat} -> Vec A n -> Nat
len3 {n = Z} [] = Z
len3 {n = S n} (_::_ .{n} x xs) = S n
len4 : {A : Set}{n : Nat} -> Vec A n -> Nat
len4 [] = Z
len4 (_::_ {Z} x xs) = S Z
len4 (_::_ {S n} x xs) = S (S n)
main : IO Unit
main =
printNat (len l1) ,,
printNat (len l2) ,,
printNat (len l3) ,,
printNat (len2 l1) ,,
printNat (len2 l2) ,,
printNat (len2 l3) ,,
printNat (len3 l1) ,,
printNat (len3 l2) ,,
printNat (len3 l3) ,,
printNat (len4 l1) ,,
printNat (len4 l2) ,,
printNat (len4 l3) ,,
return unit
where l1 = "a" :: "b" :: "c" :: []
l2 = 1 :: 2 :: 3 :: 4 :: 5 :: []
l3 : Vec Nat Z
l3 = []
| {
"alphanum_fraction": 0.4622553588,
"avg_line_length": 20.2452830189,
"ext": "agda",
"hexsha": "5c043b4e66fe6a8fca78061562e5f7e10c7b4249",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "larrytheliquid/agda",
"max_forks_repo_path": "test/epic/tests/Forcing.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/agda",
"max_issues_repo_path": "test/epic/tests/Forcing.agda",
"max_line_length": 46,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "test/epic/tests/Forcing.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 436,
"size": 1073
} |
{-# COMPILE GHC myNat = 0 #-}
| {
"alphanum_fraction": 0.5333333333,
"avg_line_length": 15,
"ext": "agda",
"hexsha": "888a864fc79cd9700e2fa40e264204ab8c28a6d2",
"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/Issue4026.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/Issue4026.agda",
"max_line_length": 29,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue4026.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 10,
"size": 30
} |
-- Free category over a directed graph/quiver
{-# OPTIONS --safe #-}
module Cubical.Categories.Constructions.Free where
open import Cubical.Categories.Category.Base
open import Cubical.Data.Graph.Base
open import Cubical.Data.Graph.Path
open import Cubical.Foundations.Prelude hiding (Path)
module _ {ℓv ℓe : Level} where
module _ (G : Graph ℓv ℓe)
(isSetNode : isSet (Node G))
(isSetEdge : ∀ v w → isSet (Edge G v w)) where
open Category
FreeCategory : Category ℓv (ℓ-max ℓv ℓe)
FreeCategory .ob = Node G
FreeCategory .Hom[_,_] = Path G
FreeCategory .id = pnil
FreeCategory ._⋆_ = ccat G
FreeCategory .⋆IdL = pnil++ G
FreeCategory .⋆IdR P = refl
FreeCategory .⋆Assoc = ++assoc G
FreeCategory .isSetHom = isSetPath G isSetNode isSetEdge _ _
| {
"alphanum_fraction": 0.6856435644,
"avg_line_length": 29.9259259259,
"ext": "agda",
"hexsha": "5bab3d91402430195e63c79d0a6b019c33fd9643",
"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/Categories/Constructions/Free.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/Categories/Constructions/Free.agda",
"max_line_length": 64,
"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/Categories/Constructions/Free.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": 248,
"size": 808
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- An All predicate for the partiality monad
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe --guardedness #-}
module Category.Monad.Partiality.All where
open import Category.Monad
open import Category.Monad.Partiality as Partiality using (_⊥; ⇒≈)
open import Codata.Musical.Notation
open import Function
open import Level
open import Relation.Binary using (_Respects_; IsEquivalence)
open import Relation.Binary.PropositionalEquality as P using (_≡_)
open Partiality._⊥
open Partiality.Equality using (Rel)
open Partiality.Equality.Rel
private
open module E {a} {A : Set a} = Partiality.Equality (_≡_ {A = A})
using (_≅_; _≳_)
open module M {f} = RawMonad (Partiality.monad {f = f})
using (_>>=_)
------------------------------------------------------------------------
-- All, along with some lemmas
-- All P x means that if x terminates with the value v, then P v
-- holds.
data All {a p} {A : Set a} (P : A → Set p) : A ⊥ → Set (a ⊔ p) where
now : ∀ {v} (p : P v) → All P (now v)
later : ∀ {x} (p : ∞ (All P (♭ x))) → All P (later x)
-- Bind preserves All in the following way:
_>>=-cong_ : ∀ {ℓ p q} {A B : Set ℓ} {P : A → Set p} {Q : B → Set q}
{x : A ⊥} {f : A → B ⊥} →
All P x → (∀ {x} → P x → All Q (f x)) →
All Q (x >>= f)
now p >>=-cong f = f p
later p >>=-cong f = later (♯ (♭ p >>=-cong f))
-- All respects all the relations, given that the predicate respects
-- the underlying relation.
respects :
∀ {k a p ℓ} {A : Set a} {P : A → Set p} {_∼_ : A → A → Set ℓ} →
P Respects _∼_ → All P Respects Rel _∼_ k
respects resp (now x∼y) (now p) = now (resp x∼y p)
respects resp (later x∼y) (later p) = later (♯ respects resp (♭ x∼y) (♭ p))
respects resp (laterˡ x∼y) (later p) = respects resp x∼y (♭ p)
respects resp (laterʳ x≈y) p = later (♯ respects resp x≈y p)
respects-flip :
∀ {k a p ℓ} {A : Set a} {P : A → Set p} {_∼_ : A → A → Set ℓ} →
P Respects flip _∼_ → All P Respects flip (Rel _∼_ k)
respects-flip resp (now x∼y) (now p) = now (resp x∼y p)
respects-flip resp (later x∼y) (later p) = later (♯ respects-flip resp (♭ x∼y) (♭ p))
respects-flip resp (laterˡ x∼y) p = later (♯ respects-flip resp x∼y p)
respects-flip resp (laterʳ x≈y) (later p) = respects-flip resp x≈y (♭ p)
-- "Equational" reasoning.
module Reasoning {a p ℓ}
{A : Set a} {P : A → Set p}
{_∼_ : A → A → Set ℓ}
(resp : P Respects flip _∼_) where
infix 3 finally
infixr 2 _≡⟨_⟩_ _∼⟨_⟩_
_≡⟨_⟩_ : ∀ x {y} → x ≡ y → All P y → All P x
_ ≡⟨ P.refl ⟩ p = p
_∼⟨_⟩_ : ∀ {k} x {y} → Rel _∼_ k x y → All P y → All P x
_ ∼⟨ x∼y ⟩ p = respects-flip resp (⇒≈ x∼y) p
-- A cosmetic combinator.
finally : (x : A ⊥) → All P x → All P x
finally _ p = p
syntax finally x p = x ⟨ p ⟩
-- "Equational" reasoning with _∼_ instantiated to propositional
-- equality.
module Reasoning-≡ {a p} {A : Set a} {P : A → Set p}
= Reasoning {P = P} {_∼_ = _≡_} (P.subst P ∘ P.sym)
------------------------------------------------------------------------
-- An alternative, but equivalent, formulation of All
module Alternative {a p : Level} where
infix 3 _⟨_⟩P
infixr 2 _≅⟨_⟩P_ _≳⟨_⟩P_
-- All "programs".
data AllP {A : Set a} (P : A → Set p) : A ⊥ → Set (suc (a ⊔ p)) where
now : ∀ {x} (p : P x) → AllP P (now x)
later : ∀ {x} (p : ∞ (AllP P (♭ x))) → AllP P (later x)
_>>=-congP_ : ∀ {B : Set a} {Q : B → Set p} {x f}
(p-x : AllP Q x) (p-f : ∀ {v} → Q v → AllP P (f v)) →
AllP P (x >>= f)
_≅⟨_⟩P_ : ∀ x {y} (x≅y : x ≅ y) (p : AllP P y) → AllP P x
_≳⟨_⟩P_ : ∀ x {y} (x≳y : x ≳ y) (p : AllP P y) → AllP P x
_⟨_⟩P : ∀ x (p : AllP P x) → AllP P x
private
-- WHNFs.
data AllW {A} (P : A → Set p) : A ⊥ → Set (suc (a ⊔ p)) where
now : ∀ {x} (p : P x) → AllW P (now x)
later : ∀ {x} (p : AllP P (♭ x)) → AllW P (later x)
-- A function which turns WHNFs into programs.
program : ∀ {A} {P : A → Set p} {x} → AllW P x → AllP P x
program (now p) = now p
program (later p) = later (♯ p)
-- Functions which turn programs into WHNFs.
trans-≅ : ∀ {A} {P : A → Set p} {x y : A ⊥} →
x ≅ y → AllW P y → AllW P x
trans-≅ (now P.refl) (now p) = now p
trans-≅ (later x≅y) (later p) = later (_ ≅⟨ ♭ x≅y ⟩P p)
trans-≳ : ∀ {A} {P : A → Set p} {x y : A ⊥} →
x ≳ y → AllW P y → AllW P x
trans-≳ (now P.refl) (now p) = now p
trans-≳ (later x≳y) (later p) = later (_ ≳⟨ ♭ x≳y ⟩P p)
trans-≳ (laterˡ x≳y) p = later (_ ≳⟨ x≳y ⟩P program p)
mutual
_>>=-congW_ : ∀ {A B} {P : A → Set p} {Q : B → Set p} {x f} →
AllW P x → (∀ {v} → P v → AllP Q (f v)) →
AllW Q (x >>= f)
now p >>=-congW p-f = whnf (p-f p)
later p >>=-congW p-f = later (p >>=-congP p-f)
whnf : ∀ {A} {P : A → Set p} {x} → AllP P x → AllW P x
whnf (now p) = now p
whnf (later p) = later (♭ p)
whnf (p-x >>=-congP p-f) = whnf p-x >>=-congW p-f
whnf (_ ≅⟨ x≅y ⟩P p) = trans-≅ x≅y (whnf p)
whnf (_ ≳⟨ x≳y ⟩P p) = trans-≳ x≳y (whnf p)
whnf (_ ⟨ p ⟩P) = whnf p
-- AllP P is sound and complete with respect to All P.
sound : ∀ {A} {P : A → Set p} {x} → AllP P x → All P x
sound = λ p → soundW (whnf p)
where
soundW : ∀ {A} {P : A → Set p} {x} → AllW P x → All P x
soundW (now p) = now p
soundW (later p) = later (♯ sound p)
complete : ∀ {A} {P : A → Set p} {x} → All P x → AllP P x
complete (now p) = now p
complete (later p) = later (♯ complete (♭ p))
| {
"alphanum_fraction": 0.4779757902,
"avg_line_length": 34.9882352941,
"ext": "agda",
"hexsha": "8fa559bf60aeb9b3704a8b5c61e39d10294d0889",
"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/Category/Monad/Partiality/All.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/Category/Monad/Partiality/All.agda",
"max_line_length": 86,
"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/Category/Monad/Partiality/All.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2346,
"size": 5948
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.FiniteMultiset where
open import Cubical.HITs.FiniteMultiset.Base public
open import Cubical.HITs.FiniteMultiset.Properties public
| {
"alphanum_fraction": 0.7990196078,
"avg_line_length": 29.1428571429,
"ext": "agda",
"hexsha": "d63529f90228bc3ebe0d3a37e506e1e721a77b46",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/HITs/FiniteMultiset.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/HITs/FiniteMultiset.agda",
"max_line_length": 57,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/HITs/FiniteMultiset.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 54,
"size": 204
} |
open import Data.Nat using ( zero ; suc ) renaming ( ℕ to ♭ℕ ; _+_ to add )
open import Function using () renaming ( _∘′_ to _∘_ )
open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl ; sym ; trans ; cong ; cong₂ )
open import AssocFree.Util using ( ≡-relevant )
module AssocFree.DNat where
open Relation.Binary.PropositionalEquality.≡-Reasoning using ( begin_ ; _≡⟨_⟩_ ; _∎ )
infixr 5 _,_
infixr 5 _+_
_+♭_ = add
add-unit : ∀ n → (add n 0) ≡ n
add-unit zero = refl
add-unit (suc n) = cong suc (add-unit n)
add-assoc : ∀ m n → (add (add m n) ≡ ((add m) ∘ (add n)))
add-assoc zero n = refl
add-assoc (suc m) n = cong (_∘_ suc) (add-assoc m n)
-- "Difference nats" are isomorphic to ℕ but have _+_ associative up
-- to beta-reduction, not just up to _≡_.
record ℕ : Set where
constructor _,_
field
fun : ♭ℕ → ♭ℕ
.fun✓ : fun ≡ add (fun 0)
open ℕ public
-- Convert ℕ to ♭ℕ and back
♯ : ♭ℕ → ℕ
♯ n = (add n , cong add (sym (add-unit n)))
♭ : ℕ → ♭ℕ
♭ (f , f✓) = f 0
-- Constants
♯0 = ♯ 0
♯1 = ♯ 1
-- Addition
_+_ : ℕ → ℕ → ℕ
(f , f✓) + (g , g✓) = ((f ∘ g) , f∘g✓) where
.f∘g✓ : (f ∘ g) ≡ add (f (g 0))
f∘g✓ = begin
f ∘ g
≡⟨ cong₂ _∘_ f✓ g✓ ⟩
add (f 0) ∘ add (g 0)
≡⟨ sym (add-assoc (f 0) (g 0)) ⟩
add (add (f 0) (g 0))
≡⟨ cong (λ X → add (X (g 0))) (sym f✓) ⟩
add (f (g 0))
∎
--Isomorphism which respects +
inject : ∀ m n → (fun m ≡ fun n) → (m ≡ n)
inject (f , f✓) (.f , g✓) refl = refl
iso : ∀ n → ♯ (♭ n) ≡ n
iso n = inject (♯ (♭ n)) n (sym (≡-relevant (fun✓ n)))
iso⁻¹ : ∀ n → ♭ (♯ n) ≡ n
iso⁻¹ = add-unit
iso-resp-+ : ∀ m n → ♭ (m + n) ≡ (♭ m +♭ ♭ n)
iso-resp-+ (f , f✓) (g , g✓) = cong (λ X → X (g 0)) (≡-relevant f✓)
-- Addition forms a monoid on the nose
+-assoc : ∀ l m n → (((l + m) + n) ≡ (l + (m + n)))
+-assoc l m n = refl
+-unit₁ : ∀ n → ((♯0 + n) ≡ n)
+-unit₁ n = refl
+-unit₂ : ∀ n → ((n + ♯0) ≡ n)
+-unit₂ n = refl
| {
"alphanum_fraction": 0.5147439214,
"avg_line_length": 22.2183908046,
"ext": "agda",
"hexsha": "b2a78796370def4318d18002b22f278ee9f8b95f",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:38:44.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-03-03T04:39:31.000Z",
"max_forks_repo_head_hexsha": "08337fdb8375137a52cc9b3ade766305191b2394",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/agda-assoc-free",
"max_forks_repo_path": "src/AssocFree/DNat.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "08337fdb8375137a52cc9b3ade766305191b2394",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/agda-assoc-free",
"max_issues_repo_path": "src/AssocFree/DNat.agda",
"max_line_length": 99,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "08337fdb8375137a52cc9b3ade766305191b2394",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/agda-assoc-free",
"max_stars_repo_path": "src/AssocFree/DNat.agda",
"max_stars_repo_stars_event_max_datetime": "2020-08-27T20:56:20.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-11-22T11:48:31.000Z",
"num_tokens": 878,
"size": 1933
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
-- a zero object is both terminal and initial.
module Categories.Object.Zero {o ℓ e} (C : Category o ℓ e) where
open import Level
open import Categories.Object.Terminal C
open import Categories.Object.Initial C
open import Categories.Morphism C
open import Categories.Morphism.Reasoning C
open Category C
open HomReasoning
record IsZero (Z : Obj) : Set (o ⊔ ℓ ⊔ e) where
field
isInitial : IsInitial Z
isTerminal : IsTerminal Z
open IsInitial isInitial public
renaming
( ! to ¡
; !-unique to ¡-unique
; !-unique₂ to ¡-unique₂
)
open IsTerminal isTerminal public
zero⇒ : ∀ {A B : Obj} → A ⇒ B
zero⇒ = ¡ ∘ !
zero-∘ˡ : ∀ {X Y Z} → (f : Y ⇒ Z) → f ∘ zero⇒ {X} ≈ zero⇒
zero-∘ˡ f = pullˡ (⟺ (¡-unique (f ∘ ¡)))
zero-∘ʳ : ∀ {X Y Z} → (f : X ⇒ Y) → zero⇒ {Y} {Z} ∘ f ≈ zero⇒
zero-∘ʳ f = pullʳ (⟺ (!-unique (! ∘ f)))
record Zero : Set (o ⊔ ℓ ⊔ e) where
field
𝟘 : Obj
isZero : IsZero 𝟘
open IsZero isZero public
terminal : Terminal
terminal = record { ⊤-is-terminal = isTerminal }
initial : Initial
initial = record { ⊥-is-initial = isInitial }
open Zero
¡-Mono : ∀ {A} {z : Zero} → Mono (¡ z {A})
¡-Mono {z = z} = from-⊤-is-Mono {t = terminal z} (¡ z)
!-Epi : ∀ {A} {z : Zero} → Epi (! z {A})
!-Epi {z = z} = to-⊥-is-Epi {i = initial z} (! z)
| {
"alphanum_fraction": 0.5917630058,
"avg_line_length": 22.6885245902,
"ext": "agda",
"hexsha": "5574f1d39cba797d5a74406e94aeb10ef25ecbe5",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Object/Zero.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Object/Zero.agda",
"max_line_length": 64,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Object/Zero.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z",
"num_tokens": 524,
"size": 1384
} |
module Issue279-2 where
data ⊥ : Set where
data ⊤ : Set where
tt : ⊤
module M (A : Set) where
data P : ⊤ → Set where
tt : A → P tt
module X = M ⊥ using (tt)
open X
good : ⊥ → M.P ⊥ tt
good = tt
bad : M.P ⊤ tt
bad = tt tt
| {
"alphanum_fraction": 0.5466101695,
"avg_line_length": 11.2380952381,
"ext": "agda",
"hexsha": "6061b54f3e4f6d2a9640cae353a595f38fc8a0a1",
"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/Issue279-2.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/Issue279-2.agda",
"max_line_length": 25,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Issue279-2.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 95,
"size": 236
} |
abstract
data D : Set where
d : D
data P : D → Set where
p : P d
d′ : D
d′ = d
d₂ : D
d₂ = d
private
abstract
p′ : P d
p′ = p
A : P d′
A = p′
-- A : Set₁ -- P d′
-- A = Set -- p′
-- where
-- abstract
-- p′ : P d
-- p′ = p
| {
"alphanum_fraction": 0.3832116788,
"avg_line_length": 8.5625,
"ext": "agda",
"hexsha": "dacbff17c68f4bf4536e3b947ad7458aa765d8a8",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "cagix/agda",
"max_forks_repo_path": "test/Fail/Issue3744.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "cagix/agda",
"max_issues_repo_path": "test/Fail/Issue3744.agda",
"max_line_length": 24,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "cagix/agda",
"max_stars_repo_path": "test/Fail/Issue3744.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": 124,
"size": 274
} |
{-# OPTIONS --rewriting #-}
open import Library
-- Focusing proofs
-- parametrized by positive and negative atoms
-- module Formulas (PosAt NegAt : Set) where
-- module Formulas (Atoms : Set) where
postulate Atoms : Set
-- Polarity + (positive formulas) are those whose introduction requires
data Pol : Set where
+ - : Pol
-- -- Opposite polarities
-- data Op : (p q : Pol) → Set where
-- +- : Op + -
-- -+ : Op - +
-- Atoms : Pol → Set
-- Atoms + = PosAt
-- Atoms - = NegAt
data Form : Pol → Set where
-- Atom : ∀{p} → Atoms p → Form p
True : ∀{p} → Form p
_∧_ : ∀{p} (A B : Form p) → Form p -- +: tensor (strict tuple), -: record types (lazy tuple)
-- only positive
Atom : (P : Atoms) → Form +
False : Form +
_∨_ : (A B : Form +) → Form +
-- only negative
_⇒_ : (A : Form +) (B : Form -) → Form -
-- embedding (switching)
Comp : (A : Form +) → Form - -- The F of CBPV.
Thunk : (A : Form -) → Form + -- The U of CBPV.
-- Sw : ∀{p q} (op : Op p q) (A : Form p) → Form q
infixl 8 _∧_
infixl 7 _∨_
infixr 6 _⇒_
-- Generic hypotheses, taken from a set S.
module _ (S : Set) where
data Cxt' : Set where
ε : Cxt'
_∙_ : (Γ : Cxt') (A : S) → Cxt'
data Hyp' (A : S) : (Γ : Cxt') → Set where
top : ∀{Γ} → Hyp' A (Γ ∙ A)
pop : ∀{B Γ} (x : Hyp' A Γ) → Hyp' A (Γ ∙ B)
infixl 4 _∙_
-- Contexts only contain negative formulas.
-- This is because we eagerly split positive ones.
-- In CBPV, hypotheses are positive (values).
Cxt = Cxt' (Form -)
Hyp = Hyp' (Form -)
-- Positive atoms in hypotheses via switching.
Atom- = λ P → Comp (Atom P)
HypAtom = λ P → Hyp (Atom- P)
-- Non-invertible left rules:
module _ (Nf : (A : Form +) (Γ : Cxt) → Set) where
data Ne' (C : Form -) (Γ : Cxt) : Set where
hyp : ∀ (x : Hyp C Γ) → Ne' C Γ
impE : ∀{A} (t : Ne' (A ⇒ C) Γ) (u : Nf A Γ) → Ne' C Γ
andE₁ : ∀{D} (t : Ne' (C ∧ D) Γ) → Ne' C Γ
andE₂ : ∀{D} (t : Ne' (D ∧ C) Γ) → Ne' C Γ
-- Invertible left rules:
-- Break up a positive formula and add the bits as hypotheses
-- "case tree" / "cover"
-- Produces a cover of Γ.A by splitting A
mutual
AddHyp = λ A J Γ → AddHyp' Γ J A
data AddHyp' (Γ : Cxt) (J : Cxt → Set) : (A : Form +) → Set where
addAtom : ∀{P} (t : J (Γ ∙ Atom- P)) → AddHyp (Atom P) J Γ
addNeg : ∀{A} (t : J (Γ ∙ A)) → AddHyp (Thunk A) J Γ
trueE : (t : J Γ) → AddHyp True J Γ
andE : ∀{A B} (t : AddHyp A (AddHyp B J) Γ) → AddHyp (A ∧ B) J Γ
falseE : AddHyp False J Γ
orE : ∀{A B} (t : AddHyp A J Γ) (u : AddHyp B J Γ) → AddHyp (A ∨ B) J Γ
module UNUSED where
addHyp : ∀ (A : Form +) {Γ} {J : Cxt → Set} (j : ∀{Δ} → J Δ) → AddHyp A J Γ
addHyp (Atom P) j = addAtom j
addHyp (Thunk A) j = addNeg j
addHyp True j = trueE j
addHyp False _ = falseE
addHyp (A ∧ B) j = andE (addHyp A (addHyp B j))
addHyp (A ∨ B) j = orE (addHyp A j) (addHyp B j)
module _ (Ne : (A : Form +) (Γ : Cxt) → Set) where
data Cover' (i : Size) (J : Cxt → Set) (Γ : Cxt) : Set where
returnC : (t : J Γ) → Cover' i J Γ
matchC : ∀{j : Size< i} {A} (t : Ne A Γ) (c : AddHyp A (Cover' j J) Γ) → Cover' i J Γ
-- Left focusing (break a negative hypothesis A down into something positive)
-- "spine"
mutual
-- Neutrals, containing values (RFoc) as arguments to functions.
Ne : (i : Size) (C : Form -) (Γ : Cxt) → Set
Ne i = Ne' (RFoc i)
-- Cover monad, containing neutrals of type (Comp A) as scrutinees.
Cover : (i j : Size) (J : Cxt → Set) (Γ : Cxt) → Set
Cover i j = Cover' (λ A → Ne j (Comp A)) i
-- Non-invertible right rules:
-- Right focusing (proof of a positive goal by decisions)
-- "normal" / values.
data RFoc : (i : Size) (A : Form +) (Γ : Cxt) → Set where
-- Right focusing stops at a negative formulas
thunk : ∀{i Γ A} (t : RInv i A Γ) → RFoc (↑ i) (Thunk A) Γ
-- Success:
hyp : ∀{i Γ P} (x : HypAtom P Γ) → RFoc (↑ i) (Atom P) Γ
trueI : ∀{i Γ} → RFoc (↑ i) True Γ
-- Choices:
andI : ∀{i Γ A B} (t : RFoc i A Γ) (u : RFoc i B Γ) → RFoc (↑ i) (A ∧ B) Γ
orI₁ : ∀{i Γ B A} (t : RFoc i A Γ) → RFoc (↑ i) (A ∨ B) Γ
orI₂ : ∀{i Γ A B} (u : RFoc i B Γ) → RFoc (↑ i) (A ∨ B) Γ
-- Invertible right rules:
-- Right inversion: break a goal into subgoals
-- "eta" / definitions by copattern matching.
data RInv : (i : Size) (A : Form -) (Γ : Cxt) → Set where
-- Right inversion ends at a positive formula
ret : ∀{i Γ A} (t : Cover ∞ i (RFoc i A) Γ) → RInv (↑ i) (Comp A) Γ
-- Goal splitting
trueI : ∀{i Γ} → RInv (↑ i) True Γ
andI : ∀{i Γ A B} (t : RInv i A Γ) (u : RInv i B Γ) → RInv (↑ i) (A ∧ B) Γ
impI : ∀{i Γ A B} (t : AddHyp A (RInv i B) Γ) → RInv (↑ i) (A ⇒ B) Γ
-- Pointwise mapping
_→̇_ : (P Q : Cxt → Set) → Set
P →̇ Q = ∀{Γ} → P Γ → Q Γ
mapAddHyp : ∀{P Q} (f : P →̇ Q) → ∀{A} → AddHyp A P →̇ AddHyp A Q
mapAddHyp f (addAtom t) = addAtom (f t)
mapAddHyp f (addNeg t) = addNeg (f t)
mapAddHyp f (trueE t) = trueE (f t)
mapAddHyp f falseE = falseE
mapAddHyp f (andE t) = andE (mapAddHyp (mapAddHyp f) t) -- By induction on types!
mapAddHyp f (orE t u) = orE (mapAddHyp f t) (mapAddHyp f u)
mapCover : ∀{P Q} (f : P →̇ Q) {i j} → Cover i j P →̇ Cover i j Q
mapCover f (returnC t) = returnC (f t)
mapCover f (matchC t c) = matchC t (mapAddHyp (mapCover f) c) -- Cover should be sized!
-- Cover monad
joinCover : ∀{i j P} → Cover i j (Cover ∞ j P) →̇ Cover ∞ j P
joinCover (returnC t) = t
joinCover (matchC t c) = matchC t (mapAddHyp joinCover c)
-- Context extension (thinning)
infix 3 _≤_
data _≤_ : (Γ Δ : Cxt) → Set where
id≤ : ∀{Γ} → Γ ≤ Γ
weak : ∀{A Γ Δ} (τ : Γ ≤ Δ) → Γ ∙ A ≤ Δ
lift : ∀{A Γ Δ} (τ : Γ ≤ Δ) → Γ ∙ A ≤ Δ ∙ A
postulate lift-id≤ : ∀{Γ A} → lift id≤ ≡ id≤ {Γ ∙ A}
{-# REWRITE lift-id≤ #-}
-- Category of thinnings
_•_ : ∀{Γ Δ Φ} (τ : Γ ≤ Δ) (σ : Δ ≤ Φ) → Γ ≤ Φ
id≤ • σ = σ
weak τ • σ = weak (τ • σ)
lift τ • id≤ = lift τ
lift τ • weak σ = weak (τ • σ)
lift τ • lift σ = lift (τ • σ)
•-id : ∀{Γ Δ} (τ : Γ ≤ Δ) → τ • id≤ ≡ τ
•-id id≤ = refl
•-id (weak τ) = cong weak (•-id τ)
•-id (lift τ) = refl
{-# REWRITE •-id #-}
-- Monotonicity
Mon : (P : Cxt → Set) → Set
Mon P = ∀{Γ Δ} (τ : Γ ≤ Δ) → P Δ → P Γ
-- Monotonicity of hypotheses
monH : ∀{A} → Mon (Hyp A)
monH id≤ x = x
monH (weak τ) x = pop (monH τ x)
monH (lift τ) top = top
monH (lift τ) (pop x) = pop (monH τ x)
monH• : ∀{Γ Δ Φ A} (τ : Γ ≤ Δ) (σ : Δ ≤ Φ) (x : Hyp A Φ) → monH (τ • σ) x ≡ monH τ (monH σ x)
monH• id≤ σ x = refl
monH• (weak τ) σ x = cong pop (monH• τ σ x)
monH• (lift τ) id≤ x = refl
monH• (lift τ) (weak σ) x = cong pop (monH• τ σ x)
monH• (lift τ) (lift σ) top = refl
monH• (lift τ) (lift σ) (pop x) = cong pop (monH• τ σ x)
{-# REWRITE monH• #-}
-- Monotonicity of neutrals
monNe' : ∀{P : Form + → Cxt → Set}
(monP : ∀{A} → Mon (P A)) →
∀{A} → Mon (Ne' P A)
monNe' monP τ (hyp x) = hyp (monH τ x)
monNe' monP τ (impE t u) = impE (monNe' monP τ t) (monP τ u)
monNe' monP τ (andE₁ t) = andE₁ (monNe' monP τ t)
monNe' monP τ (andE₂ t) = andE₂ (monNe' monP τ t)
-- Monotonicity of covers
monAddHyp : ∀{P} (monP : Mon P) → ∀{A} → Mon (AddHyp A P)
monAddHyp monP τ (addAtom t) = addAtom (monP (lift τ) t)
monAddHyp monP τ (addNeg t) = addNeg (monP (lift τ) t)
monAddHyp monP τ (trueE t) = trueE (monP τ t)
monAddHyp monP τ falseE = falseE
monAddHyp monP τ (andE t) = andE (monAddHyp (monAddHyp monP) τ t)
monAddHyp monP τ (orE t u) = orE (monAddHyp monP τ t) (monAddHyp monP τ u)
-- Monotonicity of derivations
mutual
monNe : ∀{i A} → Mon (Ne i A)
monNe {i} τ t = monNe' (monRFoc {i}) τ t
monCover : ∀{i j P} (monP : Mon P) → Mon (Cover i j P)
monCover monP τ (returnC t) = returnC (monP τ t)
monCover {i} {j} monP τ (matchC {i'} t c) = matchC (monNe τ t)
(monAddHyp (monCover {i'} {j} monP) τ c)
monRFoc : ∀{i A} → Mon (RFoc i A)
monRFoc τ (thunk t) = thunk (monRInv τ t)
monRFoc τ (hyp x) = hyp (monH τ x)
monRFoc τ trueI = trueI
monRFoc τ (andI t t₁) = andI (monRFoc τ t) (monRFoc τ t₁)
monRFoc τ (orI₁ t) = orI₁ (monRFoc τ t)
monRFoc τ (orI₂ t) = orI₂ (monRFoc τ t)
monRInv : ∀{i A} → Mon (RInv i A)
monRInv τ (ret {i} t) = ret (monCover (monRFoc {i}) τ t)
monRInv τ trueI = trueI
monRInv τ (andI t t₁) = andI (monRInv τ t) (monRInv τ t₁)
monRInv τ (impI {i} t) = impI (monAddHyp (monRInv {i}) τ t)
KFun : (P Q : Cxt → Set) (Γ : Cxt) → Set
KFun P Q Γ = ∀{Δ} (τ : Δ ≤ Γ) → P Δ → Q Δ
_⇒̂_ : (P Q : Cxt → Set) (Γ : Cxt) → Set
_⇒̂_ P Q Γ = ∀{Δ} (τ : Δ ≤ Γ) → P Δ → Q Δ
mapAddHyp' : ∀{P Q Γ} (f : (P ⇒̂ Q) Γ) → ∀{A} → AddHyp A P Γ → AddHyp A Q Γ
mapAddHyp' f (addAtom t) = addAtom (f (weak id≤) t)
mapAddHyp' f (addNeg t) = addNeg (f (weak id≤) t)
mapAddHyp' f (trueE t) = trueE (f id≤ t)
mapAddHyp' f falseE = falseE
mapAddHyp' f (andE t) = andE (mapAddHyp' (λ τ → mapAddHyp' λ τ' → f (τ' • τ)) t) -- By induction on types!
mapAddHyp' f (orE t u) = orE (mapAddHyp' f t) (mapAddHyp' f u)
mapCover' : ∀{P Q Γ} (f : (P ⇒̂ Q) Γ) {i j} (c : Cover i j P Γ) → Cover i j Q Γ
mapCover' f (returnC t) = returnC (f id≤ t)
mapCover' f (matchC t c) = matchC t (mapAddHyp' (λ τ → mapCover' λ τ' → f (τ' • τ)) c) -- Cover is sized!
-- Remark: Graded monad (andE)
bindAddHyp : ∀{A B J K} (monJ : Mon J) → AddHyp A J →̇ ((J ⇒̂ AddHyp B K) ⇒̂ AddHyp (A ∧ B) K)
bindAddHyp monJ t τ k = andE (mapAddHyp' k (monAddHyp monJ τ t))
-- Semantics
⟦_⟧ : ∀{p} (A : Form p) (Γ : Cxt) → Set
⟦ Atom P ⟧ Γ = HypAtom P Γ
⟦ False ⟧ Γ = ⊥
⟦ A ∨ B ⟧ Γ = ⟦ A ⟧ Γ ⊎ ⟦ B ⟧ Γ
⟦ True ⟧ Γ = ⊤
⟦ A ∧ B ⟧ Γ = ⟦ A ⟧ Γ × ⟦ B ⟧ Γ
⟦ A ⇒ B ⟧ Γ = ∀ {Δ} (τ : Δ ≤ Γ) (a : ⟦ A ⟧ Δ) → ⟦ B ⟧ Δ
⟦ Comp A ⟧ = Cover ∞ ∞ ⟦ A ⟧ -- values to computations
⟦ Thunk A ⟧ = ⟦ A ⟧
-- Monotonicity of semantics
mon⟦_⟧ : ∀{p} (A : Form p) → Mon ⟦ A ⟧
mon⟦ True ⟧ τ _ = _
mon⟦ A ∧ B ⟧ τ (a , b) = mon⟦ A ⟧ τ a , mon⟦ B ⟧ τ b
mon⟦ Atom P ⟧ = monH
mon⟦ False ⟧ τ ()
mon⟦ A ∨ B ⟧ τ = map-⊎ (mon⟦ A ⟧ τ) (mon⟦ B ⟧ τ)
mon⟦ A ⇒ B ⟧ τ f δ = f (δ • τ)
mon⟦ Comp A ⟧ = monCover mon⟦ A ⟧
mon⟦ Thunk A ⟧ = mon⟦ A ⟧
-- Reflection and reification.
mutual
reify- : ∀ (A : Form -) → ⟦ A ⟧ →̇ RInv ∞ A
reify- True _ = trueI
reify- (A ∧ B) (a , b) = andI (reify- A a) (reify- B b)
reify- (A ⇒ B) f = impI (reflectHyp A λ τ a → reify- B (f τ a))
reify- (Comp A) c = ret (mapCover (reify+ A) c)
reify+ : ∀ (A : Form +) → ⟦ A ⟧ →̇ RFoc ∞ A
reify+ True _ = trueI
reify+ (A ∧ B) (a , b) = andI (reify+ A a) (reify+ B b)
reify+ (Atom P) x = hyp x
reify+ False ()
reify+ (A ∨ B) (inj₁ a) = orI₁ (reify+ A a)
reify+ (A ∨ B) (inj₂ b) = orI₂ (reify+ B b)
reify+ (Thunk A) a = thunk (reify- A a)
reflectHyp : ∀ A {Γ} {J} (k : ∀ {Δ} (τ : Δ ≤ Γ) → ⟦ A ⟧ Δ → J Δ) → AddHyp A J Γ
reflectHyp True k = trueE (k id≤ _)
reflectHyp (A ∧ B) k = andE (reflectHyp A λ τ a →
reflectHyp B λ τ' b → k (τ' • τ) (mon⟦ A ⟧ τ' a , b)) -- need monT
reflectHyp (Atom P) k = addAtom (k (weak id≤) top)
reflectHyp False k = falseE
reflectHyp (A ∨ B) k = orE (reflectHyp A (λ τ a → k τ (inj₁ a)))
(reflectHyp B (λ τ b → k τ (inj₂ b)))
reflectHyp (Thunk A) k = addNeg (k (weak id≤) (reflect A (hyp top)))
-- Since we only have negative hypotheses, we only need to reflect these
reflect : ∀ (A : Form -) → Ne ∞ A →̇ ⟦ A ⟧
reflect True t = _
reflect (A ∧ B) t = reflect A (andE₁ t) , reflect B (andE₂ t)
reflect (A ⇒ B) t τ a = reflect B (impE (monNe τ t) (reify+ A a)) -- need monNe
reflect (Comp A) t = matchC t (reflectHyp A λ τ a → returnC a)
-- Negative propositions are comonadic
paste : ∀ (A : Form -) → Cover ∞ ∞ ⟦ A ⟧ →̇ ⟦ A ⟧
paste True _ = _
paste (A ∧ B) c = paste A (mapCover proj₁ c) , paste B (mapCover proj₂ c)
paste (A ⇒ B) c τ a = paste B (mapCover' (λ τ' f → f id≤ (mon⟦ A ⟧ τ' a)) (monCover mon⟦ A ⇒ B ⟧ τ c))
paste (Comp A) = joinCover
-- Snippets to define evaluation in polarized lambda calculus
module Evaluation where
-- Environments
G⟦_⟧ : (Γ : Cxt) → Cxt → Set
G⟦ ε ⟧ Δ = ⊤
G⟦ Γ ∙ P ⟧ Δ = G⟦ Γ ⟧ Δ × ⟦ P ⟧ Δ
monG⟦_⟧ : (Γ : Cxt) → Mon (G⟦ Γ ⟧)
monG⟦ ε ⟧ = _
monG⟦ Γ ∙ P ⟧ τ (γ , a) = monG⟦ Γ ⟧ τ γ , mon⟦ P ⟧ τ a
Ev : (R : Set) (Δ Γ : Cxt) → Set
Ev R Δ Γ = G⟦ Γ ⟧ Δ → R
cut : ∀{R P Δ} → ⟦ P ⟧ Δ → AddHyp P (Ev R Δ) →̇ Ev R Δ
cut x (addAtom t) γ = t (γ , returnC x)
cut a (addNeg t) γ = t (γ , a)
cut _ (trueE t) = t
cut (a , b) (andE t) = cut a (mapAddHyp (cut b) t)
cut () falseE
cut (inj₁ a) (orE t u) = cut a t
cut (inj₂ b) (orE t u) = cut b u
-- Intuitionistic propositional logic
data IPL : Set where
Atom : (P : Atoms) → IPL
True False : IPL
_∨_ _∧_ _⇒_ : (A B : IPL) → IPL
module CallByName where
_⁻ : IPL → Form -
Atom P ⁻ = Atom- P
True ⁻ = True
False ⁻ = Comp False
(A ∨ B) ⁻ = Comp (Thunk (A ⁻) ∨ Thunk (B ⁻))
(A ∧ B) ⁻ = A ⁻ ∧ B ⁻
(A ⇒ B) ⁻ = Thunk (A ⁻) ⇒ B ⁻
module CallByValue where
_⁺ : IPL → Form +
Atom P ⁺ = Atom P
True ⁺ = True
False ⁺ = False
(A ∨ B) ⁺ = A ⁺ ∨ B ⁺
(A ∧ B) ⁺ = A ⁺ ∧ B ⁺
(A ⇒ B) ⁺ = Thunk (A ⁺ ⇒ Comp (B ⁺))
mutual
_⁺ : IPL → Form +
Atom P ⁺ = Atom P
True ⁺ = True
False ⁺ = False
(A ∨ B) ⁺ = A ⁺ ∨ B ⁺
(A ∧ B) ⁺ = A ⁺ ∧ B ⁺
(A ⇒ B) ⁺ = Thunk (A ⁺ ⇒ B ⁻)
_⁻ : IPL → Form -
Atom P ⁻ = Atom- P
True ⁻ = True
False ⁻ = Comp False
(A ∨ B) ⁻ = Comp (A ⁺ ∨ B ⁺)
(A ∧ B) ⁻ = A ⁻ ∧ B ⁻
(A ⇒ B) ⁻ = A ⁺ ⇒ B ⁻
-- Derivations
infix 2 _⊢_
data _⊢_ (Γ : Cxt' IPL) : (A : IPL) → Set where
hyp : ∀{A} (x : Hyp' IPL A Γ) → Γ ⊢ A
impI : ∀{A B} (t : Γ ∙ A ⊢ B) → Γ ⊢ A ⇒ B
impE : ∀{A B} (t : Γ ⊢ A ⇒ B) (u : Γ ⊢ A) → Γ ⊢ B
andI : ∀{A B} (t : Γ ⊢ A) (u : Γ ⊢ B) → Γ ⊢ A ∧ B
andE₁ : ∀{A B} (t : Γ ⊢ A ∧ B) → Γ ⊢ A
andE₂ : ∀{A B} (t : Γ ⊢ A ∧ B) → Γ ⊢ B
orI₁ : ∀{A B} (t : Γ ⊢ A) → Γ ⊢ A ∨ B
orI₂ : ∀{A B} (t : Γ ⊢ B) → Γ ⊢ A ∨ B
orE : ∀{A B C} (t : Γ ⊢ A ∨ B) (u : Γ ∙ A ⊢ C) (v : Γ ∙ B ⊢ C) → Γ ⊢ C
falseE : ∀{C} (t : Γ ⊢ False) → Γ ⊢ C
trueI : Γ ⊢ True
Tm = λ A Γ → Γ ⊢ A
-- Call-by value evaluation
module CBV where
V⟦_⟧ = λ A → ⟦ A ⁺ ⟧
C⟦_⟧ = λ A → ⟦ A ⁻ ⟧
return : ∀ A → V⟦ A ⟧ →̇ C⟦ A ⟧
return (Atom P) v = returnC v
return True v = v
return False v = returnC v
return (A ∨ B) v = returnC v
return (A ∧ B) (a , b) = return A a , return B b
return (A ⇒ B) v = v
run : ∀ A → C⟦ A ⟧ →̇ Cover ∞ ∞ V⟦ A ⟧
run (Atom P) c = c
run True c = returnC c
run False c = c
run (A ∨ B) c = c
run (A ∧ B) c = joinCover (mapCover' (λ τ a → mapCover' (λ τ' b → (mon⟦ A ⁺ ⟧ τ' a , b)) (run B (mon⟦ B ⁻ ⟧ τ (proj₂ c)))) (run A (proj₁ c)))
run (A ⇒ B) c = returnC c
-- Fundamental theorem
-- Extension of ⟦_⟧ to contexts
G⟦_⟧ : ∀ (Γ : Cxt' IPL) (Δ : Cxt) → Set
G⟦ ε ⟧ Δ = ⊤
G⟦ Γ ∙ A ⟧ Δ = G⟦ Γ ⟧ Δ × V⟦ A ⟧ Δ
-- monG : ∀{Γ Δ Φ} (τ : Φ ≤ Δ) → G⟦ Γ ⟧ Δ → G⟦ Γ ⟧ Φ
monG : ∀{Γ} → Mon G⟦ Γ ⟧
monG {ε} τ _ = _
monG {Γ ∙ A} τ (γ , a) = monG τ γ , mon⟦ A ⁺ ⟧ τ a
-- Variable case.
lookup : ∀{Γ A} (x : Hyp' IPL A Γ) → G⟦ Γ ⟧ →̇ V⟦ A ⟧
lookup top = proj₂
lookup (pop x) = lookup x ∘ proj₁
impIntro : ∀ {A B Γ} (f : KFun (Cover ∞ ∞ ⟦ A ⟧) ⟦ B ⟧ Γ) → ⟦ A ⇒ B ⟧ Γ
impIntro f τ a = f τ (returnC a)
-- impElim : ∀ A B {Γ} → (f : C⟦ A ⇒ B ⟧ Γ) (a : C⟦ A ⟧ Γ) → C⟦ B ⟧ Γ
-- impElim (Atom P) B f = paste (B ⁻) ∘ mapCover' f
-- impElim False B f = paste (B ⁻) ∘ mapCover' f
-- impElim True B f = f id≤
-- impElim (A ∨ A₁) B f = paste (B ⁻) ∘ mapCover' f
-- impElim (A ∧ A₁) B f = {!paste (B ⁻) ∘ mapCover' f!}
-- impElim (A ⇒ A₁) B f = f id≤
impElim : ∀ A B {Γ} → (f : C⟦ A ⇒ B ⟧ Γ) (a : C⟦ A ⟧ Γ) → C⟦ B ⟧ Γ
impElim A B f a = paste (B ⁻) (mapCover' f (run A a))
-- A lemma for the orE case.
orElim : ∀ A B C {Γ} → C⟦ A ∨ B ⟧ Γ → C⟦ A ⇒ C ⟧ Γ → C⟦ B ⇒ C ⟧ Γ → C⟦ C ⟧ Γ
orElim A B C c g h = paste (C ⁻) (mapCover' (λ τ → [ g τ , h τ ]) c)
-- A lemma for the falseE case.
-- Casts an empty cover into any semantic value (by contradiction).
falseElim : ∀ C → C⟦ False ⟧ →̇ C⟦ C ⟧
falseElim C = paste (C ⁻) ∘ mapCover ⊥-elim
-- The fundamental theorem
eval : ∀{A Γ} (t : Γ ⊢ A) → G⟦ Γ ⟧ →̇ C⟦ A ⟧
eval {A} (hyp x) = return A ∘ lookup x
eval (impI t) γ τ a = eval t (monG τ γ , a)
eval (impE {A} {B} t u) γ = impElim A B (eval t γ) (eval u γ)
eval (andI t u) γ = eval t γ , eval u γ
eval (andE₁ t) = proj₁ ∘ eval t
eval (andE₂ t) = proj₂ ∘ eval t
eval (orI₁ {A} {B} t) γ = mapCover inj₁ (run A (eval t γ))
eval (orI₂ {A} {B} t) γ = mapCover inj₂ (run B (eval t γ))
eval (orE {A} {B} {C} t u v) γ = orElim A B C (eval t γ)
(λ τ a → eval u (monG τ γ , a))
(λ τ b → eval v (monG τ γ , b))
eval {C} (falseE t) γ = falseElim C (eval t γ)
eval trueI γ = _
_⁺⁺ : (Γ : Cxt' IPL) → Cxt
ε ⁺⁺ = ε
(Γ ∙ A) ⁺⁺ = Γ ⁺⁺ ∙ A ⁻
-- Identity environment
ide : ∀ Γ → Cover ∞ ∞ G⟦ Γ ⟧ (Γ ⁺⁺)
ide ε = returnC _
ide (Γ ∙ A) = {!!}
-- monG (weak id≤) (ide Γ) , {! reflectHyp (A ⁺) (λ τ a → a) !}
{-
-- Normalization
norm : ∀{A : IPL} {Γ : Cxt' IPL} → Tm A Γ → RInv (Γ ⁺⁺) (A ⁻)
norm t = reify- _ (eval t (ide _))
-- -}
-- -}
-- -}
-- -}
-- -}
-- -}
-- -}
-- -}
-- -}
| {
"alphanum_fraction": 0.4949489217,
"avg_line_length": 30.3270223752,
"ext": "agda",
"hexsha": "5fe125110255485f9b7ca13e04609d7a6ef48814",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-02-25T20:39:03.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-11-13T16:01:46.000Z",
"max_forks_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "andreasabel/ipl",
"max_forks_repo_path": "src-focusing/Formulas.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"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": "andreasabel/ipl",
"max_issues_repo_path": "src-focusing/Formulas.agda",
"max_line_length": 143,
"max_stars_count": 19,
"max_stars_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "andreasabel/ipl",
"max_stars_repo_path": "src-focusing/Formulas.agda",
"max_stars_repo_stars_event_max_datetime": "2021-04-27T19:10:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-16T08:08:51.000Z",
"num_tokens": 8069,
"size": 17620
} |
postulate
X : Set
T : X → Set
H : ∀ x → T x → Set
g : ∀ x → T x → Set
g x t = ∀ x → H x t
| {
"alphanum_fraction": 0.3979591837,
"avg_line_length": 10.8888888889,
"ext": "agda",
"hexsha": "6e5bb207b2558ffa01cbad6b79fe334fcdbd780a",
"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/Issue1005.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/Issue1005.agda",
"max_line_length": 21,
"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/Issue1005.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 48,
"size": 98
} |
-- Copyright: (c) 2016 Ertugrul Söylemez
-- License: BSD3
-- Maintainer: Ertugrul Söylemez <[email protected]>
module Data.Fin where
open import Data.Fin.Core public
using (Fin; Fin-Number; fsuc; fzero)
| {
"alphanum_fraction": 0.7198067633,
"avg_line_length": 23,
"ext": "agda",
"hexsha": "a80e847b1a6ef96cae6842b196c8c220e3e8a697",
"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": "Data/Fin.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": "Data/Fin.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": "Data/Fin.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": 76,
"size": 207
} |
------------------------------------------------------------------------------
-- Conversion rules for the recursive operator rec
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module LTC-PCF.Data.Nat.Rec.ConversionRules where
open import Common.FOL.Relation.Binary.EqReasoning
open import LTC-PCF.Base
open import LTC-PCF.Data.Nat.Rec
----------------------------------------------------------------------------
private
-- We follow the same methodology used in
-- LTC-PCF.Program.Division.EquationsI (see it for the
-- documentation).
----------------------------------------------------------------------------
-- The steps
-- Initially, the conversion rule fix-eq is applied.
rec-s₁ : D → D → D → D
rec-s₁ n a f = rech (fix rech) · n · a · f
-- First argument application.
rec-s₂ : D → D
rec-s₂ n = lam (λ a → lam (λ f →
if (iszero₁ n)
then a
else f · pred₁ n · (fix rech · pred₁ n · a · f)))
-- Second argument application.
rec-s₃ : D → D → D
rec-s₃ n a = lam (λ f →
if (iszero₁ n)
then a
else f · pred₁ n · (fix rech · pred₁ n · a · f))
-- Third argument application.
rec-s₄ : D → D → D → D
rec-s₄ n a f = if (iszero₁ n)
then a
else f · pred₁ n · (fix rech · pred₁ n · a · f)
-- Reduction iszero₁ n ≡ b.
rec-s₅ : D → D → D → D → D
rec-s₅ n a f b = if b
then a
else f · pred₁ n · (fix rech · pred₁ n · a · f)
-- Reduction of iszero₁ n ≡ true
--
-- It should be
-- rec-s₆ : D → D → D → D
-- rec-s₆ n a f = a
--
-- but we do not give a name to this step.
-- Reduction iszero₁ n ≡ false.
rec-s₆ : D → D → D → D
rec-s₆ n a f = f · pred₁ n · (fix rech · pred₁ n · a · f)
-- Reduction pred₁ (succ n) ≡ n.
rec-s₇ : D → D → D → D
rec-s₇ n a f = f · n · (fix rech · n · a · f)
----------------------------------------------------------------------------
-- The execution steps
-- We follow the same methodology used in
-- LTC-PCF.Program.Division.EquationsI (see it for the
-- documentation).
-- Application of the conversion rule fix-eq.
proof₀₋₁ : ∀ n a f → fix rech · n · a · f ≡ rec-s₁ n a f
proof₀₋₁ n a f = subst (λ x → x · n · a · f ≡ rech (fix rech) · n · a · f )
(sym (fix-eq rech))
refl
-- Application of the first argument.
proof₁₋₂ : ∀ n a f → rec-s₁ n a f ≡ rec-s₂ n · a · f
proof₁₋₂ n a f = subst (λ x → x · a · f ≡ rec-s₂ n · a · f)
(sym (beta rec-s₂ n))
refl
-- Application of the second argument.
proof₂₋₃ : ∀ n a f → rec-s₂ n · a · f ≡ rec-s₃ n a · f
proof₂₋₃ n a f = subst (λ x → x · f ≡ rec-s₃ n a · f)
(sym (beta (rec-s₃ n) a))
refl
-- Application of the third argument.
proof₃₋₄ : ∀ n a f → rec-s₃ n a · f ≡ rec-s₄ n a f
proof₃₋₄ n a f = beta (rec-s₄ n a) f
-- Cases iszero₁ n ≡ b using that proof.
-- 25 April 2014. Failed with Andreas' --without-K.
proof₄₋₅ : ∀ n a f b → iszero₁ n ≡ b → rec-s₄ n a f ≡ rec-s₅ n a f b
proof₄₋₅ n a f .(iszero₁ n) refl = refl
-- Reduction of if true ... using the conversion rule if-true.
proof₅₊ : ∀ n a f → rec-s₅ n a f true ≡ a
proof₅₊ n a f = if-true a
-- Reduction of if false ... using the conversion rule if-false.
proof₅₋₆ : ∀ n a f → rec-s₅ n a f false ≡ rec-s₆ n a f
proof₅₋₆ n a f = if-false (rec-s₆ n a f)
-- Reduction pred₁ (succ n) ≡ n using the conversion rule pred₁-S.
proof₆₋₇ : ∀ n a f → rec-s₆ (succ₁ n) a f ≡ rec-s₇ n a f
proof₆₋₇ n a f = subst (λ x → rec-s₇ x a f ≡ rec-s₇ n a f)
(sym (pred-S n))
refl
------------------------------------------------------------------------------
-- The conversion rules for rec.
rec-0 : ∀ a {f} → rec zero a f ≡ a
rec-0 a {f} =
fix rech · zero · a · f ≡⟨ proof₀₋₁ zero a f ⟩
rec-s₁ zero a f ≡⟨ proof₁₋₂ zero a f ⟩
rec-s₂ zero · a · f ≡⟨ proof₂₋₃ zero a f ⟩
rec-s₃ zero a · f ≡⟨ proof₃₋₄ zero a f ⟩
rec-s₄ zero a f ≡⟨ proof₄₋₅ zero a f true iszero-0 ⟩
rec-s₅ zero a f true ≡⟨ proof₅₊ zero a f ⟩
a ∎
rec-S : ∀ n a f → rec (succ₁ n) a f ≡ f · n · (rec n a f)
rec-S n a f =
fix rech · (succ₁ n) · a · f ≡⟨ proof₀₋₁ (succ₁ n) a f ⟩
rec-s₁ (succ₁ n) a f ≡⟨ proof₁₋₂ (succ₁ n) a f ⟩
rec-s₂ (succ₁ n) · a · f ≡⟨ proof₂₋₃ (succ₁ n) a f ⟩
rec-s₃ (succ₁ n) a · f ≡⟨ proof₃₋₄ (succ₁ n) a f ⟩
rec-s₄ (succ₁ n) a f ≡⟨ proof₄₋₅ (succ₁ n) a f false (iszero-S n) ⟩
rec-s₅ (succ₁ n) a f false ≡⟨ proof₅₋₆ (succ₁ n) a f ⟩
rec-s₆ (succ₁ n) a f ≡⟨ proof₆₋₇ n a f ⟩
rec-s₇ n a f ∎
| {
"alphanum_fraction": 0.4618426255,
"avg_line_length": 35.125,
"ext": "agda",
"hexsha": "0a4415595af6e00f25dd3222b270ace6a3f056b0",
"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/LTC-PCF/Data/Nat/Rec/ConversionRules.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/LTC-PCF/Data/Nat/Rec/ConversionRules.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/LTC-PCF/Data/Nat/Rec/ConversionRules.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": 1773,
"size": 5058
} |
------------------------------------------------------------------------
-- Functional semantics for an untyped λ-calculus with constants
------------------------------------------------------------------------
{-# OPTIONS --no-termination-check #-}
module Lambda.Closure.Functional.No-workarounds where
open import Category.Monad
open import Category.Monad.Partiality as Partiality
using (_⊥; never; OtherKind; other; steps)
open import Codata.Musical.Notation
open import Data.Empty using (⊥-elim)
open import Data.List hiding (lookup)
open import Data.Maybe hiding (_>>=_)
import Data.Maybe.Categorical as Maybe
open import Data.Nat
open import Data.Product
open import Data.Sum
open import Data.Vec using (Vec; []; _∷_; lookup)
open import Function
import Level
open import Relation.Binary using (module Preorder)
open import Relation.Binary.PropositionalEquality as P using (_≡_)
open import Relation.Nullary
open import Relation.Nullary.Negation
open Partiality._⊥
private
open module E {A : Set} = Partiality.Equality (_≡_ {A = A})
open module R {A : Set} =
Partiality.Reasoning (P.isEquivalence {A = A})
open import Lambda.Syntax
open Closure Tm
open import Lambda.VirtualMachine
open Functional
private
module VM = Closure Code
------------------------------------------------------------------------
-- A monad with partiality and failure
PF : RawMonad {f = Level.zero} (_⊥ ∘ Maybe)
PF = Maybe.monadT Partiality.monad
module PF where
open RawMonad PF public
fail : {A : Set} → Maybe A ⊥
fail = now nothing
_>>=-cong_ :
∀ {k} {A B : Set} {x₁ x₂ : Maybe A ⊥} {f₁ f₂ : A → Maybe B ⊥} →
Rel k x₁ x₂ → (∀ x → Rel k (f₁ x) (f₂ x)) →
Rel k (x₁ >>= f₁) (x₂ >>= f₂)
_>>=-cong_ {k} {f₁ = f₁} {f₂} x₁≈x₂ f₁≈f₂ =
Partiality._>>=-cong_ x₁≈x₂ helper
where
helper : ∀ {x y} → x ≡ y →
Rel k (maybe f₁ fail x) (maybe f₂ fail y)
helper {x = nothing} P.refl = fail ∎
helper {x = just x} P.refl = f₁≈f₂ x
associative :
{A B C : Set}
(x : Maybe A ⊥) (f : A → Maybe B ⊥) (g : B → Maybe C ⊥) →
(x >>= f >>= g) ≅ (x >>= λ y → f y >>= g)
associative x f g =
(x >>= f >>= g) ≅⟨ Partiality.associative P.refl x _ _ ⟩
(x >>=′ λ y → maybe f fail y >>= g) ≅⟨ Partiality._>>=-cong_ (x ∎) helper ⟩
(x >>= λ y → f y >>= g) ∎
where
open RawMonad Partiality.monad renaming (_>>=_ to _>>=′_)
helper : ∀ {y₁ y₂} → y₁ ≡ y₂ →
(maybe f fail y₁ >>= g) ≅ maybe (λ z → f z >>= g) fail y₂
helper {y₁ = nothing} P.refl = fail ∎
helper {y₁ = just y} P.refl = (f y >>= g) ∎
>>=-inversion-⇓ :
∀ {k} {A B : Set} x {f : A → Maybe B ⊥} {y} →
(x>>=f⇓ : (x >>= f) ⇓[ k ] just y) →
∃ λ z → ∃₂ λ (x⇓ : x ⇓[ k ] just z)
(fz⇓ : f z ⇓[ k ] just y) →
steps x⇓ + steps fz⇓ ≡ steps x>>=f⇓
>>=-inversion-⇓ x {f} x>>=f⇓
with Partiality.>>=-inversion-⇓ {_∼A_ = _≡_} P.refl x x>>=f⇓
... | (nothing , x↯ , now () , _)
... | (just z , x⇓ , fz⇓ , eq) = (z , x⇓ , fz⇓ , eq)
>>=-inversion-⇑ :
∀ {k} {A B : Set} x {f : A → Maybe B ⊥} →
(x >>= f) ⇑[ other k ] →
¬ ¬ (x ⇑[ other k ] ⊎
∃ λ y → x ⇓[ other k ] just y × f y ⇑[ other k ])
>>=-inversion-⇑ {k} x {f} x>>=f⇑ =
helper ⟨$⟩ Partiality.>>=-inversion-⇑ P.isEquivalence x x>>=f⇑
where
open RawMonad ¬¬-Monad renaming (_<$>_ to _⟨$⟩_)
helper : (_ ⊎ ∃ λ (y : Maybe _) → _) → _
helper (inj₁ x⇑ ) = inj₁ x⇑
helper (inj₂ (just y , x⇓,fy⇑) ) = inj₂ (y , x⇓,fy⇑)
helper (inj₂ (nothing , x↯,now∼never)) =
⊥-elim (Partiality.now≉never (proj₂ x↯,now∼never))
open PF
------------------------------------------------------------------------
-- Semantics
infix 5 _∙_
-- Note that this definition gives us determinism "for free".
mutual
⟦_⟧ : ∀ {n} → Tm n → Env n → Maybe Value ⊥
⟦ con i ⟧ ρ = return (con i)
⟦ var x ⟧ ρ = return (lookup ρ x)
⟦ ƛ t ⟧ ρ = return (ƛ t ρ)
⟦ t₁ · t₂ ⟧ ρ = ⟦ t₁ ⟧ ρ >>= λ v₁ →
⟦ t₂ ⟧ ρ >>= λ v₂ →
v₁ ∙ v₂
_∙_ : Value → Value → Maybe Value ⊥
con i ∙ v₂ = fail
ƛ t₁ ρ ∙ v₂ = later (♯ (⟦ t₁ ⟧ (v₂ ∷ ρ)))
------------------------------------------------------------------------
-- Example
Ω-loops : ⟦ Ω ⟧ [] ≈ never
Ω-loops = later (♯ Ω-loops)
------------------------------------------------------------------------
-- Some lemmas
-- An abbreviation.
infix 5 _⟦·⟧_
_⟦·⟧_ : Maybe Value ⊥ → Maybe Value ⊥ → Maybe Value ⊥
v₁ ⟦·⟧ v₂ = v₁ >>= λ v₁ → v₂ >>= λ v₂ → v₁ ∙ v₂
-- _⟦·⟧_ preserves equality.
_⟦·⟧-cong_ : ∀ {k v₁₁ v₁₂ v₂₁ v₂₂} →
Rel k v₁₁ v₂₁ → Rel k v₁₂ v₂₂ →
Rel k (v₁₁ ⟦·⟧ v₁₂) (v₂₁ ⟦·⟧ v₂₂)
v₁₁≈v₂₁ ⟦·⟧-cong v₁₂≈v₂₂ =
v₁₁≈v₂₁ >>=-cong λ v₁ →
v₁₂≈v₂₂ >>=-cong λ v₂ →
v₁ ∙ v₂ ∎
-- The semantics of application is compositional (with respect to the
-- syntactic equality which is used).
·-comp : ∀ {n} (t₁ t₂ : Tm n) {ρ} →
⟦ t₁ · t₂ ⟧ ρ ≅ ⟦ t₁ ⟧ ρ ⟦·⟧ ⟦ t₂ ⟧ ρ
·-comp t₁ t₂ = _ ∎
------------------------------------------------------------------------
-- Compiler correctness
module Correctness where
-- The relation _≈_ does not admit unrestricted use of transitivity
-- in corecursive proofs, so I have formulated the correctness proof
-- using a continuation. Note that the proof would perhaps be easier
-- if the semantics was also formulated in continuation-passing
-- style.
mutual
correct :
∀ {n} t {ρ : Env n} {c s} {k : Value → Maybe VM.Value ⊥} →
(∀ v → exec ⟨ c , val (comp-val v) ∷ s , comp-env ρ ⟩ ≈ k v) →
exec ⟨ comp t c , s , comp-env ρ ⟩ ≈ (⟦ t ⟧ ρ >>= k)
correct (con i) {ρ} {c} {s} {k} hyp = laterˡ (
exec ⟨ c , val (Lambda.Syntax.Closure.con i) ∷ s , comp-env ρ ⟩ ≈⟨ hyp (con i) ⟩
k (con i) ∎)
correct (var x) {ρ} {c} {s} {k} hyp = laterˡ (
exec ⟨ c , val (lookup (comp-env ρ) x) ∷ s , comp-env ρ ⟩ ≡⟨ P.cong (λ v → exec ⟨ c , val v ∷ s , comp-env ρ ⟩) (lookup-hom x ρ) ⟩
exec ⟨ c , val (comp-val (lookup ρ x)) ∷ s , comp-env ρ ⟩ ≈⟨ hyp (lookup ρ x) ⟩
k (lookup ρ x) ∎)
correct (ƛ t) {ρ} {c} {s} {k} hyp = laterˡ (
exec ⟨ c , val (comp-val (ƛ t ρ)) ∷ s , comp-env ρ ⟩ ≈⟨ hyp (ƛ t ρ) ⟩
k (ƛ t ρ) ∎)
correct (t₁ · t₂) {ρ} {c} {s} {k} hyp =
exec ⟨ comp t₁ (comp t₂ (app ∷ c)) , s , comp-env ρ ⟩ ≈⟨ correct t₁ (λ v₁ → correct t₂ (λ v₂ → ∙-correct v₁ v₂ hyp)) ⟩
(⟦ t₁ ⟧ ρ >>= λ v₁ → ⟦ t₂ ⟧ ρ >>= λ v₂ → v₁ ∙ v₂ >>= k) ≅⟨ ((⟦ t₁ ⟧ ρ ∎) >>=-cong λ _ → sym $ associative (⟦ t₂ ⟧ ρ) _ _) ⟩
(⟦ t₁ ⟧ ρ >>= λ v₁ → (⟦ t₂ ⟧ ρ >>= λ v₂ → v₁ ∙ v₂) >>= k) ≅⟨ sym $ associative (⟦ t₁ ⟧ ρ) _ _ ⟩
(⟦ t₁ ⟧ ρ ⟦·⟧ ⟦ t₂ ⟧ ρ >>= k) ≅⟨ _ ∎ ⟩
(⟦ t₁ · t₂ ⟧ ρ >>= k) ∎
∙-correct :
∀ {n} v₁ v₂ {ρ : Env n} {c s} {k : Value → Maybe VM.Value ⊥} →
(∀ v → exec ⟨ c , val (comp-val v) ∷ s , comp-env ρ ⟩ ≈ k v) →
exec ⟨ app ∷ c , val (comp-val v₂) ∷ val (comp-val v₁) ∷ s , comp-env ρ ⟩ ≈
(v₁ ∙ v₂ >>= k)
∙-correct (con i) v₂ _ = fail ∎
∙-correct (ƛ t₁ ρ₁) v₂ {ρ} {c} {s} {k} hyp =
exec ⟨ app ∷ c , val (comp-val v₂) ∷ val (comp-val (ƛ t₁ ρ₁)) ∷ s , comp-env ρ ⟩ ≈⟨ later (♯ (
exec ⟨ comp t₁ [ ret ] , ret c (comp-env ρ) ∷ s , comp-env (v₂ ∷ ρ₁) ⟩ ≈⟨ correct t₁ (λ v → laterˡ (hyp v)) ⟩
(⟦ t₁ ⟧ (v₂ ∷ ρ₁) >>= k) ∎)) ⟩
(ƛ t₁ ρ₁ ∙ v₂ >>= k) ∎
-- Note that the equality that is used here is syntactic.
correct : ∀ t →
exec ⟨ comp t [] , [] , [] ⟩ ≈
(⟦ t ⟧ [] >>= λ v → PF.return (comp-val v))
correct t = Correctness.correct t (λ v → return (comp-val v) ∎)
| {
"alphanum_fraction": 0.4599974959,
"avg_line_length": 36.6376146789,
"ext": "agda",
"hexsha": "9e4690b678bec1db2ff6c999950f132795362d4d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/codata",
"max_forks_repo_path": "Lambda/Closure/Functional/No-workarounds.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/codata",
"max_issues_repo_path": "Lambda/Closure/Functional/No-workarounds.agda",
"max_line_length": 137,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/codata",
"max_stars_repo_path": "Lambda/Closure/Functional/No-workarounds.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z",
"num_tokens": 3066,
"size": 7987
} |
{-# OPTIONS --allow-unsolved-metas #-}
postulate
A : Set
R : A → Set
M : (a : A) (s t : R a) → Set
variable
a : A
s : R a
t : _
postulate
m : M _ s t
t = _
| {
"alphanum_fraction": 0.4855491329,
"avg_line_length": 9.6111111111,
"ext": "agda",
"hexsha": "d21dcd658cd00593960a492f877bad1685b3f3ad",
"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/Issue4314.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/Issue4314.agda",
"max_line_length": 38,
"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/Issue4314.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": 73,
"size": 173
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Groups.Abelian.Definition
open import Groups.Definition
open import Groups.Lemmas
open import Rings.Definition
open import Setoids.Setoids
open import Sets.EquivalenceRelations
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.EuclideanAlgorithm
open import Numbers.Primes.PrimeNumbers
module Rings.Characteristic {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} {_*_ : A → A → A} (R : Ring S _+_ _*_) where
open import Rings.InitialRing R
open Ring R
open Setoid S
open Equivalence eq
open Group additiveGroup
characteristicWellDefined : (0R ∼ 1R → False) → {n m : ℕ} → Prime n → Prime m → fromN n ∼ 0R → fromN m ∼ 0R → n ≡ m
characteristicWellDefined 0!=1 {n} {m} pN pM n=0 m=0 with divisionDecidable m n
... | inl n|m = equalityCommutative (primeDivPrimeImpliesEqual pM pN n|m)
... | inr notDiv with hcfPrimeIsOne {m} {n} pM notDiv
... | bl = exFalso (0!=1 v)
where
t : (n *N extendedHcf.extended1 (euclid n m) ≡ m *N extendedHcf.extended2 (euclid n m) +N extendedHcf.c (euclid n m)) || (n *N extendedHcf.extended1 (euclid n m) +N extendedHcf.c (euclid n m) ≡ m *N extendedHcf.extended2 (euclid n m))
t = extendedHcf.extendedProof (euclid n m)
u : (n *N extendedHcf.extended1 (euclid n m) ≡ m *N extendedHcf.extended2 (euclid n m) +N 1) || (n *N extendedHcf.extended1 (euclid n m) +N 1 ≡ m *N extendedHcf.extended2 (euclid n m))
u with t
... | inl x = inl (transitivity x (applyEquality (λ i → m *N extendedHcf.extended2 (euclid n m) +N i) bl))
... | inr x = inr (transitivity (applyEquality (n *N extendedHcf.extended1 (euclid n m) +N_) (equalityCommutative bl)) x)
v : 0R ∼ 1R
v with u
... | inr x = symmetric (transitive (symmetric (transitive (fromNPreserves+ (n *N extendedHcf.extended1 (euclid n m)) 1) (transitive (+WellDefined (transitive (fromNPreserves* n (extendedHcf.extended1 (euclid n m))) (transitive (*WellDefined n=0 reflexive) timesZero')) identRight) identLeft))) (transitive (fromNWellDefined x) (transitive (fromNPreserves* m (extendedHcf.extended2 (euclid n m))) (transitive (*WellDefined m=0 reflexive) timesZero'))))
... | inl x = transitive (transitive (transitive (symmetric timesZero') (transitive (*WellDefined (symmetric n=0) reflexive) (transitive (symmetric (fromNPreserves* n (extendedHcf.extended1 (euclid n m)))) (transitive (fromNWellDefined x) (transitive (fromNPreserves+ (m *N extendedHcf.extended2 (euclid n m)) 1) (+WellDefined (fromNPreserves* m (extendedHcf.extended2 (euclid n m))) reflexive)))))) (+WellDefined (transitive (*WellDefined m=0 reflexive) timesZero') (identRight))) identLeft
| {
"alphanum_fraction": 0.7122781065,
"avg_line_length": 71.1578947368,
"ext": "agda",
"hexsha": "118023ac48585dbfff2a3fb3972e7db6bf532d94",
"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/Characteristic.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/Characteristic.agda",
"max_line_length": 495,
"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/Characteristic.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": 913,
"size": 2704
} |
module TelescopingLet5 where
postulate
A : Set
a : A
module B (a : A) where
postulate
C : Set
-- B.C : (a : A) → Set
module N = B a
module M' (open N) (c : C) where
postulate cc : C
-- M.cc : (a : B.A a) → B.A a
E = let open B a in C
module M (open B a) (x : A) where
D = C
postulate cc : C
-- M.cc : (a : B.A a) → B.A a
| {
"alphanum_fraction": 0.5260115607,
"avg_line_length": 13.84,
"ext": "agda",
"hexsha": "1cfbb93b620f0232fea3e6c0a1027b498c1cbd41",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/succeed/TelescopingLet5.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/TelescopingLet5.agda",
"max_line_length": 33,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "masondesu/agda",
"max_stars_repo_path": "test/succeed/TelescopingLet5.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": 145,
"size": 346
} |
{-# OPTIONS --termination-depth=2 #-}
module TerminationWithTwoConstructors where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
f : Nat -> Nat
f zero = zero
f (suc zero) = zero
f (suc (suc n)) with zero
... | m = f (suc n)
{- internal represenation
f : Nat -> Nat
f zero = zero
f (suc zero) = zero
f (suc (suc n)) = faux n zero
faux : Nat -> Nat -> Nat
faux n m = f (suc n)
-}
{- this type checks with --termination-depth >= 2
calls:
f -> f_with (-2)
f_with -> f (+1)
-} | {
"alphanum_fraction": 0.5947046843,
"avg_line_length": 14.8787878788,
"ext": "agda",
"hexsha": "d7ea7c39f99633bf86998c2c06166aaff5288c0e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/succeed/TerminationWithTwoConstructors.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/TerminationWithTwoConstructors.agda",
"max_line_length": 49,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/succeed/TerminationWithTwoConstructors.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": 172,
"size": 491
} |
------------------------------------------------------------------------------
-- Testing the erasing of proof terms
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module ProofTerm4 where
postulate
D : Set
_≡_ : D → D → Set
A : D → D → D → D → Set
-- We can erase proof terms of type D → ⋯ → D → Set.
foo : ∀ x₁ x₂ x₃ x₄ → A x₁ x₂ x₃ x₄ → x₁ ≡ x₁
foo x₁ x₂ x₃ x₄ h = bar x₁
where
-- Since @bar@ is insidere a where clause, we erase the proof
-- term @h@.
postulate bar : ∀ x → x ≡ x
{-# ATP prove bar #-}
| {
"alphanum_fraction": 0.4242837653,
"avg_line_length": 29.32,
"ext": "agda",
"hexsha": "a9f2161d9ef1d523be2d54b3e8d132d9813860c4",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z",
"max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/apia",
"max_forks_repo_path": "test/Succeed/fol-theorems/ProofTerm4.agda",
"max_issues_count": 121,
"max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/apia",
"max_issues_repo_path": "test/Succeed/fol-theorems/ProofTerm4.agda",
"max_line_length": 78,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/apia",
"max_stars_repo_path": "test/Succeed/fol-theorems/ProofTerm4.agda",
"max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z",
"num_tokens": 203,
"size": 733
} |
-- Andreas, 2016-08-04, issue #964
-- Allow open metas and interaction points in imported files
-- {-# OPTIONS -v import:100 #-}
-- {-# OPTIONS -v meta.postulate:20 #-}
-- {-# OPTIONS -v tc.conv.level:50 #-}
open import Common.Level
open import Common.Equality
postulate something : Set₁
open import Common.Issue964.UnsolvedMetas something
test1 : Level
test1 = meta
test2 : (B : Set) → Set test1
test2 B = M.meta2 B
test3 = M.N.meta3
-- Should succeed
| {
"alphanum_fraction": 0.694143167,
"avg_line_length": 19.2083333333,
"ext": "agda",
"hexsha": "ddcec2704dbf4dee5abbcb9f0145e7ce7b00e5e1",
"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/Issue964.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/Issue964.agda",
"max_line_length": 60,
"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/Issue964.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": 136,
"size": 461
} |
module Sets.PredicateSet.Relations{ℓₗ}{ℓₒ} where
import Lvl
open import Functional
open import Logic.Propositional{ℓₗ Lvl.⊔ ℓₒ}
open import Logic.Predicate{ℓₗ}{ℓₒ}
open import Numeral.Finite
open import Numeral.Natural
import Relator.Equals
open import Sets.PredicateSet
open import Structure.Function.Domain
Empty : ∀{T} → PredSet{ℓₗ}{ℓₒ}(T) → Stmt
Empty(S) = (∀{x} → (x ∉' S)) where
_∉'_ = _∉_ {ℓₗ}{ℓₒ}
NonEmpty : ∀{T} → PredSet{ℓₗ}{ℓₒ}(T) → Stmt
NonEmpty(S) = ∃(x ↦ (x ∈' S)) where
_∈'_ = _∈_ {ℓₗ}{ℓₒ}
| {
"alphanum_fraction": 0.6724137931,
"avg_line_length": 26.1,
"ext": "agda",
"hexsha": "d5112736693e29ef5a497a6d9bc6f33a5394ad44",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "old/Sets/PredicateSet/Relations.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "old/Sets/PredicateSet/Relations.agda",
"max_line_length": 48,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "old/Sets/PredicateSet/Relations.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": 228,
"size": 522
} |
{-# OPTIONS --safe #-}
open import Definition.Typed.EqualityRelation
module Definition.LogicalRelation.Substitution.Introductions.IdPi {{eqrel : EqRelSet}} where
open EqRelSet {{...}}
open import Definition.Untyped as U hiding (wk)
open import Definition.Untyped.Properties
open import Definition.Typed
open import Definition.Typed.Properties
open import Definition.Typed.Weakening as T hiding (wk; wkTerm; wkEqTerm)
open import Definition.Typed.RedSteps
open import Definition.LogicalRelation
open import Definition.LogicalRelation.ShapeView
open import Definition.LogicalRelation.Irrelevance
open import Definition.LogicalRelation.Weakening
open import Definition.LogicalRelation.Properties
open import Definition.LogicalRelation.Application
open import Definition.LogicalRelation.Substitution
open import Definition.LogicalRelation.Substitution.Properties
open import Definition.LogicalRelation.Substitution.Irrelevance as S
open import Definition.LogicalRelation.Substitution.Reflexivity
open import Definition.LogicalRelation.Substitution.Introductions.Sigma
open import Definition.LogicalRelation.Substitution.Introductions.Fst
open import Definition.LogicalRelation.Substitution.Introductions.Snd
open import Definition.LogicalRelation.Substitution.Introductions.Pi
open import Definition.LogicalRelation.Substitution.Introductions.Lambda
open import Definition.LogicalRelation.Substitution.Introductions.Application
open import Definition.LogicalRelation.Substitution.Introductions.Cast
open import Definition.LogicalRelation.Substitution.Introductions.Id
open import Definition.LogicalRelation.Substitution.Introductions.IdUPiPi
open import Definition.LogicalRelation.Substitution.Introductions.Transp
open import Definition.LogicalRelation.Substitution.Introductions.SingleSubst
open import Definition.LogicalRelation.Substitution.MaybeEmbed
open import Definition.LogicalRelation.Substitution.Introductions.Universe
open import Definition.LogicalRelation.Substitution.Reduction
open import Definition.LogicalRelation.Substitution.Weakening
open import Definition.LogicalRelation.Substitution.Conversion
open import Definition.LogicalRelation.Substitution.ProofIrrelevance
open import Definition.LogicalRelation.Fundamental.Variable
open import Tools.Product
import Tools.PropositionalEquality as PE
abstract
Id-Πᵗᵛ : ∀ {A B rA lA lB l Γ t u} ([Γ] : ⊩ᵛ Γ)
→ lA ≤ l
→ lB ≤ l →
let [UA] = maybeEmbᵛ {A = Univ rA _} [Γ] (Uᵛ (proj₂ (levelBounded lA)) [Γ])
in
([A] : Γ ⊩ᵛ⟨ ∞ ⟩ A ^ [ rA , ι lA ] / [Γ])
([UB] : Γ ∙ A ^ [ rA , ι lA ] ⊩ᵛ⟨ ∞ ⟩ Univ ! lB ^ [ ! , next lB ] / [Γ] ∙ [A])
([A]ₜ : Γ ⊩ᵛ⟨ ∞ ⟩ A ∷ Univ rA lA ^ [ ! , next lA ] / [Γ] / [UA])
([B]ₜ : Γ ∙ A ^ [ rA , ι lA ] ⊩ᵛ⟨ ∞ ⟩ B ∷ Univ ! lB ^ [ ! , next lB ] / [Γ] ∙ [A] / (λ {Δ} {σ} → [UB] {Δ} {σ}))
([ΠAB] : Γ ⊩ᵛ⟨ ∞ ⟩ Π A ^ rA ° lA ▹ B ° lB ° l ^ [ ! , ι l ] / [Γ])
([t]ₜ : Γ ⊩ᵛ⟨ ∞ ⟩ t ∷ Π A ^ rA ° lA ▹ B ° lB ° l ^ [ ! , ι l ] / [Γ] / [ΠAB]) →
([u]ₜ : Γ ⊩ᵛ⟨ ∞ ⟩ u ∷ Π A ^ rA ° lA ▹ B ° lB ° l ^ [ ! , ι l ] / [Γ] / [ΠAB]) →
[ Γ ⊩ᵛ⟨ ∞ ⟩ Id (Π A ^ rA ° lA ▹ B ° lB ° l) t u ≡ Π A ^ rA ° lA ▹ (Id B ((wk1 t) ∘ (var 0) ^ l) ((wk1 u) ∘ (var 0) ^ l)) ° lB ° l ∷ SProp l ^ [ ! , next l ] / [Γ] ]
Id-Πᵗᵛ {A} {B} {rA} {lA} {lB} {l} {Γ} {t} {u} [Γ] lA≤ lB≤
[A] [UB] [A]ₜ [B]ₜ [ΠAB] [t]ₜ [u]ₜ =
let [SProp] = maybeEmbᵛ {A = Univ _ _} [Γ] (Uᵛ {rU = %} (proj₂ (levelBounded l)) [Γ])
[UA] = maybeEmbᵛ {A = Univ rA _} [Γ] (Uᵛ (proj₂ (levelBounded lA)) [Γ])
[ΓA] = _∙_ {A = A} [Γ] [A]
⊢AₜΔ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UA] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([A]ₜ ⊢Δ [σ]))
[B] = maybeEmbᵛ {A = B} [ΓA] (univᵛ {A = B} [ΓA] (≡is≤ PE.refl) (λ {Δ} {σ} → [UB] {Δ} {σ}) [B]ₜ)
⊢BΔ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UB] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([B]ₜ ⊢Δ [σ]))
⊢tΔ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([ΠAB] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([t]ₜ ⊢Δ [σ]))
⊢uΔ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([ΠAB] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([u]ₜ ⊢Δ [σ]))
Id-Π-res = λ A B → Π A ^ rA ° lA ▹ (Id B ((wk1 t) ∘ (var 0) ^ l ) ((wk1 u) ∘ (var 0) ^ l)) ° lB ° l
[liftσ] = λ {Δ} {σ} ⊢Δ [σ] → liftSubstS {F = A} {σ = σ} {Δ = Δ} [Γ] ⊢Δ [A] [σ]
⊢AΔ = λ {Δ} {σ} ⊢Δ [σ] → escape (proj₁ ([A] {Δ = Δ} {σ = σ} ⊢Δ [σ]))
[SPropB] = maybeEmbᵛ {A = SProp lB} [ΓA] (λ {Δ} {σ} → Uᵛ <next [ΓA] {Δ} {σ})
[wA] = wk1ᵛ {A = A} {F = A} [Γ] [A] [A]
[wΠ] = wk1ᵛ {A = Π A ^ rA ° lA ▹ B ° lB ° l} {F = A} [Γ] [A] [ΠAB]
[wt] = wk1Termᵛ {F = A} {G = Π A ^ rA ° lA ▹ B ° lB ° l} {t = t} [Γ] [A] [ΠAB] [t]ₜ
[wu] = wk1Termᵛ {F = A} {G = Π A ^ rA ° lA ▹ B ° lB ° l} {t = u} [Γ] [A] [ΠAB] [u]ₜ
[Id-Π] : Γ ⊩ᵛ Id (Π A ^ rA ° lA ▹ B ° lB ° l) t u ⇒ Id-Π-res A B ∷ SProp l ^ next l / [Γ]
[Id-Π] = λ {Δ} {σ} ⊢Δ [σ] →
PE.subst (λ ret → Δ ⊢ Id (Π (subst σ A) ^ rA ° lA ▹ (subst (liftSubst σ) B) ° lB ° l) (subst σ t) (subst σ u) ⇒ Π subst σ A ^ rA ° lA ▹ ret ° lB ° l ∷ SProp l ^ next l)
(PE.cong₂ (λ a b → Id (subst (liftSubst σ) B) (a ∘ (var 0) ^ l) (b ∘ (var 0) ^ l)) (PE.sym (Idsym-subst-lemma σ t)) (PE.sym (Idsym-subst-lemma σ u)))
(Id-Π {A = subst σ A} {rA} {lA} {lB} {l} {subst (liftSubst σ) B} {subst σ t} {subst σ u} lA≤ lB≤
(⊢AₜΔ {Δ} {σ} ⊢Δ [σ]) (⊢BΔ (⊢Δ ∙ ⊢AΔ {Δ} {σ} ⊢Δ [σ]) ([liftσ] {Δ} {σ} ⊢Δ [σ])) (⊢tΔ {Δ} {σ} ⊢Δ [σ]) (⊢uΔ {Δ} {σ} ⊢Δ [σ]))
[UB'] = maybeEmbᵛ {l = next lB} {A = U _} [ΓA] (λ {Δ} {σ} → Uᵛ <next [ΓA] {Δ} {σ})
[Id-Π-res] : Γ ⊩ᵛ⟨ ∞ ⟩ Id-Π-res A B ∷ SProp l ^ [ ! , next l ] / [Γ] / [SProp]
[Id-Π-res] = Πᵗᵛ {F = A} {G = Id B ((wk1 t) ∘ (var 0) ^ l) ((wk1 u) ∘ (var 0) ^ l)} lA≤ lB≤ [Γ] [A] (λ {Δ} {σ} → [SPropB] {Δ} {σ}) [A]ₜ
(Idᵗᵛ {A = B} {t = (wk1 t) ∘ (var 0) ^ l} {u = (wk1 u) ∘ (var 0) ^ l} [ΓA] [B]
(S.irrelevanceTerm′ {A = (wk1d B) [ var 0 ]} {A′ = B} {t = (wk1 t) ∘ (var 0) ^ l}
(wkSingleSubstId B) PE.refl [ΓA] [ΓA]
(substSΠ {wk1 A} {wk1d B} {var 0} [ΓA] [wA] [wΠ] (proj₂ (fundamentalVar here [ΓA]))) [B]
(appᵛ {F = wk1 A} {G = wk1d B} {t = wk1 t} {u = var 0} [ΓA] [wA] [wΠ] [wt] (proj₂ (fundamentalVar here [ΓA]))))
(S.irrelevanceTerm′ {A = (wk1d B) [ var 0 ]} {A′ = B} {t = (wk1 u) ∘ (var 0) ^ l}
(wkSingleSubstId B) PE.refl [ΓA] [ΓA]
(substSΠ {wk1 A} {wk1d B} {var 0} [ΓA] [wA] [wΠ] (proj₂ (fundamentalVar here [ΓA]))) [B]
(appᵛ {F = wk1 A} {G = wk1d B} {t = wk1 u} {u = var 0} [ΓA] [wA] [wΠ] [wu] (proj₂ (fundamentalVar here [ΓA]))))
(S.irrelevanceTerm {A = Univ _ _} {t = B} [ΓA] [ΓA] (λ {Δ} {σ} → [UB] {Δ} {σ}) (λ {Δ} {σ} → [UB'] {Δ} {σ}) [B]ₜ))
[id] , [eq] = redSubstTermᵛ {SProp l} {Id (Π A ^ rA ° lA ▹ B ° lB ° l) t u} {Id-Π-res A B}
[Γ] (λ {Δ} {σ} ⊢Δ [σ] → [Id-Π] {Δ} {σ} ⊢Δ [σ])
[SProp] [Id-Π-res]
in modelsTermEq [SProp] [id] [Id-Π-res] [eq]
| {
"alphanum_fraction": 0.5160118407,
"avg_line_length": 72.862745098,
"ext": "agda",
"hexsha": "0c2f1748784eac8508c6f1d709c97d32b5b5da1d",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z",
"max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "CoqHott/logrel-mltt",
"max_forks_repo_path": "Definition/LogicalRelation/Substitution/Introductions/IdPi.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "CoqHott/logrel-mltt",
"max_issues_repo_path": "Definition/LogicalRelation/Substitution/Introductions/IdPi.agda",
"max_line_length": 187,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "CoqHott/logrel-mltt",
"max_stars_repo_path": "Definition/LogicalRelation/Substitution/Introductions/IdPi.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z",
"num_tokens": 3233,
"size": 7432
} |
open import MJ.Types
import MJ.Classtable.Core as Core
import MJ.Classtable.Code as Code
import MJ.Syntax as Syntax
import MJ.Semantics.Values as Values
module MJ.Semantics {c}(Ct : Core.Classtable c)(ℂ : Code.Code Ct) where
-- functional big-step definitional interpreter
-- open import MJ.Semantics.Functional Σ ℂ
open import MJ.Semantics.Monadic Ct ℂ public
| {
"alphanum_fraction": 0.7884615385,
"avg_line_length": 28,
"ext": "agda",
"hexsha": "797e255adeef406c0150c9f1a4de710d30ffb7af",
"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/MJ/Semantics.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/MJ/Semantics.agda",
"max_line_length": 71,
"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/MJ/Semantics.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": 99,
"size": 364
} |
open import Data.Product using ( _,_ )
open import Relation.Nullary using ( yes ; no )
open import Relation.Unary using ( _∈_ )
open import Web.Semantic.DL.ABox.Interp using
( Interp ; _,_ ; ⌊_⌋ ; ind ; ind² ; Surjective ; surj ; ind⁻¹ ; surj✓ )
open import Web.Semantic.DL.ABox.Interp.Morphism using ( _≲_ ; _,_ ; ≲⌊_⌋ ; ≲-resp-ind ; _≋_ )
open import Web.Semantic.DL.Signature using ( Signature )
open import Web.Semantic.DL.TBox.Interp using ( interp ; _⊨_≈_ ; ≈-refl ; ≈-sym ; ≈-trans ; con ; rol ; con-≈ ; rol-≈ )
open import Web.Semantic.DL.TBox.Interp.Morphism using ( morph ; ≲-image ; ≲-resp-≈ ; ≲-resp-con ; ≲-resp-rol )
open import Web.Semantic.Util using ( _∘_ ; ExclMiddle₁ ; ExclMiddle ; smaller-excl-middle ; id ; □ ; is ; is! ; is✓ )
-- Note that this construction uses excluded middle
-- (for cardinality reasons, to embed a large set in a small set).
module Web.Semantic.DL.ABox.Interp.Meet ( excl-middle₁ : ExclMiddle₁ ) { Σ : Signature } { X : Set } where
-- This constructs the meet of a set of interpretations,
-- which is the greatest lower bound on surjective interpretations
meet : (Interp Σ X → Set) → Interp Σ X
meet Is =
( interp X
(λ x y → □ (is (excl-middle₁ (∀ I → (I ∈ Is) →
(⌊ I ⌋ ⊨ ind I x ≈ ind I y)))))
(λ {x} → is! (λ I I∈Is →
≈-refl ⌊ I ⌋))
(λ {x} {y} x≈y → is! (λ I I∈Is →
≈-sym ⌊ I ⌋ (is✓ x≈y I I∈Is)))
(λ {x} {y} {z} x≈y y≈z → is! (λ I I∈Is →
≈-trans ⌊ I ⌋ (is✓ x≈y I I∈Is) (is✓ y≈z I I∈Is)))
(λ c x → □ (is (excl-middle₁ (∀ I → (I ∈ Is) →
(ind I x ∈ con ⌊ I ⌋ c)))))
(λ r xy → □ (is (excl-middle₁ (∀ I → (I ∈ Is) →
ind² I xy ∈ rol ⌊ I ⌋ r))))
(λ {x} {y} c x∈c x≈y → is! (λ I I∈Is →
con-≈ ⌊ I ⌋ c (is✓ x∈c I I∈Is) (is✓ x≈y I I∈Is)))
(λ {w} {x} {y} {z} r w≈x xy∈r y≈z → is! (λ I I∈Is →
rol-≈ ⌊ I ⌋ r (is✓ w≈x I I∈Is) (is✓ xy∈r I I∈Is) (is✓ y≈z I I∈Is)))
, id )
-- meets are surjective
meet-surj : ∀ Is → (meet Is ∈ Surjective)
meet-surj Is = surj (λ x → (x , ≈-refl ⌊ meet Is ⌋))
-- meets are lower bounds
meet-lb : ∀ Is I → (I ∈ Is) → (meet Is ≲ I)
meet-lb Is I I∈Is =
( morph (ind I)
(λ x≈y → is✓ x≈y I I∈Is)
(λ x∈⟦c⟧ → is✓ x∈⟦c⟧ I I∈Is)
(λ xy∈⟦r⟧ → is✓ xy∈⟦r⟧ I I∈Is)
, λ x → ≈-refl ⌊ I ⌋ )
-- meets are greatest lower bounds on surjective interpretations
meet-glb : ∀ Is J → (J ∈ Surjective) → (∀ I → (I ∈ Is) → (J ≲ I)) → (J ≲ meet Is)
meet-glb Is J J∈Surj J≲Is =
( morph (ind⁻¹ J∈Surj)
(λ {x} {y} x≈y → is! (λ I I∈Is →
≈-trans ⌊ I ⌋ (≈-sym ⌊ I ⌋ (lemma I I∈Is x)) (≈-trans ⌊ I ⌋ (≲-resp-≈ ≲⌊ J≲Is I I∈Is ⌋ x≈y) (lemma I I∈Is y))))
(λ {c} {x} x∈⟦c⟧ → is! (λ I I∈Is →
con-≈ ⌊ I ⌋ c (≲-resp-con ≲⌊ J≲Is I I∈Is ⌋ x∈⟦c⟧) (lemma I I∈Is x)))
(λ {r} {x} {y} xy∈⟦r⟧ → is! (λ I I∈Is →
rol-≈ ⌊ I ⌋ r (≈-sym ⌊ I ⌋ (lemma I I∈Is x)) (≲-resp-rol ≲⌊ J≲Is I I∈Is ⌋ xy∈⟦r⟧) (lemma I I∈Is y)))
, λ x → is! (λ I I∈Is →
≈-trans ⌊ I ⌋ (≈-sym ⌊ I ⌋ (lemma I I∈Is (ind J x))) (≲-resp-ind (J≲Is I I∈Is) x)) ) where
lemma : ∀ I I∈Is x → ⌊ I ⌋ ⊨ ≲-image ≲⌊ J≲Is I I∈Is ⌋ x ≈ ind I (ind⁻¹ J∈Surj x)
lemma I I∈Is x =
≈-trans ⌊ I ⌋ (≲-resp-≈ ≲⌊ J≲Is I I∈Is ⌋ (surj✓ J∈Surj x))
(≲-resp-ind (J≲Is I I∈Is) (ind⁻¹ J∈Surj x))
-- Mediating morphisms for meets are unique
meet-uniq : ∀ Is (I : Interp Σ X) → (I ∈ Is) → (J≲₁I J≲₂I : meet Is ≲ I) → (J≲₁I ≋ J≲₂I)
meet-uniq Is I I∈Is J≲₁I J≲₂I x = ≈-trans ⌊ I ⌋ (≲-resp-ind J≲₁I x) (≈-sym ⌊ I ⌋ (≲-resp-ind J≲₂I x))
| {
"alphanum_fraction": 0.5143595635,
"avg_line_length": 44.0759493671,
"ext": "agda",
"hexsha": "af299768d38217f4624059823a438ad93decb5c1",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z",
"max_forks_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bblfish/agda-web-semantic",
"max_forks_repo_path": "src/Web/Semantic/DL/ABox/Interp/Meet.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057",
"max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bblfish/agda-web-semantic",
"max_issues_repo_path": "src/Web/Semantic/DL/ABox/Interp/Meet.agda",
"max_line_length": 119,
"max_stars_count": 9,
"max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/agda-web-semantic",
"max_stars_repo_path": "src/Web/Semantic/DL/ABox/Interp/Meet.agda",
"max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z",
"num_tokens": 1783,
"size": 3482
} |
{-# OPTIONS --cubical --no-import-sorts #-}
module MorePropAlgebra.Structures where
open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero)
private
variable
ℓ ℓ' ℓ'' : Level
open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc)
open import Cubical.Relation.Nullary.Base renaming (¬_ to ¬ᵗ_)-- ¬ᵗ_
open import Cubical.Relation.Binary.Base
open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_)
open import Cubical.Data.Sigma renaming (_×_ to infixr 4 _×_)
open import Cubical.Data.Empty renaming (elim to ⊥-elim; ⊥ to ⊥⊥) -- `⊥` and `elim`
open import Function.Base using (_∋_; _$_)
open import Cubical.Foundations.Function
-- open import Function.Reasoning using (∋-syntax)
open import Cubical.Foundations.Logic renaming
( inl to inlᵖ
; inr to inrᵖ
; _⇒_ to infixr 0 _⇒_ -- shifting by -6
; _⇔_ to infixr -2 _⇔_ --
; ∃[]-syntax to infix -4 ∃[]-syntax --
; ∃[∶]-syntax to infix -4 ∃[∶]-syntax --
; ∀[∶]-syntax to infix -4 ∀[∶]-syntax --
; ∀[]-syntax to infix -4 ∀[]-syntax --
)
open import Utils
open import MoreLogic.Reasoning
open import MoreLogic.Definitions renaming
( _ᵗ⇒_ to infixr 0 _ᵗ⇒_
; ∀ᵖ[∶]-syntax to infix -4 ∀ᵖ[∶]-syntax
; ∀ᵖ〚∶〛-syntax to infix -4 ∀ᵖ〚∶〛-syntax
; ∀ᵖ!〚∶〛-syntax to infix -4 ∀ᵖ!〚∶〛-syntax
; ∀〚∶〛-syntax to infix -4 ∀〚∶〛-syntax
)
open import MoreLogic.Properties
open import MorePropAlgebra.Definitions hiding (_≤''_)
open import MorePropAlgebra.Consequences
-- taken from the cubical standard library and adapted to hProps:
-- IsSemigroup
-- IsMonoid
-- IsGroup
-- IsAbGroup
-- IsRing
-- IsCommRing
record IsSemigroup {A : Type ℓ} (_·_ : A → A → A) : Type ℓ where
constructor issemigroup
field
is-set : [ isSetᵖ A ]
is-assoc : ∀ x y z → x · (y · z) ≡ (x · y) · z
_ : [ isSetᵖ A ]; _ = is-set
_ : [ isAssociativeˢ _·_ is-set ]; _ = is-assoc
isSemigroup : {A : Type ℓ} (_·_ : A → A → A) → hProp ℓ
isSemigroup _·_ .fst = IsSemigroup _·_
isSemigroup _·_ .snd (issemigroup a₀ b₀) (issemigroup a₁ b₁) = φ where
abstract φ = λ i → let is-set = isSetIsProp a₀ a₁ i in issemigroup is-set (snd (isAssociativeˢ _·_ is-set) b₀ b₁ i)
record IsMonoid {A : Type ℓ} (ε : A) (_·_ : A → A → A) : Type ℓ where
constructor ismonoid
field
is-Semigroup : [ isSemigroup _·_ ]
is-identity : ∀ x → (x · ε ≡ x) × (ε · x ≡ x)
open IsSemigroup is-Semigroup public
_ : [ isSemigroup _·_ ]; _ = is-Semigroup
_ : [ isIdentityˢ _·_ is-set ε ]; _ = is-identity
is-lid : (x : A) → ε · x ≡ x
is-lid x = is-identity x .snd
is-rid : (x : A) → x · ε ≡ x
is-rid x = is-identity x .fst
isMonoid : {A : Type ℓ} (ε : A) (_·_ : A → A → A) → hProp ℓ
isMonoid ε _·_ .fst = IsMonoid ε _·_
isMonoid ε _·_ .snd (ismonoid a₀ b₀) (ismonoid a₁ b₁) = φ where
abstract φ = λ i → let is-Semigroup = snd (isSemigroup _·_) a₀ a₁ i
is-set = IsSemigroup.is-set is-Semigroup
in ismonoid is-Semigroup (snd (isIdentityˢ _·_ is-set ε) b₀ b₁ i)
record IsGroup {G : Type ℓ} (0g : G) (_+_ : G → G → G) (-_ : G → G) : Type ℓ where
constructor isgroup
field
is-Monoid : [ isMonoid 0g _+_ ]
is-inverse : ∀ x → (x + (- x) ≡ 0g) × ((- x) + x ≡ 0g)
open IsMonoid is-Monoid public
_ : [ isMonoid 0g _+_ ]; _ = is-Monoid
_ : [ isInverseˢ is-set 0g _+_ -_ ]; _ = is-inverse
infixl 6 _-_
_-_ : G → G → G
x - y = x + (- y)
is-invl : (x : G) → (- x) + x ≡ 0g
is-invl x = is-inverse x .snd
is-invr : (x : G) → x + (- x) ≡ 0g
is-invr x = is-inverse x .fst
isGroup : {G : Type ℓ} (0g : G) (_+_ : G → G → G) (-_ : G → G) → hProp ℓ
isGroup 0g _+_ -_ .fst = IsGroup 0g _+_ -_
isGroup 0g _+_ -_ .snd (isgroup a₀ b₀) (isgroup a₁ b₁) = φ where
abstract φ = λ i → let is-Monoid = snd (isMonoid 0g _+_) a₀ a₁ i
is-set = IsMonoid.is-set is-Monoid
in isgroup is-Monoid (snd (isInverseˢ is-set 0g _+_ -_) b₀ b₁ i)
record IsAbGroup {G : Type ℓ} (0g : G) (_+_ : G → G → G) (-_ : G → G) : Type ℓ where
constructor isabgroup
field
is-Group : [ isGroup 0g _+_ -_ ]
is-comm : ∀ x y → x + y ≡ y + x
open IsGroup is-Group public
_ : [ isGroup 0g _+_ (-_) ]; _ = is-Group
_ : [ isCommutativeˢ _+_ is-set ]; _ = is-comm
isAbGroup : {G : Type ℓ} (0g : G) (_+_ : G → G → G) (-_ : G → G) → hProp ℓ
isAbGroup 0g _+_ -_ .fst = IsAbGroup 0g _+_ -_
isAbGroup 0g _+_ -_ .snd (isabgroup a₀ b₀) (isabgroup a₁ b₁) = φ where
abstract φ = λ i → let is-Group = snd (isGroup 0g _+_ -_) a₀ a₁ i
is-set = IsGroup.is-set is-Group
in isabgroup is-Group (snd (isCommutativeˢ _+_ is-set) b₀ b₁ i)
record IsSemiring {R : Type ℓ} (0r 1r : R) (_+_ _·_ : R → R → R) : Type ℓ where
constructor issemiring
field
+-Monoid : [ isMonoid 0r _+_ ]
·-Monoid : [ isMonoid 1r _·_ ]
+-comm : ∀ x y → x + y ≡ y + x
is-dist : ∀ x y z → (x · (y + z) ≡ (x · y) + (x · z)) × ((x + y) · z ≡ (x · z) + (y · z))
open IsMonoid +-Monoid public
renaming
( is-assoc to +-assoc
; is-identity to +-identity
; is-lid to +-lid
; is-rid to +-rid
; is-Semigroup to +-Semigroup )
open IsMonoid ·-Monoid hiding (is-set) public
renaming
( is-assoc to ·-assoc
; is-identity to ·-identity
; is-lid to ·-lid
; is-rid to ·-rid
; is-Semigroup to ·-Semigroup )
_ : [ isMonoid 0r _+_ ]; _ = +-Monoid
_ : [ isMonoid 1r _·_ ]; _ = ·-Monoid
_ : [ isCommutativeˢ _+_ is-set ]; _ = +-comm
_ : [ isDistributiveˢ is-set _+_ _·_ ]; _ = is-dist
isSemiring : {R : Type ℓ} (0r 1r : R) (_+_ _·_ : R → R → R) → hProp ℓ
isSemiring 0r 1r _+_ _·_ .fst = IsSemiring 0r 1r _+_ _·_
isSemiring 0r 1r _+_ _·_ .snd (issemiring a₀ b₀ c₀ d₀) (issemiring a₁ b₁ c₁ d₁) = φ where
abstract φ = λ i → let +-Monoid = snd (isMonoid 0r _+_) a₀ a₁ i
·-Monoid = snd (isMonoid 1r _·_) b₀ b₁ i
is-set = IsMonoid.is-set +-Monoid
+-comm = snd (isCommutativeˢ _+_ is-set) c₀ c₁ i
is-dist = snd (isDistributiveˢ is-set _+_ _·_) d₀ d₁ i
in issemiring +-Monoid ·-Monoid +-comm is-dist
record IsCommSemiring {R : Type ℓ} (0r 1r : R) (_+_ _·_ : R → R → R) : Type ℓ where
constructor iscommsemiring
field
is-Semiring : [ isSemiring 0r 1r _+_ _·_ ]
·-comm : ∀ x y → x · y ≡ y · x
open IsSemiring is-Semiring public
_ : [ isSemiring 0r 1r _+_ _·_ ]; _ = is-Semiring
_ : [ isCommutativeˢ _+_ is-set ]; _ = +-comm
isCommSemiring : {R : Type ℓ} (0r 1r : R) (_+_ _·_ : R → R → R) → hProp ℓ
isCommSemiring 0r 1r _+_ _·_ .fst = IsCommSemiring 0r 1r _+_ _·_
isCommSemiring 0r 1r _+_ _·_ .snd (iscommsemiring a₀ b₀) (iscommsemiring a₁ b₁) = φ where
abstract φ = λ i → let is-Semiring = snd (isSemiring 0r 1r _+_ _·_) a₀ a₁ i
is-set = IsSemiring.is-set is-Semiring
·-comm = snd (isCommutativeˢ _·_ is-set) b₀ b₁ i
in iscommsemiring is-Semiring ·-comm
record IsRing {R : Type ℓ} (0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R) : Type ℓ where
constructor isring
field
+-AbGroup : [ isAbGroup 0r _+_ -_ ]
·-Monoid : [ isMonoid 1r _·_ ]
is-dist : ∀ x y z → (x · (y + z) ≡ (x · y) + (x · z)) × ((x + y) · z ≡ (x · z) + (y · z))
open IsAbGroup +-AbGroup using (is-set) public
_ : [ isAbGroup 0r _+_ -_ ]; _ = +-AbGroup
_ : [ isMonoid 1r _·_ ]; _ = ·-Monoid
_ : [ isDistributiveˢ is-set _+_ _·_ ]; _ = is-dist
open IsAbGroup +-AbGroup hiding (is-set) public
renaming
( is-assoc to +-assoc
; is-identity to +-identity
; is-lid to +-lid
; is-rid to +-rid
; is-inverse to +-inv
; is-invl to +-linv
; is-invr to +-rinv
; is-comm to +-comm
; is-Semigroup to +-Semigroup
; is-Monoid to +-Monoid
; is-Group to +-Group )
open IsMonoid ·-Monoid hiding (is-set) public
renaming
( is-assoc to ·-assoc
; is-identity to ·-identity
; is-lid to ·-lid
; is-rid to ·-rid
; is-Semigroup to ·-Semigroup )
·-rdist-+ : (x y z : R) → x · (y + z) ≡ (x · y) + (x · z)
·-rdist-+ x y z = is-dist x y z .fst
·-ldist-+ : (x y z : R) → (x + y) · z ≡ (x · z) + (y · z)
·-ldist-+ x y z = is-dist x y z .snd
-- TODO: prove these somewhere
-- zero-lid : (x : R) → 0r · x ≡ 0r
-- zero-lid x = zero x .snd
-- zero-rid : (x : R) → x · 0r ≡ 0r
-- zero-rid x = zero x .fst
isRing : {R : Type ℓ} (0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R) → hProp ℓ
isRing 0r 1r _+_ _·_ -_ .fst = IsRing 0r 1r _+_ _·_ -_
isRing 0r 1r _+_ _·_ -_ .snd (isring a₀ b₀ c₀) (isring a₁ b₁ c₁) = φ where
abstract φ = λ i → let +-AbGroup = snd (isAbGroup 0r _+_ -_) a₀ a₁ i
·-Monoid = snd (isMonoid 1r _·_) b₀ b₁ i
is-set = IsAbGroup.is-set +-AbGroup
is-dist = snd (isDistributiveˢ is-set _+_ _·_) c₀ c₁ i
in isring +-AbGroup ·-Monoid is-dist
record IsCommRing {R : Type ℓ} (0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R) : Type ℓ where
constructor iscommring
field
is-Ring : [ isRing 0r 1r _+_ _·_ -_ ]
·-comm : ∀ x y → x · y ≡ y · x
open IsRing is-Ring public
_ : [ isRing 0r 1r _+_ _·_ (-_) ]; _ = is-Ring
_ : [ isCommutativeˢ _·_ is-set ]; _ = ·-comm
isCommRing : {R : Type ℓ} (0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R) → hProp ℓ
isCommRing 0r 1r _+_ _·_ -_ .fst = IsCommRing 0r 1r _+_ _·_ -_
isCommRing 0r 1r _+_ _·_ -_ .snd (iscommring a₀ b₀) (iscommring a₁ b₁) = φ where
abstract φ = λ i → let is-Ring = snd (isRing 0r 1r _+_ _·_ -_) a₀ a₁ i
is-set = IsRing.is-set is-Ring
·-comm = snd (isCommutativeˢ _·_ is-set) b₀ b₁ i
in iscommring is-Ring ·-comm
-- 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.
record IsClassicalField {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_⁻¹ : (x : F) → {{ ! [ ¬'(x ≡ 0f) ] }} → F) : Type ℓ where
constructor isclassicalfield
field
is-set : [ isSetᵖ F ]
is-CommRing : [ isCommRing 0f 1f _+_ _·_ -_ ]
-- WARNING: this is not directly Booij's definition, since Booij does not talk about an inverse operation `_⁻¹`
-- we need to somehow obtain this operation
·-inv : [ isNonzeroInverseˢ' is-set 0f 1f _·_ _⁻¹ ] -- classical version of `isNonzeroInverse`
·-linv : (x : F) {{ p : ! [ ¬' (x ≡ 0f) ] }} → ((x ⁻¹) · x) ≡ 1f -- wow, uses `p` already in `⁻¹`
·-linv x {{p}} = snd (·-inv x)
·-rinv : (x : F) {{ p : ! [ ¬' (x ≡ 0f) ] }} → (x · (x ⁻¹)) ≡ 1f
·-rinv x {{p}} = fst (·-inv x)
open IsCommRing is-CommRing hiding (is-set) public
isClassicalField : {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_⁻¹ : (x : F) → {{ ! [ ¬'(x ≡ 0f) ] }} → F) → hProp ℓ
isClassicalField 0f 1f _+_ _·_ -_ _⁻¹ .fst = IsClassicalField 0f 1f _+_ _·_ -_ _⁻¹
isClassicalField 0f 1f _+_ _·_ -_ _⁻¹ .snd (isclassicalfield a₀ b₀ c₀) (isclassicalfield a₁ b₁ c₁) = φ where
abstract φ = λ i → let is-set = isSetIsProp a₀ a₁ i in isclassicalfield is-set (snd (isCommRing 0f 1f _+_ _·_ -_) b₀ b₁ i) (snd (isNonzeroInverseˢ' is-set 0f 1f _·_ _⁻¹) c₀ c₁ i)
-- 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 tight, i.e. ¬(x # y) ⇒ x = y;
-- 4. + is #-extensional, that is, for all w, x, y, z : F
-- w + x # y + z ⇒ w # y ∨ x # z.
record IsConstructiveField {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_#_ : hPropRel F F ℓ') {- (_⁻¹ : (x : F) → {{[ x # 0f ]}} → F) -} : Type (ℓ-max ℓ ℓ') where
constructor isconstructivefield
field
is-CommRing : [ isCommRing 0f 1f _+_ _·_ -_ ]
open IsCommRing is-CommRing using (is-set)
field
·-inv'' : ∀ x → [ (∃[ y ] [ is-set ] x · y ≡ˢ 1f) ⇔ x # 0f ]
-- these should follow:
-- ·-inv : [ isNonzeroInverseˢ is-set 0f 1f _·_ _#_ _⁻¹ ]
-- ·-invnz : [ isInverseNonzeroˢ is-set 0f 1f _·_ _#_ ]
-- ·-inv-back : ∀ x y → (x · y ≡ 1f) → [ x # 0f ] × [ y # 0f ]
+-#-ext : ∀ w x y z → [ (w + x) # (y + z) ] → [ (w # y) ⊔ (x # z) ]
#-tight : ∀ a b → [ ¬(a # b) ] → a ≡ b
-- #-ApartnessRel : [ isApartnessRel _#_ ]
--
-- ·-linv : (x : F) {{ p : [ x # 0f ] }} → ((x ⁻¹) · x) ≡ 1f -- wow, uses `p` already in `⁻¹`
-- ·-linv x {{p}} = snd (·-inv x)
--
-- ·-rinv : (x : F) {{ p : [ x # 0f ] }} → (x · (x ⁻¹)) ≡ 1f
-- ·-rinv x {{p}} = fst (·-inv x)
_ : [ isCommRing 0f 1f _+_ _·_ -_ ]; _ = is-CommRing
_ : [ isNonzeroInverseˢ'' is-set 0f 1f _·_ _#_ ]; _ = ·-inv''
_ : [ is-+-#-Extensional _+_ _#_ ]; _ = +-#-ext
_ : [ isTightˢ''' _#_ is-set ]; _ = #-tight
open IsCommRing is-CommRing hiding (is-set) public
-- open IsApartnessRelᵖ isApartnessRel public
-- renaming
-- ( isIrrefl to #-irrefl
-- ; isSym to #-sym
-- ; isCotrans to #-cotrans )
isConstructiveField : {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_#_ : hPropRel F F ℓ') {- (_⁻¹ : (x : F) → {{[ x # 0f ]}} → F) -} → hProp (ℓ-max ℓ ℓ')
isConstructiveField 0f 1f _+_ _·_ -_ _#_ {- _⁻¹ -} .fst = IsConstructiveField 0f 1f _+_ _·_ -_ _#_ {- _⁻¹ -}
isConstructiveField 0f 1f _+_ _·_ -_ _#_ {- _⁻¹ -} .snd (isconstructivefield a₀ b₀ c₀ d₀) (isconstructivefield a₁ b₁ c₁ d₁) = φ where
abstract φ = λ i → let is-CommRing = snd (isCommRing 0f 1f _+_ _·_ -_) a₀ a₁ i
is-set = IsCommRing.is-set is-CommRing
in isconstructivefield is-CommRing (snd (isNonzeroInverseˢ'' is-set 0f 1f _·_ _#_) b₀ b₁ i) (snd (is-+-#-Extensional _+_ _#_) c₀ c₁ i) (snd (isTightˢ''' _#_ is-set) d₀ d₁ i)
-- 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,
-- max(x, y) = x ∨ max(x, y) = y,
-- which would hold in a linear order.
-- However, in Lemma 6.7.1 we characterize max as
-- z < max(x, y) ⇔ z < x ∨ z < y,
-- and similarly for min.
-- 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 existence of all binary joins and meets.
-- NOTE: in the non-cubical standard library, we have
--
-- record IsLattice (∨ ∧ : Op₂ A) : Set (a ⊔ ℓ) where
-- field
-- ∨-comm : Commutative ∨ -- ∀ x y → (x ∨ y) ≈ (y ∨ x)
-- ∨-assoc : Associative ∨ -- ∀ x y z → ((x ∨ y) ∨ z) ≈ (x ∨ (y ∨ z))
-- ∨-cong : Congruent₂ ∨ -- ∀ x y u v → x ≈ y → u ≈ v → (x ∨ u) ≈ (y ∨ v)
-- ∧-comm : Commutative ∧ -- ∀ x y → (x ∧ y) ≈ (y ∧ x)
-- ∧-assoc : Associative ∧ -- ∀ x y z → ((x ∧ y) ∧ z) ≈ (x ∧ (y ∧ z))
-- ∧-cong : Congruent₂ ∧ -- ∀ x y u v → x ≈ y → u ≈ v → (x ∧ u) ≈ (y ∧ v)
-- absorptive : Absorptive ∨ ∧ -- ∀ x y → ((x ∨ (x ∧ y)) ≈ x) × ((x ∧ (x ∨ y)) ≈ x)
--
-- where they derive
--
-- ∨-absorbs-∧ : ∨ Absorbs ∧
-- ∨-absorbs-∧ = proj₁ absorptive
--
-- ∧-absorbs-∨ : ∧ Absorbs ∨
-- ∧-absorbs-∨ = proj₂ absorptive
--
-- ∧-congˡ : LeftCongruent ∧
-- ∧-congˡ y≈z = ∧-cong refl y≈z
--
-- ∧-congʳ : RightCongruent ∧
-- ∧-congʳ y≈z = ∧-cong y≈z refl
--
-- ∨-congˡ : LeftCongruent ∨
-- ∨-congˡ y≈z = ∨-cong refl y≈z
--
-- ∨-congʳ : RightCongruent ∨
-- ∨-congʳ y≈z = ∨-cong y≈z refl
--
-- and additionally we might also proof Lemma 6.7.1 and Lemma 2.6.20 (as mentioned in the remark above)
-- maybe we can proof from a linearorder that we have MinTrichtotomy and MaxTrichtotomy
record IsLattice {A : Type ℓ} (_≤_ : hPropRel A A ℓ') (min max : A → A → A) : Type (ℓ-max ℓ ℓ') where
constructor islattice
field
≤-PartialOrder : [ isPartialOrder _≤_ ]
is-min : ∀ x y z → [ z ≤ (min x y) ⇔ z ≤ x ⊓ z ≤ y ]
is-max : ∀ x y z → [ (max x y) ≤ z ⇔ x ≤ z ⊓ y ≤ z ]
-- glb : ∀ x y z → z ≤ min x y → z ≤ x × z ≤ y
-- glb-back : ∀ x y z → z ≤ x × z ≤ y → z ≤ min x y
-- lub : ∀ x y z → max x y ≤ z → x ≤ z × y ≤ z
-- lub-back : ∀ x y z → x ≤ z × y ≤ z → max x y ≤ z
_ : [ isPartialOrder _≤_ ]; _ = ≤-PartialOrder
_ : [ isMin _≤_ min ]; _ = is-min
_ : [ isMax _≤_ max ]; _ = is-max
open IsPartialOrder ≤-PartialOrder public
renaming
( is-refl to ≤-refl
; is-antisym to ≤-antisym
; is-trans to ≤-trans )
isLattice : {A : Type ℓ} (_≤_ : hPropRel A A ℓ') (min max : A → A → A) → hProp (ℓ-max ℓ ℓ')
isLattice _≤_ min max .fst = IsLattice _≤_ min max
isLattice _≤_ min max .snd (islattice a₀ b₀ c₀) (islattice a₁ b₁ c₁) = φ where
abstract φ = λ i → islattice (snd (isPartialOrder _≤_) a₀ a₁ i) (snd (isMin _≤_ min) b₀ b₁ i) (snd (isMax _≤_ max) c₀ c₁ i)
-- 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 [partial] 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].
-- NOTE: well, the HOTT book definition organizes things slightly different. Why prefer one approach over the other?
record IsAlmostPartiallyOrderedField {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_<_ : hPropRel F F ℓ') (min max : F → F → F) {- (_⁻¹ᶠ : (x : F) → {{x # 0f}} → F) -} : Type (ℓ-max ℓ ℓ') where
constructor isalmostpartiallyorderedfield
infixl 4 _#_
infixl 4 _≤_
-- ≤, as in Lemma 4.1.7
_≤_ : hPropRel F F ℓ'
x ≤ y = ¬ (y < x)
field
-- 1.
is-CommRing : [ isCommRing 0f 1f _+_ _·_ -_ ]
-- 2.
<-StrictPartialOrder : [ isStrictPartialOrder _<_ ]
open IsCommRing is-CommRing public
open IsStrictPartialOrder <-StrictPartialOrder public
renaming
( is-irrefl to <-irrefl
; is-trans to <-trans
; is-cotrans to <-cotrans )
<-asym : [ isAsym _<_ ]
<-asym = irrefl+trans⇒asym _<_ <-irrefl <-trans
-- # is defined as in Lemma 4.1.7
_#_ : hPropRel F F ℓ'
x # y = [ <-asym x y ] (x < y) ⊎ᵖ (y < x)
field
-- 3.
·-inv'' : ∀ x → [ (∃[ y ] [ is-set ] x · y ≡ˢ 1f) ⇔ x # 0f ]
-- ·-rinv : (x : F) → (p : x # 0f) → x · (_⁻¹ᶠ x {{p}}) ≡ 1f
-- ·-linv : (x : F) → (p : x # 0f) → (_⁻¹ᶠ x {{p}}) · x ≡ 1f
-- ·-inv-back : (x y : F) → (x · y ≡ 1f) → x # 0f × y # 0f
-- 4. NOTE: we already have ≤-isPartialOrder in ≤-isLattice
-- ≤-isPartialOrder : IsPartialOrder _≤_
-- 5.
≤-Lattice : [ isLattice _≤_ min max ]
_ : isSet F ; _ = is-set
_ : [ isCommRing 0f 1f _+_ _·_ (-_) ]; _ = is-CommRing
_ : [ isStrictPartialOrder _<_ ]; _ = <-StrictPartialOrder
_ : [ isNonzeroInverseˢ'' is-set 0f 1f _·_ _#_ ]; _ = ·-inv''
_ : [ isLattice _≤_ min max ]; _ = ≤-Lattice
open IsLattice ≤-Lattice renaming (≤-antisym to ≤-antisymᵗ) public
≤-antisym : [ isAntisymˢ _≤_ is-set ]
≤-antisym = isAntisymˢ⇔isAntisym _≤_ is-set .snd ≤-antisymᵗ
isAlmostPartiallyOrderedField : {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_<_ : hPropRel F F ℓ') (min max : F → F → F) {- (_⁻¹ᶠ : (x : F) → {{x # 0f}} → F) -} → hProp (ℓ-max ℓ ℓ')
isAlmostPartiallyOrderedField {ℓ = ℓ} {ℓ' = ℓ'} {F = F} 0f 1f _+_ _·_ -_ _<_ min max {- _⁻¹ -} .fst = IsAlmostPartiallyOrderedField 0f 1f _+_ _·_ -_ _<_ min max {- _⁻¹ -}
isAlmostPartiallyOrderedField {ℓ = ℓ} {ℓ' = ℓ'} {F = F} 0f 1f _+_ _·_ -_ _<_ min max {- _⁻¹ -} .snd (isalmostpartiallyorderedfield a₀ b₀ c₀ d₀) (isalmostpartiallyorderedfield a₁ b₁ c₁ d₁) = φ where
abstract φ = λ i → let -- we are doing basically "the same" as in `IsAlmostPartiallyOrderedField`
_≤_ : hPropRel F F ℓ'
x ≤ y = ¬ (y < x) -- ≤, as in Lemma 4.1.7
is-CommRing = snd (isCommRing 0f 1f _+_ _·_ -_) a₀ a₁ i
is-set = IsCommRing.is-set is-CommRing
<-StrictPartialOrder = snd (isStrictPartialOrder _<_) b₀ b₁ i
open IsStrictPartialOrder <-StrictPartialOrder
renaming
( is-irrefl to <-irrefl
; is-trans to <-trans
; is-cotrans to <-cotrans )
<-asym : [ isAsym _<_ ]
<-asym = irrefl+trans⇒asym _<_ <-irrefl <-trans
_#_ : hPropRel F F ℓ'
x # y = [ <-asym x y ] (x < y) ⊎ᵖ (y < x) -- # is defined as in Lemma 4.1.7
·-inv'' = snd (isNonzeroInverseˢ'' is-set 0f 1f _·_ _#_) c₀ c₁ i
≤-isLattice = snd (isLattice _≤_ min max) d₀ d₁ i
in isalmostpartiallyorderedfield is-CommRing <-StrictPartialOrder ·-inv'' ≤-isLattice
record IsPartiallyOrderedField {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_<_ : hPropRel F F ℓ') (min max : F → F → F) {- (_⁻¹ᶠ : (x : F) → {{x # 0f}} → F) -} : Type (ℓ-max ℓ ℓ') where
constructor ispartiallyorderedfield
field
-- 1. 2. 3. 4. 5.
is-AlmostPartiallyOrderedField : [ isAlmostPartiallyOrderedField 0f 1f _+_ _·_ -_ _<_ min max {- _⁻¹ᶠ -} ]
-- 6. (†)
+-<-ext : ∀ w x y z → [ (w + x) < (y + z) ] → [ (w < y) ⊔ (x < z) ]
-- 6. (∗)
·-preserves-< : ∀ x y z → [ 0f < z ] → [ x < y ] → [ (x · z) < (y · z) ]
_ : [ isAlmostPartiallyOrderedField 0f 1f _+_ _·_ -_ _<_ min max ]; _ = is-AlmostPartiallyOrderedField
_ : [ is-+-<-Extensional _+_ _<_ ]; _ = +-<-ext
_ : [ operation _·_ preserves _<_ when (λ z → 0f < z) ]; _ = ·-preserves-<
open IsAlmostPartiallyOrderedField is-AlmostPartiallyOrderedField public
isPartiallyOrderedField : {F : Type ℓ} (0f 1f : F) (_+_ _·_ : F → F → F) (-_ : F → F) (_<_ : hPropRel F F ℓ') (min max : F → F → F) {- (_⁻¹ᶠ : (x : F) → {{x # 0f}} → F) -} → hProp (ℓ-max ℓ ℓ')
isPartiallyOrderedField 0f 1f _+_ _·_ -_ _<_ min max {- _⁻¹ -} .fst = IsPartiallyOrderedField 0f 1f _+_ _·_ -_ _<_ min max {- _⁻¹ -}
isPartiallyOrderedField 0f 1f _+_ _·_ -_ _<_ min max {- _⁻¹ -} .snd (ispartiallyorderedfield a₀ b₀ c₀) (ispartiallyorderedfield a₁ b₁ c₁) = φ where
abstract φ = λ i → ispartiallyorderedfield (snd (isAlmostPartiallyOrderedField 0f 1f _+_ _·_ -_ _<_ min max {- _⁻¹ᶠ -}) a₀ a₁ i) (snd (is-+-<-Extensional _+_ _<_) b₀ b₁ i) (snd (operation _·_ preserves _<_ when (λ z → 0f < z)) c₀ c₁ i)
| {
"alphanum_fraction": 0.5265869744,
"avg_line_length": 45.3457943925,
"ext": "agda",
"hexsha": "e8a91d935ad147c40ca085025f5206209c0a581f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mchristianl/synthetic-reals",
"max_forks_repo_path": "agda/MorePropAlgebra/Structures.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mchristianl/synthetic-reals",
"max_issues_repo_path": "agda/MorePropAlgebra/Structures.agda",
"max_line_length": 237,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mchristianl/synthetic-reals",
"max_stars_repo_path": "agda/MorePropAlgebra/Structures.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": 9836,
"size": 24260
} |
-- Occurs there are several ways to parse an operator application.
module AmbiguousParseForApplication where
postulate
X : Set
if_then_else_ : X -> X -> X -> X
if_then_ : X -> X -> X
bad : X -> X
bad x = if x then if x then x else x
| {
"alphanum_fraction": 0.6254826255,
"avg_line_length": 21.5833333333,
"ext": "agda",
"hexsha": "9ed51f5578e21819d7ff7d5f6c2397eb6b2c82d7",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/AmbiguousParseForApplication.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/AmbiguousParseForApplication.agda",
"max_line_length": 66,
"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/AmbiguousParseForApplication.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": 75,
"size": 259
} |
module SafeFlagPrimTrustMe-2 where
open import Agda.Builtin.TrustMe
| {
"alphanum_fraction": 0.8550724638,
"avg_line_length": 17.25,
"ext": "agda",
"hexsha": "6e0a8288cd022a25b7fbdc5ce290e5ed804bbd49",
"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/SafeFlagPrimTrustMe-2.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/SafeFlagPrimTrustMe-2.agda",
"max_line_length": 34,
"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/SafeFlagPrimTrustMe-2.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 20,
"size": 69
} |
-- Andreas, 2015-09-09 Issue 1643
-- {-# OPTIONS -v tc.mod.apply:20 #-}
-- {-# OPTIONS -v scope:50 -v scope.inverse:100 -v interactive.meta:20 #-}
module _ where
module M where
postulate A : Set
module N = M -- This alias used to introduce a display form M.A --> N.A
open M
postulate
a : A
test : Set
test = a
-- Error WAS: N.A !=< Set of type Set
-- SHOULD BE: A !=< Set of type Set
{-
ScopeInfo
current = ModuleAlias
context = TopCtx
modules
scope
scope ModuleAlias
private
names
A --> [ModuleAlias.M.A]
public
modules
M --> [ModuleAlias.M]
N --> [ModuleAlias.N]
scope ModuleAlias.M
public
names
A --> [ModuleAlias.M.A]
scope ModuleAlias.N
public
names
A --> [ModuleAlias.N.A]
-}
| {
"alphanum_fraction": 0.5648484848,
"avg_line_length": 17.9347826087,
"ext": "agda",
"hexsha": "271cb50381bc50ec1755ddbea4cf88e1a6a81584",
"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/Issue1643.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/Issue1643.agda",
"max_line_length": 74,
"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/Issue1643.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": 238,
"size": 825
} |
{-# OPTIONS --safe #-}
module Cubical.Algebra.OrderedCommMonoid where
open import Cubical.Algebra.OrderedCommMonoid.Base public
open import Cubical.Algebra.OrderedCommMonoid.Properties public
| {
"alphanum_fraction": 0.8341968912,
"avg_line_length": 32.1666666667,
"ext": "agda",
"hexsha": "bef93b5c3144cea8ebb61591b22d4caba7e7f174",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/Algebra/OrderedCommMonoid.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/Algebra/OrderedCommMonoid.agda",
"max_line_length": 63,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/Algebra/OrderedCommMonoid.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 45,
"size": 193
} |
------------------------------------------------------------------------------
-- Properties for the equality on streams
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Data.Stream.Equality.PropertiesI where
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Data.Stream.Type
open import FOTC.Relation.Binary.Bisimilarity.PropertiesI
open import FOTC.Relation.Binary.Bisimilarity.Type
------------------------------------------------------------------------------
stream-≡→≈ : ∀ {xs ys} → Stream xs → Stream ys → xs ≡ ys → xs ≈ ys
stream-≡→≈ Sxs _ refl = ≈-refl Sxs
≈→Stream₁ : ∀ {xs ys} → xs ≈ ys → Stream xs
≈→Stream₁ {xs} {ys} h = Stream-coind A h' (ys , h)
where
A : D → Set
A ws = ∃[ zs ] ws ≈ zs
h' : ∀ {xs} → A xs → ∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ A xs'
h' (_ , Axs) with ≈-out Axs
... | x' , xs' , zs' , prf₁ , prf₂ , prf₃ = x' , xs' , prf₁ , (zs' , prf₃)
≈→Stream₂ : ∀ {xs ys} → xs ≈ ys → Stream ys
≈→Stream₂ {xs} {ys} h = Stream-coind A h' (xs , h)
where
A : D → Set
A zs = ∃[ ws ] ws ≈ zs
h' : ∀ {ys} → A ys → ∃[ y' ] ∃[ ys' ] ys ≡ y' ∷ ys' ∧ A ys'
h' (_ , Ays) with ≈-out Ays
... | y' , ys' , zs' , prf₁ , prf₂ , prf₃ = y' , zs' , prf₂ , (ys' , prf₃)
≈→Stream : ∀ {xs ys} → xs ≈ ys → Stream xs ∧ Stream ys
≈→Stream {xs} {ys} h = ≈→Stream₁ h , ≈→Stream₂ h
| {
"alphanum_fraction": 0.4504854369,
"avg_line_length": 34.3333333333,
"ext": "agda",
"hexsha": "e4bffed96a2ba350d36f3241cbee4404619335cd",
"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/Equality/PropertiesI.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "src/fot/FOTC/Data/Stream/Equality/PropertiesI.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "src/fot/FOTC/Data/Stream/Equality/PropertiesI.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z",
"num_tokens": 540,
"size": 1545
} |
{- Adjunction between suspension and loop space (Rongji Kang, Oct. 2021)
Main results:
- Ω∙ : ℕ → Pointed ℓ → Pointed ℓ
- ΣΩAdjunction : ((X , x₀) : Pointed ℓ) (Y : Pointed ℓ') → (∙Susp X →∙ Y) ≃ ((X , x₀) →∙ Ω∙ 1 Y)
-}
{-# OPTIONS --safe #-}
module Cubical.HITs.Susp.LoopAdjunction where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Pointed.Base
open import Cubical.Data.Nat.Base
open import Cubical.HITs.Susp.Base
private
variable
ℓ ℓ' : Level
Ω∙ : ℕ → Pointed ℓ → Pointed ℓ
Ω∙ 0 X = X
Ω∙ 1 (X , x) = (x ≡ x) , refl
Ω∙ (suc (suc n)) X = Ω∙ 1 (Ω∙ (suc n) X)
ΣX→∙YEquiv : ((X , x₀) : Pointed ℓ) ((Y , y₀) : Pointed ℓ')
→ (Susp∙ X →∙ (Y , y₀)) ≃ (Σ[ y ∈ Y ] (X → (y₀ ≡ y)))
ΣX→∙YEquiv (X , x₀) (Y , y₀) =
isoToEquiv (iso left→right right→left right→left→right left→right→left)
where
left→right : (Susp∙ X →∙ (Y , y₀)) → Σ[ y ∈ Y ] (X → (y₀ ≡ y))
left→right (f , b) .fst = f south
left→right (f , b) .snd x = sym b ∙ cong f (merid x)
right→left : (Σ[ y ∈ Y ] (X → (y₀ ≡ y))) → (Susp∙ X →∙ (Y , y₀))
right→left (y , g) .fst north = y₀
right→left (y , g) .fst south = y
right→left (y , g) .fst (merid x i) = g x i
right→left (y , g) .snd = refl
right→left→right : (g : Σ[ y ∈ Y ] (X → (y₀ ≡ y))) → left→right (right→left g) ≡ g
right→left→right (y , g) i .fst = y
right→left→right (y , g) i .snd x = lUnit (g x) (~ i)
left→right→left : (f : Susp∙ X →∙ (Y , y₀)) → right→left (left→right f) ≡ f
left→right→left (f , b) i .fst north = b (~ i)
left→right→left (f , b) i .fst south = f south
left→right→left (f , b) i .fst (merid x j) =
hcomp (λ k → λ { (i = i0) → compPath-filler (sym b) (cong f (merid x)) k j
; (i = i1) → f (merid x (j ∧ k))
; (j = i0) → b (~ i)
; (j = i1) → f (merid x k) })
(b (~ (i ∨ j)))
left→right→left (f , b) i .snd j = b (~ i ∨ j)
X→∙ΩYEquiv : ((X , x₀) : Pointed ℓ)((Y , y₀) : Pointed ℓ')
→ ((X , x₀) →∙ Ω∙ 1 (Y , y₀)) ≃ (Σ[ y ∈ Y ] (X → (y₀ ≡ y)))
X→∙ΩYEquiv (X , x₀) (Y , y₀) =
isoToEquiv (iso left→right right→left right→left→right left→right→left)
where
left→right : ((X , x₀) →∙ Ω∙ 1 (Y , y₀)) → Σ[ y ∈ Y ] (X → (y₀ ≡ y))
left→right _ .fst = y₀
left→right (f , b) .snd = f
right→left : (Σ[ y ∈ Y ] (X → (y₀ ≡ y))) → ((X , x₀) →∙ Ω∙ 1 (Y , y₀))
right→left (y , g) .fst x = g x ∙ sym (g x₀)
right→left (y , g) .snd = rCancel (g x₀)
right→left→right : (g : Σ[ y ∈ Y ] (X → (y₀ ≡ y))) → left→right (right→left g) ≡ g
right→left→right (y , g) i .fst = g x₀ i
right→left→right (y , g) i .snd x j =
hcomp (λ k → λ { (i = i0) → compPath-filler (g x) (sym (g x₀)) k j
; (i = i1) → g x j
; (j = i0) → y₀
; (j = i1) → g x₀ (i ∨ ~ k) })
(g x j)
f-filler : ((X , x₀) →∙ Ω∙ 1 (Y , y₀)) → X → (i j k : I) → Y
f-filler (f , b) x i j k =
hfill (λ k' → λ { (i = i0) → compPath-filler (f x) (sym (f x₀)) k' j
; (i = i1) → f x j
; (j = i0) → y₀
; (j = i1) → b i (~ k') })
(inS (f x j)) k
bottom : ((X , x₀) →∙ Ω∙ 1 (Y , y₀)) → (i j k : I) → Y
bottom (f , b) i j k =
hcomp (λ l → λ { (i = i0) → b (~ l) (k ∧ ~ j)
; (i = i1) → b (j ∨ ~ l) k
; (j = i0) → b (~ l) k
; (j = i1) → y₀
; (k = i0) → y₀
; (k = i1) → b (~ l ∨ i) (~ j) })
y₀
left→right→left : (f : (X , x₀) →∙ Ω∙ 1 (Y , y₀)) → right→left (left→right f) ≡ f
left→right→left (f , b) i .fst x j =
f-filler (f , b) x i j i1
left→right→left (f , b) i .snd j k =
hcomp (λ l → λ { (i = i0) → rCancel-filler (f x₀) l j k
; (i = i1) → b j k
; (j = i0) → f-filler (f , b) x₀ i k l
; (j = i1) → y₀
; (k = i0) → y₀
; (k = i1) → b i (~ l ∧ ~ j) })
(bottom (f , b) i j k)
{- The Main Theorem -}
ΣΩAdjunction : ((X , x₀) : Pointed ℓ) (Y : Pointed ℓ') → (Susp∙ X →∙ Y) ≃ ((X , x₀) →∙ Ω∙ 1 Y)
ΣΩAdjunction X Y = compEquiv (ΣX→∙YEquiv X Y) (invEquiv (X→∙ΩYEquiv X Y))
| {
"alphanum_fraction": 0.44071991,
"avg_line_length": 38.9912280702,
"ext": "agda",
"hexsha": "91be404b7bca0afb8b176b9957a56f691275266b",
"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": "58f2d0dd07e51f8aa5b348a522691097b6695d1c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Seanpm2001-web/cubical",
"max_forks_repo_path": "Cubical/HITs/Susp/LoopAdjunction.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c",
"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": "Seanpm2001-web/cubical",
"max_issues_repo_path": "Cubical/HITs/Susp/LoopAdjunction.agda",
"max_line_length": 96,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "FernandoLarrain/cubical",
"max_stars_repo_path": "Cubical/HITs/Susp/LoopAdjunction.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z",
"num_tokens": 1936,
"size": 4445
} |
module Prelude.Fractional where
open import Agda.Primitive
record Fractional {a} (A : Set a) : Set (lsuc a) where
infixl 7 _/_
field
Constraint : A → A → Set a
_/_ : (x y : A) {{_ : Constraint x y}} → A
NoConstraint : Set a
NoConstraint = ∀ {x y} → Constraint x y
open Fractional {{...}} using (_/_) public
{-# DISPLAY Fractional._/_ _ x y = x / y #-}
| {
"alphanum_fraction": 0.6112600536,
"avg_line_length": 21.9411764706,
"ext": "agda",
"hexsha": "6e38b003e95acc35111b9a928f7231aa723d57e8",
"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/Fractional.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/Fractional.agda",
"max_line_length": 54,
"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/Fractional.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": 124,
"size": 373
} |
{-# OPTIONS --guardedness --without-K #-}
module ky where
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; _≢_; refl; cong; cong₂; sym)
open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _≡⟨_⟩_; _∎)
open import Data.Rational using (ℚ; _+_; _*_; _-_)
open import Data.Bool
open import Data.Bool.Properties
open import Data.Rational
open import Data.Nat as ℕ using (ℕ; zero; suc; ⌊_/2⌋)
open import Data.Empty
open import Relation.Nullary
open import Relation.Nullary.Negation
open import Agda.Builtin.Size
open import Data.Product
open import Data.Unit
open import Data.Maybe
open import Data.List
TyCon = List Set
data Env : TyCon → Set₁ where
nil : Env []
cons : ∀{t Γ} → t → Env Γ → Env (t ∷ Γ)
data Idx : Set → TyCon → Set₁ where
fst : ∀{t Γ} → Idx t (t ∷ Γ)
nxt : ∀{t t' Γ} → Idx t Γ → Idx t (t' ∷ Γ)
get : ∀{t Γ} → Idx t Γ → Env Γ → t
get fst (cons v _) = v
get (nxt idx) (cons _ vs) = get idx vs
upd : ∀{t Γ} → Idx t Γ → t -> Env Γ → Env Γ
upd fst v' (cons _ vs) = cons v' vs
upd (nxt idx) v' (cons v vs) = cons v (upd idx v' vs)
data Exp : TyCon → Set → Set₁ where
EVal : ∀{t Γ} → t → Exp Γ t
EVar : ∀{t Γ} → Idx t Γ → Exp Γ t
EPlus : ∀{Γ} → Exp Γ ℚ → Exp Γ ℚ → Exp Γ ℚ
record Cotree (i : Size) (A : Set) (Γ : TyCon) : Set₁
data Pattern : Size → TyCon → Set₁ where
mkPattern : ∀{i Γ} → --{j₁ j₂ : Size< i} →
(Cotree i Bool Γ → Cotree i Bool Γ → Cotree i Bool Γ) →
Pattern i Γ
data Com : Size → TyCon → Set → Set₁ where
CSkip : ∀{i Γ} → Com i Γ ⊤
CPrim : ∀{i t Γ} → Pattern i Γ → Com i Γ t → Com i Γ t → Com i Γ t
--CFlip : ∀{i t Γ} → Com i Γ t → Com i Γ t → Com i Γ t
CUpd : ∀{i t Γ} → Idx t Γ → Exp Γ t → Com i Γ ⊤
--CAlloc : ∀{t Γ} → Exp Γ t → Com (t ∷ Γ) ⊤
CIte : ∀{i t Γ} → Exp Γ Bool → Com i Γ t → Com i Γ t → Com i Γ t
CSeq : ∀{i t Γ} → Com i Γ ⊤ → Com i Γ t → Com i Γ t
CWhile : ∀{i t Γ} → Exp Γ Bool → Com i Γ t → Com i Γ ⊤
eval : ∀{t Γ} → Env Γ → Exp Γ t → t
eval ρ (EVal v) = v
eval ρ (EVar x) = get x ρ
eval ρ (EPlus e₁ e₂) = eval ρ e₁ + eval ρ e₂
-- Cf. Abel 2017 (Equational Reasoning about Formal Languages in Coalgebraic Style)
record Cotree i A Γ where
coinductive
field
ν : Env Γ -> Maybe (Env Γ)
δ : ∀{j : Size< i} → Env Γ → A → Cotree j A Γ
open Cotree
∅ : ∀{i A Γ} → Cotree i A Γ
ν ∅ _ = nothing
δ ∅ _ _ = ∅
flip : ∀(i Γ) → Cotree i Bool Γ → Cotree i Bool Γ → Cotree i Bool Γ
flip i Γ t₁ t₂ = t
where t : Cotree i Bool Γ
ν t ρ = nothing
δ t ρ true = t₁
δ t ρ false = t₂
interp : ∀(i){τ} → ∀(Γ) → Com i Γ τ → Cotree i Bool Γ
interp i Γ CSkip = t
where t : ∀{j} → Cotree j Bool Γ
ν t ρ = just ρ
δ t ρ _ = ∅
interp i Γ (CPrim (mkPattern f) c₁ c₂) = t
where t : Cotree i Bool Γ
ν t ρ = nothing
δ t ρ _ = f (interp i Γ c₁) (interp i Γ c₂)
{-interp i Γ (CFlip c₁ c₂) = t
where t : Cotree i Bool Γ
ν t ρ = nothing
δ t ρ true = interp i Γ c₁
δ t ρ false = interp i Γ c₂-}
interp i Γ (CUpd x e) = t
where t : ∀{j} → Cotree j Bool Γ
ν t ρ = just (upd x (eval ρ e) ρ)
δ t ρ _ = ∅
interp i Γ (CIte e c₁ c₂) = t
where t : Cotree i Bool Γ
ν t ρ with eval ρ e
... | true = ν (interp i Γ c₁) ρ
... | false = ν (interp i Γ c₂) ρ
δ t ρ b with eval ρ e
... | true = δ (interp i Γ c₁) ρ b
... | false = δ (interp i Γ c₂) ρ b
interp i Γ (CSeq c₁ c₂) = t
where t : Cotree i Bool Γ
ν t ρ = nothing
δ t ρ b with ν (interp i Γ c₁) ρ
... | nothing = δ (interp i Γ c₁) ρ b
... | just ρ' = δ (interp i Γ c₂) ρ' b
interp i Γ (CWhile e c) = t
where t : Cotree i Bool Γ
ν t ρ with eval ρ e
... | true = ν (interp i Γ c) ρ
... | false = just ρ
δ t ρ b with eval ρ e
... | true = δ (interp i Γ c) ρ b
... | false = ∅
-- Flip as a derived command
cflip : ∀(i Γ){τ} → Com i Γ τ → Com i Γ τ → Com i Γ τ
cflip i Γ = CPrim (mkPattern (flip i Γ))
| {
"alphanum_fraction": 0.5292247493,
"avg_line_length": 31.213740458,
"ext": "agda",
"hexsha": "6008bd133596a14131db2d63dccb3c94f5e031ef",
"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": "9243f9d77d0c8af99afa4f536156a3e23b1c40e1",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "OUPL/Zar",
"max_forks_repo_path": "theory/ky.agda",
"max_issues_count": 5,
"max_issues_repo_head_hexsha": "9243f9d77d0c8af99afa4f536156a3e23b1c40e1",
"max_issues_repo_issues_event_max_datetime": "2019-10-06T16:32:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-09-13T15:40:08.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "OUPL/Zar",
"max_issues_repo_path": "theory/ky.agda",
"max_line_length": 83,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "9243f9d77d0c8af99afa4f536156a3e23b1c40e1",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "OUPL/Zar",
"max_stars_repo_path": "theory/ky.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1630,
"size": 4089
} |
open import Agda.Builtin.Coinduction
open import Agda.Builtin.IO
open import Agda.Builtin.Unit
data D : Set where
c : ∞ D → D
d : D
d = c (♯ d)
postulate
seq : {A B : Set} → A → B → B
return : {A : Set} → A → IO A
{-# COMPILE GHC return = \_ -> return #-}
{-# COMPILE GHC seq = \_ _ -> seq #-}
main : IO ⊤
main = seq d (return tt)
| {
"alphanum_fraction": 0.5609065156,
"avg_line_length": 17.65,
"ext": "agda",
"hexsha": "8c2d8bc2485024cca10b8a0b5b3f70c69ed8a6f2",
"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/Compiler/simple/Issue2909-2.agda",
"max_issues_count": 16,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": "2019-09-08T13:47:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-10-08T00:32:04.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/Compiler/simple/Issue2909-2.agda",
"max_line_length": 43,
"max_stars_count": 7,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/Compiler/simple/Issue2909-2.agda",
"max_stars_repo_stars_event_max_datetime": "2018-11-06T16:38:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-11-05T22:13:36.000Z",
"num_tokens": 127,
"size": 353
} |
module Common.Char where
open import Agda.Builtin.Char public
open import Common.Bool
charEq : Char -> Char -> Bool
charEq = primCharEquality
| {
"alphanum_fraction": 0.7724137931,
"avg_line_length": 16.1111111111,
"ext": "agda",
"hexsha": "466653df952558f32e69d4b92d67189f6c85809d",
"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/Common/Char.agda",
"max_issues_count": 16,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": "2019-09-08T13:47:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-10-08T00:32:04.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/Common/Char.agda",
"max_line_length": 36,
"max_stars_count": 7,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/Common/Char.agda",
"max_stars_repo_stars_event_max_datetime": "2018-11-06T16:38:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-11-05T22:13:36.000Z",
"num_tokens": 35,
"size": 145
} |
module Data.List.Iterable where
open import Data
open import Data.List
import Data.List.Functions as List
open import Logic.Propositional
open import Logic.Predicate
import Lvl
open import Relator.Equals
open import Structure.Container.Iterable
open import Type
private variable ℓ : Lvl.Level
private variable T : Type{ℓ}
instance
List-iterable : Iterable(List(T))
Iterable.Element (List-iterable {T = T}) = T
Iterable.isEmpty List-iterable = List.isEmpty
Iterable.current List-iterable ∅ = <>
Iterable.current List-iterable (x ⊰ l) = x
Iterable.indexStep List-iterable ∅ = <>
Iterable.indexStep List-iterable (_ ⊰ _) = <>
Iterable.step List-iterable ∅ = <>
Iterable.step List-iterable (x ⊰ l) = l
instance
List-finite-iterable : Iterable.Finite(List-iterable{T = T})
∃.witness List-finite-iterable = List.foldᵣ
∃.proof List-finite-iterable {iter = ∅} = [≡]-intro
∃.proof List-finite-iterable {iter = x ⊰ l} = [≡]-intro
instance
List-empty : Iterable.EmptyConstruction(List-iterable{T = T})(∅)
List-empty = <>
instance
List-prepend : Iterable.PrependConstruction(List-iterable{T = T})(_⊰_)
∃.witness List-prepend = [≡]-intro
∃.proof List-prepend = [∧]-intro [≡]-intro [≡]-intro
| {
"alphanum_fraction": 0.6945773525,
"avg_line_length": 30.5853658537,
"ext": "agda",
"hexsha": "207bb976f747a3ff504b6a63b04d66bb7d341625",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Data/List/Iterable.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Data/List/Iterable.agda",
"max_line_length": 72,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Data/List/Iterable.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": 379,
"size": 1254
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.S2 where
open import Cubical.HITs.S2.Base public
-- open import Cubical.HITs.S2.Properties public
| {
"alphanum_fraction": 0.7426900585,
"avg_line_length": 24.4285714286,
"ext": "agda",
"hexsha": "5fb9ced1647d6c576b21202bdb36ef8724a3b124",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/HITs/S2.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/HITs/S2.agda",
"max_line_length": 50,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/HITs/S2.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 49,
"size": 171
} |
module FRP.JS.Size where
postulate
Size : Set
↑_ : Size → Size
∞ : Size
{-# BUILTIN SIZE Size #-}
{-# BUILTIN SIZESUC ↑_ #-}
{-# BUILTIN SIZEINF ∞ #-}
{-# COMPILED_JS ↑_ function(x) { return null; } #-}
{-# COMPILED_JS ∞ null #-}
| {
"alphanum_fraction": 0.5346153846,
"avg_line_length": 20,
"ext": "agda",
"hexsha": "0982c030002f14659c3ff46b8e7564f8adb75840",
"lang": "Agda",
"max_forks_count": 7,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z",
"max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_forks_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_forks_repo_name": "agda/agda-frp-js",
"max_forks_repo_path": "src/agda/FRP/JS/Size.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_issues_repo_name": "agda/agda-frp-js",
"max_issues_repo_path": "src/agda/FRP/JS/Size.agda",
"max_line_length": 55,
"max_stars_count": 63,
"max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_stars_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_stars_repo_name": "agda/agda-frp-js",
"max_stars_repo_path": "src/agda/FRP/JS/Size.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": 86,
"size": 260
} |
{-# OPTIONS --universe-polymorphism #-}
module Categories.Monad.Kleisli where
open import Categories.Category
open import Categories.Functor using (Functor; module Functor)
open import Categories.NaturalTransformation hiding (_≡_; equiv; id)
open import Categories.Monad
Kleisli : ∀ {o ℓ e} {C : Category o ℓ e} → Monad C → Category o ℓ e
Kleisli {C = C} M = record
{ Obj = Obj
; _⇒_ = λ A B → (A ⇒ F₀ B)
; _≡_ = _≡_
; _∘_ = λ f g → (μ.η _ ∘ F₁ f) ∘ g
; id = η.η _
; assoc = assoc′
; identityˡ = identityˡ′
; identityʳ = identityʳ′
; equiv = equiv
; ∘-resp-≡ = λ f≡h g≡i → ∘-resp-≡ (∘-resp-≡ refl (F-resp-≡ f≡h)) g≡i
}
where
module M = Monad M
open M using (μ; η; F)
module μ = NaturalTransformation μ
module η = NaturalTransformation η
open Functor F
open Category C
open Equiv
.assoc′ : ∀ {A B C D} {f : A ⇒ F₀ B} {g : B ⇒ F₀ C} {h : C ⇒ F₀ D}
→ (μ.η D ∘ (F₁ ((μ.η D ∘ F₁ h) ∘ g))) ∘ f ≡ (μ.η D ∘ F₁ h) ∘ ((μ.η C ∘ F₁ g) ∘ f)
assoc′ {A} {B} {C} {D} {f} {g} {h} =
begin
(μ.η D ∘ F₁ ((μ.η D ∘ F₁ h) ∘ g)) ∘ f
↓⟨ assoc ⟩
μ.η D ∘ (F₁ ((μ.η D ∘ F₁ h) ∘ g) ∘ f)
↓⟨ ∘-resp-≡ʳ (∘-resp-≡ˡ (F-resp-≡ assoc)) ⟩
μ.η D ∘ (F₁ (μ.η D ∘ (F₁ h ∘ g)) ∘ f)
↓⟨ ∘-resp-≡ʳ (∘-resp-≡ˡ homomorphism) ⟩
μ.η D ∘ ((F₁ (μ.η D) ∘ F₁ (F₁ h ∘ g)) ∘ f)
↓⟨ ∘-resp-≡ʳ assoc ⟩
μ.η D ∘ (F₁ (μ.η D) ∘ (F₁ (F₁ h ∘ g) ∘ f))
↑⟨ assoc ⟩
(μ.η D ∘ F₁ (μ.η D)) ∘ (F₁ (F₁ h ∘ g) ∘ f)
↓⟨ ∘-resp-≡ˡ M.assoc ⟩
(μ.η D ∘ μ.η (F₀ D)) ∘ (F₁ (F₁ h ∘ g) ∘ f)
↓⟨ assoc ⟩
μ.η D ∘ (μ.η (F₀ D) ∘ (F₁ (F₁ h ∘ g) ∘ f))
↑⟨ ∘-resp-≡ʳ assoc ⟩
μ.η D ∘ ((μ.η (F₀ D) ∘ F₁ (F₁ h ∘ g)) ∘ f)
↓⟨ ∘-resp-≡ʳ (∘-resp-≡ˡ (∘-resp-≡ʳ homomorphism)) ⟩
μ.η D ∘ ((μ.η (F₀ D) ∘ (F₁ (F₁ h) ∘ F₁ g)) ∘ f)
↑⟨ ∘-resp-≡ʳ (∘-resp-≡ˡ assoc) ⟩
μ.η D ∘ (((μ.η (F₀ D) ∘ F₁ (F₁ h)) ∘ F₁ g) ∘ f)
↓⟨ ∘-resp-≡ʳ (∘-resp-≡ˡ (∘-resp-≡ˡ (μ.commute h))) ⟩
μ.η D ∘ (((F₁ h ∘ μ.η C) ∘ F₁ g) ∘ f)
↓⟨ ∘-resp-≡ʳ (∘-resp-≡ˡ assoc) ⟩
μ.η D ∘ ((F₁ h ∘ (μ.η C ∘ F₁ g)) ∘ f)
↓⟨ ∘-resp-≡ʳ assoc ⟩
μ.η D ∘ (F₁ h ∘ ((μ.η C ∘ F₁ g) ∘ f))
↑⟨ assoc ⟩
(μ.η D ∘ F₁ h) ∘ ((μ.η C ∘ F₁ g) ∘ f)
∎
where
open HomReasoning
.identityˡ′ : ∀ {A B} {f : A ⇒ F₀ B} → (μ.η B ∘ F₁ (η.η B)) ∘ f ≡ f
identityˡ′ {A} {B} {f} =
begin
(μ.η B ∘ F₁ (η.η B)) ∘ f
↓⟨ ∘-resp-≡ˡ M.identityˡ ⟩
id ∘ f
↓⟨ identityˡ ⟩
f
∎
where
open HomReasoning
.identityʳ′ : ∀ {A B} {f : A ⇒ F₀ B} → (μ.η B ∘ F₁ f) ∘ η.η A ≡ f
identityʳ′ {A} {B} {f} =
begin
(μ.η B ∘ F₁ f) ∘ η.η A
↓⟨ assoc ⟩
μ.η B ∘ (F₁ f ∘ η.η A)
↑⟨ ∘-resp-≡ʳ (η.commute f) ⟩
μ.η B ∘ (η.η (F₀ B) ∘ f)
↑⟨ assoc ⟩
(μ.η B ∘ η.η (F₀ B)) ∘ f
↓⟨ ∘-resp-≡ˡ M.identityʳ ⟩
id ∘ f
↓⟨ identityˡ ⟩
f
∎
where
open HomReasoning
| {
"alphanum_fraction": 0.4244362168,
"avg_line_length": 30.6288659794,
"ext": "agda",
"hexsha": "b073c1a0ad8ac541f3e2c18f5d49d92a2f6bf54f",
"lang": "Agda",
"max_forks_count": 23,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z",
"max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "p-pavel/categories",
"max_forks_repo_path": "Categories/Monad/Kleisli.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "p-pavel/categories",
"max_issues_repo_path": "Categories/Monad/Kleisli.agda",
"max_line_length": 91,
"max_stars_count": 98,
"max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "copumpkin/categories",
"max_stars_repo_path": "Categories/Monad/Kleisli.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z",
"num_tokens": 1598,
"size": 2971
} |
module Issue533 where
data Empty : Set where
empty : {A B : Set} → (B → Empty) → B → A
empty f x with f x
... | ()
fail : ∀ {A : Set} → Empty → A
fail {A} = empty absurd
where
absurd : _ → Empty
absurd ()
-- should check (due to postponed emptyness constraint, see issue 479)
| {
"alphanum_fraction": 0.6055363322,
"avg_line_length": 19.2666666667,
"ext": "agda",
"hexsha": "0518bbd269a1cf28a863c947296e204f0799d1be",
"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/Issue533.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/Issue533.agda",
"max_line_length": 70,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue533.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": 90,
"size": 289
} |
open import Agda.Builtin.Nat
data S : Set where
c : S
module _ (A : Set) where
test : S
test with c
... | q = {!q!} -- Splitting on q should succeed
data Vec (A : Set) : Nat → Set where
[] : Vec A zero
_∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)
module _ {A : Set} {n : Nat} (xs : Vec A n) where
foo : Vec A n → Nat
foo [] = 0
foo (x ∷ ys) with x ∷ xs
... | zs = {!zs!}
-- Splitting on zs should succeed here.
-- Splitting on xs should fail.
| {
"alphanum_fraction": 0.5368421053,
"avg_line_length": 19.7916666667,
"ext": "agda",
"hexsha": "b18f6c4149a0a3d3f04831165d40055cb3c120db",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/interaction/Issue2181.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/interaction/Issue2181.agda",
"max_line_length": 51,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/interaction/Issue2181.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": 181,
"size": 475
} |
data {-sdaf-} Nat {-sdaf-} : {-sdaf-} Set {-sdaf-} where {-sdaf-}
zero {-sdaf-} : {-sdaf-} Nat {-sdaf-}
suc {-sdaf-} :{-sdaf-} Nat {-sdaf-} -> {-sdaf-} Nat {-sdaf-}
data Impossible : Set where {-Comment which should not be duplicated-}
| {
"alphanum_fraction": 0.552,
"avg_line_length": 35.7142857143,
"ext": "agda",
"hexsha": "f567550c792bc6789436a49c658321897c599d71",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-01-31T08:40:41.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-01-31T08:40:41.000Z",
"max_forks_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "omega12345/RefactorAgda",
"max_forks_repo_path": "RefactorAgdaEngine/Test/Tests/input/DataStructure.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b",
"max_issues_repo_issues_event_max_datetime": "2019-02-05T12:53:36.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-31T08:03:07.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "omega12345/RefactorAgda",
"max_issues_repo_path": "RefactorAgdaEngine/Test/Tests/input/DataStructure.agda",
"max_line_length": 70,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "omega12345/RefactorAgda",
"max_stars_repo_path": "RefactorAgdaEngine/Test/Tests/input/DataStructure.agda",
"max_stars_repo_stars_event_max_datetime": "2019-05-03T10:03:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-01-31T14:10:18.000Z",
"num_tokens": 94,
"size": 250
} |
------------------------------------------------------------------------
-- Canonical kinding of Fω with interval kinds
------------------------------------------------------------------------
{-# OPTIONS --safe --without-K #-}
module FOmegaInt.Kinding.Canonical where
open import Data.Context.WellFormed
open import Data.Fin using (Fin; zero; suc)
open import Data.Fin.Substitution
open import Data.Fin.Substitution.Lemmas
open import Data.Fin.Substitution.ExtraLemmas
open import Data.Fin.Substitution.Typed
open import Data.List using ([]; _∷_; _∷ʳ_)
open import Data.Product using (∃; _,_; _×_)
open import Data.Vec as Vec using ([])
open import Level using () renaming (zero to lzero)
open import Relation.Binary.PropositionalEquality
open import FOmegaInt.Syntax
open import FOmegaInt.Syntax.HereditarySubstitution
open import FOmegaInt.Syntax.Normalization
import FOmegaInt.Kinding.Simple as SimpleKinding
------------------------------------------------------------------------
-- Canonical kinding derivations.
--
-- TODO: explain the point of this and how "canonical" kinding differs
-- from "algorithmic" kinding.
--
-- NOTE. In the rules below, we use (singleton) kind synthesis
-- judgments of the form `Γ ⊢Nf a ⇉ a ⋯ a' to ensure that `a' is a
-- well-kinded proper type rather than kind checking judgments of the
-- form `Γ ⊢Nf a ⇇ *'. While the latter may seem more natural, it
-- involves the use of subsumption/subtyping to ensure that `Γ ⊢ a ⋯ a
-- <∷ *'. As we will show, this is always true (if `a' is indeed a
-- proper type) but the extra use of subsumption complicates the
-- proofs of properties that require (partial) inversion of kinding
-- derivations. See e.g. the Nf⇉-⋯-* and Nf⇇-⋯-* lemmas.
module Kinding where
open ElimCtx
open Syntax
infix 4 _⊢_wf _ctx _⊢_kd
infix 4 _⊢Nf_⇉_ _⊢Ne_∈_ _⊢Var_∈_ _⊢_⇉∙_⇉_ _⊢Nf_⇇_
infix 4 _⊢_<∷_ _⊢_<:_ _⊢_<:_⇇_
infix 4 _⊢_≅_ _⊢_≃_⇇_ _⊢_⇉∙_≃_⇉_
mutual
-- Well-formed type/kind ascriptions in typing contexts.
--
-- A raw kind ascriptions is considered well-formed if it
-- corresponds to a well-formed normal kind. Raw type ascriptions
-- are are considered well-formed if they correspond to proper
-- normal types.
data _⊢_wf {n} (Γ : Ctx n) : ElimAsc n → Set where
wf-kd : ∀ {a} → Γ ⊢ a kd → Γ ⊢ kd a wf
wf-tp : ∀ {a} → Γ ⊢Nf a ⇉ a ⋯ a → Γ ⊢ tp a wf
-- Well-formed typing contexts.
--
-- Contexts and context extensions are well-formed if all the
-- ascriptions they contain are well-formed.
_ctx : ∀ {n} → Ctx n → Set
Γ ctx = ContextFormation._wf _⊢_wf Γ
-- Well-formedness checking for η-long β-normal kinds.
data _⊢_kd {n} (Γ : Ctx n) : Kind Elim n → Set where
kd-⋯ : ∀ {a b} → Γ ⊢Nf a ⇉ a ⋯ a → Γ ⊢Nf b ⇉ b ⋯ b → Γ ⊢ a ⋯ b kd
kd-Π : ∀ {j k} → Γ ⊢ j kd → kd j ∷ Γ ⊢ k kd → Γ ⊢ Π j k kd
-- Kind synthesis for η-long β-normal types.
data _⊢Nf_⇉_ {n} (Γ : Ctx n) : Elim n → Kind Elim n → Set where
⇉-⊥-f : Γ ctx → Γ ⊢Nf ⊥∙ ⇉ ⊥∙ ⋯ ⊥∙
⇉-⊤-f : Γ ctx → Γ ⊢Nf ⊤∙ ⇉ ⊤∙ ⋯ ⊤∙
⇉-∀-f : ∀ {k a} → Γ ⊢ k kd → kd k ∷ Γ ⊢Nf a ⇉ a ⋯ a →
Γ ⊢Nf ∀∙ k a ⇉ ∀∙ k a ⋯ ∀∙ k a
⇉-→-f : ∀ {a b} → Γ ⊢Nf a ⇉ a ⋯ a → Γ ⊢Nf b ⇉ b ⋯ b →
Γ ⊢Nf a ⇒∙ b ⇉ a ⇒∙ b ⋯ a ⇒∙ b
⇉-Π-i : ∀ {j a k} → Γ ⊢ j kd → kd j ∷ Γ ⊢Nf a ⇉ k → Γ ⊢Nf Λ∙ j a ⇉ Π j k
⇉-s-i : ∀ {a b c} → Γ ⊢Ne a ∈ b ⋯ c → Γ ⊢Nf a ⇉ a ⋯ a
-- Canonical kinding of neutral types.
--
-- NOTE. This is *not* a kind synthesis judgment! See the
-- comment on canonical variable kinding for an explanation.
data _⊢Ne_∈_ {n} (Γ : Ctx n) : Elim n → Kind Elim n → Set where
∈-∙ : ∀ {x j k} {as : Spine n} → Γ ⊢Var x ∈ j →
Γ ⊢ j ⇉∙ as ⇉ k → Γ ⊢Ne var x ∙ as ∈ k
-- Canonical kinding of variables.
--
-- NOTE. This would be a kind synthesis judgment if it weren't
-- for the subsumption rule (⇇-⇑). Thanks to this rule, the proof
-- of the "context narrowing" property is easy to establish for
-- canonical typing (see the ContextNarrowing module below).
-- Without a proof of this property, the various lemmas about
-- kinded hereditary substitutions become difficult to establish
-- (see Kinding.HereditarySubstitution). Unfortunately, proving
-- that context narrowing is admissible *without* (⇇-⇑) would
-- require precisely these substitution lemmas, leading to a
-- cyclic dependency. Introducing the subsumption rule for
-- variables thus allows us to break that cycle. On the other
-- hand, the subsumption rule breaks functionality of the
-- canonical kinding relations for variables and neutral types,
-- i.e. their canonical kinds are no longer unique. This is
-- partly remedied by the singleton-introduction rule (⇉-s-i) in
-- the kind synthesis judgment for normal types: neutrals have
-- unique (singleton) kinds when viewed as normal forms. However,
-- neutral kinding is also used in subtyping, in particular by the
-- bound projection rules (<:-⟨|) and (<:-|⟩). Because the kinds
-- of neutrals are not unique, neither are the bounds projected by
-- these subtyping rules, and eliminating adjacent instances of
-- (<:-⟨|) and (<:-|⟩) becomes difficult. This, in turn,
-- complicates transitivity elimination (i.e. a proof that
-- transitivity of subtyping is admissible) in arbitrary contexts.
-- However, it does not affect elimination of *top-level*
-- occurrences of the transitivity rule (<:-trans), i.e. those in
-- the empty contexts, because there are no closed neutral terms,
-- and therefore no instances of the bound projection rules in
-- top-level subtyping statements.
data _⊢Var_∈_ {n} (Γ : Ctx n) : Fin n → Kind Elim n → Set where
⇉-var : ∀ {k} x → Γ ctx → lookup Γ x ≡ kd k → Γ ⊢Var x ∈ k
⇇-⇑ : ∀ {x j k} → Γ ⊢Var x ∈ j → Γ ⊢ j <∷ k → Γ ⊢ k kd →
Γ ⊢Var x ∈ k
-- Kind synthesis for spines: given the kind of the head and a
-- spine, synthesize the overall kind of the elimination.
data _⊢_⇉∙_⇉_ {n} (Γ : Ctx n)
: Kind Elim n → Spine n → Kind Elim n → Set where
⇉-[] : ∀ {k} → Γ ⊢ k ⇉∙ [] ⇉ k
⇉-∷ : ∀ {a as j k l} → Γ ⊢Nf a ⇇ j → Γ ⊢ j kd →
Γ ⊢ k Kind[ a ∈ ⌊ j ⌋ ] ⇉∙ as ⇉ l →
Γ ⊢ Π j k ⇉∙ a ∷ as ⇉ l
-- Kind checking for η-long β-normal types.
data _⊢Nf_⇇_ {n} (Γ : Ctx n) : Elim n → Kind Elim n → Set where
⇇-⇑ : ∀ {a j k} → Γ ⊢Nf a ⇉ j → Γ ⊢ j <∷ k → Γ ⊢Nf a ⇇ k
-- Canonical subkinding derivations.
data _⊢_<∷_ {n} (Γ : Ctx n) : Kind Elim n → Kind Elim n → Set where
<∷-⋯ : ∀ {a₁ a₂ b₁ b₂} →
Γ ⊢ a₂ <: a₁ → Γ ⊢ b₁ <: b₂ → Γ ⊢ a₁ ⋯ b₁ <∷ a₂ ⋯ b₂
<∷-Π : ∀ {j₁ j₂ k₁ k₂} →
Γ ⊢ j₂ <∷ j₁ → kd j₂ ∷ Γ ⊢ k₁ <∷ k₂ → Γ ⊢ Π j₁ k₁ kd →
Γ ⊢ Π j₁ k₁ <∷ Π j₂ k₂
-- Canonical subtyping of proper types.
data _⊢_<:_ {n} (Γ : Ctx n) : Elim n → Elim n → Set where
<:-trans : ∀ {a b c} → Γ ⊢ a <: b → Γ ⊢ b <: c → Γ ⊢ a <: c
<:-⊥ : ∀ {a} → Γ ⊢Nf a ⇉ a ⋯ a → Γ ⊢ ⊥∙ <: a
<:-⊤ : ∀ {a} → Γ ⊢Nf a ⇉ a ⋯ a → Γ ⊢ a <: ⊤∙
<:-∀ : ∀ {k₁ k₂ a₁ a₂} →
Γ ⊢ k₂ <∷ k₁ → kd k₂ ∷ Γ ⊢ a₁ <: a₂ →
Γ ⊢Nf ∀∙ k₁ a₁ ⇉ ∀∙ k₁ a₁ ⋯ ∀∙ k₁ a₁ →
Γ ⊢ ∀∙ k₁ a₁ <: ∀∙ k₂ a₂
<:-→ : ∀ {a₁ a₂ b₁ b₂} →
Γ ⊢ a₂ <: a₁ → Γ ⊢ b₁ <: b₂ → Γ ⊢ a₁ ⇒∙ b₁ <: a₂ ⇒∙ b₂
<:-∙ : ∀ {x as₁ as₂ k b c} →
Γ ⊢Var x ∈ k → Γ ⊢ k ⇉∙ as₁ ≃ as₂ ⇉ b ⋯ c →
Γ ⊢ var x ∙ as₁ <: var x ∙ as₂
<:-⟨| : ∀ {a b c} → Γ ⊢Ne a ∈ b ⋯ c → Γ ⊢ b <: a
<:-|⟩ : ∀ {a b c} → Γ ⊢Ne a ∈ b ⋯ c → Γ ⊢ a <: c
-- Checked/kind-driven subtyping.
data _⊢_<:_⇇_ {n} (Γ : Ctx n) : Elim n → Elim n → Kind Elim n → Set where
<:-⇇ : ∀ {a b c d} → Γ ⊢Nf a ⇇ c ⋯ d → Γ ⊢Nf b ⇇ c ⋯ d →
Γ ⊢ a <: b → Γ ⊢ a <: b ⇇ c ⋯ d
<:-λ : ∀ {j₁ j₂ a₁ a₂ j k} → kd j ∷ Γ ⊢ a₁ <: a₂ ⇇ k →
Γ ⊢Nf Λ∙ j₁ a₁ ⇇ Π j k → Γ ⊢Nf Λ∙ j₂ a₂ ⇇ Π j k →
Γ ⊢ Λ∙ j₁ a₁ <: Λ∙ j₂ a₂ ⇇ Π j k
-- Canonical kind equality.
data _⊢_≅_ {n} (Γ : Ctx n) : Kind Elim n → Kind Elim n → Set where
<∷-antisym : ∀ {j k} → Γ ⊢ j kd → Γ ⊢ k kd →
Γ ⊢ j <∷ k → Γ ⊢ k <∷ j → Γ ⊢ j ≅ k
-- Canonical type equality derivations with checked kinds.
data _⊢_≃_⇇_ {n} (Γ : Ctx n) : Elim n → Elim n → Kind Elim n → Set where
<:-antisym : ∀ {a b k} →
Γ ⊢ k kd → Γ ⊢ a <: b ⇇ k → Γ ⊢ b <: a ⇇ k → Γ ⊢ a ≃ b ⇇ k
-- Canonical equality of spines.
data _⊢_⇉∙_≃_⇉_ {n} (Γ : Ctx n)
: Kind Elim n → Spine n → Spine n → Kind Elim n → Set where
≃-[] : ∀ {k} → Γ ⊢ k ⇉∙ [] ≃ [] ⇉ k
≃-∷ : ∀ {a as b bs j k l} →
Γ ⊢ a ≃ b ⇇ j → Γ ⊢ k Kind[ a ∈ ⌊ j ⌋ ] ⇉∙ as ≃ bs ⇉ l →
Γ ⊢ Π j k ⇉∙ a ∷ as ≃ b ∷ bs ⇉ l
-- Well-formed context extensions.
open ContextFormation _⊢_wf public
hiding (_wf) renaming (_⊢_wfExt to _⊢_ext)
-- A wrapper for the _⊢Var_∈_ judgment that also provides term
-- variable bindings.
infix 4 _⊢Var′_∈_
data _⊢Var′_∈_ {n} (Γ : Ctx n) : Fin n → ElimAsc n → Set where
∈-tp : ∀ {x k} → Γ ⊢Var x ∈ k → Γ ⊢Var′ x ∈ kd k
∈-tm : ∀ x {a} → Γ ctx → lookup Γ x ≡ tp a → Γ ⊢Var′ x ∈ tp a
-- A derived variable rule.
∈-var′ : ∀ {n} {Γ : Ctx n} x → Γ ctx → Γ ⊢Var′ x ∈ lookup Γ x
∈-var′ {Γ = Γ} x Γ-ctx with lookup Γ x | inspect (lookup Γ) x
∈-var′ x Γ-ctx | kd k | [ Γ[x]≡kd-k ] = ∈-tp (⇉-var x Γ-ctx Γ[x]≡kd-k)
∈-var′ x Γ-ctx | tp a | [ Γ[x]≡tp-a ] = ∈-tm x Γ-ctx Γ[x]≡tp-a
------------------------------------------------------------------------
-- Simple properties of canonical kindings
open Syntax
open ElimCtx
open SimpleCtx using (kd; tp; ⌊_⌋Asc)
open Kinding
open ContextConversions using (⌊_⌋Ctx; module ⌊⌋Ctx-Lemmas)
-- An inversion lemma for _⊢_wf.
wf-kd-inv : ∀ {n} {Γ : Ctx n} {k} → Γ ⊢ kd k wf → Γ ⊢ k kd
wf-kd-inv (wf-kd k-kd) = k-kd
-- Subkinds have the same shape.
<∷-⌊⌋ : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j <∷ k → ⌊ j ⌋ ≡ ⌊ k ⌋
<∷-⌊⌋ (<∷-⋯ _ _) = refl
<∷-⌊⌋ (<∷-Π j₂<∷j₁ k₁<∷k₂ _) = cong₂ _⇒_ (sym (<∷-⌊⌋ j₂<∷j₁)) (<∷-⌊⌋ k₁<∷k₂)
-- Equal kinds have the same shape.
≅-⌊⌋ : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j ≅ k → ⌊ j ⌋ ≡ ⌊ k ⌋
≅-⌊⌋ (<∷-antisym j-kd k-kd j<∷k k<∷j) = <∷-⌊⌋ j<∷k
-- Kind and type equality imply subkinding and subtyping, respectively.
≅⇒<∷ : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j ≅ k → Γ ⊢ j <∷ k
≅⇒<∷ (<∷-antisym j-kd k-kd j<∷k k<∷j) = j<∷k
≃⇒<: : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a ≃ b ⇇ k → Γ ⊢ a <: b ⇇ k
≃⇒<: (<:-antisym k-kd a<:b⇇k b<:a⇇k) = a<:b⇇k
≃⇒<:-⋯ : ∀ {n} {Γ : Ctx n} {a b c d} → Γ ⊢ a ≃ b ⇇ c ⋯ d → Γ ⊢ a <: b
≃⇒<:-⋯ (<:-antisym c⋯d-kd (<:-⇇ a⇇c⋯d b⇇c⋯d a<:b) b<:a⇇c⋯d) = a<:b
-- Symmetry of kind and type equality.
≅-sym : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j ≅ k → Γ ⊢ k ≅ j
≅-sym (<∷-antisym j-kd k-kd j<:k k<∷j) = <∷-antisym k-kd j-kd k<∷j j<:k
≃-sym : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a ≃ b ⇇ k → Γ ⊢ b ≃ a ⇇ k
≃-sym (<:-antisym k-kd a<:b b<:a) = <:-antisym k-kd b<:a a<:b
-- Transitivity of checked subtyping and type equality are admissible.
<:⇇-trans : ∀ {n} {Γ : Ctx n} {a b c k} →
Γ ⊢ a <: b ⇇ k → Γ ⊢ b <: c ⇇ k → Γ ⊢ a <: c ⇇ k
<:⇇-trans (<:-⇇ a₁⇇b⋯c _ a₁<:a₂) (<:-⇇ _ a₃⇇b⋯c a₂<:a₃) =
<:-⇇ a₁⇇b⋯c a₃⇇b⋯c (<:-trans a₁<:a₂ a₂<:a₃)
<:⇇-trans (<:-λ a₁<:a₂ Λj₁a₁⇇Πjk _) (<:-λ a₂<:a₃ _ Λj₃a₃⇇Πjk) =
<:-λ (<:⇇-trans a₁<:a₂ a₂<:a₃) Λj₁a₁⇇Πjk Λj₃a₃⇇Πjk
≃-trans : ∀ {n} {Γ : Ctx n} {a b c k} →
Γ ⊢ a ≃ b ⇇ k → Γ ⊢ b ≃ c ⇇ k → Γ ⊢ a ≃ c ⇇ k
≃-trans (<:-antisym k-kd a<:b⇇k b<:a⇇k) (<:-antisym _ b<:c⇇k c<:b⇇k) =
<:-antisym k-kd (<:⇇-trans a<:b⇇k b<:c⇇k) (<:⇇-trans c<:b⇇k b<:a⇇k)
-- The synthesized kind of a normal proper type is exactly the singleton
-- containing that type.
Nf⇉-≡ : ∀ {n} {Γ : Ctx n} {a b c} → Γ ⊢Nf a ⇉ b ⋯ c → a ≡ b × a ≡ c
Nf⇉-≡ (⇉-⊥-f Γ-ctx) = refl , refl
Nf⇉-≡ (⇉-⊤-f Γ-ctx) = refl , refl
Nf⇉-≡ (⇉-∀-f k-kd b⇉b⋯b) = refl , refl
Nf⇉-≡ (⇉-→-f a⇉a⋯a b⇉b⋯b) = refl , refl
Nf⇉-≡ (⇉-s-i a∈b⋯c) = refl , refl
-- Derived singleton introduction rules where the premises are
-- well-kinded normal forms rather than neutrals.
Nf⇉-s-i : ∀ {n} {Γ : Ctx n} {a b c} → Γ ⊢Nf a ⇉ b ⋯ c → Γ ⊢Nf a ⇉ a ⋯ a
Nf⇉-s-i a⇉b⋯c with Nf⇉-≡ a⇉b⋯c
Nf⇉-s-i a⇉a⋯a | refl , refl = a⇉a⋯a
Nf⇇-s-i : ∀ {n} {Γ : Ctx n} {a b c} → Γ ⊢Nf a ⇇ b ⋯ c → Γ ⊢Nf a ⇉ a ⋯ a
Nf⇇-s-i (⇇-⇑ a⇉b₁⋯c₁ (<∷-⋯ b₂<:b₁ c₁<:c₂)) = Nf⇉-s-i a⇉b₁⋯c₁
-- Inhabitants of interval kinds are proper types.
Nf⇉-⋯-* : ∀ {n} {Γ : Ctx n} {a b c} → Γ ⊢Nf a ⇉ b ⋯ c → Γ ⊢Nf a ⇇ ⌜*⌝
Nf⇉-⋯-* a⇉b⋯c with Nf⇉-≡ a⇉b⋯c
Nf⇉-⋯-* a⇉a⋯a | refl , refl = ⇇-⇑ a⇉a⋯a (<∷-⋯ (<:-⊥ a⇉a⋯a) (<:-⊤ a⇉a⋯a))
Nf⇇-⋯-* : ∀ {n} {Γ : Ctx n} {a b c} → Γ ⊢Nf a ⇇ b ⋯ c → Γ ⊢Nf a ⇇ ⌜*⌝
Nf⇇-⋯-* (⇇-⇑ a⇉b₁⋯c₁ (<∷-⋯ b₂<:b₁ c₁<:c₂)) = Nf⇉-⋯-* a⇉b₁⋯c₁
-- Validity of synthesized kinds: synthesized kinds are well-formed.
Nf⇉-valid : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Nf a ⇉ k → Γ ⊢ k kd
Nf⇉-valid (⇉-⊥-f Γ-ctx) = kd-⋯ (⇉-⊥-f Γ-ctx) (⇉-⊥-f Γ-ctx)
Nf⇉-valid (⇉-⊤-f Γ-ctx) = kd-⋯ (⇉-⊤-f Γ-ctx) (⇉-⊤-f Γ-ctx)
Nf⇉-valid (⇉-∀-f k-kd a⇉a⋯a) = kd-⋯ (⇉-∀-f k-kd a⇉a⋯a) (⇉-∀-f k-kd a⇉a⋯a)
Nf⇉-valid (⇉-→-f a⇉a⋯a b⇉b⋯b) = kd-⋯ (⇉-→-f a⇉a⋯a b⇉b⋯b) (⇉-→-f a⇉a⋯a b⇉b⋯b)
Nf⇉-valid (⇉-Π-i j-kd a⇉k) = kd-Π j-kd (Nf⇉-valid a⇉k)
Nf⇉-valid (⇉-s-i a∈b⋯c) = kd-⋯ (⇉-s-i a∈b⋯c) (⇉-s-i a∈b⋯c)
-- Validity of checked subtyping: the checked subtyping judgment
-- relates well-kinded types.
<:⇇-valid : ∀ {n} {Γ : Ctx n} {a b k} →
Γ ⊢ a <: b ⇇ k → Γ ⊢Nf a ⇇ k × Γ ⊢Nf b ⇇ k
<:⇇-valid (<:-⇇ a⇇k b⇇k a<:b) = a⇇k , b⇇k
<:⇇-valid (<:-λ a₁<:a₂ Λj₁a₁⇇Πjk Λj₂a₂⇇Πjk) = Λj₁a₁⇇Πjk , Λj₂a₂⇇Πjk
-- Validity of kind and type equality: the equality judgments relate
-- well-formed kinds, resp. well-kinded types.
≅-valid : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j ≅ k → Γ ⊢ j kd × Γ ⊢ k kd
≅-valid (<∷-antisym j-kd k-kd j<∷k k<∷j) = j-kd , k-kd
≃-valid : ∀ {n} {Γ : Ctx n} {a b k} →
Γ ⊢ a ≃ b ⇇ k → Γ ⊢Nf a ⇇ k × Γ ⊢Nf b ⇇ k
≃-valid (<:-antisym k-kd a<:b⇇k b<:a⇇k) = <:⇇-valid a<:b⇇k
≃-valid-kd : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a ≃ b ⇇ k → Γ ⊢ k kd
≃-valid-kd (<:-antisym k-kd a<:b b<:a) = k-kd
-- NOTE. In order to prove validity for the remainder of the kinding,
-- subkinding and subtyping judgments, we first need to prove that
-- hereditary substitutions preserve well-formedness of kinds (see
-- Kinding.Canonical.HereditarySubstitution). See the definition of
-- `Var∈-valid' below and the module Kinding.Canonical.Validity for
-- the remaining (strong) validity lemmas.
-- The synthesized kinds of neutrals kind-check.
Nf⇇-ne : ∀ {n} {Γ : Ctx n} {a b c} → Γ ⊢Ne a ∈ b ⋯ c → Γ ⊢Nf a ⇇ b ⋯ c
Nf⇇-ne (∈-∙ x∈k k⇉as⇉b⋯c) =
⇇-⇑ (⇉-s-i (∈-∙ x∈k k⇉as⇉b⋯c))
(<∷-⋯ (<:-⟨| (∈-∙ x∈k k⇉as⇉b⋯c)) (<:-|⟩ (∈-∙ x∈k k⇉as⇉b⋯c)))
-- The contexts of (most of) the above judgments are well-formed.
--
-- NOTE. The exceptions are kinding and equality of spines, as the
-- ⇉-[] and ≃-[] rules offer no guarantee that the enclosing context
-- is well-formed. This is not a problem in practice, since
-- well-kinded spines are used in the kinding of neutral types, the
-- head of which is guaranteed to be kinded in a well-formed context.
mutual
kd-ctx : ∀ {n} {Γ : Ctx n} {k} → Γ ⊢ k kd → Γ ctx
kd-ctx (kd-⋯ a⇉a⋯a b⇉b⋯b) = Nf⇉-ctx a⇉a⋯a
kd-ctx (kd-Π j-kd k-kd) = kd-ctx j-kd
Nf⇉-ctx : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Nf a ⇉ k → Γ ctx
Nf⇉-ctx (⇉-⊥-f Γ-ctx) = Γ-ctx
Nf⇉-ctx (⇉-⊤-f Γ-ctx) = Γ-ctx
Nf⇉-ctx (⇉-∀-f k-kd a⇉a⋯a) = kd-ctx k-kd
Nf⇉-ctx (⇉-→-f a⇉a⋯a b⇉b⋯b) = Nf⇉-ctx a⇉a⋯a
Nf⇉-ctx (⇉-Π-i j-kd a⇉k) = kd-ctx j-kd
Nf⇉-ctx (⇉-s-i a∈b⋯c) = Ne∈-ctx a∈b⋯c
Ne∈-ctx : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Ne a ∈ k → Γ ctx
Ne∈-ctx (∈-∙ x∈j j⇉as⇉k) = Var∈-ctx x∈j
Var∈-ctx : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Var a ∈ k → Γ ctx
Var∈-ctx (⇉-var x Γ-ctx _) = Γ-ctx
Var∈-ctx (⇇-⇑ x∈j j<∷k k-kd) = Var∈-ctx x∈j
Nf⇇-ctx : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Nf a ⇇ k → Γ ctx
Nf⇇-ctx (⇇-⇑ a⇉j j<∷k) = Nf⇉-ctx a⇉j
mutual
<∷-ctx : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j <∷ k → Γ ctx
<∷-ctx (<∷-⋯ b₁<:a₁ a₂<:b₂) = <:-ctx b₁<:a₁
<∷-ctx (<∷-Π j₂<∷j₁ k₁<∷k₂ Πj₁k₁-kd) = <∷-ctx j₂<∷j₁
<:-ctx : ∀ {n} {Γ : Ctx n} {a b} → Γ ⊢ a <: b → Γ ctx
<:-ctx (<:-trans a<:b b<:c) = <:-ctx a<:b
<:-ctx (<:-⊥ a⇉a⋯a) = Nf⇉-ctx a⇉a⋯a
<:-ctx (<:-⊤ a⇉a⋯a) = Nf⇉-ctx a⇉a⋯a
<:-ctx (<:-∀ k₂<∷k₁ a₁<:a₂ _) = <∷-ctx k₂<∷k₁
<:-ctx (<:-→ a₂<:a₁ b₁<:b₂) = <:-ctx a₂<:a₁
<:-ctx (<:-∙ x∈j as<:bs) = Var∈-ctx x∈j
<:-ctx (<:-⟨| a∈b⋯c) = Ne∈-ctx a∈b⋯c
<:-ctx (<:-|⟩ a∈b⋯c) = Ne∈-ctx a∈b⋯c
≅-ctx : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j ≅ k → Γ ctx
≅-ctx (<∷-antisym j-kd k-kd j<∷k k<∷j) = <∷-ctx j<∷k
wf-ctx : ∀ {n} {Γ : Ctx n} {a} → Γ ⊢ a wf → Γ ctx
wf-ctx (wf-kd k-kd) = kd-ctx k-kd
wf-ctx (wf-tp a⇉a⋯a) = Nf⇉-ctx a⇉a⋯a
<:⇇-ctx : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a <: b ⇇ k → Γ ctx
<:⇇-ctx (<:-⇇ a⇇k b⇇k a<:b) = Nf⇇-ctx a⇇k
<:⇇-ctx (<:-λ a₁<:a₂ Λj₁a₁⇇Πjk Λj₂a₂⇇Πjk) = Nf⇇-ctx Λj₁a₁⇇Πjk
≃-ctx : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a ≃ b ⇇ k → Γ ctx
≃-ctx (<:-antisym k-kd a<:b b<:a) = <:⇇-ctx a<:b
Var′∈-ctx : ∀ {n} {Γ : Ctx n} {x a} → Γ ⊢Var′ x ∈ a → Γ ctx
Var′∈-ctx (∈-tp x∈k) = Var∈-ctx x∈k
Var′∈-ctx (∈-tm _ Γ-ctx _) = Γ-ctx
-- An admissible formation rule for the kind of proper types.
kd-⌜*⌝ : ∀ {n} {Γ : Ctx n} → Γ ctx → Γ ⊢ ⌜*⌝ kd
kd-⌜*⌝ Γ-ctx = kd-⋯ (⇉-⊥-f Γ-ctx) (⇉-⊤-f Γ-ctx)
-- Admissible formation rules for canonically kinded proper types.
Nf⇇-∀-f : ∀ {n} {Γ : Ctx n} {k a} →
Γ ⊢ k kd → kd k ∷ Γ ⊢Nf a ⇇ ⌜*⌝ → Γ ⊢Nf ∀∙ k a ⇇ ⌜*⌝
Nf⇇-∀-f k-kd a⇇* =
let a⇉a⋯a = Nf⇇-s-i a⇇*
in Nf⇉-⋯-* (⇉-∀-f k-kd a⇉a⋯a)
Nf⇇-→-f : ∀ {n} {Γ : Ctx n} {a b} →
Γ ⊢Nf a ⇇ ⌜*⌝ → Γ ⊢Nf b ⇇ ⌜*⌝ → Γ ⊢Nf a ⇒∙ b ⇇ ⌜*⌝
Nf⇇-→-f a⇇* b⇇* =
let a⇉a⋯a = Nf⇇-s-i a⇇*
b⇉b⋯b = Nf⇇-s-i b⇇*
in Nf⇉-⋯-* (⇉-→-f a⇉a⋯a b⇉b⋯b)
-- Admissible kinding and equality rules for appending a normal form
-- to a spine.
⇉-∷ʳ : ∀ {n} {Γ : Ctx n} {as : Spine n} {a j k l} →
Γ ⊢ j ⇉∙ as ⇉ Π k l → Γ ⊢Nf a ⇇ k → Γ ⊢ k kd →
Γ ⊢ j ⇉∙ as ∷ʳ a ⇉ l Kind[ a ∈ ⌊ k ⌋ ]
⇉-∷ʳ ⇉-[] a⇇k k-kd = ⇉-∷ a⇇k k-kd ⇉-[]
⇉-∷ʳ (⇉-∷ a⇇j j-kd k[a]⇉as⇉Πlm) b⇇l l-kd =
⇉-∷ a⇇j j-kd (⇉-∷ʳ k[a]⇉as⇉Πlm b⇇l l-kd)
≃-∷ʳ : ∀ {n} {Γ : Ctx n} {as bs : Spine n} {a b j k l} →
Γ ⊢ j ⇉∙ as ≃ bs ⇉ Π k l → Γ ⊢ a ≃ b ⇇ k →
Γ ⊢ j ⇉∙ as ∷ʳ a ≃ bs ∷ʳ b ⇉ l Kind[ a ∈ ⌊ k ⌋ ]
≃-∷ʳ ≃-[] a≃b = ≃-∷ a≃b ≃-[]
≃-∷ʳ (≃-∷ a≃b as≃bs) c≃d = ≃-∷ a≃b (≃-∷ʳ as≃bs c≃d)
----------------------------------------------------------------------
-- Well-kinded variable substitutions in canonically kinded types
--
-- We define two different kinds of well-kinded variable
-- substitutions:
--
-- 1. well-kinded renamings, which don't change kinds of variables,
--
-- 2. variable substitutions that also allow conversion/subsumption.
--
-- The first kind are used to prove e.g. that weakening preserve
-- (canonical) well-kindedness, while the second kind are used to
-- prove context conversion/narrowing preserves well-kindedness. The
-- two definitions share a common generic core, which is instantiated
-- to obtain the concrete definitions. The two separate definitions
-- are necessary because the latter requires the weakening lemma,
-- which in turn depends on the former.
-- Liftings between variable typings
record LiftTo-Var′∈ (_⊢V_∈_ : Typing ElimAsc Fin ElimAsc lzero) : Set₁ where
open Substitution using (weakenElimAsc; _ElimAsc/Var_)
typedSub : TypedSub ElimAsc Fin lzero
typedSub = record
{ _⊢_wf = _⊢_wf
; _⊢_∈_ = _⊢V_∈_
; typeExtension = record { weaken = weakenElimAsc }
; typeTermApplication = record { _/_ = _ElimAsc/Var_ }
; termSimple = VarSubst.simple
}
open TypedSub typedSub public
renaming (_⊢/_∈_ to _⊢/Var_∈_) hiding (_⊢_wf; _⊢_∈_; typeExtension)
-- Simple typed variable substitutions.
field typedSimple : TypedSimple typedSub
open TypedSimple typedSimple public renaming (lookup to /∈-lookup)
-- Lifts well-typed Term₁-terms to well-typed Term₂-terms.
field ∈-lift : ∀ {n} {Γ : Ctx n} {x a} → Γ ⊢V x ∈ a → Γ ⊢Var′ x ∈ a
module TypedVarSubstApp (_⊢V_∈_ : Typing ElimAsc Fin ElimAsc lzero)
(liftTyped : LiftTo-Var′∈ _⊢V_∈_)
where
open LiftTo-Var′∈ liftTyped
open Substitution hiding (subst; _/Var_) renaming (_Elim/Var_ to _/Var_)
open RenamingCommutes using (Kind[∈⌊⌋]-/Var)
-- A helper.
∈-↑′ : ∀ {m n} {Δ : Ctx n} {Γ : Ctx m} {k ρ} →
Δ ⊢ k Kind′/Var ρ kd → Δ ⊢/Var ρ ∈ Γ →
kd (k Kind′/Var ρ) ∷ Δ ⊢/Var ρ VarSubst.↑ ∈ kd k ∷ Γ
∈-↑′ k/ρ-kd ρ∈Γ = ∈-↑ (wf-kd k/ρ-kd) ρ∈Γ
-- Convert between well-kindedness judgments for variables.
V∈-Var∈ : ∀ {n} {Γ : Ctx n} {x a k} → a ≡ kd k →
Γ ⊢V x ∈ a → Γ ⊢Var x ∈ k
V∈-Var∈ refl xT∈kd-k with ∈-lift xT∈kd-k
V∈-Var∈ refl xT∈kd-k | ∈-tp x∈k = x∈k
mutual
-- Renamings preserve well-formedness of ascriptions.
wf-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a ρ} →
Γ ⊢ a wf → Δ ⊢/Var ρ ∈ Γ → Δ ⊢ a ElimAsc/Var ρ wf
wf-/Var (wf-kd k-kd) ρ∈Γ = wf-kd (kd-/Var k-kd ρ∈Γ)
wf-/Var (wf-tp a⇉a⋯a) ρ∈Γ = wf-tp (Nf⇉-/Var a⇉a⋯a ρ∈Γ)
-- Renamings preserve well-formedness of kinds.
kd-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {k ρ} →
Γ ⊢ k kd → Δ ⊢/Var ρ ∈ Γ → Δ ⊢ k Kind′/Var ρ kd
kd-/Var (kd-⋯ a⇉a⋯a b⇉b⋯b) ρ∈Γ =
kd-⋯ (Nf⇉-/Var a⇉a⋯a ρ∈Γ) (Nf⇉-/Var b⇉b⋯b ρ∈Γ)
kd-/Var (kd-Π j-kd k-kd) ρ∈Γ =
let j/ρ-kd = kd-/Var j-kd ρ∈Γ
in kd-Π j/ρ-kd (kd-/Var k-kd (∈-↑′ j/ρ-kd ρ∈Γ))
-- Renamings preserve synthesized kinds of normal types.
Nf⇉-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a k ρ} →
Γ ⊢Nf a ⇉ k → Δ ⊢/Var ρ ∈ Γ → Δ ⊢Nf a /Var ρ ⇉ k Kind′/Var ρ
Nf⇉-/Var (⇉-⊥-f Γ-ctx) ρ∈Γ = ⇉-⊥-f (/∈-wf ρ∈Γ)
Nf⇉-/Var (⇉-⊤-f Γ-ctx) ρ∈Γ = ⇉-⊤-f (/∈-wf ρ∈Γ)
Nf⇉-/Var (⇉-∀-f k-kd a⇉a⋯a) ρ∈Γ =
let k/ρ-kd = kd-/Var k-kd ρ∈Γ
in ⇉-∀-f k/ρ-kd (Nf⇉-/Var a⇉a⋯a (∈-↑′ k/ρ-kd ρ∈Γ))
Nf⇉-/Var (⇉-→-f a⇉a⋯a b⇉b⋯b) ρ∈Γ =
⇉-→-f (Nf⇉-/Var a⇉a⋯a ρ∈Γ) (Nf⇉-/Var b⇉b⋯b ρ∈Γ)
Nf⇉-/Var (⇉-Π-i j-kd a⇉k) ρ∈Γ =
let j/ρ-kd = kd-/Var j-kd ρ∈Γ
in ⇉-Π-i j/ρ-kd (Nf⇉-/Var a⇉k (∈-↑′ j/ρ-kd ρ∈Γ))
Nf⇉-/Var (⇉-s-i a∈b⋯c) ρ∈Γ = ⇉-s-i (Ne∈-/Var a∈b⋯c ρ∈Γ)
-- Renamings preserve the kinds of variables.
Var∈-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {x k ρ} →
Γ ⊢Var x ∈ k → Δ ⊢/Var ρ ∈ Γ →
Δ ⊢Var (Vec.lookup ρ x) ∈ k Kind′/Var ρ
Var∈-/Var {ρ = ρ} (⇉-var x Γ-ctx Γ[x]≡kd-k) ρ∈Γ =
V∈-Var∈ (cong (_ElimAsc/Var ρ) Γ[x]≡kd-k) (/∈-lookup ρ∈Γ x)
Var∈-/Var (⇇-⇑ x∈j j<∷k k-kd) ρ∈Γ =
⇇-⇑ (Var∈-/Var x∈j ρ∈Γ) (<∷-/Var j<∷k ρ∈Γ) (kd-/Var k-kd ρ∈Γ)
-- Renamings preserve synthesized kinds of neutral types.
Ne∈-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a k ρ} →
Γ ⊢Ne a ∈ k → Δ ⊢/Var ρ ∈ Γ → Δ ⊢Ne a /Var ρ ∈ k Kind′/Var ρ
Ne∈-/Var (∈-∙ x∈j k⇉as⇉l) ρ∈Γ =
∈-∙ (Var∈-/Var x∈j ρ∈Γ) (Sp⇉-/Var k⇉as⇉l ρ∈Γ)
-- Renamings preserve spine kindings.
Sp⇉-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {as j k ρ} →
Γ ⊢ j ⇉∙ as ⇉ k → Δ ⊢/Var ρ ∈ Γ →
Δ ⊢ j Kind′/Var ρ ⇉∙ as //Var ρ ⇉ k Kind′/Var ρ
Sp⇉-/Var ⇉-[] ρ∈Γ = ⇉-[]
Sp⇉-/Var (⇉-∷ {a} {_} {j} {k} a⇇j j-kd k[a]⇉as⇉l) ρ∈Γ =
⇉-∷ (Nf⇇-/Var a⇇j ρ∈Γ) (kd-/Var j-kd ρ∈Γ)
(subst (_ ⊢_⇉∙ _ ⇉ _) (Kind[∈⌊⌋]-/Var k a j)
(Sp⇉-/Var k[a]⇉as⇉l ρ∈Γ))
-- Renamings preserve checked kinds of neutral types.
Nf⇇-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a k ρ} →
Γ ⊢Nf a ⇇ k → Δ ⊢/Var ρ ∈ Γ → Δ ⊢Nf a /Var ρ ⇇ k Kind′/Var ρ
Nf⇇-/Var (⇇-⇑ a⇉j j<∷k) ρ∈Γ = ⇇-⇑ (Nf⇉-/Var a⇉j ρ∈Γ) (<∷-/Var j<∷k ρ∈Γ)
-- Renamings preserve subkinding.
<∷-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {j k ρ} →
Γ ⊢ j <∷ k → Δ ⊢/Var ρ ∈ Γ → Δ ⊢ j Kind′/Var ρ <∷ k Kind′/Var ρ
<∷-/Var (<∷-⋯ a₂<:a₁ b₁<:b₂) ρ∈Γ =
<∷-⋯ (<:-/Var a₂<:a₁ ρ∈Γ) (<:-/Var b₁<:b₂ ρ∈Γ)
<∷-/Var (<∷-Π j₂<∷j₁ k₁<∷k₂ Πj₁k₁-kd) ρ∈Γ =
<∷-Π (<∷-/Var j₂<∷j₁ ρ∈Γ)
(<∷-/Var k₁<∷k₂ (∈-↑ (<∷-/Var-wf k₁<∷k₂ ρ∈Γ) ρ∈Γ))
(kd-/Var Πj₁k₁-kd ρ∈Γ)
-- Renamings preserve subtyping.
<:-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a b ρ} →
Γ ⊢ a <: b → Δ ⊢/Var ρ ∈ Γ → Δ ⊢ a /Var ρ <: b /Var ρ
<:-/Var (<:-trans a<:b b<:c) ρ∈Γ =
<:-trans (<:-/Var a<:b ρ∈Γ) (<:-/Var b<:c ρ∈Γ)
<:-/Var (<:-⊥ a⇉a⋯a) ρ∈Γ = <:-⊥ (Nf⇉-/Var a⇉a⋯a ρ∈Γ)
<:-/Var (<:-⊤ a⇉a⋯a) ρ∈Γ = <:-⊤ (Nf⇉-/Var a⇉a⋯a ρ∈Γ)
<:-/Var (<:-∀ k₂<∷k₁ a₁<:a₂ Πk₁a₁⇉Πk₁a₁⋯Πk₁a₁) ρ∈Γ =
<:-∀ (<∷-/Var k₂<∷k₁ ρ∈Γ)
(<:-/Var a₁<:a₂ (∈-↑ (<:-/Var-wf a₁<:a₂ ρ∈Γ) ρ∈Γ))
(Nf⇉-/Var Πk₁a₁⇉Πk₁a₁⋯Πk₁a₁ ρ∈Γ)
<:-/Var (<:-→ a₂<:a₁ b₁<:b₂) ρ∈Γ =
<:-→ (<:-/Var a₂<:a₁ ρ∈Γ) (<:-/Var b₁<:b₂ ρ∈Γ)
<:-/Var (<:-∙ x∈j j⇉as₁<:as₂⇉k) ρ∈Γ =
<:-∙ (Var∈-/Var x∈j ρ∈Γ) (Sp≃-/Var j⇉as₁<:as₂⇉k ρ∈Γ)
<:-/Var (<:-⟨| a∈b⋯c) ρ∈Γ = <:-⟨| (Ne∈-/Var a∈b⋯c ρ∈Γ)
<:-/Var (<:-|⟩ a∈b⋯c) ρ∈Γ = <:-|⟩ (Ne∈-/Var a∈b⋯c ρ∈Γ)
<:⇇-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a b k ρ} →
Γ ⊢ a <: b ⇇ k → Δ ⊢/Var ρ ∈ Γ →
Δ ⊢ a /Var ρ <: b /Var ρ ⇇ k Kind′/Var ρ
<:⇇-/Var (<:-⇇ a⇇k b⇇k a<:b) ρ∈Γ =
<:-⇇ (Nf⇇-/Var a⇇k ρ∈Γ) (Nf⇇-/Var b⇇k ρ∈Γ) (<:-/Var a<:b ρ∈Γ)
<:⇇-/Var (<:-λ a₁<:a₂ Λj₁a₁⇇Πjk Λj₂a₂⇇Πjk) ρ∈Γ =
<:-λ (<:⇇-/Var a₁<:a₂ (∈-↑ (<:⇇-/Var-wf a₁<:a₂ ρ∈Γ) ρ∈Γ))
(Nf⇇-/Var Λj₁a₁⇇Πjk ρ∈Γ) (Nf⇇-/Var Λj₂a₂⇇Πjk ρ∈Γ)
-- Renamings preserve type equality.
≃-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a b k ρ} →
Γ ⊢ a ≃ b ⇇ k → Δ ⊢/Var ρ ∈ Γ →
Δ ⊢ a /Var ρ ≃ b /Var ρ ⇇ k Kind′/Var ρ
≃-/Var (<:-antisym k-kd a<:b b<:a) ρ∈Γ =
<:-antisym (kd-/Var k-kd ρ∈Γ) (<:⇇-/Var a<:b ρ∈Γ) (<:⇇-/Var b<:a ρ∈Γ)
Sp≃-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {as bs j k ρ} →
Γ ⊢ j ⇉∙ as ≃ bs ⇉ k → Δ ⊢/Var ρ ∈ Γ →
Δ ⊢ j Kind′/Var ρ ⇉∙ as //Var ρ ≃ bs //Var ρ ⇉ k Kind′/Var ρ
Sp≃-/Var ≃-[] ρ∈Γ = ≃-[]
Sp≃-/Var (≃-∷ {a} {_} {_} {_} {j} {k} a≃b as≃bs) ρ∈Γ =
≃-∷ (≃-/Var a≃b ρ∈Γ)
(subst (_ ⊢_⇉∙ _ ≃ _ ⇉ _) (Kind[∈⌊⌋]-/Var k a j)
(Sp≃-/Var as≃bs ρ∈Γ))
-- Helpers (to satisfy the termination checker).
--
-- These are simply (manual) expansions of the form
--
-- XX-/Var-wf x ρ∈Γ = wf-/Var (wf-∷₁ (XX-ctx x)) ρ∈Γ
--
-- to ensure the above definitions remain structurally recursive
-- in the various derivations.
kd-/Var-wf : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {j k ρ} →
kd j ∷ Γ ⊢ k kd → Δ ⊢/Var ρ ∈ Γ → Δ ⊢ kd (j Kind′/Var ρ) wf
kd-/Var-wf (kd-⋯ a∈a⋯a _) ρ∈Γ = Nf⇉-/Var-wf a∈a⋯a ρ∈Γ
kd-/Var-wf (kd-Π j-kd _) ρ∈Γ = kd-/Var-wf j-kd ρ∈Γ
Nf⇉-/Var-wf : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a j k ρ} →
kd j ∷ Γ ⊢Nf a ⇉ k → Δ ⊢/Var ρ ∈ Γ →
Δ ⊢ kd (j Kind′/Var ρ) wf
Nf⇉-/Var-wf (⇉-⊥-f (j-wf ∷ _)) ρ∈Γ = wf-/Var j-wf ρ∈Γ
Nf⇉-/Var-wf (⇉-⊤-f (j-wf ∷ _)) ρ∈Γ = wf-/Var j-wf ρ∈Γ
Nf⇉-/Var-wf (⇉-∀-f k-kd _) ρ∈Γ = kd-/Var-wf k-kd ρ∈Γ
Nf⇉-/Var-wf (⇉-→-f a⇉a⋯a _) ρ∈Γ = Nf⇉-/Var-wf a⇉a⋯a ρ∈Γ
Nf⇉-/Var-wf (⇉-Π-i j-kd _) ρ∈Γ = kd-/Var-wf j-kd ρ∈Γ
Nf⇉-/Var-wf (⇉-s-i a∈b⋯c) ρ∈Γ = Ne∈-/Var-wf a∈b⋯c ρ∈Γ
Ne∈-/Var-wf : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a j k ρ} →
kd j ∷ Γ ⊢Ne a ∈ k → Δ ⊢/Var ρ ∈ Γ →
Δ ⊢ kd (j Kind′/Var ρ) wf
Ne∈-/Var-wf (∈-∙ x∈k _) ρ∈Γ = Var∈-/Var-wf x∈k ρ∈Γ
Var∈-/Var-wf : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a j k ρ} →
kd j ∷ Γ ⊢Var a ∈ k → Δ ⊢/Var ρ ∈ Γ →
Δ ⊢ kd (j Kind′/Var ρ) wf
Var∈-/Var-wf (⇉-var x (j-wf ∷ _) _) ρ∈Γ = wf-/Var j-wf ρ∈Γ
Var∈-/Var-wf (⇇-⇑ x∈j _ _) ρ∈Γ = Var∈-/Var-wf x∈j ρ∈Γ
Nf⇇-/Var-wf : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a j k ρ} →
kd j ∷ Γ ⊢Nf a ⇇ k → Δ ⊢/Var ρ ∈ Γ →
Δ ⊢ kd (j Kind′/Var ρ) wf
Nf⇇-/Var-wf (⇇-⇑ a⇉j _) ρ∈Γ = Nf⇉-/Var-wf a⇉j ρ∈Γ
<∷-/Var-wf : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {j k l ρ} →
kd j ∷ Γ ⊢ k <∷ l → Δ ⊢/Var ρ ∈ Γ → Δ ⊢ kd (j Kind′/Var ρ) wf
<∷-/Var-wf (<∷-⋯ a₂<:a₁ _) ρ∈Γ = <:-/Var-wf a₂<:a₁ ρ∈Γ
<∷-/Var-wf (<∷-Π j₂<∷j₁ _ _) ρ∈Γ = <∷-/Var-wf j₂<∷j₁ ρ∈Γ
<:-/Var-wf : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a b j ρ} →
kd j ∷ Γ ⊢ a <: b → Δ ⊢/Var ρ ∈ Γ →
Δ ⊢ kd (j Kind′/Var ρ) wf
<:-/Var-wf (<:-trans a<:b _) ρ∈Γ = <:-/Var-wf a<:b ρ∈Γ
<:-/Var-wf (<:-⊥ a⇉a⋯a) ρ∈Γ = Nf⇉-/Var-wf a⇉a⋯a ρ∈Γ
<:-/Var-wf (<:-⊤ a⇉a⋯a) ρ∈Γ = Nf⇉-/Var-wf a⇉a⋯a ρ∈Γ
<:-/Var-wf (<:-∀ k₂<∷k₁ _ _) ρ∈Γ = <∷-/Var-wf k₂<∷k₁ ρ∈Γ
<:-/Var-wf (<:-→ a₂<:a₁ _) ρ∈Γ = <:-/Var-wf a₂<:a₁ ρ∈Γ
<:-/Var-wf (<:-∙ x∈j _) ρ∈Γ = Var∈-/Var-wf x∈j ρ∈Γ
<:-/Var-wf (<:-⟨| a∈b⋯c) ρ∈Γ = Ne∈-/Var-wf a∈b⋯c ρ∈Γ
<:-/Var-wf (<:-|⟩ a∈b⋯c) ρ∈Γ = Ne∈-/Var-wf a∈b⋯c ρ∈Γ
<:⇇-/Var-wf : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a b j k ρ} →
kd j ∷ Γ ⊢ a <: b ⇇ k → Δ ⊢/Var ρ ∈ Γ →
Δ ⊢ kd (j Kind′/Var ρ) wf
<:⇇-/Var-wf (<:-⇇ a⇇k _ _) ρ∈Γ = Nf⇇-/Var-wf a⇇k ρ∈Γ
<:⇇-/Var-wf (<:-λ _ Λj₁a₁⇇Πjk _) ρ∈Γ = Nf⇇-/Var-wf Λj₁a₁⇇Πjk ρ∈Γ
≅-/Var-wf : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {j k l ρ} →
kd j ∷ Γ ⊢ k ≅ l → Δ ⊢/Var ρ ∈ Γ → Δ ⊢ kd (j Kind′/Var ρ) wf
≅-/Var-wf (<∷-antisym _ _ j<∷k _) ρ∈Γ = <∷-/Var-wf j<∷k ρ∈Γ
-- Renamings preserve kind equality.
≅-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {j k ρ} →
Γ ⊢ j ≅ k → Δ ⊢/Var ρ ∈ Γ → Δ ⊢ j Kind′/Var ρ ≅ k Kind′/Var ρ
≅-/Var (<∷-antisym j-kd k-kd j<∷k k<∷j) ρ∈Γ =
<∷-antisym (kd-/Var j-kd ρ∈Γ) (kd-/Var k-kd ρ∈Γ)
(<∷-/Var j<∷k ρ∈Γ) (<∷-/Var k<∷j ρ∈Γ)
-- Renamings preserve wrapped variable typing
Var′∈-/Var : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {x k ρ} →
Γ ⊢Var′ x ∈ k → Δ ⊢/Var ρ ∈ Γ →
Δ ⊢Var′ (Vec.lookup ρ x) ∈ k ElimAsc/Var ρ
Var′∈-/Var (∈-tp x∈k) ρ∈Γ = ∈-tp (Var∈-/Var x∈k ρ∈Γ)
Var′∈-/Var {ρ = ρ} (∈-tm x Γ-ctx Γ[x]≡tp-t) ρ∈Γ =
subst (_ ⊢Var′ _ ∈_) (cong (_ElimAsc/Var ρ) Γ[x]≡tp-t)
(∈-lift (/∈-lookup ρ∈Γ x))
-- Well-kinded renamings in canonically kinded types, i.e. lemmas
-- showing that renaming preserves kinding.
--
-- Note that these are pure renamings that cannot change the kinds of
-- variables (i.e. they cannot be used to implement context conversion
-- or narrowing).
module KindedRenaming where
open Substitution using (termLikeLemmasElimAsc)
typedVarSubst : TypedVarSubst ElimAsc lzero
typedVarSubst = record
{ _⊢_wf = _⊢_wf
; typeExtension = ElimCtx.weakenOps
; typeVarApplication = AppLemmas.application appLemmas
; wf-wf = wf-ctx
; /-wk = refl
; id-vanishes = id-vanishes
; /-⊙ = /-⊙
}
where
open TermLikeLemmas termLikeLemmasElimAsc using (varLiftAppLemmas)
open LiftAppLemmas varLiftAppLemmas
open TypedVarSubst typedVarSubst
hiding (_⊢_wf) renaming (_⊢Var_∈_ to _⊢GenVar_∈_)
-- Liftings from generic variable typings to variable kindings.
liftTyped : LiftTo-Var′∈ _⊢GenVar_∈_
liftTyped = record
{ typedSimple = typedSimple
; ∈-lift = ∈-lift
}
where
∈-lift : ∀ {n} {Γ : Ctx n} {x a} → Γ ⊢GenVar x ∈ a → Γ ⊢Var′ x ∈ a
∈-lift (∈-var x Γ-ctx) = ∈-var′ x Γ-ctx
open TypedVarSubstApp _⊢GenVar_∈_ liftTyped public
open Substitution hiding (subst)
-- Weakening preserves well-formedness of kinds.
kd-weaken : ∀ {n} {Γ : Ctx n} {a k} →
Γ ⊢ a wf → Γ ⊢ k kd → a ∷ Γ ⊢ weakenKind′ k kd
kd-weaken a-wf k-kd = kd-/Var k-kd (∈-wk a-wf)
-- Weakening preserves variable kinding.
Var∈-weaken : ∀ {n} {Γ : Ctx n} {a x k} → Γ ⊢ a wf →
Γ ⊢Var x ∈ k →
a ∷ Γ ⊢Var Vec.lookup VarSubst.wk x ∈ weakenKind′ k
Var∈-weaken a-wf x∈k = Var∈-/Var x∈k (∈-wk a-wf)
Var′∈-weaken : ∀ {n} {Γ : Ctx n} {a x b} → Γ ⊢ a wf →
Γ ⊢Var′ x ∈ b → a ∷ Γ ⊢Var′ suc x ∈ weakenElimAsc b
Var′∈-weaken a-wf x∈b =
subst (_ ⊢Var′_∈ _) VarLemmas./-wk (Var′∈-/Var x∈b (∈-wk a-wf))
-- Weakening preserves spine kinding.
Sp⇉-weaken : ∀ {n} {Γ : Ctx n} {a bs j k} → Γ ⊢ a wf → Γ ⊢ j ⇉∙ bs ⇉ k →
a ∷ Γ ⊢ weakenKind′ j ⇉∙ weakenSpine bs ⇉ weakenKind′ k
Sp⇉-weaken a-wf j⇉bs⇉k = Sp⇉-/Var j⇉bs⇉k (∈-wk a-wf)
-- Weakening preserves checked kinding.
Nf⇇-weaken : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a wf →
Γ ⊢Nf b ⇇ k → (a ∷ Γ) ⊢Nf weakenElim b ⇇ weakenKind′ k
Nf⇇-weaken a-wf b⇇k = Nf⇇-/Var b⇇k (∈-wk a-wf)
-- Weakening preserves subkinding.
<∷-weaken : ∀ {n} {Γ : Ctx n} {a j k} → Γ ⊢ a wf →
Γ ⊢ j <∷ k → (a ∷ Γ) ⊢ weakenKind′ j <∷ weakenKind′ k
<∷-weaken a-wf j<∷k = <∷-/Var j<∷k (∈-wk a-wf)
-- Weakening preserves subtyping.
<:-weaken : ∀ {n} {Γ : Ctx n} {a b c} → Γ ⊢ a wf → Γ ⊢ b <: c →
a ∷ Γ ⊢ weakenElim b <: weakenElim c
<:-weaken a-wf b<:c = <:-/Var b<:c (∈-wk a-wf)
<:⇇-weaken : ∀ {n} {Γ : Ctx n} {a b c k} → Γ ⊢ a wf → Γ ⊢ b <: c ⇇ k →
a ∷ Γ ⊢ weakenElim b <: weakenElim c ⇇ weakenKind′ k
<:⇇-weaken a-wf b<:c = <:⇇-/Var b<:c (∈-wk a-wf)
-- Weakening preserves well-formedness of ascriptions.
wf-weaken : ∀ {n} {Γ : Ctx n} {a b} →
Γ ⊢ a wf → Γ ⊢ b wf → a ∷ Γ ⊢ weakenElimAsc b wf
wf-weaken a-wf b-wf = wf-/Var b-wf (∈-wk a-wf)
-- Weakening preserves kind and type equality.
≃-weaken : ∀ {n} {Γ : Ctx n} {a b c k} → Γ ⊢ a wf → Γ ⊢ b ≃ c ⇇ k →
a ∷ Γ ⊢ weakenElim b ≃ weakenElim c ⇇ weakenKind′ k
≃-weaken a-wf b≃c = ≃-/Var b≃c (∈-wk a-wf)
≅-weaken : ∀ {n} {Γ : Ctx n} {a j k} → Γ ⊢ a wf → Γ ⊢ j ≅ k →
a ∷ Γ ⊢ weakenKind′ j ≅ weakenKind′ k
≅-weaken a-wf j≅k = ≅-/Var j≅k (∈-wk a-wf)
Sp≃-weaken : ∀ {n} {Γ : Ctx n} {a bs cs j k} → Γ ⊢ a wf →
Γ ⊢ j ⇉∙ bs ≃ cs ⇉ k →
a ∷ Γ ⊢ weakenKind′ j ⇉∙ weakenSpine bs ≃ weakenSpine cs ⇉
weakenKind′ k
Sp≃-weaken a-wf bs≃cs = Sp≃-/Var bs≃cs (∈-wk a-wf)
-- Operations on well-formed contexts that require weakening of
-- well-formedness judgments.
module WfCtxOps where
open KindedRenaming using (wf-weaken)
wfWeakenOps : WellFormedWeakenOps weakenOps
wfWeakenOps = record { wf-weaken = wf-weaken }
open WellFormedWeakenOps wfWeakenOps public
hiding (wf-weaken) renaming (lookup to lookup-wf)
-- Lookup the kind of a type variable in a well-formed context.
lookup-kd : ∀ {m} {Γ : Ctx m} {k} x →
Γ ctx → ElimCtx.lookup Γ x ≡ kd k → Γ ⊢ k kd
lookup-kd x Γ-ctx Γ[x]≡kd-k =
wf-kd-inv (subst (_ ⊢_wf) Γ[x]≡kd-k (lookup-wf Γ-ctx x))
open WfCtxOps
-- A corollary (validity of variable kinding): the kinds of variables
-- are well-formed.
Var∈-valid : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Var a ∈ k → Γ ⊢ k kd
Var∈-valid (⇉-var x Γ-ctx Γ[x]≡kd-k) = lookup-kd x Γ-ctx Γ[x]≡kd-k
Var∈-valid (⇇-⇑ x∈j j<∷k k-kd) = k-kd
----------------------------------------------------------------------
-- Context narrowing
--
-- The various judgments are preserved by narrowing of kind
-- ascriptions in their contexts.
module ContextNarrowing where
open Substitution
using (termLikeLemmasElim; termLikeLemmasKind′; termLikeLemmasElimAsc)
open TermLikeLemmas termLikeLemmasElimAsc using (varLiftAppLemmas)
open LiftAppLemmas varLiftAppLemmas
open KindedRenaming using (kd-weaken; <∷-weaken; Var′∈-weaken)
private
module EL = LiftAppLemmas
(TermLikeLemmas.varLiftAppLemmas termLikeLemmasElim)
module KL = LiftAppLemmas
(TermLikeLemmas.varLiftAppLemmas termLikeLemmasKind′)
-- NOTE. Rather than proving context narrowing directly by induction
-- on typing derivations, we instead define a more flexible variant
-- of well-typed variable substitutions based on the canonical
-- variable kinding judgment (_⊢Var_∈_). This judgment features a
-- subsumption rule (∈-⇑), which is not available in the generic
-- variable judgment from Data.Fin.Substitutions.Typed that we used
-- to define basic typed renamings. With support for subsumption in
-- typed renamings, we get context narrowing "for free", as it is
-- just another variable substitution (one that happens to change
-- the kind rather than the name of a variable). This way of
-- proving context narrowing is more convenient since we can reuse
-- the generic lemmas proven for typed variable substitution and
-- avoid some explicit fiddling with context.
--
-- Note also that we could not have defined typed renamings
-- directly using the _⊢Var_∈_ judgment since that would have
-- required a weakening lemma for subkiding, which in turn is
-- implemented via typed renamings.
-- The trivial lifting from _⊢Var′_∈_ to itself, and simple typed
-- variable substitutions.
liftTyped : LiftTo-Var′∈ _⊢Var′_∈_
liftTyped = record
{ typedSimple = record
{ typedWeakenOps = record
{ ∈-weaken = Var′∈-weaken
; ∈-wf = Var′∈-ctx
; /-wk = refl
; /-weaken = /-weaken
; weaken-/-∷ = weaken-/-∷
}
; ∈-var = ∈-var′
; wf-wf = wf-ctx
; id-vanishes = id-vanishes
}
; ∈-lift = λ x∈a → x∈a
}
where
weakenLemmas : WeakenLemmas ElimAsc Fin
weakenLemmas = record { appLemmas = appLemmas ; /-wk = refl }
open WeakenLemmas weakenLemmas
open LiftTo-Var′∈ liftTyped
open TypedVarSubstApp _⊢Var′_∈_ liftTyped
-- A typed renaming that narrows the kind of the first type
-- variable.
∈-<∷-sub : ∀ {n} {Γ : Ctx n} {j k} →
Γ ⊢ j kd → Γ ⊢ j <∷ k → (kd k ∷ Γ) ctx →
kd j ∷ Γ ⊢/Var id ∈ kd k ∷ Γ
∈-<∷-sub j-kd j<∷k k∷Γ-ctx =
∈-tsub (∈-tp (⇇-⇑ x∈k (<∷-weaken j-wf j<∷k) k-kd))
where
j-wf = wf-kd j-kd
Γ-ctx = kd-ctx j-kd
x∈k = ⇉-var zero (j-wf ∷ Γ-ctx) refl
k-kd = kd-weaken j-wf (wf-kd-inv (wf-∷₁ k∷Γ-ctx))
-- Narrowing the kind of the first type variable preserves
-- well-formedness of kinds.
⇓-kd : ∀ {n} {Γ : Ctx n} {j₁ j₂ k} →
Γ ⊢ j₁ kd → Γ ⊢ j₁ <∷ j₂ → kd j₂ ∷ Γ ⊢ k kd → kd j₁ ∷ Γ ⊢ k kd
⇓-kd j₁-kd j₁<∷j₂ k-kd =
subst (_ ⊢_kd) (KL.id-vanishes _)
(kd-/Var k-kd (∈-<∷-sub j₁-kd j₁<∷j₂ (kd-ctx k-kd)))
-- Narrowing the kind of the first type variable preserves
-- well-kindedness.
⇓-Nf⇉ : ∀ {n} {Γ : Ctx n} {j₁ j₂ a k} →
Γ ⊢ j₁ kd → Γ ⊢ j₁ <∷ j₂ → kd j₂ ∷ Γ ⊢Nf a ⇉ k → kd j₁ ∷ Γ ⊢Nf a ⇉ k
⇓-Nf⇉ j₁-kd j₁<∷j₂ a⇉k =
subst₂ (_ ⊢Nf_⇉_) (EL.id-vanishes _) (KL.id-vanishes _)
(Nf⇉-/Var a⇉k (∈-<∷-sub j₁-kd j₁<∷j₂ (Nf⇉-ctx a⇉k)))
-- Narrowing the kind of the first type variable preserves
-- subkinding and subtyping.
⇓-<∷ : ∀ {n} {Γ : Ctx n} {j₁ j₂ k₁ k₂} →
Γ ⊢ j₁ kd → Γ ⊢ j₁ <∷ j₂ → kd j₂ ∷ Γ ⊢ k₁ <∷ k₂ → kd j₁ ∷ Γ ⊢ k₁ <∷ k₂
⇓-<∷ j₁-kd j₁<∷j₂ k₁<∷k₂ =
subst₂ (_ ⊢_<∷_) (KL.id-vanishes _) (KL.id-vanishes _)
(<∷-/Var k₁<∷k₂ (∈-<∷-sub j₁-kd j₁<∷j₂ (<∷-ctx k₁<∷k₂)))
⇓-<: : ∀ {n} {Γ : Ctx n} {j₁ j₂ a₁ a₂} →
Γ ⊢ j₁ kd → Γ ⊢ j₁ <∷ j₂ → kd j₂ ∷ Γ ⊢ a₁ <: a₂ → kd j₁ ∷ Γ ⊢ a₁ <: a₂
⇓-<: j₁-kd j₁<∷j₂ a₁<:a₂ =
subst₂ (_ ⊢_<:_) (EL.id-vanishes _) (EL.id-vanishes _)
(<:-/Var a₁<:a₂ (∈-<∷-sub j₁-kd j₁<∷j₂ (<:-ctx a₁<:a₂)))
⇓-<:⇇ : ∀ {n} {Γ : Ctx n} {j₁ j₂ a₁ a₂ k} →
Γ ⊢ j₁ kd → Γ ⊢ j₁ <∷ j₂ → kd j₂ ∷ Γ ⊢ a₁ <: a₂ ⇇ k →
kd j₁ ∷ Γ ⊢ a₁ <: a₂ ⇇ k
⇓-<:⇇ j₁-kd j₁<∷j₂ a₁<:a₂∈k =
subst (_ ⊢ _ <: _ ⇇_) (KL.id-vanishes _)
(subst₂ (_ ⊢_<:_⇇ _) (EL.id-vanishes _) (EL.id-vanishes _)
(<:⇇-/Var a₁<:a₂∈k
(∈-<∷-sub j₁-kd j₁<∷j₂ (<:⇇-ctx a₁<:a₂∈k))))
open KindedRenaming
open ContextNarrowing
open Substitution hiding (subst)
private module TV = TypedVarSubst typedVarSubst
-- Some corollaries of context narrowing: transitivity of subkinding
-- and kind equality are admissible.
<∷-trans : ∀ {n} {Γ : Ctx n} {j k l} → Γ ⊢ j <∷ k → Γ ⊢ k <∷ l → Γ ⊢ j <∷ l
<∷-trans (<∷-⋯ a₂<:a₁ b₁<:b₂) (<∷-⋯ a₃<:a₂ b₂<:b₃) =
<∷-⋯ (<:-trans a₃<:a₂ a₂<:a₁) (<:-trans b₁<:b₂ b₂<:b₃)
<∷-trans (<∷-Π j₂<∷j₁ k₁<∷k₂ Πj₁k₁-kd) (<∷-Π j₃<∷j₂ k₂<∷k₃ _) =
let j₃-kd = wf-kd-inv (wf-∷₁ (<∷-ctx k₂<∷k₃))
in <∷-Π (<∷-trans j₃<∷j₂ j₂<∷j₁)
(<∷-trans (⇓-<∷ j₃-kd j₃<∷j₂ k₁<∷k₂) k₂<∷k₃) Πj₁k₁-kd
≅-trans : ∀ {n} {Γ : Ctx n} {j k l} → Γ ⊢ j ≅ k → Γ ⊢ k ≅ l → Γ ⊢ j ≅ l
≅-trans (<∷-antisym j-kd _ j<∷k k<∷j) (<∷-antisym _ l-kd k<∷l l<∷k) =
<∷-antisym j-kd l-kd (<∷-trans j<∷k k<∷l) (<∷-trans l<∷k k<∷j)
-- Some more corollaries: subsumption is admissible in canonical kind
-- checking, checked subtyping and kind equality.
--
-- NOTE. The proof of (<:⇇-⇑) is by induction on subkinding
-- derivations (the second hypothesis) rather than kinding derivations
-- (the first hypothesis).
Nf⇇-⇑ : ∀ {n} {Γ : Ctx n} {a j k} → Γ ⊢Nf a ⇇ j → Γ ⊢ j <∷ k → Γ ⊢Nf a ⇇ k
Nf⇇-⇑ (⇇-⇑ a⇇j₁ j₁<∷j₂) j₂<∷j₃ = ⇇-⇑ a⇇j₁ (<∷-trans j₁<∷j₂ j₂<∷j₃)
<:⇇-⇑ : ∀ {n} {Γ : Ctx n} {a b j k} →
Γ ⊢ a <: b ⇇ j → Γ ⊢ j <∷ k → Γ ⊢ k kd → Γ ⊢ a <: b ⇇ k
<:⇇-⇑ (<:-⇇ a⇇c₁⋯d₁ b⇇c₁⋯d₁ a<:b) (<∷-⋯ c₂<:c₁ d₁<:d₂) _ =
<:-⇇ (Nf⇇-⇑ a⇇c₁⋯d₁ (<∷-⋯ c₂<:c₁ d₁<:d₂))
(Nf⇇-⇑ b⇇c₁⋯d₁ (<∷-⋯ c₂<:c₁ d₁<:d₂)) a<:b
<:⇇-⇑ (<:-λ a₁<:a₂ Λj₁a₁⇇Πk₁l₁ Λj₂a₂⇇Πk₁l₁) (<∷-Π k₂<∷k₁ l₁<∷l₂ Πk₁l₁-kd)
(kd-Π k₂-kd l₂-kd) =
<:-λ (<:⇇-⇑ (⇓-<:⇇ k₂-kd k₂<∷k₁ a₁<:a₂) l₁<∷l₂ l₂-kd)
(Nf⇇-⇑ Λj₁a₁⇇Πk₁l₁ (<∷-Π k₂<∷k₁ l₁<∷l₂ Πk₁l₁-kd))
(Nf⇇-⇑ Λj₂a₂⇇Πk₁l₁ (<∷-Π k₂<∷k₁ l₁<∷l₂ Πk₁l₁-kd))
≃-⇑ : ∀ {n} {Γ : Ctx n} {a b j k} →
Γ ⊢ a ≃ b ⇇ j → Γ ⊢ j <∷ k → Γ ⊢ k kd → Γ ⊢ a ≃ b ⇇ k
≃-⇑ (<:-antisym j-kd a<:b b<:a) j<∷k k-kd =
<:-antisym k-kd (<:⇇-⇑ a<:b j<∷k k-kd) (<:⇇-⇑ b<:a j<∷k k-kd)
------------------------------------------------------------------------
-- Reflexivity of the various relations.
--
-- NOTE. The proof is by mutual induction in the structure of the
-- types and kinds being related to themselves, and then by
-- case-analysis on formation/kinding derivations (rather than
-- induction on the typing/kinding derivations directly). For
-- example, the proof of (<:⇇-reflNf⇉-⇑) is not decreasing in the
-- kinding derivation of `a' in the type abstraction (Π-intro) case.
-- To avoid clutter, we do not make the corresponding type/kind
-- parameters explicit in the implementations below: thanks to the
-- structure of canonical formation/kinding, every kind/type
-- constructor corresponds to exactly one kinding/typing rule
-- (i.e. the rules are syntax directed).
mutual
-- Reflexivity of canonical subkinding.
<∷-refl : ∀ {n} {Γ : Ctx n} {k} → Γ ⊢ k kd → Γ ⊢ k <∷ k
<∷-refl (kd-⋯ a⇉a⋯a b⇉b⋯b) = <∷-⋯ (<:-reflNf⇉ a⇉a⋯a) (<:-reflNf⇉ b⇉b⋯b)
<∷-refl (kd-Π j-kd k-kd) =
<∷-Π (<∷-refl j-kd) (<∷-refl k-kd) (kd-Π j-kd k-kd)
-- Reflexivity of canonical subtyping.
<:-reflNf⇉ : ∀ {n} {Γ : Ctx n} {a b c} → Γ ⊢Nf a ⇉ b ⋯ c → Γ ⊢ a <: a
<:-reflNf⇉ (⇉-⊥-f Γ-ctx) = <:-⊥ (⇉-⊥-f Γ-ctx)
<:-reflNf⇉ (⇉-⊤-f Γ-ctx) = <:-⊤ (⇉-⊤-f Γ-ctx)
<:-reflNf⇉ (⇉-∀-f k-kd a⇉a⋯a) =
<:-∀ (<∷-refl k-kd) (<:-reflNf⇉ a⇉a⋯a) (⇉-∀-f k-kd a⇉a⋯a)
<:-reflNf⇉ (⇉-→-f a⇉a⋯a b⇉b⋯b) =
<:-→ (<:-reflNf⇉ a⇉a⋯a) (<:-reflNf⇉ b⇉b⋯b)
<:-reflNf⇉ (⇉-s-i (∈-∙ x∈j j⇉as⇉k)) = <:-∙ x∈j (≃-reflSp⇉ j⇉as⇉k)
<:⇇-reflNf⇉-⇑ : ∀ {n} {Γ : Ctx n} {a j k} →
Γ ⊢Nf a ⇉ j → Γ ⊢ j <∷ k → Γ ⊢ k kd → Γ ⊢ a <: a ⇇ k
<:⇇-reflNf⇉-⇑ a⇉b₁⋯c₁ (<∷-⋯ b₂<:b₁ c₁<:c₂) _ =
let a⇇b₂⋯c₂ = ⇇-⇑ a⇉b₁⋯c₁ (<∷-⋯ b₂<:b₁ c₁<:c₂)
in <:-⇇ a⇇b₂⋯c₂ a⇇b₂⋯c₂ (<:-reflNf⇉ a⇉b₁⋯c₁)
<:⇇-reflNf⇉-⇑ (⇉-Π-i j₁-kd a⇉k₁) (<∷-Π j₂<∷j₁ k₁<∷k₂ Πj₁k₁-kd)
(kd-Π j₂-kd k₂-kd) =
let a<:a⇇k₂ = <:⇇-reflNf⇉-⇑ (⇓-Nf⇉ j₂-kd j₂<∷j₁ a⇉k₁) k₁<∷k₂ k₂-kd
Λj₁a⇇Πj₂k₂ = ⇇-⇑ (⇉-Π-i j₁-kd a⇉k₁) (<∷-Π j₂<∷j₁ k₁<∷k₂ Πj₁k₁-kd)
in <:-λ a<:a⇇k₂ Λj₁a⇇Πj₂k₂ Λj₁a⇇Πj₂k₂
<:⇇-reflNf⇇ : ∀ {n} {Γ : Ctx n} {a k} →
Γ ⊢Nf a ⇇ k → Γ ⊢ k kd → Γ ⊢ a <: a ⇇ k
<:⇇-reflNf⇇ (⇇-⇑ a⇉k j<∷k) k-kd = <:⇇-reflNf⇉-⇑ a⇉k j<∷k k-kd
-- Reflexivity of canonical spine equality.
≃-reflSp⇉ : ∀ {n} {Γ : Ctx n} {as j k} →
Γ ⊢ j ⇉∙ as ⇉ k → Γ ⊢ j ⇉∙ as ≃ as ⇉ k
≃-reflSp⇉ ⇉-[] = ≃-[]
≃-reflSp⇉ (⇉-∷ a⇇j j-kd k[a]⇉as⇉l) =
≃-∷ (≃-reflNf⇇ a⇇j j-kd) (≃-reflSp⇉ k[a]⇉as⇉l)
-- A checked variant of reflexivity.
≃-reflNf⇇ : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Nf a ⇇ k → Γ ⊢ k kd → Γ ⊢ a ≃ a ⇇ k
≃-reflNf⇇ a⇇k k-kd =
<:-antisym k-kd (<:⇇-reflNf⇇ a⇇k k-kd) (<:⇇-reflNf⇇ a⇇k k-kd)
-- Reflexivity of canonical kind equality.
≅-refl : ∀ {n} {Γ : Ctx n} {k} → Γ ⊢ k kd → Γ ⊢ k ≅ k
≅-refl k-kd = <∷-antisym k-kd k-kd (<∷-refl k-kd) (<∷-refl k-kd)
-- A shorthand.
<:⇇-reflNf⇉ : ∀ {n} {Γ : Ctx n} {a k} →
Γ ⊢Nf a ⇉ k → Γ ⊢ k kd → Γ ⊢ a <: a ⇇ k
<:⇇-reflNf⇉ a⇉k k-kd = <:⇇-reflNf⇉-⇑ a⇉k (<∷-refl k-kd) k-kd
-- Some corollaryies of reflexivity.
-- The synthesized kinds of normal forms kind-check.
Nf⇉⇒Nf⇇ : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Nf a ⇉ k → Γ ⊢Nf a ⇇ k
Nf⇉⇒Nf⇇ a⇉k = ⇇-⇑ a⇉k (<∷-refl (Nf⇉-valid a⇉k))
-- An admissible operator introduction rule accepting a checked body.
Nf⇇-Π-i : ∀ {n} {Γ : Ctx n} {j a k} →
Γ ⊢ j kd → kd j ∷ Γ ⊢Nf a ⇇ k → Γ ⊢Nf Λ∙ j a ⇇ Π j k
Nf⇇-Π-i j-kd (⇇-⇑ a⇉l l<∷k) =
⇇-⇑ (⇉-Π-i j-kd a⇉l) (<∷-Π (<∷-refl j-kd) l<∷k (kd-Π j-kd (Nf⇉-valid a⇉l)))
-- Admissible projection rules for canonically kinded proper types.
<:-⟨|-Nf⇉ : ∀ {n} {Γ : Ctx n} {a b c} → Γ ⊢Nf a ⇉ b ⋯ c → Γ ⊢ b <: a
<:-⟨|-Nf⇉ a⇉b⋯c with Nf⇉-≡ a⇉b⋯c
<:-⟨|-Nf⇉ a⇉a⋯a | refl , refl = <:-reflNf⇉ a⇉a⋯a
<:-⟨|-Nf⇇ : ∀ {n} {Γ : Ctx n} {a b c} → Γ ⊢Nf a ⇇ b ⋯ c → Γ ⊢ b <: a
<:-⟨|-Nf⇇ (⇇-⇑ a⇉b₁⋯c₁ (<∷-⋯ b₂<:b₁ c₁<:c₂)) =
<:-trans b₂<:b₁ (<:-⟨|-Nf⇉ a⇉b₁⋯c₁)
<:-|⟩-Nf⇉ : ∀ {n} {Γ : Ctx n} {a b c} → Γ ⊢Nf a ⇉ b ⋯ c → Γ ⊢ a <: c
<:-|⟩-Nf⇉ a⇉b⋯c with Nf⇉-≡ a⇉b⋯c
<:-|⟩-Nf⇉ a⇉a⋯a | refl , refl = <:-reflNf⇉ a⇉a⋯a
<:-|⟩-Nf⇇ : ∀ {n} {Γ : Ctx n} {a b c} → Γ ⊢Nf a ⇇ b ⋯ c → Γ ⊢ a <: c
<:-|⟩-Nf⇇ (⇇-⇑ a⇉b₁⋯c₁ (<∷-⋯ b₂<:b₁ c₁<:c₂)) =
<:-trans (<:-|⟩-Nf⇉ a⇉b₁⋯c₁) c₁<:c₂
-- An admissible interval rule for checked subtyping.
<:⇇-⋯-i : ∀ {n} {Γ : Ctx n} {a b c d} →
Γ ⊢ a <: b ⇇ c ⋯ d → Γ ⊢ a <: b ⇇ a ⋯ b
<:⇇-⋯-i (<:-⇇ a⇇c⋯d b⇇c⋯d a<:b) =
let a⇉a⋯a = Nf⇇-s-i a⇇c⋯d
b⇉b⋯b = Nf⇇-s-i b⇇c⋯d
in <:-⇇ (⇇-⇑ a⇉a⋯a (<∷-⋯ (<:-reflNf⇉ a⇉a⋯a) a<:b))
(⇇-⇑ b⇉b⋯b (<∷-⋯ a<:b (<:-reflNf⇉ b⇉b⋯b))) a<:b
-- An inversion lemma about variable kinding.
Var∈-inv : ∀ {n} {Γ : Ctx n} {x k} → Γ ⊢Var x ∈ k →
∃ λ j → lookup Γ x ≡ kd j × Γ ⊢ j <∷ k × Γ ⊢ j kd × Γ ⊢ k kd
Var∈-inv (⇉-var x Γ-ctx Γ[x]≡kd-j) =
let j-kd = lookup-kd x Γ-ctx Γ[x]≡kd-j
in _ , Γ[x]≡kd-j , <∷-refl j-kd , j-kd , j-kd
Var∈-inv (⇇-⇑ x∈j j<∷k k-kd) =
let l , Γ[x]≡kd-l , l<∷j , l-kd , _ = Var∈-inv x∈j
in l , Γ[x]≡kd-l , <∷-trans l<∷j j<∷k , l-kd , k-kd
-- A "canonical forms" lemma for operator equality.
≃-Π-can : ∀ {n} {Γ : Ctx n} {a₁ a₂ j k} → Γ ⊢ a₁ ≃ a₂ ⇇ Π j k →
∃ λ j₁ → ∃ λ b₁ → ∃ λ j₂ → ∃ λ b₂ →
Γ ⊢Nf Λ∙ j₁ b₁ ⇇ Π j k × Γ ⊢Nf Λ∙ j₂ b₂ ⇇ Π j k × Γ ⊢ Π j k kd ×
Γ ⊢ j <∷ j₁ × Γ ⊢ j <∷ j₂ ×
kd j ∷ Γ ⊢ b₁ <: b₂ ⇇ k × kd j ∷ Γ ⊢ b₂ <: b₁ ⇇ k ×
a₁ ≡ Λ∙ j₁ b₁ × a₂ ≡ Λ∙ j₂ b₂
≃-Π-can (<:-antisym Πjk-kd
(<:-λ a₁<:a₂
(⇇-⇑ (⇉-Π-i j₁-kd a₁⇉k₁) (<∷-Π j<∷j₁ k₁<∷k Πj₁k₁-kd))
(⇇-⇑ (⇉-Π-i j₂-kd a₂⇉k₂) (<∷-Π j<∷j₂ k₂<∷k Πj₂k₂-kd)))
(<:-λ a₂<:a₁ _ _)) =
_ , _ , _ , _ ,
(⇇-⇑ (⇉-Π-i j₁-kd a₁⇉k₁) (<∷-Π j<∷j₁ k₁<∷k Πj₁k₁-kd)) ,
(⇇-⇑ (⇉-Π-i j₂-kd a₂⇉k₂) (<∷-Π j<∷j₂ k₂<∷k Πj₂k₂-kd)) ,
Πjk-kd , j<∷j₁ , j<∷j₂ , a₁<:a₂ , a₂<:a₁ , refl , refl
------------------------------------------------------------------------
-- Simplification of well-formed kinding.
module _ where
open SimpleKinding
open SimpleKinding.Kinding
renaming (_⊢Var_∈_ to _⊢sVar_∈_; _⊢Ne_∈_ to _⊢sNe_∈_)
open KindedHereditarySubstitution
open ≡-Reasoning
-- Simplification of well-formedness and kinding: well-formed kinds
-- resp. well-kinded normal forms, neutrals and spines are also
-- simply well-formed resp. well-kinded.
Var∈-sVar∈ : ∀ {n} {Γ : Ctx n} {a k} →
Γ ⊢Var a ∈ k → ⌊ Γ ⌋Ctx ⊢sVar a ∈ ⌊ k ⌋
Var∈-sVar∈ {_} {Γ} {_} {k} (⇉-var x Γ-ctx Γ[x]≡kd-k) = ∈-var x (begin
SimpleCtx.lookup ⌊ Γ ⌋Ctx x ≡⟨ ⌊⌋Asc-lookup Γ x ⟩
⌊ ElimCtx.lookup Γ x ⌋Asc ≡⟨ cong ⌊_⌋Asc Γ[x]≡kd-k ⟩
kd ⌊ k ⌋ ∎)
where open ContextConversions
Var∈-sVar∈ (⇇-⇑ x∈j j<∷k k-kd) =
subst (_ ⊢sVar _ ∈_) (<∷-⌊⌋ j<∷k) (Var∈-sVar∈ x∈j)
mutual
kd-kds : ∀ {n} {Γ : Ctx n} {k} → Γ ⊢ k kd → ⌊ Γ ⌋Ctx ⊢ k kds
kd-kds (kd-⋯ a∈a⋯a b∈b⋯b) = kds-⋯ (Nf⇉-Nf∈ a∈a⋯a) (Nf⇉-Nf∈ b∈b⋯b)
kd-kds (kd-Π j-kd k-kd) = kds-Π (kd-kds j-kd) (kd-kds k-kd)
Nf⇉-Nf∈ : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Nf a ⇉ k → ⌊ Γ ⌋Ctx ⊢Nf a ∈ ⌊ k ⌋
Nf⇉-Nf∈ (⇉-⊥-f Γ-ctx) = ∈-⊥-f
Nf⇉-Nf∈ (⇉-⊤-f Γ-ctx) = ∈-⊤-f
Nf⇉-Nf∈ (⇉-∀-f k-kd a⇉a⋯a) = ∈-∀-f (kd-kds k-kd) (Nf⇉-Nf∈ a⇉a⋯a)
Nf⇉-Nf∈ (⇉-→-f a∈a⋯a b∈b⋯b) = ∈-→-f (Nf⇉-Nf∈ a∈a⋯a) (Nf⇉-Nf∈ b∈b⋯b)
Nf⇉-Nf∈ (⇉-Π-i j-kd a⇉k) = ∈-Π-i (kd-kds j-kd) (Nf⇉-Nf∈ a⇉k)
Nf⇉-Nf∈ (⇉-s-i a∈b⋯c) = ∈-ne (Ne∈-sNe∈ a∈b⋯c)
Ne∈-sNe∈ : ∀ {n} {Γ : Ctx n} {a k} →
Γ ⊢Ne a ∈ k → ⌊ Γ ⌋Ctx ⊢sNe a ∈ ⌊ k ⌋
Ne∈-sNe∈ (∈-∙ x∈j j⇉as⇉k) = ∈-∙ (Var∈-sVar∈ x∈j) (Sp⇉-Sp∈ j⇉as⇉k)
Sp⇉-Sp∈ : ∀ {n} {Γ : Ctx n} {as j k} → Γ ⊢ j ⇉∙ as ⇉ k →
⌊ Γ ⌋Ctx ⊢ ⌊ j ⌋ ∋∙ as ∈ ⌊ k ⌋
Sp⇉-Sp∈ ⇉-[] = ∈-[]
Sp⇉-Sp∈ (⇉-∷ a⇇j j-kd k[a]⇉as⇉l) =
∈-∷ (Nf⇇-Nf∈ a⇇j)
(subst (_ ⊢_∋∙ _ ∈ _) (⌊⌋-Kind/⟨⟩ _) (Sp⇉-Sp∈ k[a]⇉as⇉l))
Nf⇇-Nf∈ : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Nf a ⇇ k → ⌊ Γ ⌋Ctx ⊢Nf a ∈ ⌊ k ⌋
Nf⇇-Nf∈ (⇇-⇑ a⇉j j<∷k) = subst (_ ⊢Nf _ ∈_) (<∷-⌊⌋ j<∷k) (Nf⇉-Nf∈ a⇉j)
| {
"alphanum_fraction": 0.4874324595,
"avg_line_length": 41.0599835661,
"ext": "agda",
"hexsha": "5e419cacf5de1ec1de80e6e8e373ca309dc0b92f",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-05-14T10:25:05.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-05-13T22:29:48.000Z",
"max_forks_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Blaisorblade/f-omega-int-agda",
"max_forks_repo_path": "src/FOmegaInt/Kinding/Canonical.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_issues_repo_issues_event_max_datetime": "2021-05-14T08:54:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-05-14T08:09:40.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Blaisorblade/f-omega-int-agda",
"max_issues_repo_path": "src/FOmegaInt/Kinding/Canonical.agda",
"max_line_length": 79,
"max_stars_count": 12,
"max_stars_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Blaisorblade/f-omega-int-agda",
"max_stars_repo_path": "src/FOmegaInt/Kinding/Canonical.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-27T05:53:06.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-06-13T16:05:35.000Z",
"num_tokens": 26887,
"size": 49970
} |
------------------------------------------------------------------------------
-- The the power function
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOT.FOTC.Data.Nat.Pow where
open import FOTC.Base
open import FOTC.Data.Nat
open import FOTC.Data.Nat.UnaryNumbers
------------------------------------------------------------------------------
infixr 11 _^_
postulate
_^_ : D → D → D
^-0 : ∀ n → n ^ zero ≡ 1'
^-S : ∀ m n → m ^ succ₁ n ≡ m * m ^ n
{-# ATP axioms ^-0 ^-S #-}
| {
"alphanum_fraction": 0.3617021277,
"avg_line_length": 28.2,
"ext": "agda",
"hexsha": "855f0ce7049f2499ee792982938aecba99686251",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "notes/FOT/FOTC/Data/Nat/Pow.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "notes/FOT/FOTC/Data/Nat/Pow.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/FOT/FOTC/Data/Nat/Pow.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": 156,
"size": 705
} |
module List.Permutation.Base.Concatenation (A : Set) where
open import List.Permutation.Base A
open import List.Permutation.Base.Equivalence A
open import List.Permutation.Base.Preorder A
open import Data.List
open import Data.Product
open import Relation.Binary.PreorderReasoning ∼-preorder
open import Algebra
open import Algebra.Structures
lemma++/r : {x : A}{xs ys xs' : List A} → (xs / x ⟶ xs') → (xs ++ ys) / x ⟶ (xs' ++ ys)
lemma++/r /head = /head
lemma++/r (/tail xs/x⟶xs') = /tail (lemma++/r xs/x⟶xs')
lemma++/l : {y : A}{xs ys ys' : List A} → (ys / y ⟶ ys') → (xs ++ ys) / y ⟶ (xs ++ ys')
lemma++/l {xs = []} ys/y⟶ys' = ys/y⟶ys'
lemma++/l {xs = x ∷ xs} ys/y⟶ys' = /tail (lemma++/l {xs = xs} ys/y⟶ys')
lemma++/ : {y : A}{xs ys : List A} → (xs ++ y ∷ ys) / y ⟶ (xs ++ ys)
lemma++/ {xs = xs} = lemma++/l {xs = xs} /head
lemma++∼r : {xs xs' ys : List A} → xs ∼ xs' → (xs ++ ys) ∼ (xs' ++ ys)
lemma++∼r {xs} {xs'} {[]} xs∼xs'
rewrite ((proj₂ (IsMonoid.identity (Monoid.isMonoid (monoid A)))) xs)
| ((proj₂ (IsMonoid.identity (Monoid.isMonoid (monoid A)))) xs') = xs∼xs'
lemma++∼r {xs} {xs'} {y ∷ ys} xs∼xs' = ∼x (lemma++/ {y} {xs} {ys}) (lemma++/ {y} {xs'} {ys}) (lemma++∼r xs∼xs')
lemma++∼l : {xs ys ys' : List A} → ys ∼ ys' → (xs ++ ys) ∼ (xs ++ ys')
lemma++∼l {xs = []} ys∼ys' = ys∼ys'
lemma++∼l {xs = x ∷ xs} ys∼ys' = ∼x /head /head (lemma++∼l {xs = xs} ys∼ys')
lemma++∼ : {xs ys xs' ys' : List A} → xs ∼ xs' → ys ∼ ys' → (xs ++ ys) ∼ (xs' ++ ys')
lemma++∼ {xs} {ys} {xs'} {ys'} xs∼xs' ys∼ys'
= begin
xs ++ ys
∼⟨ lemma++∼r xs∼xs' ⟩
xs' ++ ys
∼⟨ lemma++∼l {xs = xs'} ys∼ys' ⟩
xs' ++ ys'
∎
| {
"alphanum_fraction": 0.5126843658,
"avg_line_length": 40.3571428571,
"ext": "agda",
"hexsha": "6f315efa0e390b75313cfac41a19e56cc51de14f",
"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/List/Permutation/Base/Concatenation.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/List/Permutation/Base/Concatenation.agda",
"max_line_length": 113,
"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/List/Permutation/Base/Concatenation.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": 728,
"size": 1695
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.