hexsha
stringlengths 40
40
| size
int64 3
1.05M
| ext
stringclasses 163
values | lang
stringclasses 53
values | max_stars_repo_path
stringlengths 3
945
| max_stars_repo_name
stringlengths 4
112
| max_stars_repo_head_hexsha
stringlengths 40
78
| max_stars_repo_licenses
listlengths 1
10
| max_stars_count
float64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 3
945
| max_issues_repo_name
stringlengths 4
113
| max_issues_repo_head_hexsha
stringlengths 40
78
| max_issues_repo_licenses
listlengths 1
10
| max_issues_count
float64 1
116k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 3
945
| max_forks_repo_name
stringlengths 4
113
| max_forks_repo_head_hexsha
stringlengths 40
78
| max_forks_repo_licenses
listlengths 1
10
| max_forks_count
float64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 3
1.05M
| avg_line_length
float64 1
966k
| max_line_length
int64 1
977k
| alphanum_fraction
float64 0
1
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4d7f114e68131c13a4cb1a17e92d1704deb5cf0d
| 349
|
agda
|
Agda
|
Chapter1/#9.agda
|
CodaFi/HoTT-Exercises
|
3411b253b0a49a5f9c3301df175ae8ecdc563b12
|
[
"MIT"
] | null | null | null |
Chapter1/#9.agda
|
CodaFi/HoTT-Exercises
|
3411b253b0a49a5f9c3301df175ae8ecdc563b12
|
[
"MIT"
] | null | null | null |
Chapter1/#9.agda
|
CodaFi/HoTT-Exercises
|
3411b253b0a49a5f9c3301df175ae8ecdc563b12
|
[
"MIT"
] | null | null | null |
module #9 where
{-
Define the type family Fin : N → U mentioned at the end of §1.3, and the dependent
function fmax : ∏(n:N) Fin(n + 1) mentioned in §1.4.
-}
open import Data.Nat
data Fin : ℕ → Set where
FZ : {n : ℕ} → Fin (suc n)
FS : {n : ℕ} → Fin n → Fin (suc n)
fmax : (n : ℕ) → Fin (n + 1)
fmax zero = FZ
fmax (suc n) = FS (fmax n)
| 20.529412
| 84
| 0.570201
|
fbc43fc9f2459bfecfdfeb5430f78d9033bc69d6
| 1,664
|
agda
|
Agda
|
src/Subset.agda
|
acallesalda/setform
|
4ab3c1a8bfd679cb3ced25500aa8103cb6c4b1f4
|
[
"MIT"
] | 3
|
2019-08-02T23:13:13.000Z
|
2022-01-06T20:04:13.000Z
|
src/Subset.agda
|
acallesalda/setform
|
4ab3c1a8bfd679cb3ced25500aa8103cb6c4b1f4
|
[
"MIT"
] | null | null | null |
src/Subset.agda
|
acallesalda/setform
|
4ab3c1a8bfd679cb3ced25500aa8103cb6c4b1f4
|
[
"MIT"
] | null | null | null |
-- Properties involving susbets and membership
-- between sets.
module Subset where
open import Logic
open import ZAxioms
memberEq : (x y z : 𝓢) → x ∈ y ∧ y ≡ z → x ∈ z
memberEq x y z (x₁ , x₂) = subs _ x₂ x₁
-- Theorem 1, p. 21 (Suppes 1960)
notInEmpty : ∀ x → x ∉ ∅
notInEmpty x h = (proj₂ _ empt) x h
prop-∅ : (x A : 𝓢) → x ∈ A → A ≢ ∅
prop-∅ x A x∈A h = notInEmpty x (subs _ h x∈A)
prop₂-∅ : (x : 𝓢) → ∃ (λ y → y ∈ x) → x ≢ ∅
prop₂-∅ x h₁ h₂ = cont _ (h₂ , prop-∅ _ _ aux-p)
where
aux : 𝓢
aux = proj₁ h₁
aux-p : aux ∈ x
aux-p = proj₂ _ h₁
-- Theorem 3, p. 22 (Suppes 1960)
subsetOfItself : ∀ {x} → x ⊆ x
subsetOfItself _ t∈x = t∈x
-- Theorem 4, p. 22 (Suppes 1960)
equalitySubset : (x y : 𝓢) → x ⊆ y ∧ y ⊆ x → x ≡ y
equalitySubset x y (x⊆y , y⊆x) = ext x y ((x⊆y x) , (y⊆x x))
-- Theorem 6, p. 23 (Suppes 1960)
trans-⊆ : (x y z : 𝓢) → x ⊆ y ∧ y ⊆ z → x ⊆ z
trans-⊆ x y z (x⊆y , y⊆z) t t∈x = y⊆z t (x⊆y t t∈x)
-- Theorem 7, p. 23 (Suppes 1960)
notContainedInItself : ∀ {x} → ¬ (x ⊂ x)
notContainedInItself (_ , x≢x) = x≢x refl
-- Theorem 8, p. 23 (Suppes 1960)
nonSymmetry-⊂ : (x y : 𝓢) (p : x ⊂ y) → ¬ (y ⊂ x)
nonSymmetry-⊂ x y (x⊆y , x≢y) (y⊆x , _) = x≢y (equalitySubset x y (x⊆y , y⊆x))
-- Theorem 10, p. 23 (Suppes 1960)
⊂→⊆ : ∀ {x y} → x ⊂ y → x ⊆ y
⊂→⊆ (x⊆y , _) z z∈x = x⊆y z z∈x
prop-⊆ : (x A B : 𝓢) → x ∈ A → A ⊆ B → x ∈ B
prop-⊆ x A B x₁ x₂ = i x₁
where
i : x ∈ A → x ∈ B
i = x₂ _
-- References
--
-- Suppes, Patrick (1960). Axiomatic Set Theory.
-- The University Series in Undergraduate Mathematics.
-- D. Van Nostrand Company, inc.
--
-- Enderton, Herbert B. (1977). Elements of Set Theory.
-- Academic Press Inc.
| 24.835821
| 78
| 0.545673
|
1d0db41ef171ee0a6250ca7dff9a47d2d8348a1a
| 12,948
|
agda
|
Agda
|
LibraBFT/Impl/Handle/Properties.agda
|
cwjnkins/bft-consensus-agda
|
71aa2168e4875ffdeece9ba7472ee3cee5fa9084
|
[
"UPL-1.0"
] | null | null | null |
LibraBFT/Impl/Handle/Properties.agda
|
cwjnkins/bft-consensus-agda
|
71aa2168e4875ffdeece9ba7472ee3cee5fa9084
|
[
"UPL-1.0"
] | null | null | null |
LibraBFT/Impl/Handle/Properties.agda
|
cwjnkins/bft-consensus-agda
|
71aa2168e4875ffdeece9ba7472ee3cee5fa9084
|
[
"UPL-1.0"
] | null | null | null |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
{-# OPTIONS --allow-unsolved-metas #-}
-- This module provides some scaffolding to define the handlers for our fake/simple "implementation"
-- and connect them to the interface of the SystemModel.
open import Optics.All
open import LibraBFT.Prelude
open import LibraBFT.Lemmas
open import LibraBFT.Base.ByteString
open import LibraBFT.Base.Encode
open import LibraBFT.Base.KVMap
open import LibraBFT.Base.PKCS
open import LibraBFT.Hash
open import LibraBFT.Impl.Base.Types
open import LibraBFT.Impl.Consensus.RoundManager.Properties
open import LibraBFT.Impl.Consensus.Types
open import LibraBFT.Impl.Util.Crypto
open import LibraBFT.Impl.Util.Util
open import LibraBFT.Concrete.System
open import LibraBFT.Concrete.System.Parameters
open EpochConfig
open import LibraBFT.Yasm.Types
open import LibraBFT.Yasm.Yasm ℓ-RoundManager ℓ-VSFP ConcSysParms PeerCanSignForPK (λ {st} {part} {pk} → PeerCanSignForPK-stable {st} {part} {pk})
module LibraBFT.Impl.Handle.Properties where
open import LibraBFT.Impl.Consensus.RoundManager
open import LibraBFT.Impl.Handle
-- This proof is complete except for pieces that are directly about the handlers. Our
-- fake/simple handler does not yet obey the needed properties, so we can't finish this yet.
impl-sps-avp : StepPeerState-AllValidParts
-- In our fake/simple implementation, init and handling V and C msgs do not send any messages
impl-sps-avp _ hpk (step-init _) m∈outs part⊂m ver = ⊥-elim (¬Any[] m∈outs)
impl-sps-avp _ hpk (step-msg {sndr , V vm} _ _) m∈outs _ _ = ⊥-elim (¬Any[] m∈outs)
impl-sps-avp _ hpk (step-msg {sndr , C cm} _ _) m∈outs _ _ = ⊥-elim (¬Any[] m∈outs)
-- These aren't true yet, because processProposalMsgM sends fake votes that don't follow the rules for ValidPartForPK
impl-sps-avp preach hpk (step-msg {sndr , P pm} m∈pool ps≡) m∈outs v⊂m ver ¬init
with m∈outs
-- Handler sends at most one vote, so it can't be "there"
...| there {xs = xs} imp = ⊥-elim (¬Any[] imp)
...| here refl
with v⊂m
...| vote∈qc vs∈qc rbld≈ qc∈m
with qc∈m
...| xxx = {!x!} -- We will prove that votes represented in the SyncInfo of a
-- proposal message were sent before, so these will be inj₂.
-- This will be based on an invariant of the implementation, for
-- example that the QCs included in the SyncInfo of a VoteMsg have
-- been sent before. We will need to use hash injectivity and
-- signature injectivity to ensure a different vote was not sent
-- previously with the same signature.
impl-sps-avp {pk = pk} {α = α} {st = st} preach hpk (step-msg {sndr , P pm} m∈pool ps≡) m∈outs v⊂m ver ¬init
| here refl
| vote∈vm {si}
with MsgWithSig∈? {pk} {ver-signature ver} {msgPool st}
...| yes msg∈ = inj₂ msg∈
...| no msg∉ = inj₁ ( mkPCS4PK {! !} {!!} (inGenInfo refl) {!!} {!!} {!!}
-- The implementation will need to provide evidence that the peer is a member of
-- the epoch of the message it's sending and that it is assigned pk for that epoch.
, msg∉)
open Structural impl-sps-avp
----- Properties that bridge the system model gap to the handler -----
msgsToSendWereSent1 : ∀ {pid ts pm vm} {st : RoundManager}
→ send (V vm) ∈ proj₂ (peerStep pid (P pm) ts st)
→ ∃[ αs ] (SendVote vm αs ∈ LBFT-outs (handle pid (P pm) ts) st)
msgsToSendWereSent1 {pid} {ts} {pm} {vm} {st} send∈acts
with send∈acts
-- The fake handler sends only to node 0 (fakeAuthor), so this doesn't
-- need to be very general yet.
-- TODO-1: generalize this proof so it will work when the set of recipients is
-- not hard coded.
-- The system model allows any message sent to be received by any peer (so the list of
-- recipients it essentially ignored), meaning that our safety proofs will be for a slightly
-- stronger model. Progress proofs will require knowledge of recipients, though, so we will
-- keep the implementation model faithful to the implementation.
...| here refl = fakeAuthor ∷ [] , here refl
-- This captures which kinds of messages are sent by handling which kind of message. It will
-- require additional disjuncts when we implement processVote.
msgsToSendWereSent : ∀ {pid nm m} {st : RoundManager}
→ send m ∈ proj₂ (peerStepWrapper pid nm st)
→ send m ∈ proj₂ (peerStep pid nm 0 st)
× ∃[ vm ] ∃[ pm ] (m ≡ V vm × nm ≡ P pm)
msgsToSendWereSent {pid} {nm = nm} {m} {st} m∈outs
with nm
...| C _ = ⊥-elim (¬Any[] m∈outs)
...| V _ = ⊥-elim (¬Any[] m∈outs)
...| P pm
with m∈outs
...| here v∈outs
with m
...| P _ = ⊥-elim (P≢V (action-send-injective v∈outs))
...| C _ = ⊥-elim (C≢V (action-send-injective v∈outs))
...| V vm rewrite sym v∈outs = here refl , vm , pm , refl , refl
proposalHandlerSentVote : ∀ {pid ts pm vm} {st : RoundManager}
→ send (V vm) ∈ proj₂ (peerStepWrapper pid (P pm) st)
→ ∃[ αs ] (SendVote vm αs ∈ LBFT-outs (handle pid (P pm) ts) st)
proposalHandlerSentVote {pid} {ts} {pm} {vm} {st} m∈outs
with msgsToSendWereSent {pid} {P pm} {st = st} m∈outs
...| send∈ , vm , pm' , refl , refl
with msgsToSendWereSent1 {pid} {ts} {pm'} {st = st} send∈
...| αs , sv = αs , sv
----- Properties that relate handler to system state -----
data _∈RoundManager_ (qc : QuorumCert) (rm : RoundManager) : Set where
inHQC : qc ≡ ₋rmHighestQC rm → qc ∈RoundManager rm
inHCC : qc ≡ ₋rmHighestCommitQC rm → qc ∈RoundManager rm
postulate -- TODO-2: this will be proved for the implementation, confirming that honest
-- participants only store QCs comprising votes that have actually been sent.
-- Votes stored in highesQuorumCert and highestCommitCert were sent before.
-- Note that some implementations might not ensure this, but LibraBFT does
-- because even the leader of the next round sends its own vote to itself,
-- as opposed to using it to construct a QC using its own unsent vote.
qcVotesSentB4 : ∀{pid qc vs pk}{st : SystemState}
→ ReachableSystemState st
→ initialised st pid ≡ initd
→ qc ∈RoundManager (peerStates st pid)
→ vs ∈ qcVotes qc
→ ¬ (∈GenInfo (proj₂ vs))
→ MsgWithSig∈ pk (proj₂ vs) (msgPool st)
-- We can prove this easily because we don't yet do epoch changes,
-- so only the initial EC is relevant. Later, this will require us to use the fact that
-- epoch changes require proof of committing an epoch-changing transaction.
availEpochsConsistent :
∀{pid pid' v v' pk}{st : SystemState}
→ ReachableSystemState st
→ (pkvpf : PeerCanSignForPK st v pid pk)
→ (pkvpf' : PeerCanSignForPK st v' pid' pk)
→ PeerCanSignForPK.𝓔 pkvpf ≡ PeerCanSignForPK.𝓔 pkvpf'
availEpochsConsistent r (mkPCS4PK _ _ (inGenInfo refl) _ _ _)
(mkPCS4PK _ _ (inGenInfo refl) _ _ _) = refl
-- Always true, so far, as no epoch changes.
noEpochIdChangeYet : ∀ {pre : SystemState}{pid}{ppre ppost msgs}
→ ReachableSystemState pre
→ ppre ≡ peerStates pre pid
→ StepPeerState pid (msgPool pre) (initialised pre) ppre (ppost , msgs)
→ initialised pre pid ≡ initd
→ (₋rmEC ppre) ^∙ rmEpoch ≡ (₋rmEC ppost) ^∙ rmEpoch
noEpochIdChangeYet _ ppre≡ (step-init uni) ini = ⊥-elim (uninitd≢initd (trans (sym uni) ini))
noEpochIdChangeYet _ ppre≡ (step-msg {(_ , m)} _ _) ini
with m
...| P p = refl
...| V v = refl
...| C c = refl
open SyncInfo
-- QCs in VoteMsg come from RoundManager
VoteMsgQCsFromRoundManager :
∀ {pid s' outs pk}{pre : SystemState}
→ ReachableSystemState pre
-- For any honest call to /handle/ or /init/,
→ (sps : StepPeerState pid (msgPool pre) (initialised pre) (peerStates pre pid) (s' , outs))
→ ∀{v vm qc} → Meta-Honest-PK pk
-- For every vote v represented in a message output by the call
→ v ⊂Msg (V vm)
→ send (V vm) ∈ outs
→ qc QC∈SyncInfo (vm ^∙ vmSyncInfo)
→ qc ∈RoundManager (peerStates pre pid)
VoteMsgQCsFromRoundManager r (step-init _) _ _ ()
VoteMsgQCsFromRoundManager {pid} {pre = pre} r (step-msg {_ , P pm} m∈pool pinit) {v} {vm}
hpk v⊂m m∈outs qc∈m
with peerStates pre pid
...| rm
with proposalHandlerSentVote {pid} {0} {pm} {vm} {rm} m∈outs
...| _ , v∈outs
with qc∈m
...| withVoteSIHighQC refl
= inHQC (cong ₋siHighestQuorumCert (procPMCerts≡ {0} {pm} {rm} v∈outs))
VoteMsgQCsFromRoundManager {pid} {pre = pre} r (step-msg {_ , P pm} m∈pool pinit) {v} {vm1}
hpk v⊂m m∈outs qc∈m
| rm
| _ , v∈outs
| withVoteSIHighCC hqcIsJust
with cong ₋siHighestCommitCert (procPMCerts≡ {0} {pm} {rm} v∈outs)
...| refl
with (rm ^∙ rmHighestQC) ≟QC (rm ^∙ rmHighestCommitQC)
...| true because (ofʸ refl) = ⊥-elim (maybe-⊥ hqcIsJust refl)
...| false because _ = inHCC (just-injective (sym hqcIsJust))
newVoteSameEpochGreaterRound : ∀ {pre : SystemState}{pid s' outs v m pk}
→ ReachableSystemState pre
→ StepPeerState pid (msgPool pre) (initialised pre) (peerStates pre pid) (s' , outs)
→ ¬ (∈GenInfo (₋vSignature v))
→ Meta-Honest-PK pk
→ v ⊂Msg m → send m ∈ outs → (sig : WithVerSig pk v)
→ ¬ MsgWithSig∈ pk (ver-signature sig) (msgPool pre)
→ v ^∙ vEpoch ≡ (₋rmEC (peerStates pre pid)) ^∙ rmEpoch
× suc ((₋rmEC (peerStates pre pid)) ^∙ rmLastVotedRound) ≡ v ^∙ vRound -- New vote for higher round than last voted
× v ^∙ vRound ≡ ((₋rmEC s') ^∙ rmLastVotedRound) -- Last voted round is round of new vote
newVoteSameEpochGreaterRound {pre = pre} {pid} {v = v} {m} {pk} r (step-msg {(_ , P pm)} msg∈pool pinit) ¬init hpk v⊂m m∈outs sig vnew
rewrite pinit
with msgsToSendWereSent {pid} {P pm} {m} {peerStates pre pid} m∈outs
...| _ , vm , _ , refl , refl
with proposalHandlerSentVote {pid} {0} {pm} {vm} {peerStates pre pid} m∈outs
...| _ , v∈outs
rewrite SendVote-inj-v (Any-singleton⁻ v∈outs)
| SendVote-inj-si (Any-singleton⁻ v∈outs)
with v⊂m
-- Rebuilding keeps the same signature, and the SyncInfo included with the
-- VoteMsg sent comprises QCs from the peer's state. Votes represented in
-- those QCS have signatures that have been sent before, contradicting the
-- assumption that v's signature has not been sent before.
...| vote∈vm {si} = refl , refl , refl
...| vote∈qc {vs = vs} {qc} vs∈qc v≈rbld (inV qc∈m)
rewrite cong ₋vSignature v≈rbld
| procPMCerts≡ {0} {pm} {peerStates pre pid} {vm} v∈outs
with qcVotesSentB4 r pinit (VoteMsgQCsFromRoundManager r (step-msg msg∈pool pinit) hpk v⊂m (here refl) qc∈m) vs∈qc ¬init
...| sentb4 = ⊥-elim (vnew sentb4)
-- We resist the temptation to combine this with the noEpochChangeYet because in future there will be epoch changes
lastVoteRound-mono : ∀ {pre : SystemState}{pid}{ppre ppost msgs}
→ ReachableSystemState pre
→ ppre ≡ peerStates pre pid
→ StepPeerState pid (msgPool pre) (initialised pre) ppre (ppost , msgs)
→ initialised pre pid ≡ initd
→ (₋rmEC ppre) ^∙ rmEpoch ≡ (₋rmEC ppost) ^∙ rmEpoch
→ (₋rmEC ppre) ^∙ rmLastVotedRound ≤ (₋rmEC ppost) ^∙ rmLastVotedRound
lastVoteRound-mono _ ppre≡ (step-init uni) ini = ⊥-elim (uninitd≢initd (trans (sym uni) ini))
lastVoteRound-mono _ ppre≡ (step-msg {(_ , m)} _ _) _
with m
...| P p = const (≤-step (≤-reflexive refl))
...| V v = const (≤-reflexive refl)
...| C c = const (≤-reflexive refl)
postulate -- TODO-1: prove it
¬genVotesRound≢0 : ∀ {pk sig}{st : SystemState}
→ ReachableSystemState st
→ Meta-Honest-PK pk
→ (mws : MsgWithSig∈ pk sig (msgPool st))
→ ¬ (∈GenInfo sig)
→ (msgPart mws) ^∙ vRound ≢ 0
| 52
| 147
| 0.60658
|
105f8c2c9617253bab2eb82db3d3e97aa504b00b
| 579
|
agda
|
Agda
|
lib/types/FundamentalGroupoid.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | 1
|
2021-06-30T00:17:55.000Z
|
2021-06-30T00:17:55.000Z
|
lib/types/FundamentalGroupoid.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | null | null | null |
lib/types/FundamentalGroupoid.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.types.Truncation
open import lib.types.Groupoid
open import lib.types.PathSet
module lib.types.FundamentalGroupoid {i} (A : Type i) where
fundamental-groupoid : Groupoid
fundamental-groupoid = record
{ El = A
; Arr = _=₀_ {A = A}
; Arr-level = λ _ _ → Trunc-level
; groupoid-struct = record
{ id = idp₀
; inv = !₀
; comp = _∙₀_
; unit-l = ∙₀-unit-l
; unit-r = ∙₀-unit-r
; assoc = ∙₀-assoc
; inv-l = !₀-inv-l
; inv-r = !₀-inv-r
}
}
| 22.269231
| 59
| 0.569948
|
50c5caa452df11c3c6670e8b51749163b3876b38
| 112
|
agda
|
Agda
|
Cubical/HITs/Ints/IsoInt.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Ints/IsoInt.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Ints/IsoInt.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | 1
|
2021-03-12T20:08:45.000Z
|
2021-03-12T20:08:45.000Z
|
{-# OPTIONS --safe #-}
module Cubical.HITs.Ints.IsoInt where
open import Cubical.HITs.Ints.IsoInt.Base public
| 18.666667
| 48
| 0.75
|
0e3686e5f8340df0a230d8c0eb3c39bf966149e9
| 18,467
|
agda
|
Agda
|
Cubical/Foundations/GroupoidLaws.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/GroupoidLaws.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/GroupoidLaws.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
{-
This file proves the higher groupoid structure of types
for homogeneous and heterogeneous paths
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Foundations.GroupoidLaws where
open import Cubical.Foundations.Prelude
private
variable
ℓ : Level
A : Type ℓ
x y z w v : A
_⁻¹ : (x ≡ y) → (y ≡ x)
x≡y ⁻¹ = sym x≡y
infix 40 _⁻¹
-- homogeneous groupoid laws
symInvo : (p : x ≡ y) → p ≡ p ⁻¹ ⁻¹
symInvo p = refl
rUnit : (p : x ≡ y) → p ≡ p ∙ refl
rUnit p j i = compPath-filler p refl j i
-- The filler of left unit: lUnit-filler p =
-- PathP (λ i → PathP (λ j → PathP (λ k → A) x (p (~ j ∨ i)))
-- (refl i) (λ j → compPath-filler refl p i j)) (λ k i → (p (~ k ∧ i ))) (lUnit p)
lUnit-filler : {x y : A} (p : x ≡ y) → I → I → I → A
lUnit-filler {x = x} p j k i =
hfill (λ j → λ { (i = i0) → x
; (i = i1) → p (~ k ∨ j )
; (k = i0) → p i
-- ; (k = i1) → compPath-filler refl p j i
}) (inS (p (~ k ∧ i ))) j
lUnit : (p : x ≡ y) → p ≡ refl ∙ p
lUnit p j i = lUnit-filler p i1 j i
symRefl : refl {x = x} ≡ refl ⁻¹
symRefl i = refl
compPathRefl : refl {x = x} ≡ refl ∙ refl
compPathRefl = rUnit refl
-- The filler of right cancellation: rCancel-filler p =
-- PathP (λ i → PathP (λ j → PathP (λ k → A) x (p (~ j ∧ ~ i)))
-- (λ j → compPath-filler p (p ⁻¹) i j) (refl i)) (λ j i → (p (i ∧ ~ j))) (rCancel p)
rCancel-filler : ∀ {x y : A} (p : x ≡ y) → (k j i : I) → A
rCancel-filler {x = x} p k j i =
hfill (λ k → λ { (i = i0) → x
; (i = i1) → p (~ k ∧ ~ j)
-- ; (j = i0) → compPath-filler p (p ⁻¹) k i
; (j = i1) → x
}) (inS (p (i ∧ ~ j))) k
rCancel : (p : x ≡ y) → p ∙ p ⁻¹ ≡ refl
rCancel {x = x} p j i = rCancel-filler p i1 j i
rCancel-filler' : ∀ {ℓ} {A : Type ℓ} {x y : A} (p : x ≡ y) → (i j k : I) → A
rCancel-filler' {x = x} {y} p i j k =
hfill
(λ i → λ
{ (j = i1) → p (~ i ∧ k)
; (k = i0) → x
; (k = i1) → p (~ i)
})
(inS (p k))
(~ i)
rCancel' : ∀ {ℓ} {A : Type ℓ} {x y : A} (p : x ≡ y) → p ∙ p ⁻¹ ≡ refl
rCancel' p j k = rCancel-filler' p i0 j k
lCancel : (p : x ≡ y) → p ⁻¹ ∙ p ≡ refl
lCancel p = rCancel (p ⁻¹)
assoc : (p : x ≡ y) (q : y ≡ z) (r : z ≡ w) →
p ∙ q ∙ r ≡ (p ∙ q) ∙ r
assoc p q r k = (compPath-filler p q k) ∙ compPath-filler' q r (~ k)
-- heterogeneous groupoid laws
symInvoP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) →
PathP (λ j → PathP (λ i → symInvo (λ i → A i) j i) x y) p (symP (symP p))
symInvoP p = refl
rUnitP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) →
PathP (λ j → PathP (λ i → rUnit (λ i → A i) j i) x y) p (compPathP p refl)
rUnitP p j i = compPathP-filler p refl j i
lUnitP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) →
PathP (λ j → PathP (λ i → lUnit (λ i → A i) j i) x y) p (compPathP refl p)
lUnitP {A = A} {x = x} p k i =
comp (λ j → lUnit-filler (λ i → A i) j k i)
(λ j → λ { (i = i0) → x
; (i = i1) → p (~ k ∨ j )
; (k = i0) → p i
}) (p (~ k ∧ i ))
rCancelP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) →
PathP (λ j → PathP (λ i → rCancel (λ i → A i) j i) x x) (compPathP p (symP p)) refl
rCancelP {A = A} {x = x} p j i =
comp (λ k → rCancel-filler (λ i → A i) k j i)
(λ k → λ { (i = i0) → x
; (i = i1) → p (~ k ∧ ~ j)
; (j = i1) → x
}) (p (i ∧ ~ j))
lCancelP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) →
PathP (λ j → PathP (λ i → lCancel (λ i → A i) j i) y y) (compPathP (symP p) p) refl
lCancelP p = rCancelP (symP p)
assocP : {A : I → Type ℓ} {x : A i0} {y : A i1} {B_i1 : Type ℓ} {B : (A i1) ≡ B_i1} {z : B i1}
{C_i1 : Type ℓ} {C : (B i1) ≡ C_i1} {w : C i1} (p : PathP A x y) (q : PathP (λ i → B i) y z) (r : PathP (λ i → C i) z w) →
PathP (λ j → PathP (λ i → assoc (λ i → A i) B C j i) x w) (compPathP p (compPathP q r)) (compPathP (compPathP p q) r)
assocP {A = A} {B = B} {C = C} p q r k i =
comp (\ j' → hfill (λ j → λ {
(i = i0) → A i0
; (i = i1) → compPath-filler' (λ i₁ → B i₁) (λ i₁ → C i₁) (~ k) j })
(inS (compPath-filler (λ i₁ → A i₁) (λ i₁ → B i₁) k i)) j')
(λ j → λ
{ (i = i0) → p i0
; (i = i1) →
comp (\ j' → hfill ((λ l → λ
{ (j = i0) → B k
; (j = i1) → C l
; (k = i1) → C (j ∧ l)
})) (inS (B ( j ∨ k)) ) j')
(λ l → λ
{ (j = i0) → q k
; (j = i1) → r l
; (k = i1) → r (j ∧ l)
})
(q (j ∨ k))
})
(compPathP-filler p q k i)
-- Loic's code below
-- some exchange law for doubleCompPath and refl
invSides-filler : {x y z : A} (p : x ≡ y) (q : x ≡ z) → Square p (sym q) q (sym p)
invSides-filler {x = x} p q i j =
hcomp (λ k → λ { (i = i0) → p (k ∧ j)
; (i = i1) → q (~ j ∧ k)
; (j = i0) → q (i ∧ k)
; (j = i1) → p (~ i ∧ k)})
x
leftright : {ℓ : Level} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : y ≡ z) →
(refl ∙∙ p ∙∙ q) ≡ (p ∙∙ q ∙∙ refl)
leftright p q i j =
hcomp (λ t → λ { (j = i0) → p (i ∧ (~ t))
; (j = i1) → q (t ∨ i) })
(invSides-filler q (sym p) (~ i) j)
-- equating doubleCompPath and a succession of two compPath
split-leftright : {ℓ : Level} {A : Type ℓ} {w x y z : A} (p : w ≡ x) (q : x ≡ y) (r : y ≡ z) →
(p ∙∙ q ∙∙ r) ≡ (refl ∙∙ (p ∙∙ q ∙∙ refl) ∙∙ r)
split-leftright p q r j i =
hcomp (λ t → λ { (i = i0) → p (~ j ∧ ~ t)
; (i = i1) → r t })
(doubleCompPath-filler p q refl j i)
split-leftright' : {ℓ : Level} {A : Type ℓ} {w x y z : A} (p : w ≡ x) (q : x ≡ y) (r : y ≡ z) →
(p ∙∙ q ∙∙ r) ≡ (p ∙∙ (refl ∙∙ q ∙∙ r) ∙∙ refl)
split-leftright' p q r j i =
hcomp (λ t → λ { (i = i0) → p (~ t)
; (i = i1) → r (j ∨ t) })
(doubleCompPath-filler refl q r j i)
doubleCompPath-elim : {ℓ : Level} {A : Type ℓ} {w x y z : A} (p : w ≡ x) (q : x ≡ y)
(r : y ≡ z) → (p ∙∙ q ∙∙ r) ≡ (p ∙ q) ∙ r
doubleCompPath-elim p q r = (split-leftright p q r) ∙ (λ i → (leftright p q (~ i)) ∙ r)
doubleCompPath-elim' : {ℓ : Level} {A : Type ℓ} {w x y z : A} (p : w ≡ x) (q : x ≡ y)
(r : y ≡ z) → (p ∙∙ q ∙∙ r) ≡ p ∙ (q ∙ r)
doubleCompPath-elim' p q r = (split-leftright' p q r) ∙ (sym (leftright p (q ∙ r)))
cong-∙ : ∀ {B : Type ℓ} (f : A → B) (p : x ≡ y) (q : y ≡ z)
→ cong f (p ∙ q) ≡ (cong f p) ∙ (cong f q)
cong-∙ f p q j i = hcomp (λ k → λ { (j = i0) → f (compPath-filler p q k i)
; (i = i0) → f (p i0)
; (i = i1) → f (q k) })
(f (p i))
cong-∙∙ : ∀ {B : Type ℓ} (f : A → B) (p : w ≡ x) (q : x ≡ y) (r : y ≡ z)
→ cong f (p ∙∙ q ∙∙ r) ≡ (cong f p) ∙∙ (cong f q) ∙∙ (cong f r)
cong-∙∙ f p q r j i = hcomp (λ k → λ { (j = i0) → f (doubleCompPath-filler p q r k i)
; (i = i0) → f (p (~ k))
; (i = i1) → f (r k) })
(f (q i))
hcomp-unique : ∀ {ℓ} {A : Type ℓ} {φ} → (u : I → Partial φ A) → (u0 : A [ φ ↦ u i0 ]) →
(h2 : ∀ i → A [ (φ ∨ ~ i) ↦ (\ { (φ = i1) → u i 1=1; (i = i0) → outS u0}) ])
→ (hcomp u (outS u0) ≡ outS (h2 i1)) [ φ ↦ (\ { (φ = i1) → (\ i → u i1 1=1)}) ]
hcomp-unique {φ = φ} u u0 h2 = inS (\ i → hcomp (\ k → \ { (φ = i1) → u k 1=1
; (i = i1) → outS (h2 k) })
(outS u0))
lid-unique : ∀ {ℓ} {A : Type ℓ} {φ} → (u : I → Partial φ A) → (u0 : A [ φ ↦ u i0 ]) →
(h1 h2 : ∀ i → A [ (φ ∨ ~ i) ↦ (\ { (φ = i1) → u i 1=1; (i = i0) → outS u0}) ])
→ (outS (h1 i1) ≡ outS (h2 i1)) [ φ ↦ (\ { (φ = i1) → (\ i → u i1 1=1)}) ]
lid-unique {φ = φ} u u0 h1 h2 = inS (\ i → hcomp (\ k → \ { (φ = i1) → u k 1=1
; (i = i0) → outS (h1 k)
; (i = i1) → outS (h2 k) })
(outS u0))
transp-hcomp : ∀ {ℓ} (φ : I) {A' : Type ℓ}
(A : (i : I) → Type ℓ [ φ ↦ (λ _ → A') ]) (let B = \ (i : I) → outS (A i))
→ ∀ {ψ} (u : I → Partial ψ (B i0)) → (u0 : B i0 [ ψ ↦ u i0 ]) →
(transp (\ i → B i) φ (hcomp u (outS u0)) ≡ hcomp (\ i o → transp (\ i → B i) φ (u i o)) (transp (\ i → B i) φ (outS u0)))
[ ψ ↦ (\ { (ψ = i1) → (\ i → transp (\ i → B i) φ (u i1 1=1))}) ]
transp-hcomp φ A u u0 = inS (sym (outS (hcomp-unique
((\ i o → transp (\ i → B i) φ (u i o))) (inS (transp (\ i → B i) φ (outS u0)))
\ i → inS (transp (\ i → B i) φ (hfill u u0 i)))))
where
B = \ (i : I) → outS (A i)
hcomp-cong : ∀ {ℓ} {A : Type ℓ} {φ} → (u : I → Partial φ A) → (u0 : A [ φ ↦ u i0 ]) →
(u' : I → Partial φ A) → (u0' : A [ φ ↦ u' i0 ]) →
(ueq : ∀ i → PartialP φ (\ o → u i o ≡ u' i o)) → (outS u0 ≡ outS u0') [ φ ↦ (\ { (φ = i1) → ueq i0 1=1}) ]
→ (hcomp u (outS u0) ≡ hcomp u' (outS u0')) [ φ ↦ (\ { (φ = i1) → ueq i1 1=1 }) ]
hcomp-cong u u0 u' u0' ueq 0eq = inS (\ j → hcomp (\ i o → ueq i o j) (outS 0eq j))
congFunct-filler : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} {x y z : A} (f : A → B) (p : x ≡ y) (q : y ≡ z)
→ I → I → I → B
congFunct-filler {x = x} f p q i j z =
hfill (λ k → λ { (i = i0) → f x
; (i = i1) → f (q k)
; (j = i0) → f (compPath-filler p q k i)})
(inS (f (p i)))
z
congFunct : ∀ {ℓ} {B : Type ℓ} (f : A → B) (p : x ≡ y) (q : y ≡ z) → cong f (p ∙ q) ≡ cong f p ∙ cong f q
congFunct f p q j i = congFunct-filler f p q i j i1
-- congFunct for dependent types
congFunct-dep : ∀ {ℓ ℓ'} {A : Type ℓ} {B : A → Type ℓ'} {x y z : A} (f : (a : A) → B a) (p : x ≡ y) (q : y ≡ z)
→ PathP (λ i → PathP (λ j → B (compPath-filler p q i j)) (f x) (f (q i))) (cong f p) (cong f (p ∙ q))
congFunct-dep {B = B} {x = x} f p q i j = f (compPath-filler p q i j)
cong₂Funct : ∀ {ℓ ℓ'} {A : Type ℓ} {x y : A} {B : Type ℓ'} (f : A → A → B) →
(p : x ≡ y) →
{u v : A} (q : u ≡ v) →
cong₂ f p q ≡ cong (λ x → f x u) p ∙ cong (f y) q
cong₂Funct {x = x} {y = y} f p {u = u} {v = v} q j i =
hcomp (λ k → λ { (i = i0) → f x u
; (i = i1) → f y (q k)
; (j = i0) → f (p i) (q (i ∧ k))})
(f (p i) u)
symDistr-filler : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : y ≡ z) → I → I → I → A
symDistr-filler {A = A} {z = z} p q i j k =
hfill (λ k → λ { (i = i0) → q (k ∨ j)
; (i = i1) → p (~ k ∧ j) })
(inS (invSides-filler q (sym p) i j))
k
symDistr : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : y ≡ z) → sym (p ∙ q) ≡ sym q ∙ sym p
symDistr p q i j = symDistr-filler p q j i i1
-- we can not write hcomp-isEquiv : {ϕ : I} → (p : I → Partial ϕ A) → isEquiv (λ (a : A [ ϕ ↦ p i0 ]) → hcomp p a)
-- due to size issues. But what we can write (compare to hfill) is:
hcomp-equivFillerSub : {ϕ : I} → (p : I → Partial ϕ A) → (a : A [ ϕ ↦ p i0 ])
→ (i : I)
→ A [ ϕ ∨ i ∨ ~ i ↦ (λ { (i = i0) → outS a
; (i = i1) → hcomp (λ i → p (~ i)) (hcomp p (outS a))
; (ϕ = i1) → p i0 1=1 }) ]
hcomp-equivFillerSub {ϕ = ϕ} p a i =
inS (hcomp (λ k → λ { (i = i1) → hfill (λ j → p (~ j)) (inS (hcomp p (outS a))) k
; (i = i0) → outS a
; (ϕ = i1) → p (~ k ∧ i) 1=1 })
(hfill p a i))
hcomp-equivFiller : {ϕ : I} → (p : I → Partial ϕ A) → (a : A [ ϕ ↦ p i0 ])
→ (i : I) → A
hcomp-equivFiller p a i = outS (hcomp-equivFillerSub p a i)
pentagonIdentity : (p : x ≡ y) → (q : y ≡ z) → (r : z ≡ w) → (s : w ≡ v)
→
(assoc p q (r ∙ s) ∙ assoc (p ∙ q) r s)
≡
cong (p ∙_) (assoc q r s) ∙∙ assoc p (q ∙ r) s ∙∙ cong (_∙ s) (assoc p q r)
pentagonIdentity {x = x} {y} p q r s =
(λ i →
(λ j → cong (p ∙_) (assoc q r s) (i ∧ j))
∙∙ (λ j → lemma₀₀ i j ∙ lemma₀₁ i j)
∙∙ (λ j → lemma₁₀ i j ∙ lemma₁₁ i j)
)
where
lemma₀₀ : ( i j : I) → _ ≡ _
lemma₀₀ i j i₁ =
hcomp
(λ k → λ { (j = i0) → p i₁
; (i₁ = i0) → x
; (i₁ = i1) → hcomp
(λ k₁ → λ { (i = i0) → (q (j ∧ k))
; (k = i0) → y
; (j = i0) → y
; (j = i1)(k = i1) → r (k₁ ∧ i)})
(q (j ∧ k))
}) (p i₁)
lemma₀₁ : ( i j : I) → hcomp
(λ k → λ {(i = i0) → q j
; (j = i0) → y
; (j = i1) → r (k ∧ i)
})
(q j) ≡ _
lemma₀₁ i j i₁ = (hcomp
(λ k → λ { (j = i1) → hcomp
(λ k₁ → λ { (i₁ = i0) → r i
; (k = i0) → r i
; (i = i1) → s (k₁ ∧ k ∧ i₁)
; (i₁ = i1)(k = i1) → s k₁ })
(r ((i₁ ∧ k) ∨ i))
; (i₁ = i0) → compPath-filler q r i j
; (i₁ = i1) → hcomp
(λ k₁ → λ { (k = i0) → r i
; (k = i1) → s k₁
; (i = i1) → s (k ∧ k₁)})
(r (i ∨ k))})
(hfill
(λ k → λ { (j = i1) → r k
; (i₁ = i1) → r k
; (i₁ = i0)(j = i0) → y })
(inS (q (i₁ ∨ j))) i))
lemma₁₁ : ( i j : I) → (r (i ∨ j)) ≡ _
lemma₁₁ i j i₁ =
hcomp
(λ k → λ { (i = i1) → s (i₁ ∧ k)
; (j = i1) → s (i₁ ∧ k)
; (i₁ = i0) → r (i ∨ j)
; (i₁ = i1) → s k
}) (r (i ∨ j ∨ i₁))
lemma₁₀-back : I → I → I → _
lemma₁₀-back i j i₁ =
hcomp
(λ k → λ {
(i₁ = i0) → x
; (i₁ = i1) → hcomp
(λ k₁ → λ { (k = i0) → q (j ∨ ~ i)
; (k = i1) → r (k₁ ∧ j)
; (j = i0) → q (k ∨ ~ i)
; (j = i1) → r (k₁ ∧ k)
; (i = i0) → r (k ∧ j ∧ k₁)
})
(q (k ∨ j ∨ ~ i))
; (i = i0)(j = i0) → (p ∙ q) i₁
})
(hcomp
(λ k → λ { (i₁ = i0) → x
; (i₁ = i1) → q ((j ∨ ~ i ) ∧ k)
; (j = i0)(i = i1) → p i₁
})
(p i₁))
lemma₁₀-front : I → I → I → _
lemma₁₀-front i j i₁ =
(((λ _ → x) ∙∙ compPath-filler p q j ∙∙
(λ i₁ →
hcomp
(λ k → λ { (i₁ = i0) → q j
; (i₁ = i1) → r (k ∧ (j ∨ i))
; (j = i0)(i = i0) → q i₁
; (j = i1) → r (i₁ ∧ k)
})
(q (j ∨ i₁))
)) i₁)
compPath-filler-in-filler :
(p : _ ≡ y) → (q : _ ≡ _ )
→ _≡_ {A = Square (p ∙ q) (p ∙ q) (λ _ → x) (λ _ → z)}
(λ i j → hcomp
(λ i₂ →
λ { (j = i0) → x
; (j = i1) → q (i₂ ∨ ~ i)
; (i = i0) → (p ∙ q) j
})
(compPath-filler p q (~ i) j))
(λ _ → p ∙ q)
compPath-filler-in-filler p q z i j =
hcomp
(λ k → λ {
(j = i0) → p i0
; (j = i1) → q (k ∨ ~ i ∧ ~ z)
; (i = i0) → hcomp
(λ i₂ → λ {
(j = i0) → p i0
;(j = i1) → q ((k ∨ ~ z) ∧ i₂)
;(z = i1) (k = i0) → p j
})
(p j)
; (i = i1) → compPath-filler p (λ i₁ → q (k ∧ i₁)) k j
; (z = i0) → hfill
((λ i₂ → λ { (j = i0) → p i0
; (j = i1) → q (i₂ ∨ ~ i)
; (i = i0) → (p ∙ q) j
}))
(inS ((compPath-filler p q (~ i) j))) k
; (z = i1) → compPath-filler p q k j
})
(compPath-filler p q (~ i ∧ ~ z) j)
cube-comp₋₀₋ :
(c : I → I → I → A)
→ {a' : Square _ _ _ _}
→ (λ i i₁ → c i i0 i₁) ≡ a'
→ (I → I → I → A)
cube-comp₋₀₋ c p i j k =
hcomp
(λ l → λ {
(i = i0) → c i0 j k
;(i = i1) → c i1 j k
;(j = i0) → p l i k
;(j = i1) → c i i1 k
;(k = i0) → c i j i0
;(k = i1) → c i j i1
})
(c i j k)
cube-comp₀₋₋ :
(c : I → I → I → A)
→ {a' : Square _ _ _ _}
→ (λ i i₁ → c i0 i i₁) ≡ a'
→ (I → I → I → A)
cube-comp₀₋₋ c p i j k =
hcomp
(λ l → λ {
(i = i0) → p l j k
;(i = i1) → c i1 j k
;(j = i0) → c i i0 k
;(j = i1) → c i i1 k
;(k = i0) → c i j i0
;(k = i1) → c i j i1
})
(c i j k)
lemma₁₀-back' : _
lemma₁₀-back' k j i₁ =
(cube-comp₋₀₋ (lemma₁₀-back)
(compPath-filler-in-filler p q)) k j i₁
lemma₁₀ : ( i j : I) → _ ≡ _
lemma₁₀ i j i₁ =
(cube-comp₀₋₋ lemma₁₀-front (sym lemma₁₀-back')) i j i₁
| 38.553236
| 139
| 0.332756
|
1c48e9d8a81ff42ddb14d3da4ccb6ca351f7ca1b
| 5,777
|
agda
|
Agda
|
Type/Size/Proofs.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Type/Size/Proofs.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Type/Size/Proofs.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
module Type.Size.Proofs where
import Lvl
open import Data
open import Data.Proofs
open import Functional
open import Function.Equals
open import Function.Inverseᵣ
open import Function.Inverse
open import Function.Proofs
open import Logic
open import Logic.IntroInstances
open import Logic.Propositional
open import Logic.Predicate
open import Structure.Setoid
open import Structure.Function
open import Structure.Function.Domain
open import Structure.Function.Domain.Proofs
open import Structure.Relator.Equivalence
open import Structure.Relator.Ordering
open import Structure.Relator.Properties
open import Type
import Type.Size
private variable ℓ ℓ₁ ℓ₂ ℓₑ ℓₑ₁ ℓₑ₂ ℓₑ₃ : Lvl.Level
private variable T A B C : Type{ℓ}
module _ ⦃ equiv : Equiv{ℓₑ}(T) ⦄ where
open Type.Size
[≼]-maximum : (_≼_ T (T → T) ⦃ [⊜]-equiv ⦄)
[≼]-maximum = [∃]-intro(const) ⦃ intro(proof) ⦄ where
proof : ∀{x y} → (const(x) ⊜ const(y)) → (x ≡ y)
proof{x}{y} (intro fneq) = fneq{x}
[≍]-reflexivity-raw : (T ≍ T)
[≍]-reflexivity-raw = [∃]-intro(id) ⦃ id-bijective ⦄
[≼]-reflexivity-raw : (T ≼ T)
[≼]-reflexivity-raw = [∃]-intro(id) ⦃ id-injective ⦄
[≽]-reflexivity-raw : (T ≽ T)
[≽]-reflexivity-raw = [∃]-intro(id) ⦃ id-surjective ⦄
[≼]-minimum-raw : ⦃ equiv-empty : Equiv{ℓₑ₁}(Empty{ℓ}) ⦄ → (_≼_ Empty ⦃ equiv-empty ⦄ T)
[≼]-minimum-raw = [∃]-intro(empty) ⦃ empty-injective ⦄
-- TODO: Impossible because there are no functions of type (T → ⊥)?
-- instance
-- [≽]-minimum : Weak.Properties.Maximum(_≽_ {ℓ})(Empty)
-- Weak.Properties.Maximum.proof([≽]-minimum) {T} {}
module _ ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄ ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ where
open Type.Size
[≍]-to-[≼] : (A ≍ B) → (A ≼ B)
[≍]-to-[≼] ([∃]-intro(f) ⦃ f-bijective ⦄) =
([∃]-intro(f) ⦃ bijective-to-injective(f) ⦃ f-bijective ⦄ ⦄)
[≍]-to-[≽] : (A ≍ B) → (A ≽ B)
[≍]-to-[≽] ([∃]-intro(f) ⦃ f-bijective ⦄) =
([∃]-intro(f) ⦃ bijective-to-surjective(f) ⦃ f-bijective ⦄ ⦄)
[≽]-to-[≼] : (ab@([∃]-intro f) : (A ≽ B)) → ⦃ func : Function(f) ⦄ ⦃ inv-func : Function(invᵣ-surjective f) ⦄ → (B ≼ A)
[≽]-to-[≼] ([∃]-intro(f) ⦃ f-surjective ⦄) ⦃ inv-func ⦄ = [∃]-intro(invᵣ f ⦃ surjective-to-invertibleᵣ ⦄) ⦃ inverseᵣ-injective{f = f} ⦃ [∧]-elimᵣ([∃]-proof surjective-to-invertibleᵣ) ⦄ ⦄
{-[≼]-to-[≽] : (A ≼ B) → (B ≽ A)
[≼]-to-[≽] ([∃]-intro(f) ⦃ f-injective ⦄) =
{![∃]-intro()!}
-}
[≍]-symmetry-raw : (ab@([∃]-intro f) : (A ≍ B)) → ⦃ func : Function(f) ⦄ → (B ≍ A)
[≍]-symmetry-raw ([∃]-intro(f) ⦃ f-bijective ⦄)
= [∃]-intro(inv f ⦃ bijective-to-invertible ⦄) ⦃ inv-bijective{f = f} ⦃ inver = bijective-to-invertible ⦄ ⦄
module _ ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄ ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ ⦃ equiv-C : Equiv{ℓₑ₃}(C) ⦄ where
open Type.Size
[≍]-transitivity-raw : (ab@([∃]-intro f) : (A ≍ B)) ⦃ func-f : Function(f) ⦄ → (bc@([∃]-intro g) : (B ≍ C)) ⦃ func-g : Function(g) ⦄ → (A ≍ C)
[≍]-transitivity-raw ([∃]-intro(f) ⦃ f-bijective ⦄) ([∃]-intro(g) ⦃ g-bijective ⦄)
= [∃]-intro(g ∘ f) ⦃ [∘]-bijective {f = g} {g = f} ⦃ g-bijective ⦄ ⦃ f-bijective ⦄ ⦄
[≼]-transitivity-raw : (A ≼ B) → (B ≼ C) → (A ≼ C)
[≼]-transitivity-raw ([∃]-intro(f) ⦃ f-injective ⦄) ([∃]-intro(g) ⦃ g-injective ⦄)
= [∃]-intro(g ∘ f) ⦃ [∘]-injective {f = g}{g = f} ⦃ g-injective ⦄ ⦃ f-injective ⦄ ⦄
[≽]-transitivity-raw : (A ≽ B) → (([∃]-intro g) : (B ≽ C)) ⦃ func-g : Function(g) ⦄ → (A ≽ C)
[≽]-transitivity-raw ([∃]-intro(f) ⦃ f-surjective ⦄) ([∃]-intro(g) ⦃ g-surjective ⦄)
= [∃]-intro(g ∘ f) ⦃ [∘]-surjective {f = g} {g = f} ⦃ g-surjective ⦄ ⦃ f-surjective ⦄ ⦄
module _ where
open import Relator.Equals renaming (_≡_ to _≡ₑ_)
open import Relator.Equals.Proofs
private
_≍_ : ∀{ℓ₁ ℓ₂} → (A : Type{ℓ₁}) → (B : Type{ℓ₂}) → Stmt
_≍_ A B = Type.Size._≍_ A B
_≼_ : ∀{ℓ₁ ℓ₂} → (A : Type{ℓ₁}) → (B : Type{ℓ₂}) → Stmt
_≼_ A B = Type.Size._≼_ A B
_≽_ : ∀{ℓ₁ ℓ₂} → (A : Type{ℓ₁}) → (B : Type{ℓ₂}) → Stmt
_≽_ A B = Type.Size._≽_ A B
_≭_ : ∀{ℓ₁ ℓ₂} → (A : Type{ℓ₁}) → (B : Type{ℓ₂}) → Stmt
_≭_ A B = Type.Size._≭_ A B
_≺_ : ∀{ℓ₁ ℓ₂} → (A : Type{ℓ₁}) → (B : Type{ℓ₂}) → Stmt
_≺_ A B = Type.Size._≺_ A B
_≻_ : ∀{ℓ₁ ℓ₂} → (A : Type{ℓ₁}) → (B : Type{ℓ₂}) → Stmt
_≻_ A B = Type.Size._≻_ A B
module _ {ℓ} where
instance
[≍]-reflexivity : Reflexivity(_≍_ {ℓ})
[≍]-reflexivity = intro [≍]-reflexivity-raw
instance
[≍]-symmetry : Symmetry(_≍_ {ℓ})
[≍]-symmetry = intro(f ↦ [≍]-symmetry-raw f)
instance
[≍]-transitivity : Transitivity(_≍_ {ℓ})
[≍]-transitivity = intro(f ↦ g ↦ [≍]-transitivity-raw f g)
instance
[≍]-equivalence : Equivalence(_≍_ {ℓ})
[≍]-equivalence = intro
instance
[≼]-reflexivity : Reflexivity(_≼_ {ℓ})
[≼]-reflexivity = intro [≼]-reflexivity-raw
instance
[≼]-transitivity : Transitivity(_≼_ {ℓ})
[≼]-transitivity = intro [≼]-transitivity-raw
instance
[≽]-reflexivity : Reflexivity(_≽_ {ℓ})
[≽]-reflexivity = intro [≽]-reflexivity-raw
instance
[≽]-transitivity : Transitivity(_≽_ {ℓ})
[≽]-transitivity = intro(p ↦ q ↦ [≽]-transitivity-raw p q)
instance
[≼]-minimum : Weak.Properties.LE.Minimum(_≼_ {ℓ})(Empty)
Weak.Properties.Extremumₗ.proof [≼]-minimum = [≼]-minimum-raw
-- TODO: Impossible because there are no functions of type (T → ⊥)?
-- instance
-- [≽]-minimum : Weak.Properties.Maximum(_≽_ {ℓ})(Empty)
-- Weak.Properties.Maximum.proof([≽]-minimum) {T} {}
-- TODO: Remove this and the similar one in the other module. A more general variant is defined in Relator.Equals.Proofs
module _ {A : Type{ℓ}} {B : Type{ℓ}} where
[≡]-to-[≍] : (A ≡ₑ B) → (A ≍ B)
[≡]-to-[≍] [≡]-intro = reflexivity(_≍_)
| 36.10625
| 188
| 0.564134
|
0e03ede06225d7057f62b521f788d825b823b2d5
| 430
|
agda
|
Agda
|
test/Common/MAlonzo.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Common/MAlonzo.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | null | null | null |
test/Common/MAlonzo.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | null | null | null |
module Common.MAlonzo where
open import Common.Prelude hiding (putStrLn)
open import Common.Coinduction
{-# FOREIGN GHC import qualified Data.Text.IO #-}
postulate
putStrLn : ∞ String → IO Unit
{-# COMPILE GHC putStrLn = Data.Text.IO.putStrLn #-}
main = putStrLn (♯ "This is a dummy main routine.")
mainPrint : String → _
mainPrint s = putStrLn (♯ s)
mainPrintNat : Nat → _
mainPrintNat n = putStrLn (♯ (natToString n))
| 20.47619
| 52
| 0.713953
|
120227048b7f3309dcacc92c994095b4006b6ce9
| 319
|
agda
|
Agda
|
notes/thesis/report/CombiningProofs/CommDisjunction.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
notes/thesis/report/CombiningProofs/CommDisjunction.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
notes/thesis/report/CombiningProofs/CommDisjunction.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module CombiningProofs.CommDisjunction where
open import Common.FOL.FOL
postulate
A B : Set
∨-comm : A ∨ B → B ∨ A
{-# ATP prove ∨-comm #-}
| 22.785714
| 44
| 0.554859
|
50929eca1d6b85e2437e0e55941884f581f6690c
| 368
|
agda
|
Agda
|
test/succeed/SizeSucMonotone.agda
|
larrytheliquid/agda
|
477c8c37f948e6038b773409358fd8f38395f827
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
test/succeed/SizeSucMonotone.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | null | null | null |
test/succeed/SizeSucMonotone.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
-- Andreas, 2012-09-24 Ensure that size successor is monotone
{-# OPTIONS --sized-types #-}
module SizeSucMonotone where
open import Common.Size
data Bool : Set where
true false : Bool
-- T should be monotone in its second arg
T : Bool → Size → Set
T true i = Size< i
T false i = Size< (↑ i)
test : {x : Bool}{i : Size}{j : Size< i} → T x j → T x i
test h = h
| 20.444444
| 61
| 0.646739
|
39c2a0f1de8bc4c184a47475c0076a4870c4ad89
| 912
|
agda
|
Agda
|
test/Succeed/Issue292-17.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue292-17.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue292-17.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- 2011-09-15 by Nisse
-- {-# OPTIONS -v tc.lhs.unify:15 #-}
module Issue292-17 where
data _≡_ {A : Set} (x : A) : A → Set where
refl : x ≡ x
record Σ (A : Set) (B : A → Set) : Set where
constructor _,_
field
proj₁ : A
proj₂ : B proj₁
open Σ
postulate
I : Set
U : I → Set
El : ∀ {i} → U i → Set
mutual
infixl 5 _▻_
data Ctxt : Set where
_▻_ : (Γ : Ctxt) (σ : Type Γ) → Ctxt
Type : Ctxt → Set
Type Γ = Σ I (λ i → Env Γ → U i)
Env : Ctxt → Set
Env (Γ ▻ σ) = Σ (Env Γ) λ γ → El (proj₂ σ γ)
postulate
Γ : Ctxt
σ : Type Γ
data D : Type (Γ ▻ σ) → Set where
d : (τ : Type Γ) → D (proj₁ τ , λ γ → proj₂ τ (proj₁ γ))
record [D] : Set where
constructor [d]
field
τ : Type (Γ ▻ σ)
x : D τ
Foo : {τ₁ τ₂ : Type Γ} →
[d] (proj₁ τ₁ , λ γ → proj₂ τ₁ (proj₁ γ)) (d τ₁) ≡
[d] (proj₁ τ₂ , λ γ → proj₂ τ₂ (proj₁ γ)) (d τ₂) →
Set₁
Foo refl = Set
| 17.538462
| 58
| 0.509868
|
a1198d33ac792382ab9ff29c87e0478dc6b035d9
| 8,177
|
agda
|
Agda
|
Cubical/Algebra/Ring/Base.agda
|
jespercockx/cubical
|
94b474af2909727d04706d562d949928c19faf7b
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/Ring/Base.agda
|
jespercockx/cubical
|
94b474af2909727d04706d562d949928c19faf7b
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/Ring/Base.agda
|
jespercockx/cubical
|
94b474af2909727d04706d562d949928c19faf7b
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe #-}
module Cubical.Algebra.Ring.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.Function
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Transport
open import Cubical.Foundations.SIP
open import Cubical.Data.Sigma
open import Cubical.Algebra.Semigroup
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.Group
open import Cubical.Algebra.AbGroup
open import Cubical.Displayed.Base
open import Cubical.Displayed.Auto
open import Cubical.Displayed.Record
open import Cubical.Displayed.Universe
open import Cubical.Reflection.RecordEquiv
open Iso
private
variable
ℓ ℓ' : Level
record IsRing {R : Type ℓ}
(0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R) : Type ℓ where
constructor isring
field
+IsAbGroup : IsAbGroup 0r _+_ -_
·IsMonoid : IsMonoid 1r _·_
dist : (x y z : R) → (x · (y + z) ≡ (x · y) + (x · z))
× ((x + y) · z ≡ (x · z) + (y · z))
-- This is in the Agda stdlib, but it's redundant
-- zero : (x : R) → (x · 0r ≡ 0r) × (0r · x ≡ 0r)
open IsAbGroup +IsAbGroup public
renaming
( assoc to +Assoc
; identity to +Identity
; lid to +Lid
; rid to +Rid
; inverse to +Inv
; invl to +Linv
; invr to +Rinv
; comm to +Comm
; isSemigroup to +IsSemigroup
; isMonoid to +IsMonoid
; isGroup to +IsGroup )
open IsMonoid ·IsMonoid public
renaming
( assoc to ·Assoc
; identity to ·Identity
; lid to ·Lid
; rid to ·Rid
; isSemigroup to ·IsSemigroup )
hiding
( is-set ) -- We only want to export one proof of this
·Rdist+ : (x y z : R) → x · (y + z) ≡ (x · y) + (x · z)
·Rdist+ x y z = dist x y z .fst
·Ldist+ : (x y z : R) → (x + y) · z ≡ (x · z) + (y · z)
·Ldist+ x y z = dist x y z .snd
record RingStr (A : Type ℓ) : Type (ℓ-suc ℓ) where
constructor ringstr
field
0r : A
1r : A
_+_ : A → A → A
_·_ : A → A → A
-_ : A → A
isRing : IsRing 0r 1r _+_ _·_ -_
infix 8 -_
infixl 7 _·_
infixl 6 _+_
open IsRing isRing public
Ring : ∀ ℓ → Type (ℓ-suc ℓ)
Ring ℓ = TypeWithStr ℓ RingStr
isSetRing : (R : Ring ℓ) → isSet ⟨ R ⟩
isSetRing R = R .snd .RingStr.isRing .IsRing.·IsMonoid .IsMonoid.isSemigroup .IsSemigroup.is-set
makeIsRing : {R : Type ℓ} {0r 1r : R} {_+_ _·_ : R → R → R} { -_ : R → R}
(is-setR : isSet R)
(+-assoc : (x y z : R) → x + (y + z) ≡ (x + y) + z)
(+-rid : (x : R) → x + 0r ≡ x)
(+-rinv : (x : R) → x + (- x) ≡ 0r)
(+-comm : (x y : R) → x + y ≡ y + x)
(r+-assoc : (x y z : R) → x · (y · z) ≡ (x · y) · z)
(·-rid : (x : R) → x · 1r ≡ x)
(·-lid : (x : R) → 1r · x ≡ x)
(·-rdist-+ : (x y z : R) → x · (y + z) ≡ (x · y) + (x · z))
(·-ldist-+ : (x y z : R) → (x + y) · z ≡ (x · z) + (y · z))
→ IsRing 0r 1r _+_ _·_ -_
makeIsRing is-setR assoc +-rid +-rinv +-comm ·-assoc ·-rid ·-lid ·-rdist-+ ·-ldist-+ =
isring (makeIsAbGroup is-setR assoc +-rid +-rinv +-comm)
(makeIsMonoid is-setR ·-assoc ·-rid ·-lid)
λ x y z → ·-rdist-+ x y z , ·-ldist-+ x y z
makeRing : {R : Type ℓ} (0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R)
(is-setR : isSet R)
(+-assoc : (x y z : R) → x + (y + z) ≡ (x + y) + z)
(+-rid : (x : R) → x + 0r ≡ x)
(+-rinv : (x : R) → x + (- x) ≡ 0r)
(+-comm : (x y : R) → x + y ≡ y + x)
(+-assoc : (x y z : R) → x · (y · z) ≡ (x · y) · z)
(·-rid : (x : R) → x · 1r ≡ x)
(·-lid : (x : R) → 1r · x ≡ x)
(·-rdist-+ : (x y z : R) → x · (y + z) ≡ (x · y) + (x · z))
(·-ldist-+ : (x y z : R) → (x + y) · z ≡ (x · z) + (y · z))
→ Ring ℓ
makeRing 0r 1r _+_ _·_ -_ is-setR assoc +-rid +-rinv +-comm ·-assoc ·-rid ·-lid ·-rdist-+ ·-ldist-+ =
_ , ringstr 0r 1r _+_ _·_ -_
(makeIsRing is-setR assoc +-rid +-rinv +-comm
·-assoc ·-rid ·-lid ·-rdist-+ ·-ldist-+ )
record IsRingHom {A : Type ℓ} {B : Type ℓ'} (R : RingStr A) (f : A → B) (S : RingStr B)
: Type (ℓ-max ℓ ℓ')
where
-- Shorter qualified names
private
module R = RingStr R
module S = RingStr S
field
pres0 : f R.0r ≡ S.0r
pres1 : f R.1r ≡ S.1r
pres+ : (x y : A) → f (x R.+ y) ≡ f x S.+ f y
pres· : (x y : A) → f (x R.· y) ≡ f x S.· f y
pres- : (x : A) → f (R.- x) ≡ S.- (f x)
unquoteDecl IsRingHomIsoΣ = declareRecordIsoΣ IsRingHomIsoΣ (quote IsRingHom)
RingHom : (R : Ring ℓ) (S : Ring ℓ') → Type (ℓ-max ℓ ℓ')
RingHom R S = Σ[ f ∈ (⟨ R ⟩ → ⟨ S ⟩) ] IsRingHom (R .snd) f (S .snd)
IsRingEquiv : {A : Type ℓ} {B : Type ℓ'} (M : RingStr A) (e : A ≃ B) (N : RingStr B)
→ Type (ℓ-max ℓ ℓ')
IsRingEquiv M e N = IsRingHom M (e .fst) N
RingEquiv : (R : Ring ℓ) (S : Ring ℓ') → Type (ℓ-max ℓ ℓ')
RingEquiv R S = Σ[ e ∈ (⟨ R ⟩ ≃ ⟨ S ⟩) ] IsRingEquiv (R .snd) e (S .snd)
_$_ : {R S : Ring ℓ} → (φ : RingHom R S) → (x : ⟨ R ⟩) → ⟨ S ⟩
φ $ x = φ .fst x
isPropIsRing : {R : Type ℓ} (0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R)
→ isProp (IsRing 0r 1r _+_ _·_ -_)
isPropIsRing 0r 1r _+_ _·_ -_ (isring RG RM RD) (isring SG SM SD) =
λ i → isring (isPropIsAbGroup _ _ _ RG SG i)
(isPropIsMonoid _ _ RM SM i)
(isPropDistr RD SD i)
where
isSetR : isSet _
isSetR = RM .IsMonoid.isSemigroup .IsSemigroup.is-set
isPropDistr : isProp ((x y z : _) → ((x · (y + z)) ≡ ((x · y) + (x · z)))
× (((x + y) · z) ≡ ((x · z) + (y · z))))
isPropDistr = isPropΠ3 λ _ _ _ → isProp× (isSetR _ _) (isSetR _ _)
isPropIsRingHom : {A : Type ℓ} {B : Type ℓ'} (R : RingStr A) (f : A → B) (S : RingStr B)
→ isProp (IsRingHom R f S)
isPropIsRingHom R f S =
isOfHLevelRetractFromIso 1 IsRingHomIsoΣ
(isProp× (isSetRing (_ , S) _ _)
(isProp× (isSetRing (_ , S) _ _)
(isProp× (isPropΠ2 λ _ _ → isSetRing (_ , S) _ _)
(isProp× (isPropΠ2 λ _ _ → isSetRing (_ , S) _ _)
(isPropΠ λ _ → isSetRing (_ , S) _ _)))))
𝒮ᴰ-Ring : DUARel (𝒮-Univ ℓ) RingStr ℓ
𝒮ᴰ-Ring =
𝒮ᴰ-Record (𝒮-Univ _) IsRingEquiv
(fields:
data[ 0r ∣ null ∣ pres0 ]
data[ 1r ∣ null ∣ pres1 ]
data[ _+_ ∣ bin ∣ pres+ ]
data[ _·_ ∣ bin ∣ pres· ]
data[ -_ ∣ un ∣ pres- ]
prop[ isRing ∣ (λ _ _ → isPropIsRing _ _ _ _ _) ])
where
open RingStr
open IsRingHom
-- faster with some sharing
null = autoDUARel (𝒮-Univ _) (λ A → A)
un = autoDUARel (𝒮-Univ _) (λ A → A → A)
bin = autoDUARel (𝒮-Univ _) (λ A → A → A → A)
RingPath : (R S : Ring ℓ) → RingEquiv R S ≃ (R ≡ S)
RingPath = ∫ 𝒮ᴰ-Ring .UARel.ua
-- Rings have an abelian group and a monoid
Ring→AbGroup : Ring ℓ → AbGroup ℓ
Ring→AbGroup (A , ringstr _ _ _ _ _ R) = A , abgroupstr _ _ _ (IsRing.+IsAbGroup R)
Ring→Group : Ring ℓ → Group ℓ
Ring→Group = AbGroup→Group ∘ Ring→AbGroup
Ring→Monoid : Ring ℓ → Monoid ℓ
Ring→Monoid (A , ringstr _ _ _ _ _ R) = monoid _ _ _ (IsRing.·IsMonoid R)
-- Smart constructor for ring homomorphisms
-- that infers the other equations from pres1, pres+, and pres·
module _ {R : Ring ℓ} {S : Ring ℓ'} {f : ⟨ R ⟩ → ⟨ S ⟩} where
private
module R = RingStr (R .snd)
module S = RingStr (S .snd)
module _
(p1 : f R.1r ≡ S.1r)
(p+ : (x y : ⟨ R ⟩) → f (x R.+ y) ≡ f x S.+ f y)
(p· : (x y : ⟨ R ⟩) → f (x R.· y) ≡ f x S.· f y)
where
open IsRingHom
private
isGHom : IsGroupHom (Ring→Group R .snd) f (Ring→Group S .snd)
isGHom = makeIsGroupHom p+
makeIsRingHom : IsRingHom (R .snd) f (S .snd)
makeIsRingHom .pres0 = isGHom .IsGroupHom.pres1
makeIsRingHom .pres1 = p1
makeIsRingHom .pres+ = p+
makeIsRingHom .pres· = p·
makeIsRingHom .pres- = isGHom .IsGroupHom.presinv
| 32.839357
| 101
| 0.517305
|
c5945ede4389948ed9282c37f21a1d5c65c68528
| 1,563
|
agda
|
Agda
|
Univalence/Obsolete/PiLevel1Alternative.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 14
|
2015-08-18T21:40:15.000Z
|
2021-05-05T01:07:57.000Z
|
Univalence/Obsolete/PiLevel1Alternative.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 4
|
2018-06-07T16:27:41.000Z
|
2021-10-29T20:41:23.000Z
|
Univalence/Obsolete/PiLevel1Alternative.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 3
|
2016-05-29T01:56:33.000Z
|
2019-09-10T09:47:13.000Z
|
{-# OPTIONS --without-K #-}
module PiLevel1Alternative where
open import Relation.Binary.PropositionalEquality
open import Data.Nat
open import Data.Vec
open import FinVec
open F
open import ConcretePermutation
------------------------------------------------------------------------------
-- Equivalences between permutations
-- Objects are level 0 permutations ⟷
-- Morphisms are equivalences between these permutations
factorial : ℕ → ℕ
factorial 0 = 1
factorial (suc n) = n * factorial n
record EquivBetweenPerm {values : ℕ} {size : ℕ} (p₁ p₂ : CPerm values size) : Set where
constructor ebp
module p₁ = CPerm p₁
module p₂ = CPerm p₂
field
-- first we have a permutation on the underlying finite sets
π : FinVec values size
πᵒ : FinVec size values
αp : π ∘̂ πᵒ ≡ F.1C
βp : πᵒ ∘̂ π ≡ F.1C
-- then we have a permutation on these maps are consistent with p₁.π, p₂.π, etc.
ππ : Vec (FinVec values size) (factorial size) -- ??? NO
-- and so on
-- and apply
{--
Ex: the two underlying permutations p₁ and p₂ are:
values = {A,B,C}
size = 3
p₁.π = { A <=> C, B <=> A, C <=> B } represented as {C,A,B}
p₂.π = { A <=> C, B <=> A, C <=> B } represented as {C,A,B}
one equivalence between these permutations is 'id'; another has:
π = { A <=> B, B <=> C, C <=> A }
ππ = { (A <=> C) <=> (B <=> A),
(B <=> A) <=> (C <=> B),
(C <=> B) <=> (A <=> C) }
represented as p₁.πᵒ ???
--}
------------------------------------------------------------------------------
| 28.418182
| 88
| 0.537428
|
2f4d8611d38cf2c388a2b0a08339dec3e55c45e2
| 137
|
agda
|
Agda
|
tests/beyond/evenodd.agda
|
andrejtokarcik/agda-semantics
|
dc333ed142584cf52cc885644eed34b356967d8b
|
[
"MIT"
] | 3
|
2015-08-10T15:33:56.000Z
|
2018-12-06T17:24:25.000Z
|
tests/beyond/evenodd.agda
|
andrejtokarcik/agda-semantics
|
dc333ed142584cf52cc885644eed34b356967d8b
|
[
"MIT"
] | null | null | null |
tests/beyond/evenodd.agda
|
andrejtokarcik/agda-semantics
|
dc333ed142584cf52cc885644eed34b356967d8b
|
[
"MIT"
] | null | null | null |
module evenodd where
mutual
data Even : Set where
Z : Even
S : Odd -> Even
data Odd : Set where
S' : Even -> Odd
| 12.454545
| 23
| 0.554745
|
a13d289d0f5e798882535afc7d1ee0079ba26988
| 8,226
|
agda
|
Agda
|
Groups/Actions/OrbitStabiliser.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Groups/Actions/OrbitStabiliser.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Groups/Actions/OrbitStabiliser.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 1
|
2021-11-29T13:23:07.000Z
|
2021-11-29T13:23:07.000Z
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Setoids.Setoids
open import Functions
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Numbers.Naturals.Naturals
open import Sets.FinSet
open import Groups.Definition
open import Groups.Lemmas
open import Groups.Groups
open import Groups.Actions.Definition
open import Groups.Actions.Stabiliser
open import Groups.Groups2
open import Sets.EquivalenceRelations
module Groups.Actions.OrbitStabiliser where
orbitStabiliserEquivRel1 : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) → Rel A
orbitStabiliserEquivRel1 {T = T} action x g1 g2 = Setoid._∼_ T (GroupAction.action action g1 x) (GroupAction.action action g2 x)
orbitStabiliserEquivRel2 : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) → Rel A
orbitStabiliserEquivRel2 {T = T} {_+_ = _+_} {G = G} action x g1 g2 = Setoid._∼_ T (GroupAction.action action ((Group.inverse G g2) + g1) x) x
osEquivRel1Equiv : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) → Equivalence (orbitStabiliserEquivRel1 action x)
Equivalence.reflexive (osEquivRel1Equiv {T = T} action x) {a} = Equivalence.reflexive (Setoid.eq T)
Equivalence.symmetric (osEquivRel1Equiv {T = T} action x) {a} {b} = Equivalence.symmetric (Setoid.eq T)
Equivalence.transitive (osEquivRel1Equiv {T = T} action x) {a} {b} {c} = Equivalence.transitive (Setoid.eq T)
osEquivRel2Equiv : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) → Equivalence (orbitStabiliserEquivRel2 action x)
Equivalence.reflexive (osEquivRel2Equiv {T = T} {G = G} action x) = transitive (GroupAction.actionWellDefined1 action (Group.invLeft G)) (GroupAction.identityAction action)
where
open Equivalence (Setoid.eq T)
Equivalence.symmetric (osEquivRel2Equiv {S = S} {T = T} {_+_ = _+_} {G = G} gAction x) {b} {c} b=c = need
where
open Equivalence (Setoid.eq T)
open Equivalence (Setoid.eq S) renaming (symmetric to symmetricS ; transitive to transitiveS ; reflexive to reflexiveS)
open Setoid T
open GroupAction gAction
open Group G
have : action ((inverse c) + b) x ∼ x
have = b=c
p : action (inverse (inverse b + c)) x ∼ x
p = transitive (actionWellDefined1 (transitiveS (invContravariant G) (Group.+WellDefined G reflexiveS (invInv G)))) have
q : action ((inverse b) + c) (action (inverse (inverse b + c)) x) ∼ action ((inverse b) + c) x
q = actionWellDefined2 p
r : action (((inverse b) + c) + (inverse (inverse b + c))) x ∼ action ((inverse b) + c) x
r = transitive associativeAction q
s : action identity x ∼ action ((inverse b) + c) x
s = transitive (actionWellDefined1 (symmetricS invRight)) r
need : action ((inverse b) + c) x ∼ x
need = symmetric (transitive (symmetric identityAction) s)
Equivalence.transitive (osEquivRel2Equiv {S = S} {T = T} {_+_ = _+_} {G = G} gAction x) {a} {b} {c} a=b b=c = need
where
open Equivalence (Setoid.eq T)
open Equivalence (Setoid.eq S) renaming (symmetric to symmetricS ; reflexive to reflexiveS ; transitive to transitiveS)
open Setoid T
open GroupAction gAction
open Group G
have1 : action ((inverse c) + b) x ∼ x
have1 = b=c
have2 : action ((inverse b) + a) x ∼ x
have2 = a=b
p : action ((inverse c) + b) (action (inverse b + a) x) ∼ x
p = transitive (actionWellDefined2 have2) have1
q : action ((inverse c + b) + (inverse b + a)) x ∼ x
q = transitive associativeAction p
need : action ((inverse c) + a) x ∼ x
need = transitive (actionWellDefined1 (transitiveS (+WellDefined reflexiveS (transitiveS (symmetricS identLeft) (+WellDefined (symmetricS invRight) reflexiveS))) (fourWayAssoc G))) q
osEquivRelsEqual' : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) {g h : A} → (orbitStabiliserEquivRel2 action x) g h → (orbitStabiliserEquivRel1 action x) g h
osEquivRelsEqual' {S = S} {T = T} {_+_ = _+_} {G = G} action x {g} {h} g=h = need
where
open Setoid T
open Group G
open Equivalence eq
open Equivalence (Setoid.eq S) renaming (symmetric to symmetricS ; transitive to transitiveS)
have : (GroupAction.action action ((inverse h) + g) x) ∼ x
have = g=h
p : (GroupAction.action action (inverse h) (GroupAction.action action g x)) ∼ x
p = transitive (symmetric (GroupAction.associativeAction action)) have
q : (GroupAction.action action h (GroupAction.action action (inverse h) (GroupAction.action action g x))) ∼ GroupAction.action action h x
q = GroupAction.actionWellDefined2 action p
r : (GroupAction.action action (h + inverse h) (GroupAction.action action g x)) ∼ GroupAction.action action h x
r = transitive (GroupAction.associativeAction action) q
s : (GroupAction.action action identity (GroupAction.action action g x)) ∼ GroupAction.action action h x
s = transitive (GroupAction.actionWellDefined1 action (symmetricS (Group.invRight G))) r
need : (GroupAction.action action g x) ∼ (GroupAction.action action h x)
need = transitive (symmetric (GroupAction.identityAction action)) s
osEquivRelsEqual : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) {g h : A} → (orbitStabiliserEquivRel1 action x) g h → (orbitStabiliserEquivRel2 action x) g h
osEquivRelsEqual {T = T} {_+_ = _+_} {G = G} action x {g} {h} g=h = need
where
open Setoid T
open Group G
open Equivalence eq
have : (GroupAction.action action g x) ∼ (GroupAction.action action h x)
have = g=h
p : GroupAction.action action (inverse h) (GroupAction.action action g x) ∼ GroupAction.action action (inverse h) (GroupAction.action action h x)
p = GroupAction.actionWellDefined2 action have
need : (GroupAction.action action ((inverse h) + g) x) ∼ x
need = transitive (GroupAction.associativeAction action) (transitive p (transitive (symmetric (GroupAction.associativeAction action)) (transitive (GroupAction.actionWellDefined1 action (Group.invLeft G)) (GroupAction.identityAction action))))
orbitStabiliserBijection : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) → A → ((Stabiliser action x) && Orbit action x)
orbitStabiliserBijection action x g = stab {!GroupAction.action action ? ?!} {!!} ,, orbitElt g
where
osBijWellDefined : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) → {r s : A} → (Setoid._∼_ S r s) → Setoid._∼_ (directSumSetoid (stabiliserSetoid action x) (orbitSetoid action x)) (orbitStabiliserBijection action x r) (orbitStabiliserBijection action x s)
_&&_.fst (osBijWellDefined action x r~s) = {!!}
_&&_.snd (osBijWellDefined action x r~s) = GroupAction.actionWellDefined1 action r~s
orbitStabiliserTheorem : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) → SetoidBijection S (directSumSetoid (stabiliserSetoid action x) (orbitSetoid action x)) (orbitStabiliserBijection action x)
SetoidInjection.+WellDefined (SetoidBijection.inj (orbitStabiliserTheorem {S = S} action x)) = osBijWellDefined action x
SetoidInjection.injective (SetoidBijection.inj (orbitStabiliserTheorem {S = S} action x)) {g} {h} (fst ,, gx=hx) = {!!}
SetoidSurjection.+WellDefined (SetoidBijection.surj (orbitStabiliserTheorem action x)) = osBijWellDefined action x
SetoidSurjection.surjective (SetoidBijection.surj (orbitStabiliserTheorem action x)) {stab g gx=x ,, orbitElt h} = h , ({!!} ,, {!!})
| 70.307692
| 364
| 0.671043
|
0e231e5071df3b7b561665d616316d3e6d9bbd24
| 934
|
agda
|
Agda
|
agda/Data/Nat/Base.agda
|
oisdk/combinatorics-paper
|
3c176d4690566d81611080e9378f5a178b39b851
|
[
"MIT"
] | 4
|
2021-01-05T14:07:44.000Z
|
2021-01-05T15:32:14.000Z
|
agda/Data/Nat/Base.agda
|
oisdk/combinatorics-paper
|
3c176d4690566d81611080e9378f5a178b39b851
|
[
"MIT"
] | null | null | null |
agda/Data/Nat/Base.agda
|
oisdk/combinatorics-paper
|
3c176d4690566d81611080e9378f5a178b39b851
|
[
"MIT"
] | 1
|
2021-01-05T14:05:30.000Z
|
2021-01-05T14:05:30.000Z
|
{-# OPTIONS --cubical --safe #-}
module Data.Nat.Base where
open import Agda.Builtin.Nat public
using (_+_; _*_; zero; suc)
renaming (Nat to ℕ; _-_ to _∸_)
import Agda.Builtin.Nat as Nat
open import Level
open import Data.Bool
data Ordering : ℕ → ℕ → Type₀ where
less : ∀ m k → Ordering m (suc (m + k))
equal : ∀ m → Ordering m m
greater : ∀ m k → Ordering (suc (m + k)) m
compare : ∀ m n → Ordering m n
compare zero zero = equal zero
compare (suc m) zero = greater zero m
compare zero (suc n) = less zero n
compare (suc m) (suc n) with compare m n
... | less m k = less (suc m) k
... | equal m = equal (suc m)
... | greater n k = greater (suc n) k
nonZero : ℕ → Bool
nonZero (suc _) = true
nonZero zero = false
_÷_ : (n m : ℕ) → { m≢0 : T (nonZero m) } → ℕ
_÷_ n (suc m) = Nat.div-helper 0 m n m
rem : (n m : ℕ) → { m≢0 : T (nonZero m) } → ℕ
rem n (suc m) = Nat.mod-helper 0 m n m
| 25.944444
| 45
| 0.583512
|
121568bb204132ab3fa7bc08e0f216b2da6e095e
| 16,246
|
agda
|
Agda
|
src/Colimit/Sequential.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | 3
|
2020-05-21T22:58:50.000Z
|
2021-09-02T17:18:15.000Z
|
src/Colimit/Sequential.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | null | null | null |
src/Colimit/Sequential.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- Sequential colimits
------------------------------------------------------------------------
{-# OPTIONS --erased-cubical --safe #-}
-- The definition of sequential colimits and the statement of the
-- non-dependent universal property are based on those in van Doorn's
-- "Constructing the Propositional Truncation using Non-recursive
-- HITs".
-- The module is parametrised by a notion of equality. The higher
-- constructor of the HIT defining sequential colimits uses path
-- equality, but the supplied notion of equality is used for many
-- other things.
import Equality.Path as P
module Colimit.Sequential
{e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where
open P.Derived-definitions-and-properties eq hiding (elim)
open import Prelude
open import Bijection equality-with-J using (_↔_)
import Colimit.Sequential.Erased eq as E
import Colimit.Sequential.Very-erased eq as VE
open import Equality.Path.Isomorphisms eq
open import Equivalence equality-with-J as Eq using (_≃_)
import Equivalence P.equality-with-J as PEq
open import Function-universe equality-with-J hiding (id; _∘_)
private
variable
a b p q : Level
A B : Type a
P : A → Type p
n : ℕ
e x : A
------------------------------------------------------------------------
-- The type
-- Sequential colimits.
data Colimit (P : ℕ → Type p) (step : ∀ {n} → P n → P (suc n)) :
Type p where
∣_∣ : P n → Colimit P step
∣∣≡∣∣ᴾ : (x : P n) → ∣ step x ∣ P.≡ ∣ x ∣
-- A variant of ∣∣≡∣∣ᴾ.
∣∣≡∣∣ : {step : ∀ {n} → P n → P (suc n)} (x : P n) →
_≡_ {A = Colimit P step} ∣ step x ∣ ∣ x ∣
∣∣≡∣∣ x = _↔_.from ≡↔≡ (∣∣≡∣∣ᴾ x)
------------------------------------------------------------------------
-- Eliminators
-- A dependent eliminator, expressed using paths.
record Elimᴾ
{P : ℕ → Type p} {step : ∀ {n} → P n → P (suc n)}
(Q : Colimit P step → Type q) : Type (p ⊔ q) where
no-eta-equality
field
∣∣ʳ : (x : P n) → Q ∣ x ∣
∣∣≡∣∣ʳ :
(x : P n) →
P.[ (λ i → Q (∣∣≡∣∣ᴾ x i)) ] ∣∣ʳ (step x) ≡ ∣∣ʳ x
open Elimᴾ public
elimᴾ :
{step : ∀ {n} → P n → P (suc n)} {Q : Colimit P step → Type q} →
Elimᴾ Q → (x : Colimit P step) → Q x
elimᴾ {P = P} {step = step} {Q = Q} e = helper
where
module E′ = Elimᴾ e
helper : (x : Colimit P step) → Q x
helper ∣ x ∣ = E′.∣∣ʳ x
helper (∣∣≡∣∣ᴾ x i) = E′.∣∣≡∣∣ʳ x i
-- A non-dependent eliminator, expressed using paths.
record Recᴾ
(P : ℕ → Type p) (step : ∀ {n} → P n → P (suc n))
(B : Type b) : Type (p ⊔ b) where
no-eta-equality
field
∣∣ʳ : P n → B
∣∣≡∣∣ʳ : (x : P n) → ∣∣ʳ (step x) P.≡ ∣∣ʳ x
open Recᴾ public
recᴾ :
{step : ∀ {n} → P n → P (suc n)} →
Recᴾ P step B → Colimit P step → B
recᴾ r = elimᴾ λ where
.∣∣ʳ → R.∣∣ʳ
.∣∣≡∣∣ʳ → R.∣∣≡∣∣ʳ
where
module R = Recᴾ r
-- A dependent eliminator.
record Elim
{P : ℕ → Type p} {step : ∀ {n} → P n → P (suc n)}
(Q : Colimit P step → Type q) : Type (p ⊔ q) where
no-eta-equality
field
∣∣ʳ : (x : P n) → Q ∣ x ∣
∣∣≡∣∣ʳ : (x : P n) → subst Q (∣∣≡∣∣ x) (∣∣ʳ (step x)) ≡ ∣∣ʳ x
open Elim public
elim :
{step : ∀ {n} → P n → P (suc n)} {Q : Colimit P step → Type q} →
Elim Q → (x : Colimit P step) → Q x
elim e = elimᴾ λ where
.∣∣ʳ → E′.∣∣ʳ
.∣∣≡∣∣ʳ x → subst≡→[]≡ (E′.∣∣≡∣∣ʳ x)
where
module E′ = Elim e
-- A "computation" rule.
elim-∣∣≡∣∣ : dcong (elim e) (∣∣≡∣∣ x) ≡ Elim.∣∣≡∣∣ʳ e x
elim-∣∣≡∣∣ = dcong-subst≡→[]≡ (refl _)
-- A non-dependent eliminator.
record Rec
(P : ℕ → Type p) (step : ∀ {n} → P n → P (suc n))
(B : Type b) : Type (p ⊔ b) where
no-eta-equality
field
∣∣ʳ : P n → B
∣∣≡∣∣ʳ : (x : P n) → ∣∣ʳ (step x) ≡ ∣∣ʳ x
open Rec public
rec :
{step : ∀ {n} → P n → P (suc n)} →
Rec P step B → Colimit P step → B
rec r = recᴾ λ where
.∣∣ʳ → R.∣∣ʳ
.∣∣≡∣∣ʳ x → _↔_.to ≡↔≡ (R.∣∣≡∣∣ʳ x)
where
module R = Rec r
-- A "computation" rule.
rec-∣∣≡∣∣ :
{step : ∀ {n} → P n → P (suc n)} {r : Rec P step B} {x : P n} →
cong (rec r) (∣∣≡∣∣ x) ≡ Rec.∣∣≡∣∣ʳ r x
rec-∣∣≡∣∣ = cong-≡↔≡ (refl _)
------------------------------------------------------------------------
-- The universal property
-- The universal property of the sequential colimit.
universal-property :
{step : ∀ {n} → P n → P (suc n)} →
(Colimit P step → B) ≃
(∃ λ (f : ∀ n → P n → B) → ∀ n x → f (suc n) (step x) ≡ f n x)
universal-property {P = P} {B = B} {step = step} =
Eq.↔→≃ to from to∘from from∘to
where
to :
(Colimit P step → B) →
∃ λ (f : ∀ n → P n → B) → ∀ n x → f (suc n) (step x) ≡ f n x
to h = (λ _ → h ∘ ∣_∣)
, (λ _ x →
h ∣ step x ∣ ≡⟨ cong h (∣∣≡∣∣ x) ⟩∎
h ∣ x ∣ ∎)
from :
(∃ λ (f : ∀ n → P n → B) → ∀ n x → f (suc n) (step x) ≡ f n x) →
Colimit P step → B
from (f , g) = rec λ where
.∣∣ʳ → f _
.∣∣≡∣∣ʳ → g _
to∘from : ∀ p → to (from p) ≡ p
to∘from (f , g) = cong (f ,_) $ ⟨ext⟩ λ n → ⟨ext⟩ λ x →
cong (rec _) (∣∣≡∣∣ x) ≡⟨ rec-∣∣≡∣∣ ⟩∎
g n x ∎
from∘to : ∀ h → from (to h) ≡ h
from∘to h = ⟨ext⟩ $ elim λ where
.∣∣ʳ _ → refl _
.∣∣≡∣∣ʳ x →
subst (λ z → from (to h) z ≡ h z) (∣∣≡∣∣ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩
trans (sym (cong (from (to h)) (∣∣≡∣∣ x)))
(trans (refl _) (cong h (∣∣≡∣∣ x))) ≡⟨ cong₂ (λ p q → trans (sym p) q)
rec-∣∣≡∣∣
(trans-reflˡ _) ⟩
trans (sym (cong h (∣∣≡∣∣ x))) (cong h (∣∣≡∣∣ x)) ≡⟨ trans-symˡ _ ⟩∎
refl _ ∎
-- A dependently typed variant of the sequential colimit's universal
-- property.
universal-property-Π :
{step : ∀ {n} → P n → P (suc n)} →
{Q : Colimit P step → Type q} →
((x : Colimit P step) → Q x) ≃
(∃ λ (f : ∀ n (x : P n) → Q ∣ x ∣) →
∀ n x → subst Q (∣∣≡∣∣ x) (f (suc n) (step x)) ≡ f n x)
universal-property-Π {P = P} {step = step} {Q = Q} =
Eq.↔→≃ to from to∘from from∘to
where
to :
((x : Colimit P step) → Q x) →
∃ λ (f : ∀ n (x : P n) → Q ∣ x ∣) →
∀ n x → subst Q (∣∣≡∣∣ x) (f (suc n) (step x)) ≡ f n x
to h = (λ _ → h ∘ ∣_∣)
, (λ _ x →
subst Q (∣∣≡∣∣ x) (h ∣ step x ∣) ≡⟨ dcong h (∣∣≡∣∣ x) ⟩∎
h ∣ x ∣ ∎)
from :
(∃ λ (f : ∀ n (x : P n) → Q ∣ x ∣) →
∀ n x → subst Q (∣∣≡∣∣ x) (f (suc n) (step x)) ≡ f n x) →
(x : Colimit P step) → Q x
from (f , g) = elim λ where
.∣∣ʳ → f _
.∣∣≡∣∣ʳ → g _
to∘from : ∀ p → to (from p) ≡ p
to∘from (f , g) = cong (f ,_) $ ⟨ext⟩ λ n → ⟨ext⟩ λ x →
dcong (elim _) (∣∣≡∣∣ x) ≡⟨ elim-∣∣≡∣∣ ⟩∎
g n x ∎
from∘to : ∀ h → from (to h) ≡ h
from∘to h = ⟨ext⟩ $ elim λ where
.∣∣ʳ _ → refl _
.∣∣≡∣∣ʳ x →
subst (λ z → from (to h) z ≡ h z) (∣∣≡∣∣ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-dcong ⟩
trans (sym (dcong (from (to h)) (∣∣≡∣∣ x)))
(trans (cong (subst Q (∣∣≡∣∣ x)) (refl _))
(dcong h (∣∣≡∣∣ x))) ≡⟨ cong₂ (λ p q → trans (sym p) q)
elim-∣∣≡∣∣
(trans (cong (flip trans _) $
cong-refl _) $
trans-reflˡ _) ⟩
trans (sym (dcong h (∣∣≡∣∣ x))) (dcong h (∣∣≡∣∣ x)) ≡⟨ trans-symˡ _ ⟩∎
refl _ ∎
------------------------------------------------------------------------
-- Some conversion functions
-- E.Colimitᴱ P step implies Colimit P step.
Colimitᴱ→Colimit :
{step : ∀ {n} → P n → P (suc n)} →
E.Colimitᴱ P step → Colimit P step
Colimitᴱ→Colimit = E.rec λ where
.E.∣∣ʳ → ∣_∣
.E.∣∣≡∣∣ʳ → ∣∣≡∣∣
-- In erased contexts E.Colimitᴱ P step is equivalent to
-- Colimit P step.
@0 Colimitᴱ≃Colimit :
{step : ∀ {n} → P n → P (suc n)} →
E.Colimitᴱ P step ≃ Colimit P step
Colimitᴱ≃Colimit = Eq.↔→≃
Colimitᴱ→Colimit
Colimit→Colimitᴱ
(elim λ @0 where
.∣∣ʳ _ → refl _
.∣∣≡∣∣ʳ x →
subst (λ x → Colimitᴱ→Colimit (Colimit→Colimitᴱ x) ≡ x)
(∣∣≡∣∣ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩
trans (sym (cong (Colimitᴱ→Colimit ∘ Colimit→Colimitᴱ)
(∣∣≡∣∣ x)))
(trans (refl _) (cong id (∣∣≡∣∣ x))) ≡⟨ cong₂ (trans ∘ sym)
(trans (sym $ cong-∘ _ _ _) $
trans (cong (cong Colimitᴱ→Colimit) rec-∣∣≡∣∣) $
E.rec-∣∣≡∣∣)
(trans (trans-reflˡ _) $
sym $ cong-id _) ⟩
trans (sym (∣∣≡∣∣ x)) (∣∣≡∣∣ x) ≡⟨ trans-symˡ _ ⟩∎
refl _ ∎)
(E.elim λ where
.E.∣∣ʳ _ → refl _
.E.∣∣≡∣∣ʳ x →
subst (λ x → Colimit→Colimitᴱ (Colimitᴱ→Colimit x) ≡ x)
(E.∣∣≡∣∣ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩
trans (sym (cong (Colimit→Colimitᴱ ∘ Colimitᴱ→Colimit)
(E.∣∣≡∣∣ x)))
(trans (refl _) (cong id (E.∣∣≡∣∣ x))) ≡⟨ cong₂ (trans ∘ sym)
(trans (sym $ cong-∘ _ _ _) $
trans (cong (cong Colimit→Colimitᴱ) E.rec-∣∣≡∣∣) $
rec-∣∣≡∣∣)
(trans (trans-reflˡ _) $
sym $ cong-id _) ⟩
trans (sym (E.∣∣≡∣∣ x)) (E.∣∣≡∣∣ x) ≡⟨ trans-symˡ _ ⟩∎
refl _ ∎)
where
Colimit→Colimitᴱ = rec λ @0 where
.∣∣ʳ → E.∣_∣
.∣∣≡∣∣ʳ → E.∣∣≡∣∣
-- Some instances of VE.Colimitᴱ can be converted to instances of
-- Colimit. Note that P₀ and P₊ target the same universe.
Very-Colimitᴱ→Colimit :
{P₀ : Type p}
{P₊ : ℕ → Type p}
{step₀ : P₀ → P₊ zero} →
{step₊ : ∀ {n} → P₊ n → P₊ (suc n)} →
VE.Colimitᴱ P₀ P₊ step₀ step₊ →
Colimit
(ℕ-rec P₀ (λ n _ → P₊ n))
(λ {n} → ℕ-rec {P = λ n → ℕ-rec P₀ (λ n _ → P₊ n) n → P₊ n}
step₀ (λ _ _ → step₊) n)
Very-Colimitᴱ→Colimit = VE.rec λ where
.VE.∣∣₀ʳ → ∣_∣ {n = 0}
.VE.∣∣₊ʳ → ∣_∣
.VE.∣∣₊≡∣∣₀ʳ → ∣∣≡∣∣
.VE.∣∣₊≡∣∣₊ʳ → ∣∣≡∣∣
-- In erased contexts there are equivalences between some instances of
-- VE.Colimitᴱ and some instances of Colimit.
@0 Very-Colimitᴱ≃Colimit :
{P₀ : Type p}
{P₊ : ℕ → Type p}
{step₀ : P₀ → P₊ zero} →
{step₊ : ∀ {n} → P₊ n → P₊ (suc n)} →
VE.Colimitᴱ P₀ P₊ step₀ step₊ ≃
Colimit
(ℕ-rec P₀ (λ n _ → P₊ n))
(λ {n} → ℕ-rec {P = λ n → ℕ-rec P₀ (λ n _ → P₊ n) n → P₊ n}
step₀ (λ _ _ → step₊) n)
Very-Colimitᴱ≃Colimit = Eq.↔→≃
Very-Colimitᴱ→Colimit
Colimit→Colimitᴱ
(elim λ @0 where
.∣∣ʳ {n = zero} _ → refl _
.∣∣ʳ {n = suc _} _ → refl _
.∣∣≡∣∣ʳ {n = zero} x →
subst (λ x → Very-Colimitᴱ→Colimit (Colimit→Colimitᴱ x) ≡ x)
(∣∣≡∣∣ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩
trans (sym (cong (Very-Colimitᴱ→Colimit ∘ Colimit→Colimitᴱ)
(∣∣≡∣∣ x)))
(trans (refl _) (cong id (∣∣≡∣∣ x))) ≡⟨ cong₂ (trans ∘ sym)
(trans (sym $ cong-∘ _ _ _) $
trans (cong (cong Very-Colimitᴱ→Colimit) rec-∣∣≡∣∣) $
VE.rec-∣∣₊≡∣∣₀)
(trans (trans-reflˡ _) $
sym $ cong-id _) ⟩
trans (sym (∣∣≡∣∣ x)) (∣∣≡∣∣ x) ≡⟨ trans-symˡ _ ⟩∎
refl _ ∎
.∣∣≡∣∣ʳ {n = suc _} x →
subst (λ x → Very-Colimitᴱ→Colimit (Colimit→Colimitᴱ x) ≡ x)
(∣∣≡∣∣ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩
trans (sym (cong (Very-Colimitᴱ→Colimit ∘ Colimit→Colimitᴱ)
(∣∣≡∣∣ x)))
(trans (refl _) (cong id (∣∣≡∣∣ x))) ≡⟨ cong₂ (trans ∘ sym)
(trans (sym $ cong-∘ _ _ _) $
trans (cong (cong Very-Colimitᴱ→Colimit) rec-∣∣≡∣∣) $
VE.rec-∣∣₊≡∣∣₊)
(trans (trans-reflˡ _) $
sym $ cong-id _) ⟩
trans (sym (∣∣≡∣∣ x)) (∣∣≡∣∣ x) ≡⟨ trans-symˡ _ ⟩∎
refl _ ∎)
(VE.elim λ where
.VE.∣∣₀ʳ _ → refl _
.VE.∣∣₊ʳ _ → refl _
.VE.∣∣₊≡∣∣₀ʳ x →
subst (λ x → Colimit→Colimitᴱ (Very-Colimitᴱ→Colimit x) ≡ x)
(VE.∣∣₊≡∣∣₀ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩
trans (sym (cong (Colimit→Colimitᴱ ∘ Very-Colimitᴱ→Colimit)
(VE.∣∣₊≡∣∣₀ x)))
(trans (refl _) (cong id (VE.∣∣₊≡∣∣₀ x))) ≡⟨ cong₂ (trans ∘ sym)
(trans (sym $ cong-∘ _ _ _) $
trans (cong (cong Colimit→Colimitᴱ) VE.rec-∣∣₊≡∣∣₀) $
rec-∣∣≡∣∣)
(trans (trans-reflˡ _) $
sym $ cong-id _) ⟩
trans (sym (VE.∣∣₊≡∣∣₀ x)) (VE.∣∣₊≡∣∣₀ x) ≡⟨ trans-symˡ _ ⟩∎
refl _ ∎
.VE.∣∣₊≡∣∣₊ʳ x →
subst (λ x → Colimit→Colimitᴱ (Very-Colimitᴱ→Colimit x) ≡ x)
(VE.∣∣₊≡∣∣₊ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩
trans (sym (cong (Colimit→Colimitᴱ ∘ Very-Colimitᴱ→Colimit)
(VE.∣∣₊≡∣∣₊ x)))
(trans (refl _) (cong id (VE.∣∣₊≡∣∣₊ x))) ≡⟨ cong₂ (trans ∘ sym)
(trans (sym $ cong-∘ _ _ _) $
trans (cong (cong Colimit→Colimitᴱ) VE.rec-∣∣₊≡∣∣₊) $
rec-∣∣≡∣∣)
(trans (trans-reflˡ _) $
sym $ cong-id _) ⟩
trans (sym (VE.∣∣₊≡∣∣₊ x)) (VE.∣∣₊≡∣∣₊ x) ≡⟨ trans-symˡ _ ⟩∎
refl _ ∎)
where
Colimit→Colimitᴱ = rec λ @0 where
.∣∣ʳ {n = zero} → VE.∣_∣₀
.∣∣ʳ {n = suc _} → VE.∣_∣₊
.∣∣≡∣∣ʳ {n = zero} → VE.∣∣₊≡∣∣₀
.∣∣≡∣∣ʳ {n = suc _} → VE.∣∣₊≡∣∣₊
| 37.51963
| 128
| 0.363351
|
2f871417d2c65c970799fb154750787dae3bf5f2
| 262
|
agda
|
Agda
|
Algebra/Group.agda
|
esoeylemez/agda-simple
|
d9245e5a8b2e902781736de09bd17e81022f6f13
|
[
"BSD-3-Clause"
] | 1
|
2019-10-07T17:36:42.000Z
|
2019-10-07T17:36:42.000Z
|
Algebra/Group.agda
|
esoeylemez/agda-simple
|
d9245e5a8b2e902781736de09bd17e81022f6f13
|
[
"BSD-3-Clause"
] | null | null | null |
Algebra/Group.agda
|
esoeylemez/agda-simple
|
d9245e5a8b2e902781736de09bd17e81022f6f13
|
[
"BSD-3-Clause"
] | null | null | null |
-- Copyright: (c) 2016 Ertugrul Söylemez
-- License: BSD3
-- Maintainer: Ertugrul Söylemez <esz@posteo.de>
module Algebra.Group where
open import Algebra.Group.Group public
open import Algebra.Group.Monoid public
open import Algebra.Group.Semigroup public
| 26.2
| 48
| 0.782443
|
c5e04b557d286db9b83119f96cf1a2cb4ace1bef
| 1,778
|
agda
|
Agda
|
probability/Listy.agda
|
oisdk/prob-presentation
|
880217ca51ab62f6feee58ccacdb39bfade43101
|
[
"MIT"
] | null | null | null |
probability/Listy.agda
|
oisdk/prob-presentation
|
880217ca51ab62f6feee58ccacdb39bfade43101
|
[
"MIT"
] | null | null | null |
probability/Listy.agda
|
oisdk/prob-presentation
|
880217ca51ab62f6feee58ccacdb39bfade43101
|
[
"MIT"
] | null | null | null |
module Listy where
open import Measure
open import Data.List as List using (List; []; _∷_)
open import Data.Product using (_,_; _×_; proj₁; proj₂)
open import Data.Nat as ℕ using (ℕ; suc; zero)
open import Function
record Prob (A : Set) : Set where
constructor weighted
field
runProb : List (A × ℙ)
open Prob
open import Category.Monad
monad : RawMonad Prob
monad = record
{ return = λ x → weighted ((x , fromNat 1) ∷ [])
; _>>=_ = bind
}
where
import Data.List.Categorical
open RawMonad Data.List.Categorical.monad
bind : {A B : Set} → Prob A → (A → Prob B) → Prob B
bind xs f = weighted do
(x , xp) ← runProb xs
(y , yp) ← runProb (f x)
return (y , xp * yp)
support : {A : Set} → Prob A → List A
support = List.map proj₁ ∘ runProb
expect : {A : Set} → (A → ℙ) → Prob A → ℙ
expect p = List.foldl (λ ys y → ys + (p (proj₁ y) * (proj₂ y)) ) (fromNat 0) ∘ runProb
open import Data.Bool using (Bool; if_then_else_)
probOf : {A : Set} → (A → Bool) → Prob A → ℙ
probOf p = expect (λ x → if p x then fromNat 1 else fromNat 0)
uniform : {A : Set} → List A → Prob A
uniform [] = weighted []
uniform (x ∷ xs) = weighted (List.map (flip _,_ p) (x ∷ xs))
where
p : ℙ
p = 1 ?÷ (suc (List.length xs))
open import Data.Fin as Fin using (Fin)
enumerate : (n : ℕ) → List (Fin n)
enumerate zero = []
enumerate (suc n) = Fin.zero ∷ List.map Fin.suc (enumerate n)
module Die where
die : Prob (Fin 6)
die = uniform (enumerate 6)
open RawMonad monad
pairadice : Prob ℕ
pairadice = do
x ← die
y ← die
return (suc (Fin.toℕ x) ℕ.+ suc (Fin.toℕ y))
open import Data.String using (String)
open import Relation.Nullary.Decidable using (⌊_⌋)
example : String
example = show (probOf (λ x → ⌊ x ℕ.≟ 7 ⌋) Die.pairadice)
| 24.027027
| 86
| 0.624297
|
31527d4fb3b4e104e35d07233140df9a6ea2ea06
| 14,808
|
agda
|
Agda
|
BTA3_polybta-review.agda
|
luminousfennell/polybta
|
ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb
|
[
"BSD-3-Clause"
] | 1
|
2019-10-15T04:35:29.000Z
|
2019-10-15T04:35:29.000Z
|
BTA3_polybta-review.agda
|
luminousfennell/polybta
|
ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb
|
[
"BSD-3-Clause"
] | null | null | null |
BTA3_polybta-review.agda
|
luminousfennell/polybta
|
ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb
|
[
"BSD-3-Clause"
] | 1
|
2019-10-15T09:01:37.000Z
|
2019-10-15T09:01:37.000Z
|
module BTA3 where
open import Data.Nat
open import Data.Bool
open import Data.List
-- Binding times
data BT : Set where
S : BT
D : BT
-- defining a data type [BT],where two members are
-- [S] standing for "static" and [D] standing for dynamic.
-- ``subsumption'' binding times; static can be treated as dynamic,
-- but not vice versa
_≼_ : BT → BT → Bool
_≼_ D S = false
_≼_ _ _ = true
-- note that the above function can also be specified as follows,
-- _≼_ : BT → BT → Bool
-- D ≼ S = false
-- _ ≼ _ = true
-- note that the function [≼] specifies that a "static",S, can be treated
-- as a "dynamic",D, and not the other way round
-- since in Agda, pattern matching is conducted in a sequencial fashion,
-- the above specification makes sure that it returns [false] when the
-- first argument is [D] and the second [S] and returns [true] in all
-- the other three cases.
-- BEGIN: stuff that is also in the standard library
-- Standard propositional equality, see also Relation.Binary.PropositionalEquality
data _==_ {A : Set} (x : A) : A → Set where
refl : x == x
-- [_==_] defines an equality proposition
-- it takes two identical elements of one type as arguments and gives one
-- evidence,[refl],for the proposition
-- subst lemma
subst : {A B : Set}{x x' : A} {C : A → B} → x == x' → C x == C x'
subst{A}{B}{x}{.x} refl = refl
-- or being defined in the following manner...
-- my_subst : {A B : Set}{x x' : A}{C : A → B} → x == x' → C x == C x'
-- my_subst refl = refl
-- the above function further helps to construct evidence for equality
-- proposition
-- it says that if two elements are identical then two new elements obtained
-- by applying the former to a function should also be identical
record True : Set where
data False : Set where
-- note that the above is regarding two simple proposition [True] and [False]
-- regarding [True],
-- it is defined as empty record with a single element of type [True],[record{}]
-- the trick here is that the type checker knows this and fills in any implicit
-- arguments of [True] with this element
-- another way of defining [True] as follows,
-- record True : Set where
-- trivial : True
-- trivial = _
-- regarding [False],
-- it is defined as a proposition without any evidence corresponding well to
-- what a [False] proposition really means
isTrue : Bool → Set
isTrue true = True
isTrue false = False
-- note the isTrue b,given b as boolean, is the type of proof that b is equal to
-- true since if it is the case, [isTrue b] returns type [True] where its
-- evidence is automatically filled in by the type checker while if it is not
-- the case there is no way to supply for the evidence due to the way how
-- [false] is constructed
-- END standard library
----------------------
-- Sublists
----------------------
data _cx-≤_ {A : Set} : List A → List A → Set where
cxle-eq : (l : List A) → l cx-≤ l
cxle-lt : ∀ {l₁ l₂} x → l₁ cx-≤ l₂ → l₁ cx-≤ (x ∷ l₂)
lem-cx-≤-trans : {A : Set} → {l₁ : List A} {l₂ : List A} {l₃ : List A} →
l₁ cx-≤ l₂ → l₂ cx-≤ l₃ → l₁ cx-≤ l₃
lem-cx-≤-trans le1 (cxle-eq l) = le1
lem-cx-≤-trans (cxle-eq l) (cxle-lt x e) = cxle-lt x e
lem-cx-≤-trans (cxle-lt x e) (cxle-lt x' e') = cxle-lt x' (lem-cx-≤-trans (cxle-lt x e) e')
_cxle-∷_ : {A : Set} (x : A) (l : List A) → l cx-≤ (x ∷ l)
x cxle-∷ l = cxle-lt x (cxle-eq l)
data _⊆_ {A : Set} : List A → List A → Set where
refl-⊆ : ∀ {l} → l ⊆ l
step-⊆ : ∀ {l} x l₁ l₂ → l ⊆ (l₁ ++ l₂) → l ⊆ (l₁ ++ (x ∷ l₂))
lem-⊆-trans : {A : Set} → {l₁ : List A} {l₂ : List A} {l₃ : List A} →
l₁ ⊆ l₂ → l₂ ⊆ l₃ → l₁ ⊆ l₃
lem-⊆-trans e (refl-⊆ {l}) = e
lem-⊆-trans (refl-⊆ {l}) (step-⊆ x l₁ l₂ e) = step-⊆ x l₁ l₂ e
lem-⊆-trans (step-⊆ x l₁ l₂ e) (step-⊆ x' l₁' l₂' e') = step-⊆ x' l₁' l₂' (lem-⊆-trans (step-⊆ x l₁ l₂ e) e')
-- data _≤1_ {A : Set} : List A → List A → Set where
-- cxle1-eq : (l : List A) → l ≤1 l
-- cxle1-lt : ∀ x (l : List A) → l ≤1 (x ∷ l)
-- data _?∷_ {A : Set} (x : A): List A → Set where
-- yes∷ : (l : List A) → x ?∷ (x ∷ l)
-- no∷ : (l : List A) → x ?∷ l
-- getList : ∀ {A} {x : A} {l : List A} → x ?∷ l → List A
-- getList {x = x} (yes∷ l) = x ∷ l
-- getList {_} {_} {l} (no∷ .l) = l
-- end sublists
-- some lemmas about BT subsumption
lem-bt≼S : {bt : BT} → isTrue (bt ≼ S) → bt == S
lem-bt≼S {S} bt≼S = refl
lem-bt≼S {D} ()
-- which can also be defined as follows,
-- my_lem-bt≼S : {bt : BT} → isTrue (bt ≼ S) → bt == S
-- my_lem-bt≼S {S} _ = refl
-- my_lem-bt≼S {D} ()
lem-D≼bt : {bt : BT} → isTrue (D ≼ bt) → bt == D
lem-D≼bt {S} ()
lem-D≼bt {D} D≼bt = refl
-- Types of the calculus
mutual
-- s ^ BT
data AType : Set where
Ann : BT → SType → AType
-- int | t -> t
data SType : Set where
SInt : SType
SFun : AType → AType → SType
-- aux definitions
ATInt : BT → AType
ATInt bt = Ann bt SInt
ATFun : BT → AType → AType → AType
ATFun bt at1 at2 = Ann bt (SFun at1 at2)
-- note that the above function labels a ground type with annotations [S] or
-- [D],sort of a labelling function
-- projection: get the BT from a type
btof : AType → BT
btof (Ann bt _) = bt
-- a related function which takes an annotated type as argument and returns
-- the annotation of that type
-- "constraint on types: functions have to be at least as dynamic as their component" should be corrected as follows,
-- arguments of function should be as dynamic as the function
data wft : AType → Set where
wf-int : ∀ {bt} → wft (Ann bt SInt)
wf-fun : ∀ {bt at1 at2} → wft at1 → wft at2
→ isTrue (bt ≼ btof at1) → isTrue (bt ≼ btof at2) → wft (Ann bt (SFun at1 at2))
-- the above proposition specifies a set of well-formed [AType]s,
-- any annotated [SInt]s are well-formed, wft (Ann bt SInt) forall bt ∈ BT
-- in case of functional type with annotation, the following two criteria have
-- to be satisfied to be a well form,
-- a. each of its arguments is well-formed
-- b. the annotation of the function and the annotations of its arguments must
-- satisfy [_≼_] relation
-- for instance, the functional type defined above is well-formed while
-- the following is not,
-- Ann D (
-- SFun (Ann S SInt) (Ann D SInt)
-- )
-- in conclusion,for functional type with annotation to be well-formed,
-- each of its arguments annotations has to be [D] when that of the function
-- is [D] while there is no constraint upon the annotations of its arguments
-- when that of the function is [S]
lem-force-bt : ∀ {bt at} → isTrue (bt ≼ btof at) → D == bt → D == btof at
lem-force-bt {S} bt≼at ()
lem-force-bt {D} {Ann S y'} () D=bt
lem-force-bt {D} {Ann D y'} bt≼at D=bt = refl
-- note the above function takes an element[bt] of type [BT] and a type with
-- annotation,
-- if both
-- a. the type is at least as dynamic as [bt]
-- b. [bt == D]
-- then we know that the annotation of the type must be [D] as well
-- and the function in that case returns evidence for that
-- Low-level types; types wihtout binding information
data Type : Set where
TInt : Type
TFun : Type → Type → Type
-- translation from ATypes to low-level types
mutual
strip : AType → Type
strip (Ann _ σ) = strip' σ
strip' : SType → Type
strip' SInt = TInt
strip' (SFun y y') = TFun (strip y) (strip y')
-- note that the above function [strip] converts a type with annotation [AType]
-- to a low-level type [Type],
-- for instance,
-- strip (Ann D SInt)
-- = strip' SInt
-- = TInt
-- strip (Ann S
-- SFun (Ann S SInt) (Ann D SInt)
-- )
-- = strip' (SFun (Ann S SInt) (Ann D SInt))
-- = TFun (strip (Ann S SInt)) (strip (Ann D SInt))
-- = TFun (strip' SInt) (strip' SInt)
-- = TFun TInt TInt^
-- More general purpose definitions (should also be in standard library)
-- list membership
infix 4 _∈_
data _∈_ {A : Set} : A → List A → Set where
hd : ∀ {x xs} → x ∈ (x ∷ xs)
tl : ∀ {x y xs} → x ∈ xs → x ∈ (y ∷ xs)
-- note the above proposition gives us two constructors for getting
-- evidences for an element being a member of one list
-- end general purpose definitions
-- Typing context
Ctx = List Type
--data Exp' (Γ Γ' : Ctx) : Type → Set where
-- EVar' :
-- Typed expression
data Exp (Γ : Ctx) : Type → Set where
-- [EVar] corresponds to the bounded variables in [AExp]
EVar : ∀ {τ} → τ ∈ Γ → Exp Γ τ
EInt : ℕ → Exp Γ TInt
EFun : ∀ {τ₁ τ₂} → Exp (τ₂ ∷ Γ) τ₁ → Exp Γ (TFun τ₂ τ₁)
EApp : ∀ {τ₁ τ₂} → Exp Γ (TFun τ₂ τ₁) → Exp Γ τ₂ → Exp Γ τ₁
-- one additional term,
count_tl : ∀ {τ Γ Γ'} → τ ∈ Γ → Γ cx-≤ Γ' → τ ∈ Γ'
count_tl x (cxle-eq Γ) = x
count_tl x (cxle-lt T e) = tl (count_tl x e)
data _cx=≤_ {A : Set} : List A → List A → Set where
cxle-peq : ∀ {l₁ l₂} { x } → l₁ cx-≤ l₂ → (x ∷ l₁) cx=≤ (x ∷ l₂)
cxle-plt : ∀ {l₁ l₂} { x } → l₁ cx=≤ l₂ → (x ∷ l₁) cx=≤ (x ∷ l₂)
get_cx-≤ : ∀{Γ₁ Γ₂ Γ₃ Γ₄} → Γ₁ cx=≤ Γ₂ → Γ₃ cx-≤ Γ₄
get_cx-≤ (cxle-plt e) = get_cx-≤ e
get_cx-≤ (cxle-peq e) = e
_id≤Bid_ : ∀{τ Γ Γ'} → τ ∈ Γ → Γ cx=≤ Γ' → Bool
(tl x) id≤Bid (cxle-plt e) = x id≤Bid e
hd id≤Bid e = true
(tl x) id≤Bid (cxle-peq e) = false
lem-x-weakening : ∀{τ Γ Γ'} → (x : τ ∈ Γ) → (e : Γ cx=≤ Γ') → isTrue (x id≤Bid e) → τ ∈ Γ'
lem-x-weakening = {!!}
lem-Exp-weakening' : ∀ {τ₂ τ₁ Γ Γ'} → Exp (τ₂ ∷ Γ) τ₁ → (τ₂ ∷ Γ) cx=≤ (τ₂ ∷ Γ') → Exp (τ₂ ∷ Γ') τ₁
lem-Exp-weakening' (EVar x) e with x id≤Bid e
lem-Exp-weakening' (EVar x) e | true = EVar (lem-x-weakening x e _ )
lem-Exp-weakening' (EVar x) e | false = EVar (count_tl x (get_cx-≤ e))
lem-Exp-weakening' (EInt n) e = EInt n
lem-Exp-weakening' (EFun t) e = EFun (lem-Exp-weakening' t (cxle-plt e))
lem-Exp-weakening' (EApp t1 t2) e = EApp (lem-Exp-weakening' t1 e) (lem-Exp-weakening' t2 e)
lem-Exp-weakening : ∀ {τ Γ Γ'} → Exp Γ τ → Γ cx-≤ Γ' → Exp Γ' τ
lem-Exp-weakening t (cxle-eq Γ) = t
lem-Exp-weakening (EInt n) e = EInt n
lem-Exp-weakening (EVar x) e = EVar (count_tl x e)
lem-Exp-weakening (EFun t) (cxle-lt T e) = EFun (lem-Exp-weakening' t (cxle-peq (cxle-lt T e)))
lem-Exp-weakening (EApp t1 t2) e = EApp (lem-Exp-weakening t1 e) (lem-Exp-weakening t2 e)
-- typed annotated expressions
ACtx = List AType
data AExp (Δ : ACtx) : AType → Set where
AVar : ∀ {α} → α ∈ Δ → AExp Δ α
AInt : (bt : BT) → ℕ → AExp Δ (ATInt bt)
AFun : ∀ {α₁ α₂} (bt : BT) → wft (ATFun bt α₂ α₁) → AExp (α₂ ∷ Δ) α₁ → AExp Δ (ATFun bt α₂ α₁)
AApp : ∀ {α₁ α₂} (bt : BT) → wft (ATFun bt α₂ α₁) → AExp Δ (ATFun bt α₂ α₁) → AExp Δ α₂ → AExp Δ α₁
-- PT: why wft in the AApp case? everything in Δ should be wft!
-- stripping of contexts
residual : ACtx → Ctx
residual [] = []
residual (Ann S _ ∷ xs) = residual xs
residual (Ann D σ ∷ xs) = strip' σ ∷ residual xs
-- ``semantic domain'' for partially evaluated AExp-terms:
-- - AExp-terms of dynamic type evaluate to Exp-terms
-- - AExp-terms of static type evaluate to agda terms, where SFun
-- are functions and SInt are natural numbers
mutual
impTA : Ctx → AType → Set
impTA Γ (Ann S σ) = impTA' Γ σ
impTA Γ (Ann D σ) = Exp Γ (strip' σ)
impTA' : Ctx → SType → Set
impTA' Γ SInt = ℕ
-- impTA' Γ (SFun y y') = impTA Γ y → impTA Γ y'
impTA' Γ (SFun y y') = ∀ {Γ'} → Γ cx-≤ Γ' → (impTA Γ' y → impTA Γ' y')
{-
assumption: Γ binds all dynamic variables Γ = f:Int -> Int
λ_ x. f @_ x : Int_ -> Int_
ImpTA Γ (Int_ -> Int_) = Exp Γ ℕ -> Exp Γ ℕ
f : Int_ ->_ Int_
ImpTA Γ (Int_ ->_ Int_) = Exp Γ (Int -> Int)
-}
lem-impTA-weakening : ∀ {α Γ Γ'} →
impTA Γ α →
Γ cx-≤ Γ' →
impTA Γ' α
lem-impTA-weakening {Ann S SInt} v _ = v
lem-impTA-weakening {Ann S (SFun x x₁)} f prf = λ prf' → f (lem-cx-≤-trans prf prf')
lem-impTA-weakening {Ann D x₁} v prf = lem-Exp-weakening v prf
-- mutual
-- impTA-try : Ctx → AType → Set
-- impTA-try Γ (Ann S σ) = impTA-try' Γ σ
-- impTA-try Γ (Ann D σ) = Exp Γ (strip' σ)
-- impTA-try' : Ctx → SType → Set
-- impTA-try' Γ SInt = ℕ
-- impTA-try' Γ (SFun y y') = impTA-try Γ y → impTA-try Γ y'
-- lem-impTA-try-weakening : ∀ {α Γ Γ'} →
-- impTA-try Γ α →
-- Γ cx-≤ Γ' →
-- impTA-try Γ' α
-- lem-impTA-try-weakening {Ann S SInt} v _ = v
-- lem-impTA-try-weakening {Ann S (SFun α x₁)} {Γ} {Γ'} f prf = {! λ (v : impTA-try Γ' α) → f v!}
-- lem-impTA-try-weakening {Ann D x₁} v prf = lem-Exp-weakening v prf
data AEnv : Ctx → ACtx → Set where
env[] : ∀ {Γ} → AEnv Γ []
envS:: : ∀ {Γ Δ} {α} →
impTA Γ α →
AEnv Γ Δ →
AEnv Γ (α ∷ Δ)
envD:: : ∀ {Γ Δ} →
(σ : SType) →
impTA (strip' σ ∷ Γ) (Ann D σ) →
AEnv Γ Δ →
AEnv (strip' σ ∷ Γ) (Ann D σ ∷ Δ)
lem-AEnv-weakening : ∀ {Γ Γ' Δ} → AEnv Γ Δ → Γ cx-≤ Γ' → AEnv Γ' Δ
lem-AEnv-weakening env[] prf = env[]
lem-AEnv-weakening (envS:: {α = α} x env) prf = envS:: (lem-impTA-weakening {α} x prf) (lem-AEnv-weakening env prf)
lem-AEnv-weakening (envD:: {Γ} σ x env) prf = envS:: (lem-impTA-weakening {Ann D σ} x prf) (lem-AEnv-weakening env (lem-cx-≤-trans (cxle-lt (strip' σ) (cxle-eq Γ)) prf)) -- non-primitive recursion... this should be fixable by extending Γ in the middle, rather than in the end
lookup : ∀ {Γ Δ α} → AEnv Γ Δ → (o : α ∈ Δ ) → impTA Γ α
lookup env[] ()
lookup (envS:: x env) hd = x
lookup (envS:: x env) (tl idx) = lookup env idx
lookup (envD:: σ x env) hd = x
lookup {α = α} (envD:: {Γ} σ x env) (tl idx) = lem-impTA-weakening {α} (lookup env idx) (strip' σ cxle-∷ Γ)
data IsDynamic : AType → Set where
is-dyn : ∀ σ → IsDynamic (Ann D σ)
lem-IsDynamic-by-wf : ∀ α → isTrue (D ≼ btof α) → IsDynamic α
lem-IsDynamic-by-wf (Ann S σ) ()
lem-IsDynamic-by-wf (Ann D σ) _ = is-dyn σ
-- TODO: Do we need additional assurance in the type signature (or as
-- an aux. lemma) that Γ is the residue of Δ?
pe : ∀ {Δ Γ α} → AEnv Γ Δ → AExp Δ α → impTA Γ α
pe env (AVar idx) = lookup env idx
pe env (AInt S i) = i
pe env (AInt D i) = EInt i
pe {Γ = Γ} env (AFun {α₁} {α₂} S prf exp) = λ {Γ'} (prf₁ : Γ cx-≤ Γ') (v : impTA Γ' α₂) →
pe (envS:: v (lem-AEnv-weakening env prf₁)) exp
pe env (AFun {α₁} {α₂} D (wf-fun _ _ prf-2 prf-1) e)
with lem-IsDynamic-by-wf α₁ prf-1 | lem-IsDynamic-by-wf α₂ prf-2
pe {Γ = Γ} env (AFun {.(Ann D σ₁)} {.(Ann D σ₂)} D (wf-fun _ _ prf-1 prf-2) e)
| is-dyn σ₁ | is-dyn σ₂ =
EFun (pe (envD:: σ₂ (EVar hd) env) e)
pe {Γ = Γ} env (AApp S _ f e) = (pe env f (cxle-eq Γ)) (pe env e)
pe env (AApp {α₁} {α₂} D (wf-fun _ _ prf-2 prf-1) f e)
with lem-IsDynamic-by-wf α₁ prf-1 | lem-IsDynamic-by-wf α₂ prf-2
pe env (AApp {.(Ann D σ₁)}{.(Ann D σ₂)} D (wf-fun _ _ prf-2 prf-1) f e)
| is-dyn σ₁ | is-dyn σ₂ =
EApp (pe env f) (pe env e) -- construct an Exp-application using the proof that argument and results are dynamic and thus pe yields Exp-terms for them
| 34.842353
| 276
| 0.595286
|
4ded3fd061f5569bbdbf29406a245efb5d3eb371
| 711
|
agda
|
Agda
|
test/Succeed/HITs.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/HITs.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/HITs.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --cubical #-}
open import Agda.Builtin.Cubical.Path
data PushOut {A B C : Set} (f : C → A) (g : C → B) : Set where
inl : A → PushOut f g
inr : B → PushOut f g
push : ∀ c → inl (f c) ≡ inr (g c)
squash : ∀ a b → a ≡ b
data ∥_∥₀ (A : Set) : Set where
∣_∣ : A → ∥ A ∥₀
squash : ∀ (x y : ∥ A ∥₀) → (p q : x ≡ y) → p ≡ q
data Segment : Set where
start end : Segment
line : start ≡ end
-- prop truncation
data ∥_∥ (A : Set) : Set where
∣_∣ : A → ∥ A ∥
squash : ∀ (x y : ∥ A ∥) → x ≡ y
elim : ∀ {A : Set} (P : Set) → ((x y : P) → x ≡ y) → (A → P) → ∥ A ∥ → P
elim P Pprop f ∣ x ∣ = f x
elim P Pprop f (squash x y i) = Pprop (elim P Pprop f x) (elim P Pprop f y) i
| 27.346154
| 77
| 0.481013
|
395e53f50b32727b1c14f996cd245d0aa596b17c
| 1,041
|
agda
|
Agda
|
examples/outdated-and-incorrect/clowns/Clowns.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
examples/outdated-and-incorrect/clowns/Clowns.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
examples/outdated-and-incorrect/clowns/Clowns.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --no-positivity-check #-}
module Clowns where
import Equality
import Isomorphism
import Derivative
import ChainRule
open import Sets
open import Functor
open import Zipper
open import Dissect
open Functor.Recursive
open Functor.Semantics
-- Natural numbers
NatF : U
NatF = K [1] + Id
Nat : Set
Nat = μ NatF
zero : Nat
zero = inn (inl <>)
suc : Nat -> Nat
suc n = inn (inr n)
plus : Nat -> Nat -> Nat
plus n m = fold NatF φ n where
φ : ⟦ NatF ⟧ Nat -> Nat
φ (inl <>) = m
φ (inr z) = suc z
-- Lists
ListF : (A : Set) -> U
ListF A = K [1] + K A × Id
List' : (A : Set) -> Set
List' A = μ (ListF A)
nil : {A : Set} -> List' A
nil = inn (inl <>)
cons : {A : Set} -> A -> List' A -> List' A
cons x xs = inn (inr < x , xs >)
sum : List' Nat -> Nat
sum = fold (ListF Nat) φ where
φ : ⟦ ListF Nat ⟧ Nat -> Nat
φ (inl <>) = zero
φ (inr < n , m >) = plus n m
TreeF : U
TreeF = K [1] + Id × Id
Tree : Set
Tree = μ TreeF
leaf : Tree
leaf = inn (inl <>)
node : Tree -> Tree -> Tree
node l r = inn (inr < l , r >)
| 15.537313
| 43
| 0.577329
|
0e11ca6abdd9f2076214feeb5e3c88ae1064f8a9
| 3,155
|
agda
|
Agda
|
examples/outdated-and-incorrect/iird/IID.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
examples/outdated-and-incorrect/iird/IID.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
examples/outdated-and-incorrect/iird/IID.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
-- The simpler case of index inductive definitions. (no induction-recursion)
module IID where
open import LF
-- A code for an IID
-- I - index set
-- E = I for general IIDs
-- E = One for restricted IIDs
data OP (I : Set)(E : Set) : Set1 where
ι : E -> OP I E
σ : (A : Set)(γ : A -> OP I E) -> OP I E
δ : (A : Set)(i : A -> I)(γ : OP I E) -> OP I E
-- The type of constructor arguments. Parameterised over
-- U - the inductive type
-- This is the F of the simple polynomial type μF
Args : {I : Set}{E : Set} -> OP I E ->
(U : I -> Set) -> Set
Args (ι e) U = One
Args (σ A γ) U = A × \a -> Args (γ a) U
Args (δ A i γ) U = ((a : A) -> U (i a)) × \_ -> Args γ U
-- Computing the index
index : {I : Set}{E : Set}(γ : OP I E)(U : I -> Set) -> Args γ U -> E
index (ι e) U _ = e
index (σ A γ) U a = index (γ (π₀ a)) U (π₁ a)
index (δ A i γ) U a = index γ U (π₁ a)
-- The assumptions of a particular inductive occurrence in a value.
IndArg : {I : Set}{E : Set}
(γ : OP I E)(U : I -> Set) ->
Args γ U -> Set
IndArg (ι e) U _ = Zero
IndArg (σ A γ) U a = IndArg (γ (π₀ a)) U (π₁ a)
IndArg (δ A i γ) U a = A + IndArg γ U (π₁ a)
-- Given the assumptions of an inductive occurence in a value we can compute
-- its index.
IndIndex : {I : Set}{E : Set}
(γ : OP I E)(U : I -> Set) ->
(a : Args γ U) -> IndArg γ U a -> I
IndIndex (ι e) U _ ()
IndIndex (σ A γ) U arg c = IndIndex (γ (π₀ arg)) U (π₁ arg) c
IndIndex (δ A i γ) U arg (inl a) = i a
IndIndex (δ A i γ) U arg (inr a) = IndIndex γ U (π₁ arg) a
-- Given the assumptions of an inductive occurrence in a value we can compute
-- its value.
Ind : {I : Set}{E : Set}
(γ : OP I E)(U : I -> Set) ->
(a : Args γ U)(v : IndArg γ U a) -> U (IndIndex γ U a v)
Ind (ι e) U _ ()
Ind (σ A γ) U arg c = Ind (γ (π₀ arg)) U (π₁ arg) c
Ind (δ A i γ) U arg (inl a) = (π₀ arg) a
Ind (δ A i γ) U arg (inr a) = Ind γ U (π₁ arg) a
-- The type of induction hypotheses. Basically
-- forall assumptions, the predicate holds for an inductive occurrence with
-- those assumptions
IndHyp : {I : Set}{E : Set}
(γ : OP I E)(U : I -> Set) ->
(F : (i : I) -> U i -> Set)(a : Args γ U) -> Set
IndHyp γ U F a = (v : IndArg γ U a) -> F (IndIndex γ U a v) (Ind γ U a v)
IndHyp₁ : {I : Set}{E : Set}
(γ : OP I E)(U : I -> Set) ->
(F : (i : I) -> U i -> Set1)(a : Args γ U) -> Set1
IndHyp₁ γ U F a = (v : IndArg γ U a) -> F (IndIndex γ U a v) (Ind γ U a v)
-- If we can prove a predicate F for any values, we can construct the inductive
-- hypotheses for a given value.
-- Termination note: g will only be applied to values smaller than a
induction :
{I : Set}{E : Set}
(γ : OP I E)(U : I -> Set)
(F : (i : I) -> U i -> Set)
(g : (i : I)(u : U i) -> F i u)
(a : Args γ U) -> IndHyp γ U F a
induction γ U F g a = \hyp -> g (IndIndex γ U a hyp) (Ind γ U a hyp)
induction₁ :
{I : Set}{E : Set}
(γ : OP I E)(U : I -> Set)
(F : (i : I) -> U i -> Set1)
(g : (i : I)(u : U i) -> F i u)
(a : Args γ U) -> IndHyp₁ γ U F a
induction₁ γ U F g a = \hyp -> g (IndIndex γ U a hyp) (Ind γ U a hyp)
| 34.67033
| 79
| 0.532488
|
1d0ec9e540ec12cb1679035cdcd9d6ba9b5a46d4
| 4,868
|
agda
|
Agda
|
prototyping/Luau/Type.agda
|
JohnnyMorganz/luau
|
f2191b9e4da6a4bb2d9d344ebd7941ec2f00844b
|
[
"MIT"
] | 1
|
2021-11-06T08:03:00.000Z
|
2021-11-06T08:03:00.000Z
|
prototyping/Luau/Type.agda
|
JohnnyMorganz/luau
|
f2191b9e4da6a4bb2d9d344ebd7941ec2f00844b
|
[
"MIT"
] | null | null | null |
prototyping/Luau/Type.agda
|
JohnnyMorganz/luau
|
f2191b9e4da6a4bb2d9d344ebd7941ec2f00844b
|
[
"MIT"
] | null | null | null |
module Luau.Type where
open import FFI.Data.Maybe using (Maybe; just; nothing; just-inv)
open import Agda.Builtin.Equality using (_≡_; refl)
open import Properties.Dec using (Dec; yes; no)
open import Properties.Equality using (cong)
open import FFI.Data.Maybe using (Maybe; just; nothing)
data Type : Set where
nil : Type
_⇒_ : Type → Type → Type
never : Type
unknown : Type
boolean : Type
number : Type
string : Type
_∪_ : Type → Type → Type
_∩_ : Type → Type → Type
data Scalar : Type → Set where
number : Scalar number
boolean : Scalar boolean
string : Scalar string
nil : Scalar nil
skalar = number ∪ (string ∪ (nil ∪ boolean))
lhs : Type → Type
lhs (T ⇒ _) = T
lhs (T ∪ _) = T
lhs (T ∩ _) = T
lhs nil = nil
lhs never = never
lhs unknown = unknown
lhs number = number
lhs boolean = boolean
lhs string = string
rhs : Type → Type
rhs (_ ⇒ T) = T
rhs (_ ∪ T) = T
rhs (_ ∩ T) = T
rhs nil = nil
rhs never = never
rhs unknown = unknown
rhs number = number
rhs boolean = boolean
rhs string = string
_≡ᵀ_ : ∀ (T U : Type) → Dec(T ≡ U)
nil ≡ᵀ nil = yes refl
nil ≡ᵀ (S ⇒ T) = no (λ ())
nil ≡ᵀ never = no (λ ())
nil ≡ᵀ unknown = no (λ ())
nil ≡ᵀ number = no (λ ())
nil ≡ᵀ boolean = no (λ ())
nil ≡ᵀ (S ∪ T) = no (λ ())
nil ≡ᵀ (S ∩ T) = no (λ ())
nil ≡ᵀ string = no (λ ())
(S ⇒ T) ≡ᵀ string = no (λ ())
never ≡ᵀ string = no (λ ())
unknown ≡ᵀ string = no (λ ())
boolean ≡ᵀ string = no (λ ())
number ≡ᵀ string = no (λ ())
(S ∪ T) ≡ᵀ string = no (λ ())
(S ∩ T) ≡ᵀ string = no (λ ())
(S ⇒ T) ≡ᵀ nil = no (λ ())
(S ⇒ T) ≡ᵀ (U ⇒ V) with (S ≡ᵀ U) | (T ≡ᵀ V)
(S ⇒ T) ≡ᵀ (S ⇒ T) | yes refl | yes refl = yes refl
(S ⇒ T) ≡ᵀ (U ⇒ V) | _ | no p = no (λ q → p (cong rhs q))
(S ⇒ T) ≡ᵀ (U ⇒ V) | no p | _ = no (λ q → p (cong lhs q))
(S ⇒ T) ≡ᵀ never = no (λ ())
(S ⇒ T) ≡ᵀ unknown = no (λ ())
(S ⇒ T) ≡ᵀ number = no (λ ())
(S ⇒ T) ≡ᵀ boolean = no (λ ())
(S ⇒ T) ≡ᵀ (U ∪ V) = no (λ ())
(S ⇒ T) ≡ᵀ (U ∩ V) = no (λ ())
never ≡ᵀ nil = no (λ ())
never ≡ᵀ (U ⇒ V) = no (λ ())
never ≡ᵀ never = yes refl
never ≡ᵀ unknown = no (λ ())
never ≡ᵀ number = no (λ ())
never ≡ᵀ boolean = no (λ ())
never ≡ᵀ (U ∪ V) = no (λ ())
never ≡ᵀ (U ∩ V) = no (λ ())
unknown ≡ᵀ nil = no (λ ())
unknown ≡ᵀ (U ⇒ V) = no (λ ())
unknown ≡ᵀ never = no (λ ())
unknown ≡ᵀ unknown = yes refl
unknown ≡ᵀ number = no (λ ())
unknown ≡ᵀ boolean = no (λ ())
unknown ≡ᵀ (U ∪ V) = no (λ ())
unknown ≡ᵀ (U ∩ V) = no (λ ())
number ≡ᵀ nil = no (λ ())
number ≡ᵀ (T ⇒ U) = no (λ ())
number ≡ᵀ never = no (λ ())
number ≡ᵀ unknown = no (λ ())
number ≡ᵀ number = yes refl
number ≡ᵀ boolean = no (λ ())
number ≡ᵀ (T ∪ U) = no (λ ())
number ≡ᵀ (T ∩ U) = no (λ ())
boolean ≡ᵀ nil = no (λ ())
boolean ≡ᵀ (T ⇒ U) = no (λ ())
boolean ≡ᵀ never = no (λ ())
boolean ≡ᵀ unknown = no (λ ())
boolean ≡ᵀ boolean = yes refl
boolean ≡ᵀ number = no (λ ())
boolean ≡ᵀ (T ∪ U) = no (λ ())
boolean ≡ᵀ (T ∩ U) = no (λ ())
string ≡ᵀ nil = no (λ ())
string ≡ᵀ (x ⇒ x₁) = no (λ ())
string ≡ᵀ never = no (λ ())
string ≡ᵀ unknown = no (λ ())
string ≡ᵀ boolean = no (λ ())
string ≡ᵀ number = no (λ ())
string ≡ᵀ string = yes refl
string ≡ᵀ (U ∪ V) = no (λ ())
string ≡ᵀ (U ∩ V) = no (λ ())
(S ∪ T) ≡ᵀ nil = no (λ ())
(S ∪ T) ≡ᵀ (U ⇒ V) = no (λ ())
(S ∪ T) ≡ᵀ never = no (λ ())
(S ∪ T) ≡ᵀ unknown = no (λ ())
(S ∪ T) ≡ᵀ number = no (λ ())
(S ∪ T) ≡ᵀ boolean = no (λ ())
(S ∪ T) ≡ᵀ (U ∪ V) with (S ≡ᵀ U) | (T ≡ᵀ V)
(S ∪ T) ≡ᵀ (S ∪ T) | yes refl | yes refl = yes refl
(S ∪ T) ≡ᵀ (U ∪ V) | _ | no p = no (λ q → p (cong rhs q))
(S ∪ T) ≡ᵀ (U ∪ V) | no p | _ = no (λ q → p (cong lhs q))
(S ∪ T) ≡ᵀ (U ∩ V) = no (λ ())
(S ∩ T) ≡ᵀ nil = no (λ ())
(S ∩ T) ≡ᵀ (U ⇒ V) = no (λ ())
(S ∩ T) ≡ᵀ never = no (λ ())
(S ∩ T) ≡ᵀ unknown = no (λ ())
(S ∩ T) ≡ᵀ number = no (λ ())
(S ∩ T) ≡ᵀ boolean = no (λ ())
(S ∩ T) ≡ᵀ (U ∪ V) = no (λ ())
(S ∩ T) ≡ᵀ (U ∩ V) with (S ≡ᵀ U) | (T ≡ᵀ V)
(S ∩ T) ≡ᵀ (U ∩ V) | yes refl | yes refl = yes refl
(S ∩ T) ≡ᵀ (U ∩ V) | _ | no p = no (λ q → p (cong rhs q))
(S ∩ T) ≡ᵀ (U ∩ V) | no p | _ = no (λ q → p (cong lhs q))
_≡ᴹᵀ_ : ∀ (T U : Maybe Type) → Dec(T ≡ U)
nothing ≡ᴹᵀ nothing = yes refl
nothing ≡ᴹᵀ just U = no (λ ())
just T ≡ᴹᵀ nothing = no (λ ())
just T ≡ᴹᵀ just U with T ≡ᵀ U
(just T ≡ᴹᵀ just T) | yes refl = yes refl
(just T ≡ᴹᵀ just U) | no p = no (λ q → p (just-inv q))
optional : Type → Type
optional nil = nil
optional (T ∪ nil) = (T ∪ nil)
optional T = (T ∪ nil)
normalizeOptional : Type → Type
normalizeOptional (S ∪ T) with normalizeOptional S | normalizeOptional T
normalizeOptional (S ∪ T) | (S′ ∪ nil) | (T′ ∪ nil) = (S′ ∪ T′) ∪ nil
normalizeOptional (S ∪ T) | S′ | (T′ ∪ nil) = (S′ ∪ T′) ∪ nil
normalizeOptional (S ∪ T) | (S′ ∪ nil) | T′ = (S′ ∪ T′) ∪ nil
normalizeOptional (S ∪ T) | S′ | nil = optional S′
normalizeOptional (S ∪ T) | nil | T′ = optional T′
normalizeOptional (S ∪ T) | S′ | T′ = S′ ∪ T′
normalizeOptional T = T
| 29.50303
| 72
| 0.511915
|
0bdc025f0aa6908f5f01889326d8f81365e1b1ee
| 282
|
agda
|
Agda
|
Chunk.agda
|
righ1113/Agda
|
9117b6bec9880d8c0a5d6ee4399fd841c3544d84
|
[
"MIT"
] | null | null | null |
Chunk.agda
|
righ1113/Agda
|
9117b6bec9880d8c0a5d6ee4399fd841c3544d84
|
[
"MIT"
] | null | null | null |
Chunk.agda
|
righ1113/Agda
|
9117b6bec9880d8c0a5d6ee4399fd841c3544d84
|
[
"MIT"
] | null | null | null |
module Chunk where
open import Codata.Stream using (chunksOf; iterate; take)
open import Data.Nat using (ℕ; suc)
open import Data.Vec using (Vec; []; _∷_)
-- mylist 3 = [[1,2,3],[4,5,6],[7,8,9]]
myVec : (n : ℕ) → Vec (Vec ℕ n) n
myVec n = take n (chunksOf n (iterate suc 1))
| 18.8
| 57
| 0.631206
|
1273b3c086e308284d8da8fe3ca6a537611c67f0
| 313
|
agda
|
Agda
|
test/fail/CoinductiveConstructorsAndLet.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2019-11-27T04:41:05.000Z
|
2019-11-27T04:41:05.000Z
|
test/fail/CoinductiveConstructorsAndLet.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/fail/CoinductiveConstructorsAndLet.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
module CoinductiveConstructorsAndLet where
open import Imports.Coinduction
data D : Set where
foo : D → ∞ D
foo x = let y = x in ♯ y
-- CoinductiveConstructorsAndLet.agda:9,24-25
-- Panic: thing out of context ([CtxId 1] is not a sub context of
-- [CtxId 3])
-- when checking that the expression y has type D
| 22.357143
| 65
| 0.722045
|
505c6632e632e2513f305b8cb99f782a6bbf17ac
| 30,430
|
agda
|
Agda
|
Agda/06-equivalences.agda
|
tadejpetric/HoTT-Intro
|
f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5
|
[
"CC-BY-4.0"
] | null | null | null |
Agda/06-equivalences.agda
|
tadejpetric/HoTT-Intro
|
f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5
|
[
"CC-BY-4.0"
] | null | null | null |
Agda/06-equivalences.agda
|
tadejpetric/HoTT-Intro
|
f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5
|
[
"CC-BY-4.0"
] | null | null | null |
{-# OPTIONS --without-K --exact-split #-}
module 06-equivalences where
import 06-universes
open 06-universes public
-- Section 6.1 Homotopies
_~_ :
{i j : Level} {A : UU i} {B : A → UU j} (f g : (x : A) → B x) → UU (i ⊔ j)
f ~ g = (x : _) → Id (f x) (g x)
htpy-refl :
{i j : Level} {A : UU i} {B : A → UU j} {f : (x : A) → B x} → f ~ f
htpy-refl x = refl
{- Most of the time we get by with htpy-refl. However, sometimes Agda wants us
to specify the implicit argument. The it is easier to call htpy-refl' than
to use Agda's {f = ?} notation. -}
htpy-refl' :
{i j : Level} {A : UU i} {B : A → UU j} (f : (x : A) → B x) → f ~ f
htpy-refl' f = htpy-refl
htpy-inv :
{i j : Level} {A : UU i} {B : A → UU j} {f g : (x : A) → B x} →
(f ~ g) → (g ~ f)
htpy-inv H x = inv (H x)
_∙h_ :
{i j : Level} {A : UU i} {B : A → UU j} {f g h : (x : A) → B x} →
(f ~ g) → (g ~ h) → (f ~ h)
_∙h_ H K x = (H x) ∙ (K x)
htpy-concat :
{i j : Level} {A : UU i} {B : A → UU j} {f g : (x : A) → B x} →
(f ~ g) → (h : (x : A) → B x) → (g ~ h) → (f ~ h)
htpy-concat H h K x = concat (H x) (h x) (K x)
htpy-assoc :
{i j : Level} {A : UU i} {B : A → UU j} {f g h k : (x : A) → B x} →
(H : f ~ g) → (K : g ~ h) → (L : h ~ k) →
((H ∙h K) ∙h L) ~ (H ∙h (K ∙h L))
htpy-assoc H K L x = assoc (H x) (K x) (L x)
htpy-left-unit :
{i j : Level} {A : UU i} {B : A → UU j} {f g : (x : A) → B x}
{H : f ~ g} → (htpy-refl ∙h H) ~ H
htpy-left-unit x = left-unit
htpy-right-unit :
{i j : Level} {A : UU i} {B : A → UU j} {f g : (x : A) → B x}
{H : f ~ g} → (H ∙h htpy-refl) ~ H
htpy-right-unit x = right-unit
htpy-left-inv :
{i j : Level} {A : UU i} {B : A → UU j} {f g : (x : A) → B x}
(H : f ~ g) → ((htpy-inv H) ∙h H) ~ htpy-refl
htpy-left-inv H x = left-inv (H x)
htpy-right-inv :
{i j : Level} {A : UU i} {B : A → UU j} {f g : (x : A) → B x}
(H : f ~ g) → (H ∙h (htpy-inv H)) ~ htpy-refl
htpy-right-inv H x = right-inv (H x)
htpy-left-whisk :
{i j k : Level} {A : UU i} {B : UU j} {C : UU k}
(h : B → C) {f g : A → B} → (f ~ g) → ((h ∘ f) ~ (h ∘ g))
htpy-left-whisk h H x = ap h (H x)
_·l_ = htpy-left-whisk
htpy-right-whisk :
{i j k : Level} {A : UU i} {B : UU j} {C : UU k}
{g h : B → C} (H : g ~ h) (f : A → B) → ((g ∘ f) ~ (h ∘ f))
htpy-right-whisk H f x = H (f x)
_·r_ = htpy-right-whisk
-- Section 6.2 Bi-invertible maps
sec :
{i j : Level} {A : UU i} {B : UU j} (f : A → B) → UU (i ⊔ j)
sec {i} {j} {A} {B} f = Σ (B → A) (λ g → (f ∘ g) ~ id)
retr :
{i j : Level} {A : UU i} {B : UU j} (f : A → B) → UU (i ⊔ j)
retr {i} {j} {A} {B} f = Σ (B → A) (λ g → (g ∘ f) ~ id)
_retract-of_ :
{i j : Level} → UU i → UU j → UU (i ⊔ j)
A retract-of B = Σ (A → B) retr
is-equiv :
{i j : Level} {A : UU i} {B : UU j} (f : A → B) → UU (i ⊔ j)
is-equiv f = sec f × retr f
_≃_ :
{i j : Level} (A : UU i) (B : UU j) → UU (i ⊔ j)
A ≃ B = Σ (A → B) (λ f → is-equiv f)
map-equiv :
{i j : Level} {A : UU i} {B : UU j} → (A ≃ B) → (A → B)
map-equiv e = pr1 e
is-equiv-map-equiv :
{i j : Level} {A : UU i} {B : UU j} (e : A ≃ B) → is-equiv (map-equiv e)
is-equiv-map-equiv e = pr2 e
has-inverse :
{i j : Level} {A : UU i} {B : UU j} (f : A → B) → UU (i ⊔ j)
has-inverse {i} {j} {A} {B} f =
Σ (B → A) (λ g → ((f ∘ g) ~ id) × ((g ∘ f) ~ id))
abstract
is-equiv-has-inverse' :
{i j : Level} {A : UU i} {B : UU j} {f : A → B} →
has-inverse f → is-equiv f
is-equiv-has-inverse' (pair g (pair H K)) = pair (pair g H) (pair g K)
abstract
is-equiv-has-inverse :
{i j : Level} {A : UU i} {B : UU j} {f : A → B} →
(g : B → A) (H : (f ∘ g) ~ id) (K : (g ∘ f) ~ id) → is-equiv f
is-equiv-has-inverse g H K =
is-equiv-has-inverse' (pair g (pair H K))
{- We now show that if f is an equivalence, then it has an inverse. -}
htpy-section-retraction :
{ i j : Level} {A : UU i} {B : UU j} {f : A → B}
( is-equiv-f : is-equiv f) →
( (pr1 (pr1 is-equiv-f))) ~ (pr1 (pr2 is-equiv-f))
htpy-section-retraction {i} {j} {A} {B} {f} (pair (pair g G) (pair h H)) =
(htpy-inv (H ·r g)) ∙h (h ·l G)
has-inverse-is-equiv :
{i j : Level} {A : UU i} {B : UU j} {f : A → B} →
is-equiv f → has-inverse f
has-inverse-is-equiv {i} {j} {A} {B} {f} (pair (pair g G) (pair h H)) =
let is-equiv-f = pair (pair g G) (pair h H) in
pair g (pair G (((htpy-section-retraction is-equiv-f) ·r f) ∙h H))
inv-is-equiv :
{i j : Level} {A : UU i} {B : UU j} {f : A → B} → is-equiv f → B → A
inv-is-equiv is-equiv-f = pr1 (has-inverse-is-equiv is-equiv-f)
issec-inv-is-equiv :
{i j : Level} {A : UU i} {B : UU j} {f : A → B} →
(is-equiv-f : is-equiv f) → (f ∘ (inv-is-equiv is-equiv-f)) ~ id
issec-inv-is-equiv is-equiv-f = pr1 (pr2 (has-inverse-is-equiv is-equiv-f))
isretr-inv-is-equiv :
{i j : Level} {A : UU i} {B : UU j} {f : A → B} →
(is-equiv-f : is-equiv f) → ((inv-is-equiv is-equiv-f) ∘ f) ~ id
isretr-inv-is-equiv is-equiv-f = pr2 (pr2 (has-inverse-is-equiv is-equiv-f))
abstract
is-equiv-inv-is-equiv :
{i j : Level} {A : UU i} {B : UU j} {f : A → B} →
(is-equiv-f : is-equiv f) → is-equiv (inv-is-equiv is-equiv-f)
is-equiv-inv-is-equiv {i} {j} {A} {B} {f} is-equiv-f =
is-equiv-has-inverse f
( isretr-inv-is-equiv is-equiv-f)
( issec-inv-is-equiv is-equiv-f)
inv-map-equiv :
{i j : Level} {A : UU i} {B : UU j} → (A ≃ B) → (B → A)
inv-map-equiv e = inv-is-equiv (is-equiv-map-equiv e)
abstract
is-equiv-inv-map-equiv :
{i j : Level} {A : UU i} {B : UU j} (e : A ≃ B) → is-equiv (inv-map-equiv e)
is-equiv-inv-map-equiv e =
is-equiv-inv-is-equiv (is-equiv-map-equiv e)
inv-equiv :
{i j : Level} {A : UU i} {B : UU j} → (A ≃ B) → (B ≃ A)
inv-equiv e = pair (inv-map-equiv e) (is-equiv-inv-map-equiv e)
is-equiv-id :
{i : Level} (A : UU i) → is-equiv (id {i} {A})
is-equiv-id A = pair (pair id htpy-refl) (pair id htpy-refl)
equiv-id :
{i : Level} (A : UU i) → A ≃ A
equiv-id A = pair id (is-equiv-id A)
inv-Π-swap :
{i j k : Level} {A : UU i} {B : UU j} (C : A → B → UU k) →
((y : B) (x : A) → C x y) → ((x : A) (y : B) → C x y)
inv-Π-swap C g x y = g y x
abstract
is-equiv-Π-swap :
{i j k : Level} {A : UU i} {B : UU j} (C : A → B → UU k) →
is-equiv (Π-swap {i} {j} {k} {A} {B} {C})
is-equiv-Π-swap C =
is-equiv-has-inverse
( inv-Π-swap C)
( htpy-refl)
( htpy-refl)
-- Section 6.3 The identity type of a Σ-type
Eq-Σ :
{i j : Level} {A : UU i} {B : A → UU j} (s t : Σ A B) → UU (i ⊔ j)
Eq-Σ {B = B} s t = Σ (Id (pr1 s) (pr1 t)) (λ α → Id (tr B α (pr2 s)) (pr2 t))
reflexive-Eq-Σ :
{i j : Level} {A : UU i} {B : A → UU j} (s : Σ A B) → Eq-Σ s s
reflexive-Eq-Σ (pair a b) = pair refl refl
pair-eq :
{i j : Level} {A : UU i} {B : A → UU j} {s t : Σ A B} →
(Id s t) → Eq-Σ s t
pair-eq {s = s} refl = reflexive-Eq-Σ s
eq-pair :
{i j : Level} {A : UU i} {B : A → UU j} {s t : Σ A B} →
(α : Id (pr1 s) (pr1 t)) → Id (tr B α (pr2 s)) (pr2 t) → Id s t
eq-pair {B = B} {pair x y} {pair .x .y} refl refl = refl
eq-pair' :
{i j : Level} {A : UU i} {B : A → UU j} {s t : Σ A B} →
Eq-Σ s t → Id s t
eq-pair' (pair α β) = eq-pair α β
isretr-pair-eq :
{i j : Level} {A : UU i} {B : A → UU j} (s t : Σ A B) →
((pair-eq {s = s} {t}) ∘ (eq-pair' {s = s} {t})) ~ id {A = Eq-Σ s t}
isretr-pair-eq (pair x y) (pair .x .y) (pair refl refl) = refl
issec-pair-eq :
{i j : Level} {A : UU i} {B : A → UU j} (s t : Σ A B) →
((eq-pair' {s = s} {t}) ∘ (pair-eq {s = s} {t})) ~ id
issec-pair-eq (pair x y) .(pair x y) refl = refl
abstract
is-equiv-eq-pair :
{i j : Level} {A : UU i} {B : A → UU j} (s t : Σ A B) →
is-equiv (eq-pair' {s = s} {t})
is-equiv-eq-pair s t =
is-equiv-has-inverse
( pair-eq)
( issec-pair-eq s t)
( isretr-pair-eq s t)
abstract
is-equiv-pair-eq :
{i j : Level} {A : UU i} {B : A → UU j} (s t : Σ A B) →
is-equiv (pair-eq {s = s} {t})
is-equiv-pair-eq s t =
is-equiv-has-inverse
( eq-pair')
( isretr-pair-eq s t)
( issec-pair-eq s t)
η-pair :
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} (t : Σ A B) →
Id (pair (pr1 t) (pr2 t)) t
η-pair t = eq-pair refl refl
{- We also define a function eq-pair-triv, which is like eq-pair but simplified
for the case where B is just a type. -}
Eq-prod :
{i j : Level} {A : UU i} {B : UU j} (s t : A × B) → UU (i ⊔ j)
Eq-prod s t = (Id (pr1 s) (pr1 t)) × (Id (pr2 s) (pr2 t))
eq-pair-triv' :
{i j : Level} {A : UU i} {B : UU j} (s t : prod A B) →
Eq-prod s t → Id s t
eq-pair-triv' (pair x y) (pair .x .y) (pair refl refl) = refl
eq-pair-triv :
{i j : Level} {A : UU i} {B : UU j} {s t : prod A B} →
Eq-prod s t → Id s t
eq-pair-triv {s = s} {t} = eq-pair-triv' s t
{- Ideally, we would use the 3-for-2 property of equivalences to show that
eq-pair-triv is an equivalence, using that eq-pair is an equivalence.
Indeed, there is an equivalence
(Id x x') × (Id y y') → Σ (Id x x') (λ p → Id (tr (λ x → B) p y) y').
However, to show that this map is an equivalence we either give a direct
proof (in which case we might as well have given a direct proof that
eq-pair-triv is an equivalence), or we use the fact that it is the induced
map on total spaces of a fiberwise equivalence (the topic of Lecture 8).
Thus it seems that a direct proof showing that eq-pair-triv is an
equivalence is quickest for now. -}
pair-eq-triv' :
{i j : Level} {A : UU i} {B : UU j} (s t : prod A B) →
Id s t → Eq-prod s t
pair-eq-triv' s t α = pair (ap pr1 α) (ap pr2 α)
isretr-pair-eq-triv' :
{i j : Level} {A : UU i} {B : UU j} (s t : prod A B) →
((pair-eq-triv' s t) ∘ (eq-pair-triv' s t)) ~ id
isretr-pair-eq-triv' (pair x y) (pair .x .y) (pair refl refl) = refl
issec-pair-eq-triv' :
{i j : Level} {A : UU i} {B : UU j} (s t : prod A B) →
((eq-pair-triv' s t) ∘ (pair-eq-triv' s t)) ~ id
issec-pair-eq-triv' (pair x y) (pair .x .y) refl = refl
abstract
is-equiv-eq-pair-triv' :
{i j : Level} {A : UU i} {B : UU j} (s t : prod A B) →
is-equiv (eq-pair-triv' s t)
is-equiv-eq-pair-triv' s t =
is-equiv-has-inverse
( pair-eq-triv' s t)
( issec-pair-eq-triv' s t)
( isretr-pair-eq-triv' s t)
-- Exercises
-- Exercise 6.1
element :
{i : Level} {A : UU i} → A → unit → A
element a star = a
htpy-element-constant :
{i : Level} {A : UU i} (a : A) →
(element a) ~ (const unit A a)
htpy-element-constant a star = refl
-- Exercise 6.2
ap-const :
{i j : Level} {A : UU i} {B : UU j} (b : B) (x y : A) →
(ap (const A B b) {x} {y}) ~ const (Id x y) (Id b b) refl
ap-const b x .x refl = refl
-- Exercise 6.3
inv-inv :
{i : Level} {A : UU i} {x y : A} (p : Id x y) → Id (inv (inv p)) p
inv-inv refl = refl
abstract
is-equiv-inv :
{i : Level} {A : UU i} (x y : A) →
is-equiv (λ (p : Id x y) → inv p)
is-equiv-inv x y =
is-equiv-has-inverse inv inv-inv inv-inv
equiv-inv :
{i : Level} {A : UU i} (x y : A) → (Id x y) ≃ (Id y x)
equiv-inv x y = pair inv (is-equiv-inv x y)
inv-concat :
{i : Level} {A : UU i} {x y : A} (p : Id x y) (z : A) →
(Id x z) → (Id y z)
inv-concat p = concat (inv p)
isretr-inv-concat :
{i : Level} {A : UU i} {x y : A} (p : Id x y) (z : A) →
((inv-concat p z) ∘ (concat p z)) ~ id
isretr-inv-concat refl z q = refl
issec-inv-concat :
{i : Level} {A : UU i} {x y : A} (p : Id x y) (z : A) →
((concat p z) ∘ (inv-concat p z)) ~ id
issec-inv-concat refl z refl = refl
abstract
is-equiv-concat :
{i : Level} {A : UU i} {x y : A} (p : Id x y) (z : A) →
is-equiv (concat p z)
is-equiv-concat p z =
is-equiv-has-inverse
( inv-concat p z)
( issec-inv-concat p z)
( isretr-inv-concat p z)
equiv-concat :
{i : Level} {A : UU i} {x y : A} (p : Id x y) (z : A) →
Id y z ≃ Id x z
equiv-concat p z = pair (concat p z) (is-equiv-concat p z)
concat' :
{i : Level} {A : UU i} (x : A) {y z : A} → Id y z → Id x y → Id x z
concat' x q p = p ∙ q
inv-concat' :
{i : Level} {A : UU i} (x : A) {y z : A} → Id y z →
Id x z → Id x y
inv-concat' x q = concat' x (inv q)
isretr-inv-concat' :
{i : Level} {A : UU i} (x : A) {y z : A} (q : Id y z) →
((inv-concat' x q) ∘ (concat' x q)) ~ id
isretr-inv-concat' x refl refl = refl
issec-inv-concat' :
{i : Level} {A : UU i} (x : A) {y z : A} (q : Id y z) →
((concat' x q) ∘ (inv-concat' x q)) ~ id
issec-inv-concat' x refl refl = refl
abstract
is-equiv-concat' :
{i : Level} {A : UU i} (x : A) {y z : A} (q : Id y z) →
is-equiv (concat' x q)
is-equiv-concat' x q =
is-equiv-has-inverse
( inv-concat' x q)
( issec-inv-concat' x q)
( isretr-inv-concat' x q)
equiv-concat' :
{i : Level} {A : UU i} (x : A) {y z : A} (q : Id y z) →
Id x y ≃ Id x z
equiv-concat' x q = pair (concat' x q) (is-equiv-concat' x q)
inv-tr :
{i j : Level} {A : UU i} (B : A → UU j) {x y : A} →
Id x y → B y → B x
inv-tr B p = tr B (inv p)
isretr-inv-tr :
{i j : Level} {A : UU i} (B : A → UU j) {x y : A}
(p : Id x y) → ((inv-tr B p ) ∘ (tr B p)) ~ id
isretr-inv-tr B refl b = refl
issec-inv-tr :
{i j : Level} {A : UU i} (B : A → UU j) {x y : A}
(p : Id x y) → ((tr B p) ∘ (inv-tr B p)) ~ id
issec-inv-tr B refl b = refl
abstract
is-equiv-tr :
{i j : Level} {A : UU i} (B : A → UU j) {x y : A}
(p : Id x y) → is-equiv (tr B p)
is-equiv-tr B p =
is-equiv-has-inverse
( inv-tr B p)
( issec-inv-tr B p)
( isretr-inv-tr B p)
equiv-tr :
{i j : Level} {A : UU i} (B : A → UU j) {x y : A}
(p : Id x y) → (B x) ≃ (B y)
equiv-tr B p = pair (tr B p) (is-equiv-tr B p)
-- Exercise 6.4
abstract
is-equiv-htpy :
{i j : Level} {A : UU i} {B : UU j} {f : A → B} (g : A → B) →
f ~ g → is-equiv g → is-equiv f
is-equiv-htpy g H (pair (pair gs issec) (pair gr isretr)) =
pair
( pair gs ((H ·r gs) ∙h issec))
( pair gr ((gr ·l H) ∙h isretr))
abstract
is-equiv-htpy' :
{i j : Level} {A : UU i} {B : UU j} (f : A → B) {g : A → B} →
f ~ g → is-equiv f → is-equiv g
is-equiv-htpy' f H = is-equiv-htpy f (htpy-inv H)
htpy-inv-is-equiv :
{i j : Level} {A : UU i} {B : UU j} {f f' : A → B} (H : f ~ f') →
(is-equiv-f : is-equiv f) (is-equiv-f' : is-equiv f') →
(inv-is-equiv is-equiv-f) ~ (inv-is-equiv is-equiv-f')
htpy-inv-is-equiv H is-equiv-f is-equiv-f' b =
( inv (isretr-inv-is-equiv is-equiv-f' (inv-is-equiv is-equiv-f b))) ∙
( ap (inv-is-equiv is-equiv-f')
( ( inv (H (inv-is-equiv is-equiv-f b))) ∙
( issec-inv-is-equiv is-equiv-f b)))
-- Exercise 6.5
{- Exercise 6.5 (a) asks to show that, given a commuting triangle f ~ g ∘ h and
a section s of h, we get a new commuting triangle g ~ f ∘ s. Moreover, under
the same assumptions it follows that f has a section if and only if g has a
section. -}
triangle-section :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k}
(f : A → X) (g : B → X) (h : A → B) (H : f ~ (g ∘ h)) (S : sec h) →
g ~ (f ∘ (pr1 S))
triangle-section f g h H (pair s issec) =
htpy-inv (( H ·r s) ∙h (g ·l issec))
section-comp :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k}
(f : A → X) (g : B → X) (h : A → B) (H : f ~ (g ∘ h)) →
sec h → sec f → sec g
section-comp f g h H sec-h sec-f =
pair (h ∘ (pr1 sec-f)) ((htpy-inv (H ·r (pr1 sec-f))) ∙h (pr2 sec-f))
section-comp' :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k}
(f : A → X) (g : B → X) (h : A → B) (H : f ~ (g ∘ h)) →
sec h → sec g → sec f
section-comp' f g h H sec-h sec-g =
pair
( (pr1 sec-h) ∘ (pr1 sec-g))
( ( H ·r ((pr1 sec-h) ∘ (pr1 sec-g))) ∙h
( ( g ·l ((pr2 sec-h) ·r (pr1 sec-g))) ∙h ((pr2 sec-g))))
{- Exercise 6.5 (b) is dual to exercise 5.5 (a). It asks to show that, given a
commuting triangle f ~ g ∘ h and a retraction r of g, we get a new commuting
triangle h ~ r ∘ f. Moreover, under these assumptions it also follows that f
has a retraction if and only if h has a retraction. -}
triangle-retraction :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k}
(f : A → X) (g : B → X) (h : A → B) (H : f ~ (g ∘ h)) (R : retr g) →
h ~ ((pr1 R) ∘ f)
triangle-retraction f g h H (pair r isretr) =
htpy-inv (( r ·l H) ∙h (isretr ·r h))
retraction-comp :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k}
(f : A → X) (g : B → X) (h : A → B) (H : f ~ (g ∘ h)) →
retr g → retr f → retr h
retraction-comp f g h H retr-g retr-f =
pair
( (pr1 retr-f) ∘ g)
( (htpy-inv ((pr1 retr-f) ·l H)) ∙h (pr2 retr-f))
retraction-comp' :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k}
(f : A → X) (g : B → X) (h : A → B) (H : f ~ (g ∘ h)) →
retr g → retr h → retr f
retraction-comp' f g h H retr-g retr-h =
pair
( (pr1 retr-h) ∘ (pr1 retr-g))
( ( ((pr1 retr-h) ∘ (pr1 retr-g)) ·l H) ∙h
( ((pr1 retr-h) ·l ((pr2 retr-g) ·r h)) ∙h (pr2 retr-h)))
{- In Exercise 6.5 (c) we use the constructions of parts (a) and (b) to derive
the 3-for-2 property of equivalences. -}
abstract
is-equiv-comp :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k}
(f : A → X) (g : B → X) (h : A → B) (H : f ~ (g ∘ h)) →
is-equiv h → is-equiv g → is-equiv f
is-equiv-comp f g h H (pair sec-h retr-h) (pair sec-g retr-g) =
pair
( section-comp' f g h H sec-h sec-g)
( retraction-comp' f g h H retr-g retr-h)
abstract
is-equiv-comp' :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k} (g : B → X) (h : A → B) →
is-equiv h → is-equiv g → is-equiv (g ∘ h)
is-equiv-comp' g h = is-equiv-comp (g ∘ h) g h htpy-refl
equiv-comp :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k} →
(B ≃ X) → (A ≃ B) → (A ≃ X)
equiv-comp g h =
pair ((pr1 g) ∘ (pr1 h)) (is-equiv-comp' (pr1 g) (pr1 h) (pr2 h) (pr2 g))
_∘e_ :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k} →
(B ≃ X) → (A ≃ B) → (A ≃ X)
_∘e_ = equiv-comp
abstract
is-equiv-left-factor :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k}
(f : A → X) (g : B → X) (h : A → B) (H : f ~ (g ∘ h)) →
is-equiv f → is-equiv h → is-equiv g
is-equiv-left-factor f g h H
( pair sec-f retr-f)
( pair (pair sh sh-issec) retr-h) =
pair
( section-comp f g h H (pair sh sh-issec) sec-f)
( retraction-comp' g f sh
( triangle-section f g h H (pair sh sh-issec))
( retr-f)
( pair h sh-issec))
abstract
is-equiv-left-factor' :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k} (g : B → X) (h : A → B) →
is-equiv (g ∘ h) → is-equiv h → is-equiv g
is-equiv-left-factor' g h =
is-equiv-left-factor (g ∘ h) g h htpy-refl
abstract
is-equiv-right-factor :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k}
(f : A → X) (g : B → X) (h : A → B) (H : f ~ (g ∘ h)) →
is-equiv g → is-equiv f → is-equiv h
is-equiv-right-factor f g h H
( pair sec-g (pair rg rg-isretr))
( pair sec-f retr-f) =
pair
( section-comp' h rg f
( triangle-retraction f g h H (pair rg rg-isretr))
( sec-f)
( pair g rg-isretr))
( retraction-comp f g h H (pair rg rg-isretr) retr-f)
abstract
is-equiv-right-factor' :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k} (g : B → X) (h : A → B) →
is-equiv g → is-equiv (g ∘ h) → is-equiv h
is-equiv-right-factor' g h =
is-equiv-right-factor (g ∘ h) g h htpy-refl
-- Exercise 6.6
{- In this exercise we show that the negation function on the booleans is an
equivalence. Moreover, we show that any constant function on the booleans is
not an equivalence. -}
neg-neg-𝟚 : (neg-𝟚 ∘ neg-𝟚) ~ id
neg-neg-𝟚 true = refl
neg-neg-𝟚 false = refl
abstract
is-equiv-neg-𝟚 : is-equiv neg-𝟚
is-equiv-neg-𝟚 = is-equiv-has-inverse neg-𝟚 neg-neg-𝟚 neg-neg-𝟚
equiv-neg-𝟚 : bool ≃ bool
equiv-neg-𝟚 = pair neg-𝟚 is-equiv-neg-𝟚
abstract
not-true-is-false : ¬ (Id true false)
not-true-is-false p =
tr (Eq-𝟚 true) p (reflexive-Eq-𝟚 true)
abstract
not-equiv-const :
(b : bool) → ¬ (is-equiv (const bool bool b))
not-equiv-const true (pair (pair s issec) (pair r isretr)) =
not-true-is-false (issec false)
not-equiv-const false (pair (pair s issec) (pair r isretr)) =
not-true-is-false (inv (issec true))
-- Exercise 6.7
is-equiv-succ-ℤ : is-equiv succ-ℤ
is-equiv-succ-ℤ =
is-equiv-has-inverse pred-ℤ right-inverse-pred-ℤ left-inverse-pred-ℤ
equiv-succ-ℤ : ℤ ≃ ℤ
equiv-succ-ℤ = pair succ-ℤ is-equiv-succ-ℤ
-- Exercise 6.8
{- In this exercise we construct an equivalence from A + B to B + A, showing
that the coproduct is commutative. -}
swap-coprod :
{i j : Level} (A : UU i) (B : UU j) → coprod A B → coprod B A
swap-coprod A B (inl x) = inr x
swap-coprod A B (inr x) = inl x
swap-swap-coprod :
{i j : Level} (A : UU i) (B : UU j) →
((swap-coprod B A) ∘ (swap-coprod A B)) ~ id
swap-swap-coprod A B (inl x) = refl
swap-swap-coprod A B (inr x) = refl
abstract
is-equiv-swap-coprod :
{i j : Level} (A : UU i) (B : UU j) → is-equiv (swap-coprod A B)
is-equiv-swap-coprod A B =
is-equiv-has-inverse
( swap-coprod B A)
( swap-swap-coprod B A)
( swap-swap-coprod A B)
equiv-swap-coprod :
{i j : Level} (A : UU i) (B : UU j) → coprod A B ≃ coprod B A
equiv-swap-coprod A B = pair (swap-coprod A B) (is-equiv-swap-coprod A B)
swap-prod :
{i j : Level} (A : UU i) (B : UU j) → prod A B → prod B A
swap-prod A B t = pair (pr2 t) (pr1 t)
swap-swap-prod :
{i j : Level} (A : UU i) (B : UU j) →
((swap-prod B A) ∘ (swap-prod A B)) ~ id
swap-swap-prod A B (pair x y) = refl
abstract
is-equiv-swap-prod :
{i j : Level} (A : UU i) (B : UU j) →
is-equiv (swap-prod A B)
is-equiv-swap-prod A B =
is-equiv-has-inverse
( swap-prod B A)
( swap-swap-prod B A)
( swap-swap-prod A B)
equiv-swap-prod :
{i j : Level} (A : UU i) (B : UU j) → (A × B) ≃ (B × A)
equiv-swap-prod A B = pair (swap-prod A B) (is-equiv-swap-prod A B)
-- Exercise 6.9
{- In this exercise we show that if A is a retract of B, then so are its
identity types. -}
ap-retraction :
{i j : Level} {A : UU i} {B : UU j}
(i : A → B) (r : B → A) (H : (r ∘ i) ~ id)
(x y : A) → Id (i x) (i y) → Id x y
ap-retraction i r H x y p =
( inv (H x)) ∙ ((ap r p) ∙ (H y))
isretr-ap-retraction :
{i j : Level} {A : UU i} {B : UU j}
(i : A → B) (r : B → A) (H : (r ∘ i) ~ id)
(x y : A) → ((ap-retraction i r H x y) ∘ (ap i {x} {y})) ~ id
isretr-ap-retraction i r H x .x refl = left-inv (H x)
retr-ap :
{i j : Level} {A : UU i} {B : UU j} (i : A → B) →
retr i → (x y : A) → retr (ap i {x} {y})
retr-ap i (pair r H) x y =
pair (ap-retraction i r H x y) (isretr-ap-retraction i r H x y)
Id-retract-of-Id :
{i j : Level} {A : UU i} {B : UU j} (R : A retract-of B) →
(x y : A) → (Id x y) retract-of (Id (pr1 R x) (pr1 R y))
Id-retract-of-Id (pair i (pair r H)) x y =
pair
( ap i {x} {y})
( retr-ap i (pair r H) x y)
-- Exercise 6.10
Σ-assoc :
{i j k : Level} (A : UU i) (B : A → UU j) (C : (Σ A B) → UU k) →
Σ (Σ A B) C → Σ A (λ x → Σ (B x) (λ y → C (pair x y)))
Σ-assoc A B C (pair (pair x y) z) = pair x (pair y z)
Σ-assoc' :
{i j k : Level} (A : UU i) (B : A → UU j) (C : (Σ A B) → UU k) →
Σ A (λ x → Σ (B x) (λ y → C (pair x y))) → Σ (Σ A B) C
Σ-assoc' A B C t = pair (pair (pr1 t) (pr1 (pr2 t))) (pr2 (pr2 t))
Σ-assoc-assoc :
{i j k : Level} (A : UU i) (B : A → UU j)
(C : (Σ A B) → UU k) → ((Σ-assoc' A B C) ∘ (Σ-assoc A B C)) ~ id
Σ-assoc-assoc A B C (pair (pair x y) z) = refl
Σ-assoc-assoc' :
{i j k : Level} (A : UU i) (B : A → UU j)
(C : (Σ A B) → UU k) → ((Σ-assoc A B C) ∘ (Σ-assoc' A B C)) ~ id
Σ-assoc-assoc' A B C (pair x (pair y z)) = refl
abstract
is-equiv-Σ-assoc :
{i j k : Level} (A : UU i) (B : A → UU j)
(C : (Σ A B) → UU k) → is-equiv (Σ-assoc A B C)
is-equiv-Σ-assoc A B C =
is-equiv-has-inverse
( Σ-assoc' A B C)
( Σ-assoc-assoc' A B C)
( Σ-assoc-assoc A B C)
equiv-Σ-assoc :
{i j k : Level} (A : UU i) (B : A → UU j) (C : (Σ A B) → UU k) →
Σ (Σ A B) C ≃ Σ A (λ x → Σ (B x) (λ y → C (pair x y)))
equiv-Σ-assoc A B C =
pair (Σ-assoc A B C) (is-equiv-Σ-assoc A B C)
-- Exercise 6.11
Σ-swap :
{i j k : Level} (A : UU i) (B : UU j) (C : A → B → UU k) →
Σ A (λ x → Σ B (C x)) → Σ B (λ y → Σ A (λ x → C x y))
Σ-swap A B C t = pair (pr1 (pr2 t)) (pair (pr1 t) (pr2 (pr2 t)))
Σ-swap' :
{i j k : Level} (A : UU i) (B : UU j) (C : A → B → UU k) →
Σ B (λ y → Σ A (λ x → C x y)) → Σ A (λ x → Σ B (C x))
Σ-swap' A B C = Σ-swap B A (λ y x → C x y)
Σ-swap-swap :
{i j k : Level} (A : UU i) (B : UU j) (C : A → B → UU k) →
((Σ-swap' A B C) ∘ (Σ-swap A B C)) ~ id
Σ-swap-swap A B C (pair x (pair y z)) = refl
abstract
is-equiv-Σ-swap :
{i j k : Level} (A : UU i) (B : UU j) (C : A → B → UU k) →
is-equiv (Σ-swap A B C)
is-equiv-Σ-swap A B C =
is-equiv-has-inverse
( Σ-swap' A B C)
( Σ-swap-swap B A (λ y x → C x y))
( Σ-swap-swap A B C)
-- Exercise 6.12
abstract
is-equiv-add-ℤ-right :
(x : ℤ) → is-equiv (add-ℤ x)
is-equiv-add-ℤ-right x =
is-equiv-has-inverse
( add-ℤ (neg-ℤ x))
( λ y →
( inv (associative-add-ℤ x (neg-ℤ x) y)) ∙
( ap (λ t → add-ℤ t y) (right-inverse-law-add-ℤ x)))
( λ y →
( inv (associative-add-ℤ (neg-ℤ x) x y)) ∙
( ap (λ t → add-ℤ t y) (left-inverse-law-add-ℤ x)))
abstract
is-equiv-add-ℤ-left :
(y : ℤ) → is-equiv (λ x → add-ℤ x y)
is-equiv-add-ℤ-left y =
is-equiv-htpy (add-ℤ y)
( λ x → commutative-add-ℤ x y)
( is-equiv-add-ℤ-right y)
-- Exercise 6.13
{- We construct the functoriality of coproducts. -}
functor-coprod :
{l1 l2 l1' l2' : Level} {A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'} →
(A → A') → (B → B') → coprod A B → coprod A' B'
functor-coprod f g (inl x) = inl (f x)
functor-coprod f g (inr y) = inr (g y)
htpy-functor-coprod :
{l1 l2 l1' l2' : Level} {A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'}
{f f' : A → A'} (H : f ~ f') {g g' : B → B'} (K : g ~ g') →
(functor-coprod f g) ~ (functor-coprod f' g')
htpy-functor-coprod H K (inl x) = ap inl (H x)
htpy-functor-coprod H K (inr y) = ap inr (K y)
id-functor-coprod :
{l1 l2 : Level} (A : UU l1) (B : UU l2) →
(functor-coprod (id {A = A}) (id {A = B})) ~ id
id-functor-coprod A B (inl x) = refl
id-functor-coprod A B (inr x) = refl
compose-functor-coprod :
{l1 l2 l1' l2' l1'' l2'' : Level}
{A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'}
{A'' : UU l1''} {B'' : UU l2''}
(f : A → A') (f' : A' → A'') (g : B → B') (g' : B' → B'') →
(functor-coprod (f' ∘ f) (g' ∘ g)) ~
((functor-coprod f' g') ∘ (functor-coprod f g))
compose-functor-coprod f f' g g' (inl x) = refl
compose-functor-coprod f f' g g' (inr y) = refl
abstract
is-equiv-functor-coprod :
{l1 l2 l1' l2' : Level} {A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'}
{f : A → A'} {g : B → B'} →
is-equiv f → is-equiv g → is-equiv (functor-coprod f g)
is-equiv-functor-coprod {A = A} {B = B} {A' = A'} {B' = B'} {f = f} {g = g}
(pair (pair sf issec-sf) (pair rf isretr-rf))
(pair (pair sg issec-sg) (pair rg isretr-rg)) =
pair
( pair
( functor-coprod sf sg)
( ( ( htpy-inv (compose-functor-coprod sf f sg g)) ∙h
( htpy-functor-coprod issec-sf issec-sg)) ∙h
( id-functor-coprod A' B')))
( pair
( functor-coprod rf rg)
( ( ( htpy-inv (compose-functor-coprod f rf g rg)) ∙h
( htpy-functor-coprod isretr-rf isretr-rg)) ∙h
( id-functor-coprod A B)))
equiv-functor-coprod :
{l1 l2 l1' l2' : Level} {A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'} →
(A ≃ A') → (B ≃ B') → ((coprod A B) ≃ (coprod A' B'))
equiv-functor-coprod (pair e is-equiv-e) (pair f is-equiv-f) =
pair
( functor-coprod e f)
( is-equiv-functor-coprod is-equiv-e is-equiv-f)
-- Extra material
abstract
is-equiv-inv-con :
{i : Level} {A : UU i} {x y z : A} (p : Id x y)
(q : Id y z) (r : Id x z) → is-equiv (inv-con p q r)
is-equiv-inv-con refl q r = is-equiv-id (Id q r)
equiv-inv-con :
{i : Level} {A : UU i} {x y z : A} (p : Id x y) (q : Id y z) (r : Id x z) →
Id (p ∙ q) r ≃ Id q ((inv p) ∙ r)
equiv-inv-con p q r = pair (inv-con p q r) (is-equiv-inv-con p q r)
abstract
is-equiv-con-inv :
{i : Level} {A : UU i} {x y z : A} (p : Id x y)
(q : Id y z) (r : Id x z) → is-equiv (con-inv p q r)
is-equiv-con-inv p refl r =
is-equiv-comp'
( concat' p (inv right-unit))
( concat (inv right-unit) r)
( is-equiv-concat (inv right-unit) r)
( is-equiv-concat' p (inv right-unit))
equiv-con-inv :
{i : Level} {A : UU i} {x y z : A} (p : Id x y) (q : Id y z) (r : Id x z) →
Id (p ∙ q) r ≃ Id p (r ∙ (inv q))
equiv-con-inv p q r = pair (con-inv p q r) (is-equiv-con-inv p q r)
htpy-inv-con :
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g h : (x : A) → B x} →
(H : f ~ g) (K : g ~ h) (L : f ~ h) →
(H ∙h K) ~ L → K ~ ((htpy-inv H) ∙h L)
htpy-inv-con H K L M x = inv-con (H x) (K x) (L x) (M x)
htpy-con-inv :
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g h : (x : A) → B x} →
(H : f ~ g) (K : g ~ h) (L : f ~ h) →
(H ∙h K) ~ L → H ~ (L ∙h (htpy-inv K))
htpy-con-inv H K L M x = con-inv (H x) (K x) (L x) (M x)
htpy-ap-concat :
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g h : (x : A) → B x} →
(H : f ~ g) (K K' : g ~ h) →
K ~ K' → (H ∙h K) ~ (H ∙h K')
htpy-ap-concat {g = g} {h} H K K' L x =
ap (concat (H x) (h x)) (L x)
htpy-ap-concat' :
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g h : (x : A) → B x} →
(H H' : f ~ g) (K : g ~ h) →
H ~ H' → (H ∙h K) ~ (H' ∙h K)
htpy-ap-concat' H H' K L x =
ap (concat' _ (K x)) (L x)
htpy-distributive-inv-concat :
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g h : (x : A) → B x} →
(H : f ~ g) (K : g ~ h) →
(htpy-inv (H ∙h K)) ~ ((htpy-inv K) ∙h (htpy-inv H))
htpy-distributive-inv-concat H K x = distributive-inv-concat (H x) (K x)
htpy-ap-inv :
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g : (x : A) → B x} →
{H H' : f ~ g} →
H ~ H' → (htpy-inv H) ~ (htpy-inv H')
htpy-ap-inv K x = ap inv (K x)
htpy-left-whisk-htpy-inv :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {C : UU l3}
{f f' : A → B} (g : B → C) (H : f ~ f') →
(g ·l (htpy-inv H)) ~ htpy-inv (g ·l H)
htpy-left-whisk-htpy-inv g H x = ap-inv g (H x)
htpy-right-whisk-htpy-inv :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {C : UU l3}
{g g' : B → C} (H : g ~ g') (f : A → B) →
((htpy-inv H) ·r f) ~ (htpy-inv (H ·r f))
htpy-right-whisk-htpy-inv H f = htpy-refl
| 31.56639
| 80
| 0.508939
|
3185bc2787be2ef0f43ad002925d8dbdfba414cc
| 5,408
|
agda
|
Agda
|
Cubical/Structures/Relational/Maybe.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/Structures/Relational/Maybe.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/Structures/Relational/Maybe.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
{-
Maybe structure: X ↦ Maybe (S X)
-}
{-# OPTIONS --no-exact-split --safe #-}
module Cubical.Structures.Relational.Maybe where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Structure
open import Cubical.Foundations.RelationalStructure
open import Cubical.Data.Unit
open import Cubical.Data.Empty
open import Cubical.Data.Maybe
open import Cubical.Data.Sigma
open import Cubical.HITs.PropositionalTruncation as Trunc
open import Cubical.HITs.SetQuotients
open import Cubical.Structures.Maybe
private
variable
ℓ ℓ₁ ℓ₁' ℓ₁'' : Level
-- Structured relations
MaybeRelStr : {S : Type ℓ → Type ℓ₁} {ℓ₁' : Level}
→ StrRel S ℓ₁' → StrRel (λ X → Maybe (S X)) ℓ₁'
MaybeRelStr ρ R = MaybeRel (ρ R)
maybeSuitableRel : {S : Type ℓ → Type ℓ₁} {ρ : StrRel S ℓ₁'}
→ SuitableStrRel S ρ
→ SuitableStrRel (MaybeStructure S) (MaybeRelStr ρ)
maybeSuitableRel θ .quo (X , nothing) R _ .fst = nothing , _
maybeSuitableRel θ .quo (X , nothing) R _ .snd (nothing , _) = refl
maybeSuitableRel θ .quo (X , just s) R c .fst =
just (θ .quo (X , s) R c .fst .fst) , θ .quo (X , s) R c .fst .snd
maybeSuitableRel θ .quo (X , just s) R c .snd (just s' , r) =
cong (λ {(t , r') → just t , r'}) (θ .quo (X , s) R c .snd (s' , r))
maybeSuitableRel θ .symmetric R {nothing} {nothing} r = _
maybeSuitableRel θ .symmetric R {just s} {just t} r = θ .symmetric R r
maybeSuitableRel θ .transitive R R' {nothing} {nothing} {nothing} r r' = _
maybeSuitableRel θ .transitive R R' {just s} {just t} {just u} r r' = θ .transitive R R' r r'
maybeSuitableRel θ .set setX = isOfHLevelMaybe 0 (θ .set setX)
maybeSuitableRel θ .prop propR nothing nothing = isOfHLevelLift 1 isPropUnit
maybeSuitableRel θ .prop propR nothing (just y) = isOfHLevelLift 1 isProp⊥
maybeSuitableRel θ .prop propR (just x) nothing = isOfHLevelLift 1 isProp⊥
maybeSuitableRel θ .prop propR (just x) (just y) = θ .prop propR x y
maybeRelMatchesEquiv : {S : Type ℓ → Type ℓ₁} (ρ : StrRel S ℓ₁') {ι : StrEquiv S ℓ₁''}
→ StrRelMatchesEquiv ρ ι
→ StrRelMatchesEquiv (MaybeRelStr ρ) (MaybeEquivStr ι)
maybeRelMatchesEquiv ρ μ (X , nothing) (Y , nothing) _ = Lift≃Lift (idEquiv _)
maybeRelMatchesEquiv ρ μ (X , nothing) (Y , just y) _ = Lift≃Lift (idEquiv _)
maybeRelMatchesEquiv ρ μ (X , just x) (Y , nothing) _ = Lift≃Lift (idEquiv _)
maybeRelMatchesEquiv ρ μ (X , just x) (Y , just y) = μ (X , x) (Y , y)
maybeRelAction :
{S : Type ℓ → Type ℓ₁} {ρ : StrRel S ℓ₁'}
→ StrRelAction ρ
→ StrRelAction (MaybeRelStr ρ)
maybeRelAction α .actStr f = map-Maybe (α .actStr f)
maybeRelAction α .actStrId s =
funExt⁻ (cong map-Maybe (funExt (α .actStrId))) s ∙ map-Maybe-id s
maybeRelAction α .actRel h nothing nothing = _
maybeRelAction α .actRel h (just s) (just t) r = α .actRel h s t r
maybePositiveRel :
{S : Type ℓ → Type ℓ₁} {ρ : StrRel S ℓ₁'} {θ : SuitableStrRel S ρ}
→ PositiveStrRel θ
→ PositiveStrRel (maybeSuitableRel θ)
maybePositiveRel σ .act = maybeRelAction (σ .act)
maybePositiveRel σ .reflexive nothing = _
maybePositiveRel σ .reflexive (just s) = σ .reflexive s
maybePositiveRel σ .detransitive R R' {nothing} {nothing} r = ∣ nothing , _ , _ ∣₁
maybePositiveRel σ .detransitive R R' {just s} {just u} rr' =
Trunc.map (λ {(t , r , r') → just t , r , r'}) (σ .detransitive R R' rr')
maybePositiveRel {S = S} {ρ = ρ} {θ = θ} σ .quo {X} R =
subst isEquiv
(funExt
(elimProp (λ _ → maybeSuitableRel θ .set squash/ _ _)
(λ {nothing → refl; (just _) → refl})))
(compEquiv (isoToEquiv isom) (congMaybeEquiv (_ , σ .quo R)) .snd)
where
fwd : Maybe (S X) / MaybeRel (ρ (R .fst .fst)) → Maybe (S X / ρ (R .fst .fst))
fwd [ nothing ] = nothing
fwd [ just s ] = just [ s ]
fwd (eq/ nothing nothing r i) = nothing
fwd (eq/ (just s) (just t) r i) = just (eq/ s t r i)
fwd (squash/ _ _ p q i j) =
isOfHLevelMaybe 0 squash/ _ _ (cong fwd p) (cong fwd q) i j
bwd : Maybe (S X / ρ (R .fst .fst)) → Maybe (S X) / MaybeRel (ρ (R .fst .fst))
bwd nothing = [ nothing ]
bwd (just [ s ]) = [ just s ]
bwd (just (eq/ s t r i)) = eq/ (just s) (just t) r i
bwd (just (squash/ _ _ p q i j)) =
squash/ _ _ (cong (bwd ∘ just) p) (cong (bwd ∘ just) q) i j
open Iso
isom : Iso (Maybe (S X) / MaybeRel (ρ (R .fst .fst))) (Maybe (S X / ρ (R .fst .fst)))
isom .fun = fwd
isom .inv = bwd
isom .rightInv nothing = refl
isom .rightInv (just x) =
elimProp {P = λ x → fwd (bwd (just x)) ≡ just x}
(λ _ → isOfHLevelMaybe 0 squash/ _ _)
(λ _ → refl)
x
isom .leftInv = elimProp (λ _ → squash/ _ _) (λ {nothing → refl; (just _) → refl})
maybeRelMatchesTransp : {S : Type ℓ → Type ℓ₁}
(ρ : StrRel S ℓ₁') (α : EquivAction S)
→ StrRelMatchesEquiv ρ (EquivAction→StrEquiv α)
→ StrRelMatchesEquiv (MaybeRelStr ρ) (EquivAction→StrEquiv (maybeEquivAction α))
maybeRelMatchesTransp _ _ μ (X , nothing) (Y , nothing) _ =
isContr→Equiv (isOfHLevelLift 0 isContrUnit) isContr-nothing≡nothing
maybeRelMatchesTransp _ _ μ (X , nothing) (Y , just y) _ =
uninhabEquiv lower ¬nothing≡just
maybeRelMatchesTransp _ _ μ (X , just x) (Y , nothing) _ =
uninhabEquiv lower ¬just≡nothing
maybeRelMatchesTransp _ _ μ (X , just x) (Y , just y) e =
compEquiv (μ (X , x) (Y , y) e) (_ , isEmbedding-just _ _)
| 42.25
| 93
| 0.664386
|
0bf1638b20ea29811aaac2c81688919d45921705
| 208
|
agda
|
Agda
|
test/Succeed/Issue4006.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue4006.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue4006.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
data I : Set where
i : I
variable
x : I
abstract
data D : I → Set where
d : D i
accepted : {x : I} → D x → Set₁
accepted {x = i} d = Set
rejected : D x → Set₁
rejected {x = i} d = Set
| 11.555556
| 33
| 0.519231
|
06edca09ccb86e4c1781107c3498239b51163964
| 10,452
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Data/Sum/Relation/Binary/LeftOrder.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Sum/Relation/Binary/LeftOrder.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Sum/Relation/Binary/LeftOrder.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Sums of binary relations
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Sum.Relation.Binary.LeftOrder where
open import Data.Sum as Sum
open import Data.Sum.Relation.Binary.Pointwise as PW
using (Pointwise; inj₁; inj₂)
open import Data.Product
open import Data.Empty
open import Function
open import Level
open import Relation.Nullary
import Relation.Nullary.Decidable as Dec
open import Relation.Binary
open import Relation.Binary.PropositionalEquality as P using (_≡_)
----------------------------------------------------------------------
-- Definition
infixr 1 _⊎-<_
data _⊎-<_ {a₁ a₂} {A₁ : Set a₁} {A₂ : Set a₂}
{ℓ₁ ℓ₂} (_∼₁_ : Rel A₁ ℓ₁) (_∼₂_ : Rel A₂ ℓ₂) :
Rel (A₁ ⊎ A₂) (a₁ ⊔ a₂ ⊔ ℓ₁ ⊔ ℓ₂) where
₁∼₂ : ∀ {x y} → (_∼₁_ ⊎-< _∼₂_) (inj₁ x) (inj₂ y)
₁∼₁ : ∀ {x y} (x∼₁y : x ∼₁ y) → (_∼₁_ ⊎-< _∼₂_) (inj₁ x) (inj₁ y)
₂∼₂ : ∀ {x y} (x∼₂y : x ∼₂ y) → (_∼₁_ ⊎-< _∼₂_) (inj₂ x) (inj₂ y)
----------------------------------------------------------------------
-- Some properties which are preserved by _⊎-<_
module _ {a₁ a₂} {A₁ : Set a₁} {A₂ : Set a₂}
{ℓ₁ ℓ₂} {∼₁ : Rel A₁ ℓ₁} {∼₂ : Rel A₂ ℓ₂}
where
drop-inj₁ : ∀ {x y} → (∼₁ ⊎-< ∼₂) (inj₁ x) (inj₁ y) → ∼₁ x y
drop-inj₁ (₁∼₁ x∼₁y) = x∼₁y
drop-inj₂ : ∀ {x y} → (∼₁ ⊎-< ∼₂) (inj₂ x) (inj₂ y) → ∼₂ x y
drop-inj₂ (₂∼₂ x∼₂y) = x∼₂y
⊎-<-refl : Reflexive ∼₁ → Reflexive ∼₂ →
Reflexive (∼₁ ⊎-< ∼₂)
⊎-<-refl refl₁ refl₂ {inj₁ x} = ₁∼₁ refl₁
⊎-<-refl refl₁ refl₂ {inj₂ y} = ₂∼₂ refl₂
⊎-<-transitive : Transitive ∼₁ → Transitive ∼₂ →
Transitive (∼₁ ⊎-< ∼₂)
⊎-<-transitive trans₁ trans₂ ₁∼₂ (₂∼₂ x∼₂y) = ₁∼₂
⊎-<-transitive trans₁ trans₂ (₁∼₁ x∼₁y) ₁∼₂ = ₁∼₂
⊎-<-transitive trans₁ trans₂ (₁∼₁ x∼₁y) (₁∼₁ x∼₁y₁) = ₁∼₁ (trans₁ x∼₁y x∼₁y₁)
⊎-<-transitive trans₁ trans₂ (₂∼₂ x∼₂y) (₂∼₂ x∼₂y₁) = ₂∼₂ (trans₂ x∼₂y x∼₂y₁)
⊎-<-asymmetric : Asymmetric ∼₁ → Asymmetric ∼₂ →
Asymmetric (∼₁ ⊎-< ∼₂)
⊎-<-asymmetric asym₁ asym₂ ₁∼₂ ()
⊎-<-asymmetric asym₁ asym₂ (₁∼₁ x∼₁y) (₁∼₁ x∼₁y₁) = asym₁ x∼₁y x∼₁y₁
⊎-<-asymmetric asym₁ asym₂ (₂∼₂ x∼₂y) (₂∼₂ x∼₂y₁) = asym₂ x∼₂y x∼₂y₁
⊎-<-total : Total ∼₁ → Total ∼₂ → Total (∼₁ ⊎-< ∼₂)
⊎-<-total total₁ total₂ = total
where
total : Total (_ ⊎-< _)
total (inj₁ x) (inj₁ y) = Sum.map ₁∼₁ ₁∼₁ $ total₁ x y
total (inj₁ x) (inj₂ y) = inj₁ ₁∼₂
total (inj₂ x) (inj₁ y) = inj₂ ₁∼₂
total (inj₂ x) (inj₂ y) = Sum.map ₂∼₂ ₂∼₂ $ total₂ x y
⊎-<-decidable : Decidable ∼₁ → Decidable ∼₂ →
Decidable (∼₁ ⊎-< ∼₂)
⊎-<-decidable dec₁ dec₂ (inj₁ x) (inj₁ y) = Dec.map′ ₁∼₁ drop-inj₁ (dec₁ x y)
⊎-<-decidable dec₁ dec₂ (inj₁ x) (inj₂ y) = yes ₁∼₂
⊎-<-decidable dec₁ dec₂ (inj₂ x) (inj₁ y) = no λ()
⊎-<-decidable dec₁ dec₂ (inj₂ x) (inj₂ y) = Dec.map′ ₂∼₂ drop-inj₂ (dec₂ x y)
module _ {a₁ a₂} {A₁ : Set a₁} {A₂ : Set a₂}
{ℓ₁ ℓ₂} {∼₁ : Rel A₁ ℓ₁} {≈₁ : Rel A₁ ℓ₂}
{ℓ₃ ℓ₄} {∼₂ : Rel A₂ ℓ₃} {≈₂ : Rel A₂ ℓ₄}
where
⊎-<-reflexive : ≈₁ ⇒ ∼₁ → ≈₂ ⇒ ∼₂ →
(Pointwise ≈₁ ≈₂) ⇒ (∼₁ ⊎-< ∼₂)
⊎-<-reflexive refl₁ refl₂ (inj₁ x) = ₁∼₁ (refl₁ x)
⊎-<-reflexive refl₁ refl₂ (inj₂ x) = ₂∼₂ (refl₂ x)
⊎-<-irreflexive : Irreflexive ≈₁ ∼₁ → Irreflexive ≈₂ ∼₂ →
Irreflexive (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂)
⊎-<-irreflexive irrefl₁ irrefl₂ (inj₁ x) (₁∼₁ x∼₁y) = irrefl₁ x x∼₁y
⊎-<-irreflexive irrefl₁ irrefl₂ (inj₂ x) (₂∼₂ x∼₂y) = irrefl₂ x x∼₂y
⊎-<-antisymmetric : Antisymmetric ≈₁ ∼₁ → Antisymmetric ≈₂ ∼₂ →
Antisymmetric (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂)
⊎-<-antisymmetric antisym₁ antisym₂ (₁∼₁ x∼₁y) (₁∼₁ x∼₁y₁) = inj₁ (antisym₁ x∼₁y x∼₁y₁)
⊎-<-antisymmetric antisym₁ antisym₂ (₂∼₂ x∼₂y) (₂∼₂ x∼₂y₁) = inj₂ (antisym₂ x∼₂y x∼₂y₁)
-- Remove in Agda 2.6.0?
⊎-<-antisymmetric antisym₁ antisym₂ ₁∼₂ ()
⊎-<-respectsʳ : ∼₁ Respectsʳ ≈₁ → ∼₂ Respectsʳ ≈₂ →
(∼₁ ⊎-< ∼₂) Respectsʳ (Pointwise ≈₁ ≈₂)
⊎-<-respectsʳ resp₁ resp₂ (inj₁ x₁) (₁∼₁ x∼₁y) = ₁∼₁ (resp₁ x₁ x∼₁y)
⊎-<-respectsʳ resp₁ resp₂ (inj₂ x₁) ₁∼₂ = ₁∼₂
⊎-<-respectsʳ resp₁ resp₂ (inj₂ x₁) (₂∼₂ x∼₂y) = ₂∼₂ (resp₂ x₁ x∼₂y)
⊎-<-respectsˡ : ∼₁ Respectsˡ ≈₁ → ∼₂ Respectsˡ ≈₂ →
(∼₁ ⊎-< ∼₂) Respectsˡ (Pointwise ≈₁ ≈₂)
⊎-<-respectsˡ resp₁ resp₂ (inj₁ x) ₁∼₂ = ₁∼₂
⊎-<-respectsˡ resp₁ resp₂ (inj₁ x) (₁∼₁ x∼₁y) = ₁∼₁ (resp₁ x x∼₁y)
⊎-<-respectsˡ resp₁ resp₂ (inj₂ x) (₂∼₂ x∼₂y) = ₂∼₂ (resp₂ x x∼₂y)
⊎-<-respects₂ : ∼₁ Respects₂ ≈₁ → ∼₂ Respects₂ ≈₂ →
(∼₁ ⊎-< ∼₂) Respects₂ (Pointwise ≈₁ ≈₂)
⊎-<-respects₂ (r₁ , l₁) (r₂ , l₂) = ⊎-<-respectsʳ r₁ r₂ , ⊎-<-respectsˡ l₁ l₂
⊎-<-trichotomous : Trichotomous ≈₁ ∼₁ → Trichotomous ≈₂ ∼₂ →
Trichotomous (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂)
⊎-<-trichotomous tri₁ tri₂ (inj₁ x) (inj₂ y) = tri< ₁∼₂ (λ()) (λ())
⊎-<-trichotomous tri₁ tri₂ (inj₂ x) (inj₁ y) = tri> (λ()) (λ()) ₁∼₂
⊎-<-trichotomous tri₁ tri₂ (inj₁ x) (inj₁ y) with tri₁ x y
... | tri< x<y x≉y x≯y = tri< (₁∼₁ x<y) (x≉y ∘ PW.drop-inj₁) (x≯y ∘ drop-inj₁)
... | tri≈ x≮y x≈y x≯y = tri≈ (x≮y ∘ drop-inj₁) (inj₁ x≈y) (x≯y ∘ drop-inj₁)
... | tri> x≮y x≉y x>y = tri> (x≮y ∘ drop-inj₁) (x≉y ∘ PW.drop-inj₁) (₁∼₁ x>y)
⊎-<-trichotomous tri₁ tri₂ (inj₂ x) (inj₂ y) with tri₂ x y
... | tri< x<y x≉y x≯y = tri< (₂∼₂ x<y) (x≉y ∘ PW.drop-inj₂) (x≯y ∘ drop-inj₂)
... | tri≈ x≮y x≈y x≯y = tri≈ (x≮y ∘ drop-inj₂) (inj₂ x≈y) (x≯y ∘ drop-inj₂)
... | tri> x≮y x≉y x>y = tri> (x≮y ∘ drop-inj₂) (x≉y ∘ PW.drop-inj₂) (₂∼₂ x>y)
----------------------------------------------------------------------
-- Some collections of properties which are preserved
module _ {a₁ a₂} {A₁ : Set a₁} {A₂ : Set a₂}
{ℓ₁ ℓ₂} {≈₁ : Rel A₁ ℓ₁} {∼₁ : Rel A₁ ℓ₂}
{ℓ₃ ℓ₄} {≈₂ : Rel A₂ ℓ₃} {∼₂ : Rel A₂ ℓ₄} where
⊎-<-isPreorder : IsPreorder ≈₁ ∼₁ → IsPreorder ≈₂ ∼₂ →
IsPreorder (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂)
⊎-<-isPreorder pre₁ pre₂ = record
{ isEquivalence = PW.⊎-isEquivalence (isEquivalence pre₁) (isEquivalence pre₂)
; reflexive = ⊎-<-reflexive (reflexive pre₁) (reflexive pre₂)
; trans = ⊎-<-transitive (trans pre₁) (trans pre₂)
}
where open IsPreorder
⊎-<-isPartialOrder : IsPartialOrder ≈₁ ∼₁ →
IsPartialOrder ≈₂ ∼₂ →
IsPartialOrder (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂)
⊎-<-isPartialOrder po₁ po₂ = record
{ isPreorder = ⊎-<-isPreorder (isPreorder po₁) (isPreorder po₂)
; antisym = ⊎-<-antisymmetric (antisym po₁) (antisym po₂)
}
where open IsPartialOrder
⊎-<-isStrictPartialOrder : IsStrictPartialOrder ≈₁ ∼₁ →
IsStrictPartialOrder ≈₂ ∼₂ →
IsStrictPartialOrder (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂)
⊎-<-isStrictPartialOrder spo₁ spo₂ = record
{ isEquivalence = PW.⊎-isEquivalence (isEquivalence spo₁) (isEquivalence spo₂)
; irrefl = ⊎-<-irreflexive (irrefl spo₁) (irrefl spo₂)
; trans = ⊎-<-transitive (trans spo₁) (trans spo₂)
; <-resp-≈ = ⊎-<-respects₂ (<-resp-≈ spo₁) (<-resp-≈ spo₂)
}
where open IsStrictPartialOrder
⊎-<-isTotalOrder : IsTotalOrder ≈₁ ∼₁ →
IsTotalOrder ≈₂ ∼₂ →
IsTotalOrder (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂)
⊎-<-isTotalOrder to₁ to₂ = record
{ isPartialOrder = ⊎-<-isPartialOrder (isPartialOrder to₁) (isPartialOrder to₂)
; total = ⊎-<-total (total to₁) (total to₂)
}
where open IsTotalOrder
⊎-<-isDecTotalOrder : IsDecTotalOrder ≈₁ ∼₁ →
IsDecTotalOrder ≈₂ ∼₂ →
IsDecTotalOrder (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂)
⊎-<-isDecTotalOrder to₁ to₂ = record
{ isTotalOrder = ⊎-<-isTotalOrder (isTotalOrder to₁) (isTotalOrder to₂)
; _≟_ = PW.⊎-decidable (_≟_ to₁) (_≟_ to₂)
; _≤?_ = ⊎-<-decidable (_≤?_ to₁) (_≤?_ to₂)
}
where open IsDecTotalOrder
⊎-<-isStrictTotalOrder : IsStrictTotalOrder ≈₁ ∼₁ →
IsStrictTotalOrder ≈₂ ∼₂ →
IsStrictTotalOrder (Pointwise ≈₁ ≈₂) (∼₁ ⊎-< ∼₂)
⊎-<-isStrictTotalOrder sto₁ sto₂ = record
{ isEquivalence = PW.⊎-isEquivalence (isEquivalence sto₁) (isEquivalence sto₂)
; trans = ⊎-<-transitive (trans sto₁) (trans sto₂)
; compare = ⊎-<-trichotomous (compare sto₁) (compare sto₂)
}
where open IsStrictTotalOrder
------------------------------------------------------------------------
-- "Packages" can also be combined.
module _ {a b c d e f} where
⊎-<-preorder : Preorder a b c →
Preorder d e f →
Preorder _ _ _
⊎-<-preorder p₁ p₂ = record
{ isPreorder =
⊎-<-isPreorder (isPreorder p₁) (isPreorder p₂)
} where open Preorder
⊎-<-poset : Poset a b c →
Poset a b c →
Poset _ _ _
⊎-<-poset po₁ po₂ = record
{ isPartialOrder =
⊎-<-isPartialOrder (isPartialOrder po₁) (isPartialOrder po₂)
} where open Poset
⊎-<-strictPartialOrder : StrictPartialOrder a b c →
StrictPartialOrder d e f →
StrictPartialOrder _ _ _
⊎-<-strictPartialOrder spo₁ spo₂ = record
{ isStrictPartialOrder =
⊎-<-isStrictPartialOrder (isStrictPartialOrder spo₁) (isStrictPartialOrder spo₂)
} where open StrictPartialOrder
⊎-<-totalOrder : TotalOrder a b c →
TotalOrder d e f →
TotalOrder _ _ _
⊎-<-totalOrder to₁ to₂ = record
{ isTotalOrder = ⊎-<-isTotalOrder (isTotalOrder to₁) (isTotalOrder to₂)
} where open TotalOrder
⊎-<-decTotalOrder : DecTotalOrder a b c →
DecTotalOrder d e f →
DecTotalOrder _ _ _
⊎-<-decTotalOrder to₁ to₂ = record
{ isDecTotalOrder = ⊎-<-isDecTotalOrder (isDecTotalOrder to₁) (isDecTotalOrder to₂)
} where open DecTotalOrder
⊎-<-strictTotalOrder : StrictTotalOrder a b c →
StrictTotalOrder a b c →
StrictTotalOrder _ _ _
⊎-<-strictTotalOrder sto₁ sto₂ = record
{ isStrictTotalOrder = ⊎-<-isStrictTotalOrder (isStrictTotalOrder sto₁) (isStrictTotalOrder sto₂)
} where open StrictTotalOrder
| 42.315789
| 101
| 0.534443
|
234a220077aeb28ce83826a09c6b768281c6fea8
| 3,624
|
agda
|
Agda
|
theorems/cohomology/ChainComplex.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
theorems/cohomology/ChainComplex.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
theorems/cohomology/ChainComplex.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 50
|
2015-01-10T01:48:08.000Z
|
2022-02-14T03:03:25.000Z
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import groups.KernelImage
open import groups.KernelImageEmap
module cohomology.ChainComplex where
record ChainComplex i : Type (lsucc i) where
field
head : AbGroup i
chain : ℕ → AbGroup i
augment : AbGroup.grp (chain 0) →ᴳ AbGroup.grp head
boundary : ∀ n → (AbGroup.grp (chain (S n)) →ᴳ AbGroup.grp (chain n))
record CochainComplex i : Type (lsucc i) where
field
head : AbGroup i
cochain : ℕ → AbGroup i
augment : AbGroup.grp head →ᴳ AbGroup.grp (cochain 0)
coboundary : ∀ n → (AbGroup.grp (cochain n) →ᴳ AbGroup.grp (cochain (S n)))
record CochainComplexEquiv {i₀ i₁}
(cc₀ : CochainComplex i₀) (cc₁ : CochainComplex i₁) : Type (lmax i₀ i₁) where
private
module cc₀ = CochainComplex cc₀
module cc₁ = CochainComplex cc₁
field
head : AbGroup.grp cc₀.head ≃ᴳ AbGroup.grp cc₁.head
cochain : (n : ℕ) → AbGroup.grp (cc₀.cochain n) ≃ᴳ AbGroup.grp (cc₁.cochain n)
augment : CommSquareᴳ cc₀.augment cc₁.augment (–>ᴳ head) (–>ᴳ (cochain 0))
coboundary : ∀ n → CommSquareᴳ (cc₀.coboundary n) (cc₁.coboundary n)
(–>ᴳ (cochain n)) (–>ᴳ (cochain (S n)))
homology-group : ∀ {i} → ChainComplex i → (n : ℤ) → Group i
homology-group cc (pos 0) = Ker/Im cc.augment (cc.boundary 0) (snd (cc.chain 0))
where module cc = ChainComplex cc
homology-group cc (pos (S n)) = Ker/Im (cc.boundary n) (cc.boundary (S n)) (snd (cc.chain (S n)))
where module cc = ChainComplex cc
homology-group {i} cc (negsucc _) = Lift-group {j = i} Unit-group
cohomology-group : ∀ {i} → CochainComplex i → (n : ℤ) → Group i
cohomology-group cc (pos 0) = Ker/Im (cc.coboundary 0) cc.augment (snd (cc.cochain 0))
where module cc = CochainComplex cc
cohomology-group cc (pos (S n)) = Ker/Im (cc.coboundary (S n)) (cc.coboundary n) (snd (cc.cochain (S n)))
where module cc = CochainComplex cc
cohomology-group {i} cc (negsucc _) = Lift-group {j = i} Unit-group
cohomology-group-emap : ∀ {i₀ i₁} {cc₀ : CochainComplex i₀} {cc₁ : CochainComplex i₁}
→ CochainComplexEquiv cc₀ cc₁
→ (n : ℤ) → cohomology-group cc₀ n ≃ᴳ cohomology-group cc₁ n
cohomology-group-emap {cc₀ = cc₀} {cc₁} cc= (pos 0) =
Ker/Im-emap (snd (cc₀.cochain 0)) (snd (cc₁.cochain 0))
(cc=.coboundary 0) cc=.augment
(snd cc=.head) (snd (cc=.cochain 0)) (snd (cc=.cochain 1))
where module cc₀ = CochainComplex cc₀
module cc₁ = CochainComplex cc₁
module cc= = CochainComplexEquiv cc=
cohomology-group-emap {cc₀ = cc₀} {cc₁} cc= (pos (S n)) =
Ker/Im-emap (snd (cc₀.cochain (S n))) (snd (cc₁.cochain (S n)))
(cc=.coboundary (S n)) (cc=.coboundary n)
(snd (cc=.cochain n)) (snd (cc=.cochain (S n))) (snd (cc=.cochain (S (S n))))
where module cc₀ = CochainComplex cc₀
module cc₁ = CochainComplex cc₁
module cc= = CochainComplexEquiv cc=
cohomology-group-emap _ (negsucc _) = lift-iso ∘eᴳ lower-iso
complex-dualize : ∀ {i j} → ChainComplex i → AbGroup j
→ CochainComplex (lmax i j)
complex-dualize {i} {j} cc G = record {M} where
module cc = ChainComplex cc
module M where
head : AbGroup (lmax i j)
head = hom-abgroup (AbGroup.grp cc.head) G
cochain : ℕ → AbGroup (lmax i j)
cochain n = hom-abgroup (AbGroup.grp (cc.chain n)) G
augment : AbGroup.grp head →ᴳ AbGroup.grp (cochain 0)
augment = pre∘ᴳ-hom G cc.augment
coboundary : ∀ n → (AbGroup.grp (cochain n) →ᴳ AbGroup.grp (cochain (S n)))
coboundary n = pre∘ᴳ-hom G (cc.boundary n)
| 43.142857
| 107
| 0.634382
|
109c648d922e007db8b82e530fcc154a68dd0486
| 3,498
|
agda
|
Agda
|
Cubical/Foundations/Embedding.agda
|
jonsterling/cubical-1
|
794b550f40562e025b5570badd78fdc2e6597779
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Embedding.agda
|
jonsterling/cubical-1
|
794b550f40562e025b5570badd78fdc2e6597779
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Embedding.agda
|
jonsterling/cubical-1
|
794b550f40562e025b5570badd78fdc2e6597779
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --safe #-}
module Cubical.Foundations.Embedding where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Isomorphism
private
variable
ℓ : Level
A B : Type ℓ
f : A → B
w x : A
y z : B
-- Embeddings are generalizations of injections. The usual
-- definition of injection as:
--
-- f x ≡ f y → x ≡ y
--
-- is not well-behaved with higher h-levels, while embeddings
-- are.
isEmbedding : (A → B) → Type _
isEmbedding f = ∀ w x → isEquiv {A = w ≡ x} (cong f)
isEmbeddingIsProp : isProp (isEmbedding f)
isEmbeddingIsProp {f = f}
= propPi λ w → propPi λ x → isPropIsEquiv (cong f)
-- If A and B are h-sets, then injective functions between
-- them are embeddings.
--
-- Note: It doesn't appear to be possible to omit either of
-- the `isSet` hypotheses.
injEmbedding
: {f : A → B}
→ isSet A → isSet B
→ (∀{w x} → f w ≡ f x → w ≡ x)
→ isEmbedding f
injEmbedding {f = f} iSA iSB inj w x
= isoToIsEquiv (iso (cong f) inj sect retr)
where
sect : section (cong f) inj
sect p = iSB (f w) (f x) _ p
retr : retract (cong f) inj
retr p = iSA w x _ p
private
lemma₀ : (p : y ≡ z) → fiber f y ≡ fiber f z
lemma₀ {f = f} p = λ i → fiber f (p i)
lemma₁ : isEmbedding f → ∀ x → isContr (fiber f (f x))
lemma₁ {f = f} iE x = value , path
where
value : fiber f (f x)
value = (x , refl)
path : ∀(fi : fiber f (f x)) → value ≡ fi
path (w , p) i
= case equiv-proof (iE w x) p of λ
{ ((q , sq) , _)
→ hfill (λ j → λ { (i = i0) → (x , refl)
; (i = i1) → (w , sq j)
})
(inS (q (~ i) , λ j → f (q (~ i ∨ j))))
i1
}
-- If `f` is an embedding, we'd expect the fibers of `f` to be
-- propositions, like an injective function.
hasPropFibers : (A → B) → Type _
hasPropFibers f = ∀ y → isProp (fiber f y)
hasPropFibersIsProp : isProp (hasPropFibers f)
hasPropFibersIsProp = propPi (λ _ → isPropIsProp)
isEmbedding→hasPropFibers : isEmbedding f → hasPropFibers f
isEmbedding→hasPropFibers iE y (x , p)
= subst (λ f → isProp f) (lemma₀ p) (isContr→isProp (lemma₁ iE x)) (x , p)
private
fibCong→PathP
: {f : A → B}
→ (p : f w ≡ f x)
→ (fi : fiber (cong f) p)
→ PathP (λ i → fiber f (p i)) (w , refl) (x , refl)
fibCong→PathP p (q , r) i = q i , λ j → r j i
PathP→fibCong
: {f : A → B}
→ (p : f w ≡ f x)
→ (pp : PathP (λ i → fiber f (p i)) (w , refl) (x , refl))
→ fiber (cong f) p
PathP→fibCong p pp = (λ i → fst (pp i)) , (λ j i → snd (pp i) j)
PathP≡fibCong
: {f : A → B}
→ (p : f w ≡ f x)
→ PathP (λ i → fiber f (p i)) (w , refl) (x , refl) ≡ fiber (cong f) p
PathP≡fibCong p
= isoToPath (iso (PathP→fibCong p) (fibCong→PathP p) (λ _ → refl) (λ _ → refl))
hasPropFibers→isEmbedding : hasPropFibers f → isEmbedding f
hasPropFibers→isEmbedding {f = f} iP w x .equiv-proof p
= subst isContr (PathP≡fibCong p) (isProp→isContrPathP (λ i → iP (p i)) fw fx)
where
fw : fiber f (f w)
fw = (w , refl)
fx : fiber f (f x)
fx = (x , refl)
isEmbedding≡hasPropFibers : isEmbedding f ≡ hasPropFibers f
isEmbedding≡hasPropFibers
= isoToPath
(iso isEmbedding→hasPropFibers
hasPropFibers→isEmbedding
(λ _ → hasPropFibersIsProp _ _)
(λ _ → isEmbeddingIsProp _ _))
| 27.984
| 81
| 0.592338
|
df304e1d5f8786c271161f4f8117c2dc807d6937
| 976
|
agda
|
Agda
|
agda-stdlib/src/Data/Fin/Subset/Induction.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/Fin/Subset/Induction.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/Fin/Subset/Induction.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Induction over Subset
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Fin.Subset.Induction where
open import Data.Nat.Base using (ℕ)
open import Data.Nat.Induction using (<-wellFounded)
open import Data.Fin.Subset using (Subset; _⊂_; ∣_∣)
open import Data.Fin.Subset.Properties
open import Induction
open import Induction.WellFounded as WF
------------------------------------------------------------------------
-- Re-export accessability
open WF public using (Acc; acc)
------------------------------------------------------------------------
-- Complete induction based on _⊂_
⊂-Rec : ∀ {n ℓ} → RecStruct (Subset n) ℓ ℓ
⊂-Rec = WfRec _⊂_
⊂-wellFounded : ∀ {n} → WellFounded (_⊂_ {n})
⊂-wellFounded {n} = Subrelation.wellFounded p⊂q⇒∣p∣<∣q∣ (InverseImage.wellFounded ∣_∣ <-wellFounded)
| 31.483871
| 100
| 0.498975
|
2f657fd873efee8d1aa5e836d8beb1fd3755a41a
| 667
|
agda
|
Agda
|
Fields/Orders/Partial/Definition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Fields/Orders/Partial/Definition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Fields/Orders/Partial/Definition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 1
|
2021-11-29T13:23:07.000Z
|
2021-11-29T13:23:07.000Z
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import Rings.Definition
open import Rings.Orders.Partial.Definition
open import Setoids.Setoids
open import Setoids.Orders.Partial.Definition
open import Functions.Definition
open import Fields.Fields
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
module Fields.Orders.Partial.Definition {m n : _} {A : Set m} {S : Setoid {m} {n} A} {_+_ : A → A → A} {_*_ : A → A → A} {R : Ring S _+_ _*_} (F : Field R) where
open Ring R
record PartiallyOrderedField {p} {_<_ : Rel {_} {p} A} (pOrder : SetoidPartialOrder S _<_) : Set (lsuc (m ⊔ n ⊔ p)) where
field
oRing : PartiallyOrderedRing R pOrder
| 35.105263
| 161
| 0.692654
|
1d7f2cfb5c99a798a37ee2d65aa63298db1d097d
| 765
|
agda
|
Agda
|
src/fot/GroupTheory/Base/Consistency/Axioms.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
src/fot/GroupTheory/Base/Consistency/Axioms.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
src/fot/GroupTheory/Base/Consistency/Axioms.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
------------------------------------------------------------------------------
-- Test the consistency of GroupTheory.Base
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- In the module GroupTheory.Base we declare Agda postulates as FOL
-- axioms. We test if it is possible to prove an unprovable theorem
-- from these axioms.
module GroupTheory.Base.Consistency.Axioms where
open import GroupTheory.Base
------------------------------------------------------------------------------
postulate impossible : (d e : G) → d ≡ e
{-# ATP prove impossible #-}
| 34.772727
| 78
| 0.452288
|
3963edfcfe73bf98c6e1f0906f68473485cbe9c5
| 11,110
|
agda
|
Agda
|
BLAS.agda
|
ashinkarov/agda-array
|
584fedb30552f820c0668cedae53ec3d926860b5
|
[
"0BSD"
] | 6
|
2020-05-09T13:53:46.000Z
|
2021-06-15T14:21:32.000Z
|
BLAS.agda
|
ashinkarov/agda-array
|
584fedb30552f820c0668cedae53ec3d926860b5
|
[
"0BSD"
] | null | null | null |
BLAS.agda
|
ashinkarov/agda-array
|
584fedb30552f820c0668cedae53ec3d926860b5
|
[
"0BSD"
] | 1
|
2020-10-12T07:19:48.000Z
|
2020-10-12T07:19:48.000Z
|
{-# OPTIONS --rewriting #-}
open import Array
open import Array.APL using (reduce-1d)
open import Data.Nat as N
open import Data.Nat.Properties
open import Data.Vec as V hiding (_>>=_; _++_)
open import Data.Fin using (Fin; zero; suc; raise; inject+; #_)
open import Relation.Binary.PropositionalEquality
open import Data.Product
open import Function
open import Relation.Nullary
open import Relation.Nullary.Decidable
sum-1d : ∀ {n} → Ar ℕ 1 (n ∷ []) → ℕ
sum-1d v = reduce-1d v _+_ 0
zipw : ∀ {a}{X : Set a}{d s} → (X → X → X) → Ar X d s → Ar X d s → Ar X d s
zipw _⊕_ (imap a) (imap b) = imap λ iv → a iv ⊕ b iv
hd : ∀ {n s : ℕ}{ss : Vec ℕ n} → Ix (suc n) (s ∷ ss) → Fin s
hd ix = ix-lookup ix zero
vec-mat-mul : ∀ {n m} → Ar ℕ 2 (m ∷ n ∷ []) → Ar ℕ 1 (n ∷ []) → Ar ℕ 1 (m ∷ [])
vec-mat-mul (imap a) b = imap λ iv → sum-1d (zipw _*_ (imap λ jv → a (iv ix++ jv)) b)
twice : ∀ {n} → (M : Ar ℕ 2 (n ∷ n ∷ [])) → (V : Ar ℕ 1 (n ∷ [])) → Ar ℕ 1 (n ∷ [])
twice m v = vec-mat-mul m (vec-mat-mul m v)
sum-2d : ∀ {m n} → Ar ℕ 2 (m ∷ n ∷ []) → ℕ
sum-2d (imap a) = sum-1d (imap λ i → sum-1d (imap λ j → a $ i ix++ j))
_+'_ : ∀ {m n} → Fin (1 + m) → Fin (1 + n) → Fin (1 + m + n)
_+'_ {m} {n} zero j = subst Fin (+-suc m n) (raise m j)
_+'_ {suc m} {n} (suc i) j = suc (i +' j)
_+''_ : ∀ {m n} → Fin m → Fin n → Fin (m + n ∸ 1)
_+''_ {suc m} {suc n} zero j = raise m j
_+''_ {suc (suc m)} {suc n} (suc i) j = suc (i +'' j)
_ix+2_ : ∀ {m n k p} → Ix 2 (m ∷ n ∷ []) → Ix 2 (k ∷ p ∷ []) → Ix 2 (m + k ∸ 1 ∷ n + p ∸ 1 ∷ [])
(x₁ ∷ x₂ ∷ []) ix+2 (y₁ ∷ y₂ ∷ []) = x₁ +'' y₁ ∷ (x₂ +'' y₂) ∷ []
conv-2 : ∀ {m n k p} → Ar ℕ 2 (m + k ∷ n + p ∷ []) → Ar ℕ 2 (k ∷ p ∷ []) → Ar ℕ 2 (1 + m ∷ 1 + n ∷ [])
conv-2 {k = k} {p} (imap a) (imap w) = imap (λ iv → sum-2d {m = k} {n = p} (imap λ ov → w ov * a (iv ix+2 ov)))
iterate-1 : ∀ {a}{X : Set a}{n} → (Fin n → X) → (X → X → X) → X → X
iterate-1 {n = zero} f _⊕_ neut = neut
iterate-1 {n = suc n} f _⊕_ neut = f zero ⊕ iterate-1 (f ∘ suc) _⊕_ neut
red-iter : ∀ {a}{X : Set a}{n} → (f : Ix 1 (n ∷ []) → X) → (op : X → X → X) → (neut : X)
→ reduce-1d (imap f) op neut ≡ iterate-1 (λ i → f (i ∷ [])) op neut
red-iter {n = zero} f op neut = refl
red-iter {n = suc n} f op neut = cong (λ x → op _ x) (red-iter (λ iv → f (suc (hd iv) ∷ [])) op neut)
{-# BUILTIN REWRITE _≡_ #-}
{-# REWRITE red-iter #-}
thm : ∀ {n} → (m : Ar ℕ 2 (n ∷ n ∷ []))
→ (v : Ar _ _ (n ∷ []))
→ ∀ iv → unimap (twice m v) iv ≡ {!!}
thm (imap m) (imap v) (i ∷ []) = {!!}
{-
-- Reflection business
open import Reflection
open import Data.List hiding (_++_)
open import Data.Bool
open import Data.Maybe hiding (_>>=_)
open import Data.Unit
defToTerm : Name → Definition → List (Arg Term) → Term
defToTerm _ (function cs) as = pat-lam cs as
defToTerm _ (constructor′ d) as = con d as
defToTerm _ _ _ = unknown
derefImmediate : Term → TC Term
derefImmediate (def f args) = getDefinition f >>= λ f' → return (defToTerm f f' args)
derefImmediate x = return x
--reflectTerm : TC Term
--reflectTerm = (getType (quote f)) >>= λ ty → quoteTC f >>= derefImmediate >>= λ x → checkType x ty
macro
reflect : Term → Term → TC ⊤
reflect f a = derefImmediate f -- (quoteTerm f)
>>= quoteTC >>= unify a
reflect-ty : Name → Type → TC ⊤
reflect-ty f a = getType f >>= quoteTC >>= unify a
r : Term
r = reflect twice
open import Data.String
open import Data.Nat.Show as Ns
open import Data.List as L using (List)
data Prog : Set where
ok : String → Prog
error : String → Prog
record State : Set where
inductive
constructor st
field
vars : List String
defs : List $ String × String
cons : List (String × ((List $ Arg Term) → Prog))
var-lkup : State → ℕ → Prog
var-lkup s n = hlpr (State.vars s) n
where hlpr : _ → _ → _
hlpr [] n = error $ "Variable not found"
hlpr (x ∷ l) zero = ok x
hlpr (x ∷ l) (suc n) = hlpr l n
def-lkup : State → String → Prog
def-lkup ss s = hlpr (State.defs ss) s
where hlpr : _ → _ → _
hlpr [] s = error $ "Definition `" ++ s ++ "' not found"
hlpr ((k , v) ∷ dfs) s with k ≈? s
... | yes p = ok v
... | no ¬p = hlpr dfs s
cons-cont : State → String → List (Arg Term) → Prog
cons-cont ss s args = {!!} {-hlpr (State.cons ss) s args
where hlpr : _ → _ → _ → _
hlpr [] s _ = error $ "Constructor `" ++ s ++ "' not found"
hlpr ((k , f) ∷ cs) s args with k ≈? s
... | yes p = f args
... | no ¬p = hlpr cs s args
-}
infixl 5 _#_
_#_ : Prog → Prog → Prog
ok x # ok y = ok $ x ++ y
error x # _ = error x
_ # error y = error y
l→s : List String → String
l→s [] = ""
l→s (x ∷ l) = x ++ " " ++ l→s l
comp-arglist-mask : State → List (Arg Term) → List Bool → Prog
comp-arglist : State → List (Arg Term) → Prog
comp-clauses : State → List Clause → Prog
_at_ : ∀ {a}{X : Set a} → List X → ℕ → Maybe X
[] at idx = nothing
(x ∷ a) at zero = just x
(x ∷ a) at suc idx = a at idx
unmaybe : ∀ {a}{X : Set a} → List (Maybe X) → Maybe (List X)
unmaybe [] = just []
unmaybe (nothing ∷ xs) = nothing
unmaybe (just x ∷ xs) with unmaybe xs
unmaybe (just x ∷ xs) | nothing = nothing
unmaybe (just x ∷ xs) | just xs' = just $ x ∷ xs'
filter-idx : ∀ {a}{X : Set a} → List X → List ℕ → Maybe (List X)
filter-idx xs idxs = unmaybe $ L.map (xs at_) idxs
_!!_ : ∀ {a}{X : Set a} → (xs : List X) → Fin (L.length xs) → X
[] !! ()
(x ∷ xs) !! zero = x
(x ∷ xs) !! suc i = xs !! i
mk-mask : (n : ℕ) → List (Fin n) → List Bool
mk-mask n xs = V.toList $ go (V.replicate {n = n} false) xs
where go : _ → _ → _
go e [] = e
go e (x ∷ xs) = go (updateAt x (λ _ → true) e) xs
compile : State → Term → Prog
compile s (var x args) = ok "V(" # var-lkup s x # ok " " # comp-arglist s args # ok ")"
compile s (con c args) with (showName c)
compile s (con c args) | "Data.Vec.Base.Vec.[]" = ok "nil"
compile s (con c args) | "Array.Base.Ix.[]" = ok "nil"
compile s (con c args) | "Data.Vec.Base.Vec._∷_" =
ok "(cons " # comp-arglist-mask s args (mk-mask 5 $ # 3 ∷ # 4 ∷ []) # ok ")"
compile s (con c args) | "Array.Base.Ix._∷_" =
ok "(cons " # comp-arglist-mask s args (mk-mask 5 $ # 3 ∷ # 4 ∷ []) # ok ")"
compile s (con c args) | _ = ok ("C(" ++ showName c ++ " ") # comp-arglist s args # ok ")"
compile s (def f args) with def-lkup s $ showName f
... | error _ = ok "D(" # ok (showName f) # ok " " # comp-arglist s args
... | d = ok "D(" # d # ok " "
# comp-arglist s args # ok ")"
compile s (lam v (abs w x)) = ok ("(\\ " ++ w ++ " -> ") # compile (record s {vars = (w ∷ State.vars s)}) x # ok ")"
compile s (pat-lam cs []) = ok "PAT-LAM (cl = " # comp-clauses s cs # ok ")" --(args = " # comp-arglist s args # ok ")"
compile s (pat-lam cs _) = error "PAT-LAM: I don't know what args to pat-lam are"
compile s (pi a b) = ok "PI TYPE"
compile s (sort _) = ok "SORT"
compile s (lit x) = ok $ showLiteral x
compile s (meta x x₁) = ok "META"
compile s unknown = ok "_" -- "UNKNOWN"
comp-arglist s [] = ok ""
comp-arglist s (arg i x ∷ l) = compile s x # ok " " # comp-arglist s l
comp-arglist-mask s [] [] = ok ""
comp-arglist-mask s [] (x ∷ mask) = error "Incorrect argument mask"
comp-arglist-mask s (x ∷ args) [] = error "Incorrect argument mask"
comp-arglist-mask s (x ∷ args) (false ∷ mask) = comp-arglist-mask s args mask
comp-arglist-mask s (arg i x ∷ args) (true ∷ mask) = compile s x # ok " " # comp-arglist-mask s args mask
comp-pats : List (Arg Pattern) → List String
comp-pats [] = []
comp-pats (vArg (var x) ∷ l) = x ∷ comp-pats l
comp-pats (vArg _ ∷ l) = "_" ∷ comp-pats l
comp-pats (_ ∷ l) = "_" ∷ comp-pats l
comp-clauses s [] = ok ""
comp-clauses s (clause ps t ∷ cs) = let
vars = comp-pats ps
in ok ("pats = " ++ l→s vars) # compile (record s {vars = (L.reverse vars L.++ State.vars s)}) t
comp-clauses s (absurd-clause ps ∷ cs) = error "absurd clause found"
test : ∀ {n} (m : Ix 2 (n ∷ n ∷ []) → ℕ) (v : Ix 1 (n ∷ []) → ℕ)
(i : Fin n) → ℕ
test m v i = iterate-1
(λ i₁ →
m (i ∷ i₁ ∷ []) *
iterate-1 (λ i₂ → m (i₁ ∷ i₂ ∷ []) * v (i₂ ∷ [])) _+_ 0)
_+_ 0
bltin-defs : List $ String × String
bltin-defs = ("Agda.Builtin.Nat.Nat" , "nat")
∷ ("Agda.Builtin.Nat._+_" , "plus")
∷ ("Agda.Builtin.Nat._*_" , "mult")
∷ ("Agda.Primitive.lzero" , "tt")
∷ ("BLAS.iterate-1" , "for-loop-acc")
∷ []
bltin-cons : List (String × (List (Arg Term) → Prog))
bltin-cons = ("Data.Vec.Base.Vec.[]" , λ _ → ok "nil")
∷ ("Array.Base.Ix.[]" , λ _ → ok "nil")
∷ ("Array.Base.Ix._∷_" , λ args → {!!})
∷ []
ct = compile (st [] bltin-defs []) (reflect test)
foo : ∀ {n : ℕ} (a b : ℕ) → ℕ
foo x = _+ x
cr = compile (st [] bltin-defs []) (reflect foo)
cconv = compile (st [] bltin-defs []) (reflect conv-2)
-}
--t : Term
--t = reflect-ty (thm)
-- PAT-LAM (cl = pats = _ m v i D(BLAS.iterate-1 D(Agda.Primitive.lzero ) D(Agda.Builtin.Nat.Nat ) V(i )
-- (\\ i₁ -> D(Agda.Builtin.Nat._*_
-- V(v C(Array.Base.Ix._∷_ 1 C(Data.Vec.Base.Vec._∷_ UNKNOWN UNKNOWN 0 V(i ) C(Data.Vec.Base.Vec.[] UNKNOWN UNKNOWN ) )
-- V(i )
-- V(_ )
-- C(Array.Base.Ix._∷_ 0 C(Data.Vec.Base.Vec.[] UNKNOWN UNKNOWN ) V(i ) V(i₁ ) C(Array.Base.Ix.[] ) ) ) )
-- D(BLAS.iterate-1 D(Agda.Primitive.lzero ) D(Agda.Builtin.Nat.Nat ) V(i )
-- (\\ i₂ -> D(Agda.Builtin.Nat._*_
-- V(v C(Array.Base.Ix._∷_ 1 C(Data.Vec.Base.Vec._∷_ UNKNOWN UNKNOWN 0 V(i ) C(Data.Vec.Base.Vec.[] UNKNOWN UNKNOWN ) )
-- V(i )
-- V(i₁ )
-- C(Array.Base.Ix._∷_ 0 C(Data.Vec.Base.Vec.[] UNKNOWN UNKNOWN )
-- V(i ) V(i₂ ) C(Array.Base.Ix.[] ) ) ) )
-- V(m C(Array.Base.Ix._∷_ 0 C(Data.Vec.Base.Vec.[] UNKNOWN UNKNOWN ) V(i ) V(i₂ ) C(Array.Base.Ix.[] ) ) ) ))
-- D(Agda.Builtin.Nat._+_ ) 0 ) ))
-- D(Agda.Builtin.Nat._+_ ) 0 )) (args = )
--compld _ m v i = D(for-loop-acc D(tt ) D(nat ) V(_ )
-- (\\ i₁ -> D(mult V(m (cons V(i ) (cons V(i₁ ) nil ) ) )
-- D(for-loop-acc D(tt ) D(nat ) V(_ )
-- (\\ i₂ -> D(mult V(m (cons V(i₁ ) (cons V(i₂ ) nil ) ) )
-- V(v (cons V(i₂ ) nil ) ) ))
-- D(plus ) 0 ) ))
-- D(plus ) 0 )
-- A * v = { i → Σ Aᵢ×v }
-- A * A * v = { i → Σ Aᵢ×v }
| 35.608974
| 155
| 0.488569
|
2f3d8f69983ebbbfdb77b9f330f74d67ccb09bd3
| 4,344
|
agda
|
Agda
|
Ex3Lec.agda
|
clarkdm/CS410
|
523a8749f49c914bcd28402116dcbe79a78dbbf4
|
[
"CC0-1.0"
] | null | null | null |
Ex3Lec.agda
|
clarkdm/CS410
|
523a8749f49c914bcd28402116dcbe79a78dbbf4
|
[
"CC0-1.0"
] | null | null | null |
Ex3Lec.agda
|
clarkdm/CS410
|
523a8749f49c914bcd28402116dcbe79a78dbbf4
|
[
"CC0-1.0"
] | null | null | null |
module Ex3Lec where
----------------------------------------------------------------------------
-- EXERCISE 3 -- MONADS FOR HUTTON'S RAZOR
--
-- VALUE: 15%
-- DEADLINE: 5pm, Friday 20 November (week 9)
--
-- DON'T SUBMIT, COMMIT!
--
-- The purpose of this exercise is to introduce you to some useful
-- mathematical structures and build good tools for working with
-- vectors
----------------------------------------------------------------------------
open import CS410-Prelude
open import CS410-Monoid
open import CS410-Nat
open import CS410-Vec
open import CS410-Functor
-- HINT: your tasks are heralded with the eminently searchable tag, "???"
----------------------------------------------------------------------------
-- HUTTON'S RAZOR
----------------------------------------------------------------------------
HVal : Set -- the set of *values* for Hutton's Razor
HVal = Two + Nat -- Booleans or natural numbers
foo : HVal
foo = tt , ff
goo : HVal
goo = ff , 42
data HExp (X : Set) : Set where
var : X -> HExp X -- variables
val : HVal -> HExp X -- values
_+H_ _>=H_ : (e1 e2 : HExp X) -> HExp X -- addition, comparison
ifH_then_else_ : (e1 e2 e3 : HExp X) -> HExp X -- conditional
_>=2_ : Nat -> Nat -> Two
x >=2 zero = tt
zero >=2 suc _ = ff
suc m >=2 suc n = m >=2 n
----------------------------------------------------------------------------
-- ??? 3.1 the HExp syntax-with-substitution monad (score: ? / 2)
----------------------------------------------------------------------------
-- Show that HExp is a monad, where the "bind" operation performs
-- simultaneous substitution (transforming all the variables in a term).
hExpMonad : Monad HExp
hExpMonad = record { return = {!!} ; _>>=_ = {!!} }
----------------------------------------------------------------------------
-- ??? 3.2 the error management monad (score: ? / 1)
----------------------------------------------------------------------------
-- show that "+ E" is monadic, generalising the "Maybe" monad by allowing
-- some sort of error report
errorMonad : (E : Set) -> Monad \ V -> V + E -- "value or error"
errorMonad E = {!!}
----------------------------------------------------------------------------
-- ??? 3.3 the environment monad transformer (score: ? / 1)
----------------------------------------------------------------------------
-- show that "+ E" is monadic, generalising the "Maybe" monad by allowing
-- some sort of error report
envMonad : (G : Set){M : Set -> Set} -> Monad M ->
Monad \ V -> G -> M V -- "computation in an environment"
envMonad G MM = {!!} where
open Monad MM
----------------------------------------------------------------------------
-- ??? 3.4 interpreting Hutton's Razor (score: ? / 3)
----------------------------------------------------------------------------
-- Implement an interpreter for Hutton's Razor.
-- You will need to construct a type to represent possible run-time errors.
-- Ensure that addition and comparison act on numbers, not Booleans.
-- Ensure that the condition in an "if" is a Boolean, not a number.
data InterpretError : Set where
-- helpful things to build
Env : Set -> Set -- an environment for a given set of variables
Env X = X -> HVal
Compute : Set{- variables -} -> Set{- values -} -> Set
Compute X V = Env X -> V + InterpretError -- how to compute a V
computeMonad : {X : Set} -> Monad (Compute X)
computeMonad = {!!} -- build this from the above parts
-- This operation should explain how to get the value of a variable
-- from the environment.
varVal : {X : Set} -> X -> Compute X HVal
varVal x = {!!}
-- These operations should ensure that you get the sort of value
-- that you want, in order to ensure that you don't do bogus
-- computation.
mustBeNat : {X : Set} -> HVal -> Compute X Nat
mustBeNat v = {!!}
mustBeTwo : {X : Set} -> HVal -> Compute X Two
mustBeTwo v = {!!}
-- Now, you're ready to go. Don't introduce the environent explicitly.
-- Use the monad to thread it.
interpret : {X : Set} -> HExp X -> Compute X HVal
interpret {X} = go where
open Monad (envMonad (Env X) (errorMonad InterpretError))
go : HExp X -> Env X -> HVal + InterpretError
go t = {!!}
| 33.674419
| 77
| 0.494015
|
31b185c8a2eb857236d9c0a567722d1f15470a0c
| 11,864
|
agda
|
Agda
|
Cubical/Algebra/Group/MorphismProperties.agda
|
mchristianl/cubical
|
cc6ad25d5ffbe4f20ea7020474f266d24b97caa0
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/Group/MorphismProperties.agda
|
mchristianl/cubical
|
cc6ad25d5ffbe4f20ea7020474f266d24b97caa0
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/Group/MorphismProperties.agda
|
mchristianl/cubical
|
cc6ad25d5ffbe4f20ea7020474f266d24b97caa0
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.Group.MorphismProperties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.SIP
open import Cubical.Foundations.Function using (_∘_)
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Functions.Embedding
open import Cubical.Data.Sigma
open import Cubical.Structures.Axioms
open import Cubical.Structures.Pointed
open import Cubical.Algebra.Semigroup
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.Group.Base
open import Cubical.Algebra.Group.Properties
open import Cubical.Algebra.Group.Morphism
private
variable
ℓ ℓ' ℓ'' : Level
open Iso
open GroupStr
open GroupHom
isPropIsGroupHom : (G : Group {ℓ}) (H : Group {ℓ'}) {f : ⟨ G ⟩ → ⟨ H ⟩} → isProp (isGroupHom G H f)
isPropIsGroupHom G H {f} = isPropΠ2 λ a b → GroupStr.is-set (snd H) _ _
isSetGroupHom : {G : Group {ℓ}} {H : Group {ℓ'}} → isSet (GroupHom G H)
isSetGroupHom {G = G} {H = H} = isOfHLevelRespectEquiv 2 equiv (isSetΣ (isSetΠ λ _ → is-set (snd H)) λ _ → isProp→isSet (isPropIsGroupHom G H)) where
equiv : (Σ[ g ∈ (⟨ G ⟩ → ⟨ H ⟩) ] (isGroupHom G H g)) ≃ (GroupHom G H)
equiv = isoToEquiv (iso (λ (g , m) → grouphom g m) (λ hom → fun hom , isHom hom) (λ _ → refl) λ _ → refl)
-- Morphism composition
isGroupHomComp : {F : Group {ℓ}} {G : Group {ℓ'}} {H : Group {ℓ''}} →
(f : GroupHom F G) → (g : GroupHom G H) → isGroupHom F H (fun g ∘ fun f)
isGroupHomComp f g x y = cong (fun g) (isHom f _ _) ∙ isHom g _ _
compGroupHom : {F : Group {ℓ}} {G : Group {ℓ'}} {H : Group {ℓ''}} → GroupHom F G → GroupHom G H → GroupHom F H
fun (compGroupHom f g) = fun g ∘ fun f
isHom (compGroupHom f g) = isGroupHomComp f g
open GroupEquiv
compGroupEquiv : {F : Group {ℓ}} {G : Group {ℓ'}} {H : Group {ℓ''}} → GroupEquiv F G → GroupEquiv G H → GroupEquiv F H
eq (compGroupEquiv f g) = compEquiv (eq f) (eq g)
isHom (compGroupEquiv f g) = isHom (compGroupHom (hom f) (hom g))
idGroupEquiv : (G : Group {ℓ}) → GroupEquiv G G
eq (idGroupEquiv G) = idEquiv ⟨ G ⟩
isHom (idGroupEquiv G) = λ _ _ → refl
-- Isomorphism inversion
isGroupHomInv : {G : Group {ℓ}} {H : Group {ℓ'}} (f : GroupEquiv G H) → isGroupHom H G (invEq (GroupEquiv.eq f))
isGroupHomInv {G = G} {H = H} f h h' = isInj-f _ _ (
f' (g (h ⋆² h')) ≡⟨ retEq (eq f) _ ⟩
(h ⋆² h') ≡⟨ sym (cong₂ _⋆²_ (retEq (eq f) h) (retEq (eq f) h')) ⟩
(f' (g h) ⋆² f' (g h')) ≡⟨ sym (isHom (hom f) _ _) ⟩
f' (g h ⋆¹ g h') ∎)
where
f' = fst (eq f)
_⋆¹_ = _+_ (snd G)
_⋆²_ = _+_ (snd H)
g = invEq (eq f)
isInj-f : (x y : ⟨ G ⟩) → f' x ≡ f' y → x ≡ y
isInj-f x y = invEq (_ , isEquiv→isEmbedding (snd (eq f)) x y)
invGroupEquiv : {G : Group {ℓ}} {H : Group {ℓ'}} → GroupEquiv G H → GroupEquiv H G
eq (invGroupEquiv f) = invEquiv (eq f)
isHom (invGroupEquiv f) = isGroupHomInv f
dirProdEquiv : ∀ {ℓ ℓ' ℓ'' ℓ'''} {A : Group {ℓ}} {B : Group {ℓ'}} {C : Group {ℓ''}} {D : Group {ℓ'''}}
→ GroupEquiv A C → GroupEquiv B D
→ GroupEquiv (dirProd A B) (dirProd C D)
eq (dirProdEquiv eq1 eq2) = ≃-× (eq eq1) (eq eq2)
isHom (dirProdEquiv eq1 eq2) = isHom (×hom (GroupEquiv.hom eq1) (GroupEquiv.hom eq2))
groupHomEq : {G : Group {ℓ}} {H : Group {ℓ'}} {f g : GroupHom G H} → (fun f ≡ fun g) → f ≡ g
fun (groupHomEq p i) = p i
isHom (groupHomEq {G = G} {H = H} {f = f} {g = g} p i) = p-hom i
where
p-hom : PathP (λ i → isGroupHom G H (p i)) (isHom f) (isHom g)
p-hom = toPathP (isPropIsGroupHom G H _ _)
groupEquivEq : {G : Group {ℓ}} {H : Group {ℓ'}} {f g : GroupEquiv G H} → (eq f ≡ eq g) → f ≡ g
eq (groupEquivEq {G = G} {H = H} {f} {g} p i) = p i
isHom (groupEquivEq {G = G} {H = H} {f} {g} p i) = p-hom i
where
p-hom : PathP (λ i → isGroupHom G H (p i .fst)) (isHom f) (isHom g)
p-hom = toPathP (isPropIsGroupHom G H _ _)
module GroupΣTheory {ℓ} where
RawGroupStructure : Type ℓ → Type ℓ
RawGroupStructure = SemigroupΣTheory.RawSemigroupStructure
RawGroupEquivStr : StrEquiv RawGroupStructure _
RawGroupEquivStr = SemigroupΣTheory.RawSemigroupEquivStr
rawGroupUnivalentStr : UnivalentStr RawGroupStructure _
rawGroupUnivalentStr = SemigroupΣTheory.rawSemigroupUnivalentStr
-- The neutral element and the inverse function will be derived from the
-- axioms, instead of being defined in the RawGroupStructure in order
-- to have that group equivalences are equivalences that preserves
-- multiplication (so we don't have to show that they also preserve inversion
-- and neutral element, although they will preserve them).
GroupAxioms : (G : Type ℓ) → RawGroupStructure G → Type ℓ
GroupAxioms G _·_ =
IsSemigroup _·_
× (Σ[ e ∈ G ] ((x : G) → (x · e ≡ x) × (e · x ≡ x))
× ((x : G) → Σ[ x' ∈ G ] (x · x' ≡ e) × (x' · x ≡ e)))
GroupStructure : Type ℓ → Type ℓ
GroupStructure = AxiomsStructure RawGroupStructure GroupAxioms
GroupΣ : Type (ℓ-suc ℓ)
GroupΣ = TypeWithStr ℓ GroupStructure
-- Structured equivalences for groups are those for monoids (but different axioms)
GroupEquivStr : StrEquiv GroupStructure ℓ
GroupEquivStr = AxiomsEquivStr RawGroupEquivStr GroupAxioms
open MonoidTheory
isSetGroupΣ : (G : GroupΣ)
→ isSet _
isSetGroupΣ (_ , _ , (isSemigroup-G , _ , _)) = IsSemigroup.is-set isSemigroup-G
isPropGroupAxioms : (G : Type ℓ)
→ (s : RawGroupStructure G)
→ isProp (GroupAxioms G s)
isPropGroupAxioms G _+_ = isPropΣ (isPropIsSemigroup _) γ
where
γ : (h : IsSemigroup _+_) →
isProp (Σ[ e ∈ G ] ((x : G) → (x + e ≡ x) × (e + x ≡ x))
× ((x : G) → Σ[ x' ∈ G ] (x + x' ≡ e) × (x' + x ≡ e)))
γ h (e , P , _) (e' , Q , _) =
Σ≡Prop (λ x → isPropΣ (isPropΠ λ _ → isProp× ((IsSemigroup.is-set h) _ _) ((IsSemigroup.is-set h) _ _)) (β x))
(sym (fst (Q e)) ∙ snd (P e'))
where
β : (e : G) → ((x : G) → (x + e ≡ x) × (e + x ≡ x))
→ isProp ((x : G) → Σ[ x' ∈ G ] (x + x' ≡ e) × (x' + x ≡ e))
β e He =
isPropΠ λ { x (x' , _ , P) (x'' , Q , _) →
Σ≡Prop (λ _ → isProp× ((IsSemigroup.is-set h) _ _) ((IsSemigroup.is-set h) _ _))
(inv-lemma ℳ x x' x'' P Q) }
where
ℳ : Monoid
ℳ = makeMonoid e _+_ (IsSemigroup.is-set h) (IsSemigroup.assoc h) (λ x → He x .fst) (λ x → He x .snd)
Group→GroupΣ : Group → GroupΣ
Group→GroupΣ (G , GS) = _ , _ , (isSemigroup GS , _ , identity GS , λ x → (- GS) x , inverse GS x)
GroupΣ→Group : GroupΣ → Group
GroupΣ→Group (G , _ , SG , _ , H0g , invertible ) =
group _ _ _ (λ x → invertible x .fst) (isgroup (ismonoid SG H0g) λ x → invertible x .snd)
GroupIsoGroupΣ : Iso Group GroupΣ
GroupIsoGroupΣ = iso Group→GroupΣ GroupΣ→Group (λ _ → refl) (λ _ → refl)
groupUnivalentStr : UnivalentStr GroupStructure GroupEquivStr
groupUnivalentStr = axiomsUnivalentStr _ isPropGroupAxioms rawGroupUnivalentStr
GroupΣPath : (G H : GroupΣ) → (G ≃[ GroupEquivStr ] H) ≃ (G ≡ H)
GroupΣPath = SIP groupUnivalentStr
GroupEquivΣ : (G H : Group) → Type ℓ
GroupEquivΣ G H = Group→GroupΣ G ≃[ GroupEquivStr ] Group→GroupΣ H
GroupIsoΣPath : {G H : Group} → Iso (GroupEquiv G H) (GroupEquivΣ G H)
fun GroupIsoΣPath f = (eq f) , isHom f
inv GroupIsoΣPath (e , h) = groupequiv e h
rightInv GroupIsoΣPath _ = refl
leftInv GroupIsoΣPath _ = refl
GroupPath : (G H : Group) → (GroupEquiv G H) ≃ (G ≡ H)
GroupPath G H =
GroupEquiv G H ≃⟨ isoToEquiv GroupIsoΣPath ⟩
GroupEquivΣ G H ≃⟨ GroupΣPath _ _ ⟩
Group→GroupΣ G ≡ Group→GroupΣ H ≃⟨ isoToEquiv (invIso (congIso GroupIsoGroupΣ)) ⟩
G ≡ H ■
RawGroupΣ : Type (ℓ-suc ℓ)
RawGroupΣ = TypeWithStr ℓ RawGroupStructure
Group→RawGroupΣ : Group → RawGroupΣ
Group→RawGroupΣ (G , GS) = G , _+_ GS
InducedGroup : (G : Group) (H : RawGroupΣ) (e : ⟨ G ⟩ ≃ H .fst)
→ RawGroupEquivStr (Group→RawGroupΣ G) H e → Group
InducedGroup G H e r =
GroupΣ→Group (transferAxioms rawGroupUnivalentStr (Group→GroupΣ G) H (e , r))
InducedGroupPath : (G : Group {ℓ}) (H : RawGroupΣ) (e : ⟨ G ⟩ ≃ H .fst)
(E : RawGroupEquivStr (Group→RawGroupΣ G) H e)
→ G ≡ InducedGroup G H e E
InducedGroupPath G H e E =
GroupPath G (InducedGroup G H e E) .fst (groupequiv e E)
-- Extract the characterization of equality of groups
GroupPath : (G H : Group {ℓ}) → (GroupEquiv G H) ≃ (G ≡ H)
GroupPath = GroupΣTheory.GroupPath
InducedGroup : (G : Group {ℓ}) (H : GroupΣTheory.RawGroupΣ) (e : ⟨ G ⟩ ≃ H .fst)
→ GroupΣTheory.RawGroupEquivStr (GroupΣTheory.Group→RawGroupΣ G) H e
→ Group
InducedGroup = GroupΣTheory.InducedGroup
InducedGroupPath : (G : Group {ℓ}) (H : GroupΣTheory.RawGroupΣ) (e : ⟨ G ⟩ ≃ H .fst)
(E : GroupΣTheory.RawGroupEquivStr (GroupΣTheory.Group→RawGroupΣ G) H e)
→ G ≡ InducedGroup G H e E
InducedGroupPath = GroupΣTheory.InducedGroupPath
uaGroup : {G H : Group {ℓ}} → GroupEquiv G H → G ≡ H
uaGroup {G = G} {H = H} = equivFun (GroupPath G H)
carac-uaGroup : {G H : Group {ℓ}} (f : GroupEquiv G H) → cong ⟨_⟩ (uaGroup f) ≡ ua (GroupEquiv.eq f)
carac-uaGroup f = ua (eq f) ∙ refl ≡⟨ sym (rUnit _) ⟩
ua (eq f) ∎
-- Group-ua functoriality
Group≡ : (G H : Group {ℓ}) → (
Σ[ p ∈ ⟨ G ⟩ ≡ ⟨ H ⟩ ]
Σ[ q ∈ PathP (λ i → p i) (0g (snd G)) (0g (snd H)) ]
Σ[ r ∈ PathP (λ i → p i → p i → p i) (_+_ (snd G)) (_+_ (snd H)) ]
Σ[ s ∈ PathP (λ i → p i → p i) (- snd G) (- snd H) ]
PathP (λ i → IsGroup (q i) (r i) (s i)) (isGroup (snd G)) (isGroup (snd H)))
≃ (G ≡ H)
Group≡ G H = isoToEquiv theIso
where
theIso : Iso _ _
fun theIso (p , q , r , s , t) i = p i , groupstr (q i) (r i) (s i) (t i)
inv theIso x = cong ⟨_⟩ x , cong (0g ∘ snd) x , cong (_+_ ∘ snd) x , cong (-_ ∘ snd) x , cong (isGroup ∘ snd) x
rightInv theIso _ = refl
leftInv theIso _ = refl
caracGroup≡ : {G H : Group {ℓ}} (p q : G ≡ H) → cong ⟨_⟩ p ≡ cong ⟨_⟩ q → p ≡ q
caracGroup≡ {G = G} {H = H} p q P = sym (transportTransport⁻ (ua (Group≡ G H)) p)
∙∙ cong (transport (ua (Group≡ G H))) helper
∙∙ transportTransport⁻ (ua (Group≡ G H)) q
where
helper : transport (sym (ua (Group≡ G H))) p ≡ transport (sym (ua (Group≡ G H))) q
helper = Σ≡Prop
(λ _ → isPropΣ
(isOfHLevelPathP' 1 (is-set (snd H)) _ _)
λ _ → isPropΣ (isOfHLevelPathP' 1 (isSetΠ2 λ _ _ → is-set (snd H)) _ _)
λ _ → isPropΣ (isOfHLevelPathP' 1 (isSetΠ λ _ → is-set (snd H)) _ _)
λ _ → isOfHLevelPathP 1 (isPropIsGroup _ _ _) _ _)
(transportRefl (cong ⟨_⟩ p) ∙ P ∙ sym (transportRefl (cong ⟨_⟩ q)))
uaGroupId : (G : Group {ℓ}) → uaGroup (idGroupEquiv G) ≡ refl
uaGroupId G = caracGroup≡ _ _ (carac-uaGroup (idGroupEquiv G) ∙ uaIdEquiv)
uaCompGroupEquiv : {F G H : Group {ℓ}} (f : GroupEquiv F G) (g : GroupEquiv G H) → uaGroup (compGroupEquiv f g) ≡ uaGroup f ∙ uaGroup g
uaCompGroupEquiv f g = caracGroup≡ _ _ (
cong ⟨_⟩ (uaGroup (compGroupEquiv f g))
≡⟨ carac-uaGroup (compGroupEquiv f g) ⟩
ua (eq (compGroupEquiv f g))
≡⟨ uaCompEquiv _ _ ⟩
ua (eq f) ∙ ua (eq g)
≡⟨ cong (_∙ ua (eq g)) (sym (carac-uaGroup f)) ⟩
cong ⟨_⟩ (uaGroup f) ∙ ua (eq g)
≡⟨ cong (cong ⟨_⟩ (uaGroup f) ∙_) (sym (carac-uaGroup g)) ⟩
cong ⟨_⟩ (uaGroup f) ∙ cong ⟨_⟩ (uaGroup g)
≡⟨ sym (cong-∙ ⟨_⟩ (uaGroup f) (uaGroup g)) ⟩
cong ⟨_⟩ (uaGroup f ∙ uaGroup g) ∎) where
open GroupEquiv
| 42.070922
| 149
| 0.600135
|
d0af7257e32b10848d04ecb3f0fdadf348b9f207
| 404
|
agda
|
Agda
|
stdlib-exts/Data/Vec/Exts.agda
|
WhatisRT/meta-cedille
|
62fa6f36e4555360d94041113749bbb6d291691c
|
[
"MIT"
] | 35
|
2019-06-13T07:44:50.000Z
|
2021-10-12T22:59:10.000Z
|
stdlib-exts/Data/Vec/Exts.agda
|
WhatisRT/meta-cedille
|
62fa6f36e4555360d94041113749bbb6d291691c
|
[
"MIT"
] | 10
|
2019-06-13T17:44:43.000Z
|
2020-04-25T15:29:17.000Z
|
stdlib-exts/Data/Vec/Exts.agda
|
WhatisRT/meta-cedille
|
62fa6f36e4555360d94041113749bbb6d291691c
|
[
"MIT"
] | 2
|
2019-06-27T23:12:48.000Z
|
2021-10-20T10:46:20.000Z
|
module Data.Vec.Exts where
open import Data.Fin
open import Data.Maybe
open import Data.Nat
open import Data.Vec using (Vec; []; _∷_)
open import Relation.Nullary
open import Relation.Unary
open import Data.Vec.Relation.Unary.Any
findIndex : {n : ℕ} {A : Set} {P : A -> Set} -> Decidable P -> Vec A n -> Maybe (Fin n)
findIndex P? xs with any? P? xs
... | yes ix = just (index ix)
... | no _ = nothing
| 26.933333
| 87
| 0.680693
|
12dfbaef6f703c7485e9f11ff3aa1d8d49e7b16d
| 1,080
|
agda
|
Agda
|
agda-stdlib/src/Codata/Conat/Properties.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Codata/Conat/Properties.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Codata/Conat/Properties.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties for Conats
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe --sized-types #-}
module Codata.Conat.Properties where
open import Size
open import Data.Nat.Base using (ℕ; zero; suc)
open import Codata.Thunk
open import Codata.Conat
open import Codata.Conat.Bisimilarity
open import Function
open import Relation.Nullary
open import Relation.Nullary.Decidable using (map′)
open import Relation.Binary
private
variable
i : Size
0∸m≈0 : ∀ m → i ⊢ zero ∸ m ≈ zero
0∸m≈0 zero = refl
0∸m≈0 (suc m) = 0∸m≈0 m
sℕ≤s⁻¹ : ∀ {m n} → suc m ℕ≤ suc n → m ℕ≤ n .force
sℕ≤s⁻¹ (sℕ≤s p) = p
_ℕ≤?_ : Decidable _ℕ≤_
zero ℕ≤? n = yes zℕ≤n
suc m ℕ≤? zero = no (λ ())
suc m ℕ≤? suc n = map′ sℕ≤s sℕ≤s⁻¹ (m ℕ≤? n .force)
0ℕ+-identity : ∀ {n} → i ⊢ 0 ℕ+ n ≈ n
0ℕ+-identity = refl
+ℕ0-identity : ∀ {n} → i ⊢ n +ℕ 0 ≈ n
+ℕ0-identity {n = zero} = zero
+ℕ0-identity {n = suc n} = suc λ where .force → +ℕ0-identity
| 25.116279
| 72
| 0.548148
|
4a3e1bbe23385d1d1181721ce5116d801f9123df
| 4,656
|
agda
|
Agda
|
ch8.agda
|
asajeffrey/tapl
|
de2ae6c24d001b85a5032c9e06cc731557dbc5e5
|
[
"CC0-1.0"
] | 3
|
2021-03-12T22:44:19.000Z
|
2021-03-15T12:09:59.000Z
|
ch8.agda
|
asajeffrey/tapl
|
de2ae6c24d001b85a5032c9e06cc731557dbc5e5
|
[
"CC0-1.0"
] | null | null | null |
ch8.agda
|
asajeffrey/tapl
|
de2ae6c24d001b85a5032c9e06cc731557dbc5e5
|
[
"CC0-1.0"
] | null | null | null |
open import prelude
-- Copied pretty much verbatim
data Term : Set where
true : Term
false : Term
if_then_else_end : Term → Term → Term → Term
zero : Term
succ : Term → Term
iszero : Term → Term
data NValue : Term → Set where
zero : NValue zero
succ : ∀ {t} → NValue(t) → NValue(succ t)
data Value : Term → Set where
true : Value true
false : Value false
nv : ∀ {t} → NValue(t) → Value(t)
data _⟶_ : Term → Term → Set where
E─IfTrue : ∀ {t₂ t₃} →
-----------------------------------
if true then t₂ else t₃ end ⟶ t₂
E─IfFalse : ∀ {t₂ t₃} →
-----------------------------------
if false then t₂ else t₃ end ⟶ t₃
E─IfCong : ∀ {t₁ t₁′ t₂ t₃} →
(t₁ ⟶ t₁′) →
----------------------------------------------------------
(if t₁ then t₂ else t₃ end ⟶ if t₁′ then t₂ else t₃ end)
E─SuccCong : ∀ {t₁ t₁′} →
(t₁ ⟶ t₁′) →
----------------------
(succ t₁ ⟶ succ t₁′)
E─IsZero :
----------------------
(iszero zero ⟶ true)
E─IsSucc : ∀ {n} →
--------------------------
(iszero (succ n) ⟶ false)
E─IsCong : ∀ {t₁ t₁′} →
(t₁ ⟶ t₁′) →
--------------------------
(iszero t₁ ⟶ iszero t₁′)
data Redex : Term → Set where
redex : ∀ {t t′} →
t ⟶ t′ →
--------
Redex(t)
-- Types
data Type : Set where
bool : Type
nat : Type
data _∈_ : Term → Type → Set where
T-True :
-----------
true ∈ bool
T-False :
-----------
false ∈ bool
T-If : ∀ {t₁ t₂ t₃ T} →
t₁ ∈ bool →
t₂ ∈ T →
t₃ ∈ T →
-----------------------------
if t₁ then t₂ else t₃ end ∈ T
T-Zero :
----------
zero ∈ nat
T-Succ : ∀ {t₁} →
t₁ ∈ nat →
-------------
succ t₁ ∈ nat
T-IsZero : ∀ {t₁} →
t₁ ∈ nat →
-------------
iszero t₁ ∈ bool
-- Proving that well-typed terms stay well-typed
preservation : ∀ {t t′ T} → (t ∈ T) → (t ⟶ t′) → (t′ ∈ T)
preservation (T-If p₁ p₂ p₃) E─IfTrue = p₂
preservation (T-If p₁ p₂ p₃) E─IfFalse = p₃
preservation (T-If p₁ p₂ p₃) (E─IfCong q) = T-If (preservation p₁ q) p₂ p₃
preservation (T-Succ p) (E─SuccCong q) = T-Succ (preservation p q)
preservation (T-IsZero p) E─IsZero = T-True
preservation (T-IsZero p) E─IsSucc = T-False
preservation (T-IsZero p) (E─IsCong q) = T-IsZero (preservation p q)
-- Proving that every term is a value or a redex
data ValueOrRedex : Term → Set where
value : ∀ {t} →
(Value(t)) →
---------------
ValueOrRedex(t)
redex : ∀ {t t′} →
t ⟶ t′ →
---------------
ValueOrRedex(t)
progress : ∀ {t T} → (t ∈ T) → ValueOrRedex(t)
progress T-True = value true
progress T-False = value false
progress (T-If p₁ p₂ p₃) = helper (progress p₁) p₁ where
helper : ∀ {t₀ t₁ t₂} → ValueOrRedex(t₀) → t₀ ∈ bool → ValueOrRedex(if t₀ then t₁ else t₂ end)
helper (value true) p = redex E─IfTrue
helper (value false) p = redex E─IfFalse
helper (redex r) p = redex (E─IfCong r)
helper (value (nv ())) T-True
helper (value (nv ())) T-False
helper (value (nv ())) (T-If p p₁ p₂)
progress T-Zero = value (nv zero)
progress (T-Succ p) = helper (progress p) p where
helper : ∀ {t₀} → ValueOrRedex(t₀) → t₀ ∈ nat → ValueOrRedex(succ t₀)
helper (value (nv n)) p = value (nv (succ n))
helper (redex r) p = redex (E─SuccCong r)
progress (T-IsZero p) = helper (progress p) p where
helper : ∀ {t₀} → ValueOrRedex(t₀) → t₀ ∈ nat → ValueOrRedex(iszero t₀)
helper (value (nv zero)) p = redex E─IsZero
helper (value (nv (succ x))) p = redex E─IsSucc
helper (redex r) p = redex (E─IsCong r)
-- Interpreter
data _⟶*_ : Term → Term → Set where
done : ∀ {t} →
--------
t ⟶* t
redex : ∀ {t t′ t″} →
t ⟶ t′ →
t′ ⟶* t″ →
----------
t ⟶* t″
-- An interpreter result
data Result : Term → Set where
result : ∀ {t t′} →
t ⟶* t′ →
Value(t′) →
---------
Result(t)
-- The interpreter just calls `progress` until it is a value.
-- This might bot terminate!
{-# NON_TERMINATING #-}
interp : ∀ {t T} → (t ∈ T) → Result(t)
interp p = helper₂ p (progress p) where
helper₁ : ∀ {t t′} → (t ⟶ t′) → Result(t′) → Result(t)
helper₁ r (result s v) = result (redex r s) v
helper₂ : ∀ {t T} → (t ∈ T) → ValueOrRedex(t) → Result(t)
helper₂ p (value v) = result done v
helper₂ p (redex r) = helper₁ r (interp (preservation p r))
ex = if (iszero zero) then (succ zero) else (zero) end
exNat : (ex ∈ nat)
exNat = T-If (T-IsZero T-Zero) (T-Succ T-Zero) T-Zero
-- Normalize (C-N) interp exNat
-- result
-- (redex (E─IfCong E─IsZero)
-- (redex E─IfTrue
-- done))
-- (nv (succ zero))
| 21.163636
| 96
| 0.512027
|
a13a7276b51490574be95051b83fdaba23d70c9e
| 83
|
agda
|
Agda
|
test/Succeed/Issue3439.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue3439.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue3439.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --type-in-type #-}
open import Agda.Primitive
test : Set
test = Setω
| 11.857143
| 30
| 0.662651
|
fb91aca8fa584f55c1fab9aba88e246b328db318
| 746
|
agda
|
Agda
|
test/Succeed/Issue2484-9.agda
|
cagix/agda
|
cc026a6a97a3e517bb94bafa9d49233b067c7559
|
[
"BSD-2-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue2484-9.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue2484-9.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --sized-types #-}
module _ (_ : Set) where
open import Agda.Builtin.Size
postulate
I : Set
record ∃ (B : I → Set) : Set where
constructor _,_
field
proj₁ : I
proj₂ : B proj₁
module M (_ : Set₁) where
mutual
data P (i : Size) (x y : I) : Set where
⟨_⟩ : ∃ (Q i x) → P i x y
record Q (i : Size) (x y : I) : Set where
coinductive
field
force : {j : Size< i} → P j x y
open M Set
postulate
map : (B : I → Set) → (∀ x → B x → B x) → ∃ B → ∃ B
lemma : ∀ x y i → Q i x y → Q i x y
p : ∀ x i → P i x x
q′ : ∀ x i → ∃ λ y → Q i x y
q : ∀ x i → Q i x x
q′ x i = x , q x i
p x i = ⟨ map _ (λ y → lemma x y _) (q′ x i) ⟩
Q.force (q x i) {j} = p _ _
| 18.195122
| 60
| 0.458445
|
1ce9ee734008c3190da53b165acb57e914051470
| 1,411
|
agda
|
Agda
|
agda-stdlib/src/Data/Fin/Substitution/List.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/Fin/Substitution/List.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/Fin/Substitution/List.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Application of substitutions to lists, along with various lemmas
------------------------------------------------------------------------
-- This module illustrates how Data.Fin.Substitution.Lemmas.AppLemmas
-- can be used.
{-# OPTIONS --without-K --safe #-}
open import Data.Fin.Substitution.Lemmas
open import Data.Nat.Base using (ℕ)
module Data.Fin.Substitution.List {ℓ} {T : ℕ → Set ℓ} (lemmas₄ : Lemmas₄ T) where
open import Data.List.Base
open import Data.List.Properties
open import Data.Fin.Substitution
import Function as Fun
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning
private
open module L = Lemmas₄ lemmas₄ using (_/_; id; _⊙_)
infixl 8 _//_
_//_ : ∀ {m n} → List (T m) → Sub T m n → List (T n)
ts // ρ = map (λ σ → σ / ρ) ts
appLemmas : AppLemmas (λ n → List (T n)) T
appLemmas = record
{ application = record { _/_ = _//_ }
; lemmas₄ = lemmas₄
; id-vanishes = λ ts → begin
ts // id ≡⟨ map-cong L.id-vanishes ts ⟩
map Fun.id ts ≡⟨ map-id ts ⟩
ts ∎
; /-⊙ = λ {_ _ _ ρ₁ ρ₂} ts → begin
ts // ρ₁ ⊙ ρ₂ ≡⟨ map-cong L./-⊙ ts ⟩
map (λ σ → σ / ρ₁ / ρ₂) ts ≡⟨ map-compose ts ⟩
ts // ρ₁ // ρ₂ ∎
}
open AppLemmas appLemmas public
hiding (_/_) renaming (_/✶_ to _//✶_)
| 29.395833
| 81
| 0.54713
|
1db0bdc8478cdb2e2fe60699328d63ca48c729be
| 1,389
|
agda
|
Agda
|
Mockingbird/Forest/Base.agda
|
splintah/combinatory-logic
|
df8bf877e60b3059532c54a247a36a3d83cd55b0
|
[
"MIT"
] | 1
|
2022-02-28T23:44:42.000Z
|
2022-02-28T23:44:42.000Z
|
Mockingbird/Forest/Base.agda
|
splintah/combinatory-logic
|
df8bf877e60b3059532c54a247a36a3d83cd55b0
|
[
"MIT"
] | null | null | null |
Mockingbird/Forest/Base.agda
|
splintah/combinatory-logic
|
df8bf877e60b3059532c54a247a36a3d83cd55b0
|
[
"MIT"
] | null | null | null |
module Mockingbird.Forest.Base where
open import Algebra using (Op₂; Congruent₂; LeftCongruent; RightCongruent)
open import Level using (_⊔_) renaming (suc to lsuc)
open import Relation.Binary using (Rel; IsEquivalence; Setoid)
open import Relation.Nullary using (¬_)
record IsForest {b ℓ} (Bird : Set b) (_≈_ : Rel Bird ℓ) (_∙_ : Op₂ Bird) : Set (b ⊔ ℓ) where
field
isEquivalence : IsEquivalence _≈_
cong : Congruent₂ _≈_ _∙_
open IsEquivalence isEquivalence public
setoid : Setoid b ℓ
setoid = record { isEquivalence = isEquivalence }
congˡ : LeftCongruent _≈_ _∙_
congˡ A≈B = cong refl A≈B
congʳ : RightCongruent _≈_ _∙_
congʳ A≈B = cong A≈B refl
record Forest {b ℓ} : Set (lsuc (b ⊔ ℓ)) where
infix 4 _≈_
infixl 6 _∙_
field
Bird : Set b
_≈_ : Rel Bird ℓ
_∙_ : Op₂ Bird
isForest : IsForest Bird _≈_ _∙_
_≉_ : Rel Bird ℓ
x ≉ y = ¬ (x ≈ y)
open IsForest isForest public
import Relation.Binary.Reasoning.Base.Single _≈_ refl trans as Base
open Base using (begin_; _∎) public
infixr 2 _≈⟨⟩_ step-≈ step-≈˘
_≈⟨⟩_ : ∀ x {y} → x Base.IsRelatedTo y → x Base.IsRelatedTo y
_ ≈⟨⟩ x≈y = x≈y
step-≈ = Base.step-∼
syntax step-≈ x y≈z x≈y = x ≈⟨ x≈y ⟩ y≈z
step-≈˘ : ∀ x {y z} → y Base.IsRelatedTo z → y ≈ x → x Base.IsRelatedTo z
step-≈˘ x y∼z y≈x = x ≈⟨ sym y≈x ⟩ y∼z
syntax step-≈˘ x y≈z y≈x = x ≈˘⟨ y≈x ⟩ y≈z
| 26.207547
| 92
| 0.634269
|
4df67933ac16d89064b44ba83ae4c5b647b1f0c2
| 568
|
agda
|
Agda
|
slides/agda/half.agda
|
JLimperg/msc-thesis
|
a6b4cf13104112c76a07d17a9dd18f3d3589d449
|
[
"MIT"
] | 1
|
2019-12-14T01:30:46.000Z
|
2019-12-14T01:30:46.000Z
|
slides/agda/half.agda
|
JLimperg/msc-thesis
|
a6b4cf13104112c76a07d17a9dd18f3d3589d449
|
[
"MIT"
] | null | null | null |
slides/agda/half.agda
|
JLimperg/msc-thesis
|
a6b4cf13104112c76a07d17a9dd18f3d3589d449
|
[
"MIT"
] | null | null | null |
module half where
open import Relation.Binary.PropositionalEquality using (_≡_ ; refl)
open import Size
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
{-# BUILTIN NATURAL ℕ #-}
half : ℕ → ℕ
half zero = zero
half (suc zero) = zero
half (suc (suc i)) = suc (half i)
_ : half 5 ≡ 2
_ = refl
data ℕₛ (n : Size) : Set where
zero : ℕₛ n
suc : (m : Size< n) → ℕₛ m → ℕₛ n
_ : ∀ {n} → ℕₛ n
_ = zero
_ : ∀ {n} (m : Size< n) → ℕₛ m → ℕₛ n
_ = suc
halfₛ : ∀ n → ℕₛ n → ℕₛ n
halfₛ n zero = zero
halfₛ n (suc m zero) = zero
halfₛ n (suc m (suc k i)) = suc k (halfₛ k i)
| 16.228571
| 68
| 0.573944
|
4acdfbf4bdb7fa829ed701d6eb8ad00e06224b59
| 32
|
agda
|
Agda
|
test/interaction/Issue2728-2.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Issue2728-2.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Issue2728-2.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
F : {_ : Set₁} → Set₁
F {A} = A
| 10.666667
| 21
| 0.40625
|
0e13f9904479df9fdcfede37bdf4beb17f711efc
| 3,121
|
agda
|
Agda
|
test/Succeed/Issue1795.agda
|
cagix/agda
|
cc026a6a97a3e517bb94bafa9d49233b067c7559
|
[
"BSD-2-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue1795.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue1795.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2016-01-22
-- special size checking j : Size< i |- j : Size< ↑ j
-- was missing from checkInternal
-- {-# OPTIONS -v tc.polarity:10 #-}
-- {-# OPTIONS -v tc.with.type:50 #-}
-- {-# OPTIONS -v tc.check.internal:30 -v tc.infer.internal:30 #-}
{-# OPTIONS --sized-types #-}
open import Common.Unit
open import Common.Size
postulate
axiom : Unit
anything : ∀{A : Set} → A
-- An inductive-coinductive unit type.
mutual
record IC i : Set where
coinductive
field force : ∀(j : Size< i) → IC' j
data IC' i : Set where
cons : (xs : IC i) → IC' i -- necessary
-- The recursive identity on IC.
mutual
idIC : ∀ i (p : IC i) → IC i
IC.force (idIC i p) j = idIC' (↑ j) j (IC.force p j)
-- (↑ j) is triggering the error
-- if we write i here, things work
idIC' : ∀ i (j : Size< i) (p : IC' j) → IC' j
idIC' i j (cons p) = cons (idIC j p)
-- An inhabitant defined using with.
-- some : ∀ i → IC i
-- IC.force (some i) j with axiom -- with is necessary here!
-- ... | unit = cons (some j)
some : ∀ i → IC i
some' : ∀ i (j : Size< i) (u : Unit) → IC' j
IC.force (some i) j = some' i j axiom
some' i j unit = cons (some j)
-- A coindutive predicate with non-linear use of size i.
mutual
-- use of i in IC i is necessary, works with IC ∞
record All i (s : IC i) : Set where
coinductive
field force : ∀(j : Size< i) → All' j (IC.force s j)
data All' i : (s : IC' i) → Set where
-- With abstracted type is well-formed.
-- This means the type-checker can deal with it.
Test : Set₄
Test = (w : Set₃) (i : Size) (j : Size< i) →
All' j (idIC' (↑ j) j (some' i j axiom))
-- Agda claims: With abstracted type is ill-formed.
-- This means that checkInternal cannot deal with it.
test : ∀ i → All i (idIC i (some i))
All.force (test i) j with Set₂ -- any with expression does it here
... | w = anything
-- i !=< ↑ j of type Size
-- when checking that the type
-- (w : Set₃) (i : Size) (j : Size< i) →
-- All' j (idIC' (↑ j) j (some' i j axiom))
-- of the generated with function is well-formed
{-
candidate type:
(w : Set₃) (i : Size) (j : Size< i) →
All' j (idIC' (↑ j) j (some' i j axiom))
candidate type:
El {_getSort = Type (Max [ClosedLevel 4]), unEl =
Pi []r(El {_getSort = Type (Max [ClosedLevel 4]), unEl =
Sort (Type (Max [ClosedLevel 3]))}) (Abs "w"
El {_getSort = Type (Max []), unEl =
Pi []r(El {_getSort = SizeUniv, unEl =
Def Common.Size.Size []}) (Abs "i"
El {_getSort = Type (Max []), unEl =
Pi []r(El {_getSort = SizeUniv, unEl =
Def Common.Size.Size<_ [Apply []?(Var 0 [])]}) (Abs "j"
El {_getSort = Type (Max []), unEl =
Def Issue1795.All' [Apply []r(Var 0 []),Apply []r(
Def Issue1795.idIC' [Apply []r(Def Common.Size.↑_ [Apply []r(Var 0 [])]),Apply []r(Var 0 []),Apply []r(
Def Issue1795.some' [Apply []r(Var 1 []),Apply []r(Var 0 []),Apply []r(
Def Issue1795.axiom [])])])]})})})}
Last words:
type t = (j : Size< (↑ j)) → IC' j → IC' j
self = idIC' (↑ j)
eliminated by e = $ j
checking internal j : Size< (↑ j)
checking spine ( j : Size< i ) [] : Size< (↑ j)
-}
| 28.117117
| 107
| 0.575457
|
1ce8a992e827c3307cf980c7fff3cc5d25fda75c
| 689
|
agda
|
Agda
|
test/Succeed/Issue4016.agda
|
vlopezj/agda
|
ff4d89e75970cf27599fb9f572bd43c9455cbb56
|
[
"BSD-3-Clause"
] | 2
|
2019-10-29T09:40:30.000Z
|
2020-09-20T00:28:57.000Z
|
test/Succeed/Issue4016.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Succeed/Issue4016.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
-- Andreas, 2019-08-20, issue #4016
-- Debug printing should not crash Agda even if there are
-- __IMPOSSIBLE__s buried inside values that get printed.
{-# OPTIONS -v scope.decl.trace:80 #-} -- KEEP!
-- The following is some random code (see issue #4010)
-- that happened to trigger an internal error with verbosity 80.
open import Agda.Builtin.Reflection renaming (bindTC to _>>=_)
open import Agda.Builtin.List
data D : Set where
c : D
module M where
private
unquoteDecl g = do
ty ← quoteTC D
_ ← declareDef (arg (arg-info visible relevant) g) ty
qc ← quoteTC c
defineFun g (clause [] qc ∷ [])
-- Should print lots of debug stuff and succeed.
| 23.758621
| 64
| 0.683599
|
39715b7dc66fea0d5c2af1fc96e7b58c7e16ca2c
| 1,989
|
agda
|
Agda
|
Categories/Object/Products/Properties.agda
|
copumpkin/categories
|
36f4181d751e2ecb54db219911d8c69afe8ba892
|
[
"BSD-3-Clause"
] | 98
|
2015-04-15T14:57:33.000Z
|
2022-03-08T05:20:36.000Z
|
Categories/Object/Products/Properties.agda
|
p-pavel/categories
|
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
|
[
"BSD-3-Clause"
] | 19
|
2015-05-23T06:47:10.000Z
|
2019-08-09T16:31:40.000Z
|
Categories/Object/Products/Properties.agda
|
p-pavel/categories
|
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
|
[
"BSD-3-Clause"
] | 23
|
2015-02-05T13:03:09.000Z
|
2021-11-11T13:50:56.000Z
|
{-# OPTIONS --universe-polymorphism #-}
open import Categories.Category
module Categories.Object.Products.Properties {o ℓ e}
(C : Category o ℓ e) where
open Category C
open import Level
import Categories.Object.Terminal
open Categories.Object.Terminal C
import Categories.Object.BinaryProducts
open Categories.Object.BinaryProducts C
import Categories.Object.Products
open Categories.Object.Products C
import Categories.Morphisms
open Categories.Morphisms C
module Properties (P : Products) where
open Products P
open Terminal terminal
open BinaryProducts binary
open HomReasoning
open Equiv
unitˡ : ∀ {X} → (⊤ × X) ≅ X
unitˡ {X} = record
{ f = π₂
; g = ⟨ ! , id {X} ⟩
; iso = record
{ isoˡ =
begin
⟨ ! , id {X} ⟩ ∘ π₂
↓⟨ ⟨⟩∘ ⟩
⟨ ! ∘ π₂ , id ∘ π₂ ⟩
↓⟨ ⟨⟩-cong₂ (!-unique₂ (! ∘ π₂) π₁) (identityˡ) ⟩
⟨ π₁ , π₂ ⟩
↓⟨ η ⟩
id
∎
; isoʳ = commute₂
}
}
.unitˡ-natural : ∀ {X Y} {f : X ⇒ Y} → ⟨ ! , id {Y} ⟩ ∘ f ≡ second f ∘ ⟨ ! , id {X} ⟩
unitˡ-natural {f = f} =
begin
⟨ ! , id ⟩ ∘ f
↓⟨ ⟨⟩∘ ⟩
⟨ ! ∘ f , id ∘ f ⟩
↑⟨ ⟨⟩-cong₂ (!-unique (! ∘ f)) (id-comm {f = f}) ⟩
⟨ ! , f ∘ id ⟩
↑⟨ second∘⟨⟩ ⟩
second f ∘ ⟨ ! , id ⟩
∎
unitʳ : ∀ {X} → (X × ⊤) ≅ X
unitʳ {X} = record
{ f = π₁
; g = ⟨ id {X} , ! ⟩
; iso = record
{ isoˡ =
begin
⟨ id {X} , ! ⟩ ∘ π₁
↓⟨ ⟨⟩∘ ⟩
⟨ id ∘ π₁ , ! ∘ π₁ ⟩
↓⟨ ⟨⟩-cong₂ (identityˡ) (!-unique₂ (! ∘ π₁) π₂) ⟩
⟨ π₁ , π₂ ⟩
↓⟨ η ⟩
id
∎
; isoʳ = commute₁
}
}
.unitʳ-natural : ∀ {X Y} {f : X ⇒ Y} → ⟨ id , ! ⟩ ∘ f ≡ first f ∘ ⟨ id , ! ⟩
unitʳ-natural {f = f} =
begin
⟨ id , ! ⟩ ∘ f
↓⟨ ⟨⟩∘ ⟩
⟨ id ∘ f , ! ∘ f ⟩
↑⟨ ⟨⟩-cong₂ (id-comm {f = f}) (!-unique (! ∘ f)) ⟩
⟨ f ∘ id , ! ⟩
↑⟨ first∘⟨⟩ ⟩
first f ∘ ⟨ id , ! ⟩
∎
| 21.387097
| 87
| 0.441428
|
df2d19e5b9551849f6f131bada2e62bad3a605ed
| 311
|
agda
|
Agda
|
test/Common/Bool.agda
|
alex-mckenna/agda
|
78b62cd24bbd570271a7153e44ad280e52ef3e29
|
[
"BSD-3-Clause"
] | 7
|
2018-11-05T22:13:36.000Z
|
2018-11-06T16:38:43.000Z
|
test/Common/Bool.agda
|
andersk/agda
|
56928ff709dcb931cb9a48c4790e5ed3739e3032
|
[
"BSD-3-Clause"
] | 16
|
2018-10-08T00:32:04.000Z
|
2019-09-08T13:47:04.000Z
|
test/Common/Bool.agda
|
xekoukou/agda-ocaml
|
026a8f8473ab91f99c3f6545728e71fa847d2720
|
[
"BSD-3-Clause"
] | 1
|
2019-03-05T20:02:38.000Z
|
2019-03-05T20:02:38.000Z
|
module Common.Bool where
open import Agda.Builtin.Bool public
not : Bool -> Bool
not true = false
not false = true
notnot : Bool -> Bool
notnot true = not (not true)
notnot false = not (not false)
if_then_else_ : ∀ {a} {A : Set a} → Bool → A → A → A
if true then t else f = t
if false then t else f = f
| 18.294118
| 52
| 0.655949
|
4d9d1b83fdfebe0c2bcc6f881c5b3103d75b4819
| 2,538
|
agda
|
Agda
|
HoTT/Identity/Identity.agda
|
michaelforney/hott
|
ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508
|
[
"0BSD"
] | null | null | null |
HoTT/Identity/Identity.agda
|
michaelforney/hott
|
ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508
|
[
"0BSD"
] | null | null | null |
HoTT/Identity/Identity.agda
|
michaelforney/hott
|
ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508
|
[
"0BSD"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import HoTT.Base
open import HoTT.Identity
open import HoTT.Equivalence
open import HoTT.Homotopy
module HoTT.Identity.Identity where
ap⁻¹ : ∀ {i j} {A : 𝒰 i} {B : 𝒰 j} ((f , _) : A ≃ B) {a a' : A} →
f a == f a' → a == a'
ap⁻¹ e {a} {a'} p = η a ⁻¹ ∙ ap g p ∙ η a'
where open Iso (eqv→iso e)
-- Theorem 2.11.1
ap≃ : ∀ {i j} {A : 𝒰 i} {B : 𝒰 j} →
((f , _) : A ≃ B) → (a a' : A) → (a == a') ≃ (f a == f a')
ap≃ e a a' = iso→eqv iso
where
open Iso (eqv→iso e)
iso : Iso _ _
Iso.f iso = ap f
Iso.g iso = ap⁻¹ e
Iso.η iso p =
η a ⁻¹ ∙ ap g (ap f p) ∙ η a' =⟨ _ ∙ₗ ap-∘ g f p ⁻¹ ∙ᵣ _ ⟩
η a ⁻¹ ∙ ap (g ∘ f) p ∙ η a' =⟨ assoc ⁻¹ ⟩
η a ⁻¹ ∙ (ap (g ∘ f) p ∙ η a') =⟨ pivotₗ (~-natural-id η p) ⁻¹ ⟩
p ∎
where open =-Reasoning
Iso.ε iso q =
ap f (η a ⁻¹ ∙ ap g q ∙ η a') =⟨ pivotₗ (~-natural (ε ∘ f) _) ⟩
ε (f a) ⁻¹ ∙ (ap (f ∘ g ∘ f) _ ∙ ε (f a')) =⟨ _ ∙ₗ (ap-∘ f (g ∘ f) _ ∙ᵣ _) ⟩
ε (f a) ⁻¹ ∙ (ap f (ap (g ∘ f) _) ∙ ε (f a')) =⟨ ap (λ p → _ ∙ (ap f p ∙ _)) inner ⟩
ε (f a) ⁻¹ ∙ (ap f (ap g q) ∙ ε (f a')) =⟨ _ ∙ₗ (ap-∘ f g q ⁻¹ ∙ᵣ _) ⟩
ε (f a) ⁻¹ ∙ (ap (f ∘ g) q ∙ ε (f a')) =⟨ pivotₗ (~-natural-id ε q) ⁻¹ ⟩
q ∎
where
open =-Reasoning
inner : ap (g ∘ f) (η a ⁻¹ ∙ ap g q ∙ η a') == ap g q
inner =
ap (g ∘ f) (η a ⁻¹ ∙ ap g q ∙ η a') =⟨ pivotᵣ (~-natural-id η _ ⁻¹) ⟩
η a ∙ (η a ⁻¹ ∙ ap g q ∙ η a') ∙ η a' ⁻¹ =⟨ assoc ∙ᵣ η a' ⁻¹ ⟩
η a ∙ (η a ⁻¹ ∙ ap g q) ∙ η a' ∙ η a' ⁻¹ =⟨ assoc ∙ᵣ _ ∙ᵣ _ ⟩
η a ∙ η a ⁻¹ ∙ ap g q ∙ η a' ∙ η a' ⁻¹ =⟨ invᵣ ∙ᵣ _ ∙ᵣ _ ∙ᵣ _ ⟩
refl ∙ ap g q ∙ η a' ∙ η a' ⁻¹ =⟨ unitₗ ⁻¹ ∙ᵣ _ ∙ᵣ _ ⟩
ap g q ∙ η a' ∙ η a' ⁻¹ =⟨ assoc ⁻¹ ⟩
ap g q ∙ (η a' ∙ η a' ⁻¹) =⟨ _ ∙ₗ invᵣ ⟩
ap g q ∙ refl =⟨ unitᵣ ⁻¹ ⟩
ap g q ∎
-- Theorem 2.11.3
=-transport : ∀ {i j} {A : 𝒰 i} {B : 𝒰 j} {a a' : A}
(f g : A → B) (p : a == a') (q : f a == g a) →
transport (λ x → f x == g x) p q == ap f p ⁻¹ ∙ q ∙ ap g p
=-transport _ _ refl q rewrite q = refl
module _ {i} {A : 𝒰 i} {x₁ x₂ : A} (a : A) (p : x₁ == x₂)
where
=-transportₗ : (q : a == x₁) → transport (a ==_) p q == q ∙ p
=-transportₗ q rewrite p = unitᵣ
=-transportᵣ : (q : x₁ == a) → transport (_== a) p q == p ⁻¹ ∙ q
=-transportᵣ q rewrite p = unitₗ
| 40.285714
| 88
| 0.384161
|
069b71991e55c1635416a9fd452e9fee82bd9c43
| 18
|
agda
|
Agda
|
test/Fail/Issue3257.tex.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue3257.tex.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue3257.tex.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
postulate A : Set
| 9
| 17
| 0.722222
|
0e6476d713e1243440cc9f72bb425596232443c5
| 872
|
agda
|
Agda
|
test/Succeed/Issue2223b.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue2223b.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue2223b.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --allow-unsolved-metas #-}
module _ where
open import Agda.Primitive
postulate Applicative : ∀ {a b} (F : Set a → Set b) → Set (lsuc a ⊔ b)
record Traversable {a} (T : Set a) : Set (lsuc a) where
constructor mkTrav
field traverse : ∀ {F} {{AppF : Applicative F}} → T → F T
-- unsolved metas in type of F
postulate
V : ∀ {a} → Set a
travV : ∀ {a} {F : Set a → Set a} {{AppF : Applicative F}} → V → F V
module M (a : Level) where
TravV : Traversable {a} V
TravV = mkTrav travV
postulate
a : Level
F : Set → Set
instance AppF : Applicative F
mapM : V → F V
mapM = Traversable.traverse (M.TravV _)
-- Here we try to cast (TypeChecking.Constraints.castConstraintToCurrentContext)
-- a level constraint from M talking about the local (a : Level) to the top-level
-- (empty) context. This ought not result in an __IMPOSSIBLE__.
| 28.129032
| 83
| 0.651376
|
2f659f9f7b704ecc8f29f829849db43816d8dd60
| 2,105
|
agda
|
Agda
|
agda-stdlib/src/Data/List/Membership/Setoid.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/List/Membership/Setoid.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/List/Membership/Setoid.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- List membership and some related definitions
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary
module Data.List.Membership.Setoid {c ℓ} (S : Setoid c ℓ) where
open import Function using (_∘_; id; flip)
open import Data.Fin.Base using (Fin; zero; suc)
open import Data.List.Base as List using (List; []; _∷_; length; lookup)
open import Data.List.Relation.Unary.Any
using (Any; index; map; here; there)
open import Data.Product as Prod using (∃; _×_; _,_)
open import Relation.Unary using (Pred)
open import Relation.Nullary using (¬_)
open Setoid S renaming (Carrier to A)
------------------------------------------------------------------------
-- Definitions
infix 4 _∈_ _∉_
_∈_ : A → List A → Set _
x ∈ xs = Any (x ≈_) xs
_∉_ : A → List A → Set _
x ∉ xs = ¬ x ∈ xs
------------------------------------------------------------------------
-- Operations
open Data.List.Relation.Unary.Any using (_∷=_; _─_) public
mapWith∈ : ∀ {b} {B : Set b}
(xs : List A) → (∀ {x} → x ∈ xs → B) → List B
mapWith∈ [] f = []
mapWith∈ (x ∷ xs) f = f (here refl) ∷ mapWith∈ xs (f ∘ there)
------------------------------------------------------------------------
-- Finding and losing witnesses
module _ {p} {P : Pred A p} where
find : ∀ {xs} → Any P xs → ∃ λ x → x ∈ xs × P x
find (here px) = (_ , here refl , px)
find (there pxs) = Prod.map id (Prod.map there id) (find pxs)
lose : P Respects _≈_ → ∀ {x xs} → x ∈ xs → P x → Any P xs
lose resp x∈xs px = map (flip resp px) x∈xs
------------------------------------------------------------------------
-- DEPRECATED
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 0.16
map-with-∈ = mapWith∈
{-# WARNING_ON_USAGE map-with-∈
"Warning: map-with-∈ was deprecated in v0.16.
Please use mapWith∈ instead."
#-}
| 30.071429
| 72
| 0.47886
|
1ddd0d61d0e0cbda35f7aed838ce4f4cdb4759a9
| 1,033
|
agda
|
Agda
|
src/fot/FOTC/Data/Nat/Divisibility/NotBy0.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
src/fot/FOTC/Data/Nat/Divisibility/NotBy0.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
src/fot/FOTC/Data/Nat/Divisibility/NotBy0.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
------------------------------------------------------------------------------
-- The relation of divisibility on partial natural numbers
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Data.Nat.Divisibility.NotBy0 where
open import FOTC.Base
open import FOTC.Data.Nat
infix 4 _∣_
------------------------------------------------------------------------------
-- The relation of divisibility (the symbol is '\mid' not '|')
--
-- (See documentation in FOTC.Data.Nat.Divisibility.By0)
--
-- In our definition 0∤0, which is used to prove properties of the gcd
-- as it is in GHC ≤ 7.0.4, where gcd 0 0 = undefined (see
-- http://hackage.haskell.org/trac/ghc/ticket/3304).
-- Note that @k@ should be a total natural number.
_∣_ : D → D → Set
m ∣ n = (m ≢ zero) ∧ (∃[ k ] N k ∧ n ≡ k * m)
{-# ATP definition _∣_ #-}
| 34.433333
| 78
| 0.483059
|
12ce1bff91403f44c554e62ec6e5c7ac557d4a46
| 19,888
|
agda
|
Agda
|
Cubical/Algebra/CommAlgebra/Instances/FreeCommAlgebra.agda
|
mzeuner/cubical
|
63c770b381039c0132c17d7913f4566b35984701
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/CommAlgebra/Instances/FreeCommAlgebra.agda
|
mzeuner/cubical
|
63c770b381039c0132c17d7913f4566b35984701
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/CommAlgebra/Instances/FreeCommAlgebra.agda
|
mzeuner/cubical
|
63c770b381039c0132c17d7913f4566b35984701
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe #-}
module Cubical.Algebra.CommAlgebra.Instances.FreeCommAlgebra where
{-
The free commutative algebra over a commutative ring,
or in other words the ring of polynomials with coefficients in a given ring.
Note that this is a constructive definition, which entails that polynomials
cannot be represented by lists of coefficients, where the last one is non-zero.
For rings with decidable equality, that is still possible.
I learned about this (and other) definition(s) from David Jaz Myers.
You can watch him talk about these things here:
https://www.youtube.com/watch?v=VNp-f_9MnVk
This file contains
* the definition of the free commutative algebra on a type I over a commutative ring R as a HIT
(let us call that R[I])
* a prove that the construction is an commutative R-algebra
* definitions of the induced maps appearing in the universal property of R[I],
that is: * for any map I → A, where A is a commutative R-algebra,
the induced algebra homomorphism R[I] → A
('inducedHom')
* for any hom R[I] → A, the 'restricttion to variables' I → A
('evaluateAt')
* a proof that the two constructions are inverse to each other
('homRetrievable' and 'mapRetrievable')
* a proof, that the corresponding pointwise equivalence of functors is natural
('naturalR', 'naturalL')
-}
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Structure
open import Cubical.Foundations.Function hiding (const)
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.Ring using ()
open import Cubical.Algebra.CommAlgebra
open import Cubical.Algebra.Algebra
open import Cubical.HITs.SetTruncation
private
variable
ℓ ℓ' ℓ'' : Level
module Construction (R : CommRing ℓ) where
open CommRingStr (snd R) using (1r; 0r) renaming (_+_ to _+r_; _·_ to _·r_)
data R[_] (I : Type ℓ') : Type (ℓ-max ℓ ℓ') where
var : I → R[ I ]
const : ⟨ R ⟩ → R[ I ]
_+_ : R[ I ] → R[ I ] → R[ I ]
-_ : R[ I ] → R[ I ]
_·_ : R[ I ] → R[ I ] → R[ I ] -- \cdot
+-assoc : (x y z : R[ I ]) → x + (y + z) ≡ (x + y) + z
+-rid : (x : R[ I ]) → x + (const 0r) ≡ x
+-rinv : (x : R[ I ]) → x + (- x) ≡ (const 0r)
+-comm : (x y : R[ I ]) → x + y ≡ y + x
·-assoc : (x y z : R[ I ]) → x · (y · z) ≡ (x · y) · z
·-lid : (x : R[ I ]) → (const 1r) · x ≡ x
·-comm : (x y : R[ I ]) → x · y ≡ y · x
ldist : (x y z : R[ I ]) → (x + y) · z ≡ (x · z) + (y · z)
+HomConst : (s t : ⟨ R ⟩) → const (s +r t) ≡ const s + const t
·HomConst : (s t : ⟨ R ⟩) → const (s ·r t) ≡ (const s) · (const t)
0-trunc : (x y : R[ I ]) (p q : x ≡ y) → p ≡ q
_⋆_ : {I : Type ℓ'} → ⟨ R ⟩ → R[ I ] → R[ I ]
r ⋆ x = const r · x
⋆-assoc : {I : Type ℓ'} → (s t : ⟨ R ⟩) (x : R[ I ]) → (s ·r t) ⋆ x ≡ s ⋆ (t ⋆ x)
⋆-assoc s t x = const (s ·r t) · x ≡⟨ cong (λ u → u · x) (·HomConst _ _) ⟩
(const s · const t) · x ≡⟨ sym (·-assoc _ _ _) ⟩
const s · (const t · x) ≡⟨ refl ⟩
s ⋆ (t ⋆ x) ∎
⋆-ldist-+ : {I : Type ℓ'} → (s t : ⟨ R ⟩) (x : R[ I ]) → (s +r t) ⋆ x ≡ (s ⋆ x) + (t ⋆ x)
⋆-ldist-+ s t x = (s +r t) ⋆ x ≡⟨ cong (λ u → u · x) (+HomConst _ _) ⟩
(const s + const t) · x ≡⟨ ldist _ _ _ ⟩
(s ⋆ x) + (t ⋆ x) ∎
⋆-rdist-+ : {I : Type ℓ'} → (s : ⟨ R ⟩) (x y : R[ I ]) → s ⋆ (x + y) ≡ (s ⋆ x) + (s ⋆ y)
⋆-rdist-+ s x y = const s · (x + y) ≡⟨ ·-comm _ _ ⟩
(x + y) · const s ≡⟨ ldist _ _ _ ⟩
(x · const s) + (y · const s) ≡⟨ cong (λ u → u + (y · const s)) (·-comm _ _) ⟩
(s ⋆ x) + (y · const s) ≡⟨ cong (λ u → (s ⋆ x) + u) (·-comm _ _) ⟩
(s ⋆ x) + (s ⋆ y) ∎
⋆-assoc-· : {I : Type ℓ'} → (s : ⟨ R ⟩) (x y : R[ I ]) → (s ⋆ x) · y ≡ s ⋆ (x · y)
⋆-assoc-· s x y = (s ⋆ x) · y ≡⟨ sym (·-assoc _ _ _) ⟩
s ⋆ (x · y) ∎
0a : {I : Type ℓ'} → R[ I ]
0a = (const 0r)
1a : {I : Type ℓ'} → R[ I ]
1a = (const 1r)
isCommAlgebra : {I : Type ℓ'} → IsCommAlgebra R {A = R[ I ]} 0a 1a _+_ _·_ -_ _⋆_
isCommAlgebra = makeIsCommAlgebra 0-trunc
+-assoc +-rid +-rinv +-comm
·-assoc ·-lid ldist ·-comm
⋆-assoc ⋆-ldist-+ ⋆-rdist-+ ·-lid ⋆-assoc-·
_[_] : (R : CommRing ℓ) (I : Type ℓ') → CommAlgebra R (ℓ-max ℓ ℓ')
(R [ I ]) = R[ I ] , commalgebrastr 0a 1a _+_ _·_ -_ _⋆_ isCommAlgebra
where
open Construction R
module Theory {R : CommRing ℓ} {I : Type ℓ'} where
open CommRingStr (snd R)
using (0r; 1r)
renaming (_·_ to _·r_; _+_ to _+r_; ·-comm to ·r-comm; ·Rid to ·r-rid)
module _ (A : CommAlgebra R ℓ'') (φ : I → ⟨ A ⟩) where
open CommAlgebraStr (A .snd)
open AlgebraTheory (CommRing→Ring R) (CommAlgebra→Algebra A)
open Construction using (var; const) renaming (_+_ to _+c_; -_ to -c_; _·_ to _·c_)
imageOf0Works : 0r ⋆ 1a ≡ 0a
imageOf0Works = 0-actsNullifying 1a
imageOf1Works : 1r ⋆ 1a ≡ 1a
imageOf1Works = ⋆-lid 1a
inducedMap : ⟨ R [ I ] ⟩ → ⟨ A ⟩
inducedMap (var x) = φ x
inducedMap (const r) = r ⋆ 1a
inducedMap (P +c Q) = (inducedMap P) + (inducedMap Q)
inducedMap (-c P) = - inducedMap P
inducedMap (Construction.+-assoc P Q S i) = +-assoc (inducedMap P) (inducedMap Q) (inducedMap S) i
inducedMap (Construction.+-rid P i) =
let
eq : (inducedMap P) + (inducedMap (const 0r)) ≡ (inducedMap P)
eq = (inducedMap P) + (inducedMap (const 0r)) ≡⟨ refl ⟩
(inducedMap P) + (0r ⋆ 1a) ≡⟨ cong
(λ u → (inducedMap P) + u)
(imageOf0Works) ⟩
(inducedMap P) + 0a ≡⟨ +-rid _ ⟩
(inducedMap P) ∎
in eq i
inducedMap (Construction.+-rinv P i) =
let eq : (inducedMap P - inducedMap P) ≡ (inducedMap (const 0r))
eq = (inducedMap P - inducedMap P) ≡⟨ +-rinv _ ⟩
0a ≡⟨ sym imageOf0Works ⟩
(inducedMap (const 0r))∎
in eq i
inducedMap (Construction.+-comm P Q i) = +-comm (inducedMap P) (inducedMap Q) i
inducedMap (P ·c Q) = inducedMap P · inducedMap Q
inducedMap (Construction.·-assoc P Q S i) = ·Assoc (inducedMap P) (inducedMap Q) (inducedMap S) i
inducedMap (Construction.·-lid P i) =
let eq = inducedMap (const 1r) · inducedMap P ≡⟨ cong (λ u → u · inducedMap P) imageOf1Works ⟩
1a · inducedMap P ≡⟨ ·Lid (inducedMap P) ⟩
inducedMap P ∎
in eq i
inducedMap (Construction.·-comm P Q i) = ·-comm (inducedMap P) (inducedMap Q) i
inducedMap (Construction.ldist P Q S i) = ·Ldist+ (inducedMap P) (inducedMap Q) (inducedMap S) i
inducedMap (Construction.+HomConst s t i) = ⋆-ldist s t 1a i
inducedMap (Construction.·HomConst s t i) =
let eq = (s ·r t) ⋆ 1a ≡⟨ cong (λ u → u ⋆ 1a) (·r-comm _ _) ⟩
(t ·r s) ⋆ 1a ≡⟨ ⋆-assoc t s 1a ⟩
t ⋆ (s ⋆ 1a) ≡⟨ cong (λ u → t ⋆ u) (sym (·Rid _)) ⟩
t ⋆ ((s ⋆ 1a) · 1a) ≡⟨ ⋆-rassoc t (s ⋆ 1a) 1a ⟩
(s ⋆ 1a) · (t ⋆ 1a) ∎
in eq i
inducedMap (Construction.0-trunc P Q p q i j) =
isSetAlgebra (CommAlgebra→Algebra A) (inducedMap P) (inducedMap Q) (cong _ p) (cong _ q) i j
module _ where
open IsAlgebraHom
inducedHom : AlgebraHom (CommAlgebra→Algebra (R [ I ])) (CommAlgebra→Algebra A)
inducedHom .fst = inducedMap
inducedHom .snd .pres0 = 0-actsNullifying _
inducedHom .snd .pres1 = imageOf1Works
inducedHom .snd .pres+ x y = refl
inducedHom .snd .pres· x y = refl
inducedHom .snd .pres- x = refl
inducedHom .snd .pres⋆ r x =
(r ⋆ 1a) · inducedMap x ≡⟨ ⋆-lassoc r 1a (inducedMap x) ⟩
r ⋆ (1a · inducedMap x) ≡⟨ cong (λ u → r ⋆ u) (·Lid (inducedMap x)) ⟩
r ⋆ inducedMap x ∎
module _ (A : CommAlgebra R ℓ'') where
open CommAlgebraStr (A .snd)
open AlgebraTheory (CommRing→Ring R) (CommAlgebra→Algebra A)
open Construction using (var; const) renaming (_+_ to _+c_; -_ to -c_; _·_ to _·c_)
Hom = AlgebraHom (CommAlgebra→Algebra (R [ I ])) (CommAlgebra→Algebra A)
open IsAlgebraHom
evaluateAt : Hom → I → ⟨ A ⟩
evaluateAt φ x = φ .fst (var x)
mapRetrievable : ∀ (φ : I → ⟨ A ⟩)
→ evaluateAt (inducedHom A φ) ≡ φ
mapRetrievable φ = refl
proveEq : ∀ {X : Type ℓ''} (isSetX : isSet X) (f g : ⟨ R [ I ] ⟩ → X)
→ (var-eq : (x : I) → f (var x) ≡ g (var x))
→ (const-eq : (r : ⟨ R ⟩) → f (const r) ≡ g (const r))
→ (+-eq : (x y : ⟨ R [ I ] ⟩) → (eq-x : f x ≡ g x) → (eq-y : f y ≡ g y)
→ f (x +c y) ≡ g (x +c y))
→ (·-eq : (x y : ⟨ R [ I ] ⟩) → (eq-x : f x ≡ g x) → (eq-y : f y ≡ g y)
→ f (x ·c y) ≡ g (x ·c y))
→ (-eq : (x : ⟨ R [ I ] ⟩) → (eq-x : f x ≡ g x)
→ f (-c x) ≡ g (-c x))
→ f ≡ g
proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i (var x) = var-eq x i
proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i (const x) = const-eq x i
proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i (x +c y) =
+-eq x y
(λ i → proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i x)
(λ i → proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i y)
i
proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i (-c x) =
-eq x ((λ i → proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i x)) i
proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i (x ·c y) =
·-eq x y
(λ i → proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i x)
(λ i → proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i y)
i
proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i (Construction.+-assoc x y z j) =
let
rec : (x : ⟨ R [ I ] ⟩) → f x ≡ g x
rec x = (λ i → proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i x)
a₀₋ : f (x +c (y +c z)) ≡ g (x +c (y +c z))
a₀₋ = +-eq _ _ (rec x) (+-eq _ _ (rec y) (rec z))
a₁₋ : f ((x +c y) +c z) ≡ g ((x +c y) +c z)
a₁₋ = +-eq _ _ (+-eq _ _ (rec x) (rec y)) (rec z)
a₋₀ : f (x +c (y +c z)) ≡ f ((x +c y) +c z)
a₋₀ = cong f (Construction.+-assoc x y z)
a₋₁ : g (x +c (y +c z)) ≡ g ((x +c y) +c z)
a₋₁ = cong g (Construction.+-assoc x y z)
in isSet→isSet' isSetX a₀₋ a₁₋ a₋₀ a₋₁ j i
proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i (Construction.+-rid x j) =
let
rec : (x : ⟨ R [ I ] ⟩) → f x ≡ g x
rec x = (λ i → proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i x)
a₀₋ : f (x +c (const 0r)) ≡ g (x +c (const 0r))
a₀₋ = +-eq _ _ (rec x) (const-eq 0r)
a₁₋ : f x ≡ g x
a₁₋ = rec x
a₋₀ : f (x +c (const 0r)) ≡ f x
a₋₀ = cong f (Construction.+-rid x)
a₋₁ : g (x +c (const 0r)) ≡ g x
a₋₁ = cong g (Construction.+-rid x)
in isSet→isSet' isSetX a₀₋ a₁₋ a₋₀ a₋₁ j i
proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i (Construction.+-rinv x j) =
let
rec : (x : ⟨ R [ I ] ⟩) → f x ≡ g x
rec x = (λ i → proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i x)
a₀₋ : f (x +c (-c x)) ≡ g (x +c (-c x))
a₀₋ = +-eq x (-c x) (rec x) (-eq x (rec x))
a₁₋ : f (const 0r) ≡ g (const 0r)
a₁₋ = const-eq 0r
a₋₀ : f (x +c (-c x)) ≡ f (const 0r)
a₋₀ = cong f (Construction.+-rinv x)
a₋₁ : g (x +c (-c x)) ≡ g (const 0r)
a₋₁ = cong g (Construction.+-rinv x)
in isSet→isSet' isSetX a₀₋ a₁₋ a₋₀ a₋₁ j i
proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i (Construction.+-comm x y j) =
let
rec : (x : ⟨ R [ I ] ⟩) → f x ≡ g x
rec x = (λ i → proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i x)
a₀₋ : f (x +c y) ≡ g (x +c y)
a₀₋ = +-eq x y (rec x) (rec y)
a₁₋ : f (y +c x) ≡ g (y +c x)
a₁₋ = +-eq y x (rec y) (rec x)
a₋₀ : f (x +c y) ≡ f (y +c x)
a₋₀ = cong f (Construction.+-comm x y)
a₋₁ : g (x +c y) ≡ g (y +c x)
a₋₁ = cong g (Construction.+-comm x y)
in isSet→isSet' isSetX a₀₋ a₁₋ a₋₀ a₋₁ j i
proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i (Construction.·-assoc x y z j) =
let
rec : (x : ⟨ R [ I ] ⟩) → f x ≡ g x
rec x = (λ i → proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i x)
a₀₋ : f (x ·c (y ·c z)) ≡ g (x ·c (y ·c z))
a₀₋ = ·-eq _ _ (rec x) (·-eq _ _ (rec y) (rec z))
a₁₋ : f ((x ·c y) ·c z) ≡ g ((x ·c y) ·c z)
a₁₋ = ·-eq _ _ (·-eq _ _ (rec x) (rec y)) (rec z)
a₋₀ : f (x ·c (y ·c z)) ≡ f ((x ·c y) ·c z)
a₋₀ = cong f (Construction.·-assoc x y z)
a₋₁ : g (x ·c (y ·c z)) ≡ g ((x ·c y) ·c z)
a₋₁ = cong g (Construction.·-assoc x y z)
in isSet→isSet' isSetX a₀₋ a₁₋ a₋₀ a₋₁ j i
proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i (Construction.·-lid x j) =
let
rec : (x : ⟨ R [ I ] ⟩) → f x ≡ g x
rec x = (λ i → proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i x)
a₀₋ : f ((const 1r) ·c x) ≡ g ((const 1r) ·c x)
a₀₋ = ·-eq _ _ (const-eq 1r) (rec x)
a₁₋ : f x ≡ g x
a₁₋ = rec x
a₋₀ : f ((const 1r) ·c x) ≡ f x
a₋₀ = cong f (Construction.·-lid x)
a₋₁ : g ((const 1r) ·c x) ≡ g x
a₋₁ = cong g (Construction.·-lid x)
in isSet→isSet' isSetX a₀₋ a₁₋ a₋₀ a₋₁ j i
proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i (Construction.·-comm x y j) =
let
rec : (x : ⟨ R [ I ] ⟩) → f x ≡ g x
rec x = (λ i → proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i x)
a₀₋ : f (x ·c y) ≡ g (x ·c y)
a₀₋ = ·-eq _ _ (rec x) (rec y)
a₁₋ : f (y ·c x) ≡ g (y ·c x)
a₁₋ = ·-eq _ _ (rec y) (rec x)
a₋₀ : f (x ·c y) ≡ f (y ·c x)
a₋₀ = cong f (Construction.·-comm x y)
a₋₁ : g (x ·c y) ≡ g (y ·c x)
a₋₁ = cong g (Construction.·-comm x y)
in isSet→isSet' isSetX a₀₋ a₁₋ a₋₀ a₋₁ j i
proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i (Construction.ldist x y z j) =
let
rec : (x : ⟨ R [ I ] ⟩) → f x ≡ g x
rec x = (λ i → proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i x)
a₀₋ : f ((x +c y) ·c z) ≡ g ((x +c y) ·c z)
a₀₋ = ·-eq (x +c y) z
(+-eq _ _ (rec x) (rec y))
(rec z)
a₁₋ : f ((x ·c z) +c (y ·c z)) ≡ g ((x ·c z) +c (y ·c z))
a₁₋ = +-eq _ _ (·-eq _ _ (rec x) (rec z)) (·-eq _ _ (rec y) (rec z))
a₋₀ : f ((x +c y) ·c z) ≡ f ((x ·c z) +c (y ·c z))
a₋₀ = cong f (Construction.ldist x y z)
a₋₁ : g ((x +c y) ·c z) ≡ g ((x ·c z) +c (y ·c z))
a₋₁ = cong g (Construction.ldist x y z)
in isSet→isSet' isSetX a₀₋ a₁₋ a₋₀ a₋₁ j i
proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i (Construction.+HomConst s t j) =
let
rec : (x : ⟨ R [ I ] ⟩) → f x ≡ g x
rec x = (λ i → proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i x)
a₀₋ : f (const (s +r t)) ≡ g (const (s +r t))
a₀₋ = const-eq (s +r t)
a₁₋ : f (const s +c const t) ≡ g (const s +c const t)
a₁₋ = +-eq _ _ (const-eq s) (const-eq t)
a₋₀ : f (const (s +r t)) ≡ f (const s +c const t)
a₋₀ = cong f (Construction.+HomConst s t)
a₋₁ : g (const (s +r t)) ≡ g (const s +c const t)
a₋₁ = cong g (Construction.+HomConst s t)
in isSet→isSet' isSetX a₀₋ a₁₋ a₋₀ a₋₁ j i
proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i (Construction.·HomConst s t j) =
let
rec : (x : ⟨ R [ I ] ⟩) → f x ≡ g x
rec x = (λ i → proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i x)
a₀₋ : f (const (s ·r t)) ≡ g (const (s ·r t))
a₀₋ = const-eq (s ·r t)
a₁₋ : f (const s ·c const t) ≡ g (const s ·c const t)
a₁₋ = ·-eq _ _ (const-eq s) (const-eq t)
a₋₀ : f (const (s ·r t)) ≡ f (const s ·c const t)
a₋₀ = cong f (Construction.·HomConst s t)
a₋₁ : g (const (s ·r t)) ≡ g (const s ·c const t)
a₋₁ = cong g (Construction.·HomConst s t)
in isSet→isSet' isSetX a₀₋ a₁₋ a₋₀ a₋₁ j i
proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i (Construction.0-trunc x y p q j k) =
let
P : (x : ⟨ R [ I ] ⟩) → f x ≡ g x
P x i = proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i x
Q : (x : ⟨ R [ I ] ⟩) → f x ≡ g x
Q x i = proveEq isSetX f g var-eq const-eq +-eq ·-eq -eq i x
in isOfHLevel→isOfHLevelDep 2
(λ z → isProp→isSet (isSetX (f z) (g z))) _ _
(cong P p)
(cong Q q)
(Construction.0-trunc x y p q) j k i
homRetrievable : ∀ (f : Hom)
→ inducedMap A (evaluateAt f) ≡ fst f
homRetrievable f =
proveEq
(isSetAlgebra (CommAlgebra→Algebra A))
(inducedMap A (evaluateAt f))
(λ x → f $a x)
(λ x → refl)
(λ r → r ⋆ 1a ≡⟨ cong (λ u → r ⋆ u) (sym f.pres1) ⟩
r ⋆ (f $a (const 1r)) ≡⟨ sym (f.pres⋆ r _) ⟩
f $a (const r ·c const 1r) ≡⟨ cong (λ u → f $a u) (sym (Construction.·HomConst r 1r)) ⟩
f $a (const (r ·r 1r)) ≡⟨ cong (λ u → f $a (const u)) (·r-rid r) ⟩
f $a (const r) ∎)
(λ x y eq-x eq-y →
ι (x +c y) ≡⟨ refl ⟩
(ι x + ι y) ≡⟨ cong (λ u → u + ι y) eq-x ⟩
((f $a x) + ι y) ≡⟨
cong (λ u → (f $a x) + u) eq-y ⟩
((f $a x) + (f $a y)) ≡⟨ sym (f.pres+ _ _) ⟩ (f $a (x +c y)) ∎)
(λ x y eq-x eq-y →
ι (x ·c y) ≡⟨ refl ⟩
ι x · ι y ≡⟨ cong (λ u → u · ι y) eq-x ⟩
(f $a x) · (ι y) ≡⟨ cong (λ u → (f $a x) · u) eq-y ⟩
(f $a x) · (f $a y) ≡⟨ sym (f.pres· _ _) ⟩
f $a (x ·c y) ∎)
(λ x eq-x →
ι (-c x) ≡⟨ refl ⟩
- ι x ≡⟨ cong (λ u → - u) eq-x ⟩
- (f $a x) ≡⟨ sym (f.pres- x) ⟩
f $a (-c x) ∎)
where
ι = inducedMap A (evaluateAt f)
module f = IsAlgebraHom (f .snd)
evaluateAt : {R : CommRing ℓ} {I : Type ℓ'} (A : CommAlgebra R ℓ'')
(f : AlgebraHom (CommAlgebra→Algebra (R [ I ])) (CommAlgebra→Algebra A))
→ (I → ⟨ A ⟩)
evaluateAt A f x = f $a (Construction.var x)
inducedHom : {R : CommRing ℓ} {I : Type ℓ'} (A : CommAlgebra R ℓ'')
(φ : I → ⟨ A ⟩)
→ AlgebraHom (CommAlgebra→Algebra (R [ I ])) (CommAlgebra→Algebra A)
inducedHom A φ = Theory.inducedHom A φ
module _ {R : CommRing ℓ} {A B : CommAlgebra R ℓ''} where
A′ = CommAlgebra→Algebra A
B′ = CommAlgebra→Algebra B
R′ = (CommRing→Ring R)
ν : AlgebraHom A′ B′ → (⟨ A ⟩ → ⟨ B ⟩)
ν φ = φ .fst
{-
Hom(R[I],A) → (I → A)
↓ ↓
Hom(R[I],B) → (I → B)
-}
naturalR : {I : Type ℓ'} (ψ : AlgebraHom A′ B′)
(f : AlgebraHom (CommAlgebra→Algebra (R [ I ])) A′)
→ (ν ψ) ∘ evaluateAt A f ≡ evaluateAt B (ψ ∘a f)
naturalR ψ f = refl
{-
Hom(R[I],A) → (I → A)
↓ ↓
Hom(R[J],A) → (J → A)
-}
naturalL : {I J : Type ℓ'} (φ : J → I)
(f : AlgebraHom (CommAlgebra→Algebra (R [ I ])) A′)
→ (evaluateAt A f) ∘ φ
≡ evaluateAt A (f ∘a (inducedHom (R [ I ]) (λ x → Construction.var (φ x))))
naturalL φ f = refl
| 43.614035
| 102
| 0.467971
|
5055488a510cda76c23416681e539a520e766b96
| 236
|
agda
|
Agda
|
test/Fail/Issue373.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue373.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue373.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Issue373 where
data Nat : Set where
zero : Nat
suc : (n : Nat) → Nat
{-# BUILTIN NATURAL Nat #-}
{-# FOREIGN GHC data Nat = Zero | Suc Nat #-}
{-# COMPILE GHC Nat = data Nat (Zero | Suc) #-} -- should fail when compiling
| 21.454545
| 77
| 0.614407
|
0b457a4a9dccd9bd48a1fdd509ed44d43555aeed
| 736
|
agda
|
Agda
|
test/succeed/Issue1136.agda
|
larrytheliquid/agda
|
477c8c37f948e6038b773409358fd8f38395f827
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
test/succeed/Issue1136.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | null | null | null |
test/succeed/Issue1136.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
-- Andreas, 2014-05-20 Triggered by Andrea Vezzosi & NAD
{-# OPTIONS --copatterns #-}
-- {-# OPTIONS -v tc.conv.coerce:10 #-}
open import Common.Size
Size≤ : Size → Set
Size≤ i = Size< ↑ i
postulate
Dom : Size → Set
mapDom : ∀ i (j : Size≤ i) → Dom i → Dom j
record ∞Dom i : Set where
field
force : ∀ (j : Size< i) → Dom j
∞mapDom : ∀ i (j : Size≤ i) → ∞Dom i → ∞Dom j
∞Dom.force (∞mapDom i j x) k = mapDom k k (∞Dom.force x k)
-- The second k on the rhs has type
-- k : Size< j
-- and should have type
-- k : Size≤ k = Size< ↑ k
-- Since j <= ↑ k does not hold (we have only k < j),
-- we cannot do the usual subtyping Size< j <= Size≤ k,
-- but we have to use the "singleton type property"
-- k : Size< ↑ k
| 24.533333
| 58
| 0.580163
|
fbaf3bb592fa76b0d48c2901503c515b4aaae46d
| 5,495
|
agda
|
Agda
|
src/Prelude.agda
|
mietek/nbe-correctness
|
54e9a83a8db4e33a33bf5dae5b2d651ad38aa3d5
|
[
"X11"
] | 3
|
2017-03-23T06:25:23.000Z
|
2017-03-23T18:51:34.000Z
|
src/Prelude.agda
|
mietek/nbe-correctness
|
54e9a83a8db4e33a33bf5dae5b2d651ad38aa3d5
|
[
"X11"
] | null | null | null |
src/Prelude.agda
|
mietek/nbe-correctness
|
54e9a83a8db4e33a33bf5dae5b2d651ad38aa3d5
|
[
"X11"
] | null | null | null |
module Prelude where
open import Agda.Primitive public
using (_⊔_)
renaming (lsuc to ↑_)
-- Built-in implication.
id : ∀ {ℓ} {X : Set ℓ} → X → X
id x = x
const : ∀ {ℓ ℓ′} {X : Set ℓ} {Y : Set ℓ′} → X → Y → X
const x y = x
flip : ∀ {ℓ ℓ′ ℓ″} {X : Set ℓ} {Y : Set ℓ′} {Z : Set ℓ″} →
(X → Y → Z) → Y → X → Z
flip P y x = P x y
ap : ∀ {ℓ ℓ′ ℓ″} {X : Set ℓ} {Y : Set ℓ′} {Z : Set ℓ″} →
(X → Y → Z) → (X → Y) → X → Z
ap f g x = f x (g x)
infixr 9 _∘_
_∘_ : ∀ {ℓ ℓ′ ℓ″} {X : Set ℓ} {Y : Set ℓ′} {Z : Set ℓ″} →
(Y → Z) → (X → Y) → X → Z
f ∘ g = λ x → f (g x)
refl→ : ∀ {ℓ} {X : Set ℓ} → X → X
refl→ = id
trans→ : ∀ {ℓ ℓ′ ℓ″} {X : Set ℓ} {Y : Set ℓ′} {Z : Set ℓ″} →
(X → Y) → (Y → Z) → X → Z
trans→ = flip _∘_
-- Built-in verum.
open import Agda.Builtin.Unit public
using (⊤)
renaming (tt to ∙)
-- Falsum.
data ⊥ : Set where
{-# HASKELL data AgdaEmpty #-}
{-# COMPILED_DATA ⊥ MAlonzo.Code.Data.Empty.AgdaEmpty #-}
elim⊥ : ∀ {ℓ} {X : Set ℓ} → ⊥ → X
elim⊥ ()
-- Negation.
infix 3 ¬_
¬_ : ∀ {ℓ} → Set ℓ → Set ℓ
¬ X = X → ⊥
_↯_ : ∀ {ℓ ℓ′} {X : Set ℓ} {Y : Set ℓ′} → X → ¬ X → Y
p ↯ ¬p = elim⊥ (¬p p)
-- Built-in equality.
open import Agda.Builtin.Equality public
using (_≡_ ; refl)
infix 4 _≢_
_≢_ : ∀ {ℓ} {X : Set ℓ} → X → X → Set ℓ
x ≢ x′ = ¬ (x ≡ x′)
trans : ∀ {ℓ} {X : Set ℓ} {x x′ x″ : X} → x ≡ x′ → x′ ≡ x″ → x ≡ x″
trans refl refl = refl
sym : ∀ {ℓ} {X : Set ℓ} {x x′ : X} → x ≡ x′ → x′ ≡ x
sym refl = refl
subst : ∀ {ℓ ℓ′} {X : Set ℓ} → (P : X → Set ℓ′) →
∀ {x x′} → x ≡ x′ → P x → P x′
subst P refl p = p
cong : ∀ {ℓ ℓ′} {X : Set ℓ} {Y : Set ℓ′} → (f : X → Y) →
∀ {x x′} → x ≡ x′ → f x ≡ f x′
cong f refl = refl
cong² : ∀ {ℓ ℓ′ ℓ″} {X : Set ℓ} {Y : Set ℓ′} {Z : Set ℓ″} → (f : X → Y → Z) →
∀ {x x′ y y′} → x ≡ x′ → y ≡ y′ → f x y ≡ f x′ y′
cong² f refl refl = refl
cong³ : ∀ {ℓ ℓ′ ℓ″ ℓ‴} {X : Set ℓ} {Y : Set ℓ′} {Z : Set ℓ″} {A : Set ℓ‴} →
(f : X → Y → Z → A) →
∀ {x x′ y y′ z z′} → x ≡ x′ → y ≡ y′ → z ≡ z′ → f x y z ≡ f x′ y′ z′
cong³ f refl refl refl = refl
-- Equational reasoning with built-in equality.
module ≡-Reasoning {ℓ} {X : Set ℓ} where
infix 1 begin_
begin_ : ∀ {x x′ : X} → x ≡ x′ → x ≡ x′
begin p = p
infixr 2 _≡⟨⟩_
_≡⟨⟩_ : ∀ (x {x′} : X) → x ≡ x′ → x ≡ x′
x ≡⟨⟩ p = p
infixr 2 _≡⟨_⟩_
_≡⟨_⟩_ : ∀ (x {x′ x″} : X) → x ≡ x′ → x′ ≡ x″ → x ≡ x″
x ≡⟨ p ⟩ q = trans p q
infix 3 _∎
_∎ : ∀ (x : X) → x ≡ x
x ∎ = refl
open ≡-Reasoning public
-- Constructive existence.
infixl 5 _,_
record Σ {ℓ ℓ′} (X : Set ℓ) (Y : X → Set ℓ′) : Set (ℓ ⊔ ℓ′) where
constructor _,_
field
π₁ : X
π₂ : Y π₁
open Σ public
-- Conjunction.
infixr 2 _∧_
_∧_ : ∀ {ℓ ℓ′} → Set ℓ → Set ℓ′ → Set (ℓ ⊔ ℓ′)
X ∧ Y = Σ X (λ x → Y)
-- Disjunction.
infixr 1 _∨_
data _∨_ {ℓ ℓ′} (X : Set ℓ) (Y : Set ℓ′) : Set (ℓ ⊔ ℓ′) where
ι₁ : X → X ∨ Y
ι₂ : Y → X ∨ Y
{-# HASKELL type AgdaEither _ _ x y = Either x y #-}
{-# COMPILED_DATA _∨_ MAlonzo.Code.Data.Sum.AgdaEither Left Right #-}
elim∨ : ∀ {ℓ ℓ′ ℓ″} {X : Set ℓ} {Y : Set ℓ′} {Z : Set ℓ″} →
X ∨ Y → (X → Z) → (Y → Z) → Z
elim∨ (ι₁ x) f g = f x
elim∨ (ι₂ y) f g = g y
-- Equivalence.
infix 3 _↔_
_↔_ : ∀ {ℓ ℓ′} → (X : Set ℓ) (Y : Set ℓ′) → Set (ℓ ⊔ ℓ′)
X ↔ Y = (X → Y) ∧ (Y → X)
infix 3 _↮_
_↮_ : ∀ {ℓ ℓ′} → (X : Set ℓ) (Y : Set ℓ′) → Set (ℓ ⊔ ℓ′)
X ↮ Y = ¬ (X ↔ Y)
refl↔ : ∀ {ℓ} {X : Set ℓ} → X ↔ X
refl↔ = refl→ , refl→
trans↔ : ∀ {ℓ ℓ′ ℓ″} {X : Set ℓ} {Y : Set ℓ′} {Z : Set ℓ″} →
X ↔ Y → Y ↔ Z → X ↔ Z
trans↔ (P , Q) (P′ , Q′) = trans→ P P′ , trans→ Q′ Q
sym↔ : ∀ {ℓ ℓ′} {X : Set ℓ} {Y : Set ℓ′} → X ↔ Y → Y ↔ X
sym↔ (P , Q) = Q , P
antisym→ : ∀ {ℓ ℓ′} {X : Set ℓ} {Y : Set ℓ′} →
((X → Y) ∧ (Y → X)) ≡ (X ↔ Y)
antisym→ = refl
≡→↔ : ∀ {ℓ} {X Y : Set ℓ} → X ≡ Y → X ↔ Y
≡→↔ refl = refl↔
-- Equational reasoning with equivalence.
module ↔-Reasoning where
infix 1 begin↔_
begin↔_ : ∀ {ℓ ℓ′} {X : Set ℓ} {Y : Set ℓ′} → X ↔ Y → X ↔ Y
begin↔ P = P
infixr 2 _↔⟨⟩_
_↔⟨⟩_ : ∀ {ℓ ℓ′} → (X : Set ℓ) → {Y : Set ℓ′} → X ↔ Y → X ↔ Y
X ↔⟨⟩ P = P
infixr 2 _≡→↔⟨⟩_
_≡→↔⟨⟩_ : ∀ {ℓ} → (X : Set ℓ) → {Y : Set ℓ} → X ≡ Y → X ↔ Y
X ≡→↔⟨⟩ P = ≡→↔ P
infixr 2 _↔⟨_⟩_
_↔⟨_⟩_ : ∀ {ℓ ℓ′ ℓ″} → (X : Set ℓ) → {Y : Set ℓ′} {Z : Set ℓ″} →
X ↔ Y → Y ↔ Z → X ↔ Z
X ↔⟨ P ⟩ Q = trans↔ P Q
infix 3 _∎↔
_∎↔ : ∀ {ℓ} → (X : Set ℓ) → X ↔ X
X ∎↔ = refl↔
open ↔-Reasoning public
-- Booleans.
open import Agda.Builtin.Bool public
using (Bool ; false ; true)
elimBool : ∀ {ℓ} {X : Set ℓ} → Bool → X → X → X
elimBool false z s = z
elimBool true z s = s
-- Conditionals.
data Maybe {ℓ} (X : Set ℓ) : Set ℓ where
nothing : Maybe X
just : X → Maybe X
{-# HASKELL type AgdaMaybe _ x = Maybe x #-}
{-# COMPILED_DATA Maybe MAlonzo.Code.Data.Maybe.Base.AgdaMaybe Just Nothing #-}
elimMaybe : ∀ {ℓ ℓ′} {X : Set ℓ} {Y : Set ℓ′} → Maybe X → Y → (X → Y) → Y
elimMaybe nothing z f = z
elimMaybe (just x) z f = f x
-- Naturals.
open import Agda.Builtin.Nat public
using (Nat ; zero ; suc)
elimNat : ∀ {ℓ} {X : Set ℓ} → Nat → X → (Nat → X → X) → X
elimNat zero z f = z
elimNat (suc n) z f = f n (elimNat n z f)
-- Decidability.
data Dec {ℓ} (X : Set ℓ) : Set ℓ where
yes : X → Dec X
no : ¬ X → Dec X
mapDec : ∀ {ℓ ℓ′} {X : Set ℓ} {Y : Set ℓ′} →
(X → Y) → (Y → X) → Dec X → Dec Y
mapDec f g (yes x) = yes (f x)
mapDec f g (no ¬x) = no (λ y → g y ↯ ¬x)
⌊_⌋Dec : ∀ {ℓ} {X : Set ℓ} → Dec X → Bool
⌊ yes x ⌋Dec = true
⌊ no ¬x ⌋Dec = false
| 21.29845
| 79
| 0.44859
|
063fc54551fc842bfb86123ee862607ad8fa9b10
| 1,147
|
agda
|
Agda
|
test/Succeed/Issue5075.agda
|
sseefried/agda
|
6b13364d36eeb60d8ec15eaf8effe23c73401900
|
[
"BSD-2-Clause"
] | 1
|
2022-02-05T01:20:23.000Z
|
2022-02-05T01:20:23.000Z
|
test/Succeed/Issue5075.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 6
|
2021-10-18T08:12:24.000Z
|
2021-11-24T08:31:10.000Z
|
test/Succeed/Issue5075.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | null | null | null |
open import Agda.Builtin.Reflection renaming (bindTC to _>>=_)
open import Agda.Builtin.Sigma
open import Agda.Builtin.List
open import Agda.Builtin.Unit
open import Agda.Builtin.Nat
map : {A B : Set} → (A → B) → List A → List B
map f [] = []
map f (x ∷ xs) = f x ∷ map f xs
reverseAcc : {A : Set} → List A → List A → List A
reverseAcc [] ys = ys
reverseAcc (x ∷ xs) ys = reverseAcc xs (x ∷ ys)
reverse : {A : Set} → List A → List A
reverse xs = reverseAcc xs []
data Vec (A : Set) : Nat → Set where
_∷_ : ∀ {n} (x : A) (xs : Vec A n) → Vec A (suc n)
postulate
replicate : ∀ {A : Set} {n} → A → Vec A n
zipWith : ∀ {A B C : Set} {n} → (A → B → C) → Vec A n → Vec B n → Vec C n
macro
rtest : Name → Term → TC ⊤
rtest f a = do
(function (clause tel _ t ∷ [])) ← withReconstructed (getDefinition f) where
_ → typeError (strErr "ERROR" ∷ [])
t ← inContext (reverse tel) (normalise t)
quoteTC t >>= unify a
transp : ∀ m n → Vec (Vec Nat n) m → Vec (Vec Nat m) n
transp .(suc m) n (_∷_ {m} x xs) = zipWith {Nat} {Vec Nat m} {Vec Nat (suc m)} {n} (_∷_ {Nat} {m}) x (transp _ n xs)
test : Term
test = rtest transp
| 30.184211
| 116
| 0.584133
|
0bb1c5b6a558342774c31c950dbb259ef587b759
| 131
|
agda
|
Agda
|
propositional-equality.agda
|
guilhermehas/Equality
|
e1104012d85d2072318656f6c6d31acff75c9460
|
[
"MIT"
] | 1
|
2021-10-01T06:04:21.000Z
|
2021-10-01T06:04:21.000Z
|
propositional-equality.agda
|
guilhermehas/Equality
|
e1104012d85d2072318656f6c6d31acff75c9460
|
[
"MIT"
] | null | null | null |
propositional-equality.agda
|
guilhermehas/Equality
|
e1104012d85d2072318656f6c6d31acff75c9460
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical #-}
module propositional-equality where
open import Cubical.Foundations.Prelude
open import Agda.Primitive
| 18.714286
| 39
| 0.793893
|
a14c0d99017f4aaf667b7d87a8858f1d05699085
| 1,798
|
agda
|
Agda
|
Types.agda
|
danelahman/higher-order-aeff-agda
|
b41df71f4456666aab4bd14e13d285c31af80ff6
|
[
"MIT"
] | 2
|
2021-08-17T15:00:34.000Z
|
2022-02-05T18:50:26.000Z
|
Types.agda
|
danelahman/modal-aeff-agda
|
b41df71f4456666aab4bd14e13d285c31af80ff6
|
[
"MIT"
] | null | null | null |
Types.agda
|
danelahman/modal-aeff-agda
|
b41df71f4456666aab4bd14e13d285c31af80ff6
|
[
"MIT"
] | null | null | null |
open import Data.Empty
open import Data.Product
open import Data.Unit
open import Relation.Binary.PropositionalEquality hiding ([_] ; Extensionality)
open import Relation.Nullary
open import Relation.Nullary.Negation
open import EffectAnnotations
module Types where
-- BASE TYPES
postulate BType : Set
-- VALUE AND COMPUTATION TYPES
mutual
data VType : Set where
`` : BType → VType
𝟙 : VType
_⇒_ : VType → CType → VType
⟨_⟩ : VType → VType
□ : VType → VType
data CType : Set where
_!_ : VType → O × I → CType
infix 30 _⇒_
infix 30 _!_
-- MOBILE TYPES
mobile : VType → Set
mobile (`` A) = ⊤
mobile 𝟙 = ⊤
mobile (X ⇒ C) = ⊥
mobile ⟨ X ⟩ = ⊥
mobile (□ X) = ⊤
-- PROCESS TYPES
data PTypeShape : Set where
_!_ : VType → I → PTypeShape
_∥_ : PTypeShape → PTypeShape → PTypeShape
data PType : O → Set where
_‼_,_ : (X : VType) →
(o : O) →
(i : I) →
---------------
PType o
_∥_ : {o o' : O} →
(PP : PType o) →
(QQ : PType o') →
---------------------------
PType (o ∪ₒ o')
-- ACTION OF INTERRUPTS ON PROCESS TYPES
_↓ₚₚ_ : (op : Σₛ) → {o : O} →
PType o → Σ[ o' ∈ O ] PType o'
op ↓ₚₚ (X ‼ o , i) with op ↓ₑ (o , i)
... | (o' , i') =
o' , (X ‼ o' , i')
op ↓ₚₚ (PP ∥ QQ) with op ↓ₚₚ PP | op ↓ₚₚ QQ
... | (o'' , PP') | (o''' , QQ') =
(o'' ∪ₒ o''') , (PP' ∥ QQ')
_↓ₚ_ : (op : Σₛ) → {o : O} →
(PP : PType o) → PType (proj₁ (op ↓ₚₚ PP))
op ↓ₚ PP = proj₂ (op ↓ₚₚ PP)
-- ACTION OF INTERRUPTS ON PROCESS TYPES PRESERVES SIGNAL ANNOTATIONS
↓ₚₚ-⊑ₒ : {op : Σₛ}
{o : O} →
(PP : PType o) →
----------------------
o ⊑ₒ proj₁ (op ↓ₚₚ PP)
↓ₚₚ-⊑ₒ (X ‼ o , i) =
↓ₑ-⊑ₒ
↓ₚₚ-⊑ₒ (PP ∥ QQ) =
∪ₒ-fun (↓ₚₚ-⊑ₒ PP) (↓ₚₚ-⊑ₒ QQ)
| 18.536082
| 79
| 0.497219
|
df1a2e05e4d48050ab3a43b8003bdbfa4df8a10b
| 1,525
|
agda
|
Agda
|
lib/Explore/Two.agda
|
crypto-agda/explore
|
16bc8333503ff9c00d47d56f4ec6113b9269a43e
|
[
"BSD-3-Clause"
] | 2
|
2016-06-05T09:25:32.000Z
|
2017-06-28T19:19:29.000Z
|
lib/Explore/Two.agda
|
crypto-agda/explore
|
16bc8333503ff9c00d47d56f4ec6113b9269a43e
|
[
"BSD-3-Clause"
] | 1
|
2019-03-16T14:24:04.000Z
|
2019-03-16T14:24:04.000Z
|
lib/Explore/Two.agda
|
crypto-agda/explore
|
16bc8333503ff9c00d47d56f4ec6113b9269a43e
|
[
"BSD-3-Clause"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import Type
open import Type.Identities
open import Level.NP
open import Data.Two
open import Function
open import Function.Extensionality
open import Data.Product
open import Data.Sum
open import Data.Fin
open import Relation.Binary.PropositionalEquality.NP using (_≡_; refl; !_; _∙_)
open import Relation.Binary.Sum
open import HoTT
open import Explore.Sum
open import Explore.Core
open import Explore.Properties
open import Explore.Explorable
module Explore.Two where
module _ {ℓ} where
𝟚ᵉ : Explore ℓ 𝟚
𝟚ᵉ _ _∙_ f = f 0₂ ∙ f 1₂
𝟚ⁱ : ∀ {p} → ExploreInd p 𝟚ᵉ
𝟚ⁱ _ _ _P∙_ Pf = Pf 0₂ P∙ Pf 1₂
module _ {ℓ₁ ℓ₂ ℓᵣ} {R : 𝟚 → 𝟚 → ★₀} {r0 : R 0₂ 0₂}{r1 : R 1₂ 1₂} where
⟦𝟚ᵉ⟧ : ⟦Explore⟧ {ℓ₁} {ℓ₂} ℓᵣ R 𝟚ᵉ 𝟚ᵉ
⟦𝟚ᵉ⟧ _ _ _∙ᵣ_ fᵣ = fᵣ r0 ∙ᵣ fᵣ r1
module 𝟚ⁱ = FromExploreInd 𝟚ⁱ
open 𝟚ⁱ public using ()
renaming (sum to 𝟚ˢ
;product to 𝟚ᵖ
;reify to 𝟚ʳ
;unfocus to 𝟚ᵘ
)
module _ {ℓ} where
module _ {{_ : UA}}{{_ : FunExt}} where
Σᵉ𝟚-ok : Adequate-Σ {ℓ} (Σᵉ 𝟚ᵉ)
Σᵉ𝟚-ok _ = ! Σ𝟚-⊎
Πᵉ𝟚-ok : Adequate-Π {ℓ} (Πᵉ 𝟚ᵉ)
Πᵉ𝟚-ok _ = ! Π𝟚-×
𝟚ˡ : Lookup {ℓ} 𝟚ᵉ
𝟚ˡ = proj
𝟚ᶠ : Focus {ℓ} 𝟚ᵉ
𝟚ᶠ (0₂ , x) = inj₁ x
𝟚ᶠ (1₂ , x) = inj₂ x
explore𝟚 = 𝟚ᵉ
explore𝟚-ind = 𝟚ⁱ
lookup𝟚 = 𝟚ˡ
reify𝟚 = 𝟚ʳ
focus𝟚 = 𝟚ᶠ
unfocus𝟚 = 𝟚ᵘ
sum𝟚 = 𝟚ˢ
module _ {{_ : UA}}{{_ : FunExt}} where
open Adequacy _≡_
𝟚ˢ-ok : Adequate-sum 𝟚ˢ
𝟚ˢ-ok f = ! (Σ𝟚-⊎ ∙ Fin-⊎-+)
| 22.101449
| 79
| 0.592787
|
10309dc1d6ce8c224a45e22f9ef04076d939fc21
| 3,163
|
agda
|
Agda
|
old/Metalogic/Metalogic/Classical/Propositional/TruthSemanticsModel.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
old/Metalogic/Metalogic/Classical/Propositional/TruthSemanticsModel.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
old/Metalogic/Metalogic/Classical/Propositional/TruthSemanticsModel.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
module Metalogic.Classical.Propositional.TruthSemanticsModel {ℓ} (Proposition : Set(ℓ)) where
import Lvl
open import Data.Boolean
open import Data
open import Data.Tuple as Tuple using (_⨯_ ; _,_)
open import Functional
open import Metalogic.Classical.Propositional.Syntax{ℓ} (Proposition)
renaming (
⊤ to ⊤ₗ ;
⊥ to ⊥ₗ ;
¬_ to ¬ₗ_ ;
_∧_ to _∧ₗ_ ;
_∨_ to _∨ₗ_ ;
_⇒_ to _⇒ₗ_ )
open import Relator.Equals
open import Relator.Equals.Proofs
open import Sets.BoolSet
-- A model decides whether a proposition is true or false
-- Also known as Interpretation, Structure, Model
record Model : Set(ℓ) where
field
interpretProp : Proposition → Bool
-- TODO: Can this be called a "theory" of propositional logic? So that instances of the type Semantics is the "models" of logic?
-- TODO: Now, all the metalogic depends on booleans, which may not be satisfactory
module _ where
import Data.Boolean.Operators
open Data.Boolean.Operators.Logic
satisfaction : Model → Formula → Bool
satisfaction(𝔐)(• prop) = Model.interpretProp(𝔐) (prop)
satisfaction(𝔐)(⊤ₗ) = 𝑇
satisfaction(𝔐)(⊥ₗ) = 𝐹
satisfaction(𝔐)(¬ₗ φ) = ¬(satisfaction(𝔐)(φ))
satisfaction(𝔐)(φ₁ ∧ₗ φ₂) = (satisfaction(𝔐)(φ₁)) ∧ (satisfaction(𝔐)(φ₂))
satisfaction(𝔐)(φ₁ ∨ₗ φ₂) = (satisfaction(𝔐)(φ₁)) ∨ (satisfaction(𝔐)(φ₂))
satisfaction(𝔐)(φ₁ ⇒ₗ φ₂) = ¬(satisfaction(𝔐)(φ₁)) ∨ (satisfaction(𝔐)(φ₂))
-- Syntactic details with the relation symbol
record SatisfactionRelation {ℓ₁}{ℓ₂} (Obj : Set(ℓ) → Set(ℓ₁)) : Set(Lvl.𝐒(ℓ Lvl.⊔ ℓ₁ Lvl.⊔ ℓ₂)) where
field
_⊧_ : Model → Obj(Formula) → Set(ℓ₂)
open SatisfactionRelation ⦃ ... ⦄ public
instance
-- Satisfaction for a single formula
formula-satisfaction-relation : SatisfactionRelation(id)
formula-satisfaction-relation = record{_⊧_ = \𝔐 φ → satisfaction(𝔐)(φ) ≡ 𝑇}
instance
-- Satisfaction for a list of formulas
list-satisfaction-relation : SatisfactionRelation(BoolSet{ℓ})
list-satisfaction-relation = record{_⊧_ = \𝔐 Γ → (∀{γ} → (γ ∈ Γ) → satisfaction(𝔐)(γ) ≡ 𝑇)}
-- Entailment
data _⊨_ (Γ : BoolSet{ℓ}(Formula)) (φ : Formula) : Set(ℓ) where
[⊨]-intro : (∀{𝔐} → (𝔐 ⊧ Γ) → (𝔐 ⊧ φ)) → (Γ ⊨ φ)
_⊭_ : BoolSet{ℓ}(Formula) → Formula → Set(ℓ)
_⊭_ Γ φ = (_⊨_ Γ φ) → Empty{ℓ}
-- Validity
valid : Formula → Set(ℓ)
valid = (∅ ⊨_)
module Theorems where
[⊤]-entailment : (∅ ⊨ ⊤ₗ)
[⊤]-entailment = [⊨]-intro(const [≡]-intro)
-- ∅ ⊨ ⊤ₗ
-- ∀{𝔐} → (𝔐 ⊧ ∅) → (𝔐 ⊧ ⊤ₗ)
-- ∀{𝔐} → (𝔐 ⊧ ∅) → (satisfaction(𝔐)(⊤ₗ) ≡ 𝑇)
-- ∀{𝔐} → (∀{γ} → (γ ∈ ∅) → satisfaction(𝔐)(γ) ≡ 𝑇) → (satisfaction(𝔐)(⊤ₗ) ≡ 𝑇)
-- [∧]-entailment : ∀{φ₁ φ₂} → ([ φ₁ ⊰ φ₂ ] ⊨ (φ₁ ∧ₗ φ₂))
-- [∧]-entailment{φ₁}{φ₂} = [⊨]-intro ([∈]-proof ↦ congruence₁-op(_∧_) ([∈]-proof (use)) ([∈]-proof (skip use)))
-- [ φ₁ ⊰ φ₂ ] ⊨ (φ₁ ∧ φ₂)
-- ∀{𝔐} → (𝔐 ⊧ [ φ₁ ⊰ φ₂ ]) → (𝔐 ⊧ (φ₁ ∧ φ₂))
-- ∀{𝔐} → (𝔐 ⊧ [ φ₁ ⊰ φ₂ ]) → (satisfaction(𝔐)(φ₁ ∧ₗ φ₂) ≡ 𝑇)
-- ∀{𝔐} → (𝔐 ⊧ [ φ₁ ⊰ φ₂ ]) → (satisfaction(𝔐)(φ₁) ∧ satisfaction(𝔐)(φ₂) ≡ 𝑇)
-- ∀{𝔐} → (∀{γ} → (γ ∈ [ φ₁ ⊰ φ₂ ]) → satisfaction(𝔐)(γ) ≡ 𝑇) → (satisfaction(𝔐)(φ₁) ∧ satisfaction(𝔐)(φ₂) ≡ 𝑇)
| 38.108434
| 128
| 0.595005
|
1c8b9dd2f9fcfbbcf4fa77093b1ac839bd473a35
| 878
|
agda
|
Agda
|
test/Succeed/Issue392.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Succeed/Issue392.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/Issue392.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | 1
|
2019-03-05T20:02:38.000Z
|
2019-03-05T20:02:38.000Z
|
-- Andreas, 2011-09-11
module Issue392 where
import Common.Irrelevance
-- Create an irrelevant record R1 (all fields irrelevant).
record R1 : Set1 where
field
.f1 : Set
{- module R1 .(r : R1) where
.f1 : Set -- = R1.f1 r
-}
-- Create an irrelevant instance f2 of R1.
record R2 : Set2 where
field
.f2 : R1
f3 : Set
-- This succeeds even though f2 is irrelevant.
open R1 f2 public
{- A more realistic use would be s.th. like
record IsEquivalence {a ℓ} {A : Set a}
(_≈_ : Rel A ℓ) : Set (a ⊔ ℓ) where
field
.refl : Reflexive _≈_
.sym : Symmetric _≈_
.trans : Transitive _≈_
record Setoid c ℓ : Set (suc (c ⊔ ℓ)) where
infix 4 _≈_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ
.isEquivalence : IsEquivalence _≈_
open IsEquivalence isEquivalence public
-}
| 20.904762
| 58
| 0.593394
|
0e7c880b2195c173b2dd94e89882c8a0904aaa73
| 1,195
|
agda
|
Agda
|
src/data/lib/prim/Agda/Builtin/Nat.agda
|
redfish64/autonomic-agda
|
c0ae7d20728b15d7da4efff6ffadae6fe4590016
|
[
"BSD-3-Clause"
] | null | null | null |
src/data/lib/prim/Agda/Builtin/Nat.agda
|
redfish64/autonomic-agda
|
c0ae7d20728b15d7da4efff6ffadae6fe4590016
|
[
"BSD-3-Clause"
] | null | null | null |
src/data/lib/prim/Agda/Builtin/Nat.agda
|
redfish64/autonomic-agda
|
c0ae7d20728b15d7da4efff6ffadae6fe4590016
|
[
"BSD-3-Clause"
] | null | null | null |
module Agda.Builtin.Nat where
open import Agda.Builtin.Bool
data Nat : Set where
zero : Nat
suc : (n : Nat) → Nat
{-# BUILTIN NATURAL Nat #-}
infix 4 _==_ _<_
infixl 6 _+_ _-_
infixl 7 _*_
_+_ : Nat → Nat → Nat
zero + m = m
suc n + m = suc (n + m)
{-# BUILTIN NATPLUS _+_ #-}
_-_ : Nat → Nat → Nat
n - zero = n
zero - suc m = zero
suc n - suc m = n - m
{-# BUILTIN NATMINUS _-_ #-}
_*_ : Nat → Nat → Nat
zero * m = zero
suc n * m = m + n * m
{-# BUILTIN NATTIMES _*_ #-}
_==_ : Nat → Nat → Bool
zero == zero = true
suc n == suc m = n == m
_ == _ = false
{-# BUILTIN NATEQUALS _==_ #-}
_<_ : Nat → Nat → Bool
_ < zero = false
zero < suc _ = true
suc n < suc m = n < m
{-# BUILTIN NATLESS _<_ #-}
div-helper : Nat → Nat → Nat → Nat → Nat
div-helper k m zero j = k
div-helper k m (suc n) zero = div-helper (suc k) m n m
div-helper k m (suc n) (suc j) = div-helper k m n j
{-# BUILTIN NATDIVSUCAUX div-helper #-}
mod-helper : Nat → Nat → Nat → Nat → Nat
mod-helper k m zero j = k
mod-helper k m (suc n) zero = mod-helper 0 m n m
mod-helper k m (suc n) (suc j) = mod-helper (suc k) m n j
{-# BUILTIN NATMODSUCAUX mod-helper #-}
| 19.274194
| 57
| 0.555649
|
397ad41ce2041452a91be7be93f037d82355eaac
| 6,070
|
agda
|
Agda
|
src/Categories/Diagram/Coend/Properties.agda
|
jaykru/agda-categories
|
a4053cf700bcefdf73b857c3352f1eae29382a60
|
[
"MIT"
] | 279
|
2019-06-01T14:36:40.000Z
|
2022-03-22T00:40:14.000Z
|
src/Categories/Diagram/Coend/Properties.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 236
|
2019-06-01T14:53:54.000Z
|
2022-03-28T14:31:43.000Z
|
src/Categories/Diagram/Coend/Properties.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 64
|
2019-06-02T16:58:15.000Z
|
2022-03-14T02:00:59.000Z
|
{-# OPTIONS --without-K --safe #-}
module Categories.Diagram.Coend.Properties where
open import Categories.Category.Core using (Category)
open import Categories.Category.Product
import Categories.Category.Construction.Cowedges as Cowedges
open import Categories.Category.Construction.Functors
open import Categories.Category.Equivalence
open import Categories.Category.Equivalence.Preserves
open import Categories.Diagram.Coend
open import Categories.Diagram.Colimit
open import Categories.Diagram.Cowedge
open import Categories.Diagram.Cowedge.Properties
open import Categories.Functor using (Functor)
open import Categories.Functor.Bifunctor using (Bifunctor)
open import Categories.Functor.Instance.Twisted
import Categories.Morphism as M
open import Categories.NaturalTransformation hiding (id)
open import Categories.NaturalTransformation.Dinatural
open import Categories.Object.Initial as Initial
import Categories.Morphism.Reasoning as MR
open import Level
open import Data.Product using (Σ; _,_)
open import Function using (_$_)
module _ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′}
(F : Bifunctor (Category.op C) C D) where
open Cowedges F
-- Being a Coend is the same as being an Initial object in the category of Cowedges
Coend⇒Initial : Coend F → Initial Cowedges
Coend⇒Initial c = record
{ ⊥ = cowedge
; ⊥-is-initial = record
{ ! = λ {A} → record { u = factor A ; commute = universal }
; !-unique = λ {A} f → unique {A} (Cowedge-Morphism.commute f)
}
}
where
open Coend c
Initial⇒Coend : Initial Cowedges → Coend F
Initial⇒Coend i = record
{ cowedge = ⊥
; factor = λ W → u {W₂ = W} !
; universal = commute !
; unique = λ {_} {g} x → !-unique (record { u = g ; commute = x })
}
where
open Initial.Initial i
open Cowedge-Morphism
private
variable
o ℓ e : Level
C D E : Category o ℓ e
module _ (F : Functor E (Functors (Product (Category.op C) C) D)) where
private
module C = Category C
module D = Category D
module E = Category E
module NT = NaturalTransformation
open D
open HomReasoning
open MR D
open Functor F
open Coend hiding (E)
open NT using (η)
CoendF : (∀ X → Coend (F₀ X)) → Functor E D
CoendF coend = record
{ F₀ = λ X → Coend.E (coend X)
; F₁ = F₁′
; identity = λ {A} → unique (coend A) (id-comm-sym ○ ∘-resp-≈ʳ (⟺ identity))
; homomorphism = λ {A B C} {f g} → unique (coend A) $ λ {Z} → begin
(F₁′ g ∘ F₁′ f) ∘ dinatural.α (coend A) Z ≈⟨ pullʳ (universal (coend A)) ⟩
(F₁′ g ∘ (dinatural.α (coend B) Z ∘ η (F₁ f) (Z , Z) ) ) ≈⟨ pullˡ (universal (coend B)) ⟩
((dinatural.α (coend C) Z ∘ η (F₁ g) (Z , Z)) ∘ η (F₁ f) (Z , Z)) ≈˘⟨ pushʳ homomorphism ⟩
dinatural.α (coend C) Z ∘ η (F₁ (g E.∘ f)) (Z , Z) ∎
; F-resp-≈ = λ {A B f g} eq → unique (coend A) $ λ {Z} → begin
F₁′ g ∘ dinatural.α (coend A) Z ≈⟨ universal (coend A) ⟩
dinatural.α (coend B) Z ∘ η (F₁ g) (Z , Z) ≈˘⟨ refl⟩∘⟨ F-resp-≈ eq ⟩
dinatural.α (coend B) Z ∘ η (F₁ f) (Z , Z) ∎
}
where F₁′ : ∀ {X Y} → X E.⇒ Y → Coend.E (coend X) ⇒ Coend.E (coend Y)
F₁′ {X} {Y} f = factor (coend X) $ record
{ E = Coend.E (coend Y)
; dinatural = dinatural (coend Y) ∘> F₁ f
}
-- A Natural Transformation between two functors induces an arrow between the
-- (object part of) the respective coends.
module _ {P Q : Functor (Product (Category.op C) C) D} (P⇒Q : NaturalTransformation P Q) where
open Coend renaming (E to coend)
open Category D
coend-η : {cp : Coend P} {cq : Coend Q} → coend cp ⇒ coend cq
coend-η {cp} {cq} = factor cp ((record
{ E = Coend.E cq
; dinatural = dtHelper record
{ α = λ c → dinatural.α cq c ∘ η (c , c)
; commute = λ {C} {C′} f → begin
id ∘ (αq C ∘ η (C , C)) ∘ P.₁ (f , C.id) ≈⟨ pushʳ assoc ⟩
(id ∘ αq C) ∘ (η (C , C) ∘ P.₁ (f , C.id)) ≈⟨ refl⟩∘⟨ nt.commute (f , C.id) ⟩
(id ∘ αq C) ∘ (Q.₁ (f , C.id) ∘ η (C′ , C)) ≈⟨ pullˡ assoc ⟩
(id ∘ αq C ∘ Q.₁ (f , C.id)) ∘ η (C′ , C) ≈⟨ αq-comm f ⟩∘⟨refl ⟩
(id ∘ αq C′ ∘ Q.₁ (C.id , f)) ∘ η (C′ , C) ≈⟨ pushˡ sym-assoc ⟩
(id ∘ αq C′) ∘ Q.₁ (C.id , f) ∘ η (C′ , C) ≈⟨ refl⟩∘⟨ nt.sym-commute (C.id , f) ⟩
(id ∘ αq C′) ∘ η (C′ , C′) ∘ P.₁ (C.id , f) ≈⟨ pullʳ sym-assoc ⟩
id ∘ (αq C′ ∘ η (C′ , C′)) ∘ P.₁ (C.id , f) ∎
}
}))
where
module nt = NaturalTransformation P⇒Q
open nt using (η)
open HomReasoning
module C = Category C
module P = Functor P
module Q = Functor Q
open DinaturalTransformation (dinatural cp) renaming (α to αp; commute to αp-comm)
open DinaturalTransformation (dinatural cq) renaming (α to αq; commute to αq-comm)
open Cowedge
open MR D
module _ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′}
(F : Bifunctor (Category.op C) C D) where
private
Eq = CoconesTwist≅Cowedges F
module O = M D
open M (Cowedges.Cowedges F)
open Functor
open StrongEquivalence Eq renaming (F to F⇒)
-- Coends and Colimits are equivalent, in the category Cowedge F
Coend-as-Colimit : (coend : Coend F) → (cl : Colimit (Twist′ C D F)) → Coend.cowedge coend ≅ F₀ F⇒ (Colimit.initial.⊥ cl)
Coend-as-Colimit coend cl = Initial.up-to-iso (Cowedges.Cowedges F) (Coend⇒Initial F coend) (pres-Initial Eq initial)
where
open Colimit cl
-- Which then induces that the objects, in D, are also equivalent.
Coend-as-Colimit-on-Obj : (coend : Coend F) → (cl : Colimit (Twist′ C D F)) → Coend.E coend O.≅ Colimit.coapex cl
Coend-as-Colimit-on-Obj coend cl = record
{ from = Cowedge-Morphism.u (M._≅_.from X≅Y)
; to = Cowedge-Morphism.u (M._≅_.to X≅Y)
; iso = record
{ isoˡ = M._≅_.isoˡ X≅Y
; isoʳ = M._≅_.isoʳ X≅Y
}
}
where
X≅Y = Coend-as-Colimit coend cl
open Category D
| 38.176101
| 123
| 0.592092
|
3117120599021e1e8a249c22b785f6f122f102b7
| 2,409
|
agda
|
Agda
|
container/m/extensionality.agda
|
HoTT/M-types
|
beebe176981953ab48f37de5eb74557cfc5402f4
|
[
"BSD-3-Clause"
] | 27
|
2015-04-14T15:47:03.000Z
|
2022-01-09T07:26:57.000Z
|
src/container/m/extensionality.agda
|
pcapriotti/agda-base
|
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
|
[
"BSD-3-Clause"
] | 4
|
2015-02-02T14:32:16.000Z
|
2016-10-26T11:57:26.000Z
|
src/container/m/extensionality.agda
|
pcapriotti/agda-base
|
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
|
[
"BSD-3-Clause"
] | 4
|
2015-02-02T12:17:00.000Z
|
2019-05-04T19:31:00.000Z
|
module container.m.extensionality where
open import sum
open import equality
open import container.core
open import container.fixpoint
open import container.equality
open import container.m.core
module Extensionality {li la lb}(c : Container li la lb) where
private
module C where
open Definition c public
fp : Fixpoint c _
fp = fix M fixpoint
open Fixpoint fp public
using (head; tail)
module S where
open Equality c C.fp
using (equality)
open Equality c C.fp public
using (substX)
open Definition equality public
fp : Fixpoint equality _
fp = fix M fixpoint
open Fixpoint fp public
using (head; tail)
open C
-- bisimilarity relation
_≡M_ : ∀ {i}(u v : M i) → Set _
u ≡M v = S.M (_ , u , v)
reflM : ∀ {i}{u : M i} → u ≡M u
reflM = S.inf refl (λ b → ♯ reflM)
private
-- total space of bisimilarity
E : ∀ i → Set _
E i = Σ (M i × M i) (uncurry _≡M_)
f : E →ⁱ F E
f i ((xs , ys) , bisim)
= head xs
, (λ b → (( tail xs b
, S.substX (S.head bisim) b
(tail ys (subst B (S.head bisim) b)))
, S.tail bisim b))
π₁ : E →ⁱ M
π₁ i ((xs , _), _) = xs
π₁-mor : ∀ {i} (e : E i) → out i (π₁ i e) ≡ imap π₁ i (f i e)
π₁-mor ((xs , ys) , p) = refl
π₂ : E →ⁱ M
π₂ _ ((_ , ys), _) = ys
π₂-mor : ∀ {i} (e : E i) → out i (π₂ i e) ≡ imap π₂ i (f i e)
π₂-mor {i} ((xs , ys) , bisim) = lem (S.head bisim) (tail ys)
where
lem : {a a' : A i}(p : a ≡ a')
→ (f : (b' : B a') → M (r b'))
→ _≡_ {A = F M i}
(a' , f)
(a , λ b → S.substX p b (f (subst B p b)))
lem refl f = refl
equal-π : ∀ {i}(e : E i) → π₁ i e ≡ π₂ i e
equal-π e = unfold-η f π₁ π₁-mor e · sym (unfold-η f π₂ π₂-mor e)
abstract
mext₀ : ∀ {i} {xs ys : M i} → xs ≡M ys → xs ≡ ys
mext₀ p = equal-π (_ , p)
mext-inv : ∀ {i}{xs ys : M i} → xs ≡ ys → xs ≡M ys
mext-inv refl = reflM
mext : ∀ {i} {xs ys : M i} → xs ≡M ys → xs ≡ ys
mext p = mext₀ p · sym (mext₀ reflM)
mext-id : ∀ {i}{u : M i} → mext (reflM {u = u}) ≡ refl
mext-id = left-inverse (mext₀ reflM)
mext-retraction : ∀ {i}{xs ys : M i}(p : xs ≡ ys)
→ mext (mext-inv p) ≡ p
mext-retraction refl = left-inverse (mext₀ reflM)
| 25.62766
| 69
| 0.499792
|
1c3fd1a8ceed5b3964db37a029e0905358c9373a
| 16,114
|
agda
|
Agda
|
src/Delay-monad/Sized/Bisimilarity.agda
|
nad/delay-monad
|
495f9996673d0f1f34ce202902daaa6c39f8925e
|
[
"MIT"
] | null | null | null |
src/Delay-monad/Sized/Bisimilarity.agda
|
nad/delay-monad
|
495f9996673d0f1f34ce202902daaa6c39f8925e
|
[
"MIT"
] | null | null | null |
src/Delay-monad/Sized/Bisimilarity.agda
|
nad/delay-monad
|
495f9996673d0f1f34ce202902daaa6c39f8925e
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- A combined definition of strong and weak bisimilarity and
-- expansion, along with various properties
------------------------------------------------------------------------
{-# OPTIONS --sized-types #-}
module Delay-monad.Sized.Bisimilarity where
open import Equality.Propositional as E using (_≡_)
open import Logical-equivalence using (_⇔_)
open import Prelude
open import Prelude.Size
open import Function-universe E.equality-with-J hiding (_∘_; Kind)
open import Delay-monad.Sized
open import Delay-monad.Bisimilarity.Kind
------------------------------------------------------------------------
-- The code below is defined for a fixed type family A
module _ {a} {A : Size → Type a} where
----------------------------------------------------------------------
-- The relations
mutual
-- A combined definition of all three relations. The definition
-- uses mixed induction and coinduction.
--
-- Note that this type is not defined in the same way as Delay.
-- One might argue that the now constructor should have the
-- following type, using a /sized/ identity type Id:
--
-- now : ∀ {x y} →
-- Id (A ∞) i x y →
-- [ i ] now x ∼ now y
infix 4 [_]_⟨_⟩_ [_]_⟨_⟩′_
data [_]_⟨_⟩_ (i : Size) :
Delay A ∞ → Kind → Delay A ∞ → Type a where
now : ∀ {k x} → [ i ] now x ⟨ k ⟩ now x
later : ∀ {k x₁ x₂} →
[ i ] force x₁ ⟨ k ⟩′ force x₂ →
[ i ] later x₁ ⟨ k ⟩ later x₂
laterˡ : ∀ {k x₁ x₂} →
[ i ] force x₁ ⟨ other k ⟩ x₂ →
[ i ] later x₁ ⟨ other k ⟩ x₂
laterʳ : ∀ {x₁ x₂} →
[ i ] x₁ ⟨ other weak ⟩ force x₂ →
[ i ] x₁ ⟨ other weak ⟩ later x₂
record [_]_⟨_⟩′_ (i : Size)
(x₁ : Delay A ∞) (k : Kind) (x₂ : Delay A ∞) :
Type a where
coinductive
field
force : {j : Size< i} → [ j ] x₁ ⟨ k ⟩ x₂
open [_]_⟨_⟩′_ public
-- Strong bisimilarity.
infix 4 [_]_∼_ [_]_∼′_ _∼_ _∼′_
[_]_∼_ : Size → Delay A ∞ → Delay A ∞ → Type a
[_]_∼_ = [_]_⟨ strong ⟩_
[_]_∼′_ : Size → Delay A ∞ → Delay A ∞ → Type a
[_]_∼′_ = [_]_⟨ strong ⟩′_
_∼_ : Delay A ∞ → Delay A ∞ → Type a
_∼_ = [ ∞ ]_∼_
_∼′_ : Delay A ∞ → Delay A ∞ → Type a
_∼′_ = [ ∞ ]_∼′_
-- Expansion.
infix 4 [_]_≳_ [_]_≳′_ _≳_ _≳′_
[_]_≳_ : Size → Delay A ∞ → Delay A ∞ → Type a
[_]_≳_ = [_]_⟨ other expansion ⟩_
[_]_≳′_ : Size → Delay A ∞ → Delay A ∞ → Type a
[_]_≳′_ = [_]_⟨ other expansion ⟩′_
_≳_ : Delay A ∞ → Delay A ∞ → Type a
_≳_ = [ ∞ ]_≳_
_≳′_ : Delay A ∞ → Delay A ∞ → Type a
_≳′_ = [ ∞ ]_≳′_
-- The converse of expansion.
infix 4 [_]_≲_ [_]_≲′_ _≲_ _≲′_
[_]_≲_ : Size → Delay A ∞ → Delay A ∞ → Type a
[_]_≲_ i = flip [ i ]_⟨ other expansion ⟩_
[_]_≲′_ : Size → Delay A ∞ → Delay A ∞ → Type a
[_]_≲′_ i = flip [ i ]_⟨ other expansion ⟩′_
_≲_ : Delay A ∞ → Delay A ∞ → Type a
_≲_ = [ ∞ ]_≲_
_≲′_ : Delay A ∞ → Delay A ∞ → Type a
_≲′_ = [ ∞ ]_≲′_
-- Weak bisimilarity.
infix 4 [_]_≈_ [_]_≈′_ _≈_ _≈′_
[_]_≈_ : Size → Delay A ∞ → Delay A ∞ → Type a
[_]_≈_ = [_]_⟨ other weak ⟩_
[_]_≈′_ : Size → Delay A ∞ → Delay A ∞ → Type a
[_]_≈′_ = [_]_⟨ other weak ⟩′_
_≈_ : Delay A ∞ → Delay A ∞ → Type a
_≈_ = [ ∞ ]_≈_
_≈′_ : Delay A ∞ → Delay A ∞ → Type a
_≈′_ = [ ∞ ]_≈′_
----------------------------------------------------------------------
-- Conversions
-- Strong bisimilarity is contained in the other relations (and
-- itself).
∼→ : ∀ {k i x y} → [ i ] x ∼ y → [ i ] x ⟨ k ⟩ y
∼→ now = now
∼→ (later p) = later λ { .force → ∼→ (force p) }
-- Expansion is contained in weak bisimilarity (and expansion).
≳→ : ∀ {k i x y} → [ i ] x ≳ y → [ i ] x ⟨ other k ⟩ y
≳→ now = now
≳→ (later p) = later λ { .force → ≳→ (force p) }
≳→ (laterˡ p) = laterˡ (≳→ p)
-- In some cases weak bisimilarity is contained in expansion (and
-- itself).
≈→-now : ∀ {k i x y} → [ i ] x ≈ now y → [ i ] x ⟨ other k ⟩ now y
≈→-now now = now
≈→-now (laterˡ p) = laterˡ (≈→-now p)
-- In some cases all three relations are contained in strong
-- bisimilarity.
→∼-neverˡ : ∀ {k i x} → [ i ] never ⟨ k ⟩ x → [ i ] never ∼ x
→∼-neverˡ (later p) = later λ { .force → →∼-neverˡ (force p) }
→∼-neverˡ (laterˡ p) = →∼-neverˡ p
→∼-neverˡ (laterʳ p) = later λ { .force → →∼-neverˡ p }
→∼-neverʳ : ∀ {k i x} → [ i ] x ⟨ k ⟩ never → [ i ] x ∼ never
→∼-neverʳ (later p) = later λ { .force → →∼-neverʳ (force p) }
→∼-neverʳ (laterˡ p) = later λ { .force → →∼-neverʳ p }
→∼-neverʳ (laterʳ p) = →∼-neverʳ p
----------------------------------------------------------------------
-- Removing later constructors
-- Later constructors can sometimes be removed.
drop-laterʳ :
∀ {k i} {j : Size< i} {x y} →
[ i ] x ⟨ other k ⟩ y →
[ j ] x ⟨ other k ⟩ drop-later y
drop-laterʳ now = now
drop-laterʳ (later p) = laterˡ (force p)
drop-laterʳ (laterʳ p) = p
drop-laterʳ (laterˡ p) = laterˡ (drop-laterʳ p)
drop-laterˡ :
∀ {i} {j : Size< i} {x y} →
[ i ] x ≈ y →
[ j ] drop-later x ≈ y
drop-laterˡ now = now
drop-laterˡ (later p) = laterʳ (force p)
drop-laterˡ (laterʳ p) = laterʳ (drop-laterˡ p)
drop-laterˡ (laterˡ p) = p
drop-laterˡʳ :
∀ {k i} {j : Size< i} {x y} →
[ i ] x ⟨ k ⟩ y →
[ j ] drop-later x ⟨ k ⟩ drop-later y
drop-laterˡʳ now = now
drop-laterˡʳ (later p) = force p
drop-laterˡʳ (laterʳ p) = drop-laterˡ p
drop-laterˡʳ (laterˡ p) = drop-laterʳ p
-- Special cases of the functions above.
laterʳ⁻¹ : ∀ {k i} {j : Size< i} {x y} →
[ i ] x ⟨ other k ⟩ later y →
[ j ] x ⟨ other k ⟩ force y
laterʳ⁻¹ = drop-laterʳ
laterˡ⁻¹ : ∀ {i} {j : Size< i} {x y} →
[ i ] later x ≈ y →
[ j ] force x ≈ y
laterˡ⁻¹ = drop-laterˡ
later⁻¹ : ∀ {k i} {j : Size< i} {x y} →
[ i ] later x ⟨ k ⟩ later y →
[ j ] force x ⟨ k ⟩ force y
later⁻¹ = drop-laterˡʳ
-- The following size-preserving variant of laterʳ⁻¹ and laterˡ⁻¹
-- can be defined.
--
-- Several other variants cannot be defined if ∀ i → A i is
-- inhabited, see Delay-monad.Bisimilarity.Sized.Negative.
laterˡʳ⁻¹ :
∀ {k i x y} →
[ i ] later x ⟨ other k ⟩ force y →
[ i ] force x ⟨ other k ⟩ later y →
[ i ] force x ⟨ other k ⟩ force y
laterˡʳ⁻¹ {k} {i} p q = laterˡʳ⁻¹′ p q E.refl E.refl
where
laterˡʳ⁻¹″ :
∀ {x′ y′ x y} →
({j : Size< i} → [ j ] x′ ⟨ other k ⟩ force y) →
({j : Size< i} → [ j ] force x ⟨ other k ⟩ y′) →
x′ ≡ later x → y′ ≡ later y →
[ i ] later x ⟨ other k ⟩ later y
laterˡʳ⁻¹″ p q E.refl E.refl = later λ { .force → laterˡʳ⁻¹ p q }
laterˡʳ⁻¹′ :
∀ {x′ y′ x y} →
[ i ] later x ⟨ other k ⟩ y′ →
[ i ] x′ ⟨ other k ⟩ later y →
force x ≡ x′ → force y ≡ y′ →
[ i ] x′ ⟨ other k ⟩ y′
laterˡʳ⁻¹′ (later p) (later q) ≡x′ ≡y′ = laterˡʳ⁻¹″ (force p) (force q) ≡x′ ≡y′
laterˡʳ⁻¹′ (laterʳ p) (later q) ≡x′ ≡y′ = laterˡʳ⁻¹″ (λ { {_} → laterˡ⁻¹ p }) (force q) ≡x′ ≡y′
laterˡʳ⁻¹′ (later p) (laterˡ q) ≡x′ ≡y′ = laterˡʳ⁻¹″ (force p) (λ { {_} → laterʳ⁻¹ q }) ≡x′ ≡y′
laterˡʳ⁻¹′ (laterʳ p) (laterˡ q) ≡x′ ≡y′ = laterˡʳ⁻¹″ (λ { {_} → laterˡ⁻¹ p }) (λ { {_} → laterʳ⁻¹ q }) ≡x′ ≡y′
laterˡʳ⁻¹′ (laterˡ p) _ E.refl E.refl = p
laterˡʳ⁻¹′ _ (laterʳ q) E.refl ≡y′ = E.subst ([ i ] _ ⟨ _ ⟩_) ≡y′ q
----------------------------------------------------------------------
-- Reflexivity, symmetry/antisymmetry, transitivity
-- All three relations are reflexive.
reflexive : ∀ {k i} x → [ i ] x ⟨ k ⟩ x
reflexive (now _) = now
reflexive (later x) = later λ { .force → reflexive (force x) }
-- Strong and weak bisimilarity are symmetric.
symmetric :
∀ {k i x y} {¬≳ : if k ≟-Kind other expansion then ⊥ else ⊤} →
[ i ] x ⟨ k ⟩ y → [ i ] y ⟨ k ⟩ x
symmetric now = now
symmetric (laterˡ {k = weak} p) = laterʳ (symmetric p)
symmetric (laterʳ p) = laterˡ (symmetric p)
symmetric {¬≳ = ¬≳} (later p) =
later λ { .force → symmetric {¬≳ = ¬≳} (force p) }
symmetric {¬≳ = ()} (laterˡ {k = expansion} _)
-- Some special cases of symmetry hold for expansion.
symmetric-neverˡ : ∀ {i x} → [ i ] never ≳ x → [ i ] x ≳ never
symmetric-neverˡ = ∼→ ∘ symmetric ∘ →∼-neverˡ
symmetric-neverʳ : ∀ {i x} → [ i ] x ≳ never → [ i ] never ≳ x
symmetric-neverʳ = ∼→ ∘ symmetric ∘ →∼-neverʳ
-- The expansion relation is antisymmetric (up to weak
-- bisimilarity).
antisymmetric-≳ : ∀ {i x y} → [ i ] x ≳ y → [ i ] y ≳ x → [ i ] x ≈ y
antisymmetric-≳ p _ = ≳→ p
-- Several more or less size-preserving variants of transitivity.
--
-- Many size-preserving variants cannot be defined if ∀ i → A i is
-- inhabited, see Delay-monad.Sized.Bisimilarity.Negative.
transitive-∼ʳ :
∀ {k i x y z}
{¬≈ : if k ≟-Kind other weak then ⊥ else ⊤} →
[ i ] x ⟨ k ⟩ y → [ i ] y ∼ z → [ i ] x ⟨ k ⟩ z
transitive-∼ʳ now now = now
transitive-∼ʳ {¬≈ = ¬≈} (laterˡ p) q = laterˡ
(transitive-∼ʳ {¬≈ = ¬≈} p q)
transitive-∼ʳ {¬≈ = ()} (laterʳ _) _
transitive-∼ʳ {¬≈ = ¬≈} (later p) (later q) =
later λ { .force → transitive-∼ʳ {¬≈ = ¬≈} (force p) (force q) }
transitive-∼ˡ :
∀ {k i x y z} →
x ∼ y → [ i ] y ⟨ k ⟩ z → [ i ] x ⟨ k ⟩ z
transitive-∼ˡ now now = now
transitive-∼ˡ (later p) (later q) = later λ { .force →
transitive-∼ˡ (force p) (force q) }
transitive-∼ˡ (later p) (laterˡ q) = laterˡ (transitive-∼ˡ (force p) q)
transitive-∼ˡ p (laterʳ q) = laterʳ (transitive-∼ˡ p q)
transitive-∞∼ʳ :
∀ {k i x y z} →
[ i ] x ⟨ k ⟩ y → y ∼ z → [ i ] x ⟨ k ⟩ z
transitive-∞∼ʳ now now = now
transitive-∞∼ʳ (later p) (later q) = later λ { .force →
transitive-∞∼ʳ (force p) (force q) }
transitive-∞∼ʳ (laterˡ p) q = laterˡ (transitive-∞∼ʳ p q)
transitive-∞∼ʳ (laterʳ p) (later q) = laterʳ (transitive-∞∼ʳ p (force q))
transitive-≳ˡ :
∀ {k i x y z} →
x ≳ y → [ i ] y ⟨ other k ⟩ z → [ i ] x ⟨ other k ⟩ z
transitive-≳ˡ now now = now
transitive-≳ˡ (later p) (later q) = later λ { .force →
transitive-≳ˡ (force p) (force q) }
transitive-≳ˡ (later p) (laterˡ q) = laterˡ (transitive-≳ˡ (force p) q)
transitive-≳ˡ (laterˡ p) q = laterˡ (transitive-≳ˡ p q)
transitive-≳ˡ p (laterʳ q) = laterʳ (transitive-≳ˡ p q)
transitive-≈≲ :
∀ {i x y z} →
[ i ] x ≈ y → y ≲ z → [ i ] x ≈ z
transitive-≈≲ p q = symmetric (transitive-≳ˡ q (symmetric p))
transitive-≈-now :
∀ {i x′ y z} →
let x = now x′ in
[ i ] x ≈ y → y ≈ z → [ i ] x ≈ z
transitive-≈-now now now = now
transitive-≈-now (laterʳ p) q = transitive-≈-now p (laterˡ⁻¹ q)
transitive-≈-now p (laterʳ q) = laterʳ (transitive-≈-now p q)
mutual
transitive-≈-later :
∀ {i x′ y z} →
let x = later x′ in
x ≈ y → y ≈ z → [ i ] x ≈ z
transitive-≈-later p (later q) = later λ { .force →
transitive-≈ (later⁻¹ p) (force q) }
transitive-≈-later p (laterʳ q) = laterʳ (transitive-≈-later p q)
transitive-≈-later p (laterˡ q) = transitive-≈ (laterʳ⁻¹ p) q
transitive-≈-later (laterˡ p) q = laterˡ (transitive-≈ p q)
transitive-≈ : ∀ {i x y z} → x ≈ y → y ≈ z → [ i ] x ≈ z
transitive-≈ {x = now x} p q = transitive-≈-now p q
transitive-≈ {x = later x} p q = transitive-≈-later p q
-- Equational reasoning combinators.
infix -1 _∎ finally finally-≳ finally-≈
infixr -2 step-∼ˡ step-∼∼ step-≳∼ step-≈∼ step-?∼ step-≳ˡ step-≈
_≳⟨⟩_ step-≡ˡ _∼⟨⟩_
_∎ : ∀ {k i} x → [ i ] x ⟨ k ⟩ x
_∎ = reflexive
finally : ∀ {k i} x y →
[ i ] x ⟨ k ⟩ y → [ i ] x ⟨ k ⟩ y
finally _ _ x?y = x?y
syntax finally x y x≈y = x ?⟨ x≈y ⟩∎ y ∎
finally-≳ : ∀ {i} x y →
[ i ] x ≳ y → [ i ] x ≳ y
finally-≳ _ _ x≳y = x≳y
syntax finally-≳ x y x≳y = x ≳⟨ x≳y ⟩∎ y ∎
finally-≈ : ∀ {i} x y →
[ i ] x ≈ y → [ i ] x ≈ y
finally-≈ _ _ x≈y = x≈y
syntax finally-≈ x y x≈y = x ≈⟨ x≈y ⟩∎ y ∎
step-∼ˡ : ∀ {k i} x {y z} →
[ i ] y ⟨ k ⟩ z → x ∼ y → [ i ] x ⟨ k ⟩ z
step-∼ˡ _ y⟨⟩z x∼y = transitive-∼ˡ x∼y y⟨⟩z
syntax step-∼ˡ x y⟨⟩z x∼y = x ∼⟨ x∼y ⟩ y⟨⟩z
step-∼∼ : ∀ {i} x {y z} →
[ i ] y ∼ z → [ i ] x ∼ y → [ i ] x ∼ z
step-∼∼ _ y∼z x∼y = transitive-∼ʳ x∼y y∼z
syntax step-∼∼ x y∼z x∼y = x ∼⟨ x∼y ⟩∼ y∼z
step-≳∼ : ∀ {i} x {y z} →
[ i ] y ∼ z → [ i ] x ≳ y → [ i ] x ≳ z
step-≳∼ _ y∼z x≳y = transitive-∼ʳ x≳y y∼z
syntax step-≳∼ x y∼z x≳y = x ≳⟨ x≳y ⟩∼ y∼z
step-≈∼ : ∀ {k i} x {y z} →
y ∼ z → [ i ] x ⟨ k ⟩ y → [ i ] x ⟨ k ⟩ z
step-≈∼ _ y∼z x≈y = transitive-∞∼ʳ x≈y y∼z
syntax step-≈∼ x y∼z x≈y = x ≈⟨ x≈y ⟩∼ y∼z
step-?∼ : ∀ {k i} x {y z} →
y ∼ z → [ i ] x ⟨ k ⟩ y → [ i ] x ⟨ k ⟩ z
step-?∼ _ y∼z x?y = transitive-∞∼ʳ x?y y∼z
syntax step-?∼ x y∼z x?y = x ?⟨ x?y ⟩∼ y∼z
step-≳ˡ : ∀ {k i} x {y z} →
[ i ] y ⟨ other k ⟩ z → x ≳ y →
[ i ] x ⟨ other k ⟩ z
step-≳ˡ _ y≳≈z x≳y = transitive-≳ˡ x≳y y≳≈z
syntax step-≳ˡ x y≳≈z x≳y = x ≳⟨ x≳y ⟩ y≳≈z
step-≈ : ∀ {i} x {y z} →
y ≈ z → x ≈ y → [ i ] x ≈ z
step-≈ _ y≈z x≈y = transitive-≈ x≈y y≈z
syntax step-≈ x y≈z x≈y = x ≈⟨ x≈y ⟩ y≈z
_≳⟨⟩_ : ∀ {k i} x {y} →
[ i ] drop-later x ⟨ other k ⟩ y → [ i ] x ⟨ other k ⟩ y
now _ ≳⟨⟩ p = p
later _ ≳⟨⟩ p = laterˡ p
step-≡ˡ : ∀ {k i} x {y z} →
[ i ] y ⟨ k ⟩ z → x ≡ y → [ i ] x ⟨ k ⟩ z
step-≡ˡ _ y⟨⟩z E.refl = y⟨⟩z
syntax step-≡ˡ x y⟨⟩z x≡y = x ≡⟨ x≡y ⟩ y⟨⟩z
_∼⟨⟩_ : ∀ {k i} x {y} →
[ i ] x ⟨ k ⟩ y → [ i ] x ⟨ k ⟩ y
_ ∼⟨⟩ x≈y = x≈y
----------------------------------------------------------------------
-- Some results related to negation
-- The computation never is not related to now x.
never≉now : ∀ {k i x} → ¬ [ i ] never ⟨ k ⟩ now x
never≉now (laterˡ p) = never≉now p
-- The computation now x is not related to never.
now≉never : ∀ {k i x} → ¬ [ i ] now x ⟨ k ⟩ never
now≉never (laterʳ p) = now≉never p
-- If A ∞ is uninhabited, then the three relations defined above are
-- trivial.
uninhabited→trivial : ∀ {k i} → ¬ A ∞ → ∀ x y → [ i ] x ⟨ k ⟩ y
uninhabited→trivial ¬A (now x) _ = ⊥-elim (¬A x)
uninhabited→trivial ¬A (later x) (now y) = ⊥-elim (¬A y)
uninhabited→trivial ¬A (later x) (later y) =
later λ { .force → uninhabited→trivial ¬A (force x) (force y) }
-- Expansion and weak bisimilarity are not pointwise propositional.
¬-≳≈-propositional :
∀ {k} → ¬ (∀ {x y} → E.Is-proposition ([ ∞ ] x ⟨ other k ⟩ y))
¬-≳≈-propositional {k} =
(∀ {x y} → E.Is-proposition ([ ∞ ] x ⟨ other k ⟩ y)) ↝⟨ (λ prop → prop {x = never} {y = never}) ⟩
E.Is-proposition ([ ∞ ] never ⟨ other k ⟩ never) ↝⟨ (λ irr → irr _ _) ⟩
proof₁ ≡ proof₂ ↝⟨ (λ ()) ⟩□
⊥₀ □
where
proof₁ : ∀ {i} → [ i ] never ⟨ other k ⟩ never
proof₁ = later λ { .force → proof₁ }
proof₂ : ∀ {i} → [ i ] never ⟨ other k ⟩ never
proof₂ = laterˡ proof₁
------------------------------------------------------------------------
-- A statement of extensionality for strong bisimilarity
-- A statement of extensionality: strongly bisimilar computations are
-- equal.
Extensionality : (ℓ : Level) → Type (lsuc ℓ)
Extensionality a =
{A : Size → Type a} {x y : Delay A ∞} → x ∼ y → x ≡ y
| 32.885714
| 121
| 0.464503
|
1cdb93a454c94804223ccc66ec278e301323c23c
| 402
|
agda
|
Agda
|
test/Fail/Issue1976.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue1976.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue1976.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2016-12-31, issue #1976 raised by nad
-- Check for correct parameters in projection pattern
-- {-# OPTIONS -v tc.lhs.split:40 #-}
postulate
A B : Set
module M (_ : Set) where
record R : Set₂ where
field
F : Set₁
open R public
open M A
wrong : M.R B
F wrong = Set
-- Expected error:
-- A != B of type Set
-- when checking that the clause F wrong = Set has type M.R B
| 16.08
| 61
| 0.639303
|
a1af26bf6d0878b4a3a2c8eb5ed5e8e7acade38e
| 520
|
agda
|
Agda
|
src/data/lib/prim/Agda/Builtin/List.agda
|
zliu41/agda
|
73405f70bced057d24dd4bf122d53f9548544aba
|
[
"BSD-3-Clause"
] | 1
|
2020-04-26T09:35:17.000Z
|
2020-04-26T09:35:17.000Z
|
src/data/lib/prim/Agda/Builtin/List.agda
|
zliu41/agda
|
73405f70bced057d24dd4bf122d53f9548544aba
|
[
"BSD-3-Clause"
] | null | null | null |
src/data/lib/prim/Agda/Builtin/List.agda
|
zliu41/agda
|
73405f70bced057d24dd4bf122d53f9548544aba
|
[
"BSD-3-Clause"
] | 1
|
2021-04-18T13:34:07.000Z
|
2021-04-18T13:34:07.000Z
|
{-# OPTIONS --without-K --safe --no-sized-types --no-guardedness
--no-subtyping #-}
module Agda.Builtin.List where
infixr 5 _∷_
data List {a} (A : Set a) : Set a where
[] : List A
_∷_ : (x : A) (xs : List A) → List A
{-# BUILTIN LIST List #-}
{-# COMPILE JS List = function(x,v) {
if (x.length < 1) { return v["[]"](); } else { return v["_∷_"](x[0], x.slice(1)); }
} #-}
{-# COMPILE JS [] = Array() #-}
{-# COMPILE JS _∷_ = function (x) { return function(y) { return Array(x).concat(y); }; } #-}
| 28.888889
| 92
| 0.536538
|
3191cde2fb31aeca4020c9c90388c0db212df6fb
| 970
|
agda
|
Agda
|
Cubical/Relation/Binary/Raw/Construct/Always.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/Relation/Binary/Raw/Construct/Always.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/Relation/Binary/Raw/Construct/Always.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Relation.Binary.Raw.Construct.Always where
open import Cubical.Core.Everything
open import Cubical.Relation.Binary.Raw
open import Cubical.Relation.Binary.Raw.Construct.Constant using (Const)
open import Cubical.Data.Unit.Polymorphic
------------------------------------------------------------------------
-- Definition
Always : ∀ {a b ℓ} {A : Type a} {B : Type b} → RawREL A B ℓ
Always = Const ⊤
------------------------------------------------------------------------
-- Properties
module _ {a} (A : Type a) ℓ where
reflexive : Reflexive {A = A} {ℓ = ℓ} Always
reflexive = _
symmetric : Symmetric {A = A} {ℓ = ℓ} Always
symmetric _ = _
transitive : Transitive {A = A} {ℓ = ℓ} Always
transitive _ _ = _
isEquivalence : IsEquivalence {ℓ = ℓ} {A} Always
isEquivalence = record {}
equivalence : Equivalence A ℓ
equivalence = record
{ isEquivalence = isEquivalence
}
| 26.216216
| 72
| 0.582474
|
fba9200511ce140fbf8d41d782724efc1a30857f
| 615
|
agda
|
Agda
|
test/succeed/RewriteAndWhere.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2019-11-27T07:26:06.000Z
|
2019-11-27T07:26:06.000Z
|
test/succeed/RewriteAndWhere.agda
|
dagit/agda
|
4383a3d20328a6c43689161496cee8eb479aca08
|
[
"MIT"
] | null | null | null |
test/succeed/RewriteAndWhere.agda
|
dagit/agda
|
4383a3d20328a6c43689161496cee8eb479aca08
|
[
"MIT"
] | null | null | null |
module RewriteAndWhere where
open import Common.Equality
sym : {A : Set}{a b : A} → a ≡ b → b ≡ a
sym refl = refl
data ℕ : Set where
zero : ℕ
good : (a b : ℕ) → a ≡ b → b ≡ a
good a b eq with a | eq
... | .b | refl = foo
where
foo : b ≡ b
foo = refl
mutual
aux : (a b : ℕ)(w : ℕ) → w ≡ b → b ≡ w
aux a b .b refl = foo
where
foo : b ≡ b
foo = refl
good₂ : (a b : ℕ) → a ≡ b → b ≡ a
good₂ a b eq = aux a b a eq
bad : (a b : ℕ) → a ≡ b → b ≡ a
bad a b eq rewrite eq = foo
where
foo : b ≡ b
foo rewrite sym eq = bar
where
bar : a ≡ a
bar = refl
| 16.621622
| 40
| 0.479675
|
3159287729235ebbe5a1dc33490e5fdd2c8f6d80
| 554
|
agda
|
Agda
|
examples/outdated-and-incorrect/clowns/Derivative.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
examples/outdated-and-incorrect/clowns/Derivative.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
examples/outdated-and-incorrect/clowns/Derivative.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
module Derivative where
open import Sets
open import Functor
import Isomorphism
∂ : U -> U
∂ (K A) = K [0]
∂ Id = K [1]
∂ (F + G) = ∂ F + ∂ G
∂ (F × G) = ∂ F × G + F × ∂ G
open Semantics
-- Plugging a hole
plug-∂ : {X : Set}(F : U) -> ⟦ ∂ F ⟧ X -> X -> ⟦ F ⟧ X
plug-∂ (K _) () x
plug-∂ Id <> x = x
plug-∂ (F + G) (inl c) x = inl (plug-∂ F c x)
plug-∂ (F + G) (inr c) x = inr (plug-∂ G c x)
plug-∂ (F × G) (inl < c , g >) x = < plug-∂ F c x , g >
plug-∂ (F × G) (inr < f , c >) x = < f , plug-∂ G c x >
| 22.16
| 57
| 0.409747
|
dc4e0198522b7723157fe9303e35c9d38eb6263a
| 1,705
|
agda
|
Agda
|
test/Succeed/Issue1944-Stream.agda
|
alex-mckenna/agda
|
78b62cd24bbd570271a7153e44ad280e52ef3e29
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Succeed/Issue1944-Stream.agda
|
andersk/agda
|
56928ff709dcb931cb9a48c4790e5ed3739e3032
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/Issue1944-Stream.agda
|
andersk/agda
|
56928ff709dcb931cb9a48c4790e5ed3739e3032
|
[
"BSD-3-Clause"
] | 1
|
2019-03-05T20:02:38.000Z
|
2019-03-05T20:02:38.000Z
|
-- AIM XXIII, Andreas, 2016-04-24
-- Overloaded projections and projection patterns
-- {-# OPTIONS -v tc.proj.amb:30 #-}
-- {-# OPTIONS -v tc.lhs.split:20 #-}
module _ where
import Common.Level
open import Common.Prelude hiding (map)
open import Common.Equality
module M (A : Set) where
record Stream : Set where
coinductive
field
head : A
tail : Stream
open M using (Stream)
open module S = M.Stream public
-- This is a bit trickier for overloading projections
-- as it has a parameter with is of a record type
-- with the same projections.
record _≈_ {A : Set}(s t : Stream A) : Set where
coinductive
field
head : head s ≡ head t
tail : tail s ≈ tail t
open module B = _≈_ public
≈refl : ∀{A} {s : Stream A} → s ≈ s
head ≈refl = refl
tail ≈refl = ≈refl
≈sym : ∀{A} {s t : Stream A} → s ≈ t → t ≈ s
head (≈sym p) = sym (head p)
tail (≈sym p) = ≈sym (tail p)
module N (A : Set) (s : Stream A) where
open module SS = Stream s public
myhead : A
myhead = SS.head -- cannot use ambiguous head here
map : {A B : Set} → (A → B) → Stream A → Stream B
head (map f s) = f (head s)
tail (map f s) = map f (tail s)
map_id : {A : Set}(s : Stream A) → map (λ x → x) s ≈ s
head (map_id s) = refl
tail (map_id s) = map_id (tail s)
repeat : {A : Set}(a : A) → Stream A
head (repeat a) = a
tail (repeat a) = repeat a
repeat₂ : {A : Set}(a₁ a₂ : A) → Stream A
( (head (repeat₂ a₁ a₂))) = a₁
(head (tail (repeat₂ a₁ a₂))) = a₂
(tail (tail (repeat₂ a₁ a₂))) = repeat₂ a₁ a₂
repeat≈repeat₂ : {A : Set}(a : A) → repeat a ≈ repeat₂ a a
( (head (repeat≈repeat₂ a))) = refl
(head (tail (repeat≈repeat₂ a))) = refl
(tail (tail (repeat≈repeat₂ a))) = repeat≈repeat₂ a
| 25.073529
| 58
| 0.615836
|
0bde5648dec6b172e5436317f52e91bdef90d587
| 130
|
agda
|
Agda
|
test/interaction/Issue4954-2.agda
|
AntoineAllioux/agda
|
68ec2312961776e415c99d2839e41a92ffe464db
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Issue4954-2.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Issue4954-2.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --cubical #-}
F : Set → Set
F A = A
record R : Set₁ where
field
A : Set
r : Set → R
r A = λ where
.R.A → A
| 10
| 25
| 0.5
|
1dc933b43e2ab6d8fcd7f4f35c22045a194272d9
| 4,060
|
agda
|
Agda
|
GSeTT/Rules.agda
|
thibautbenjamin/catt-formalization
|
3a02010a869697f4833c9bc6047d66ca27b87cf2
|
[
"MIT"
] | null | null | null |
GSeTT/Rules.agda
|
thibautbenjamin/catt-formalization
|
3a02010a869697f4833c9bc6047d66ca27b87cf2
|
[
"MIT"
] | null | null | null |
GSeTT/Rules.agda
|
thibautbenjamin/catt-formalization
|
3a02010a869697f4833c9bc6047d66ca27b87cf2
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --rewriting --without-K #-}
open import Agda.Primitive
open import Prelude
open import GSeTT.Syntax
{- Typing Rules and basic syntactic properties for the type theory for globular sets -}
module GSeTT.Rules where
{- Well-formedness statements ≡ inference rules -}
data _⊢C : Pre-Ctx → Set₁
data _⊢T_ : Pre-Ctx → Pre-Ty → Set₁
data _⊢t_#_ : Pre-Ctx → Pre-Tm → Pre-Ty → Set₁
data _⊢S_>_ : Pre-Ctx → Pre-Sub → Pre-Ctx → Set₁
data _⊢C where
ec : nil ⊢C
cc : ∀ {Γ x A} → Γ ⊢C → Γ ⊢T A → x == length Γ → (Γ :: (x , A)) ⊢C
data _⊢T_ where
ob : ∀ {Γ} → Γ ⊢C → Γ ⊢T ∗
ar : ∀ {Γ A t u} → Γ ⊢t t # A → Γ ⊢t u # A → Γ ⊢T ⇒ A t u
data _⊢t_#_ where
var : ∀ {Γ x A} → Γ ⊢C → x # A ∈ Γ → Γ ⊢t (Var x) # A
data _⊢S_>_ where
es : ∀ {Δ} → Δ ⊢C → Δ ⊢S nil > nil
sc : ∀ {Δ Γ γ x y A t} → Δ ⊢S γ > Γ → (Γ :: (x , A)) ⊢C → (Δ ⊢t t # (A [ γ ]Pre-Ty)) → x == y → Δ ⊢S (γ :: (y , t)) > (Γ :: (x , A))
{- Weakening admissibility -}
wkT : ∀ {Γ A y B} → Γ ⊢T A → (Γ :: (y , B)) ⊢C → (Γ :: (y , B)) ⊢T A
wkt : ∀ {Γ A t y B} → Γ ⊢t t # A → (Γ :: (y , B)) ⊢C → (Γ :: (y , B)) ⊢t t # A
wkT (ob _) Γ,y:B⊢ = ob Γ,y:B⊢
wkT (ar Γ⊢t:A Γ⊢u:A) Γ,y:B⊢ = ar (wkt Γ⊢t:A Γ,y:B⊢) (wkt Γ⊢u:A Γ,y:B⊢)
wkt (var Γ⊢C x∈Γ) Γ,y:B⊢ = var Γ,y:B⊢ (inl x∈Γ)
wkS : ∀ {Δ Γ γ y B} → Δ ⊢S γ > Γ → (Δ :: (y , B)) ⊢C → (Δ :: (y , B)) ⊢S γ > Γ
wkS (es _) Δ,y:B⊢ = es Δ,y:B⊢
wkS (sc Δ⊢γ:Γ Γ,x:A⊢ Δ⊢t:A[γ] idp) Δ,y:B⊢ = sc (wkS Δ⊢γ:Γ Δ,y:B⊢) Γ,x:A⊢ (wkt Δ⊢t:A[γ] Δ,y:B⊢) idp
{- Consistency : all objects appearing in derivable judgments are derivable -}
Γ⊢A→Γ⊢ : ∀ {Γ A} → Γ ⊢T A → Γ ⊢C
Γ⊢t:A→Γ⊢ : ∀ {Γ A t} → Γ ⊢t t # A → Γ ⊢C
Γ⊢A→Γ⊢ (ob Γ⊢) = Γ⊢
Γ⊢A→Γ⊢ (ar Γ⊢t:A Γ⊢u:A) = Γ⊢t:A→Γ⊢ Γ⊢t:A
Γ⊢t:A→Γ⊢ (var Γ⊢ _) = Γ⊢
Δ⊢γ:Γ→Γ⊢ : ∀ {Δ Γ γ} → Δ ⊢S γ > Γ → Γ ⊢C
Δ⊢γ:Γ→Γ⊢ (es Δ⊢) = ec
Δ⊢γ:Γ→Γ⊢ (sc Δ⊢γ:Γ Γ,x:A⊢ Δ⊢t:A[γ] idp) = Γ,x:A⊢
Δ⊢γ:Γ→Δ⊢ : ∀ {Δ Γ γ} → Δ ⊢S γ > Γ → Δ ⊢C
Δ⊢γ:Γ→Δ⊢ (es Δ⊢) = Δ⊢
Δ⊢γ:Γ→Δ⊢ (sc Δ⊢γ:Γ Γ,x:A⊢ Δ⊢t:A[γ] idp) = Δ⊢γ:Γ→Δ⊢ Δ⊢γ:Γ
Γ,x:A⊢→Γ,x:A⊢A : ∀ {Γ x A} → (Γ :: (x , A)) ⊢C → (Γ :: (x , A)) ⊢T A
Γ,x:A⊢→Γ,x:A⊢A Γ,x:A⊢@(cc Γ⊢ Γ⊢A idp) = wkT Γ⊢A Γ,x:A⊢
Γ,x:A⊢→Γ,x:A⊢x:A : ∀ {Γ x A} → (Γ :: (x , A)) ⊢C → (Γ :: (x , A)) ⊢t (Var x) # A
Γ,x:A⊢→Γ,x:A⊢x:A Γ,x:A⊢ = var Γ,x:A⊢ (inr (idp , idp))
Γ,x:A⊢→Γ⊢ : ∀ {Γ x A} → (Γ :: (x , A)) ⊢C → Γ ⊢C
Γ,x:A⊢→Γ⊢ (cc Γ⊢ _ _) = Γ⊢
Γ⊢t:A→Γ⊢A : ∀ {Γ A t} → Γ ⊢t t # A → Γ ⊢T A
Γ⊢t:A→Γ⊢A (var Γ,x:A⊢@(cc Γ⊢ Γ⊢A idp) (inl y∈Γ)) = wkT (Γ⊢t:A→Γ⊢A (var Γ⊢ y∈Γ)) Γ,x:A⊢
Γ⊢t:A→Γ⊢A (var Γ,x:A⊢@(cc _ _ idp) (inr (idp , idp))) = Γ,x:A⊢→Γ,x:A⊢A Γ,x:A⊢
Γ⊢src : ∀ {Γ A t u} → Γ ⊢T ⇒ A t u → Γ ⊢t t # A
Γ⊢src (ar Γ⊢t Γ⊢u) = Γ⊢t
Γ⊢tgt : ∀ {Γ A t u} → Γ ⊢T ⇒ A t u → Γ ⊢t u # A
Γ⊢tgt (ar Γ⊢t Γ⊢u) = Γ⊢u
{- Cut-admissibility -}
-- notational shortcut : if A = B a term of type A is also of type B
trT : ∀ {Γ A B t} → A == B → Γ ⊢t t # A → Γ ⊢t t # B
trT idp Γ⊢t:A = Γ⊢t:A
n∉Γ : ∀ {Γ A n} → Γ ⊢C → (length Γ ≤ n) → ¬ (n # A ∈ Γ)
n∉Γ (cc Γ⊢ _ _) l+1≤n (inl n∈Γ) = n∉Γ Γ⊢ (Sn≤m→n≤m l+1≤n) n∈Γ
n∉Γ (cc Γ⊢ _ idp) Sn≤n (inr (idp , idp)) = Sn≰n _ Sn≤n
lΓ∉Γ : ∀ {Γ A} → Γ ⊢C → ¬ ((length Γ) # A ∈ Γ)
lΓ∉Γ Γ⊢ = n∉Γ Γ⊢ (n≤n _)
Γ+⊢l : ∀ {Γ x A} → (Γ :: (x , A)) ⊢C → x == length Γ
Γ+⊢l (cc _ _ idp) = idp
{- action on weakened types and terms -}
wk[]T : ∀ {Γ Δ γ x u A B} → Γ ⊢T A → Δ ⊢S (γ :: (x , u)) > (Γ :: (x , B)) → (A [ (γ :: (x , u)) ]Pre-Ty) == (A [ γ ]Pre-Ty)
wk[]t : ∀ {Γ Δ γ x u A t B} → Γ ⊢t t # A → Δ ⊢S (γ :: (x , u)) > (Γ :: (x , B)) → (t [ (γ :: (x , u)) ]Pre-Tm) == (t [ γ ]Pre-Tm)
wk[]T (ob Γ⊢) _ = idp
wk[]T (ar Γ⊢t:A Γ⊢u:A) Δ⊢γ+:Γ+ = ⇒= (wk[]T (Γ⊢t:A→Γ⊢A Γ⊢t:A) Δ⊢γ+:Γ+) (wk[]t Γ⊢t:A Δ⊢γ+:Γ+) (wk[]t Γ⊢u:A Δ⊢γ+:Γ+)
wk[]t {x = x} (var {x = y} Γ⊢ y∈Γ) Δ⊢γ+:Γ+ with (eqdecℕ y x)
wk[]t {x = x} (var {x = y} Γ⊢ y∈Γ) Δ⊢γ+:Γ+ | inr _ = idp
wk[]t (var {Γ = Γ} Γ⊢ x∈Γ) Δ⊢γ+:Γ+ | inl idp = ⊥-elim (lΓ∉Γ Γ⊢ (transport {B = λ n → n # _ ∈ Γ} (Γ+⊢l (Δ⊢γ:Γ→Γ⊢ Δ⊢γ+:Γ+)) x∈Γ))
dim[] : ∀ (A : Pre-Ty) (γ : Pre-Sub) → dim (A [ γ ]Pre-Ty) == dim A
dim[] ∗ γ = idp
dim[] (⇒ A x x₁) γ = S= (dim[] A γ)
| 37.247706
| 136
| 0.422906
|
a10908419d42e3f3f77ce9b9b38af6f675337ab6
| 196
|
agda
|
Agda
|
test/Succeed/AbsurdPattern.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/AbsurdPattern.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/AbsurdPattern.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Pattern matching on a (decidably) empty type allows you to omit the
-- right-hand side.
module AbsurdPattern where
data Empty : Set where
elim-Empty : {A : Set} -> Empty -> A
elim-Empty ()
| 17.818182
| 70
| 0.693878
|
200d8f3f53894bac975413cd00b6cd1bc44a706a
| 1,194
|
agda
|
Agda
|
Categories/Fibration.agda
|
copumpkin/categories
|
36f4181d751e2ecb54db219911d8c69afe8ba892
|
[
"BSD-3-Clause"
] | 98
|
2015-04-15T14:57:33.000Z
|
2022-03-08T05:20:36.000Z
|
Categories/Fibration.agda
|
p-pavel/categories
|
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
|
[
"BSD-3-Clause"
] | 19
|
2015-05-23T06:47:10.000Z
|
2019-08-09T16:31:40.000Z
|
Categories/Fibration.agda
|
p-pavel/categories
|
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
|
[
"BSD-3-Clause"
] | 23
|
2015-02-05T13:03:09.000Z
|
2021-11-11T13:50:56.000Z
|
{-# OPTIONS --universe-polymorphism #-}
module Categories.Fibration where
open import Level hiding (lift)
open import Data.Product
open import Categories.Category
open import Categories.Functor hiding (_∘_; _≡_)
open import Categories.Morphism.Cartesian
import Categories.Morphisms as Morphisms
record CartesianLifting {o₀ ℓ₀ e₀} {o₁ ℓ₁ e₁} {E : Category o₀ ℓ₀ e₀} {B : Category o₁ ℓ₁ e₁}
(p : Functor E B) {a e} (f : B [ a , Functor.F₀ p e ]) : Set (o₀ ⊔ ℓ₀ ⊔ e₀ ⊔ o₁ ⊔ ℓ₁ ⊔ e₁) where
private module E = Category E
private module B = Category B
open B using (_∘_; _≡_)
open Functor p renaming (F₀ to p₀; F₁ to p₁)
open Morphisms B
field
e′ : E.Obj
φ : E [ e′ , e ]
proof : ∃ \ (h : a ≅ p₀ e′) → f ∘ _≅_.g h ≡ p₁ φ
φ-cartesian : Cartesian p φ
record Fibration {o₀ ℓ₀ e₀} {o₁ ℓ₁ e₁} (E : Category o₀ ℓ₀ e₀) (B : Category o₁ ℓ₁ e₁) : Set (o₀ ⊔ ℓ₀ ⊔ e₀ ⊔ o₁ ⊔ ℓ₁ ⊔ e₁) where
private module E = Category E
private module B = Category B
open B using (_∘_; _≡_)
field
p : Functor E B
open Functor p renaming (F₀ to p₀; F₁ to p₁)
open Morphisms B
field
lift : ∀ {a} e → (f : B [ a , p₀ e ]) → CartesianLifting p f
| 27.767442
| 128
| 0.622278
|
0ed03b0e3c0b242114cdef79a211fa8589861966
| 2,074
|
agda
|
Agda
|
TD6/List.agda
|
erwinkn/program-eq-proof
|
9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23
|
[
"MIT"
] | null | null | null |
TD6/List.agda
|
erwinkn/program-eq-proof
|
9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23
|
[
"MIT"
] | null | null | null |
TD6/List.agda
|
erwinkn/program-eq-proof
|
9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23
|
[
"MIT"
] | null | null | null |
{- --- 4. Lists --- -}
data List (A : Set) : Set where
[] : List A
_∷_ : A → List A → List A
infixr 5 _∷_
open import Data.Nat
open import Relation.Binary.PropositionalEquality
{- 4.1 Length -}
length : {A : Set} → List A → ℕ
length [] = 0
length (x ∷ l) = 1 + (length l)
{- 4.2 List reversal -}
concat : {A : Set} → List A → List A → List A
concat [] l = l
concat (x ∷ k) l = x ∷ (concat k l)
concat-length : {A : Set} → (k l : List A) → length (concat k l) ≡ (length k) + (length l)
concat-length [] l = refl
concat-length (x ∷ k) l rewrite concat-length k l = refl
concat-assoc : {A : Set} → (j k l : List A) → concat (concat j k) l ≡ concat j (concat k l)
concat-assoc [] k l = refl
concat-assoc (x ∷ j) k l rewrite concat-assoc j k l = refl
{- 4.3 List reversal -}
snoc : {A : Set} → A -> List A → List A
snoc a [] = a ∷ []
snoc a (x ∷ l) = x ∷ (snoc a l)
rev : {A : Set} → List A → List A
rev [] = []
rev (x ∷ l) = snoc x (rev l)
snoc-length : {A : Set} → (a : A) → (l : List A) → length (snoc a l) ≡ suc (length l)
snoc-length a [] = refl
snoc-length a (x ∷ l) rewrite snoc-length a l = refl
rev-length : {A : Set} → (l : List A) → (length (rev l)) ≡ (length l)
rev-length [] = refl
rev-length (x ∷ l) rewrite snoc-length x (rev l) | rev-length l = refl
snoc-rev : {A : Set} → (a : A) → (l : List A) → rev (snoc a l) ≡ a ∷ (rev l)
snoc-rev a [] = refl
snoc-rev a (x ∷ l) rewrite snoc-rev a l = refl
double-rev : {A : Set} → (l : List A) → rev (rev l) ≡ l
double-rev [] = refl
double-rev (x ∷ l) rewrite snoc-rev x (rev l) | double-rev l = refl
{- 4.4 Filtering -}
open import Data.Bool
filter : {A : Set} → (p : A → Bool) → (l : List A) → List A
filter p [] = []
filter p (x ∷ l) with p x
filter p (x ∷ l) | false = filter p l
filter p (x ∷ l) | true = x ∷ (filter p l)
empty-list : {A : Set} → (l : List A) → filter (λ _ → false) l ≡ []
empty-list [] = refl
empty-list (x ∷ l) = empty-list l
identity-list : {A : Set} → (l : List A) → filter (λ _ → true) l ≡ l
identity-list [] = refl
identity-list (x ∷ l) rewrite identity-list l = refl
| 26.935065
| 91
| 0.559788
|
066c62821371906dbe8851610c0af2eddfe23c29
| 26,447
|
agda
|
Agda
|
src/Equivalence/Path-split.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | 3
|
2020-05-21T22:58:50.000Z
|
2021-09-02T17:18:15.000Z
|
src/Equivalence/Path-split.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | null | null | null |
src/Equivalence/Path-split.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- Some alternative definitions of the concept of being an equivalence
------------------------------------------------------------------------
-- Partly based on the blog post "Universal properties without
-- function extensionality" by Mike Shulman
-- (https://homotopytypetheory.org/2014/11/02/universal-properties-without-function-extensionality/),
-- and the corresponding code in the Coq HoTT library
-- (https://github.com/HoTT/HoTT).
{-# OPTIONS --without-K --safe #-}
open import Equality
module Equivalence.Path-split
{e⁺} (eq : ∀ {a p} → Equality-with-J a p e⁺) where
open Derived-definitions-and-properties eq
open import Logical-equivalence using (_⇔_)
open import Prelude
open import Bijection eq as B using (_↔_)
open import Embedding eq using (Embedding)
open import Equality.Decision-procedures eq
open import Equivalence eq as Eq using (_≃_; Is-equivalence)
open import Equivalence.Erased.Basics eq using (Is-equivalenceᴱ)
open import Function-universe eq as F hiding (id; _∘_)
open import H-level eq as H-level
open import H-level.Closure eq
open import Surjection eq using (Split-surjective; _↠_)
private
variable
a b c d p : Level
A B : Type a
x y : A
f : A → B
k : Kind
n : ℕ
------------------------------------------------------------------------
-- Path-split
-- An alternative definition of "Is-equivalence".
Path-split : {A : Type a} {B : Type b} → ℕ → (A → B) → Type (a ⊔ b)
Path-split zero f = ↑ _ ⊤
Path-split (suc n) f =
Split-surjective f ×
(∀ x y → Path-split n (cong {x = x} {y = y} f))
private
-- A lemma.
eq→emb : Is-equivalence f → Is-equivalence (cong {x = x} {y = y} f)
eq→emb eq =
Embedding.is-embedding (from-isomorphism Eq.⟨ _ , eq ⟩) _ _
-- Equivalences are path-split.
Is-equivalence→Path-split : Is-equivalence f → Path-split n f
Is-equivalence→Path-split {n = zero} eq = _
Is-equivalence→Path-split {n = suc n} eq =
_≃_.split-surjective Eq.⟨ _ , eq ⟩
, λ x y → Is-equivalence→Path-split (eq→emb eq)
private
-- Path-split n f holds, for n ≥ 2, iff f is an equivalence.
Path-split⇔Is-equivalence :
Path-split (2 + n) f ⇔ Is-equivalence f
Path-split⇔Is-equivalence {f = f} = record
{ to = λ (s , p) →
let inv = proj₁ ∘ s
is-inv = proj₂ ∘ s
in _≃_.is-equivalence $ Eq.↔⇒≃ (record
{ surjection = record
{ right-inverse-of = is-inv
}
; left-inverse-of = λ x → $⟨ is-inv (f x) ⟩
f (inv (f x)) ≡ f x ↝⟨ proj₁ ∘ proj₁ (p _ _) ⟩
inv (f x) ≡ x □
})
; from = Is-equivalence→Path-split
}
-- If f is an equivalence, then Split-surjective f is contractible
-- (assuming extensionality).
Split-surjective-contractible-for-equivalences :
∀ {a b} {A : Type a} {B : Type b} {f : A → B} →
Extensionality b (a ⊔ b) →
Is-equivalence f →
Contractible (Split-surjective f)
Split-surjective-contractible-for-equivalences
{A = A} {B = B} {f = f} ext eq =
propositional⇒inhabited⇒contractible
(Π-closure ext 1 λ y →
let surj : (∃ λ x → x ≡ _≃_.from A≃B y) ↠ (∃ λ x → f x ≡ y)
surj = ∃-cong λ x →
x ≡ _≃_.from A≃B y ↔⟨ inverse $ Eq.≃-≡ A≃B ⟩
f x ≡ f (_≃_.from A≃B y) ↝⟨ ≡⇒↝ _ $ cong (_ ≡_) $ _≃_.right-inverse-of A≃B _ ⟩□
f x ≡ y □
in
H-level.respects-surjection surj 1 $
mono₁ 0 $
singleton-contractible _)
(_≃_.split-surjective A≃B)
where
A≃B : A ≃ B
A≃B = Eq.⟨ _ , eq ⟩
-- If f is an equivalence, then Path-split n f is contractible
-- (assuming extensionality).
Path-split-contractible-for-equivalences :
{A : Type a} {B : Type b} {f : A → B} →
Extensionality (a ⊔ b) (a ⊔ b) →
Is-equivalence f →
Contractible (Path-split n f)
Path-split-contractible-for-equivalences {n = zero} _ _ =
↑-closure 0 $
⊤-contractible
Path-split-contractible-for-equivalences
{a = a} {b = b} {n = suc n} {A = A} {B = B} {f = f} ext eq =
×-closure 0
(Split-surjective-contractible-for-equivalences
(lower-extensionality a lzero ext) eq)
(Π-closure (lower-extensionality b lzero ext) 0 λ _ →
Π-closure (lower-extensionality b lzero ext) 0 λ _ →
Path-split-contractible-for-equivalences
ext (eq→emb eq))
-- Path-split n is pointwise propositional for n ≥ 2 (assuming
-- extensionality).
Path-split-propositional :
{A : Type a} {B : Type b} {f : A → B} →
Extensionality (a ⊔ b) (a ⊔ b) →
Is-proposition (Path-split (2 + n) f)
Path-split-propositional ext =
[inhabited⇒contractible]⇒propositional λ p →
Path-split-contractible-for-equivalences ext $
_⇔_.to Path-split⇔Is-equivalence p
-- There is a bijection between Path-split n f, for n ≥ 2, and
-- Is-equivalence f (assuming extensionality).
Path-split↔Is-equivalence :
{A : Type a} {B : Type b} {f : A → B} →
Path-split (2 + n) f ↝[ a ⊔ b ∣ a ⊔ b ] Is-equivalence f
Path-split↔Is-equivalence =
generalise-ext?-prop
Path-split⇔Is-equivalence
Path-split-propositional
(λ ext → Eq.propositional ext _)
-- Another alternative definition of "Is-equivalence".
Path-split-∞ : {A : Type a} {B : Type b} → (A → B) → Type (a ⊔ b)
Path-split-∞ f = ∀ n → Path-split n f
-- Path-split-∞ is pointwise propositional (assuming extensionality).
Path-split-∞-propositional :
{A : Type a} {B : Type b} {f : A → B} →
Extensionality (a ⊔ b) (a ⊔ b) →
Is-proposition (Path-split-∞ f)
Path-split-∞-propositional ext =
[inhabited⇒contractible]⇒propositional λ p →
Π-closure (lower-extensionality _ lzero ext) 0 λ _ →
Path-split-contractible-for-equivalences ext $
_⇔_.to Path-split⇔Is-equivalence (p 2)
-- There is a bijection between Path-split-∞ f and Is-equivalence f
-- (assuming extensionality).
Path-split-∞↔Is-equivalence :
{A : Type a} {B : Type b} {f : A → B} →
Path-split-∞ f ↝[ a ⊔ b ∣ a ⊔ b ] Is-equivalence f
Path-split-∞↔Is-equivalence =
generalise-ext?-prop
(record
{ to = λ p → _⇔_.to Path-split⇔Is-equivalence (p 2)
; from = λ eq _ → Is-equivalence→Path-split eq
})
Path-split-∞-propositional
(λ ext → Eq.propositional ext _)
-- A preservation lemma for Path-split.
Path-split-cong :
{A : Type a} {B : Type b} {C : Type c} {D : Type d}
{f : A → B} {g : C → D} →
Extensionality? k (a ⊔ b ⊔ c ⊔ d) (a ⊔ b ⊔ c ⊔ d) →
(A≃C : A ≃ C) (B≃D : B ≃ D) →
(∀ x → g (_≃_.to A≃C x) ≡ _≃_.to B≃D (f x)) →
∀ n → Path-split n f ↝[ k ] Path-split n g
Path-split-cong
{a = a} {b = b} {c = c} {d = d} {k = k} {f = f} {g = g}
ext A≃C B≃D hyp = λ where
zero →
↑ _ ⊤ ↔⟨ B.↑↔ ⟩
⊤ ↔⟨ inverse B.↑↔ ⟩□
↑ _ ⊤ □
(suc n) →
(Split-surjective f ↔⟨⟩
(∀ y → ∃ λ x → f x ≡ y) ↝⟨ (Π-cong (lower-extensionality? k (a ⊔ c) lzero ext) B≃D λ y →
Σ-cong A≃C λ x →
(f x ≡ y) ↔⟨ inverse $ Eq.≃-≡ B≃D ⟩
(_≃_.to B≃D (f x) ≡ _≃_.to B≃D y) ↝⟨ ≡⇒↝ _ $ cong (_≡ _) $ sym $ hyp x ⟩□
(g (_≃_.to A≃C x) ≡ _≃_.to B≃D y) □) ⟩
(∀ y → ∃ λ x → g x ≡ y) ↔⟨⟩
Split-surjective g □)
×-cong
(Π-cong (lower-extensionality? k (b ⊔ d) lzero ext) A≃C λ x →
Π-cong (lower-extensionality? k (b ⊔ d) lzero ext) A≃C λ y →
Path-split-cong ext
(x ≡ y ↝⟨ inverse $ Eq.≃-≡ A≃C ⟩□
_≃_.to A≃C x ≡ _≃_.to A≃C y □)
(f x ≡ f y ↝⟨ inverse $ Eq.≃-≡ B≃D ⟩
_≃_.to B≃D (f x) ≡ _≃_.to B≃D (f y) ↝⟨ ≡⇒↝ _ $ cong₂ _≡_ (sym $ hyp x) (sym $ hyp y) ⟩□
g (_≃_.to A≃C x) ≡ g (_≃_.to A≃C y) □)
(λ x≡y →
cong g (cong (_≃_.to A≃C) x≡y) ≡⟨ cong-∘ _ _ _ ⟩
cong (g ∘ _≃_.to A≃C) x≡y ≡⟨ elim¹
(λ {y} x≡y →
cong (g ∘ _≃_.to A≃C) x≡y ≡
trans (trans (hyp x) (cong (_≃_.to B≃D ∘ f) x≡y))
(sym $ hyp y))
(
cong (g ∘ _≃_.to A≃C) (refl _) ≡⟨ cong-refl _ ⟩
refl _ ≡⟨ sym $ trans-symʳ _ ⟩
trans (hyp x) (sym $ hyp x) ≡⟨ cong (flip trans _) $
trans (sym $ trans-reflʳ _) $
cong (trans _) $ sym $ cong-refl _ ⟩∎
trans (trans (hyp x) (cong (_≃_.to B≃D ∘ f) (refl _)))
(sym $ hyp x) ∎)
_ ⟩
trans (trans (hyp x) (cong (_≃_.to B≃D ∘ f) x≡y))
(sym $ hyp y) ≡⟨ trans (cong (flip trans _) $ sym $
subst-trans _) $
trans-subst ⟩
subst (_ ≡_) (sym $ hyp y)
(subst (_≡ _) (sym $ hyp x)
(cong (_≃_.to B≃D ∘ f) x≡y)) ≡⟨ trans (cong (subst _ _) $
subst-in-terms-of-≡⇒↝ equivalence _ _ _) $
subst-in-terms-of-≡⇒↝ equivalence _ _ _ ⟩
_≃_.to (≡⇒↝ _ (cong (_ ≡_) (sym $ hyp y)))
(_≃_.to (≡⇒↝ _ (cong (_≡ _) (sym $ hyp x)))
(cong (_≃_.to B≃D ∘ f) x≡y)) ≡⟨ cong (_$ cong (_≃_.to B≃D ∘ f) x≡y) $ sym $
≡⇒↝-trans equivalence ⟩
_≃_.to
(≡⇒↝ _ $
trans (cong (_≡ _) (sym $ hyp x))
(cong (_ ≡_) (sym $ hyp y)))
(cong (_≃_.to B≃D ∘ f) x≡y) ≡⟨⟩
_≃_.to (≡⇒↝ _ $ cong₂ _≡_ (sym $ hyp x) (sym $ hyp y))
(cong (_≃_.to B≃D ∘ f) x≡y) ≡⟨ cong (_≃_.to (≡⇒↝ _ _)) $ sym $
cong-∘ _ _ _ ⟩∎
_≃_.to (≡⇒↝ _ $ cong₂ _≡_ (sym $ hyp x) (sym $ hyp y))
(cong (_≃_.to B≃D) (cong f x≡y)) ∎)
n)
------------------------------------------------------------------------
-- Extendable along
-- Is-[ n ]-extendable-along-[ f ] P means that P is n-extendable
-- along f.
Is-[_]-extendable-along-[_] :
{A : Type a} {B : Type b} →
ℕ → (A → B) → (B → Type c) → Type (a ⊔ b ⊔ c)
Is-[ zero ]-extendable-along-[ f ] P = ↑ _ ⊤
Is-[ suc n ]-extendable-along-[ f ] P =
((g : ∀ x → P (f x)) →
∃ λ (h : ∀ x → P x) → ∀ x → h (f x) ≡ g x) ×
((g h : ∀ x → P x) →
Is-[ n ]-extendable-along-[ f ] (λ x → g x ≡ h x))
-- Is-∞-extendable-along-[ f ] P means that P is ∞-extendable along f.
Is-∞-extendable-along-[_] :
{A : Type a} {B : Type b} →
(A → B) → (B → Type c) → Type (a ⊔ b ⊔ c)
Is-∞-extendable-along-[ f ] P =
∀ n → Is-[ n ]-extendable-along-[ f ] P
-- In the presence of extensionality Is-[_]-extendable-along-[_] can
-- be expressed using Path-split.
Is-extendable-along≃Path-split :
{A : Type a} {B : Type b} {P : B → Type p} {f : A → B} →
Extensionality (a ⊔ b ⊔ p) (a ⊔ b ⊔ p) →
∀ n →
Is-[ n ]-extendable-along-[ f ] P ≃
Path-split n (λ (g : ∀ x → P x) → g ∘ f)
Is-extendable-along≃Path-split {a = a} {b = b} {p = p} {f = f} ext =
λ where
zero → Eq.id
(suc n) →
(∀-cong (lower-extensionality b lzero ext) λ g →
∃-cong λ h →
(∀ x → h (f x) ≡ g x) ↝⟨ Eq.extensionality-isomorphism
(lower-extensionality (b ⊔ p) (a ⊔ b) ext) ⟩□
h ∘ f ≡ g □)
×-cong
(∀-cong (lower-extensionality a lzero ext) λ g →
∀-cong (lower-extensionality a lzero ext) λ h →
Is-[ n ]-extendable-along-[ f ] (λ x → g x ≡ h x) ↝⟨ Is-extendable-along≃Path-split ext n ⟩
Path-split n (_∘ f) ↝⟨ Path-split-cong ext
(Eq.extensionality-isomorphism ext₁)
(Eq.extensionality-isomorphism ext₂)
(λ eq →
cong (_∘ f) (apply-ext (Eq.good-ext ext₁) eq) ≡⟨ Eq.cong-pre-∘-good-ext ext₂ ext₁ _ ⟩∎
apply-ext (Eq.good-ext ext₂) (eq ∘ f) ∎)
n ⟩□
Path-split n (cong (_∘ f)) □)
where
ext₁ = lower-extensionality (a ⊔ p) (a ⊔ b) ext
ext₂ = lower-extensionality (b ⊔ p) (a ⊔ b) ext
-- In the presence of extensionality Is-∞-extendable-along-[_] can
-- be expressed using Path-split-∞.
Is-∞-extendable-along≃Path-split-∞ :
{A : Type a} {B : Type b} {P : B → Type p} {f : A → B} →
Extensionality (a ⊔ b ⊔ p) (a ⊔ b ⊔ p) →
Is-∞-extendable-along-[ f ] P ≃
Path-split-∞ (λ (g : ∀ x → P x) → g ∘ f)
Is-∞-extendable-along≃Path-split-∞ ext =
∀-cong (lower-extensionality _ lzero ext) $
Is-extendable-along≃Path-split ext
-- Is-[ 2 + n ]-extendable-along-[ f ] P is propositional (assuming
-- extensionality).
Is-extendable-along-propositional :
{A : Type a} {B : Type b} {P : B → Type p} {f : A → B} →
Extensionality (a ⊔ b ⊔ p) (a ⊔ b ⊔ p) →
Is-proposition (Is-[ 2 + n ]-extendable-along-[ f ] P)
Is-extendable-along-propositional ext =
H-level-cong _ 1 (inverse $ Is-extendable-along≃Path-split ext _) $
Path-split-propositional ext
-- Is-∞-extendable-along-[ f ] P is propositional (assuming
-- extensionality).
Is-∞-extendable-along-propositional :
{A : Type a} {B : Type b} {P : B → Type p} {f : A → B} →
Extensionality (a ⊔ b ⊔ p) (a ⊔ b ⊔ p) →
Is-proposition (Is-∞-extendable-along-[ f ] P)
Is-∞-extendable-along-propositional ext =
H-level-cong _ 1 (inverse $ Is-∞-extendable-along≃Path-split-∞ ext) $
Path-split-∞-propositional ext
-- In the presence of extensionality Is-∞-extendable-along-[_] can be
-- expressed using Is-equivalence.
Is-∞-extendable-along≃Is-equivalence :
{A : Type a} {B : Type b} {P : B → Type p} {f : A → B} →
Extensionality (a ⊔ b ⊔ p) (a ⊔ b ⊔ p) →
Is-∞-extendable-along-[ f ] P ≃
Is-equivalence (λ (g : ∀ x → P x) → g ∘ f)
Is-∞-extendable-along≃Is-equivalence {P = P} {f = f} ext =
Is-∞-extendable-along-[ f ] P ↝⟨ Is-∞-extendable-along≃Path-split-∞ ext ⟩
Path-split-∞ (_∘ f) ↝⟨ Path-split-∞↔Is-equivalence ext ⟩□
Is-equivalence (_∘ f) □
-- The definitions below are not taken directly from "Universal
-- properties without function extensionality".
-- A type B is P-null for a predicate P of type A → Type p if the
-- function const of type B → P x → B is an equivalence for each x.
--
-- This definition is based on one from "Modalities in Homotopy Type
-- Theory" by Rijke, Shulman and Spitters.
_-Null_ : {A : Type a} → (A → Type p) → Type b → Type (a ⊔ b ⊔ p)
P -Null B = ∀ x → Is-equivalence (const ⦂ (B → P x → B))
-- A variant of _-Null_ with erased proofs.
_-Nullᴱ_ : {A : Type a} → (A → Type p) → Type b → Type (a ⊔ b ⊔ p)
P -Nullᴱ B = ∀ x → Is-equivalenceᴱ (const ⦂ (B → P x → B))
-- Is-∞-extendable-along-[_] can sometimes be replaced by
-- Is-equivalence const.
Is-∞-extendable-along≃Is-equivalence-const :
{A : Type a} {B : Type b} →
Extensionality (a ⊔ b) (a ⊔ b) →
Is-∞-extendable-along-[ (λ (_ : A) → lift tt) ] (λ (_ : ↑ a ⊤) → B) ≃
Is-equivalence (const ⦂ (B → A → B))
Is-∞-extendable-along≃Is-equivalence-const {a = a} {A = A} {B = B} ext =
Is-∞-extendable-along-[ (λ _ → lift tt) ] (λ (_ : ↑ a ⊤) → B) ↝⟨ Is-∞-extendable-along≃Is-equivalence ext ⟩
Is-equivalence (_∘ (λ _ → lift tt) ⦂ ((↑ a ⊤ → B) → (A → B))) ↝⟨ inverse $
Is-equivalence≃Is-equivalence-∘ʳ
(_≃_.is-equivalence $ Eq.↔→≃ (_$ lift tt) const refl refl) ext ⟩□
Is-equivalence (const ⦂ (B → A → B)) □
-- A corollary of Is-∞-extendable-along≃Is-equivalence-const.
Π-Is-∞-extendable-along≃Null :
{A : Type a} {P : A → Type p} {B : Type b} →
Extensionality (a ⊔ b ⊔ p) (b ⊔ p) →
(∀ x → Is-∞-extendable-along-[ (λ (_ : P x) → lift tt) ]
(λ (_ : ↑ p ⊤) → B)) ≃
P -Null B
Π-Is-∞-extendable-along≃Null {a = a} {p = p} {b = b} ext =
∀-cong (lower-extensionality (b ⊔ p) lzero ext) λ _ →
Is-∞-extendable-along≃Is-equivalence-const
(lower-extensionality a lzero ext)
private
-- If const is an equivalence from Bool to B → Bool, then B is not
-- not inhabited (assuming extensionality).
Is-equivalence-const→¬¬ :
{B : Type b} →
Extensionality b lzero →
Is-equivalence (const ⦂ (Bool → B → Bool)) →
¬ ¬ B
Is-equivalence-const→¬¬ {B = B} ext =
curry
(Is-equivalence (const ⦂ (Bool → B → Bool)) × ¬ B →⟨ Σ-map Eq.⟨ _ ,_⟩ (Eq.↔⇒≃ ∘ inverse ∘ B.⊥↔uninhabited) ⟩
Bool ≃ (B → Bool) × B ≃ ⊥ →⟨ (λ (≃B→ , B≃) → →-cong ext B≃ F.id F.∘ ≃B→) ⟩
Bool ≃ (⊥ → Bool) →⟨ Π⊥↔⊤ ext F.∘_ ⟩
Bool ≃ ⊤ →⟨ (λ eq → _≃_.to (Eq.≃-≡ eq) (refl _)) ⟩
true ≡ false →⟨ Bool.true≢false ⟩□
⊥ □)
-- If const is an equivalence from Bool to B → Bool, and equality is
-- decidable for B, then B is a proposition.
Is-equivalence-const→Decidable-equality→Is-proposition :
Is-equivalence (const ⦂ (Bool → B → Bool)) →
Decidable-equality B →
Is-proposition B
Is-equivalence-const→Decidable-equality→Is-proposition
{B = B} eq _≟_ x y = x≡y
where
lemma :
(f g : B → Bool) → f ≢ g →
(h : B → Bool) → f ≡ h ⊎ g ≡ h
lemma = $⟨ helper ⟩
((x y : Bool) → x ≢ y → (z : Bool) → x ≡ z ⊎ y ≡ z) →⟨ (Π-cong _ equiv λ x → Π-cong _ equiv λ y →
→-cong-→ (→-cong-→ (_≃_.from (Eq.≃-≡ equiv)) id) $
Π-cong _ equiv λ z →
_≃_.from (Eq.≃-≡ equiv ⊎-cong Eq.≃-≡ equiv)) ⟩□
((f g : B → Bool) → f ≢ g → (h : B → Bool) → f ≡ h ⊎ g ≡ h) □
where
equiv : Bool ≃ (B → Bool)
equiv = Eq.⟨ _ , eq ⟩
true≡⊎false≡ : (b : Bool) → true ≡ b ⊎ false ≡ b
true≡⊎false≡ true = inj₁ (refl _)
true≡⊎false≡ false = inj₂ (refl _)
helper : (x y : Bool) → x ≢ y → (z : Bool) → x ≡ z ⊎ y ≡ z
helper true true t≢t = ⊥-elim $ t≢t (refl _)
helper true false _ = true≡⊎false≡
helper false true _ = _↔_.to ⊎-comm ∘ true≡⊎false≡
helper false false f≢f = ⊥-elim $ f≢f (refl _)
f₁ f₂ f₃ : B → Bool
f₁ _ = true
f₂ _ = false
f₃ z = if x ≟ z then true else false
f₁≢f₂ : f₁ ≢ f₂
f₁≢f₂ f₁≡f₂ = Bool.true≢false $ cong (_$ x) f₁≡f₂
f₁≡f₃→x≡y : f₁ ≡ f₃ → x ≡ y
f₁≡f₃→x≡y f₁≡f₃ = helper (x ≟ y) (cong (_$ y) f₁≡f₃)
where
helper :
(d : Dec (x ≡ y)) →
true ≡ if d then true else false →
x ≡ y
helper (yes x≡y) _ = x≡y
helper (no _) true≡false =
⊥-elim $ Bool.true≢false true≡false
f₂≢f₃ : f₂ ≢ f₃
f₂≢f₃ =
f₂ ≡ f₃ →⟨ cong (_$ x) ⟩
false ≡ if x ≟ x then true else false →⟨ flip trans (helper (x ≟ x)) ⟩
false ≡ true →⟨ Bool.true≢false ∘ sym ⟩□
⊥ □
where
helper :
(d : Dec (x ≡ x)) →
if d then true else false ≡ true
helper (yes _) = refl _
helper (no x≢x) = ⊥-elim $ x≢x $ refl _
f₁≡⊎f₂≡ : (f : B → Bool) → f₁ ≡ f ⊎ f₂ ≡ f
f₁≡⊎f₂≡ = lemma f₁ f₂ f₁≢f₂
x≡y : x ≡ y
x≡y with f₁≡⊎f₂≡ f₃
… | inj₁ f₁≡f₃ = f₁≡f₃→x≡y f₁≡f₃
… | inj₂ f₂≡f₃ = ⊥-elim $ f₂≢f₃ f₂≡f₃
-- If f is an equivalence, then n-extendability along f is
-- contractible (assuming extensionality).
Is-extendable-along-contractible-for-equivalences :
{A : Type a} {B : Type b} {f : A → B} {P : B → Type p} →
Extensionality (a ⊔ b ⊔ p) (a ⊔ b ⊔ p) →
Is-equivalence f →
∀ n → Contractible (Is-[ n ]-extendable-along-[ f ] P)
Is-extendable-along-contractible-for-equivalences _ _ zero =
↑-closure 0 ⊤-contractible
Is-extendable-along-contractible-for-equivalences
{a = a} {b = b} {p = p} {f = f} {P = P} ext eq (suc n) =
×-closure 0
(Π-closure (lower-extensionality b lzero ext) 0 λ g →
$⟨ singleton-contractible _ ⟩
Contractible (∃ λ h → h ≡ subst P (inv _) ∘ g ∘ f⁻¹) ↝⟨ H-level-cong _ 0 (lemma g) ⦂ (_ → _) ⟩□
Contractible (∃ λ h → ∀ x → h (f x) ≡ g x) □)
(Π-closure (lower-extensionality a lzero ext) 0 λ _ →
Π-closure (lower-extensionality a lzero ext) 0 λ _ →
Is-extendable-along-contractible-for-equivalences ext eq n)
where
f⁻¹ = _≃_.from Eq.⟨ _ , eq ⟩
inv = _≃_.left-inverse-of (inverse Eq.⟨ _ , eq ⟩)
lemma : ∀ _ → _ ≃ _
lemma g =
(∃ λ h → h ≡ subst P (inv _) ∘ g ∘ f⁻¹) ↔⟨ (∃-cong λ h → inverse $
∘from≡↔≡∘to′ (lower-extensionality p (a ⊔ b) ext) (inverse Eq.⟨ _ , eq ⟩)) ⟩
(∃ λ h → h ∘ f ≡ g) ↝⟨ (∃-cong λ _ → inverse $
Eq.extensionality-isomorphism (lower-extensionality (b ⊔ p) (a ⊔ b) ext)) ⟩□
(∃ λ h → ∀ x → h (f x) ≡ g x) □
-- If f is an equivalence, then ∞-extendability along f is
-- contractible (assuming extensionality).
Is-∞-extendable-along-contractible-for-equivalences :
{A : Type a} {B : Type b} {f : A → B} {P : B → Type p} →
Extensionality (a ⊔ b ⊔ p) (a ⊔ b ⊔ p) →
Is-equivalence f →
Contractible (Is-∞-extendable-along-[ f ] P)
Is-∞-extendable-along-contractible-for-equivalences ext eq =
Π-closure (lower-extensionality _ lzero ext) 0 λ n →
Is-extendable-along-contractible-for-equivalences ext eq n
------------------------------------------------------------------------
-- Alternatives to Is-[_]-extendable-along-[_] and
-- Is-∞-extendable-along-[_]
-- A variant of Is-[_]-extendable-along-[_].
Is-[_]-extendable-along-const-tt-[_] :
ℕ → Type a → Type b → Type (a ⊔ b)
Is-[ zero ]-extendable-along-const-tt-[ A ] B = ↑ _ ⊤
Is-[ suc n ]-extendable-along-const-tt-[ A ] B =
((g : A → B) → ∃ λ (x : B) → ∀ y → x ≡ g y) ×
((x y : B) → Is-[ n ]-extendable-along-const-tt-[ A ] (x ≡ y))
-- A variant of Is-∞-extendable-along-[_].
Is-∞-extendable-along-const-tt-[_] :
Type a → Type b → Type (a ⊔ b)
Is-∞-extendable-along-const-tt-[ A ] B =
∀ n → Is-[ n ]-extendable-along-const-tt-[ A ] B
-- In some cases Is-[_]-extendable-along-[_] and
-- Is-∞-extendable-along-[_] can be replaced by the variants.
≃Is-extendable-along-const-tt :
{A : Type a} {B : Type b} →
Extensionality? k (a ⊔ b) (a ⊔ b) →
∀ n →
Is-[ n ]-extendable-along-[ (λ (_ : A) → lift tt) ]
(λ (_ : ↑ a ⊤) → B) ↝[ k ]
Is-[ n ]-extendable-along-const-tt-[ A ] B
≃Is-extendable-along-const-tt _ zero = F.id
≃Is-extendable-along-const-tt {a = a} {k = k} ext (suc n) =
(∀-cong ext λ _ →
Σ-cong (Eq.↔→≃ (_$ lift tt) const refl refl) λ _ →
F.id)
×-cong
Π-cong ext′ (Eq.↔→≃ (_$ lift tt) const refl refl) λ _ →
Π-cong ext′ (Eq.↔→≃ (_$ lift tt) const refl refl) λ _ →
≃Is-extendable-along-const-tt ext n
where
ext′ = lower-extensionality? k a lzero ext
≃Is-∞-extendable-along-const-tt :
{A : Type a} {B : Type b} →
Extensionality? k (a ⊔ b) (a ⊔ b) →
Is-∞-extendable-along-[ (λ (_ : A) → lift tt) ] (λ (_ : ↑ a ⊤) → B)
↝[ k ]
Is-∞-extendable-along-const-tt-[ A ] B
≃Is-∞-extendable-along-const-tt {k = k} ext =
∀-cong (lower-extensionality? k _ lzero ext) λ n →
≃Is-extendable-along-const-tt ext n
-- Preservation lemmas for Is-[_]-extendable-along-[_] and
-- Is-∞-extendable-along-[_].
Is-extendable-along-const-tt-cong :
{A : Type a} {B : Type b} {C : Type c} →
Extensionality? k (a ⊔ b ⊔ c) (a ⊔ b ⊔ c) →
(A≃B : A ≃ B)
(A→≃B→ : {C : Type c} → (A → C) ≃ (B → C)) →
({C : Type c} (f : A → C) (x : A) →
_≃_.to A→≃B→ f (_≃_.to A≃B x) ≡ f x) →
∀ n →
Is-[ n ]-extendable-along-const-tt-[ A ] C ↝[ k ]
Is-[ n ]-extendable-along-const-tt-[ B ] C
Is-extendable-along-const-tt-cong _ _ _ _ zero =
↑ _ ⊤ ↔⟨ B.↑↔ ⟩
⊤ ↔⟨ inverse B.↑↔ ⟩□
↑ _ ⊤ □
Is-extendable-along-const-tt-cong
{a = a} {b = b} {c = c} {k = k} ext A≃B A→≃B→ hyp (suc n) =
(Π-cong ext A→≃B→ λ g →
∃-cong λ x →
Π-cong (lower-extensionality? k c (a ⊔ b) ext) A≃B λ y →
x ≡ g y ↝⟨ ≡⇒↝ _ $ cong (_ ≡_) $ sym $ hyp g y ⟩□
x ≡ _≃_.to A→≃B→ g (_≃_.to A≃B y) □)
×-cong
(∀-cong (lower-extensionality? k (a ⊔ b) lzero ext) λ x →
∀-cong (lower-extensionality? k (a ⊔ b) lzero ext) λ y →
Is-extendable-along-const-tt-cong ext A≃B A→≃B→ hyp n)
Is-∞-extendable-along-const-tt-cong :
{A : Type a} {B : Type b} {C : Type c} →
Extensionality? k (a ⊔ b ⊔ c) (a ⊔ b ⊔ c) →
(A≃B : A ≃ B)
(A→≃B→ : {C : Type c} → (A → C) ≃ (B → C)) →
({C : Type c} (f : A → C) (x : A) →
_≃_.to A→≃B→ f (_≃_.to A≃B x) ≡ f x) →
Is-∞-extendable-along-const-tt-[ A ] C ↝[ k ]
Is-∞-extendable-along-const-tt-[ B ] C
Is-∞-extendable-along-const-tt-cong {k = k} ext A≃B A→≃B→ hyp =
∀-cong (lower-extensionality? k _ lzero ext) λ n →
Is-extendable-along-const-tt-cong ext A≃B A→≃B→ hyp n
| 39.414307
| 135
| 0.479449
|
06f71e99950b70a4f45a9fb8ca5b93982607fe9c
| 2,900
|
agda
|
Agda
|
src/index.agda
|
JLimperg/msc-thesis-code
|
104cddc6b65386c7e121c13db417aebfd4b7a863
|
[
"MIT"
] | 5
|
2021-04-13T21:31:17.000Z
|
2021-06-26T06:37:31.000Z
|
src/index.agda
|
JLimperg/msc-thesis-code
|
104cddc6b65386c7e121c13db417aebfd4b7a863
|
[
"MIT"
] | null | null | null |
src/index.agda
|
JLimperg/msc-thesis-code
|
104cddc6b65386c7e121c13db417aebfd4b7a863
|
[
"MIT"
] | null | null | null |
-- # A Reflexive Graph Model of Sized Types
-- This is the formalisation of my M.Sc. thesis, available at
-- https://limperg.de/paper/msc-thesis/
-- I define λST, a simply typed lambda calculus extended with sized types. I
-- then give a reflexive graph model of λST which incorporates a notion of size
-- irrelevance. This document lists all modules belonging to the development,
-- roughly in dependency order.
module index where
-- ## Object Language
-- The following modules define the syntax and type system of λST.
-- Sizes, size contexts, size comparison.
import Source.Size
-- First formulation of size substitutions.
import Source.Size.Substitution.Canonical
-- Second formulation of size substitutions.
import Source.Size.Substitution.Universe
-- An abstraction for things which size substitutions can be applied to.
import Source.Size.Substitution.Theory
-- Types.
import Source.Type
-- Terms.
import Source.Term
-- ## Model
-- The following modules define the reflexive graph model of λST.
-- Propositional reflexive graphs and their morphisms.
import Model.RGraph
-- Model of sizes, size contexts, size comparison.
import Model.Size
-- Families of propositional reflexive graphs (PRGraph families) and their
-- morphisms.
import Model.Type.Core
-- The terminal PRGraph family.
import Model.Terminal
-- Binary products of PRGraph families.
import Model.Product
-- Exponentials of PRGraph families (model of the function space).
import Model.Exponential
-- Model of size quantification.
import Model.Quantification
-- Model of the natural number type.
import Model.Nat
-- Model of the stream type.
import Model.Stream
-- Model of types and type contexts.
import Model.Type
-- Model of terms.
import Model.Term
-- ## Utility Library
-- The following modules contain utility code. The majority of this is an
-- implementation of (parts of) Homotopy Type Theory.
import Util.Data.Product
import Util.HoTT.Equiv
import Util.HoTT.Equiv.Core
import Util.HoTT.Equiv.Induction
import Util.HoTT.FunctionalExtensionality
import Util.HoTT.HLevel
import Util.HoTT.HLevel.Core
import Util.HoTT.Homotopy
import Util.HoTT.Section
import Util.HoTT.Singleton
import Util.HoTT.Univalence
import Util.HoTT.Univalence.Axiom
import Util.HoTT.Univalence.Beta
import Util.HoTT.Univalence.ContrFormulation
import Util.HoTT.Univalence.Statement
import Util.Induction.WellFounded
import Util.Prelude
import Util.Relation.Binary.Closure.SymmetricTransitive
import Util.Relation.Binary.LogicalEquivalence
import Util.Relation.Binary.PropositionalEquality
import Util.Vec
-- ## Miscellaneous
-- Some terms of λST and their typing derivations.
import Source.Examples
-- Experiments with a hypothetical Agda without the ∞ < ∞ rule.
import irreflexive-lt
-- Ordinals as defined in the HoTT book.
import Ordinal.HoTT
-- Plump ordinals as presented by Shulman.
import Ordinal.Shulman
| 24.576271
| 79
| 0.788276
|
fb5a7b23dce6c8349960d76ddfb4d12f26541821
| 743
|
agda
|
Agda
|
test/Fail/Issue295.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue295.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue295.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- {-# OPTIONS -v tc.with:50 #-}
module Issue295 where
data ⊥ : Set where
data Arr : Set where
_⟶_ : ⊥ → ⊥ → Arr
_﹔_ : Arr → Arr → Arr
(a ⟶ b)﹔(c ⟶ d) with b
... | ()
data Fun : Arr → Set where
∙ : ∀ a b c d → Fun (a ⟶ b) → Fun (c ⟶ d) → Fun ((a ⟶ b)﹔(c ⟶ d))
f : ∀ a b c d e f → Fun (a ⟶ b) → Fun (c ⟶ d) → Fun (e ⟶ f)
f a b c d e f F G = ∙ a b c d F G
-- The problem does not appear to be restricted to the pretty-printer.
-- With -v10 I get the following output:
--
-- compareTerm (a ⟶ b) ﹔ (b ⟶ c) == a ⟶ c : Arr
-- { compareAtom
-- compareAtom (b ⟶ a) ﹔ (c ⟶ b) | b == a ⟶ c : Arr
-- /tmp/Bug.agda:16,15-28
-- (b ⟶ a) ﹔ (c ⟶ b) | b != a ⟶ c of type Arr
-- when checking that the expression ∙ a b b c F G has type
-- Fun (a ⟶ c)
| 25.62069
| 70
| 0.508748
|
c5699424064ae764646e525fe6ffe22214328478
| 1,950
|
agda
|
Agda
|
theorems/cw/cohomology/HigherCohomologyGroupsOnDiag.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
theorems/cw/cohomology/HigherCohomologyGroupsOnDiag.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
theorems/cw/cohomology/HigherCohomologyGroupsOnDiag.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | 1
|
2018-12-26T21:31:57.000Z
|
2018-12-26T21:31:57.000Z
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import cohomology.Theory
open import groups.ExactSequence
open import groups.Exactness
open import groups.HomSequence
open import groups.KernelImageUniqueFactorization
import cw.cohomology.GridPtdMap as GPM
open import cw.CW
module cw.cohomology.HigherCohomologyGroupsOnDiag {i} (OT : OrdinaryTheory i)
{n} (⊙skel : ⊙Skeleton {i} (S (S n))) (ac : ⊙has-cells-with-choice 0 ⊙skel i) where
private
n≤SSn : n ≤ S (S n)
n≤SSn = lteSR lteS
⊙skel₋₁ = ⊙cw-init ⊙skel
ac₋₁ = ⊙init-has-cells-with-choice ⊙skel ac
⊙skel₋₂ = ⊙cw-take n≤SSn ⊙skel
ac₋₂ = ⊙take-has-cells-with-choice n≤SSn ⊙skel ac
open OrdinaryTheory OT
open import cw.cohomology.Descending OT
open import cw.cohomology.WedgeOfCells OT
open import cw.cohomology.HigherCoboundary OT ⊙skel
open import cw.cohomology.HigherCoboundaryGrid OT ⊙skel ac
{-
Coker ≃ C(X₂/X₀) ≃ C(X)
^
|
|
C(X₁/X₀)
WoC
WoC := Wedges of Cells
-}
private
C-apex : Group i
C-apex = C (ℕ-to-ℤ (S (S n))) (⊙Cofiber (⊙cw-incl-tail n≤SSn ⊙skel))
open import cohomology.LongExactSequence cohomology-theory
(ℕ-to-ℤ (S n)) (⊙cw-incl-tail n≤SSn ⊙skel)
C-apex-iso-C-cw : C-apex ≃ᴳ C (ℕ-to-ℤ (S (S n))) ⊙⟦ ⊙skel ⟧
C-apex-iso-C-cw = Exact2.G-trivial-and-L-trivial-implies-H-iso-K
(exact-seq-index 1 C-cofiber-exact-seq)
(exact-seq-index 2 C-cofiber-exact-seq)
(C-cw-at-higher ⊙skel₋₂ ltS ac₋₂)
(C-cw-at-higher ⊙skel₋₂ (ltSR ltS) ac₋₂)
open import groups.KernelImage (cst-hom {H = Lift-group {j = i} Unit-group}) cw-co∂-last
(CXₙ/Xₙ₋₁-is-abelian ⊙skel (ℕ-to-ℤ (S (S n))))
open import groups.KernelCstImage (Lift-group {j = i} Unit-group) cw-co∂-last
(CXₙ/Xₙ₋₁-is-abelian ⊙skel (ℕ-to-ℤ (S (S n))))
C-cw-iso-ker/im : C (ℕ-to-ℤ (S (S n))) ⊙⟦ ⊙skel ⟧ ≃ᴳ Ker/Im
C-cw-iso-ker/im = (C-apex-iso-C-cw ∘eᴳ Coker-cw-co∂-last ∘eᴳ Ker-cst-quot-Im) ⁻¹ᴳ
| 29.545455
| 88
| 0.651282
|
20a7871deb90eb4ecbe4247aaee222e84e9a3c82
| 1,237
|
agda
|
Agda
|
src/Tactic/Reflection/Telescope.agda
|
lclem/agda-prelude
|
75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6
|
[
"MIT"
] | null | null | null |
src/Tactic/Reflection/Telescope.agda
|
lclem/agda-prelude
|
75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6
|
[
"MIT"
] | null | null | null |
src/Tactic/Reflection/Telescope.agda
|
lclem/agda-prelude
|
75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6
|
[
"MIT"
] | null | null | null |
module Tactic.Reflection.Telescope where
open import Prelude hiding (abs)
open import Builtin.Reflection
open import Tactic.Reflection.DeBruijn
Telescope = List (Arg Type)
telView : Type → Telescope × Type
telView (pi a (abs _ b)) = first (_∷_ a) (telView b)
telView a = [] , a
visibleArity : Type → Nat
visibleArity = length ∘ filter isVisible ∘ fst ∘ telView
telPi : Telescope → Type → Type
telPi tel b = foldr (λ a b → pi a (abs "_" b)) b tel
arity : Name → TC Nat
arity f = length ∘ fst ∘ telView <$> getType f
argTel : Name → TC Telescope
argTel f = fst ∘ telView <$> getType f
telePat : Telescope → List (Arg Pattern)
telePat = map (var "_" <$_)
private
teleArgs′ : Nat → List (Arg Type) → List (Arg Term)
teleArgs′ (suc n) (a ∷ Γ) = (var n [] <$ a) ∷ teleArgs′ n Γ
teleArgs′ _ _ = []
teleArgs : Telescope → List (Arg Term)
teleArgs Γ = teleArgs′ (length Γ) Γ
conParams : Name → TC Nat
conParams c =
caseM getDefinition c of λ
{ (data-cons d) → getParameters d
; _ → pure 0 }
conPat : Name → TC Pattern
conPat c = do
np ← conParams c
con c ∘ telePat ∘ drop np <$> argTel c
conTerm : Name → TC Term
conTerm c = do
np ← conParams c
con c ∘ teleArgs ∘ drop np <$> argTel c
| 23.788462
| 61
| 0.641876
|
4d04760abadabadf249cb8c67524c9d5fbfc5028
| 221
|
agda
|
Agda
|
test/Common/Nat.agda
|
favonia/agda
|
8d433b967567c08afe15d04a5cb63b6f6d8884ee
|
[
"BSD-2-Clause"
] | null | null | null |
test/Common/Nat.agda
|
favonia/agda
|
8d433b967567c08afe15d04a5cb63b6f6d8884ee
|
[
"BSD-2-Clause"
] | 6
|
2021-10-18T08:12:24.000Z
|
2021-11-24T08:31:10.000Z
|
test/Common/Nat.agda
|
antoinevanmuylder/agda
|
bd59d5b07ffe02a43b28d186d95e1747aac5bc8c
|
[
"BSD-2-Clause"
] | null | null | null |
{-# OPTIONS --cubical-compatible #-}
module Common.Nat where
open import Agda.Builtin.Nat public
using ( Nat; zero; suc; _+_; _*_ )
renaming ( _-_ to _∸_ )
pred : Nat → Nat
pred zero = zero
pred (suc n) = n
| 17
| 39
| 0.624434
|
1dbaa30924a3c02e202f4a3b6d7c83b8c0334272
| 1,616
|
agda
|
Agda
|
src/Web/Semantic/DL/Category/Properties/Tensor/RespectsEquiv.agda
|
agda/agda-web-semantic
|
8ddbe83965a616bff6fc7a237191fa261fa78bab
|
[
"MIT"
] | 9
|
2015-09-13T17:46:41.000Z
|
2020-03-14T14:21:08.000Z
|
src/Web/Semantic/DL/Category/Properties/Tensor/RespectsEquiv.agda
|
bblfish/agda-web-semantic
|
38fbc3af7062ba5c3d7d289b2b4bcfb995d99057
|
[
"MIT"
] | 4
|
2018-11-14T02:32:28.000Z
|
2021-01-04T20:57:19.000Z
|
src/Web/Semantic/DL/Category/Properties/Tensor/RespectsEquiv.agda
|
bblfish/agda-web-semantic
|
38fbc3af7062ba5c3d7d289b2b4bcfb995d99057
|
[
"MIT"
] | 3
|
2017-12-03T14:52:09.000Z
|
2022-03-12T11:40:03.000Z
|
open import Data.Product using ( _,_ )
open import Data.Sum using ( inj₁ ; inj₂ )
open import Web.Semantic.DL.ABox.Interp using ( _*_ )
open import Web.Semantic.DL.ABox.Model using ( *-resp-⟨ABox⟩ )
open import Web.Semantic.DL.Category.Object using ( Object ; iface )
open import Web.Semantic.DL.Category.Morphism using ( _⇒_ ; _≣_ ; _⊑_ ; _,_ )
open import Web.Semantic.DL.Category.Tensor using ( _⟨⊗⟩_ )
open import Web.Semantic.DL.Category.Properties.Tensor.Lemmas using
( tensor-up ; tensor-down ; tensor-resp-⊨b )
open import Web.Semantic.DL.Signature using ( Signature )
open import Web.Semantic.DL.TBox using ( TBox )
open import Web.Semantic.Util using ( inode ; up ; down )
module Web.Semantic.DL.Category.Properties.Tensor.RespectsEquiv
{Σ : Signature} {S T : TBox Σ} where
tensor-resp-⊑ : ∀ {A₁ A₂ B₁ B₂ : Object S T}
(F₁ G₁ : A₁ ⇒ B₁) (F₂ G₂ : A₂ ⇒ B₂) →
(F₁ ⊑ G₁) → (F₂ ⊑ G₂) → (F₁ ⟨⊗⟩ F₂ ⊑ G₁ ⟨⊗⟩ G₂)
tensor-resp-⊑ {A₁} {A₂} F₁ G₁ F₂ G₂ F₁⊑G₁ F₂⊑G₂
I (I⊨ST , (I⊨A₁ , I⊨A₂)) I⊨F₁F₂ =
tensor-resp-⊨b G₁ G₂ I
(F₁⊑G₁ (up * I)
(I⊨ST , *-resp-⟨ABox⟩ inj₁ (inode * I) (iface A₁) I⊨A₁)
(tensor-up F₁ F₂ I I⊨F₁F₂))
(F₂⊑G₂ (down * I)
(I⊨ST , *-resp-⟨ABox⟩ inj₂ (inode * I) (iface A₂) I⊨A₂)
(tensor-down F₁ F₂ I I⊨F₁F₂))
tensor-resp-≣ : ∀ {A₁ A₂ B₁ B₂ : Object S T}
{F₁ G₁ : A₁ ⇒ B₁} {F₂ G₂ : A₂ ⇒ B₂} →
(F₁ ≣ G₁) → (F₂ ≣ G₂) → (F₁ ⟨⊗⟩ F₂ ≣ G₁ ⟨⊗⟩ G₂)
tensor-resp-≣ {A₁} {A₂} {B₁} {B₂} {F₁} {G₁} {F₂} {G₂}
(F₁⊑G₁ , G₁⊑F₁) (F₂⊑G₂ , G₂⊑F₂) =
( tensor-resp-⊑ F₁ G₁ F₂ G₂ F₁⊑G₁ F₂⊑G₂
, tensor-resp-⊑ G₁ F₁ G₂ F₂ G₁⊑F₁ G₂⊑F₂ )
| 43.675676
| 77
| 0.598391
|
317e0fb8ac6aac5c63c2bfe2e2394b6605b1fad5
| 2,968
|
agda
|
Agda
|
Cubical/Categories/Monoidal/Base.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/Categories/Monoidal/Base.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/Categories/Monoidal/Base.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
-- Monoidal categories
{-# OPTIONS --safe #-}
module Cubical.Categories.Monoidal.Base where
open import Cubical.Categories.Category.Base
open import Cubical.Categories.Constructions.BinProduct
open import Cubical.Categories.Functor.Base
open import Cubical.Categories.Functor.BinProduct
open import Cubical.Categories.Morphism
open import Cubical.Categories.NaturalTransformation.Base
open import Cubical.Foundations.Prelude
module _ {ℓ ℓ' : Level} (C : Category ℓ ℓ') where
open Category C
record TensorStr : Type (ℓ-max ℓ ℓ') where
field
─⊗─ : Functor (C × C) C
unit : ob
open Functor
-- Useful tensor product notation
_⊗_ : ob → ob → ob
x ⊗ y = ─⊗─ .F-ob (x , y)
_⊗ₕ_ : ∀ {x y z w} → Hom[ x , y ] → Hom[ z , w ]
→ Hom[ x ⊗ z , y ⊗ w ]
f ⊗ₕ g = ─⊗─ .F-hom (f , g)
record StrictMonStr : Type (ℓ-max ℓ ℓ') where
field
tenstr : TensorStr
open TensorStr tenstr public
field
-- Axioms - strict
assoc : ∀ x y z → x ⊗ (y ⊗ z) ≡ (x ⊗ y) ⊗ z
idl : ∀ x → unit ⊗ x ≡ x
idr : ∀ x → x ⊗ unit ≡ x
record MonoidalStr : Type (ℓ-max ℓ ℓ') where
field
tenstr : TensorStr
open TensorStr tenstr public
private
-- Private names to make the axioms below look nice
x⊗[y⊗z] : Functor (C × C × C) C
x⊗[y⊗z] = ─⊗─ ∘F (𝟙⟨ C ⟩ ×F ─⊗─)
[x⊗y]⊗z : Functor (C × C × C) C
[x⊗y]⊗z = ─⊗─ ∘F (─⊗─ ×F 𝟙⟨ C ⟩) ∘F (×C-assoc C C C)
x = 𝟙⟨ C ⟩
1⊗x = ─⊗─ ∘F (rinj C C unit)
x⊗1 = ─⊗─ ∘F (linj C C unit)
field
-- "Axioms" - up to natural isomorphism
α : x⊗[y⊗z] ≅ᶜ [x⊗y]⊗z
η : 1⊗x ≅ᶜ x
ρ : x⊗1 ≅ᶜ x
open NatIso
-- More nice notations
α⟨_,_,_⟩ : (x y z : ob) → Hom[ x ⊗ (y ⊗ z) , (x ⊗ y) ⊗ z ]
α⟨ x , y , z ⟩ = α .trans ⟦ ( x , y , z ) ⟧
η⟨_⟩ : (x : ob) → Hom[ unit ⊗ x , x ]
η⟨ x ⟩ = η .trans ⟦ x ⟧
ρ⟨_⟩ : (x : ob) → Hom[ x ⊗ unit , x ]
ρ⟨ x ⟩ = ρ .trans ⟦ x ⟧
field
-- Coherence conditions
pentagon : ∀ w x y z →
id ⊗ₕ α⟨ x , y , z ⟩ ⋆ α⟨ w , x ⊗ y , z ⟩ ⋆ α⟨ w , x , y ⟩ ⊗ₕ id
≡ α⟨ w , x , y ⊗ z ⟩ ⋆ α⟨ w ⊗ x , y , z ⟩
triangle : ∀ x y →
α⟨ x , unit , y ⟩ ⋆ ρ⟨ x ⟩ ⊗ₕ id ≡ id ⊗ₕ η⟨ y ⟩
open isIso
-- Inverses of α, η, ρ for convenience
α⁻¹⟨_,_,_⟩ : (x y z : ob) → Hom[ (x ⊗ y) ⊗ z , x ⊗ (y ⊗ z) ]
α⁻¹⟨ x , y , z ⟩ = α .nIso (x , y , z) .inv
η⁻¹⟨_⟩ : (x : ob) → Hom[ x , unit ⊗ x ]
η⁻¹⟨ x ⟩ = η .nIso (x) .inv
ρ⁻¹⟨_⟩ : (x : ob) → Hom[ x , x ⊗ unit ]
ρ⁻¹⟨ x ⟩ = ρ .nIso (x) .inv
record StrictMonCategory ℓ ℓ' : Type (ℓ-suc (ℓ-max ℓ ℓ')) where
field
C : Category ℓ ℓ'
sms : StrictMonStr C
open Category C public
open StrictMonStr sms public
record MonoidalCategory ℓ ℓ' : Type (ℓ-suc (ℓ-max ℓ ℓ')) where
field
C : Category ℓ ℓ'
monstr : MonoidalStr C
open Category C public
open MonoidalStr monstr public
| 24.528926
| 76
| 0.502358
|
0634e9170bbde22552080142c2de5f54104a8f16
| 1,475
|
agda
|
Agda
|
src/LibraBFT/Impl/Consensus/Properties/MetricsSafetyRules.agda
|
LaudateCorpus1/bft-consensus-agda
|
a4674fc473f2457fd3fe5123af48253cfb2404ef
|
[
"UPL-1.0"
] | null | null | null |
src/LibraBFT/Impl/Consensus/Properties/MetricsSafetyRules.agda
|
LaudateCorpus1/bft-consensus-agda
|
a4674fc473f2457fd3fe5123af48253cfb2404ef
|
[
"UPL-1.0"
] | null | null | null |
src/LibraBFT/Impl/Consensus/Properties/MetricsSafetyRules.agda
|
LaudateCorpus1/bft-consensus-agda
|
a4674fc473f2457fd3fe5123af48253cfb2404ef
|
[
"UPL-1.0"
] | null | null | null |
open import LibraBFT.Impl.Consensus.MetricsSafetyRules
open import LibraBFT.Impl.OBM.Logging.Logging
open import LibraBFT.Impl.Properties.Util
open import LibraBFT.ImplShared.Consensus.Types
open import LibraBFT.ImplShared.Consensus.Types.EpochIndep
open import LibraBFT.ImplShared.Util.Dijkstra.All
open import Optics.All
open import Util.Prelude hiding (_++_)
module LibraBFT.Impl.Consensus.Properties.MetricsSafetyRules where
open Invariants
module performInitializeSpec
(safetyRules : SafetyRules)
(storage : PersistentLivenessStorage)
where
record ContractOk (sr : SafetyRules) : Set where
constructor mkContractOk
field
srPres : Preserves SafetyRulesInv safetyRules sr
lvNothing : sr ^∙ srPersistentStorage ∙ pssSafetyData ∙ sdLastVote ≡ nothing
open ContractOk
Contract : EitherD-Post ErrLog SafetyRules
Contract (Left _) = ⊤
Contract (Right sr) = ContractOk sr
module _ (sri : SafetyRulesInv safetyRules)
(lvNothing : safetyRules ^∙ srPersistentStorage ∙ pssSafetyData ∙ sdLastVote ≡ nothing)
where
-- TODO-2: Requires refinement
postulate
contract' : EitherD-weakestPre (performInitialize-ed-abs safetyRules storage) Contract
contract : Contract (performInitialize-abs safetyRules storage)
contract rewrite performInitialize-abs-≡ safetyRules storage =
EitherD-contract (performInitialize-ed-abs safetyRules storage) Contract contract'
| 36.875
| 98
| 0.757966
|
12c9f0f81952b1e529e328547dcc99c2dfa69f3d
| 1,180
|
agda
|
Agda
|
theorems/cohomology/Sphere.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
theorems/cohomology/Sphere.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
theorems/cohomology/Sphere.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | 1
|
2018-12-26T21:31:57.000Z
|
2018-12-26T21:31:57.000Z
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import cohomology.Theory
module cohomology.Sphere {i} (OT : OrdinaryTheory i) where
open OrdinaryTheory OT
C-Sphere-≠-is-trivial : (n : ℤ) (m : ℕ) → (n ≠ ℕ-to-ℤ m)
→ is-trivialᴳ (C n (⊙Lift (⊙Sphere m)))
C-Sphere-≠-is-trivial n O n≠0 = C-dimension n≠0
C-Sphere-≠-is-trivial n (S m) n≠Sm = iso-preserves'-trivial
(C n (⊙Lift (⊙Sphere (S m)))
≃ᴳ⟨ C-emap n $ ⊙Susp-Lift-econv (⊙Sphere m) ⟩
C n (⊙Susp (⊙Lift (⊙Sphere m)))
≃ᴳ⟨ transportᴳ-iso (λ n → C n (⊙Susp (⊙Lift (⊙Sphere m)))) (succ-pred n) ⁻¹ᴳ ⟩
C (succ (pred n)) (⊙Susp (⊙Lift (⊙Sphere m)))
≃ᴳ⟨ C-Susp (pred n) (⊙Lift (⊙Sphere m)) ⟩
C (pred n) (⊙Lift (⊙Sphere m))
≃ᴳ∎)
(C-Sphere-≠-is-trivial (pred n) m (pred-≠ n≠Sm))
C-Sphere-diag : (m : ℕ) → C (ℕ-to-ℤ m) (⊙Lift (⊙Sphere m)) ≃ᴳ C 0 (⊙Lift ⊙S⁰)
C-Sphere-diag O = idiso _
C-Sphere-diag (S m) =
C (ℕ-to-ℤ (S m)) (⊙Lift (⊙Sphere (S m)))
≃ᴳ⟨ C-emap (ℕ-to-ℤ (S m)) (⊙Susp-Lift-econv (⊙Sphere m)) ⟩
C (ℕ-to-ℤ (S m)) (⊙Susp (⊙Lift (⊙Sphere m)))
≃ᴳ⟨ C-Susp (ℕ-to-ℤ m) (⊙Lift (⊙Sphere m)) ⟩
C (ℕ-to-ℤ m) (⊙Lift (⊙Sphere m))
≃ᴳ⟨ C-Sphere-diag m ⟩
C 0 (⊙Lift ⊙S⁰)
≃ᴳ∎
| 33.714286
| 82
| 0.551695
|
1865bbbe83213ebca933c206674009ecd0e4fa35
| 2,449
|
agda
|
Agda
|
src/VL.agda
|
shinji-kono/zf-in-agda
|
031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0
|
[
"MIT"
] | 5
|
2019-10-02T13:46:23.000Z
|
2021-01-10T13:27:48.000Z
|
src/VL.agda
|
shinji-kono/zf-in-agda
|
031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0
|
[
"MIT"
] | null | null | null |
src/VL.agda
|
shinji-kono/zf-in-agda
|
031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0
|
[
"MIT"
] | null | null | null |
open import Level
open import Ordinals
module VL {n : Level } (O : Ordinals {n}) where
open import zf
open import logic
import OD
open import Relation.Nullary
open import Relation.Binary
open import Data.Empty
open import Relation.Binary
open import Relation.Binary.Core
open import Relation.Binary.PropositionalEquality
open import Data.Nat renaming ( zero to Zero ; suc to Suc ; ℕ to Nat ; _⊔_ to _n⊔_ )
import BAlgbra
open BAlgbra O
open inOrdinal O
import OrdUtil
import ODUtil
open Ordinals.Ordinals O
open Ordinals.IsOrdinals isOrdinal
open Ordinals.IsNext isNext
open OrdUtil O
open ODUtil O
open OD O
open OD.OD
open ODAxiom odAxiom
-- import ODC
open _∧_
open _∨_
open Bool
open HOD
-- The cumulative hierarchy
-- V 0 := ∅
-- V α + 1 := P ( V α )
-- V α := ⋃ { V β | β < α }
V : ( β : Ordinal ) → HOD
V β = TransFinite V1 β where
V1 : (x : Ordinal ) → ( ( y : Ordinal) → y o< x → HOD ) → HOD
V1 x V0 with trio< x o∅
V1 x V0 | tri< a ¬b ¬c = ⊥-elim ( ¬x<0 a)
V1 x V0 | tri≈ ¬a refl ¬c = Ord o∅
V1 x V0 | tri> ¬a ¬b c with Oprev-p x
V1 x V0 | tri> ¬a ¬b c | yes p = Power ( V0 (Oprev.oprev p ) (subst (λ k → _ o< k) (Oprev.oprev=x p) <-osuc ))
V1 x V0 | tri> ¬a ¬b c | no ¬p =
record { od = record { def = λ y → (y o< x ) ∧ ((lt : y o< x ) → odef (V0 y lt) x ) } ; odmax = x; <odmax = λ {x} lt → proj1 lt }
--
-- L ⊆ HOD ⊆ V
--
-- HOD=V : (x : HOD) → V (odmax x) ∋ x
-- HOD=V x = {!!}
--
-- Definition for Power Set
--
record Definitions : Set (suc n) where
field
Definition : HOD → HOD
open Definitions
Df : Definitions → (x : HOD) → HOD
Df D x = Power x ∩ Definition D x
-- The constructible Sets
-- L 0 := ∅
-- L α + 1 := Df (L α) -- Definable Power Set
-- V α := ⋃ { L β | β < α }
L : ( β : Ordinal ) → Definitions → HOD
L β D = TransFinite L1 β where
L1 : (x : Ordinal ) → ( ( y : Ordinal) → y o< x → HOD ) → HOD
L1 x L0 with trio< x o∅
L1 x L0 | tri< a ¬b ¬c = ⊥-elim ( ¬x<0 a)
L1 x L0 | tri≈ ¬a refl ¬c = Ord o∅
L1 x L0 | tri> ¬a ¬b c with Oprev-p x
L1 x L0 | tri> ¬a ¬b c | yes p = Df D ( L0 (Oprev.oprev p ) (subst (λ k → _ o< k) (Oprev.oprev=x p) <-osuc ))
L1 x L0 | tri> ¬a ¬b c | no ¬p =
record { od = record { def = λ y → (y o< x ) ∧ ((lt : y o< x ) → odef (L0 y lt) x ) } ; odmax = x; <odmax = λ {x} lt → proj1 lt }
V=L0 : Set (suc n)
V=L0 = (x : Ordinal) → V x ≡ L x record { Definition = λ y → y }
| 28.149425
| 138
| 0.561862
|
c5e69fcd18d870b66c4ac5b9826aa86745db1b5f
| 452
|
agda
|
Agda
|
test/Succeed/Issue1791.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue1791.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue1791.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2016-01-21, issue 1791
-- With-clause stripping for copatterns with "polymorphic" field.
-- {-# OPTIONS -v tc.with.strip:60 #-}
postulate anything : ∀{A : Set} → A
record Wrap (A : Set) : Set where
field unwrap : A
record Pointed (M : Set → Set) : Set₁ where
field point : ∀{A} → M A -- field type starts with hidden quantifier!
test : Pointed Wrap
Wrap.unwrap (Pointed.point test) with Set₂
... | _ = anything
-- should succeed
| 23.789474
| 72
| 0.665929
|
4da4acae750527734c63676a9279a39a11989513
| 197
|
agda
|
Agda
|
Cubical/Codata/M/AsLimit/M.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | 1
|
2020-03-23T23:52:11.000Z
|
2020-03-23T23:52:11.000Z
|
Cubical/Codata/M/AsLimit/M.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
Cubical/Codata/M/AsLimit/M.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --guardedness --safe #-}
module Cubical.Codata.M.AsLimit.M where
open import Cubical.Codata.M.AsLimit.M.Base public
open import Cubical.Codata.M.AsLimit.M.Properties public
| 28.142857
| 56
| 0.771574
|
c59c6b555d4a5193022caf272e767e5f3d03a924
| 2,884
|
agda
|
Agda
|
Equivalence.agda
|
NAMEhzj/Divide-and-Conquer-in-Agda
|
99bd3a5e772563153d78f61c1bbca48d7809ff48
|
[
"MIT"
] | null | null | null |
Equivalence.agda
|
NAMEhzj/Divide-and-Conquer-in-Agda
|
99bd3a5e772563153d78f61c1bbca48d7809ff48
|
[
"MIT"
] | null | null | null |
Equivalence.agda
|
NAMEhzj/Divide-and-Conquer-in-Agda
|
99bd3a5e772563153d78f61c1bbca48d7809ff48
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --no-universe-polymorphism #-}
open import Relation.Binary.Core
open import Function
module Equivalence where
infixr 5 _⇔_
record _⇔_ (A B : Set) : Set where
field to : A → B
from : B → A
infixr 3 _↔_
record _↔_ (A B : Set) : Set where
field to : A → B
from : B → A
from-to : ∀ a → from (to a) ≡ a
to-from : ∀ b → to (from b) ≡ b
infixr 3 _=⟨_⟩_
_=⟨_⟩_ : {A : Set} (x : A) { y z : A} → x ≡ y → y ≡ z → x ≡ z
_=⟨_⟩_ _ refl refl = refl
=sym : {A : Set} {x y : A} → x ≡ y → y ≡ x
=sym refl = refl
infixr 5 _under_
_under_ : {A B : Set} → {x y : A} → x ≡ y → (f : A → B) → f x ≡ f y
_under_ refl f = refl
infixr 4 _□=
_□= : {A : Set} → (x : A) → x ≡ x
_□= x = refl
⇔sym : {A B : Set} → A ⇔ B → B ⇔ A
⇔sym p = record {to = _⇔_.from p ;
from = _⇔_.to p }
infixr 4 _□⇔
_□⇔ : (A : Set) → A ⇔ A
_□⇔ A = record {to = λ x → x;
from = λ x → x}
infixr 3 _⇔⟨_⟩_
_⇔⟨_⟩_ : (A : Set) {B C : Set} → A ⇔ B → B ⇔ C → A ⇔ C
_⇔⟨_⟩_ A {B} {C} AisB BisC = record {to = (_⇔_.to BisC) ∘ (_⇔_.to AisB);
from = (_⇔_.from AisB) ∘ (_⇔_.from BisC) }
↔sym : {A B : Set} → A ↔ B → B ↔ A
↔sym p = record {to = _↔_.from p ;
from = _↔_.to p ;
from-to = _↔_.to-from p ;
to-from = _↔_.from-to p }
infixr 4 _□↔
_□↔ : (A : Set) → A ↔ A
_□↔ A = record {to = λ x → x;
from = λ x → x;
from-to = λ a → refl;
to-from = λ b → refl}
infixr 3 _↔⟨_⟩_
_↔⟨_⟩_ : (A : Set) {B C : Set} → A ↔ B → B ↔ C → A ↔ C
_↔⟨_⟩_ A {B} {C} AisB BisC = record {to = to₂ ∘ to₁ ;
from = from₁ ∘ from₂ ;
from-to = λ a → (from₁ ∘ from₂ ∘ to₂ ∘ to₁) a =⟨ from-to₂ (to₁ a) under from₁ ⟩
from₁ (to₁ a) =⟨ from-to₁ a ⟩
a □= ;
to-from = λ c → (to₂ ∘ to₁ ∘ from₁ ∘ from₂) c =⟨ to-from₁ (from₂ c) under to₂ ⟩
to₂ (from₂ c) =⟨ to-from₂ c ⟩
c □= } where
to₁ = _↔_.to AisB
to₂ = _↔_.to BisC
from₁ = _↔_.from AisB
from₂ = _↔_.from BisC
from-to₁ = _↔_.from-to AisB
from-to₂ = _↔_.from-to BisC
to-from₁ = _↔_.to-from AisB
to-from₂ = _↔_.to-from BisC
| 28.554455
| 117
| 0.34258
|
fbd7e480fc6820cc5cb8583e06706e481d86c9d4
| 373
|
agda
|
Agda
|
test/Fail/Issue1266a.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue1266a.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue1266a.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2014-09-02
-- Up to today, there was no implementation of shadowing local variables
-- (e.g., λ-bound variables) by local imports.
-- {-# OPTIONS -v scope.locals:10 #-}
module _ where
module M where
A = Set1
test : (A : Set) → let open M in A
test A = Set
-- The A exported by M is in competition with the local A.
-- Ambiguous name should be reported.
| 20.722222
| 72
| 0.678284
|
12e994adc9b111fdb1c589955d26f81c357e2ce0
| 10,189
|
agda
|
Agda
|
core/lib/types/Paths.agda
|
timjb/HoTT-Agda
|
66f800adef943afdf08c17b8ecfba67340fead5e
|
[
"MIT"
] | null | null | null |
core/lib/types/Paths.agda
|
timjb/HoTT-Agda
|
66f800adef943afdf08c17b8ecfba67340fead5e
|
[
"MIT"
] | null | null | null |
core/lib/types/Paths.agda
|
timjb/HoTT-Agda
|
66f800adef943afdf08c17b8ecfba67340fead5e
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --rewriting #-}
open import lib.Basics
module lib.types.Paths where
{- ! is an equivalence and works on ≠ -}
module _ {i} {A : Type i} {x y : A} where
!-equiv : (x == y) ≃ (y == x)
!-equiv = equiv ! ! !-! !-!
≠-inv : (x ≠ y) → (y ≠ x)
≠-inv x≠y y=x = x≠y (! y=x)
{- Pre- and post- concatenation are equivalences -}
module _ {i} {A : Type i} {x y z : A} where
pre∙-is-equiv : (p : x == y) → is-equiv (λ (q : y == z) → p ∙ q)
pre∙-is-equiv p = is-eq (λ q → p ∙ q) (λ r → ! p ∙ r) f-g g-f
where f-g : ∀ r → p ∙ ! p ∙ r == r
f-g r = ! (∙-assoc p (! p) r) ∙ ap (λ s → s ∙ r) (!-inv-r p)
g-f : ∀ q → ! p ∙ p ∙ q == q
g-f q = ! (∙-assoc (! p) p q) ∙ ap (λ s → s ∙ q) (!-inv-l p)
pre∙-equiv : (p : x == y) → (y == z) ≃ (x == z)
pre∙-equiv p = ((λ q → p ∙ q) , pre∙-is-equiv p)
post∙-is-equiv : (p : y == z) → is-equiv (λ (q : x == y) → q ∙ p)
post∙-is-equiv p = is-eq (λ q → q ∙ p) (λ r → r ∙ ! p) f-g g-f
where f-g : ∀ r → (r ∙ ! p) ∙ p == r
f-g r = ∙-assoc r (! p) p ∙ ap (λ s → r ∙ s) (!-inv-l p) ∙ ∙-unit-r r
g-f : ∀ q → (q ∙ p) ∙ ! p == q
g-f q = ∙-assoc q p (! p) ∙ ap (λ s → q ∙ s) (!-inv-r p) ∙ ∙-unit-r q
post∙-equiv : (p : y == z) → (x == y) ≃ (x == z)
post∙-equiv p = ((λ q → q ∙ p) , post∙-is-equiv p)
pre∙'-is-equiv : (p : x == y) → is-equiv (λ (q : y == z) → p ∙' q)
pre∙'-is-equiv p = is-eq (λ q → p ∙' q) (λ r → ! p ∙' r) f-g g-f
where f-g : ∀ r → p ∙' ! p ∙' r == r
f-g r = ! (∙'-assoc p (! p) r) ∙ ap (λ s → s ∙' r) (!-inv'-r p)
∙ ∙'-unit-l r
g-f : ∀ q → ! p ∙' p ∙' q == q
g-f q = ! (∙'-assoc (! p) p q) ∙ ap (λ s → s ∙' q) (!-inv'-l p)
∙ ∙'-unit-l q
pre∙'-equiv : (p : x == y) → (y == z) ≃ (x == z)
pre∙'-equiv p = ((λ q → p ∙' q) , pre∙'-is-equiv p)
post∙'-is-equiv : (p : y == z) → is-equiv (λ (q : x == y) → q ∙' p)
post∙'-is-equiv p = is-eq (λ q → q ∙' p) (λ r → r ∙' ! p) f-g g-f
where f-g : ∀ r → (r ∙' ! p) ∙' p == r
f-g r = ∙'-assoc r (! p) p ∙ ap (λ s → r ∙' s) (!-inv'-l p)
g-f : ∀ q → (q ∙' p) ∙' ! p == q
g-f q = ∙'-assoc q p (! p) ∙ ap (λ s → q ∙' s) (!-inv'-r p)
post∙'-equiv : (p : y == z) → (x == y) ≃ (x == z)
post∙'-equiv p = ((λ q → q ∙' p) , post∙'-is-equiv p)
module _ {i j} {A : Type i} {B : Type j}
{f : A → B} {x y : A} {b : B} where
↓-app=cst-in : {p : x == y} {u : f x == b} {v : f y == b}
→ u == (ap f p ∙ v)
→ (u == v [ (λ x → f x == b) ↓ p ])
↓-app=cst-in {p = idp} q = q
↓-app=cst-out : {p : x == y} {u : f x == b} {v : f y == b}
→ (u == v [ (λ x → f x == b) ↓ p ])
→ u == (ap f p ∙ v)
↓-app=cst-out {p = idp} r = r
↓-app=cst-β : {p : x == y} {u : f x == b} {v : f y == b}
→ (q : u == (ap f p ∙ v))
→ ↓-app=cst-out {p = p} (↓-app=cst-in q) == q
↓-app=cst-β {p = idp} q = idp
↓-app=cst-η : {p : x == y} {u : f x == b} {v : f y == b}
→ (q : u == v [ (λ x → f x == b) ↓ p ])
→ ↓-app=cst-in (↓-app=cst-out q) == q
↓-app=cst-η {p = idp} q = idp
↓-app=cst-econv : {p : x == y} {u : f x == b} {v : f y == b}
→ (u == (ap f p ∙ v)) ≃ (u == v [ (λ x → f x == b) ↓ p ])
↓-app=cst-econv {p = p} = equiv ↓-app=cst-in ↓-app=cst-out
(↓-app=cst-η {p = p}) (↓-app=cst-β {p = p})
↓-cst=app-in : {p : x == y} {u : b == f x} {v : b == f y}
→ (u ∙' ap f p) == v
→ (u == v [ (λ x → b == f x) ↓ p ])
↓-cst=app-in {p = idp} q = q
↓-cst=app-out : {p : x == y} {u : b == f x} {v : b == f y}
→ (u == v [ (λ x → b == f x) ↓ p ])
→ (u ∙' ap f p) == v
↓-cst=app-out {p = idp} r = r
↓-cst=app-econv : {p : x == y} {u : b == f x} {v : b == f y}
→ ((u ∙' ap f p) == v) ≃ (u == v [ (λ x → b == f x) ↓ p ])
↓-cst=app-econv {p = idp} = equiv ↓-cst=app-in ↓-cst=app-out
(λ _ → idp) (λ _ → idp)
{- alternative versions -}
module _ {i j} {A : Type i} {B : Type j}
{f : A → B} {x y : A} {b : B} where
↓-app=cst-in' : {p : x == y} {u : f x == b} {v : f y == b}
→ u == (ap f p ∙' v)
→ (u == v [ (λ x → f x == b) ↓ p ])
↓-app=cst-in' {p = idp} {v = idp} q = q
↓-app=cst-out' : {p : x == y} {u : f x == b} {v : f y == b}
→ (u == v [ (λ x → f x == b) ↓ p ])
→ u == (ap f p ∙' v)
↓-app=cst-out' {p = idp} {v = idp} r = r
↓-app=cst-β' : {p : x == y} {u : f x == b} {v : f y == b}
→ (q : u == (ap f p ∙' v))
→ ↓-app=cst-out' {p = p} {v = v} (↓-app=cst-in' q) == q
↓-app=cst-β' {p = idp} {v = idp} q = idp
↓-app=cst-η' : {p : x == y} {u : f x == b} {v : f y == b}
→ (q : u == v [ (λ x → f x == b) ↓ p ])
→ ↓-app=cst-in' (↓-app=cst-out' q) == q
↓-app=cst-η' {p = idp} {v = idp} q = idp
↓-cst=app-in' : {p : x == y} {u : b == f x} {v : b == f y}
→ (u ∙ ap f p) == v
→ (u == v [ (λ x → b == f x) ↓ p ])
↓-cst=app-in' {p = idp} {u = idp} q = q
↓-cst=app-out' : {p : x == y} {u : b == f x} {v : b == f y}
→ (u == v [ (λ x → b == f x) ↓ p ])
→ (u ∙ ap f p) == v
↓-cst=app-out' {p = idp} {u = idp} r = r
module _ {i} {A : Type i} where
↓-app=idf-in : {f : A → A} {x y : A} {p : x == y}
{u : f x == x} {v : f y == y}
→ u ∙' p == ap f p ∙ v
→ u == v [ (λ z → f z == z) ↓ p ]
↓-app=idf-in {p = idp} q = q
↓-app=idf-out : {f : A → A} {x y : A} {p : x == y}
{u : f x == x} {v : f y == y}
→ u == v [ (λ z → f z == z) ↓ p ]
→ u ∙' p == ap f p ∙ v
↓-app=idf-out {p = idp} q = q
↓-cst=idf-in : {a : A} {x y : A} {p : x == y} {u : a == x} {v : a == y}
→ (u ∙' p) == v
→ (u == v [ (λ x → a == x) ↓ p ])
↓-cst=idf-in {p = idp} q = q
↓-cst=idf-in' : {a : A} {x y : A} {p : x == y} {u : a == x} {v : a == y}
→ (u ∙ p) == v
→ (u == v [ (λ x → a == x) ↓ p ])
↓-cst=idf-in' {p = idp} q = ! (∙-unit-r _) ∙ q
↓-idf=cst-in : {a : A} {x y : A} {p : x == y} {u : x == a} {v : y == a}
→ u == p ∙ v
→ (u == v [ (λ x → x == a) ↓ p ])
↓-idf=cst-in {p = idp} q = q
↓-idf=cst-out : {a : A} {x y : A} {p : x == y} {u : x == a} {v : y == a}
→ (u == v [ (λ x → x == a) ↓ p ])
→ u == p ∙ v
↓-idf=cst-out {p = idp} q = q
↓-idf=cst-in' : {a : A} {x y : A} {p : x == y} {u : x == a} {v : y == a}
→ u == p ∙' v
→ (u == v [ (λ x → x == a) ↓ p ])
↓-idf=cst-in' {p = idp} q = q ∙ ∙'-unit-l _
↓-idf=idf-in' : {x y : A} {p : x == y} {u : x == x} {v : y == y}
→ u ∙ p == p ∙' v
→ (u == v [ (λ x → x == x) ↓ p ])
↓-idf=idf-in' {p = idp} q = ! (∙-unit-r _) ∙ q ∙ ∙'-unit-l _
↓-idf=idf-out' : {x y : A} {p : x == y} {u : x == x} {v : y == y}
→ (u == v [ (λ x → x == x) ↓ p ])
→ u ∙ p == p ∙' v
↓-idf=idf-out' {p = idp} q = ∙-unit-r _ ∙ q ∙ ! (∙'-unit-l _)
{- Nondependent identity type -}
↓-='-in : ∀ {i j} {A : Type i} {B : Type j} {f g : A → B}
{x y : A} {p : x == y} {u : f x == g x} {v : f y == g y}
→ (u ∙' ap g p) == (ap f p ∙ v)
→ (u == v [ (λ x → f x == g x) ↓ p ])
↓-='-in {p = idp} q = q
↓-='-out : ∀ {i j} {A : Type i} {B : Type j} {f g : A → B}
{x y : A} {p : x == y} {u : f x == g x} {v : f y == g y}
→ (u == v [ (λ x → f x == g x) ↓ p ])
→ (u ∙' ap g p) == (ap f p ∙ v)
↓-='-out {p = idp} q = q
↓-='-in' : ∀ {i j} {A : Type i} {B : Type j} {f g : A → B}
{x y : A} {p : x == y} {u : f x == g x} {v : f y == g y}
→ (u ∙ ap g p) == (ap f p ∙' v)
→ (u == v [ (λ x → f x == g x) ↓ p ])
↓-='-in' {p = idp} q = ! (∙-unit-r _) ∙ q ∙ (∙'-unit-l _)
↓-='-out' : ∀ {i j} {A : Type i} {B : Type j} {f g : A → B}
{x y : A} {p : x == y} {u : f x == g x} {v : f y == g y}
→ (u == v [ (λ x → f x == g x) ↓ p ])
→ (u ∙ ap g p) == (ap f p ∙' v)
↓-='-out' {p = idp} q = (∙-unit-r _) ∙ q ∙ ! (∙'-unit-l _)
{- Identity type where the type is dependent -}
↓-=-in : ∀ {i j} {A : Type i} {B : A → Type j} {f g : Π A B}
{x y : A} {p : x == y} {u : g x == f x} {v : g y == f y}
→ (u ◃ apd f p) == (apd g p ▹ v)
→ (u == v [ (λ x → g x == f x) ↓ p ])
↓-=-in {B = B} {p = idp} {u} {v} q = ! (◃idp {B = B} u) ∙ q ∙ idp▹ {B = B} v
↓-=-out : ∀ {i j} {A : Type i} {B : A → Type j} {f g : Π A B}
{x y : A} {p : x == y} {u : g x == f x} {v : g y == f y}
→ (u == v [ (λ x → g x == f x) ↓ p ])
→ (u ◃ apd f p) == (apd g p ▹ v)
↓-=-out {B = B} {p = idp} {u} {v} q = (◃idp {B = B} u) ∙ q ∙ ! (idp▹ {B = B} v)
-- Dependent path in a type of the form [λ x → g (f x) == x]
module _ {i j} {A : Type i} {B : Type j} (g : B → A) (f : A → B) where
↓-∘=idf-in' : {x y : A} {p : x == y} {u : g (f x) == x} {v : g (f y) == y}
→ ((ap g (ap f p) ∙' v) == (u ∙ p))
→ (u == v [ (λ x → g (f x) == x) ↓ p ])
↓-∘=idf-in' {p = idp} q = ! (∙-unit-r _) ∙ (! q) ∙ (∙'-unit-l _)
-- WIP, derive it from more primitive principles
-- ↓-∘=id-in f g {p = p} {u} {v} q =
-- ↓-=-in (u ◃ apd (λ x → g (f x)) p =⟨ apd-∘ f g p |in-ctx (λ t → u ◃ t) ⟩
-- u ◃ ↓-apd-out _ f p (apdd g p (apd f p)) =⟨ apdd-cst (λ _ b → g b) p (ap f p) (! (apd-nd f p)) |in-ctx (λ t → u ◃ ↓-apd-out _ f p t) ⟩
-- u ◃ ↓-apd-out _ f p (apd (λ t → g (π₂ t)) (pair= p (apd f p))) =⟨ apd-∘ π₂ g (pair= p (apd f p)) |in-ctx (λ t → u ◃ ↓-apd-out _ f p t) ⟩
-- u ◃ ↓-apd-out _ f p (↓-apd-out _ π₂ (pair= p (apd f p)) (apdd g (pair= p (apd f p)) (apd π₂ (pair= p (apd f p))))) =⟨ {!!} ⟩
-- apd (λ x → x) p ▹ v ∎)
-- module _ {i j} {A : Type i} {B : Type j} {x y z : A → B} where
-- lhs :
-- {a a' : A} {p : a == a'} {q : x a == y a} {q' : x a' == y a'}
-- {r : y a == z a} {r' : y a' == z a'}
-- (α : q == q' [ (λ a → x a == y a) ↓ p ])
-- (β : r ∙ ap z p == ap y p ∙' r')
-- → (q ∙' r) ∙ ap z p == ap x p ∙' q' ∙' r'
-- lhs =
-- (q ∙' r) ∙ ap z p =⟨ ? ⟩ -- assoc
-- q ∙' (r ∙ ap z p) =⟨ ? ⟩ -- β
-- q ∙' (ap y p ∙' r') =⟨ ? ⟩ -- assoc
-- (q ∙' ap y p) ∙' r' =⟨ ? ⟩ -- ∙ = ∙'
-- (q ∙ ap y p) ∙' r' =⟨ ? ⟩ -- α
-- (ap x p ∙' q') ∙' r' =⟨ ? ⟩ -- assoc
-- ap x p ∙' q' ∙' r' ∎
-- thing :
-- {a a' : A} {p : a == a'} {q : x a == y a} {q' : x a' == y a'}
-- {r : y a == z a} {r' : y a' == z a'}
-- (α : q == q' [ (λ a → x a == y a) ↓ p ])
-- (β : r ∙ ap z p == ap y p ∙' r')
-- → (_∙'2ᵈ_ {r = r} {r' = r'} α (↓-='-in' β) == ↓-='-in' {!!})
-- thing = {!!}
| 37.459559
| 147
| 0.333693
|
1d04ed093bcafae099408ffeb6c0dee3a873086e
| 1,694
|
agda
|
Agda
|
Fields/Orders/Total/Lemmas.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Fields/Orders/Total/Lemmas.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Fields/Orders/Total/Lemmas.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 1
|
2021-11-29T13:23:07.000Z
|
2021-11-29T13:23:07.000Z
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import Rings.Definition
open import Rings.Orders.Partial.Definition
open import Rings.Orders.Total.Definition
open import Setoids.Setoids
open import Setoids.Orders.Partial.Definition
open import Setoids.Orders.Total.Definition
open import Functions.Definition
open import Fields.Fields
open import Fields.Orders.Total.Definition
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Order
open import Sets.EquivalenceRelations
open import LogicalFormulae
open import Groups.Definition
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
module Fields.Orders.Total.Lemmas {m n : _} {A : Set m} {S : Setoid {m} {n} A} {_+_ : A → A → A} {_*_ : A → A → A} {R : Ring S _+_ _*_} {F : Field R} {p : _} {_<_ : Rel {_} {p} A} {pOrder : SetoidPartialOrder S _<_} {oR : PartiallyOrderedRing R pOrder} (oF : TotallyOrderedField F oR) where
open Ring R
open Group additiveGroup
open Setoid S
open Equivalence eq
open Field F
open TotallyOrderedField oF
open TotallyOrderedRing oRing
open PartiallyOrderedRing oR
open SetoidTotalOrder total
open SetoidPartialOrder pOrder
open import Rings.InitialRing R
open import Rings.Orders.Total.Lemmas oRing
open import Rings.Orders.Partial.Lemmas oR
open import Rings.Lemmas R
open import Groups.Lemmas additiveGroup
charNotN : (n : ℕ) → fromN (succ n) ∼ 0R → False
charNotN n pr = irreflexive (<WellDefined reflexive pr t)
where
t : 0R < fromN (succ n)
t = fromNPreservesOrder (0<1 (Field.nontrivial F)) (succIsPositive n)
charNot2 : Setoid._∼_ S ((Ring.1R R) + (Ring.1R R)) (Ring.0R R) → False
charNot2 pr = charNotN 1 (transitive (transitive +Associative identRight) pr)
| 36.826087
| 290
| 0.75915
|
590f3bf8c87c2595d9fe2789b13273163ad79795
| 3,970
|
agda
|
Agda
|
Categories/Category/Monoidal/Braided/Properties.agda
|
rei1024/agda-categories
|
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
|
[
"MIT"
] | null | null | null |
Categories/Category/Monoidal/Braided/Properties.agda
|
rei1024/agda-categories
|
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
|
[
"MIT"
] | null | null | null |
Categories/Category/Monoidal/Braided/Properties.agda
|
rei1024/agda-categories
|
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category using (Category)
open import Categories.Category.Monoidal
open import Categories.Category.Monoidal.Braided using (Braided)
module Categories.Category.Monoidal.Braided.Properties
{o ℓ e} {C : Category o ℓ e} {M : Monoidal C} (BM : Braided M) where
open import Data.Product using (_,_)
open import Categories.Category.Monoidal.Properties M
open import Categories.Category.Monoidal.Reasoning M
open import Categories.Category.Monoidal.Utilities M
open import Categories.Functor using (Functor)
open import Categories.Morphism.Reasoning C hiding (push-eq)
open import Categories.NaturalTransformation.NaturalIsomorphism.Properties
using (push-eq)
open Category C
open Braided BM
open Commutation
private
variable
X Y Z : Obj
-- A shorthand for the braiding
B : ∀ {X Y} → X ⊗₀ Y ⇒ Y ⊗₀ X
B {X} {Y} = braiding.⇒.η (X , Y)
-- It's easier to prove the following lemma, which is the desired
-- coherence theorem moduolo application of the |-⊗ unit| functor.
-- Because |-⊗ unit| is equivalent to the identity functor, the
-- lemma and the theorem are equivalent.
-- The following diagram illustrates the hexagon that we are
-- operating on. The main outer hexagon is hexagon₁, the braiding
-- coherence, instantiated with X, 1 and 1 (Here we denote the unit
-- by 1 for brevity).
-- In the middle are X1 and 1X along with morphisms towards them.
-- The lower hexagon (given by the double lines) commutes and is
-- an intermediary in the final proof. It is there to effectively
-- get rid of the top half of the main hexagon.
-- The rest of the proof is isolating the bottom left triangle
-- which represents our desired identity. It is doing that by
-- proving that the pentagon to the right of it commutes.
-- The pentagon commuting is, in turn, proved by gluing the
-- rightmost "square" onto the middle triangle.
--
--
-- ┌─────> X(11) ─────────> (11)X ──────┐
-- ┌┘ α │ B │ α └┐
-- ┌┘ │id⊗λ │λ⊗id └┐
-- ┌┘ V V V
-- (X1)1 ═══════> X1 ════════════> 1X <══════ 1(1X)
-- ╚╗ ρ⊗id Λ <───┐ B λ Λ
-- ╚╗ │λ⊗id └────────┐ ╔╝
-- ╚╗ │ λ └┐ ╔╝
-- ╚═════> (1X)1 ═════════> 1(X1) ═════╝
-- B⊗id α id⊗B
braiding-coherence⊗unit : [ (X ⊗₀ unit) ⊗₀ unit ⇒ X ⊗₀ unit ]⟨
B ⊗₁ id ⇒⟨ (unit ⊗₀ X) ⊗₀ unit ⟩
unitorˡ.from ⊗₁ id
≈ unitorʳ.from ⊗₁ id
⟩
braiding-coherence⊗unit = cancel-fromˡ braiding.FX≅GX (
begin
B ∘ unitorˡ.from ⊗₁ id ∘ B ⊗₁ id ≈⟨ pullˡ (⟺ (glue◽◃ unitorˡ-commute-from coherence₁)) ⟩
(unitorˡ.from ∘ id ⊗₁ B ∘ associator.from) ∘ B ⊗₁ id ≈⟨ assoc²' ⟩
unitorˡ.from ∘ id ⊗₁ B ∘ associator.from ∘ B ⊗₁ id ≈⟨ refl⟩∘⟨ hexagon₁ ⟩
unitorˡ.from ∘ associator.from ∘ B ∘ associator.from ≈⟨ pullˡ coherence₁ ⟩
unitorˡ.from ⊗₁ id ∘ B ∘ associator.from ≈˘⟨ pushˡ (braiding.⇒.commute _) ⟩
(B ∘ id ⊗₁ unitorˡ.from) ∘ associator.from ≈⟨ pullʳ triangle ⟩
B ∘ unitorʳ.from ⊗₁ id
∎)
-- The desired theorem follows from |braiding-coherence⊗unit| by
-- translating it along the right unitor (which is a natural iso).
braiding-coherence : [ X ⊗₀ unit ⇒ X ]⟨
B ⇒⟨ unit ⊗₀ X ⟩
unitorˡ.from
≈ unitorʳ.from
⟩
braiding-coherence = push-eq unitorʳ-naturalIsomorphism (begin
(unitorˡ.from ∘ B) ⊗₁ id ≈⟨ homomorphism ⟩
(unitorˡ.from ⊗₁ id) ∘ (B ⊗₁ id) ≈⟨ braiding-coherence⊗unit ⟩
unitorʳ.from ⊗₁ id ∎)
where open Functor (-⊗ unit)
| 42.688172
| 124
| 0.559698
|
c57ff3179387b73111589c536d3e7ac5da346a83
| 6,903
|
agda
|
Agda
|
completeness.agda
|
hazelgrove/hazelnat-myth
|
a8f9299090d95f4ef1a6c2f15954c2981c0ee25c
|
[
"MIT"
] | 1
|
2019-12-19T23:42:31.000Z
|
2019-12-19T23:42:31.000Z
|
completeness.agda
|
hazelgrove/hazelnat-myth
|
a8f9299090d95f4ef1a6c2f15954c2981c0ee25c
|
[
"MIT"
] | null | null | null |
completeness.agda
|
hazelgrove/hazelnat-myth
|
a8f9299090d95f4ef1a6c2f15954c2981c0ee25c
|
[
"MIT"
] | null | null | null |
open import Nat
open import Prelude
open import List
open import contexts
open import core
module completeness where
-- any hole is new to a complete expression
e-complete-hnn : ∀{e u} → e ecomplete → hole-name-new e u
e-complete-hnn (ECFix cmp) = HNNFix (e-complete-hnn cmp)
e-complete-hnn ECVar = HNNVar
e-complete-hnn (ECAp cmp1 cmp2) = HNNAp (e-complete-hnn cmp1) (e-complete-hnn cmp2)
e-complete-hnn ECUnit = HNNUnit
e-complete-hnn (ECPair cmp cmp₁) = HNNPair (e-complete-hnn cmp) (e-complete-hnn cmp₁)
e-complete-hnn (ECFst cmp) = HNNFst (e-complete-hnn cmp)
e-complete-hnn (ECSnd cmp) = HNNSnd (e-complete-hnn cmp)
e-complete-hnn (ECCtor cmp) = HNNCtor (e-complete-hnn cmp)
e-complete-hnn (ECCase cmp h) = HNNCase (e-complete-hnn cmp) λ i<∥rules∥ → e-complete-hnn (h i<∥rules∥)
e-complete-hnn (ECAsrt cmp1 cmp2) = HNNAsrt (e-complete-hnn cmp1) (e-complete-hnn cmp2)
{- TODO : probably delete
e-hnn-complete : ∀{e} → (∀{u} → hole-name-new e u) → e ecomplete
e-hnn-complete hnn∀ = {!!}
-}
-- a complete expression is holes-disjoint to all expressions
e-complete-disjoint : ∀{e1 e2} → e1 ecomplete → holes-disjoint e1 e2
e-complete-disjoint (ECFix cmp) = HDFix (e-complete-disjoint cmp)
e-complete-disjoint ECVar = HDVar
e-complete-disjoint (ECAp cmp1 cmp2) = HDAp (e-complete-disjoint cmp1) (e-complete-disjoint cmp2)
e-complete-disjoint ECUnit = HDUnit
e-complete-disjoint (ECPair cmp cmp₁) = HDPair (e-complete-disjoint cmp) (e-complete-disjoint cmp₁)
e-complete-disjoint (ECFst cmp) = HDFst (e-complete-disjoint cmp)
e-complete-disjoint (ECSnd cmp) = HDSnd (e-complete-disjoint cmp)
e-complete-disjoint (ECCtor cmp) = HDCtor (e-complete-disjoint cmp)
e-complete-disjoint (ECCase cmp h) = HDCase (e-complete-disjoint cmp) λ i<∥rules∥ → e-complete-disjoint (h i<∥rules∥)
e-complete-disjoint (ECAsrt cmp1 cmp2) = HDAsrt (e-complete-disjoint cmp1) (e-complete-disjoint cmp2)
-- TODO a holes-disjoint-sym check - very involved but arguably pretty important
-- TODO we should generalize this, to a theorem that says that if a hole name is new in
-- e, then it is new in r and k
{- TODO}
-- if e evals to r, and e is complete, then r is complete
eval-completeness : ∀{Δ Σ' Γ E e r τ k} →
E env-complete →
Δ , Σ' , Γ ⊢ E →
Δ , Σ' , Γ ⊢ e :: τ →
E ⊢ e ⇒ r ⊣ k →
e ecomplete →
r rcomplete
eval-completeness Ecmp Γ⊢E (TALam _ _) EFun (ECLam ecmp) = RCLam Ecmp ecmp
eval-completeness Ecmp Γ⊢E (TAFix _ _ _) EFix (ECFix ecmp) = RCFix Ecmp ecmp
eval-completeness (ENVC Ecmp) Γ⊢E (TAVar _) (EVar h) ECVar = Ecmp h
eval-completeness Ecmp Γ⊢E (TAApp _ ta-f ta-arg) (EApp {Ef = Ef} {x} {r2 = r2} CF∞ eval-f eval-arg eval-ef) (ECAp cmp-f cmp-arg)
with eval-completeness Ecmp Γ⊢E ta-f eval-f cmp-f | preservation Γ⊢E ta-f eval-f
... | RCLam (ENVC Efcmp) efcmp | TALam Γ'⊢Ef (TALam _ ta-ef)
= eval-completeness (ENVC env-cmp) (EnvInd Γ'⊢Ef (preservation Γ⊢E ta-arg eval-arg)) ta-ef eval-ef efcmp
where
env-cmp : ∀{x' rx'} → (x' , rx') ∈ (Ef ,, (x , r2)) → rx' rcomplete
env-cmp {x'} {rx'} h with ctx-split {Γ = Ef} h
env-cmp {x'} {rx'} h | Inl (_ , x'∈Ef) = Efcmp x'∈Ef
env-cmp {x'} {rx'} h | Inr (_ , rx'==r2) rewrite rx'==r2 =
eval-completeness Ecmp Γ⊢E ta-arg eval-arg cmp-arg
eval-completeness Ecmp Γ⊢E (TAApp _ ta-f ta-arg) (EAppFix {Ef = Ef} {f} {x} {ef} {r2 = r2} CF∞ h eval-f eval-arg eval-ef) (ECAp cmp-f cmp-arg)
rewrite h with eval-completeness Ecmp Γ⊢E ta-f eval-f cmp-f | preservation Γ⊢E ta-f eval-f
... | RCFix (ENVC Efcmp) efcmp | TAFix Γ'⊢Ef (TAFix _ _ ta-ef) =
eval-completeness (ENVC new-Ef+-cmp) new-ctxcons ta-ef eval-ef efcmp
where
new-ctxcons =
EnvInd (EnvInd Γ'⊢Ef (preservation Γ⊢E ta-f eval-f)) (preservation Γ⊢E ta-arg eval-arg)
new-Ef-cmp : ∀{x' rx'} → (x' , rx') ∈ (Ef ,, (f , [ Ef ]fix f ⦇·λ x => ef ·⦈)) → rx' rcomplete
new-Ef-cmp {x'} {rx'} h with ctx-split {Γ = Ef} h
new-Ef-cmp {x'} {rx'} h | Inl (_ , x'∈Ef) = Efcmp x'∈Ef
new-Ef-cmp {x'} {rx'} h | Inr (_ , rx'==r2) rewrite rx'==r2 = RCFix (ENVC Efcmp) efcmp
new-Ef+-cmp : ∀{x' rx'} → (x' , rx') ∈ (Ef ,, (f , [ Ef ]fix f ⦇·λ x => ef ·⦈) ,, (x , r2)) → rx' rcomplete
new-Ef+-cmp {x'} {rx'} h with ctx-split {Γ = Ef ,, (f , [ Ef ]fix f ⦇·λ x => ef ·⦈)} h
new-Ef+-cmp {x'} {rx'} h | Inl (_ , x'∈Ef+) = new-Ef-cmp x'∈Ef+
new-Ef+-cmp {x'} {rx'} h | Inr (_ , rx'==r2) rewrite rx'==r2 =
eval-completeness Ecmp Γ⊢E ta-arg eval-arg cmp-arg
eval-completeness Ecmp Γ⊢E (TAApp _ ta1 ta2) (EAppUnfinished eval1 _ _ eval2) (ECAp ecmp1 ecmp2) =
RCAp (eval-completeness Ecmp Γ⊢E ta1 eval1 ecmp1) (eval-completeness Ecmp Γ⊢E ta2 eval2 ecmp2)
eval-completeness Ecmp Γ⊢E (TATpl ∥es∥==∥τs∥ _ tas) (ETuple ∥es∥==∥rs∥ ∥es∥==∥ks∥ evals) (ECTpl cmps) =
RCTpl λ {i} rs[i] →
let
_ , es[i] = ∥l1∥==∥l2∥→l1[i]→l2[i] (! ∥es∥==∥rs∥) rs[i]
_ , ks[i] = ∥l1∥==∥l2∥→l1[i]→l2[i] ∥es∥==∥ks∥ es[i]
_ , τs[i] = ∥l1∥==∥l2∥→l1[i]→l2[i] ∥es∥==∥τs∥ es[i]
in
eval-completeness Ecmp Γ⊢E (tas es[i] τs[i]) (evals es[i] rs[i] ks[i]) (cmps es[i])
eval-completeness Ecmp Γ⊢E (TAGet ∥rs⊫=∥τs∥ i<∥τs∥ ta) (EGet _ i<∥rs∥ eval) (ECGet ecmp)
with eval-completeness Ecmp Γ⊢E ta eval ecmp
... | RCTpl h = h i<∥rs∥
eval-completeness Ecmp Γ⊢E (TAGet _ i<∥τs∥ ta) (EGetUnfinished eval _) (ECGet ecmp) =
RCGet (eval-completeness Ecmp Γ⊢E ta eval ecmp)
eval-completeness Ecmp Γ⊢E (TACtor _ _ ta) (ECtor eval) (ECCtor ecmp) =
RCCtor (eval-completeness Ecmp Γ⊢E ta eval ecmp)
eval-completeness {Σ' = Σ'} (ENVC Ecmp) Γ⊢E (TACase d∈Σ'1 ta h1 h2) (EMatch {E = E} {xc = xc} {r' = r'} CF∞ form eval eval-ec) (ECCase ecmp rules-cmp)
with h2 form
... | _ , _ , _ , _ , c∈cctx1 , ta-ec
with preservation Γ⊢E ta eval
... | TACtor {cctx = cctx} d∈Σ' c∈cctx ta-r'
rewrite ctxunicity {Γ = π1 Σ'} d∈Σ'1 d∈Σ' | ctxunicity {Γ = cctx} c∈cctx1 c∈cctx =
eval-completeness (ENVC new-E-cmp) (EnvInd Γ⊢E ta-r') ta-ec eval-ec (rules-cmp form)
where
new-E-cmp : ∀{x' rx'} → (x' , rx') ∈ (E ,, (xc , r')) → rx' rcomplete
new-E-cmp {x'} {rx'} x'∈E+ with ctx-split {Γ = E} x'∈E+
... | Inl (_ , x'∈E) = Ecmp x'∈E
... | Inr (_ , rx'==r') rewrite rx'==r'
with eval-completeness (ENVC Ecmp) Γ⊢E ta eval ecmp
... | RCCtor r'cmp = r'cmp
eval-completeness Ecmp Γ⊢E (TACase _ ta _ _) (EMatchUnfinished eval _) (ECCase ecmp rulescmp) =
RCCase Ecmp (eval-completeness Ecmp Γ⊢E ta eval ecmp) rulescmp
eval-completeness Ecmp Γ⊢E (TAHole _) EHole ()
eval-completeness Ecmp Γ⊢E (TAPF _) EPF (ECPF pf-cmp) = RCPF pf-cmp
eval-completeness Ecmp Γ⊢E (TAAsrt _ _ _) (EAsrt _ _ _) (ECAsrt _ _) = RCTpl (λ ())
-}
| 58.008403
| 152
| 0.60423
|
Subsets and Splits
HTML Code Excluding Scripts
The query retrieves a limited set of HTML content entries that are longer than 8 characters and do not contain script tags, offering only basic filtering with minimal analytical value.