id
stringlengths
27
136
text
stringlengths
4
1.05M
algebraic-stack_agda0000_doc_17412
{-# OPTIONS --cubical --safe #-} module Data.List.Properties where open import Data.List open import Prelude open import Data.Fin map-length : (f : A → B) (xs : List A) → length xs ≡ length (map f xs) map-length f [] _ = zero map-length f (x ∷ xs) i = suc (map-length f xs i) map-ind : (f : A → B) (xs : List A) → PathP (λ i → Fin (map-length f xs i) → B) (f ∘ (xs !_)) (map f xs !_) map-ind f [] i () map-ind f (x ∷ xs) i f0 = f x map-ind f (x ∷ xs) i (fs n) = map-ind f xs i n tab-length : ∀ n (f : Fin n → A) → length (tabulate n f) ≡ n tab-length zero f _ = zero tab-length (suc n) f i = suc (tab-length n (f ∘ fs) i) tab-distrib : ∀ n (f : Fin n → A) m → ∃[ i ] (f i ≡ tabulate n f ! m) tab-distrib (suc n) f f0 = f0 , refl tab-distrib (suc n) f (fs m) = let i , p = tab-distrib n (f ∘ fs) m in fs i , p tab-id : ∀ n (f : Fin n → A) → PathP (λ i → Fin (tab-length n f i) → A) (_!_ (tabulate n f)) f tab-id zero f _ () tab-id (suc n) f i f0 = f f0 tab-id (suc n) f i (fs m) = tab-id n (f ∘ fs) i m
algebraic-stack_agda0000_doc_17413
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} import LibraBFT.Impl.Types.CryptoProxies as CryptoProxies import LibraBFT.Impl.Types.LedgerInfo as LedgerInfo import LibraBFT.Impl.Types.LedgerInfoWithSignatures as LedgerInfoWithSignatures import LibraBFT.Impl.Types.ValidatorSigner as ValidatorSigner import LibraBFT.Impl.Types.ValidatorVerifier as ValidatorVerifier open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.Consensus.Types.EpochIndep open import Optics.All open import Util.Prelude module LibraBFT.Impl.OBM.Genesis where ------------------------------------------------------------------------------ obmMkLedgerInfoWithEpochState : ValidatorSet → Either ErrLog LedgerInfo ------------------------------------------------------------------------------ obmMkGenesisLedgerInfoWithSignatures : List ValidatorSigner → ValidatorSet → Either ErrLog LedgerInfoWithSignatures obmMkGenesisLedgerInfoWithSignatures vss0 vs0 = do liwes ← obmMkLedgerInfoWithEpochState vs0 let sigs = fmap (λ vs → (vs ^∙ vsAuthor , ValidatorSigner.sign vs liwes)) vss0 pure $ foldl' (λ acc (a , sig) → CryptoProxies.addToLi a sig acc) (LedgerInfoWithSignatures.obmNewNoSigs liwes) sigs obmMkLedgerInfoWithEpochState vs = do li ← LedgerInfo.mockGenesis (just vs) vv ← ValidatorVerifier.from-e-abs vs pure (li & liCommitInfo ∙ biNextEpochState ?~ EpochState∙new (li ^∙ liEpoch) vv)
algebraic-stack_agda0000_doc_17414
module PreludeInt where open import AlonzoPrelude import RTP int : Nat -> Int int = RTP.primNatToInt _+_ : Int -> Int -> Int _+_ = RTP.primIntAdd _-_ : Int -> Int -> Int _-_ = RTP.primIntSub _*_ : Int -> Int -> Int _*_ = RTP.primIntMul div : Int -> Int -> Int div = RTP.primIntDiv mod : Int -> Int -> Int mod = RTP.primIntMod
algebraic-stack_agda0000_doc_17415
------------------------------------------------------------------------ -- Some theory of equivalences with erased "proofs", defined in terms -- of partly erased contractible fibres, developed using Cubical Agda ------------------------------------------------------------------------ -- This module instantiates and reexports code from -- Equivalence.Erased.Contractible-preimages. {-# OPTIONS --erased-cubical --safe #-} import Equality.Path as P module Equivalence.Erased.Contractible-preimages.Cubical {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq open import Erased.Cubical eq import Equivalence.Erased.Contractible-preimages open Equivalence.Erased.Contractible-preimages equality-with-J public hiding (module []-cong) open Equivalence.Erased.Contractible-preimages.[]-cong equality-with-J instance-of-[]-cong-axiomatisation public
algebraic-stack_agda0000_doc_17416
module Integer.Difference where open import Data.Product as Σ open import Data.Product.Relation.Pointwise.NonDependent open import Data.Unit open import Equality open import Natural as ℕ open import Quotient as / open import Relation.Binary open import Syntax infixl 6 _–_ pattern _–_ a b = _,_ a b ⟦ℤ⟧ = ℕ × ℕ ⟦ℤ²⟧ = ⟦ℤ⟧ × ⟦ℤ⟧ _≈_ : ⟦ℤ⟧ → ⟦ℤ⟧ → Set (a – b) ≈ (c – d) = a + d ≡ c + b ≈-refl : ∀ {x} → x ≈ x ≈-refl = refl ℤ = ⟦ℤ⟧ / _≈_ ℤ² = ⟦ℤ²⟧ / Pointwise _≈_ _≈_ instance ⟦ℤ⟧-Number : Number ⟦ℤ⟧ ⟦ℤ⟧-Number = record { Constraint = λ _ → ⊤ ; fromNat = λ x → x – 0 } ℤ-Number : Number ℤ ℤ-Number = record { Constraint = λ _ → ⊤ ; fromNat = λ x → ⟦ fromNat x ⟧ } ⟦ℤ⟧-Negative : Negative ⟦ℤ⟧ ⟦ℤ⟧-Negative = record { Constraint = λ _ → ⊤ ; fromNeg = λ x → 0 – x } ℤ-Negative : Negative ℤ ℤ-Negative = record { Constraint = λ _ → ⊤ ; fromNeg = λ x → ⟦ fromNeg x ⟧ } suc–suc-injective : ∀ a b → Path ℤ ⟦ suc a – suc b ⟧ ⟦ a – b ⟧ suc–suc-injective a b = equiv (suc a – suc b) (a – b) (sym (+-suc a b )) ⟦negate⟧ : ⟦ℤ⟧ → ⟦ℤ⟧ ⟦negate⟧ (a – b) = b – a negate : ℤ → ℤ negate = ⟦negate⟧ // λ where (a – b) (c – d) p → ⟨ +-comm b c ⟩ ≫ sym p ≫ ⟨ +-comm a d ⟩ ⟦plus⟧ : ⟦ℤ²⟧ → ⟦ℤ⟧ ⟦plus⟧ ((a – b) , (c – d)) = (a + c) – (d + b) plus : ℤ² → ℤ plus = ⟦plus⟧ // λ where ((a – b) , (c – d)) ((e – f) , (g – h)) (p , q) → (a + c) + (h + f) ≡⟨ sym (ℕ.+-assoc a _ _) ⟩ a + (c + (h + f)) ≡⟨ cong (a +_) (ℕ.+-assoc c _ _) ⟩ a + ((c + h) + f) ≡⟨ cong (λ z → a + (z + f)) q ⟩ a + ((g + d) + f) ≡⟨ cong (a +_) ⟨ ℕ.+-comm (g + d) _ ⟩ ⟩ a + (f + (g + d)) ≡⟨ ℕ.+-assoc a _ _ ⟩ (a + f) + (g + d) ≡⟨ cong (_+ (g + d)) p ⟩ (e + b) + (g + d) ≡⟨ ℕ.+-cross e _ _ _ ⟩ (e + g) + (b + d) ≡⟨ cong ((e + g) +_) ⟨ ℕ.+-comm b _ ⟩ ⟩ (e + g) + (d + b) ∎ instance ⟦ℤ⟧-plus-syntax : plus-syntax-simple ⟦ℤ⟧ ⟦ℤ⟧ ⟦ℤ⟧ ⟦ℤ⟧-plus-syntax = λ where ._+_ x y → ⟦plus⟧ (x , y) ⟦ℤ⟧-minus-syntax : minus-syntax-simple ⟦ℤ⟧ ⟦ℤ⟧ ⟦ℤ⟧ ⟦ℤ⟧-minus-syntax = λ where ._-_ x y → ⟦plus⟧ (x , ⟦negate⟧ y) ℕ-⟦ℤ⟧-minus-syntax : minus-syntax-simple ℕ ℕ ⟦ℤ⟧ ℕ-⟦ℤ⟧-minus-syntax = λ where ._-_ → _–_ ℤ-plus-syntax : plus-syntax-simple ℤ ℤ ℤ ℤ-plus-syntax = λ where ._+_ → /.uncurry refl refl plus ℤ-minus-syntax : minus-syntax-simple ℤ ℤ ℤ ℤ-minus-syntax = λ where ._-_ x y → x + negate y ℕ-ℤ-minus-syntax : minus-syntax-simple ℕ ℕ ℤ ℕ-ℤ-minus-syntax = λ where ._-_ x y → ⟦ x – y ⟧
algebraic-stack_agda0000_doc_17417
module MissingTypeSignature where data Nat : Set where zero : Nat suc : Nat -> Nat pred zero = zero pred (suc n) = n
algebraic-stack_agda0000_doc_17418
module ProofUtilities where -- open import Data.Nat hiding (_>_) open import StdLibStuff open import Syntax open import FSC mutual hn-left-i : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} {α β : Type n} (m : ℕ) (S : Form Γ-t β → Form Γ-t α) (F : Form Γ-t β) (G : Form Γ-t α) → Γ ⊢ α ∋ S (headNorm m F) ↔ G → Γ ⊢ α ∋ S F ↔ G hn-left-i m S (app F H) G p = hn-left-i m (λ x → S (app x H)) F G (hn-left-i' m S (headNorm m F) H G p) hn-left-i _ _ (var _ _) _ p = p hn-left-i _ _ N _ p = p hn-left-i _ _ A _ p = p hn-left-i _ _ Π _ p = p hn-left-i _ _ i _ p = p hn-left-i _ _ (lam _ _) _ p = p hn-left-i' : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} {α β γ : Type n} (m : ℕ) (S : Form Γ-t β → Form Γ-t α) (F : Form Γ-t (γ > β)) (H : Form Γ-t γ) (G : Form Γ-t α) → Γ ⊢ α ∋ S (headNorm' m F H) ↔ G → Γ ⊢ α ∋ S (app F H) ↔ G hn-left-i' (suc m) S (lam _ F) H G p with hn-left-i m S (sub H F) G p hn-left-i' (suc _) S (lam _ _) _ _ _ | p' = reduce-l {_} {_} {_} {_} {_} {_} {S} p' hn-left-i' 0 _ (lam _ _) _ _ p = p hn-left-i' zero _ (var _ _) _ _ p = p hn-left-i' (suc _) _ (var _ _) _ _ p = p hn-left-i' zero _ N _ _ p = p hn-left-i' (suc _) _ N _ _ p = p hn-left-i' zero _ A _ _ p = p hn-left-i' (suc _) _ A _ _ p = p hn-left-i' zero _ Π _ _ p = p hn-left-i' (suc _) _ Π _ _ p = p hn-left-i' zero _ i _ _ p = p hn-left-i' (suc _) _ i _ _ p = p hn-left-i' zero _ (app _ _) _ _ p = p hn-left-i' (suc _) _ (app _ _) _ _ p = p hn-left : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} {α : Type n} (m : ℕ) (F : Form Γ-t α) (G : Form Γ-t α) → Γ ⊢ α ∋ headNorm m F ↔ G → Γ ⊢ α ∋ F ↔ G hn-left m F G p = hn-left-i m (λ x → x) F G p mutual hn-right-i : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} {α β : Type n} (m : ℕ) (S : Form Γ-t β → Form Γ-t α) (F : Form Γ-t β) (G : Form Γ-t α) → Γ ⊢ α ∋ G ↔ S (headNorm m F) → Γ ⊢ α ∋ G ↔ S F hn-right-i m S (app F H) G p = hn-right-i m (λ x → S (app x H)) F G (hn-right-i' m S (headNorm m F) H G p) hn-right-i _ _ (var _ _) _ p = p hn-right-i _ _ N _ p = p hn-right-i _ _ A _ p = p hn-right-i _ _ Π _ p = p hn-right-i _ _ i _ p = p hn-right-i _ _ (lam _ _) _ p = p hn-right-i' : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} {α β γ : Type n} (m : ℕ) (S : Form Γ-t β → Form Γ-t α) (F : Form Γ-t (γ > β)) (H : Form Γ-t γ) (G : Form Γ-t α) → Γ ⊢ α ∋ G ↔ S (headNorm' m F H) → Γ ⊢ α ∋ G ↔ S (app F H) hn-right-i' (suc m) S (lam _ F) H G p with hn-right-i m S (sub H F) G p hn-right-i' (suc _) S (lam _ _) _ _ _ | p' = reduce-r {_} {_} {_} {_} {_} {_} {S} p' hn-right-i' 0 _ (lam _ _) _ _ p = p hn-right-i' zero _ (var _ _) _ _ p = p hn-right-i' (suc _) _ (var _ _) _ _ p = p hn-right-i' zero _ N _ _ p = p hn-right-i' (suc _) _ N _ _ p = p hn-right-i' zero _ A _ _ p = p hn-right-i' (suc _) _ A _ _ p = p hn-right-i' zero _ Π _ _ p = p hn-right-i' (suc _) _ Π _ _ p = p hn-right-i' zero _ i _ _ p = p hn-right-i' (suc _) _ i _ _ p = p hn-right-i' zero _ (app _ _) _ _ p = p hn-right-i' (suc _) _ (app _ _) _ _ p = p hn-right : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} {α : Type n} (m : ℕ) (F : Form Γ-t α) (G : Form Γ-t α) → Γ ⊢ α ∋ G ↔ headNorm m F → Γ ⊢ α ∋ G ↔ F hn-right m F G p = hn-right-i m (λ x → x) F G p mutual hn-succ-i : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} {β : Type n} (m : ℕ) (S : Form Γ-t β → Form Γ-t $o) (F : Form Γ-t β) → Γ ⊢ S (headNorm m F) → Γ ⊢ S F hn-succ-i m S (app F H) p = hn-succ-i m (λ x → S (app x H)) F (hn-succ-i' m S (headNorm m F) H p) hn-succ-i _ _ (var _ _) p = p hn-succ-i _ _ N p = p hn-succ-i _ _ A p = p hn-succ-i _ _ Π p = p hn-succ-i _ _ i p = p hn-succ-i _ _ (lam _ _) p = p hn-succ-i' : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} {β γ : Type n} (m : ℕ) (S : Form Γ-t β → Form Γ-t $o) (F : Form Γ-t (γ > β)) (H : Form Γ-t γ) → Γ ⊢ S (headNorm' m F H) → Γ ⊢ S (app F H) hn-succ-i' (suc m) S (lam _ F) H p with hn-succ-i m S (sub H F) p hn-succ-i' (suc _) S (lam _ _) _ _ | p' = reduce {_} {_} {_} {_} {_} {S} p' hn-succ-i' 0 _ (lam _ _) _ p = p hn-succ-i' zero _ (var _ _) _ p = p hn-succ-i' (suc _) _ (var _ _) _ p = p hn-succ-i' zero _ N _ p = p hn-succ-i' (suc _) _ N _ p = p hn-succ-i' zero _ A _ p = p hn-succ-i' (suc _) _ A _ p = p hn-succ-i' zero _ Π _ p = p hn-succ-i' (suc _) _ Π _ p = p hn-succ-i' zero _ i _ p = p hn-succ-i' (suc _) _ i _ p = p hn-succ-i' zero _ (app _ _) _ p = p hn-succ-i' (suc _) _ (app _ _) _ p = p hn-succ : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} (m : ℕ) (F : Form Γ-t $o) → Γ ⊢ headNorm m F → Γ ⊢ F hn-succ m F p = hn-succ-i m (λ x → x) F p mutual hn-ante-i : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} {β : Type n} (m : ℕ) (S : Form Γ-t β → Form Γ-t $o) (F : Form Γ-t β) (G : Form Γ-t $o) → Γ , S (headNorm m F) ⊢ G → Γ , S F ⊢ G hn-ante-i m S (app F H) G p = hn-ante-i m (λ x → S (app x H)) F G (hn-ante-i' m S (headNorm m F) H G p) hn-ante-i _ _ (var _ _) _ p = p hn-ante-i _ _ N _ p = p hn-ante-i _ _ A _ p = p hn-ante-i _ _ Π _ p = p hn-ante-i _ _ i _ p = p hn-ante-i _ _ (lam _ _) _ p = p hn-ante-i' : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} {β γ : Type n} (m : ℕ) (S : Form Γ-t β → Form Γ-t $o) (F : Form Γ-t (γ > β)) (H : Form Γ-t γ) (G : Form Γ-t $o) → Γ , S (headNorm' m F H) ⊢ G → Γ , S (app F H) ⊢ G hn-ante-i' (suc m) S (lam _ F) H G p with hn-ante-i m S (sub H F) G p hn-ante-i' (suc _) S (lam _ _) _ _ _ | p' = reduce {_} {_} {_} {_} {_} {S} p' hn-ante-i' 0 _ (lam _ _) _ _ p = p hn-ante-i' zero _ (var _ _) _ _ p = p hn-ante-i' (suc _) _ (var _ _) _ _ p = p hn-ante-i' zero _ N _ _ p = p hn-ante-i' (suc _) _ N _ _ p = p hn-ante-i' zero _ A _ _ p = p hn-ante-i' (suc _) _ A _ _ p = p hn-ante-i' zero _ Π _ _ p = p hn-ante-i' (suc _) _ Π _ _ p = p hn-ante-i' zero _ i _ _ p = p hn-ante-i' (suc _) _ i _ _ p = p hn-ante-i' zero _ (app _ _) _ _ p = p hn-ante-i' (suc _) _ (app _ _) _ _ p = p hn-ante : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} (m : ℕ) (F : Form Γ-t $o) (G : Form Γ-t $o) → Γ , headNorm m F ⊢ G → Γ , F ⊢ G hn-ante m F G p = hn-ante-i m (λ x → x) F G p mutual hn-ante-eq-i : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} {α β : Type n} (m : ℕ) (S : Form Γ-t β → Form Γ-t $o) (F : Form Γ-t β) (G H : Form Γ-t α) → Γ , S (headNorm m F) ⊢ G == H → Γ , S F ⊢ G == H hn-ante-eq-i m S (app F I) G H p = hn-ante-eq-i m (λ x → S (app x I)) F G H (hn-ante-eq-i' m S (headNorm m F) I G H p) hn-ante-eq-i _ _ (var _ _) _ _ p = p hn-ante-eq-i _ _ N _ _ p = p hn-ante-eq-i _ _ A _ _ p = p hn-ante-eq-i _ _ Π _ _ p = p hn-ante-eq-i _ _ i _ _ p = p hn-ante-eq-i _ _ (lam _ _) _ _ p = p hn-ante-eq-i' : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} {α β γ : Type n} (m : ℕ) (S : Form Γ-t β → Form Γ-t $o) (F : Form Γ-t (γ > β)) (I : Form Γ-t γ) (G H : Form Γ-t α) → Γ , S (headNorm' m F I) ⊢ G == H → Γ , S (app F I) ⊢ G == H hn-ante-eq-i' (suc m) S (lam _ F) I G H p with hn-ante-eq-i m S (sub I F) G H p hn-ante-eq-i' (suc _) S (lam _ _) _ _ _ _ | p' = reduce {_} {_} {_} {_} {_} {_} {S} p' hn-ante-eq-i' 0 _ (lam _ _) _ _ _ p = p hn-ante-eq-i' zero _ (var _ _) _ _ _ p = p hn-ante-eq-i' (suc _) _ (var _ _) _ _ _ p = p hn-ante-eq-i' zero _ N _ _ _ p = p hn-ante-eq-i' (suc _) _ N _ _ _ p = p hn-ante-eq-i' zero _ A _ _ _ p = p hn-ante-eq-i' (suc _) _ A _ _ _ p = p hn-ante-eq-i' zero _ Π _ _ _ p = p hn-ante-eq-i' (suc _) _ Π _ _ _ p = p hn-ante-eq-i' zero _ i _ _ _ p = p hn-ante-eq-i' (suc _) _ i _ _ _ p = p hn-ante-eq-i' zero _ (app _ _) _ _ _ p = p hn-ante-eq-i' (suc _) _ (app _ _) _ _ _ p = p hn-ante-eq : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} {α : Type n} (m : ℕ) (F : Form Γ-t $o) (G H : Form Γ-t α) → Γ , headNorm m F ⊢ G == H → Γ , F ⊢ G == H hn-ante-eq m F G H p = hn-ante-eq-i m (λ x → x) F G H p -- ------------------------------------ head-& : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} {F₁ F₂ G₁ G₂ : Form Γ-t $o} → Γ ⊢ $o ∋ F₁ == F₂ → Γ ⊢ $o ∋ G₁ == G₂ → Γ ⊢ $o ∋ (F₁ & G₁) ↔ (F₂ & G₂) head-& p₁ p₂ = head-app _ _ _ _ _ _ (simp (head-const _ N)) (simp (head-app _ _ _ _ _ _ (simp (head-app _ _ _ _ _ _ (simp (head-const _ A)) (simp (head-app _ _ _ _ _ _ (simp (head-const _ N)) p₁)))) (simp (head-app _ _ _ _ _ _ (simp (head-const _ N)) p₂)))) head-|| : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} {F₁ F₂ G₁ G₂ : Form Γ-t $o} → Γ ⊢ $o ∋ F₁ == F₂ → Γ ⊢ $o ∋ G₁ == G₂ → Γ ⊢ $o ∋ (F₁ || G₁) ↔ (F₂ || G₂) head-|| p₁ p₂ = head-app _ _ _ _ _ _ (simp (head-app _ _ _ _ _ _ (simp (head-const _ A)) p₁)) p₂ head-=> : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} {F₁ F₂ G₁ G₂ : Form Γ-t $o} → Γ ⊢ $o ∋ F₁ == F₂ → Γ ⊢ $o ∋ G₁ == G₂ → Γ ⊢ $o ∋ (F₁ => G₁) ↔ (F₂ => G₂) head-=> p₁ p₂ = head-app _ _ _ _ _ _ (simp (head-app _ _ _ _ _ _ (simp (head-const _ A)) (simp (head-app _ _ _ _ _ _ (simp (head-const _ N)) p₁)))) p₂ head-~ : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} {F₁ F₂ : Form Γ-t $o} → Γ ⊢ $o ∋ F₁ == F₂ → Γ ⊢ $o ∋ (~ F₁) ↔ (~ F₂) head-~ p = head-app _ _ _ _ _ _ (simp (head-const _ N)) p head-== : {n : ℕ} {Γ-t : Ctx n} {Γ : FSC-Ctx n Γ-t} {α : Type n} {F₁ F₂ G₁ G₂ : Form Γ-t α} → Γ ⊢ α ∋ F₁ == F₂ → Γ ⊢ α ∋ G₁ == G₂ → Γ ⊢ $o ∋ (F₁ == G₁) ↔ (F₂ == G₂) head-== p₁ p₂ = head-app _ _ _ _ _ _ (simp (head-app _ _ _ _ _ _ (simp (head-const _ _)) p₁)) p₂
algebraic-stack_agda0000_doc_17419
{-# OPTIONS --without-K #-} open import HoTT open import cohomology.Exactness open import cohomology.Choice module cohomology.Theory where record CohomologyTheory i : Type (lsucc i) where field C : ℤ → Ptd i → Group i CEl : ℤ → Ptd i → Type i CEl n X = Group.El (C n X) Cid : (n : ℤ) (X : Ptd i) → CEl n X Cid n X = GroupStructure.ident (Group.group-struct (C n X)) ⊙CEl : ℤ → Ptd i → Ptd i ⊙CEl n X = ⊙[ CEl n X , Cid n X ] field CF-hom : (n : ℤ) {X Y : Ptd i} → fst (X ⊙→ Y) → (C n Y →ᴳ C n X) CF-ident : (n : ℤ) {X : Ptd i} → CF-hom n {X} {X} (⊙idf X) == idhom (C n X) CF-comp : (n : ℤ) {X Y Z : Ptd i} (g : fst (Y ⊙→ Z)) (f : fst (X ⊙→ Y)) → CF-hom n (g ⊙∘ f) == CF-hom n f ∘ᴳ CF-hom n g CF : (n : ℤ) {X Y : Ptd i} → fst (X ⊙→ Y) → fst (⊙CEl n Y ⊙→ ⊙CEl n X) CF n f = GroupHom.⊙f (CF-hom n f) field C-abelian : (n : ℤ) (X : Ptd i) → is-abelian (C n X) C-Susp : (n : ℤ) (X : Ptd i) → C (succ n) (⊙Susp X) == C n X C-exact : (n : ℤ) {X Y : Ptd i} (f : fst (X ⊙→ Y)) → is-exact (CF n (⊙cfcod f)) (CF n f) C-additive : (n : ℤ) {I : Type i} (Z : I → Ptd i) → ((W : I → Type i) → has-choice ⟨0⟩ I W) → C n (⊙BigWedge Z) == Πᴳ I (C n ∘ Z) {- A quick useful special case of C-additive: C n (X ∨ Y) == C n X × C n Y -} C-binary-additive : (n : ℤ) (X Y : Ptd i) → C n (X ⊙∨ Y) == C n X ×ᴳ C n Y C-binary-additive n X Y = ap (C n) (! (BigWedge-Bool-⊙path Pick)) ∙ C-additive n _ (λ _ → Bool-has-choice) ∙ Πᴳ-Bool-is-×ᴳ (C n ∘ Pick) where Pick : Lift {j = i} Bool → Ptd i Pick (lift true) = X Pick (lift false) = Y record OrdinaryTheory i : Type (lsucc i) where constructor ordinary-theory field cohomology-theory : CohomologyTheory i open CohomologyTheory cohomology-theory public field C-dimension : (n : ℤ) → n ≠ O → C n (⊙Sphere O) == 0ᴳ
algebraic-stack_agda0000_doc_17420
{-# OPTIONS --cubical --safe #-} module Relation.Nullary.Discrete.FromBoolean where open import Prelude open import Relation.Nullary.Discrete module _ {a} {A : Type a} (_≡ᴮ_ : A → A → Bool) (sound : ∀ x y → T (x ≡ᴮ y) → x ≡ y) (complete : ∀ x → T (x ≡ᴮ x)) where from-bool-eq : Discrete A from-bool-eq x y = iff-dec (sound x y iff flip (subst (λ z → T (x ≡ᴮ z))) (complete x)) (T? (x ≡ᴮ y))
algebraic-stack_agda0000_doc_17421
module calculus-examples where open import Data.List using (List ; _∷_ ; [] ; _++_) open import Data.List.Any using (here ; there ; any) open import Data.List.Any.Properties open import Data.OrderedListMap open import Data.Sum using (inj₁ ; inj₂ ; _⊎_) open import Data.Maybe.Base open import Data.Empty using (⊥ ; ⊥-elim) open import Data.Bool.Base using (true ; false) open import Relation.Nullary using (Dec ; yes ; no ; ¬_) open import Agda.Builtin.Equality using (refl ; _≡_) open import Relation.Nullary.Decidable using (⌊_⌋) open import Relation.Binary.PropositionalEquality using (subst ; cong ; sym ; trans) open import calculus open import utility open import Esterel.Environment as Env open import Esterel.Variable.Signal as Signal using (Signal ; _ₛ ; unknown ; present ; absent ; _≟ₛₜ_) open import Esterel.Variable.Shared as SharedVar using (SharedVar) open import Esterel.Variable.Sequential as SeqVar using (SeqVar) open import Esterel.Lang open import Esterel.Lang.CanFunction open import Esterel.Lang.CanFunction.Properties open import Esterel.Lang.CanFunction.SetSigMonotonic using (canₛ-set-sig-monotonic) open import Esterel.Lang.Properties open import Esterel.Lang.Binding open import Esterel.Context open import Esterel.CompletionCode as Code using () renaming (CompletionCode to Code) open import context-properties open import Esterel.Lang.CanFunction.Base using (canₛ-⊆-FV) open import Data.Nat as Nat using (ℕ ; zero ; suc ; _+_) renaming (_⊔_ to _⊔ℕ_) open import Data.Nat.Properties.Simple using (+-comm) open import Data.Product using (Σ-syntax ; Σ ; _,_ ; _,′_ ; proj₁ ; proj₂ ; _×_) open import eval {- This example is not true (and not provable under the current calculus) {- rewriting a present to the true branch -} {- cannot prove without the `signal` form -} ex1 : ∀ S p q -> CB p -> signl S (emit S >> (present S ∣⇒ p ∣⇒ q)) ≡ₑ signl S (emit S >> p) # [] ex1 S p q CBp = calc where θS→unk : Env θS→unk = Θ SigMap.[ S ↦ Signal.unknown ] [] [] S∈θS→unk : SigMap.∈Dom S (sig θS→unk) S∈θS→unk = sig-∈-single S Signal.unknown θS→unk[S]≡unk : sig-stats{S = S} θS→unk S∈θS→unk ≡ Signal.unknown θS→unk[S]≡unk = sig-stats-1map' S Signal.unknown S∈θS→unk θS→pre : Env θS→pre = set-sig{S} θS→unk S∈θS→unk Signal.present S∈θS→pre : SigMap.∈Dom S (sig θS→pre) S∈θS→pre = sig-set-mono' {S} {S} {θS→unk} {Signal.present} {S∈θS→unk} S∈θS→unk θS→pre[S]≡pre : sig-stats{S = S} θS→pre S∈θS→pre ≡ Signal.present θS→pre[S]≡pre = sig-putget{S} {θS→unk} {Signal.present} S∈θS→unk S∈θS→pre θS→unk[S]≠absent : ¬ sig-stats{S = S} θS→unk S∈θS→unk ≡ Signal.absent θS→unk[S]≠absent is rewrite θS→unk[S]≡unk = unknotabs is where unknotabs : Signal.unknown ≡ Signal.absent → ⊥ unknotabs () CBsignalS[emitS>>p] : CB (signl S (emit S >> p)) CBsignalS[emitS>>p] = CBsig (CBseq (CBemit{S}) CBp ((λ z → λ ()) , (λ z → λ ()) , (λ z → λ ()))) calc : signl S (emit S >> (present S ∣⇒ p ∣⇒ q)) ≡ₑ signl S (emit S >> p) # [] calc = ≡ₑtran {r = (ρ θS→unk · (emit S >> (present S ∣⇒ p ∣⇒ q)))} (≡ₑstep [raise-signal]) (≡ₑtran {r = (ρ θS→pre · (nothin >> (present S ∣⇒ p ∣⇒ q)))} (≡ₑstep ([emit] S∈θS→unk θS→unk[S]≠absent (deseq dehole))) (≡ₑtran {r = (ρ θS→pre · (present S ∣⇒ p ∣⇒ q))} (≡ₑctxt (dcenv dchole) (dcenv dchole) (≡ₑstep [seq-done])) (≡ₑtran {r = (ρ θS→pre · p)} (≡ₑstep ([is-present] S S∈θS→pre θS→pre[S]≡pre dehole)) (≡ₑsymm CBsignalS[emitS>>p] (≡ₑtran {r = (ρ θS→unk · (emit S >> p))} (≡ₑstep [raise-signal]) (≡ₑtran {r = (ρ θS→pre · (nothin >> p))} (≡ₑstep ([emit] S∈θS→unk θS→unk[S]≠absent (deseq dehole))) (≡ₑtran {r = ρ θS→pre · p} (≡ₑctxt (dcenv dchole) (dcenv dchole) (≡ₑstep [seq-done])) ≡ₑrefl))))))) -} Canₛpresent-fact : ∀ S p q -> (Signal.unwrap S) ∈ Canₛ (present S ∣⇒ p ∣⇒ q) (Θ SigMap.[ S ↦ Signal.unknown ] [] []) -> (Signal.unwrap S ∈ Canₛ p (Θ SigMap.[ S ↦ Signal.unknown ] [] [])) ⊎ (Signal.unwrap S ∈ Canₛ q (Θ SigMap.[ S ↦ Signal.unknown ] [] [])) Canₛpresent-fact S p q S∈Canₛ[presentSpq] with Env.Sig∈ S (Θ SigMap.[ S ↦ Signal.unknown ] [] []) Canₛpresent-fact S p q S∈Canₛ[presentSpq] | yes S∈ with ⌊ present ≟ₛₜ (Env.sig-stats{S} (Θ SigMap.[ S ↦ Signal.unknown ] [] []) S∈) ⌋ Canₛpresent-fact S p q S∈Canₛ[presentSpq] | yes S∈ | true = inj₁ S∈Canₛ[presentSpq] Canₛpresent-fact S p q S∈Canₛ[presentSpq] | yes S∈ | false with ⌊ absent ≟ₛₜ Env.sig-stats{S} (Θ SigMap.[ S ↦ Signal.unknown ] [] []) S∈ ⌋ Canₛpresent-fact S p q S∈Canₛ[presentSpq] | yes S∈ | false | true = inj₂ S∈Canₛ[presentSpq] Canₛpresent-fact S p q S∈Canₛ[presentSpq] | yes S∈ | false | false = ++⁻ (Canₛ p (Θ SigMap.[ S ↦ Signal.unknown ] [] [])) S∈Canₛ[presentSpq] Canₛpresent-fact S p q _ | no ¬p = ⊥-elim (¬p (SigMap.update-in-keys [] S unknown)) {- rewriting a present to the false branch -} ex2b : ∀ S p q C -> CB (C ⟦ signl S q ⟧c) -> Signal.unwrap S ∉ (Canₛ p (Θ SigMap.[ S ↦ unknown ] [] [])) -> Signal.unwrap S ∉ (Canₛ q (Θ SigMap.[ S ↦ unknown ] [] [])) -> signl S (present S ∣⇒ p ∣⇒ q) ≡ₑ signl S q # C ex2b S p q C CBq s∉Canₛp s∉Canₛq = calc where θS→unk : Env θS→unk = Θ SigMap.[ S ↦ Signal.unknown ] [] [] S∈θS→unk : SigMap.∈Dom S (sig θS→unk) S∈θS→unk = sig-∈-single S Signal.unknown θS→unk[S]≡unk : sig-stats{S = S} θS→unk S∈θS→unk ≡ Signal.unknown θS→unk[S]≡unk = sig-stats-1map' S Signal.unknown S∈θS→unk θS→abs : Env θS→abs = set-sig{S} θS→unk S∈θS→unk Signal.absent S∈θS→abs : SigMap.∈Dom S (sig θS→abs) S∈θS→abs = sig-set-mono' {S} {S} {θS→unk} {Signal.absent} {S∈θS→unk} S∈θS→unk θS→abs[S]≡abs : sig-stats{S = S} θS→abs S∈θS→abs ≡ Signal.absent θS→abs[S]≡abs = sig-putget{S} {θS→unk} {Signal.absent} S∈θS→unk S∈θS→abs S∉Canθₛq : Signal.unwrap S ∉ Canθₛ SigMap.[ S ↦ unknown ] 0 q []env S∉Canθₛq S∈Canθₛq = s∉Canₛq (Canθₛunknown->Canₛunknown S q S∈Canθₛq) S∉CanθₛpresentSpq : Signal.unwrap S ∉ Canθₛ SigMap.[ S ↦ unknown ] 0 (present S ∣⇒ p ∣⇒ q) []env S∉CanθₛpresentSpq S∈Canθₛ with Canθₛunknown->Canₛunknown S (present S ∣⇒ p ∣⇒ q) S∈Canθₛ ... | fact with Canₛpresent-fact S p q fact ... | inj₁ s∈Canₛp = s∉Canₛp s∈Canₛp ... | inj₂ s∈Canₛq = s∉Canₛq s∈Canₛq bwd : signl S q ≡ₑ (ρ⟨ θS→abs , WAIT ⟩· q) # C bwd = ≡ₑtran (≡ₑstep [raise-signal]) (≡ₑtran (≡ₑstep ([absence] S S∈θS→unk θS→unk[S]≡unk S∉Canθₛq)) ≡ₑrefl) fwd : signl S (present S ∣⇒ p ∣⇒ q) ≡ₑ (ρ⟨ θS→abs , WAIT ⟩· q) # C fwd = ≡ₑtran (≡ₑstep [raise-signal]) (≡ₑtran (≡ₑstep ([absence] S S∈θS→unk θS→unk[S]≡unk S∉CanθₛpresentSpq)) (≡ₑtran (≡ₑstep ([is-absent] S S∈θS→abs θS→abs[S]≡abs dehole)) ≡ₑrefl)) where calc : signl S (present S ∣⇒ p ∣⇒ q) ≡ₑ signl S q # C calc = ≡ₑtran fwd (≡ₑsymm CBq bwd) ex2 : ∀ S p q C -> CB (C ⟦ signl S q ⟧c) -> (∀ status -> Signal.unwrap S ∉ (Canₛ p (Θ SigMap.[ S ↦ status ] [] []))) -> (∀ status -> Signal.unwrap S ∉ (Canₛ q (Θ SigMap.[ S ↦ status ] [] []))) -> signl S (present S ∣⇒ p ∣⇒ q) ≡ₑ signl S q # C ex2 S p q C CB noSp noSq = ex2b S p q C CB (noSp unknown) (noSq unknown) {- Although true, the this example is not provable under the current calculus {- lifting an emit out of a par -} ex3 : ∀ S p q -> CB (p ∥ q) -> signl S ((emit S >> p) ∥ q) ≡ₑ signl S (emit S >> (p ∥ q)) # [] ex3 S p q CBp∥q = calc where θS→unk : Env θS→unk = Θ SigMap.[ S ↦ Signal.unknown ] [] [] S∈θS→unk : SigMap.∈Dom S (sig θS→unk) S∈θS→unk = sig-∈-single S Signal.unknown θS→unk[S]≡unk : sig-stats{S = S} θS→unk S∈θS→unk ≡ Signal.unknown θS→unk[S]≡unk = sig-stats-1map' S Signal.unknown S∈θS→unk θS→pre : Env θS→pre = set-sig{S} θS→unk S∈θS→unk Signal.present θS→unk[S]≠absent : ¬ sig-stats{S = S} θS→unk S∈θS→unk ≡ Signal.absent θS→unk[S]≠absent is rewrite θS→unk[S]≡unk = unknotabs is where unknotabs : Signal.unknown ≡ Signal.absent → ⊥ unknotabs () calc : signl S ((emit S >> p) ∥ q) ≡ₑ signl S (emit S >> (p ∥ q)) # [] calc = ≡ₑtran {r = ρ⟨ θS→unk · ((emit S >> p) ∥ q)} (≡ₑstep [raise-signal]) (≡ₑtran {r = ρ θS→pre · (nothin >> p ∥ q)} (≡ₑstep ([emit]{S = S} S∈θS→unk θS→unk[S]≠absent (depar₁ (deseq dehole)))) (≡ₑtran {r = ρ θS→pre · (p ∥ q)} (≡ₑctxt (dcenv (dcpar₁ dchole)) (dcenv (dcpar₁ dchole)) (≡ₑstep [seq-done])) (≡ₑsymm (CBsig (CBseq CBemit CBp∥q (((λ z → λ ()) , (λ z → λ ()) , (λ z → λ ()))))) (≡ₑtran {r = ρ θS→unk · (emit S >> (p ∥ q))} (≡ₑstep [raise-signal]) (≡ₑtran (≡ₑstep ([emit] S∈θS→unk θS→unk[S]≠absent (deseq dehole))) (≡ₑctxt (dcenv dchole) (dcenv dchole) (≡ₑstep [seq-done]))))))) -} {- pushing a trap across a par -} ex4 : ∀ n p q -> CB p -> done q -> p ≡ₑ q # [] -> (trap (exit (suc n) ∥ p)) ≡ₑ (exit n ∥ trap p) # [] ex4 = ex4-split where basealwaysdistinct : ∀ x -> distinct base x basealwaysdistinct x = (λ { z () x₂ }) , (λ { z () x₂ }) , (λ { z () x₂}) CBplugrpartrap : ∀ n -> ∀ {r r′ BVp FVp} -> CorrectBinding r BVp FVp → r′ ≐ ceval (epar₂ (exit n)) ∷ ceval etrap ∷ [] ⟦ r ⟧c → CB r′ CBplugrpartrap n {p} {p′} {BVp} {FVp} CBp r′dc with BVFVcorrect p BVp FVp CBp | unplugc r′dc ... | refl , refl | refl = CBpar CBexit (CBtrap CBp) (basealwaysdistinct BVp) (basealwaysdistinct (BVars p)) (basealwaysdistinct (FVars p)) (λ { _ () _ }) CBplugtraprpar : ∀ n -> {r r′ : Term} {BVp FVp : Σ (List ℕ) (λ x → List ℕ × List ℕ)} → CorrectBinding r BVp FVp → r′ ≐ ceval etrap ∷ ceval (epar₂ (exit (suc n))) ∷ [] ⟦ r ⟧c → CB r′ CBplugtraprpar n {r} {r′} {BVp} {FVp} CBr r′C with unplugc r′C ... | refl with BVFVcorrect r BVp FVp CBr ... | refl , refl = CBtrap (CBpar CBexit CBr (basealwaysdistinct BVp) (basealwaysdistinct (BVars r)) (basealwaysdistinct (FVars r)) (λ { _ () _})) ex4-split : ∀ n p q -> CB p -> done q -> p ≡ₑ q # [] -> (trap (exit (suc n) ∥ p)) ≡ₑ (exit n ∥ trap p) # [] ex4-split n p .nothin CBp (dhalted hnothin) p≡ₑnothin = ≡ₑtran {r = trap (exit (suc n) ∥ nothin)} (≡ₑctxt (dctrap (dcpar₂ dchole)) (dctrap (dcpar₂ dchole)) (≡ₑ-context [] _ (CBplugtraprpar n) p≡ₑnothin)) (≡ₑtran {r = trap (exit (suc n))} (≡ₑctxt (dctrap dchole) (dctrap dchole) (≡ₑtran (≡ₑstep [par-swap]) (≡ₑstep ([par-nothing] (dhalted (hexit (suc n))))))) (≡ₑtran {r = exit n} (≡ₑstep ([trap-done] (hexit (suc n)))) (≡ₑsymm (CBpar CBexit (CBtrap CBp) (basealwaysdistinct (BVars p)) (basealwaysdistinct (BVars p)) (basealwaysdistinct (FVars p)) (λ { _ () _ })) (≡ₑtran {r = exit n ∥ trap nothin} (≡ₑctxt (dcpar₂ (dctrap dchole)) (dcpar₂ (dctrap dchole)) (≡ₑ-context [] _ (CBplugrpartrap n) p≡ₑnothin)) (≡ₑtran {r = exit n ∥ nothin} (≡ₑctxt (dcpar₂ dchole) (dcpar₂ dchole) (≡ₑstep ([trap-done] hnothin))) (≡ₑtran {r = nothin ∥ exit n} (≡ₑstep [par-swap]) (≡ₑtran {r = exit n} (≡ₑstep ([par-nothing] (dhalted (hexit n)))) ≡ₑrefl))))))) ex4-split n p .(exit 0) CBp (dhalted (hexit 0)) p≡ₑexit0 = ≡ₑtran {r = trap (exit (suc n) ∥ exit 0) } (≡ₑctxt (dctrap (dcpar₂ dchole)) (dctrap (dcpar₂ dchole)) (≡ₑ-context [] _ (CBplugtraprpar n) p≡ₑexit0)) (≡ₑtran {r = trap (exit (suc n))} (≡ₑctxt (dctrap dchole) (dctrap dchole) (≡ₑstep ([par-2exit] (suc n) zero))) (≡ₑtran {r = exit n} (≡ₑstep ([trap-done] (hexit (suc n)))) (≡ₑsymm (CBpar CBexit (CBtrap CBp) (basealwaysdistinct (BVars p)) (basealwaysdistinct (BVars p)) (basealwaysdistinct (FVars p)) (λ { _ () _ })) (≡ₑtran {r = exit n ∥ trap (exit 0)} (≡ₑctxt (dcpar₂ (dctrap dchole)) (dcpar₂ (dctrap dchole)) (≡ₑ-context [] _ (CBplugrpartrap n) p≡ₑexit0)) (≡ₑtran {r = exit n ∥ nothin } (≡ₑctxt (dcpar₂ dchole) (dcpar₂ dchole) (≡ₑstep ([trap-done] (hexit zero)))) (≡ₑtran {r = nothin ∥ exit n} (≡ₑstep [par-swap]) (≡ₑtran {r = exit n} (≡ₑstep ([par-nothing] (dhalted (hexit n)))) ≡ₑrefl))))))) ex4-split n p .(exit (suc m)) CBp (dhalted (hexit (suc m))) p≡ₑexitm = ≡ₑtran {r = trap (exit (suc n) ∥ exit (suc m)) } (≡ₑctxt (dctrap (dcpar₂ dchole)) (dctrap (dcpar₂ dchole)) (≡ₑ-context [] _ (CBplugtraprpar n) p≡ₑexitm)) (≡ₑtran {r = trap (exit (suc n ⊔ℕ (suc m)))} (≡ₑctxt (dctrap dchole) (dctrap dchole) (≡ₑstep ([par-2exit] (suc n) (suc m)))) (≡ₑtran {r = ↓_ {p = (exit (suc n ⊔ℕ (suc m)))} (hexit (suc n ⊔ℕ (suc m))) } (≡ₑstep ([trap-done] (hexit (suc (n ⊔ℕ m))))) (≡ₑsymm (CBpar CBexit (CBtrap CBp) (basealwaysdistinct (BVars p)) (basealwaysdistinct (BVars p)) (basealwaysdistinct (FVars p)) (λ { _ () _ })) (≡ₑtran {r = exit n ∥ trap (exit (suc m))} (≡ₑctxt (dcpar₂ (dctrap dchole)) (dcpar₂ (dctrap dchole)) (≡ₑ-context [] _ (CBplugrpartrap n) p≡ₑexitm)) (≡ₑtran {r = exit n ∥ ↓_ {p = exit (suc m)} (hexit (suc m))} (≡ₑctxt (dcpar₂ dchole) (dcpar₂ dchole) (≡ₑstep ([trap-done] (hexit (suc m)))) ) (≡ₑtran {r = ↓_ {p = (exit (suc n ⊔ℕ (suc m)))} (hexit (suc n ⊔ℕ (suc m))) } (≡ₑstep ([par-2exit] n m)) ≡ₑrefl)))))) ex4-split n p q CBp (dpaused pausedq) p≡ₑq = ≡ₑtran {r = trap (exit (suc n) ∥ q)} (≡ₑctxt (dctrap (dcpar₂ dchole)) (dctrap (dcpar₂ dchole)) (≡ₑ-context [] _ (CBplugtraprpar n) p≡ₑq)) (≡ₑtran {r = trap (exit (suc n))} (≡ₑctxt (dctrap dchole) (dctrap dchole) (≡ₑstep ([par-1exit] (suc n) pausedq))) (≡ₑtran {r = exit n} (≡ₑstep ([trap-done] (hexit (suc n)))) (≡ₑsymm (CBpar CBexit (CBtrap CBp) (basealwaysdistinct (BVars p)) (basealwaysdistinct (BVars p)) (basealwaysdistinct (FVars p)) (λ { _ () _ })) (≡ₑtran {r = exit n ∥ trap q} (≡ₑctxt (dcpar₂ (dctrap dchole)) (dcpar₂ (dctrap dchole)) (≡ₑ-context [] _ (CBplugrpartrap n) p≡ₑq)) (≡ₑtran {r = exit n} (≡ₑstep ([par-1exit] n (ptrap pausedq))) ≡ₑrefl))))) {- lifting a signal out of an evaluation context -} ex5 : ∀ S p q r E -> CB r -> q ≐ E ⟦(signl S p)⟧e -> r ≐ E ⟦ p ⟧e -> (ρ⟨ []env , WAIT ⟩· q) ≡ₑ (ρ⟨ []env , WAIT ⟩· (signl S r)) # [] ex5 S p q r E CBr decomp1 decomp2 = calc where θS→unk : Env θS→unk = Θ SigMap.[ S ↦ Signal.unknown ] [] [] replugit : q ≐ Data.List.map ceval E ⟦ signl S p ⟧c -> E ⟦ ρ⟨ θS→unk , WAIT ⟩· p ⟧e ≐ Data.List.map ceval E ⟦ ρ⟨ θS→unk , WAIT ⟩· p ⟧c replugit x = ⟦⟧e-to-⟦⟧c Erefl calc : (ρ⟨ []env , WAIT ⟩· q) ≡ₑ (ρ⟨ []env , WAIT ⟩· (signl S r)) # [] calc = ≡ₑtran {r = ρ⟨ []env , WAIT ⟩· (E ⟦ (ρ⟨ θS→unk , WAIT ⟩· p) ⟧e)} (≡ₑctxt (dcenv (⟦⟧e-to-⟦⟧c decomp1)) (dcenv (replugit (⟦⟧e-to-⟦⟧c decomp1))) (≡ₑstep [raise-signal])) (≡ₑtran {r = ρ⟨ θS→unk , WAIT ⟩· (E ⟦ p ⟧e)} (≡ₑstep ([merge]{E = E} Erefl)) (≡ₑsymm (CBρ (CBsig CBr)) (≡ₑtran {r = ρ⟨ []env , WAIT ⟩· (ρ⟨ θS→unk , WAIT ⟩· r)} (≡ₑctxt (dcenv dchole) (dcenv dchole) (≡ₑstep [raise-signal])) (≡ₑstep ([merge] {E = []} (subst (\ x -> ρ⟨ θS→unk , WAIT ⟩· x ≐ [] ⟦ ρ⟨ θS→unk , WAIT ⟩· E ⟦ p ⟧e ⟧e) (unplug decomp2) dehole)))))) {- two specific examples of lifting a signal out of an evaluation context -} ex6 : ∀ S p q -> CB (p ∥ q) -> (ρ⟨ []env , WAIT ⟩· ((signl S p) ∥ q)) ≡ₑ (ρ⟨ []env , WAIT ⟩· (signl S (p ∥ q))) # [] ex6 S p q CBp∥q = ex5 S p (signl S p ∥ q) (p ∥ q) ((epar₁ q) ∷ []) CBp∥q (depar₁ dehole) (depar₁ dehole) ex7 : ∀ S p q -> CB (p >> q) -> (ρ⟨ []env , WAIT ⟩· ((signl S p) >> q)) ≡ₑ (ρ⟨ []env , WAIT ⟩· (signl S (p >> q))) # [] ex7 S p q CBp>>q = ex5 S p (signl S p >> q) (p >> q) ((eseq q) ∷ []) CBp>>q (deseq dehole) (deseq dehole) {- pushing a seq into a binding form (a signal in this case). this shows the need for the outer environment ρ [} · _ in order to manipulate the environment. -} ex8-worker : ∀ {BV FV} S p q -> CorrectBinding ((signl S p) >> q) BV FV -> (ρ⟨ []env , WAIT ⟩· (signl S p) >> q) ≡ₑ (ρ⟨ []env , WAIT ⟩· signl S (p >> q)) # [] ex8-worker S p q (CBseq {BVp = BVsigS·p} {FVq = FVq} (CBsig {BV = BVp} CBp) CBq BVsigS·p≠FVq) = ≡ₑtran {r = ρ⟨ []env , WAIT ⟩· (ρ⟨ [S]-env S , WAIT ⟩· p) >> q} {C = []} (≡ₑctxt {C = []} {C′ = cenv []env WAIT ∷ ceval (eseq q) ∷ []} Crefl Crefl (≡ₑstep ([raise-signal] {p} {S}))) (≡ₑtran {r = ρ⟨ [S]-env S , WAIT ⟩· p >> q} {C = []} (≡ₑstep ([merge] (deseq dehole))) (≡ₑsymm (CBρ (CBsig (CBseq CBp CBq (⊆-respect-distinct-left (∪ʳ (+S S base) ⊆-refl) BVsigS·p≠FVq)))) (≡ₑtran {r = ρ⟨ []env , WAIT ⟩· (ρ⟨ [S]-env S , WAIT ⟩· p >> q)} {C = []} (≡ₑctxt {C = []} {C′ = cenv []env WAIT ∷ []} Crefl Crefl (≡ₑstep ([raise-signal] {p >> q} {S}))) (≡ₑstep ([merge] dehole))))) ex8 : ∀ S p q -> CB ((signl S p) >> q) -> (ρ⟨ []env , WAIT ⟩· (signl S p) >> q) ≡ₑ (ρ⟨ []env , WAIT ⟩· signl S (p >> q)) # [] ex8 S p q cb = ex8-worker S p q cb {- rearranging signal forms -} ex9 : ∀ S1 S2 p -> CB p -> signl S1 (signl S2 p) ≡ₑ signl S2 (signl S1 p) # [] ex9 S1 S2 p CBp = ≡ₑtran {r = ρ⟨ (Θ SigMap.[ S1 ↦ Signal.unknown ] [] []) , WAIT ⟩· (signl S2 p)} (≡ₑstep [raise-signal]) (≡ₑtran {r = (ρ⟨ Θ SigMap.[ S1 ↦ Signal.unknown ] [] [] , WAIT ⟩· (ρ⟨ Θ SigMap.[ S2 ↦ Signal.unknown ] [] [] , WAIT ⟩· p))} (≡ₑctxt (dcenv dchole) (dcenv dchole) (≡ₑstep [raise-signal])) (≡ₑtran {r = (ρ⟨ (Θ SigMap.[ S1 ↦ Signal.unknown ] [] []) ← (Θ SigMap.[ S2 ↦ Signal.unknown ] [] []) , A-max WAIT WAIT ⟩· p)} (≡ₑstep ([merge] dehole)) (≡ₑsymm (CBsig (CBsig CBp)) (≡ₑtran {r = ρ⟨ (Θ SigMap.[ S2 ↦ Signal.unknown ] [] []) , WAIT ⟩· (signl S1 p)} (≡ₑstep [raise-signal]) (≡ₑtran {r = (ρ⟨ Θ SigMap.[ S2 ↦ Signal.unknown ] [] [] , WAIT ⟩· (ρ⟨ Θ SigMap.[ S1 ↦ Signal.unknown ] [] [] , WAIT ⟩· p))} (≡ₑctxt (dcenv dchole) (dcenv dchole) (≡ₑstep [raise-signal])) (≡ₑtran {r = (ρ⟨ (Θ SigMap.[ S2 ↦ Signal.unknown ] [] []) ← (Θ SigMap.[ S1 ↦ Signal.unknown ] [] []) , A-max WAIT WAIT ⟩· p)} (≡ₑstep ([merge] dehole)) (map-order-irr S1 S2 WAIT p))))))) where distinct-Ss-env'' : ∀ S1 S2 S3 -> ¬ Signal.unwrap S1 ≡ Signal.unwrap S2 -> Data.List.Any.Any (_≡_ S3) (Signal.unwrap S1 ∷ []) -> Data.List.Any.Any (_≡_ S3) (Signal.unwrap S2 ∷ []) -> ⊥ distinct-Ss-env'' S1 S2 S3 S1≠S2 (here S3=S1) (here S3=S2) rewrite S3=S1 = S1≠S2 S3=S2 distinct-Ss-env'' S1 S2 S3 S1≠S2 (here px) (there ()) distinct-Ss-env'' S1 S2 S3 S1≠S2 (there ()) S3∈Domθ2 distinct-Ss-env' : ∀ S1 S2 S3 -> ¬ Signal.unwrap S1 ≡ Signal.unwrap S2 -> Data.List.Any.Any (_≡_ S3) (Signal.unwrap S1 ∷ []) -> S3 ∈ proj₁ (Dom (Θ SigMap.[ S2 ↦ Signal.unknown ] [] [])) -> ⊥ distinct-Ss-env' S1 S2 S3 S1≠S2 S3∈Domθ1 S3∈Domθ2 rewrite SigMap.keys-1map S2 Signal.unknown = distinct-Ss-env'' S1 S2 S3 S1≠S2 S3∈Domθ1 S3∈Domθ2 distinct-Ss-env : ∀ S1 S2 S3 -> ¬ Signal.unwrap S1 ≡ Signal.unwrap S2 -> S3 ∈ proj₁ (Dom (Θ SigMap.[ S1 ↦ Signal.unknown ] [] [])) -> S3 ∈ proj₁ (Dom (Θ SigMap.[ S2 ↦ Signal.unknown ] [] [])) -> ⊥ distinct-Ss-env S1 S2 S3 S1≠S2 S3∈Domθ1 S3∈Domθ2 rewrite SigMap.keys-1map S1 Signal.unknown = distinct-Ss-env' S1 S2 S3 S1≠S2 S3∈Domθ1 S3∈Domθ2 distinct-doms : ∀ S1 S2 -> ¬ (Signal.unwrap S1 ≡ Signal.unwrap S2) -> distinct (Env.Dom (Θ SigMap.[ S1 ↦ Signal.unknown ] [] [])) (Env.Dom (Θ SigMap.[ S2 ↦ Signal.unknown ] [] [])) distinct-doms S1 S2 S1≠S2 = (λ {S3 S3∈θ1 S3∈θ2 -> distinct-Ss-env S1 S2 S3 S1≠S2 S3∈θ1 S3∈θ2}) , (λ x₁ x₂ → λ ()) , (λ x₁ x₂ → λ ()) map-order-irr' : ∀ S1 S2 -> (Θ SigMap.[ S1 ↦ Signal.unknown ] [] []) ← (Θ SigMap.[ S2 ↦ Signal.unknown ] [] []) ≡ (Θ SigMap.[ S2 ↦ Signal.unknown ] [] []) ← (Θ SigMap.[ S1 ↦ Signal.unknown ] [] []) map-order-irr' S1 S2 with (Signal.unwrap S1) Nat.≟ (Signal.unwrap S2) map-order-irr' S1 S2 | yes S1=S2 rewrite S1=S2 = refl map-order-irr' S1 S2 | no ¬S1=S2 = Env.←-comm ((Θ SigMap.[ S1 ↦ Signal.unknown ] [] [])) ((Θ SigMap.[ S2 ↦ Signal.unknown ] [] [])) (distinct-doms S1 S2 ¬S1=S2) map-order-irr : ∀ S1 S2 A p -> (ρ⟨ Θ SigMap.[ S2 ↦ Signal.unknown ] [] [] ← Θ SigMap.[ S1 ↦ Signal.unknown ] [] [] , A ⟩· p) ≡ₑ (ρ⟨ Θ SigMap.[ S1 ↦ Signal.unknown ] [] [] ← Θ SigMap.[ S2 ↦ Signal.unknown ] [] [] , A ⟩· p) # [] map-order-irr S1 S2 A p rewrite map-order-irr' S1 S2 = ≡ₑrefl {- dropping a loop whose body is just `exit` -} ex10 : ∀ C n -> (loop (exit n)) ≡ₑ (exit n) # C ex10 C n = ≡ₑtran (≡ₑstep [loop-unroll]) (≡ₑstep [loopˢ-exit]) {- (nothin ∥ p) ≡ₑ p, but only if we know that p goes to something that's done -} ex11 : ∀ p q -> CB p -> done q -> p ≡ₑ q # [] -> (nothin ∥ p) ≡ₑ p # [] ex11 = calc where ex11-pq : ∀ q C -> done q -> (nothin ∥ q) ≡ₑ q # C ex11-pq .nothin C (dhalted hnothin) = ≡ₑtran (≡ₑstep [par-swap]) (≡ₑstep ([par-nothing] (dhalted hnothin))) ex11-pq .(exit n) C (dhalted (hexit n)) = ≡ₑstep ([par-nothing] (dhalted (hexit n))) ex11-pq q C (dpaused p/paused) = ≡ₑstep ([par-nothing] (dpaused p/paused)) basealwaysdistinct : ∀ x -> distinct base x basealwaysdistinct x = (λ { z () x₂ }) , (λ { z () x₂ }) , (λ { z () x₂}) CBp->CBnothingp : {r r′ : Term} {BVp FVp : Σ (List ℕ) (λ x → List ℕ × List ℕ)} → CorrectBinding r BVp FVp → r′ ≐ ceval (epar₂ nothin) ∷ [] ⟦ r ⟧c → CB r′ CBp->CBnothingp {r} CBr r′dc with sym (unplugc r′dc) | BVFVcorrect _ _ _ CBr ... | refl | refl , refl = CBpar CBnothing CBr (basealwaysdistinct (BVars r)) (basealwaysdistinct (BVars r)) (basealwaysdistinct (FVars r)) (λ { _ () _ }) calc : ∀ p q -> CB p -> done q -> p ≡ₑ q # [] -> (nothin ∥ p) ≡ₑ p # [] calc p q CBp doneq p≡ₑq = ≡ₑtran {r = (nothin ∥ q)} (≡ₑctxt (dcpar₂ dchole) (dcpar₂ dchole) (≡ₑ-context [] _ CBp->CBnothingp p≡ₑq)) (≡ₑtran {r = q} (ex11-pq q [] doneq) (≡ₑsymm CBp p≡ₑq)) {- although true, can no longer prove {- an emit (first) in sequence is the same as emit in parallel -} ex12 : ∀ S p q -> CB p -> done q -> p ≡ₑ q # [] -> (signl S ((emit S) ∥ p)) ≡ₑ (signl S ((emit S) >> p)) # [] ex12 S p q CBp doneq p≡ₑq = calc where θS→unk : Env θS→unk = Θ SigMap.[ S ↦ Signal.unknown ] [] [] S∈θS→unk : SigMap.∈Dom S (sig θS→unk) S∈θS→unk = sig-∈-single S Signal.unknown θS→unk[S]≡unk : sig-stats{S = S} θS→unk S∈θS→unk ≡ Signal.unknown θS→unk[S]≡unk = sig-stats-1map' S Signal.unknown S∈θS→unk θS→pre : Env θS→pre = set-sig{S} θS→unk S∈θS→unk Signal.present θS→unk[S]≠absent : ¬ sig-stats{S = S} θS→unk S∈θS→unk ≡ Signal.absent θS→unk[S]≠absent is rewrite θS→unk[S]≡unk = unknotabs is where unknotabs : Signal.unknown ≡ Signal.absent → ⊥ unknotabs () CBp->CBρθSp : {r r′ : Term} {BVp FVp : Σ (List ℕ) (λ x → List ℕ × List ℕ)} → CorrectBinding r BVp FVp → r′ ≐ cenv θS→pre ∷ [] ⟦ r ⟧c → CB r′ CBp->CBρθSp {r} CBr r′dc with sym (unplugc r′dc) | BVFVcorrect _ _ _ CBr ... | refl | refl , refl = CBρ CBr basealwaysdistinct : ∀ x -> distinct base x basealwaysdistinct x = (λ { z () x₂ }) , (λ { z () x₂ }) , (λ { z () x₂}) CBsiglSemitS>>p : CB (signl S (emit S >> p)) CBsiglSemitS>>p = CBsig (CBseq CBemit CBp (basealwaysdistinct (FVars p))) calc : (signl S ((emit S) ∥ p)) ≡ₑ (signl S ((emit S) >> p)) # [] calc = ≡ₑtran {r = ρ θS→unk · ((emit S) ∥ p)} (≡ₑstep [raise-signal]) (≡ₑtran {r = ρ θS→pre · (nothin ∥ p)} (≡ₑstep ([emit] S∈θS→unk θS→unk[S]≠absent (depar₁ dehole))) (≡ₑtran {r = ρ θS→pre · p} (≡ₑctxt (dcenv dchole) (dcenv dchole) (≡ₑ-context [] (cenv _ ∷ []) CBp->CBρθSp (ex11 p q CBp doneq p≡ₑq))) (≡ₑsymm CBsiglSemitS>>p (≡ₑtran {r = ρ θS→unk · (emit S >> p)} (≡ₑstep [raise-signal]) (≡ₑtran {r = ρ θS→pre · nothin >> p} (≡ₑstep ([emit] S∈θS→unk θS→unk[S]≠absent (deseq dehole))) (≡ₑctxt (dcenv dchole) (dcenv dchole) (≡ₑstep [seq-done]))))))) -}
algebraic-stack_agda0000_doc_17422
interleaved mutual -- we don't do `data A : Set` data A where -- you don't have to actually define any constructor to trigger the error, the "where" is enough data B where b : B
algebraic-stack_agda0000_doc_17423
module getline where -- https://github.com/alhassy/AgdaCheatSheet#interacting-with-the-real-world-compilation-haskell-and-io open import Data.Nat using (ℕ; suc) open import Data.Nat.Show using (show) open import Data.Char using (Char) open import Data.List as L using (map; sum; upTo) open import Function using (_$_; const; _∘_) open import Data.String as S using (String; _++_; fromList) open import Agda.Builtin.Unit using (⊤) open import Codata.Musical.Colist using (take) open import Codata.Musical.Costring using (Costring) open import Data.Vec.Bounded as B using (toList) open import Agda.Builtin.Coinduction using (♯_) open import IO as IO using (run ; putStrLn ; IO) import IO.Primitive as Primitive infixr 1 _>>=_ _>>_ _>>=_ : ∀ {ℓ} {α β : Set ℓ} → IO α → (α → IO β) → IO β this >>= f = ♯ this IO.>>= λ x → ♯ f x _>>_ : ∀{ℓ} {α β : Set ℓ} → IO α → IO β → IO β x >> y = x >>= const y postulate getLine∞ : Primitive.IO Costring {-# FOREIGN GHC toColist :: [a] -> MAlonzo.Code.Codata.Musical.Colist.AgdaColist a toColist [] = MAlonzo.Code.Codata.Musical.Colist.Nil toColist (x : xs) = MAlonzo.Code.Codata.Musical.Colist.Cons x (MAlonzo.RTE.Sharp (toColist xs)) #-} {- Haskell's prelude is implicitly available; this is for demonstration. -} {-# FOREIGN GHC import Prelude as Haskell #-} {-# COMPILE GHC getLine∞ = fmap toColist Haskell.getLine #-} -- (1) -- getLine : IO Costring -- getLine = IO.lift getLine∞ getLine : IO String getLine = IO.lift $ getLine∞ Primitive.>>= (Primitive.return ∘ S.fromList ∘ B.toList ∘ take 100) postulate readInt : L.List Char → ℕ {-# COMPILE GHC readInt = \x -> read x :: Integer #-} main : Primitive.IO ⊤ main = run do putStrLn "Hello, world! I'm a compiled Agda program!" IO.putStrLn "What is your name?:" name ← getLine IO.putStrLn "Please enter a number:" num ← getLine let tri = show $ sum $ upTo $ suc $ readInt $ S.toList num putStrLn $ "The triangle number of " ++ num ++ " is " ++ tri putStrLn ("Bye, " ++ name) -- IO.putStrLn∞ ("Bye, " ++ name) {- If using approach (1) above. -}
algebraic-stack_agda0000_doc_8720
module plfa.part1.Induction where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; cong; sym) open Eq.≡-Reasoning open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_) +-assoc : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p) +-assoc zero n p = begin (zero + n) + p ≡⟨⟩ n + p ≡⟨⟩ zero + (n + p) ∎ +-assoc (suc m) n p = begin (suc m + n) + p ≡⟨⟩ suc (m + n) + p ≡⟨⟩ suc ((m + n) + p) -- A relation is said to be a congruence for -- a given function if it is preserved by applying that function -- If e is evidence that x ≡ y, -- then cong f e is evidence that f x ≡ f y, -- for any function f -- The correspondence between proof by induction and -- definition by recursion is one of the most appealing -- aspects of Agda -- cong : ∀ (f : A → B) {x y} → x ≡ y → f x ≡ f y -- ^- suc ^- (m + n) + p ≡ m + (n + p) -- ----------------------------------------------------------- (=> implies) -- suc ((m + n) + p) ≡ suc (m + (n + p)) ≡⟨ cong suc (+-assoc m n p) ⟩ suc (m + (n + p)) -- cong : ∀ (f : A → B) {x y} → x ≡ y → f x ≡ f y -- cong f refl = refl ≡⟨⟩ suc m + (n + p) ∎ +-assoc-2 : ∀ (n p : ℕ) → (2 + n) + p ≡ 2 + (n + p) +-assoc-2 n p = begin (2 + n) + p ≡⟨⟩ suc (1 + n) + p ≡⟨⟩ suc ((1 + n) + p) ≡⟨ cong suc (+-assoc-1 n p) ⟩ suc (1 + (n + p)) ≡⟨⟩ 2 + (n + p) ∎ where +-assoc-1 : ∀ (n p : ℕ) -> (1 + n) + p ≡ 1 + (n + p) +-assoc-1 n p = begin (1 + n) + p ≡⟨⟩ suc (0 + n) + p ≡⟨⟩ suc ((0 + n) + p) ≡⟨ cong suc (+-assoc-0 n p) ⟩ suc (0 + (n + p)) ≡⟨⟩ 1 + (n + p) ∎ where +-assoc-0 : ∀ (n p : ℕ) → (0 + n) + p ≡ 0 + (n + p) +-assoc-0 n p = begin (0 + n) + p ≡⟨⟩ n + p ≡⟨⟩ 0 + (n + p) ∎ +-identityᴿ : ∀ (m : ℕ) → m + zero ≡ m +-identityᴿ zero = begin zero + zero ≡⟨⟩ zero ∎ +-identityᴿ (suc m) = begin suc m + zero ≡⟨⟩ suc (m + zero) ≡⟨ cong suc (+-identityᴿ m) ⟩ suc m ∎ +-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n) +-suc zero n = begin zero + suc n ≡⟨⟩ suc n ≡⟨⟩ suc (zero + n) ∎ +-suc (suc m) n = begin suc m + suc n ≡⟨⟩ suc (m + suc n) ≡⟨ cong suc (+-suc m n) ⟩ suc (suc (m + n)) ≡⟨⟩ suc (suc m + n) ∎ +-comm : ∀ (m n : ℕ) → m + n ≡ n + m +-comm m zero = begin m + zero ≡⟨ +-identityᴿ m ⟩ m ≡⟨⟩ zero + m ∎ +-comm m (suc n) = begin m + suc n ≡⟨ +-suc m n ⟩ suc (m + n) ≡⟨ cong suc (+-comm m n) ⟩ suc (n + m) ≡⟨⟩ suc n + m ∎ -- Rearranging -- We can apply associativity to -- rearrange parentheses however we like +-rearrange : ∀ (m n p q : ℕ) → (m + n) + (p + q) ≡ m + (n + p) + q +-rearrange m n p q = begin (m + n) + (p + q) ≡⟨ +-assoc m n (p + q) ⟩ m + (n + (p + q)) ≡⟨ cong (m +_) (sym (+-assoc n p q)) ⟩ m + ((n + p) + q) -- +-assoc : (m + n) + p ≡ m + (n + p) -- sym (+-assoc) : m + (n + p) ≡ (m + n) + p ≡⟨ sym (+-assoc m (n + p) q) ⟩ (m + (n + p)) + q ∎ -- Associativity with rewrite -- Rewriting avoids not only chains of -- equations but also the need to invoke cong +-assoc' : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p) +-assoc' zero n p = refl +-assoc' (suc m) n p rewrite +-assoc' m n p = refl +-identity' : ∀ (n : ℕ) → n + zero ≡ n +-identity' zero = refl +-identity' (suc n) rewrite +-identity' n = refl +-suc' : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n) +-suc' zero n = refl +-suc' (suc m) n rewrite +-suc' m n = refl +-comm' : ∀ (m n : ℕ) → m + n ≡ n + m +-comm' m zero rewrite +-identity' m = refl +-comm' m (suc n) rewrite +-suc' m n | +-comm' m n = refl -- Building proofs interactively +-assoc'' : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p) +-assoc'' zero n p = refl +-assoc'' (suc m) n p rewrite +-assoc'' m n p = refl -- Exercise -- Note: -- sym -- rewrites the left side of the Goal +-swap : ∀ (m n p : ℕ) → m + (n + p) ≡ n + (m + p) +-swap zero n p = refl +-swap (suc m) n p rewrite +-assoc'' m n p | +-suc n (m + p) | +-swap m n p = refl -- (suc m + n) * p ≡ suc m * p + n * p -- p + (m * p + n * p) ≡ p + m * p + n * p *-distrib-+ : ∀ (m n p : ℕ) → (m + n) * p ≡ m * p + n * p *-distrib-+ zero n p = refl *-distrib-+ (suc m) n p rewrite *-distrib-+ m n p | sym (+-assoc p (m * p) (n * p)) = refl -- (n + m * n) * p ≡ n * p + m * (n * p) *-assoc : ∀ (m n p : ℕ) → (m * n) * p ≡ m * (n * p) *-assoc zero n p = refl *-assoc (suc m) n p rewrite *-distrib-+ n (m * n) p | *-assoc m n p = refl
algebraic-stack_agda0000_doc_8721
module ProjectingRecordMeta where data _==_ {A : Set}(a : A) : A -> Set where refl : a == a -- Andreas, Feb/Apr 2011 record Prod (A B : Set) : Set where constructor _,_ field fst : A snd : B open Prod public testProj : {A B : Set}(y z : Prod A B) -> let X : Prod A B X = _ -- Solution: fst y , snd z in (C : Set) -> (fst X == fst y -> snd X == snd z -> C) -> C testProj y z C k = k refl refl -- ok, Agda handles projections properly during unification testProj' : {A B : Set}(y z : Prod A B) -> let X : Prod A B X = _ -- Solution: fst y , snd z in Prod (fst X == fst y) (snd X == snd z) testProj' y z = refl , refl
algebraic-stack_agda0000_doc_8722
------------------------------------------------------------------------ -- The Agda standard library -- -- "Finite" sets indexed on coinductive "natural" numbers ------------------------------------------------------------------------ module Data.Cofin where open import Coinduction open import Data.Conat as Conat using (Coℕ; suc; ∞ℕ) open import Data.Nat using (ℕ; zero; suc) open import Data.Fin using (Fin; zero; suc) ------------------------------------------------------------------------ -- The type -- Note that Cofin ∞ℕ is /not/ finite. Note also that this is not a -- coinductive type, but it is indexed on a coinductive type. data Cofin : Coℕ → Set where zero : ∀ {n} → Cofin (suc n) suc : ∀ {n} (i : Cofin (♭ n)) → Cofin (suc n) ------------------------------------------------------------------------ -- Some operations fromℕ : ℕ → Cofin ∞ℕ fromℕ zero = zero fromℕ (suc n) = suc (fromℕ n) toℕ : ∀ {n} → Cofin n → ℕ toℕ zero = zero toℕ (suc i) = suc (toℕ i) fromFin : ∀ {n} → Fin n → Cofin (Conat.fromℕ n) fromFin zero = zero fromFin (suc i) = suc (fromFin i) toFin : ∀ n → Cofin (Conat.fromℕ n) → Fin n toFin zero () toFin (suc n) zero = zero toFin (suc n) (suc i) = suc (toFin n i)
algebraic-stack_agda0000_doc_8723
module Pi1r where open import Data.Empty open import Data.Unit open import Data.Sum open import Data.Product open import Relation.Binary.PropositionalEquality open ≡-Reasoning open import Groupoid -- infix 2 _∎ -- equational reasoning for paths -- infixr 2 _≡⟨_⟩_ -- equational reasoning for paths infixr 10 _◎_ infixr 30 _⟷_ ------------------------------------------------------------------------------ -- Level 0: -- Types at this level are just plain sets with no interesting path structure. -- The path structure is defined at levels 1 and beyond. data U : Set where ZERO : U ONE : U PLUS : U → U → U TIMES : U → U → U ⟦_⟧ : U → Set ⟦ ZERO ⟧ = ⊥ ⟦ ONE ⟧ = ⊤ ⟦ PLUS t₁ t₂ ⟧ = ⟦ t₁ ⟧ ⊎ ⟦ t₂ ⟧ ⟦ TIMES t₁ t₂ ⟧ = ⟦ t₁ ⟧ × ⟦ t₂ ⟧ -- Programs -- We use pointed types; programs map a pointed type to another -- In other words, each program takes one particular value to another; if we -- want to work on another value, we generally use another program record U• : Set where constructor •[_,_] field ∣_∣ : U • : ⟦ ∣_∣ ⟧ open U• -- examples of plain types, values, and pointed types ONE• : U• ONE• = •[ ONE , tt ] BOOL : U BOOL = PLUS ONE ONE BOOL² : U BOOL² = TIMES BOOL BOOL TRUE : ⟦ BOOL ⟧ TRUE = inj₁ tt FALSE : ⟦ BOOL ⟧ FALSE = inj₂ tt BOOL•F : U• BOOL•F = •[ BOOL , FALSE ] BOOL•T : U• BOOL•T = •[ BOOL , TRUE ] -- The actual programs are the commutative semiring isomorphisms between -- pointed types. data _⟷_ : U• → U• → Set where unite₊ : ∀ {t v} → •[ PLUS ZERO t , inj₂ v ] ⟷ •[ t , v ] uniti₊ : ∀ {t v} → •[ t , v ] ⟷ •[ PLUS ZERO t , inj₂ v ] swap1₊ : ∀ {t₁ t₂ v₁} → •[ PLUS t₁ t₂ , inj₁ v₁ ] ⟷ •[ PLUS t₂ t₁ , inj₂ v₁ ] swap2₊ : ∀ {t₁ t₂ v₂} → •[ PLUS t₁ t₂ , inj₂ v₂ ] ⟷ •[ PLUS t₂ t₁ , inj₁ v₂ ] assocl1₊ : ∀ {t₁ t₂ t₃ v₁} → •[ PLUS t₁ (PLUS t₂ t₃) , inj₁ v₁ ] ⟷ •[ PLUS (PLUS t₁ t₂) t₃ , inj₁ (inj₁ v₁) ] assocl2₊ : ∀ {t₁ t₂ t₃ v₂} → •[ PLUS t₁ (PLUS t₂ t₃) , inj₂ (inj₁ v₂) ] ⟷ •[ PLUS (PLUS t₁ t₂) t₃ , inj₁ (inj₂ v₂) ] assocl3₊ : ∀ {t₁ t₂ t₃ v₃} → •[ PLUS t₁ (PLUS t₂ t₃) , inj₂ (inj₂ v₃) ] ⟷ •[ PLUS (PLUS t₁ t₂) t₃ , inj₂ v₃ ] assocr1₊ : ∀ {t₁ t₂ t₃ v₁} → •[ PLUS (PLUS t₁ t₂) t₃ , inj₁ (inj₁ v₁) ] ⟷ •[ PLUS t₁ (PLUS t₂ t₃) , inj₁ v₁ ] assocr2₊ : ∀ {t₁ t₂ t₃ v₂} → •[ PLUS (PLUS t₁ t₂) t₃ , inj₁ (inj₂ v₂) ] ⟷ •[ PLUS t₁ (PLUS t₂ t₃) , inj₂ (inj₁ v₂) ] assocr3₊ : ∀ {t₁ t₂ t₃ v₃} → •[ PLUS (PLUS t₁ t₂) t₃ , inj₂ v₃ ] ⟷ •[ PLUS t₁ (PLUS t₂ t₃) , inj₂ (inj₂ v₃) ] unite⋆ : ∀ {t v} → •[ TIMES ONE t , (tt , v) ] ⟷ •[ t , v ] uniti⋆ : ∀ {t v} → •[ t , v ] ⟷ •[ TIMES ONE t , (tt , v) ] swap⋆ : ∀ {t₁ t₂ v₁ v₂} → •[ TIMES t₁ t₂ , (v₁ , v₂) ] ⟷ •[ TIMES t₂ t₁ , (v₂ , v₁) ] assocl⋆ : ∀ {t₁ t₂ t₃ v₁ v₂ v₃} → •[ TIMES t₁ (TIMES t₂ t₃) , (v₁ , (v₂ , v₃)) ] ⟷ •[ TIMES (TIMES t₁ t₂) t₃ , ((v₁ , v₂) , v₃) ] assocr⋆ : ∀ {t₁ t₂ t₃ v₁ v₂ v₃} → •[ TIMES (TIMES t₁ t₂) t₃ , ((v₁ , v₂) , v₃) ] ⟷ •[ TIMES t₁ (TIMES t₂ t₃) , (v₁ , (v₂ , v₃)) ] distz : ∀ {t v absurd} → •[ TIMES ZERO t , (absurd , v) ] ⟷ •[ ZERO , absurd ] factorz : ∀ {t v absurd} → •[ ZERO , absurd ] ⟷ •[ TIMES ZERO t , (absurd , v) ] dist1 : ∀ {t₁ t₂ t₃ v₁ v₃} → •[ TIMES (PLUS t₁ t₂) t₃ , (inj₁ v₁ , v₃) ] ⟷ •[ PLUS (TIMES t₁ t₃) (TIMES t₂ t₃) , inj₁ (v₁ , v₃) ] dist2 : ∀ {t₁ t₂ t₃ v₂ v₃} → •[ TIMES (PLUS t₁ t₂) t₃ , (inj₂ v₂ , v₃) ] ⟷ •[ PLUS (TIMES t₁ t₃) (TIMES t₂ t₃) , inj₂ (v₂ , v₃) ] factor1 : ∀ {t₁ t₂ t₃ v₁ v₃} → •[ PLUS (TIMES t₁ t₃) (TIMES t₂ t₃) , inj₁ (v₁ , v₃) ] ⟷ •[ TIMES (PLUS t₁ t₂) t₃ , (inj₁ v₁ , v₃) ] factor2 : ∀ {t₁ t₂ t₃ v₂ v₃} → •[ PLUS (TIMES t₁ t₃) (TIMES t₂ t₃) , inj₂ (v₂ , v₃) ] ⟷ •[ TIMES (PLUS t₁ t₂) t₃ , (inj₂ v₂ , v₃) ] id⟷ : ∀ {t v} → •[ t , v ] ⟷ •[ t , v ] _◎_ : ∀ {t₁ t₂ t₃ v₁ v₂ v₃} → (•[ t₁ , v₁ ] ⟷ •[ t₂ , v₂ ]) → (•[ t₂ , v₂ ] ⟷ •[ t₃ , v₃ ]) → (•[ t₁ , v₁ ] ⟷ •[ t₃ , v₃ ]) _⊕1_ : ∀ {t₁ t₂ t₃ t₄ v₁ v₂ v₃ v₄} → (•[ t₁ , v₁ ] ⟷ •[ t₃ , v₃ ]) → (•[ t₂ , v₂ ] ⟷ •[ t₄ , v₄ ]) → (•[ PLUS t₁ t₂ , inj₁ v₁ ] ⟷ •[ PLUS t₃ t₄ , inj₁ v₃ ]) _⊕2_ : ∀ {t₁ t₂ t₃ t₄ v₁ v₂ v₃ v₄} → (•[ t₁ , v₁ ] ⟷ •[ t₃ , v₃ ]) → (•[ t₂ , v₂ ] ⟷ •[ t₄ , v₄ ]) → (•[ PLUS t₁ t₂ , inj₂ v₂ ] ⟷ •[ PLUS t₃ t₄ , inj₂ v₄ ]) _⊗_ : ∀ {t₁ t₂ t₃ t₄ v₁ v₂ v₃ v₄} → (•[ t₁ , v₁ ] ⟷ •[ t₃ , v₃ ]) → (•[ t₂ , v₂ ] ⟷ •[ t₄ , v₄ ]) → (•[ TIMES t₁ t₂ , (v₁ , v₂) ] ⟷ •[ TIMES t₃ t₄ , (v₃ , v₄) ]) loop : ∀ {t v} → •[ t , v ] ⟷ •[ t , v ] ! : {t₁ t₂ : U•} → (t₁ ⟷ t₂) → (t₂ ⟷ t₁) ! unite₊ = uniti₊ ! uniti₊ = unite₊ ! swap1₊ = swap2₊ ! swap2₊ = swap1₊ ! assocl1₊ = assocr1₊ ! assocl2₊ = assocr2₊ ! assocl3₊ = assocr3₊ ! assocr1₊ = assocl1₊ ! assocr2₊ = assocl2₊ ! assocr3₊ = assocl3₊ ! unite⋆ = uniti⋆ ! uniti⋆ = unite⋆ ! swap⋆ = swap⋆ ! assocl⋆ = assocr⋆ ! assocr⋆ = assocl⋆ ! distz = factorz ! factorz = distz ! dist1 = factor1 ! dist2 = factor2 ! factor1 = dist1 ! factor2 = dist2 ! id⟷ = id⟷ ! (c₁ ◎ c₂) = ! c₂ ◎ ! c₁ ! (c₁ ⊕1 c₂) = ! c₁ ⊕1 ! c₂ ! (c₁ ⊕2 c₂) = ! c₁ ⊕2 ! c₂ ! (c₁ ⊗ c₂) = ! c₁ ⊗ ! c₂ ! loop = loop -- example programs NOT•T : •[ BOOL , TRUE ] ⟷ •[ BOOL , FALSE ] NOT•T = swap1₊ NOT•F : •[ BOOL , FALSE ] ⟷ •[ BOOL , TRUE ] NOT•F = swap2₊ CNOT•Fx : {b : ⟦ BOOL ⟧} → •[ BOOL² , (FALSE , b) ] ⟷ •[ BOOL² , (FALSE , b) ] CNOT•Fx = dist2 ◎ ((id⟷ ⊗ NOT•F) ⊕2 id⟷) ◎ factor2 CNOT•TF : •[ BOOL² , (TRUE , FALSE) ] ⟷ •[ BOOL² , (TRUE , TRUE) ] CNOT•TF = dist1 ◎ ((id⟷ ⊗ NOT•F) ⊕1 (id⟷ {TIMES ONE BOOL} {(tt , TRUE)})) ◎ factor1 CNOT•TT : •[ BOOL² , (TRUE , TRUE) ] ⟷ •[ BOOL² , (TRUE , FALSE) ] CNOT•TT = dist1 ◎ ((id⟷ ⊗ NOT•T) ⊕1 (id⟷ {TIMES ONE BOOL} {(tt , TRUE)})) ◎ factor1 -- The evaluation of a program is not done in order to figure out the output -- value. Both the input and output values are encoded in the type of the -- program; what the evaluation does is follow the path to constructively -- reach the ouput value from the input value. Even though programs of the -- same pointed types are, by definition, observationally equivalent, they -- may follow different paths. At this point, we simply declare that all such -- programs are "the same." At the next level, we will weaken this "path -- irrelevant" equivalence and reason about which paths can be equated to -- other paths via 2paths etc. -- Even though individual types are sets, the universe of types is a -- groupoid. The objects of this groupoid are the pointed types; the -- morphisms are the programs; and the equivalence of programs is the -- degenerate observational equivalence that equates every two programs that -- are extensionally equivalent. _obs≅_ : {t₁ t₂ : U•} → (c₁ c₂ : t₁ ⟷ t₂) → Set c₁ obs≅ c₂ = ⊤ UG : 1Groupoid UG = record { set = U• ; _↝_ = _⟷_ ; _≈_ = _obs≅_ ; id = id⟷ ; _∘_ = λ y⟷z x⟷y → x⟷y ◎ y⟷z ; _⁻¹ = ! ; lneutr = λ _ → tt ; rneutr = λ _ → tt ; assoc = λ _ _ _ → tt ; equiv = record { refl = tt ; sym = λ _ → tt ; trans = λ _ _ → tt } ; linv = λ _ → tt ; rinv = λ _ → tt ; ∘-resp-≈ = λ _ _ → tt } ------------------------------------------------------------------------------ -- Level 1: -- Types are sets of paths. The paths are defined at the previous level -- (level 0). At level 1, there is no interesting 2path structure. From -- the perspective of level 0, we have points with non-trivial paths between -- them, i.e., we have a groupoid. The paths cross type boundaries, i.e., we -- have heterogeneous equality -- types data 1U : Set where 1ZERO : 1U -- empty set of paths 1ONE : 1U -- a trivial path 1PLUS : 1U → 1U → 1U -- disjoint union of paths 1TIMES : 1U → 1U → 1U -- pairs of paths PATH : (t₁ t₂ : U•) → 1U -- level 0 paths between values -- values data Path (t₁ t₂ : U•) : Set where path : (c : t₁ ⟷ t₂) → Path t₁ t₂ 1⟦_⟧ : 1U → Set 1⟦ 1ZERO ⟧ = ⊥ 1⟦ 1ONE ⟧ = ⊤ 1⟦ 1PLUS t₁ t₂ ⟧ = 1⟦ t₁ ⟧ ⊎ 1⟦ t₂ ⟧ 1⟦ 1TIMES t₁ t₂ ⟧ = 1⟦ t₁ ⟧ × 1⟦ t₂ ⟧ 1⟦ PATH t₁ t₂ ⟧ = Path t₁ t₂ -- examples T⟷F : Set T⟷F = Path BOOL•T BOOL•F F⟷T : Set F⟷T = Path BOOL•F BOOL•T -- all the following are paths from T to F; we will show below that they -- are equivalent using 2paths p₁ p₂ p₃ p₄ p₅ : T⟷F p₁ = path NOT•T p₂ = path (id⟷ ◎ NOT•T) p₃ = path (NOT•T ◎ NOT•F ◎ NOT•T) p₄ = path (NOT•T ◎ id⟷) p₅ = path (uniti⋆ ◎ swap⋆ ◎ (NOT•T ⊗ id⟷) ◎ swap⋆ ◎ unite⋆) p₆ : (T⟷F × T⟷F) ⊎ F⟷T p₆ = inj₁ (p₁ , p₂) -- Programs map paths to paths. We also use pointed types. record 1U• : Set where constructor 1•[_,_] field 1∣_∣ : 1U 1• : 1⟦ 1∣_∣ ⟧ open 1U• data _⇔_ : 1U• → 1U• → Set where unite₊ : ∀ {t v} → 1•[ 1PLUS 1ZERO t , inj₂ v ] ⇔ 1•[ t , v ] uniti₊ : ∀ {t v} → 1•[ t , v ] ⇔ 1•[ 1PLUS 1ZERO t , inj₂ v ] swap1₊ : ∀ {t₁ t₂ v₁} → 1•[ 1PLUS t₁ t₂ , inj₁ v₁ ] ⇔ 1•[ 1PLUS t₂ t₁ , inj₂ v₁ ] swap2₊ : ∀ {t₁ t₂ v₂} → 1•[ 1PLUS t₁ t₂ , inj₂ v₂ ] ⇔ 1•[ 1PLUS t₂ t₁ , inj₁ v₂ ] assocl1₊ : ∀ {t₁ t₂ t₃ v₁} → 1•[ 1PLUS t₁ (1PLUS t₂ t₃) , inj₁ v₁ ] ⇔ 1•[ 1PLUS (1PLUS t₁ t₂) t₃ , inj₁ (inj₁ v₁) ] assocl2₊ : ∀ {t₁ t₂ t₃ v₂} → 1•[ 1PLUS t₁ (1PLUS t₂ t₃) , inj₂ (inj₁ v₂) ] ⇔ 1•[ 1PLUS (1PLUS t₁ t₂) t₃ , inj₁ (inj₂ v₂) ] assocl3₊ : ∀ {t₁ t₂ t₃ v₃} → 1•[ 1PLUS t₁ (1PLUS t₂ t₃) , inj₂ (inj₂ v₃) ] ⇔ 1•[ 1PLUS (1PLUS t₁ t₂) t₃ , inj₂ v₃ ] assocr1₊ : ∀ {t₁ t₂ t₃ v₁} → 1•[ 1PLUS (1PLUS t₁ t₂) t₃ , inj₁ (inj₁ v₁) ] ⇔ 1•[ 1PLUS t₁ (1PLUS t₂ t₃) , inj₁ v₁ ] assocr2₊ : ∀ {t₁ t₂ t₃ v₂} → 1•[ 1PLUS (1PLUS t₁ t₂) t₃ , inj₁ (inj₂ v₂) ] ⇔ 1•[ 1PLUS t₁ (1PLUS t₂ t₃) , inj₂ (inj₁ v₂) ] assocr3₊ : ∀ {t₁ t₂ t₃ v₃} → 1•[ 1PLUS (1PLUS t₁ t₂) t₃ , inj₂ v₃ ] ⇔ 1•[ 1PLUS t₁ (1PLUS t₂ t₃) , inj₂ (inj₂ v₃) ] unite⋆ : ∀ {t v} → 1•[ 1TIMES 1ONE t , (tt , v) ] ⇔ 1•[ t , v ] uniti⋆ : ∀ {t v} → 1•[ t , v ] ⇔ 1•[ 1TIMES 1ONE t , (tt , v) ] swap⋆ : ∀ {t₁ t₂ v₁ v₂} → 1•[ 1TIMES t₁ t₂ , (v₁ , v₂) ] ⇔ 1•[ 1TIMES t₂ t₁ , (v₂ , v₁) ] assocl⋆ : ∀ {t₁ t₂ t₃ v₁ v₂ v₃} → 1•[ 1TIMES t₁ (1TIMES t₂ t₃) , (v₁ , (v₂ , v₃)) ] ⇔ 1•[ 1TIMES (1TIMES t₁ t₂) t₃ , ((v₁ , v₂) , v₃) ] assocr⋆ : ∀ {t₁ t₂ t₃ v₁ v₂ v₃} → 1•[ 1TIMES (1TIMES t₁ t₂) t₃ , ((v₁ , v₂) , v₃) ] ⇔ 1•[ 1TIMES t₁ (1TIMES t₂ t₃) , (v₁ , (v₂ , v₃)) ] distz : ∀ {t v absurd} → 1•[ 1TIMES 1ZERO t , (absurd , v) ] ⇔ 1•[ 1ZERO , absurd ] factorz : ∀ {t v absurd} → 1•[ 1ZERO , absurd ] ⇔ 1•[ 1TIMES 1ZERO t , (absurd , v) ] dist1 : ∀ {t₁ t₂ t₃ v₁ v₃} → 1•[ 1TIMES (1PLUS t₁ t₂) t₃ , (inj₁ v₁ , v₃) ] ⇔ 1•[ 1PLUS (1TIMES t₁ t₃) (1TIMES t₂ t₃) , inj₁ (v₁ , v₃) ] dist2 : ∀ {t₁ t₂ t₃ v₂ v₃} → 1•[ 1TIMES (1PLUS t₁ t₂) t₃ , (inj₂ v₂ , v₃) ] ⇔ 1•[ 1PLUS (1TIMES t₁ t₃) (1TIMES t₂ t₃) , inj₂ (v₂ , v₃) ] factor1 : ∀ {t₁ t₂ t₃ v₁ v₃} → 1•[ 1PLUS (1TIMES t₁ t₃) (1TIMES t₂ t₃) , inj₁ (v₁ , v₃) ] ⇔ 1•[ 1TIMES (1PLUS t₁ t₂) t₃ , (inj₁ v₁ , v₃) ] factor2 : ∀ {t₁ t₂ t₃ v₂ v₃} → 1•[ 1PLUS (1TIMES t₁ t₃) (1TIMES t₂ t₃) , inj₂ (v₂ , v₃) ] ⇔ 1•[ 1TIMES (1PLUS t₁ t₂) t₃ , (inj₂ v₂ , v₃) ] id⇔ : ∀ {t v} → 1•[ t , v ] ⇔ 1•[ t , v ] _◎_ : ∀ {t₁ t₂ t₃ v₁ v₂ v₃} → (1•[ t₁ , v₁ ] ⇔ 1•[ t₂ , v₂ ]) → (1•[ t₂ , v₂ ] ⇔ 1•[ t₃ , v₃ ]) → (1•[ t₁ , v₁ ] ⇔ 1•[ t₃ , v₃ ]) _⊕1_ : ∀ {t₁ t₂ t₃ t₄ v₁ v₂ v₃ v₄} → (1•[ t₁ , v₁ ] ⇔ 1•[ t₃ , v₃ ]) → (1•[ t₂ , v₂ ] ⇔ 1•[ t₄ , v₄ ]) → (1•[ 1PLUS t₁ t₂ , inj₁ v₁ ] ⇔ 1•[ 1PLUS t₃ t₄ , inj₁ v₃ ]) _⊕2_ : ∀ {t₁ t₂ t₃ t₄ v₁ v₂ v₃ v₄} → (1•[ t₁ , v₁ ] ⇔ 1•[ t₃ , v₃ ]) → (1•[ t₂ , v₂ ] ⇔ 1•[ t₄ , v₄ ]) → (1•[ 1PLUS t₁ t₂ , inj₂ v₂ ] ⇔ 1•[ 1PLUS t₃ t₄ , inj₂ v₄ ]) _⊗_ : ∀ {t₁ t₂ t₃ t₄ v₁ v₂ v₃ v₄} → (1•[ t₁ , v₁ ] ⇔ 1•[ t₃ , v₃ ]) → (1•[ t₂ , v₂ ] ⇔ 1•[ t₄ , v₄ ]) → (1•[ 1TIMES t₁ t₂ , (v₁ , v₂) ] ⇔ 1•[ 1TIMES t₃ t₄ , (v₃ , v₄) ]) lidl : ∀ {t₁ t₂} → {c : t₁ ⟷ t₂} → 1•[ PATH t₁ t₂ , path (id⟷ ◎ c) ] ⇔ 1•[ PATH t₁ t₂ , path c ] lidr : ∀ {t₁ t₂} → {c : t₁ ⟷ t₂} → 1•[ PATH t₁ t₂ , path c ] ⇔ 1•[ PATH t₁ t₂ , path (id⟷ ◎ c) ] ridl : ∀ {t₁ t₂} → {c : t₁ ⟷ t₂} → 1•[ PATH t₁ t₂ , path (c ◎ id⟷) ] ⇔ 1•[ PATH t₁ t₂ , path c ] ridr : ∀ {t₁ t₂} → {c : t₁ ⟷ t₂} → 1•[ PATH t₁ t₂ , path c ] ⇔ 1•[ PATH t₁ t₂ , path (c ◎ id⟷) ] assocl : ∀ {t₁ t₂ t₃ t₄} → {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} → 1•[ PATH t₁ t₄ , path (c₁ ◎ (c₂ ◎ c₃)) ] ⇔ 1•[ PATH t₁ t₄ , path ((c₁ ◎ c₂) ◎ c₃) ] assocr : ∀ {t₁ t₂ t₃ t₄} → {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} → 1•[ PATH t₁ t₄ , path ((c₁ ◎ c₂) ◎ c₃) ] ⇔ 1•[ PATH t₁ t₄ , path (c₁ ◎ (c₂ ◎ c₃)) ] unit₊l : ∀ {t v} → 1•[ PATH (•[ PLUS ZERO t , inj₂ v ]) (•[ PLUS ZERO t , inj₂ v ]) , path (unite₊ ◎ uniti₊) ] ⇔ 1•[ PATH (•[ PLUS ZERO t , inj₂ v ]) (•[ PLUS ZERO t , inj₂ v ]) , path id⟷ ] unit₊r : ∀ {t v} → 1•[ PATH (•[ PLUS ZERO t , inj₂ v ]) (•[ PLUS ZERO t , inj₂ v ]) , path id⟷ ] ⇔ 1•[ PATH (•[ PLUS ZERO t , inj₂ v ]) (•[ PLUS ZERO t , inj₂ v ]) , path (unite₊ ◎ uniti₊) ] resp◎ : ∀ {t₁ t₂ t₃} → {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₁ ⟷ t₂} {c₄ : t₂ ⟷ t₃} → (1•[ PATH t₁ t₂ , path c₁ ] ⇔ 1•[ PATH t₁ t₂ , path c₃ ]) → (1•[ PATH t₂ t₃ , path c₂ ] ⇔ 1•[ PATH t₂ t₃ , path c₄ ]) → 1•[ PATH t₁ t₃ , path (c₁ ◎ c₂) ] ⇔ 1•[ PATH t₁ t₃ , path (c₃ ◎ c₄) ] 1! : {t₁ t₂ : 1U•} → (t₁ ⇔ t₂) → (t₂ ⇔ t₁) 1! unite₊ = uniti₊ 1! uniti₊ = unite₊ 1! swap1₊ = swap2₊ 1! swap2₊ = swap1₊ 1! assocl1₊ = assocr1₊ 1! assocl2₊ = assocr2₊ 1! assocl3₊ = assocr3₊ 1! assocr1₊ = assocl1₊ 1! assocr2₊ = assocl2₊ 1! assocr3₊ = assocl3₊ 1! unite⋆ = uniti⋆ 1! uniti⋆ = unite⋆ 1! swap⋆ = swap⋆ 1! assocl⋆ = assocr⋆ 1! assocr⋆ = assocl⋆ 1! distz = factorz 1! factorz = distz 1! dist1 = factor1 1! dist2 = factor2 1! factor1 = dist1 1! factor2 = dist2 1! id⇔ = id⇔ 1! (c₁ ◎ c₂) = 1! c₂ ◎ 1! c₁ 1! (c₁ ⊕1 c₂) = 1! c₁ ⊕1 1! c₂ 1! (c₁ ⊕2 c₂) = 1! c₁ ⊕2 1! c₂ 1! (c₁ ⊗ c₂) = 1! c₁ ⊗ 1! c₂ 1! (resp◎ c₁ c₂) = resp◎ (1! c₁) (1! c₂) 1! ridl = ridr 1! ridr = ridl 1! lidl = lidr 1! lidr = lidl 1! assocl = assocr 1! assocr = assocl 1! unit₊l = unit₊r 1! unit₊r = unit₊l 1!≡ : {t₁ t₂ : 1U•} → (c : t₁ ⇔ t₂) → 1! (1! c) ≡ c 1!≡ unite₊ = refl 1!≡ uniti₊ = refl 1!≡ swap1₊ = refl 1!≡ swap2₊ = refl 1!≡ assocl1₊ = refl 1!≡ assocl2₊ = refl 1!≡ assocl3₊ = refl 1!≡ assocr1₊ = refl 1!≡ assocr2₊ = refl 1!≡ assocr3₊ = refl 1!≡ unite⋆ = refl 1!≡ uniti⋆ = refl 1!≡ swap⋆ = refl 1!≡ assocl⋆ = refl 1!≡ assocr⋆ = refl 1!≡ distz = refl 1!≡ factorz = refl 1!≡ dist1 = refl 1!≡ dist2 = refl 1!≡ factor1 = refl 1!≡ factor2 = refl 1!≡ id⇔ = refl 1!≡ (c₁ ◎ c₂) = cong₂ (λ c₁ c₂ → c₁ ◎ c₂) (1!≡ c₁) (1!≡ c₂) 1!≡ (c₁ ⊕1 c₂) = cong₂ (λ c₁ c₂ → c₁ ⊕1 c₂) (1!≡ c₁) (1!≡ c₂) 1!≡ (c₁ ⊕2 c₂) = cong₂ (λ c₁ c₂ → c₁ ⊕2 c₂) (1!≡ c₁) (1!≡ c₂) 1!≡ (c₁ ⊗ c₂) = cong₂ (λ c₁ c₂ → c₁ ⊗ c₂) (1!≡ c₁) (1!≡ c₂) 1!≡ lidl = refl 1!≡ lidr = refl 1!≡ ridl = refl 1!≡ ridr = refl 1!≡ (resp◎ c₁ c₂) = cong₂ (λ c₁ c₂ → resp◎ c₁ c₂) (1!≡ c₁) (1!≡ c₂) 1!≡ assocl = refl 1!≡ assocr = refl 1!≡ unit₊l = refl 1!≡ unit₊r = refl -- sane syntax α₁ : 1•[ PATH BOOL•T BOOL•F , p₁ ] ⇔ 1•[ PATH BOOL•T BOOL•F , p₁ ] α₁ = id⇔ α₂ : 1•[ PATH BOOL•T BOOL•F , p₁ ] ⇔ 1•[ PATH BOOL•T BOOL•F , p₂ ] α₂ = lidr {-- _≡⟨_⟩_ : {t₁ t₂ : U•} (c₁ : t₁ ⟷ t₂) {c₂ : t₁ ⟷ t₂} {c₃ : t₁ ⟷ t₂} → (2•[ PATH c₁ , path c₁ ] ⇔ 2•[ PATH c₂ , path c₂ ]) → (2•[ PATH c₂ , path c₂ ] ⇔ 2•[ PATH c₃ , path c₃ ]) → (2•[ PATH c₁ , path c₁ ] ⇔ 2•[ PATH c₃ , path c₃ ]) _ ≡⟨ α ⟩ β = α ◎ β _∎ : {t₁ t₂ : U•} → (c : t₁ ⟷ t₂) → 2•[ PATH c , path c ] ⇔ 2•[ PATH c , path c ] _∎ c = id⟷ --} -- example programs -- level 0 is a groupoid with a non-trivial path equivalence the various inv* -- rules are not justified by the groupoid proof; they are justified by the -- need for computational rules. So it is important to have not just a -- groupoid structure but a groupoid structure that we can compute with. So -- if we say that we want p ◎ p⁻¹ to be id, we must have computational rules -- that allow us to derive this for any path p, and similarly for all the -- other groupoid rules. (cf. The canonicity for 2D type theory by Licata and -- Harper) linv : {t₁ t₂ : U•} → (c : t₁ ⟷ t₂) → 1•[ PATH t₁ t₁ , path (c ◎ ! c) ] ⇔ 1•[ PATH t₁ t₁ , path id⟷ ] linv unite₊ = unit₊l linv uniti₊ = {!!} linv swap1₊ = {!!} linv swap2₊ = {!!} linv assocl1₊ = {!!} linv assocl2₊ = {!!} linv assocl3₊ = {!!} linv assocr1₊ = {!!} linv assocr2₊ = {!!} linv assocr3₊ = {!!} linv unite⋆ = {!!} linv uniti⋆ = {!!} linv swap⋆ = {!!} linv assocl⋆ = {!!} linv assocr⋆ = {!!} linv distz = {!!} linv factorz = {!!} linv dist1 = {!!} linv dist2 = {!!} linv factor1 = {!!} linv factor2 = {!!} linv id⟷ = {!!} linv (c ◎ c₁) = {!!} linv (c ⊕1 c₁) = {!!} linv (c ⊕2 c₁) = {!!} linv (c ⊗ c₁) = {!!} linv loop = {!!} G : 1Groupoid G = record { set = U• ; _↝_ = _⟷_ ; _≈_ = λ {t₁} {t₂} c₀ c₁ → 1•[ PATH t₁ t₂ , path c₀ ] ⇔ 1•[ PATH t₁ t₂ , path c₁ ] ; id = id⟷ ; _∘_ = λ c₀ c₁ → c₁ ◎ c₀ ; _⁻¹ = ! ; lneutr = λ _ → ridl ; rneutr = λ _ → lidl ; assoc = λ _ _ _ → assocl ; equiv = record { refl = id⇔ ; sym = λ c → 1! c ; trans = λ c₀ c₁ → c₀ ◎ c₁ } ; linv = λ {t₁} {t₂} c → linv c ; rinv = λ {t₁} {t₂} c → {!!} ; ∘-resp-≈ = λ f⟷h g⟷i → resp◎ g⟷i f⟷h } ------------------------------------------------------------------------------
algebraic-stack_agda0000_doc_8724
{-# OPTIONS --without-K --safe #-} -- A Categorical WeakInverse induces an Adjoint Equivalence module Categories.Category.Equivalence.Properties where open import Level open import Data.Product using (Σ-syntax; _,_; proj₁) open import Categories.Adjoint.Equivalence using (⊣Equivalence) open import Categories.Adjoint open import Categories.Adjoint.TwoSided using (_⊣⊢_; withZig) open import Categories.Category open import Categories.Category.Equivalence using (WeakInverse; StrongEquivalence) open import Categories.Morphism import Categories.Morphism.Reasoning as MR import Categories.Morphism.Properties as MP open import Categories.Functor renaming (id to idF) open import Categories.Functor.Properties using ([_]-resp-Iso) open import Categories.NaturalTransformation using (ntHelper; _∘ᵥ_; _∘ˡ_; _∘ʳ_) open import Categories.NaturalTransformation.NaturalIsomorphism as ≃ using (NaturalIsomorphism ; unitorˡ; unitorʳ; associator; _ⓘᵥ_; _ⓘˡ_; _ⓘʳ_) open import Categories.NaturalTransformation.NaturalIsomorphism.Properties using (pointwise-iso) private variable o ℓ e : Level C D E : Category o ℓ e module _ {F : Functor C D} {G : Functor D C} (W : WeakInverse F G) where open WeakInverse W private module C = Category C module D = Category D module F = Functor F module G = Functor G -- adjoint equivalence F⊣⊢G : F ⊣⊢ G F⊣⊢G = withZig record { unit = ≃.sym G∘F≈id ; counit = let open D open HomReasoning open MR D open MP D in record { F⇒G = ntHelper record { η = λ X → F∘G≈id.⇒.η X ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ X)) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X)) ; commute = λ {X Y} f → begin (F∘G≈id.⇒.η Y ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ Y)) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ Y))) ∘ F.F₁ (G.F₁ f) ≈⟨ pull-last (F∘G≈id.⇐.commute (F.F₁ (G.F₁ f))) ⟩ F∘G≈id.⇒.η Y ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ Y)) ∘ (F.F₁ (G.F₁ (F.F₁ (G.F₁ f))) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X))) ≈˘⟨ refl⟩∘⟨ pushˡ F.homomorphism ⟩ F∘G≈id.⇒.η Y ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ Y) C.∘ G.F₁ (F.F₁ (G.F₁ f))) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X)) ≈⟨ refl⟩∘⟨ F.F-resp-≈ (G∘F≈id.⇒.commute (G.F₁ f)) ⟩∘⟨refl ⟩ F∘G≈id.⇒.η Y ∘ F.F₁ (G.F₁ f C.∘ G∘F≈id.⇒.η (G.F₀ X)) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X)) ≈⟨ refl⟩∘⟨ F.homomorphism ⟩∘⟨refl ⟩ F∘G≈id.⇒.η Y ∘ (F.F₁ (G.F₁ f) ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ X))) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X)) ≈⟨ center⁻¹ (F∘G≈id.⇒.commute f) Equiv.refl ⟩ (f ∘ F∘G≈id.⇒.η X) ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ X)) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X)) ≈⟨ assoc ⟩ f ∘ F∘G≈id.⇒.η X ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ X)) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X)) ∎ } ; F⇐G = ntHelper record { η = λ X → (F∘G≈id.⇒.η (F.F₀ (G.F₀ X)) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ X))) ∘ F∘G≈id.⇐.η X ; commute = λ {X Y} f → begin ((F∘G≈id.⇒.η (F.F₀ (G.F₀ Y)) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ Y))) ∘ F∘G≈id.⇐.η Y) ∘ f ≈⟨ pullʳ (F∘G≈id.⇐.commute f) ⟩ (F∘G≈id.⇒.η (F.F₀ (G.F₀ Y)) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ Y))) ∘ F.F₁ (G.F₁ f) ∘ F∘G≈id.⇐.η X ≈⟨ center (⟺ F.homomorphism) ⟩ F∘G≈id.⇒.η (F.F₀ (G.F₀ Y)) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ Y) C.∘ G.F₁ f) ∘ F∘G≈id.⇐.η X ≈⟨ refl⟩∘⟨ F.F-resp-≈ (G∘F≈id.⇐.commute (G.F₁ f)) ⟩∘⟨refl ⟩ F∘G≈id.⇒.η (F.F₀ (G.F₀ Y)) ∘ F.F₁ (G.F₁ (F.F₁ (G.F₁ f)) C.∘ G∘F≈id.⇐.η (G.F₀ X)) ∘ F∘G≈id.⇐.η X ≈⟨ refl⟩∘⟨ F.homomorphism ⟩∘⟨refl ⟩ F∘G≈id.⇒.η (F.F₀ (G.F₀ Y)) ∘ (F.F₁ (G.F₁ (F.F₁ (G.F₁ f))) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ X))) ∘ F∘G≈id.⇐.η X ≈⟨ center⁻¹ (F∘G≈id.⇒.commute _) Equiv.refl ⟩ (F.F₁ (G.F₁ f) ∘ F∘G≈id.⇒.η (F.F₀ (G.F₀ X))) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ X)) ∘ F∘G≈id.⇐.η X ≈⟨ center Equiv.refl ⟩ F.F₁ (G.F₁ f) ∘ (F∘G≈id.⇒.η (F.F₀ (G.F₀ X)) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ X))) ∘ F∘G≈id.⇐.η X ∎ } ; iso = λ X → Iso-∘ (Iso-∘ (Iso-swap (F∘G≈id.iso _)) ([ F ]-resp-Iso (G∘F≈id.iso _))) (F∘G≈id.iso X) } ; zig = λ {A} → let open D open HomReasoning open MR D in begin (F∘G≈id.⇒.η (F.F₀ A) ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ (F.F₀ A))) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ (F.F₀ A)))) ∘ F.F₁ (G∘F≈id.⇐.η A) ≈⟨ pull-last (F∘G≈id.⇐.commute (F.F₁ (G∘F≈id.⇐.η A))) ⟩ F∘G≈id.⇒.η (F.F₀ A) ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ (F.F₀ A))) ∘ F.F₁ (G.F₁ (F.F₁ (G∘F≈id.⇐.η A))) ∘ F∘G≈id.⇐.η (F.F₀ A) ≈˘⟨ refl⟩∘⟨ pushˡ F.homomorphism ⟩ F∘G≈id.⇒.η (F.F₀ A) ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ (F.F₀ A)) C.∘ G.F₁ (F.F₁ (G∘F≈id.⇐.η A))) ∘ F∘G≈id.⇐.η (F.F₀ A) ≈⟨ refl⟩∘⟨ F.F-resp-≈ (G∘F≈id.⇒.commute (G∘F≈id.⇐.η A)) ⟩∘⟨refl ⟩ F∘G≈id.⇒.η (F.F₀ A) ∘ F.F₁ (G∘F≈id.⇐.η A C.∘ G∘F≈id.⇒.η A) ∘ F∘G≈id.⇐.η (F.F₀ A) ≈⟨ refl⟩∘⟨ elimˡ ((F.F-resp-≈ (G∘F≈id.iso.isoˡ _)) ○ F.identity) ⟩ F∘G≈id.⇒.η (F.F₀ A) ∘ F∘G≈id.⇐.η (F.F₀ A) ≈⟨ F∘G≈id.iso.isoʳ _ ⟩ id ∎ } module F⊣⊢G = _⊣⊢_ F⊣⊢G module _ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (SE : StrongEquivalence C D) where open StrongEquivalence SE C≅D : ⊣Equivalence C D C≅D = record { L = F ; R = G ; L⊣⊢R = F⊣⊢G weak-inverse } module C≅D = ⊣Equivalence C≅D module _ {F : Functor C D} {G : Functor D C} (F⊣G : F ⊣ G) where private module C = Category C module D = Category D module F = Functor F module G = Functor G open Adjoint F⊣G -- If the unit and the counit of an adjuction are pointwise isomorphisms, then they form an equivalence of categories. pointwise-iso-equivalence : (∀ X → Σ[ f ∈ D [ X , F.F₀ (G.F₀ X) ] ] Iso D (counit.η X) f) → (∀ X → Σ[ f ∈ C [ G.F₀ (F.F₀ X) , X ] ] Iso C (unit.η X) f) → WeakInverse F G pointwise-iso-equivalence counit-iso unit-iso = record { F∘G≈id = let iso X = let (to , is-iso) = counit-iso X in record { from = counit.η X ; to = to ; iso = is-iso } in pointwise-iso iso counit.commute ; G∘F≈id = let iso X = let (to , is-iso) = unit-iso X in record { from = unit.η X ; to = to ; iso = is-iso } in ≃.sym (pointwise-iso iso unit.commute) }
algebraic-stack_agda0000_doc_8725
-- Andreas, 2019-08-08, issue #3972 (and #3967) -- In the presence of an unreachable clause, the serializer crashed on a unsolve meta. -- It seems this issue was fixed along #3966: only the ranges of unreachable clauses -- are now serialized. open import Agda.Builtin.Equality public postulate List : Set → Set data Coo {A} (xs : List A) : Set where coo : Coo xs → Coo xs test : {A : Set} (xs : List A) (z : Coo xs) → Set₁ test xs z = cs xs z refl where cs : (xs : List _) -- filling this meta _=A removes the internal error (z : Coo xs) (eq : xs ≡ xs) → Set₁ cs xs (coo z) refl = Set cs xs (coo z) eq = Set -- unreachable
algebraic-stack_agda0000_doc_8726
{-# OPTIONS --type-in-type #-} module functors where open import prelude record Category {O : Set} (𝒞[_,_] : O → O → Set) : Set where constructor 𝒾:_▸:_𝒾▸:_▸𝒾: infixl 8 _▸_ field 𝒾 : ∀ {x} → 𝒞[ x , x ] _▸_ : ∀ {x y z} → 𝒞[ x , y ] → 𝒞[ y , z ] → 𝒞[ x , z ] 𝒾▸ : ∀ {x y} (f : 𝒞[ x , y ]) → (𝒾 ▸ f) ≡ f ▸𝒾 : ∀ {x y} (f : 𝒞[ x , y ]) → (f ▸ 𝒾) ≡ f open Category ⦃...⦄ public record Functor {A : Set} {𝒜[_,_] : A → A → Set} {B : Set} {ℬ[_,_] : B → B → Set} (f : A → B) : Set where constructor φ:_𝒾:_▸: field ⦃ cat₁ ⦄ : Category {A} 𝒜[_,_] ⦃ cat₂ ⦄ : Category {B} ℬ[_,_] φ : ∀ {a b} → 𝒜[ a , b ] → ℬ[ f a , f b ] functor-id : ∀ {a} → φ {a} 𝒾 ≡ 𝒾 functor-comp : ∀ {A B C} → (f : 𝒜[ A , B ]) (g : 𝒜[ B , C ]) → φ (f ▸ g) ≡ φ f ▸ φ g open Functor ⦃...⦄ public record Nat {A : Set} {𝒜[_,_] : A → A → Set} {B : Set} {ℬ[_,_] : B → B → Set} {F : A → B} {G : A → B} (α : (x : A) → ℬ[ F x , G x ]) : Set where field overlap ⦃ fun₁ ⦄ : Functor {A} {𝒜[_,_]} {B} {ℬ[_,_]} F overlap ⦃ fun₂ ⦄ : Functor {A} {𝒜[_,_]} {B} {ℬ[_,_]} G nat : ∀ {x y : A} (f : 𝒜[ x , y ]) → let _▹_ = _▸_ ⦃ cat₂ ⦄ in φ f ▹ α y ≡ α x ▹ φ f module _ {A : Set} {𝒜[_,_] : A → A → Set} where instance id-functor : ⦃ Category 𝒜[_,_] ⦄ → Functor id id-functor = φ: id 𝒾: refl ▸: λ f g → refl record Monad (f : A → A) : Set where field ⦃ functor ⦄ : Functor {_} {𝒜[_,_]} {_} {𝒜[_,_]} f η : ∀ {a} → 𝒜[ a , f a ] μ : ∀ {a} → 𝒜[ f (f a) , f a ] open Monad ⦃...⦄ public {- record Lift[_⇒_] (pre post : (Set → Set) → Set) (t : (Set → Set) → Set → Set) : Set where field ⦃ lifted ⦄ : ∀ {f} → post (t f) lift : {f : Set → Set} {a : Set} → ⦃ pre f ⦄ → f a → t f a open Lift[_⇒_] ⦃...⦄ public -} Cat[_,_] : Set → Set → Set Cat[ a , b ] = a → b instance Cat-cat : Category Cat[_,_] Cat-cat = record { 𝒾 = id ; _▸_ = λ f g → g ∘ f ; 𝒾▸ = λ _ → refl; ▸𝒾 = λ _ → refl} instance ≡-cat : ∀ {A} → Category {A} (λ a b → a ≡ b) 𝒾 {{≡-cat}} = refl _▸_ {{≡-cat}} = trans 𝒾▸ {{≡-cat}} _ = refl ▸𝒾 {{≡-cat}} x≡y rewrite x≡y = refl instance ×-cat : ∀ {A 𝒜[_,_]} ⦃ 𝒜 : Category {A} 𝒜[_,_] ⦄ {B ℬ[_,_]} ⦃ ℬ : Category {B} ℬ[_,_] ⦄ → Category {A × B} (λ (a , b) (a′ , b′) → 𝒜[ a , a′ ] × ℬ[ b , b′ ]) 𝒾 {{×-cat}} = 𝒾 , 𝒾 _▸_ {{×-cat}} (f , f′ ) ( g , g′ ) = f ▸ g , f′ ▸ g′ 𝒾▸ {{×-cat}} (f , g) = 𝒾▸ f ×⁼ 𝒾▸ g ▸𝒾 {{×-cat}} (f , g) = ▸𝒾 f ×⁼ ▸𝒾 g data _ᵒᵖ {A : Set} (𝒜 : A → A → Set) : A → A → Set where _ᵗ : ∀ {y x} → 𝒜(y )( x) → (𝒜 ᵒᵖ)(x )( y) instance op-cat : {A : Set} {𝒜[_,_] : A → A → Set} ⦃ 𝒜 : Category {A} 𝒜[_,_] ⦄ → Category (𝒜[_,_] ᵒᵖ) 𝒾 {{op-cat}} = 𝒾 ᵗ _▸_ {{op-cat}} (f ᵗ) (g ᵗ) = (g ▸ f) ᵗ 𝒾▸ {{op-cat}} (f ᵗ) = _ᵗ ⟨$⟩ ▸𝒾 f ▸𝒾 {{op-cat}} (f ᵗ) = _ᵗ ⟨$⟩ 𝒾▸ f
algebraic-stack_agda0000_doc_8727
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Properties.Neutral {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.Weakening open import Definition.LogicalRelation open import Definition.LogicalRelation.ShapeView open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.Properties.Reflexivity open import Definition.LogicalRelation.Properties.Escape open import Definition.LogicalRelation.Properties.Symmetry open import Tools.Embedding open import Tools.Product import Tools.PropositionalEquality as PE -- Neutral reflexive types are reducible. neu : ∀ {l Γ A} (neA : Neutral A) → Γ ⊢ A → Γ ⊢ A ~ A ∷ U → Γ ⊩⟨ l ⟩ A neu neA A A~A = ne′ _ (idRed:*: A) neA A~A -- Helper function for reducible neutral equality of a specific type of derivation. neuEq′ : ∀ {l Γ A B} ([A] : Γ ⊩⟨ l ⟩ne A) (neA : Neutral A) (neB : Neutral B) → Γ ⊢ A → Γ ⊢ B → Γ ⊢ A ~ B ∷ U → Γ ⊩⟨ l ⟩ A ≡ B / ne-intr [A] neuEq′ (noemb (ne K [ ⊢A , ⊢B , D ] neK K≡K)) neA neB A B A~B = let A≡K = whnfRed* D (ne neA) in ιx (ne₌ _ (idRed:*: B) neB (PE.subst (λ x → _ ⊢ x ~ _ ∷ _) A≡K A~B)) neuEq′ (emb 0<1 x) neA neB A B A~B = ιx (neuEq′ x neA neB A B A~B) -- Neutrally equal types are of reducible equality. neuEq : ∀ {l Γ A B} ([A] : Γ ⊩⟨ l ⟩ A) (neA : Neutral A) (neB : Neutral B) → Γ ⊢ A → Γ ⊢ B → Γ ⊢ A ~ B ∷ U → Γ ⊩⟨ l ⟩ A ≡ B / [A] neuEq [A] neA neB A B A~B = irrelevanceEq (ne-intr (ne-elim neA [A])) [A] (neuEq′ (ne-elim neA [A]) neA neB A B A~B) mutual -- Neutral reflexive terms are reducible. neuTerm : ∀ {l Γ A n} ([A] : Γ ⊩⟨ l ⟩ A) (neN : Neutral n) → Γ ⊢ n ∷ A → Γ ⊢ n ~ n ∷ A → Γ ⊩⟨ l ⟩ n ∷ A / [A] neuTerm (Uᵣ′ .⁰ 0<1 ⊢Γ) neN n n~n = Uₜ _ (idRedTerm:*: n) (ne neN) (~-to-≅ₜ n~n) (neu neN (univ n) n~n) neuTerm (ℕᵣ [ ⊢A , ⊢B , D ]) neN n n~n = let A≡ℕ = subset* D n~n′ = ~-conv n~n A≡ℕ n≡n = ~-to-≅ₜ n~n′ in ιx (ℕₜ _ (idRedTerm:*: (conv n A≡ℕ)) n≡n (ne (neNfₜ neN (conv n A≡ℕ) n~n′))) neuTerm (ne′ K [ ⊢A , ⊢B , D ] neK K≡K) neN n n~n = let A≡K = subset* D in ιx (neₜ _ (idRedTerm:*: (conv n A≡K)) (neNfₜ neN (conv n A≡K) (~-conv n~n A≡K))) neuTerm (Πᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) neN n n~n = let A≡ΠFG = subset* (red D) in Πₜ _ (idRedTerm:*: (conv n A≡ΠFG)) (ne neN) (~-to-≅ₜ (~-conv n~n A≡ΠFG)) (λ {ρ} [ρ] ⊢Δ [a] [b] [a≡b] → let A≡ΠFG = subset* (red D) ρA≡ρΠFG = wkEq [ρ] ⊢Δ (subset* (red D)) G[a]≡G[b] = escapeEq ([G] [ρ] ⊢Δ [b]) (symEq ([G] [ρ] ⊢Δ [a]) ([G] [ρ] ⊢Δ [b]) (G-ext [ρ] ⊢Δ [a] [b] [a≡b])) a = escapeTerm ([F] [ρ] ⊢Δ) [a] b = escapeTerm ([F] [ρ] ⊢Δ) [b] a≡b = escapeTermEq ([F] [ρ] ⊢Δ) [a≡b] ρn = conv (wkTerm [ρ] ⊢Δ n) ρA≡ρΠFG neN∘a = ∘ₙ (wkNeutral ρ neN) neN∘b = ∘ₙ (wkNeutral ρ neN) in neuEqTerm ([G] [ρ] ⊢Δ [a]) neN∘a neN∘b (ρn ∘ⱼ a) (conv (ρn ∘ⱼ b) (≅-eq G[a]≡G[b])) (~-app (~-wk [ρ] ⊢Δ (~-conv n~n A≡ΠFG)) a≡b)) (λ {ρ} [ρ] ⊢Δ [a] → let ρA≡ρΠFG = wkEq [ρ] ⊢Δ (subset* (red D)) a = escapeTerm ([F] [ρ] ⊢Δ) [a] a≡a = escapeTermEq ([F] [ρ] ⊢Δ) (reflEqTerm ([F] [ρ] ⊢Δ) [a]) in neuTerm ([G] [ρ] ⊢Δ [a]) (∘ₙ (wkNeutral ρ neN)) (conv (wkTerm [ρ] ⊢Δ n) ρA≡ρΠFG ∘ⱼ a) (~-app (~-wk [ρ] ⊢Δ (~-conv n~n A≡ΠFG)) a≡a)) neuTerm (emb′ 0<1 x) neN n n~n = ιx (neuTerm x neN n n~n) -- Neutrally equal terms are of reducible equality. neuEqTerm : ∀ {l Γ A n n′} ([A] : Γ ⊩⟨ l ⟩ A) (neN : Neutral n) (neN′ : Neutral n′) → Γ ⊢ n ∷ A → Γ ⊢ n′ ∷ A → Γ ⊢ n ~ n′ ∷ A → Γ ⊩⟨ l ⟩ n ≡ n′ ∷ A / [A] neuEqTerm (Uᵣ′ .⁰ 0<1 ⊢Γ) neN neN′ n n′ n~n′ = let [n] = neu neN (univ n) (~-trans n~n′ (~-sym n~n′)) [n′] = neu neN′ (univ n′) (~-trans (~-sym n~n′) n~n′) in Uₜ₌ _ _ (idRedTerm:*: n) (idRedTerm:*: n′) (ne neN) (ne neN′) (~-to-≅ₜ n~n′) [n] [n′] (neuEq [n] neN neN′ (univ n) (univ n′) n~n′) neuEqTerm (ℕᵣ [ ⊢A , ⊢B , D ]) neN neN′ n n′ n~n′ = let A≡ℕ = subset* D n~n′₁ = ~-conv n~n′ A≡ℕ n≡n′ = ~-to-≅ₜ n~n′₁ in ιx (ℕₜ₌ _ _ (idRedTerm:*: (conv n A≡ℕ)) (idRedTerm:*: (conv n′ A≡ℕ)) n≡n′ (ne (neNfₜ₌ neN neN′ n~n′₁))) neuEqTerm (ne′ K [ ⊢A , ⊢B , D ] neK K≡K) neN neN′ n n′ n~n′ = let A≡K = subset* D in ιx (neₜ₌ _ _ (idRedTerm:*: (conv n A≡K)) (idRedTerm:*: (conv n′ A≡K)) (neNfₜ₌ neN neN′ (~-conv n~n′ A≡K))) neuEqTerm (Πᵣ′ F G [ ⊢A , ⊢B , D ] ⊢F ⊢G A≡A [F] [G] G-ext) neN neN′ n n′ n~n′ = let [ΠFG] = Πᵣ′ F G [ ⊢A , ⊢B , D ] ⊢F ⊢G A≡A [F] [G] G-ext A≡ΠFG = subset* D n~n′₁ = ~-conv n~n′ A≡ΠFG n≡n′ = ~-to-≅ₜ n~n′₁ n~n = ~-trans n~n′ (~-sym n~n′) n′~n′ = ~-trans (~-sym n~n′) n~n′ in Πₜ₌ _ _ (idRedTerm:*: (conv n A≡ΠFG)) (idRedTerm:*: (conv n′ A≡ΠFG)) (ne neN) (ne neN′) n≡n′ (neuTerm [ΠFG] neN n n~n) (neuTerm [ΠFG] neN′ n′ n′~n′) (λ {ρ} [ρ] ⊢Δ [a] → let ρA≡ρΠFG = wkEq [ρ] ⊢Δ A≡ΠFG ρn = wkTerm [ρ] ⊢Δ n ρn′ = wkTerm [ρ] ⊢Δ n′ a = escapeTerm ([F] [ρ] ⊢Δ) [a] a≡a = escapeTermEq ([F] [ρ] ⊢Δ) (reflEqTerm ([F] [ρ] ⊢Δ) [a]) neN∙a = ∘ₙ (wkNeutral ρ neN) neN′∙a′ = ∘ₙ (wkNeutral ρ neN′) in neuEqTerm ([G] [ρ] ⊢Δ [a]) neN∙a neN′∙a′ (conv ρn ρA≡ρΠFG ∘ⱼ a) (conv ρn′ ρA≡ρΠFG ∘ⱼ a) (~-app (~-wk [ρ] ⊢Δ n~n′₁) a≡a)) neuEqTerm (emb′ 0<1 x) neN neN′ n n′ n~n′ = ιx (neuEqTerm x neN neN′ n n′ n~n′)
algebraic-stack_agda0000_doc_8728
{-# OPTIONS --without-K #-} -- Define all the permutations that occur in Pi -- These are defined by transport, using univalence module Permutation where open import Relation.Binary.PropositionalEquality using (_≡_; refl) open import Data.Nat using (_+_;_*_) open import Data.Fin using (Fin) open import Relation.Binary using (Setoid) open import Function.Equality using (_⟨$⟩_) open import Equiv using (_≃_; id≃; sym≃; trans≃; _●_) open import ConcretePermutation open import ConcretePermutationProperties open import SEquivSCPermEquiv open import FinEquivTypeEquiv using (module PlusE; module TimesE) open import EquivEquiv open import Proofs using ( -- FiniteFunctions finext ) infixr 5 _●p_ infix 8 _⊎p_ infixr 7 _×p_ ------------------------------------------------------------------------------ -- useful short-hands; these should all be moved elsewhere. e⇒p : ∀ {m n} → (Fin m ≃ Fin n) → CPerm m n e⇒p e = _≃S_.g univalence ⟨$⟩ e p⇒e : ∀ {m n} → CPerm m n → (Fin m ≃ Fin n) p⇒e p = _≃S_.f univalence ⟨$⟩ p αu : ∀ {m n} → {e f : Fin m ≃ Fin n} → e ≋ f → p⇒e (e⇒p e) ≋ f αu e≋f = _≃S_.α univalence e≋f βu : ∀ {m n} → {p q : CPerm m n} → p ≡ q → e⇒p (p⇒e p) ≡ q βu p≡q = _≃S_.β univalence p≡q α₁ : ∀ {m n} → {e : Fin m ≃ Fin n} → p⇒e (e⇒p e) ≋ e α₁ {e = e} = αu (id≋ {x = e}) -- Agda can infer here, but this helps later? -- inside an e⇒p, we can freely replace equivalences -- this expresses the fundamental property that equivalent equivalences -- map to THE SAME permutation. ≋⇒≡ : ∀ {m n} → {e₁ e₂ : Fin m ≃ Fin n} → e₁ ≋ e₂ → e⇒p e₁ ≡ e⇒p e₂ ≋⇒≡ {e₁} {e₂} (eq fwd bwd) = p≡ (finext bwd) -- combination of above, where we use αu on left/right of ● right-α-over-● : ∀ {m n o} → (e₁ : Fin n ≃ Fin o) → (e₂ : Fin m ≃ Fin n) → (e₁ ● (p⇒e (e⇒p e₂))) ≋ (e₁ ● e₂) right-α-over-● e₁ e₂ = (id≋ {x = e₁}) ◎ (αu {e = e₂} id≋) left-α-over-● : ∀ {m n o} → (e₁ : Fin n ≃ Fin o) → (e₂ : Fin m ≃ Fin n) → ((p⇒e (e⇒p e₁)) ● e₂) ≋ (e₁ ● e₂) left-α-over-● e₁ e₂ = (αu {e = e₁} id≋) ◎ (id≋ {x = e₂}) ------------------------------------------------------------------------------ -- zero permutation 0p : CPerm 0 0 0p = e⇒p (id≃ {A = Fin 0}) -- identity permutation idp : ∀ {n} → CPerm n n idp {n} = e⇒p (id≃ {A = Fin n}) -- disjoint union _⊎p_ : ∀ {m₁ m₂ n₁ n₂} → CPerm m₁ m₂ → CPerm n₁ n₂ → CPerm (m₁ + n₁) (m₂ + n₂) p₁ ⊎p p₂ = e⇒p ((p⇒e p₁) +F (p⇒e p₂)) where open PlusE -- cartesian product _×p_ : ∀ {m₁ m₂ n₁ n₂} → CPerm m₁ m₂ → CPerm n₁ n₂ → CPerm (m₁ * n₁) (m₂ * n₂) p₁ ×p p₂ = e⇒p ((p⇒e p₁) *F (p⇒e p₂)) where open TimesE -- symmetry symp : ∀ {m n} → CPerm m n → CPerm n m symp p = e⇒p (sym≃ (p⇒e p)) -- transitivity; note the 'transposition' of the arguments! _●p_ : ∀ {m₁ m₂ m₃} → CPerm m₂ m₁ → CPerm m₃ m₂ → CPerm m₃ m₁ p₁ ●p p₂ = e⇒p ((p⇒e p₁) ● (p⇒e p₂))
algebraic-stack_agda0000_doc_8729
module PreludeShow where import RTP -- magic module import AlonzoPrelude as Prelude open import PreludeNat open import PreludeString import PreludeList open import PreludeBool open Prelude -- open Data.Integer, using (Int, pos, neg) open PreludeList hiding (_++_) showInt : Int -> String showInt = RTP.primShowInt showNat : Nat -> String showNat n = showInt (RTP.primNatToInt n) {- showNat : Nat -> String showNat zero = "0" showNat n = reverseString $ show n where digit : Nat -> String digit 0 = "0" digit 1 = "1" digit 2 = "2" digit 3 = "3" digit 4 = "4" digit 5 = "5" digit 6 = "6" digit 7 = "7" digit 8 = "8" digit 9 = "9" digit _ = "?" show : Nat -> String show zero = "" show n = digit (mod n 10) ++ show (div n 10) -} {- showInt : Int -> String showInt (pos n) = showNat n showInt (neg n) = "-" ++ showNat (suc n) -} showChar : Char -> String showChar = RTP.primShowChar showBool : Bool -> String showBool true = "true" showBool false = "false" primitive primShowFloat : Float -> String showFloat : Float -> String showFloat = primShowFloat
algebraic-stack_agda0000_doc_8730
-- | Trailing inductive copattern matches on the LHS can be savely -- translated to record expressions on RHS, without jeopardizing -- termination. -- {-# LANGUAGE CPP #-} module Agda.TypeChecking.CompiledClause.ToRHS where -- import Control.Applicative import Data.Monoid import qualified Data.Map as Map import Data.List (genericReplicate, nubBy, findIndex) import Data.Function import Agda.Syntax.Common import Agda.Syntax.Internal as I import Agda.TypeChecking.CompiledClause import Agda.TypeChecking.Coverage import Agda.TypeChecking.Coverage.SplitTree import Agda.TypeChecking.Monad import Agda.TypeChecking.RecordPatterns import Agda.TypeChecking.Substitute import Agda.TypeChecking.Pretty import Agda.Utils.List import Agda.Utils.Impossible #include "../../undefined.h"
algebraic-stack_agda0000_doc_8731
module _ where open import Agda.Builtin.Bool module M (b : Bool) where module Inner where some-boolean : Bool some-boolean = b postulate @0 a-postulate : Bool @0 A : @0 Bool → Set A b = Bool module A where module M′ = M b bad : @0 Bool → Bool bad = A.M′.Inner.some-boolean
algebraic-stack_agda0000_doc_8732
-- MIT License -- Copyright (c) 2021 Luca Ciccone and Luca Padovani -- Permission is hereby granted, free of charge, to any person -- obtaining a copy of this software and associated documentation -- files (the "Software"), to deal in the Software without -- restriction, including without limitation the rights to use, -- copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the -- Software is furnished to do so, subject to the following -- conditions: -- The above copyright notice and this permission notice shall be -- included in all copies or substantial portions of the Software. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -- OTHER DEALINGS IN THE SOFTWARE. {-# OPTIONS --guardedness --sized-types #-} open import Data.Product open import Data.Empty open import Data.Sum open import Data.Vec open import Data.List as List open import Data.Unit open import Data.Fin open import Data.Bool renaming (Bool to 𝔹) open import Relation.Unary using (_∈_; _⊆_;_∉_) open import Relation.Binary.Construct.Closure.ReflexiveTransitive open import Relation.Binary.PropositionalEquality open import Relation.Nullary open import Size open import Codata.Thunk open import is-lib.InfSys open import Common using (Message) module FairSubtyping-IS {𝕋 : Set} (message : Message 𝕋) where open Message message open import SessionType message open import Session message open import Transitions message open import Convergence message open import Divergence message open import Discriminator message open import Action message using (Action) open import Subtyping message open import FairSubtyping message as FS open import HasTrace message open import Compliance message open import FairCompliance message open import Trace message open import FairCompliance-IS message private U : Set U = SessionType × SessionType data FSubIS-RN : Set where nil-any end-def : FSubIS-RN ii oo : FSubIS-RN data FSubCOIS-RN : Set where co-conv : FSubCOIS-RN nil-any-r : FinMetaRule U nil-any-r .Ctx = SessionType nil-any-r .comp T = [] , ------------------ (nil , T) end-def-r : FinMetaRule U end-def-r .Ctx = Σ[ (T , S) ∈ SessionType × SessionType ] End T × Defined S end-def-r .comp ((T , S) , _) = [] , ------------------ (T , S) ii-r : MetaRule U ii-r .Ctx = Σ[ (f , g) ∈ Continuation × Continuation ] dom f ⊆ dom g ii-r .Pos ((f , _) , _) = Σ[ t ∈ 𝕋 ] t ∈ dom f ii-r .prems ((f , g) , _) (t , _) = f t .force , g t .force ii-r .conclu ((f , g) , _) = inp f , inp g oo-r : MetaRule U oo-r .Ctx = Σ[ (f , g) ∈ Continuation × Continuation ] dom g ⊆ dom f × Witness g oo-r .Pos ((_ , g) , _) = Σ[ t ∈ 𝕋 ] t ∈ dom g oo-r .prems ((f , g) , _) (t , _) = f t .force , g t .force oo-r .conclu ((f , g) , _) = out f , out g co-conv-r : FinMetaRule U co-conv-r .Ctx = Σ[ (T , S) ∈ SessionType × SessionType ] T ↓ S co-conv-r .comp ((T , S) , _) = [] , ------------------ (T , S) FSubIS : IS U FSubIS .Names = FSubIS-RN FSubIS .rules nil-any = from nil-any-r FSubIS .rules end-def = from end-def-r FSubIS .rules ii = ii-r FSubIS .rules oo = oo-r FSubCOIS : IS U FSubCOIS .Names = FSubCOIS-RN FSubCOIS .rules co-conv = from co-conv-r _≤F_ : SessionType → SessionType → Set T ≤F S = FCoInd⟦ FSubIS , FSubCOIS ⟧ (T , S) _≤Fᵢ_ : SessionType → SessionType → Set T ≤Fᵢ S = Ind⟦ FSubIS ∪ FSubCOIS ⟧ (T , S) _≤Fc_ : SessionType → SessionType → Set T ≤Fc S = CoInd⟦ FSubIS ⟧ (T , S) {- Specification using _⊢_ is correct wrt FairSubtypingS -} FSSpec-⊢ : U → Set FSSpec-⊢ (T , S) = ∀{R} → R ⊢ T → R ⊢ S spec-sound : ∀{T S} → FairSubtypingS T S → FSSpec-⊢ (T , S) spec-sound fs fc = fc-complete (fs (fc-sound fc)) spec-complete : ∀{T S} → FSSpec-⊢ (T , S) → FairSubtypingS T S spec-complete fs fc = fc-sound (fs (fc-complete fc)) ------------------------------------------------------ {- Soundness -}   -- Using bounded coinduction wrt SpecAux ≤Fᵢ->↓ : ∀{S T} → S ≤Fᵢ T → S ↓ T ≤Fᵢ->↓ (fold (inj₁ nil-any , _ , refl , _)) = nil-converges ≤Fᵢ->↓ (fold (inj₁ end-def , (_ , (end , def)) , refl , _)) = end-converges end def ≤Fᵢ->↓ (fold (inj₁ ii , _ , refl , pr)) = converge (pre-conv-inp-back λ x → ↓->preconv (≤Fᵢ->↓ (pr (_ , x)))) ≤Fᵢ->↓ (fold (inj₁ oo , (_ , (incl , (t , ok-t))) , refl , pr)) = converge λ _ _ → [] , t , none , (_ , incl ok-t , step (out (incl ok-t)) refl) , (_ , ok-t , step (out ok-t) refl) , ≤Fᵢ->↓ (pr (t , ok-t)) ≤Fᵢ->↓ (fold (inj₂ co-conv , (_ , conv) , refl , _)) = conv SpecAux : U → Set SpecAux (R , T) = Σ[ S ∈ SessionType ] S ≤F T × R ⊢ S ≤Fᵢ->defined : ∀{S T} → Defined S → S ≤Fᵢ T → Defined T ≤Fᵢ->defined def fs = conv->defined def (≤Fᵢ->↓ fs) spec-bounded-rec : ∀{R S} T → T ≤Fᵢ S → R ⊢ T → R ⊢ᵢ S spec-bounded-rec _ fs fc = let _ , reds , succ = con-sound (≤Fᵢ->↓ fs) (fc-sound fc) in maysucceed->⊢ᵢ reds succ spec-bounded : SpecAux ⊆ λ (R , S) → R ⊢ᵢ S spec-bounded (T , fs , fc) = spec-bounded-rec T (fcoind-to-ind fs) fc spec-cons : SpecAux ⊆ ISF[ FCompIS ] SpecAux spec-cons {(R , T)} (S , fs , fc) with fc .CoInd⟦_⟧.unfold spec-cons {(R , T)} (S , fs , fc) | client-end , ((_ , (win , def)) , _) , refl , _ = client-end , ((R , _) , (win , ≤Fᵢ->defined def (fcoind-to-ind fs))) , refl , λ () spec-cons {(out r , _)} ((inp f) , fs , fc) | oi , (((.r , .f) , wit-r) , _) , refl , pr with fs .CoInd⟦_⟧.unfold ... | end-def , (((.(inp f) , _) , (inp e , _)) , _) , refl , _ = ⊥-elim (e _ (proj₂ (fc->defined (pr wit-r)))) ... | ii , (((.f , g) , _) , _) , refl , pr' = oi , (_ , wit-r) , refl , λ wit → _ , pr' (_ , proj₂ (fc->defined (pr wit))) , pr wit spec-cons {(inp r , T)} (out f , fs , fc) | io , (((.r , .f) , wit-f) , _) , refl , pr with fs .CoInd⟦_⟧.unfold ... | end-def , (((.(out f) , _) , (out e , _)) , _) , refl , _ = ⊥-elim (e _ (proj₂ wit-f)) ... | oo , (((.f , g) , (incl , wit-g)) , _) , refl , pr' = io , (_ , wit-g) , refl , λ wit → _ , pr' wit , pr (_ , incl (proj₂ wit)) spec-aux-sound : SpecAux ⊆ λ (R , S) → R ⊢ S spec-aux-sound = bounded-coind[ FCompIS , FCompCOIS ] SpecAux spec-bounded spec-cons fs-sound : ∀{T S} → T ≤F S → FSSpec-⊢ (T , S) fs-sound {T} fs fc = spec-aux-sound (T , fs , fc) {- Soundness & Completeness of Sub wrt ≤Fc -} ≤Fc->sub : ∀{S T} → S ≤Fc T → ∀ {i} → Sub S T i ≤Fc->sub fs with fs .CoInd⟦_⟧.unfold ... | nil-any , _ , refl , _ = nil<:any ... | end-def , (_ , (end , def)) , refl , _ = end<:def end def ... | ii , ((f , g) , incl) , refl , pr = inp<:inp incl λ x → λ where .force → if-def x where if-def : (t : 𝕋) → ∀{i} → Sub (f t .force) (g t .force) i if-def t with t ∈? f ... | yes ok-t = ≤Fc->sub (pr (_ , ok-t)) ... | no no-t = subst (λ x → Sub x (g t .force) _) (sym (not-def->nil no-t)) nil<:any ... | oo , (_ , (incl , wit)) , refl , pr = out<:out wit incl λ ok-x → λ where .force → ≤Fc->sub (pr (_ , ok-x)) sub->≤Fc : ∀{S T} → (∀{i} → Sub S T i) → S ≤Fc T CoInd⟦_⟧.unfold (sub->≤Fc fs) with fs ... | nil<:any = nil-any , _ , refl , λ () ... | end<:def end def = end-def , (_ , (end , def)) , refl , λ () ... | inp<:inp incl pr = ii , (_ , incl) , refl , λ (p , _) → sub->≤Fc (pr p .force) ... | out<:out wit incl pr = oo , (_ , (incl , wit)) , refl , λ (_ , ok) → sub->≤Fc (pr ok .force) {- Auxiliary -} -- Only premise for rules using sample-cont in ⊢ sample-cont-prem : ∀{f : Continuation}{t R} → R ⊢ f t .force → (pos : Σ[ p ∈ 𝕋 ] p ∈ dom (sample-cont t R nil)) → (sample-cont t R nil) (proj₁ pos) .force ⊢ f (proj₁ pos) .force sample-cont-prem {f} {t} pr (p , ok-p) with p ?= t ... | yes refl = pr sample-cont-prem {f} {t} pr (p , ()) | no ¬eq -- Premises using sample-cont-dual in ⊢ sample-cont-prems : ∀{f : Continuation}{t} → t ∉ dom f → (pos : Σ[ p ∈ 𝕋 ] p ∈ dom f) → (sample-cont t nil win) (proj₁ pos) .force ⊢ f (proj₁ pos) .force sample-cont-prems {f} {t} no-t (p , ok-p) with p ?= t ... | yes refl = ⊥-elim (no-t ok-p) ... | no ¬eq = win⊢def ok-p -- Premises using sample-cont-dual in ⊢ sample-cont-prems' : ∀{f : Continuation}{t R} → R ⊢ f t .force → (pos : Σ[ p ∈ 𝕋 ] p ∈ dom f) → (sample-cont t R win) (proj₁ pos) .force ⊢ f (proj₁ pos) .force sample-cont-prems' {f} {t} pr (p , ok-p) with p ?= t ... | yes refl = pr ... | no ¬eq = win⊢def ok-p spec-inp->incl : ∀{f g} → FSSpec-⊢ (inp f , inp g) → dom f ⊆ dom g spec-inp->incl {f} {g} fs {t} ok-t with fs (apply-fcoind oi ((sample-cont t win nil , f) , wit-cont out) (sample-cont-prem {f} {t} (win⊢def ok-t))) .CoInd⟦_⟧.unfold ... | client-end , ((_ , (out e , _)) , _) , refl , _ = ⊥-elim (e t (proj₂ (wit-cont out))) ... | oi , _ , refl , pr = proj₂ (fc->defined (pr (t , proj₂ (wit-cont out)))) spec-out->incl : ∀{f g} → FSSpec-⊢ (out f , out g) → Witness f → dom g ⊆ dom f spec-out->incl {f} {g} fs wit {t} ok-t with t ∈? f ... | yes ok = ok ... | no no-t with (fs (apply-fcoind io ((sample-cont t nil win , f) , wit) (sample-cont-prems {f} {t} no-t))) .CoInd⟦_⟧.unfold ... | client-end , ((_ , (() , _)) , _) , refl , _ ... | io , _ , refl , pr = ⊥-elim (cont-not-def (proj₁ (fc->defined (pr (t , ok-t))))) spec-out->wit : ∀{f g} → Witness f → FSSpec-⊢ (out f , out g) → Witness g spec-out->wit {f} {g} wit-f fs with Empty? g ... | inj₂ wit = wit ... | inj₁ e with (fs (apply-fcoind io ((full-cont win , f) , wit-f) λ (_ , ok) → win⊢def ok)) .CoInd⟦_⟧.unfold ... | client-end , ((_ , (() , _)) , _) , refl , _ ... | io , ((_ , wit-g) , _) , refl , _ = ⊥-elim (e _ (proj₂ wit-g)) {- Boundedness & Consistency -} fsspec-cons : FSSpec-⊢ ⊆ ISF[ FSubIS ] FSSpec-⊢ fsspec-cons {nil , T} fs = nil-any , _ , refl , λ () fsspec-cons {inp f , nil} fs with (fs (apply-fcoind client-end ((win , _) , (Win-win , inp)) λ ())) .CoInd⟦_⟧.unfold ... | client-end , ((_ , (_ , ())) , _) , refl , _ fsspec-cons {inp f , inp g} fs = ii , ((f , g) , spec-inp->incl fs) , refl , λ (p , _) {R} fc-r-f → let wit = wit-cont (proj₁ (fc->defined fc-r-f)) in let fc-Or-Ig = fs (apply-fcoind oi ((sample-cont p R nil , f) , wit) (sample-cont-prem {f} {p} fc-r-f)) in let fc-r-g = ⊢-after-out {sample-cont p R nil} {g} {p} (proj₂ wit) fc-Or-Ig in subst (λ x → x ⊢ g p .force) (sym force-eq) fc-r-g fsspec-cons {inp f , out g} fs with Empty? f ... | inj₁ e = end-def , (_ , (inp e , out)) , refl , λ () ... | inj₂ (t , ok-t) with (fs (apply-fcoind oi ((sample-cont t win nil , f) , wit-cont out) (sample-cont-prem {f} {t} (win⊢def ok-t)))) .CoInd⟦_⟧.unfold ... | client-end , ((_ , (out e , out)) , _) , refl , _ = ⊥-elim (e t (proj₂ (wit-cont out))) fsspec-cons {out f , nil} fs with (fs (apply-fcoind client-end ((win , _) , (Win-win , out)) λ ())) .CoInd⟦_⟧.unfold ... | client-end , ((_ , (_ , ())) , _) , refl , _ fsspec-cons {out f , inp g} fs with Empty? f ... | inj₁ e = end-def , (_ , (out e , inp)) , refl , λ () ... | inj₂ (t , ok-t) with (fs (apply-fcoind io ((full-cont win , f) , (t , ok-t)) λ (_ , ok-p) → win⊢def ok-p)) .CoInd⟦_⟧.unfold ... | client-end , ((_ , (() , inp)) , _) , refl , _ fsspec-cons {out f , out g} fs with Empty? f ... | inj₁ e = end-def , (_ , (out e , out)) , refl , λ () ... | inj₂ (t , ok-t) = let wit-g = spec-out->wit (t , ok-t) fs in let incl = spec-out->incl fs (t , ok-t) in oo , ((f , g) , (incl , wit-g)) , refl , λ (p , ok-p) {R} fc-r-f → let fc-Ir-Og = fs (apply-fcoind io ((sample-cont p R win , f) , (t , ok-t)) (sample-cont-prems' {f} {p} fc-r-f)) in let fc-r-g = ⊢-after-in {sample-cont p R win} {g} {p} ok-p fc-Ir-Og in subst (λ x → x ⊢ g p .force) (sym force-eq) fc-r-g fsspec->sub : ∀{S T} → FSSpec-⊢ (S , T) → S ≤Fc T fsspec->sub = coind[ FSubIS ] FSSpec-⊢ fsspec-cons postulate not-conv-div : ∀{T S} → ¬ T ↓ S → T ↑ S fs-convergence : ∀{T S} → FairSubtypingS T S → T ↓ S fs-convergence {T} {S} fs with Common.excluded-middle {T ↓ S} fs-convergence {T} {S} fs | yes p = p fs-convergence {T} {S} fs | no p = let div = not-conv-div p in let sub = ≤Fc->sub (fsspec->sub (spec-sound fs)) in let d-comp = discriminator-compliant sub div in let ¬d-comp = discriminator-not-compliant sub div in ⊥-elim (¬d-comp (fs d-comp)) fsspec-bounded : ∀{S T} → FSSpec-⊢ (S , T) → S ≤Fᵢ T fsspec-bounded fs = apply-ind (inj₂ co-conv) (_ , (fs-convergence (spec-complete fs))) λ () {- Completeness -} fs-complete : ∀{S T} → FSSpec-⊢ (S , T) → S ≤F T fs-complete = bounded-coind[ FSubIS , FSubCOIS ] FSSpec-⊢ fsspec-bounded fsspec-cons
algebraic-stack_agda0000_doc_8733
-- Andreas, 2016-10-11, AIM XXIV -- We cannot bind NATURAL to an abstract version of Nat. abstract data ℕ : Set where zero : ℕ suc : ℕ → ℕ {-# BUILTIN NATURAL ℕ #-}
algebraic-stack_agda0000_doc_8734
-- Jesper, 2018-10-29 (comment on #3332): Besides for rewrite, builtin -- equality is also used for primErase and primForceLemma. But I don't -- see how it would hurt to have these use a Prop instead of a Set for -- equality. {-# OPTIONS --prop #-} data _≡_ {A : Set} (a : A) : A → Prop where refl : a ≡ a {-# BUILTIN EQUALITY _≡_ #-}
algebraic-stack_agda0000_doc_8735
open import Agda.Builtin.Nat open import Agda.Builtin.Reflection open import Agda.Builtin.Unit macro five : Term → TC ⊤ five hole = unify hole (lit (nat 5)) -- Here you get hole = _X (λ {n} → y {_n}) -- and fail to solve _n. yellow : ({n : Nat} → Set) → Nat yellow y = five -- Here you get hole = _X ⦃ n ⦄ (λ ⦃ n' ⦄ → y ⦃ _n ⦄) -- and fail to solve _n due to the multiple candidates n and n'. more-yellow : ⦃ n : Nat ⦄ → (⦃ n : Nat ⦄ → Set) → Nat more-yellow y = five
algebraic-stack_agda0000_doc_8704
{-# OPTIONS --without-K --safe --no-sized-types --no-guardedness #-} module Agda.Builtin.Reflection where open import Agda.Builtin.Unit open import Agda.Builtin.Bool open import Agda.Builtin.Nat open import Agda.Builtin.Word open import Agda.Builtin.List open import Agda.Builtin.String open import Agda.Builtin.Char open import Agda.Builtin.Float open import Agda.Builtin.Int open import Agda.Builtin.Sigma -- Names -- postulate Name : Set {-# BUILTIN QNAME Name #-} primitive primQNameEquality : Name → Name → Bool primQNameLess : Name → Name → Bool primShowQName : Name → String -- Fixity -- data Associativity : Set where left-assoc : Associativity right-assoc : Associativity non-assoc : Associativity data Precedence : Set where related : Int → Precedence unrelated : Precedence data Fixity : Set where fixity : Associativity → Precedence → Fixity {-# BUILTIN ASSOC Associativity #-} {-# BUILTIN ASSOCLEFT left-assoc #-} {-# BUILTIN ASSOCRIGHT right-assoc #-} {-# BUILTIN ASSOCNON non-assoc #-} {-# BUILTIN PRECEDENCE Precedence #-} {-# BUILTIN PRECRELATED related #-} {-# BUILTIN PRECUNRELATED unrelated #-} {-# BUILTIN FIXITY Fixity #-} {-# BUILTIN FIXITYFIXITY fixity #-} {-# COMPILE GHC Associativity = data MAlonzo.RTE.Assoc (MAlonzo.RTE.LeftAssoc | MAlonzo.RTE.RightAssoc | MAlonzo.RTE.NonAssoc) #-} {-# COMPILE GHC Precedence = data MAlonzo.RTE.Precedence (MAlonzo.RTE.Related | MAlonzo.RTE.Unrelated) #-} {-# COMPILE GHC Fixity = data MAlonzo.RTE.Fixity (MAlonzo.RTE.Fixity) #-} {-# COMPILE JS Associativity = function (x,v) { return v[x](); } #-} {-# COMPILE JS left-assoc = "left-assoc" #-} {-# COMPILE JS right-assoc = "right-assoc" #-} {-# COMPILE JS non-assoc = "non-assoc" #-} {-# COMPILE JS Precedence = function (x,v) { if (x === "unrelated") { return v[x](); } else { return v["related"](x); }} #-} {-# COMPILE JS related = function(x) { return x; } #-} {-# COMPILE JS unrelated = "unrelated" #-} {-# COMPILE JS Fixity = function (x,v) { return v["fixity"](x["assoc"], x["prec"]); } #-} {-# COMPILE JS fixity = function (x) { return function (y) { return { "assoc": x, "prec": y}; }; } #-} primitive primQNameFixity : Name → Fixity -- Metavariables -- postulate Meta : Set {-# BUILTIN AGDAMETA Meta #-} primitive primMetaEquality : Meta → Meta → Bool primMetaLess : Meta → Meta → Bool primShowMeta : Meta → String -- Arguments -- -- Arguments can be (visible), {hidden}, or {{instance}}. data Visibility : Set where visible hidden instance′ : Visibility {-# BUILTIN HIDING Visibility #-} {-# BUILTIN VISIBLE visible #-} {-# BUILTIN HIDDEN hidden #-} {-# BUILTIN INSTANCE instance′ #-} -- Arguments can be relevant or irrelevant. data Relevance : Set where relevant irrelevant : Relevance {-# BUILTIN RELEVANCE Relevance #-} {-# BUILTIN RELEVANT relevant #-} {-# BUILTIN IRRELEVANT irrelevant #-} data ArgInfo : Set where arg-info : (v : Visibility) (r : Relevance) → ArgInfo data Arg (A : Set) : Set where arg : (i : ArgInfo) (x : A) → Arg A {-# BUILTIN ARGINFO ArgInfo #-} {-# BUILTIN ARGARGINFO arg-info #-} {-# BUILTIN ARG Arg #-} {-# BUILTIN ARGARG arg #-} -- Name abstraction -- data Abs (A : Set) : Set where abs : (s : String) (x : A) → Abs A {-# BUILTIN ABS Abs #-} {-# BUILTIN ABSABS abs #-} -- Literals -- data Literal : Set where nat : (n : Nat) → Literal word64 : (n : Word64) → Literal float : (x : Float) → Literal char : (c : Char) → Literal string : (s : String) → Literal name : (x : Name) → Literal meta : (x : Meta) → Literal {-# BUILTIN AGDALITERAL Literal #-} {-# BUILTIN AGDALITNAT nat #-} {-# BUILTIN AGDALITWORD64 word64 #-} {-# BUILTIN AGDALITFLOAT float #-} {-# BUILTIN AGDALITCHAR char #-} {-# BUILTIN AGDALITSTRING string #-} {-# BUILTIN AGDALITQNAME name #-} {-# BUILTIN AGDALITMETA meta #-} -- Patterns -- data Pattern : Set where con : (c : Name) (ps : List (Arg Pattern)) → Pattern dot : Pattern var : (s : String) → Pattern lit : (l : Literal) → Pattern proj : (f : Name) → Pattern absurd : Pattern {-# BUILTIN AGDAPATTERN Pattern #-} {-# BUILTIN AGDAPATCON con #-} {-# BUILTIN AGDAPATDOT dot #-} {-# BUILTIN AGDAPATVAR var #-} {-# BUILTIN AGDAPATLIT lit #-} {-# BUILTIN AGDAPATPROJ proj #-} {-# BUILTIN AGDAPATABSURD absurd #-} -- Terms -- data Sort : Set data Clause : Set data Term : Set Type = Term data Term where var : (x : Nat) (args : List (Arg Term)) → Term con : (c : Name) (args : List (Arg Term)) → Term def : (f : Name) (args : List (Arg Term)) → Term lam : (v : Visibility) (t : Abs Term) → Term pat-lam : (cs : List Clause) (args : List (Arg Term)) → Term pi : (a : Arg Type) (b : Abs Type) → Term agda-sort : (s : Sort) → Term lit : (l : Literal) → Term meta : (x : Meta) → List (Arg Term) → Term unknown : Term data Sort where set : (t : Term) → Sort lit : (n : Nat) → Sort unknown : Sort data Clause where clause : (ps : List (Arg Pattern)) (t : Term) → Clause absurd-clause : (ps : List (Arg Pattern)) → Clause {-# BUILTIN AGDASORT Sort #-} {-# BUILTIN AGDATERM Term #-} {-# BUILTIN AGDACLAUSE Clause #-} {-# BUILTIN AGDATERMVAR var #-} {-# BUILTIN AGDATERMCON con #-} {-# BUILTIN AGDATERMDEF def #-} {-# BUILTIN AGDATERMMETA meta #-} {-# BUILTIN AGDATERMLAM lam #-} {-# BUILTIN AGDATERMEXTLAM pat-lam #-} {-# BUILTIN AGDATERMPI pi #-} {-# BUILTIN AGDATERMSORT agda-sort #-} {-# BUILTIN AGDATERMLIT lit #-} {-# BUILTIN AGDATERMUNSUPPORTED unknown #-} {-# BUILTIN AGDASORTSET set #-} {-# BUILTIN AGDASORTLIT lit #-} {-# BUILTIN AGDASORTUNSUPPORTED unknown #-} {-# BUILTIN AGDACLAUSECLAUSE clause #-} {-# BUILTIN AGDACLAUSEABSURD absurd-clause #-} -- Definitions -- data Definition : Set where function : (cs : List Clause) → Definition data-type : (pars : Nat) (cs : List Name) → Definition record-type : (c : Name) (fs : List (Arg Name)) → Definition data-cons : (d : Name) → Definition axiom : Definition prim-fun : Definition {-# BUILTIN AGDADEFINITION Definition #-} {-# BUILTIN AGDADEFINITIONFUNDEF function #-} {-# BUILTIN AGDADEFINITIONDATADEF data-type #-} {-# BUILTIN AGDADEFINITIONRECORDDEF record-type #-} {-# BUILTIN AGDADEFINITIONDATACONSTRUCTOR data-cons #-} {-# BUILTIN AGDADEFINITIONPOSTULATE axiom #-} {-# BUILTIN AGDADEFINITIONPRIMITIVE prim-fun #-} -- Errors -- data ErrorPart : Set where strErr : String → ErrorPart termErr : Term → ErrorPart nameErr : Name → ErrorPart {-# BUILTIN AGDAERRORPART ErrorPart #-} {-# BUILTIN AGDAERRORPARTSTRING strErr #-} {-# BUILTIN AGDAERRORPARTTERM termErr #-} {-# BUILTIN AGDAERRORPARTNAME nameErr #-} -- TC monad -- postulate TC : ∀ {a} → Set a → Set a returnTC : ∀ {a} {A : Set a} → A → TC A bindTC : ∀ {a b} {A : Set a} {B : Set b} → TC A → (A → TC B) → TC B unify : Term → Term → TC ⊤ typeError : ∀ {a} {A : Set a} → List ErrorPart → TC A inferType : Term → TC Type checkType : Term → Type → TC Term normalise : Term → TC Term reduce : Term → TC Term catchTC : ∀ {a} {A : Set a} → TC A → TC A → TC A quoteTC : ∀ {a} {A : Set a} → A → TC Term unquoteTC : ∀ {a} {A : Set a} → Term → TC A getContext : TC (List (Arg Type)) extendContext : ∀ {a} {A : Set a} → Arg Type → TC A → TC A inContext : ∀ {a} {A : Set a} → List (Arg Type) → TC A → TC A freshName : String → TC Name declareDef : Arg Name → Type → TC ⊤ declarePostulate : Arg Name → Type → TC ⊤ defineFun : Name → List Clause → TC ⊤ getType : Name → TC Type getDefinition : Name → TC Definition blockOnMeta : ∀ {a} {A : Set a} → Meta → TC A commitTC : TC ⊤ isMacro : Name → TC Bool -- If the argument is 'true' makes the following primitives also normalise -- their results: inferType, checkType, quoteTC, getType, and getContext withNormalisation : ∀ {a} {A : Set a} → Bool → TC A → TC A -- Prints the third argument if the corresponding verbosity level is turned -- on (with the -v flag to Agda). debugPrint : String → Nat → List ErrorPart → TC ⊤ -- Fail if the given computation gives rise to new, unsolved -- "blocking" constraints. noConstraints : ∀ {a} {A : Set a} → TC A → TC A -- Run the given TC action and return the first component. Resets to -- the old TC state if the second component is 'false', or keep the -- new TC state if it is 'true'. runSpeculative : ∀ {a} {A : Set a} → TC (Σ A λ _ → Bool) → TC A {-# BUILTIN AGDATCM TC #-} {-# BUILTIN AGDATCMRETURN returnTC #-} {-# BUILTIN AGDATCMBIND bindTC #-} {-# BUILTIN AGDATCMUNIFY unify #-} {-# BUILTIN AGDATCMTYPEERROR typeError #-} {-# BUILTIN AGDATCMINFERTYPE inferType #-} {-# BUILTIN AGDATCMCHECKTYPE checkType #-} {-# BUILTIN AGDATCMNORMALISE normalise #-} {-# BUILTIN AGDATCMREDUCE reduce #-} {-# BUILTIN AGDATCMCATCHERROR catchTC #-} {-# BUILTIN AGDATCMQUOTETERM quoteTC #-} {-# BUILTIN AGDATCMUNQUOTETERM unquoteTC #-} {-# BUILTIN AGDATCMGETCONTEXT getContext #-} {-# BUILTIN AGDATCMEXTENDCONTEXT extendContext #-} {-# BUILTIN AGDATCMINCONTEXT inContext #-} {-# BUILTIN AGDATCMFRESHNAME freshName #-} {-# BUILTIN AGDATCMDECLAREDEF declareDef #-} {-# BUILTIN AGDATCMDECLAREPOSTULATE declarePostulate #-} {-# BUILTIN AGDATCMDEFINEFUN defineFun #-} {-# BUILTIN AGDATCMGETTYPE getType #-} {-# BUILTIN AGDATCMGETDEFINITION getDefinition #-} {-# BUILTIN AGDATCMBLOCKONMETA blockOnMeta #-} {-# BUILTIN AGDATCMCOMMIT commitTC #-} {-# BUILTIN AGDATCMISMACRO isMacro #-} {-# BUILTIN AGDATCMWITHNORMALISATION withNormalisation #-} {-# BUILTIN AGDATCMDEBUGPRINT debugPrint #-} {-# BUILTIN AGDATCMNOCONSTRAINTS noConstraints #-} {-# BUILTIN AGDATCMRUNSPECULATIVE runSpeculative #-}
algebraic-stack_agda0000_doc_8705
module Where where {- id : Set -> Set id a = a -} -- x : (_ : _) -> _ x = id Set3000 where id = \x -> x y = False where data False : Set where
algebraic-stack_agda0000_doc_8706
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.CircleHSpace open import homotopy.JoinAssocCubical open import homotopy.JoinSusp module homotopy.Hopf where import homotopy.HopfConstruction module Hopf = homotopy.HopfConstruction S¹-conn ⊙S¹-hSpace Hopf : S² → Type₀ Hopf = Hopf.H.f Hopf-fiber : Hopf north == S¹ Hopf-fiber = idp -- TODO Turn [Hopf.theorem] into an equivalence Hopf-total : Σ _ Hopf ≃ S³ Hopf-total = Σ _ Hopf ≃⟨ coe-equiv Hopf.theorem ⟩ S¹ * S¹ ≃⟨ *-Susp-l S⁰ S¹ ⟩ Susp (S⁰ * S¹) ≃⟨ Susp-emap (*-Bool-l S¹) ⟩ S³ ≃∎
algebraic-stack_agda0000_doc_8707
module Relations where open import Agda.Builtin.Equality open import Natural data _≤_ : ℕ → ℕ → Set where z≤n : ∀ {n : ℕ} → zero ≤ n s≤s : ∀ {m n : ℕ} → m ≤ n → (suc m) ≤ (suc n) infix 4 _≤_ -- example : finished by auto mode _ : 3 ≤ 5 _ = s≤s {2} {4} (s≤s {1} {3} (s≤s {0} {2} (z≤n {2}))) inv-s≤s : ∀ {m n : ℕ} → suc m ≤ suc n → m ≤ n inv-s≤s (s≤s m≤n) = m≤n inv-z≤n : ∀ {m : ℕ} → m ≤ zero → m ≡ zero inv-z≤n z≤n = refl
algebraic-stack_agda0000_doc_8708
-- cj-xu and fredriknordvallforsberg, 2018-04-30 open import Common.IO data Bool : Set where true false : Bool data MyUnit : Set where tt : MyUnit -- no eta! HiddenFunType : MyUnit -> Set HiddenFunType tt = Bool -> Bool notTooManyArgs : (x : MyUnit) -> HiddenFunType x notTooManyArgs tt b = b {- This should not happen when compiling notTooManyArgs: • Couldn't match expected type ‘GHC.Prim.Any’ with actual type ‘a0 -> b0’ The type variables ‘b0’, ‘a0’ are ambiguous • The equation(s) for ‘d10’ have two arguments, but its type ‘T2 -> AgdaAny’ has only one -} main : IO MyUnit main = return tt
algebraic-stack_agda0000_doc_8709
module Data.Num.Nat where open import Data.Num.Core renaming ( carry to carry' ; carry-lower-bound to carry-lower-bound' ; carry-upper-bound to carry-upper-bound' ) open import Data.Num.Maximum open import Data.Num.Bounded open import Data.Num.Next open import Data.Num.Increment open import Data.Num.Continuous open import Data.Nat open import Data.Nat.Properties open import Data.Nat.Properties.Simple open import Data.Nat.Properties.Extra open import Data.Nat.DM open import Data.Fin as Fin using (Fin; fromℕ≤; inject≤) renaming (zero to z; suc to s) open import Data.Fin.Properties using (toℕ-fromℕ≤; bounded) open import Data.Product open import Data.Empty using (⊥) open import Data.Unit using (⊤; tt) open import Function open import Relation.Nullary.Decidable open import Relation.Nullary open import Relation.Nullary.Negation open import Relation.Binary open import Relation.Binary.PropositionalEquality open ≡-Reasoning open ≤-Reasoning renaming (begin_ to start_; _∎ to _□; _≡⟨_⟩_ to _≈⟨_⟩_) open DecTotalOrder decTotalOrder using (reflexive) renaming (refl to ≤-refl) -- left-bounded infinite interval of natural number data Nat : ℕ → Set where from : ∀ offset → Nat offset suc : ∀ {offset} → Nat offset → Nat offset Nat-toℕ : ∀ {offset} → Nat offset → ℕ Nat-toℕ (from offset) = offset Nat-toℕ (suc n) = suc (Nat-toℕ n) Nat-fromℕ : ∀ offset → (n : ℕ) → .(offset ≤ n) → Nat offset Nat-fromℕ offset n p with offset ≟ n Nat-fromℕ offset n p | yes eq = from offset Nat-fromℕ offset zero p | no ¬eq = from offset Nat-fromℕ offset (suc n) p | no ¬eq = suc (Nat-fromℕ offset n (≤-pred (≤∧≢⇒< p ¬eq))) Nat-fromℕ-toℕ : ∀ offset → (n : ℕ) → (p : offset ≤ n) → Nat-toℕ (Nat-fromℕ offset n p) ≡ n Nat-fromℕ-toℕ offset n p with offset ≟ n Nat-fromℕ-toℕ offset n p | yes eq = eq Nat-fromℕ-toℕ .0 zero z≤n | no ¬eq = refl Nat-fromℕ-toℕ offset (suc n) p | no ¬eq = begin suc (Nat-toℕ (Nat-fromℕ offset n (≤-pred (≤∧≢⇒< p ¬eq)))) ≡⟨ cong suc (Nat-fromℕ-toℕ offset n (≤-pred (≤∧≢⇒< p ¬eq))) ⟩ suc n ∎ fromNat : ∀ {b d o} → {cont : True (Continuous? b (suc d) o)} → Nat o → Num b (suc d) o fromNat (from offset) = z ∙ fromNat {cont = cont} (suc nat) = 1+ {cont = cont} (fromNat {cont = cont} nat) toℕ-fromNat : ∀ b d o → (cont : True (Continuous? b (suc d) o)) → (n : ℕ) → (p : o ≤ n) → ⟦ fromNat {b} {d} {o} {cont = cont} (Nat-fromℕ o n p) ⟧ ≡ n toℕ-fromNat b d o cont n p with o ≟ n toℕ-fromNat b d o cont n p | yes eq = cong (_+_ zero) eq toℕ-fromNat b d .0 cont zero z≤n | no ¬eq = refl toℕ-fromNat b d o cont (suc n) p | no ¬eq = begin ⟦ 1+ {b} {cont = cont} (fromNat (Nat-fromℕ o n (≤-pred (≤∧≢⇒< p ¬eq)))) ⟧ ≡⟨ 1+-toℕ {b} (fromNat {cont = cont} (Nat-fromℕ o n (≤-pred (≤∧≢⇒< p ¬eq)))) ⟩ suc ⟦ fromNat {cont = cont} (Nat-fromℕ o n (≤-pred (≤∧≢⇒< p ¬eq))) ⟧ -- mysterious agda bug, this refl must stay here ≡⟨ refl ⟩ suc ⟦ fromNat {cont = cont} (Nat-fromℕ o n (≤-pred (≤∧≢⇒< p ¬eq))) ⟧ ≡⟨ cong suc (toℕ-fromNat b d o cont n (≤-pred (≤∧≢⇒< p ¬eq))) ⟩ suc n ∎ -- -- a partial function that only maps ℕ to Continuous Nums -- fromℕ : ∀ {b d o} -- → {cond : N+Closed b d o} -- → ℕ -- → Num b (suc d) o -- fromℕ {cond = cond} zero = z ∙ -- fromℕ {cond = cond} (suc n) = {! !} -- fromℕ {cont = cont} zero = z ∙ -- fromℕ {cont = cont} (suc n) = 1+ {cont = cont} (fromℕ {cont = cont} n) -- toℕ-fromℕ : ∀ {b d o} -- → {cont : True (Continuous? b (suc d) o)} -- → (n : ℕ) -- → ⟦ fromℕ {cont = cont} n ⟧ ≡ n + o -- toℕ-fromℕ {_} {_} {_} {cont} zero = refl -- toℕ-fromℕ {b} {d} {o} {cont} (suc n) = -- begin -- ⟦ 1+ {cont = cont} (fromℕ {cont = cont} n) ⟧ -- ≡⟨ 1+-toℕ {cont = cont} (fromℕ {cont = cont} n) ⟩ -- suc ⟦ fromℕ {cont = cont} n ⟧ -- ≡⟨ cong suc (toℕ-fromℕ {cont = cont} n) ⟩ -- suc (n + o) -- ∎
algebraic-stack_agda0000_doc_8710
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use -- Data.List.Relation.Binary.BagAndSetEquality directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Relation.BagAndSetEquality where open import Data.List.Relation.Binary.BagAndSetEquality public {-# WARNING_ON_IMPORT "Data.List.Relation.BagAndSetEquality was deprecated in v1.0. Use Data.List.Relation.Binary.BagAndSetEquality instead." #-}
algebraic-stack_agda0000_doc_8711
open import Categories open import Monads module Monads.EM.Functors {a b}{C : Cat {a}{b}}(M : Monad C) where open import Library open import Functors open import Monads.EM M open Cat C open Fun open Monad M open Alg open AlgMorph EML : Fun C EM EML = record { OMap = λ X → record { acar = T X; astr = λ _ → bind; alaw1 = sym law2; alaw2 = law3}; HMap = λ f → record { amor = bind (comp η f); ahom = λ {Z} {g} → proof comp (bind (comp η f)) (bind g) ≅⟨ sym law3 ⟩ bind (comp (bind (comp η f)) g) ∎}; fid = AlgMorphEq ( proof bind (comp η iden) ≅⟨ cong bind idr ⟩ bind η ≅⟨ law1 ⟩ iden ∎); fcomp = λ {_}{_}{_}{f}{g} → AlgMorphEq ( proof bind (comp η (comp f g)) ≅⟨ cong bind (sym ass) ⟩ bind (comp (comp η f) g) ≅⟨ cong (λ f → bind (comp f g)) (sym law2) ⟩ bind (comp (comp (bind (comp η f)) η) g) ≅⟨ cong bind ass ⟩ bind (comp (bind (comp η f)) (comp η g)) ≅⟨ law3 ⟩ comp (bind (comp η f)) (bind (comp η g)) ∎)} EMR : Fun EM C EMR = record { OMap = acar; HMap = amor; fid = refl; fcomp = refl}
algebraic-stack_agda0000_doc_8712
{-# OPTIONS --no-positivity-check #-} open import Prelude module Implicits.Resolution.Undecidable.Resolution where open import Data.Fin.Substitution open import Implicits.Syntax open import Implicits.Syntax.MetaType open import Implicits.Substitutions open import Extensions.ListFirst infixl 4 _⊢ᵣ_ _⊢_↓_ _⟨_⟩=_ mutual data _⊢_↓_ {ν} (Δ : ICtx ν) : Type ν → SimpleType ν → Set where i-simp : ∀ a → Δ ⊢ simpl a ↓ a i-iabs : ∀ {ρ₁ ρ₂ a} → Δ ⊢ᵣ ρ₁ → Δ ⊢ ρ₂ ↓ a → Δ ⊢ ρ₁ ⇒ ρ₂ ↓ a i-tabs : ∀ {ρ a} b → Δ ⊢ ρ tp[/tp b ] ↓ a → Δ ⊢ ∀' ρ ↓ a -- implicit resolution is simply the first rule in the implicit context -- that yields the queried type _⟨_⟩=_ : ∀ {ν} → ICtx ν → SimpleType ν → Type ν → Set Δ ⟨ a ⟩= r = first r ∈ Δ ⇔ (λ r' → Δ ⊢ r' ↓ a) data _⊢ᵣ_ {ν} (Δ : ICtx ν) : Type ν → Set where r-simp : ∀ {τ ρ} → Δ ⟨ τ ⟩= ρ → Δ ⊢ᵣ simpl τ r-iabs : ∀ ρ₁ {ρ₂} → ρ₁ List.∷ Δ ⊢ᵣ ρ₂ → Δ ⊢ᵣ ρ₁ ⇒ ρ₂ r-tabs : ∀ {ρ} → ictx-weaken Δ ⊢ᵣ ρ → Δ ⊢ᵣ ∀' ρ _⊢ᵣ[_] : ∀ {ν} → (Δ : ICtx ν) → List (Type ν) → Set _⊢ᵣ[_] Δ ρs = All (λ r → Δ ⊢ᵣ r) ρs
algebraic-stack_agda0000_doc_8713
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-} module Light.Library.Data.Natural where open import Light.Level using (Level ; Setω) open import Light.Library.Arithmetic using (Arithmetic) open import Light.Package using (Package) open import Light.Library.Relation.Binary using (SelfTransitive ; SelfSymmetric ; Reflexive) open import Light.Library.Relation.Binary.Decidable using (DecidableSelfBinary) import Light.Library.Relation.Decidable open import Light.Library.Relation.Binary.Equality as ≈ using (_≈_) open import Light.Library.Relation.Binary.Equality.Decidable using (DecidableSelfEquality) open import Light.Library.Relation using (False) record Dependencies : Setω where record Library (dependencies : Dependencies) : Setω where field ℓ : Level ℕ : Set ℓ ⦃ equals ⦄ : DecidableSelfEquality ℕ zero : ℕ successor : ℕ → ℕ predecessor : ∀ (a : ℕ) ⦃ a‐≉‐0 : False (a ≈ zero) ⦄ → ℕ _+_ _∗_ _//_ _∸_ : ℕ → ℕ → ℕ ⦃ ≈‐transitive ⦄ : SelfTransitive (≈.self‐relation ℕ) ⦃ ≈‐symmetric ⦄ : SelfSymmetric (≈.self‐relation ℕ) ⦃ ≈‐reflexive ⦄ : Reflexive (≈.self‐relation ℕ) instance arithmetic : Arithmetic ℕ arithmetic = record { _+_ = _+_ ; _∗_ = _∗_ } open Library ⦃ ... ⦄ public
algebraic-stack_agda0000_doc_8714
------------------------------------------------------------------------ -- The Agda standard library -- -- An either-or-both data type ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.These where open import Level open import Data.Maybe.Base using (Maybe; just; nothing; maybe′) open import Data.Sum.Base using (_⊎_; [_,_]′) open import Function ------------------------------------------------------------------------ -- Re-exporting the datatype and its operations open import Data.These.Base public private variable a b : Level A : Set a B : Set b ------------------------------------------------------------------------ -- Additional operations -- projections fromThis : These A B → Maybe A fromThis = fold just (const nothing) (const ∘′ just) fromThat : These A B → Maybe B fromThat = fold (const nothing) just (const just) leftMost : These A A → A leftMost = fold id id const rightMost : These A A → A rightMost = fold id id (flip const) mergeThese : (A → A → A) → These A A → A mergeThese = fold id id -- deletions deleteThis : These A B → Maybe (These A B) deleteThis = fold (const nothing) (just ∘′ that) (const (just ∘′ that)) deleteThat : These A B → Maybe (These A B) deleteThat = fold (just ∘′ this) (const nothing) (const ∘′ just ∘′ this)
algebraic-stack_agda0000_doc_8715
module Formalization.ClassicalPropositionalLogic.NaturalDeduction where open import Data.Either as Either using (Left ; Right) open import Formalization.ClassicalPropositionalLogic.Syntax open import Functional import Lvl import Logic.Propositional as Meta open import Logic open import Relator.Equals open import Relator.Equals.Proofs.Equiv open import Sets.PredicateSet using (PredSet ; _∈_ ; _∉_ ; _∪_ ; _∪•_ ; _∖_ ; _⊆_ ; _⊇_ ; ∅ ; [≡]-to-[⊆] ; [≡]-to-[⊇]) renaming (•_ to singleton ; _≡_ to _≡ₛ_) open import Type private variable ℓₚ ℓ ℓ₁ ℓ₂ : Lvl.Level data _⊢_ {ℓ ℓₚ} {P : Type{ℓₚ}} : Formulas(P){ℓ} → Formula(P) → Stmt{Lvl.𝐒(ℓₚ Lvl.⊔ ℓ)} where direct : ∀{Γ} → (Γ ⊆ (Γ ⊢_)) [⊤]-intro : ∀{Γ} → (Γ ⊢ ⊤) [⊥]-intro : ∀{Γ}{φ} → (Γ ⊢ φ) → (Γ ⊢ (¬ φ)) → (Γ ⊢ ⊥) [⊥]-elim : ∀{Γ}{φ} → (Γ ⊢ ⊥) → (Γ ⊢ φ) [¬]-intro : ∀{Γ}{φ} → ((Γ ∪ singleton(φ)) ⊢ ⊥) → (Γ ⊢ (¬ φ)) [¬]-elim : ∀{Γ}{φ} → ((Γ ∪ singleton(¬ φ)) ⊢ ⊥) → (Γ ⊢ φ) [∧]-intro : ∀{Γ}{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ ψ) → (Γ ⊢ (φ ∧ ψ)) [∧]-elimₗ : ∀{Γ}{φ ψ} → (Γ ⊢ (φ ∧ ψ)) → (Γ ⊢ φ) [∧]-elimᵣ : ∀{Γ}{φ ψ} → (Γ ⊢ (φ ∧ ψ)) → (Γ ⊢ ψ) [∨]-introₗ : ∀{Γ}{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ (φ ∨ ψ)) [∨]-introᵣ : ∀{Γ}{φ ψ} → (Γ ⊢ ψ) → (Γ ⊢ (φ ∨ ψ)) [∨]-elim : ∀{Γ}{φ ψ χ} → ((Γ ∪ singleton(φ)) ⊢ χ) → ((Γ ∪ singleton(ψ)) ⊢ χ) → (Γ ⊢ (φ ∨ ψ)) → (Γ ⊢ χ) [⟶]-intro : ∀{Γ}{φ ψ} → ((Γ ∪ singleton(φ)) ⊢ ψ) → (Γ ⊢ (φ ⟶ ψ)) [⟶]-elim : ∀{Γ}{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ (φ ⟶ ψ)) → (Γ ⊢ ψ) [⟷]-intro : ∀{Γ}{φ ψ} → ((Γ ∪ singleton(ψ)) ⊢ φ) → ((Γ ∪ singleton(φ)) ⊢ ψ) → (Γ ⊢ (φ ⟷ ψ)) [⟷]-elimₗ : ∀{Γ}{φ ψ} → (Γ ⊢ ψ) → (Γ ⊢ (φ ⟷ ψ)) → (Γ ⊢ φ) [⟷]-elimᵣ : ∀{Γ}{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ (φ ⟷ ψ)) → (Γ ⊢ ψ) module _ where private variable P : Type{ℓₚ} private variable Γ Γ₁ Γ₂ : Formulas(P){ℓ} private variable φ ψ : Formula(P) _⊬_ : Formulas(P){ℓ} → Formula(P) → Stmt _⊬_ = Meta.¬_ ∘₂ (_⊢_) weaken-union-singleton : (Γ₁ ⊆ Γ₂) → (((Γ₁ ∪ singleton(φ)) ⊢_) ⊆ ((Γ₂ ∪ singleton(φ)) ⊢_)) weaken : (Γ₁ ⊆ Γ₂) → ((Γ₁ ⊢_) ⊆ (Γ₂ ⊢_)) weaken Γ₁Γ₂ {φ} (direct p) = direct (Γ₁Γ₂ p) weaken Γ₁Γ₂ {.⊤} [⊤]-intro = [⊤]-intro weaken Γ₁Γ₂ {.⊥} ([⊥]-intro p q) = [⊥]-intro (weaken Γ₁Γ₂ p) (weaken Γ₁Γ₂ q) weaken Γ₁Γ₂ {φ} ([⊥]-elim p) = [⊥]-elim (weaken Γ₁Γ₂ p) weaken Γ₁Γ₂ {.(¬ _)} ([¬]-intro p) = [¬]-intro (weaken-union-singleton Γ₁Γ₂ p) weaken Γ₁Γ₂ {φ} ([¬]-elim p) = [¬]-elim (weaken-union-singleton Γ₁Γ₂ p) weaken Γ₁Γ₂ {.(_ ∧ _)} ([∧]-intro p q) = [∧]-intro (weaken Γ₁Γ₂ p) (weaken Γ₁Γ₂ q) weaken Γ₁Γ₂ {φ} ([∧]-elimₗ p) = [∧]-elimₗ (weaken Γ₁Γ₂ p) weaken Γ₁Γ₂ {φ} ([∧]-elimᵣ p) = [∧]-elimᵣ (weaken Γ₁Γ₂ p) weaken Γ₁Γ₂ {.(_ ∨ _)} ([∨]-introₗ p) = [∨]-introₗ (weaken Γ₁Γ₂ p) weaken Γ₁Γ₂ {.(_ ∨ _)} ([∨]-introᵣ p) = [∨]-introᵣ (weaken Γ₁Γ₂ p) weaken Γ₁Γ₂ {φ} ([∨]-elim p q r) = [∨]-elim (weaken-union-singleton Γ₁Γ₂ p) (weaken-union-singleton Γ₁Γ₂ q) (weaken Γ₁Γ₂ r) weaken Γ₁Γ₂ {.(_ ⟶ _)} ([⟶]-intro p) = [⟶]-intro (weaken-union-singleton Γ₁Γ₂ p) weaken Γ₁Γ₂ {φ} ([⟶]-elim p q) = [⟶]-elim (weaken Γ₁Γ₂ p) (weaken Γ₁Γ₂ q) weaken Γ₁Γ₂ {.(_ ⟷ _)} ([⟷]-intro p q) = [⟷]-intro (weaken-union-singleton Γ₁Γ₂ p) (weaken-union-singleton Γ₁Γ₂ q) weaken Γ₁Γ₂ {φ} ([⟷]-elimₗ p q) = [⟷]-elimₗ (weaken Γ₁Γ₂ p) (weaken Γ₁Γ₂ q) weaken Γ₁Γ₂ {φ} ([⟷]-elimᵣ p q) = [⟷]-elimᵣ (weaken Γ₁Γ₂ p) (weaken Γ₁Γ₂ q) weaken-union-singleton Γ₁Γ₂ p = weaken (Either.mapLeft Γ₁Γ₂) p weaken-union : (Γ₁ ⊢_) ⊆ ((Γ₁ ∪ Γ₂) ⊢_) weaken-union = weaken Either.Left [⟵]-intro : ((Γ ∪ singleton(φ)) ⊢ ψ) → (Γ ⊢ (ψ ⟵ φ)) [⟵]-intro = [⟶]-intro [⟵]-elim : (Γ ⊢ φ) → (Γ ⊢ (ψ ⟵ φ)) → (Γ ⊢ ψ) [⟵]-elim = [⟶]-elim [¬¬]-elim : (Γ ⊢ ¬(¬ φ)) → (Γ ⊢ φ) [¬¬]-elim nnφ = ([¬]-elim ([⊥]-intro (direct(Right [≡]-intro)) (weaken-union nnφ) ) ) [¬¬]-intro : (Γ ⊢ φ) → (Γ ⊢ ¬(¬ φ)) [¬¬]-intro Γφ = ([¬]-intro ([⊥]-intro (weaken-union Γφ) (direct (Right [≡]-intro)) ) )
algebraic-stack_agda0000_doc_8716
{-# OPTIONS --without-K #-} open import Base module Homotopy.Skeleton where private module Graveyard {i} {A B : Set i} {f : A → B} where private data #skeleton₁ : Set i where #point : A → #skeleton₁ skeleton₁ : Set i skeleton₁ = #skeleton₁ point : A → skeleton₁ point = #point postulate -- HIT link : ∀ a₁ a₂ → f a₁ ≡ f a₂ → point a₁ ≡ point a₂ skeleton₁-rec : ∀ {l} (P : skeleton₁ → Set l) (point* : ∀ a → P (point a)) (link* : ∀ a₁ a₂ (p : f a₁ ≡ f a₂) → transport P (link a₁ a₂ p) (point* a₁) ≡ point* a₂) → (x : skeleton₁) → P x skeleton₁-rec P point* link* (#point a) = point* a postulate -- HIT skeleton₁-β-link : ∀ {l} (P : skeleton₁ → Set l) (point* : ∀ a → P (point a)) (link* : ∀ a₁ a₂ (p : f a₁ ≡ f a₂) → transport P (link a₁ a₂ p) (point* a₁) ≡ point* a₂) a₁ a₂ (p : f a₁ ≡ f a₂) → apd (skeleton₁-rec {l} P point* link*) (link a₁ a₂ p) ≡ link* a₁ a₂ p skeleton₁-rec-nondep : ∀ {l} (P : Set l) (point* : A → P) (link* : ∀ a₁ a₂ → f a₁ ≡ f a₂ → point* a₁ ≡ point* a₂) → (skeleton₁ → P) skeleton₁-rec-nondep P point* link* (#point a) = point* a postulate -- HIT skeleton₁-β-link-nondep : ∀ {l} (P : Set l) (point* : A → P) (link* : ∀ a₁ a₂ → f a₁ ≡ f a₂ → point* a₁ ≡ point* a₂) a₁ a₂ (p : f a₁ ≡ f a₂) → ap (skeleton₁-rec-nondep P point* link*) (link a₁ a₂ p) ≡ link* a₁ a₂ p open Graveyard public hiding (skeleton₁) module _ {i} {A B : Set i} where skeleton₁ : (A → B) → Set i skeleton₁ f = Graveyard.skeleton₁ {i} {A} {B} {f} skeleton₁-lifted : ∀ {f} → skeleton₁ f → B skeleton₁-lifted {f} = skeleton₁-rec-nondep B f (λ _ _ p → p)
algebraic-stack_agda0000_doc_8717
{-# OPTIONS --cubical-compatible --rewriting --local-confluence-check #-} open import Agda.Primitive using (Level; _⊔_; Setω; lzero; lsuc) infix 4 _≡_ data _≡_ {ℓ : Level} {A : Set ℓ} (a : A) : A → Set ℓ where refl : a ≡ a {-# BUILTIN REWRITE _≡_ #-} run : ∀ {ℓ} {A B : Set ℓ} → A ≡ B → A → B run refl x = x ap : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) {a₁ a₂} → a₁ ≡ a₂ → f a₁ ≡ f a₂ ap f refl = refl transport1 : ∀ {a b} {A : Set a} (B : A → Set b) {x y : A} (p : x ≡ y) → B x → B y transport1 B p = run (ap B p) ap-const : ∀ {a b} {A : Set a} {B : Set b} (f : B) {a₁ a₂ : A} (p : a₁ ≡ a₂) → ap (\ _ → f) p ≡ refl ap-const f refl = refl {-# REWRITE ap-const #-} ap2 : ∀ {a b rv} {A : Set a} {B : A → Set b} {RV : Set rv} (fn : ∀ a → B a → RV) {a₁ a₂} (pa : a₁ ≡ a₂) {b₁ b₂} (pb : transport1 B pa b₁ ≡ b₂) → fn a₁ b₁ ≡ fn a₂ b₂ ap2 fn refl refl = refl transport2 : ∀ {a b rv} {A : Set a} {B : A → Set b} (RV : ∀ a → B a → Set rv) {a₁ a₂} (pa : a₁ ≡ a₂) {b₁ b₂} (pb : transport1 B pa b₁ ≡ b₂) → RV a₁ b₁ → RV a₂ b₂ transport2 RV pa pb = run (ap2 RV pa pb) ap2-const : ∀ {a b rv} {A : Set a} {B : A → Set b} {RV : Set rv} (fn : RV) {a₁ a₂} (pa : a₁ ≡ a₂) {b₁ b₂} (pb : transport1 B pa b₁ ≡ b₂) → ap2 {a} {b} {rv} {A} {B} {RV} (λ _ _ → fn) pa pb ≡ refl ap2-const fn refl refl = refl {-# REWRITE ap2-const #-} ap2-const' : ∀ {a b rv} {A : Set a} {B : A → Set b} {RV : Set rv} (fn : RV) {a₁ a₂} (pa : a₁ ≡ a₂) {b₁ b₂} (pb : transport1 B pa b₁ ≡ b₂) → ap2 {a} {b} {rv} {A} {B} {RV} (λ _ _ → fn) pa pb ≡ refl ap2-const' {a} {b} {rv} {A} {B} {RV} fn pa pb = {!ap2 {a} {b} {_} {A} {_} {_} (λ _ _ → fn ≡ fn) pa _!}
algebraic-stack_agda0000_doc_8718
module conversion where open import lib open import cedille-types open import ctxt open import is-free open import lift open import rename open import subst open import syntax-util open import general-util open import to-string {- Some notes: -- hnf{TERM} implements erasure as well as normalization. -- hnf{TYPE} does not descend into terms. -- definitions are assumed to be in hnf -} data unfolding : Set where no-unfolding : unfolding unfold : (unfold-all : 𝔹) {- if ff we unfold just the head -} → (unfold-lift : 𝔹) {- if tt we unfold lifting types -} → (dampen-after-head-beta : 𝔹) {- if tt we will not unfold definitions after a head beta reduction -} → (erase : 𝔹) -- if tt erase the term as we unfold → unfolding unfolding-get-erased : unfolding → 𝔹 unfolding-get-erased no-unfolding = ff unfolding-get-erased (unfold _ _ _ e) = e unfolding-set-erased : unfolding → 𝔹 → unfolding unfolding-set-erased no-unfolding e = no-unfolding unfolding-set-erased (unfold b1 b2 b3 _) e = unfold b1 b2 b3 e unfold-all : unfolding unfold-all = unfold tt tt ff tt unfold-head : unfolding unfold-head = unfold ff tt ff tt unfold-head-no-lift : unfolding unfold-head-no-lift = unfold ff ff ff ff unfold-head-one : unfolding unfold-head-one = unfold ff tt tt tt unfold-dampen : (after-head-beta : 𝔹) → unfolding → unfolding unfold-dampen _ no-unfolding = no-unfolding unfold-dampen _ (unfold tt b b' e) = unfold tt b b e -- we do not dampen unfolding when unfolding everywhere unfold-dampen tt (unfold ff b tt e) = no-unfolding unfold-dampen tt (unfold ff b ff e) = (unfold ff b ff e) unfold-dampen ff _ = no-unfolding unfolding-elab : unfolding → unfolding unfolding-elab no-unfolding = no-unfolding unfolding-elab (unfold b b' b'' _) = unfold b b' b'' ff conv-t : Set → Set conv-t T = ctxt → T → T → 𝔹 {-# TERMINATING #-} -- main entry point -- does not assume erased conv-term : conv-t term conv-type : conv-t type conv-kind : conv-t kind -- assume erased conv-terme : conv-t term conv-argse : conv-t (𝕃 term) conv-typee : conv-t type conv-kinde : conv-t kind -- call hnf, then the conv-X-norm functions conv-term' : conv-t term conv-type' : conv-t type hnf : {ed : exprd} → ctxt → (u : unfolding) → ⟦ ed ⟧ → (is-head : 𝔹) → ⟦ ed ⟧ -- assume head normalized inputs conv-term-norm : conv-t term conv-type-norm : conv-t type conv-kind-norm : conv-t kind hnf-optClass : ctxt → unfolding → optClass → optClass -- hnf-tk : ctxt → unfolding → tk → tk -- does not assume erased conv-tk : conv-t tk conv-liftingType : conv-t liftingType conv-optClass : conv-t optClass -- conv-optType : conv-t optType conv-tty* : conv-t (𝕃 tty) -- assume erased conv-tke : conv-t tk conv-liftingTypee : conv-t liftingType conv-optClasse : conv-t optClass -- -- conv-optTypee : conv-t optType conv-ttye* : conv-t (𝕃 tty) conv-term Γ t t' = conv-terme Γ (erase t) (erase t') conv-terme Γ t t' with decompose-apps t | decompose-apps t' conv-terme Γ t t' | Var _ x , args | Var _ x' , args' = if ctxt-eq-rep Γ x x' && conv-argse Γ args args' then tt else conv-term' Γ t t' conv-terme Γ t t' | _ | _ = conv-term' Γ t t' conv-argse Γ [] [] = tt conv-argse Γ (a :: args) (a' :: args') = conv-terme Γ a a' && conv-argse Γ args args' conv-argse Γ _ _ = ff conv-type Γ t t' = conv-typee Γ (erase t) (erase t') conv-typee Γ t t' with decompose-tpapps t | decompose-tpapps t' conv-typee Γ t t' | TpVar _ x , args | TpVar _ x' , args' = if ctxt-eq-rep Γ x x' && conv-tty* Γ args args' then tt else conv-type' Γ t t' conv-typee Γ t t' | _ | _ = conv-type' Γ t t' conv-kind Γ k k' = conv-kinde Γ (erase k) (erase k') conv-kinde Γ k k' = conv-kind-norm Γ (hnf Γ unfold-head k tt) (hnf Γ unfold-head k' tt) conv-term' Γ t t' = conv-term-norm Γ (hnf Γ unfold-head t tt) (hnf Γ unfold-head t' tt) conv-type' Γ t t' = conv-type-norm Γ (hnf Γ unfold-head t tt) (hnf Γ unfold-head t' tt) -- is-head is only used in hnf{TYPE} hnf{TERM} Γ no-unfolding e hd = erase-term e hnf{TERM} Γ u (Parens _ t _) hd = hnf Γ u t hd hnf{TERM} Γ u (App t1 Erased t2) hd = hnf Γ u t1 hd hnf{TERM} Γ u (App t1 NotErased t2) hd with hnf Γ u t1 hd hnf{TERM} Γ u (App _ NotErased t2) hd | Lam _ _ _ x _ t1 = hnf Γ (unfold-dampen tt u) (subst Γ t2 x t1) hd hnf{TERM} Γ u (App _ NotErased t2) hd | t1 = App t1 NotErased (hnf Γ (unfold-dampen ff u) t2 hd) hnf{TERM} Γ u (Lam _ Erased _ _ _ t) hd = hnf Γ u t hd hnf{TERM} Γ u (Lam _ NotErased _ x oc t) hd with hnf (ctxt-var-decl x Γ) u t hd hnf{TERM} Γ u (Lam _ NotErased _ x oc t) hd | (App t' NotErased (Var _ x')) with x =string x' && ~ (is-free-in skip-erased x t') hnf{TERM} Γ u (Lam _ NotErased _ x oc t) hd | (App t' NotErased (Var _ x')) | tt = t' -- eta-contraction hnf{TERM} Γ u (Lam _ NotErased _ x oc t) hd | (App t' NotErased (Var _ x')) | ff = Lam posinfo-gen NotErased posinfo-gen x NoClass (App t' NotErased (Var posinfo-gen x')) hnf{TERM} Γ u (Lam _ NotErased _ x oc t) hd | t' = Lam posinfo-gen NotErased posinfo-gen x NoClass t' hnf{TERM} Γ u (Let _ (DefTerm _ x _ t) t') hd = hnf Γ u (subst Γ t x t') hd hnf{TERM} Γ u (Let _ (DefType _ x _ _) t') hd = hnf (ctxt-var-decl x Γ) u t' hd hnf{TERM} Γ (unfold _ _ _ _) (Var _ x) hd with ctxt-lookup-term-var-def Γ x hnf{TERM} Γ (unfold _ _ _ _) (Var _ x) hd | nothing = Var posinfo-gen x hnf{TERM} Γ (unfold ff _ _ e) (Var _ x) hd | just t = erase-if e t -- definitions should be stored in hnf hnf{TERM} Γ (unfold tt b b' e) (Var _ x) hd | just t = hnf Γ (unfold tt b b' e) t hd -- this might not be fully normalized, only head-normalized hnf{TERM} Γ u (AppTp t tp) hd = hnf Γ u t hd hnf{TERM} Γ u (Sigma _ t) hd = hnf Γ u t hd hnf{TERM} Γ u (Epsilon _ _ _ t) hd = hnf Γ u t hd hnf{TERM} Γ u (IotaPair _ t1 t2 _ _) hd = hnf Γ u t1 hd hnf{TERM} Γ u (IotaProj t _ _) hd = hnf Γ u t hd hnf{TERM} Γ u (Phi _ eq t₁ t₂ _) hd = hnf Γ u t₂ hd hnf{TERM} Γ u (Rho _ _ _ t _ t') hd = hnf Γ u t' hd hnf{TERM} Γ u (Chi _ T t') hd = hnf Γ u t' hd hnf{TERM} Γ u (Delta _ T t') hd = hnf Γ u t' hd hnf{TERM} Γ u (Theta _ u' t ls) hd = hnf Γ u (lterms-to-term u' t ls) hd hnf{TERM} Γ u (Beta _ _ (SomeTerm t _)) hd = hnf Γ u t hd hnf{TERM} Γ u (Beta _ _ NoTerm) hd = id-term hnf{TERM} Γ u (Open _ _ t) hd = hnf Γ u t hd hnf{TERM} Γ u x hd = x hnf{TYPE} Γ no-unfolding e _ = e hnf{TYPE} Γ u (TpParens _ t _) hd = hnf Γ u t hd hnf{TYPE} Γ u (NoSpans t _) hd = hnf Γ u t hd hnf{TYPE} Γ (unfold b b' _ _) (TpVar _ x) ff = TpVar posinfo-gen x hnf{TYPE} Γ (unfold b b' _ _) (TpVar _ x) tt with ctxt-lookup-type-var-def Γ x hnf{TYPE} Γ (unfold b b' _ _) (TpVar _ x) tt | just tp = tp hnf{TYPE} Γ (unfold b b' _ _) (TpVar _ x) tt | nothing = TpVar posinfo-gen x hnf{TYPE} Γ u (TpAppt tp t) hd with hnf Γ u tp hd hnf{TYPE} Γ u (TpAppt _ t) hd | TpLambda _ _ x _ tp = hnf Γ u (subst Γ t x tp) hd hnf{TYPE} Γ u (TpAppt _ t) hd | tp = TpAppt tp (erase-if (unfolding-get-erased u) t) hnf{TYPE} Γ u (TpApp tp tp') hd with hnf Γ u tp hd hnf{TYPE} Γ u (TpApp _ tp') hd | TpLambda _ _ x _ tp = hnf Γ u (subst Γ tp' x tp) hd hnf{TYPE} Γ u (TpApp _ tp') hd | tp with hnf Γ u tp' hd hnf{TYPE} Γ u (TpApp _ _) hd | tp | tp' = try-pull-lift-types tp tp' {- given (T1 T2), with T1 and T2 types, see if we can pull a lifting operation from the heads of T1 and T2 to surround the entire application. If not, just return (T1 T2). -} where try-pull-lift-types : type → type → type try-pull-lift-types tp1 tp2 with decompose-tpapps tp1 | decompose-tpapps (hnf Γ u tp2 tt) try-pull-lift-types tp1 tp2 | Lft _ _ X t l , args1 | Lft _ _ X' t' l' , args2 = if conv-tty* Γ args1 args2 then try-pull-term-in Γ t l (length args1) [] [] else TpApp tp1 tp2 where try-pull-term-in : ctxt → term → liftingType → ℕ → 𝕃 var → 𝕃 liftingType → type try-pull-term-in Γ t (LiftParens _ l _) n vars ltps = try-pull-term-in Γ t l n vars ltps try-pull-term-in Γ t (LiftArrow _ l) 0 vars ltps = recompose-tpapps (Lft posinfo-gen posinfo-gen X (Lam* vars (hnf Γ no-unfolding (App t NotErased (App* t' (map (λ v → NotErased , mvar v) vars))) tt)) (LiftArrow* ltps l) , args1) try-pull-term-in Γ (Lam _ _ _ x _ t) (LiftArrow l1 l2) (suc n) vars ltps = try-pull-term-in (ctxt-var-decl x Γ) t l2 n (x :: vars) (l1 :: ltps) try-pull-term-in Γ t (LiftArrow l1 l2) (suc n) vars ltps = let x = fresh-var "x" (ctxt-binds-var Γ) empty-renamectxt in try-pull-term-in (ctxt-var-decl x Γ) (App t NotErased (mvar x)) l2 n (x :: vars) (l1 :: ltps) try-pull-term-in Γ t l n vars ltps = TpApp tp1 tp2 try-pull-lift-types tp1 tp2 | _ | _ = TpApp tp1 tp2 hnf{TYPE} Γ u (Abs _ b _ x atk tp) _ with Abs posinfo-gen b posinfo-gen x atk (hnf (ctxt-var-decl x Γ) u tp ff) hnf{TYPE} Γ u (Abs _ b _ x atk tp) _ | tp' with to-abs tp' hnf{TYPE} Γ u (Abs _ _ _ _ _ _) _ | tp'' | just (mk-abs b x atk tt {- x is free in tp -} tp) = Abs posinfo-gen b posinfo-gen x atk tp hnf{TYPE} Γ u (Abs _ _ _ _ _ _) _ | tp'' | just (mk-abs b x (Tkk k) ff tp) = Abs posinfo-gen b posinfo-gen x (Tkk k) tp hnf{TYPE} Γ u (Abs _ _ _ _ _ _) _ | tp'' | just (mk-abs b x (Tkt tp') ff tp) = TpArrow tp' b tp hnf{TYPE} Γ u (Abs _ _ _ _ _ _) _ | tp'' | nothing = tp'' hnf{TYPE} Γ u (TpArrow tp1 arrowtype tp2) _ = TpArrow (hnf Γ u tp1 ff) arrowtype (hnf Γ u tp2 ff) hnf{TYPE} Γ u (TpEq _ t1 t2 _) _ = TpEq posinfo-gen (erase t1) (erase t2) posinfo-gen hnf{TYPE} Γ u (TpLambda _ _ x atk tp) _ = TpLambda posinfo-gen posinfo-gen x (hnf Γ u atk ff) (hnf (ctxt-var-decl x Γ) u tp ff) hnf{TYPE} Γ u @ (unfold b tt b'' b''') (Lft _ _ y t l) _ = let t = hnf (ctxt-var-decl y Γ) u t tt in do-lift Γ (Lft posinfo-gen posinfo-gen y t l) y l (λ t → hnf{TERM} Γ unfold-head t ff) t -- We need hnf{TYPE} to preserve types' well-kindedness, so we must check if -- the defined term is being checked against a type and use chi to make sure -- that wherever it is substituted, the term will have the same directionality. -- For example, "[e ◂ {a ≃ b} = ρ e' - β] - A (ρ e - a)", would otherwise -- head-normalize to A (ρ (ρ e' - β) - a), which wouldn't check because it -- synthesizes the type of "ρ e' - β" (which in turn fails to synthesize the type -- of "β"). Similar issues could happen if the term is synthesized and it uses a ρ, -- and then substitutes into a place where it would be checked against a type. hnf{TYPE} Γ u (TpLet _ (DefTerm _ x ot t) T) hd = hnf Γ u (subst Γ (Chi posinfo-gen ot t) x T) hd -- Note that if we ever remove the requirement that type-lambdas have a classifier, -- we would need to introduce a type-level chi to do the same thing as above. -- Currently, synthesizing or checking a type should not make a difference. hnf{TYPE} Γ u (TpLet _ (DefType _ x k T) T') hd = hnf Γ u (subst Γ T x T') hd hnf{TYPE} Γ u x _ = x hnf{KIND} Γ no-unfolding e hd = e hnf{KIND} Γ u (KndParens _ k _) hd = hnf Γ u k hd hnf{KIND} Γ (unfold _ _ _ _) (KndVar _ x ys) _ with ctxt-lookup-kind-var-def Γ x ... | nothing = KndVar posinfo-gen x ys ... | just (ps , k) = fst $ subst-params-args Γ ps ys k {- do-subst ys ps k where do-subst : args → params → kind → kind do-subst (ArgsCons (TermArg _ t) ys) (ParamsCons (Decl _ _ _ x _ _) ps) k = do-subst ys ps (subst Γ t x k) do-subst (ArgsCons (TypeArg t) ys) (ParamsCons (Decl _ _ _ x _ _) ps) k = do-subst ys ps (subst Γ t x k) do-subst _ _ k = k -- should not happen -} hnf{KIND} Γ u (KndPi _ _ x atk k) hd = if is-free-in check-erased x k then (KndPi posinfo-gen posinfo-gen x atk k) else tk-arrow-kind atk k hnf{KIND} Γ u x hd = x hnf{LIFTINGTYPE} Γ u x hd = x hnf{TK} Γ u (Tkk k) _ = Tkk (hnf Γ u k tt) hnf{TK} Γ u (Tkt tp) _ = Tkt (hnf Γ u tp ff) hnf{QUALIF} Γ u x hd = x hnf{ARG} Γ u x hd = x hnf-optClass Γ u NoClass = NoClass hnf-optClass Γ u (SomeClass atk) = SomeClass (hnf Γ u atk ff) {- this function reduces a term to "head-applicative" normal form, which avoids unfolding definitions if they would lead to a top-level lambda-abstraction or top-level application headed by a variable for which we do not have a (global) definition. -} {-# TERMINATING #-} hanf : ctxt → (e : 𝔹) → term → term hanf Γ e t with hnf Γ (unfolding-set-erased unfold-head-one e) t tt hanf Γ e t | t' with decompose-apps t' hanf Γ e t | t' | (Var _ x) , [] = t' hanf Γ e t | t' | (Var _ x) , args with ctxt-lookup-term-var-def Γ x hanf Γ e t | t' | (Var _ x) , args | nothing = t' hanf Γ e t | t' | (Var _ x) , args | just _ = hanf Γ e t' hanf Γ e t | t' | h , args {- h could be a Lambda if args is [] -} = t -- unfold across the term-type barrier hnf-term-type : ctxt → (e : 𝔹) → type → type hnf-term-type Γ e (TpEq _ t1 t2 _) = TpEq posinfo-gen (hanf Γ e t1) (hanf Γ e t2) posinfo-gen hnf-term-type Γ e (TpAppt tp t) = hnf Γ (unfolding-set-erased unfold-head e) (TpAppt tp (hanf Γ e t)) tt hnf-term-type Γ e tp = hnf Γ unfold-head tp tt conv-term-norm Γ (Var _ x) (Var _ x') = ctxt-eq-rep Γ x x' -- hnf implements erasure for terms, so we can ignore some subterms for App and Lam cases below conv-term-norm Γ (App t1 m t2) (App t1' m' t2') = conv-term-norm Γ t1 t1' && conv-term Γ t2 t2' conv-term-norm Γ (Lam _ l _ x oc t) (Lam _ l' _ x' oc' t') = conv-term (ctxt-rename x x' (ctxt-var-decl-if x' Γ)) t t' conv-term-norm Γ (Hole _) _ = tt conv-term-norm Γ _ (Hole _) = tt -- conv-term-norm Γ (Beta _ _ NoTerm) (Beta _ _ NoTerm) = tt -- conv-term-norm Γ (Beta _ _ (SomeTerm t _)) (Beta _ _ (SomeTerm t' _)) = conv-term Γ t t' -- conv-term-norm Γ (Beta _ _ _) (Beta _ _ _) = ff {- it can happen that a term is equal to a lambda abstraction in head-normal form, if that lambda-abstraction would eta-contract following some further beta-reductions. We implement this here by implicitly eta-expanding the variable and continuing the comparison. A simple example is λ v . t ((λ a . a) v) ≃ t -} conv-term-norm Γ (Lam _ l _ x oc t) t' = let x' = fresh-var x (ctxt-binds-var Γ) empty-renamectxt in conv-term (ctxt-rename x x' Γ) t (App t' NotErased (Var posinfo-gen x')) conv-term-norm Γ t' (Lam _ l _ x oc t) = let x' = fresh-var x (ctxt-binds-var Γ) empty-renamectxt in conv-term (ctxt-rename x x' Γ) (App t' NotErased (Var posinfo-gen x')) t conv-term-norm Γ _ _ = ff conv-type-norm Γ (TpVar _ x) (TpVar _ x') = ctxt-eq-rep Γ x x' conv-type-norm Γ (TpApp t1 t2) (TpApp t1' t2') = conv-type-norm Γ t1 t1' && conv-type Γ t2 t2' conv-type-norm Γ (TpAppt t1 t2) (TpAppt t1' t2') = conv-type-norm Γ t1 t1' && conv-term Γ t2 t2' conv-type-norm Γ (Abs _ b _ x atk tp) (Abs _ b' _ x' atk' tp') = eq-maybeErased b b' && conv-tk Γ atk atk' && conv-type (ctxt-rename x x' (ctxt-var-decl-if x' Γ)) tp tp' conv-type-norm Γ (TpArrow tp1 a1 tp2) (TpArrow tp1' a2 tp2') = eq-maybeErased a1 a2 && conv-type Γ tp1 tp1' && conv-type Γ tp2 tp2' conv-type-norm Γ (TpArrow tp1 a tp2) (Abs _ b _ _ (Tkt tp1') tp2') = eq-maybeErased a b && conv-type Γ tp1 tp1' && conv-type Γ tp2 tp2' conv-type-norm Γ (Abs _ b _ _ (Tkt tp1) tp2) (TpArrow tp1' a tp2') = eq-maybeErased a b && conv-type Γ tp1 tp1' && conv-type Γ tp2 tp2' conv-type-norm Γ (Iota _ _ x m tp) (Iota _ _ x' m' tp') = conv-type Γ m m' && conv-type (ctxt-rename x x' (ctxt-var-decl-if x' Γ)) tp tp' conv-type-norm Γ (TpEq _ t1 t2 _) (TpEq _ t1' t2' _) = conv-term Γ t1 t1' && conv-term Γ t2 t2' conv-type-norm Γ (Lft _ _ x t l) (Lft _ _ x' t' l') = conv-liftingType Γ l l' && conv-term (ctxt-rename x x' (ctxt-var-decl-if x' Γ)) t t' conv-type-norm Γ (TpLambda _ _ x atk tp) (TpLambda _ _ x' atk' tp') = conv-tk Γ atk atk' && conv-type (ctxt-rename x x' (ctxt-var-decl-if x' Γ)) tp tp' conv-type-norm Γ _ _ = ff {- even though hnf turns Pi-kinds where the variable is not free in the body into arrow kinds, we still need to check off-cases, because normalizing the body of a kind could cause the bound variable to be erased (hence allowing it to match an arrow kind). -} conv-kind-norm Γ (KndArrow k k₁) (KndArrow k' k'') = conv-kind Γ k k' && conv-kind Γ k₁ k'' conv-kind-norm Γ (KndArrow k k₁) (KndPi _ _ x (Tkk k') k'') = conv-kind Γ k k' && conv-kind Γ k₁ k'' conv-kind-norm Γ (KndArrow k k₁) _ = ff conv-kind-norm Γ (KndPi _ _ x (Tkk k₁) k) (KndArrow k' k'') = conv-kind Γ k₁ k' && conv-kind Γ k k'' conv-kind-norm Γ (KndPi _ _ x atk k) (KndPi _ _ x' atk' k'') = conv-tk Γ atk atk' && conv-kind (ctxt-rename x x' (ctxt-var-decl-if x' Γ)) k k'' conv-kind-norm Γ (KndPi _ _ x (Tkt t) k) (KndTpArrow t' k'') = conv-type Γ t t' && conv-kind Γ k k'' conv-kind-norm Γ (KndPi _ _ x (Tkt t) k) _ = ff conv-kind-norm Γ (KndPi _ _ x (Tkk k') k) _ = ff conv-kind-norm Γ (KndTpArrow t k) (KndTpArrow t' k') = conv-type Γ t t' && conv-kind Γ k k' conv-kind-norm Γ (KndTpArrow t k) (KndPi _ _ x (Tkt t') k') = conv-type Γ t t' && conv-kind Γ k k' conv-kind-norm Γ (KndTpArrow t k) _ = ff conv-kind-norm Γ (Star x) (Star x') = tt conv-kind-norm Γ (Star x) _ = ff conv-kind-norm Γ _ _ = ff -- should not happen, since the kinds are in hnf conv-tk Γ tk tk' = conv-tke Γ (erase-tk tk) (erase-tk tk') conv-tke Γ (Tkk k) (Tkk k') = conv-kind Γ k k' conv-tke Γ (Tkt t) (Tkt t') = conv-type Γ t t' conv-tke Γ _ _ = ff conv-liftingType Γ l l' = conv-liftingTypee Γ (erase l) (erase l') conv-liftingTypee Γ l l' = conv-kind Γ (liftingType-to-kind l) (liftingType-to-kind l') conv-optClass Γ NoClass NoClass = tt conv-optClass Γ (SomeClass x) (SomeClass x') = conv-tk Γ (erase-tk x) (erase-tk x') conv-optClass Γ _ _ = ff conv-optClasse Γ NoClass NoClass = tt conv-optClasse Γ (SomeClass x) (SomeClass x') = conv-tk Γ x x' conv-optClasse Γ _ _ = ff -- conv-optType Γ NoType NoType = tt -- conv-optType Γ (SomeType x) (SomeType x') = conv-type Γ x x' -- conv-optType Γ _ _ = ff conv-tty* Γ [] [] = tt conv-tty* Γ (tterm t :: args) (tterm t' :: args') = conv-term Γ (erase t) (erase t') && conv-tty* Γ args args' conv-tty* Γ (ttype t :: args) (ttype t' :: args') = conv-type Γ (erase t) (erase t') && conv-tty* Γ args args' conv-tty* Γ _ _ = ff conv-ttye* Γ [] [] = tt conv-ttye* Γ (tterm t :: args) (tterm t' :: args') = conv-term Γ t t' && conv-ttye* Γ args args' conv-ttye* Γ (ttype t :: args) (ttype t' :: args') = conv-type Γ t t' && conv-ttye* Γ args args' conv-ttye* Γ _ _ = ff hnf-qualif-term : ctxt → term → term hnf-qualif-term Γ t = hnf Γ unfold-head (qualif-term Γ t) tt hnf-qualif-type : ctxt → type → type hnf-qualif-type Γ t = hnf Γ unfold-head (qualif-type Γ t) tt hnf-qualif-kind : ctxt → kind → kind hnf-qualif-kind Γ t = hnf Γ unfold-head (qualif-kind Γ t) tt ctxt-params-def : params → ctxt → ctxt ctxt-params-def ps Γ@(mk-ctxt (fn , mn , _ , q) syms i symb-occs d) = mk-ctxt (fn , mn , ps' , q) syms i symb-occs d where ps' = qualif-params Γ ps ctxt-kind-def : posinfo → var → params → kind → ctxt → ctxt ctxt-kind-def pi v ps2 k Γ@(mk-ctxt (fn , mn , ps1 , q) (syms , mn-fn) i symb-occs d) = mk-ctxt (fn , mn , ps1 , qualif-insert-params q (mn # v) v ps1) (trie-insert-append2 syms fn mn v , mn-fn) (trie-insert i (mn # v) (kind-def (append-params ps1 $ qualif-params Γ ps2) k' , fn , pi)) symb-occs d where k' = hnf Γ unfold-head (qualif-kind Γ k) tt -- assumption: classifier (i.e. kind) already qualified ctxt-datatype-def : posinfo → var → params → kind → defDatatype → ctxt → ctxt ctxt-datatype-def pi v pa k dd Γ@(mk-ctxt (fn , mn , ps , q) (syms , mn-fn) i symb-occs d) = mk-ctxt (fn , mn , ps , q') ((trie-insert-append2 syms fn mn v) , mn-fn) (trie-insert i v' (datatype-def pa k , fn , pi)) symb-occs (trie-insert d v' dd) where v' = mn # v q' = qualif-insert-params q v' v ps -- assumption: classifier (i.e. kind) already qualified ctxt-type-def : posinfo → defScope → opacity → var → type → kind → ctxt → ctxt ctxt-type-def pi s op v t k Γ@(mk-ctxt (fn , mn , ps , q) (syms , mn-fn) i symb-occs d) = mk-ctxt (fn , mn , ps , q') ((if (s iff localScope) then syms else trie-insert-append2 syms fn mn v) , mn-fn) (trie-insert i v' (type-def (def-params s ps) op t' k , fn , pi)) symb-occs d where t' = hnf Γ unfold-head (qualif-type Γ t) tt v' = if s iff localScope then pi % v else mn # v q' = qualif-insert-params q v' v ps ctxt-const-def : posinfo → var → type → ctxt → ctxt ctxt-const-def pi c t Γ@(mk-ctxt mod@(fn , mn , ps , q) (syms , mn-fn) i symb-occs d) = mk-ctxt (fn , mn , ps , q') ((trie-insert-append2 syms fn mn c) , mn-fn) (trie-insert i c' (const-def t , fn , pi)) symb-occs d where c' = mn # c q' = qualif-insert-params q c' c ps -- assumption: classifier (i.e. type) already qualified ctxt-term-def : posinfo → defScope → opacity → var → term → type → ctxt → ctxt ctxt-term-def pi s op v t tp Γ@(mk-ctxt (fn , mn , ps , q) (syms , mn-fn) i symb-occs d) = mk-ctxt (fn , mn , ps , q') ((if (s iff localScope) then syms else trie-insert-append2 syms fn mn v) , mn-fn) (trie-insert i v' (term-def (def-params s ps) op t' tp , fn , pi)) symb-occs d where t' = hnf Γ unfold-head (qualif-term Γ t) tt v' = if s iff localScope then pi % v else mn # v q' = qualif-insert-params q v' v ps ctxt-term-udef : posinfo → defScope → opacity → var → term → ctxt → ctxt ctxt-term-udef pi s op v t Γ@(mk-ctxt (fn , mn , ps , q) (syms , mn-fn) i symb-occs d) = mk-ctxt (fn , mn , ps , qualif-insert-params q v' v ps) ((if (s iff localScope) then syms else trie-insert-append2 syms fn mn v) , mn-fn) (trie-insert i v' (term-udef (def-params s ps) op t' , fn , pi)) symb-occs d where t' = hnf Γ unfold-head (qualif-term Γ t) tt v' = if s iff localScope then pi % v else mn # v
algebraic-stack_agda0000_doc_8719
{-# OPTIONS --without-K #-} open import lib.Basics open import lib.types.Paths open import lib.types.Sigma open import lib.types.Span open import lib.types.Pointed open import lib.types.Pushout module lib.types.Join where module _ {i j} (A : Type i) (B : Type j) where *-span : Span *-span = span A B (A × B) fst snd infix 80 _*_ _*_ : Type _ _*_ = Pushout *-span module JoinElim {i j} {A : Type i} {B : Type j} {k} {P : A * B → Type k} (left* : (a : A) → P (left a)) (right* : (b : B) → P (right b)) (glue* : (ab : A × B) → left* (fst ab) == right* (snd ab) [ P ↓ glue ab ]) = PushoutElim left* right* glue* open JoinElim public using () renaming (f to Join-elim) module JoinRec {i j} {A : Type i} {B : Type j} {k} {D : Type k} (left* : (a : A) → D) (right* : (b : B) → D) (glue* : (ab : A × B) → left* (fst ab) == right* (snd ab)) = PushoutRec left* right* glue* open JoinRec public using () renaming (f to Join-rec) module _ {i j} (X : Ptd i) (Y : Ptd j) where *-⊙span : ⊙Span *-⊙span = ⊙span X Y (X ⊙× Y) ⊙fst ⊙snd infix 80 _⊙*_ _⊙*_ : Ptd _ _⊙*_ = ⊙Pushout *-⊙span module _ {i i' j j'} {A : Type i} {A' : Type i'} {B : Type j} {B' : Type j'} where equiv-* : A ≃ A' → B ≃ B' → A * B ≃ A' * B' equiv-* eqA eqB = equiv to from to-from from-to where module To = JoinRec {D = A' * B'} (left ∘ –> eqA) (right ∘ –> eqB) (λ{(a , b) → glue (–> eqA a , –> eqB b)}) module From = JoinRec {D = A * B} (left ∘ <– eqA) (right ∘ <– eqB) (λ{(a , b) → glue (<– eqA a , <– eqB b)}) to : A * B → A' * B' to = To.f from : A' * B' → A * B from = From.f to-from : ∀ y → to (from y) == y to-from = Join-elim (ap left ∘ <–-inv-r eqA) (ap right ∘ <–-inv-r eqB) to-from-glue where to-from-glue : ∀ (ab : A' × B') → ap left (<–-inv-r eqA (fst ab)) == ap right (<–-inv-r eqB (snd ab)) [ (λ y → to (from y) == y) ↓ glue ab ] to-from-glue (a , b) = ↓-app=idf-in $ ap left (<–-inv-r eqA a) ∙' glue (a , b) =⟨ htpy-natural'-app=cst (λ a → glue (a , b)) (<–-inv-r eqA a) ⟩ glue (–> eqA (<– eqA a) , b) =⟨ ! $ htpy-natural-cst=app (λ b → glue (–> eqA (<– eqA a) , b)) (<–-inv-r eqB b) ⟩ glue (–> eqA (<– eqA a) , –> eqB (<– eqB b)) ∙ ap right (<–-inv-r eqB b) =⟨ ! $ To.glue-β (<– eqA a , <– eqB b) |in-ctx (_∙ ap right (<–-inv-r eqB b)) ⟩ ap to (glue (<– eqA a , <– eqB b)) ∙ ap right (<–-inv-r eqB b) =⟨ ! $ From.glue-β (a , b) |in-ctx (λ p → ap to p ∙ ap right (<–-inv-r eqB b)) ⟩ ap to (ap from (glue (a , b))) ∙ ap right (<–-inv-r eqB b) =⟨ ! $ ap-∘ to from (glue (a , b)) |in-ctx (_∙ ap right (<–-inv-r eqB b)) ⟩ ap (to ∘ from) (glue (a , b)) ∙ ap right (<–-inv-r eqB b) ∎ from-to : ∀ x → from (to x) == x from-to = Join-elim (ap left ∘ <–-inv-l eqA) (ap right ∘ <–-inv-l eqB) from-to-glue where from-to-glue : ∀ (ab : A × B) → ap left (<–-inv-l eqA (fst ab)) == ap right (<–-inv-l eqB (snd ab)) [ (λ x → from (to x) == x) ↓ glue ab ] from-to-glue (a , b) = ↓-app=idf-in $ ap left (<–-inv-l eqA a) ∙' glue (a , b) =⟨ htpy-natural'-app=cst (λ a → glue (a , b)) (<–-inv-l eqA a) ⟩ glue (<– eqA (–> eqA a) , b) =⟨ ! $ htpy-natural-cst=app (λ b → glue (<– eqA (–> eqA a) , b)) (<–-inv-l eqB b) ⟩ glue (<– eqA (–> eqA a) , <– eqB (–> eqB b)) ∙ ap right (<–-inv-l eqB b) =⟨ ! $ From.glue-β (–> eqA a , –> eqB b) |in-ctx (_∙ ap right (<–-inv-l eqB b)) ⟩ ap from (glue (–> eqA a , –> eqB b)) ∙ ap right (<–-inv-l eqB b) =⟨ ! $ To.glue-β (a , b) |in-ctx (λ p → ap from p ∙ ap right (<–-inv-l eqB b)) ⟩ ap from (ap to (glue (a , b))) ∙ ap right (<–-inv-l eqB b) =⟨ ! $ ap-∘ from to (glue (a , b)) |in-ctx (_∙ ap right (<–-inv-l eqB b)) ⟩ ap (from ∘ to) (glue (a , b)) ∙ ap right (<–-inv-l eqB b) ∎ module _ {i i' j j'} {X : Ptd i} {X' : Ptd i'} {Y : Ptd j} {Y' : Ptd j'} where ⊙equiv-⊙* : X ⊙≃ X' → Y ⊙≃ Y' → X ⊙* Y ⊙≃ X' ⊙* Y' ⊙equiv-⊙* ⊙eqX ⊙eqY = ⊙≃-in (equiv-* (fst (⊙≃-out ⊙eqX)) (fst (⊙≃-out ⊙eqY))) (ap left (snd (⊙≃-out ⊙eqX)))
algebraic-stack_agda0000_doc_8736
{-# OPTIONS --without-K --safe #-} open import Categories.Category open import Categories.Category.Monoidal.Core using (Monoidal) open import Categories.Category.Monoidal.Symmetric open import Data.Sum module Categories.Category.Monoidal.CompactClosed {o ℓ e} {C : Category o ℓ e} (M : Monoidal C) where open import Level open import Categories.Functor.Bifunctor open import Categories.NaturalTransformation.NaturalIsomorphism open import Categories.Category.Monoidal.Rigid open Category C open Commutation C record CompactClosed : Set (levelOfTerm M) where field symmetric : Symmetric M rigid : LeftRigid M ⊎ RightRigid M
algebraic-stack_agda0000_doc_8737
{-# OPTIONS --rewriting #-} data Unit : Set where unit : Unit _+_ : Unit → Unit → Unit unit + x = x data _≡_ (x : Unit) : Unit → Set where refl : x ≡ x {-# BUILTIN REWRITE _≡_ #-} postulate f : Unit → Unit fu : f unit ≡ unit {-# REWRITE fu #-} g : Unit → Unit g unit = unit data D (h : Unit → Unit) (x : Unit) : Set where wrap : Unit → D h x run : ∀ {h x} → D h x → Unit run (wrap x) = x postulate d₁ : ∀ n x y (p : D y n) → x (run p + n) ≡ y (run p + n) → D x n d₂ : ∀ s n → D s n d₂ _ _ = wrap unit d₃ : D (λ _ → unit) unit d₃ = d₁ _ (λ _ → unit) (λ n → f (g n)) (d₂ (λ n → f (g n)) _) refl
algebraic-stack_agda0000_doc_8738
module Yoneda where open import Level open import Data.Product open import Relation.Binary import Relation.Binary.SetoidReasoning as SetR open Setoid renaming (_≈_ to eqSetoid) open import Basic open import Category import Functor import Nat open Category.Category open Functor.Functor open Nat.Nat open Nat.Export yoneda : ∀{C₀ C₁ ℓ} (C : Category C₀ C₁ ℓ) → Functor.Functor C PSh[ C ] yoneda C = record { fobj = λ x → Hom[ C ][-, x ] ; fmapsetoid = λ {A} {B} → record { mapping = λ f → HomNat[ C ][-, f ] ; preserveEq = λ {x} {y} x₁ x₂ → begin⟨ C ⟩ Map.mapping (component HomNat[ C ][-, x ] _) x₂ ≈⟨ refl-hom C ⟩ C [ x ∘ x₂ ] ≈⟨ ≈-composite C x₁ (refl-hom C) ⟩ C [ y ∘ x₂ ] ≈⟨ refl-hom C ⟩ Map.mapping (component HomNat[ C ][-, y ] _) x₂ ∎ } ; preserveId = λ x → leftId C ; preserveComp = λ x → assoc C } YonedaLemma : ∀{C₀ C₁ ℓ} {C : Category C₀ C₁ ℓ} {F : Obj PSh[ C ]} {X : Obj C} → Setoids [ Homsetoid [ op C , Setoids ] (fobj (yoneda C) X) F ≅ LiftSetoid {C₁} {suc (suc ℓ) ⊔ (suc (suc C₁) ⊔ suc C₀)} {ℓ} {C₀ ⊔ C₁ ⊔ ℓ} (fobj F X) ] YonedaLemma {C₀} {C₁} {ℓ} {C} {F} {X} = record { map-→ = nat→obj ; map-← = obj→nat ; proof = obj→obj≈id , nat→nat≈id } where nat→obj : Map.Map (Homsetoid [ op C , Setoids ] (fobj (yoneda C) X) F) (LiftSetoid (fobj F X)) nat→obj = record { mapping = λ α → lift (Map.mapping (component α X) (id C)) ; preserveEq = λ x≈y → lift (x≈y (id C)) } obj→nat : Map.Map (LiftSetoid (fobj F X)) (Homsetoid [ op C , Setoids ] (fobj (yoneda C) X) F) obj→nat = record { mapping = λ a → record { component = component-map a ; naturality = λ {c} {d} {f} x → SetR.begin⟨ fobj F d ⟩ Map.mapping (Setoids [ component-map a d ∘ fmap (fobj (yoneda C) X) f ]) x SetR.≈⟨ refl (fobj F d) ⟩ Map.mapping (Map.mapping (fmapsetoid F) (C [ x ∘ f ])) (lower a) SetR.≈⟨ (preserveComp F) (lower a) ⟩ Map.mapping (Map.mapping (fmapsetoid F) f) (Map.mapping (Map.mapping (fmapsetoid F) x) (lower a)) SetR.≈⟨ refl (fobj F d) ⟩ Map.mapping (Setoids [ fmap F f ∘ component-map a c ]) x SetR.∎} ; preserveEq = λ {x} {y} x≈y f → SetR.begin⟨ fobj F _ ⟩ Map.mapping (component-map x _) f SetR.≈⟨ refl (fobj F _) ⟩ Map.mapping (Map.mapping (fmapsetoid F) f) (lower x) SetR.≈⟨ Map.preserveEq (fmap F f) (lower x≈y) ⟩ Map.mapping (Map.mapping (fmapsetoid F) f) (lower y) SetR.≈⟨ refl (fobj F _) ⟩ Map.mapping (component-map y _) f SetR.∎} where component-map = λ a b → record { mapping = λ u → Map.mapping (fmap F u) (lower a) ; preserveEq = λ {x} {y} x≈y → SetR.begin⟨ fobj F b ⟩ Map.mapping (fmap F x) (lower a) SetR.≈⟨ (Functor.preserveEq F x≈y) (lower a) ⟩ Map.mapping (fmap F y) (lower a) SetR.∎ } obj→obj≈id : Setoids [ Setoids [ nat→obj ∘ obj→nat ] ≈ id Setoids ] obj→obj≈id = λ x → lift (SetR.begin⟨ fobj F X ⟩ lower (Map.mapping (Setoids [ nat→obj ∘ obj→nat ]) x) SetR.≈⟨ refl (fobj F X) ⟩ Map.mapping (Map.mapping (fmapsetoid F) (id C)) (lower x) SetR.≈⟨ (preserveId F) (lower x) ⟩ lower x SetR.≈⟨ refl (fobj F X) ⟩ lower (Map.mapping {A = LiftSetoid {ℓ′ = ℓ} (fobj F X)} (id Setoids) x) SetR.∎) nat→nat≈id : Setoids [ Setoids [ obj→nat ∘ nat→obj ] ≈ id Setoids ] nat→nat≈id α f = SetR.begin⟨ fobj F _ ⟩ Map.mapping (component (Map.mapping (Setoids [ obj→nat ∘ nat→obj ]) α) _) f SetR.≈⟨ refl (fobj F _) ⟩ Map.mapping (Setoids [ fmap F f ∘ component α X ]) (id C) SetR.≈⟨ lemma (id C) ⟩ Map.mapping (Setoids [ component α (dom C f) ∘ fmap (fobj (yoneda C) X) f ]) (id C) SetR.≈⟨ Map.preserveEq (component α (dom C f)) (leftId C) ⟩ Map.mapping (component α (dom C f)) f SetR.≈⟨ refl (fobj F _) ⟩ Map.mapping (component (Map.mapping (id Setoids {Homsetoid [ (op C) , Setoids ] _ _}) α) (dom C f)) f SetR.∎ where lemma : Setoids [ Setoids [ fmap F f ∘ component α X ] ≈ Setoids [ component α (dom C f) ∘ fmap (fobj (yoneda C) X) f ] ] lemma = sym-hom Setoids {f = Setoids [ component α (dom C f) ∘ fmap (fobj (yoneda C) X) f ]} {g = Setoids [ fmap F f ∘ component α X ]} (naturality α)
algebraic-stack_agda0000_doc_8739
------------------------------------------------------------------------ -- "Equational" reasoning combinator setup ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} open import Prelude open import Labelled-transition-system module Similarity.Weak.Equational-reasoning-instances {ℓ} {lts : LTS ℓ} where open import Bisimilarity lts open import Bisimilarity.Weak lts import Bisimilarity.Weak.Equational-reasoning-instances open import Equational-reasoning open import Expansion lts import Expansion.Equational-reasoning-instances open import Similarity lts open import Similarity.Weak lts instance reflexive≼ : ∀ {i} → Reflexive [ i ]_≼_ reflexive≼ = is-reflexive reflexive-≼ reflexive≼′ : ∀ {i} → Reflexive [ i ]_≼′_ reflexive≼′ = is-reflexive reflexive-≼′ convert≼≼ : ∀ {i} → Convertible [ i ]_≼_ [ i ]_≼_ convert≼≼ = is-convertible id convert≼′≼ : ∀ {i} → Convertible _≼′_ [ i ]_≼_ convert≼′≼ = is-convertible λ p≼′q → force p≼′q convert≼≼′ : ∀ {i} → Convertible [ i ]_≼_ [ i ]_≼′_ convert≼≼′ {i} = is-convertible lemma where lemma : ∀ {p q} → [ i ] p ≼ q → [ i ] p ≼′ q force (lemma p≼q) = p≼q convert≼′≼′ : ∀ {i} → Convertible [ i ]_≼′_ [ i ]_≼′_ convert≼′≼′ = is-convertible id convert≤≼ : ∀ {i} → Convertible [ i ]_≤_ [ i ]_≼_ convert≤≼ = is-convertible ≤⇒≼ convert≤′≼ : ∀ {i} → Convertible _≤′_ [ i ]_≼_ convert≤′≼ = is-convertible (convert ∘ ≤⇒≼′) convert≤≼′ : ∀ {i} → Convertible [ i ]_≤_ [ i ]_≼′_ convert≤≼′ {i} = is-convertible lemma where lemma : ∀ {p q} → [ i ] p ≤ q → [ i ] p ≼′ q force (lemma p≤q) = convert p≤q convert≤′≼′ : ∀ {i} → Convertible [ i ]_≤′_ [ i ]_≼′_ convert≤′≼′ = is-convertible ≤⇒≼′ convert≈≼ : ∀ {i} → Convertible [ i ]_≈_ [ i ]_≼_ convert≈≼ = is-convertible ≈⇒≼ convert≈′≼ : ∀ {i} → Convertible _≈′_ [ i ]_≼_ convert≈′≼ = is-convertible (convert ∘ ≈⇒≼′) convert≈≼′ : ∀ {i} → Convertible [ i ]_≈_ [ i ]_≼′_ convert≈≼′ {i} = is-convertible lemma where lemma : ∀ {p q} → [ i ] p ≈ q → [ i ] p ≼′ q force (lemma p≈q) = convert p≈q convert≈′≼′ : ∀ {i} → Convertible [ i ]_≈′_ [ i ]_≼′_ convert≈′≼′ = is-convertible ≈⇒≼′ convert∼≼ : ∀ {i} → Convertible [ i ]_∼_ [ i ]_≼_ convert∼≼ = is-convertible (≈⇒≼ ∘ convert {a = ℓ}) convert∼′≼ : ∀ {i} → Convertible _∼′_ [ i ]_≼_ convert∼′≼ = is-convertible (convert ∘ ≈⇒≼′ ∘ convert {a = ℓ}) convert∼≼′ : ∀ {i} → Convertible [ i ]_∼_ [ i ]_≼′_ convert∼≼′ {i} = is-convertible lemma where lemma : ∀ {p q} → [ i ] p ∼ q → [ i ] p ≼′ q force (lemma p∼q) = ≈⇒≼ (convert {a = ℓ} p∼q) convert∼′≼′ : ∀ {i} → Convertible [ i ]_∼′_ [ i ]_≼′_ convert∼′≼′ = is-convertible (≈⇒≼′ ∘ convert {a = ℓ}) trans≼≼ : ∀ {i} → Transitive′ [ i ]_≼_ _≼_ trans≼≼ = is-transitive transitive-≼ trans≼′≼ : Transitive′ _≼′_ _≼_ trans≼′≼ = is-transitive transitive-≼′ trans≼′≼′ : ∀ {i} → Transitive′ [ i ]_≼′_ _≼′_ trans≼′≼′ = is-transitive (λ p≼q → transitive-≼′ p≼q ∘ convert) trans≼≼′ : ∀ {i} → Transitive′ [ i ]_≼_ _≼′_ trans≼≼′ = is-transitive (λ p≼q → transitive-≼ p≼q ∘ convert) trans≳≼ : ∀ {i} → Transitive [ i ]_≳_ [ i ]_≼_ trans≳≼ = is-transitive transitive-≳≼ trans≳′≼ : ∀ {i} → Transitive _≳′_ [ i ]_≼_ trans≳′≼ = is-transitive (transitive-≳≼ ∘ convert {a = ℓ}) trans≳′≼′ : ∀ {i} → Transitive [ i ]_≳′_ [ i ]_≼′_ trans≳′≼′ = is-transitive transitive-≳≼′ trans≳≼′ : ∀ {i} → Transitive [ i ]_≳_ [ i ]_≼′_ trans≳≼′ = is-transitive (transitive-≳≼′ ∘ convert {a = ℓ})
algebraic-stack_agda0000_doc_8740
{-# OPTIONS --safe --warning=error --without-K #-} open import Numbers.Naturals.Semiring open import Functions open import LogicalFormulae open import Groups.Definition open import Rings.Definition open import Rings.IntegralDomains.Definition open import Setoids.Setoids open import Sets.EquivalenceRelations open import Setoids.Orders.Partial.Definition open import Setoids.Orders.Total.Definition open import Rings.Orders.Partial.Definition open import Rings.Orders.Total.Definition open import Groups.Orders.Archimedean module Fields.FieldOfFractions.Archimedean {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} {_*_ : A → A → A} {R : Ring S _+_ _*_} (I : IntegralDomain R) {c : _} {_<_ : Rel {_} {c} A} {pOrder : SetoidPartialOrder S _<_} {pRing : PartiallyOrderedRing R pOrder} (order : TotallyOrderedRing pRing) where open import Groups.Cyclic.Definition open import Fields.FieldOfFractions.Setoid I open import Fields.FieldOfFractions.Group I open import Fields.FieldOfFractions.Addition I open import Fields.FieldOfFractions.Ring I open import Fields.FieldOfFractions.Order I order open import Fields.FieldOfFractions.Field I open import Fields.Orders.Partial.Archimedean {F = fieldOfFractions} record { oRing = fieldOfFractionsPOrderedRing } open import Rings.Orders.Partial.Lemmas pRing open import Rings.Orders.Total.Lemmas open Setoid S open Equivalence eq open Ring R open Group additiveGroup open TotallyOrderedRing order open SetoidTotalOrder total private denomPower : (n : ℕ) → fieldOfFractionsSet.denom (positiveEltPower fieldOfFractionsGroup record { num = 1R ; denom = 1R ; denomNonzero = IntegralDomain.nontrivial I } n) ∼ 1R denomPower zero = reflexive denomPower (succ n) = transitive identIsIdent (denomPower n) denomPlus : {a : A} .(a!=0 : a ∼ 0R → False) (n1 n2 : A) → Setoid._∼_ fieldOfFractionsSetoid (fieldOfFractionsPlus record { num = n1 ; denom = a ; denomNonzero = a!=0 } record { num = n2 ; denom = a ; denomNonzero = a!=0 }) (record { num = n1 + n2 ; denom = a ; denomNonzero = a!=0 }) denomPlus {a} a!=0 n1 n2 = transitive *Commutative (transitive (*WellDefined reflexive (transitive (+WellDefined *Commutative reflexive) (symmetric *DistributesOver+))) *Associative) d : (a : fieldOfFractionsSet) → fieldOfFractionsSet.denom a ∼ 0R → False d record { num = num ; denom = denom ; denomNonzero = denomNonzero } bad = exFalso (denomNonzero bad) simpPower : (n : ℕ) → Setoid._∼_ fieldOfFractionsSetoid (positiveEltPower fieldOfFractionsGroup record { num = Ring.1R R ; denom = Ring.1R R ; denomNonzero = IntegralDomain.nontrivial I} n) record { num = positiveEltPower (Ring.additiveGroup R) (Ring.1R R) n ; denom = Ring.1R R ; denomNonzero = IntegralDomain.nontrivial I } simpPower zero = Equivalence.reflexive (Setoid.eq fieldOfFractionsSetoid) {Group.0G fieldOfFractionsGroup} simpPower (succ n) = Equivalence.transitive (Setoid.eq fieldOfFractionsSetoid) {record { denomNonzero = d (fieldOfFractionsPlus (record { num = 1R ; denom = 1R ; denomNonzero = λ t → IntegralDomain.nontrivial I t }) (positiveEltPower fieldOfFractionsGroup _ n)) }} {record { denomNonzero = λ t → IntegralDomain.nontrivial I (transitive (symmetric identIsIdent) t) }} {record { denomNonzero = IntegralDomain.nontrivial I }} (Group.+WellDefined fieldOfFractionsGroup {record { num = Ring.1R R ; denom = Ring.1R R ; denomNonzero = IntegralDomain.nontrivial I }} {positiveEltPower fieldOfFractionsGroup record { num = Ring.1R R ; denom = Ring.1R R ; denomNonzero = IntegralDomain.nontrivial I } n} {record { num = Ring.1R R ; denom = Ring.1R R ; denomNonzero = IntegralDomain.nontrivial I }} {record { num = positiveEltPower (Ring.additiveGroup R) (Ring.1R R) n ; denom = Ring.1R R ; denomNonzero = IntegralDomain.nontrivial I }} (Equivalence.reflexive (Setoid.eq fieldOfFractionsSetoid) {record { num = Ring.1R R ; denom = Ring.1R R ; denomNonzero = IntegralDomain.nontrivial I}}) (simpPower n)) (transitive (transitive (transitive *Commutative (transitive identIsIdent (+WellDefined identIsIdent identIsIdent))) (symmetric identIsIdent)) (*WellDefined (symmetric identIsIdent) reflexive)) lemma : (n : ℕ) {num denom : A} .(d!=0 : denom ∼ 0G → False) → (num * denom) < positiveEltPower additiveGroup 1R n → fieldOfFractionsComparison (record { num = num ; denom = denom ; denomNonzero = d!=0}) record { num = positiveEltPower additiveGroup (Ring.1R R) n ; denom = 1R ; denomNonzero = IntegralDomain.nontrivial I } lemma n {num} {denom} d!=0 numdenom<n with totality 0G denom ... | inl (inl 0<denom) with totality 0G 1R ... | inl (inl 0<1) = {!!} ... | inl (inr x) = exFalso (1<0False order x) ... | inr x = exFalso (IntegralDomain.nontrivial I (symmetric x)) lemma n {num} {denom} d!=0 numdenom<n | inl (inr denom<0) with totality 0G 1R ... | inl (inl 0<1) = {!!} ... | inl (inr 1<0) = exFalso (1<0False order 1<0) ... | inr 0=1 = exFalso (IntegralDomain.nontrivial I (symmetric 0=1)) lemma n {num} {denom} d!=0 numdenom<n | inr 0=denom = exFalso (d!=0 (symmetric 0=denom)) fieldOfFractionsArchimedean : Archimedean (toGroup R pRing) → ArchimedeanField fieldOfFractionsArchimedean arch (record { num = num ; denom = denom ; denomNonzero = denom!=0 }) 0<q with totality 0G denom ,, totality 0G 1R ... | inl (inl 0<denom) ,, inl (inl 0<1) rewrite refl { x = 0} = {!!} ... | inl (inl 0<denom) ,, inl (inr x) = exFalso {!!} ... | inl (inl 0<denom) ,, inr x = exFalso {!!} ... | inl (inr denom<0) ,, inl (inl 0<1) = 0 , {!!} where t : {!!} t = {!!} ... | inl (inr denom<0) ,, inl (inr x) = exFalso {!!} ... | inl (inr denom<0) ,, inr x = exFalso {!!} ... | inr x ,, snd = exFalso (denom!=0 (symmetric x)) --... | N , pr = N , SetoidPartialOrder.<WellDefined fieldOfFractionsOrder {record { denomNonzero = denom!=0 }} {record { denomNonzero = denom!=0 }} {record { denomNonzero = λ t → nonempty (symmetric t) }} {record { denomNonzero = d (positiveEltPower fieldOfFractionsGroup record { num = 1R ; denom = 1R ; denomNonzero = λ t → nonempty (symmetric t) } N) }} (Equivalence.reflexive (Setoid.eq fieldOfFractionsSetoid) { record { denomNonzero = denom!=0 } }) (Equivalence.symmetric (Setoid.eq fieldOfFractionsSetoid) {record { denomNonzero = λ t → d (positiveEltPower fieldOfFractionsGroup record { num = 1R ; denom = 1R ; denomNonzero = λ t → nonempty (symmetric t) } N) t }} {record { denomNonzero = λ t → nonempty (symmetric t) }} (simpPower N)) (lemma N denom!=0 pr) fieldOfFractionsArchimedean' : Archimedean (toGroup R pRing) → Archimedean (toGroup fieldOfFractionsRing fieldOfFractionsPOrderedRing) fieldOfFractionsArchimedean' arch = archFieldToGrp (reciprocalPositive fieldOfFractionsOrderedRing) (fieldOfFractionsArchimedean arch)
algebraic-stack_agda0000_doc_8741
------------------------------------------------------------------------ -- Vectors parameterised on types in Set₁ ------------------------------------------------------------------------ -- I want universe polymorphism. module Data.Vec1 where infixr 5 _∷_ open import Data.Nat open import Data.Vec using (Vec; []; _∷_) open import Data.Fin ------------------------------------------------------------------------ -- The type data Vec₁ (a : Set₁) : ℕ → Set₁ where [] : Vec₁ a zero _∷_ : ∀ {n} (x : a) (xs : Vec₁ a n) → Vec₁ a (suc n) ------------------------------------------------------------------------ -- Some operations map : ∀ {a b n} → (a → b) → Vec₁ a n → Vec₁ b n map f [] = [] map f (x ∷ xs) = f x ∷ map f xs map₀₁ : ∀ {a b n} → (a → b) → Vec a n → Vec₁ b n map₀₁ f [] = [] map₀₁ f (x ∷ xs) = f x ∷ map₀₁ f xs map₁₀ : ∀ {a b n} → (a → b) → Vec₁ a n → Vec b n map₁₀ f [] = [] map₁₀ f (x ∷ xs) = f x ∷ map₁₀ f xs lookup : ∀ {a n} → Fin n → Vec₁ a n → a lookup zero (x ∷ xs) = x lookup (suc i) (x ∷ xs) = lookup i xs
algebraic-stack_agda0000_doc_8742
open import Common.Prelude open import Common.Reflection open import Common.Equality postulate trustme : ∀ {a} {A : Set a} {x y : A} → x ≡ y magic : List (Arg Type) → Term → Tactic magic _ _ = give (def (quote trustme) []) id : ∀ {a} {A : Set a} → A → A id x = x science : List (Arg Type) → Term → Tactic science _ _ = give (def (quote id) []) by-magic : ∀ n → n + 4 ≡ 3 by-magic n = tactic magic by-science : ∀ n → 0 + n ≡ n by-science n = tactic science | refl
algebraic-stack_agda0000_doc_8743
module Issue274 where -- data ⊥ : Set where record U : Set where constructor roll field ap : U → U -- lemma : U → ⊥ -- lemma (roll u) = lemma (u (roll u)) -- bottom : ⊥ -- bottom = lemma (roll λ x → x)
algebraic-stack_agda0000_doc_8744
{-# OPTIONS --without-K #-} open import HoTT module cohomology.Choice where unchoose : ∀ {i j} {n : ℕ₋₂} {A : Type i} {B : A → Type j} → Trunc n (Π A B) → Π A (Trunc n ∘ B) unchoose = Trunc-rec (Π-level (λ _ → Trunc-level)) (λ f → [_] ∘ f) has-choice : ∀ {i j} (n : ℕ₋₂) (A : Type i) (B : A → Type j) → Type (lmax i j) has-choice {i} {j} n A B = is-equiv (unchoose {n = n} {A} {B}) {- Binary Choice -} module _ {k} where pick-Bool : ∀ {j} {C : Lift {j = k} Bool → Type j} → (C (lift true)) → (C (lift false)) → Π (Lift Bool) C pick-Bool x y (lift true) = x pick-Bool x y (lift false) = y pick-Bool-η : ∀ {j} {C : Lift Bool → Type j} (f : Π (Lift Bool) C) → pick-Bool (f (lift true)) (f (lift false)) == f pick-Bool-η {C = C} f = λ= lemma where lemma : (b : Lift Bool) → pick-Bool {C = C} (f (lift true)) (f (lift false)) b == f b lemma (lift true) = idp lemma (lift false) = idp module _ {i} {n : ℕ₋₂} {A : Lift {j = k} Bool → Type i} where choose-Bool : Π (Lift Bool) (Trunc n ∘ A) → Trunc n (Π (Lift Bool) A) choose-Bool f = Trunc-rec Trunc-level (λ ft → Trunc-rec Trunc-level (λ ff → [ pick-Bool ft ff ] ) (f (lift false))) (f (lift true)) choose-Bool-squash : (f : Π (Lift Bool) A) → choose-Bool (λ b → [ f b ]) == [ f ] choose-Bool-squash f = ap [_] (pick-Bool-η f) private unc-c : ∀ f → unchoose (choose-Bool f) == f unc-c f = transport (λ h → unchoose (choose-Bool h) == h) (pick-Bool-η f) (Trunc-elim {P = λ tft → unchoose (choose-Bool (pick-Bool tft (f (lift false)))) == pick-Bool tft (f (lift false))} (λ _ → =-preserves-level _ (Π-level (λ _ → Trunc-level))) (λ ft → Trunc-elim {P = λ tff → unchoose (choose-Bool (pick-Bool [ ft ] tff )) == pick-Bool [ ft ] tff} (λ _ → =-preserves-level _ (Π-level (λ _ → Trunc-level))) (λ ff → ! (pick-Bool-η _)) (f (lift false))) (f (lift true))) c-unc : ∀ tg → choose-Bool (unchoose tg) == tg c-unc = Trunc-elim {P = λ tg → choose-Bool (unchoose tg) == tg} (λ _ → =-preserves-level _ Trunc-level) (λ g → ap [_] (pick-Bool-η g)) Bool-has-choice : has-choice n (Lift Bool) A Bool-has-choice = is-eq unchoose choose-Bool unc-c c-unc
algebraic-stack_agda0000_doc_8745
{-# OPTIONS --without-K #-} module Data.Tuple where open import Data.Tuple.Base public import Data.Product as P Pair→× : ∀ {a b A B} → Pair {a} {b} A B → A P.× B Pair→× (fst , snd) = fst P., snd ×→Pair : ∀ {a b A B} → P._×_ {a} {b} A B → Pair A B ×→Pair (fst P., snd) = fst , snd
algebraic-stack_agda0000_doc_8746
module Type.NbE where open import Context open import Type.Core open import Function open import Data.Empty open import Data.Sum.Base infix 3 _⊢ᵗⁿᵉ_ _⊢ᵗⁿᶠ_ _⊨ᵗ_ infixl 9 _[_]ᵗ mutual Starⁿᵉ : Conᵏ -> Set Starⁿᵉ Θ = Θ ⊢ᵗⁿᵉ ⋆ Starⁿᶠ : Conᵏ -> Set Starⁿᶠ Θ = Θ ⊢ᵗⁿᶠ ⋆ data _⊢ᵗⁿᵉ_ Θ : Kind -> Set where Varⁿᵉ : ∀ {σ} -> σ ∈ Θ -> Θ ⊢ᵗⁿᵉ σ _∙ⁿᵉ_ : ∀ {σ τ} -> Θ ⊢ᵗⁿᵉ σ ⇒ᵏ τ -> Θ ⊢ᵗⁿᶠ σ -> Θ ⊢ᵗⁿᵉ τ _⇒ⁿᵉ_ : Starⁿᵉ Θ -> Starⁿᵉ Θ -> Starⁿᵉ Θ πⁿᵉ : ∀ σ -> Starⁿᵉ (Θ ▻ σ) -> Starⁿᵉ Θ μⁿᵉ : ∀ {κ} -> Θ ⊢ᵗⁿᶠ (κ ⇒ᵏ ⋆) ⇒ᵏ κ ⇒ᵏ ⋆ -> Θ ⊢ᵗⁿᶠ κ -> Starⁿᵉ Θ data _⊢ᵗⁿᶠ_ Θ : Kind -> Set where Neⁿᶠ : ∀ {σ} -> Θ ⊢ᵗⁿᵉ σ -> Θ ⊢ᵗⁿᶠ σ Lamⁿᶠ_ : ∀ {σ τ} -> Θ ▻ σ ⊢ᵗⁿᶠ τ -> Θ ⊢ᵗⁿᶠ σ ⇒ᵏ τ mutual embᵗⁿᵉ : ∀ {Θ σ} -> Θ ⊢ᵗⁿᵉ σ -> Θ ⊢ᵗ σ embᵗⁿᵉ (Varⁿᵉ v) = Var v embᵗⁿᵉ (φ ∙ⁿᵉ α) = embᵗⁿᵉ φ ∙ embᵗⁿᶠ α embᵗⁿᵉ (α ⇒ⁿᵉ β) = embᵗⁿᵉ α ⇒ embᵗⁿᵉ β embᵗⁿᵉ (πⁿᵉ σ α) = π σ (embᵗⁿᵉ α) embᵗⁿᵉ (μⁿᵉ ψ α) = μ (embᵗⁿᶠ ψ) (embᵗⁿᶠ α) embᵗⁿᶠ : ∀ {Θ σ} -> Θ ⊢ᵗⁿᶠ σ -> Θ ⊢ᵗ σ embᵗⁿᶠ (Neⁿᶠ α) = embᵗⁿᵉ α embᵗⁿᶠ (Lamⁿᶠ β) = Lam (embᵗⁿᶠ β) mutual renᵗⁿᵉ : ∀ {Θ Ξ σ} -> Θ ⊆ Ξ -> Θ ⊢ᵗⁿᵉ σ -> Ξ ⊢ᵗⁿᵉ σ renᵗⁿᵉ ι (Varⁿᵉ v) = Varⁿᵉ (renᵛ ι v) renᵗⁿᵉ ι (φ ∙ⁿᵉ α) = renᵗⁿᵉ ι φ ∙ⁿᵉ renᵗⁿᶠ ι α renᵗⁿᵉ ι (α ⇒ⁿᵉ β) = renᵗⁿᵉ ι α ⇒ⁿᵉ renᵗⁿᵉ ι β renᵗⁿᵉ ι (πⁿᵉ σ α) = πⁿᵉ σ (renᵗⁿᵉ (keep ι) α) renᵗⁿᵉ ι (μⁿᵉ ψ α) = μⁿᵉ (renᵗⁿᶠ ι ψ) (renᵗⁿᶠ ι α) renᵗⁿᶠ : ∀ {Θ Ξ σ} -> Θ ⊆ Ξ -> Θ ⊢ᵗⁿᶠ σ -> Ξ ⊢ᵗⁿᶠ σ renᵗⁿᶠ ι (Neⁿᶠ α) = Neⁿᶠ (renᵗⁿᵉ ι α) renᵗⁿᶠ ι (Lamⁿᶠ β) = Lamⁿᶠ (renᵗⁿᶠ (keep ι) β) mutual _⊨ᵗ_ : Conᵏ -> Kind -> Set Θ ⊨ᵗ σ = Θ ⊢ᵗⁿᵉ σ ⊎ Kripke Θ σ Kripke : Conᵏ -> Kind -> Set Kripke Θ ⋆ = ⊥ Kripke Θ (σ ⇒ᵏ τ) = ∀ {Ξ} -> Θ ⊆ Ξ -> Ξ ⊨ᵗ σ -> Ξ ⊨ᵗ τ Neˢ : ∀ {σ Θ} -> Θ ⊢ᵗⁿᵉ σ -> Θ ⊨ᵗ σ Neˢ = inj₁ Varˢ : ∀ {σ Θ} -> σ ∈ Θ -> Θ ⊨ᵗ σ Varˢ = Neˢ ∘ Varⁿᵉ renᵗˢ : ∀ {σ Θ Δ} -> Θ ⊆ Δ -> Θ ⊨ᵗ σ -> Δ ⊨ᵗ σ renᵗˢ ι (inj₁ α) = inj₁ (renᵗⁿᵉ ι α) renᵗˢ {⋆} ι (inj₂ ()) renᵗˢ {σ ⇒ᵏ τ} ι (inj₂ k) = inj₂ λ κ -> k (κ ∘ ι) readbackᵗ : ∀ {σ Θ} -> Θ ⊨ᵗ σ -> Θ ⊢ᵗⁿᶠ σ readbackᵗ (inj₁ α) = Neⁿᶠ α readbackᵗ {⋆} (inj₂ ()) readbackᵗ {σ ⇒ᵏ τ} (inj₂ k) = Lamⁿᶠ (readbackᵗ (k topᵒ (Varˢ vz))) _∙ˢ_ : ∀ {Θ σ τ} -> Θ ⊨ᵗ σ ⇒ᵏ τ -> Θ ⊨ᵗ σ -> Θ ⊨ᵗ τ inj₁ f ∙ˢ x = Neˢ (f ∙ⁿᵉ readbackᵗ x) inj₂ k ∙ˢ x = k idᵒ x groundⁿᵉ : ∀ {Θ} -> Θ ⊨ᵗ ⋆ -> Θ ⊢ᵗⁿᵉ ⋆ groundⁿᵉ (inj₁ α) = α groundⁿᵉ (inj₂ ()) environmentᵗˢ : Environment _⊨ᵗ_ environmentᵗˢ = record { varᵈ = Varˢ ; renᵈ = renᵗˢ } module _ where open Environment environmentᵗˢ mutual evalᵗ : ∀ {Θ Ξ σ} -> Ξ ⊢ᵉ Θ -> Θ ⊢ᵗ σ -> Ξ ⊨ᵗ σ evalᵗ ρ (Var v) = lookupᵉ v ρ evalᵗ ρ (Lam β) = inj₂ λ ι α -> evalᵗ (renᵉ ι ρ ▷ α) β evalᵗ ρ (φ ∙ α) = evalᵗ ρ φ ∙ˢ evalᵗ ρ α evalᵗ ρ (α ⇒ β) = inj₁ $ groundⁿᵉ (evalᵗ ρ α) ⇒ⁿᵉ groundⁿᵉ (evalᵗ ρ β) evalᵗ ρ (π σ α) = inj₁ $ πⁿᵉ σ ∘ groundⁿᵉ $ evalᵗ (keepᵉ ρ) α evalᵗ ρ (μ ψ α) = inj₁ $ μⁿᵉ (nfᵗ ρ ψ) (nfᵗ ρ α) nfᵗ : ∀ {Θ Ξ σ} -> Ξ ⊢ᵉ Θ -> Θ ⊢ᵗ σ -> Ξ ⊢ᵗⁿᶠ σ nfᵗ ρ = readbackᵗ ∘ evalᵗ ρ normalize : ∀ {Θ σ} -> Θ ⊢ᵗ σ -> Θ ⊢ᵗ σ normalize = embᵗⁿᶠ ∘ nfᵗ idᵉ _[_]ᵗ : ∀ {Θ σ τ} -> Θ ▻ σ ⊢ᵗ τ -> Θ ⊢ᵗ σ -> Θ ⊢ᵗ τ β [ α ]ᵗ = normalize $ Lam β ∙ α {-# DISPLAY normalize (Lam β ∙ α) = β [ α ]ᵗ #-}
algebraic-stack_agda0000_doc_8747
postulate _→_ : Set
algebraic-stack_agda0000_doc_8748
{-# OPTIONS --safe --no-termination-check #-} module Issue2442-conflicting where
algebraic-stack_agda0000_doc_8749
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.NType2 open import lib.Function2 open import lib.types.Group open import lib.types.Sigma open import lib.types.Truncation open import lib.groups.Homomorphism open import lib.groups.Isomorphism open import lib.groups.SubgroupProp module lib.groups.Subgroup where module _ {i j} {G : Group i} (P : SubgroupProp G j) where private module G = Group G module P = SubgroupProp P subgroup-struct : GroupStructure P.SubEl subgroup-struct = record {M} where module M where ident : P.SubEl ident = G.ident , P.ident inv : P.SubEl → P.SubEl inv (g , p) = G.inv g , P.inv p comp : P.SubEl → P.SubEl → P.SubEl comp (g₁ , p₁) (g₂ , p₂) = G.comp g₁ g₂ , P.comp p₁ p₂ abstract unit-l : ∀ g → comp ident g == g unit-l (g , _) = Subtype=-out P.subEl-prop (G.unit-l g) assoc : ∀ g₁ g₂ g₃ → comp (comp g₁ g₂) g₃ == comp g₁ (comp g₂ g₃) assoc (g₁ , _) (g₂ , _) (g₃ , _) = Subtype=-out P.subEl-prop (G.assoc g₁ g₂ g₃) inv-l : ∀ g → comp (inv g) g == ident inv-l (g , _) = Subtype=-out P.subEl-prop (G.inv-l g) Subgroup : Group (lmax i j) Subgroup = group _ SubEl-level subgroup-struct where abstract SubEl-level = Subtype-level P.subEl-prop G.El-level module Subgroup {i j} {G : Group i} (P : SubgroupProp G j) where private module P = SubgroupProp P module G = Group G grp = Subgroup P open Group grp public El=-out : ∀ {s₁ s₂ : El} → fst s₁ == fst s₂ → s₁ == s₂ El=-out = Subtype=-out P.subEl-prop inject : Subgroup P →ᴳ G inject = record {f = fst; pres-comp = λ _ _ → idp} inject-lift : ∀ {j} {H : Group j} (φ : H →ᴳ G) → Π (Group.El H) (P.prop ∘ GroupHom.f φ) → (H →ᴳ Subgroup P) inject-lift {H = H} φ P-all = record {M} where module H = Group H module φ = GroupHom φ module M where f : H.El → P.SubEl f h = φ.f h , P-all h abstract pres-comp : ∀ h₁ h₂ → f (H.comp h₁ h₂) == Group.comp (Subgroup P) (f h₁) (f h₂) pres-comp h₁ h₂ = Subtype=-out P.subEl-prop (φ.pres-comp h₁ h₂) full-subgroup : ∀ {i j} {G : Group i} {P : SubgroupProp G j} → is-fullᴳ P → Subgroup P ≃ᴳ G full-subgroup {G = G} {P} full = Subgroup.inject P , is-eq _ from to-from from-to where from : Group.El G → Subgroup.El P from g = g , full g abstract from-to : ∀ p → from (fst p) == p from-to p = Subtype=-out (SubgroupProp.subEl-prop P) idp to-from : ∀ g → fst (from g) == g to-from g = idp module _ {i} {j} {G : Group i} {H : Group j} (φ : G →ᴳ H) where private module G = Group G module H = Group H module φ = GroupHom φ module Ker = Subgroup (ker-propᴳ φ) Ker = Ker.grp module Im = Subgroup (im-propᴳ φ) Im = Im.grp im-lift : G →ᴳ Im im-lift = Im.inject-lift φ (λ g → [ g , idp ]) im-lift-is-surj : is-surjᴳ im-lift im-lift-is-surj (_ , s) = Trunc-fmap (λ {(g , p) → (g , Subtype=-out (_ , λ _ → Trunc-level) p)}) s module _ {i j k} {G : Group i} (P : SubgroupProp G j) (Q : SubgroupProp G k) where -- FIXME looks like a bad name Subgroup-fmap-r : P ⊆ᴳ Q → Subgroup P →ᴳ Subgroup Q Subgroup-fmap-r P⊆Q = group-hom (Σ-fmap-r P⊆Q) (λ _ _ → Subtype=-out (SubgroupProp.subEl-prop Q) idp) Subgroup-emap-r : P ⊆ᴳ Q → Q ⊆ᴳ P → Subgroup P ≃ᴳ Subgroup Q Subgroup-emap-r P⊆Q Q⊆P = Subgroup-fmap-r P⊆Q , is-eq _ (Σ-fmap-r Q⊆P) (λ _ → Subtype=-out (SubgroupProp.subEl-prop Q) idp) (λ _ → Subtype=-out (SubgroupProp.subEl-prop P) idp)
algebraic-stack_agda0000_doc_8750
module Lemmachine.Resource.Configure where open import Lemmachine.Request open import Lemmachine.Response open import Lemmachine.Resource open import Lemmachine.Resource.Universe open import Data.Bool open import Data.Maybe open import Data.Product open import Data.List open import Data.Function using (const) private update : (code : Code) → El code → Resource → Resource update resourceExists f c = record { resourceExists = f ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update serviceAvailable f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = f ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update isAuthorized f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = f ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update forbidden f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = f ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update allowMissingPost f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = f ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update malformedRequest f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = f ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update uriTooLong f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = f ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update knownContentType f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = f ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update validContentHeaders f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = f ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update validEntityLength f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = f ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update options f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = f ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update allowedMethods f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = f ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update knownMethods f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = f ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update deleteResource f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = f ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update deleteCompleted f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = f ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update postIsCreate f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = f ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update createPath f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = f ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update processPost f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = f ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update contentTypesProvided f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = f ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update languageAvailable f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = f ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update contentTypesAccepted f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = f ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update charsetsProvided f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = f ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update encodingsProvided f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = f ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update variances f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = f ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update isConflict f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = f ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update multipleChoices f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = f ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update previouslyExisted f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = f ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update movedPermanently f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = f ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update movedTemporarily f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = f ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update lastModified f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = f ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update expires f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = f ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update generateETag f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = f ; finishRequest = Resource.finishRequest c ; body = Resource.body c } update finishRequest f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = f ; body = Resource.body c } update body f c = record { resourceExists = Resource.resourceExists c ; serviceAvailable = Resource.serviceAvailable c ; isAuthorized = Resource.isAuthorized c ; forbidden = Resource.forbidden c ; allowMissingPost = Resource.allowMissingPost c ; malformedRequest = Resource.malformedRequest c ; uriTooLong = Resource.uriTooLong c ; knownContentType = Resource.knownContentType c ; validContentHeaders = Resource.validContentHeaders c ; validEntityLength = Resource.validEntityLength c ; options = Resource.options c ; allowedMethods = Resource.allowedMethods c ; knownMethods = Resource.knownMethods c ; deleteResource = Resource.deleteResource c ; deleteCompleted = Resource.deleteCompleted c ; postIsCreate = Resource.postIsCreate c ; createPath = Resource.createPath c ; processPost = Resource.processPost c ; contentTypesProvided = Resource.contentTypesProvided c ; languageAvailable = Resource.languageAvailable c ; contentTypesAccepted = Resource.contentTypesAccepted c ; charsetsProvided = Resource.charsetsProvided c ; encodingsProvided = Resource.encodingsProvided c ; variances = Resource.variances c ; isConflict = Resource.isConflict c ; multipleChoices = Resource.multipleChoices c ; previouslyExisted = Resource.previouslyExisted c ; movedPermanently = Resource.movedPermanently c ; movedTemporarily = Resource.movedTemporarily c ; lastModified = Resource.lastModified c ; expires = Resource.expires c ; generateETag = Resource.generateETag c ; finishRequest = Resource.finishRequest c ; body = f } default : Resource default = record { resourceExists = const true ; serviceAvailable = const true ; isAuthorized = const true ; forbidden = const false ; allowMissingPost = const false ; malformedRequest = const false ; uriTooLong = const false ; knownContentType = const true ; validContentHeaders = const true ; validEntityLength = const true ; options = const [] ; allowedMethods = const (HEAD ∷ GET ∷ []) ; knownMethods = const (HEAD ∷ GET ∷ PUT ∷ DELETE ∷ POST ∷ TRACE ∷ CONNECT ∷ OPTIONS ∷ []) ; deleteResource = const false ; deleteCompleted = const true ; postIsCreate = const false ; createPath = const nothing ; processPost = const false ; contentTypesProvided = const [ "text/html" ] ; languageAvailable = const true ; contentTypesAccepted = const [] ; charsetsProvided = const [] ; encodingsProvided = const [ "identity" , "defaultEncoder" ] ; variances = const [] ; isConflict = const false ; multipleChoices = const false ; previouslyExisted = const false ; movedPermanently = const nothing ; movedTemporarily = const nothing ; lastModified = const nothing ; expires = const nothing ; generateETag = const nothing ; finishRequest = const true ; body = defaultHtml } configure : Resource → Hooks → Resource configure base [] = base configure base ((code , f) ∷ cfs) = update code f (configure base cfs) toResource : Hooks → Resource toResource props = configure default props
algebraic-stack_agda0000_doc_8751
------------------------------------------------------------------------ -- The Agda standard library -- -- Finite sets, based on AVL trees ------------------------------------------------------------------------ open import Relation.Binary open import Relation.Binary.PropositionalEquality using (_≡_) module Data.AVL.Sets {k ℓ} {Key : Set k} {_<_ : Rel Key ℓ} (isStrictTotalOrder : IsStrictTotalOrder _≡_ _<_) where import Data.AVL as AVL open import Data.Bool open import Data.List as List using (List) open import Data.Maybe as Maybe open import Data.Product as Prod using (_×_; _,_; proj₁) open import Data.Unit open import Function open import Level -- The set type. (Note that Set is a reserved word.) private open module S = AVL (const ⊤) isStrictTotalOrder public using () renaming (Tree to ⟨Set⟩) -- Repackaged functions. empty : ⟨Set⟩ empty = S.empty singleton : Key → ⟨Set⟩ singleton k = S.singleton k _ insert : Key → ⟨Set⟩ → ⟨Set⟩ insert k = S.insert k _ delete : Key → ⟨Set⟩ → ⟨Set⟩ delete = S.delete _∈?_ : Key → ⟨Set⟩ → Bool _∈?_ = S._∈?_ headTail : ⟨Set⟩ → Maybe (Key × ⟨Set⟩) headTail s = Maybe.map (Prod.map proj₁ id) (S.headTail s) initLast : ⟨Set⟩ → Maybe (⟨Set⟩ × Key) initLast s = Maybe.map (Prod.map id proj₁) (S.initLast s) fromList : List Key → ⟨Set⟩ fromList = S.fromList ∘ List.map (λ k → (k , _)) toList : ⟨Set⟩ → List Key toList = List.map proj₁ ∘ S.toList
algebraic-stack_agda0000_doc_16640
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020 Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import Function open import Data.Unit open import Data.List as List open import Data.Char open import Data.Nat as ℕ open import Data.Product open import Data.String open import Relation.Nullary using (Dec; yes; no) open import Category.Functor open import Reflection open import Optics.Functorial module Optics.Reflection where private tcMapM : {A B : Set} → (A → TC B) → List A → TC (List B) tcMapM f [] = return [] tcMapM f (x ∷ xs) = do y ← f x ys ← tcMapM f xs return (y ∷ ys) count : ℕ → List ℕ count 0 = [] count (suc n) = 0 ∷ List.map suc (count n) List-last : {A : Set} → A → List A → A List-last d [] = d List-last d (x ∷ []) = x List-last d (x ∷ xs) = List-last d xs ai : {A : Set} → A → Arg A ai x = arg (arg-info visible relevant) x record MetaLens : Set where constructor ml field mlName : Name mlType : Type mkDef : Term -- Example call: -- Let: -- > record Test : Set where -- > constructor test -- > field -- > firstField : ℕ -- > secondField : Maybe String -- -- Then; consider the call: -- -- > go Test test [x , y] 2 secondField -- -- What we want to generate is: -- -- -- > secondField : Lens Name (Maybe String) -- > secondField = lens (λ { F rf f (test x y) -- > → (RawFunctor._<$>_ rf) -- > (λ y' → test x y') (f y) -- > }) -- -- Which is captured by the MetaLens go : Name → Name → List String → ℕ → (Name × Arg Name) → TC MetaLens go rec cName vars curr (lensName , (arg _ fld)) = do -- Get the type of the field; in our case: Mabe String tyFld ← (getType fld >>= parseTy) -- compute the full lens type: Lens Test (Maybe String) let finalTy = def (quote Lens) (ai (def rec []) ∷ ai tyFld ∷ []) -- compute the clause of the lens: return (ml lensName finalTy genTerm) where parseTy : Type → TC Type parseTy (pi _ (abs _ t)) = parseTy t parseTy (var (suc x) i) = return (var x i) parseTy r = return r -- We might be at field 0; but our de Bruijn index depends -- on the total of fields curr' : ℕ curr' = List.length vars ∸ suc curr testxy : Pattern testxy = Pattern.con cName (List.map (ai ∘ Pattern.var) vars) myabs : Term → Term myabs t = pat-lam (Clause.clause (ai (Pattern.var "F") ∷ ai (Pattern.var "rf") ∷ ai (Pattern.var "f") ∷ ai testxy ∷ []) t ∷ []) [] myvar : ℕ → List (Arg Term) → Term myvar n args = var (List.length vars + n) args RawFunctor-<$>-var2 : Term → Term → Term RawFunctor-<$>-var2 testxy' fy = let rawf = quote RawFunctor._<$>_ in def rawf (ai (myvar 1 []) ∷ (ai testxy') ∷ (ai fy) ∷ []) f-varN : Term f-varN = myvar 0 (ai (var curr' []) ∷ []) xy' : List (Arg Term) xy' = let xs = reverse (count (List.length vars)) in List.map (λ m → ai (var (suc+set0 m) [])) xs where suc+set0 : ℕ → ℕ suc+set0 m = case m ℕ.≟ curr' of λ { (no _) → suc m ; (yes _) → zero } testxy' : Term testxy' = lam visible (abs "y'" (con cName xy')) -- We will now generate the RHS of second field: lens (λ { F rf ⋯ genTerm : Term genTerm = con (quote lens) (ai (myabs (RawFunctor-<$>-var2 testxy' f-varN)) ∷ []) mkLensFrom : Name → Definition → List Name → TC (List MetaLens) mkLensFrom rec (record-type c fs) lnames = do let xs = count (List.length fs) let vars = List.map (flip Data.String.replicate 'v' ∘ suc) xs tcMapM (uncurry (go rec c vars)) (List.zip xs (List.zip lnames fs)) mkLensFrom _ _ _ = typeError (strErr "Not a record" ∷ []) defineLens : MetaLens → TC ⊤ defineLens (ml n ty trm) = do -- typeError (nameErr n ∷ strErr "%%" ∷ termErr ty ∷ strErr "%%" ∷ termErr trm ∷ []) declareDef (arg (arg-info visible relevant) n) ty defineFun n (Clause.clause [] trm ∷ []) mkLens : Name → List Name → TC ⊤ mkLens rec lenses = do r ← getDefinition rec res ← mkLensFrom rec r lenses tcMapM defineLens res return tt -- usage will be: unquoteDecl = mkLens RecordName
algebraic-stack_agda0000_doc_16641
{- This second-order signature was created from the following second-order syntax description: syntax CommRing | CR type * : 0-ary term zero : * | 𝟘 add : * * -> * | _⊕_ l20 one : * | 𝟙 mult : * * -> * | _⊗_ l30 neg : * -> * | ⊖_ r50 theory (𝟘U⊕ᴸ) a |> add (zero, a) = a (𝟘U⊕ᴿ) a |> add (a, zero) = a (⊕A) a b c |> add (add(a, b), c) = add (a, add(b, c)) (⊕C) a b |> add(a, b) = add(b, a) (𝟙U⊗ᴸ) a |> mult (one, a) = a (𝟙U⊗ᴿ) a |> mult (a, one) = a (⊗A) a b c |> mult (mult(a, b), c) = mult (a, mult(b, c)) (⊗D⊕ᴸ) a b c |> mult (a, add (b, c)) = add (mult(a, b), mult(a, c)) (⊗D⊕ᴿ) a b c |> mult (add (a, b), c) = add (mult(a, c), mult(b, c)) (𝟘X⊗ᴸ) a |> mult (zero, a) = zero (𝟘X⊗ᴿ) a |> mult (a, zero) = zero (⊖N⊕ᴸ) a |> add (neg (a), a) = zero (⊖N⊕ᴿ) a |> add (a, neg (a)) = zero (⊗C) a b |> mult(a, b) = mult(b, a) -} module CommRing.Signature where open import SOAS.Context open import SOAS.Common open import SOAS.Syntax.Signature *T public open import SOAS.Syntax.Build *T public -- Operator symbols data CRₒ : Set where zeroₒ addₒ oneₒ multₒ negₒ : CRₒ -- Term signature CR:Sig : Signature CRₒ CR:Sig = sig λ { zeroₒ → ⟼₀ * ; addₒ → (⊢₀ *) , (⊢₀ *) ⟼₂ * ; oneₒ → ⟼₀ * ; multₒ → (⊢₀ *) , (⊢₀ *) ⟼₂ * ; negₒ → (⊢₀ *) ⟼₁ * } open Signature CR:Sig public
algebraic-stack_agda0000_doc_16642
module examplesPaperJFP.Console where open import examplesPaperJFP.NativeIOSafe open import examplesPaperJFP.BasicIO hiding (main) open import examplesPaperJFP.ConsoleInterface public IOConsole : Set → Set IOConsole = IO ConsoleInterface --IOConsole+ : Set → Set --IOConsole+ = IO+ ConsoleInterface translateIOConsoleLocal : (c : ConsoleCommand) → NativeIO (ConsoleResponse c) translateIOConsoleLocal (putStrLn s) = nativePutStrLn s translateIOConsoleLocal getLine = nativeGetLine translateIOConsole : {A : Set} → IOConsole A → NativeIO A translateIOConsole = translateIO translateIOConsoleLocal main : NativeIO Unit main = nativePutStrLn "Console"
algebraic-stack_agda0000_doc_16643
open import Signature import Program -- | Herbrand model that takes the distinction between inductive -- and coinductive clauses into account. module Herbrand (Σ : Sig) (V : Set) (P : Program.Program Σ V) where open import Function open import Data.Empty open import Data.Product as Prod renaming (Σ to ⨿) open import Data.Sum as Sum open import Relation.Unary hiding (_⇒_) open import Relation.Binary.PropositionalEquality hiding ([_]) open import Program Σ V open import Terms Σ mutual record Herbrand-ν (t : T∞ ⊥) : Set where coinductive field bw-closed : (∀ (i : dom-ν P) {σ} → (t ~ app∞ σ (χ (geth-ν P i))) → ∀ (j : dom (getb-ν P i)) → (app∞ σ (χ (get (getb-ν P i) j))) ∈ Herbrand-ν) ⊎ (t ∈ Herbrand-μ) data Herbrand-μ : T∞ ⊥ → Set where fw-closed : (t : T∞ ⊥) → (t ∈ Herbrand-μ) → (i : dom-μ P) (σ : Subst∞ V ⊥) → t ≡ app∞ σ (χ (geth-μ P i)) → (j : dom (getb-μ P i)) → Herbrand-μ (app∞ σ (χ (get (getb-μ P i) j))) coind-μ : {t : T∞ ⊥} → t ∈ Herbrand-ν → Herbrand-μ t open Herbrand-ν public
algebraic-stack_agda0000_doc_16644
{-# OPTIONS --cubical --safe #-} module Cubical.Data.Bool.Base where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Data.Empty open import Cubical.Relation.Nullary open import Cubical.Relation.Nullary.DecidableEq -- Obtain the booleans open import Agda.Builtin.Bool public infixr 6 _and_ infixr 5 _or_ not : Bool → Bool not true = false not false = true _or_ : Bool → Bool → Bool false or false = false false or true = true true or false = true true or true = true _and_ : Bool → Bool → Bool false and false = false false and true = false true and false = false true and true = true caseBool : ∀ {ℓ} → {A : Type ℓ} → (a0 aS : A) → Bool → A caseBool att aff true = att caseBool att aff false = aff _≟_ : Discrete Bool false ≟ false = yes refl false ≟ true = no λ p → subst (caseBool ⊥ Bool) p true true ≟ false = no λ p → subst (caseBool Bool ⊥) p true true ≟ true = yes refl Dec→Bool : ∀ {ℓ} {A : Type ℓ} → Dec A → Bool Dec→Bool (yes p) = true Dec→Bool (no ¬p) = false
algebraic-stack_agda0000_doc_16645
{-# OPTIONS --safe #-} module Cubical.Algebra.CommRing.QuotientRing where open import Cubical.Foundations.Prelude open import Cubical.HITs.SetQuotients hiding (_/_) open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.Ideal open import Cubical.Algebra.Ring open import Cubical.Algebra.Ring.QuotientRing renaming (_/_ to _/Ring_) hiding (asRing) private variable ℓ : Level _/_ : (R : CommRing ℓ) → (I : IdealsIn R) → CommRing ℓ R / I = fst asRing , commringstr _ _ _ _ _ (iscommring (RingStr.isRing (snd asRing)) (elimProp2 (λ _ _ → squash/ _ _) commEq)) where asRing = (CommRing→Ring R) /Ring (CommIdeal→Ideal I) _·/_ : fst asRing → fst asRing → fst asRing _·/_ = RingStr._·_ (snd asRing) commEq : (x y : fst R) → ([ x ] ·/ [ y ]) ≡ ([ y ] ·/ [ x ]) commEq x y i = [ CommRingStr.·Comm (snd R) x y i ] [_]/ : {R : CommRing ℓ} {I : IdealsIn R} → (a : fst R) → fst (R / I) [ a ]/ = [ a ]
algebraic-stack_agda0000_doc_16646
{-# OPTIONS --rewriting #-} module RingSolving where open import Data.Nat hiding (_≟_) open import Data.Nat.Properties hiding (_≟_) import Relation.Binary.PropositionalEquality open Relation.Binary.PropositionalEquality open import Agda.Builtin.Equality.Rewrite open import Function import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl) module _ (A : Set) where infixr 5 _+H_ infixr 6 _*H_ infixr 5 _:+_ infixr 6 _:*_ infixr 5 _+A_ infixr 6 _*A_ postulate #0 : A #1 : A _+A_ : A → A → A _*A_ : A → A → A data Poly : Set where con : A → Poly var : Poly _:+_ : Poly → Poly → Poly _:*_ : Poly → Poly → Poly data Horner : Set where PC : A → Horner PX : A → Horner → Horner scalMapHorner : (A → A) → Horner → Horner scalMapHorner f (PC x) = PC (f x) scalMapHorner f (PX x xs) = PX (f x) (scalMapHorner f xs) postulate extensionality : {S : Set}{T : S -> Set} {f g : (x : S) -> T x} -> ((x : S) -> f x ≡ g x) -> f ≡ g postulate +A-id-l : ∀ m → #0 +A m ≡ m *A-id-l : ∀ m → #1 *A m ≡ m +A-id-r : ∀ m → m +A #0 ≡ m *A-id-r : ∀ m → m *A #1 ≡ m +A-assoc : ∀ m n p → (m +A n) +A p ≡ m +A n +A p *A-assoc : ∀ m n p → (m *A n) *A p ≡ m *A n *A p +A-comm : ∀ m n → m +A n ≡ n +A m *A-comm : ∀ m n → m *A n ≡ n *A m *A-+A-distrib : ∀ m n p → m *A (n +A p) ≡ m *A n +A m *A p *A-annhiliate-r : ∀ m → m *A #0 ≡ #0 *A-annhiliate-l : ∀ m → #0 *A m ≡ #0 *A-+A-distrib′ : ∀ m n p → (m +A n) *A p ≡ m *A p +A n *A p *A-+A-distrib′ m n p = begin (m +A n) *A p ≡⟨ *A-comm (m +A n) p ⟩ p *A (m +A n) ≡⟨ *A-+A-distrib p m n ⟩ p *A m +A p *A n ≡⟨ cong₂ (_+A_) (*A-comm p m) (*A-comm p n) ⟩ m *A p +A n *A p ∎ where open ≡-Reasoning {-# REWRITE +A-id-l *A-id-l +A-id-r *A-id-r *A-annhiliate-r *A-annhiliate-l +A-assoc *A-assoc *A-+A-distrib #-} _+H_ : Horner → Horner → Horner _+H_ (PC x) (PC y) = PC (x +A y) _+H_ (PC x) (PX y ys) = PX (x +A y) ys _+H_ (PX x xs) (PC y) = PX (x +A y) xs _+H_ (PX x xs) (PX y ys) = PX (x +A y) (_+H_ xs ys) is-lt : (m : ℕ) → (n : ℕ) → n ⊔ (m Data.Nat.+ suc n) ≡ m Data.Nat.+ suc n is-lt m n = m≤n⇒m⊔n≡n $ begin n ≤⟨ n≤1+n n ⟩ suc n ≤⟨ m≤n+m (suc n) m ⟩ m Data.Nat.+ suc n ∎ where open ≤-Reasoning _*H_ : Horner → Horner → Horner _*H_ (PC x) y = scalMapHorner (x *A_) y _*H_ (PX x xs) y = (scalMapHorner (x *A_) y) +H (PX #0 (xs *H y)) evaluate : Horner → A → A evaluate (PC x) v = x evaluate (PX x xs) v = x +A (v *A evaluate xs v) varH : Horner varH = PX #0 $ PC #1 conH : A → Horner conH = PC construct : Poly → A → A construct (con x) a = x construct var a = a construct (p :+ p2) a = construct p a +A construct p2 a construct (p :* p2) a = construct p a *A construct p2 a normalize : Poly → Horner normalize (con x) = conH x normalize var = varH normalize (x :+ y) = normalize x +H normalize y normalize (x :* y) = normalize x *H normalize y swap : ∀ m n j k → (m +A n) +A (j +A k) ≡ (m +A j) +A (n +A k) swap m n j k = begin (m +A n) +A (j +A k) ≡⟨ +A-assoc m n (j +A k) ⟩ m +A (n +A (j +A k)) ≡⟨ cong (m +A_) $ sym $ +A-assoc n j k ⟩ m +A ((n +A j) +A k) ≡⟨ cong (\ φ → m +A (φ +A k)) $ +A-comm n j ⟩ m +A ((j +A n) +A k) ≡⟨ cong (m +A_) $ +A-assoc j n k ⟩ m +A (j +A (n +A k)) ≡⟨ sym $ +A-assoc m j (n +A k) ⟩ (m +A j) +A (n +A k) ∎ where open Eq.≡-Reasoning swap2-+A : ∀ m n p → m +A (n +A p) ≡ n +A (m +A p) swap2-+A m n p = begin m +A (n +A p) ≡⟨ +A-assoc m n p ⟩ (m +A n) +A p ≡⟨ cong ( _+A p) $ +A-comm m n ⟩ (n +A m) +A p ≡⟨ sym $ +A-assoc n m p ⟩ n +A (m +A p) ∎ where open Eq.≡-Reasoning swap2-*A : ∀ m n p → m *A (n *A p) ≡ n *A (m *A p) swap2-*A m n p = begin m *A (n *A p) ≡⟨ *A-assoc m n p ⟩ (m *A n) *A p ≡⟨ cong ( _*A p) $ *A-comm m n ⟩ (n *A m) *A p ≡⟨ sym $ *A-assoc n m p ⟩ n *A (m *A p) ∎ where open Eq.≡-Reasoning +A-+H-homo : ∀ j k a → evaluate j a +A evaluate k a ≡ evaluate (j +H k) a +A-+H-homo (PC x) (PC x₁) a = refl +A-+H-homo (PC x) (PX x₁ k) a = refl +A-+H-homo (PX x x₁) (PC x₂) a = begin x +A ((a *A evaluate x₁ a) +A x₂) ≡⟨ cong (x +A_) $ +A-comm (a *A evaluate x₁ a) x₂ ⟩ x +A (x₂ +A (a *A evaluate x₁ a)) ∎ where open Eq.≡-Reasoning +A-+H-homo (PX x x₁) (PX x₂ y) a rewrite +A-+H-homo x₁ y a = begin (x +A (a *A evaluate x₁ a)) +A (x₂ +A (a *A evaluate y a)) ≡⟨ swap x (a *A evaluate x₁ a) x₂ (a *A evaluate y a) ⟩ (x +A x₂) +A ((a *A evaluate x₁ a) +A (a *A evaluate y a)) ≡⟨ cong (\φ → (x +A x₂) +A φ) (sym $ *A-+A-distrib a (evaluate x₁ a) (evaluate y a)) ⟩ (x +A x₂) +A (a *A (evaluate x₁ a +A evaluate y a)) ≡⟨ cong (\φ → (x +A x₂) +A (a *A φ)) (+A-+H-homo x₁ y a) ⟩ (x +A x₂) +A (a *A evaluate (x₁ +H y) a) ∎ where open Eq.≡-Reasoning scale-evaluate : ∀ x k a → x *A evaluate k a ≡ evaluate (scalMapHorner (x *A_) k) a scale-evaluate x (PC x₁) a = refl scale-evaluate x (PX x₁ k) a = begin x *A evaluate (PX x₁ k) a ≡⟨⟩ x *A (x₁ +A (a *A evaluate k a)) ≡⟨ *A-+A-distrib x x₁ (a *A evaluate k a) ⟩ (x *A x₁) +A (x *A (a *A evaluate k a)) ≡⟨ cong ((x *A x₁) +A_) $ swap2-*A x a $ evaluate k a ⟩ (x *A x₁) +A (a *A (x *A evaluate k a)) ≡⟨ cong (\ φ → (x *A x₁) +A (a *A φ)) $ scale-evaluate x k a ⟩ (x *A x₁) +A (a *A evaluate (scalMapHorner (x *A_) k) a) ≡⟨⟩ evaluate (PX (x *A x₁) (scalMapHorner (x *A_) k)) a ≡⟨⟩ evaluate (scalMapHorner (x *A_) (PX x₁ k)) a ∎ where open Eq.≡-Reasoning *A-*H-homo : ∀ j k a → evaluate j a *A evaluate k a ≡ evaluate (j *H k) a *A-*H-homo (PC x) k a = scale-evaluate x k a *A-*H-homo (PX x j) k a = begin evaluate (PX x j) a *A evaluate k a ≡⟨⟩ (x +A a *A evaluate j a) *A evaluate k a ≡⟨ *A-+A-distrib′ x (a *A evaluate j a) (evaluate k a) ⟩ x *A (evaluate k a) +A (a *A evaluate j a) *A evaluate k a ≡⟨ cong₂ _+A_ (scale-evaluate x k a) (cong (a *A_) (*A-*H-homo j k a)) ⟩ evaluate (scalMapHorner (_*A_ x) k) a +A evaluate (PX #0 (j *H k)) a ≡⟨ +A-+H-homo (scalMapHorner (_*A_ x) k) (PX #0 (j *H k)) a ⟩ evaluate (scalMapHorner (_*A_ x) k +H PX #0 (j *H k)) a ≡⟨⟩ evaluate (PX x j *H k) a ∎ where open Eq.≡-Reasoning isoToConstruction : (x : Poly) → (a : A) → construct x a ≡ evaluate (normalize x) a isoToConstruction (con x) a = refl isoToConstruction var a = refl isoToConstruction (x :+ y) a rewrite isoToConstruction x a | isoToConstruction y a | +A-+H-homo (normalize x) (normalize y) a = refl isoToConstruction (x :* y) a rewrite isoToConstruction x a | isoToConstruction y a | *A-*H-homo (normalize x) (normalize y) a = refl solve : (x y : Poly) → normalize x ≡ normalize y → (a : A) → construct x a ≡ construct y a solve x y eq a = begin construct x a ≡⟨ isoToConstruction x a ⟩ evaluate (normalize x) a ≡⟨ cong (\φ → evaluate φ a) eq ⟩ evaluate (normalize y) a ≡⟨ sym $ isoToConstruction y a ⟩ construct y a ∎ where open Eq.≡-Reasoning test-a : Poly test-a = (var :+ con #1) :* (var :+ con #1) test-b : Poly test-b = var :* var :+ two :* var :+ con #1 where two = con #1 :+ con #1 blah : (x : A) → (x +A #1) *A (x +A #1) ≡ (x *A x) +A (#1 +A #1) *A x +A #1 blah x = solve test-a test-b refl x
algebraic-stack_agda0000_doc_16647
import Lvl open import Data.Boolean open import Type module Data.List.Sorting.Functions {ℓ} {T : Type{ℓ}} (_≤?_ : T → T → Bool) where open import Data.List import Data.List.Functions as List -- Inserts an element to a sorted list so that the resulting list is still sorted. insert : T → List(T) → List(T) insert x ∅ = List.singleton(x) insert x (y ⊰ l) = if(x ≤? y) then (x ⊰ y ⊰ l) else (y ⊰ insert x l) -- Merges two sorted lists so that the resulting list is still sorted. merge : List(T) → List(T) → List(T) merge = List.foldᵣ insert -- Merges a list of sorted lists so that the resulting list is still sorted. mergeAll : List(List(T)) → List(T) mergeAll = List.foldᵣ merge ∅ open import Data.Tuple open import Data.Option import Data.Option.Functions as Option -- Extracts a smallest element from a list. extractMinimal : List(T) → Option(T ⨯ List(T)) extractMinimal ∅ = None extractMinimal (x ⊰ ∅) = Some(x , ∅) extractMinimal (x ⊰ l@(_ ⊰ _)) = Option.map(\{(la , las) → if(x ≤? la) then (x , l) else (la , x ⊰ las)}) (extractMinimal l)
algebraic-stack_agda0000_doc_16648
{-# OPTIONS --without-K #-} module Types where -- Universe levels postulate -- Universe levels Level : Set zero : Level suc : Level → Level max : Level → Level → Level {-# BUILTIN LEVEL Level #-} {-# BUILTIN LEVELZERO zero #-} {-# BUILTIN LEVELSUC suc #-} {-# BUILTIN LEVELMAX max #-} -- Empty type data ⊥ {i} : Set i where -- \bot abort : ∀ {i j} {P : ⊥ {i} → Set j} → ((x : ⊥) → P x) abort () abort-nondep : ∀ {i j} {A : Set j} → (⊥ {i} → A) abort-nondep () ¬ : ∀ {i} (A : Set i) → Set i ¬ A = A → ⊥ {zero} -- Unit type record unit {i} : Set i where constructor tt ⊤ = unit -- \top -- Booleans data bool {i} : Set i where true : bool false : bool -- Dependent sum record Σ {i j} (A : Set i) (P : A → Set j) : Set (max i j) where -- \Sigma constructor _,_ field π₁ : A -- \pi\_1 π₂ : P (π₁) -- \pi\_2 open Σ public -- Disjoint sum data _⊔_ {i j} (A : Set i) (B : Set j) : Set (max i j) where -- \sqcup inl : A → A ⊔ B inr : B → A ⊔ B -- Product _×_ : ∀ {i j} (A : Set i) (B : Set j) → Set (max i j) -- \times A × B = Σ A (λ _ → B) -- Dependent product Π : ∀ {i j} (A : Set i) (P : A → Set j) → Set (max i j) Π A P = (x : A) → P x -- Natural numbers data ℕ : Set where -- \bn O : ℕ S : (n : ℕ) → ℕ {-# BUILTIN NATURAL ℕ #-} {-# BUILTIN ZERO O #-} {-# BUILTIN SUC S #-} -- Truncation index (isomorphic to the type of integers ≥ -2) data ℕ₋₂ : Set where ⟨-2⟩ : ℕ₋₂ S : (n : ℕ₋₂) → ℕ₋₂ ⟨-1⟩ : ℕ₋₂ ⟨-1⟩ = S ⟨-2⟩ ⟨0⟩ : ℕ₋₂ ⟨0⟩ = S ⟨-1⟩ _-1 : ℕ → ℕ₋₂ O -1 = ⟨-1⟩ (S n) -1 = S (n -1) ⟨_⟩ : ℕ → ℕ₋₂ ⟨ n ⟩ = S (n -1) ⟨1⟩ = ⟨ 1 ⟩ ⟨2⟩ = ⟨ 2 ⟩ _+2+_ : ℕ₋₂ → ℕ₋₂ → ℕ₋₂ ⟨-2⟩ +2+ n = n S m +2+ n = S (m +2+ n) -- Integers data ℤ : Set where -- \bz O : ℤ pos : (n : ℕ) → ℤ neg : (n : ℕ) → ℤ -- Lifting record lift {i} (j : Level) (A : Set i) : Set (max i j) where constructor ↑ -- \u field ↓ : A -- \d open lift public
algebraic-stack_agda0000_doc_16649
------------------------------------------------------------------------------ -- Auxiliary properties of the McCarthy 91 function ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Program.McCarthy91.AuxiliaryPropertiesATP where open import FOTC.Base open import FOTC.Data.Nat open import FOTC.Data.Nat.Inequalities open import FOTC.Data.Nat.Inequalities.PropertiesATP using ( x<y→y≤z→x<z ) open import FOTC.Data.Nat.PropertiesATP using ( +-N ; ∸-N ) open import FOTC.Data.Nat.UnaryNumbers open import FOTC.Data.Nat.UnaryNumbers.Inequalities.PropertiesATP using ( x<x+1 ) open import FOTC.Program.McCarthy91.ArithmeticATP open import FOTC.Program.McCarthy91.McCarthy91 ------------------------------------------------------------------------------ --- Auxiliary properties postulate x>100→x<f₉₁-x+11 : ∀ {n} → N n → n > 100' → n < f₉₁ n + 11' {-# ATP prove x>100→x<f₉₁-x+11 +-N ∸-N x<y→y≤z→x<z x<x+1 x+1≤x∸10+11 #-} -- Case n ≡ 100 can be proved automatically postulate f₉₁-100 : f₉₁ 100' ≡ 91' {-# ATP prove f₉₁-100 100+11>100 100+11∸10>100 101≡100+11∸10 91≡100+11∸10∸10 #-} postulate f₉₁x+11<f₉₁x+11 : ∀ n → n ≯ 100' → f₉₁ (n + 11') < f₉₁ (f₉₁ (n + 11')) + 11' → f₉₁ (n + 11') < f₉₁ n + 11' {-# ATP prove f₉₁x+11<f₉₁x+11 #-} postulate f₉₁-x≯100-helper : ∀ m n → m ≯ 100' → f₉₁ (m + 11') ≡ n → f₉₁ n ≡ 91' → f₉₁ m ≡ 91' {-# ATP prove f₉₁-x≯100-helper #-} postulate f₉₁-110 : f₉₁ (99' + 11') ≡ 100' f₉₁-109 : f₉₁ (98' + 11') ≡ 99' f₉₁-108 : f₉₁ (97' + 11') ≡ 98' f₉₁-107 : f₉₁ (96' + 11') ≡ 97' f₉₁-106 : f₉₁ (95' + 11') ≡ 96' f₉₁-105 : f₉₁ (94' + 11') ≡ 95' f₉₁-104 : f₉₁ (93' + 11') ≡ 94' f₉₁-103 : f₉₁ (92' + 11') ≡ 93' f₉₁-102 : f₉₁ (91' + 11') ≡ 92' f₉₁-101 : f₉₁ (90' + 11') ≡ 91' {-# ATP prove f₉₁-110 99+11>100 x+11∸10≡Sx #-} {-# ATP prove f₉₁-109 98+11>100 x+11∸10≡Sx #-} {-# ATP prove f₉₁-108 97+11>100 x+11∸10≡Sx #-} {-# ATP prove f₉₁-107 96+11>100 x+11∸10≡Sx #-} {-# ATP prove f₉₁-106 95+11>100 x+11∸10≡Sx #-} {-# ATP prove f₉₁-105 94+11>100 x+11∸10≡Sx #-} {-# ATP prove f₉₁-104 93+11>100 x+11∸10≡Sx #-} {-# ATP prove f₉₁-103 92+11>100 x+11∸10≡Sx #-} {-# ATP prove f₉₁-102 91+11>100 x+11∸10≡Sx #-} {-# ATP prove f₉₁-101 90+11>100 x+11∸10≡Sx #-} postulate f₉₁-99 : f₉₁ 99' ≡ 91' f₉₁-98 : f₉₁ 98' ≡ 91' f₉₁-97 : f₉₁ 97' ≡ 91' f₉₁-96 : f₉₁ 96' ≡ 91' f₉₁-95 : f₉₁ 95' ≡ 91' f₉₁-94 : f₉₁ 94' ≡ 91' f₉₁-93 : f₉₁ 93' ≡ 91' f₉₁-92 : f₉₁ 92' ≡ 91' f₉₁-91 : f₉₁ 91' ≡ 91' f₉₁-90 : f₉₁ 90' ≡ 91' {-# ATP prove f₉₁-99 f₉₁-x≯100-helper f₉₁-110 f₉₁-100 #-} {-# ATP prove f₉₁-98 f₉₁-x≯100-helper f₉₁-109 f₉₁-99 #-} {-# ATP prove f₉₁-97 f₉₁-x≯100-helper f₉₁-108 f₉₁-98 #-} {-# ATP prove f₉₁-96 f₉₁-x≯100-helper f₉₁-107 f₉₁-97 #-} {-# ATP prove f₉₁-95 f₉₁-x≯100-helper f₉₁-106 f₉₁-96 #-} {-# ATP prove f₉₁-94 f₉₁-x≯100-helper f₉₁-105 f₉₁-95 #-} {-# ATP prove f₉₁-93 f₉₁-x≯100-helper f₉₁-104 f₉₁-94 #-} {-# ATP prove f₉₁-92 f₉₁-x≯100-helper f₉₁-103 f₉₁-93 #-} {-# ATP prove f₉₁-91 f₉₁-x≯100-helper f₉₁-102 f₉₁-92 #-} {-# ATP prove f₉₁-90 f₉₁-x≯100-helper f₉₁-101 f₉₁-91 #-} f₉₁-x≡y : ∀ {m n o} → f₉₁ m ≡ n → o ≡ m → f₉₁ o ≡ n f₉₁-x≡y h refl = h
algebraic-stack_agda0000_doc_16650
{-# OPTIONS --allow-unsolved-metas #-} module ExtractFunction where open import Agda.Builtin.Nat open import Agda.Builtin.Bool plus : Nat -> Nat -> Nat plus = {! !} function1 : (x : Nat) -> (y : Nat) -> Nat function1 x y = plus x y pickTheFirst : Nat -> Bool -> Nat pickTheFirst x y = x function2 : Nat -> Bool -> Nat function2 x y = pickTheFirst x y
algebraic-stack_agda0000_doc_16651
{-# OPTIONS --without-K #-} open import Base open import Algebra.Groups open import Integers open import Homotopy.Truncation open import Homotopy.Pointed open import Homotopy.PathTruncation open import Homotopy.Connected -- Definitions and properties of homotopy groups module Homotopy.HomotopyGroups {i} where -- Loop space Ω : (X : pType i) → pType i Ω X = ⋆[ ⋆ X ≡ ⋆ X , refl ] Ω-pregroup : (X : pType i) → pregroup i Ω-pregroup X = record { carrier = (⋆ X) ≡ (⋆ X) ; _∙_ = _∘_ ; e = refl ; _′ = ! ; assoc = concat-assoc ; right-unit = refl-right-unit ; left-unit = λ _ → refl ; right-inverse = opposite-right-inverse ; left-inverse = opposite-left-inverse } Ωⁿ-pregroup : (n : ℕ) ⦃ ≢0 : n ≢ O ⦄ (X : pType i) → pregroup i Ωⁿ-pregroup O ⦃ ≢0 ⦄ X = abort-nondep (≢0 refl) Ωⁿ-pregroup 1 X = Ω-pregroup X Ωⁿ-pregroup (S (S n)) X = Ωⁿ-pregroup (S n) (Ω X) -- Homotopy groups πⁿ-group : (n : ℕ) ⦃ >0 : n ≢ O ⦄ (X : pType i) → group i πⁿ-group n X = π₀-pregroup (Ωⁿ-pregroup n X) fundamental-group : (X : pType i) → group i fundamental-group X = πⁿ-group 1 ⦃ ℕ-S≢O 0 ⦄ X -- Homotopy groups of loop space πⁿ-group-from-πⁿΩ : (n : ℕ) ⦃ ≢0 : n ≢ 0 ⦄ (X : pType i) → πⁿ-group (S n) X ≡ πⁿ-group n (Ω X) πⁿ-group-from-πⁿΩ O ⦃ ≢0 ⦄ X = abort-nondep (≢0 refl) πⁿ-group-from-πⁿΩ 1 X = refl πⁿ-group-from-πⁿΩ (S (S n)) X = refl -- Homotopy groups of spaces of a given h-level abstract truncated-πⁿ-group : (n : ℕ) ⦃ ≢0 : n ≢ 0 ⦄ (X : pType i) (p : is-truncated (n -1) ∣ X ∣) → πⁿ-group n X ≡ unit-group truncated-πⁿ-group O ⦃ ≢0 ⦄ X p = abort-nondep (≢0 refl) truncated-πⁿ-group 1 X p = unit-group-unique _ (proj refl , π₀-extend ⦃ p = λ x → truncated-is-truncated-S _ (π₀-is-set _ _ _) ⦄ (λ x → ap proj (π₁ (p _ _ _ _)))) truncated-πⁿ-group (S (S n)) X p = truncated-πⁿ-group (S n) (Ω X) (λ x y → p _ _ x y) Ωⁿ : (n : ℕ) (X : pType i) → pType i Ωⁿ 0 X = X Ωⁿ (S n) X = Ω (Ωⁿ n X) πⁿ : (n : ℕ) (X : pType i) → pType i πⁿ n X = τ⋆ ⟨0⟩ (Ωⁿ n X) other-πⁿ : (n : ℕ) (X : pType i) → pType i other-πⁿ n X = Ωⁿ n (τ⋆ ⟨ n ⟩ X) ap-Ω-equiv : (X Y : pType i) (e : X ≃⋆ Y) → Ω X ≃⋆ Ω Y ap-Ω-equiv X Y e = transport (λ u → Ω X ≃⋆ Ω u) (pType-eq e) (id-equiv⋆ _) τ⋆Ω-is-Ωτ⋆S : (n : ℕ₋₂) (X : pType i) → τ⋆ n (Ω X) ≃⋆ Ω (τ⋆ (S n) X) τ⋆Ω-is-Ωτ⋆S n X = (τ-path-equiv-path-τ-S , refl) τ⋆kΩⁿ-is-Ωⁿτ⋆n+k : (k n : ℕ) (X : pType i) → τ⋆ ⟨ k ⟩ (Ωⁿ n X) ≃⋆ Ωⁿ n (τ⋆ ⟨ n + k ⟩ X) τ⋆kΩⁿ-is-Ωⁿτ⋆n+k k O X = id-equiv⋆ _ τ⋆kΩⁿ-is-Ωⁿτ⋆n+k k (S n) X = equiv-compose⋆ (τ⋆Ω-is-Ωτ⋆S _ _) (ap-Ω-equiv _ _ (equiv-compose⋆ (τ⋆kΩⁿ-is-Ωⁿτ⋆n+k (S k) n _) (transport (λ u → Ωⁿ n (τ⋆ ⟨ n + S k ⟩ X) ≃⋆ Ωⁿ n (τ⋆ ⟨ u ⟩ X)) (+S-is-S+ n k) (id-equiv⋆ _)))) πⁿ-is-other-πⁿ : (n : ℕ) (X : pType i) → πⁿ n X ≃⋆ other-πⁿ n X πⁿ-is-other-πⁿ n X = transport (λ u → πⁿ n X ≃⋆ Ωⁿ n (τ⋆ ⟨ u ⟩ X)) (+0-is-id n) (τ⋆kΩⁿ-is-Ωⁿτ⋆n+k 0 n X) contr-is-contr-Ω : (X : pType i) → (is-contr⋆ X → is-contr⋆ (Ω X)) contr-is-contr-Ω X p = ≡-is-truncated ⟨-2⟩ p contr-is-contr-Ωⁿ : (n : ℕ) (X : pType i) → (is-contr⋆ X) → is-contr⋆ (Ωⁿ n X) contr-is-contr-Ωⁿ O X p = p contr-is-contr-Ωⁿ (S n) X p = contr-is-contr-Ω _ (contr-is-contr-Ωⁿ n X p) connected-other-πⁿ : (k n : ℕ) (lt : k < S n) (X : pType i) → (is-connected⋆ ⟨ n ⟩ X → is-contr⋆ (other-πⁿ k X)) connected-other-πⁿ k n lt X p = contr-is-contr-Ωⁿ k _ (connected⋆-lt k n lt X p) connected-πⁿ : (k n : ℕ) (lt : k < S n) (X : pType i) → (is-connected⋆ ⟨ n ⟩ X → is-contr⋆ (πⁿ k X)) connected-πⁿ k n lt X p = equiv-types-truncated _ (π₁ (πⁿ-is-other-πⁿ k X) ⁻¹) (connected-other-πⁿ k n lt X p)
algebraic-stack_agda0000_doc_16652
{-# OPTIONS -W ignore #-} module Issue2596b where -- This warning will be ignored {-# REWRITE #-} -- but this error will still be raised f : Set f = f
algebraic-stack_agda0000_doc_16653
{-# OPTIONS --without-K #-} module hott.level.sets.core where open import sum open import equality.core open import sets.unit open import sets.empty open import hott.level.core ⊤-contr : ∀ {i} → contr (⊤ {i}) ⊤-contr = tt , λ { tt → refl } ⊥-prop : ∀ {i} → h 1 (⊥ {i}) ⊥-prop x _ = ⊥-elim x
algebraic-stack_agda0000_doc_16654
{-# OPTIONS --without-K #-} module equality.core where open import sum open import level using () open import function.core infix 4 _≡_ data _≡_ {a} {A : Set a} (x : A) : A → Set a where refl : x ≡ x sym : ∀ {i} {A : Set i} {x y : A} → x ≡ y → y ≡ x sym refl = refl _·_ : ∀ {i}{X : Set i}{x y z : X} → x ≡ y → y ≡ z → x ≡ z refl · p = p infixl 9 _·_ ap : ∀ {i j}{A : Set i}{B : Set j}{x y : A} → (f : A → B) → x ≡ y → f x ≡ f y ap f refl = refl ap₂ : ∀ {i j k}{A : Set i}{B : Set j}{C : Set k} {x x' : A}{y y' : B} → (f : A → B → C) → x ≡ x' → y ≡ y' → f x y ≡ f x' y' ap₂ f refl refl = refl subst : ∀ {i j} {A : Set i}{x y : A} → (B : A → Set j) → x ≡ y → B x → B y subst B refl = id subst₂ : ∀ {i j k} {A : Set i}{x x' : A} {B : Set j}{y y' : B} → (C : A → B → Set k) → x ≡ x' → y ≡ y' → C x y → C x' y' subst₂ C refl refl = id singleton : ∀ {i}{A : Set i} → A → Set i singleton {A = A} a = Σ A λ a' → a ≡ a' singleton' : ∀ {i}{A : Set i} → A → Set i singleton' {A = A} a = Σ A λ a' → a' ≡ a J' : ∀ {i j}{X : Set i}{x : X} → (P : (y : X) → x ≡ y → Set j) → P x refl → (y : X) → (p : x ≡ y) → P y p J' P u y refl = u J : ∀ {i j}{X : Set i} → (P : (x y : X) → x ≡ y → Set j) → ((x : X) → P x x refl) → (x y : X) → (p : x ≡ y) → P x y p J P u x y p = J' (P x) (u x) y p
algebraic-stack_agda0000_doc_16655
-- The ATP pragma with the role <hint> can be used with functions. module ATPHint where postulate D : Set data _≡_ (x : D) : D → Set where refl : x ≡ x sym : ∀ {m n} → m ≡ n → n ≡ m sym refl = refl {-# ATP hint sym #-}
algebraic-stack_agda0000_doc_224
module Ord where data Nat : Set where Z : Nat S : Nat -> Nat data Ord : Set where z : Ord lim : (Nat -> Ord) -> Ord zp : Ord -> Ord zp z = z zp (lim f) = lim (\x -> zp (f x))
algebraic-stack_agda0000_doc_225
-- 2018-11-02, Jesper: -- Problem reported by Martin Escardo -- Example by Guillaume Brunerie -- C-c C-s was generating postfix projections -- even with --postfix-projections disabled. open import Agda.Builtin.Equality record _×_ (A B : Set) : Set where constructor _,_ field fst : A snd : B open _×_ postulate A B : Set p : A × B eta : p ≡ ({!!} , snd p) eta = refl -- C-c C-s should fill the hole with 'fst p'.
algebraic-stack_agda0000_doc_226
module Lib.IO where open import Lib.List open import Lib.Prelude {-# IMPORT System.Environment #-} FilePath = String postulate IO : Set -> Set getLine : IO String putStrLn : String -> IO Unit putStr : String -> IO Unit bindIO : {A B : Set} -> IO A -> (A -> IO B) -> IO B returnIO : {A : Set} -> A -> IO A getArgs : IO (List String) readFile : FilePath -> IO String writeFile : FilePath -> String -> IO Unit {-# BUILTIN IO IO #-} {-# COMPILED_TYPE IO IO #-} {-# COMPILED putStr putStr #-} {-# COMPILED putStrLn putStrLn #-} {-# COMPILED bindIO (\_ _ -> (>>=) :: IO a -> (a -> IO b) -> IO b) #-} {-# COMPILED returnIO (\_ -> return :: a -> IO a) #-} -- we need to throw away the type argument to return and bind -- and resolve the overloading explicitly (since Alonzo -- output is sprinkled with unsafeCoerce#). {-# COMPILED getLine getLine #-} {-# COMPILED getArgs System.Environment.getArgs #-} {-# COMPILED readFile readFile #-} {-# COMPILED writeFile writeFile #-} mapM : {A B : Set} -> (A -> IO B) -> List A -> IO (List B) mapM f [] = returnIO [] mapM f (x :: xs) = bindIO (f x) \y -> bindIO (mapM f xs) \ys -> returnIO (y :: ys) mapM₋ : {A : Set} -> (A -> IO Unit) -> List A -> IO Unit mapM₋ f xs = bindIO (mapM f xs) \_ -> returnIO unit
algebraic-stack_agda0000_doc_227
{-# OPTIONS --without-K --safe #-} module Categories.Category.Instance.Nat where -- Skeleton of FinSetoid as a Category open import Level open import Data.Fin.Base using (Fin; inject+; raise; splitAt; join) open import Data.Fin.Properties open import Data.Nat.Base using (ℕ; _+_) open import Data.Sum using (inj₁; inj₂; [_,_]′) open import Data.Sum.Properties open import Relation.Binary.PropositionalEquality using (_≗_; _≡_; refl; sym; trans; cong; module ≡-Reasoning; inspect; [_]) open import Function using (id; _∘′_) open import Categories.Category.Cartesian.Bundle using (CartesianCategory) open import Categories.Category.Cocartesian using (Cocartesian) open import Categories.Category.Cocartesian.Bundle using (CocartesianCategory) open import Categories.Category.Core using (Category) open import Categories.Category.Duality using (Cocartesian⇒coCartesian) open import Categories.Object.Coproduct open import Categories.Object.Duality using (Coproduct⇒coProduct) open import Categories.Object.Product Nat : Category 0ℓ 0ℓ 0ℓ Nat = record { Obj = ℕ ; _⇒_ = λ m n → (Fin m → Fin n) ; _≈_ = _≗_ ; id = id ; _∘_ = _∘′_ ; assoc = λ _ → refl ; sym-assoc = λ _ → refl ; identityˡ = λ _ → refl ; identityʳ = λ _ → refl ; identity² = λ _ → refl ; equiv = record { refl = λ _ → refl ; sym = λ x≡y z → sym (x≡y z) ; trans = λ x≡y y≡z w → trans (x≡y w) (y≡z w) } ; ∘-resp-≈ = λ {_ _ _ f h g i} f≗h g≗i x → trans (f≗h (g x)) (cong h (g≗i x)) } -- For other uses, it is important to choose coproducts -- in theory, it should be strictly associative... but it's not, and won't be for any choice. Coprod : (m n : ℕ) → Coproduct Nat m n Coprod m n = record { A+B = m + n ; i₁ = inject+ n ; i₂ = raise m ; [_,_] = λ l r z → [ l , r ]′ (splitAt m z) ; inject₁ = λ {_ f g} x → cong [ f , g ]′ (splitAt-inject+ m n x) ; inject₂ = λ {_ f g} x → cong [ f , g ]′ (splitAt-raise m n x) ; unique = uniq } where open ≡-Reasoning uniq : {o : ℕ} {h : Fin (m + n) → Fin o} {f : Fin m → Fin o} {g : Fin n → Fin o} → h ∘′ inject+ n ≗ f → h ∘′ raise m ≗ g → (λ z → [ f , g ]′ (splitAt m z)) ≗ h uniq {_} {h} {f} {g} h≗f h≗g w = begin [ f , g ]′ (splitAt m w) ≡⟨ [,]-cong (λ x → sym (h≗f x)) (λ x → sym (h≗g x)) (splitAt m w) ⟩ [ h ∘′ inject+ n , h ∘′ raise m ]′ (splitAt m w) ≡˘⟨ [,]-∘-distr h (splitAt m w) ⟩ h ([ inject+ n , raise m ]′ (splitAt m w)) ≡⟨ cong h (join-splitAt m n w) ⟩ h w ∎ Nat-Cocartesian : Cocartesian Nat Nat-Cocartesian = record { initial = record { ⊥ = 0 ; ⊥-is-initial = record { ! = λ () ; !-unique = λ _ () } } ; coproducts = record { coproduct = λ {m} {n} → Coprod m n } } -- And Natop is what is used a lot, so record some things here too Natop : Category 0ℓ 0ℓ 0ℓ Natop = Category.op Nat Natop-Product : (m n : ℕ) → Product Natop m n Natop-Product m n = Coproduct⇒coProduct Nat (Coprod m n) Natop-Cartesian : CartesianCategory 0ℓ 0ℓ 0ℓ Natop-Cartesian = record { U = Natop ; cartesian = Cocartesian⇒coCartesian Nat Nat-Cocartesian }
algebraic-stack_agda0000_doc_228
-- Path induction {-# OPTIONS --without-K --safe #-} module Experiment.PropositionalEq where open import Level renaming (zero to lzero; suc to lsuc) open import Relation.Binary.PropositionalEquality import Relation.Binary.Reasoning.Setoid as SetoidReasoning open import Relation.Binary private variable a c : Level A : Set a -- HoTT 1.12.1 -- Path induction PathInd : (C : (x y : A) → x ≡ y → Set c) → (∀ x → C x x refl) → ∀ x y (p : x ≡ y) → C x y p PathInd C c x .x refl = c x PathInd-refl : ∀ (C : (x y : A) → x ≡ y → Set c) (c : ∀ x → C x x refl) x → PathInd C c x x refl ≡ c x PathInd-refl C c x = refl -- Based path induction BasedPathInd : (a : A) (C : ∀ x → a ≡ x → Set c) → C a refl → ∀ x (p : a ≡ x) → C x p BasedPathInd a C c .a refl = c BasedPathInd-refl : ∀ (a : A) (C : ∀ x → a ≡ x → Set c) (c : C a refl) → BasedPathInd a C c a refl ≡ c BasedPathInd-refl _ _ _ = refl
algebraic-stack_agda0000_doc_229
------------------------------------------------------------------------ -- The Agda standard library -- -- Characters ------------------------------------------------------------------------ module Data.Char where open import Data.Nat using (ℕ) import Data.Nat.Properties as NatProp open import Data.Bool using (Bool; true; false) open import Relation.Nullary open import Relation.Nullary.Decidable open import Relation.Binary import Relation.Binary.On as On open import Relation.Binary.PropositionalEquality as PropEq using (_≡_) open import Relation.Binary.PropositionalEquality.TrustMe open import Data.String.Core using (String; primShowChar) import Data.Char.Core as Core open Core public using (Char) open Core show : Char → String show = primShowChar toNat : Char → ℕ toNat = primCharToNat -- Informative equality test. _≟_ : Decidable {A = Char} _≡_ s₁ ≟ s₂ with primCharEquality s₁ s₂ ... | true = yes trustMe ... | false = no whatever where postulate whatever : _ -- Boolean equality test. -- -- Why is the definition _==_ = primCharEquality not used? One reason -- is that the present definition can sometimes improve type -- inference, at least with the version of Agda that is current at the -- time of writing: see unit-test below. infix 4 _==_ _==_ : Char → Char → Bool c₁ == c₂ = ⌊ c₁ ≟ c₂ ⌋ private -- The following unit test does not type-check (at the time of -- writing) if _==_ is replaced by primCharEquality. data P : (Char → Bool) → Set where p : (c : Char) → P (_==_ c) unit-test : P (_==_ 'x') unit-test = p _ setoid : Setoid _ _ setoid = PropEq.setoid Char decSetoid : DecSetoid _ _ decSetoid = PropEq.decSetoid _≟_ -- An ordering induced by the toNat function. strictTotalOrder : StrictTotalOrder _ _ _ strictTotalOrder = On.strictTotalOrder NatProp.strictTotalOrder toNat
algebraic-stack_agda0000_doc_230
------------------------------------------------------------------------ -- The Agda standard library -- -- Convenient syntax for "equational reasoning" in multiple Setoids ------------------------------------------------------------------------ -- Example use: -- -- open import Data.Maybe -- import Relation.Binary.SetoidReasoning as SetR -- -- begin⟨ S ⟩ -- x -- ≈⟨ drop-just (begin⟨ setoid S ⟩ -- just x -- ≈⟨ justx≈mz ⟩ -- mz -- ≈⟨ mz≈justy ⟩ -- just y ∎) ⟩ -- y -- ≈⟨ y≈z ⟩ -- z ∎ open import Relation.Binary.EqReasoning as EqR using (_IsRelatedTo_) open import Relation.Binary open import Relation.Binary.Core open Setoid module Relation.Binary.SetoidReasoning where infix 1 begin⟨_⟩_ infixr 2 _≈⟨_⟩_ _≡⟨_⟩_ infix 2 _∎ begin⟨_⟩_ : ∀ {c l} (S : Setoid c l) → {x y : Carrier S} → _IsRelatedTo_ S x y → _≈_ S x y begin⟨_⟩_ S p = EqR.begin_ S p _∎ : ∀ {c l} {S : Setoid c l} → (x : Carrier S) → _IsRelatedTo_ S x x _∎ {S = S} = EqR._∎ S _≈⟨_⟩_ : ∀ {c l} {S : Setoid c l} → (x : Carrier S) → {y z : Carrier S} → _≈_ S x y → _IsRelatedTo_ S y z → _IsRelatedTo_ S x z _≈⟨_⟩_ {S = S} = EqR._≈⟨_⟩_ S _≡⟨_⟩_ : ∀ {c l} {S : Setoid c l} → (x : Carrier S) → {y z : Carrier S} → x ≡ y → _IsRelatedTo_ S y z → _IsRelatedTo_ S x z _≡⟨_⟩_ {S = S} = EqR._≡⟨_⟩_ S
algebraic-stack_agda0000_doc_231
{-# OPTIONS --without-K #-} open import Base open import Homotopy.Pushout open import Homotopy.VanKampen.Guide module Homotopy.VanKampen.Code {i} (d : pushout-diag i) (l : legend i (pushout-diag.C d)) where open pushout-diag d open legend l open import Homotopy.Truncation open import Homotopy.PathTruncation -- Code from A. import Homotopy.VanKampen.SplitCode d l as SC import Homotopy.VanKampen.Code.LemmaPackA d l as C -- Code from B. Code flipped. import Homotopy.VanKampen.SplitCode (pushout-diag-flip d) l as SCF import Homotopy.VanKampen.Code.LemmaPackA (pushout-diag-flip d) l as CF P : Set i P = pushout d module _ where -- Things that can be directly re-exported -- FIXME Ideally, this should be ‵SC'. -- Somehow that doesn′t work. open import Homotopy.VanKampen.SplitCode d l public using () renaming ( code to a-code ; code-a to a-code-a ; code-b to a-code-b ; code-rec to a-code-rec ; code-rec-nondep to a-code-rec-nondep ; code-is-set to a-code-is-set ; code-a-is-set to a-code-a-is-set ; code-b-is-set to a-code-b-is-set ) module _ {a₁ : A} where open import Homotopy.VanKampen.SplitCode d l a₁ public using () renaming ( code-a-refl-refl to a-code-a-refl-refl ; code-b-refl-refl to a-code-b-refl-refl ; code-ab-swap to a-code-ab-swap ; trans-a to trans-a-code-a ; trans-ba to trans-a-code-ba ; trans-ab to trans-a-code-ab ; a⇒b to aa⇒ab ; b⇒a to ab⇒aa ) a-a : ∀ {a₁} {a₂} → a₁ ≡₀ a₂ → a-code-a a₁ a₂ a-a = SC.a _ infixl 6 a-a syntax a-a co = ⟧a co a-ba : ∀ {a₁} {a₂} n → a-code-b a₁ (g $ loc n) → f (loc n) ≡₀ a₂ → a-code-a a₁ a₂ a-ba = SC.ba _ infixl 6 a-ba syntax a-ba n co p = co ab⟦ n ⟧a p a-ab : ∀ {a₁} {b₂} n → a-code-a a₁ (f $ loc n) → g (loc n) ≡₀ b₂ → a-code-b a₁ b₂ a-ab = SC.ab _ infixl 6 a-ab syntax a-ab n co p = co aa⟦ n ⟧b p module _ where -- Things that can be directly re-exported open import Homotopy.VanKampen.SplitCode (pushout-diag-flip d) l public using () renaming ( code-a to b-code-b ; code-b to b-code-a ; code-rec to b-code-rec ; code-rec-nondep to b-code-rec-nondep ; code-a-is-set to b-code-b-is-set ; code-b-is-set to b-code-a-is-set ) b-code : B → P → Set i b-code b = SCF.code b ◯ pushout-flip module _ {b₁ : B} where open import Homotopy.VanKampen.SplitCode (pushout-diag-flip d) l b₁ public using () renaming ( code-a-refl-refl to b-code-b-refl-refl ; code-b-refl-refl to b-code-a-refl-refl ; code-ab-swap to b-code-ba-swap ; trans-a to trans-b-code-b ; trans-ba to trans-b-code-ab ; trans-ab to trans-b-code-ba ; a⇒b to bb⇒ba ; b⇒a to ba⇒bb ) b-b : ∀ {b₁} {b₂} → b₁ ≡₀ b₂ → b-code-b b₁ b₂ b-b = SCF.a _ infixl 6 b-b syntax b-b co = ⟧b co b-ab : ∀ {b₁} {b₂} n → b-code-a b₁ (f $ loc n) → g (loc n) ≡₀ b₂ → b-code-b b₁ b₂ b-ab = SCF.ba _ infixl 6 b-ab syntax b-ab c co p = co ba⟦ c ⟧b p b-ba : ∀ {b₁} {a₂} n → b-code-b b₁ (g $ loc n) → f (loc n) ≡₀ a₂ → b-code-a b₁ a₂ b-ba = SCF.ab _ infixl 6 b-ba syntax b-ba c co p = co bb⟦ c ⟧a p b-code-is-set : ∀ b₁ p₂ → is-set (b-code b₁ p₂) b-code-is-set b₁ = SCF.code-is-set b₁ ◯ pushout-flip -- Tail flipping open import Homotopy.VanKampen.Code.LemmaPackA d l public using () renaming ( aa⇒ba to aa⇒ba ; ab⇒bb to ab⇒bb ; ap⇒bp to ap⇒bp ) open import Homotopy.VanKampen.Code.LemmaPackA (pushout-diag-flip d) l public using () renaming ( aa⇒ba to bb⇒ab ; ab⇒bb to ba⇒aa ) -- Tail drifting open import Homotopy.VanKampen.Code.LemmaPackB d l public using () renaming ( trans-q-code-a to trans-q-a-code-a ; trans-!q-code-a to trans-!q-a-code-a ; trans-q-code-ba to trans-q-a-code-ba ; trans-q-code-ab to trans-q-a-code-ab ) open import Homotopy.VanKampen.Code.LemmaPackB (pushout-diag-flip d) l public using () renaming ( trans-q-code-a to trans-q-b-code-b ; trans-!q-code-a to trans-!q-b-code-b ; trans-q-code-ba to trans-q-b-code-ab ; trans-q-code-ab to trans-q-b-code-ba ) bp⇒ap : ∀ n {p} → b-code (g $ loc n) p → a-code (f $ loc n) p bp⇒ap n {p} = transport (λ x → b-code (g $ loc n) p → a-code (f $ loc n) x) (pushout-flip-flip p) (CF.ap⇒bp n {pushout-flip p}) private Laba : name → P → Set i Laba = λ n p → ∀ (co : a-code (f $ loc n) p) → bp⇒ap n {p} (ap⇒bp n {p} co) ≡ co private aba-glue-code : ∀ c {p} → Laba c p abstract aba-glue-code n {p} = pushout-rec (Laba n) (λ _ → C.aba-glue-code-a n) (λ _ → C.aba-glue-code-b n) (λ _ → funext λ _ → prop-has-all-paths (a-code-b-is-set (f $ loc n) _ _ _) _ _) p private Lbab : name → P → Set i Lbab = λ n p → ∀ (co : b-code (g $ loc n) p) → ap⇒bp n {p} (bp⇒ap n {p} co) ≡ co private bab-glue-code : ∀ n {p} → Lbab n p abstract bab-glue-code n {p} = pushout-rec (Lbab n) (λ _ → CF.aba-glue-code-b n) (λ _ → CF.aba-glue-code-a n) (λ _ → funext λ _ → prop-has-all-paths (b-code-b-is-set (g $ loc n) _ _ _) _ _) p private glue-code-loc : ∀ n p → a-code (f $ loc n) p ≃ b-code (g $ loc n) p glue-code-loc n p = ap⇒bp n {p} , iso-is-eq (ap⇒bp n {p}) (bp⇒ap n {p}) (bab-glue-code n {p}) (aba-glue-code n {p}) private TapbpTa : ∀ n₁ n₂ (r : loc n₁ ≡ loc n₂) {a} → a-code-a (f $ loc n₂) a → Set i TapbpTa n₁ n₂ r {a} co = transport (λ x → b-code-a x a) (ap g r) (aa⇒ba n₁ {a} $ transport (λ x → a-code-a x a) (! $ ap f r) co) ≡ aa⇒ba n₂ {a} co TapbpTb : ∀ n₁ n₂ (r : loc n₁ ≡ loc n₂) {b} → a-code-b (f $ loc n₂) b → Set i TapbpTb n₁ n₂ r {b} co = transport (λ x → b-code-b x b) (ap g r) (ab⇒bb n₁ {b} $ transport (λ x → a-code-b x b) (! $ ap f r) co) ≡ ab⇒bb n₂ {b} co TapbpTp : ∀ n₁ n₂ (r : loc n₁ ≡ loc n₂) {p} → a-code (f $ loc n₂) p → Set i TapbpTp n₁ n₂ r {p} co = transport (λ x → b-code x p) (ap g r) (ap⇒bp n₁ {p} $ transport (λ x → a-code x p) (! $ ap f r) co) ≡ ap⇒bp n₂ {p} co private ap⇒bp-shift-split : ∀ n₁ n₂ r → (∀ {a₂} co → TapbpTa n₁ n₂ r {a₂} co) × (∀ {b₂} co → TapbpTb n₁ n₂ r {b₂} co) abstract ap⇒bp-shift-split n₁ n₂ r = a-code-rec (f $ loc n₂) (TapbpTa n₁ n₂ r) ⦃ λ _ → ≡-is-set $ b-code-a-is-set _ _ ⦄ (TapbpTb n₁ n₂ r) ⦃ λ _ → ≡-is-set $ b-code-b-is-set _ _ ⦄ (λ {a} p → transport (λ x → b-code-a x a) (ap g r) (aa⇒ba n₁ {a} $ transport (λ x → a-code-a x a) (! $ ap f r) $ ⟧a p) ≡⟨ ap (transport (λ x → b-code-a x a) (ap g r) ◯ aa⇒ba n₁ {a}) $ trans-!q-a-code-a (ap f r) p ⟩ transport (λ x → b-code-a x a) (ap g r) (⟧b refl₀ bb⟦ n₁ ⟧a proj (ap f r) ∘₀ p) ≡⟨ trans-q-b-code-ba (ap g r) _ _ _ ⟩ transport (λ x → b-code-b x (g $ loc n₁)) (ap g r) (⟧b refl₀) bb⟦ n₁ ⟧a proj (ap f r) ∘₀ p ≡⟨ ap (λ x → x bb⟦ n₁ ⟧a proj (ap f r) ∘₀ p) $ trans-q-b-code-b (ap g r) _ ⟩ ⟧b proj (! (ap g r)) ∘₀ refl₀ bb⟦ n₁ ⟧a proj (ap f r) ∘₀ p ≡⟨ ap (λ x → ⟧b x bb⟦ n₁ ⟧a proj (ap f r) ∘₀ p) $ refl₀-right-unit _ ⟩ ⟧b proj (! (ap g r)) bb⟦ n₁ ⟧a proj (ap f r) ∘₀ p ≡⟨ ! $ SCF.code-a-shift (g $ loc n₂) n₁ (proj (! (ap g r))) n₂ (proj r) p ⟩ ⟧b proj (! (ap g r) ∘ ap g r) bb⟦ n₂ ⟧a p ≡⟨ ap (λ x → ⟧b proj x bb⟦ n₂ ⟧a p) $ opposite-left-inverse $ ap g r ⟩∎ aa⇒ba n₂ {a} (⟧a p) ∎) (λ {a} n {co} pco p → transport (λ x → b-code-a x a) (ap g r) (aa⇒ba n₁ {a} $ transport (λ x → a-code-a x a) (! $ ap f r) $ co ab⟦ n ⟧a p) ≡⟨ ap (transport (λ x → b-code-a x a) (ap g r) ◯ aa⇒ba n₁ {a}) $ trans-q-a-code-ba (! $ ap f r) n co p ⟩ transport (λ x → b-code-a x a) (ap g r) (ab⇒bb n₁ {g $ loc n} (transport (λ x → a-code-b x (g $ loc n)) (! $ ap f r) co) bb⟦ n ⟧a p) ≡⟨ trans-q-b-code-ba (ap g r) _ _ _ ⟩ transport (λ x → b-code-b x (g $ loc n)) (ap g r) (ab⇒bb n₁ {g $ loc n} (transport (λ x → a-code-b x (g $ loc n)) (! $ ap f r) co)) bb⟦ n ⟧a p ≡⟨ ap (λ x → x bb⟦ n ⟧a p) pco ⟩∎ ab⇒bb n₂ {g $ loc n} co bb⟦ n ⟧a p ∎) (λ {b} n {co} pco p → transport (λ x → b-code-b x b) (ap g r) (ab⇒bb n₁ {b} $ transport (λ x → a-code-b x b) (! $ ap f r) $ co aa⟦ n ⟧b p) ≡⟨ ap (transport (λ x → b-code-b x b) (ap g r) ◯ ab⇒bb n₁ {b}) $ trans-q-a-code-ab (! $ ap f r) n co p ⟩ transport (λ x → b-code-b x b) (ap g r) (aa⇒ba n₁ {f $ loc n} (transport (λ x → a-code-a x (f $ loc n)) (! $ ap f r) co) ba⟦ n ⟧b p) ≡⟨ trans-q-b-code-ab (ap g r) _ _ _ ⟩ transport (λ x → b-code-a x (f $ loc n)) (ap g r) (aa⇒ba n₁ {f $ loc n} (transport (λ x → a-code-a x (f $ loc n)) (! $ ap f r) co)) ba⟦ n ⟧b p ≡⟨ ap (λ x → x ba⟦ n ⟧b p) pco ⟩∎ aa⇒ba n₂ {f $ loc n} co ba⟦ n ⟧b p ∎) (λ _ _ → prop-has-all-paths (b-code-a-is-set _ _ _ _) _ _) (λ _ _ → prop-has-all-paths (b-code-b-is-set _ _ _ _) _ _) (λ _ _ _ _ → prop-has-all-paths (b-code-a-is-set _ _ _ _) _ _) private ap⇒bp-shift : ∀ n₁ n₂ r {p} co → TapbpTp n₁ n₂ r {p} co abstract ap⇒bp-shift n₁ n₂ r {p} co = pushout-rec (λ p → ∀ co → TapbpTp n₁ n₂ r {p} co) (λ a → π₁ (ap⇒bp-shift-split n₁ n₂ r) {a}) (λ b → π₂ (ap⇒bp-shift-split n₁ n₂ r) {b}) (λ c → funext λ _ → prop-has-all-paths (b-code-is-set (g $ loc n₂) (right $ g c) _ _) _ _) p co glue-code-eq-route : ∀ p n₁ n₂ (r : loc n₁ ≡ loc n₂) → transport (λ c → a-code (f c) p ≃ b-code (g c) p) r (glue-code-loc n₁ p) ≡ glue-code-loc n₂ p abstract glue-code-eq-route p n₁ n₂ r = equiv-eq $ funext λ co → π₁ (transport (λ c → a-code (f c) p ≃ b-code (g c) p) r (glue-code-loc n₁ p)) co ≡⟨ ap (λ x → x co) $ app-trans (λ c → a-code (f c) p ≃ b-code (g c) p) (λ c → a-code (f c) p → b-code (g c) p) (λ _ → π₁) r (glue-code-loc n₁ p) ⟩ transport (λ c → a-code (f c) p → b-code (g c) p) r (ap⇒bp n₁ {p}) co ≡⟨ trans-→ (λ c → a-code (f c) p) (λ c → b-code (g c) p) r (ap⇒bp n₁ {p}) co ⟩ transport (λ c → b-code (g c) p) r (ap⇒bp n₁ {p} $ transport (λ c → a-code (f c) p) (! r) co) ≡⟨ ap (transport (λ c → b-code (g c) p) r ◯ ap⇒bp n₁ {p}) $ ! $ trans-ap (λ x → a-code x p) f (! r) co ⟩ transport (λ c → b-code (g c) p) r (ap⇒bp n₁ {p} $ transport (λ x → a-code x p) (ap f (! r)) co) ≡⟨ ap (λ x → transport (λ c → b-code (g c) p) r $ ap⇒bp n₁ {p} $ transport (λ x → a-code x p) x co) $ ap-opposite f r ⟩ transport (λ c → b-code (g c) p) r (ap⇒bp n₁ {p} $ transport (λ x → a-code x p) (! $ ap f r) co) ≡⟨ ! $ trans-ap (λ x → b-code x p) g r _ ⟩ transport (λ x → b-code x p) (ap g r) (ap⇒bp n₁ {p} $ transport (λ x → a-code x p) (! $ ap f r) co) ≡⟨ ap⇒bp-shift n₁ n₂ r {p} co ⟩∎ ap⇒bp n₂ {p} co ∎ glue-code-eq : ∀ c p → a-code (f c) p ≃ b-code (g c) p glue-code-eq c p = visit-fiber-rec l (λ c → a-code (f c) p ≃ b-code (g c) p) ⦃ λ c → ≃-is-set (a-code-is-set (f c) p) (b-code-is-set (g c) p) ⦄ (λ n → glue-code-loc n p) (glue-code-eq-route p) c code : P → P → Set i code = pushout-rec-nondep (P → Set i) a-code b-code (λ c → funext λ p → eq-to-path $ glue-code-eq c p) open import HLevelBis abstract code-is-set : ∀ p₁ p₂ → is-set (code p₁ p₂) code-is-set = pushout-rec (λ p₁ → ∀ p₂ → is-set $ code p₁ p₂) a-code-is-set b-code-is-set (λ _ → prop-has-all-paths (Π-is-prop λ _ → is-set-is-prop) _ _) -- Useful lemma module _ {a₁ : A} where open import Homotopy.VanKampen.SplitCode d l a₁ public using () renaming ( trans-code-glue-loc to trans-a-code-glue-loc ; trans-code-!glue-loc to trans-a-code-!glue-loc ) abstract trans-b-code-glue-loc : ∀ {b₁} n₂ co → transport (b-code b₁) (glue $ loc n₂) co ≡ ba⇒bb n₂ co trans-b-code-glue-loc {b₁} n₂ co = transport (b-code b₁) (glue $ loc n₂) co ≡⟨ ! $ trans-ap (SCF.code b₁) pushout-flip (glue $ loc n₂) co ⟩ transport (SCF.code b₁) (ap pushout-flip (glue $ loc n₂)) co ≡⟨ ap (λ x → transport (SCF.code b₁) x co) $ pushout-β-glue-nondep _ right left (! ◯ glue) (loc n₂) ⟩ transport (SCF.code b₁) (! (glue $ loc n₂)) co ≡⟨ SCF.trans-code-!glue-loc b₁ n₂ co ⟩∎ ba⇒bb n₂ co ∎ abstract trans-b-code-!glue-loc : ∀ {b₁} n₂ co → transport (b-code b₁) (! (glue $ loc n₂)) co ≡ bb⇒ba n₂ co trans-b-code-!glue-loc {b₁} n₂ co = transport (b-code b₁) (! (glue $ loc n₂)) co ≡⟨ ! $ trans-ap (SCF.code b₁) pushout-flip (! (glue $ loc n₂)) co ⟩ transport (SCF.code b₁) (ap pushout-flip (! (glue $ loc n₂))) co ≡⟨ ap (λ x → transport (SCF.code b₁) x co) $ pushout-β-!glue-nondep _ right left (! ◯ glue) (loc n₂) ⟩ transport (SCF.code b₁) (! (! (glue $ loc n₂))) co ≡⟨ ap (λ x → transport (SCF.code b₁) x co) $ opposite-opposite $ glue $ loc n₂ ⟩ transport (SCF.code b₁) (glue $ loc n₂) co ≡⟨ SCF.trans-code-glue-loc b₁ n₂ co ⟩∎ bb⇒ba n₂ co ∎ abstract trans-glue-code-loc : ∀ n {p} (co : a-code (f $ loc n) p) → transport (λ x → code x p) (glue $ loc n) co ≡ ap⇒bp n {p} co trans-glue-code-loc n {p} co = transport (λ x → code x p) (glue $ loc n) co ≡⟨ ! $ trans-ap (λ f → f p) code (glue $ loc n) co ⟩ transport (λ f → f p) (ap code (glue $ loc n)) co ≡⟨ ap (λ x → transport (λ f → f p) x co) $ pushout-β-glue-nondep (P → Set i) a-code b-code (λ c → funext λ p → eq-to-path $ glue-code-eq c p) $ loc n ⟩ transport (λ f → f p) (funext λ p → eq-to-path $ glue-code-eq (loc n) p) co ≡⟨ ! $ trans-ap (λ X → X) (λ f → f p) (funext λ p → eq-to-path $ glue-code-eq (loc n) p) co ⟩ transport (λ X → X) (happly (funext λ p → eq-to-path $ glue-code-eq (loc n) p) p) co ≡⟨ ap (λ x → transport (λ X → X) (x p) co) $ happly-funext (λ p → eq-to-path $ glue-code-eq (loc n) p) ⟩ transport (λ X → X) (eq-to-path $ glue-code-eq (loc n) p) co ≡⟨ trans-id-eq-to-path (glue-code-eq (loc n) p) co ⟩ π₁ (glue-code-eq (loc n) p) co ≡⟨ ap (λ x → π₁ x co) $ visit-fiber-β-loc l (λ c → a-code (f c) p ≃ b-code (g c) p) ⦃ λ c → ≃-is-set (a-code-is-set (f c) p) (b-code-is-set (g c) p) ⦄ (λ n → glue-code-loc n p) (glue-code-eq-route p) n ⟩∎ ap⇒bp n {p} co ∎ abstract trans-!glue-code-loc : ∀ n {p} (co : b-code (g $ loc n) p) → transport (λ x → code x p) (! $ glue $ loc n) co ≡ bp⇒ap n {p} co trans-!glue-code-loc n {p} co = move!-transp-right (λ x → code x p) (glue $ loc n) co (bp⇒ap n {p} co) $ ! $ transport (λ x → code x p) (glue $ loc n) (bp⇒ap n {p} co) ≡⟨ trans-glue-code-loc n {p} (bp⇒ap n {p} co) ⟩ ap⇒bp n {p} (bp⇒ap n {p} co) ≡⟨ bab-glue-code n {p} co ⟩∎ co ∎
algebraic-stack_agda0000_doc_232
open import Prelude open import core module lemmas-consistency where -- type consistency is symmetric ~sym : {t1 t2 : typ} → t1 ~ t2 → t2 ~ t1 ~sym TCRefl = TCRefl ~sym TCHole1 = TCHole2 ~sym TCHole2 = TCHole1 ~sym (TCArr p1 p2) = TCArr (~sym p1) (~sym p2) ~sym (TCProd h h₁) = TCProd (~sym h) (~sym h₁) -- type consistency isn't transitive not-trans : ((t1 t2 t3 : typ) → t1 ~ t2 → t2 ~ t3 → t1 ~ t3) → ⊥ not-trans t with t (b ==> b) ⦇·⦈ b TCHole1 TCHole2 ... | () -- every pair of types is either consistent or not consistent ~dec : (t1 t2 : typ) → ((t1 ~ t2) + (t1 ~̸ t2)) -- this takes care of all hole cases, so we don't consider them below ~dec _ ⦇·⦈ = Inl TCHole1 ~dec ⦇·⦈ b = Inl TCHole2 ~dec ⦇·⦈ (q ==> q₁) = Inl TCHole2 ~dec ⦇·⦈ (q ⊗ q₁) = Inl TCHole2 -- num cases ~dec b b = Inl TCRefl ~dec b (t2 ==> t3) = Inr ICBaseArr1 -- arrow cases ~dec (t1 ==> t2) b = Inr ICBaseArr2 ~dec (t1 ==> t2) (t3 ==> t4) with ~dec t1 t3 | ~dec t2 t4 ... | Inl x | Inl y = Inl (TCArr x y) ... | Inl _ | Inr y = Inr (ICArr2 y) ... | Inr x | _ = Inr (ICArr1 x) ~dec b (t2 ⊗ t3) = Inr ICBaseProd1 ~dec (t1 ==> t2) (t3 ⊗ t4) = Inr ICProdArr1 ~dec (t1 ⊗ t2) b = Inr ICBaseProd2 ~dec (t1 ⊗ t2) (t3 ==> t4) = Inr ICProdArr2 ~dec (t1 ⊗ t2) (t3 ⊗ t4) with ~dec t1 t3 | ~dec t2 t4 ~dec (t1 ⊗ t2) (t3 ⊗ t4) | Inl x | Inl x₁ = Inl (TCProd x x₁) ~dec (t1 ⊗ t2) (t3 ⊗ t4) | Inl x | Inr x₁ = Inr (ICProd2 x₁) ~dec (t1 ⊗ t2) (t3 ⊗ t4) | Inr x | Inl x₁ = Inr (ICProd1 x) ~dec (t1 ⊗ t2) (t3 ⊗ t4) | Inr x | Inr x₁ = Inr (ICProd1 x) -- no pair of types is both consistent and not consistent ~apart : {t1 t2 : typ} → (t1 ~̸ t2) → (t1 ~ t2) → ⊥ ~apart ICBaseArr1 () ~apart ICBaseArr2 () ~apart (ICArr1 x) TCRefl = ~apart x TCRefl ~apart (ICArr1 x) (TCArr y y₁) = ~apart x y ~apart (ICArr2 x) TCRefl = ~apart x TCRefl ~apart (ICArr2 x) (TCArr y y₁) = ~apart x y₁ ~apart ICBaseProd1 () ~apart ICBaseProd2 () ~apart ICProdArr1 () ~apart ICProdArr2 () ~apart (ICProd1 h) TCRefl = ~apart h TCRefl ~apart (ICProd1 h) (TCProd h₁ h₂) = ~apart h h₁ ~apart (ICProd2 h) TCRefl = ~apart h TCRefl ~apart (ICProd2 h) (TCProd h₁ h₂) = ~apart h h₂ ~apart-converse : (τ1 τ2 : typ) → (τ1 ~ τ2 → ⊥) → τ1 ~̸ τ2 ~apart-converse τ1 τ2 ne with ~dec τ1 τ2 ~apart-converse τ1 τ2 ne | Inl h = abort (ne h) ~apart-converse τ1 τ2 ne | Inr h = h ~decPair : (τ1 τ2 τ3 τ4 : typ) → ((τ1 ⊗ τ2) ~ (τ3 ⊗ τ4) → ⊥) → (τ1 ~ τ3 → ⊥) + (τ2 ~ τ4 → ⊥) ~decPair τ1 τ2 τ3 τ4 inc with ~apart-converse (τ1 ⊗ τ2) (τ3 ⊗ τ4) inc ~decPair τ1 τ2 τ3 τ4 inc | ICProd1 h = Inl (~apart h) ~decPair τ1 τ2 τ3 τ4 inc | ICProd2 h = Inr (~apart h) ~prod1 : ∀{τ1 τ2 τ3 τ4} → (τ1 ⊗ τ2) ~ (τ3 ⊗ τ4) → τ1 ~ τ3 ~prod1 TCRefl = TCRefl ~prod1 (TCProd h1 h2) = h1 ~prod2 : ∀{τ1 τ2 τ3 τ4} → (τ1 ⊗ τ2) ~ (τ3 ⊗ τ4) → τ2 ~ τ4 ~prod2 TCRefl = TCRefl ~prod2 (TCProd h1 h2) = h2
algebraic-stack_agda0000_doc_233
{-# OPTIONS --cubical --safe #-} module Relation.Nullary.Discrete where open import Relation.Nullary.Decidable open import Path open import Level Discrete : Type a → Type a Discrete A = (x y : A) → Dec (x ≡ y)
algebraic-stack_agda0000_doc_234
-- Andreas, 2017-10-04, issue #689, test case by stevana -- {-# OPTIONS -v tc.data:50 #-} -- {-# OPTIONS -v tc.force:100 #-} -- {-# OPTIONS -v tc.constr:50 #-} -- {-# OPTIONS -v tc.conv.sort:30 #-} -- {-# OPTIONS -v tc.conv.nat:30 #-} open import Agda.Primitive data L {a} (A : Set a) : Set a where _∷_ : A → L A → L A data S {a} {A : Set a} : L A → Set₁ where _∷_ : (x : A) → (xs : L A) → S (x ∷ xs) -- x and xs are forced! -- Should succeed without unsolved constraints. -- There was a problem in the forcing analysis which I introduced -- with apparently improper use of `noConstraints` (still do not know why) -- for the Big/Small Forced argument analysis. -- The latter one is obsolete and thus removed.
algebraic-stack_agda0000_doc_235
module Data.Num.Injection where open import Data.Num.Core open import Data.Nat hiding (compare) open import Data.Nat.Properties open import Data.Nat.Properties.Simple open import Data.Nat.Properties.Extra open import Data.Fin as Fin using (Fin; fromℕ≤; inject≤) renaming (zero to z; suc to s) open import Data.Fin.Properties using (toℕ-fromℕ≤; to-from; bounded; inject≤-lemma) renaming (toℕ-injective to Fin→ℕ-injective; _≟_ to _Fin≟_) open import Data.Fin.Properties.Extra open import Data.Sum open import Data.Product open import Data.Empty using (⊥) open import Data.Unit using (⊤; tt) open import Function open import Function.Injection open Injection -- open import Function.Equality using (_⟶_; _⟨$⟩_) open import Relation.Nullary.Decidable open import Relation.Nullary open import Relation.Nullary.Negation open import Relation.Binary open import Relation.Binary.PropositionalEquality open ≡-Reasoning open ≤-Reasoning renaming (begin_ to start_; _∎ to _□; _≡⟨_⟩_ to _≈⟨_⟩_) open DecTotalOrder decTotalOrder using (reflexive) renaming (refl to ≤-refl) open StrictTotalOrder strictTotalOrder using (compare) data InjCond : ℕ → ℕ → ℕ → Set where Ordinary : ∀ {b d o} → (b≥d : b ≥ d) → (o≥1 : o ≥ 1) → InjCond b d o Digitless : ∀ {b d o} → (d≡0 : d ≡ 0) → InjCond b 0 o -- having no digits at all data NonInjCond : ℕ → ℕ → ℕ → Set where Redundant : ∀ {b d o} → (d>b : d > b) → NonInjCond b d o -- having to many digits WithZeros : ∀ {b d o} → (o≡0 : o ≡ 0) → (d≢0 : d ≢ 0) → NonInjCond b d 0 -- with leading zeroes data InjectionView : ℕ → ℕ → ℕ → Set where Inj : ∀ {b d o} → InjCond b d o → InjectionView b d o NonInj : ∀ {b d o} → NonInjCond b d o → InjectionView b d o injectionView : (b d o : ℕ) → InjectionView b d o injectionView b zero zero = Inj (Digitless refl) injectionView b (suc d) zero = NonInj (WithZeros refl (λ ())) injectionView b d (suc o) with d ≤? b injectionView b d (suc o) | yes p = Inj (Ordinary p (s≤s z≤n)) injectionView b d (suc o) | no ¬p = NonInj (Redundant (≰⇒> ¬p)) IsInjective : ℕ → ℕ → ℕ → Set IsInjective b d o with injectionView b d o IsInjective b d o | Inj _ = ⊤ IsInjective b d o | NonInj _ = ⊥ InjCond⇒IsInj : ∀ {b d o} → InjCond b d o → IsInjective b d o InjCond⇒IsInj {b} {d} {o} cond with injectionView b d o InjCond⇒IsInj _ | Inj _ = tt InjCond⇒IsInj (Ordinary b≥d o≥1) | NonInj (Redundant d>b) = contradiction b≥d (>⇒≰ d>b) InjCond⇒IsInj (Ordinary b≥d ()) | NonInj (WithZeros o≡0 d≢0) InjCond⇒IsInj (Digitless d≡0) | NonInj (Redundant ()) InjCond⇒IsInj (Digitless d≡0) | NonInj (WithZeros refl d≢0) = contradiction refl d≢0 -- InjCond⇒b≥1 : ∀ {b d o} → InjCond b (suc d) o → b ≥ 1 -- InjCond⇒b≥1 {zero} (bijCond b≥d: o≥1:) = contradiction b≥d: (>⇒≰ (s≤s z≤n)) -- InjCond⇒b≥1 {suc b} (bijCond b≥d: o≥1:) = s≤s z≤n -- NonInjCond⇏IsInj : ∀ {b d o} → NonInjCond b d o → ¬ IsInjective b d o NonInjCond⇏IsInj {b} {d} {o} reason claim with injectionView b d o NonInjCond⇏IsInj (Redundant d>b) claim | Inj (Ordinary b≥d o≥1) = contradiction b≥d (>⇒≰ d>b) NonInjCond⇏IsInj (Redundant ()) claim | Inj (Digitless d≡0) NonInjCond⇏IsInj (WithZeros o≡0 d≢0) claim | Inj (Ordinary b≥d ()) NonInjCond⇏IsInj (WithZeros o≡0 d≢0) claim | Inj (Digitless d≡0) = contradiction refl d≢0 NonInjCond⇏IsInj reason () | NonInj _ Digit-toℕ-injective : ∀ {d} o (x y : Fin d) → Digit-toℕ x o ≡ Digit-toℕ y o -- o + toℕ x ≡ o + toℕ y → x ≡ y Digit-toℕ-injective {_} o x y eq = Fin→ℕ-injective -- cancels `Fin.toℕ` $ cancel-+-left o -- cancels `o +` $ eq n∷-mono-strict : ∀ {b d o} (x y : Fin d) (xs ys : Num b d o) → InjCond b d o → toℕ xs < toℕ ys → toℕ (x ∷ xs) < toℕ (y ∷ ys) n∷-mono-strict {b} {_} {o} () () xs ys (Digitless d≡0) ⟦xs⟧<⟦ys⟧ n∷-mono-strict {b} {d} {o} x y xs ys (Ordinary b≥d o≥1) ⟦xs⟧<⟦ys⟧ = start suc (Digit-toℕ x o) + toℕ xs * b ≤⟨ +n-mono (toℕ xs * b) $ start suc (Digit-toℕ x o) ≈⟨ sym (+-suc o (Fin.toℕ x)) ⟩ -- push `o` to the left o + suc (Fin.toℕ x) ≤⟨ n+-mono o $ start suc (Fin.toℕ x) ≤⟨ bounded x ⟩ d ≤⟨ b≥d ⟩ b ≤⟨ n≤m+n (Fin.toℕ y) b ⟩ Fin.toℕ y + b □ ⟩ o + (Fin.toℕ y + b) ≈⟨ sym (+-assoc o (Fin.toℕ y) b) ⟩ Digit-toℕ y o + b □ ⟩ Digit-toℕ y o + b + toℕ xs * b ≈⟨ +-assoc (Digit-toℕ y o) b (toℕ xs * b) ⟩ Digit-toℕ y o + (b + toℕ xs * b) ≤⟨ n+-mono (Digit-toℕ y o) (*n-mono b ⟦xs⟧<⟦ys⟧) ⟩ -- replace `xs` with `ys` Digit-toℕ y o + toℕ ys * b □ ∷ns-mono-strict : ∀ {b d o} (x y : Fin d) (xs ys : Num b d o) → toℕ xs ≡ toℕ ys → Digit-toℕ x o < Digit-toℕ y o → toℕ (x ∷ xs) < toℕ (y ∷ ys) ∷ns-mono-strict {b} {d} {o} x y xs ys ⟦xs⟧≡⟦ys⟧ ⟦x⟧<⟦y⟧ = start suc (Digit-toℕ x o + toℕ xs * b) ≈⟨ cong (λ w → suc (Digit-toℕ x o + w * b)) ⟦xs⟧≡⟦ys⟧ ⟩ suc (Digit-toℕ x o + toℕ ys * b) ≤⟨ +n-mono (toℕ ys * b) ⟦x⟧<⟦y⟧ ⟩ Digit-toℕ y o + toℕ ys * b □ toℕ-injective-⟦x∷xs⟧>0-lemma : ∀ {b d o} → o ≥ 1 → (x : Fin d) → (xs : Num b d o) → toℕ (x ∷ xs) > 0 toℕ-injective-⟦x∷xs⟧>0-lemma {b} {d} {o} o≥1 x xs = start suc zero ≤⟨ o≥1 ⟩ o ≤⟨ m≤m+n o (Fin.toℕ x) ⟩ o + Fin.toℕ x ≤⟨ m≤m+n (o + Fin.toℕ x) (toℕ xs * b) ⟩ o + Fin.toℕ x + toℕ xs * b □ toℕ-injective : ∀ {b d o} → {isInj : IsInjective b d o} → (xs ys : Num b d o) → toℕ xs ≡ toℕ ys → xs ≡ ys toℕ-injective {b} {d} {o} xs ys eq with injectionView b d o toℕ-injective ∙ ∙ eq | Inj (Ordinary b≥d o≥1) = refl toℕ-injective ∙ (y ∷ ys) eq | Inj (Ordinary b≥d o≥1) = contradiction eq (<⇒≢ (toℕ-injective-⟦x∷xs⟧>0-lemma o≥1 y ys)) toℕ-injective (x ∷ xs) ∙ eq | Inj (Ordinary b≥d o≥1) = contradiction eq (>⇒≢ (toℕ-injective-⟦x∷xs⟧>0-lemma o≥1 x xs)) toℕ-injective {b} {zero} {o} (() ∷ xs) (y ∷ ys) eq | Inj cond toℕ-injective {b} {suc d} {o} (x ∷ xs) (y ∷ ys) eq | Inj cond with compare (toℕ xs) (toℕ ys) toℕ-injective {b} {suc d} {o} (x ∷ xs) (y ∷ ys) eq | Inj cond | tri< ⟦xs⟧<⟦ys⟧ _ _ = contradiction eq (<⇒≢ (n∷-mono-strict x y xs ys cond ⟦xs⟧<⟦ys⟧)) toℕ-injective {b} {suc d} {o} (x ∷ xs) (y ∷ ys) eq | Inj cond | tri≈ _ ⟦xs⟧≡⟦ys⟧ _ with compare (Digit-toℕ x o) (Digit-toℕ y o) toℕ-injective {b} {suc d} {o} (x ∷ xs) (y ∷ ys) eq | Inj cond | tri≈ _ ⟦xs⟧≡⟦ys⟧ _ | tri< ⟦x⟧<⟦y⟧ _ _ = contradiction eq (<⇒≢ (∷ns-mono-strict x y xs ys ⟦xs⟧≡⟦ys⟧ ⟦x⟧<⟦y⟧)) toℕ-injective {b} {suc d} {o} (x ∷ xs) (y ∷ ys) eq | Inj cond | tri≈ _ ⟦xs⟧≡⟦ys⟧ _ | tri≈ _ ⟦x⟧≡⟦y⟧ _ = cong₂ _∷_ (Digit-toℕ-injective o x y ⟦x⟧≡⟦y⟧) (toℕ-injective {isInj = InjCond⇒IsInj cond} xs ys ⟦xs⟧≡⟦ys⟧) toℕ-injective {b} {suc d} {o} (x ∷ xs) (y ∷ ys) eq | Inj cond | tri≈ _ ⟦xs⟧≡⟦ys⟧ _ | tri> _ _ ⟦x⟧>⟦y⟧ = contradiction eq (>⇒≢ (∷ns-mono-strict y x ys xs (sym ⟦xs⟧≡⟦ys⟧) ⟦x⟧>⟦y⟧)) toℕ-injective {b} {suc d} {o} (x ∷ xs) (y ∷ ys) eq | Inj cond | tri> _ _ ⟦xs⟧>⟦ys⟧ = contradiction eq (>⇒≢ ((n∷-mono-strict y x ys xs cond ⟦xs⟧>⟦ys⟧))) toℕ-injective ∙ ∙ eq | Inj (Digitless d≡0) = refl toℕ-injective ∙ (() ∷ ys) eq | Inj (Digitless d≡0) toℕ-injective (() ∷ xs) ys eq | Inj (Digitless d≡0) toℕ-injective {isInj = ()} xs ys eq | NonInj reason InjCond⇒Injective : ∀ {b} {d} {o} → InjCond b d o → Injective (Num⟶ℕ b d o) InjCond⇒Injective condition {x} {y} = toℕ-injective {isInj = InjCond⇒IsInj condition} x y NonInjCond⇏Injective : ∀ {b} {d} {o} → NonInjCond b d o → ¬ (Injective (Num⟶ℕ b d o)) NonInjCond⇏Injective {zero} {zero} (Redundant ()) claim NonInjCond⇏Injective {zero} {suc d} {o} (Redundant d>b) claim = contradiction (claim {z ∷ ∙} {z ∷ z ∷ ∙} ⟦1∷∙⟧≡⟦1∷1∷∙⟧) (λ ()) where ⟦1∷∙⟧≡⟦1∷1∷∙⟧ : toℕ {zero} {suc d} {o} (z ∷ ∙) ≡ toℕ {zero} {suc d} {o} (z ∷ z ∷ ∙) ⟦1∷∙⟧≡⟦1∷1∷∙⟧ = cong (λ w → o + 0 + w) (sym (*-right-zero (o + 0 + 0))) NonInjCond⇏Injective {suc b} {zero} (Redundant ()) claim NonInjCond⇏Injective {suc b} {suc zero} (Redundant (s≤s ())) claim NonInjCond⇏Injective {suc b} {suc (suc d)} {o} (Redundant d>b) claim = contradiction (claim {z ∷ s z ∷ ∙} {fromℕ≤ d>b ∷ z ∷ ∙} ⟦1∷2⟧≡⟦b+1∷1⟧) (λ ()) where ⟦1∷2⟧≡⟦b+1∷1⟧ : toℕ {suc b} {suc (suc d)} {o} (z ∷ s z ∷ ∙) ≡ toℕ {suc b} {suc (suc d)} {o} (fromℕ≤ {suc b} d>b ∷ z ∷ ∙) ⟦1∷2⟧≡⟦b+1∷1⟧ = begin o + zero + (o + suc zero + zero) * suc b ≡⟨ cong (λ x → x + (o + suc zero + zero) * suc b) (+-right-identity o) ⟩ o + (o + suc zero + zero) * suc b ≡⟨ cong (λ x → o + (x + zero) * suc b) (+-suc o zero) ⟩ o + (suc (o + zero) + zero) * suc b ≡⟨ refl ⟩ o + (suc b + (o + zero + zero) * suc b) ≡⟨ sym (+-assoc o (suc b) ((o + zero + zero) * suc b)) ⟩ o + suc b + (o + zero + zero) * suc b ≡⟨ cong (λ x → o + x + (o + zero + zero) * suc b) (sym (toℕ-fromℕ≤ d>b)) ⟩ o + Fin.toℕ (fromℕ≤ d>b) + (o + zero + zero) * suc b ∎ NonInjCond⇏Injective {b} {zero} {_} (WithZeros o≡0 d≢0) claim = contradiction refl d≢0 NonInjCond⇏Injective {b} {suc d} {_} (WithZeros o≡0 d≢0) claim = contradiction (claim {z ∷ ∙} {∙} ⟦0∷∙⟧≡⟦∙⟧) (λ ()) where ⟦0∷∙⟧≡⟦∙⟧ : toℕ {b} {suc d} {0} (z ∷ ∙) ≡ toℕ {b} {suc d} {0} ∙ ⟦0∷∙⟧≡⟦∙⟧ = refl Injective? : ∀ b d o → Dec (Injective (Num⟶ℕ b d o)) Injective? b d o with injectionView b d o Injective? b d o | Inj condition = yes (InjCond⇒Injective condition) Injective? b d o | NonInj reason = no (NonInjCond⇏Injective reason) -- begin -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ∎
algebraic-stack_agda0000_doc_236
module Lambda where open import Prelude open import Star open import Examples open import Modal -- Environments record TyAlg (ty : Set) : Set where field nat : ty _⟶_ : ty -> ty -> ty data Ty : Set where <nat> : Ty _<⟶>_ : Ty -> Ty -> Ty freeTyAlg : TyAlg Ty freeTyAlg = record { nat = <nat>; _⟶_ = _<⟶>_ } termTyAlg : TyAlg True termTyAlg = record { nat = _; _⟶_ = \_ _ -> _ } record TyArrow {ty₁ ty₂ : Set}(T₁ : TyAlg ty₁)(T₂ : TyAlg ty₂) : Set where field apply : ty₁ -> ty₂ respNat : apply (TyAlg.nat T₁) == TyAlg.nat T₂ resp⟶ : forall {τ₁ τ₂} -> apply (TyAlg._⟶_ T₁ τ₁ τ₂) == TyAlg._⟶_ T₂ (apply τ₁) (apply τ₂) _=Ty=>_ : {ty₁ ty₂ : Set}(T₁ : TyAlg ty₁)(T₂ : TyAlg ty₂) -> Set _=Ty=>_ = TyArrow !Ty : {ty : Set}{T : TyAlg ty} -> T =Ty=> termTyAlg !Ty = record { apply = ! ; respNat = refl ; resp⟶ = refl } Ctx : Set Ctx = List Ty Var : {ty : Set} -> List ty -> ty -> Set Var Γ τ = Any (_==_ τ) Γ vzero : {τ : Ty} {Γ : Ctx} -> Var (τ • Γ) τ vzero = done refl • ε vsuc : {σ τ : Ty} {Γ : Ctx} -> Var Γ τ -> Var (σ • Γ) τ vsuc v = step • v module Term {ty : Set}(T : TyAlg ty) where private open module TT = TyAlg T data Tm : List ty -> ty -> Set where var : forall {Γ τ} -> Var Γ τ -> Tm Γ τ zz : forall {Γ} -> Tm Γ nat ss : forall {Γ} -> Tm Γ (nat ⟶ nat) ƛ : forall {Γ σ τ} -> Tm (σ • Γ) τ -> Tm Γ (σ ⟶ τ) _$_ : forall {Γ σ τ} -> Tm Γ (σ ⟶ τ) -> Tm Γ σ -> Tm Γ τ module Eval where private open module TT = Term freeTyAlg ty⟦_⟧ : Ty -> Set ty⟦ <nat> ⟧ = Nat ty⟦ σ <⟶> τ ⟧ = ty⟦ σ ⟧ -> ty⟦ τ ⟧ Env : Ctx -> Set Env = All ty⟦_⟧ _[_] : forall {Γ τ} -> Env Γ -> Var Γ τ -> ty⟦ τ ⟧ ρ [ x ] with lookup x ρ ... | result _ refl v = v ⟦_⟧_ : forall {Γ τ} -> Tm Γ τ -> Env Γ -> ty⟦ τ ⟧ ⟦ var x ⟧ ρ = ρ [ x ] ⟦ zz ⟧ ρ = zero ⟦ ss ⟧ ρ = suc ⟦ ƛ t ⟧ ρ = \x -> ⟦ t ⟧ (check x • ρ) ⟦ s $ t ⟧ ρ = (⟦ s ⟧ ρ) (⟦ t ⟧ ρ) module MoreExamples where private open module TT = TyAlg freeTyAlg private open module Tm = Term freeTyAlg open Eval tm-one : Tm ε nat tm-one = ss $ zz tm-id : Tm ε (nat ⟶ nat) tm-id = ƛ (var (done refl • ε)) tm : Tm ε nat tm = tm-id $ tm-one tm-twice : Tm ε ((nat ⟶ nat) ⟶ (nat ⟶ nat)) tm-twice = ƛ (ƛ (f $ (f $ x))) where Γ : Ctx Γ = nat • (nat ⟶ nat) • ε f : Tm Γ (nat ⟶ nat) f = var (vsuc vzero) x : Tm Γ nat x = var vzero sem : {τ : Ty} -> Tm ε τ -> ty⟦ τ ⟧ sem e = ⟦ e ⟧ ε one : Nat one = sem tm twice : (Nat -> Nat) -> (Nat -> Nat) twice = sem tm-twice
algebraic-stack_agda0000_doc_237
{-# OPTIONS --allow-unsolved-metas #-} module regex1 where open import Level renaming ( suc to succ ; zero to Zero ) open import Data.Fin open import Data.Nat hiding ( _≟_ ) open import Data.List hiding ( any ; [_] ) -- import Data.Bool using ( Bool ; true ; false ; _∧_ ) -- open import Data.Bool using ( Bool ; true ; false ; _∧_ ; _∨_ ) open import Relation.Binary.PropositionalEquality as RBF hiding ( [_] ) open import Relation.Nullary using (¬_; Dec; yes; no) open import regex open import logic -- postulate a b c d : Set data In : Set where a : In b : In c : In d : In -- infixr 40 _&_ _||_ r1' = (< a > & < b >) & < c > --- abc r1 = < a > & < b > & < c > --- abc r0 : ¬ (r1' ≡ r1) r0 () any = < a > || < b > || < c > || < d > --- a|b|c|d r2 = ( any * ) & ( < a > & < b > & < c > ) -- .*abc r3 = ( any * ) & ( < a > & < b > & < c > & < a > & < b > & < c > ) r4 = ( < a > & < b > & < c > ) || ( < b > & < c > & < d > ) r5 = ( any * ) & ( < a > & < b > & < c > || < b > & < c > & < d > ) open import nfa -- former ++ later ≡ x split : {Σ : Set} → ((former : List Σ) → Bool) → ((later : List Σ) → Bool) → (x : List Σ ) → Bool split x y [] = x [] /\ y [] split x y (h ∷ t) = (x [] /\ y (h ∷ t)) \/ split (λ t1 → x ( h ∷ t1 )) (λ t2 → y t2 ) t -- tt1 : {Σ : Set} → ( P Q : List In → Bool ) → split P Q ( a ∷ b ∷ c ∷ [] ) -- tt1 P Q = ? {-# TERMINATING #-} repeat : {Σ : Set} → (List Σ → Bool) → List Σ → Bool repeat x [] = true repeat {Σ} x ( h ∷ t ) = split x (repeat {Σ} x) ( h ∷ t ) -- Meaning of regular expression regular-language : {Σ : Set} → Regex Σ → ((x y : Σ ) → Dec (x ≡ y)) → List Σ → Bool regular-language φ cmp _ = false regular-language ε cmp [] = true regular-language ε cmp (_ ∷ _) = false regular-language (x *) cmp = repeat ( regular-language x cmp ) regular-language (x & y) cmp = split ( λ z → regular-language x cmp z ) (λ z → regular-language y cmp z ) regular-language (x || y) cmp = λ s → ( regular-language x cmp s ) \/ ( regular-language y cmp s) regular-language < h > cmp [] = false regular-language < h > cmp (h1 ∷ [] ) with cmp h h1 ... | yes _ = true ... | no _ = false regular-language < h > _ (_ ∷ _ ∷ _) = false cmpi : (x y : In ) → Dec (x ≡ y) cmpi a a = yes refl cmpi b b = yes refl cmpi c c = yes refl cmpi d d = yes refl cmpi a b = no (λ ()) cmpi a c = no (λ ()) cmpi a d = no (λ ()) cmpi b a = no (λ ()) cmpi b c = no (λ ()) cmpi b d = no (λ ()) cmpi c a = no (λ ()) cmpi c b = no (λ ()) cmpi c d = no (λ ()) cmpi d a = no (λ ()) cmpi d b = no (λ ()) cmpi d c = no (λ ()) test-regex : regular-language r1' cmpi ( a ∷ [] ) ≡ false test-regex = refl test-regex1 : regular-language r2 cmpi ( a ∷ a ∷ b ∷ c ∷ [] ) ≡ true test-regex1 = refl test-AB→split : {Σ : Set} → {A B : List In → Bool} → split A B ( a ∷ b ∷ a ∷ [] ) ≡ ( ( A [] /\ B ( a ∷ b ∷ a ∷ [] ) ) \/ ( A ( a ∷ [] ) /\ B ( b ∷ a ∷ [] ) ) \/ ( A ( a ∷ b ∷ [] ) /\ B ( a ∷ [] ) ) \/ ( A ( a ∷ b ∷ a ∷ [] ) /\ B [] ) ) test-AB→split {_} {A} {B} = refl list-eq : {Σ : Set} → (cmpi : (s t : Σ) → Dec (s ≡ t )) → (s t : List Σ ) → Bool list-eq cmpi [] [] = true list-eq cmpi [] (x ∷ t) = false list-eq cmpi (x ∷ s) [] = false list-eq cmpi (x ∷ s) (y ∷ t) with cmpi x y ... | yes _ = list-eq cmpi s t ... | no _ = false -- split-spec-01 : {s t u : List In } → s ++ t ≡ u → split (list-eq cmpi s) (list-eq cmpi t) u ≡ true -- split-spec-01 = {!!} -- from example 1.53 1 ex53-1 : Set ex53-1 = (s : List In ) → regular-language ( (< a > *) & < b > & (< a > *) ) cmpi s ≡ true → {!!} -- contains exact one b ex53-2 : Set ex53-2 = (s : List In ) → regular-language ( (any * ) & < b > & (any *) ) cmpi s ≡ true → {!!} -- contains at lease one b evenp : {Σ : Set} → List Σ → Bool oddp : {Σ : Set} → List Σ → Bool oddp [] = false oddp (_ ∷ t) = evenp t evenp [] = true evenp (_ ∷ t) = oddp t -- from example 1.53 5 egex-even : Set egex-even = (s : List In ) → regular-language ( ( any & any ) * ) cmpi s ≡ true → evenp s ≡ true test11 = regular-language ( ( any & any ) * ) cmpi (a ∷ []) test12 = regular-language ( ( any & any ) * ) cmpi (a ∷ b ∷ []) -- proof-egex-even : egex-even -- proof-egex-even [] _ = refl -- proof-egex-even (a ∷ []) () -- proof-egex-even (b ∷ []) () -- proof-egex-even (c ∷ []) () -- proof-egex-even (x ∷ x₁ ∷ s) y = proof-egex-even s {!!} open import finiteSet iFin : FiniteSet In iFin = record { finite = finite0 ; Q←F = Q←F0 ; F←Q = F←Q0 ; finiso→ = finiso→0 ; finiso← = finiso←0 } where finite0 : ℕ finite0 = 4 Q←F0 : Fin finite0 → In Q←F0 zero = a Q←F0 (suc zero) = b Q←F0 (suc (suc zero)) = c Q←F0 (suc (suc (suc zero))) = d F←Q0 : In → Fin finite0 F←Q0 a = # 0 F←Q0 b = # 1 F←Q0 c = # 2 F←Q0 d = # 3 finiso→0 : (q : In) → Q←F0 ( F←Q0 q ) ≡ q finiso→0 a = refl finiso→0 b = refl finiso→0 c = refl finiso→0 d = refl finiso←0 : (f : Fin finite0 ) → F←Q0 ( Q←F0 f ) ≡ f finiso←0 zero = refl finiso←0 (suc zero) = refl finiso←0 (suc (suc zero)) = refl finiso←0 (suc (suc (suc zero))) = refl open import derive In iFin open import automaton ra-ex = trace (regex→automaton cmpi r2) (record { state = r2 ; is-derived = unit }) ( a ∷ b ∷ c ∷ [])
algebraic-stack_agda0000_doc_238
------------------------------------------------------------------------ -- Labelled transition systems ------------------------------------------------------------------------ {-# OPTIONS --safe #-} module Labelled-transition-system where open import Equality.Propositional import Logical-equivalence open import Prelude open import Bijection equality-with-J using (_↔_) open import Equivalence equality-with-J using (↔⇒≃) open import Function-universe equality-with-J hiding (id; _∘_) open import Univalence-axiom equality-with-J -- Labelled transition systems were perhaps first defined by Robert M. -- Keller (https://doi.org/10.1145/360248.360251). The definition -- below is a variant with a field "is-silent", added by me. -- -- I don't know who first came up with the concept of a weak -- transition. The definitions of _⇒_, _[_]⇒_, _[_]⇒̂_ and _[_]⟶̂_ below -- are based on definitions in "Enhancements of the bisimulation proof -- method" by Pous and Sangiorgi. record LTS ℓ : Type (lsuc ℓ) where infix 4 _[_]⟶_ _⇒_ _[_]⇒_ _[_]⇒̂_ _[_]⟶̂_ field -- Processes. Proc : Type ℓ -- Labels. Label : Type ℓ -- Transitions. _[_]⟶_ : Proc → Label → Proc → Type ℓ -- Is the label silent? is-silent : Label → Bool -- Is the label silent? Silent : Label → Type Silent μ with is-silent μ ... | true = ⊤ ... | false = ⊥ -- Silence can be decided. silent? : ∀ μ → Dec (Silent μ) silent? μ with is-silent μ ... | true = yes _ ... | false = no id -- Sequences of zero or more silent transitions. data _⇒_ : Proc → Proc → Type ℓ where done : ∀ {p} → p ⇒ p step : ∀ {p q r μ} → Silent μ → p [ μ ]⟶ q → q ⇒ r → p ⇒ r -- Weak transitions (one kind). data _[_]⇒_ (p : Proc) (μ : Label) (q : Proc) : Type ℓ where steps : ∀ {p′ q′} → p ⇒ p′ → p′ [ μ ]⟶ q′ → q′ ⇒ q → p [ μ ]⇒ q -- Weak transitions (another kind). data _[_]⇒̂_ (p : Proc) (μ : Label) (q : Proc) : Type ℓ where silent : Silent μ → p ⇒ q → p [ μ ]⇒̂ q non-silent : ¬ Silent μ → p [ μ ]⇒ q → p [ μ ]⇒̂ q -- Weak transitions (yet another kind). data _[_]⟶̂_ (p : Proc) (μ : Label) : Proc → Type ℓ where done : Silent μ → p [ μ ]⟶̂ p step : ∀ {q} → p [ μ ]⟶ q → p [ μ ]⟶̂ q -- Functions that can be used to aid the instance resolution -- mechanism. infix -2 ⟶:_ ⇒:_ []⇒:_ ⇒̂:_ ⟶̂:_ ⟶:_ : ∀ {p μ q} → p [ μ ]⟶ q → p [ μ ]⟶ q ⟶:_ = id ⇒:_ : ∀ {p q} → p ⇒ q → p ⇒ q ⇒:_ = id []⇒:_ : ∀ {p μ q} → p [ μ ]⇒ q → p [ μ ]⇒ q []⇒:_ = id ⇒̂:_ : ∀ {p μ q} → p [ μ ]⇒̂ q → p [ μ ]⇒̂ q ⇒̂:_ = id ⟶̂:_ : ∀ {p μ q} → p [ μ ]⟶̂ q → p [ μ ]⟶̂ q ⟶̂:_ = id -- An "equational" reasoning combinator that is not subsumed by the -- combinators in Equational-reasoning, because the types of the two -- main arguments and the result use three different relations. infixr -2 ⟶⇒→[]⇒ ⟶⇒→[]⇒ : ∀ p μ {q r} → p [ μ ]⟶ q → q ⇒ r → p [ μ ]⇒ r ⟶⇒→[]⇒ _ _ = steps done syntax ⟶⇒→[]⇒ p μ p⟶q q⇒r = p [ μ ]⇒⟨ p⟶q ⟩ q⇒r -- Combinators that can be used to add visible type information to -- an expression. infix -1 step-with-action step-without-action step-with-action : ∀ p μ q → p [ μ ]⟶ q → p [ μ ]⟶ q step-with-action _ _ _ p⟶q = p⟶q step-without-action : ∀ p {μ} q → p [ μ ]⟶ q → p [ μ ]⟶ q step-without-action _ _ p⟶q = p⟶q syntax step-with-action p μ q p⟶q = p [ μ ]⟶⟨ p⟶q ⟩ q syntax step-without-action p q p⟶q = p ⟶⟨ p⟶q ⟩ q -- Regular transitions can (sometimes) be turned into weak ones. ⟶→⇒ : ∀ {p μ q} → Silent μ → p [ μ ]⟶ q → p ⇒ q ⟶→⇒ s tr = step s tr done ⟶→[]⇒ : ∀ {p μ q} → p [ μ ]⟶ q → p [ μ ]⇒ q ⟶→[]⇒ tr = steps done tr done ⟶→⇒̂ : ∀ {p μ q} → p [ μ ]⟶ q → p [ μ ]⇒̂ q ⟶→⇒̂ {μ = μ} tr with silent? μ ... | yes s = silent s (⟶→⇒ s tr) ... | no ¬s = non-silent ¬s (⟶→[]⇒ tr) ⟶→⟶̂ : ∀ {p μ q} → p [ μ ]⟶ q → p [ μ ]⟶̂ q ⟶→⟶̂ = step -- Several transitivity-like properties. ⇒-transitive : ∀ {p q r} → p ⇒ q → q ⇒ r → p ⇒ r ⇒-transitive done p⇒q = p⇒q ⇒-transitive (step s p⟶q q⇒r) r⇒s = step s p⟶q (⇒-transitive q⇒r r⇒s) ⇒[]⇒-transitive : ∀ {p q r μ} → p ⇒ q → q [ μ ]⇒ r → p [ μ ]⇒ r ⇒[]⇒-transitive p⇒q (steps q⇒r r⟶s s⇒t) = steps (⇒-transitive p⇒q q⇒r) r⟶s s⇒t []⇒⇒-transitive : ∀ {p q r μ} → p [ μ ]⇒ q → q ⇒ r → p [ μ ]⇒ r []⇒⇒-transitive (steps p⇒q q⟶r r⇒s) s⇒t = steps p⇒q q⟶r (⇒-transitive r⇒s s⇒t) ⇒⇒̂-transitive : ∀ {p q r μ} → p ⇒ q → q [ μ ]⇒̂ r → p [ μ ]⇒̂ r ⇒⇒̂-transitive p⇒q (silent s q⇒r) = silent s (⇒-transitive p⇒q q⇒r) ⇒⇒̂-transitive p⇒q (non-silent ¬s q⇒r) = non-silent ¬s (⇒[]⇒-transitive p⇒q q⇒r) ⇒̂⇒-transitive : ∀ {p q r μ} → p [ μ ]⇒̂ q → q ⇒ r → p [ μ ]⇒̂ r ⇒̂⇒-transitive (silent s p⇒q) q⇒r = silent s (⇒-transitive p⇒q q⇒r) ⇒̂⇒-transitive (non-silent ¬s p⇒q) q⇒r = non-silent ¬s ([]⇒⇒-transitive p⇒q q⇒r) -- More conversion functions. []⇒→⇒ : ∀ {p q μ} → Silent μ → p [ μ ]⇒ q → p ⇒ q []⇒→⇒ s (steps p⇒p′ p′⟶p″ p″⇒p‴) = ⇒-transitive p⇒p′ (step s p′⟶p″ p″⇒p‴) ⇒̂→⇒ : ∀ {p q μ} → Silent μ → p [ μ ]⇒̂ q → p ⇒ q ⇒̂→⇒ s (silent _ p⇒q) = p⇒q ⇒̂→⇒ s (non-silent ¬s _) = ⊥-elim (¬s s) ⇒→⇒̂ : ∀ {p q μ} → p [ μ ]⇒ q → p [ μ ]⇒̂ q ⇒→⇒̂ {μ = μ} tr with silent? μ ... | yes s = silent s ([]⇒→⇒ s tr) ... | no ¬s = non-silent ¬s tr ⇒̂→[]⇒ : ∀ {p q μ} → ¬ Silent μ → p [ μ ]⇒̂ q → p [ μ ]⇒ q ⇒̂→[]⇒ ¬s (silent s _) = ⊥-elim (¬s s) ⇒̂→[]⇒ _ (non-silent _ tr) = tr ⟶̂→⇒̂ : ∀ {p μ q} → p [ μ ]⟶̂ q → p [ μ ]⇒̂ q ⟶̂→⇒̂ (done s) = silent s done ⟶̂→⇒̂ (step tr) = ⟶→⇒̂ tr ⟶̂→⇒ : ∀ {p q μ} → Silent μ → p [ μ ]⟶̂ q → p ⇒ q ⟶̂→⇒ s = ⇒̂→⇒ s ∘ ⟶̂→⇒̂ -- Lemmas that can be used to show that relations are weak -- simulations of various kinds. module _ {ℓ} {_%_ _%′_ : Proc → Proc → Type ℓ} {_[_]%_ : Proc → Label → Proc → Type ℓ} (left-to-right : ∀ {p q} → p % q → ∀ {p′ μ} → p [ μ ]⟶ p′ → ∃ λ q′ → q [ μ ]% q′ × p′ %′ q′) (%′⇒% : ∀ {p q} → p %′ q → p % q) (%⇒⇒ : ∀ {p p′ μ} → Silent μ → p [ μ ]% p′ → p ⇒ p′) where is-weak⇒ : ∀ {p p′ q} → p % q → p ⇒ p′ → ∃ λ q′ → q ⇒ q′ × (p′ % q′) is-weak⇒ p%q done = _ , done , p%q is-weak⇒ p%q (step s p⟶p′ p′⇒p″) = let q′ , q%q′ , p′%′q′ = left-to-right p%q p⟶p′ q″ , q′⇒q″ , p″%q″ = is-weak⇒ (%′⇒% p′%′q′) p′⇒p″ in q″ , ⇒-transitive (%⇒⇒ s q%q′) q′⇒q″ , p″%q″ is-weak[]⇒ : ∀ {p p′ q μ} → (∀ {p p′} → p [ μ ]% p′ → p [ μ ]⇒ p′) → p % q → p [ μ ]⇒ p′ → ∃ λ q′ → q [ μ ]⇒ q′ × (p′ % q′) is-weak[]⇒ %⇒[]⇒ p%q (steps p⇒p′ p′⟶p″ p″⇒p‴) = let q′ , q⇒q′ , p′%q′ = is-weak⇒ p%q p⇒p′ q″ , q′%q″ , p″%′q″ = left-to-right p′%q′ p′⟶p″ q‴ , q″⇒q‴ , p‴%q‴ = is-weak⇒ (%′⇒% p″%′q″) p″⇒p‴ in q‴ , ⇒[]⇒-transitive q⇒q′ ([]⇒⇒-transitive (%⇒[]⇒ q′%q″) q″⇒q‴) , p‴%q‴ is-weak⇒̂ : ∀ {p p′ q μ} → (∀ {p p′} → p [ μ ]% p′ → p [ μ ]⇒̂ p′) → p % q → p [ μ ]⇒̂ p′ → ∃ λ q′ → q [ μ ]⇒̂ q′ × (p′ % q′) is-weak⇒̂ _ q%r (silent s q⇒q′) = Σ-map id (Σ-map (silent s) id) (is-weak⇒ q%r q⇒q′) is-weak⇒̂ %⇒⇒̂ q%r (non-silent ¬s q⇒q′) = Σ-map id (Σ-map ⇒→⇒̂ id) (is-weak[]⇒ (⇒̂→[]⇒ ¬s ∘ %⇒⇒̂) q%r q⇒q′) -- If no action is silent, then _[_]⇒_ is pointwise isomorphic to -- _[_]⟶_. ⟶↔⇒ : (∀ μ → ¬ Silent μ) → ∀ {p μ q} → p [ μ ]⟶ q ↔ p [ μ ]⇒ q ⟶↔⇒ ¬silent = record { surjection = record { logical-equivalence = record { to = ⟶→[]⇒ ; from = λ { (steps (step s _ _) _ _) → ⊥-elim (¬silent _ s) ; (steps _ _ (step s _ _)) → ⊥-elim (¬silent _ s) ; (steps done tr done) → tr } } ; right-inverse-of = λ { (steps (step s _ _) _ _) → ⊥-elim (¬silent _ s) ; (steps _ _ (step s _ _)) → ⊥-elim (¬silent _ s) ; (steps done tr done) → refl } } ; left-inverse-of = λ _ → refl } -- If no action is silent, then _[_]⇒̂_ is pointwise logically -- equivalent to _[_]⟶_, and in the presence of extensionality they -- are pointwise isomorphic. ⟶↔⇒̂ : ∀ {k} → Extensionality? k lzero lzero → (∀ μ → ¬ Silent μ) → ∀ {p μ q} → p [ μ ]⟶ q ↝[ k ] p [ μ ]⇒̂ q ⟶↔⇒̂ ext ¬silent = generalise-ext? ⟶⇔⇒̂ (λ ext → (λ { (silent s _) → ⊥-elim (¬silent _ s) ; (non-silent _ tr) → cong₂ non-silent (apply-ext ext (⊥-elim ∘ ¬silent _)) (_↔_.right-inverse-of (⟶↔⇒ ¬silent) tr) }) , (λ _ → refl)) ext where ⟶⇔⇒̂ = record { to = λ tr → non-silent (¬silent _) (_↔_.to (⟶↔⇒ ¬silent) tr) ; from = λ { (silent s _) → ⊥-elim (¬silent _ s) ; (non-silent _ tr) → _↔_.from (⟶↔⇒ ¬silent) tr } } -- Map-like functions. map-⇒′ : {F : Proc → Proc} → (∀ {p p′ μ} → Silent μ → p [ μ ]⟶ p′ → F p [ μ ]⟶ F p′) → ∀ {p p′} → p ⇒ p′ → F p ⇒ F p′ map-⇒′ f done = done map-⇒′ f (step s p⟶p′ p′⇒p″) = step s (f s p⟶p′) (map-⇒′ f p′⇒p″) map-⇒ : {F : Proc → Proc} → (∀ {p p′ μ} → p [ μ ]⟶ p′ → F p [ μ ]⟶ F p′) → ∀ {p p′} → p ⇒ p′ → F p ⇒ F p′ map-⇒ f = map-⇒′ (λ _ → f) map-[]⇒′ : ∀ {μ} {F : Proc → Proc} → (∀ {p p′ μ} → Silent μ → p [ μ ]⟶ p′ → F p [ μ ]⟶ F p′) → (∀ {p p′} → p [ μ ]⟶ p′ → F p [ μ ]⟶ F p′) → ∀ {p p′} → p [ μ ]⇒ p′ → F p [ μ ]⇒ F p′ map-[]⇒′ f g (steps p⇒p′ p′⟶p″ p″⇒p‴) = steps (map-⇒′ f p⇒p′) (g p′⟶p″) (map-⇒′ f p″⇒p‴) map-[]⇒ : {F : Proc → Proc} → (∀ {p p′ μ} → p [ μ ]⟶ p′ → F p [ μ ]⟶ F p′) → ∀ {p p′ μ} → p [ μ ]⇒ p′ → F p [ μ ]⇒ F p′ map-[]⇒ f = map-[]⇒′ (λ _ → f) f map-⇒̂′ : ∀ {μ} {F : Proc → Proc} → (∀ {p p′ μ} → Silent μ → p [ μ ]⟶ p′ → F p [ μ ]⟶ F p′) → (∀ {p p′} → p [ μ ]⟶ p′ → F p [ μ ]⟶ F p′) → ∀ {p p′} → p [ μ ]⇒̂ p′ → F p [ μ ]⇒̂ F p′ map-⇒̂′ f g (silent s p⇒p′) = silent s (map-⇒′ f p⇒p′) map-⇒̂′ f g (non-silent ¬s p⇒p′) = non-silent ¬s (map-[]⇒′ f g p⇒p′) map-⇒̂ : {F : Proc → Proc} → (∀ {p p′ μ} → p [ μ ]⟶ p′ → F p [ μ ]⟶ F p′) → ∀ {p p′ μ} → p [ μ ]⇒̂ p′ → F p [ μ ]⇒̂ F p′ map-⇒̂ f = map-⇒̂′ (λ _ → f) f map-⟶̂ : ∀ {μ p p′} {F : Proc → Proc} → (p [ μ ]⟶ p′ → F p [ μ ]⟶ F p′) → p [ μ ]⟶̂ p′ → F p [ μ ]⟶̂ F p′ map-⟶̂ f (done s) = done s map-⟶̂ f (step p⟶p′) = step (f p⟶p′) -- Zip-like functions. module _ {F : Proc → Proc → Proc} (f : ∀ {p p′ q μ} → p [ μ ]⟶ p′ → F p q [ μ ]⟶ F p′ q) (g : ∀ {p q q′ μ} → q [ μ ]⟶ q′ → F p q [ μ ]⟶ F p q′) where zip-⇒ : ∀ {p p′ q q′} → p ⇒ p′ → q ⇒ q′ → F p q ⇒ F p′ q′ zip-⇒ done done = done zip-⇒ done (step s q⟶q′ q′⇒q″) = step s (g q⟶q′) (zip-⇒ done q′⇒q″) zip-⇒ (step s p⟶p′ p′⇒p″) tr = step s (f p⟶p′) (zip-⇒ p′⇒p″ tr) zip-[]⇒ˡ′ : ∀ {p p′ q q′ μ₁ μ₃} → (∀ {p p′ q} → p [ μ₁ ]⟶ p′ → F p q [ μ₃ ]⟶ F p′ q) → p [ μ₁ ]⇒ p′ → q ⇒ q′ → F p q [ μ₃ ]⇒ F p′ q′ zip-[]⇒ˡ′ h (steps p⇒p′ p′⟶p″ p″⇒p‴) q⇒q′ = steps (zip-⇒ p⇒p′ q⇒q′) (h p′⟶p″) (zip-⇒ p″⇒p‴ done) zip-[]⇒ˡ : ∀ {p p′ q q′ μ} → p [ μ ]⇒ p′ → q ⇒ q′ → F p q [ μ ]⇒ F p′ q′ zip-[]⇒ˡ = zip-[]⇒ˡ′ f zip-[]⇒ʳ′ : ∀ {p p′ q q′ μ₂ μ₃} → (∀ {p q q′} → q [ μ₂ ]⟶ q′ → F p q [ μ₃ ]⟶ F p q′) → p ⇒ p′ → q [ μ₂ ]⇒ q′ → F p q [ μ₃ ]⇒ F p′ q′ zip-[]⇒ʳ′ h p⇒p′ (steps q⇒q′ q′⟶q″ q″⇒q‴) = steps (zip-⇒ p⇒p′ q⇒q′) (h q′⟶q″) (zip-⇒ done q″⇒q‴) zip-[]⇒ʳ : ∀ {p p′ q q′ μ} → p ⇒ p′ → q [ μ ]⇒ q′ → F p q [ μ ]⇒ F p′ q′ zip-[]⇒ʳ = zip-[]⇒ʳ′ g zip-[]⇒ : ∀ {μ₁ μ₂ μ₃} → (∀ {p p′ q q′} → p [ μ₁ ]⟶ p′ → q [ μ₂ ]⟶ q′ → F p q [ μ₃ ]⟶ F p′ q′) → ∀ {p p′ q q′} → p [ μ₁ ]⇒ p′ → q [ μ₂ ]⇒ q′ → F p q [ μ₃ ]⇒ F p′ q′ zip-[]⇒ h (steps p⇒p′ p′⟶p″ p″⇒p‴) (steps q⇒q′ q′⟶q″ q″⇒q‴) = steps (zip-⇒ p⇒p′ q⇒q′) (h p′⟶p″ q′⟶q″) (zip-⇒ p″⇒p‴ q″⇒q‴) zip-⇒̂ : ∀ {μ₁ μ₂ μ₃} → (Silent μ₁ → Silent μ₂ → Silent μ₃) → (∀ {p p′ q} → p [ μ₁ ]⟶ p′ → Silent μ₂ → F p q [ μ₃ ]⟶ F p′ q) → (∀ {p q q′} → Silent μ₁ → q [ μ₂ ]⟶ q′ → F p q [ μ₃ ]⟶ F p q′) → (∀ {p p′ q q′} → p [ μ₁ ]⟶ p′ → q [ μ₂ ]⟶ q′ → F p q [ μ₃ ]⟶ F p′ q′) → ∀ {p p′ q q′} → p [ μ₁ ]⇒̂ p′ → q [ μ₂ ]⇒̂ q′ → F p q [ μ₃ ]⇒̂ F p′ q′ zip-⇒̂ fs hˡ hʳ h = λ where (silent s₁ tr₁) (silent s₂ tr₂) → silent (fs s₁ s₂) (zip-⇒ tr₁ tr₂) (silent s₁ tr₁) (non-silent ¬s₂ tr₂) → ⇒→⇒̂ (zip-[]⇒ʳ′ (hʳ s₁) tr₁ tr₂) (non-silent ¬s₁ tr₁) (silent s₂ tr₂) → ⇒→⇒̂ (zip-[]⇒ˡ′ (flip hˡ s₂) tr₁ tr₂) (non-silent ¬s₁ tr₁) (non-silent ¬s₂ tr₂) → ⇒→⇒̂ (zip-[]⇒ h tr₁ tr₂) zip-⟶̂ : ∀ {F : Proc → Proc → Proc} {μ₁ μ₂ μ₃} → (Silent μ₁ → Silent μ₂ → Silent μ₃) → (∀ {p p′ q} → p [ μ₁ ]⟶ p′ → Silent μ₂ → F p q [ μ₃ ]⟶ F p′ q) → (∀ {p q q′} → Silent μ₁ → q [ μ₂ ]⟶ q′ → F p q [ μ₃ ]⟶ F p q′) → (∀ {p p′ q q′} → p [ μ₁ ]⟶ p′ → q [ μ₂ ]⟶ q′ → F p q [ μ₃ ]⟶ F p′ q′) → ∀ {p p′ q q′} → p [ μ₁ ]⟶̂ p′ → q [ μ₂ ]⟶̂ q′ → F p q [ μ₃ ]⟶̂ F p′ q′ zip-⟶̂ s f g h (done s₁) (done s₂) = done (s s₁ s₂) zip-⟶̂ s f g h (done s₁) (step q⟶q′) = step (g s₁ q⟶q′) zip-⟶̂ s f g h (step p⟶p′) (done s₂) = step (f p⟶p′ s₂) zip-⟶̂ s f g h (step p⟶p′) (step q⟶q′) = step (h p⟶p′ q⟶q′) -- Transforms an LTS into one which uses weak transitions as -- transitions. weak : ∀ {ℓ} → LTS ℓ → LTS ℓ weak lts = record { Proc = Proc ; Label = Label ; _[_]⟶_ = _[_]⇒̂_ ; is-silent = is-silent } where open LTS lts -- If no lts action is silent, then weak lts is equal to lts (assuming -- extensionality and univalence). weak≡id : ∀ {ℓ} → Extensionality ℓ (lsuc ℓ) → Univalence ℓ → (lts : LTS ℓ) → (∀ μ → ¬ LTS.Silent lts μ) → weak lts ≡ lts weak≡id ext univ lts ¬silent = cong (λ _[_]⟶_ → record { Proc = Proc ; Label = Label ; _[_]⟶_ = _[_]⟶_ ; is-silent = is-silent }) (apply-ext ext λ p → apply-ext ext λ μ → apply-ext ext λ q → p [ μ ]⇒̂ q ≡⟨ ≃⇒≡ univ $ ↔⇒≃ $ inverse $ ⟶↔⇒̂ (lower-extensionality _ _ ext) ¬silent ⟩∎ p [ μ ]⟶ q ∎) where open LTS lts -- An LTS with no processes or labels. empty : LTS lzero empty = record { Proc = ⊥ ; Label = ⊥ ; _[_]⟶_ = λ () ; is-silent = λ () } -- An LTS with a single process, a single (non-silent) label, and a -- single transition. one-loop : LTS lzero one-loop = record { Proc = ⊤ ; Label = ⊤ ; _[_]⟶_ = λ _ _ _ → ⊤ ; is-silent = λ _ → false } -- An LTS with two distinct, but bisimilar, processes. There are -- transitions between the two processes. two-bisimilar-processes : LTS lzero two-bisimilar-processes = record { Proc = Bool ; Label = ⊤ ; _[_]⟶_ = λ _ _ _ → ⊤ ; is-silent = λ _ → false } -- A parametrised LTS for which bisimilarity is logically equivalent -- to equality. bisimilarity⇔equality : ∀ {ℓ} → Type ℓ → LTS ℓ bisimilarity⇔equality A = record { Proc = A ; Label = A ; _[_]⟶_ = λ p μ q → p ≡ μ × p ≡ q ; is-silent = λ _ → false }
algebraic-stack_agda0000_doc_239
{- following Johnstone's book "Stone Spaces" we define semilattices to be commutative monoids such that every element is idempotent. In particular, we take every semilattice to have a neutral element that is either the maximal or minimal element depending on whether we have a join or meet semilattice. -} {-# OPTIONS --safe #-} module Cubical.Algebra.Semilattice.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.CommMonoid open import Cubical.Displayed.Base open import Cubical.Displayed.Auto open import Cubical.Displayed.Record open import Cubical.Displayed.Universe open import Cubical.Relation.Binary open import Cubical.Relation.Binary.Poset open import Cubical.Reflection.RecordEquiv open Iso private variable ℓ ℓ' : Level record IsSemilattice {A : Type ℓ} (ε : A) (_·_ : A → A → A) : Type ℓ where constructor issemilattice field isCommMonoid : IsCommMonoid ε _·_ idem : (x : A) → x · x ≡ x open IsCommMonoid isCommMonoid public unquoteDecl IsSemilatticeIsoΣ = declareRecordIsoΣ IsSemilatticeIsoΣ (quote IsSemilattice) record SemilatticeStr (A : Type ℓ) : Type ℓ where constructor semilatticestr field ε : A _·_ : A → A → A isSemilattice : IsSemilattice ε _·_ infixl 7 _·_ open IsSemilattice isSemilattice public Semilattice : ∀ ℓ → Type (ℓ-suc ℓ) Semilattice ℓ = TypeWithStr ℓ SemilatticeStr semilattice : (A : Type ℓ) (ε : A) (_·_ : A → A → A) (h : IsSemilattice ε _·_) → Semilattice ℓ semilattice A ε _·_ h = A , semilatticestr ε _·_ h -- Easier to use constructors makeIsSemilattice : {L : Type ℓ} {ε : L} {_·_ : L → L → L} (is-setL : isSet L) (assoc : (x y z : L) → x · (y · z) ≡ (x · y) · z) (rid : (x : L) → x · ε ≡ x) (lid : (x : L) → ε · x ≡ x) (comm : (x y : L) → x · y ≡ y · x) (idem : (x : L) → x · x ≡ x) → IsSemilattice ε _·_ IsSemilattice.isCommMonoid (makeIsSemilattice is-setL assoc rid lid comm idem) = makeIsCommMonoid is-setL assoc rid lid comm IsSemilattice.idem (makeIsSemilattice is-setL assoc rid lid comm idem) = idem makeSemilattice : {L : Type ℓ} (ε : L) (_·_ : L → L → L) (is-setL : isSet L) (assoc : (x y z : L) → x · (y · z) ≡ (x · y) · z) (rid : (x : L) → x · ε ≡ x) (lid : (x : L) → ε · x ≡ x) (comm : (x y : L) → x · y ≡ y · x) (idem : (x : L) → x · x ≡ x) → Semilattice ℓ makeSemilattice ε _·_ is-setL assoc rid lid comm idem = semilattice _ ε _·_ (makeIsSemilattice is-setL assoc rid lid comm idem) SemilatticeStr→MonoidStr : {A : Type ℓ} → SemilatticeStr A → MonoidStr A SemilatticeStr→MonoidStr (semilatticestr _ _ H) = monoidstr _ _ (H .IsSemilattice.isCommMonoid .IsCommMonoid.isMonoid) Semilattice→Monoid : Semilattice ℓ → Monoid ℓ Semilattice→Monoid (_ , semilatticestr _ _ H) = _ , monoidstr _ _ (H .IsSemilattice.isCommMonoid .IsCommMonoid.isMonoid) Semilattice→CommMonoid : Semilattice ℓ → CommMonoid ℓ Semilattice→CommMonoid (_ , semilatticestr _ _ H) = _ , commmonoidstr _ _ (H .IsSemilattice.isCommMonoid) SemilatticeHom : (L : Semilattice ℓ) (M : Semilattice ℓ') → Type (ℓ-max ℓ ℓ') SemilatticeHom L M = MonoidHom (Semilattice→Monoid L) (Semilattice→Monoid M) IsSemilatticeEquiv : {A : Type ℓ} {B : Type ℓ'} (M : SemilatticeStr A) (e : A ≃ B) (N : SemilatticeStr B) → Type (ℓ-max ℓ ℓ') IsSemilatticeEquiv M e N = IsMonoidHom (SemilatticeStr→MonoidStr M) (e .fst) (SemilatticeStr→MonoidStr N) SemilatticeEquiv : (M : Semilattice ℓ) (N : Semilattice ℓ') → Type (ℓ-max ℓ ℓ') SemilatticeEquiv M N = Σ[ e ∈ (M .fst ≃ N .fst) ] IsSemilatticeEquiv (M .snd) e (N .snd) isPropIsSemilattice : {L : Type ℓ} (ε : L) (_·_ : L → L → L) → isProp (IsSemilattice ε _·_) isPropIsSemilattice ε _·_ (issemilattice LL LC) (issemilattice SL SC) = λ i → issemilattice (isPropIsCommMonoid _ _ LL SL i) (isPropIdem LC SC i) where isSetL : isSet _ isSetL = LL .IsCommMonoid.isMonoid .IsMonoid.isSemigroup .IsSemigroup.is-set isPropIdem : isProp ((x : _) → x · x ≡ x) isPropIdem = isPropΠ λ _ → isSetL _ _ 𝒮ᴰ-Semilattice : DUARel (𝒮-Univ ℓ) SemilatticeStr ℓ 𝒮ᴰ-Semilattice = 𝒮ᴰ-Record (𝒮-Univ _) IsSemilatticeEquiv (fields: data[ ε ∣ autoDUARel _ _ ∣ presε ] data[ _·_ ∣ autoDUARel _ _ ∣ isHom ] prop[ isSemilattice ∣ (λ _ _ → isPropIsSemilattice _ _) ]) where open SemilatticeStr open IsMonoidHom SemilatticePath : (L K : Semilattice ℓ) → SemilatticeEquiv L K ≃ (L ≡ K) SemilatticePath = ∫ 𝒮ᴰ-Semilattice .UARel.ua -- TODO: decide if that's the right approach module JoinSemilattice (L' : Semilattice ℓ) where private L = fst L' open SemilatticeStr (snd L') renaming (_·_ to _∨l_ ; ε to 1l) open CommMonoidTheory (Semilattice→CommMonoid L') _≤_ : L → L → Type ℓ x ≤ y = x ∨l y ≡ y infix 4 _≤_ IndPoset : Poset ℓ ℓ fst IndPoset = L PosetStr._≤_ (snd IndPoset) = _≤_ IsPoset.is-set (PosetStr.isPoset (snd IndPoset)) = is-set IsPoset.is-prop-valued (PosetStr.isPoset (snd IndPoset)) = λ _ _ → is-set _ _ IsPoset.is-refl (PosetStr.isPoset (snd IndPoset)) = idem IsPoset.is-trans (PosetStr.isPoset (snd IndPoset)) = path where path : (a b c : L) → a ∨l b ≡ b → b ∨l c ≡ c → a ∨l c ≡ c path a b c a∨b≡b b∨c≡c = a ∨l c ≡⟨ cong (a ∨l_) (sym b∨c≡c) ⟩ a ∨l (b ∨l c) ≡⟨ assoc _ _ _ ⟩ (a ∨l b) ∨l c ≡⟨ cong (_∨l c) a∨b≡b ⟩ b ∨l c ≡⟨ b∨c≡c ⟩ c ∎ IsPoset.is-antisym (PosetStr.isPoset (snd IndPoset)) = λ _ _ a∨b≡b b∨a≡a → sym b∨a≡a ∙∙ comm _ _ ∙∙ a∨b≡b ∨lIsMax : ∀ x y z → x ≤ z → y ≤ z → x ∨l y ≤ z ∨lIsMax x y z x≤z y≤z = cong ((x ∨l y) ∨l_) (sym (idem z)) ∙ commAssocSwap x y z z ∙ cong₂ (_∨l_) x≤z y≤z ∙ idem z ≤-∨Pres : ∀ x y u w → x ≤ y → u ≤ w → x ∨l u ≤ y ∨l w ≤-∨Pres x y u w x≤y u≤w = commAssocSwap x u y w ∙ cong₂ (_∨l_) x≤y u≤w ≤-∨LPres : ∀ x y z → x ≤ y → z ∨l x ≤ z ∨l y ≤-∨LPres x y z x≤y = ≤-∨Pres _ _ _ _ (idem z) x≤y module MeetSemilattice (L' : Semilattice ℓ) where private L = fst L' open SemilatticeStr (snd L') renaming (_·_ to _∧l_ ; ε to 0l) open CommMonoidTheory (Semilattice→CommMonoid L') _≤_ : L → L → Type ℓ x ≤ y = x ∧l y ≡ x infix 4 _≤_ IndPoset : Poset ℓ ℓ fst IndPoset = L PosetStr._≤_ (snd IndPoset) = _≤_ IsPoset.is-set (PosetStr.isPoset (snd IndPoset)) = is-set IsPoset.is-prop-valued (PosetStr.isPoset (snd IndPoset)) = λ _ _ → is-set _ _ IsPoset.is-refl (PosetStr.isPoset (snd IndPoset)) = idem IsPoset.is-trans (PosetStr.isPoset (snd IndPoset)) = path where path : (a b c : L) → a ∧l b ≡ a → b ∧l c ≡ b → a ∧l c ≡ a path a b c a∧b≡a b∧c≡b = a ∧l c ≡⟨ cong (_∧l c) (sym a∧b≡a) ⟩ (a ∧l b) ∧l c ≡⟨ sym (assoc _ _ _) ⟩ a ∧l (b ∧l c) ≡⟨ cong (a ∧l_) b∧c≡b ⟩ a ∧l b ≡⟨ a∧b≡a ⟩ a ∎ IsPoset.is-antisym (PosetStr.isPoset (snd IndPoset)) = λ _ _ a∧b≡a b∧a≡b → sym a∧b≡a ∙∙ comm _ _ ∙∙ b∧a≡b ≤-∧LPres : ∀ x y z → x ≤ y → z ∧l x ≤ z ∧l y ≤-∧LPres x y z x≤y = commAssocSwap z x z y ∙∙ cong (_∧l (x ∧l y)) (idem z) ∙∙ cong (z ∧l_) x≤y ∧≤LCancel : ∀ x y → x ∧l y ≤ y ∧≤LCancel x y = sym (assoc _ _ _) ∙ cong (x ∧l_) (idem y) ∧≤RCancel : ∀ x y → x ∧l y ≤ x ∧≤RCancel x y = commAssocr x y x ∙ cong (_∧l y) (idem x) ∧lIsMin : ∀ x y z → z ≤ x → z ≤ y → z ≤ x ∧l y ∧lIsMin x y z z≤x z≤y = cong (_∧l (x ∧l y)) (sym (idem z)) ∙ commAssocSwap z z x y ∙ cong₂ (_∧l_) z≤x z≤y ∙ idem z
algebraic-stack_agda0000_doc_48
module ShouldBeApplicationOf where data One : Set where one : One data Two : Set where two : Two f : One -> Two f two = two
algebraic-stack_agda0000_doc_49
-- Andreas, bug found 2011-12-31 {-# OPTIONS --irrelevant-projections #-} module Issue543 where open import Common.Equality data ⊥ : Set where record ⊤ : Set where constructor tt data Bool : Set where true false : Bool T : Bool → Set T true = ⊤ T false = ⊥ record Squash {ℓ}(A : Set ℓ) : Set ℓ where constructor squash field .unsquash : A open Squash -- ok: sqT≡sqF : squash true ≡ squash false sqT≡sqF = refl -- this should not be provable!! .irrT≡F : true ≡ false irrT≡F = subst (λ s → unsquash (squash true) ≡ unsquash s) sqT≡sqF refl -- the rest is easy T≠F : true ≡ false → ⊥ T≠F p = subst T p tt .irr⊥ : ⊥ irr⊥ = T≠F irrT≡F rel⊥ : .⊥ → ⊥ rel⊥ () absurd : ⊥ absurd = rel⊥ irr⊥
algebraic-stack_agda0000_doc_50
{-# OPTIONS --without-K --exact-split --safe #-} module HoTT.Ident where data Id (X : Set) : X → X → Set where refl : (x : X) → Id X x x _≡_ : {X : Set} → X → X → Set x ≡ y = Id _ x y 𝕁 : {X : Set} → (A : (x y : X) → x ≡ y → Set) → ((x : X) → A x x (refl x)) → (x y : X) → (p : x ≡ y) → A x y p 𝕁 A f x x (refl x) = f x ℍ : {X : Set} → (x : X) → (B : (y : X) → x ≡ y → Set) → B x (refl x) → (y : X) → (p : x ≡ y) → B y p ℍ x B b x (refl x) = b -- Defining `𝕁` in terms of `ℍ`. 𝕁' : {X : Set} → (A : (x y : X) → x ≡ y → Set) → ((x : X) → A x x (refl x)) → (x y : X) → (p : x ≡ y) → A x y p 𝕁' A f x = ℍ x (A x) (f x) -- Defining `ℍ` in terms of `𝕁`. transport : {X : Set} → (f : X → Set) → (x y : X) → (x ≡ y) → f x → f y transport f = 𝕁 (λ x y p → f x → f y) (λ x y → y) data Σ (A : Set) (p : A → Set) : Set where _,_ : (x : A) → p x → Σ A p curry : {A : Set} {B : A → Set} → ((x : A) → B x → Set) → Σ A B → Set curry f (x , y) = f x y -- This is just for the "Note" below. singl : (A : Set) → A → Set singl A x = Σ A (λ y → x ≡ y) -- Note: `≡` in the conclusion is WRT `Id (singl X x)`. -- Source: http://www.cse.chalmers.se/~coquand/singl.pdf lemma : {X : Set} → (x y : X) → (p : x ≡ y) → (x , refl x) ≡ (y , p) lemma = 𝕁 (λ x y p → (x , refl x) ≡ (y , p)) (λ x → refl (x , refl x)) ℍ' : {X : Set} → (x : X) → (B : (y : X) → x ≡ y → Set) → B x (refl x) → (y : X) → (p : x ≡ y) → B y p ℍ' x B b y p = transport (curry B) (x , refl x) (y , p) (lemma x y p) b
algebraic-stack_agda0000_doc_51
------------------------------------------------------------------------ -- Compiler correctness ------------------------------------------------------------------------ open import Prelude import Lambda.Syntax module Lambda.Compiler-correctness {Name : Type} (open Lambda.Syntax Name) (def : Name → Tm 1) where import Equality.Propositional as E import Tactic.By.Propositional as By open import Prelude.Size open import List E.equality-with-J using (_++_) open import Monad E.equality-with-J using (return; _>>=_) open import Vec.Data E.equality-with-J open import Delay-monad.Bisimilarity open import Lambda.Compiler def open import Lambda.Delay-crash open import Lambda.Interpreter def open import Lambda.Virtual-machine.Instructions Name hiding (crash) open import Lambda.Virtual-machine comp-name private module C = Closure Code module T = Closure Tm ------------------------------------------------------------------------ -- A lemma -- A rearrangement lemma for ⟦_⟧. ⟦⟧-· : ∀ {n} (t₁ t₂ : Tm n) {ρ} {k : T.Value → Delay-crash C.Value ∞} → ⟦ t₁ · t₂ ⟧ ρ >>= k ∼ ⟦ t₁ ⟧ ρ >>= λ v₁ → ⟦ t₂ ⟧ ρ >>= λ v₂ → v₁ ∙ v₂ >>= k ⟦⟧-· t₁ t₂ {ρ} {k} = ⟦ t₁ · t₂ ⟧ ρ >>= k ∼⟨⟩ (do v₁ ← ⟦ t₁ ⟧ ρ v₂ ← ⟦ t₂ ⟧ ρ v₁ ∙ v₂) >>= k ∼⟨ symmetric (associativity (⟦ t₁ ⟧ _) _ _) ⟩ (do v₁ ← ⟦ t₁ ⟧ ρ (do v₂ ← ⟦ t₂ ⟧ ρ v₁ ∙ v₂) >>= k) ∼⟨ (⟦ t₁ ⟧ _ ∎) >>=-cong (λ _ → symmetric (associativity (⟦ t₂ ⟧ _) _ _)) ⟩ (do v₁ ← ⟦ t₁ ⟧ ρ v₂ ← ⟦ t₂ ⟧ ρ v₁ ∙ v₂ >>= k) ∎ ------------------------------------------------------------------------ -- Well-formed continuations and stacks -- A continuation is OK with respect to a certain state if the -- following property is satisfied. Cont-OK : Size → State → (T.Value → Delay-crash C.Value ∞) → Type Cont-OK i ⟨ c , s , ρ ⟩ k = ∀ v → [ i ] exec ⟨ c , val (comp-val v) ∷ s , ρ ⟩ ≈ k v -- If the In-tail-context parameter indicates that we are in a tail -- context, then the stack must have a certain shape, and it must be -- related to the continuation in a certain way. data Stack-OK (i : Size) (k : T.Value → Delay-crash C.Value ∞) : In-tail-context → Stack → Type where unrestricted : ∀ {s} → Stack-OK i k false s restricted : ∀ {s n} {c : Code n} {ρ : C.Env n} → Cont-OK i ⟨ c , s , ρ ⟩ k → Stack-OK i k true (ret c ρ ∷ s) -- A lemma that can be used to show that certain stacks are OK. ret-ok : ∀ {p i s n c} {ρ : C.Env n} {k} → Cont-OK i ⟨ c , s , ρ ⟩ k → Stack-OK i k p (ret c ρ ∷ s) ret-ok {true} c-ok = restricted c-ok ret-ok {false} _ = unrestricted ------------------------------------------------------------------------ -- The semantics of the compiled program matches that of the source -- code mutual -- Some lemmas making up the main part of the compiler correctness -- result. ⟦⟧-correct : ∀ {i n} (t : Tm n) (ρ : T.Env n) {c s} {k : T.Value → Delay-crash C.Value ∞} {tc} → Stack-OK i k tc s → Cont-OK i ⟨ c , s , comp-env ρ ⟩ k → [ i ] exec ⟨ comp tc t c , s , comp-env ρ ⟩ ≈ ⟦ t ⟧ ρ >>= k ⟦⟧-correct (var x) ρ {c} {s} {k} _ c-ok = exec ⟨ var x ∷ c , s , comp-env ρ ⟩ ≳⟨⟩ exec ⟨ c , val By.⟨ index (comp-env ρ) x ⟩ ∷ s , comp-env ρ ⟩ ≡⟨ By.⟨by⟩ (comp-index ρ x) ⟩ exec ⟨ c , val (comp-val (index ρ x)) ∷ s , comp-env ρ ⟩ ≈⟨ c-ok (index ρ x) ⟩∼ k (index ρ x) ∼⟨⟩ ⟦ var x ⟧ ρ >>= k ∎ ⟦⟧-correct (lam t) ρ {c} {s} {k} _ c-ok = exec ⟨ clo (comp-body t) ∷ c , s , comp-env ρ ⟩ ≳⟨⟩ exec ⟨ c , val (comp-val (T.lam t ρ)) ∷ s , comp-env ρ ⟩ ≈⟨ c-ok (T.lam t ρ) ⟩∼ k (T.lam t ρ) ∼⟨⟩ ⟦ lam t ⟧ ρ >>= k ∎ ⟦⟧-correct (t₁ · t₂) ρ {c} {s} {k} _ c-ok = exec ⟨ comp false t₁ (comp false t₂ (app ∷ c)) , s , comp-env ρ ⟩ ≈⟨ (⟦⟧-correct t₁ _ unrestricted λ v₁ → exec ⟨ comp false t₂ (app ∷ c) , val (comp-val v₁) ∷ s , comp-env ρ ⟩ ≈⟨ (⟦⟧-correct t₂ _ unrestricted λ v₂ → exec ⟨ app ∷ c , val (comp-val v₂) ∷ val (comp-val v₁) ∷ s , comp-env ρ ⟩ ≈⟨ ∙-correct v₁ v₂ c-ok ⟩∼ v₁ ∙ v₂ >>= k ∎) ⟩∼ (⟦ t₂ ⟧ ρ >>= λ v₂ → v₁ ∙ v₂ >>= k) ∎) ⟩∼ (⟦ t₁ ⟧ ρ >>= λ v₁ → ⟦ t₂ ⟧ ρ >>= λ v₂ → v₁ ∙ v₂ >>= k) ∼⟨ symmetric (⟦⟧-· t₁ t₂) ⟩ ⟦ t₁ · t₂ ⟧ ρ >>= k ∎ ⟦⟧-correct (call f t) ρ {c} {s} {k} unrestricted c-ok = exec ⟨ comp false (call f t) c , s , comp-env ρ ⟩ ∼⟨⟩ exec ⟨ comp false t (cal f ∷ c) , s , comp-env ρ ⟩ ≈⟨ (⟦⟧-correct t _ unrestricted λ v → exec ⟨ cal f ∷ c , val (comp-val v) ∷ s , comp-env ρ ⟩ ≈⟨ (later λ { .force → exec ⟨ comp-name f , ret c (comp-env ρ) ∷ s , comp-val v ∷ [] ⟩ ≈⟨ body-lemma (def f) [] c-ok ⟩∼ (⟦ def f ⟧ (v ∷ []) >>= k) ∎ }) ⟩∼ (T.lam (def f) [] ∙ v >>= k) ∎) ⟩∼ (⟦ t ⟧ ρ >>= λ v → T.lam (def f) [] ∙ v >>= k) ∼⟨ associativity (⟦ t ⟧ ρ) _ _ ⟩ (⟦ t ⟧ ρ >>= λ v → T.lam (def f) [] ∙ v) >>= k ∼⟨⟩ ⟦ call f t ⟧ ρ >>= k ∎ ⟦⟧-correct (call f t) ρ {c} {ret c′ ρ′ ∷ s} {k} (restricted c-ok) _ = exec ⟨ comp true (call f t) c , ret c′ ρ′ ∷ s , comp-env ρ ⟩ ∼⟨⟩ exec ⟨ comp false t (tcl f ∷ c) , ret c′ ρ′ ∷ s , comp-env ρ ⟩ ≈⟨ (⟦⟧-correct t _ unrestricted λ v → exec ⟨ tcl f ∷ c , val (comp-val v) ∷ ret c′ ρ′ ∷ s , comp-env ρ ⟩ ≈⟨ (later λ { .force → exec ⟨ comp-name f , ret c′ ρ′ ∷ s , comp-val v ∷ [] ⟩ ≈⟨ body-lemma (def f) [] c-ok ⟩∼ ⟦ def f ⟧ (v ∷ []) >>= k ∎ }) ⟩∼ T.lam (def f) [] ∙ v >>= k ∎) ⟩∼ (⟦ t ⟧ ρ >>= λ v → T.lam (def f) [] ∙ v >>= k) ∼⟨ associativity (⟦ t ⟧ ρ) _ _ ⟩ (⟦ t ⟧ ρ >>= λ v → T.lam (def f) [] ∙ v) >>= k ∼⟨⟩ ⟦ call f t ⟧ ρ >>= k ∎ ⟦⟧-correct (con b) ρ {c} {s} {k} _ c-ok = exec ⟨ con b ∷ c , s , comp-env ρ ⟩ ≳⟨⟩ exec ⟨ c , val (comp-val (T.con b)) ∷ s , comp-env ρ ⟩ ≈⟨ c-ok (T.con b) ⟩∼ k (T.con b) ∼⟨⟩ ⟦ con b ⟧ ρ >>= k ∎ ⟦⟧-correct (if t₁ t₂ t₃) ρ {c} {s} {k} {tc} s-ok c-ok = exec ⟨ comp false t₁ (bra (comp tc t₂ []) (comp tc t₃ []) ∷ c) , s , comp-env ρ ⟩ ≈⟨ (⟦⟧-correct t₁ _ unrestricted λ v₁ → ⟦if⟧-correct v₁ t₂ t₃ s-ok c-ok) ⟩∼ (⟦ t₁ ⟧ ρ >>= λ v₁ → ⟦if⟧ v₁ t₂ t₃ ρ >>= k) ∼⟨ associativity (⟦ t₁ ⟧ ρ) _ _ ⟩ (⟦ t₁ ⟧ ρ >>= λ v₁ → ⟦if⟧ v₁ t₂ t₃ ρ) >>= k ∼⟨⟩ ⟦ if t₁ t₂ t₃ ⟧ ρ >>= k ∎ body-lemma : ∀ {i n n′} (t : Tm (1 + n)) ρ {ρ′ : C.Env n′} {c s v} {k : T.Value → Delay-crash C.Value ∞} → Cont-OK i ⟨ c , s , ρ′ ⟩ k → [ i ] exec ⟨ comp-body t , ret c ρ′ ∷ s , comp-val v ∷ comp-env ρ ⟩ ≈ ⟦ t ⟧ (v ∷ ρ) >>= k body-lemma t ρ {ρ′} {c} {s} {v} {k} c-ok = exec ⟨ comp-body t , ret c ρ′ ∷ s , comp-val v ∷ comp-env ρ ⟩ ∼⟨⟩ exec ⟨ comp-body t , ret c ρ′ ∷ s , comp-env (v ∷ ρ) ⟩ ≈⟨ (⟦⟧-correct t (_ ∷ _) (ret-ok c-ok) λ v′ → exec ⟨ ret ∷ [] , val (comp-val v′) ∷ ret c ρ′ ∷ s , comp-env (v ∷ ρ) ⟩ ≳⟨⟩ exec ⟨ c , val (comp-val v′) ∷ s , ρ′ ⟩ ≈⟨ c-ok v′ ⟩∼ k v′ ∎) ⟩∼ ⟦ t ⟧ (v ∷ ρ) >>= k ∎ ∙-correct : ∀ {i n} v₁ v₂ {ρ : C.Env n} {c s} {k : T.Value → Delay-crash C.Value ∞} → Cont-OK i ⟨ c , s , ρ ⟩ k → [ i ] exec ⟨ app ∷ c , val (comp-val v₂) ∷ val (comp-val v₁) ∷ s , ρ ⟩ ≈ v₁ ∙ v₂ >>= k ∙-correct (T.lam t₁ ρ₁) v₂ {ρ} {c} {s} {k} c-ok = exec ⟨ app ∷ c , val (comp-val v₂) ∷ val (comp-val (T.lam t₁ ρ₁)) ∷ s , ρ ⟩ ≈⟨ later (λ { .force → exec ⟨ comp-body t₁ , ret c ρ ∷ s , comp-val v₂ ∷ comp-env ρ₁ ⟩ ≈⟨ body-lemma t₁ _ c-ok ⟩∼ ⟦ t₁ ⟧ (v₂ ∷ ρ₁) >>= k ∎ }) ⟩∎ T.lam t₁ ρ₁ ∙ v₂ >>= k ∎ ∙-correct (T.con b) v₂ {ρ} {c} {s} {k} _ = exec ⟨ app ∷ c , val (comp-val v₂) ∷ val (comp-val (T.con b)) ∷ s , ρ ⟩ ≳⟨⟩ crash ∼⟨⟩ T.con b ∙ v₂ >>= k ∎ ⟦if⟧-correct : ∀ {i n} v₁ (t₂ t₃ : Tm n) {ρ : T.Env n} {c s} {k : T.Value → Delay-crash C.Value ∞} {tc} → Stack-OK i k tc s → Cont-OK i ⟨ c , s , comp-env ρ ⟩ k → [ i ] exec ⟨ bra (comp tc t₂ []) (comp tc t₃ []) ∷ c , val (comp-val v₁) ∷ s , comp-env ρ ⟩ ≈ ⟦if⟧ v₁ t₂ t₃ ρ >>= k ⟦if⟧-correct (T.lam t₁ ρ₁) t₂ t₃ {ρ} {c} {s} {k} {tc} _ _ = exec ⟨ bra (comp tc t₂ []) (comp tc t₃ []) ∷ c , val (comp-val (T.lam t₁ ρ₁)) ∷ s , comp-env ρ ⟩ ≳⟨⟩ crash ∼⟨⟩ ⟦if⟧ (T.lam t₁ ρ₁) t₂ t₃ ρ >>= k ∎ ⟦if⟧-correct (T.con true) t₂ t₃ {ρ} {c} {s} {k} {tc} s-ok c-ok = exec ⟨ bra (comp tc t₂ []) (comp tc t₃ []) ∷ c , val (comp-val (T.con true)) ∷ s , comp-env ρ ⟩ ≳⟨⟩ exec ⟨ comp tc t₂ [] ++ c , s , comp-env ρ ⟩ ≡⟨ By.by (comp-++ _ t₂) ⟩ exec ⟨ comp tc t₂ c , s , comp-env ρ ⟩ ≈⟨ ⟦⟧-correct t₂ _ s-ok c-ok ⟩∼ ⟦ t₂ ⟧ ρ >>= k ∼⟨⟩ ⟦if⟧ (T.con true) t₂ t₃ ρ >>= k ∎ ⟦if⟧-correct (T.con false) t₂ t₃ {ρ} {c} {s} {k} {tc} s-ok c-ok = exec ⟨ bra (comp tc t₂ []) (comp tc t₃ []) ∷ c , val (comp-val (T.con false)) ∷ s , comp-env ρ ⟩ ≳⟨⟩ exec ⟨ comp tc t₃ [] ++ c , s , comp-env ρ ⟩ ≡⟨ By.by (comp-++ _ t₃) ⟩ exec ⟨ comp tc t₃ c , s , comp-env ρ ⟩ ≈⟨ ⟦⟧-correct t₃ _ s-ok c-ok ⟩∼ ⟦ t₃ ⟧ ρ >>= k ∼⟨⟩ ⟦if⟧ (T.con false) t₂ t₃ ρ >>= k ∎ -- Compiler correctness. Note that the equality that is used here is -- syntactic. correct : (t : Tm 0) → exec ⟨ comp₀ t , [] , [] ⟩ ≈ ⟦ t ⟧ [] >>= λ v → return (comp-val v) correct t = exec ⟨ comp false t [] , [] , [] ⟩ ∼⟨⟩ exec ⟨ comp false t [] , [] , comp-env [] ⟩ ≈⟨ ⟦⟧-correct t [] unrestricted (λ v → laterˡ (return (comp-val v) ∎)) ⟩ (⟦ t ⟧ [] >>= λ v → return (comp-val v)) ∎
algebraic-stack_agda0000_doc_52
{-# OPTIONS --cubical-compatible #-} data Bool : Set where true : Bool false : Bool data ℕ : Set where zero : ℕ suc : (n : ℕ) → ℕ data Fin : ℕ → Set where zero : {n : ℕ} → Fin (suc n) suc : {n : ℕ} (i : Fin n) → Fin (suc n) infixr 5 _∷_ data Vec {a} (A : Set a) : ℕ → Set a where [] : Vec A zero _∷_ : ∀ {n} (x : A) (xs : Vec A n) → Vec A (suc n) infix 4 _[_]=_ data _[_]=_ {a} {A : Set a} : {n : ℕ} → Vec A n → Fin n → A → Set a where here : ∀ {n} {x} {xs : Vec A n} → x ∷ xs [ zero ]= x there : ∀ {n} {i} {x y} {xs : Vec A n} (xs[i]=x : xs [ i ]= x) → y ∷ xs [ suc i ]= x Subset : ℕ → Set Subset = Vec Bool infix 4 _∈_ _∈_ : ∀ {n} → Fin n → Subset n → Set x ∈ p = p [ x ]= true drop-there : ∀ {s n x} {p : Subset n} → suc x ∈ s ∷ p → x ∈ p drop-there (there x∈p) = x∈p _∘_ : ∀ {a b c} {A : Set a} {B : A → Set b} {C : {x : A} → B x → Set c} → (∀ {x} (y : B x) → C y) → (g : (x : A) → B x) → ((x : A) → C (g x)) f ∘ g = λ x → f (g x) data ⊥ : Set where infix 3 ¬_ ¬_ : ∀ {ℓ} → Set ℓ → Set ℓ ¬ P = P → ⊥ data Dec {p} (P : Set p) : Set p where yes : ( p : P) → Dec P no : (¬p : ¬ P) → Dec P infix 4 _∈?_ _∈?_ : ∀ {n} x (p : Subset n) → Dec (x ∈ p) zero ∈? true ∷ p = yes here zero ∈? false ∷ p = no λ() suc n ∈? s ∷ p with n ∈? p ... | yes n∈p = yes (there n∈p) ... | no n∉p = no (n∉p ∘ drop-there)
algebraic-stack_agda0000_doc_53
module STLC1.Kovacs.Soundness where open import STLC1.Kovacs.Convertibility public open import STLC1.Kovacs.PresheafRefinement public -------------------------------------------------------------------------------- infix 3 _≈_ _≈_ : ∀ {A Γ} → Γ ⊩ A → Γ ⊩ A → Set _≈_ {⎵} {Γ} M₁ M₂ = M₁ ≡ M₂ _≈_ {A ⇒ B} {Γ} f₁ f₂ = ∀ {Γ′} → (η : Γ′ ⊇ Γ) {a₁ a₂ : Γ′ ⊩ A} → (p : a₁ ≈ a₂) (u₁ : 𝒰 a₁) (u₂ : 𝒰 a₂) → f₁ η a₁ ≈ f₂ η a₂ _≈_ {A ⩕ B} {Γ} s₁ s₂ = proj₁ s₁ ≈ proj₁ s₂ × proj₂ s₁ ≈ proj₂ s₂ _≈_ {⫪} {Γ} s₁ s₂ = ⊤ -- (≈ᶜ ; ∙ ; _,_) infix 3 _≈⋆_ data _≈⋆_ : ∀ {Γ Ξ} → Γ ⊩⋆ Ξ → Γ ⊩⋆ Ξ → Set where ∅ : ∀ {Γ} → ∅ {Γ} ≈⋆ ∅ _,_ : ∀ {Γ Ξ A} → {ρ₁ ρ₂ : Γ ⊩⋆ Ξ} {M₁ M₂ : Γ ⊩ A} → (χ : ρ₁ ≈⋆ ρ₂) (p : M₁ ≈ M₂) → ρ₁ , M₁ ≈⋆ ρ₂ , M₂ -- (_≈⁻¹) _⁻¹≈ : ∀ {A Γ} → {a₁ a₂ : Γ ⊩ A} → a₁ ≈ a₂ → a₂ ≈ a₁ _⁻¹≈ {⎵} p = p ⁻¹ _⁻¹≈ {A ⇒ B} F = λ η p u₁ u₂ → F η (p ⁻¹≈) u₂ u₁ ⁻¹≈ _⁻¹≈ {A ⩕ B} p = proj₁ p ⁻¹≈ , proj₂ p ⁻¹≈ _⁻¹≈ {⫪} p = tt -- (_≈ᶜ⁻¹) _⁻¹≈⋆ : ∀ {Γ Ξ} → {ρ₁ ρ₂ : Γ ⊩⋆ Ξ} → ρ₁ ≈⋆ ρ₂ → ρ₂ ≈⋆ ρ₁ ∅ ⁻¹≈⋆ = ∅ (χ , p) ⁻¹≈⋆ = χ ⁻¹≈⋆ , p ⁻¹≈ -- (_≈◾_) _⦙≈_ : ∀ {A Γ} → {a₁ a₂ a₃ : Γ ⊩ A} → a₁ ≈ a₂ → a₂ ≈ a₃ → a₁ ≈ a₃ _⦙≈_ {⎵} p q = p ⦙ q _⦙≈_ {A ⇒ B} F G = λ η p u₁ u₂ → F η (p ⦙≈ (p ⁻¹≈)) u₁ u₁ ⦙≈ G η p u₁ u₂ _⦙≈_ {A ⩕ B} p q = proj₁ p ⦙≈ proj₁ q , proj₂ p ⦙≈ proj₂ q _⦙≈_ {⫪} p q = tt -- (_≈ᶜ◾_) _⦙≈⋆_ : ∀ {Γ Ξ} → {ρ₁ ρ₂ ρ₃ : Γ ⊩⋆ Ξ} → ρ₁ ≈⋆ ρ₂ → ρ₂ ≈⋆ ρ₃ → ρ₁ ≈⋆ ρ₃ ∅ ⦙≈⋆ ∅ = ∅ (χ₁ , p) ⦙≈⋆ (χ₂ , q) = χ₁ ⦙≈⋆ χ₂ , p ⦙≈ q instance per≈ : ∀ {Γ A} → PER (Γ ⊩ A) _≈_ per≈ = record { _⁻¹ = _⁻¹≈ ; _⦙_ = _⦙≈_ } instance per≈⋆ : ∀ {Γ Ξ} → PER (Γ ⊩⋆ Ξ) _≈⋆_ per≈⋆ = record { _⁻¹ = _⁻¹≈⋆ ; _⦙_ = _⦙≈⋆_ } -------------------------------------------------------------------------------- -- (≈ₑ) acc≈ : ∀ {A Γ Γ′} → {a₁ a₂ : Γ ⊩ A} → (η : Γ′ ⊇ Γ) → a₁ ≈ a₂ → acc η a₁ ≈ acc η a₂ acc≈ {⎵} η p = renⁿᶠ η & p acc≈ {A ⇒ B} η F = λ η′ → F (η ○ η′) acc≈ {A ⩕ B} η p = acc≈ η (proj₁ p) , acc≈ η (proj₂ p) acc≈ {⫪} η p = tt -- (≈ᶜₑ) _⬖≈_ : ∀ {Γ Γ′ Ξ} → {ρ₁ ρ₂ : Γ ⊩⋆ Ξ} → ρ₁ ≈⋆ ρ₂ → (η : Γ′ ⊇ Γ) → ρ₁ ⬖ η ≈⋆ ρ₂ ⬖ η ∅ ⬖≈ η = ∅ (χ , p) ⬖≈ η = χ ⬖≈ η , acc≈ η p -- (∈≈) get≈ : ∀ {Γ Ξ A} → {ρ₁ ρ₂ : Γ ⊩⋆ Ξ} → ρ₁ ≈⋆ ρ₂ → (i : Ξ ∋ A) → getᵥ ρ₁ i ≈ getᵥ ρ₂ i get≈ (χ , p) zero = p get≈ (χ , p) (suc i) = get≈ χ i -- (Tm≈) eval≈ : ∀ {Γ Ξ A} → {ρ₁ ρ₂ : Γ ⊩⋆ Ξ} → ρ₁ ≈⋆ ρ₂ → 𝒰⋆ ρ₁ → 𝒰⋆ ρ₂ → (M : Ξ ⊢ A) → eval ρ₁ M ≈ eval ρ₂ M eval≈ χ υ₁ υ₂ (𝓋 i) = get≈ χ i eval≈ χ υ₁ υ₂ (ƛ M) = λ η p u₁ u₂ → eval≈ (χ ⬖≈ η , p) (υ₁ ⬖𝒰 η , u₁) (υ₂ ⬖𝒰 η , u₂) M eval≈ χ υ₁ υ₂ (M ∙ N) = eval≈ χ υ₁ υ₂ M idₑ (eval≈ χ υ₁ υ₂ N) (eval𝒰 υ₁ N) (eval𝒰 υ₂ N) eval≈ χ υ₁ υ₂ (M , N) = eval≈ χ υ₁ υ₂ M , eval≈ χ υ₁ υ₂ N eval≈ χ υ₁ υ₂ (π₁ M) = proj₁ (eval≈ χ υ₁ υ₂ M) eval≈ χ υ₁ υ₂ (π₂ M) = proj₂ (eval≈ χ υ₁ υ₂ M) eval≈ χ υ₁ υ₂ τ = tt -------------------------------------------------------------------------------- -- (Subᴺᴾ) -- NOTE: _◆𝒰_ = eval𝒰⋆ _◆𝒰_ : ∀ {Γ Ξ Φ} → {ρ : Γ ⊩⋆ Ξ} → (σ : Ξ ⊢⋆ Φ) → 𝒰⋆ ρ → 𝒰⋆ (σ ◆ ρ) ∅ ◆𝒰 υ = ∅ (σ , M) ◆𝒰 υ = σ ◆𝒰 υ , eval𝒰 υ M -- (Subᴺ≈ᶜ) -- NOTE: _◆≈_ = eval≈⋆ _◆≈_ : ∀ {Γ Ξ Φ} → {ρ₁ ρ₂ : Γ ⊩⋆ Ξ} → (σ : Ξ ⊢⋆ Φ) → ρ₁ ≈⋆ ρ₂ → 𝒰⋆ ρ₁ → 𝒰⋆ ρ₂ → σ ◆ ρ₁ ≈⋆ σ ◆ ρ₂ (∅ ◆≈ χ) υ₁ υ₂ = ∅ ((σ , M) ◆≈ χ) υ₁ υ₂ = (σ ◆≈ χ) υ₁ υ₂ , eval≈ χ υ₁ υ₂ M -------------------------------------------------------------------------------- -- (Tmₛᴺ) eval◆ : ∀ {Γ Ξ Φ A} → {ρ : Γ ⊩⋆ Ξ} → ρ ≈⋆ ρ → 𝒰⋆ ρ → (σ : Ξ ⊢⋆ Φ) (M : Φ ⊢ A) → eval ρ (sub σ M) ≈ eval (σ ◆ ρ) M eval◆ {ρ = ρ} χ υ σ (𝓋 i) rewrite get◆ ρ σ i = eval≈ χ υ υ (getₛ σ i) eval◆ {ρ = ρ} χ υ σ (ƛ M) η {a₁} {a₂} p u₁ u₂ rewrite comp◆⬖ η υ σ = let υ′ = υ ⬖𝒰 η in eval◆ {ρ = ρ ⬖ η , a₁} ((χ ⬖≈ η) , (p ⦙ p ⁻¹)) (υ ⬖𝒰 η , u₁) (liftₛ σ) M ⦙ coe ((λ ρ′ → eval (ρ′ , a₁) M ≈ _) & ( comp◆⬗ (ρ ⬖ η , a₁) (wkₑ idₑ) σ ⦙ (σ ◆_) & lid⬗ (ρ ⬖ η) ) ⁻¹) (eval≈ ((σ ◆≈ (χ ⬖≈ η)) υ′ υ′ , p) (σ ◆𝒰 υ′ , u₁) (σ ◆𝒰 υ′ , u₂) M) eval◆ {ρ = ρ} χ υ σ (M ∙ N) = eval◆ χ υ σ M idₑ (eval◆ χ υ σ N) (eval𝒰 υ (sub σ N)) (eval𝒰 (σ ◆𝒰 υ) N) eval◆ {ρ = ρ} χ υ σ (M , N) = eval◆ χ υ σ M , eval◆ χ υ σ N eval◆ {ρ = ρ} χ υ σ (π₁ M) = proj₁ (eval◆ χ υ σ M) eval◆ {ρ = ρ} χ υ σ (π₂ M) = proj₂ (eval◆ χ υ σ M) eval◆ {ρ = ρ} χ υ σ τ = tt -------------------------------------------------------------------------------- -- (~≈) eval∼ : ∀ {Γ Ξ A} → {ρ₁ ρ₂ : Γ ⊩⋆ Ξ} → ρ₁ ≈⋆ ρ₂ → 𝒰⋆ ρ₁ → 𝒰⋆ ρ₂ → {M₁ M₂ : Ξ ⊢ A} → M₁ ∼ M₂ → eval ρ₁ M₁ ≈ eval ρ₂ M₂ eval∼ χ υ₁ υ₂ {M} refl∼ = eval≈ χ υ₁ υ₂ M eval∼ χ υ₁ υ₂ (p ⁻¹∼) = eval∼ (χ ⁻¹) υ₂ υ₁ p ⁻¹ eval∼ χ υ₁ υ₂ (p ⦙∼ q) = eval∼ (χ ⦙ χ ⁻¹) υ₁ υ₁ p ⦙ eval∼ χ υ₁ υ₂ q eval∼ χ υ₁ υ₂ (ƛ∼ p) = λ η q u₁ u₂ → eval∼ (χ ⬖≈ η , q) (υ₁ ⬖𝒰 η , u₁) (υ₂ ⬖𝒰 η , u₂) p eval∼ χ υ₁ υ₂ (_∙∼_ {N₁ = N₁} {N₂} p q) = eval∼ χ υ₁ υ₂ p idₑ (eval∼ χ υ₁ υ₂ q) (eval𝒰 υ₁ N₁) (eval𝒰 υ₂ N₂) eval∼ χ υ₁ υ₂ (p ,∼ q) = eval∼ χ υ₁ υ₂ p , eval∼ χ υ₁ υ₂ q eval∼ χ υ₁ υ₂ (π₁∼ p ) = proj₁ (eval∼ χ υ₁ υ₂ p) eval∼ χ υ₁ υ₂ (π₂∼ p ) = proj₂ (eval∼ χ υ₁ υ₂ p) eval∼ {ρ₁ = ρ₁} {ρ₂} χ υ₁ υ₂ (red⇒ M N) = coe ((λ ρ₁′ ρ₂′ → eval (ρ₁′ , eval ρ₁ N) M ≈ eval (ρ₂′ , eval ρ₂ N) M) & (lid⬖ ρ₁ ⁻¹) ⊗ (lid◆ ρ₂ ⁻¹)) (eval≈ (χ , eval≈ χ υ₁ υ₂ N) (υ₁ , eval𝒰 υ₁ N) (υ₂ , eval𝒰 υ₂ N) M) ⦙ eval◆ (χ ⁻¹ ⦙ χ) υ₂ (idₛ , N) M ⁻¹ eval∼ χ υ₁ υ₂ (red⩕₁ M N) = eval≈ χ υ₁ υ₂ M eval∼ χ υ₁ υ₂ (red⩕₂ M N) = eval≈ χ υ₁ υ₂ N eval∼ {ρ₂ = ρ₂} χ υ₁ υ₂ (exp⇒ M) η {a₂ = a₂} p u₁ u₂ rewrite eval⬗ (ρ₂ ⬖ η , a₂) (wkₑ idₑ) M ⁻¹ | lid⬗ (ρ₂ ⬖ η) | eval⬖ η υ₂ M | rid○ η = eval≈ χ υ₁ υ₂ M η p u₁ u₂ eval∼ χ υ₁ υ₂ (exp⩕ M) = eval≈ χ υ₁ υ₂ M eval∼ χ υ₁ υ₂ (exp⫪ M) = tt -------------------------------------------------------------------------------- mutual -- (q≈) reify≈ : ∀ {A Γ} → {a₁ a₂ : Γ ⊩ A} → a₁ ≈ a₂ → reify a₁ ≡ reify a₂ reify≈ {⎵} p = p reify≈ {A ⇒ B} F = ƛ & reify≈ (F (wkₑ {A = A} idₑ) (reflect≈ refl) (reflect𝒰 {A} 0) (reflect𝒰 {A} 0)) reify≈ {A ⩕ B} p = _,_ & reify≈ (proj₁ p) ⊗ reify≈ (proj₂ p) reify≈ {⫪} p = refl -- (u≈) reflect≈ : ∀ {A Γ} → {M₁ M₂ : Γ ⊢ⁿᵉ A} → M₁ ≡ M₂ → reflect M₁ ≈ reflect M₂ reflect≈ {⎵} p = ne & p reflect≈ {A ⇒ B} p = λ η q u₁ u₂ → reflect≈ (_∙_ & (renⁿᵉ η & p) ⊗ reify≈ q) reflect≈ {A ⩕ B} p = reflect≈ (π₁ & p) , reflect≈ (π₂ & p) reflect≈ {⫪} p = tt -- (uᶜ≈) id≈ : ∀ {Γ} → idᵥ {Γ} ≈⋆ idᵥ id≈ {∅} = ∅ id≈ {Γ , A} = id≈ ⬖≈ wkₑ idₑ , reflect≈ refl sound : ∀ {Γ A} → {M₁ M₂ : Γ ⊢ A} → M₁ ∼ M₂ → nf M₁ ≡ nf M₂ sound p = reify≈ (eval∼ id≈ id𝒰 id𝒰 p) --------------------------------------------------------------------------------
algebraic-stack_agda0000_doc_54
------------------------------------------------------------------------ -- The Agda standard library -- -- Decision procedures for finite sets and subsets of finite sets -- -- This module is DEPRECATED. Please use the Data.Fin.Properties -- and Data.Fin.Subset.Properties directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Fin.Dec where open import Data.Fin.Properties public using (decFinSubset; any?; all?; ¬∀⟶∃¬-smallest; ¬∀⟶∃¬) open import Data.Fin.Subset.Properties public using (_∈?_; _⊆?_; nonempty?; anySubset?) renaming (Lift? to decLift)
algebraic-stack_agda0000_doc_55
module ial where open import ial-datatypes public open import logic public open import thms public open import termination public open import error public open import io public