id
stringlengths
27
136
text
stringlengths
4
1.05M
algebraic-stack_agda0000_doc_13652
------------------------------------------------------------------------ -- Parsers containing non-terminals, and grammars using such parsers ------------------------------------------------------------------------ module StructurallyRecursiveDescentParsing.Grammar where open import Data.Bool open import Data.Empty open import Data.Product open import Relation.Binary.PropositionalEquality open import Codata.Musical.Notation open import Level open import StructurallyRecursiveDescentParsing.Index import StructurallyRecursiveDescentParsing.Simplified as Simplified open Simplified hiding (Parser; module Parser; ⟦_⟧) infixl 10 _!>>=_ _?>>=_ infixl 5 _∣_ -- The parsers are parameterised on a type of nonterminals. data Parser (NT : NonTerminalType) (Tok : Set) : NonTerminalType where return : ∀ {R} (x : R) → Parser NT Tok (true ◇ ε) R fail : ∀ {R} → Parser NT Tok (false ◇ ε) R token : Parser NT Tok (false ◇ ε) Tok _∣_ : ∀ {e₁ e₂ c₁ c₂ R} (p₁ : Parser NT Tok (e₁ ◇ c₁ ) R) (p₂ : Parser NT Tok ( e₂ ◇ c₂) R) → Parser NT Tok (e₁ ∨ e₂ ◇ c₁ ∪ c₂) R _?>>=_ : ∀ {e₂ c₁ c₂ R₁ R₂} (p₁ : Parser NT Tok (true ◇ c₁ ) R₁) (p₂ : R₁ → Parser NT Tok (e₂ ◇ c₂) R₂) → Parser NT Tok (e₂ ◇ c₁ ∪ c₂) R₂ _!>>=_ : ∀ {c₁ R₁ R₂} {i₂ : R₁ → Index} (p₁ : Parser NT Tok (false ◇ c₁) R₁) (p₂ : (x : R₁) → ∞ (Parser NT Tok (i₂ x) R₂)) → Parser NT Tok (false ◇ c₁) R₂ ! : ∀ {e c R} (nt : NT (e ◇ c) R) → Parser NT Tok (e ◇ c ∪ ε) R -- Grammars. Grammar : NonTerminalType → Set → Set1 Grammar NT Tok = ∀ {i R} → NT i R → Parser NT Tok i R -- An empty non-terminal type. EmptyNT : NonTerminalType EmptyNT _ _ = Lift _ ⊥ -- An empty grammar. emptyGrammar : ∀ {Tok} → Grammar EmptyNT Tok emptyGrammar (lift ()) -- The semantics of grammar-based parsers is defined in terms of their -- translation into "plain" parsers. The translation instantiates all -- non-terminals corecursively. ⟦_⟧ : ∀ {Tok NT e c R} → Parser NT Tok (e ◇ c) R → Grammar NT Tok → Simplified.Parser Tok e R ⟦ return x ⟧ g = return x ⟦ fail ⟧ g = fail ⟦ token ⟧ g = token ⟦ p₁ ∣ p₂ ⟧ g = ⟦ p₁ ⟧ g ∣ ⟦ p₂ ⟧ g ⟦ p₁ ?>>= p₂ ⟧ g = ⟦ p₁ ⟧ g ?>>= λ x → ⟦ p₂ x ⟧ g ⟦ p₁ !>>= p₂ ⟧ g = ⟦ p₁ ⟧ g !>>= λ x → ♯ ⟦ ♭ (p₂ x) ⟧ g ⟦ ! nt ⟧ g = ⟦ g nt ⟧ g -- Note that some "plain" parsers cannot be directly rewritten using -- the parser type in this module (although there may be /equivalent/ -- parsers): private only-plain : Simplified.Parser Bool false Bool only-plain = return true ?>>= λ x → if x then token else token ∣ token -- The following code does not type-check. -- doesnt-work : Parser EmptyNT Bool (false ◇ _) Bool -- doesnt-work = return true ?>>= λ x → -- if x then token else token ∣ token -- A map function which can be useful when combining grammars. mapNT : ∀ {NT₁ NT₂ Tok i R} → (∀ {i R} → NT₁ i R → NT₂ i R) → Parser NT₁ Tok i R → Parser NT₂ Tok i R mapNT f (return x) = return x mapNT f fail = fail mapNT f token = token mapNT f (p₁ ∣ p₂) = mapNT f p₁ ∣ mapNT f p₂ mapNT f (p₁ ?>>= p₂) = mapNT f p₁ ?>>= λ x → mapNT f (p₂ x) mapNT f (p₁ !>>= p₂) = mapNT f p₁ !>>= λ x → ♯ mapNT f (♭ (p₂ x)) mapNT f (! nt) = ! (f nt)
algebraic-stack_agda0000_doc_13653
{-# OPTIONS --universe-polymorphism #-} module Categories.Square where open import Level open import Function renaming (id to idᶠ; _∘_ to _©_) open import Categories.Support.PropositionalEquality open import Categories.Category import Categories.Morphisms as Mor open import Relation.Binary hiding (_⇒_) module GlueSquares {o ℓ e} (C : Category o ℓ e) where private module C = Category C open C open Mor C module Pulls {X Y Z} {a : Y ⇒ Z} {b : X ⇒ Y} {c : X ⇒ Z} (ab≡c : a ∘ b ≡ c) where .pullʳ : ∀ {W} {f : Z ⇒ W} → (f ∘ a) ∘ b ≡ f ∘ c pullʳ {f = f} = begin (f ∘ a) ∘ b ↓⟨ assoc ⟩ f ∘ (a ∘ b) ↓⟨ ∘-resp-≡ʳ ab≡c ⟩ f ∘ c ∎ where open HomReasoning .pullˡ : ∀ {W} {f : W ⇒ X} → a ∘ (b ∘ f) ≡ c ∘ f pullˡ {f = f} = begin a ∘ (b ∘ f) ↑⟨ assoc ⟩ (a ∘ b) ∘ f ↓⟨ ∘-resp-≡ˡ ab≡c ⟩ c ∘ f ∎ where open HomReasoning open Pulls public module Pushes {X Y Z} {a : Y ⇒ Z} {b : X ⇒ Y} {c : X ⇒ Z} (c≡ab : c ≡ a ∘ b) where .pushʳ : ∀ {W} {f : Z ⇒ W} → f ∘ c ≡ (f ∘ a) ∘ b pushʳ {f = f} = begin f ∘ c ↓⟨ ∘-resp-≡ʳ c≡ab ⟩ f ∘ (a ∘ b) ↑⟨ assoc ⟩ (f ∘ a) ∘ b ∎ where open HomReasoning .pushˡ : ∀ {W} {f : W ⇒ X} → c ∘ f ≡ a ∘ (b ∘ f) pushˡ {f = f} = begin c ∘ f ↓⟨ ∘-resp-≡ˡ c≡ab ⟩ (a ∘ b) ∘ f ↓⟨ assoc ⟩ a ∘ (b ∘ f) ∎ where open HomReasoning open Pushes public module IntroElim {X} {a : X ⇒ X} (a≡id : a ≡ id) where .elimʳ : ∀ {W} {f : X ⇒ W} → (f ∘ a) ≡ f elimʳ {f = f} = begin f ∘ a ↓⟨ ∘-resp-≡ʳ a≡id ⟩ f ∘ id ↓⟨ identityʳ ⟩ f ∎ where open HomReasoning .introʳ : ∀ {W} {f : X ⇒ W} → f ≡ f ∘ a introʳ = Equiv.sym elimʳ .elimˡ : ∀ {W} {f : W ⇒ X} → (a ∘ f) ≡ f elimˡ {f = f} = begin a ∘ f ↓⟨ ∘-resp-≡ˡ a≡id ⟩ id ∘ f ↓⟨ identityˡ ⟩ f ∎ where open HomReasoning .introˡ : ∀ {W} {f : W ⇒ X} → f ≡ a ∘ f introˡ = Equiv.sym elimˡ open IntroElim public module Extends {X Y Z W} {f : X ⇒ Y} {g : X ⇒ Z} {h : Y ⇒ W} {i : Z ⇒ W} (s : CommutativeSquare f g h i) where .extendˡ : ∀ {A} {a : W ⇒ A} → CommutativeSquare f g (a ∘ h) (a ∘ i) extendˡ {a = a} = begin (a ∘ h) ∘ f ↓⟨ pullʳ s ⟩ a ∘ i ∘ g ↑⟨ assoc ⟩ (a ∘ i) ∘ g ∎ where open HomReasoning .extendʳ : ∀ {A} {a : A ⇒ X} → CommutativeSquare (f ∘ a) (g ∘ a) h i extendʳ {a = a} = begin h ∘ (f ∘ a) ↓⟨ pullˡ s ⟩ (i ∘ g) ∘ a ↓⟨ assoc ⟩ i ∘ (g ∘ a) ∎ where open HomReasoning .extend² : ∀ {A B} {a : W ⇒ A} {b : B ⇒ X} → CommutativeSquare (f ∘ b) (g ∘ b) (a ∘ h) (a ∘ i) extend² {a = a} {b} = begin (a ∘ h) ∘ (f ∘ b) ↓⟨ pullʳ extendʳ ⟩ a ∘ (i ∘ (g ∘ b)) ↑⟨ assoc ⟩ (a ∘ i) ∘ (g ∘ b) ∎ where open HomReasoning open Extends public -- essentially composition in the arrow category .glue : {X Y Y′ Z Z′ W : Obj} {a : Z ⇒ W} {a′ : Y′ ⇒ Z′} {b : Y ⇒ Z} {b′ : X ⇒ Y′} {c : X ⇒ Y} {c′ : Y′ ⇒ Z} {c″ : Z′ ⇒ W} → CommutativeSquare c′ a′ a c″ → CommutativeSquare c b′ b c′ → CommutativeSquare c (a′ ∘ b′) (a ∘ b) c″ glue {a = a} {a′} {b} {b′} {c} {c′} {c″} sq-a sq-b = begin (a ∘ b) ∘ c ↓⟨ pullʳ sq-b ⟩ a ∘ (c′ ∘ b′) ↓⟨ pullˡ sq-a ⟩ (c″ ∘ a′) ∘ b′ ↓⟨ assoc ⟩ c″ ∘ (a′ ∘ b′) ∎ where open HomReasoning .glue◃◽ : {X Y Y′ Z W : Obj} {a : Z ⇒ W} {b : Y ⇒ Z} {b′ : X ⇒ Y′} {c : X ⇒ Y} {c′ : Y′ ⇒ Z} {c″ : Y′ ⇒ W} → a ∘ c′ ≡ c″ → CommutativeSquare c b′ b c′ → CommutativeSquare c b′ (a ∘ b) c″ glue◃◽ {a = a} {b} {b′} {c} {c′} {c″} tri-a sq-b = begin (a ∘ b) ∘ c ↓⟨ pullʳ sq-b ⟩ a ∘ (c′ ∘ b′) ↓⟨ pullˡ tri-a ⟩ c″ ∘ b′ ∎ where open HomReasoning -- essentially composition in the over category .glueTrianglesʳ : ∀ {X X′ X″ Y} {a : X ⇒ Y} {b : X′ ⇒ X} {a′ : X′ ⇒ Y} {b′ : X″ ⇒ X′} {a″ : X″ ⇒ Y} → a ∘ b ≡ a′ → a′ ∘ b′ ≡ a″ → a ∘ (b ∘ b′) ≡ a″ glueTrianglesʳ {a = a} {b} {a′} {b′} {a″} a∘b≡a′ a′∘b′≡a″ = begin a ∘ (b ∘ b′) ↓⟨ pullˡ a∘b≡a′ ⟩ a′ ∘ b′ ↓⟨ a′∘b′≡a″ ⟩ a″ ∎ where open HomReasoning -- essentially composition in the under category .glueTrianglesˡ : ∀ {X Y Y′ Y″} {b : X ⇒ Y} {a : Y ⇒ Y′} {b′ : X ⇒ Y′} {a′ : Y′ ⇒ Y″} {b″ : X ⇒ Y″} → a′ ∘ b′ ≡ b″ → a ∘ b ≡ b′ → (a′ ∘ a) ∘ b ≡ b″ glueTrianglesˡ {b = b} {a} {b′} {a′} {b″} a′∘b′≡b″ a∘b≡b′ = begin (a′ ∘ a) ∘ b ↓⟨ pullʳ a∘b≡b′ ⟩ a′ ∘ b′ ↓⟨ a′∘b′≡b″ ⟩ b″ ∎ where open HomReasoning module Cancellers {Y Y′ : Obj} {h : Y′ ⇒ Y} {i : Y ⇒ Y′} (inv : h ∘ i ≡ id) where .cancelRight : ∀ {Z} {f : Y ⇒ Z} → (f ∘ h) ∘ i ≡ f cancelRight {f = f} = begin (f ∘ h) ∘ i ↓⟨ pullʳ inv ⟩ f ∘ id ↓⟨ identityʳ ⟩ f ∎ where open HomReasoning .cancelLeft : ∀ {X} {f : X ⇒ Y} → h ∘ (i ∘ f) ≡ f cancelLeft {f = f} = begin h ∘ (i ∘ f) ↓⟨ pullˡ inv ⟩ id ∘ f ↓⟨ identityˡ ⟩ f ∎ where open HomReasoning .cancelInner : ∀ {X Z} {f : Y ⇒ Z} {g : X ⇒ Y} → (f ∘ h) ∘ (i ∘ g) ≡ f ∘ g cancelInner {f = f} {g} = begin (f ∘ h) ∘ (i ∘ g) ↓⟨ pullˡ cancelRight ⟩ f ∘ g ∎ where open HomReasoning open Cancellers public module Switch {X Y} (i : X ≅ Y) where open _≅_ i .switch-fgˡ : ∀ {W} {h : W ⇒ X} {k : W ⇒ Y} → (f ∘ h ≡ k) → (h ≡ g ∘ k) switch-fgˡ {h = h} {k} pf = begin h ↑⟨ cancelLeft isoˡ ⟩ g ∘ (f ∘ h) ↓⟨ ∘-resp-≡ʳ pf ⟩ g ∘ k ∎ where open HomReasoning .switch-gfˡ : ∀ {W} {h : W ⇒ Y} {k : W ⇒ X} → (g ∘ h ≡ k) → (h ≡ f ∘ k) switch-gfˡ {h = h} {k} pf = begin h ↑⟨ cancelLeft isoʳ ⟩ f ∘ (g ∘ h) ↓⟨ ∘-resp-≡ʳ pf ⟩ f ∘ k ∎ where open HomReasoning .switch-fgʳ : ∀ {W} {h : Y ⇒ W} {k : X ⇒ W} → (h ∘ f ≡ k) → (h ≡ k ∘ g) switch-fgʳ {h = h} {k} pf = begin h ↑⟨ cancelRight isoʳ ⟩ (h ∘ f) ∘ g ↓⟨ ∘-resp-≡ˡ pf ⟩ k ∘ g ∎ where open HomReasoning .switch-gfʳ : ∀ {W} {h : X ⇒ W} {k : Y ⇒ W} → (h ∘ g ≡ k) → (h ≡ k ∘ f) switch-gfʳ {h = h} {k} pf = begin h ↑⟨ cancelRight isoˡ ⟩ (h ∘ g) ∘ f ↓⟨ ∘-resp-≡ˡ pf ⟩ k ∘ f ∎ where open HomReasoning open Switch public module Yon-Eda {o ℓ e} (C : Category o ℓ e) where private module C = Category C open C open Equiv record Yon (X Y : Obj) : Set (o ⊔ ℓ ⊔ e) where field arr : X ⇒ Y fun : ∀ {W} (f : W ⇒ X) → (W ⇒ Y) .ok : ∀ {W} (f : W ⇒ X) → fun f ≡ arr ∘ f norm : X ⇒ Y norm = fun id .norm≡arr : norm ≡ arr norm≡arr = trans (ok id) identityʳ record _≡′_ {X Y : Obj} (f g : Yon X Y) : Set (o ⊔ ℓ ⊔ e) where constructor yeq field arr-≡ : Yon.arr f ≡ Yon.arr g open _≡′_ public using (arr-≡) module _ {X Y} where .Yon-refl : Reflexive (_≡′_ {X} {Y}) Yon-refl = yeq refl .Yon-sym : Symmetric (_≡′_ {X} {Y}) Yon-sym = yeq © sym © arr-≡ .Yon-trans : Transitive (_≡′_ {X} {Y}) Yon-trans eq eq′ = yeq (trans (arr-≡ eq) (arr-≡ eq′)) Yon-id : ∀ {X} → Yon X X Yon-id = record { arr = id ; fun = idᶠ ; ok = λ _ → sym identityˡ } Yon-inject : ∀ {X Y} → (X ⇒ Y) → Yon X Y Yon-inject f = record { arr = f; fun = _∘_ f; ok = λ _ → refl } Yon-compose : ∀ {X Y Z} → (Yon Y Z) → (Yon X Y) → (Yon X Z) Yon-compose g f = record { arr = g.fun f.arr ; fun = g.fun © f.fun ; ok = λ h → trans (g.ok (f.fun h)) (trans (∘-resp-≡ʳ (f.ok h)) (trans (sym assoc) (sym (∘-resp-≡ˡ (g.ok f.arr))))) } where module g = Yon g module f = Yon f .Yon-assoc : ∀ {X Y Z W} (f : Yon Z W) (g : Yon Y Z) (h : Yon X Y) → Yon-compose f (Yon-compose g h) ≣ Yon-compose (Yon-compose f g) h Yon-assoc f g h = ≣-refl .Yon-identityˡ : ∀ {X Y} (f : Yon X Y) → Yon-compose Yon-id f ≣ f Yon-identityˡ f = ≣-refl .Yon-identityʳ : ∀ {X Y} (f : Yon X Y) → Yon-compose f Yon-id ≡′ f Yon-identityʳ f = yeq (Yon.norm≡arr f) .Yon-compose-resp-≡′ : ∀ {X Y Z} {f f′ : Yon Y Z} {g g′ : Yon X Y} → f ≡′ f′ → g ≡′ g′ → Yon-compose f g ≡′ Yon-compose f′ g′ Yon-compose-resp-≡′ {f = f} {f′} {g} {g′} f≡′f′ g≡′g′ = yeq (trans (Yon.ok f (Yon.arr g)) (trans (∘-resp-≡ (arr-≡ f≡′f′) (arr-≡ g≡′g′)) (sym (Yon.ok f′ (Yon.arr g′))))) record Eda (X Y : Obj) : Set (o ⊔ ℓ ⊔ e) where field yon : Yon X Y fun : ∀ {Z} (f : Yon Y Z) → Yon X Z .ok : ∀ {Z} (f : Yon Y Z) → fun f ≡′ Yon-compose f yon norm : Yon X Y norm = fun Yon-id open Yon yon public using (arr) Eda-id : ∀ {X} → Eda X X Eda-id = record { yon = Yon-id ; fun = idᶠ ; ok = yeq © sym © arr-≡ © Yon-identityʳ } Eda-inject : ∀ {X Y} → Yon X Y → Eda X Y Eda-inject f = record { yon = f; fun = flip Yon-compose f; ok = λ _ → yeq refl } Eda-compose : ∀ {X Y Z} → (Eda Y Z) → (Eda X Y) → (Eda X Z) Eda-compose {X} {Y} {Z} g f = record { yon = f.fun g.yon ; fun = f.fun © g.fun ; ok = λ {W} h → Yon-trans {X} {W} {f.fun (g.fun h)} (f.ok (g.fun h)) (Yon-trans (Yon-compose-resp-≡′ (g.ok h) (Yon-refl {x = f.yon})) (Yon-sym (Yon-compose-resp-≡′ (Yon-refl {x = h}) (f.ok g.yon)))) } where module g = Eda g module f = Eda f .Eda-assoc : ∀ {X Y Z W} (f : Eda Z W) (g : Eda Y Z) (h : Eda X Y) → Eda-compose f (Eda-compose g h) ≣ Eda-compose (Eda-compose f g) h Eda-assoc f g h = ≣-refl -- .Eda-identityˡ : ∀ {X Y} (f : Eda X Y) → Eda-compose Eda-id f ≣ f -- Eda-identityˡ f = {!!} .Eda-identityʳ : ∀ {X Y} (f : Eda X Y) → Eda-compose f Eda-id ≣ f Eda-identityʳ f = ≣-refl record NormReasoning {o ℓ e} (C : Category o ℓ e) (o′ ℓ′ : _) : Set (suc o′ ⊔ o ⊔ ℓ ⊔ e ⊔ suc ℓ′) where private module C = Category C field U : Set o′ T : U -> C.Obj _#⇒_ : U -> U -> Set ℓ′ eval : ∀ {A B} -> A #⇒ B -> T A C.⇒ T B norm : ∀ {A B} -> A #⇒ B -> T A C.⇒ T B .norm≡eval : ∀ {A B} (f : A #⇒ B) -> norm f C.≡ eval f open C.Equiv open C infix 4 _IsRelatedTo_ infix 1 begin_ infixr 2 _≈⟨_⟩_ _↓⟨_⟩_ _↑⟨_⟩_ _↓≡⟨_⟩_ _↑≡⟨_⟩_ _↕_ infix 3 _∎ data _IsRelatedTo_ {X Y} (f g : _#⇒_ X Y) : Set e where relTo : (f∼g : norm f ≡ norm g) → f IsRelatedTo g .begin_ : ∀ {X Y} {f g : _#⇒_ X Y} → f IsRelatedTo g → eval f ≡ eval g begin_ {f = f} {g} (relTo f∼g) = trans (sym (norm≡eval f)) (trans f∼g (norm≡eval g)) ._↓⟨_⟩_ : ∀ {X Y} (f : _#⇒_ X Y) {g h} → (norm f ≡ norm g) → g IsRelatedTo h → f IsRelatedTo h _ ↓⟨ f∼g ⟩ relTo g∼h = relTo (trans f∼g g∼h) ._↑⟨_⟩_ : ∀ {X Y} (f : _#⇒_ X Y) {g h} → (norm g ≡ norm f) → g IsRelatedTo h → f IsRelatedTo h _ ↑⟨ g∼f ⟩ relTo g∼h = relTo (trans (sym g∼f) g∼h) -- the syntax of the ancients, for compatibility ._≈⟨_⟩_ : ∀ {X Y} (f : _#⇒_ X Y) {g h} → (norm f ≡ norm g) → g IsRelatedTo h → f IsRelatedTo h _ ≈⟨ f∼g ⟩ relTo g∼h = relTo (trans f∼g g∼h) ._↓≡⟨_⟩_ : ∀ {X Y} (f : _#⇒_ X Y) {g h} → eval f ≡ eval g → g IsRelatedTo h → f IsRelatedTo h _↓≡⟨_⟩_ f {g} f∼g (relTo g∼h) = relTo (trans (norm≡eval f) (trans f∼g (trans (sym (norm≡eval g)) g∼h))) ._↑≡⟨_⟩_ : ∀ {X Y} (f : _#⇒_ X Y) {g h} → eval g ≡ eval f → g IsRelatedTo h → f IsRelatedTo h _↑≡⟨_⟩_ f {g} g∼f (relTo g∼h) = relTo (trans (norm≡eval f) (trans (sym g∼f) (trans (sym (norm≡eval g)) g∼h))) ._↕_ : ∀ {X Y} (f : _#⇒_ X Y) {h} → f IsRelatedTo h → f IsRelatedTo h _ ↕ f∼h = f∼h ._∎ : ∀ {X Y} (f : _#⇒_ X Y) → f IsRelatedTo f _∎ _ = relTo refl .by_ : ∀ {X Y} {f g h : X ⇒ Y} -> ((h ≡ h) -> f ≡ g) -> f ≡ g by eq = eq refl .computation : ∀ {X Y} (f g : X #⇒ Y) -> norm f ≡ norm g → eval f ≡ eval g computation f g eq = begin f ↓⟨ eq ⟩ g ∎ module AUReasoning {o ℓ e} (C : Category o ℓ e) where private module C = Category C open C open Equiv {- infix 4 _IsRelatedTo_ infix 2 _∎ infixr 2 _≈⟨_⟩_ infixr 2 _↓⟨_⟩_ infixr 2 _↑⟨_⟩_ infixr 2 _↓≡⟨_⟩_ infixr 2 _↑≡⟨_⟩_ infixr 2 _↕_ infix 1 begin_ -} infixr 8 _∙_ open Yon-Eda C public data Climb : Rel Obj (o ⊔ ℓ) where ID : ∀ {X} → Climb X X leaf : ∀ {X Y} → (X ⇒ Y) → Climb X Y _branch_ : ∀ {X Y Z} (l : Climb Y Z) (r : Climb X Y) → Climb X Z interp : ∀ {p} (P : Rel Obj p) (f-id : ∀ {X} → P X X) (f-leaf : ∀ {X Y} → X ⇒ Y → P X Y) (f-branch : ∀ {X Y Z} → P Y Z → P X Y → P X Z) → ∀ {X Y} → Climb X Y → P X Y interp P f-id f-leaf f-branch ID = f-id interp P f-id f-leaf f-branch (leaf y) = f-leaf y interp P f-id f-leaf f-branch (l branch r) = f-branch (interp P f-id f-leaf f-branch l) (interp P f-id f-leaf f-branch r) eval : ∀ {X Y} → Climb X Y → X ⇒ Y eval = interp _⇒_ id idᶠ _∘_ yeval : ∀ {X Y} → Climb X Y → Yon X Y yeval = interp Yon Yon-id Yon-inject Yon-compose .yarr : ∀ {X Y} → (t : Climb X Y) → Yon.arr (yeval t) ≡ eval t yarr ID = refl yarr (leaf y) = refl yarr (t branch t1) = trans (Yon.ok (yeval t) (Yon.arr (yeval t1))) (∘-resp-≡ (yarr t) (yarr t1)) eeval : ∀ {X Y} → Climb X Y → Eda X Y eeval = interp Eda Eda-id (Eda-inject © Yon-inject) Eda-compose .eyon : ∀ {X Y} → (t : Climb X Y) → Eda.yon (eeval t) ≡′ yeval t eyon ID = Yon-refl eyon (leaf y) = Yon-refl eyon (t branch t1) = Yon-trans (Eda.ok (eeval t1) (Eda.yon (eeval t))) (Yon-compose-resp-≡′ (eyon t) (eyon t1)) .earr : ∀ {X Y} → (t : Climb X Y) → Eda.arr (eeval t) ≡ eval t earr t = trans (arr-≡ (eyon t)) (yarr t) yyeval : ∀ {X Y} → (t : Climb X Y) → (X ⇒ Y) yyeval = Eda.arr © eeval record ClimbBuilder (X Y : Obj) {t} (T : Set t) : Set (o ⊔ ℓ ⊔ t) where field build : T → Climb X Y instance leafBuilder : ∀ {X Y} → ClimbBuilder X Y (X ⇒ Y) leafBuilder = record { build = leaf } idBuilder : ∀ {X Y} → ClimbBuilder X Y (Climb X Y) idBuilder = record { build = idᶠ } _∙_ : ∀ {X Y Z} {s} {S : Set s} {{Sb : ClimbBuilder Y Z S}} (f : S) {t} {T : Set t} {{Tb : ClimbBuilder X Y T}} (g : T) → Climb X Z _∙_ {{Sb}} f {{Tb}} g = ClimbBuilder.build Sb f branch ClimbBuilder.build Tb g aureasoning : NormReasoning C o (ℓ ⊔ o) aureasoning = record { U = Obj ; T = λ A → A ; _#⇒_ = Climb ; eval = eval ; norm = yyeval ; norm≡eval = earr } open NormReasoning aureasoning public hiding (eval) {- data _IsRelatedTo_ {X Y} (f g : Climb X Y) : Set e where relTo : (f∼g : yyeval f ≡ yyeval g) → f IsRelatedTo g .begin_ : ∀ {X Y} {f g : Climb X Y} → f IsRelatedTo g → eval f ≡ eval g begin_ {f = f} {g} (relTo f∼g) = trans (sym (earr f)) (trans f∼g (earr g)) ._↓⟨_⟩_ : ∀ {X Y} (f : Climb X Y) {g h} → (yyeval f ≡ yyeval g) → g IsRelatedTo h → f IsRelatedTo h _ ↓⟨ f∼g ⟩ relTo g∼h = relTo (trans f∼g g∼h) ._↑⟨_⟩_ : ∀ {X Y} (f : Climb X Y) {g h} → (yyeval g ≡ yyeval f) → g IsRelatedTo h → f IsRelatedTo h _ ↑⟨ g∼f ⟩ relTo g∼h = relTo (trans (sym g∼f) g∼h) -- the syntax of the ancients, for compatibility ._≈⟨_⟩_ : ∀ {X Y} (f : Climb X Y) {g h} → (yyeval f ≡ yyeval g) → g IsRelatedTo h → f IsRelatedTo h _ ≈⟨ f∼g ⟩ relTo g∼h = relTo (trans f∼g g∼h) ._↓≡⟨_⟩_ : ∀ {X Y} (f : Climb X Y) {g h} → eval f ≡ eval g → g IsRelatedTo h → f IsRelatedTo h _↓≡⟨_⟩_ f {g} f∼g (relTo g∼h) = relTo (trans (earr f) (trans f∼g (trans (sym (earr g)) g∼h))) ._↑≡⟨_⟩_ : ∀ {X Y} (f : Climb X Y) {g h} → eval g ≡ eval f → g IsRelatedTo h → f IsRelatedTo h _↑≡⟨_⟩_ f {g} g∼f (relTo g∼h) = relTo (trans (earr f) (trans (sym g∼f) (trans (sym (earr g)) g∼h))) {- -- XXX i want this to work whenever the Edas are equal -- but that probably -- requires Climb to be indexed by yyeval! oh, for cheap ornamentation. ._↕_ : ∀ {X Y} (f : Climb X Y) {h} → f IsRelatedTo h → f IsRelatedTo h _ ↕ f∼h = f∼h -} ._∎ : ∀ {X Y} (f : Climb X Y) → f IsRelatedTo f _∎ _ = relTo refl -}
algebraic-stack_agda0000_doc_13654
-- Andreas, 2016-06-09 issue during refactoring for #1963 -- Shrunk this issue with projection-like functions from std-lib -- {-# OPTIONS --show-implicit #-} -- {-# OPTIONS -v tc.proj.like:10 #-} open import Common.Level open import Common.Nat renaming ( Nat to ℕ ) data ⊥ : Set where record ⊤ : Set where constructor tt postulate anything : ∀{A : Set} → A data _≤_ : (m n : ℕ) → Set where z≤n : ∀ {n} → zero ≤ n s≤s : ∀ {m n} (m≤n : m ≤ n) → suc m ≤ suc n ≤-refl : ∀{n} → n ≤ n ≤-refl {zero} = z≤n ≤-refl {suc n} = s≤s ≤-refl ≤-trans : ∀{k l m} → k ≤ l → l ≤ m → k ≤ m ≤-trans z≤n q = z≤n ≤-trans (s≤s p) (s≤s q) = s≤s (≤-trans p q) n≤m+n : ∀ m n → n ≤ (m + n) n≤m+n zero zero = z≤n n≤m+n zero (suc n) = s≤s (n≤m+n zero n) n≤m+n (suc m) zero = z≤n n≤m+n (suc m) (suc n) = s≤s anything record Preord c ℓ₁ : Set (lsuc (c ⊔ ℓ₁)) where infix 4 _∼_ field Carrier : Set c _∼_ : (x y : Carrier) → Set ℓ₁ -- The relation. refl : ∀{x} → x ∼ x trans : ∀{x y z} → x ∼ y → y ∼ z → x ∼ z Npreord : Preord _ _ Npreord = record { Carrier = ℕ ; _∼_ = _≤_ ; refl = ≤-refl; trans = ≤-trans } module Pre {p₁ p₂} (P : Preord p₁ p₂) where open Preord P infix 4 _IsRelatedTo_ infix 3 _∎ infixr 2 _≤⟨_⟩_ infix 1 begin_ data _IsRelatedTo_ (x y : Carrier) : Set p₂ where relTo : (x≤y : x ∼ y) → x IsRelatedTo y begin_ : ∀ {x y} → x IsRelatedTo y → x ∼ y begin relTo x≤y = x≤y _≤⟨_⟩_ : ∀ x {y z} → x ∼ y → y IsRelatedTo z → x IsRelatedTo z _ ≤⟨ x≤y ⟩ relTo y≤z = relTo (trans x≤y y≤z) _∎ : ∀ x → x IsRelatedTo x _∎ _ = relTo refl -- begin_ : {p₁ p₂ : Level} (P : Preord p₁ p₂) -- {x y : Preord.Carrier P} → -- x IsRelatedTo y → (P Preord.∼ x) y -- is projection like in argument 5 for type ProjectionLike1963.Pre._IsRelatedTo_ -- _∎ : {p₁ p₂ : Level} (P : Preord p₁ p₂) (x : Preord.Carrier P) → -- x IsRelatedTo x -- is projection like in argument 2 for type ProjectionLike1963.Preord open Pre Npreord _+-mono_ : ∀{m₁ m₂ n₁ n₂} → m₁ ≤ m₂ → n₁ ≤ n₂ → (m₁ + n₁) ≤ (m₂ + n₂) _+-mono_ {zero} {m₂} {n₁} {n₂} z≤n n₁≤n₂ = begin n₁ ≤⟨ n₁≤n₂ ⟩ n₂ ≤⟨ n≤m+n m₂ n₂ ⟩ m₂ + n₂ ∎ s≤s m₁≤m₂ +-mono n₁≤n₂ = s≤s (m₁≤m₂ +-mono n₁≤n₂) ISS : ∀ {n m} (p : n ≤ m) → Set ISS z≤n = ⊥ ISS (s≤s p) = ⊤ test : ISS ((z≤n {0}) +-mono (s≤s (z≤n {0}))) test = tt -- Goal display: -- C-u C-c C-, ISS (z≤n +-mono s≤s z≤n) -- C-c C-, ISS (begin 1 ≤⟨ s≤s z≤n ⟩ 1 ≤⟨ s≤s z≤n ⟩ 1 ∎) -- C-u C-u C-c C-, ISS (λ {y} → Pre.begin _)
algebraic-stack_agda0000_doc_13655
open import Level using (_⊔_; suc; Lift; lift) open import Function using (_$_; _∘_; _⤖_) open import Relation.Nullary using (¬_) open import Relation.Nullary.Decidable using (False) open import Relation.Binary using (Rel; Decidable; Setoid; DecSetoid; IsEquivalence; IsDecEquivalence) open import Data.Empty using (⊥) open import Data.Product using (∃-syntax; _,_) open import Data.Sum using (_⊎_) module AKS.Algebra.Structures {c ℓ} (C : Set c) (_≈_ : Rel C ℓ) where open import Data.Unit using (⊤; tt) open import Agda.Builtin.FromNat using (Number) open import AKS.Nat using (ℕ; _<_; _≟_) open import AKS.Fin using (Fin) open import Algebra.Core using (Op₂; Op₁) open import Algebra.Structures _≈_ using (IsCommutativeRing; IsAbelianGroup) infix 4 _≉_ _≉_ : Rel C ℓ x ≉ y = x ≈ y → ⊥ record IsNonZeroCommutativeRing (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) : Set (c ⊔ ℓ) where field isCommutativeRing : IsCommutativeRing _+_ _*_ -_ 0# 1# 0#≉1# : 0# ≉ 1# open IsCommutativeRing isCommutativeRing public open import Relation.Binary.Reasoning.Setoid setoid open import Algebra.Properties.Ring (record { isRing = isRing }) using (-‿distribˡ-*; -‿involutive) 1#≉0# : 1# ≉ 0# 1#≉0# = 0#≉1# ∘ sym 0#≉-1# : 0# ≉ - 1# 0#≉-1# 0#≈-1# = 0#≉1# $ begin 0# ≈⟨ sym (zeroʳ 0#) ⟩ 0# * 0# ≈⟨ *-cong 0#≈-1# 0#≈-1# ⟩ (- 1#) * (- 1#) ≈⟨ sym (-‿distribˡ-* 1# (- 1#)) ⟩ - (1# * (- 1#)) ≈⟨ -‿cong (*-identityˡ (- 1#)) ⟩ - (- 1#) ≈⟨ -‿involutive 1# ⟩ 1# ∎ -1#≉0# : - 1# ≉ 0# -1#≉0# = 0#≉-1# ∘ sym C/0 : Set (c ⊔ ℓ) C/0 = ∃[ x ] (x ≉ 0#) 1#-nonzero : C/0 1#-nonzero = 1# , 1#≉0# -1#-nonzero : C/0 -1#-nonzero = - 1# , -1#≉0# fromNat : ℕ → C fromNat ℕ.zero = 0# fromNat (ℕ.suc ℕ.zero) = 1# fromNat (ℕ.suc (ℕ.suc n)) = 1# + fromNat (ℕ.suc n) instance C-number : Number C C-number = record { Constraint = λ _ → Lift c ⊤ ; fromNat = λ n → fromNat n } record IsIntegralDomain (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) : Set (c ⊔ ℓ) where field isNonZeroCommutativeRing : IsNonZeroCommutativeRing _+_ _*_ -_ 0# 1# *-cancelˡ : ∀ x {y z} → x ≉ 0# → (x * y) ≈ (x * z) → y ≈ z open IsNonZeroCommutativeRing isNonZeroCommutativeRing public open import Relation.Binary.Reasoning.Setoid setoid *-cancelʳ : ∀ x {y z} → x ≉ 0# → (y * x) ≈ (z * x) → y ≈ z *-cancelʳ x {y} {z} x≉0 y*x≈z*x = *-cancelˡ x x≉0 $ begin (x * y) ≈⟨ *-comm x y ⟩ (y * x) ≈⟨ y*x≈z*x ⟩ (z * x) ≈⟨ *-comm z x ⟩ (x * z) ∎ *≉0 : ∀ {c₁ c₂} → c₁ ≉ 0# → c₂ ≉ 0# → c₁ * c₂ ≉ 0# *≉0 {c₁} {c₂} c₁≉0 c₂≉0 c₁*c₂≈0 = c₂≉0 $ *-cancelˡ c₁ c₁≉0 $ begin (c₁ * c₂) ≈⟨ c₁*c₂≈0 ⟩ (0#) ≈⟨ sym (zeroʳ c₁) ⟩ (c₁ * 0#) ∎ infixl 7 _*-nonzero_ _*-nonzero_ : C/0 → C/0 → C/0 (c₁ , c₁≉0) *-nonzero (c₂ , c₂≉0) = c₁ * c₂ , *≉0 c₁≉0 c₂≉0 module Divisibility (_*_ : Op₂ C) where infix 4 _∣_ record _∣_ (d : C) (a : C) : Set (c ⊔ ℓ) where constructor divides field quotient : C equality : a ≈ (quotient * d) infix 4 _∤_ _∤_ : C → C → Set (c ⊔ ℓ) d ∤ a = ¬ (d ∣ a) record IsGCD (gcd : Op₂ C) : Set (c ⊔ ℓ) where field gcd[a,b]∣a : ∀ a b → gcd a b ∣ a gcd[a,b]∣b : ∀ a b → gcd a b ∣ b gcd-greatest : ∀ {c a b} → c ∣ a → c ∣ b → c ∣ gcd a b record IsGCDDomain (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) (gcd : Op₂ C) : Set (c ⊔ ℓ) where open Divisibility _*_ public field isIntegralDomain : IsIntegralDomain _+_ _*_ -_ 0# 1# gcd-isGCD : IsGCD gcd open IsIntegralDomain isIntegralDomain public record IsUniqueFactorizationDomain (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) (gcd : Op₂ C) : Set (c ⊔ ℓ) where field isGCDDomain : IsGCDDomain _+_ _*_ -_ 0# 1# gcd -- TODO define factorization open IsGCDDomain isGCDDomain public module Modulus (0# : C) (∣_∣ : ∀ n {n≉0 : n ≉ 0#} → ℕ) (_mod_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C) where data Remainder (n : C) (m : C) {m≉0 : m ≉ 0#} : Set (c ⊔ ℓ) where 0≈ : (r≈0 : (n mod m) {m≉0} ≈ 0#) → Remainder n m 0≉ : (r≉0 : (n mod m) {m≉0} ≉ 0#) → ∣ n mod m ∣ {r≉0} < ∣ m ∣ {m≉0} → Remainder n m module _ (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) (∣_∣ : ∀ n {n≉0 : n ≉ 0#} → ℕ) (_div_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C) (_mod_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C) (gcd : Op₂ C) where record IsEuclideanDomain : Set (c ⊔ ℓ) where open Modulus 0# ∣_∣ _mod_ public field isUniqueFactorizationDomain : IsUniqueFactorizationDomain _+_ _*_ -_ 0# 1# gcd division : ∀ n m {m≉0 : m ≉ 0#} → n ≈ ((m * (n div m) {m≉0}) + (n mod m) {m≉0}) modulus : ∀ n m {m≉0 : m ≉ 0#} → Remainder n m {m≉0} div-cong : ∀ {x₁ x₂} {y₁ y₂} → x₁ ≈ x₂ → y₁ ≈ y₂ → ∀ {y₁≉0 y₂≉0} → (x₁ div y₁) {y₁≉0} ≈ (x₂ div y₂) {y₂≉0} mod-cong : ∀ {x₁ x₂} {y₁ y₂} → x₁ ≈ x₂ → y₁ ≈ y₂ → ∀ {y₁≉0 y₂≉0} → (x₁ mod y₁) {y₁≉0} ≈ (x₂ mod y₂) {y₂≉0} open IsUniqueFactorizationDomain isUniqueFactorizationDomain public record IsField (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) (_/_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C) (gcd : Op₂ C) : Set (c ⊔ ℓ) where field isEuclideanDomain : IsEuclideanDomain _+_ _*_ -_ 0# 1# (λ _ → 0) _/_ (λ _ _ → 0#) gcd open IsEuclideanDomain isEuclideanDomain public renaming (div-cong to /-cong) open import Relation.Binary.Reasoning.Setoid setoid m*[n/m]≈n : ∀ n m {m≉0 : m ≉ 0#} → (m * (n / m) {m≉0}) ≈ n m*[n/m]≈n n m {m≉0} = begin (m * (n / m) {m≉0}) ≈⟨ sym (+-identityʳ (m * (n / m) {m≉0})) ⟩ ((m * (n / m) {m≉0}) + 0#) ≈⟨ sym (division n m) ⟩ n ∎ [n/m]*m≈n : ∀ n m {m≉0 : m ≉ 0#} → ((n / m) {m≉0} * m) ≈ n [n/m]*m≈n n m {m≉0} = begin ((n / m) * m) ≈⟨ *-comm (n / m) m ⟩ (m * (n / m)) ≈⟨ m*[n/m]≈n n m ⟩ n ∎ /≉0 : ∀ {c₁ c₂} → c₁ ≉ 0# → (c₂≉0 : c₂ ≉ 0#) → (c₁ / c₂) {c₂≉0} ≉ 0# /≉0 {c₁} {c₂} c₁≉0 c₂≉0 c₁/c₂≈0 = 0#≉1# $ *-cancelˡ c₂ c₂≉0 $ begin c₂ * 0# ≈⟨ *-congˡ (sym (zeroˡ ((c₂ / c₁) {c₁≉0}))) ⟩ c₂ * (0# * (c₂ / c₁)) ≈⟨ *-congˡ (*-congʳ (sym (c₁/c₂≈0))) ⟩ c₂ * ((c₁ / c₂) * (c₂ / c₁)) ≈⟨ sym (*-assoc c₂ (c₁ / c₂) (c₂ / c₁)) ⟩ (c₂ * (c₁ / c₂)) * (c₂ / c₁) ≈⟨ *-congʳ (m*[n/m]≈n c₁ c₂) ⟩ c₁ * (c₂ / c₁) ≈⟨ m*[n/m]≈n c₂ c₁ ⟩ c₂ ≈⟨ sym (*-identityʳ c₂) ⟩ c₂ * 1# ∎ infixl 7 _/-nonzero_ _/-nonzero_ : C/0 → C/0 → C/0 (c₁ , c₁≉0) /-nonzero (c₂ , c₂≉0) = (c₁ / c₂) {c₂≉0} , /≉0 c₁≉0 c₂≉0 infix 8 _⁻¹ _⁻¹ : ∀ x {x≉0 : x ≉ 0#} → C _⁻¹ x {x≉0} = (1# / x) {x≉0} ⁻¹-inverseʳ : ∀ x {x≉0 : x ≉ 0#} → (x * (x ⁻¹) {x≉0}) ≈ 1# ⁻¹-inverseʳ = m*[n/m]≈n 1# ⁻¹-inverseˡ : ∀ x {x≉0 : x ≉ 0#} → ((x ⁻¹) {x≉0} * x) ≈ 1# ⁻¹-inverseˡ = [n/m]*m≈n 1# x⁻¹≉0 : ∀ x {x≉0 : x ≉ 0#} → (x ⁻¹) {x≉0} ≉ 0# x⁻¹≉0 x {x≉0} = /≉0 1#≉0# x≉0 -- 0#≉1# $ begin -- 0# ≈⟨ sym (zeroʳ x) ⟩ -- x * 0# ≈⟨ *-congˡ (sym x⁻¹≈0) ⟩ -- x * (x ⁻¹) {x≉0} ≈⟨ ⁻¹-inverseʳ x ⟩ -- 1# ∎ ⁻¹-cong : ∀ {x y} {x≉0 : x ≉ 0#} {y≉0 : y ≉ 0#} → x ≈ y → (x ⁻¹) {x≉0} ≈ (y ⁻¹) {y≉0} ⁻¹-cong {x} {y} {x≉0} {y≉0} x≈y = *-cancelˡ x x≉0 $ begin (x * (x ⁻¹)) ≈⟨ ⁻¹-inverseʳ x ⟩ 1# ≈⟨ sym (⁻¹-inverseʳ y {y≉0}) ⟩ (y * (y ⁻¹)) ≈⟨ *-congʳ (sym x≈y) ⟩ (x * (y ⁻¹)) ∎ record IsDecField (_≈?_ : Decidable _≈_) (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) (_/_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C) (gcd : Op₂ C) : Set (c ⊔ ℓ) where field isField : IsField _+_ _*_ -_ 0# 1# _/_ gcd open IsField isField public isDecEquivalence : IsDecEquivalence _≈_ isDecEquivalence = record { isEquivalence = isEquivalence ; _≟_ = _≈?_ } record IsFiniteField (_≈?_ : Decidable _≈_) (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) (_/_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C) (gcd : Op₂ C) (cardinality : ℕ) : Set (suc c ⊔ ℓ) where field isDecField : IsDecField _≈?_ _+_ _*_ -_ 0# 1# _/_ gcd C↦Fin[cardinality] : C ⤖ Fin cardinality open IsDecField isDecField public
algebraic-stack_agda0000_doc_13656
open import Agda.Builtin.Nat open import Agda.Builtin.Equality record Eq (A : Set) : Set₁ where field _≈_ : A → A → Set open Eq {{...}} public record Setoid : Set₁ where field ∣_∣ : Set {{eq}} : Eq ∣_∣ open Setoid public -- instance -- EqNat : Eq Nat -- _≈_ {{EqNat}} = _≡_ NatSetoid : Setoid ∣ NatSetoid ∣ = Nat -- Should give: No instance of type Eq Nat
algebraic-stack_agda0000_doc_13657
open import Data.Bool module GUIgeneric.GUIExample where open import GUIgeneric.Prelude renaming (inj₁ to secondBtn; inj₂ to firstBtn; WxColor to Color) hiding (addButton; _>>_) open import GUIgeneric.GUIDefinitions renaming (add to add'; add' to add) open import GUIgeneric.GUI open import GUIgeneric.GUIExampleLib renaming (addButton to addButton') open import Data.Product addButton : String → Frame → Frame addButton str fr = addButton' str fr optimized addTxtBox : String → Frame → Frame addTxtBox str fr = addTxtBox' str fr optimized oneBtnGUI : Frame oneBtnGUI = addButton "OK" create-frame twoBtnGUI : Frame twoBtnGUI = addButton "Cancel" oneBtnGUI -- Attributes -- Cols = ℕ Margin = ℕ HSpace = ℕ VSpace = ℕ oneColumnLayout : Cols × Margin × HSpace × VSpace oneColumnLayout = (1 , 10 , 2 , 2) black : Color black = rgb 0 0 0 propOneBtn : properties oneBtnGUI propOneBtn = black , oneColumnLayout propTwoBtn : properties twoBtnGUI propTwoBtn = black , black , oneColumnLayout putStr' : {A : Set} → String → (f : IO GuiLev1Interface ∞ A) → IO GuiLev1Interface ∞ A putStr' s f = do (putStrLn s) (λ _ → f) syntax putStr' s f = putStrLn s >> f keepGUI : {j : Size} → HandlerObject j twoBtnGUI → IO GuiLev1Interface ∞ (Σ-syntax (returnType twoBtnGUI) (λ r → IOObjectˢ GuiLev1Interface handlerInterface j (nextStateFrame twoBtnGUI r))) keepGUI = λ obj → return (noChange , obj) changeGUI : ∀ {j} (g : CompEls frame) {g'} (prop : properties g) obj → IO GuiLev1Interface ∞ (Σ (returnType g') (\r -> IOObjectˢ GuiLev1Interface handlerInterface j (nextStateFrame g' r))) changeGUI = λ g prop obj → return (changedGUI g prop , obj) mutual objTwoBtnGUI' : ∀ i → HandlerObject i twoBtnGUI objTwoBtnGUI' i .method {j} (secondBtn bt) = putStrLn "Cancel Fired! NO GUI Change." >> keepGUI (objTwoBtnGUI' j) objTwoBtnGUI' i .method {j} (firstBtn bt) = putStrLn "OK Fired! Redefining GUI." >> changeGUI oneBtnGUI propOneBtn (objOneBtnGUI' j) objOneBtnGUI' : ∀ i → HandlerObject i oneBtnGUI objOneBtnGUI' i .method {j} bt = putStrLn "OK Fired! Redefining GUI." >> changeGUI twoBtnGUI propTwoBtn (objTwoBtnGUI' j) obj2Btn : ∀ {i} → HandlerObject i twoBtnGUI obj2Btn .method (firstBtn bt) = putStrLn "OK fired! Redefining GUI." >> changeGUI oneBtnGUI propOneBtn obj1Btn obj2Btn .method (secondBtn bt) = putStrLn "Cancel fired! No GUI change." >> keepGUI obj2Btn obj1Btn : ∀ {i} → HandlerObject i oneBtnGUI obj1Btn .method bt = putStrLn "OK fired! Redefining GUI." >> changeGUI twoBtnGUI propTwoBtn obj2Btn main : NativeIO Unit main = compileProgram twoBtnGUI propTwoBtn (obj2Btn {∞})
algebraic-stack_agda0000_doc_13658
-- {-# OPTIONS -v tc.conv.level:60 #-} -- {-# OPTIONS -v tc.conv:30 #-} {- Agda development version: Wed Oct 30 16:30:06 GMT 2013 The last line of code triggers the following error, but replacing '_' with 'a' typechecks just fine. Bug.agda:32,8-11 tt != a of type ⊤ when checking that the expression s _ has type P tt → P a Changing 'Set (q a)' to 'Set' in line 26 suppresses the error. -} -- Andreas, 2013-10-31 Fixed by retrying sort comparison after -- successful type comparison (which might have solve the missing level metas). module Issue930 where open import Common.Level data ⊤ : Set where tt : ⊤ postulate q : ⊤ → Level P : (a : ⊤) → Set (q a) s : (a : ⊤) → P tt → P a a : ⊤ g : (P tt → P a) → ⊤ v : ⊤ v = g (s _) {- coerce term v = s ?1 from type t1 = P tt → P ?1 to type t2 = P tt → P a equalSort Set (q tt ⊔ q ?1) == Set (q a ⊔ q tt) compareAtom q tt == q a : Level compareTerm tt == a : ⊤ sort comparison failed -- THIS ERROR IS CAUGHT, BUT RETHROWN AT THE END compareTerm P tt → P ?1 =< P tt → P a : Set (q tt ⊔ q ?1) compare function types t1 = P tt → P ?1 t2 = P tt → P a equalSort Set (q ?1) == Set (q a) compareTerm ?1 == a : ⊤ attempting shortcut ?1 := a solving _13 := a -}
algebraic-stack_agda0000_doc_13659
module x01-842Naturals where -- This is a comment. {- This is a multi-line comment -} -- Definition of datatype representing natural numbers. ♭ data ℕ : Set where zero : ℕ suc : ℕ → ℕ -- A couple of definitions using this datatype. one : ℕ one = suc zero two : ℕ two = suc (suc zero) -- I could have also said two = suc one. -- PLFA exercise: write out seven. -- Pragma to use decimal notation as shorthand. {-# BUILTIN NATURAL ℕ #-} -- Some useful imports from the standard library: import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎) -- Addition on naturals. _+_ : ℕ → ℕ → ℕ zero + n = n suc m + n = suc {!m + n!} -- Agda normalization; proof of equality. _ : 2 + 3 ≡ 5 _ = refl -- Equational reasoning. _ : 2 + 3 ≡ 5 _ = begin 2 + 3 ≡⟨⟩ -- is shorthand for (suc (suc zero)) + (suc (suc (suc zero))) ≡⟨⟩ -- many steps condensed 5 ∎ -- PLFA shows longhand and shorthand are interchangeable. -- PLFA exercise: write out the reduction for 3+4 equationally. -- Multiplication. _*_ : ℕ → ℕ → ℕ m * n = {!!} _ = begin 2 * 3 ≡⟨⟩ -- many steps condensed 6 ∎ -- PLFA exercise: write out 3*4. -- 842 exercise: Exponentiation (1 point) -- Define exponentiation (m raised to the power n). _^_ : ℕ → ℕ → ℕ m ^ n = {!!} -- One test for exponentiation (you should write others). _ : 2 ^ 3 ≡ 8 _ = refl -- Monus (subtraction for naturals, bottoms out at zero). _∸_ : ℕ → ℕ → ℕ m ∸ n = {!!} _ = begin 3 ∸ 2 ≡⟨⟩ -- many steps condensed 1 ∎ _ = begin 2 ∸ 3 ≡⟨⟩ -- many steps condensed 0 ∎ -- PLFA exercise: write out 5 ∸ 3 and 3 ∸ 5. infixl 6 _+_ _∸_ infixl 7 _*_ -- These pragmas will register our operations, if we want, -- so that they work with decimal notation. -- {-# BUILTIN NATPLUS _+_ #-} -- {-# BUILTIN NATTIMES _*_ #-} -- {-# BUILTIN NATMINUS _∸_ #-} -- Binary representation. -- Modified from PLFA exercise (thanks to David Darais). data Bin-ℕ : Set where bits : Bin-ℕ _x0 : Bin-ℕ → Bin-ℕ _x1 : Bin-ℕ → Bin-ℕ -- Our representation of zero is different from PLFA. -- We use the empty sequence of bits (more consistent). bin-zero : Bin-ℕ bin-zero = bits bin-one : Bin-ℕ bin-one = bits x1 -- 1 in binary bin-two : Bin-ℕ bin-two = bits x1 x0 -- 10 in binary -- 842 exercise: Increment (1 point) -- Define increment (add one). inc : Bin-ℕ → Bin-ℕ inc m = {!!} -- An example/test of increment (you should create others). _ : inc (bits x1 x0 x1 x1) ≡ bits x1 x1 x0 x0 _ = refl -- 842 exercise: To/From (2 points) -- Define 'tob' and 'fromb' operations -- to convert between unary (ℕ) and binary (Bin-ℕ) notation. -- Hint: avoid addition and multiplication, -- and instead use the provided dbl (double) function. -- This will make later proofs easier. -- I've put 'b' on the end of the operations to -- avoid a name clash in a later file. -- It also makes the direction clear when using them. dbl : ℕ → ℕ dbl zero = zero dbl (suc m) = suc (suc (dbl m)) tob : ℕ → Bin-ℕ tob m = {!!} fromb : Bin-ℕ → ℕ fromb n = {!!} -- A couple of examples/tests (you should create others). _ : tob 6 ≡ bits x1 x1 x0 _ = refl _ : fromb (bits x1 x1 x0) ≡ 6 _ = refl -- 842 exercise: BinAdd (2 points) -- Write the addition function for binary notation. -- Do NOT use 'to' and 'from'. Work with Bin-ℕ as if ℕ did not exist. -- Hint: use recursion on both m and n. _bin-+_ : Bin-ℕ → Bin-ℕ → Bin-ℕ m bin-+ n = {!!} -- Tests can use to/from, or write out binary constants as below. -- Again: write more tests! _ : (bits x1 x0) bin-+ (bits x1 x1) ≡ (bits x1 x0 x1) _ = refl -- That's it for now, but we will return to binary notation later. -- Many definitions from above are also in the standard library. -- open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _^_; _∸_) -- Unicode used in this chapter: {- ℕ U+2115 DOUBLE-STRUCK CAPITAL N (\bN) → U+2192 RIGHTWARDS ARROW (\to, \r, \->) ∸ U+2238 DOT MINUS (\.-) ≡ U+2261 IDENTICAL TO (\==) ⟨ U+27E8 MATHEMATICAL LEFT ANGLE BRACKET (\<) ⟩ U+27E9 MATHEMATICAL RIGHT ANGLE BRACKET (\>) ∎ U+220E END OF PROOF (\qed) -}
algebraic-stack_agda0000_doc_13660
-- Andreas, 2018-05-28, issue #3095, fail on attempt to make hidden parent variable visible data Nat : Set where suc : {n : Nat} → Nat data IsSuc : Nat → Set where isSuc : ∀{n} → IsSuc (suc {n}) test : ∀{m} → IsSuc m → Set test p = aux p where aux : ∀{n} → IsSuc n → Set aux isSuc = {!.m!} -- Split on .m here -- Context: -- p : IsSuc .m -- .m : Nat -- .n : Nat -- Expected error: -- Cannot split on module parameter .m -- when checking that the expression ? has type Set
algebraic-stack_agda0000_doc_13661
{-# OPTIONS --without-K --safe #-} module Categories.Minus2-Category.Properties where -- All -2-Categories are equivalent to One open import Level open import Data.Product using (Σ; _,_; proj₁; proj₂) open import Data.Unit using (⊤; tt) open import Categories.Minus2-Category open import Categories.Category import Categories.Morphism as M open import Categories.Category.Monoidal open import Categories.Category.Instance.One open import Categories.Category.Equivalence hiding (refl) open import Categories.NaturalTransformation using (ntHelper) private variable o ℓ e : Level shrink-them-all : (X : -2-Category {o} {ℓ} {e}) → StrongEquivalence (-2-Category.cat X) (One {o} {ℓ} {e}) shrink-them-all X = record { F = record { F₀ = λ _ → lift tt ; F₁ = λ _ → lift tt } ; G = record { F₀ = λ _ → proj₁ Obj-Contr ; F₁ = λ _ → M._≅_.from (proj₂ Obj-Contr (proj₁ Obj-Contr)) ; identity = Hom-Conn ; homomorphism = Hom-Conn ; F-resp-≈ = λ _ → Hom-Conn } ; weak-inverse = record { F∘G≈id = _ ; G∘F≈id = record { F⇒G = ntHelper (record { η = λ y → M._≅_.from (proj₂ Obj-Contr y) ; commute = λ _ → Hom-Conn }) ; F⇐G = ntHelper (record { η = λ y → M._≅_.to (proj₂ Obj-Contr y) ; commute = λ _ → Hom-Conn }) ; iso = λ Z → record { isoˡ = M._≅_.isoˡ (proj₂ Obj-Contr Z) ; isoʳ = M._≅_.isoʳ (proj₂ Obj-Contr Z) } } } } where open -2-Category X open Category cat
algebraic-stack_agda0000_doc_13662
module gc where open import lib -- we will model addresses in memory as just natural numbers Address : Set Address = ℕ -- a value of type (Bounded n) is an address a together with a proof that a is less than n Bounded : Address → Set Bounded n = Σ Address (λ a → a < n ≡ tt) -- a (Cell a) models an addressable cell of memory data Cell(bound : Address) : Set where Scalar : ℕ → Cell bound -- this represents a cell with no outgoing pointers, just a natural number value Pointers : ∀ (p1 p2 : Bounded bound) → Cell bound -- this cell has exactly two outgoing pointers {- a (well-formed) memory is a vector of m cells, where all pointers in those cells are bounded by n. This is just a way of expressing that the memory does not have any pointers heading off to some illegal locations (outside the allocated memory). -} Memory : Address → Set Memory m = 𝕍 (Cell m) m -- return a list of natural numbers from n-1 down to 0. [5 points] nats : ∀(n : ℕ) → 𝕍 ℕ n nats zero = [] nats (suc n) = n :: (nats n) -- when the definition of nats is correct, the highlighting will disappear from refl below: test-nats : nats 3 ≡ 2 :: 1 :: 0 :: [] test-nats = refl {- (outgoingPointers m mem b) returns the list of outgoing pointers at the location given by b in the Memory m. This is either empty (for Scalar) or a list of length two (for Pointers). Hint: there is already a function in vector.agda in the IAL that can find the Cell for you from mem and b. [10 points] -} outgoingPointers : ∀ (m : Address) → Memory m → Bounded m → 𝕃 (Bounded m) outgoingPointers n mem (j , k) with (nth𝕍 j k mem) ... | Scalar c = [] ... | Pointers x y = x :: y :: [] {- (doMark u unmarked m b) is supposed to return (just v) if the address given by b is a member of unmarked, and v is the result of removing that address from unmarked. If the address given by b is not in unmarked, then return none. This function simulates marking a cell by removing it (if it is there) from the vector of unmarked cells. Because the length of the vector decreases, we can recurse in markh on the result if we need to. [17 points] -} doMark : ∀(u : ℕ)(unmarked : 𝕍 Address (suc u)) → (m : Address) → Bounded m → maybe (𝕍 Address u) doMark u ( x :: unmarked ) m ( a , b ) with ( a =ℕ x ) ... | tt = just unmarked doMark 0 ( x :: [] ) m ( a , b ) | ff = nothing doMark ( suc u ) ( x :: x1 :: unmarked ) m ( a , b ) | ff with ( doMark u ( x1 :: unmarked ) m ( a , b ) ) ... | nothing = nothing ... | just unmarked1 = just ( x :: unmarked1 ) {- given a list of unmarked addresses and a Memory m, and a worklist of addresses, return the list of all unmarked addresses that are not reachable in the memory from an address in the worklist. So this is basically implementing mark and sweep gc, where addresses are considered marked if they do not appear in unmarked, and you use outgoingPointers to update the worklist when it is time to recurse. [18 points] -} markh : ∀(u : ℕ)(unmarked : 𝕍 Address u) → (m : Address) → Memory m → (worklist : 𝕃 (Bounded m)) → 𝕃 Address markh u [] m x worklist = [] markh u unmarked m x [] = 𝕍-to-𝕃 unmarked markh ( suc u ) unmarked m x ( x1 :: worklist ) with ( doMark u unmarked m x1 ) ... | nothing = markh ( suc u ) unmarked m x worklist ... | just something = markh u something m x ( worklist ++ ( outgoingPointers m x x1 ) ) {- the final mark-and-sweep function, which just takes in a memory and list of roots, and returns the addresses not reachable in that memory from one of the roots. -} mark : ∀(m : Address) → Memory m → (roots : 𝕃 (Bounded m)) → 𝕃 Address mark m memory roots = markh m (nats m) m memory roots ---------------------------------------------------------------------- -- a test case: test-memory : Memory 3 test-memory = Pointers (0 , refl) (2 , refl) :: Pointers (0 , refl) (2 , refl) :: Pointers (0 , refl) (0 , refl) :: [] test-roots : 𝕃 (Bounded 3) test-roots = [ (0 , refl) ] -- the addresses not reachable from address 0 by following pointers in test-memory test-garbage : 𝕃 Address test-garbage = mark 3 test-memory test-roots -- if the implementation above is correct, highlighting on refl below will disappear test-check : test-garbage ≡ 1 :: [] test-check = refl
algebraic-stack_agda0000_doc_13663
{- In this file we apply the cubical machinery to Martin Hötzel-Escardó's structure identity principle: https://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html#sns -} {-# OPTIONS --cubical --safe #-} module Cubical.Foundations.SIP where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Univalence renaming (ua-pathToEquiv to ua-pathToEquiv') open import Cubical.Foundations.Transport open import Cubical.Foundations.Path open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.Properties renaming (cong≃ to _⋆_) open import Cubical.Foundations.HAEquiv open import Cubical.Data.Prod.Base hiding (_×_) renaming (_×Σ_ to _×_) open import Cubical.Foundations.Structure public private variable ℓ₁ ℓ₂ ℓ₃ ℓ₄ ℓ₅ : Level S : Type ℓ₁ → Type ℓ₂ -- For technical reasons we reprove ua-pathToEquiv using the -- particular proof constructed by iso→HAEquiv. The reason is that we -- want to later be able to extract -- -- eq : ua-au (ua e) ≡ cong ua (au-ua e) -- uaHAEquiv : (A B : Type ℓ₁) → HAEquiv (A ≃ B) (A ≡ B) uaHAEquiv A B = iso→HAEquiv (iso ua pathToEquiv ua-pathToEquiv' pathToEquiv-ua) open isHAEquiv -- We now extract the particular proof constructed from iso→HAEquiv -- for reasons explained above. ua-pathToEquiv : {A B : Type ℓ₁} (e : A ≡ B) → ua (pathToEquiv e) ≡ e ua-pathToEquiv e = uaHAEquiv _ _ .snd .ret e -- Note that for any equivalence (f , e) : X ≃ Y the type ι (X , s) (Y , t) (f , e) need not to be -- a proposition. Indeed this type should correspond to the ways s and t can be identified -- as S-structures. This we call a standard notion of structure or SNS. -- We will use a different definition, but the two definitions are interchangeable. SNS-≡ : (S : Type ℓ₁ → Type ℓ₂) (ι : StrIso S ℓ₃) → Type (ℓ-max (ℓ-max (ℓ-suc ℓ₁) ℓ₂) ℓ₃) SNS-≡ {ℓ₁} S ι = ∀ {X : Type ℓ₁} (s t : S X) → ι (X , s) (X , t) (idEquiv X) ≃ (s ≡ t) -- We introduce the notation for structure preserving equivalences a -- bit differently, but this definition doesn't actually change from -- Escardó's notes. _≃[_]_ : (A : TypeWithStr ℓ₁ S) (ι : StrIso S ℓ₂) (B : TypeWithStr ℓ₁ S) → Type (ℓ-max ℓ₁ ℓ₂) A ≃[ ι ] B = Σ[ e ∈ typ A ≃ typ B ] (ι A B e) -- The following PathP version of SNS-≡ is a bit easier to work with -- for the proof of the SIP SNS-PathP : (S : Type ℓ₁ → Type ℓ₂) (ι : StrIso S ℓ₃) → Type (ℓ-max (ℓ-max (ℓ-suc ℓ₁) ℓ₂) ℓ₃) SNS-PathP {ℓ₁} S ι = {A B : TypeWithStr ℓ₁ S} (e : typ A ≃ typ B) → ι A B e ≃ PathP (λ i → S (ua e i)) (str A) (str B) -- A quick sanity-check that our definition is interchangeable with -- Escardó's. The direction SNS-≡→SNS-PathP corresponds more or less -- to a dependent EquivJ formulation of Escardó's homomorphism-lemma. SNS-PathP→SNS-≡ : (S : Type ℓ₁ → Type ℓ₂) (ι : StrIso S ℓ₃) → SNS-PathP S ι → SNS-≡ S ι SNS-PathP→SNS-≡ S ι θ {X = X} s t = ι (X , s) (X , t) (idEquiv X) ≃⟨ θ (idEquiv X) ⟩ PathP (λ i → S (ua (idEquiv X) i)) s t ≃⟨ φ ⟩ s ≡ t ■ where φ = transportEquiv (λ j → PathP (λ i → S (uaIdEquiv {A = X} j i)) s t) SNS-≡→SNS-PathP : (ι : StrIso S ℓ₃) → SNS-≡ S ι → SNS-PathP S ι SNS-≡→SNS-PathP {S = S} ι θ {A = A} {B = B} e = EquivJ P C e (str A) (str B) where Y = typ B P : (X : Type _) → X ≃ Y → Type _ P X e' = (s : S X) (t : S Y) → ι (X , s) (Y , t) e' ≃ PathP (λ i → S (ua e' i)) s t C : (s t : S Y) → ι (Y , s) (Y , t) (idEquiv Y) ≃ PathP (λ i → S (ua (idEquiv Y) i)) s t C s t = ι (Y , s) (Y , t) (idEquiv Y) ≃⟨ θ s t ⟩ s ≡ t ≃⟨ ψ ⟩ PathP (λ i → S (ua (idEquiv Y) i)) s t ■ where ψ = transportEquiv λ j → PathP (λ i → S (uaIdEquiv {A = Y} (~ j) i)) s t -- We can now directly define an invertible function -- -- sip : A ≃[ ι ] B → A ≡ B -- sip : (S : Type ℓ₁ → Type ℓ₂) (ι : StrIso S ℓ₃) (θ : SNS-PathP S ι) (A B : TypeWithStr ℓ₁ S) → A ≃[ ι ] B → A ≡ B sip S ι θ A B (e , p) i = ua e i , θ e .fst p i -- The inverse to sip uses the following little lemma private lem : (S : Type ℓ₁ → Type ℓ₂) (A B : TypeWithStr ℓ₁ S) (e : typ A ≡ typ B) → PathP (λ i → S (ua (pathToEquiv e) i)) (A .snd) (B .snd) ≡ PathP (λ i → S (e i)) (A .snd) (B .snd) lem S A B e i = PathP (λ j → S (ua-pathToEquiv e i j)) (A .snd) (B .snd) -- The inverse sip⁻ : (S : Type ℓ₁ → Type ℓ₂) (ι : StrIso S ℓ₃) (θ : SNS-PathP S ι) (A B : TypeWithStr ℓ₁ S) → A ≡ B → A ≃[ ι ] B sip⁻ S ι θ A B r = pathToEquiv p , invEq (θ (pathToEquiv p)) q where p : typ A ≡ typ B p = cong fst r q : PathP (λ i → S (ua (pathToEquiv p) i)) (A .snd) (B .snd) q = transport⁻ (lem S A B p) (cong snd r) -- We can rather directly show that sip and sip⁻ are mutually inverse: sip-sip⁻ : (S : Type ℓ₁ → Type ℓ₂) (ι : StrIso S ℓ₃) (θ : SNS-PathP S ι) (A B : TypeWithStr ℓ₁ S) (r : A ≡ B) → sip S ι θ A B (sip⁻ S ι θ A B r) ≡ r sip-sip⁻ S ι θ A B r = let p : typ A ≡ typ B p = cong fst r q : PathP (λ i → S (p i)) (str A) (str B) q = cong snd r in sip S ι θ A B (sip⁻ S ι θ A B r) ≡⟨ refl ⟩ (λ i → ( ua (pathToEquiv p) i) , θ (pathToEquiv p) .fst (invEq (θ (pathToEquiv p)) (transport⁻ (lem S A B p) q)) i) ≡⟨ (λ i j → ( ua (pathToEquiv p) j , retEq (θ (pathToEquiv p)) (transport⁻ (lem S A B p) q) i j)) ⟩ (λ i → ( ua (pathToEquiv p) i , transport⁻ (lem S A B p) q i)) ≡⟨ (λ i j → ( ua-pathToEquiv p i j , transp (λ k → PathP (λ j → S (ua-pathToEquiv p (i ∧ k) j)) (str A) (str B)) (~ i) (transport⁻ (lem S A B p) q) j)) ⟩ (λ i → ( p i , transport (λ i → lem S A B p i) (transport⁻ (lem S A B p) q) i)) ≡⟨ (λ i j → ( p j , transportTransport⁻ (lem S A B p) q i j)) ⟩ r ∎ -- The trickier direction: sip⁻-sip : (S : Type ℓ₁ → Type ℓ₂) (ι : StrIso S ℓ₃) (θ : SNS-PathP S ι) (A B : TypeWithStr ℓ₁ S) (r : A ≃[ ι ] B) → sip⁻ S ι θ A B (sip S ι θ A B r) ≡ r sip⁻-sip S ι θ A B (e , p) = sip⁻ S ι θ A B (sip S ι θ A B (e , p)) ≡⟨ refl ⟩ pathToEquiv (ua e) , invEq (θ (pathToEquiv (ua e))) (f⁺ p') ≡⟨ (λ i → pathToEquiv-ua e i , invEq (θ (pathToEquiv-ua e i)) (pth' i)) ⟩ e , invEq (θ e) (f⁻ (f⁺ p')) ≡⟨ (λ i → e , invEq (θ e) (transportTransport⁻ (lem S A B (ua e)) p' i)) ⟩ e , invEq (θ e) (θ e .fst p) ≡⟨ (λ i → e , (secEq (θ e) p i)) ⟩ e , p ∎ where p' : PathP (λ i → S (ua e i)) (str A) (str B) p' = θ e .fst p f⁺ : PathP (λ i → S (ua e i)) (str A) (str B) → PathP (λ i → S (ua (pathToEquiv (ua e)) i)) (str A) (str B) f⁺ = transport (λ i → PathP (λ j → S (ua-pathToEquiv (ua e) (~ i) j)) (str A) (str B)) f⁻ : PathP (λ i → S (ua (pathToEquiv (ua e)) i)) (str A) (str B) → PathP (λ i → S (ua e i)) (str A) (str B) f⁻ = transport (λ i → PathP (λ j → S (ua-pathToEquiv (ua e) i j)) (str A) (str B)) -- We can prove the following as in sip∘pis-id, but the type is not -- what we want as it should be "cong ua (pathToEquiv-ua e)" pth : PathP (λ j → PathP (λ k → S (ua-pathToEquiv (ua e) j k)) (str A) (str B)) (f⁺ p') (f⁻ (f⁺ p')) pth i = transp (λ k → PathP (λ j → S (ua-pathToEquiv (ua e) (i ∧ k) j)) (str A) (str B)) (~ i) (f⁺ p') -- So we build an equality that we want to cast the types with casteq : PathP (λ j → PathP (λ k → S (ua-pathToEquiv (ua e) j k)) (str A) (str B)) (f⁺ p') (f⁻ (f⁺ p')) ≡ PathP (λ j → PathP (λ k → S (cong ua (pathToEquiv-ua e) j k)) (str A) (str B)) (f⁺ p') (f⁻ (f⁺ p')) casteq i = PathP (λ j → PathP (λ k → S (eq i j k)) (str A) (str B)) (f⁺ p') (f⁻ (f⁺ p')) where -- This is where we need the half-adjoint equivalence property eq : ua-pathToEquiv (ua e) ≡ cong ua (pathToEquiv-ua e) eq = sym (uaHAEquiv (typ A) (typ B) .snd .com e) -- We then get a term of the type we need pth' : PathP (λ j → PathP (λ k → S (cong ua (pathToEquiv-ua e) j k)) (str A) (str B)) (f⁺ p') (f⁻ (f⁺ p')) pth' = transport (λ i → casteq i) pth -- Finally package everything up to get the cubical SIP SIP : (S : Type ℓ₁ → Type ℓ₂) (ι : StrIso S ℓ₃) (θ : SNS-PathP S ι) (A B : TypeWithStr ℓ₁ S) → A ≃[ ι ] B ≃ (A ≡ B) SIP S ι θ A B = isoToEquiv (iso (sip S ι θ A B) (sip⁻ S ι θ A B) (sip-sip⁻ S ι θ A B) (sip⁻-sip S ι θ A B)) -- Now, we want to add axioms (i.e. propositions) to our Structure S that don't affect the ι. -- We use a lemma due to Zesen Qian, which can now be found in Foundations.Prelude: -- https://github.com/riaqn/cubical/blob/hgroup/Cubical/Data/Group/Properties.agda#L83 add-to-structure : (S : Type ℓ₁ → Type ℓ₂) (axioms : (X : Type ℓ₁) → S X → Type ℓ₄) → Type ℓ₁ → Type (ℓ-max ℓ₂ ℓ₄) add-to-structure S axioms X = Σ[ s ∈ S X ] (axioms X s) add-to-iso : (S : Type ℓ₁ → Type ℓ₂) (ι : StrIso S ℓ₃) (axioms : (X : Type ℓ₁) → S X → Type ℓ₄) → StrIso (add-to-structure S axioms) ℓ₃ add-to-iso S ι axioms (X , (s , a)) (Y , (t , b)) f = ι (X , s) (Y , t) f add-ax-lemma : (S : Type ℓ₁ → Type ℓ₂) (axioms : (X : Type ℓ₁) → S X → Type ℓ₄) (axioms-are-Props : (X : Type ℓ₁) (s : S X) → isProp (axioms X s)) {X Y : Type ℓ₁} {s : S X} {t : S Y} {a : axioms X s} {b : axioms Y t} (f : X ≃ Y) → PathP (λ i → S (ua f i)) s t ≃ PathP (λ i → add-to-structure S axioms (ua f i)) (s , a) (t , b) add-ax-lemma S axioms axioms-are-Props {s = s} {t = t} {a = a} {b = b} f = isoToEquiv (iso φ ψ η ε) where φ : PathP (λ i → S (ua f i)) s t → PathP (λ i → add-to-structure S axioms (ua f i)) (s , a) (t , b) φ p i = p i , isProp→PathP (λ i → axioms-are-Props (ua f i) (p i)) a b i ψ : PathP (λ i → add-to-structure S axioms (ua f i)) (s , a) (t , b) → PathP (λ i → S (ua f i)) s t ψ r i = r i .fst η : section φ ψ η r i j = r j .fst , isProp→isSet-PathP (λ k → axioms-are-Props (ua f k) (r k .fst)) _ _ (isProp→PathP (λ k → axioms-are-Props (ua f k) (r k .fst)) a b) (λ k → r k .snd) i j ε : retract φ ψ ε p = refl add-axioms-SNS : (S : Type ℓ₁ → Type ℓ₂) (ι : (A B : Σ[ X ∈ (Type ℓ₁) ] (S X)) → A .fst ≃ B .fst → Type ℓ₃) (axioms : (X : Type ℓ₁) → S X → Type ℓ₄) (axioms-are-Props : (X : Type ℓ₁) (s : S X) → isProp (axioms X s)) (θ : SNS-PathP S ι) → SNS-PathP (add-to-structure S axioms) (add-to-iso S ι axioms) add-axioms-SNS S ι axioms axioms-are-Props θ {X , s , a} {Y , t , b} f = add-to-iso S ι axioms (X , s , a) (Y , t , b) f ≃⟨ θ f ⟩ PathP (λ i → S (ua f i)) s t ≃⟨ add-ax-lemma S axioms axioms-are-Props f ⟩ PathP (λ i → (add-to-structure S axioms) (ua f i)) (s , a) (t , b) ■ -- Now, we want to join two structures. Together with the adding of -- axioms this will allow us to prove that a lot of mathematical -- structures are a standard notion of structure join-structure : (S₁ : Type ℓ₁ → Type ℓ₂) (S₂ : Type ℓ₁ → Type ℓ₄) → Type ℓ₁ → Type (ℓ-max ℓ₂ ℓ₄) join-structure S₁ S₂ X = S₁ X × S₂ X join-iso : {S₁ : Type ℓ₁ → Type ℓ₂} (ι₁ : StrIso S₁ ℓ₃) {S₂ : Type ℓ₁ → Type ℓ₄} (ι₂ : StrIso S₂ ℓ₅) → StrIso (join-structure S₁ S₂) (ℓ-max ℓ₃ ℓ₅) join-iso ι₁ ι₂ (X , s₁ , s₂) (Y , t₁ , t₂) f = (ι₁ (X , s₁) (Y , t₁) f) × (ι₂ (X , s₂) (Y , t₂) f) join-SNS : (S₁ : Type ℓ₁ → Type ℓ₂) (ι₁ : StrIso S₁ ℓ₃) (θ₁ : SNS-PathP S₁ ι₁) (S₂ : Type ℓ₁ → Type ℓ₄) (ι₂ : StrIso S₂ ℓ₅) (θ₂ : SNS-PathP S₂ ι₂) → SNS-PathP (join-structure S₁ S₂) (join-iso ι₁ ι₂) join-SNS S₁ ι₁ θ₁ S₂ ι₂ θ₂ {X , s₁ , s₂} {Y , t₁ , t₂} e = isoToEquiv (iso φ ψ η ε) where φ : join-iso ι₁ ι₂ (X , s₁ , s₂) (Y , t₁ , t₂) e → PathP (λ i → join-structure S₁ S₂ (ua e i)) (s₁ , s₂) (t₁ , t₂) φ (p , q) i = (θ₁ e .fst p i) , (θ₂ e .fst q i) ψ : PathP (λ i → join-structure S₁ S₂ (ua e i)) (s₁ , s₂) (t₁ , t₂) → join-iso ι₁ ι₂ (X , s₁ , s₂) (Y , t₁ , t₂) e ψ p = invEq (θ₁ e) (λ i → p i .fst) , invEq (θ₂ e) (λ i → p i .snd) η : section φ ψ η p i j = retEq (θ₁ e) (λ k → p k .fst) i j , retEq (θ₂ e) (λ k → p k .snd) i j ε : retract φ ψ ε (p , q) i = secEq (θ₁ e) p i , secEq (θ₂ e) q i
algebraic-stack_agda0000_doc_3936
module Record where module M where record A : Set where constructor a open M record B : Set where record C : Set where constructor c x : A x = a y : C y = record {} record D (E : Set) : Set where record F : Set₁ where field G : Set z : G
algebraic-stack_agda0000_doc_3937
{-# OPTIONS --cubical --safe #-} module JustBeInjective where open import Cubical.Core.Everything open import Cubical.Data.Unit data maybe (A : Set) : Set where just : A -> maybe A nothing : maybe A variable A : Set unwrap : A → (a : maybe A) → A unwrap _ (just x) = x unwrap a nothing = a just-injective : ∀ {A : Set} (a b : A) → just a ≡ just b → a ≡ b just-injective a b p i = unwrap a (p i)
algebraic-stack_agda0000_doc_3938
{-# OPTIONS --cubical #-} module LaterPrims where open import Agda.Primitive open import Agda.Primitive.Cubical renaming (itIsOne to 1=1) open import Agda.Builtin.Cubical.Path open import Agda.Builtin.Cubical.Sub renaming (Sub to _[_↦_]; primSubOut to outS) module Prims where primitive primLockUniv : Set₁ open Prims renaming (primLockUniv to LockU) public private variable l : Level A B : Set l -- We postulate Tick as it is supposed to be an abstract sort. postulate Tick : LockU ▹_ : ∀ {l} → Set l → Set l ▹_ A = (@tick x : Tick) -> A ▸_ : ∀ {l} → ▹ Set l → Set l ▸ A = (@tick x : Tick) → A x next : A → ▹ A next x _ = x _⊛_ : ▹ (A → B) → ▹ A → ▹ B _⊛_ f x a = f a (x a) map▹ : (f : A → B) → ▹ A → ▹ B map▹ f x α = f (x α) transpLater : ∀ (A : I → ▹ Set) → ▸ (A i0) → ▸ (A i1) transpLater A u0 a = primTransp (\ i → A i a) i0 (u0 a) transpLater-prim : (A : I → ▹ Set) → (x : ▸ (A i0)) → ▸ (A i1) transpLater-prim A x = primTransp (\ i → ▸ (A i)) i0 x transpLater-test : ∀ (A : I → ▹ Set) → (x : ▸ (A i0)) → transpLater-prim A x ≡ transpLater A x transpLater-test A x = \ _ → transpLater-prim A x hcompLater-prim : ∀ (A : ▹ Set) φ (u : I → Partial φ (▸ A)) → (u0 : (▸ A) [ φ ↦ u i0 ]) → ▸ A hcompLater-prim A φ u u0 a = primHComp (\ { i (φ = i1) → u i 1=1 a }) (outS u0 a) hcompLater : ∀ (A : ▹ Set) φ (u : I → Partial φ (▸ A)) → (u0 : (▸ A) [ φ ↦ u i0 ]) → ▸ A hcompLater A φ u u0 = primHComp (\ { i (φ = i1) → u i 1=1 }) (outS u0) hcompLater-test : ∀ (A : ▹ Set) φ (u : I → Partial φ (▸ A)) → (u0 : (▸ A) [ φ ↦ u i0 ]) → hcompLater A φ u u0 ≡ hcompLater-prim A φ u u0 hcompLater-test A φ u x = \ _ → hcompLater-prim A φ u x ap : ∀ {A B : Set} (f : A → B) → ∀ {x y} → x ≡ y → f x ≡ f y ap f eq = \ i → f (eq i) _$>_ : ∀ {A B : Set} {f g : A → B} → f ≡ g → ∀ x → f x ≡ g x eq $> x = \ i → eq i x later-ext : ∀ {A : Set} → {f g : ▹ A} → (▸ \ α → f α ≡ g α) → f ≡ g later-ext eq = \ i α → eq α i postulate dfix : ∀ {l} {A : Set l} → (▹ A → A) → ▹ A pfix : ∀ {l} {A : Set l} (f : ▹ A → A) → dfix f ≡ (\ _ → f (dfix f)) pfix' : ∀ {l} {A : Set l} (f : ▹ A → A) → ▸ \ α → dfix f α ≡ f (dfix f) pfix' f α i = pfix f i α fix : ∀ {l} {A : Set l} → (▹ A → A) → A fix f = f (dfix f) data gStream (A : Set) : Set where cons : (x : A) (xs : ▹ gStream A) → gStream A repeat : ∀ {A : Set} → A → gStream A repeat a = fix \ repeat▹ → cons a repeat▹ repeat-eq : ∀ {A : Set} (a : A) → repeat a ≡ cons a (\ α → repeat a) repeat-eq a = ap (cons a) (pfix (cons a)) map : ∀ {A B : Set} → (A → B) → gStream A → gStream B map f = fix \ map▹ → \ { (cons a as) → cons (f a) \ α → map▹ α (as α) } map-eq : ∀ {A B : Set} → (f : A → B) → ∀ a as → map f (cons a as) ≡ cons (f a) (\ α → map f (as α)) map-eq f a b = ap (cons _) (later-ext \ α → pfix' _ α $> b α) _∙_ : ∀ {A : Set} {x y z : A} → x ≡ y → y ≡ z → x ≡ z _∙_ {x = x} p q i = primHComp (\ j → \ { (i = i0) → x; (i = i1) → q j}) (p i) map-repeat : ∀ {A B : Set} → (a : A) → (f : A → B) → map f (repeat a) ≡ repeat (f a) map-repeat a f = fix \ prf▹ → ap (map f) (repeat-eq a) ∙ (map-eq f a _ ∙ ap (cons (f a)) (later-ext prf▹ ∙ later-ext \ α → \ i → pfix' (cons (f a)) α (primINeg i) ))
algebraic-stack_agda0000_doc_3939
module 120-natural-induction-necessary where open import 010-false-true open import 020-equivalence open import 100-natural -- We prove that the induction axiom is necessary. -- Peano axioms without induction. record NaturalWithoutInduction {M : Set} (zero : M) (suc : M -> M) (_==_ : M -> M -> Set) : Set1 where -- axioms field equiv : Equivalence _==_ sucn!=zero : ∀ {r} -> suc r == zero -> False sucinjective : ∀ {r s} -> suc r == suc s -> r == s cong : ∀ {r s} -> r == s -> suc r == suc s not-induction : ((p : M -> Set) -> p zero -> (∀ n -> p n -> p (suc n)) -> ∀ n -> p n) -> False open Equivalence equiv public -- Construct a model, and prove it satisfies NaturalWithoutInduction -- but not Natural. To do this, we add an extra zero. data M : Set where zero1 : M zero2 : M suc : M -> M thm-M-is-natural-without-induction : NaturalWithoutInduction zero1 suc _≡_ thm-M-is-natural-without-induction = record { equiv = thm-≡-is-equivalence; sucn!=zero = sucn!=zero; sucinjective = sucinjective; cong = cong; not-induction = not-induction } where sucn!=zero : ∀ {r} -> suc r ≡ zero1 -> False sucn!=zero () sucinjective : ∀ {r s} -> suc r ≡ suc s -> r ≡ s sucinjective refl = refl cong : ∀ {r s} -> r ≡ s -> suc r ≡ suc s cong refl = refl -- To prove that induction fails, we test the property "is a -- successor of zero1 but not of zero2". This holds for zero1 (the -- base case), and it also holds for every successor of n if it -- holds for n, but it does not hold for zero2 (or for any of its -- successors). not-induction : ((p : M -> Set) -> p zero1 -> (∀ n -> p n -> p (suc n)) -> ∀ n -> p n) -> False not-induction induction = induction p base hypothesis zero2 where -- Property "is a successor of zero1 but not a successor of zero2". p : M -> Set p zero1 = True -- true for zero1 p zero2 = False -- false (no proof) for zero2 p (suc n) = p n -- true for successor of n if and only if true for n -- Base case is trivial. base : p zero1 base = trivial -- Induction hypothesis follows by application of "p n" itself -- due to the recursive definition of p. hypothesis : ∀ n -> p n -> p (suc n) hypothesis n pn = pn -- To round this off, we explicitly prove that M is not natural. thm-M-is-not-natural : (Natural zero1 suc _≡_) -> False thm-M-is-not-natural nat = (NaturalWithoutInduction.not-induction thm-M-is-natural-without-induction) (Natural.induction nat)
algebraic-stack_agda0000_doc_3940
module Issue468 where data Unit : Set where nothing : Unit data Maybe (A : Set) : Set where nothing : Maybe A just : A → Maybe A data P : (R : Set) → Maybe R → Set₁ where p : (R : Set) (x : R) → P R (just x) works : P Unit (just _) works = p _ nothing fails : Unit → P Unit (just _) fails x = p _ nothing
algebraic-stack_agda0000_doc_3941
{-# OPTIONS --safe --warning=error --without-K #-} open import Setoids.Setoids open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Groups.Definition open import Groups.Homomorphisms.Definition module Groups.Isomorphisms.Definition where record GroupIso {m n o p : _} {A : Set m} {S : Setoid {m} {o} A} {_·A_ : A → A → A} {B : Set n} {T : Setoid {n} {p} B} {_·B_ : B → B → B} (G : Group S _·A_) (H : Group T _·B_) (f : A → B) : Set (m ⊔ n ⊔ o ⊔ p) where open Setoid S renaming (_∼_ to _∼G_) open Setoid T renaming (_∼_ to _∼H_) field groupHom : GroupHom G H f bij : SetoidBijection S T f record GroupsIsomorphic {m n o p : _} {A : Set m} {S : Setoid {m} {o} A} {_·A_ : A → A → A} {B : Set n} {T : Setoid {n} {p} B} {_·B_ : B → B → B} (G : Group S _·A_) (H : Group T _·B_) : Set (m ⊔ n ⊔ o ⊔ p) where field isomorphism : A → B proof : GroupIso G H isomorphism
algebraic-stack_agda0000_doc_3942
module Lib.Vec where open import Lib.Prelude open import Lib.Nat open import Lib.Fin infixr 40 _::_ _++_ data Vec (A : Set) : Nat -> Set where [] : Vec A 0 _::_ : forall {n} -> A -> Vec A n -> Vec A (suc n) _++_ : {A : Set}{n m : Nat} -> Vec A n -> Vec A m -> Vec A (n + m) [] ++ ys = ys (x :: xs) ++ ys = x :: xs ++ ys _!_ : forall {A n} -> Vec A n -> Fin n -> A [] ! () x :: xs ! zero = x x :: xs ! suc i = xs ! i tabulate : forall {A n} -> (Fin n -> A) -> Vec A n tabulate {n = zero} f = [] tabulate {n = suc n} f = f zero :: tabulate (f ∘ suc) vec : forall {A n} -> A -> Vec A n vec x = tabulate (\_ -> x) infixl 30 _<*>_ _<*>_ : forall {A B n} -> Vec (A -> B) n -> Vec A n -> Vec B n [] <*> [] = [] f :: fs <*> x :: xs = f x :: (fs <*> xs) map : forall {A B n} -> (A -> B) -> Vec A n -> Vec B n map f xs = vec f <*> xs zip : forall {A B C n} -> (A -> B -> C) -> Vec A n -> Vec B n -> Vec C n zip f xs ys = vec f <*> xs <*> ys
algebraic-stack_agda0000_doc_3943
{-# OPTIONS --safe #-} module Cubical.Algebra.CommRing.Instances.Unit where open import Cubical.Foundations.Prelude open import Cubical.Data.Unit open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing private variable ℓ : Level open CommRingStr UnitCommRing : ∀ {ℓ} → CommRing ℓ fst UnitCommRing = Unit* 0r (snd UnitCommRing) = tt* 1r (snd UnitCommRing) = tt* _+_ (snd UnitCommRing) = λ _ _ → tt* _·_ (snd UnitCommRing) = λ _ _ → tt* - snd UnitCommRing = λ _ → tt* isCommRing (snd UnitCommRing) = makeIsCommRing isSetUnit* (λ _ _ _ → refl) (λ { tt* → refl }) (λ _ → refl) (λ _ _ → refl) (λ _ _ _ → refl) (λ { tt* → refl }) (λ _ _ _ → refl) (λ _ _ → refl)
algebraic-stack_agda0000_doc_3944
module Prelude.String where open import Prelude.Bool open import Prelude.Char open import Prelude.List open import Prelude.Nat postulate String : Set nil : String primStringToNat : String → Nat charToString : Char -> String {-# BUILTIN STRING String #-} primitive primStringAppend : String → String → String primStringToList : String → List Char primStringFromList : List Char → String primStringEquality : String → String → Bool {-# COMPILED_EPIC nil () -> String = "" #-} {-# COMPILED_EPIC primStringToNat (s : String) -> BigInt = foreign BigInt "strToBigInt" (s : String) #-} -- {-# COMPILED_EPIC charToString (c : Int) -> String = charToString(c) #-} strEq : (x y : String) -> Bool strEq = primStringEquality infixr 30 _+S+_ _+S+_ : (x y : String) -> String _+S+_ = primStringAppend fromList : List Char -> String fromList = primStringFromList fromString : String -> List Char fromString = primStringToList
algebraic-stack_agda0000_doc_3945
module Everything where import Library import Syntax import RenamingAndSubstitution import EquationalTheory
algebraic-stack_agda0000_doc_3946
-- TODO: Unfinished open import Logic open import Type open import Structure.Relator open import Structure.Setoid module Geometry.HilbertAxioms {ℓₚ ℓₗ ℓₚₑ ℓₗₑ ℓₚₗ ℓₚₚₚ} (Point : Type{ℓₚ}) ⦃ equiv-point : Equiv{ℓₚₑ}(Point) ⦄ -- The type of points on a plane. (Line : Type{ℓₗ}) ⦃ equiv-line : Equiv{ℓₗₑ}(Line) ⦄ -- The type of lines on a plane. (Distance : Type{ℓₗ}) ⦃ equiv-distance : Equiv{ℓₗₑ}(Distance) ⦄ (Angle : Type{ℓₗ}) ⦃ equiv-angle : Equiv{ℓₗₑ}(Angle) ⦄ (_∈ₚₗ_ : Point → Line → Stmt{ℓₚₗ}) -- `p ∈ₚₗ l` means that the point `p` lies on the line `l`. (_―_―_ : Point → Point → Point → Stmt{ℓₚₚₚ}) -- `p₁ ― p₂ ― p₃` means that the second point `p₂` lies between `p₁` and `p₃` in some line. ⦃ incidence-relator : BinaryRelator(_∈ₚₗ_) ⦄ ⦃ betweenness-relator : TrinaryRelator(_―_―_) ⦄ where open import Data.Tuple as Tuple using (_⨯_ ; _,_) open import Functional open import Functional.Combinations import Lvl open import Logic.Predicate open import Logic.Propositional open import Logic.Propositional.Xor open import Sets.ExtensionalPredicateSet renaming (_≡_ to _≡ₛ_) open import Structure.Relator.Properties open import Structure.Setoid.Uniqueness open import Syntax.Function private variable p p₁ p₂ p₃ p₄ q q₁ q₂ q₃ q₄ : Point private variable l l₁ l₂ : Line module _ where -- An open line segment. -- The set of points strictly between two points in a line. -- Also called: -- • Open interval in A Minimal Version of Hilbert's Axioms for Plane Geometry by William Richter. betweens : Point → Point → PredSet(Point) betweens a b ∋ p = a ― p ― b PredSet.preserve-equiv (betweens a b) = TrinaryRelator.unary₂ betweenness-relator extensionPoints : Point → Point → PredSet(Point) extensionPoints a b ∋ p = a ― b ― p PredSet.preserve-equiv (extensionPoints a b) = TrinaryRelator.unary₃ betweenness-relator -- A line segment. -- The set of points between two points in a line including the endpoints. segment : Point → Point → PredSet(Point) segment a b = (• a) ∪ (• b) ∪ (betweens a b) -- A ray. -- The set of points between starting from `a` in the direction of `b` in a line. ray : Point → Point → PredSet(Point) ray a b = (• a) ∪ (• b) ∪ (extensionPoints a b) angle : Point → Point → Point → PredSet(PredSet(Point)) angle p₁ p₂ p₃ = (• ray p₁ p₂) ∪ (• ray p₁ p₃) Distinct₃ : Point → Point → Point → Stmt Distinct₃ = combine₃Fn₂Op₂(_≢_)(_∧_) Collinear₃ : Point → Point → Point → Stmt Collinear₃ p₁ p₂ p₃ = ∃(l ↦ all₃Fn₁Op₂(_∈ₚₗ l)(_∧_) p₁ p₂ p₃) record Axioms : Type{ℓₚ Lvl.⊔ ℓₗ Lvl.⊔ ℓₚₑ Lvl.⊔ ℓₗₑ Lvl.⊔ ℓₚₗ Lvl.⊔ ℓₚₚₚ} where field -- There is an unique line for every unordered distinct pair of points. -- Also called: -- • I1 in Hilbert’s Axiom System for Plane Geometry, A Short Introduction by Bjørn Jahren. -- • I.1 and I.2 in Project Gutenberg’s The Foundations of Geometry by David Hilbert. -- • I1 in A Minimal Version of Hilbert's Axioms for Plane Geometry by William Richter. line-construction : (p₁ ≢ p₂) → ∃!(l ↦ (p₁ ∈ₚₗ l) ∧ (p₂ ∈ₚₗ l)) -- There are two distinct points on every line. -- Also called: -- • I2 in Hilbert’s Axiom System for Plane Geometry, A Short Introduction by Bjørn Jahren. -- • I.7 in Project Gutenberg’s The Foundations of Geometry by David Hilbert. -- • I2 in A Minimal Version of Hilbert's Axioms for Plane Geometry by William Richter. line-deconstruction : ∃{Obj = Point ⨯ Point}(\{(p₁ , p₂) → (p₁ ≢ p₂) ∧ (p₁ ∈ₚₗ l) ∧ (p₂ ∈ₚₗ l)}) -- There exists three points that constructs a triangle (not all on the same line). -- • I3 in Hilbert’s Axiom System for Plane Geometry, A Short Introduction by Bjørn Jahren. -- • I3 in A Minimal Version of Hilbert's Axioms for Plane Geometry by William Richter. triangle-existence : ∃{Obj = Point ⨯ Point ⨯ Point}(\{(p₁ , p₂ , p₃) → ¬(Collinear₃ p₁ p₂ p₃)}) -- The betweenness relation is strict (pairwise irreflexive). -- There are no points between a single point. betweenness-strictness : ¬(p₁ ― p₂ ― p₁) -- The betweenness relation is symmetric. -- Also called: -- • B1 in Hilbert’s Axiom System for Plane Geometry, A Short Introduction by Bjørn Jahren. -- • II.1 in Project Gutenberg’s The Foundations of Geometry by David Hilbert. -- • B1 in A Minimal Version of Hilbert's Axioms for Plane Geometry by William Richter. betweenness-symmetry : (p₁ ― p₂ ― p₃) → (p₃ ― p₂ ― p₁) -- A line segment can be extended to a third point. -- • Part of II.2 in Project Gutenberg’s The Foundations of Geometry by David Hilbert. -- • B2 in Hilbert’s Axiom System for Plane Geometry, A Short Introduction by Bjørn Jahren. -- • B2 in A Minimal Version of Hilbert's Axioms for Plane Geometry by William Richter. betweenness-extensionᵣ : (p₁ ≢ p₂) → ∃(p₃ ↦ (p₁ ― p₂ ― p₃)) -- Three points are always between each other in a certain order. betweenness-antisymmetryₗ : (p₁ ― p₂ ― p₃) → (p₂ ― p₁ ― p₃) → ⊥ -- Three distinct points on a line are always between each other in a certain order. -- Also called: -- • Part of B3 in Hilbert’s Axiom System for Plane Geometry, A Short Introduction by Bjørn Jahren. -- • Part of II.3 in Project Gutenberg’s The Foundations of Geometry by David Hilbert. -- • Part of B3 in A Minimal Version of Hilbert's Axioms for Plane Geometry by William Richter. betweenness-cases : (Distinct₃ p₁ p₂ p₃) → (Collinear₃ p₁ p₂ p₃) → (rotate₃Fn₃Op₂(_―_―_)(_∨_) p₁ p₂ p₃) -- For three points that forms a triangle, and a line not intersecting the triangle's vertices, but intersecting one of its edges. Such a line intersects exactly one of the other edges of the triangle. -- Also called: -- • Pasch's axiom -- • B4 in Hilbert’s Axiom System for Plane Geometry, A Short Introduction by Bjørn Jahren. -- • II.5 in Project Gutenberg’s The Foundations of Geometry by David Hilbert. -- • B4 in A Minimal Version of Hilbert's Axioms for Plane Geometry by William Richter. line-triangle-intersection : ¬(Collinear₃ p₁ p₂ p₃) → (all₃Fn₁Op₂(¬_ ∘ (_∈ₚₗ l))(_∧_) p₁ p₂ p₃) → ((p ∈ₚₗ l) ∧ (p₁ ― p ― p₂)) → (∃(p ↦ (p ∈ₚₗ l) ∧ (p₁ ― p ― p₃)) ⊕ ∃(p ↦ (p ∈ₚₗ l) ∧ (p₂ ― p ― p₃))) -- TODO: The rest of the axioms are not yet formulated because I am not sure what the best way to express them is ray-segment : ∃!(p ↦ (p ∈ ray p₁ p₂) ∧ (segment q₁ q₂ ≡ₛ segment p₁ p)) segment-concat : (p₁ ― p₂ ― p₃) → (q₁ ― q₂ ― q₃) → (segment p₁ p₂ ≡ₛ segment q₁ q₂) → (segment p₂ p₃ ≡ₛ segment q₂ q₃) → (segment p₁ p₃ ≡ₛ segment q₁ q₃) -- A pair of points constructs a line. line : (a : Point) → (b : Point) → (a ≢ b) → Line line a b nab = [∃!]-witness(line-construction nab) -- A line can be deconstructed to two points. linePoints : Line → (Point ⨯ Point) linePoints l = [∃]-witness(line-deconstruction{l}) -- The point to the left in the construction of a line is in the line. line-construction-pointₗ : (np12 : p₁ ≢ p₂) → (p₁ ∈ₚₗ line p₁ p₂ np12) line-construction-pointₗ np12 = [∧]-elimₗ([∃!]-proof (line-construction np12)) -- The point to the right in the construction of a line is in the line. line-construction-pointᵣ : (np12 : p₁ ≢ p₂) → (p₂ ∈ₚₗ line p₁ p₂ np12) line-construction-pointᵣ np12 = [∧]-elimᵣ([∃!]-proof (line-construction np12)) -- Two lines having a pair of common points are the same line.. line-uniqueness : (p₁ ≢ p₂) → (p₁ ∈ₚₗ l₁) → (p₂ ∈ₚₗ l₁) → (p₁ ∈ₚₗ l₂) → (p₂ ∈ₚₗ l₂) → (l₁ ≡ l₂) line-uniqueness np12 p1l1 p2l1 p1l2 p2l2 = [∃!]-uniqueness (line-construction np12) ([∧]-intro p1l1 p2l1) ([∧]-intro p1l2 p2l2) -- The deconstructed points of a line are distinct. linePoints-distinct : let (a , b) = linePoints(l) in (a ≢ b) linePoints-distinct = [∧]-elimₗ([∧]-elimₗ([∃]-proof(line-deconstruction))) -- The left deconstructed point of a line is in the line. linePoints-pointₗ : Tuple.left(linePoints(l)) ∈ₚₗ l linePoints-pointₗ = [∧]-elimᵣ([∧]-elimₗ([∃]-proof(line-deconstruction))) -- The right deconstructed point of a line is in the line. linePoints-pointᵣ : Tuple.right(linePoints(l)) ∈ₚₗ l linePoints-pointᵣ = [∧]-elimᵣ([∃]-proof(line-deconstruction)) -- The line of the deconstructed points of a line is the same line. line-linePoints-inverseᵣ : let (a , b) = linePoints(l) in (line a b linePoints-distinct ≡ l) line-linePoints-inverseᵣ = line-uniqueness linePoints-distinct (line-construction-pointₗ linePoints-distinct) (line-construction-pointᵣ linePoints-distinct) linePoints-pointₗ linePoints-pointᵣ betweenness-antisymmetryᵣ : (p₁ ― p₂ ― p₃) → (p₁ ― p₃ ― p₂) → ⊥ betweenness-antisymmetryᵣ p123 p132 = betweenness-antisymmetryₗ (betweenness-symmetry p123) (betweenness-symmetry p132) betweenness-irreflexivityₗ : ¬(p₁ ― p₁ ― p₂) betweenness-irreflexivityₗ p112 = betweenness-antisymmetryₗ p112 p112 betweenness-irreflexivityᵣ : ¬(p₁ ― p₂ ― p₂) betweenness-irreflexivityᵣ p122 = betweenness-irreflexivityₗ (betweenness-symmetry p122) -- Also called: -- • B1 in Hilbert’s Axiom System for Plane Geometry, A Short Introduction by Bjørn Jahren. -- • B1 in A Minimal Version of Hilbert's Axioms for Plane Geometry by William Richter. betweenness-distinct : (p₁ ― p₂ ― p₃) → (Distinct₃ p₁ p₂ p₃) Tuple.left (betweenness-distinct p123) p12 = betweenness-irreflexivityₗ(substitute₃-unary₁(_―_―_) p12 p123) Tuple.left (Tuple.right (betweenness-distinct p123)) p13 = betweenness-strictness(substitute₃-unary₁(_―_―_) p13 p123) Tuple.right(Tuple.right (betweenness-distinct p123)) p23 = betweenness-irreflexivityᵣ(substitute₃-unary₂(_―_―_) p23 p123) betweenness-extensionₗ : (p₂ ≢ p₃) → ∃(p₁ ↦ (p₁ ― p₂ ― p₃)) betweenness-extensionₗ np23 = [∃]-map-proof betweenness-symmetry (betweenness-extensionᵣ (np23 ∘ symmetry(_≡_))) -- Three points are always between each other in a certain order. -- Also called: -- • B3 in Hilbert’s Axiom System for Plane Geometry, A Short Introduction by Bjørn Jahren. -- • II.3 in Project Gutenberg’s The Foundations of Geometry by David Hilbert. -- • B3 in A Minimal Version of Hilbert's Axioms for Plane Geometry by William Richter. betweenness-distinct-cases : (Distinct₃ p₁ p₂ p₃) → (Collinear₃ p₁ p₂ p₃) → ((p₁ ― p₂ ― p₃) ⊕₃ (p₂ ― p₃ ― p₁) ⊕₃ (p₃ ― p₁ ― p₂)) betweenness-distinct-cases pd pl with betweenness-cases pd pl ... | [∨]-introₗ p123 = [⊕₃]-intro₁ p123 (betweenness-antisymmetryₗ (betweenness-symmetry p123)) (betweenness-antisymmetryᵣ (betweenness-symmetry p123)) ... | [∨]-introᵣ ([∨]-introₗ p231) = [⊕₃]-intro₂ (betweenness-antisymmetryᵣ ((betweenness-symmetry p231))) p231 (betweenness-antisymmetryₗ ((betweenness-symmetry p231))) ... | [∨]-introᵣ ([∨]-introᵣ p312) = [⊕₃]-intro₃ (betweenness-antisymmetryₗ (betweenness-symmetry p312)) (betweenness-antisymmetryᵣ (betweenness-symmetry p312)) p312 --betweenness-between : (p₁ ≢ p₂) → (p₁ ∈ₚₗ l) → (p₂ ∈ₚₗ l) → ∃(p ↦ p₁ ― p ― p₂) --betweenness-between np12 p1l p2l = {!!} --betweenness-collinnear : (p₁ ― p₂ ― p₃) → (Collinear₃ p₁ p₂ p₃)
algebraic-stack_agda0000_doc_3947
{-# OPTIONS --sized-types #-} module GiveSize where postulate Size : Set {-# BUILTIN SIZE Size #-} id : Size → Size id i = {!i!}
algebraic-stack_agda0000_doc_3948
open import Formalization.PredicateLogic.Signature module Formalization.PredicateLogic.Syntax.NegativeTranslations (𝔏 : Signature) where open Signature(𝔏) open import Data.ListSized import Lvl open import Formalization.PredicateLogic.Syntax (𝔏) open import Functional using (_∘_ ; _∘₂_ ; swap) open import Numeral.Finite open import Numeral.Natural open import Sets.PredicateSet using (PredSet) open import Type private variable ℓ : Lvl.Level private variable args vars : ℕ -- Also called: Gödel-Gentzen's negative translation. -- 2.3.3 ggTrans : Formula(vars) → Formula(vars) ggTrans (P $ x) = ¬¬(P $ x) ggTrans ⊤ = ⊤ ggTrans ⊥ = ⊥ ggTrans (φ ∧ ψ) = (ggTrans φ) ∧ (ggTrans ψ) ggTrans (φ ∨ ψ) = ¬(¬(ggTrans φ) ∧ ¬(ggTrans ψ)) ggTrans (φ ⟶ ψ) = (ggTrans φ) ⟶ (ggTrans ψ) ggTrans (Ɐ φ) = Ɐ(ggTrans φ) ggTrans (∃ φ) = ¬ Ɐ(¬(ggTrans φ)) -- Also called: Kolmogorov's negative translation. -- 2.3.7A koTrans : Formula(vars) → Formula(vars) koTrans (P $ x) = ¬¬(P $ x) koTrans ⊤ = ⊤ koTrans ⊥ = ⊥ koTrans (φ ∧ ψ) = ¬¬((koTrans φ) ∧ (koTrans ψ)) koTrans (φ ∨ ψ) = ¬¬((koTrans φ) ∨ (koTrans ψ)) koTrans (φ ⟶ ψ) = ¬¬((koTrans φ) ⟶ (koTrans ψ)) koTrans (Ɐ φ) = ¬¬ Ɐ(koTrans φ) koTrans (∃ φ) = ¬¬ ∃(koTrans φ) -- Also called: Kuroda's negative translation. -- 2.3.7B kuTrans : Formula(vars) → Formula(vars) kuTrans (P $ x) = P $ x kuTrans ⊤ = ⊤ kuTrans ⊥ = ⊥ kuTrans (φ ∧ ψ) = ((koTrans φ) ∧ (koTrans ψ)) kuTrans (φ ∨ ψ) = ((koTrans φ) ∨ (koTrans ψ)) kuTrans (φ ⟶ ψ) = ((koTrans φ) ⟶ (koTrans ψ)) kuTrans (Ɐ φ) = Ɐ(¬¬(koTrans φ)) kuTrans (∃ φ) = ∃(koTrans φ)
algebraic-stack_agda0000_doc_3949
module Lawvere where open import Library open import Data.Sum open import Categories open import Categories.Sets open import Categories.Initial open import Categories.PushOuts open import Categories.Products hiding (_×_) open import Categories.CoProducts open import Categories.Terminal open import Functors open import Functors.Fin record Lawvere {a}{b} : Set (lsuc (a ⊔ b)) where constructor lawvere field T : Cat {a}{b} L : Fun (Nats Op) T L0 : Term T (Fun.OMap L zero) LP : ∀ m n → Prod T (Fun.OMap L m) (Fun.OMap L n) -- it's not the identity, it switches some implicit in fid and fcomp I think FunOp : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}} → Fun C D → Fun (C Op) (D Op) FunOp (functor OMap HMap fid fcomp) = functor OMap HMap fid fcomp LSet : Lawvere LSet = lawvere (Sets Op) (FunOp FinF) (term (λ ()) (ext λ ())) λ m n → prod (Fin m ⊎ Fin n) inj₁ inj₂ [_,_]′ refl refl λ p q → ext (λ{ (inj₁ a) -> fcong a p; (inj₂ b) -> fcong b q}) open import RMonads open import RMonads.RKleisli open import RMonads.RKleisli.Functors lem : RMonad FinF → Lawvere {lzero}{lzero} lem M = lawvere (Kl M Op) (FunOp (RKlL M) ) (term (λ ()) (ext λ ())) λ m n → prod (m + n) (η ∘ extend) (η ∘ lift m) (case m) (ext λ i → trans (fcong (extend i) law2) (lem1 m _ _ i)) (ext λ i → trans (fcong (lift m i) law2) (lem2 m _ _ i)) λ {o} {f} {g} {h} p q → ext (lem3 m f g h (trans (ext λ i → sym (fcong (extend i) law2)) p) (trans (ext λ i → sym (fcong (lift m i) law2)) q)) where open RMonad M lem-1 : Lawvere {lzero}{lzero} → RMonad FinF lem-1 LT = rmonad (λ n → Cat.Hom (Lawvere.T LT) (Fun.OMap (Lawvere.L LT) 1) (Fun.OMap (Lawvere.L LT) n)) {!!} {!!} {!!} {!!} {!!} open import Categories.Products record Model {a}{b}{c}{d} (Law : Lawvere {a}{b}) : Set (lsuc (a ⊔ b ⊔ c ⊔ d)) where open Lawvere Law field C : Cat {c}{d} F : Fun T C F0 : Term C (Fun.OMap F (Fun.OMap L zero)) FP : ∀ m n → Prod C (Fun.OMap F (Fun.OMap L m)) (Fun.OMap F (Fun.OMap L n)) open import RMonads.REM open import RMonads.CatofRAdj.InitRAdj open import RMonads.CatofRAdj.TermRAdjObj open import RMonads.REM.Functors model : (T : RMonad FinF) → Model (lem T) model T = record { C = EM T Op ; F = FunOp (K' T (EMObj T)); F0 = term (λ{alg} → ralgmorph (RAlg.astr alg {0} (λ ())) (λ {n}{f} → sym $ RAlg.alaw2 alg {n}{zero}{f}{λ ()} )) (λ{alg}{f} → RAlgMorphEq T (ext (λ t → trans (trans (cong (λ f₁ → RAlg.astr alg f₁ t) (ext (λ ()))) (sym (fcong t (RAlgMorph.ahom f {0}{RMonad.η T})))) (cong (RAlgMorph.amor f) (fcong t (RMonad.law1 T)))))); FP = λ m n → prod (Fun.OMap (REML FinF T) (m + n) ) (Fun.HMap (REML FinF T) extend) (Fun.HMap (REML FinF T) (lift m)) (λ{alg} f g → ralgmorph (RAlg.astr alg (case m (RAlgMorph.amor f ∘ RMonad.η T) (RAlgMorph.amor g ∘ RMonad.η T))) (sym (RAlg.alaw2 alg))) (λ {alg}{f}{g} → RAlgMorphEq T (trans (sym (RAlg.alaw2 alg)) (trans (cong (RAlg.astr alg) (ext λ i → trans (fcong (extend i) (sym (RAlg.alaw1 alg))) (lem1 m _ _ i))) (trans (sym (RAlgMorph.ahom f)) (ext λ i → cong (RAlgMorph.amor f) (fcong i (RMonad.law1 T))))))) (λ {alg}{f}{g} → RAlgMorphEq T (trans (sym (RAlg.alaw2 alg)) (trans (cong (RAlg.astr alg) (ext λ i → trans (fcong (lift m i) (sym (RAlg.alaw1 alg))) (lem2 m _ _ i))) (trans (sym (RAlgMorph.ahom g)) (ext λ i → cong (RAlgMorph.amor g) (fcong i (RMonad.law1 T))))))) λ{alg}{f}{g}{h} p q → RAlgMorphEq T (trans (trans (ext λ i → cong (RAlgMorph.amor h) (sym (fcong i (RMonad.law1 T)))) (RAlgMorph.ahom h)) (cong (RAlg.astr alg) (ext (lem3 m (RAlgMorph.amor f ∘ RMonad.η T) (RAlgMorph.amor g ∘ RMonad.η T) (RAlgMorph.amor h ∘ RMonad.η T) (ext λ i → trans (cong (RAlgMorph.amor h) (sym (fcong i (RMonad.law2 T)))) (fcong (RMonad.η T i) (cong RAlgMorph.amor p))) (ext λ i → trans (cong (RAlgMorph.amor h) (sym (fcong i (RMonad.law2 T)))) (fcong (RMonad.η T i) (cong RAlgMorph.amor q)))))))}
algebraic-stack_agda0000_doc_3950
module UniDB.Subst.Core where open import UniDB.Spec public open import UniDB.Morph.Unit record Ap (T X : STX) : Set₁ where field ap : {Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {γ₁ γ₂ : Dom} (ξ : Ξ γ₁ γ₂) (x : X γ₁) → X γ₂ open Ap {{...}} public record ApVr (T : STX) {{vrT : Vr T}} {{apTT : Ap T T}} : Set₁ where field ap-vr : {Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {γ₁ γ₂ : Dom} (ξ : Ξ γ₁ γ₂) → (i : Ix γ₁) → ap {T} ξ (vr i) ≡ lk {T} ξ i open ApVr {{...}} public record LkCompAp (T : STX) {{vrT : Vr T}} {{apTT : Ap T T}} (Ξ : MOR) {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {{compΞ : Comp Ξ}} : Set₁ where field lk-⊙-ap : {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Ξ γ₁ γ₂) (ξ₂ : Ξ γ₂ γ₃) (i : Ix γ₁) → lk {T} (ξ₁ ⊙ ξ₂) i ≡ ap {T} ξ₂ (lk ξ₁ i) open LkCompAp {{...}} public record ApIdm (T : STX) {{vrT : Vr T}} (X : STX) {{apTX : Ap T X}} : Set₁ where field ap-idm : {Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {{idmΞ : Idm Ξ}} {{lkIdmTΞ : LkIdm T Ξ}} {{upIdmΞ : UpIdm Ξ}} {γ : Dom} (x : X γ) → ap {T} (idm {Ξ} γ) x ≡ x open ApIdm {{...}} public record ApRel (T : STX) {{vrT : Vr T}} (X : STX) {{apTX : Ap T X}} : Set₁ where field ap-rel≅ : {Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {Ζ : MOR} {{lkTΖ : Lk T Ζ}} {{upΖ : Up Ζ}} {γ₁ γ₂ : Dom} {ξ : Ξ γ₁ γ₂} {ζ : Ζ γ₁ γ₂} (hyp : [ T ] ξ ≅ ζ) (x : X γ₁) → ap {T} ξ x ≡ ap {T} ζ x ap-rel≃ : {{wkT : Wk T}} {Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {{lkUpTΞ : LkUp T Ξ}} {Ζ : MOR} {{lkTΖ : Lk T Ζ}} {{upΖ : Up Ζ}} {{lkUpTΖ : LkUp T Ζ}} {γ₁ γ₂ : Dom} {ξ : Ξ γ₁ γ₂} {ζ : Ζ γ₁ γ₂} (hyp : [ T ] ξ ≃ ζ) (x : X γ₁) → ap {T} ξ x ≡ ap {T} ζ x ap-rel≃ hyp = ap-rel≅ (≃-to-≅` (≃-↑ hyp)) open ApRel {{...}} public module _ (T : STX) {{vrT : Vr T}} {{wkT : Wk T}} (X : STX) {{wkX : Wk X}} {{apTX : Ap T X}} where record ApWkmWk : Set₁ where field ap-wkm-wk₁ : {Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {{wkmΞ : Wkm Ξ}} {{lkUpTΞ : LkUp T Ξ}} {{lkWkmTΞ : LkWkm T Ξ}} {γ : Dom} (x : X γ) → ap {T} (wkm {Ξ} 1) x ≡ wk₁ x ap-wkm-wk : {Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {{wkmΞ : Wkm Ξ}} {{lkUpTΞ : LkUp T Ξ}} {{lkWkmTΞ : LkWkm T Ξ}} {γ : Dom} (δ : Dom) (x : X γ) → ap {T} (wkm {Ξ} δ) x ≡ wk δ x open ApWkmWk {{...}} public module _ (T : STX) {{vrT : Vr T}} {{wkT : Wk T}} (X : STX) {{wkX : Wk X}} {{apTX : Ap T X}} where record ApWk : Set₁ where field ap-wk₁ : {Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {{lkUpTΞ : LkUp T Ξ}} {γ₁ γ₂ : Dom} (ξ : Ξ γ₁ γ₂) (x : X γ₁) → ap {T} (ξ ↑₁) (wk₁ x) ≡ wk₁ (ap {T} ξ x) open ApWk {{...}} public module _ (T : STX) {{vrT : Vr T}} {{wkT : Wk T}} {{apTT : Ap T T}} (X : STX) {{apTX : Ap T X}} where record ApComp : Set₁ where field ap-⊙ : {Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {{compΞ : Comp Ξ}} {{upCompΞ : UpComp Ξ}} {{lkCompTΞ : LkCompAp T Ξ}} {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Ξ γ₁ γ₂) (ξ₂ : Ξ γ₂ γ₃) → (x : X γ₁) → ap {T} (ξ₁ ⊙ ξ₂) x ≡ ap {T} ξ₂ (ap {T} ξ₁ x) open ApComp {{...}} public instance iApIx : Ap Ix Ix ap {{iApIx}} = lk iApVrIx : ApVr Ix ap-vr {{iApVrIx}} ξ i = refl iApIdmIxIx : ApIdm Ix Ix ap-idm {{iApIdmIxIx}} {Ξ} = lk-idm {Ix} {Ξ} iApWkmWkIxIx : ApWkmWk Ix Ix ap-wkm-wk₁ {{iApWkmWkIxIx}} {Ξ} = lk-wkm {Ix} {Ξ} 1 ap-wkm-wk {{iApWkmWkIxIx}} {Ξ} = lk-wkm {Ix} {Ξ} iApRelIxIx : ApRel Ix Ix ap-rel≅ {{iApRelIxIx}} = lk≃ ∘ ≅-to-≃ iApWkIxIx : ApWk Ix Ix ap-wk₁ {{iApWkIxIx}} {Ξ} ξ i = lk-↑₁-suc {Ix} {Ξ} ξ i -- TODO: Remove module _ (T : STX) {{vrT : Vr T}} {{apTT : Ap T T}} (Ξ : MOR) {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} (Ζ : MOR) {{lkTΖ : Lk T Ζ}} {{upΖ : Up Ζ}} (Θ : MOR) {{lkTΘ : Lk T Θ}} {{upΘ : Up Θ}} {{hcompΞΖΘ : HComp Ξ Ζ Θ}} where record LkHCompAp : Set₁ where field lk-⊡-ap : {γ₁ γ₂ γ₃ : Dom} (ξ : Ξ γ₁ γ₂) (ζ : Ζ γ₂ γ₃) (i : Ix γ₁) → lk {T} {Θ} (ξ ⊡ ζ) i ≡ ap {T} ζ (lk ξ i) open LkHCompAp {{...}} public -- TODO: Remove module _ (T : STX) {{vrT : Vr T}} {{wkT : Wk T}} {{apTT : Ap T T}} (X : STX) {{apTX : Ap T X}} where record ApHComp : Set₁ where field ap-⊡ : {Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {Ζ : MOR} {{lkTΖ : Lk T Ζ}} {{upΖ : Up Ζ}} {Θ : MOR} {{lkTΘ : Lk T Θ}} {{upΘ : Up Θ}} {{hcompΞΖΘ : HComp Ξ Ζ Θ}} {{upHCompΞ : UpHComp Ξ Ζ Θ}} {{lkHCompTΞΖΘ : LkHCompAp T Ξ Ζ Θ}} {γ₁ γ₂ γ₃ : Dom} (ξ : Ξ γ₁ γ₂) (ζ : Ζ γ₂ γ₃) → (x : X γ₁) → ap {T} {X} {Θ} (ξ ⊡ ζ) x ≡ ap {T} ζ (ap {T} ξ x) open ApHComp {{...}} public -- TODO: Move module _ {T : STX} {{vrT : Vr T}} {{wkT : Wk T}} {{wkVrT : WkVr T}} {X : STX} {{wkX : Wk X}} {{apTX : Ap T X}} {{apRelTX : ApRel T X}} {{apIdmTX : ApIdm T X}} {Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {{idmΞ : Idm Ξ}} {{lkIdmTΞ : LkIdm T Ξ}} {{lkUpTΞ : LkUp T Ξ}} where ap-idm` : {γ : Dom} (x : X γ) → ap {T} (idm {Ξ} γ) x ≡ x ap-idm` {γ} x = begin ap {T} (idm {Ξ} γ) x ≡⟨ ap-rel≃ {T} lem x ⟩ ap {T} (idm {Unit} γ) x ≡⟨ ap-idm {T} x ⟩ x ∎ where lem : [ T ] idm {Ξ} γ ≃ unit lk≃ lem = lk-idm {T} {Ξ}
algebraic-stack_agda0000_doc_3951
{-# OPTIONS --allow-unsolved-metas #-} infixr 6 _∷_ data List (A : Set) : Set where [] : List A _∷_ : A -> List A -> List A postulate Bool : Set t : Bool long : List Bool long = t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ t ∷ [] meta : Set meta = _
algebraic-stack_agda0000_doc_5280
------------------------------------------------------------------------ -- A definitional interpreter ------------------------------------------------------------------------ {-# OPTIONS --cubical --safe #-} module Lambda.Simplified.Partiality-monad.Inductive.Interpreter where open import Equality.Propositional.Cubical open import Prelude hiding (⊥) open import Bijection equality-with-J using (_↔_) open import Function-universe equality-with-J hiding (id; _∘_) open import Monad equality-with-J open import Univalence-axiom equality-with-J open import Vec.Function equality-with-J open import Partiality-monad.Inductive open import Partiality-monad.Inductive.Fixpoints open import Partiality-monad.Inductive.Monad open import Lambda.Simplified.Syntax open Closure Tm ------------------------------------------------------------------------ -- One interpreter module Interpreter₁ where -- This interpreter is defined as the least upper bound of a -- sequence of increasingly defined interpreters. infix 10 _∙_ mutual ⟦_⟧′ : ∀ {n} → Tm n → Env n → ℕ → Value ⊥ ⟦ var x ⟧′ ρ n = return (ρ x) ⟦ ƛ t ⟧′ ρ n = return (ƛ t ρ) ⟦ t₁ · t₂ ⟧′ ρ n = ⟦ t₁ ⟧′ ρ n >>= λ v₁ → ⟦ t₂ ⟧′ ρ n >>= λ v₂ → (v₁ ∙ v₂) n _∙_ : Value → Value → ℕ → Value ⊥ (ƛ t₁ ρ ∙ v₂) zero = never (ƛ t₁ ρ ∙ v₂) (suc n) = ⟦ t₁ ⟧′ (cons v₂ ρ) n mutual ⟦⟧′-increasing : ∀ {n} (t : Tm n) ρ n → ⟦ t ⟧′ ρ n ⊑ ⟦ t ⟧′ ρ (suc n) ⟦⟧′-increasing (var x) ρ n = return (ρ x) ■ ⟦⟧′-increasing (ƛ t) ρ n = return (ƛ t ρ) ■ ⟦⟧′-increasing (t₁ · t₂) ρ n = ⟦⟧′-increasing t₁ ρ n >>=-mono λ v₁ → ⟦⟧′-increasing t₂ ρ n >>=-mono λ v₂ → ∙-increasing v₁ v₂ n ∙-increasing : ∀ v₁ v₂ n → (v₁ ∙ v₂) n ⊑ (v₁ ∙ v₂) (suc n) ∙-increasing (ƛ t₁ ρ) v₂ (suc n) = ⟦⟧′-increasing t₁ (cons v₂ ρ) n ∙-increasing (ƛ t₁ ρ) v₂ zero = never ⊑⟨ never⊑ _ ⟩■ ⟦ t₁ ⟧′ (cons v₂ ρ) 0 ■ ⟦_⟧ˢ : ∀ {n} → Tm n → Env n → Increasing-sequence Value ⟦ t ⟧ˢ ρ = ⟦ t ⟧′ ρ , ⟦⟧′-increasing t ρ ⟦_⟧ : ∀ {n} → Tm n → Env n → Value ⊥ ⟦ t ⟧ ρ = ⨆ (⟦ t ⟧ˢ ρ) ------------------------------------------------------------------------ -- Another interpreter module Interpreter₂ where -- This interpreter is defined using a fixpoint combinator. M : Type → Type₁ M = Partial (∃ λ n → Tm n × Env n) (λ _ → Value) infix 10 _∙_ _∙_ : Value → Value → M Value ƛ t₁ ρ ∙ v₂ = rec (_ , t₁ , cons v₂ ρ) ⟦_⟧′ : ∀ {n} → Tm n → Env n → M Value ⟦ var x ⟧′ ρ = return (ρ x) ⟦ ƛ t ⟧′ ρ = return (ƛ t ρ) ⟦ t₁ · t₂ ⟧′ ρ = ⟦ t₁ ⟧′ ρ >>= λ v₁ → ⟦ t₂ ⟧′ ρ >>= λ v₂ → v₁ ∙ v₂ evalP : (∃ λ n → Tm n × Env n) → M Value evalP (_ , t , ρ) = ⟦ t ⟧′ ρ eval : Trans-⊑ (∃ λ n → Tm n × Env n) (λ _ → Value) eval = transformer evalP ⟦_⟧ : ∀ {n} → Tm n → Env n → Value ⊥ ⟦ t ⟧ ρ = fixP evalP (_ , t , ρ) ------------------------------------------------------------------------ -- The two interpreters are pointwise equal -- Both interpreters' bodies have the form ⨆ s for some sequences s, -- and element n in the first interpreter's sequence is equal to -- element 1 + n in the second interpreter's sequence (when the -- arguments are equal). interpreters-equal : ∀ {n} (t : Tm n) ρ → Interpreter₁.⟦ t ⟧ ρ ≡ Interpreter₂.⟦ t ⟧ ρ interpreters-equal = λ t ρ → $⟨ ⟦⟧-lemma t ρ ⟩ (∀ n → Interpreter₁.⟦ t ⟧′ ρ n ≡ app→ Interpreter₂.eval (suc n) (_ , t , ρ)) ↝⟨ cong ⨆ ∘ _↔_.to equality-characterisation-increasing ⟩ ⨆ (Interpreter₁.⟦ t ⟧ˢ ρ) ≡ ⨆ (tailˢ (at (fix→-sequence Interpreter₂.eval) (_ , t , ρ))) ↝⟨ flip trans (⨆tail≡⨆ _) ⟩ ⨆ (Interpreter₁.⟦ t ⟧ˢ ρ) ≡ ⨆ (at (fix→-sequence Interpreter₂.eval) (_ , t , ρ)) ↝⟨ id ⟩□ Interpreter₁.⟦ t ⟧ ρ ≡ Interpreter₂.⟦ t ⟧ ρ □ where open Partial open Trans-⊑ mutual ⟦⟧-lemma : ∀ {n} (t : Tm n) ρ n → Interpreter₁.⟦ t ⟧′ ρ n ≡ function (Interpreter₂.⟦ t ⟧′ ρ) (app→ Interpreter₂.eval n) ⟦⟧-lemma (var x) ρ n = refl ⟦⟧-lemma (ƛ t) ρ n = refl ⟦⟧-lemma (t₁ · t₂) ρ n = cong₂ _>>=_ (⟦⟧-lemma t₁ ρ n) $ ⟨ext⟩ λ v₁ → cong₂ _>>=_ (⟦⟧-lemma t₂ ρ n) $ ⟨ext⟩ λ v₂ → ∙-lemma v₁ v₂ n ∙-lemma : ∀ v₁ v₂ n → (v₁ Interpreter₁.∙ v₂) n ≡ function (v₁ Interpreter₂.∙ v₂) (app→ Interpreter₂.eval n) ∙-lemma (ƛ t₁ ρ) v₂ zero = refl ∙-lemma (ƛ t₁ ρ) v₂ (suc n) = ⟦⟧-lemma t₁ (cons v₂ ρ) n ------------------------------------------------------------------------ -- An example -- The semantics of Ω is the non-terminating computation never. -- A proof for Interpreter₁. Ω-loops₁ : Interpreter₁.⟦ Ω ⟧ nil ≡ never Ω-loops₁ = antisymmetry (least-upper-bound _ _ lemma) (never⊑ _) where open Interpreter₁ ω-nil = ƛ (var fzero · var fzero) nil reduce-twice : ∀ n → ⟦ Ω ⟧′ nil n ≡ (ω-nil ∙ ω-nil) n reduce-twice n = ⟦ Ω ⟧′ nil n ≡⟨ now->>= ⟩ (⟦ ω ⟧′ nil n >>= λ v₂ → (ω-nil ∙ v₂) n) ≡⟨ now->>= ⟩∎ (ω-nil ∙ ω-nil) n ∎ lemma : ∀ n → ⟦ Ω ⟧′ nil n ⊑ never lemma zero = ⟦ Ω ⟧′ nil zero ≡⟨ reduce-twice zero ⟩⊑ (ω-nil ∙ ω-nil) zero ⊑⟨⟩ never ■ lemma (suc n) = ⟦ Ω ⟧′ nil (suc n) ≡⟨ reduce-twice (suc n) ⟩⊑ ⟦ Ω ⟧′ nil n ⊑⟨ lemma n ⟩■ never ■ -- A direct proof for Interpreter₂. Ω-loops₂ : Interpreter₂.⟦ Ω ⟧ nil ≡ never Ω-loops₂ = antisymmetry (least-upper-bound _ _ lemma) (never⊑ _) module Ω-loops₂ where open Interpreter₂ open Trans-⊑ open Partial ω-nil = ƛ (var fzero · var fzero) nil reduce-twice : ∀ f → function eval f (_ , Ω , nil) ≡ f (_ , var fzero · var fzero , cons ω-nil nil) reduce-twice f = function eval f (_ , Ω , nil) ≡⟨⟩ function (⟦ Ω ⟧′ nil) f ≡⟨ cong {x = function (⟦ Ω ⟧′ nil)} (_$ f) (⟨ext⟩ λ _ → now->>=) ⟩ function (⟦ ω ⟧′ nil >>= λ v₂ → ω-nil ∙ v₂) f ≡⟨ cong {x = function (⟦ ω ⟧′ nil >>= ω-nil ∙_)} (_$ f) (⟨ext⟩ λ _ → now->>=) ⟩ function (ω-nil ∙ ω-nil) f ≡⟨⟩ f (_ , var fzero · var fzero , cons ω-nil nil) ∎ lemma : ∀ n → app→ eval n (_ , Ω , nil) ⊑ never lemma zero = never⊑ never lemma (suc zero) = app→ eval 1 (_ , Ω , nil) ≡⟨ reduce-twice _ ⟩⊑ app→ eval 0 (_ , Ω , nil) ⊑⟨⟩ never ■ lemma (suc (suc n)) = app→ eval (suc (suc n)) (_ , Ω , nil) ≡⟨ reduce-twice _ ⟩⊑ app→ eval (suc n) (_ , Ω , nil) ⊑⟨ lemma (suc n) ⟩■ never ■ -- Another proof for Interpreter₂. This proof uses Scott induction. Ω-loops₂′ : Interpreter₂.⟦ Ω ⟧ nil ≡ never Ω-loops₂′ = antisymmetry lemma (never⊑ _) where open Interpreter₂ open Trans-⊑ open Partial lemma = ⟦ Ω ⟧ nil ⊑⟨⟩ fixP evalP (_ , Ω , nil) ≡⟨ cong (_$ (_ , Ω , nil)) $ fixP-is-fixpoint-combinator evalP ⟩⊑ function eval (fixP evalP) (_ , Ω , nil) ⊑⟨ fixP-induction₁ (λ f → function eval f (_ , Ω , nil) ⊑ never) ( function eval (const never) (_ , Ω , nil) ≡⟨ Ω-loops₂.reduce-twice _ ⟩⊑ never ■) (λ s hyp → function eval (⨆ ∘ s) (_ , Ω , nil) ≡⟨ Ω-loops₂.reduce-twice _ ⟩⊑ ⨆ (s _) ⊑⟨ least-upper-bound _ _ (λ n → s _ [ n ] ≡⟨ sym $ Ω-loops₂.reduce-twice _ ⟩⊑ function eval (λ x → s x [ n ]) (_ , Ω , nil) ⊑⟨ hyp n ⟩■ never ■) ⟩ never ■) evalP (λ g hyp → function eval (function eval g) (_ , Ω , nil) ≡⟨ Ω-loops₂.reduce-twice _ ⟩⊑ function eval g (_ , Ω , nil) ⊑⟨ hyp ⟩■ never ■) ⟩■ never ■ ------------------------------------------------------------------------ -- Setup -- Let us use Interpreter₂ as the default interpreter. open Interpreter₂ public
algebraic-stack_agda0000_doc_5281
module Elements where open import OscarPrelude open import Arity open import Vector open import Element record Elements : Set where constructor ⟨_⟩ field {arity} : Arity elements : Vector Element arity open Elements public instance EqElements : Eq Elements Eq._==_ EqElements (⟨_⟩ {𝑎₁} εs₁) (⟨_⟩ {𝑎₂} εs₂) with 𝑎₁ ≟ 𝑎₂ … | no 𝑎₁≢𝑎₂ = no λ {refl → 𝑎₁≢𝑎₂ refl} … | yes refl with εs₁ ≟ εs₂ … | yes refl = yes refl … | no εs₁≢εs₂ = no λ {refl → εs₁≢εs₂ refl}
algebraic-stack_agda0000_doc_5282
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Categories.DistLatticeSheaf.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Structure open import Cubical.Foundations.HLevels open import Cubical.Foundations.Powerset open import Cubical.Data.Sigma open import Cubical.Data.Nat using (ℕ) open import Cubical.Data.Nat.Order open import Cubical.Data.FinData open import Cubical.Data.FinData.Order open import Cubical.Relation.Binary.Poset open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing open import Cubical.Algebra.Semilattice open import Cubical.Algebra.Lattice open import Cubical.Algebra.DistLattice open import Cubical.Algebra.DistLattice.Basis open import Cubical.Algebra.DistLattice.BigOps open import Cubical.Categories.Category open import Cubical.Categories.Functor open import Cubical.Categories.NaturalTransformation open import Cubical.Categories.Limits.Pullback open import Cubical.Categories.Limits.Terminal open import Cubical.Categories.Limits.Limits open import Cubical.Categories.Limits.RightKan open import Cubical.Categories.Instances.Functors open import Cubical.Categories.Instances.CommRings open import Cubical.Categories.Instances.Poset open import Cubical.Categories.Instances.Semilattice open import Cubical.Categories.Instances.Lattice open import Cubical.Categories.Instances.DistLattice open import Cubical.Categories.DistLatticeSheaf.Diagram private variable ℓ ℓ' ℓ'' : Level module PreSheafExtension (L : DistLattice ℓ) (C : Category ℓ' ℓ'') (limitC : Limits {ℓ} {ℓ} C) (L' : ℙ (fst L)) where open Functor private DLCat = DistLatticeCategory L DLSubCat = ΣPropCat DLCat L' DLPreSheaf = Functor (DLCat ^op) C DLSubPreSheaf = Functor (DLSubCat ^op) C i : Functor DLSubCat DLCat F-ob i = fst F-hom i f = f F-id i = refl F-seq i _ _ = refl DLRan : DLSubPreSheaf → DLPreSheaf DLRan = Ran limitC (i ^opF) module _ (L : DistLattice ℓ) (C : Category ℓ' ℓ'') (T : Terminal C) where open Category hiding (_⋆_) open Functor open Order (DistLattice→Lattice L) open DistLatticeStr (snd L) open JoinSemilattice (Lattice→JoinSemilattice (DistLattice→Lattice L)) open MeetSemilattice (Lattice→MeetSemilattice (DistLattice→Lattice L)) using (∧≤RCancel ; ∧≤LCancel) open PosetStr (IndPoset .snd) hiding (_≤_) 𝟙 : ob C 𝟙 = terminalOb C T private DLCat : Category ℓ ℓ DLCat = DistLatticeCategory L open Category DLCat -- C-valued presheaves on a distributive lattice DLPreSheaf : Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'') DLPreSheaf = Functor (DLCat ^op) C module _ (x y : L .fst)where hom-∨₁ : DLCat [ x , x ∨l y ] hom-∨₁ = ∨≤RCancel _ _ hom-∨₂ : DLCat [ y , x ∨l y ] hom-∨₂ = ∨≤LCancel _ _ hom-∧₁ : DLCat [ x ∧l y , x ] hom-∧₁ = ≤m→≤j _ _ (∧≤RCancel _ _) hom-∧₂ : DLCat [ x ∧l y , y ] hom-∧₂ = ≤m→≤j _ _ (∧≤LCancel _ _) {- x ∧ y ----→ x | | | sq | V V y ----→ x ∨ y -} sq : hom-∧₂ ⋆ hom-∨₂ ≡ hom-∧₁ ⋆ hom-∨₁ sq = is-prop-valued (x ∧l y) (x ∨l y) (hom-∧₂ ⋆ hom-∨₂) (hom-∧₁ ⋆ hom-∨₁) {- F(x ∨ y) ----→ F(x) | | | Fsq | V V F(y) ------→ F(x ∧ y) -} Fsq : (F : DLPreSheaf) → F .F-hom hom-∨₂ ⋆⟨ C ⟩ F .F-hom hom-∧₂ ≡ F .F-hom hom-∨₁ ⋆⟨ C ⟩ F .F-hom hom-∧₁ Fsq F = F-square F sq isDLSheafPullback : (F : DLPreSheaf) → Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'') isDLSheafPullback F = (F-ob F 0l ≡ 𝟙) × ((x y : L .fst) → isPullback C _ _ _ (Fsq x y F)) -- TODO: might be better to define this as a record DLSheafPullback : Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'') DLSheafPullback = Σ[ F ∈ DLPreSheaf ] isDLSheafPullback F -- Now for the proper version using limits of the right kind: open Join L isDLSheaf : (F : DLPreSheaf) → Type _ isDLSheaf F = ∀ (n : ℕ) (α : FinVec (fst L) n) → isLimCone _ _ (F-cone F (⋁Cone L α)) --TODO: Equivalence of isDLSheaf and isDLSheafPullback module SheafOnBasis (L : DistLattice ℓ) (C : Category ℓ' ℓ'') (T : Terminal C) (L' : ℙ (fst L)) (hB : IsBasis L L') where open Category open Functor open DistLatticeStr ⦃...⦄ open SemilatticeStr ⦃...⦄ open IsBasis hB private DLCat = DistLatticeCategory L BasisCat = ΣPropCat DLCat L' DLBasisPreSheaf = Functor (BasisCat ^op) C -- to avoid writing 𝟙 L C T 1c : ob C 1c = terminalOb C T instance _ = snd L _ = snd (Basis→MeetSemilattice L L' hB) module condSquare (x y : ob BasisCat) (x∨y∈L' : fst x ∨l fst y ∈ L') where private x∨y : ob BasisCat -- = Σ[ x ∈ L ] (x ∈ L') x∨y = fst x ∨l fst y , x∨y∈L' {- x ∧ y ----→ x | | | sq | V V y ----→ x ∨ y but as a square in BasisCat -} Bsq : seq' BasisCat {x = x · y} {y = y} {z = x∨y} (hom-∧₂ L C T (fst x) (fst y)) (hom-∨₂ L C T (fst x) (fst y)) ≡ seq' BasisCat {x = x · y} {y = x} {z = x∨y} (hom-∧₁ L C T (fst x) (fst y)) (hom-∨₁ L C T (fst x) (fst y)) Bsq = sq L C T (fst x) (fst y) {- F(x ∨ y) ----→ F(x) | | | Fsq | V V F(y) ------→ F(x ∧ y) square in C but now F is only presheaf on BasisCat -} BFsq : (F : DLBasisPreSheaf) → seq' C {x = F .F-ob x∨y} {y = F .F-ob y} {z = F .F-ob (x · y)} (F .F-hom (hom-∨₂ L C T (fst x) (fst y))) (F .F-hom (hom-∧₂ L C T (fst x) (fst y))) ≡ seq' C {x = F .F-ob x∨y} {y = F .F-ob x} {z = F .F-ob (x · y)} (F .F-hom (hom-∨₁ L C T (fst x) (fst y))) (F .F-hom (hom-∧₁ L C T (fst x) (fst y))) BFsq F = F-square F Bsq -- On a basis this is weaker than the definition below! isDLBasisSheafPullback : DLBasisPreSheaf → Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'') isDLBasisSheafPullback F = ((0∈L' : 0l ∈ L') → F .F-ob (0l , 0∈L') ≡ 1c) × ((x y : ob BasisCat) (x∨y∈L' : fst x ∨l fst y ∈ L') → isPullback C _ _ _ (BFsq x y x∨y∈L' F)) where open condSquare DLBasisSheafPullback : Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'') DLBasisSheafPullback = Σ[ F ∈ DLBasisPreSheaf ] isDLBasisSheafPullback F -- the correct defintion open Join L module condCone {n : ℕ} (α : FinVec (ob BasisCat) n) (⋁α∈L' : ⋁ (λ i → α i .fst) ∈ L') where open JoinSemilattice (Lattice→JoinSemilattice (DistLattice→Lattice L)) open PosetStr (IndPoset .snd) hiding (_≤_) open MeetSemilattice (Lattice→MeetSemilattice (DistLattice→Lattice L)) using (∧≤RCancel ; ∧≤LCancel) open Order (DistLattice→Lattice L) open Cone private α' : FinVec (fst L) n α' i = α i .fst ⋁α : ob BasisCat ⋁α = ⋁ α' , ⋁α∈L' BDiag : Functor (DLShfDiag n) (BasisCat ^op) F-ob BDiag (sing i) = α i F-ob BDiag (pair i j _) = α i · α j -- α i ∧ α j + basis is closed under ∧ F-hom BDiag idAr = is-refl _ F-hom BDiag singPairL = ≤m→≤j _ _ (∧≤RCancel _ _) F-hom BDiag singPairR = ≤m→≤j _ _ (∧≤LCancel _ _) F-id BDiag = is-prop-valued _ _ _ _ F-seq BDiag _ _ = is-prop-valued _ _ _ _ B⋁Cone : Cone BDiag ⋁α coneOut B⋁Cone (sing i) = ind≤⋁ α' i coneOut B⋁Cone (pair i _ _) = is-trans _ (α' i) _ (≤m→≤j _ _ (∧≤RCancel _ _)) (ind≤⋁ α' i) coneOutCommutes B⋁Cone _ = is-prop-valued _ _ _ _ isDLBasisSheaf : DLBasisPreSheaf → Type _ isDLBasisSheaf F = ∀ {n : ℕ} (α : FinVec (ob BasisCat) n) (⋁α∈L' : ⋁ (λ i → α i .fst) ∈ L') → isLimCone _ _ (F-cone F (B⋁Cone α ⋁α∈L')) where open condCone -- To prove the statement we probably need that C is: -- 1. univalent -- 2. has finite limits (or pullbacks and a terminal object) -- 3. isGroupoid (C .ob) -- The last point is not strictly necessary, but we have to have some -- control over the hLevel as we want to write F(x) in terms of its -- basis cover which is information hidden under a prop truncation... -- Alternatively we just prove the statement for C = CommRingsCategory -- TODO: is unique existence expressed like this what we want? -- statement : (F' : DLBasisSheaf) -- → ∃![ F ∈ DLSheaf L C T ] ((x : fst L) → (x ∈ L') → CatIso C (F-ob (fst F) x) (F-ob (fst F') x)) -- TODO: if C is univalent the CatIso could be ≡? -- statement (F' , h1 , hPb) = ? -- It might be easier to prove all of these if we use the definition -- in terms of particular limits instead -- Scrap zone: -- -- Sublattices: upstream later -- record isSublattice (L' : ℙ (fst L)) : Type ℓ where -- field -- 1l-closed : 1l ∈ L' -- 0l-closed : 0l ∈ L' -- ∧l-closed : {x y : fst L} → x ∈ L' → y ∈ L' → x ∧l y ∈ L' -- ∨l-closed : {x y : fst L} → x ∈ L' → y ∈ L' → x ∨l y ∈ L' -- open isSublattice -- Sublattice : Type (ℓ-suc ℓ) -- Sublattice = Σ[ L' ∈ ℙ (fst L) ] isSublattice L' -- restrictDLSheaf : DLSheaf → Sublattice → DLSheaf -- F-ob (fst (restrictDLSheaf F (L' , HL'))) x = {!F-ob (fst F) x!} -- Hmm, not nice... -- F-hom (fst (restrictDLSheaf F L')) = {!!} -- F-id (fst (restrictDLSheaf F L')) = {!!} -- F-seq (fst (restrictDLSheaf F L')) = {!!} -- snd (restrictDLSheaf F L') = {!!}
algebraic-stack_agda0000_doc_5283
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} -- This is a selection of useful functions and definitions -- from the standard library that we tend to use a lot. module LibraBFT.Prelude where open import Level renaming (suc to ℓ+1; zero to ℓ0; _⊔_ to _ℓ⊔_) public 1ℓ : Level 1ℓ = ℓ+1 0ℓ open import Agda.Builtin.Unit public open import Data.Unit.NonEta public open import Data.Empty public open import Data.Nat renaming (_≟_ to _≟ℕ_; _≤?_ to _≤?ℕ_) public open import Data.Nat.Properties hiding (≡-irrelevant) public open import Data.List renaming (map to List-map ; filter to List-filter ; lookup to List-lookup; tabulate to List-tabulate) hiding (fromMaybe; [_]) public open import Data.List.Properties renaming (≡-dec to List-≡-dec; length-map to List-length-map; map-compose to List-map-compose) using (∷-injective; length-++; map-++-commute; sum-++-commute; map-tabulate; ++-identityʳ) public open import Data.List.Relation.Binary.Subset.Propositional renaming (_⊆_ to _⊆List_) public open import Data.List.Relation.Unary.Any using (Any; here; there) renaming (lookup to Any-lookup; map to Any-map; satisfied to Any-satisfied ;index to Any-index; any to Any-any) public open import Data.List.Relation.Unary.Any.Properties using (¬Any[]) renaming ( map⁺ to Any-map⁺ ; map⁻ to Any-map⁻ ; concat⁺ to Any-concat⁺ ; concat⁻ to Any-concat⁻ ; ++⁻ to Any-++⁻ ; ++⁺ʳ to Any-++ʳ ; ++⁺ˡ to Any-++ˡ ; singleton⁻ to Any-singleton⁻ ; tabulate⁺ to Any-tabulate⁺ ) public open import Data.List.Relation.Unary.All using (All; []; _∷_) renaming (head to All-head; tail to All-tail; lookup to All-lookup; tabulate to All-tabulate; reduce to All-reduce) public open import Data.List.Relation.Unary.All.Properties renaming ( tabulate⁻ to All-tabulate⁻ ; tabulate⁺ to All-tabulate⁺ ; map⁺ to All-map⁺ ; map⁻ to All-map⁻ ) public open import Data.List.Membership.Propositional using (_∈_; _∉_) public open import Data.Vec using (Vec; []; _∷_) renaming (replicate to Vec-replicate; lookup to Vec-lookup ;map to Vec-map; head to Vec-head; tail to Vec-tail ;updateAt to Vec-updateAt; tabulate to Vec-tabulate ;allFin to Vec-allFin; toList to Vec-toList; fromList to Vec-fromList ;_++_ to _Vec-++_) public open import Data.Vec.Relation.Unary.All using ([]; _∷_) renaming (All to Vec-All; lookup to Vec-All-lookup) public open import Data.Vec.Properties using () renaming (updateAt-minimal to Vec-updateAt-minimal ;[]=⇒lookup to Vec-[]=⇒lookup ;lookup⇒[]= to Vec-lookup⇒[]= ;lookup∘tabulate to Vec-lookup∘tabulate ;≡-dec to Vec-≡-dec) public open import Data.List.Relation.Binary.Pointwise using (decidable-≡) public open import Data.Bool renaming (_≟_ to _≟Bool_) hiding (_≤?_; _<_; _<?_; _≤_) public open import Data.Maybe renaming (map to Maybe-map; zip to Maybe-zip ; _>>=_ to _Maybe->>=_) hiding (align; alignWith; zipWith) public open import Data.Maybe.Relation.Unary.Any renaming (Any to Maybe-Any; dec to Maybe-Any-dec) hiding (map; zip; zipWith; unzip ; unzipWith) public maybe-any-⊥ : ∀{a}{A : Set a} → Maybe-Any {A = A} (λ _ → ⊤) nothing → ⊥ maybe-any-⊥ () open import Data.Maybe.Properties using (just-injective) renaming (≡-dec to Maybe-≡-dec) public open import Data.Fin using (Fin; suc; zero; fromℕ; fromℕ< ; toℕ ; cast) renaming (_≟_ to _≟Fin_; _≤?_ to _≤?Fin_; _≤_ to _≤Fin_ ; _<_ to _<Fin_; inject₁ to Fin-inject₁; inject+ to Fin-inject+) public fins : (n : ℕ) → List (Fin n) fins n = Vec-toList (Vec-allFin n) open import Data.Fin.Properties using (toℕ-injective) renaming (<-cmp to Fin-<-cmp; <⇒≢ to <⇒≢Fin) public open import Relation.Binary.PropositionalEquality hiding (decSetoid) public open import Relation.Binary.HeterogeneousEquality using (_≅_) renaming (cong to ≅-cong; cong₂ to ≅-cong₂) public open import Relation.Binary public ≡-irrelevant : ∀{a}{A : Set a} → Irrelevant {a} {A} _≡_ ≡-irrelevant refl refl = refl to-witness-lemma : ∀{ℓ}{A : Set ℓ}{a : A}{f : Maybe A}(x : Is-just f) → to-witness x ≡ a → f ≡ just a to-witness-lemma (just x) refl = refl open import Data.Sum renaming ([_,_] to either; map to ⊎-map) public open import Function using (_∘_; id; case_of_; _on_; typeOf; flip; const) public open import Data.Product renaming (map to ×-map; map₂ to ×-map₂; map₁ to ×-map₁; <_,_> to split; swap to ×-swap) hiding (zip) public open import Data.Product.Properties public open import Relation.Nullary hiding (Irrelevant; proof) public open import Relation.Nullary.Decidable hiding (map) public infix 0 if-yes_then_else_ infix 0 if-dec_then_else_ if-yes_then_else_ : {A B : Set} → Dec A → (A → B) → (¬ A → B) → B if-yes (yes prf) then f else _ = f prf if-yes (no prf) then _ else g = g prf if-dec_then_else_ : {A B : Set} → Dec A → B → B → B if-dec x then f else g = if-yes x then const f else const g open import Relation.Nullary.Negation using (contradiction; contraposition) public open import Relation.Binary using (Setoid; IsPreorder) public -- Evidence that a function is not injective NonInjective : ∀{a b c}{A : Set a}{B : Set b} → (_≈_ : Rel A c) → (A → B) → Set (a ℓ⊔ b ℓ⊔ c) NonInjective {A = A} _≈_ f = Σ (A × A) (λ { (x₁ , x₂) → ¬ (x₁ ≈ x₂) × f x₁ ≡ f x₂ }) NonInjective-≡ : ∀{a b}{A : Set a}{B : Set b} → (A → B) → Set (a ℓ⊔ b) NonInjective-≡ = NonInjective _≡_ NonInjective-∘ : ∀{a b c}{A : Set a}{B : Set b}{C : Set c} → {f : A → B}(g : B → C) → NonInjective-≡ f → NonInjective-≡ (g ∘ f) NonInjective-∘ g ((x0 , x1) , (x0≢x1 , fx0≡fx1)) = ((x0 , x1) , x0≢x1 , (cong g fx0≡fx1)) -------------------------------------------- -- Handy fmap and bind for specific types -- _<M$>_ : ∀{a b}{A : Set a}{B : Set b} → (f : A → B) → Maybe A → Maybe B _<M$>_ = Maybe-map <M$>-univ : ∀{a b}{A : Set a}{B : Set b} → (f : A → B)(x : Maybe A) → {y : B} → f <M$> x ≡ just y → ∃[ x' ] (x ≡ just x' × f x' ≡ y) <M$>-univ f (just x) refl = x , (refl , refl) maybe-lift : {A : Set} → {mx : Maybe A}{x : A} → (P : A → Set) → P x → mx ≡ just x → maybe {B = const Set} P ⊥ mx maybe-lift {mx = just .x} {x} P px refl = px <M$>-nothing : ∀ {a b}{A : Set a}{B : Set b}(f : A → B) → f <M$> nothing ≡ nothing <M$>-nothing _ = refl _<⊎$>_ : ∀{a b c}{A : Set a}{B : Set b}{C : Set c} → (A → B) → C ⊎ A → C ⊎ B f <⊎$> (inj₁ hb) = inj₁ hb f <⊎$> (inj₂ x) = inj₂ (f x) _⊎⟫=_ : ∀{a b c}{A : Set a}{B : Set b}{C : Set c} → C ⊎ A → (A → C ⊎ B) → C ⊎ B (inj₁ x) ⊎⟫= _ = inj₁ x (inj₂ a) ⊎⟫= f = f a -- TODO-1: Maybe this belongs somewhere else? It's in a similar -- category as Optics, so maybe should similarly be in a module that -- is separate from the main project? ------------------ -- Guard Syntax -- -- -- Example Usage: -- -- > f : ℕ → ℕ -- > f x = grd‖ x ≟ℕ 10 ≔ 12 -- > ‖ otherwise≔ 40 + 2 -- -- -- > g : ℕ ⊎ ℕ → ℕ -- > g x = case x of λ -- > { (inj₁ x) → grd‖ x ≤? 10 ≔ 2 * x -- > ‖ otherwise≔ 42 -- > ; (inj₂ y) → y -- > } -- -- To type: ‖ --> \Vert -- ≔ --> \:= record ToBool {a}(A : Set a) : Set a where field toBool : A → Bool open ToBool {{ ... }} public instance ToBool-Bool : ToBool Bool ToBool-Bool = record { toBool = id } ToBool-Dec : ∀{a}{A : Set a} → ToBool (Dec A) ToBool-Dec = record { toBool = ⌊_⌋ } infix 3 _≔_ data GuardClause {a}(A : Set a) : Set (ℓ+1 a) where _≔_ : {B : Set a}{{ bb : ToBool B }} → B → A → GuardClause A infix 3 otherwise≔_ data Guards {a}(A : Set a) : Set (ℓ+1 a) where otherwise≔_ : A → Guards A clause : GuardClause A → Guards A → Guards A infixr 2 _‖_ _‖_ : ∀{a}{A : Set a} → GuardClause A → Guards A → Guards A _‖_ = clause infix 1 grd‖_ grd‖_ : ∀{a}{A : Set a} → Guards A → A grd‖_ (otherwise≔ a) = a grd‖_ (clause (b ≔ a) g) = if toBool b then a else (grd‖ g) Any-satisfied-∈ : ∀{a ℓ}{A : Set a}{P : A → Set ℓ}{xs : List A} → Any P xs → Σ A (λ x → P x × x ∈ xs) Any-satisfied-∈ (here px) = _ , (px , here refl) Any-satisfied-∈ (there p) = let (a , px , prf) = Any-satisfied-∈ p in (a , px , there prf) f-sum : ∀{a}{A : Set a} → (A → ℕ) → List A → ℕ f-sum f = sum ∘ List-map f open import LibraBFT.Base.Util public
algebraic-stack_agda0000_doc_5284
{-# OPTIONS --without-K --safe #-} module Math.NumberTheory.Product.Generic where -- agda-stdlib open import Algebra -- agda-misc open import Math.NumberTheory.Summation.Generic -- TODO add syntax module MonoidProduct {c e} (M : Monoid c e) = MonoidSummation M renaming ( Σ< to Π< ; Σ≤ to Π≤ ; Σ<range to Π<range ; Σ≤range to Π≤range ) using ()
algebraic-stack_agda0000_doc_5285
postulate C : Set anything : C record I : Set where constructor c field f : C data Wrap : (j : I) → Set where wrap : ∀ {j} → Wrap j -- The following should not pass. -- It did before the fix of #142. issue142 : ∀ {j} → Wrap j → C issue142 {c _} (wrap {c _}) with anything issue142 {c _} (wrap .{c anything}) | z = z
algebraic-stack_agda0000_doc_5286
open import Relation.Unary using ( ∅ ; _∪_ ) open import Web.Semantic.DL.Signature using ( Signature ; CN ; RN ) open import Web.Semantic.Util using ( Subset ; ⁅_⁆ ) module Web.Semantic.DL.Role where data Role (Σ : Signature) : Set where ⟨_⟩ : (r : RN Σ) → Role Σ ⟨_⟩⁻¹ : (r : RN Σ) → Role Σ inv : ∀ {Σ} → Role Σ → Role Σ inv ⟨ r ⟩ = ⟨ r ⟩⁻¹ inv ⟨ r ⟩⁻¹ = ⟨ r ⟩
algebraic-stack_agda0000_doc_5287
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021 Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Prelude open import LibraBFT.Lemmas open import LibraBFT.Base.PKCS open import LibraBFT.Base.Types import LibraBFT.Yasm.Base as LYB -- This module provides some definitions and properties that facilitate -- proofs of properties about a distributed system modeled by Yasm.System -- paramaterized by some SystemParameters. module LibraBFT.Yasm.Properties (ℓ-EC : Level) (EpochConfig : Set ℓ-EC) (epochId : EpochConfig → EpochId) (authorsN : EpochConfig → ℕ) (parms : LYB.SystemParameters ℓ-EC EpochConfig epochId authorsN) -- In addition to the parameters used by the rest of the system model, this module -- needs to relate Members to PKs and PeerIds, so that StepPeerState-AllValidParts -- can be defined. This enables the application to prove that honest peers sign -- new messages only for their own public key. The system model does not know that -- directly. (senderPKOK : (ec : EpochConfig) → PK → LYB.SystemParameters.PeerId parms → Set) where open LYB.SystemParameters parms open import LibraBFT.Yasm.AvailableEpochs PeerId ℓ-EC EpochConfig epochId authorsN using (AvailableEpochs) renaming (lookup'' to EC-lookup) import LibraBFT.Yasm.AvailableEpochs PeerId ℓ-EC EpochConfig epochId authorsN as AE open import LibraBFT.Yasm.Base ℓ-EC EpochConfig epochId authorsN open import LibraBFT.Yasm.System ℓ-EC EpochConfig epochId authorsN parms open import Util.FunctionOverride PeerId _≟PeerId_ -- A ValidPartForPK collects the assumptions about what a /part/ in the outputs of an honest verifier -- satisfies: (i) the epoch field is consistent with the existent epochs and (ii) the verifier is -- a member of the associated epoch config, and (iii) has the given PK in that epoch. record ValidSenderForPK {e}(𝓔s : AvailableEpochs e)(part : Part)(sender : PeerId)(pk : PK) : Set ℓ-EC where constructor mkValidSenderForPK field vp-epoch : part-epoch part < e vp-ec : EpochConfig vp-ec-≡ : AE.lookup'' 𝓔s vp-epoch ≡ vp-ec vp-sender-ok : senderPKOK vp-ec pk sender open ValidSenderForPK public -- A valid part remains valid when new epochs are added ValidSenderForPK-stable-epoch : ∀{e part α pk}{𝓔s : AvailableEpochs e}(𝓔 : EpochConfigFor e) → ValidSenderForPK 𝓔s part α pk → ValidSenderForPK (AE.append 𝓔 𝓔s) part α pk ValidSenderForPK-stable-epoch {pk = pk} {𝓔s = 𝓔s} 𝓔 (mkValidSenderForPK e ec refl vpk) = record { vp-epoch = ≤-step e ; vp-ec = ec ; vp-ec-≡ = AE.lookup''-≤-step-lemma 𝓔s 𝓔 e ; vp-sender-ok = vpk } -- A valid part remains valid ValidSenderForPK-stable : ∀{e e' α}{st : SystemState e}{st' : SystemState e'} → Step* st st' → ∀{part pk} → ValidSenderForPK (availEpochs st) part α pk → ValidSenderForPK (availEpochs st') part α pk ValidSenderForPK-stable step-0 v = v ValidSenderForPK-stable (step-s st (step-epoch 𝓔)) v = ValidSenderForPK-stable-epoch 𝓔 (ValidSenderForPK-stable st v) ValidSenderForPK-stable (step-s st (step-peer _)) v = ValidSenderForPK-stable st v sameEpoch⇒sameEC : ∀ {e p1 p2 α1 α2 pk1 pk2}{𝓔s : AvailableEpochs e} → (vp1 : ValidSenderForPK 𝓔s p1 α1 pk1) → (vp2 : ValidSenderForPK 𝓔s p2 α2 pk2) → part-epoch p1 ≡ part-epoch p2 → vp-ec vp1 ≡ vp-ec vp2 sameEpoch⇒sameEC {𝓔s = 𝓔s} vp1 vp2 parts≡ = trans (sym (vp-ec-≡ vp1)) (trans (AE.lookup-𝓔s-injective 𝓔s (vp-epoch vp1) (vp-epoch vp2) parts≡) (vp-ec-≡ vp2)) -- TODO-1 : prove it postulate ValidSenderForPK⇒ep≡ : ∀ {e p1 p2 α1 pk} {𝓔s : AvailableEpochs e} → WithVerSig pk p1 → WithVerSig pk p2 → part-epoch p1 ≡ part-epoch p2 → ValidSenderForPK 𝓔s p1 α1 pk → ValidSenderForPK 𝓔s p2 α1 pk -- We say that an implementation produces only valid parts iff all parts of every message in the -- output of a 'StepPeerState' are either: (i) a valid new part (i.e., the part is valid and no -- message with the same signature has been sent previously), or (ii) a message has been sent -- with the same signature. StepPeerState-AllValidParts : Set ℓ-EC StepPeerState-AllValidParts = ∀{e s m part pk initd' outs}{α}{𝓔s : AvailableEpochs e}{st : SystemState e} → (r : ReachableSystemState st) → Meta-Honest-PK pk → StepPeerState α 𝓔s (msgPool st) (initialised st) (peerStates st α) initd' (s , outs) → m ∈ outs → part ⊂Msg m → (ver : WithVerSig pk part) → (ValidSenderForPK 𝓔s part α pk × ¬ (MsgWithSig∈ pk (ver-signature ver) (msgPool st))) ⊎ MsgWithSig∈ pk (ver-signature ver) (msgPool st) -- A /part/ was introduced by a specific step when: IsValidNewPart : ∀{e e'}{pre : SystemState e}{post : SystemState e'} → Signature → PK → Step pre post → Set ℓ-EC IsValidNewPart _ _ (step-epoch _) = Lift (ℓ-EC) ⊥ -- said step is a /step-peer/ and IsValidNewPart {pre = pre} sig pk (step-peer {pid = pid} pstep) -- the part has never been seen before = ReachableSystemState pre × ¬ (MsgWithSig∈ pk sig (msgPool pre)) × Σ (MsgWithSig∈ pk sig (msgPool (StepPeer-post pstep))) (λ m → ValidSenderForPK (availEpochs pre) (msgPart m) (msgSender m) pk) -- When we can prove that the implementation provided by 'parms' at the -- top of this module satisfies 'StepPeerState-AllValidParts', we can -- prove a number of useful structural properties: -- TODO-2: Refactor into a file (LibraBFT.Yasm.Properties.Structural) later on -- if this grows too large. module Structural (sps-avp : StepPeerState-AllValidParts) where -- We can unwind the state and highlight the step where a part was -- originally sent. This 'unwind' function combined with Any-Step-elim -- enables a powerful form of reasoning. The 'honestVoteEpoch' below -- exemplifies this well. unwind : ∀{e}{st : SystemState e}(tr : ReachableSystemState st) → ∀{p m σ pk} → Meta-Honest-PK pk → p ⊂Msg m → (σ , m) ∈ msgPool st → (ver : WithVerSig pk p) → Any-Step (IsValidNewPart (ver-signature ver) pk) tr unwind (step-s tr (step-epoch _)) hpk p⊂m m∈sm sig = step-there (unwind tr hpk p⊂m m∈sm sig) unwind (step-s tr (step-peer {pid = β} {outs = outs} {pre = pre} sp)) hpk p⊂m m∈sm sig with Any-++⁻ (List-map (β ,_) outs) {msgPool pre} m∈sm ...| inj₂ furtherBack = step-there (unwind tr hpk p⊂m furtherBack sig) ...| inj₁ thisStep with sp ...| step-cheat fm isCheat with thisStep ...| here refl with isCheat p⊂m sig ...| inj₁ abs = ⊥-elim (hpk abs) ...| inj₂ sentb4 with unwind tr {p = msgPart sentb4} hpk (msg⊆ sentb4) (msg∈pool sentb4) (msgSigned sentb4) ...| res rewrite msgSameSig sentb4 = step-there res unwind (step-s tr (step-peer {pid = β} {outs = outs} {pre = pre} sp)) hpk p⊂m m∈sm sig | inj₁ thisStep | step-honest x with Any-satisfied-∈ (Any-map⁻ thisStep) ...| (m , refl , m∈outs) with sps-avp tr hpk x m∈outs p⊂m sig ...| inj₂ sentb4 with unwind tr {p = msgPart sentb4} hpk (msg⊆ sentb4) (msg∈pool sentb4) (msgSigned sentb4) ...| res rewrite msgSameSig sentb4 = step-there res unwind (step-s tr (step-peer {pid = β} {outs = outs} {pre = pre} sp)) {p} hpk p⊂m m∈sm sig | inj₁ thisStep | step-honest x | (m , refl , m∈outs) | inj₁ (valid-part , notBefore) = step-here tr (tr , notBefore , MsgWithSig∈-++ˡ (mkMsgWithSig∈ _ _ p⊂m β thisStep sig refl) , valid-part) -- Unwind is inconvenient to use by itself because we have to do -- induction on Any-Step-elim. The 'honestPartValid' property below -- provides a fairly general result conveniently: for every part -- verifiable with an honest PK, there is a msg with the same -- signature that is valid for some pid. honestPartValid : ∀ {e st} → ReachableSystemState {e} st → ∀ {pk nm v sender} → Meta-Honest-PK pk → v ⊂Msg nm → (sender , nm) ∈ msgPool st → (ver : WithVerSig pk v) → Σ (MsgWithSig∈ pk (ver-signature ver) (msgPool st)) (λ msg → (ValidSenderForPK (availEpochs st) (msgPart msg) (msgSender msg) pk)) honestPartValid {e} {st} r {pk = pk} hpk v⊂m m∈pool ver -- We extract two pieces of important information from the place where the part 'v' -- was first sent: (a) there is a message with the same signature /in the current pool/ -- and (b) its epoch is less than e. = Any-Step-elim (λ { {st = step-epoch _} () ; {st = step-peer {pid = pid} ps} (_ , _ , new , valid) tr → MsgWithSig∈-Step* tr new , ValidSenderForPK-stable tr (subst (λ P → ValidSenderForPK _ P (msgSender (MsgWithSig∈-Step* tr new)) pk) (MsgWithSig∈-Step*-part tr new) (subst (λ sndr → ValidSenderForPK _ _ sndr pk) (MsgWithSig∈-Step*-sender tr new) valid)) }) (unwind r hpk v⊂m m∈pool ver) -- Unforgeability is also an important property stating that every part that is -- verified with an honest public key has either been sent by α or is a replay -- of another message sent before. ext-unforgeability' : ∀{e α m part pk}{st : SystemState e} → ReachableSystemState st -- If a message m has been sent by α, containing part → (α , m) ∈ msgPool st → part ⊂Msg m -- And the part can be verified with an honest public key, → (sig : WithVerSig pk part) → Meta-Honest-PK pk -- then either the part is a valid part by α (meaning that α can -- sign the part itself) or a message with the same signature has -- been sent previously. → ValidSenderForPK (availEpochs st) part α pk ⊎ MsgWithSig∈ pk (ver-signature sig) (msgPool st) ext-unforgeability' (step-s st (step-epoch 𝓔)) m∈sm p⊆m sig hpk = ⊎-map (ValidSenderForPK-stable-epoch 𝓔) id (ext-unforgeability' st m∈sm p⊆m sig hpk) ext-unforgeability' {part = part} (step-s st (step-peer {pid = β} {outs = outs} {pre = pre} sp)) m∈sm p⊆m sig hpk with Any-++⁻ (List-map (β ,_) outs) {msgPool pre} m∈sm ...| inj₂ furtherBack = MsgWithSig∈-++ʳ <⊎$> (ext-unforgeability' st furtherBack p⊆m sig hpk) ...| inj₁ thisStep with sp ...| step-cheat fm isCheat with thisStep ...| here refl with isCheat p⊆m sig ...| inj₁ abs = ⊥-elim (hpk abs) ...| inj₂ sentb4 = inj₂ (MsgWithSig∈-++ʳ sentb4) ext-unforgeability' {α = α} {m = m} {part = part} (step-s st (step-peer {pid = β} {outs = outs} {pre = pre} sp)) m∈sm p⊆m sig hpk | inj₁ thisStep | step-honest x with Any-satisfied-∈ (Any-map⁻ thisStep) ...| (m , refl , m∈outs) = ⊎-map proj₁ MsgWithSig∈-++ʳ (sps-avp st hpk x m∈outs p⊆m sig) -- The ext-unforgeability' property can be collapsed in a single clause. -- TODO-2: so far, ext-unforgeability is used only to get a MsgWithSig∈ that is passed to -- msgWithSigSentByAuthor, which duplicates some of the reasoning in the proof of -- ext-unforgeability'; should these properties possibly be combined into one simpler proof? ext-unforgeability : ∀{e α₀ m part pk}{st : SystemState e} → ReachableSystemState st → (α₀ , m) ∈ msgPool st → part ⊂Msg m → (sig : WithVerSig pk part) → Meta-Honest-PK pk → MsgWithSig∈ pk (ver-signature sig) (msgPool st) ext-unforgeability {_} {α₀} {m} {st = st} rst m∈sm p⊂m sig hpk with ext-unforgeability' rst m∈sm p⊂m sig hpk ...| inj₁ p = mkMsgWithSig∈ _ _ p⊂m α₀ m∈sm sig refl ...| inj₂ sentb4 = sentb4 ¬cheatForgeNew : ∀ {e pid pk vsig mst outs m}{st : SystemState e} → (sp : StepPeer st pid mst outs) → outs ≡ m ∷ [] → (ic : isCheat sp) → Meta-Honest-PK pk → MsgWithSig∈ pk vsig ((pid , m) ∷ msgPool st) → MsgWithSig∈ pk vsig (msgPool st) ¬cheatForgeNew sc@(step-cheat fm isCheat) refl _ hpk mws with msg∈pool mws ...| there m∈pool = mkMsgWithSig∈ (msgWhole mws) (msgPart mws) (msg⊆ mws) (msgSender mws) m∈pool (msgSigned mws) (msgSameSig mws) ...| here m∈pool with isCheat (subst (msgPart mws ⊂Msg_) (cong proj₂ m∈pool) (msg⊆ mws)) (msgSigned mws) ...| inj₁ dis = ⊥-elim (hpk dis) ...| inj₂ mws' rewrite msgSameSig mws = mws' msgWithSigSentByAuthor : ∀ {e pk sig}{st : SystemState e} → ReachableSystemState st → Meta-Honest-PK pk → MsgWithSig∈ pk sig (msgPool st) → Σ (MsgWithSig∈ pk sig (msgPool st)) λ mws → ValidSenderForPK (availEpochs st) (msgPart mws) (msgSender mws) pk msgWithSigSentByAuthor step-0 _ () msgWithSigSentByAuthor (step-s {pre = pre} preach (step-epoch 𝓔)) hpk mws rewrite step-epoch-does-not-send pre 𝓔 with msgWithSigSentByAuthor preach hpk mws ...| mws' , vpb = mws' , ValidSenderForPK-stable {st = pre} (step-s step-0 (step-epoch 𝓔)) vpb msgWithSigSentByAuthor {pk = pk} (step-s {pre = pre} preach (step-peer theStep@(step-cheat fm cheatCons))) hpk mws with (¬cheatForgeNew theStep refl unit hpk mws) ...| mws' with msgWithSigSentByAuthor preach hpk mws' ...| mws'' , vpb'' = MsgWithSig∈-++ʳ mws'' , vpb'' msgWithSigSentByAuthor {e} (step-s {pre = pre} preach (step-peer {pid = pid} {outs = outs} (step-honest sps))) hpk mws with Any-++⁻ (List-map (pid ,_) outs) {msgPool pre} (msg∈pool mws) ...| inj₂ furtherBack with msgWithSigSentByAuthor preach hpk (MsgWithSig∈-transp mws furtherBack) ...| mws' , vpb' = MsgWithSig∈-++ʳ mws' , vpb' msgWithSigSentByAuthor {e} (step-s {pre = pre} preach (step-peer {pid = pid} {outs = outs} (step-honest sps))) hpk mws | inj₁ thisStep with Any-satisfied-∈ (Any-map⁻ thisStep) ...| (m' , refl , m∈outs) with sps-avp preach hpk sps m∈outs (msg⊆ mws) (msgSigned mws) ...| inj₁ (vpbα₀ , _) = mws , vpbα₀ ...| inj₂ mws' with msgWithSigSentByAuthor preach hpk mws' ...| mws'' , vpb'' rewrite sym (msgSameSig mws) = MsgWithSig∈-++ʳ mws'' , vpb'' newMsg⊎msgSentB4 : ∀ {e pk v m pid sndr st' outs} {st : SystemState e} → (r : ReachableSystemState st) → (stP : StepPeer st pid st' outs) → Meta-Honest-PK pk → (sig : WithVerSig pk v) → v ⊂Msg m → (sndr , m) ∈ msgPool (StepPeer-post stP) → (m ∈ outs × ValidSenderForPK (availEpochs st) v pid pk × ¬ (MsgWithSig∈ pk (ver-signature sig) (msgPool st))) ⊎ MsgWithSig∈ pk (ver-signature sig) (msgPool st) newMsg⊎msgSentB4 {e} {pk} {v} {m} {pid} {sndr} {_} {outs} {st} r stP pkH sig v⊂m m∈post with Any-++⁻ (List-map (pid ,_) outs) m∈post ...| inj₂ m∈preSt = inj₂ (mkMsgWithSig∈ m v v⊂m sndr m∈preSt sig refl) ...| inj₁ nm∈outs with Any-map (cong proj₂) (Any-map⁻ nm∈outs) ...| m∈outs with stP ...| step-honest stH with sps-avp r pkH stH m∈outs v⊂m sig ...| inj₁ newVote = inj₁ (m∈outs , newVote) ...| inj₂ msb4 = inj₂ msb4 newMsg⊎msgSentB4 {e} {pk} {v} {m} {pid} {sndr} {_} {outs} {st} r stP pkH sig v⊂m m∈post | inj₁ nm∈outs | here refl | step-cheat fm ic = let mws = mkMsgWithSig∈ m v v⊂m pid (here refl) sig refl in inj₂ (¬cheatForgeNew {st = st} (step-cheat fm ic) refl unit pkH mws) -- This could potentially be more general, for example covering the whole SystemState, rather than -- just one peer's state. However, this would put more burden on the user and is not required so -- far. CarrierProp : Set₁ CarrierProp = Part → PeerState → Set module _ (P : CarrierProp) where record PropCarrier (pk : PK) (sig : Signature) {e} (st : SystemState e) : Set (ℓ-EC ℓ⊔ (ℓ+1 0ℓ)) where constructor mkCarrier field carrStReach : ReachableSystemState st -- Enables use of invariants when proving that steps preserve carrProp carrSent : MsgWithSig∈ pk sig (msgPool st) carrValid : ValidSenderForPK (availEpochs st) (msgPart carrSent) (msgSender carrSent) pk carrProp : P (msgPart carrSent) (peerStates st (msgSender carrSent)) open PropCarrier public PeerStepPreserves : Set (ℓ+1 ℓ0 ℓ⊔ ℓ-EC) PeerStepPreserves = ∀ {e initd' ps' outs pk sig}{pre : SystemState e} → (r : ReachableSystemState pre) → (pc : PropCarrier pk sig {e} pre) → (sps : StepPeerState {e} (msgSender (carrSent pc)) (availEpochs pre) (msgPool pre) (initialised pre) (peerStates pre (msgSender (carrSent pc))) initd' (ps' , outs)) → P (msgPart (carrSent pc)) ps' module _ (PSP : PeerStepPreserves) where Carrier-transp : ∀ {e' e'' pk sig} {pre : SystemState e'}{post : SystemState e''} → (theStep : Step pre post) → PropCarrier pk sig pre → PropCarrier pk sig post Carrier-transp {pre = pre} {post} (step-epoch ec) (mkCarrier r mws vpk lvr) = mkCarrier (step-s r (step-epoch ec)) mws (ValidSenderForPK-stable-epoch ec vpk) lvr Carrier-transp {e' = e'} {pre = pre} {post} theStep@(step-peer {pid = pid} {st'} {pre = .pre} sps) pc@(mkCarrier r mws vpk prop) with step-s r theStep ...| postReach with sps ...| step-cheat fm isch = mkCarrier postReach (MsgWithSig∈-++ʳ mws) vpk (subst (λ ps → P (msgPart mws) (ps (msgSender mws))) (sym (cheatStepDNMPeerStates {pre = pre} (step-cheat fm isch) unit)) prop) -- PeerStates not changed by cheat steps ...| step-honest {st = st} sps' with msgSender mws ≟PeerId pid ...| no neq = mkCarrier postReach (MsgWithSig∈-++ʳ mws) vpk (subst (λ ps → P (msgPart mws) ps) (override-target-≢ {f = peerStates pre} neq) prop) ...| yes refl = mkCarrier postReach (MsgWithSig∈-++ʳ mws) vpk (subst (λ ps → P (msgPart mws) ps) (sym override-target-≡) (PSP r pc sps'))
algebraic-stack_agda0000_doc_5288
module Issue252 where data I : Set where zero : I data D : I → Set where c : ∀ i → D i → D i id : I → I id i = i index : ∀ i → D i → I index i _ = i foo : ∀ i → D i → D zero foo .i (c i d) with id i foo ._ (c i d) | zero = d bar : ∀ i → D i → D zero bar .i (c i d) with index i d bar ._ (c i d) | zero = d -- In the context of the first goal d has type D i′, in the second it -- has type D i. Well, not any more.
algebraic-stack_agda0000_doc_5289
module Thesis.SIRelBigStep.Normalization where open import Thesis.SIRelBigStep.Lang open import Data.Unit.Base hiding (_≤_) open import Data.Product open import Relation.Binary.PropositionalEquality -- Define logical relation for normalization. Adapted from TAPL Ch. 12. mutual normT : ∀ {Γ} τ (t : Term Γ τ) (ρ : ⟦ Γ ⟧Context) → Set normT τ t ρ = Σ[ v ∈ Val τ ] ρ ⊢ t ↓[ no ] v × normV τ v normV : ∀ τ (v : Val τ) → Set normV (σ ⇒ τ) (closure t ρ) = ∀ (v : Val σ) → (vv : normV _ v) → normT τ t (v • ρ) normV (pair τ1 τ2) (pairV v1 v2) = normV _ v1 × normV _ v2 normV nat (natV n) = ⊤ normρ : ∀ Γ (ρ : ⟦ Γ ⟧Context) → Set normρ ∅ ∅ = ⊤ normρ (τ • Γ) (v • ρ) = normV τ v × normρ Γ ρ ⟦_⟧VarNorm : ∀ {Γ τ} (x : Var Γ τ) {ρ} → normρ Γ ρ → normV τ (⟦ x ⟧Var ρ) ⟦ this ⟧VarNorm {v • ρ} (vv , ρρ) = vv ⟦ that x ⟧VarNorm {v • ρ} (vv , ρρ) = ⟦ x ⟧VarNorm ρρ -- Prove fundamental property. normT-fund : ∀ {τ Γ} (t : Term Γ τ) ρ (ρρ : normρ Γ ρ) → normT τ t ρ normV-fund-const : ∀ {τ} (c : Const τ) → normV τ (eval-const c) normV-fund-const (lit n) = tt normV-fund-sval : ∀ {τ Γ} (sv : SVal Γ τ) ρ (ρρ : normρ Γ ρ) → normV τ (eval sv ρ) normV-fund-sval (var x) ρ ρρ = ⟦ x ⟧VarNorm ρρ normV-fund-sval (abs t) ρ ρρ v vv = normT-fund t (v • ρ) (vv , ρρ) normV-fund-sval (cons sv1 sv2) ρ ρρ = normV-fund-sval sv1 ρ ρρ , normV-fund-sval sv2 ρ ρρ normV-fund-sval (const c) ρ ρρ = normV-fund-const c -- Not inlined because it gives the right type ascription to the derivation `val sv`. normT-fund-sval : ∀ {τ Γ} (sv : SVal Γ τ) ρ (ρρ : normρ Γ ρ) → normT τ (val sv) ρ normT-fund-sval sv ρ ρρ = eval sv ρ , val sv , normV-fund-sval sv ρ ρρ normV-fund-primitive : ∀ {σ τ} p → ∀ v → (vv : normV σ v) → normV τ (eval-primitive p v) normV-fund-primitive succ (natV n) vv = tt normV-fund-primitive add (pairV (natV m) (natV n)) vv = tt open import Data.Nat normT-fund (val sv) ρ ρρ = normT-fund-sval sv ρ ρρ normT-fund (primapp p sv) ρ ρρ = eval-primitive p (eval sv ρ) , primapp p sv , normV-fund-primitive p (eval sv ρ) (normV-fund-sval sv ρ ρρ) normT-fund (app vs vt) ρ ρρ with normT-fund-sval vs ρ ρρ | normT-fund-sval vt ρ ρρ ... | closure t ρ₁ , ↓fv , fvv | av , ↓av , avv with fvv av avv ... | v , ↓v , vv = v , app zero _ ↓fv ↓av ↓v , vv normT-fund (lett s t) ρ ρρ with normT-fund s ρ ρρ ... | sv , ↓s , svv with normT-fund t (sv • ρ) (svv , ρρ) ... | tv , ↓t , tvv = tv , lett zero zero sv s t ↓s ↓t , tvv -- Deduce from fundamental property that all terms indeed normalize. normalize : ∀ {τ} (t : Term ∅ τ) → Σ[ v ∈ Val τ ] ∅ ⊢ t ↓[ no ] v normalize t with normT-fund t ∅ tt ... | v , ↓ , _ = v , ↓
algebraic-stack_agda0000_doc_5290
module Esterel.Environment where open import utility open import Data.Empty open import Esterel.Variable.Signal as Signal using (Signal ; _ₛ) open import Esterel.Variable.Shared as SharedVar using (SharedVar ; _ₛₕ) open import Esterel.Variable.Sequential as SeqVar using (SeqVar ; _ᵥ) open import Data.Product import Data.FiniteMap open import Data.Nat as Nat using (ℕ) open import Data.List as List using (List ; [] ; _∷_) open import Data.Sum using (_⊎_ ; inj₁ ; inj₂ ; [_,_]) open import Function using (_∘_) open import Relation.Nullary using (Dec ; yes ; no ; ¬_) open import Relation.Binary using (Decidable) open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; cong ; sym ; module ≡-Reasoning ; trans ; subst ; inspect) open import Data.List.Any using (Any) open ≡-Reasoning using (_≡⟨_⟩_ ; _≡⟨⟩_ ; _∎ ; begin_) module SigMap = Data.FiniteMap Signal.unwrap Signal.wrap Signal.unwrap-injective Signal.bijective module ShrMap = Data.FiniteMap SharedVar.unwrap SharedVar.wrap SharedVar.unwrap-injective SharedVar.bijective module VarMap = Data.FiniteMap SeqVar.unwrap SeqVar.wrap SeqVar.unwrap-injective SeqVar.bijective record Env : Set where constructor Θ field sig : SigMap.Map Signal.Status shr : ShrMap.Map (SharedVar.Status × ℕ) var : VarMap.Map ℕ open Env public -- A VarList is a three-tuple of lists of unwrapped signals, -- shared variables and sequential variables. VarList : Set VarList = List ℕ × List ℕ × List ℕ Dom : Env -> VarList Dom (Θ sig shr var) = (SigMap.keys sig) , (ShrMap.keys shr) , (VarMap.keys var) []env = Θ [] [] [] Sig∈ : (S : Signal) → (e : Env) → Relation.Nullary.Dec (Any (SigMap.inj= S) (SigMap.keys (sig e))) Sig∈ s e = SigMap.∈Check s (sig e) Shr∈ : (s : SharedVar) → (e : Env) → Relation.Nullary.Dec (Any (ShrMap.inj= s) (ShrMap.keys (shr e))) Shr∈ s e = ShrMap.∈Check s (shr e) Var∈ : (x : SeqVar) → (e : Env) → Relation.Nullary.Dec (Any (VarMap.inj= x) (VarMap.keys (var e))) Var∈ x e = VarMap.∈Check x (var e) isSig∈ : (S : Signal) → (e : Env) → Set isSig∈ S e = (SigMap.∈Dom S (sig e)) isShr∈ : SharedVar → Env → Set isShr∈ s e = ShrMap.∈Dom s (shr e) isVar∈ : SeqVar → Env → Set isVar∈ x e = VarMap.∈Dom x (var e) SigDomMap : ∀{a}{L : Set a} → (θ : Env) → (f : (S : Signal) → isSig∈ S θ → L) → List L SigDomMap = SigMap.key-map ∘ sig ShrDomMap : ∀{a}{L : Set a} → (θ : Env) → (f : (S : SharedVar) → isShr∈ S θ → L) → List L ShrDomMap = ShrMap.key-map ∘ shr SigDom : Env → List ℕ SigDom (Θ sig shr var) = (SigMap.keys sig) ShrDom : Env → List ℕ ShrDom (Θ sig shr var) = (ShrMap.keys shr) VarDom : Env → List ℕ VarDom (Θ sig shr var) = (VarMap.keys var) sig-stats : ∀{S} → (θ : Env) → (SigMap.∈Dom S (sig θ)) → Signal.Status sig-stats{S} θ S∈ = SigMap.lookup{k = S} (sig θ) S∈ shr-stats : ∀{s} → (θ : Env) → (ShrMap.∈Dom s (shr θ)) → SharedVar.Status shr-stats{s} θ s∈ = proj₁ (ShrMap.lookup{k = s} (shr θ) s∈) shr-vals : ∀{s} → (θ : Env) → (ShrMap.∈Dom s (shr θ)) → ℕ shr-vals{s} θ s∈ = proj₂ (ShrMap.lookup{k = s} (shr θ) s∈) var-vals : ∀{x} → (θ : Env) → (VarMap.∈Dom x (var θ)) → ℕ var-vals{x} θ x∈ = VarMap.lookup{k = x} (var θ) x∈ set-sig : ∀{S} → (θ : Env) → (SigMap.∈Dom S (sig θ)) → Signal.Status → Env set-sig{S} (Θ sig shr var) S∈ status = Θ (SigMap.update sig S status) shr var set-shr : ∀{s} → (θ : Env) → (ShrMap.∈Dom s (shr θ)) → SharedVar.Status → ℕ → Env set-shr{s} (Θ sig shr var) s∈ status n = Θ sig (ShrMap.update shr s (status , n)) var set-var : ∀{x} → (θ : Env) → (VarMap.∈Dom x (var θ)) → ℕ → Env set-var{x} (Θ sig shr var) x∈ n = Θ sig shr (VarMap.update var x n) _←_ : Env → Env → Env Θ sig₁ shr₁ seq₁ ← Θ sig₂ shr₂ seq₂ = Θ (SigMap.union sig₁ sig₂) (ShrMap.union shr₁ shr₂) (VarMap.union seq₁ seq₂) data EnvVar : Set where vsig : Signal → EnvVar vshr : SharedVar → EnvVar vvar : SeqVar → EnvVar data ∈map : EnvVar → Env → Set where ∈sig : ∀{S θ} → (isSig∈ S θ) → ∈map (vsig S) θ ∈shr : ∀{s θ} → (isShr∈ s θ) → ∈map (vshr s) θ ∈var : ∀{x θ} → (isVar∈ x θ) → ∈map (vvar x) θ -- thrms sig-set-mono' : ∀{S S' θ stat} → ∀{S'∈ : (isSig∈ S' θ)} → (isSig∈ S θ) → (isSig∈ S (set-sig{S'} θ S'∈ stat)) sig-set-mono'{S}{S'}{θ}{stat}{S'∈} i = SigMap.insert-mono{_}{k = S}{m = sig θ}{S'}{stat} i shr-set-mono' : ∀{s s' θ stat n} → ∀{s'∈ : (isShr∈ s' θ)} → (isShr∈ s θ) → (isShr∈ s (set-shr{s'} θ s'∈ stat n)) shr-set-mono'{s}{s'}{θ}{stat}{n}{s'∈} i = ShrMap.insert-mono{_}{k = s}{m = shr θ}{s'}{stat ,′ n} i seq-set-mono' : ∀{x x' θ n} → ∀{x'∈ : (isVar∈ x' θ)} → (isVar∈ x θ) → (isVar∈ x (set-var{x'} θ x'∈ n)) seq-set-mono'{x}{x'}{θ}{n}{x'∈} i = VarMap.insert-mono{_}{k = x}{m = var θ}{x'}{n} i sig-set-mono : ∀{V S' θ stat} → ∀{S'∈ : (isSig∈ S' θ)} → ∈map V θ → (∈map V (set-sig{S'} θ S'∈ stat)) sig-set-mono{S' = S'}{θ}{S'∈ = S'∈} (∈sig{S} x) = ∈sig{S} (sig-set-mono'{S = S}{S' = S'}{θ = θ}{S'∈ = S'∈} x) sig-set-mono (∈shr x) = ∈shr x sig-set-mono (∈var x₁) = ∈var x₁ shr-set-mono : ∀{V s' θ stat n} → ∀{s'∈ : (isShr∈ s' θ)} → (∈map V θ) → (∈map V (set-shr{s'} θ s'∈ stat n)) shr-set-mono (∈sig x) = ∈sig x shr-set-mono{s' = s'}{θ}{stat}{n}{s'∈}(∈shr{s} x) = ∈shr{s} (shr-set-mono'{s}{s'}{θ}{stat}{n}{s'∈} x) shr-set-mono (∈var x₁) = ∈var x₁ seq-set-mono : ∀{V x' θ n} → ∀{x'∈ : (isVar∈ x' θ)} → (∈map V θ) → (∈map V (set-var{x'} θ x'∈ n)) seq-set-mono (∈sig x) = ∈sig x seq-set-mono (∈shr x) = ∈shr x seq-set-mono{x' = x'}{θ}{n}{x'∈} (∈var{x} x₁) = ∈var {x} (seq-set-mono'{x}{x'}{θ}{n}{x'∈} x₁) ←-mono : ∀{θ θ' V} → ∈map V θ → ∈map V (θ ← θ') ←-mono{θ}{θ'}{vsig S} (∈sig x) = ∈sig{S}{(θ ← θ')} (SigMap.U-mono{_}{sig θ}{sig θ'}{S} x) ←-mono{θ}{θ'}{vshr s} (∈shr x) = ∈shr{s}{(θ ← θ')} (ShrMap.U-mono{_}{shr θ}{shr θ'}{s} x) ←-mono{θ}{θ'}{vvar x} (∈var x₁) = ∈var{x}{(θ ← θ')} (VarMap.U-mono{_}{var θ}{var θ'}{x} x₁) ←-comm : ∀ θ θ' → distinct (Dom θ) (Dom θ') → (θ ← θ') ≡ (θ' ← θ) ←-comm (Θ Ss ss xs) (Θ Ss' ss' xs') (Ss≠Ss' , ss≠ss' , xs≠xs') rewrite SigMap.union-comm Ss Ss' Ss≠Ss' | ShrMap.union-comm ss ss' ss≠ss' | VarMap.union-comm xs xs' xs≠xs' = refl ←-assoc : ∀ θ θ' θ'' → (θ ← (θ' ← θ'')) ≡ ((θ ← θ') ← θ'') ←-assoc (Θ Ss ss xs) (Θ Ss' ss' xs') (Θ Ss'' ss'' xs'') rewrite SigMap.union-assoc Ss Ss' Ss'' | ShrMap.union-assoc ss ss' ss'' | VarMap.union-assoc xs xs' xs'' = refl ←-assoc-comm : ∀ θ θ' θ'' → distinct (Dom θ') (Dom θ'') → ((θ ← θ') ← θ'') ≡ ((θ ← θ'') ← θ') ←-assoc-comm θ θ' θ'' Domθ'≠Domθ'' = (θ ← θ') ← θ'' ≡⟨ sym (←-assoc θ θ' θ'') ⟩ θ ← (θ' ← θ'') ≡⟨ cong (θ ←_) (←-comm θ' θ'' Domθ'≠Domθ'') ⟩ θ ← (θ'' ← θ') ≡⟨ ←-assoc θ θ'' θ' ⟩ (θ ← θ'') ← θ' ∎ Dom-←-assoc-comm : ∀ θ θ' θ'' → Dom ((θ ← θ') ← θ'') ≡ Dom ((θ ← θ'') ← θ') Dom-←-assoc-comm (Θ Ss ss xs) (Θ Ss' ss' xs') (Θ Ss'' ss'' xs'') rewrite SigMap.keys-assoc-comm Ss Ss' Ss'' | ShrMap.keys-assoc-comm ss ss' ss'' | VarMap.keys-assoc-comm xs xs' xs'' = refl Dom-←-comm : ∀ θ θ' → Dom (θ ← θ') ≡ Dom (θ' ← θ) Dom-←-comm θ θ' = Dom-←-assoc-comm []env θ θ' sig-←-monoʳ : ∀ S θ θ' → isSig∈ S θ → isSig∈ S (θ' ← θ) sig-←-monoʳ S θ θ' S∈Domθ rewrite cong proj₁ (Dom-←-comm θ' θ) = SigMap.U-mono {_} {Env.sig θ} {Env.sig θ'} {S} S∈Domθ shr-←-monoʳ : ∀ s θ θ' → isShr∈ s θ → isShr∈ s (θ' ← θ) shr-←-monoʳ s θ θ' s∈Domθ rewrite cong (proj₁ ∘ proj₂) (Dom-←-comm θ' θ) = ShrMap.U-mono {_} {Env.shr θ} {Env.shr θ'} {s} s∈Domθ seq-←-monoʳ : ∀ x θ θ' → isVar∈ x θ → isVar∈ x (θ' ← θ) seq-←-monoʳ x θ θ' x∈Domθ rewrite cong (proj₂ ∘ proj₂) (Dom-←-comm θ' θ) = VarMap.U-mono {_} {var θ} {var θ'} {x} x∈Domθ sig-←-monoˡ : ∀ S θ θ' → isSig∈ S θ → isSig∈ S (θ ← θ') sig-←-monoˡ S θ θ' S∈Domθ = SigMap.U-mono {_} {Env.sig θ} {Env.sig θ'} {S} S∈Domθ shr-←-monoˡ : ∀ s θ θ' → isShr∈ s θ → isShr∈ s (θ ← θ') shr-←-monoˡ s θ θ' s∈Domθ = ShrMap.U-mono {_} {Env.shr θ} {Env.shr θ'} {s} s∈Domθ seq-←-monoˡ : ∀ x θ θ' → isVar∈ x θ → isVar∈ x (θ ← θ') seq-←-monoˡ x θ θ' x∈Domθ = VarMap.U-mono {_} {var θ} {var θ'} {x} x∈Domθ sig-←⁻ : ∀ {θ₁ θ₂} S → isSig∈ S (θ₁ ← θ₂) → isSig∈ S θ₁ ⊎ isSig∈ S θ₂ sig-←⁻ {θ₁} {θ₂} S = SigMap.U⁻-m {Signal.Status} {sig θ₁} {sig θ₂} {S} shr-←⁻ : ∀ {θ₁ θ₂} s → isShr∈ s (θ₁ ← θ₂) → isShr∈ s θ₁ ⊎ isShr∈ s θ₂ shr-←⁻ {θ₁} {θ₂} s = ShrMap.U⁻-m {_} {shr θ₁} {shr θ₂} {s} seq-←⁻ : ∀ {θ₁ θ₂} x → isVar∈ x (θ₁ ← θ₂) → isVar∈ x θ₁ ⊎ isVar∈ x θ₂ seq-←⁻ {θ₁} {θ₂} x = VarMap.U⁻-m {_} {var θ₁} {var θ₂} {x} sig-↚⁻ : ∀ {θ₁ θ₂} S → ¬ isSig∈ S θ₁ → ¬ isSig∈ S θ₂ → ¬ isSig∈ S (θ₁ ← θ₂) sig-↚⁻ {θ₁} {θ₂} S S∉Domθ₁ S∉Domθ₂ = [ S∉Domθ₁ , S∉Domθ₂ ] ∘ sig-←⁻ {θ₁} {θ₂} S sig-stats-∈-irr : ∀{S θ} → (∈1 : (SigMap.∈Dom S (sig θ))) → (∈2 : (SigMap.∈Dom S (sig θ))) → sig-stats{S} θ ∈1 ≡ sig-stats{S} θ ∈2 sig-stats-∈-irr{S} {θ} ∈1 ∈2 = SigMap.lookup-∈-irr{k = S}{m = (sig θ)} ∈1 ∈2 shr-stats-∈-irr : ∀{s θ} → (∈1 : ShrMap.∈Dom s (shr θ)) → (∈2 : ShrMap.∈Dom s (shr θ)) → shr-stats{s} θ ∈1 ≡ shr-stats{s} θ ∈2 shr-stats-∈-irr{s}{θ} ∈1 ∈2 = cong proj₁ (ShrMap.lookup-∈-irr{k = s}{m = (shr θ)} ∈1 ∈2) shr-vals-∈-irr : ∀{s θ} → (∈1 : ShrMap.∈Dom s (shr θ)) → (∈2 : ShrMap.∈Dom s (shr θ)) → shr-vals{s} θ ∈1 ≡ shr-vals{s} θ ∈2 shr-vals-∈-irr{s}{θ} ∈1 ∈2 = cong proj₂ (ShrMap.lookup-∈-irr{k = s}{m = (shr θ)} ∈1 ∈2) var-vals-∈-irr : ∀{x θ} → (∈1 : VarMap.∈Dom x (var θ)) → (∈2 : VarMap.∈Dom x (var θ)) → var-vals{x} θ ∈1 ≡ var-vals{x} θ ∈2 var-vals-∈-irr{x} {θ} ∈1 ∈2 = VarMap.lookup-∈-irr{_}{x}{var θ} ∈1 ∈2 sig-←-∉-irr-stats' : ∀ S θ θ' → (S∈ : isSig∈ S θ) → (S∉ : ¬ isSig∈ S θ') → (S∈Dom⟨θ←θ'⟩ : isSig∈ S (θ ← θ')) → sig-stats {S} θ S∈ ≡ sig-stats {S} (θ ← θ') S∈Dom⟨θ←θ'⟩ sig-←-∉-irr-stats' S θ θ' S∈ S∉ S∈' = SigMap.U-∉-irr-get-help-m {_} {Env.sig θ} {Env.sig θ'} {S} S∈ S∉ S∈' sig-←-∉-irr-stats : ∀ S θ θ' → (S∈ : isSig∈ S θ) → (S∉ : ¬ isSig∈ S θ') → ∃ λ S∈Dom⟨θ←θ'⟩ → sig-stats {S} θ S∈ ≡ sig-stats {S} (θ ← θ') S∈Dom⟨θ←θ'⟩ sig-←-∉-irr-stats S θ θ' S∈ S∉ = SigMap.U-∉-irr-get-m {_} {Env.sig θ} {Env.sig θ'} {S} S∈ S∉ shr-←-∉-irr-stats' : ∀ s θ θ' → (s∈ : isShr∈ s θ) → (s∉ : ¬ isShr∈ s θ') → (s∈Dom⟨θ←θ'⟩ : isShr∈ s (θ ← θ')) → shr-stats {s} θ s∈ ≡ shr-stats {s} (θ ← θ') s∈Dom⟨θ←θ'⟩ shr-←-∉-irr-stats' s θ θ' s∈ s∉ s∈' rewrite ShrMap.U-∉-irr-get-help-m {_} {Env.shr θ} {Env.shr θ'} {s} s∈ s∉ s∈' = refl shr-←-∉-irr-stats : ∀ s θ θ' → (s∈ : isShr∈ s θ) → (s∉ : ¬ isShr∈ s θ') → ∃ λ s∈Dom⟨θ←θ'⟩ → shr-stats {s} θ s∈ ≡ shr-stats {s} (θ ← θ') s∈Dom⟨θ←θ'⟩ shr-←-∉-irr-stats s θ θ' s∈ s∉ rewrite proj₂ (ShrMap.U-∉-irr-get-m {_} {Env.shr θ} {Env.shr θ'} {s} s∈ s∉) = (_ , refl) shr-←-∉-irr-vals' : ∀ s θ θ' → (s∈ : isShr∈ s θ) → (s∉ : ¬ isShr∈ s θ') → (s∈Dom⟨θ←θ'⟩ : isShr∈ s (θ ← θ')) → shr-vals {s} θ s∈ ≡ shr-vals {s} (θ ← θ') s∈Dom⟨θ←θ'⟩ shr-←-∉-irr-vals' s θ θ' s∈ s∉ s∈' rewrite ShrMap.U-∉-irr-get-help-m {_} {Env.shr θ} {Env.shr θ'} {s} s∈ s∉ s∈' = refl shr-←-∉-irr-vals : ∀ s θ θ' → (s∈ : isShr∈ s θ) → (s∉ : ¬ isShr∈ s θ') → ∃ λ s∈Dom⟨θ←θ'⟩ → shr-vals {s} θ s∈ ≡ shr-vals {s} (θ ← θ') s∈Dom⟨θ←θ'⟩ shr-←-∉-irr-vals s θ θ' s∈ s∉ rewrite proj₂ (ShrMap.U-∉-irr-get-m {_} {Env.shr θ} {Env.shr θ'} {s} s∈ s∉) = (_ , refl) var-←-∉-irr-vals' : ∀ x θ θ' → (x∈ : isVar∈ x θ) → (x∉ : ¬ isVar∈ x θ') → (x∈Dom⟨θ←θ'⟩ : isVar∈ x (θ ← θ')) → var-vals {x} θ x∈ ≡ var-vals {x} (θ ← θ') x∈Dom⟨θ←θ'⟩ var-←-∉-irr-vals' x θ θ' x∈ x∉ x∈' = VarMap.U-∉-irr-get-help-m {_} {Env.var θ} {Env.var θ'} {x} x∈ x∉ x∈' var-←-∉-irr-vals : ∀ x θ θ' → (x∈ : isVar∈ x θ) → (x∉ : ¬ isVar∈ x θ') → ∃ λ x∈Dom⟨θ←θ'⟩ → var-vals {x} θ x∈ ≡ var-vals {x} (θ ← θ') x∈Dom⟨θ←θ'⟩ var-←-∉-irr-vals x θ θ' x∈ x∉ = VarMap.U-∉-irr-get-m {_} {Env.var θ} {Env.var θ'} {x} x∈ x∉ sig-stats-←-right-irr' : ∀ S θ θ' → (S∈ : isSig∈ S θ') → (S∈' : isSig∈ S (θ ← θ')) → sig-stats {S} (θ ← θ') S∈' ≡ sig-stats {S} θ' S∈ sig-stats-←-right-irr' S θ θ' S∈ S∈' = SigMap.get-U-right-irr-m S (Env.sig θ) (Env.sig θ') S∈' S∈ sig-stats-←-right-irr : ∀ S θ θ' → (S∈ : isSig∈ S θ') → ∃ λ S∈' → sig-stats {S} (θ ← θ') S∈' ≡ sig-stats {S} θ' S∈ sig-stats-←-right-irr S θ θ' S∈ = sig-←-monoʳ S θ' θ S∈ , SigMap.get-U-right-irr-m S (Env.sig θ) (Env.sig θ') (sig-←-monoʳ S θ' θ S∈) S∈ shr-stats-←-right-irr' : ∀ s θ θ' → (s∈ : isShr∈ s θ') → (s∈' : isShr∈ s (θ ← θ')) → shr-stats {s} (θ ← θ') s∈' ≡ shr-stats {s} θ' s∈ shr-stats-←-right-irr' s θ θ' s∈ s∈' rewrite ShrMap.get-U-right-irr-m s (Env.shr θ) (Env.shr θ') s∈' s∈ = refl shr-stats-←-right-irr : ∀ s θ θ' → (s∈ : isShr∈ s θ') → ∃ λ s∈' → shr-stats {s} (θ ← θ') s∈' ≡ shr-stats {s} θ' s∈ shr-stats-←-right-irr s θ θ' s∈ = shr-←-monoʳ s θ' θ s∈ , cong proj₁ (ShrMap.get-U-right-irr-m s (Env.shr θ) (Env.shr θ') (shr-←-monoʳ s θ' θ s∈) s∈) shr-vals-←-right-irr' : ∀ s θ θ' → (s∈ : isShr∈ s θ') → (s∈' : isShr∈ s (θ ← θ')) → shr-vals {s} (θ ← θ') s∈' ≡ shr-vals {s} θ' s∈ shr-vals-←-right-irr' s θ θ' s∈ s∈' rewrite ShrMap.get-U-right-irr-m s (Env.shr θ) (Env.shr θ') s∈' s∈ = refl shr-vals-←-right-irr : ∀ s θ θ' → (s∈ : isShr∈ s θ') → ∃ λ s∈' → shr-vals {s} (θ ← θ') s∈' ≡ shr-vals {s} θ' s∈ shr-vals-←-right-irr s θ θ' s∈ = shr-←-monoʳ s θ' θ s∈ , cong proj₂ (ShrMap.get-U-right-irr-m s (Env.shr θ) (Env.shr θ') (shr-←-monoʳ s θ' θ s∈) s∈) var-vals-←-right-irr' : ∀ x θ θ' → (x∈ : isVar∈ x θ') → (x∈' : isVar∈ x (θ ← θ')) → var-vals {x} (θ ← θ') x∈' ≡ var-vals {x} θ' x∈ var-vals-←-right-irr' x θ θ' x∈ x∈' = VarMap.get-U-right-irr-m x (Env.var θ) (Env.var θ') x∈' x∈ var-vals-←-right-irr : ∀ x θ θ' → (x∈ : isVar∈ x θ') → ∃ λ x∈' → var-vals {x} (θ ← θ') x∈' ≡ var-vals {x} θ' x∈ var-vals-←-right-irr x θ θ' x∈ = seq-←-monoʳ x θ' θ x∈ , VarMap.get-U-right-irr-m x (Env.var θ) (Env.var θ') (seq-←-monoʳ x θ' θ x∈) x∈ sig-stats-←-irr' : ∀ S θ θ' θ'' → (S∈ : isSig∈ S θ'') → (S∈' : isSig∈ S (θ ← θ'')) → (S∈'' : isSig∈ S (θ' ← θ'')) → sig-stats {S} (θ ← θ'') S∈' ≡ sig-stats {S} (θ' ← θ'') S∈'' sig-stats-←-irr' S θ θ' θ'' S∈ S∈' S∈'' = SigMap.∈-get-U-irr-m S (sig θ) (sig θ') (sig θ'') S∈' S∈'' S∈ sig-stats-←-irr : ∀ S θ θ' θ'' → (S∈ : isSig∈ S θ'') → ∃ λ S∈' → ∃ λ S∈'' → sig-stats {S} (θ ← θ'') S∈' ≡ sig-stats {S} (θ' ← θ'') S∈'' sig-stats-←-irr S θ θ' θ'' S∈ = sig-←-monoʳ S θ'' θ S∈ , sig-←-monoʳ S θ'' θ' S∈ , SigMap.∈-get-U-irr-m S (sig θ) (sig θ') (sig θ'') (sig-←-monoʳ S θ'' θ S∈) (sig-←-monoʳ S θ'' θ' S∈) S∈ shr-stats-←-irr' : ∀ s θ θ' θ'' → (s∈ : isShr∈ s θ'') → (s∈' : isShr∈ s (θ ← θ'')) → (s∈'' : isShr∈ s (θ' ← θ'')) → shr-stats {s} (θ ← θ'') s∈' ≡ shr-stats {s} (θ' ← θ'') s∈'' shr-stats-←-irr' s θ θ' θ'' s∈ s∈' s∈'' rewrite ShrMap.∈-get-U-irr-m s (shr θ) (shr θ') (shr θ'') s∈' s∈'' s∈ = refl shr-stats-←-irr : ∀ s θ θ' θ'' → (s∈ : isShr∈ s θ'') → ∃ λ s∈' → ∃ λ s∈'' → shr-stats {s} (θ ← θ'') s∈' ≡ shr-stats {s} (θ' ← θ'') s∈'' shr-stats-←-irr s θ θ' θ'' s∈ = shr-←-monoʳ s θ'' θ s∈ , shr-←-monoʳ s θ'' θ' s∈ , cong proj₁ (ShrMap.∈-get-U-irr-m s (shr θ) (shr θ') (shr θ'') (shr-←-monoʳ s θ'' θ s∈) (shr-←-monoʳ s θ'' θ' s∈) s∈) shr-vals-←-irr' : ∀ s θ θ' θ'' → (s∈ : isShr∈ s θ'') → (s∈' : isShr∈ s (θ ← θ'')) → (s∈'' : isShr∈ s (θ' ← θ'')) → shr-vals {s} (θ ← θ'') s∈' ≡ shr-vals {s} (θ' ← θ'') s∈'' shr-vals-←-irr' s θ θ' θ'' s∈ s∈' s∈'' rewrite ShrMap.∈-get-U-irr-m s (shr θ) (shr θ') (shr θ'') s∈' s∈'' s∈ = refl shr-vals-←-irr : ∀ s θ θ' θ'' → (s∈ : isShr∈ s θ'') → ∃ λ s∈' → ∃ λ s∈'' → shr-vals {s} (θ ← θ'') s∈' ≡ shr-vals {s} (θ' ← θ'') s∈'' shr-vals-←-irr s θ θ' θ'' s∈ = shr-←-monoʳ s θ'' θ s∈ , shr-←-monoʳ s θ'' θ' s∈ , cong proj₂ (ShrMap.∈-get-U-irr-m s (shr θ) (shr θ') (shr θ'') (shr-←-monoʳ s θ'' θ s∈) (shr-←-monoʳ s θ'' θ' s∈) s∈) var-vals-←-irr' : ∀ x θ θ' θ'' → (x∈ : isVar∈ x θ'') → (x∈' : isVar∈ x (θ ← θ'')) → (x∈'' : isVar∈ x (θ' ← θ'')) → var-vals {x} (θ ← θ'') x∈' ≡ var-vals {x} (θ' ← θ'') x∈'' var-vals-←-irr' x θ θ' θ'' x∈ x∈' x∈'' = VarMap.∈-get-U-irr-m x (var θ) (var θ') (var θ'') x∈' x∈'' x∈ var-vals-←-irr : ∀ x θ θ' θ'' → (x∈ : isVar∈ x θ'') → ∃ λ x∈' → ∃ λ x∈'' → var-vals {x} (θ ← θ'') x∈' ≡ var-vals {x} (θ' ← θ'') x∈'' var-vals-←-irr x θ θ' θ'' x∈ = seq-←-monoʳ x θ'' θ x∈ , seq-←-monoʳ x θ'' θ' x∈ , VarMap.∈-get-U-irr-m x (var θ) (var θ') (var θ'') (seq-←-monoʳ x θ'' θ x∈) (seq-←-monoʳ x θ'' θ' x∈) x∈ sig-stats-←-both-irr' : ∀ S θ θ' θ'' S∈ S∈' S∈Dom⟨θ←θ''⟩ S∈Dom⟨θ'←θ''⟩ → sig-stats {S} θ S∈ ≡ sig-stats {S} θ' S∈' → sig-stats {S} (θ ← θ'') S∈Dom⟨θ←θ''⟩ ≡ sig-stats {S} (θ' ← θ'') S∈Dom⟨θ'←θ''⟩ sig-stats-←-both-irr' S θ θ' θ'' S∈ S∈' S∈Dom⟨θ←θ''⟩ S∈Dom⟨θ'←θ''⟩ θS≡θ'S = SigMap.get-U-both-irr-m S (Env.sig θ) (Env.sig θ') (Env.sig θ'') S∈ S∈' S∈Dom⟨θ←θ''⟩ S∈Dom⟨θ'←θ''⟩ θS≡θ'S sig-stats-←-both-irr : ∀ S θ θ' θ'' S∈ S∈' → sig-stats {S} θ S∈ ≡ sig-stats {S} θ' S∈' → ∃ λ S∈Dom⟨θ←θ''⟩ → ∃ λ S∈Dom⟨θ'←θ''⟩ → sig-stats {S} (θ ← θ'') S∈Dom⟨θ←θ''⟩ ≡ sig-stats {S} (θ' ← θ'') S∈Dom⟨θ'←θ''⟩ sig-stats-←-both-irr S θ θ' θ'' S∈ S∈' θS≡θ'S = S∈Dom⟨θ←θ''⟩ , S∈Dom⟨θ'←θ''⟩ , SigMap.get-U-both-irr-m S (Env.sig θ) (Env.sig θ') (Env.sig θ'') S∈ S∈' S∈Dom⟨θ←θ''⟩ S∈Dom⟨θ'←θ''⟩ θS≡θ'S where S∈Dom⟨θ←θ''⟩ = sig-←-monoˡ S θ θ'' S∈ S∈Dom⟨θ'←θ''⟩ = sig-←-monoˡ S θ' θ'' S∈' shr-stats-←-both-irr' : ∀ s θ θ' θ'' s∈ s∈' s∈Dom⟨θ←θ''⟩ s∈Dom⟨θ'←θ''⟩ → shr-stats {s} θ s∈ ≡ shr-stats {s} θ' s∈' → shr-vals {s} θ s∈ ≡ shr-vals {s} θ' s∈' → shr-stats {s} (θ ← θ'') s∈Dom⟨θ←θ''⟩ ≡ shr-stats {s} (θ' ← θ'') s∈Dom⟨θ'←θ''⟩ shr-stats-←-both-irr' s θ θ' θ'' s∈ s∈' s∈Dom⟨θ←θ''⟩ s∈Dom⟨θ'←θ''⟩ proj₁θs≡proj₁θ's proj₂θs≡proj₂θ's = cong proj₁ (ShrMap.get-U-both-irr-m s (Env.shr θ) (Env.shr θ') (Env.shr θ'') s∈ s∈' s∈Dom⟨θ←θ''⟩ s∈Dom⟨θ'←θ''⟩ (prod-ind proj₁θs≡proj₁θ's proj₂θs≡proj₂θ's)) where prod-ind : {A B : Set} {x,y x',y' : A × B} → proj₁ x,y ≡ proj₁ x',y' → proj₂ x,y ≡ proj₂ x',y' → x,y ≡ x',y' prod-ind {_} {_} {x , y} {x' , y'} refl refl = refl shr-stats-←-both-irr : ∀ s θ θ' θ'' s∈ s∈' → shr-stats {s} θ s∈ ≡ shr-stats {s} θ' s∈' → shr-vals {s} θ s∈ ≡ shr-vals {s} θ' s∈' → ∃ λ s∈Dom⟨θ←θ''⟩ → ∃ λ s∈Dom⟨θ'←θ''⟩ → shr-stats {s} (θ ← θ'') s∈Dom⟨θ←θ''⟩ ≡ shr-stats {s} (θ' ← θ'') s∈Dom⟨θ'←θ''⟩ shr-stats-←-both-irr s θ θ' θ'' s∈ s∈' proj₁θs≡proj₁θ's proj₂θs≡proj₂θ's = s∈Dom⟨θ←θ''⟩ , s∈Dom⟨θ'←θ''⟩ , cong proj₁ (ShrMap.get-U-both-irr-m s (Env.shr θ) (Env.shr θ') (Env.shr θ'') s∈ s∈' s∈Dom⟨θ←θ''⟩ s∈Dom⟨θ'←θ''⟩ (prod-ind proj₁θs≡proj₁θ's proj₂θs≡proj₂θ's)) where s∈Dom⟨θ←θ''⟩ = shr-←-monoˡ s θ θ'' s∈ s∈Dom⟨θ'←θ''⟩ = shr-←-monoˡ s θ' θ'' s∈' prod-ind : {A B : Set} {x,y x',y' : A × B} → proj₁ x,y ≡ proj₁ x',y' → proj₂ x,y ≡ proj₂ x',y' → x,y ≡ x',y' prod-ind {_} {_} {x , y} {x' , y'} refl refl = refl shr-vals-←-both-irr' : ∀ s θ θ' θ'' s∈ s∈' s∈Dom⟨θ←θ''⟩ s∈Dom⟨θ'←θ''⟩ → shr-stats {s} θ s∈ ≡ shr-stats {s} θ' s∈' → shr-vals {s} θ s∈ ≡ shr-vals {s} θ' s∈' → shr-vals {s} (θ ← θ'') s∈Dom⟨θ←θ''⟩ ≡ shr-vals {s} (θ' ← θ'') s∈Dom⟨θ'←θ''⟩ shr-vals-←-both-irr' s θ θ' θ'' s∈ s∈' s∈Dom⟨θ←θ''⟩ s∈Dom⟨θ'←θ''⟩ proj₁θs≡proj₁θ's proj₂θs≡proj₂θ's = cong proj₂ (ShrMap.get-U-both-irr-m s (Env.shr θ) (Env.shr θ') (Env.shr θ'') s∈ s∈' s∈Dom⟨θ←θ''⟩ s∈Dom⟨θ'←θ''⟩ (prod-ind proj₁θs≡proj₁θ's proj₂θs≡proj₂θ's)) where prod-ind : {A B : Set} {x,y x',y' : A × B} → proj₁ x,y ≡ proj₁ x',y' → proj₂ x,y ≡ proj₂ x',y' → x,y ≡ x',y' prod-ind {_} {_} {x , y} {x' , y'} refl refl = refl shr-vals-←-both-irr : ∀ s θ θ' θ'' s∈ s∈' → shr-stats {s} θ s∈ ≡ shr-stats {s} θ' s∈' → shr-vals {s} θ s∈ ≡ shr-vals {s} θ' s∈' → ∃ λ s∈Dom⟨θ←θ''⟩ → ∃ λ s∈Dom⟨θ'←θ''⟩ → shr-vals {s} (θ ← θ'') s∈Dom⟨θ←θ''⟩ ≡ shr-vals {s} (θ' ← θ'') s∈Dom⟨θ'←θ''⟩ shr-vals-←-both-irr s θ θ' θ'' s∈ s∈' proj₁θs≡proj₁θ's proj₂θs≡proj₂θ's = s∈Dom⟨θ←θ''⟩ , s∈Dom⟨θ'←θ''⟩ , cong proj₂ (ShrMap.get-U-both-irr-m s (Env.shr θ) (Env.shr θ') (Env.shr θ'') s∈ s∈' s∈Dom⟨θ←θ''⟩ s∈Dom⟨θ'←θ''⟩ (prod-ind proj₁θs≡proj₁θ's proj₂θs≡proj₂θ's)) where s∈Dom⟨θ←θ''⟩ = shr-←-monoˡ s θ θ'' s∈ s∈Dom⟨θ'←θ''⟩ = shr-←-monoˡ s θ' θ'' s∈' prod-ind : {A B : Set} {x,y x',y' : A × B} → proj₁ x,y ≡ proj₁ x',y' → proj₂ x,y ≡ proj₂ x',y' → x,y ≡ x',y' prod-ind {_} {_} {x , y} {x' , y'} refl refl = refl var-vals-←-both-irr' : ∀ x θ θ' θ'' x∈ x∈' x∈Dom⟨θ←θ''⟩ x∈Dom⟨θ'←θ''⟩ → var-vals {x} θ x∈ ≡ var-vals {x} θ' x∈' → var-vals {x} (θ ← θ'') x∈Dom⟨θ←θ''⟩ ≡ var-vals {x} (θ' ← θ'') x∈Dom⟨θ'←θ''⟩ var-vals-←-both-irr' x θ θ' θ'' x∈ x∈' x∈Dom⟨θ←θ''⟩ x∈Dom⟨θ'←θ''⟩ θx≡θ'x = VarMap.get-U-both-irr-m x (Env.var θ) (Env.var θ') (Env.var θ'') x∈ x∈' x∈Dom⟨θ←θ''⟩ x∈Dom⟨θ'←θ''⟩ θx≡θ'x var-vals-←-both-irr : ∀ x θ θ' θ'' x∈ x∈' → var-vals {x} θ x∈ ≡ var-vals {x} θ' x∈' → ∃ λ x∈Dom⟨θ←θ''⟩ → ∃ λ x∈Dom⟨θ'←θ''⟩ → var-vals {x} (θ ← θ'') x∈Dom⟨θ←θ''⟩ ≡ var-vals {x} (θ' ← θ'') x∈Dom⟨θ'←θ''⟩ var-vals-←-both-irr x θ θ' θ'' x∈ x∈' θx≡θ'x = S∈Dom⟨θ←θ''⟩ , S∈Dom⟨θ'←θ''⟩ , VarMap.get-U-both-irr-m x (Env.var θ) (Env.var θ') (Env.var θ'') x∈ x∈' S∈Dom⟨θ←θ''⟩ S∈Dom⟨θ'←θ''⟩ θx≡θ'x where S∈Dom⟨θ←θ''⟩ = seq-←-monoˡ x θ θ'' x∈ S∈Dom⟨θ'←θ''⟩ = seq-←-monoˡ x θ' θ'' x∈' sig-putputget : ∀{S S' θ stat1 stat2} → ¬ S ≡ S' → (∈1 : SigMap.∈Dom S (sig θ)) → (∈S' : SigMap.∈Dom S' (sig θ)) → (∈2 : SigMap.∈Dom S (sig (set-sig{S'} θ ∈S' stat2))) → sig-stats{S} θ ∈1 ≡ stat1 → sig-stats{S} (set-sig{S'} θ ∈S' stat2) ∈2 ≡ stat1 sig-putputget {θ = θ} neq ∈1 ∈S' ∈2 eq = SigMap.putputget {m = (sig θ)} neq ∈1 ∈2 eq sig-putputget/m : ∀{S S' θ stat2} → ¬ S ≡ S' → (∈1 : SigMap.∈Dom S (sig θ)) → (∈S' : SigMap.∈Dom S' (sig θ)) → (∈2 : SigMap.∈Dom S (sig (set-sig{S'} θ ∈S' stat2))) → sig-stats{S} (set-sig{S'} θ ∈S' stat2) ∈2 ≡ sig-stats{S} θ ∈1 sig-putputget/m {S}{S'}{θ} neq ∈1 ∈S' ∈2 with sig-stats{S} θ ∈1 | inspect (sig-stats{S} θ) ∈1 sig-putputget/m {S} {S'} {θ} neq ∈1 ∈S' ∈2 | k | Relation.Binary.PropositionalEquality.[ eq ] = SigMap.putputget {m = (sig θ)} neq ∈1 ∈2 eq shr-putputget : ∀{s s' θ v1l v1r v2l v2r} → ¬ s ≡ s' → (∈1 : ShrMap.∈Dom s (shr θ)) → (∈s' : ShrMap.∈Dom s' (shr θ)) → (∈2 : ShrMap.∈Dom s (shr (set-shr{s'} θ ∈s' v2l v2r))) → shr-stats{s} θ ∈1 ≡ v1l → shr-vals{s} θ ∈1 ≡ v1r → (shr-stats{s} (set-shr{s'} θ ∈s' v2l v2r) ∈2) ≡ v1l × (shr-vals{s} (set-shr{s'} θ ∈s' v2l v2r) ∈2) ≡ v1r shr-putputget {θ = θ}{v1l}{v1r}{v2l}{v2r} neq ∈1 ∈S' ∈2 refl refl with ShrMap.putputget {m = (shr θ)}{v = (v1l ,′ v1r)}{(v2l ,′ v2r)} neq ∈1 ∈2 refl ... | res = (cong proj₁ res) ,′ (cong proj₂ res) seq-putputget : ∀{x x' θ v1 v2} → ¬ x ≡ x' → (∈1 : VarMap.∈Dom x (var θ)) → (∈x' : VarMap.∈Dom x' (var θ)) → (∈2 : VarMap.∈Dom x (var (set-var{x'} θ ∈x' v2))) → var-vals{x} θ ∈1 ≡ v1 → var-vals{x} (set-var{x'} θ ∈x' v2) ∈2 ≡ v1 seq-putputget {θ = θ} neq ∈1 ∈x' ∈2 eq = VarMap.putputget {m = (var θ)} neq ∈1 ∈2 eq sig-getput : ∀ {θ} S → (S∈ : isSig∈ S θ) → θ ≡ set-sig {S} θ S∈ (sig-stats {S} θ S∈) sig-getput {θ} S S∈ rewrite sym (SigMap.getput-m S (Env.sig θ) S∈) = refl shr-getput : ∀ {θ} s → (s∈ : isShr∈ s θ) → θ ≡ set-shr {s} θ s∈ (shr-stats {s} θ s∈) (shr-vals {s} θ s∈) shr-getput {θ} s s∈ rewrite sym (ShrMap.getput-m s (Env.shr θ) s∈) = refl var-getput : ∀ {θ} x → (x∈ : isVar∈ x θ) → θ ≡ set-var {x} θ x∈ (var-vals {x} θ x∈) var-getput {θ} x x∈ rewrite sym (VarMap.getput-m x (Env.var θ) x∈) = refl sig-putget : ∀{S θ stat} → (∈1 : SigMap.∈Dom S (sig θ)) → (∈2 : SigMap.∈Dom S (sig (set-sig{S} θ ∈1 stat))) → (sig-stats{S} (set-sig{S} θ ∈1 stat) ∈2) ≡ stat sig-putget {S}{θ}{stat} ∈1 ∈2 = SigMap.putget-m{_}{(sig θ)}{S}{stat} ∈2 shr-putget : ∀{s θ stat n} → (∈1 : ShrMap.∈Dom s (shr θ)) → (∈2 : ShrMap.∈Dom s (shr (set-shr{s} θ ∈1 stat n))) → (shr-stats{s} (set-shr{s} θ ∈1 stat n) ∈2) ≡ stat × (shr-vals{s} (set-shr{s} θ ∈1 stat n) ∈2) ≡ n shr-putget {s}{θ}{stat}{n} ∈1 ∈2 with ShrMap.putget-m{_}{(shr θ)}{s}{stat ,′ n} ∈2 ... | eq rewrite eq = refl , refl shr-putput-overwrite : ∀ s θ stat1 n1 stat2 n2 → (∈1 : (isShr∈ s θ)) → (∈2 : isShr∈ s (set-shr{s} θ ∈1 stat1 n1)) → (set-shr{s} (set-shr{s} θ ∈1 stat1 n1) ∈2 stat2 n2) ≡ (set-shr{s} θ ∈1 stat2 n2) shr-putput-overwrite s θ stat1 n1 stat2 n2 _ _ rewrite ShrMap.putput-overwrite (shr θ) s (stat1 ,′ n1) (stat2 ,′ n2) = refl sig-set-←-← : ∀ S v θ θ' → (S∈Domθ : isSig∈ S θ) → (S∈Domθ' : isSig∈ S θ') → θ ← θ' ≡ (set-sig {S} θ S∈Domθ v) ← θ' sig-set-←-← S v θ θ' S∈Domθ S∈Domθ' rewrite SigMap.update-union-union S v (Env.sig θ) (Env.sig θ') S∈Domθ S∈Domθ' = refl shr-set-←-← : ∀ s v n θ θ' → (s∈Domθ : isShr∈ s θ) → (s∈Domθ' : isShr∈ s θ') → θ ← θ' ≡ (set-shr {s} θ s∈Domθ v n) ← θ' shr-set-←-← s v n θ θ' s∈Domθ s∈Domθ' rewrite ShrMap.update-union-union s (v , n) (Env.shr θ) (Env.shr θ') s∈Domθ s∈Domθ' = refl var-set-←-← : ∀ x v θ θ' → (x∈Domθ : isVar∈ x θ) → (x∈Domθ' : isVar∈ x θ') → θ ← θ' ≡ (set-var {x} θ x∈Domθ v) ← θ' var-set-←-← x v θ θ' x∈Domθ x∈Domθ' rewrite VarMap.update-union-union x v (Env.var θ) (Env.var θ') x∈Domθ x∈Domθ' = refl sig∈-eq : ∀{S θ} → (∈1 : SigMap.∈Dom S (sig θ)) → (∈2 : SigMap.∈Dom S (sig θ)) → ∈1 ≡ ∈2 sig∈-eq {S}{θ} ∈1 ∈2 = SigMap.ineq-m{_}{S}{sig θ} ∈1 ∈2 shr∈-eq : ∀{s θ} → (∈1 : ShrMap.∈Dom s (shr θ)) → (∈2 : ShrMap.∈Dom s (shr θ)) → ∈1 ≡ ∈2 shr∈-eq {s}{θ} ∈1 ∈2 = ShrMap.ineq-m{_}{s}{shr θ} ∈1 ∈2 seq∈-eq : ∀{x θ} → (∈1 : VarMap.∈Dom x (var θ)) → (∈2 : VarMap.∈Dom x (var θ)) → ∈1 ≡ ∈2 seq∈-eq {x}{θ} ∈1 ∈2 = VarMap.ineq-m{_}{x}{var θ} ∈1 ∈2 sig∈-eq' : ∀{S θ} → (∈1 : SigMap.∈Dom{Signal.Status} S θ) → (∈2 : SigMap.∈Dom S θ) → ∈1 ≡ ∈2 sig∈-eq' {S}{θ} ∈1 ∈2 = SigMap.ineq-m{_}{S}{θ} ∈1 ∈2 shr∈-eq' : ∀{s θ} → (∈1 : ShrMap.∈Dom{(SharedVar.Status × ℕ)} s θ) → (∈2 : ShrMap.∈Dom s θ) → ∈1 ≡ ∈2 shr∈-eq' {s}{θ} ∈1 ∈2 = ShrMap.ineq-m{_}{s}{θ} ∈1 ∈2 seq∈-eq' : ∀{x : SeqVar} {θ : VarMap.Map ℕ} → (∈1 : VarMap.∈Dom{ℕ} x θ) → (∈2 : VarMap.∈Dom x θ) → ∈1 ≡ ∈2 seq∈-eq' {x}{θ} ∈1 ∈2 = VarMap.ineq-m{_}{x}{θ} ∈1 ∈2 sig-set-comm : ∀{θ S1 S2 stat1 stat2} → (S1∈ : isSig∈ S1 θ) → (S2∈ : isSig∈ S2 θ) → ¬ S1 ≡ S2 → ∃ λ S1∈' → ∃ λ S2∈' → (set-sig{S2} (set-sig{S1} θ S1∈ stat1) S2∈' stat2) ≡ (set-sig{S1} (set-sig{S2} θ S2∈ stat2) S1∈' stat1) sig-set-comm{θ}{S1}{S2}{stat1}{stat2} S1∈ S2∈ ¬S1≡S2 rewrite SigMap.put-comm{_}{sig θ}{S1}{S2}{stat1}{stat2} ¬S1≡S2 = sig-set-mono'{S1}{S2}{θ}{stat2}{S2∈} S1∈ , sig-set-mono'{S2}{S1}{θ}{S'∈ = S1∈} S2∈ , refl shr-set-comm : ∀ θ s1 s2 stat1 n1 stat2 n2 → (s1∈ : isShr∈ s1 θ) → (s2∈ : isShr∈ s2 θ) → ¬ s1 ≡ s2 → ∃ λ s1∈' → ∃ λ s2∈' → (set-shr{s2} (set-shr{s1} θ s1∈ stat1 n1) s2∈' stat2 n2) ≡ (set-shr{s1} (set-shr{s2} θ s2∈ stat2 n2) s1∈' stat1 n1) shr-set-comm θ s1 s2 stat1 n1 stat2 n2 s1∈ s2∈ ¬s1≡s2 rewrite ShrMap.put-comm{_}{shr θ}{s1}{s2}{stat1 , n1}{stat2 , n2} ¬s1≡s2 = shr-set-mono'{s1}{s2}{θ}{_}{_}{s2∈} s1∈ , shr-set-mono'{s2}{s1}{θ}{s'∈ = s1∈} s2∈ , refl seq-set-comm : ∀ θ x1 x2 n1 n2 → (x1∈ : isVar∈ x1 θ) → (x2∈ : isVar∈ x2 θ) → ¬ x1 ≡ x2 → ∃ λ x1∈' → ∃ λ x2∈' → (set-var{x2} (set-var{x1} θ x1∈ n1) x2∈' n2) ≡ (set-var{x1} (set-var{x2} θ x2∈ n2) x1∈' n1) seq-set-comm θ x1 x2 n1 n2 x1∈ x2∈ ¬x1≡x2 rewrite VarMap.put-comm{_}{var θ}{x1}{x2}{n1}{n2} ¬x1≡x2 = seq-set-mono'{x1}{x2}{θ}{n2}{x2∈} x1∈ , seq-set-mono'{x2}{x1}{θ}{x'∈ = x1∈} x2∈ , refl sig-←-irr-get : ∀ {θ₁ θ₂ S} → (S∈Domθ₁ : isSig∈ S θ₁) → ¬ (isSig∈ S θ₂) → ∃ λ S∈Dom⟨θ₁←θ₂⟩ → sig-stats {S} θ₁ S∈Domθ₁ ≡ sig-stats {S} (θ₁ ← θ₂) S∈Dom⟨θ₁←θ₂⟩ sig-←-irr-get {θ₁@(Θ Ss _ _)} {θ₂@(Θ Ss' _ _)} {S} S∈Domθ₁ S∉Domθ₂ with SigMap.U-∉-irr-get-m {_} {Ss} {Ss'} {S} S∈Domθ₁ S∉Domθ₂ ... | a , b rewrite b = a , refl shr-←-irr-get : ∀ {θ₁ θ₂ s} → (s∈Domθ₁ : isShr∈ s θ₁) → ¬ (isShr∈ s θ₂) → ∃ λ s∈Dom⟨θ₁←θ₂⟩ → shr-stats {s} θ₁ s∈Domθ₁ ≡ shr-stats {s} (θ₁ ← θ₂) s∈Dom⟨θ₁←θ₂⟩ shr-←-irr-get {θ₁@(Θ _ ss _)} {θ₂@(Θ _ ss' _)} {s} s∈Domθ₁ s∉Domθ₂ with ShrMap.U-∉-irr-get-m {_} {ss} {ss'} {s} s∈Domθ₁ s∉Domθ₂ ... | a , b rewrite b = a , refl seq-←-irr-get : ∀ {θ₁ θ₂ x} → (x∈Domθ₁ : isVar∈ x θ₁) → ¬ (isVar∈ x θ₂) → ∃ λ x∈Dom⟨θ₁←θ₂⟩ → var-vals {x} θ₁ x∈Domθ₁ ≡ var-vals {x} (θ₁ ← θ₂) x∈Dom⟨θ₁←θ₂⟩ seq-←-irr-get {θ₁@(Θ _ _ xs)} {θ₂@(Θ _ _ xs')} {x} x∈Domθ₁ x∉Domθ₂ with VarMap.U-∉-irr-get-m {_} {xs} {xs'} {x} x∈Domθ₁ x∉Domθ₂ ... | a , b rewrite b = a , refl sig-←-irr-get' : ∀ {θ₁ θ₂ S} → (S∈Domθ₁ : isSig∈ S θ₁) → ¬ (isSig∈ S θ₂) → (S∈Dom⟨θ₁←θ₂⟩ : isSig∈ S (θ₁ ← θ₂)) → sig-stats {S} θ₁ S∈Domθ₁ ≡ sig-stats {S} (θ₁ ← θ₂) S∈Dom⟨θ₁←θ₂⟩ sig-←-irr-get' {θ₁@(Θ Ss _ _)} {θ₂@(Θ Ss' _ _)} {S} S∈Domθ₁ S∉Domθ₂ S∈Dom⟨θ₁←θ₂⟩ with SigMap.U-∉-irr-get-m {_} {Ss} {Ss'} {S} S∈Domθ₁ S∉Domθ₂ ... | a , b rewrite b | sig∈-eq{S}{θ₁ ← θ₂} a S∈Dom⟨θ₁←θ₂⟩ = refl shr-←-irr-get' : ∀ {θ₁ θ₂ s} → (s∈Domθ₁ : isShr∈ s θ₁) → ¬ (isShr∈ s θ₂) → (s∈Dom⟨θ₁←θ₂⟩ : isShr∈ s (θ₁ ← θ₂)) → shr-stats {s} θ₁ s∈Domθ₁ ≡ shr-stats {s} (θ₁ ← θ₂) s∈Dom⟨θ₁←θ₂⟩ shr-←-irr-get' {θ₁@(Θ _ ss _)} {θ₂@(Θ _ ss' _)} {s} s∈Domθ₁ s∉Domθ₂ s∈Dom⟨θ₁←θ₂⟩ with ShrMap.U-∉-irr-get-m {_} {ss} {ss'} {s} s∈Domθ₁ s∉Domθ₂ ... | a , b rewrite (cong proj₁ b) | shr∈-eq{s}{θ₁ ← θ₂} a s∈Dom⟨θ₁←θ₂⟩ = refl shr-←-irr-get/vals' : ∀ {θ₁ θ₂ s} → (s∈Domθ₁ : isShr∈ s θ₁) → ¬ (isShr∈ s θ₂) → (s∈Dom⟨θ₁←θ₂⟩ : isShr∈ s (θ₁ ← θ₂)) → shr-vals {s} θ₁ s∈Domθ₁ ≡ shr-vals {s} (θ₁ ← θ₂) s∈Dom⟨θ₁←θ₂⟩ shr-←-irr-get/vals' {θ₁@(Θ _ ss _)} {θ₂@(Θ _ ss' _)} {s} s∈Domθ₁ s∉Domθ₂ s∈Dom⟨θ₁←θ₂⟩ with ShrMap.U-∉-irr-get-m {_} {ss} {ss'} {s} s∈Domθ₁ s∉Domθ₂ ... | a , b rewrite (cong proj₂ b) | shr∈-eq{s}{θ₁ ← θ₂} a s∈Dom⟨θ₁←θ₂⟩ = refl seq-←-irr-get' : ∀ {θ₁ θ₂ x} → (x∈Domθ₁ : isVar∈ x θ₁) → ¬ (isVar∈ x θ₂) → (x∈Dom⟨θ₁←θ₂⟩ : isVar∈ x (θ₁ ← θ₂)) → var-vals {x} θ₁ x∈Domθ₁ ≡ var-vals {x} (θ₁ ← θ₂) x∈Dom⟨θ₁←θ₂⟩ seq-←-irr-get' {θ₁@(Θ _ _ xs)} {θ₂@(Θ _ _ xs')} {x} x∈Domθ₁ x∉Domθ₂ x∈Dom⟨θ₁←θ₂⟩ with VarMap.U-∉-irr-get-m {_} {xs} {xs'} {x} x∈Domθ₁ x∉Domθ₂ ... | a , b rewrite b | seq∈-eq{x}{θ₁ ← θ₂} a x∈Dom⟨θ₁←θ₂⟩ = refl sig-set-←-comm' : ∀ S v θ θ' → (S∈ : isSig∈ S θ) → ¬ (isSig∈ S θ') → (S∈' : isSig∈ S (θ ← θ')) → (set-sig {S} θ S∈ v) ← θ' ≡ set-sig {S} (θ ← θ') S∈' v sig-set-←-comm' S v θ θ' S∈ S∉Domθ' S∈' rewrite SigMap.put-union-comm {_} S v (Env.sig θ) (Env.sig θ') S∉Domθ' = refl sig-set-←-comm : ∀ S v θ θ' → (S∈ : isSig∈ S θ) → ¬ (isSig∈ S θ') → ∃ λ S∈Dom⟨θ←θ'⟩ → (set-sig {S} θ S∈ v) ← θ' ≡ set-sig {S} (θ ← θ') S∈Dom⟨θ←θ'⟩ v sig-set-←-comm S v θ θ' S∈ S∉Domθ' rewrite SigMap.put-union-comm {_} S v (Env.sig θ) (Env.sig θ') S∉Domθ' = SigMap.U-mono {_} {Env.sig θ} {Env.sig θ'} {S} S∈ , refl shr-set-←-comm' : ∀ s v n θ θ' → (s∈ : isShr∈ s θ) → ¬ (isShr∈ s θ') → (s∈' : isShr∈ s (θ ← θ')) → (set-shr {s} θ s∈ v n) ← θ' ≡ set-shr {s} (θ ← θ') s∈' v n shr-set-←-comm' s v n θ θ' s∈ s∉Domθ' s∈' rewrite ShrMap.put-union-comm {_} s (v , n) (Env.shr θ) (Env.shr θ') s∉Domθ' = refl shr-set-←-comm : ∀ s v n θ θ' → (s∈ : isShr∈ s θ) → ¬ (isShr∈ s θ') → ∃ λ s∈Dom⟨θ←θ'⟩ → (set-shr {s} θ s∈ v n) ← θ' ≡ set-shr {s} (θ ← θ') s∈Dom⟨θ←θ'⟩ v n shr-set-←-comm s v n θ θ' s∈ s∉Domθ' rewrite ShrMap.put-union-comm {_} s (v , n) (Env.shr θ) (Env.shr θ') s∉Domθ' = ShrMap.U-mono {_} {Env.shr θ} {Env.shr θ'} {s} s∈ , refl var-set-←-comm' : ∀ x v θ θ' → (x∈ : isVar∈ x θ) → ¬ (isVar∈ x θ') → (x∈' : isVar∈ x (θ ← θ')) → (set-var {x} θ x∈ v) ← θ' ≡ set-var {x} (θ ← θ') x∈' v var-set-←-comm' x v θ θ' x∈ x∉Domθ' x∈' rewrite VarMap.put-union-comm {_} x v (Env.var θ) (Env.var θ') x∉Domθ' = refl var-set-←-comm : ∀ x v θ θ' → (x∈ : isVar∈ x θ) → ¬ (isVar∈ x θ') → ∃ λ x∈Dom⟨θ←θ'⟩ → (set-var {x} θ x∈ v) ← θ' ≡ set-var {x} (θ ← θ') x∈Dom⟨θ←θ'⟩ v var-set-←-comm x v θ θ' x∈ x∉Domθ' rewrite VarMap.put-union-comm {_} x v (Env.var θ) (Env.var θ') x∉Domθ' = VarMap.U-mono {_} {Env.var θ} {Env.var θ'} {x} x∈ , refl lookup-S-eq : ∀{a b} θ S S∈ S∈₁ → sig-stats{S = S} θ S∈ ≡ a → sig-stats{S = S} θ S∈₁ ≡ b → ¬ a ≡ b → ⊥ lookup-S-eq θ S S∈ S∈' eq1 eq2 neg rewrite sig∈-eq{S}{θ} S∈ S∈' = neg (trans (sym eq1) eq2) lookup-s-eq : ∀{a b} θ s s∈ s∈₁ → shr-stats{s = s} θ s∈ ≡ a → shr-stats{s = s} θ s∈₁ ≡ b → ¬ a ≡ b → ⊥ lookup-s-eq θ s s∈ s∈' eq1 eq2 neg rewrite shr∈-eq{s}{θ} s∈ s∈' = neg (trans (sym eq1) eq2) lookup-S-¬eq : ∀{a b} θ S S' S∈ S'∈ → sig-stats{S = S} θ S∈ ≡ a → sig-stats{S = S'} θ S'∈ ≡ b → ¬ a ≡ b → ¬ S ≡ S' lookup-S-¬eq θ S S' S∈ S'∈ S≡ S'≡ a≠b with S Signal.≟ S' ... | yes refl = ⊥-elim (lookup-S-eq θ S S∈ S'∈ S≡ S'≡ a≠b) ... | no x = x lookup-s-stat-¬eq : ∀{a b} θ s s' s∈ s'∈ → shr-stats{s = s} θ s∈ ≡ a → shr-stats{s = s'} θ s'∈ ≡ b → ¬ a ≡ b → ¬ s ≡ s' lookup-s-stat-¬eq θ s s' s∈ s'∈ s≡ s'≡ a≠b with s SharedVar.≟ s' ... | yes refl = ⊥-elim (lookup-s-eq θ s s∈ s'∈ s≡ s'≡ a≠b) ... | no x = x ←-=-irr-S : ∀ θ θ' → (Dom θ) ≡ (Dom θ') → ∀ S → (S∈ : isSig∈ S (θ ← θ')) → (S∈2 : isSig∈ S θ') → sig-stats{S} (θ ← θ') S∈ ≡ sig-stats{S} θ' S∈2 ←-=-irr-S θ θ' eq = SigMap.union-=-irr (sig θ) (sig θ') (cong proj₁ eq) ←-=-irr-s-stats : ∀ θ θ' → (Dom θ) ≡ (Dom θ') → ∀ s → (s∈ : isShr∈ s (θ ← θ')) → (s∈2 : isShr∈ s θ') → shr-stats{s} (θ ← θ') s∈ ≡ shr-stats{s} θ' s∈2 ←-=-irr-s-stats θ θ' eq a b = (cong proj₁) ∘ (ShrMap.union-=-irr (shr θ) (shr θ') (cong (proj₁ ∘ proj₂) eq) a b) ←-=-irr-s-vals : ∀ θ θ' → (Dom θ) ≡ (Dom θ') → ∀ s → (s∈ : isShr∈ s (θ ← θ')) → (s∈2 : isShr∈ s θ') → shr-vals{s} (θ ← θ') s∈ ≡ shr-vals{s} θ' s∈2 ←-=-irr-s-vals θ θ' eq a b = (cong proj₂) ∘ (ShrMap.union-=-irr (shr θ) (shr θ') (cong (proj₁ ∘ proj₂) eq) a b) ←-=-irr-x : ∀ θ θ' → (Dom θ) ≡ (Dom θ') → ∀ x → (x∈ : isVar∈ x (θ ← θ')) → (x∈2 : isVar∈ x θ') → var-vals{x} (θ ← θ') x∈ ≡ var-vals{x} θ' x∈2 ←-=-irr-x θ θ' eq = (VarMap.union-=-irr (var θ) (var θ') (cong (proj₂ ∘ proj₂) eq)) ←-single-overwrite-sig : ∀ S stat θ → isSig∈ S θ → ((Θ SigMap.[ S ↦ stat ] [] []) ← θ) ≡ θ ←-single-overwrite-sig S stat θ k∈ rewrite SigMap.single-val-overwrite S stat (sig θ) k∈ = refl ←-single-overwrite-shr : ∀ s stat v θ → isShr∈ s θ → ((Θ [] ShrMap.[ s ↦ (stat ,′ v) ] []) ← θ) ≡ θ ←-single-overwrite-shr s stat v θ k∈ rewrite ShrMap.single-val-overwrite s (stat ,′ v) (shr θ) k∈ = refl ←-single-overwrite-seq : ∀ x n θ → isVar∈ x θ → ((Θ [] [] VarMap.[ x ↦ n ]) ← θ) ≡ θ ←-single-overwrite-seq x n θ k∈ rewrite VarMap.single-val-overwrite x n (var θ) k∈ = refl sig-set=← : ∀ θ S stat → (S∈ : isSig∈ S θ) → (set-sig{S = S} θ S∈ stat) ≡ (θ ← (Θ SigMap.[ S ↦ stat ] [] [])) sig-set=← θ S stat S∈ rewrite SigMap.union-insert-eq S stat (sig θ) | ShrMap.union-comm (shr θ) [] (λ z _ → λ ()) | VarMap.union-comm (var θ) [] (λ z _ → λ ()) = refl shr-set=← : ∀ θ s stat n → (s∈ : isShr∈ s θ) → (set-shr{s = s} θ s∈ stat n) ≡ (θ ← (Θ [] ShrMap.[ s ↦ (stat ,′ n) ] [])) shr-set=← θ s stat n s∈ rewrite ShrMap.union-insert-eq s (stat ,′ n) (shr θ) | SigMap.union-comm (sig θ) [] (λ z _ → λ ()) | VarMap.union-comm (var θ) [] (λ z _ → λ ()) = refl seq-set=← : ∀ θ x n → (x∈ : isVar∈ x θ) → (set-var{x = x} θ x∈ n) ≡ (θ ← (Θ [] [] VarMap.[ x ↦ n ])) seq-set=← θ x n x∈ rewrite VarMap.union-insert-eq x n (var θ) | SigMap.union-comm (sig θ) [] (λ z _ → λ ()) | ShrMap.union-comm (shr θ) [] (λ z _ → λ ()) = refl sig-set-clobber : ∀ S stat θ θi S∈ → isSig∈ S θi → (set-sig{S = S} θ S∈ stat) ← θi ≡ θ ← θi sig-set-clobber S stat θ θi S∈θ S∈θi = (set-sig{S = S} θ S∈θ stat) ← θi ≡⟨ cong (_← θi)(sig-set=← θ S stat S∈θ) ⟩ (θ ← θ2) ← θi ≡⟨ sym (←-assoc θ θ2 θi) ⟩ (θ ← (θ2 ← θi)) ≡⟨ cong (θ ←_) (←-single-overwrite-sig S stat θi S∈θi) ⟩ (θ ← θi) ∎ where θ2 = Θ SigMap.[ S ↦ stat ] [] [] shr-set-clobber : ∀ v stat n θ θi v∈ → isShr∈ v θi → (set-shr{s = v} θ v∈ stat n) ← θi ≡ θ ← θi shr-set-clobber v stat n θ θi v∈θ v∈θi = (set-shr{s = v} θ v∈θ stat n) ← θi ≡⟨ cong (_← θi) (shr-set=← θ v stat n v∈θ) ⟩ (θ ← θ2) ← θi ≡⟨ sym (←-assoc θ θ2 θi) ⟩ (θ ← (θ2 ← θi)) ≡⟨ cong (θ ←_) (←-single-overwrite-shr v stat n θi v∈θi) ⟩ (θ ← θi) ∎ where θ2 = Θ [] ShrMap.[ v ↦ (stat ,′ n) ] [] seq-set-clobber : ∀ v n θ θi v∈ → isVar∈ v θi → (set-var{x = v} θ v∈ n) ← θi ≡ θ ← θi seq-set-clobber v n θ θi v∈θ v∈θi = (set-var{x = v} θ v∈θ n) ← θi ≡⟨ cong (_← θi) (seq-set=← θ v n v∈θ) ⟩ (θ ← θ2) ← θi ≡⟨ sym (←-assoc θ θ2 θi) ⟩ (θ ← (θ2 ← θi)) ≡⟨ cong (θ ←_) (←-single-overwrite-seq v n θi v∈θi) ⟩ (θ ← θi) ∎ where θ2 = Θ [] [] VarMap.[ v ↦ n ] sig-switch : ∀ S stat θ θi S∈ S∈2 → ¬ isSig∈ S θi → set-sig{S = S} (θ ← θi) S∈2 stat ≡ (set-sig{S = S} θ S∈ stat) ← θi sig-switch S stat θ θi S∈ S∈2 S∉ = set-sig{S = S} (θ ← θi) S∈2 stat ≡⟨ sig-set=← (θ ← θi) S stat S∈2 ⟩ (θ ← θi) ← θ2 ≡⟨ ←-assoc-comm θ θi θ2 ((λ z x x₁ → S∉ (subst (_∈ (SigMap.keys (sig θi))) (∈:: (subst (z ∈_) (SigMap.keys-1map S stat) x₁)) x)) , ((λ x x₁ → λ ()) , (λ x x₁ → λ ()))) ⟩ (θ ← θ2) ← θi ≡⟨ cong (_← θi) (sym (sig-set=← θ S stat S∈ )) ⟩ (set-sig{S = S} θ S∈ stat) ← θi ∎ where θ2 = Θ SigMap.[ S ↦ stat ] [] [] shr-switch : ∀ s stat n θ θi s∈ s∈2 → ¬ isShr∈ s θi → set-shr{s = s} (θ ← θi) s∈2 stat n ≡ (set-shr{s = s} θ s∈ stat n) ← θi shr-switch s stat n θ θi s∈ s∈2 s∉ = set-shr{s = s} (θ ← θi) s∈2 stat n ≡⟨ shr-set=← (θ ← θi) s stat n s∈2 ⟩ (θ ← θi) ← θ2 ≡⟨ ←-assoc-comm θ θi θ2 ((λ x x₁ → λ ()) , ((λ z x x₁ → s∉ (subst (_∈ (ShrMap.keys (shr θi))) (∈:: (subst (z ∈_) (ShrMap.keys-1map s (stat ,′ n)) x₁)) x)) , (λ x x₁ → λ ()))) ⟩ (θ ← θ2) ← θi ≡⟨ cong (_← θi) (sym (shr-set=← θ s stat n s∈ )) ⟩ (set-shr{s = s} θ s∈ stat n) ← θi ∎ where θ2 = Θ [] ShrMap.[ s ↦ (stat ,′ n) ] [] seq-switch : ∀ x n θ θi x∈ x∈2 → ¬ isVar∈ x θi → set-var{x = x} (θ ← θi) x∈2 n ≡ (set-var{x = x} θ x∈ n) ← θi seq-switch x n θ θi x∈ x∈2 x∉ = set-var{x = x} (θ ← θi) x∈2 n ≡⟨ seq-set=← (θ ← θi) x n x∈2 ⟩ (θ ← θi) ← θ2 ≡⟨ ←-assoc-comm θ θi θ2 ((λ x x₁ → λ ()) , ((λ x x₁ → λ ()) , (λ z j x₁ → x∉ (subst (_∈ (VarMap.keys (var θi))) (∈:: (subst (z ∈_) (VarMap.keys-1map x n) x₁)) j)))) ⟩ (θ ← θ2) ← θi ≡⟨ cong (_← θi) (sym (seq-set=← θ x n x∈ )) ⟩ (set-var{x = x} θ x∈ n) ← θi ∎ where θ2 = Θ [] [] VarMap.[ x ↦ n ] sig-switch-right : ∀ S stat θl θr S∈ S∈2 → (θl ← (set-sig{S} θr S∈ stat)) ≡ (set-sig{S} (θl ← θr) S∈2 stat) sig-switch-right S stat θl θr S∈ S∈2 = (θl ← (set-sig{S} θr S∈ stat)) ≡⟨ cong (θl ←_) (sig-set=← θr S stat S∈) ⟩ (θl ← (θr ← (Θ SigMap.[ S ↦ stat ] [] []))) ≡⟨ ←-assoc θl θr _ ⟩ ((θl ← θr) ← (Θ SigMap.[ S ↦ stat ] [] [])) ≡⟨ sym (sig-set=← (θl ← θr) S stat S∈2) ⟩ (set-sig{S} (θl ← θr) S∈2 stat) ∎ shr-switch-right : ∀ s stat n θl θr s∈ s∈2 → (θl ← (set-shr{s} θr s∈ stat n)) ≡ (set-shr{s} (θl ← θr) s∈2 stat n) shr-switch-right s stat n θl θr s∈ s∈2 = (θl ← (set-shr{s} θr s∈ stat n)) ≡⟨ cong (θl ←_) (shr-set=← θr s stat n s∈) ⟩ (θl ← (θr ← (Θ [] ShrMap.[ s ↦ (stat ,′ n) ] []))) ≡⟨ ←-assoc θl θr _ ⟩ ((θl ← θr) ← (Θ [] ShrMap.[ s ↦ (stat ,′ n) ] [])) ≡⟨ sym (shr-set=← (θl ← θr) s stat n s∈2) ⟩ (set-shr{s} (θl ← θr) s∈2 stat n) ∎ seq-switch-right : ∀ x n θl θr x∈ x∈2 → (θl ← (set-var{x} θr x∈ n)) ≡ (set-var{x} (θl ← θr) x∈2 n) seq-switch-right x n θl θr x∈ x∈2 = (θl ← (set-var{x} θr x∈ n)) ≡⟨ cong (θl ←_) (seq-set=← θr x n x∈) ⟩ (θl ← (θr ← (Θ [] [] VarMap.[ x ↦ n ]))) ≡⟨ ←-assoc θl θr _ ⟩ ((θl ← θr) ← (Θ [] [] VarMap.[ x ↦ n ])) ≡⟨ sym (seq-set=← (θl ← θr) x n x∈2) ⟩ (set-var{x} (θl ← θr) x∈2 n) ∎ sig-set-dom-eq : ∀ S stat θ S∈ → (Dom θ) ≡ (Dom (set-sig{S = S} θ S∈ stat)) sig-set-dom-eq S stat θ S∈ rewrite SigMap.update-domain-eq S stat (sig θ) S∈ = refl shr-set-dom-eq : ∀ s stat n θ s∈ → (Dom θ) ≡ (Dom (set-shr{s = s} θ s∈ stat n)) shr-set-dom-eq s stat n θ s∈ rewrite ShrMap.update-domain-eq s (stat ,′ n) (shr θ) s∈ = refl seq-set-dom-eq : ∀ x n θ x∈ → (Dom θ) ≡ (Dom (set-var{x = x} θ x∈ n)) seq-set-dom-eq x n θ x∈ rewrite VarMap.update-domain-eq x n (var θ) x∈ = refl sig-∉-maint : ∀ S S' stat θ S'∈ → ¬ isSig∈ S θ → ¬ isSig∈ S (set-sig{S = S'} θ S'∈ stat) sig-∉-maint S S' stat θ S'∈ S∉ x rewrite cong proj₁ (sig-set-dom-eq S' stat θ S'∈) = S∉ x shr-∉-maint : ∀ s s' stat n θ s'∈ → ¬ isShr∈ s θ → ¬ isShr∈ s (set-shr{s = s'} θ s'∈ stat n) shr-∉-maint s s' stat n θ s'∈ s∉ x rewrite cong snd (shr-set-dom-eq s' stat n θ s'∈) = s∉ x sig-∉-single : ∀ S S' stat → ¬ S ≡ S' → ¬ isSig∈ S (Θ SigMap.[ S' ↦ stat ] [] []) sig-∉-single S S' stat neg x rewrite SigMap.keys-1map S' stat with x ... | Any.here px = (Signal.unwrap-neq neg) px ... | Any.there () shr-∉-single : ∀ s s' stat n → ¬ s ≡ s' → ¬ isShr∈ s (Θ [] ShrMap.[ s' ↦ (stat ,′ n) ] []) shr-∉-single s s' stat n neg x rewrite ShrMap.keys-1map s' (stat ,′ n) with x ... | Any.here px = (SharedVar.unwrap-neq neg) px ... | Any.there () sig-∈-single : ∀ S stat → isSig∈ S (Θ SigMap.[ S ↦ stat ] [] []) sig-∈-single S stat rewrite SigMap.keys-1map S stat = Data.List.Any.here refl sig-∈-single-right-← : ∀ S stat θ → isSig∈ S (θ ← (Θ SigMap.[ S ↦ stat ] [] [])) sig-∈-single-right-← S stat θ = sig-←-monoʳ S (Θ SigMap.[ S ↦ stat ] [] []) θ (sig-∈-single S stat) shr-∈-single : ∀ s stat n → isShr∈ s (Θ [] ShrMap.[ s ↦ (stat ,′ n) ] []) shr-∈-single s stat n rewrite ShrMap.keys-1map s (stat ,′ n) = Data.List.Any.here refl sig-single-∈-eq : ∀ S S' stat' → isSig∈ S (Θ SigMap.[ S' ↦ stat' ] [] []) → Signal.unwrap S ≡ Signal.unwrap S' sig-single-∈-eq S S' stat' S∈Dom[S'] rewrite SigMap.keys-1map S' stat' = ∈:: S∈Dom[S'] sig-put-mby-overwrite : ∀ S S' θ statneq statput S∈ S'∈ S∈2 → ¬ statneq ≡ statput → ¬ (sig-stats{S} θ S∈ ≡ statneq) → ¬ (sig-stats{S} (set-sig{S'} θ S'∈ statput) S∈2 ≡ statneq) sig-put-mby-overwrite S S' θ statneq statput S∈ S'∈ S∈2 neq≠put ¬ref ref with S Signal.≟ S' ... | yes refl = lookup-S-eq (set-sig{S} θ S'∈ statput) S S∈2 S∈2 (sig-putget{S}{θ}{statput} S'∈ S∈2) ref (neq≠put ∘ sym) ... | no ¬refl = ¬ref (trans (sym (sig-putputget/m{S}{S'}{θ} ¬refl S∈ S'∈ S∈2)) ref) sig-stats-1map' : ∀ S status → (S∈ : isSig∈ S (Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty)) → sig-stats {S} (Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty) S∈ ≡ status sig-stats-1map' S status S∈ = SigMap.putget-m {_} {SigMap.empty} {S} {status} S∈ sig-stats-1map-right-← : ∀ S status θ → (S∈ : isSig∈ S (θ ← (Θ SigMap.[ S ↦ status ] [] []))) → (sig-stats{S} (θ ← (Θ SigMap.[ S ↦ status ] [] [])) S∈ ≡ status) sig-stats-1map-right-← S stat θ S∈ = trans (sig-stats-←-right-irr' S θ (Θ SigMap.[ S ↦ stat ] [] []) (sig-∈-single S stat) S∈) (sig-stats-1map' S stat (sig-∈-single S stat)) sig-put-1map-overwrite' : ∀ S status status' → (S∈ : isSig∈ S (Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty)) → set-sig {S} (Θ SigMap.[ S ↦ status ] ShrMap.empty VarMap.empty) S∈ status' ≡ Θ SigMap.[ S ↦ status' ] ShrMap.empty VarMap.empty sig-put-1map-overwrite' S status status' S∈ rewrite SigMap.putput-overwrite SigMap.empty S status status' = refl -- ←-comm : ∀ θ θ' → distinct (Dom θ) (Dom θ') → (θ ← θ') ≡ (θ' ← θ) sig-set-inner-clobber : ∀ θ θ' θ'' S stat → isSig∈ S θ'' → ((θ ← (Θ SigMap.[ S ↦ stat ] [] [])) ← θ') ← θ'' ≡ ((θ ← θ') ← θ'') sig-set-inner-clobber θ θ' θ'' S stat S∈θ'' with Sig∈ S θ' ... | yes S∈θ' = (((θ ← (Θ SigMap.[ S ↦ stat ] [] [])) ← θ') ← θ'') ≡⟨ cong (λ x → (x ← θ'')) (sym (←-assoc θ (Θ SigMap.[ S ↦ stat ] [] []) θ')) ⟩ ((θ ← ((Θ SigMap.[ S ↦ stat ] [] []) ← θ')) ← θ'') ≡⟨ cong (λ x → (θ ← x) ← θ'' ) (←-single-overwrite-sig S stat (Θ (sig θ') (shr θ') (var θ')) S∈θ') ⟩ ((θ ← θ') ← θ'') ∎ ... | no S∉θ' = (((θ ← (Θ SigMap.[ S ↦ stat ] [] [])) ← θ') ← θ'') ≡⟨ cong (λ x → (x ← θ'')) (sym (←-assoc θ (Θ SigMap.[ S ↦ stat ] [] []) θ')) ⟩ ((θ ← ((Θ SigMap.[ S ↦ stat ] [] []) ← θ')) ← θ'') ≡⟨ cong (λ x → (θ ← x) ← θ'' ) ( ←-comm (Θ SigMap.[ S ↦ stat ] [] []) θ' (ds , ((λ z → λ ()) , (λ z → λ ())))) ⟩ ((θ ← (θ' ← (Θ SigMap.[ S ↦ stat ] [] []))) ← θ'') ≡⟨ cong (_← θ'') (←-assoc θ θ' (Θ SigMap.[ S ↦ stat ] [] [])) ⟩ (((θ ← θ') ← (Θ SigMap.[ S ↦ stat ] [] [])) ← θ'') ≡⟨ sym (←-assoc (θ ← θ') (Θ SigMap.[ S ↦ stat ] [] []) θ'') ⟩ ((θ ← θ') ← ((Θ SigMap.[ S ↦ stat ] [] []) ← θ'')) ≡⟨ cong ((θ ← θ') ←_) (←-single-overwrite-sig S stat (Θ (sig θ'') (shr θ'') (var θ'')) S∈θ'') ⟩ ((θ ← θ') ← θ'') ∎ where ds : distinct' (proj₁ (Dom (Θ SigMap.[ S ↦ stat ] [] []))) (proj₁ (Dom θ')) ds z x y rewrite SigMap.keys-1map S stat with x ... | Any.here refl = ⊥-elim (S∉θ' y) ... | Any.there () sig-single-notin-distinct : ∀ S status θ → Signal.unwrap S ∉ proj₁ (Dom θ) → distinct (Dom (Θ SigMap.[ S ↦ status ] [] [])) (Dom θ) sig-single-notin-distinct S status θ S∉Domθ = (λ S'' S''∈[S] S''∈Domθ → S∉Domθ (subst (_∈ proj₁ (Dom θ)) (∈:: (subst (S'' ∈_) (SigMap.keys-1map S status) S''∈[S])) S''∈Domθ)) ,′ (λ _ ()) ,′ (λ _ ()) -- a special case of sig-single-notin-distinct sig-single-noteq-distinct : ∀ S status S' status' → ¬ Signal.unwrap S ≡ Signal.unwrap S' → distinct (Dom (Θ SigMap.[ S ↦ status ] [] [])) (Dom (Θ SigMap.[ S' ↦ status' ] [] [])) sig-single-noteq-distinct S status S' status' S≢S' = (λ S'' S''∈[S] S''∈[S'] → S≢S' (trans (sym (∈:: (subst (S'' ∈_) (SigMap.keys-1map S status) S''∈[S]))) (∈:: (subst (S'' ∈_) (SigMap.keys-1map S' status') S''∈[S'])))) ,′ (λ _ ()) ,′ (λ _ ()) sig-single-←-←-overwrite : ∀ θ S status status' → (θ ← Θ SigMap.[ S ↦ status ] [] []) ← Θ SigMap.[ S ↦ status' ] [] [] ≡ θ ← Θ SigMap.[ S ↦ status' ] [] [] sig-single-←-←-overwrite θ S status status' rewrite sym (←-assoc θ (Θ SigMap.[ S ↦ status ] [] []) (Θ SigMap.[ S ↦ status' ] [] [])) = cong (θ ←_) (←-single-overwrite-sig S status (Θ SigMap.[ S ↦ status' ] [] []) (sig-∈-single S status')) sig-set-clobber-single-as-← : ∀ S status status' θ S∈ → (set-sig{S} (θ ← (Θ SigMap.[ S ↦ status' ] [] [])) S∈ status) ≡ (θ ← (Θ SigMap.[ S ↦ status ] [] [])) sig-set-clobber-single-as-← S status status' θ S∈ =(begin (set-sig{S} (θ ← θs1) ((sig-∈-single-right-← S status' θ)) status) ≡⟨ sym (sig-switch-right S status θ θs1 ((sig-∈-single S status')) ((sig-∈-single-right-← S status' θ))) ⟩ (θ ← (set-sig{S} θs1 ((sig-∈-single S status')) status)) ≡⟨ cong (_←_ θ) (sig-put-1map-overwrite' S status' status ((sig-∈-single S status'))) ⟩ (θ ← θs2) ∎) where θs1 = (Θ SigMap.[ S ↦ status' ] [] []) θs2 = (Θ SigMap.[ S ↦ status ] [] [])
algebraic-stack_agda0000_doc_5291
{-# OPTIONS --safe #-} module Cubical.Algebra.DistLattice.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint 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.Displayed.Base open import Cubical.Displayed.Auto open import Cubical.Displayed.Record open import Cubical.Displayed.Universe open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open import Cubical.Algebra.CommMonoid open import Cubical.Algebra.Semilattice open import Cubical.Algebra.Lattice.Base open Iso private variable ℓ ℓ' : Level record IsDistLattice {L : Type ℓ} (0l 1l : L) (_∨l_ _∧l_ : L → L → L) : Type ℓ where constructor isdistlattice field isLattice : IsLattice 0l 1l _∨l_ _∧l_ ∨l-dist-∧l : (x y z : L) → (x ∨l (y ∧l z) ≡ (x ∨l y) ∧l (x ∨l z)) × ((y ∧l z) ∨l x ≡ (y ∨l x) ∧l (z ∨l x)) ∧l-dist-∨l : (x y z : L) → (x ∧l (y ∨l z) ≡ (x ∧l y) ∨l (x ∧l z)) × ((y ∨l z) ∧l x ≡ (y ∧l x) ∨l (z ∧l x)) open IsLattice isLattice public ∨lLdist∧l : (x y z : L) → x ∨l (y ∧l z) ≡ (x ∨l y) ∧l (x ∨l z) ∨lLdist∧l x y z = ∨l-dist-∧l x y z .fst ∨lRdist∧l : (x y z : L) → (y ∧l z) ∨l x ≡ (y ∨l x) ∧l (z ∨l x) ∨lRdist∧l x y z = ∨l-dist-∧l x y z .snd ∧lLdist∨l : (x y z : L) → x ∧l (y ∨l z) ≡ (x ∧l y) ∨l (x ∧l z) ∧lLdist∨l x y z = ∧l-dist-∨l x y z .fst ∧lRdist∨l : (x y z : L) → (y ∨l z) ∧l x ≡ (y ∧l x) ∨l (z ∧l x) ∧lRdist∨l x y z = ∧l-dist-∨l x y z .snd record DistLatticeStr (A : Type ℓ) : Type (ℓ-suc ℓ) where constructor distlatticestr field 0l : A 1l : A _∨l_ : A → A → A _∧l_ : A → A → A isDistLattice : IsDistLattice 0l 1l _∨l_ _∧l_ infix 7 _∨l_ infix 6 _∧l_ open IsDistLattice isDistLattice public DistLattice : ∀ ℓ → Type (ℓ-suc ℓ) DistLattice ℓ = TypeWithStr ℓ DistLatticeStr isSetDistLattice : (L : DistLattice ℓ) → isSet ⟨ L ⟩ isSetDistLattice L = L .snd .DistLatticeStr.is-set -- when proving the axioms for a distributive lattice -- we use the fact that from distributivity and absorption -- of ∧l over ∨l we can derive distributivity and absorption -- of ∨l over ∧l and vice versa. We give provide thus two -- ways of making a distributive lattice... makeIsDistLattice∧lOver∨l : {L : Type ℓ} {0l 1l : L} {_∨l_ _∧l_ : L → L → L} (is-setL : isSet L) (∨l-assoc : (x y z : L) → x ∨l (y ∨l z) ≡ (x ∨l y) ∨l z) (∨l-rid : (x : L) → x ∨l 0l ≡ x) (∨l-comm : (x y : L) → x ∨l y ≡ y ∨l x) (∧l-assoc : (x y z : L) → x ∧l (y ∧l z) ≡ (x ∧l y) ∧l z) (∧l-rid : (x : L) → x ∧l 1l ≡ x) (∧l-comm : (x y : L) → x ∧l y ≡ y ∧l x) (∧l-absorb-∨l : (x y : L) → x ∧l (x ∨l y) ≡ x) (∧l-ldist-∨l : (x y z : L) → x ∧l (y ∨l z) ≡ (x ∧l y) ∨l (x ∧l z)) → IsDistLattice 0l 1l _∨l_ _∧l_ makeIsDistLattice∧lOver∨l {_∨l_ = _∨l_} {_∧l_ = _∧l_} is-setL ∨l-assoc ∨l-rid ∨l-comm ∧l-assoc ∧l-rid ∧l-comm ∧l-absorb-∨l ∧l-ldist-∨l = isdistlattice (makeIsLattice is-setL ∨l-assoc ∨l-rid (λ x → ∨l-comm _ x ∙ ∨l-rid x) ∨l-comm ∧l-assoc ∧l-rid (λ x → ∧l-comm _ x ∙ ∧l-rid x) ∧l-comm ∨l-absorb-∧l ∧l-absorb-∨l) (λ x y z → ∨l-ldist-∧l _ _ _ , ∨l-rdist-∧l _ _ _) (λ x y z → ∧l-ldist-∨l _ _ _ , ∧l-rdist-∨l _ _ _) where ∧l-idem : ∀ x → x ∧l x ≡ x ∧l-idem x = cong (x ∧l_) (sym (∨l-rid _)) ∙ ∧l-absorb-∨l _ _ ∨l-absorb-∧l : ∀ x y → x ∨l (x ∧l y) ≡ x ∨l-absorb-∧l x y = cong (_∨l (x ∧l y)) (sym (∧l-idem _)) ∙∙ sym (∧l-ldist-∨l _ _ _) ∙∙ ∧l-absorb-∨l _ _ ∧l-rdist-∨l : ∀ x y z → (y ∨l z) ∧l x ≡ (y ∧l x) ∨l (z ∧l x) ∧l-rdist-∨l _ _ _ = ∧l-comm _ _ ∙∙ ∧l-ldist-∨l _ _ _ ∙∙ cong₂ (_∨l_) (∧l-comm _ _) (∧l-comm _ _) ∨l-ldist-∧l : ∀ x y z → x ∨l (y ∧l z) ≡ (x ∨l y) ∧l (x ∨l z) ∨l-ldist-∧l x y z = x ∨l (y ∧l z) ≡⟨ cong (_∨l (y ∧l z)) (sym (∨l-absorb-∧l _ _)) ⟩ (x ∨l (x ∧l z)) ∨l (y ∧l z) ≡⟨ sym (∨l-assoc _ _ _) ⟩ x ∨l ((x ∧l z) ∨l (y ∧l z)) ≡⟨ cong (_∨l ((x ∧l z) ∨l (y ∧l z))) (sym (∧l-comm _ _ ∙ ∧l-absorb-∨l _ _)) ⟩ ((x ∨l y) ∧l x) ∨l ((x ∧l z) ∨l (y ∧l z)) ≡⟨ cong (((x ∨l y) ∧l x) ∨l_) (sym (∧l-rdist-∨l _ _ _)) ⟩ ((x ∨l y) ∧l x) ∨l ((x ∨l y) ∧l z) ≡⟨ sym (∧l-ldist-∨l _ _ _) ⟩ (x ∨l y) ∧l (x ∨l z) ∎ ∨l-rdist-∧l : ∀ x y z → (y ∧l z) ∨l x ≡ (y ∨l x) ∧l (z ∨l x) ∨l-rdist-∧l x y z = ∨l-comm _ x ∙∙ ∨l-ldist-∧l _ _ _ ∙∙ cong₂ (_∧l_) (∨l-comm _ _) (∨l-comm _ _) makeDistLattice∧lOver∨l : {L : Type ℓ} (0l 1l : L) (_∨l_ _∧l_ : L → L → L) (is-setL : isSet L) (∨l-assoc : (x y z : L) → x ∨l (y ∨l z) ≡ (x ∨l y) ∨l z) (∨l-rid : (x : L) → x ∨l 0l ≡ x) (∨l-comm : (x y : L) → x ∨l y ≡ y ∨l x) (∧l-assoc : (x y z : L) → x ∧l (y ∧l z) ≡ (x ∧l y) ∧l z) (∧l-rid : (x : L) → x ∧l 1l ≡ x) (∧l-comm : (x y : L) → x ∧l y ≡ y ∧l x) (∧l-absorb-∨l : (x y : L) → x ∧l (x ∨l y) ≡ x) (∧l-ldist-∨l : (x y z : L) → x ∧l (y ∨l z) ≡ (x ∧l y) ∨l (x ∧l z)) → DistLattice ℓ makeDistLattice∧lOver∨l 0l 1l _∨l_ _∧l_ is-setL ∨l-assoc ∨l-rid ∨l-comm ∧l-assoc ∧l-rid ∧l-comm ∧l-absorb-∨l ∧l-ldist-∨l = _ , distlatticestr _ _ _ _ (makeIsDistLattice∧lOver∨l is-setL ∨l-assoc ∨l-rid ∨l-comm ∧l-assoc ∧l-rid ∧l-comm ∧l-absorb-∨l ∧l-ldist-∨l) makeIsDistLattice∨lOver∧l : {L : Type ℓ} {0l 1l : L} {_∨l_ _∧l_ : L → L → L} (is-setL : isSet L) (∨l-assoc : (x y z : L) → x ∨l (y ∨l z) ≡ (x ∨l y) ∨l z) (∨l-rid : (x : L) → x ∨l 0l ≡ x) (∨l-comm : (x y : L) → x ∨l y ≡ y ∨l x) (∧l-assoc : (x y z : L) → x ∧l (y ∧l z) ≡ (x ∧l y) ∧l z) (∧l-rid : (x : L) → x ∧l 1l ≡ x) (∧l-comm : (x y : L) → x ∧l y ≡ y ∧l x) (∨l-absorb-∧l : (x y : L) → x ∨l (x ∧l y) ≡ x) (∨l-ldist-∧l : (x y z : L) → x ∨l (y ∧l z) ≡ (x ∨l y) ∧l (x ∨l z)) → IsDistLattice 0l 1l _∨l_ _∧l_ makeIsDistLattice∨lOver∧l {_∨l_ = _∨l_} {_∧l_ = _∧l_} is-setL ∨l-assoc ∨l-rid ∨l-comm ∧l-assoc ∧l-rid ∧l-comm ∨l-absorb-∧l ∨l-ldist-∧l = isdistlattice (makeIsLattice is-setL ∨l-assoc ∨l-rid (λ x → ∨l-comm _ x ∙ ∨l-rid x) ∨l-comm ∧l-assoc ∧l-rid (λ x → ∧l-comm _ x ∙ ∧l-rid x) ∧l-comm ∨l-absorb-∧l ∧l-absorb-∨l) (λ x y z → ∨l-ldist-∧l _ _ _ , ∨l-rdist-∧l _ _ _) (λ x y z → ∧l-ldist-∨l _ _ _ , ∧l-rdist-∨l _ _ _) where ∨l-idem : ∀ x → x ∨l x ≡ x ∨l-idem x = cong (x ∨l_) (sym (∧l-rid _)) ∙ ∨l-absorb-∧l _ _ ∧l-absorb-∨l : ∀ x y → x ∧l (x ∨l y) ≡ x ∧l-absorb-∨l x y = cong (_∧l (x ∨l y)) (sym (∨l-idem _)) ∙∙ sym (∨l-ldist-∧l _ _ _) ∙∙ ∨l-absorb-∧l _ _ ∨l-rdist-∧l : ∀ x y z → (y ∧l z) ∨l x ≡ (y ∨l x) ∧l (z ∨l x) ∨l-rdist-∧l _ _ _ = ∨l-comm _ _ ∙∙ ∨l-ldist-∧l _ _ _ ∙∙ cong₂ (_∧l_) (∨l-comm _ _) (∨l-comm _ _) ∧l-ldist-∨l : ∀ x y z → x ∧l (y ∨l z) ≡ (x ∧l y) ∨l (x ∧l z) ∧l-ldist-∨l x y z = x ∧l (y ∨l z) ≡⟨ cong (_∧l (y ∨l z)) (sym (∧l-absorb-∨l _ _)) ⟩ (x ∧l (x ∨l z)) ∧l (y ∨l z) ≡⟨ sym (∧l-assoc _ _ _) ⟩ x ∧l ((x ∨l z) ∧l (y ∨l z)) ≡⟨ cong (_∧l ((x ∨l z) ∧l (y ∨l z))) (sym (∨l-comm _ _ ∙ ∨l-absorb-∧l _ _)) ⟩ ((x ∧l y) ∨l x) ∧l ((x ∨l z) ∧l (y ∨l z)) ≡⟨ cong (((x ∧l y) ∨l x) ∧l_) (sym (∨l-rdist-∧l _ _ _)) ⟩ ((x ∧l y) ∨l x) ∧l ((x ∧l y) ∨l z) ≡⟨ sym (∨l-ldist-∧l _ _ _) ⟩ (x ∧l y) ∨l (x ∧l z) ∎ ∧l-rdist-∨l : ∀ x y z → (y ∨l z) ∧l x ≡ (y ∧l x) ∨l (z ∧l x) ∧l-rdist-∨l x y z = ∧l-comm _ x ∙∙ ∧l-ldist-∨l _ _ _ ∙∙ cong₂ (_∨l_) (∧l-comm _ _) (∧l-comm _ _) makeDistLattice∨lOver∧l : {L : Type ℓ} (0l 1l : L) (_∨l_ _∧l_ : L → L → L) (is-setL : isSet L) (∨l-assoc : (x y z : L) → x ∨l (y ∨l z) ≡ (x ∨l y) ∨l z) (∨l-rid : (x : L) → x ∨l 0l ≡ x) (∨l-comm : (x y : L) → x ∨l y ≡ y ∨l x) (∧l-assoc : (x y z : L) → x ∧l (y ∧l z) ≡ (x ∧l y) ∧l z) (∧l-rid : (x : L) → x ∧l 1l ≡ x) (∧l-comm : (x y : L) → x ∧l y ≡ y ∧l x) (∨l-absorb-∧l : (x y : L) → x ∨l (x ∧l y) ≡ x) (∨l-ldist-∧l : (x y z : L) → x ∨l (y ∧l z) ≡ (x ∨l y) ∧l (x ∨l z)) → DistLattice ℓ makeDistLattice∨lOver∧l 0l 1l _∨l_ _∧l_ is-setL ∨l-assoc ∨l-rid ∨l-comm ∧l-assoc ∧l-rid ∧l-comm ∨l-absorb-∧l ∨l-ldist-∧l = _ , distlatticestr _ _ _ _ (makeIsDistLattice∨lOver∧l is-setL ∨l-assoc ∨l-rid ∨l-comm ∧l-assoc ∧l-rid ∧l-comm ∨l-absorb-∧l ∨l-ldist-∧l) DistLatticeStr→LatticeStr : {A : Type ℓ} → DistLatticeStr A → LatticeStr A DistLatticeStr→LatticeStr (distlatticestr _ _ _ _ H) = latticestr _ _ _ _ (IsDistLattice.isLattice H) DistLattice→Lattice : DistLattice ℓ → Lattice ℓ DistLattice→Lattice (_ , distlatticestr _ _ _ _ H) = _ , latticestr _ _ _ _ (IsDistLattice.isLattice H) DistLatticeHom : (L : DistLattice ℓ) (M : DistLattice ℓ') → Type (ℓ-max ℓ ℓ') DistLatticeHom L M = LatticeHom (DistLattice→Lattice L) (DistLattice→Lattice M) IsDistLatticeEquiv : {A : Type ℓ} {B : Type ℓ'} (L : DistLatticeStr A) (e : A ≃ B) (M : DistLatticeStr B) → Type (ℓ-max ℓ ℓ') IsDistLatticeEquiv L e M = IsLatticeHom (DistLatticeStr→LatticeStr L) (e .fst) (DistLatticeStr→LatticeStr M) DistLatticeEquiv : (L : DistLattice ℓ) (M : DistLattice ℓ') → Type (ℓ-max ℓ ℓ') DistLatticeEquiv L M = Σ[ e ∈ (L .fst ≃ M .fst) ] IsDistLatticeEquiv (L .snd) e (M .snd) isPropIsDistLattice : {L : Type ℓ} (0l 1l : L) (_∨l_ _∧l_ : L → L → L) → isProp (IsDistLattice 0l 1l _∨l_ _∧l_) isPropIsDistLattice 0l 1l _∨l_ _∧l_ (isdistlattice LL LD1 LD2) (isdistlattice ML MD1 MD2) = λ i → isdistlattice (isPropIsLattice _ _ _ _ LL ML i) (isPropDist1 LD1 MD1 i) (isPropDist2 LD2 MD2 i) where isSetL : isSet _ isSetL = LL .IsLattice.joinSemilattice .IsSemilattice.isCommMonoid .IsCommMonoid.isMonoid .IsMonoid.isSemigroup .IsSemigroup.is-set isPropDist1 : isProp ((x y z : _) → (x ∨l (y ∧l z) ≡ (x ∨l y) ∧l (x ∨l z)) × ((y ∧l z) ∨l x ≡ (y ∨l x) ∧l (z ∨l x))) isPropDist1 = isPropΠ3 (λ _ _ _ → isProp× (isSetL _ _) (isSetL _ _)) isPropDist2 : isProp ((x y z : _) → (x ∧l (y ∨l z) ≡ (x ∧l y) ∨l (x ∧l z)) × ((y ∨l z) ∧l x ≡ (y ∧l x) ∨l (z ∧l x))) isPropDist2 = isPropΠ3 (λ _ _ _ → isProp× (isSetL _ _) (isSetL _ _)) 𝒮ᴰ-DistLattice : DUARel (𝒮-Univ ℓ) DistLatticeStr ℓ 𝒮ᴰ-DistLattice = 𝒮ᴰ-Record (𝒮-Univ _) IsDistLatticeEquiv (fields: data[ 0l ∣ null ∣ pres0 ] data[ 1l ∣ null ∣ pres1 ] data[ _∨l_ ∣ bin ∣ pres∨l ] data[ _∧l_ ∣ bin ∣ pres∧l ] prop[ isDistLattice ∣ (λ _ _ → isPropIsDistLattice _ _ _ _) ]) where open DistLatticeStr open IsLatticeHom -- faster with some sharing null = autoDUARel (𝒮-Univ _) (λ A → A) bin = autoDUARel (𝒮-Univ _) (λ A → A → A → A) DistLatticePath : (L M : DistLattice ℓ) → DistLatticeEquiv L M ≃ (L ≡ M) DistLatticePath = ∫ 𝒮ᴰ-DistLattice .UARel.ua
algebraic-stack_agda0000_doc_5292
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Relation.Binary.Raw.Construct.Intersection where open import Cubical.Core.Everything open import Cubical.Foundations.Function using (_∘_) open import Cubical.Data.Prod open import Cubical.Data.Sum.Base using (_⊎_; inl; inr; rec) open import Cubical.Relation.Binary.Raw open import Cubical.Relation.Nullary using (yes; no) ------------------------------------------------------------------------ -- Definition _∩_ : ∀ {a b ℓ₁ ℓ₂} {A : Type a} {B : Type b} → RawREL A B ℓ₁ → RawREL A B ℓ₂ → RawREL A B (ℓ-max ℓ₁ ℓ₂) L ∩ R = λ i j → L i j × R i j ------------------------------------------------------------------------ -- Properties module _ {a ℓ₁ ℓ₂} {A : Type a} (L : RawRel A ℓ₁) (R : RawRel A ℓ₂) where reflexive : Reflexive L → Reflexive R → Reflexive (L ∩ R) reflexive L-refl R-refl = L-refl , R-refl symmetric : Symmetric L → Symmetric R → Symmetric (L ∩ R) symmetric L-sym R-sym = map L-sym R-sym transitive : Transitive L → Transitive R → Transitive (L ∩ R) transitive L-trans R-trans (xLy , xRy) (yLz , yRz) = L-trans xLy yLz , R-trans xRy yRz respects : ∀ {p} (P : A → Type p) → P Respects L ⊎ P Respects R → P Respects (L ∩ R) respects P resp (Lxy , Rxy) = rec (λ x → x Lxy) (λ x → x Rxy) resp min : ∀ {⊤} → Minimum L ⊤ → Minimum R ⊤ → Minimum (L ∩ R) ⊤ min L-min R-min = intro L-min R-min max : ∀ {⊥} → Maximum L ⊥ → Maximum R ⊥ → Maximum (L ∩ R) ⊥ max L-max R-max = intro L-max R-max toNotEq : ToNotEq L ⊎ ToNotEq R → ToNotEq (L ∩ R) toNotEq tonoteq (Lxy , Rxy) x≡y = rec (λ x → x Lxy x≡y) (λ y → y Rxy x≡y) tonoteq irreflexive : Irreflexive L ⊎ Irreflexive R → Irreflexive (L ∩ R) irreflexive irrefl (xLx , xRx) = rec (λ x → x xLx) (λ y → y xRx) irrefl antisymmetric : Antisymmetric L ⊎ Antisymmetric R → Antisymmetric (L ∩ R) antisymmetric (inl L-antisym) (Lxy , _) (Lyx , _) = L-antisym Lxy Lyx antisymmetric (inr R-antisym) (_ , Rxy) (_ , Ryx) = R-antisym Rxy Ryx module _ {a b ℓ₁ ℓ₂ ℓ₃} {A : Type a} {B : Type b} (≈ : RawREL A B ℓ₁) {L : RawREL A B ℓ₂} {R : RawREL A B ℓ₃} where implies : (≈ ⇒ L) → (≈ ⇒ R) → ≈ ⇒ (L ∩ R) implies ≈⇒L ≈⇒R = intro ≈⇒L ≈⇒R module _ {a ℓ₁ ℓ₂ ℓ₃} {A : Type a} (≈ : RawRel A ℓ₁) (L : RawRel A ℓ₂) (R : RawRel A ℓ₃) where respectsˡ : L Respectsˡ ≈ → R Respectsˡ ≈ → (L ∩ R) Respectsˡ ≈ respectsˡ L-resp R-resp x≈y = map (L-resp x≈y) (R-resp x≈y) respectsʳ : L Respectsʳ ≈ → R Respectsʳ ≈ → (L ∩ R) Respectsʳ ≈ respectsʳ L-resp R-resp x≈y = map (L-resp x≈y) (R-resp x≈y) respects₂ : L Respects₂ ≈ → R Respects₂ ≈ → (L ∩ R) Respects₂ ≈ respects₂ (Lʳ , Lˡ) (Rʳ , Rˡ) = respectsʳ Lʳ Rʳ , respectsˡ Lˡ Rˡ module _ {a b ℓ₁ ℓ₂} {A : Type a} {B : Type b} {L : RawREL A B ℓ₁} {R : RawREL A B ℓ₂} where decidable : Decidable L → Decidable R → Decidable (L ∩ R) decidable L? R? x y = ×-dec (L? x y) (R? x y) ------------------------------------------------------------------------ -- Structures module _ {a ℓ₁ ℓ₂} {A : Type a} {L : RawRel A ℓ₁} {R : RawRel A ℓ₂} where isPartialEquivalence : IsPartialEquivalence L → IsPartialEquivalence R → IsPartialEquivalence (L ∩ R) isPartialEquivalence eqₗ eqᵣ = record { symmetric = symmetric L R Eqₗ.symmetric Eqᵣ.symmetric ; transitive = transitive L R Eqₗ.transitive Eqᵣ.transitive } where module Eqₗ = IsPartialEquivalence eqₗ; module Eqᵣ = IsPartialEquivalence eqᵣ isEquivalence : IsEquivalence L → IsEquivalence R → IsEquivalence (L ∩ R) isEquivalence eqₗ eqᵣ = record { isPartialEquivalence = isPartialEquivalence Eqₗ.isPartialEquivalence Eqᵣ.isPartialEquivalence ; reflexive = reflexive L R Eqₗ.reflexive Eqᵣ.reflexive } where module Eqₗ = IsEquivalence eqₗ; module Eqᵣ = IsEquivalence eqᵣ isDecEquivalence : IsDecEquivalence L → IsDecEquivalence R → IsDecEquivalence (L ∩ R) isDecEquivalence eqₗ eqᵣ = record { isEquivalence = isEquivalence Eqₗ.isEquivalence Eqᵣ.isEquivalence ; _≟_ = decidable Eqₗ._≟_ Eqᵣ._≟_ } where module Eqₗ = IsDecEquivalence eqₗ; module Eqᵣ = IsDecEquivalence eqᵣ isPreorder : IsPreorder L → IsPreorder R → IsPreorder (L ∩ R) isPreorder Oₗ Oᵣ = record { reflexive = reflexive L R Oₗ.reflexive Oᵣ.reflexive ; transitive = transitive L R Oₗ.transitive Oᵣ.transitive } where module Oₗ = IsPreorder Oₗ; module Oᵣ = IsPreorder Oᵣ isPartialOrderˡ : IsPartialOrder L → IsPreorder R → IsPartialOrder (L ∩ R) isPartialOrderˡ Oₗ Oᵣ = record { isPreorder = isPreorder Oₗ.isPreorder Oᵣ ; antisym = antisymmetric L R (inl Oₗ.antisym) } where module Oₗ = IsPartialOrder Oₗ; module Oᵣ = IsPreorder Oᵣ isPartialOrderʳ : IsPreorder L → IsPartialOrder R → IsPartialOrder (L ∩ R) isPartialOrderʳ Oₗ Oᵣ = record { isPreorder = isPreorder Oₗ Oᵣ.isPreorder ; antisym = antisymmetric L R (inr Oᵣ.antisym) } where module Oₗ = IsPreorder Oₗ; module Oᵣ = IsPartialOrder Oᵣ isStrictPartialOrderˡ : IsStrictPartialOrder L → Transitive R → IsStrictPartialOrder (L ∩ R) isStrictPartialOrderˡ Oₗ transitiveᵣ = record { irrefl = irreflexive L R (inl Oₗ.irrefl) ; transitive = transitive L R Oₗ.transitive transitiveᵣ } where module Oₗ = IsStrictPartialOrder Oₗ isStrictPartialOrderʳ : Transitive L → IsStrictPartialOrder R → IsStrictPartialOrder (L ∩ R) isStrictPartialOrderʳ transitiveₗ Oᵣ = record { irrefl = irreflexive L R (inr Oᵣ.irrefl) ; transitive = transitive L R transitiveₗ Oᵣ.transitive } where module Oᵣ = IsStrictPartialOrder Oᵣ
algebraic-stack_agda0000_doc_5293
-- Andreas & Jesper, 2018-05-11, issue #3052 reported by identicalsnowflake -- -- The problem here was that free variable collection had the standard -- monoid instance of IntMap, which is just "randomly" picking one variant. -- Thus, if we have both irrelevant and relevant occurrences of a variable, -- we get whatever. -- Now we keep the stronger information (relevant, see maxVarOcc). {-# OPTIONS --show-irrelevant #-} -- {-# OPTIONS -v tc.meta.assign:100 -v tc.meta.occurs:45 #-} -- {-# OPTIONS -v tc.lhs:100 #-} postulate A : Set B : A → Set record Σ : Set where constructor _,_ field proj₁ : A proj₂ : B proj₁ open Σ public record Foo : Set where constructor foo field .theFoo : Σ test : Foo → Foo test (foo (a , b)) = foo (a , thm a b) -- Error at b -- Constraint: a, b ⊢ ?0 .a .b a = B a : Set -- Note the irrelevant occurrence .a and the relevant occurrence a -- on the lhs of this constraint! where -- Meta ?0 : [.a, .b, x] Set postulate thm : (x : A) (y : _) → B x -- Underscore should solved by B x -- thm x y = y -- WAS: Worked only if definition is given (which -- Should succeed.
algebraic-stack_agda0000_doc_5294
module Ex3Lec where ---------------------------------------------------------------------------- -- EXERCISE 3 -- MONADS FOR HUTTON'S RAZOR -- -- VALUE: 15% -- DEADLINE: 5pm, Friday 20 November (week 9) -- -- DON'T SUBMIT, COMMIT! -- -- The purpose of this exercise is to introduce you to some useful -- mathematical structures and build good tools for working with -- vectors ---------------------------------------------------------------------------- open import CS410-Prelude open import CS410-Monoid open import CS410-Nat open import CS410-Vec open import CS410-Functor -- HINT: your tasks are heralded with the eminently searchable tag, "???" ---------------------------------------------------------------------------- -- HUTTON'S RAZOR ---------------------------------------------------------------------------- HVal : Set -- the set of *values* for Hutton's Razor HVal = Two + Nat -- Booleans or natural numbers foo : HVal foo = tt , ff goo : HVal goo = ff , 42 data HExp (X : Set) : Set where var : X -> HExp X -- variables val : HVal -> HExp X -- values _+H_ _>=H_ : (e1 e2 : HExp X) -> HExp X -- addition, comparison ifH_then_else_ : (e1 e2 e3 : HExp X) -> HExp X -- conditional _>=2_ : Nat -> Nat -> Two x >=2 zero = tt zero >=2 suc _ = ff suc m >=2 suc n = m >=2 n ---------------------------------------------------------------------------- -- ??? 3.1 the HExp syntax-with-substitution monad (score: ? / 2) ---------------------------------------------------------------------------- -- Show that HExp is a monad, where the "bind" operation performs -- simultaneous substitution (transforming all the variables in a term). hExpMonad : Monad HExp hExpMonad = record { return = {!!} ; _>>=_ = {!!} } ---------------------------------------------------------------------------- -- ??? 3.2 the error management monad (score: ? / 1) ---------------------------------------------------------------------------- -- show that "+ E" is monadic, generalising the "Maybe" monad by allowing -- some sort of error report errorMonad : (E : Set) -> Monad \ V -> V + E -- "value or error" errorMonad E = {!!} ---------------------------------------------------------------------------- -- ??? 3.3 the environment monad transformer (score: ? / 1) ---------------------------------------------------------------------------- -- show that "+ E" is monadic, generalising the "Maybe" monad by allowing -- some sort of error report envMonad : (G : Set){M : Set -> Set} -> Monad M -> Monad \ V -> G -> M V -- "computation in an environment" envMonad G MM = {!!} where open Monad MM ---------------------------------------------------------------------------- -- ??? 3.4 interpreting Hutton's Razor (score: ? / 3) ---------------------------------------------------------------------------- -- Implement an interpreter for Hutton's Razor. -- You will need to construct a type to represent possible run-time errors. -- Ensure that addition and comparison act on numbers, not Booleans. -- Ensure that the condition in an "if" is a Boolean, not a number. data InterpretError : Set where -- helpful things to build Env : Set -> Set -- an environment for a given set of variables Env X = X -> HVal Compute : Set{- variables -} -> Set{- values -} -> Set Compute X V = Env X -> V + InterpretError -- how to compute a V computeMonad : {X : Set} -> Monad (Compute X) computeMonad = {!!} -- build this from the above parts -- This operation should explain how to get the value of a variable -- from the environment. varVal : {X : Set} -> X -> Compute X HVal varVal x = {!!} -- These operations should ensure that you get the sort of value -- that you want, in order to ensure that you don't do bogus -- computation. mustBeNat : {X : Set} -> HVal -> Compute X Nat mustBeNat v = {!!} mustBeTwo : {X : Set} -> HVal -> Compute X Two mustBeTwo v = {!!} -- Now, you're ready to go. Don't introduce the environent explicitly. -- Use the monad to thread it. interpret : {X : Set} -> HExp X -> Compute X HVal interpret {X} = go where open Monad (envMonad (Env X) (errorMonad InterpretError)) go : HExp X -> Env X -> HVal + InterpretError go t = {!!}
algebraic-stack_agda0000_doc_5295
{-# OPTIONS --type-in-type #-} open import Data.Product data ⊥ : Set where -- f doesn't type check unless we put the equality type in Set data _≡_ {ℓ} {A : Set ℓ} (a : A) : A → Set where refl : a ≡ a subst : ∀ {ℓ ℓ′} {A : Set ℓ} {a b : A} → (P : A → Set ℓ′) → (p : a ≡ b) → P a → P b subst _ refl pa = pa ¬_ : ∀ {ℓ} → Set ℓ → Set ℓ ¬ A = A → ⊥ ℘ : ∀ {ℓ} → Set ℓ → Set _ ℘ {ℓ} S = S → Set {-# NO_POSITIVITY_CHECK #-} record Bad : Set₁ where constructor mkBad field bad : ℘ (℘ Bad) f : ℘ Bad → Bad f p = mkBad (_≡ p) fInj : ∀ {p q} → f p ≡ f q → p ≡ q fInj {p} fp≡fq = subst (λ p≡ → p≡ p) (badInj fp≡fq) refl where badInj : ∀ {a b} → mkBad a ≡ mkBad b → a ≡ b badInj refl = refl -- type-in-type is for here onwards P₀ : ℘ Bad P₀ x = Σ[ P ∈ ℘ Bad ] x ≡ f P × ¬ (P x) x₀ : Bad x₀ = f P₀ P₀x₀→¬P₀x₀ : P₀ x₀ → ¬ P₀ x₀ P₀x₀→¬P₀x₀ (P , x₀≡fP , ¬Px₀) P₀x₀ = ¬Px₀ (subst (λ P → P x₀) (fInj x₀≡fP) P₀x₀) ¬P₀x₀→P₀x₀ : ¬ P₀ x₀ → P₀ x₀ ¬P₀x₀→P₀x₀ ¬P₀x₀ = P₀ , refl , ¬P₀x₀ ¬P₀x₀ : ¬ P₀ x₀ ¬P₀x₀ P₀x₀ = P₀x₀→¬P₀x₀ P₀x₀ P₀x₀ false : ⊥ false = ¬P₀x₀ (¬P₀x₀→P₀x₀ ¬P₀x₀)
algebraic-stack_agda0000_doc_4288
{-# OPTIONS --cubical --safe #-} -- Counterpoint Exercises module Exercises where open import MidiEvent open import Note open import Pitch open import Data.Fin open import Data.List open import Data.Nat -- Exercise 5.4 cantusFirmus : List Pitch cantusFirmus = a 4 ∷ c 5 ∷ b 4 ∷ c 5 ∷ d 5 ∷ e 5 ∷ c 5 ∷ b 4 ∷ a 4 ∷ [] cfNotes : List Note cfNotes = Data.List.map (λ p → tone whole p) cantusFirmus ---- instrument : InstrumentNumber-1 instrument = # 0 -- piano channel : Channel-1 channel = # 0 tempo : ℕ tempo = 120 cfTrack : List MidiTrack cfTrack = track "Piano" instrument channel tempo (notes→events defaultVelocity cfNotes) ∷ []
algebraic-stack_agda0000_doc_4289
module examplesPaperJFP.SpaceShipSimpleVar where open import SizedIO.Base open import StateSizedIO.GUI.BaseStateDependent open import Data.Bool.Base open import Data.List.Base open import Data.Integer open import Data.Product hiding (map) open import SizedIO.Object open import SizedIO.IOObject open import NativeIO open import StateSizedIO.GUI.WxBindingsFFI open import StateSizedIO.GUI.VariableList open import StateSizedIO.GUI.WxGraphicsLib open import StateSized.GUI.BitMaps VarType = ℤ varInit : VarType varInit = (+ 150) onPaint : ∀{i} → VarType → DC → Rect → IO GuiLev1Interface i VarType onPaint z dc rect = exec (drawBitmap dc ship (z , (+ 150)) true) λ _ → return z moveSpaceShip : ∀{i} → Frame → VarType → IO GuiLev1Interface i VarType moveSpaceShip fra z = return (z + (+ 20)) callRepaint : ∀{i} → Frame → VarType → IO GuiLev1Interface i VarType callRepaint fra z = exec (repaint fra) λ _ → return z buttonHandler : ∀{i} → Frame → List (VarType → IO GuiLev1Interface i VarType) buttonHandler fra = moveSpaceShip fra ∷ [ callRepaint fra ] program : ∀{i} → IOˢ GuiLev2Interface i (λ _ → Unit) [] program = execˢ (level1C makeFrame) λ fra → execˢ (level1C (makeButton fra)) λ bt → execˢ (level1C (addButton fra bt)) λ _ → execˢ (createVar varInit) λ _ → execˢ (setButtonHandler bt (moveSpaceShip fra ∷ [ callRepaint fra ])) λ _ → execˢ (setOnPaint fra [ onPaint ]) returnˢ main : NativeIO Unit main = start (translateLev2 program)
algebraic-stack_agda0000_doc_4290
-- {-# OPTIONS --no-coverage #-} -- {-# OPTIONS -v tc.cover:20 #-} open import Common.Bool open import Common.Equality _∨_ : Bool → Bool → Bool a ∨ b = if a then true else b module Works where data Term : Bool → Set where I : Term false App : ∀ a b c → a ∨ b ≡ c → Term a → Term b → Term c -- The following clause works for the coverage checker: test : Term false → Set test (App false false .false refl I x) = Bool module Fails where data Term : Bool -> Set where I : Term false App : ∀ a b c → Term a → Term b → a ∨ b ≡ c → Term c -- If we put the equality proof later in App, it fails: test : Term false → Set test (App false false .false I x refl) = Bool -- The following checks, until you split at p. -- test (App false false .false I x p) = {!p!}
algebraic-stack_agda0000_doc_4291
{-# OPTIONS --without-K --safe #-} open import Algebra module Data.FingerTree.View {r m} (ℳ : Monoid r m) where open import Level using (_⊔_) open import Data.Product open import Function open import Data.List as List using (List; _∷_; []) open import Data.FingerTree.Structures ℳ open import Data.FingerTree.Reasoning ℳ open import Data.FingerTree.Measures ℳ open import Data.FingerTree.Cons ℳ open σ ⦃ ... ⦄ {-# DISPLAY σ.μ _ = μ #-} {-# DISPLAY μ-tree _ x = μ x #-} {-# DISPLAY μ-deep _ x = μ x #-} open Monoid ℳ renaming (Carrier to 𝓡) infixr 5 _◃_ data Viewₗ {a b} (A : Set a) (Σ : Set b) : Set (a ⊔ b) where nilₗ : Viewₗ A Σ _◃_ : A → Σ → Viewₗ A Σ instance σ-Viewₗ : ∀ {a b} {A : Set a} {Σ : Set b} ⦃ _ : σ A ⦄ ⦃ _ : σ Σ ⦄ → σ (Viewₗ A Σ) μ ⦃ σ-Viewₗ ⦄ nilₗ = ε μ ⦃ σ-Viewₗ ⦄ (x ◃ xs) = μ x ∙ μ xs viewₗ : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → (xs : Tree Σ) → μ⟨ Viewₗ Σ (Tree Σ) ⟩≈ (μ xs) viewₗ empty = nilₗ ⇑ viewₗ (single x) = (x ◃ empty) ⇑[ ℳ ↯ ] viewₗ (deep (𝓂 ↤ (D₂ a b & m & rs) ⇑[ 𝓂≈ ])) = a ◃ deep ⟪ D₁ b & m & rs ⇓⟫ ⇑[ ℳ ↯ ] ≈[ 𝓂≈ ]′ viewₗ (deep (𝓂 ↤ (D₃ a b c & m & rs) ⇑[ 𝓂≈ ])) = a ◃ deep ⟪ D₂ b c & m & rs ⇓⟫ ⇑[ ℳ ↯ ] ≈[ 𝓂≈ ]′ viewₗ (deep (𝓂 ↤ (D₄ a b c d & m & rs) ⇑[ 𝓂≈ ])) = a ◃ deep ⟪ D₃ b c d & m & rs ⇓⟫ ⇑[ ℳ ↯ ] ≈[ 𝓂≈ ]′ viewₗ (deep (𝓂 ↤ (D₁ a & m & rs) ⇑[ 𝓂≈ ])) with viewₗ m ... | (μ⟨y⟩ ↤ N₂ y₁ y₂ ⇑[ yp ]) ◃ ys ⇑[ p ] = a ◃ deep (μ m ∙ μ rs ↤ D₂ y₁ y₂ & ys & rs ⇑[ ℳ ↯ ] ≈[ ≪∙ (≪∙ yp ⍮ p) ]′) ⇑[ 𝓂≈ ] ... | (μ⟨y⟩ ↤ N₃ y₁ y₂ y₃ ⇑[ yp ]) ◃ ys ⇑[ p ] = a ◃ deep (μ m ∙ μ rs ↤ D₃ y₁ y₂ y₃ & ys & rs ⇑[ ℳ ↯ ] ≈[ ≪∙ (≪∙ yp ⍮ p) ]′) ⇑[ 𝓂≈ ] ... | nilₗ ⇑[ p ] = (digitToTree rs [ _ ∙> r ⟿ r ] >>= (λ rs′ → (a ◃ rs′) ⇑)) ≈[ ∙≫ sym (identityˡ _) ⍮ (∙≫ ≪∙ p) ⍮ 𝓂≈ ] infixl 5 _▹_ data Viewᵣ {a b} (A : Set a) (Σ : Set b) : Set (a ⊔ b) where nilᵣ : Viewᵣ A Σ _▹_ : Σ → A → Viewᵣ A Σ instance σ-Viewᵣ : ∀ {a b} {A : Set a} {Σ : Set b} ⦃ _ : σ A ⦄ ⦃ _ : σ Σ ⦄ → σ (Viewᵣ A Σ) μ ⦃ σ-Viewᵣ ⦄ nilᵣ = ε μ ⦃ σ-Viewᵣ ⦄ (xs ▹ x) = μ xs ∙ μ x viewᵣ : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → (xs : Tree Σ) → μ⟨ Viewᵣ Σ (Tree Σ) ⟩≈ (μ xs) viewᵣ empty = nilᵣ ⇑ viewᵣ (single x) = empty ▹ x ⇑[ ℳ ↯ ] viewᵣ (deep (𝓂 ↤ (ls & m & D₂ a b ) ⇑[ 𝓂≈ ])) = (deep ⟪ ls & m & D₁ a ⇓⟫ ▹ b) ⇑[ ℳ ↯ ] ≈[ 𝓂≈ ]′ viewᵣ (deep (𝓂 ↤ (ls & m & D₃ a b c ) ⇑[ 𝓂≈ ])) = (deep ⟪ ls & m & D₂ a b ⇓⟫ ▹ c) ⇑[ ℳ ↯ ] ≈[ 𝓂≈ ]′ viewᵣ (deep (𝓂 ↤ (ls & m & D₄ a b c d) ⇑[ 𝓂≈ ])) = (deep ⟪ ls & m & D₃ a b c ⇓⟫ ▹ d) ⇑[ ℳ ↯ ] ≈[ 𝓂≈ ]′ viewᵣ (deep (𝓂 ↤ (ls & m & D₁ a) ⇑[ 𝓂≈ ])) with viewᵣ m ... | ys ▹ (μ⟨y⟩ ↤ N₂ y₁ y₂ ⇑[ yp ]) ⇑[ p ] = deep (μ ls ∙ μ m ↤ ls & ys & D₂ y₁ y₂ ⇑[ ℳ ↯ ] ≈[ ∙≫ (∙≫ yp ⍮ p) ]′) ▹ a ⇑[ ℳ ↯ ] ≈[ 𝓂≈ ]′ ... | ys ▹ (μ⟨y⟩ ↤ N₃ y₁ y₂ y₃ ⇑[ yp ]) ⇑[ p ] = deep (μ ls ∙ μ m ↤ ls & ys & D₃ y₁ y₂ y₃ ⇑[ ℳ ↯ ] ≈[ ∙≫ (∙≫ yp ⍮ p) ]′) ▹ a ⇑[ ℳ ↯ ] ≈[ 𝓂≈ ]′ ... | nilᵣ ⇑[ p ] = (digitToTree ls [ l <∙ _ ⟿ l ] >>= (λ ls′ → (ls′ ▹ a) ⇑)) ≈[ ℳ ↯ ↣ μ ls ∙ (ε ∙ μ a) ] ≈[ ∙≫ ≪∙ p ⍮ 𝓂≈ ]′ deepₗ : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → (l : List Σ) → (m : Tree ⟪ Node Σ ⟫) → (r : Digit Σ) → μ⟨ Tree Σ ⟩≈ (μ l ∙ (μ m ∙ μ r)) deepₗ [] m r with viewₗ m deepₗ [] m r | nilₗ ⇑[ n≈ ] = digitToTree r ≈[ ℳ ↯ ↣ ε ∙ (ε ∙ μ r) ] ≈[ ∙≫ ≪∙ n≈ ]′ deepₗ [] m r | ((μ⟨y⟩ ↤ N₂ y₁ y₂ ⇑[ yp ]) ◃ ys) ⇑[ ys≈ ] = deep (μ m ∙ μ r ↤ D₂ y₁ y₂ & ys & r ⇑[ ≪∙ yp ⍮ sym (assoc _ _ _) ⍮ ≪∙ ys≈ ]) ⇑[ ℳ ↯ ] deepₗ [] m r | ((μ⟨y⟩ ↤ N₃ y₁ y₂ y₃ ⇑[ yp ]) ◃ ys) ⇑[ ys≈ ] = deep (μ m ∙ μ r ↤ D₃ y₁ y₂ y₃ & ys & r ⇑[ ≪∙ yp ⍮ sym (assoc _ _ _) ⍮ ≪∙ ys≈ ]) ⇑[ ℳ ↯ ] deepₗ (l ∷ ls) m r = go l ls m r where go : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → (l : Σ) → (ls : List Σ) → (m : Tree ⟪ Node Σ ⟫) → (r : Digit Σ) → μ⟨ Tree Σ ⟩≈ (μ l ∙ μ ls ∙ (μ m ∙ μ r)) go l [] m r = deep ⟪ D₁ l & m & r ⇓⟫ ⇑[ ℳ ↯ ] go l₁ (l₂ ∷ ls) m r = (go l₂ ls m r [ _ ∙> ls′ ⟿ ls′ ] >>= (l₁ ◂_)) ≈[ ℳ ↯ ] deepᵣ : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → (l : Digit Σ) → (m : Tree ⟪ Node Σ ⟫) → (r : List Σ) → μ⟨ Tree Σ ⟩≈ (μ l ∙ (μ m ∙ μ r)) deepᵣ l m [] with viewᵣ m deepᵣ l m [] | nilᵣ ⇑[ p ] = digitToTree l ≈[ sym (identityʳ _) ⍮ ∙≫ (p ⍮ sym (identityʳ _)) ] deepᵣ l m [] | (ys ▹ (μ⟨y⟩ ↤ N₂ y₁ y₂ ⇑[ μ⟨y⟩≈ ])) ⇑[ p ] = deep (μ l ∙ μ m ↤ l & ys & D₂ y₁ y₂ ⇑[ ∙≫ (∙≫ μ⟨y⟩≈ ⍮ p) ]) ⇑[ ℳ ↯ ] deepᵣ l m [] | (ys ▹ (μ⟨y⟩ ↤ N₃ y₁ y₂ y₃ ⇑[ μ⟨y⟩≈ ])) ⇑[ p ] = deep (μ l ∙ μ m ↤ l & ys & D₃ y₁ y₂ y₃ ⇑[ ∙≫ (∙≫ μ⟨y⟩≈ ⍮ p) ]) ⇑[ ℳ ↯ ] deepᵣ l m (r ∷ rs) = go (deep ⟪ l & m & D₁ r ⇓⟫ ⇑) rs ≈[ ℳ ↯ ] where go : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → ∀ {xs} → μ⟨ Tree Σ ⟩≈ xs → (rs : List Σ) → μ⟨ Tree Σ ⟩≈ (xs ∙ μ rs) go xs [] = xs ≈[ sym (identityʳ _) ] go xs (r ∷ rs) = go (xs [ sz <∙ _ ⟿ sz ] >>= (_▸ r)) rs ≈[ ℳ ↯ ]
algebraic-stack_agda0000_doc_4292
module Logic.Predicate.Multi where open import Data.Tuple.RaiseTypeᵣ open import Function.Multi open import Function.Multi.Functions open import Numeral.Natural open import Logic.Predicate open import Logic -- Universal quantification of multiple variables. -- Example: -- ∀₊(3) P = ∀{x}{y}{z} → P(x)(y)(z) ∀₊ : (n : ℕ) → ∀{ℓ}{ℓ𝓈}{As : Types{n}(ℓ𝓈)} → (As ⇉ Stmt{ℓ}) → Stmt ∀₊(n) = quantifier₊(n) ∀ₗ -- Existential quantification of multiple variables. -- Example: -- ∃₊(3) P = ∃(x ↦ ∃(y ↦ ∃(z ↦ P(x)(y)(z)))) ∃₊ : (n : ℕ) → ∀{ℓ}{ℓ𝓈}{As : Types{n}(ℓ𝓈)} → (As ⇉ Stmt{ℓ}) → Stmt ∃₊(n) = quantifier₊(n) ∃
algebraic-stack_agda0000_doc_4293
{-# OPTIONS --cubical --safe --no-sized-types --no-guardedness --no-subtyping #-} module Agda.Builtin.Cubical.Glue where open import Agda.Primitive open import Agda.Builtin.Sigma open import Agda.Primitive.Cubical renaming (primINeg to ~_; primIMax to _∨_; primIMin to _∧_; primHComp to hcomp; primTransp to transp; primComp to comp; itIsOne to 1=1) open import Agda.Builtin.Cubical.Path open import Agda.Builtin.Cubical.Sub renaming (Sub to _[_↦_]; primSubOut to ouc) import Agda.Builtin.Cubical.HCompU as HCompU module Helpers = HCompU.Helpers open Helpers -- We make this a record so that isEquiv can be proved using -- copatterns. This is good because copatterns don't get unfolded -- unless a projection is applied so it should be more efficient. record isEquiv {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B) : Set (ℓ ⊔ ℓ') where no-eta-equality field equiv-proof : (y : B) → isContr (fiber f y) open isEquiv public infix 4 _≃_ _≃_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Set (ℓ ⊔ ℓ') A ≃ B = Σ (A → B) \ f → (isEquiv f) equivFun : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} → A ≃ B → A → B equivFun e = fst e -- Improved version of equivProof compared to Lemma 5 in CCHM. We put -- the (φ = i0) face in contr' making it be definitionally c in this -- case. This makes the computational behavior better, in particular -- for transp in Glue. equivProof : ∀ {la lt} (T : Set la) (A : Set lt) → (w : T ≃ A) → (a : A) → ∀ ψ → (Partial ψ (fiber (w .fst) a)) → fiber (w .fst) a equivProof A B w a ψ fb = contr' {A = fiber (w .fst) a} (w .snd .equiv-proof a) ψ fb where contr' : ∀ {ℓ} {A : Set ℓ} → isContr A → (φ : I) → (u : Partial φ A) → A contr' {A = A} (c , p) φ u = hcomp (λ i → λ { (φ = i1) → p (u 1=1) i ; (φ = i0) → c }) c {-# BUILTIN EQUIV _≃_ #-} {-# BUILTIN EQUIVFUN equivFun #-} {-# BUILTIN EQUIVPROOF equivProof #-} primitive primGlue : ∀ {ℓ ℓ'} (A : Set ℓ) {φ : I} → (T : Partial φ (Set ℓ')) → (e : PartialP φ (λ o → T o ≃ A)) → Set ℓ' prim^glue : ∀ {ℓ ℓ'} {A : Set ℓ} {φ : I} → {T : Partial φ (Set ℓ')} → {e : PartialP φ (λ o → T o ≃ A)} → (t : PartialP φ T) → (a : A) → primGlue A T e prim^unglue : ∀ {ℓ ℓ'} {A : Set ℓ} {φ : I} → {T : Partial φ (Set ℓ')} → {e : PartialP φ (λ o → T o ≃ A)} → primGlue A T e → A -- Needed for transp in Glue. primFaceForall : (I → I) → I module _ {ℓ : I → Level} (P : (i : I) → Set (ℓ i)) where private E : (i : I) → Set (ℓ i) E = λ i → P i ~E : (i : I) → Set (ℓ (~ i)) ~E = λ i → P (~ i) A = P i0 B = P i1 f : A → B f x = transp E i0 x g : B → A g y = transp ~E i0 y u : ∀ i → A → E i u i x = transp (λ j → E (i ∧ j)) (~ i) x v : ∀ i → B → E i v i y = transp (λ j → ~E ( ~ i ∧ j)) i y fiberPath : (y : B) → (xβ0 xβ1 : fiber f y) → xβ0 ≡ xβ1 fiberPath y (x0 , β0) (x1 , β1) k = ω , λ j → δ (~ j) where module _ (j : I) where private sys : A → ∀ i → PartialP (~ j ∨ j) (λ _ → E (~ i)) sys x i (j = i0) = v (~ i) y sys x i (j = i1) = u (~ i) x ω0 = comp ~E (sys x0) ((β0 (~ j))) ω1 = comp ~E (sys x1) ((β1 (~ j))) θ0 = fill ~E (sys x0) (inc (β0 (~ j))) θ1 = fill ~E (sys x1) (inc (β1 (~ j))) sys = λ {j (k = i0) → ω0 j ; j (k = i1) → ω1 j} ω = hcomp sys (g y) θ = hfill sys (inc (g y)) δ = λ (j : I) → comp E (λ i → λ { (j = i0) → v i y ; (k = i0) → θ0 j (~ i) ; (j = i1) → u i ω ; (k = i1) → θ1 j (~ i) }) (θ j) γ : (y : B) → y ≡ f (g y) γ y j = comp E (λ i → λ { (j = i0) → v i y ; (j = i1) → u i (g y) }) (g y) pathToisEquiv : isEquiv f pathToisEquiv .equiv-proof y .fst .fst = g y pathToisEquiv .equiv-proof y .fst .snd = sym (γ y) pathToisEquiv .equiv-proof y .snd = fiberPath y _ pathToEquiv : A ≃ B pathToEquiv .fst = f pathToEquiv .snd = pathToisEquiv
algebraic-stack_agda0000_doc_4294
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.RingSolver.NatAsAlmostRing where open import Cubical.Foundations.Prelude open import Cubical.Data.Nat open import Cubical.Algebra.RingSolver.AlmostRing open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open import Cubical.Algebra.AbGroup ℕAsAlmostRing : AlmostRing {ℓ-zero} ℕAsAlmostRing = almostring ℕ 0 1 _+_ _·_ (λ n → n) (isalmostring (ismonoid (issemigroup isSetℕ +-assoc) (λ n → (+-zero n) , refl)) (ismonoid (issemigroup isSetℕ ·-assoc) λ n → (·-identityʳ n) , (·-identityˡ n)) +-comm ·-comm (λ k l n → sym (·-distribˡ k l n) ) (λ k l n → sym (·-distribʳ k l n)) (λ _ _ → refl) (λ _ _ → refl) (λ _ → refl) λ x → sym (0≡m·0 x))
algebraic-stack_agda0000_doc_4295
open import Nat open import Prelude open import core open import contexts open import lemmas-consistency open import type-assignment-unicity open import binders-disjoint-checks open import lemmas-subst-ta module preservation where -- if d and d' both result from filling the hole in ε with terms of the -- same type, they too have the same type. wt-different-fill : ∀{ Δ Γ d ε d1 d2 d' τ τ1 } → d == ε ⟦ d1 ⟧ → Δ , Γ ⊢ d :: τ → Δ , Γ ⊢ d1 :: τ1 → Δ , Γ ⊢ d2 :: τ1 → d' == ε ⟦ d2 ⟧ → Δ , Γ ⊢ d' :: τ wt-different-fill FHOuter D1 D2 D3 FHOuter with type-assignment-unicity D1 D2 ... | refl = D3 wt-different-fill (FHAp1 eps) (TAAp D1 D2) D3 D4 (FHAp1 D5) = TAAp (wt-different-fill eps D1 D3 D4 D5) D2 wt-different-fill (FHAp2 eps) (TAAp D1 D2) D3 D4 (FHAp2 D5) = TAAp D1 (wt-different-fill eps D2 D3 D4 D5) wt-different-fill (FHNEHole eps) (TANEHole x D1 x₁) D2 D3 (FHNEHole D4) = TANEHole x (wt-different-fill eps D1 D2 D3 D4) x₁ wt-different-fill (FHCast eps) (TACast D1 x) D2 D3 (FHCast D4) = TACast (wt-different-fill eps D1 D2 D3 D4) x wt-different-fill (FHFailedCast x) (TAFailedCast y x₁ x₂ x₃) D3 D4 (FHFailedCast eps) = TAFailedCast (wt-different-fill x y D3 D4 eps) x₁ x₂ x₃ -- if a well typed term results from filling the hole in ε, then the term -- that filled the hole is also well typed wt-filling : ∀{ ε Δ Γ d τ d' } → Δ , Γ ⊢ d :: τ → d == ε ⟦ d' ⟧ → Σ[ τ' ∈ htyp ] (Δ , Γ ⊢ d' :: τ') wt-filling TAConst FHOuter = _ , TAConst wt-filling (TAVar x₁) FHOuter = _ , TAVar x₁ wt-filling (TALam f ta) FHOuter = _ , TALam f ta wt-filling (TAAp ta ta₁) FHOuter = _ , TAAp ta ta₁ wt-filling (TAAp ta ta₁) (FHAp1 eps) = wt-filling ta eps wt-filling (TAAp ta ta₁) (FHAp2 eps) = wt-filling ta₁ eps wt-filling (TAEHole x x₁) FHOuter = _ , TAEHole x x₁ wt-filling (TANEHole x ta x₁) FHOuter = _ , TANEHole x ta x₁ wt-filling (TANEHole x ta x₁) (FHNEHole eps) = wt-filling ta eps wt-filling (TACast ta x) FHOuter = _ , TACast ta x wt-filling (TACast ta x) (FHCast eps) = wt-filling ta eps wt-filling (TAFailedCast x y z w) FHOuter = _ , TAFailedCast x y z w wt-filling (TAFailedCast x x₁ x₂ x₃) (FHFailedCast y) = wt-filling x y -- instruction transitions preserve type preserve-trans : ∀{ Δ Γ d τ d' } → binders-unique d → Δ , Γ ⊢ d :: τ → d →> d' → Δ , Γ ⊢ d' :: τ preserve-trans bd TAConst () preserve-trans bd (TAVar x₁) () preserve-trans bd (TALam _ ta) () preserve-trans (BUAp (BULam bd x₁) bd₁ (BDLam x₂ x₃)) (TAAp (TALam apt ta) ta₁) ITLam = lem-subst apt x₂ bd₁ ta ta₁ preserve-trans bd (TAAp (TACast ta TCRefl) ta₁) ITApCast = TACast (TAAp ta (TACast ta₁ TCRefl)) TCRefl preserve-trans bd (TAAp (TACast ta (TCArr x x₁)) ta₁) ITApCast = TACast (TAAp ta (TACast ta₁ (~sym x))) x₁ preserve-trans bd (TAEHole x x₁) () preserve-trans bd (TANEHole x ta x₁) () preserve-trans bd (TACast ta x) (ITCastID) = ta preserve-trans bd (TACast (TACast ta x) x₁) (ITCastSucceed x₂) = ta preserve-trans bd (TACast ta x) (ITGround (MGArr x₁)) = TACast (TACast ta (TCArr TCHole1 TCHole1)) TCHole1 preserve-trans bd (TACast ta TCHole2) (ITExpand (MGArr x₁)) = TACast (TACast ta TCHole2) (TCArr TCHole2 TCHole2) preserve-trans bd (TACast (TACast ta x) x₁) (ITCastFail w y z) = TAFailedCast ta w y z preserve-trans bd (TAFailedCast x y z q) () lem-bd-ε1 : ∀{ d ε d0} → d == ε ⟦ d0 ⟧ → binders-unique d → binders-unique d0 lem-bd-ε1 FHOuter bd = bd lem-bd-ε1 (FHAp1 eps) (BUAp bd bd₁ x) = lem-bd-ε1 eps bd lem-bd-ε1 (FHAp2 eps) (BUAp bd bd₁ x) = lem-bd-ε1 eps bd₁ lem-bd-ε1 (FHNEHole eps) (BUNEHole bd x) = lem-bd-ε1 eps bd lem-bd-ε1 (FHCast eps) (BUCast bd) = lem-bd-ε1 eps bd lem-bd-ε1 (FHFailedCast eps) (BUFailedCast bd) = lem-bd-ε1 eps bd -- this is the main preservation theorem, gluing together the above preservation : {Δ : hctx} {d d' : ihexp} {τ : htyp} {Γ : tctx} → binders-unique d → Δ , Γ ⊢ d :: τ → d ↦ d' → Δ , Γ ⊢ d' :: τ preservation bd D (Step x x₁ x₂) with wt-filling D x ... | (_ , wt) = wt-different-fill x D wt (preserve-trans (lem-bd-ε1 x bd) wt x₁) x₂ -- note that the exact statement of preservation in the paper, where Γ is -- empty indicating that the terms are closed, is an immediate corrolary -- of the slightly more general statement above. preservation' : {Δ : hctx} {d d' : ihexp} {τ : htyp} → binders-unique d → Δ , ∅ ⊢ d :: τ → d ↦ d' → Δ , ∅ ⊢ d' :: τ preservation' = preservation
algebraic-stack_agda0000_doc_4296
{-# OPTIONS --without-K --safe #-} module Categories.NaturalTransformation.NaturalIsomorphism.Properties where open import Level open import Categories.Category open import Categories.Category.Instance.Setoids open import Categories.Functor renaming (id to idF) open import Categories.Functor.Construction.LiftSetoids open import Categories.NaturalTransformation.NaturalIsomorphism open import Categories.NaturalTransformation.Properties import Categories.Morphism as Mor import Categories.Morphism.Properties as Morₚ import Categories.Morphism.Reasoning as MR private variable o ℓ e : Level C D : Category o ℓ e module _ {F G : Functor C D} (α : NaturalIsomorphism F G) where private module C = Category C open Category D open Mor D open Functor F open Functor G renaming (F₀ to G₀; F₁ to G₁) open NaturalIsomorphism α -- We can move equations along natural isomorphism. module _ {A B} {f g : A C.⇒ B} where push-eq : F₁ f ≈ F₁ g → G₁ f ≈ G₁ g push-eq hyp = MR.push-eq D FX≅GX (⇒.commute f) (⇒.commute g) hyp pull-eq : G₁ f ≈ G₁ g → F₁ f ≈ F₁ g pull-eq hyp = MR.push-eq D (≅.sym FX≅GX) (⇐.commute f) (⇐.commute g) hyp -- properties of natural isomorphisms over an endofunctor module _ {F : Endofunctor C} where private module C = Category C module F = Functor F module MC = Mor C module _ (α : F ≃ idF) where open C open HomReasoning open F open MC open MR C open Mor C open Morₚ C open NaturalIsomorphism α F≃id-comm₁ : ∀ {A} → ⇒.η (F₀ A) ≈ F₁ (⇒.η A) F≃id-comm₁ {A} = begin ⇒.η (F₀ A) ≈⟨ introʳ (F-resp-≈ (iso.isoˡ _) ○ identity) ⟩ ⇒.η (F₀ A) ∘ F₁ (⇐.η A ∘ ⇒.η A) ≈⟨ refl⟩∘⟨ homomorphism ⟩ ⇒.η (F₀ A) ∘ F₁ (⇐.η A) ∘ F₁ (⇒.η A) ≈⟨ cancelˡ (⇒.commute _ ○ iso.isoˡ _) ⟩ F₁ (⇒.η A) ∎ F≃id-comm₂ : ∀ {A} → ⇐.η (F₀ A) ≈ F₁ (⇐.η A) F≃id-comm₂ {A} = begin ⇐.η (F₀ A) ≈⟨ introˡ (F-resp-≈ (iso.isoˡ _) ○ identity) ⟩ F₁ (⇐.η A ∘ ⇒.η A) ∘ ⇐.η (F₀ A) ≈⟨ homomorphism ⟩∘⟨refl ⟩ (F₁ (⇐.η A) ∘ F₁ (⇒.η A)) ∘ ⇐.η (F₀ A) ≈⟨ cancelʳ (⟺ (⇐.commute _) ○ iso.isoˡ _) ⟩ F₁ (⇐.η A) ∎ F≃id⇒id : ∀ {A} {f : A ⇒ A} → F₁ f ≈ id → f ≈ id F≃id⇒id {A} {f} eq = Iso⇒Mono (Iso-swap (iso A)) _ _ helper where helper : ⇐.η A ∘ f ≈ ⇐.η A ∘ id helper = begin ⇐.η A ∘ f ≈⟨ ⇐.commute f ⟩ F₁ f ∘ ⇐.η A ≈⟨ eq ⟩∘⟨refl ⟩ id ∘ ⇐.η A ≈˘⟨ id-comm ⟩ ⇐.η A ∘ id ∎ -- unlift universe level module _ {c ℓ ℓ′ e} {F G : Functor C (Setoids c ℓ)} (α : LiftSetoids ℓ′ e ∘F F ≃ LiftSetoids ℓ′ e ∘F G) where open NaturalIsomorphism α unlift-≃ : F ≃ G unlift-≃ = record { F⇒G = unlift-nat F⇒G ; F⇐G = unlift-nat F⇐G ; iso = λ X → record { isoˡ = λ eq → lower (iso.isoˡ X (lift eq)) ; isoʳ = λ eq → lower (iso.isoʳ X (lift eq)) } }
algebraic-stack_agda0000_doc_4297
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-} module Light.Implementation.Standard where module Data where module Empty where open import Light.Implementation.Standard.Data.Empty public module Unit where open import Light.Implementation.Standard.Data.Unit public module These where open import Light.Implementation.Standard.Data.These public module Product where open import Light.Implementation.Standard.Data.Product public module Relation where module Decidable where open import Light.Implementation.Standard.Relation.Decidable public module Sets where open import Light.Implementation.Standard.Relation.Sets public
algebraic-stack_agda0000_doc_4298
module Oscar.Data where open import Agda.Builtin.Unit open import Oscar.Function open import Oscar.Level infixr 20 ∷_ infixr 20 _∷_ data NAT : Set where ∅ : NAT ∷_ : NAT → NAT testNAT : NAT testNAT = ∷ ∷ ∷ ∅ -- List data ⟦_⟧ {a} (A : Set a) : Set a where ∅ : ⟦ A ⟧ _∷_ : A → ⟦ A ⟧ → ⟦ A ⟧ -- Nat ⟦⟧ = ⟦ ⊤ ⟧ test⟦⟧ : ⟦⟧ test⟦⟧ = {!(tt ∷_) ∅ !} infix 21 ¡_ pattern ¡_ ⟦A⟧ = tt ∷ ⟦A⟧ --¡ : ⟦⟧ → ⟦⟧ --¡ ⟦A⟧ = tt ∷ ⟦A⟧ -- Fin (with a payload) -- n-1 , ... 0 data ⟦_⟧[_] {a} (A : ⟦⟧ → Set a) : ⟦⟧ → Set a where ∅ : ∀ {n} → ⟦ A ⟧[ ¡ n ] _∷_ : ∀ {n} → A n → ⟦ A ⟧[ n ] → ⟦ A ⟧[ ¡ n ] ⟦⟧[_] = ⟦ const ⊤ ⟧[_] -- Vec (with an (optional) index) -- 0 ≤ n, counting down from n to 0 data ⟦_⟧[_₀] {a} (A : ⟦⟧ → Set a) : ⟦⟧ → Set a where ∅ : ⟦ A ⟧[ ∅ ₀] _∷_ : ∀ {n} → A n → ⟦ A ⟧[ n ₀] → ⟦ A ⟧[ ¡ n ₀] ⟦⟧[_₀] = ⟦ const ⊤ ⟧[_₀] -- Interval↓ -- Interval⟨_⟩[_↙_) -- Descenderval -- m ≤ n, counting down from n-1 to m data ⟦_⟧[_≤_↓] {a} (A : ⟦⟧ → Set a) (m : ⟦⟧) : ⟦⟧ → Set a where ∅ : ⟦ A ⟧[ m ≤ m ↓] _∷_ : ∀ {n} → A n → ⟦ A ⟧[ m ≤ n ↓] → ⟦ A ⟧[ m ≤ ¡ n ↓] ⟦⟧[_≤_↓] = ⟦ const ⊤ ⟧[_≤_↓] -- Fin⟨_⟩ = λ A n → Interval↓ A 0 n -- Vec n = Descenderval 0 (↑ n) -- Interval⟨_⟩[_↗_) -- Ascenderval -- m ≤ n, counting up from m to n-1 data ⟦_⟧[↑_≤_] {a} (A : ⟦⟧ → Set a) (m : ⟦⟧) : ⟦⟧ → Set a where ∅ : ⟦ A ⟧[↑ m ≤ m ] _∷_ : ∀ {n} → A m → ⟦ A ⟧[↑ ¡ m ≤ n ] → ⟦ A ⟧[↑ m ≤ n ] ⟦⟧[↑_≤_] = ⟦ const ⊤ ⟧[↑_≤_] -- Inj (almost) -- m ≤ n, m-1...0, n-1...n-m -- Paradescenderval data ⟦_⟧[↓_≤_↓] {a} (A : ⟦⟧ → ⟦⟧ → Set a) : ⟦⟧ → ⟦⟧ → Set a where ∅ : ∀ {n} → ⟦ A ⟧[↓ ∅ ≤ n ↓] _∷_ : ∀ {m n} → A m n → ⟦ A ⟧[↓ m ≤ n ↓] → ⟦ A ⟧[↓ ¡ m ≤ ¡ n ↓] -- Inj = Paradescenderval (λ _ → Fin ∘ ↑_) ⟦⟧[↓_≤_↓] = ⟦ const const ⊤ ⟧[↓_≤_↓] infix 21 ‼_ pattern ‼_ ⟦A⟧ = tt ∷ ⟦A⟧ -- tricky, works for all above _∷_ constructors only because it is defined afterwards, won't work for any later-defined constructors {- Function (B m → B n) Fin Term AList (SubstitutionList) Substilist Step List FinTerm (SubstitutionFunction) Substifunction SubstitutionFunction.internal SubstitutionFunction.Morphism SubstitutionFunction.IsSemigroupoid SubstitutionFunction.IsCategory IsSemigroupoid IsCategory -} --Nat = ⟦⟧ --Vec : -- mutual -- Terms : Nat → Nat → Set 𝔣 -- Terms N m = Vec (Term m) N -- data Term (m : Nat) : Set 𝔣 where -- i : (x : Fin m) → Term m -- leaf : Term m -- _fork_ : (s t : Term m) → Term m -- function : FunctionName → ∀ {N} → Terms N m → Term m
algebraic-stack_agda0000_doc_4299
open import Agda.Builtin.Nat record R : Set where field x : Nat open R {{...}} f₁ f₂ : R -- This is fine. x ⦃ f₁ ⦄ = 0 -- THIS WORKS BUT MAKES NO SENSE!!! f₂ ⦃ .x ⦄ = 0
algebraic-stack_agda0000_doc_4300
{-# POLARITY F #-}
algebraic-stack_agda0000_doc_4301
module Imports.Issue1913-M where data D : Set where d : D
algebraic-stack_agda0000_doc_4302
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021 Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Prelude open import LibraBFT.Base.PKCS open import LibraBFT.Base.Types import LibraBFT.Yasm.Base as LYB -- This module provides a single import for all Yasm modules module LibraBFT.Yasm.Yasm (ℓ-EC : Level) (EpochConfig : Set ℓ-EC) (epochId : EpochConfig → EpochId) (authorsN : EpochConfig → ℕ) (parms : LYB.SystemParameters ℓ-EC EpochConfig epochId authorsN) (senderPKOK : (ec : EpochConfig) → PK → LYB.SystemParameters.PeerId parms → Set) where open LYB.SystemParameters parms open import LibraBFT.Yasm.AvailableEpochs PeerId ℓ-EC EpochConfig epochId authorsN using (AvailableEpochs) renaming (lookup' to EC-lookup; lookup'' to EC-lookup') public open import LibraBFT.Yasm.Base ℓ-EC EpochConfig epochId authorsN public open import LibraBFT.Yasm.System ℓ-EC EpochConfig epochId authorsN parms public open import LibraBFT.Yasm.Properties ℓ-EC EpochConfig epochId authorsN parms senderPKOK public open import Util.FunctionOverride PeerId _≟PeerId_ public
algebraic-stack_agda0000_doc_4303
module Vehicle.Data.Tensor where open import Level using (Level) open import Data.Empty.Polymorphic using (⊥) open import Data.Nat.Base using (ℕ; zero; suc) open import Data.List.Base using (List; []; _∷_) open import Data.Vec.Functional using (Vector) private variable a : Level A : Set a n : ℕ Tensor : Set a → List ℕ → Set a Tensor A [] = ⊥ Tensor A (n ∷ []) = Vector A n Tensor A (m ∷ n ∷ ns) = Vector (Tensor A (n ∷ ns)) m
algebraic-stack_agda0000_doc_5360
module GUIgeneric.GUIExampleBankAccount where open import GUIgeneric.Prelude renaming (inj₁ to firstBtn; inj₂ to secondBtn; WxColor to Color;_∸_ to _-_) hiding (addButton; _>>_ ; show) open import GUIgeneric.GUIDefinitions renaming (add to add'; add' to add) open import GUIgeneric.GUI open import GUIgeneric.GUIExampleLib renaming (addButton to addButton') open import GUIgeneric.GUIExample hiding (main; changeGUI) open import Data.Nat.Show open import heap.libraryNat renaming (_≧ℕb_ to _≧_) guifullToReturnType : ∀ {i} {g} → GUI {i} → returnType g guifullToReturnType f = changedGUI (f .defFrame) (f .property) guifullToReturnType' : ∀ {i} {g} → GUI {i} → Σ[ r ∈ returnType g ] (IOObjectˢ GuiLev1Interface handlerInterface i (nextStateFrame g r)) guifullToReturnType' {i} {g} f = guifullToReturnType f , f .obj changeGUI : ∀ {i} {g} → GUI {i} → IO GuiLev1Interface ∞ (Σ[ r ∈ returnType g ] (IOObjectˢ GuiLev1Interface handlerInterface i (nextStateFrame g r))) changeGUI f = return (guifullToReturnType' f) threeBtnFrame : (s s' s'' : String) → Frame threeBtnFrame s s' s'' = addButton s (addButton s' (addButton s'' create-frame)) propThreeBtn : ∀{s s' s''} → properties (threeBtnFrame s s' s'') propThreeBtn = black , black , black , oneColumnLayout mutual atm : ∀{i} → ℕ → GUI {i} atm n .defFrame = addButton "Withdraw 10" (addButton "Withdraw 1" (addTxtBox (show n) create-frame)) atm n .property = black , black , black , oneColumnLayout atm n .obj .method (firstBtn x) = if n ≧ 10 then changeGUI (atm (n - 10)) else changeGUI (invalid n) atm n .obj .method (secondBtn b) = if n ≧ 1 then changeGUI (atm (n - 1)) else changeGUI (invalid n) invalid : ∀{i} → ℕ → GUI {i} invalid n .defFrame = addButton "Not enough money" create-frame invalid n .property = black , oneColumnLayout invalid n .obj .method m = changeGUI (atm n) main : NativeIO Unit main = compileGUI (atm 55)
algebraic-stack_agda0000_doc_5361
-- {-# OPTIONS -v 100 -v tc.meta.name:100 -v interactive.meta:10 #-} module Issue526 where -- Don't just write _49, -- include the corresponding implicit variable name as well (if any) postulate f : {A : Set} → {a : A} → Set1 → {B : Set} → Set test : Set test = f Set test₁ : Set test₁ = f {A = _} Set postulate g : (B : Set) → Set test₂ : Set test₂ = g _ test₃ : _ → Set test₃ ()
algebraic-stack_agda0000_doc_5362
module MLib.Prelude.RelProps where open import MLib.Prelude.FromStdlib import Relation.Binary.Indexed as I open FE using (cong) import Data.Product.Relation.SigmaPropositional as OverΣ Σ-bij : ∀ {a b c} {A : Set a} {B : A → Set b} {C : A → Set c} → (∀ x → B x ↔ C x) → Σ A B ↔ Σ A C Σ-bij pw = record { to = ≡.→-to-⟶ (uncurry λ x y → x , Inverse.to (pw x) ⟨$⟩ y) ; from = ≡.→-to-⟶ (uncurry λ x y → x , Inverse.from (pw x) ⟨$⟩ y) ; inverse-of = record { left-inverse-of = uncurry λ x y → OverΣ.to-≡ (≡.refl , Inverse.left-inverse-of (pw x) y) ; right-inverse-of = uncurry λ x y → OverΣ.to-≡ (≡.refl , Inverse.right-inverse-of (pw x) y) } } Σ-↞ : ∀ {a b c} {A : Set a} {B : A → Set b} {C : A → Set c} → (∀ x → B x ↞ C x) → Σ A B ↞ Σ A C Σ-↞ f = record { to = ≡.→-to-⟶ (uncurry λ x y → x , LeftInverse.to (f x) ⟨$⟩ y) ; from = ≡.→-to-⟶ (uncurry λ x y → x , LeftInverse.from (f x) ⟨$⟩ y) ; left-inverse-of = uncurry λ x y → OverΣ.to-≡ (≡.refl , LeftInverse.left-inverse-of (f x) y) } Σ-↞′ : ∀ {a a′ b β} {A : Set a} {A′ : Set a′} {B-setoid : A → Setoid b β} (f : A ↞ A′) → LeftInverse (OverΣ.setoid B-setoid) (OverΣ.setoid (B-setoid ∘ (LeftInverse.from f ⟨$⟩_))) Σ-↞′ {A = A} {A′} {B-setoid} f = record { to = record { _⟨$⟩_ = uncurry λ x y → LeftInverse.to f ⟨$⟩ x , ≡.subst B (≡.sym (LeftInverse.left-inverse-of f _)) y ; cong = uncurry λ {≡.refl y → ≡.refl , subst≈ _ _ (≡.sym (LeftInverse.left-inverse-of f _)) y} } ; from = record { _⟨$⟩_ = uncurry λ x y → LeftInverse.from f ⟨$⟩ x , y ; cong = λ { (≡.refl , q) → ≡.refl , q } } ; left-inverse-of = uncurry λ x y → OverΣ.symmetric sym (OverΣ.subst (≡.sym (LeftInverse.left-inverse-of f _)) refl) } where module B x = Setoid (B-setoid x) module B′ {x} = Setoid (B-setoid x) open B using () renaming (Carrier to B) open B′ subst≈ : ∀ {i j} (x y : B i) (p : i ≡ j) → x ≈ y → ≡.subst B p x ≈ ≡.subst B p y subst≈ x y ≡.refl q = q
algebraic-stack_agda0000_doc_5363
module Imports.A where postulate A : Set
algebraic-stack_agda0000_doc_5364
module _ where import Issue1168 ; module I = Issue1168 import PrettyInterface ; module P = PrettyInterface id : {A : Set} → A → A id {A = A} a = a
algebraic-stack_agda0000_doc_5365
module Dot where postulate h : Set f : Set -> Set -> Set f .n n = h
algebraic-stack_agda0000_doc_5366
{-# OPTIONS --cubical --no-exact-split --safe #-} module Cubical.Data.Nat.Properties where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Data.Nat.Base open import Cubical.Data.Empty open import Cubical.Data.Prod.Base open import Cubical.Relation.Nullary open import Cubical.Relation.Nullary.DecidableEq open import Cubical.Data.Nat.Algebra public +-zero : ∀ m → m + 0 ≡ m +-zero zero = refl +-zero (suc m) = cong suc (+-zero m) +-suc : ∀ m n → m + suc n ≡ suc (m + n) +-suc zero n = refl +-suc (suc m) n = cong suc (+-suc m n) +-comm : ∀ m n → m + n ≡ n + m +-comm m zero = +-zero m +-comm m (suc n) = (+-suc m n) ∙ (cong suc (+-comm m n)) -- Addition is associative +-assoc : ∀ m n o → m + (n + o) ≡ (m + n) + o +-assoc zero _ _ = refl +-assoc (suc m) n o = cong suc (+-assoc m n o) private variable l m n : ℕ znots : ¬ (0 ≡ suc n) znots eq = subst (caseNat ℕ ⊥) eq 0 snotz : ¬ (suc n ≡ 0) snotz eq = subst (caseNat ⊥ ℕ) eq 0 injSuc : suc m ≡ suc n → m ≡ n injSuc p = cong predℕ p inj-m+ : m + l ≡ m + n → l ≡ n inj-m+ {zero} p = p inj-m+ {suc m} p = inj-m+ (injSuc p) inj-+m : l + m ≡ n + m → l ≡ n inj-+m {l} {m} {n} p = inj-m+ ((+-comm m l) ∙ (p ∙ (+-comm n m))) m+n≡n→m≡0 : m + n ≡ n → m ≡ 0 m+n≡n→m≡0 {n = zero} = λ p → (sym (+-zero _)) ∙ p m+n≡n→m≡0 {n = suc n} p = m+n≡n→m≡0 (injSuc ((sym (+-suc _ n)) ∙ p)) m+n≡0→m≡0×n≡0 : m + n ≡ 0 → (m ≡ 0) × (n ≡ 0) m+n≡0→m≡0×n≡0 {zero} = refl ,_ m+n≡0→m≡0×n≡0 {suc m} p = ⊥-elim (snotz p) discreteℕ : Discrete ℕ discreteℕ zero zero = yes refl discreteℕ zero (suc n) = no znots discreteℕ (suc m) zero = no snotz discreteℕ (suc m) (suc n) with discreteℕ m n ... | yes p = yes (cong suc p) ... | no p = no (λ x → p (injSuc x)) isSetℕ : isSet ℕ isSetℕ = Discrete→isSet discreteℕ 0≡m*0 : ∀ m → 0 ≡ m * 0 0≡m*0 zero = refl 0≡m*0 (suc m) = 0≡m*0 m *-suc : ∀ m n → m * suc n ≡ m + m * n *-suc zero n = refl *-suc (suc m) n = cong suc ( n + m * suc n ≡⟨ cong (n +_) (*-suc m n) ⟩ n + (m + m * n) ≡⟨ +-assoc n m (m * n) ⟩ (n + m) + m * n ≡⟨ cong (_+ m * n) (+-comm n m) ⟩ (m + n) + m * n ≡⟨ sym (+-assoc m n (m * n)) ⟩ m + (n + m * n) ∎ ) *-comm : ∀ m n → m * n ≡ n * m *-comm zero n = 0≡m*0 n *-comm (suc m) n = cong (n +_) (*-comm m n) ∙ sym (*-suc n m) 0≡n*sm→0≡n : 0 ≡ n * suc m → 0 ≡ n 0≡n*sm→0≡n {n = zero} p = refl 0≡n*sm→0≡n {n = suc n} p = ⊥-elim (znots p) inj-*sm : l * suc m ≡ n * suc m → l ≡ n inj-*sm {zero} {m} {n} p = 0≡n*sm→0≡n p inj-*sm {l} {m} {zero} p = sym (0≡n*sm→0≡n (sym p)) inj-*sm {suc l} {m} {suc n} p = cong suc (inj-*sm (inj-m+ {m = suc m} p)) inj-sm* : suc m * l ≡ suc m * n → l ≡ n inj-sm* {m} {l} {n} p = inj-*sm (*-comm l (suc m) ∙ p ∙ *-comm (suc m) n)
algebraic-stack_agda0000_doc_5367
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import Haskell.Modules.RWS.RustAnyHow import LibraBFT.Impl.Consensus.ConsensusTypes.BlockRetrieval as BlockRetrieval import LibraBFT.Impl.IO.OBM.ObmNeedFetch as ObmNeedFetch open import LibraBFT.Impl.OBM.Logging.Logging open import LibraBFT.Impl.OBM.Rust.RustTypes open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.Consensus.Types.EpochIndep open import LibraBFT.ImplShared.Util.Dijkstra.All open import Optics.All import Util.KVMap as Map open import Util.Prelude ------------------------------------------------------------------------------ import Data.String as String module LibraBFT.Impl.Consensus.BlockStorage.BlockRetriever where pickPeer : ℕ → List Author → Either ErrLog (Author × List Author) -- LBFT-OBM-DIFF : this lives in sync_manager.rs (in this file to isolate IO) -- TODO-1 PROVE IT TERMINATES {-# TERMINATING #-} retrieveBlockForQCM : BlockRetriever → QuorumCert → U64 → LBFT (Either ErrLog (List Block)) retrieveBlockForQCM _retriever qc numBlocks = loop (qc ^∙ qcCertifiedBlock ∙ biId) 0 (Map.kvm-keys (qc ^∙ qcLedgerInfo ∙ liwsSignatures)) where doLoop : HashValue → ℕ → List Author → LBFT (Either ErrLog (List Block)) logIt : InfoLog → LBFT Unit here' : List String.String → List String.String loop : HashValue → ℕ → List Author → LBFT (Either ErrLog (List Block)) loop blockId attempt = λ where [] → bail fakeErr -- [ "failed to fetch block, no more peers available" -- , lsHV blockId, show attempt ] peers0@(_ ∷ _) → do mme ← use (lRoundManager ∙ rmObmMe) maybeSD mme (bail fakeErr) $ λ me → do nf ← use lObmNeedFetch eitherS (pickPeer attempt peers0) bail $ λ (peer , peers) → do let request = BlockRetrievalRequest∙new me blockId numBlocks logIt fakeInfo -- ["to", lsA peer, lsBRQ request] let response = ObmNeedFetch.writeRequestReadResponseUNSAFE nf me peer request -- TODO : sign response and check sig on response case response ^∙ brpStatus of λ where BRSSucceeded → do logIt fakeInfo -- (here [lsBRP response]) vv ← use (lRoundManager ∙ rmEpochState ∙ esVerifier) -- LBFT-OBM-DIFF/TODO : this should live in a "network" module case BlockRetrieval.verify response (request ^∙ brqBlockId) (request ^∙ brqNumBlocks) vv of λ where (Left e) → bail (withErrCtx (here' []) e) (Right _) → ok (response ^∙ brpBlocks) BRSIdNotFound → doLoop blockId attempt peers BRSNotEnoughBlocks → doLoop blockId attempt peers doLoop blockId attempt peers = do logIt fakeInfo -- (here' ["trying another peer", lsBRP response]) loop blockId (attempt + 1) peers here' t = "BlockRetriever" ∷ "retrieveBlockForQCM" ∷ "NeedFetch" ∷ t logIt l = -- do logInfo l -- let x = Unsafe.unsafePerformIO (putStrLn @Text (show l)) -- x `seq` pure x pickPeer _ = λ where [] → Left fakeErr -- ["no more peers"] (p ∷ ps) → pure (p , ps)
algebraic-stack_agda0000_doc_5368
module Data.BitVector.ContainmentOrder where open import Data.Empty open import Data.Sum open import Data.Vec open import Relation.Nullary open import Relation.Binary open import Relation.Binary.PropositionalEquality open import Data.Nat hiding (_≟_; _≤_; _≤?_) renaming (zero to Nzero; suc to Nsuc) open import Data.BitVector infix 4 _⊂_ data _⊂_ : ∀ {n} → BitVector n → BitVector n → Set where []⊂[] : [] ⊂ [] 0#⊂0# : ∀ {n} {x y : BitVector n} → (x⊂y : x ⊂ y) → (0# ∷ x) ⊂ (0# ∷ y) b⊂1# : ∀ {n} {x y : BitVector n} {b} → (x⊂y : x ⊂ y) → (b ∷ x) ⊂ (1# ∷ y) ⊂-refl : ∀ {n} → _≡_ ⇒ (_⊂_ {n}) ⊂-refl {0} {[]} refl = []⊂[] ⊂-refl {Nsuc n} {0# ∷ xs} refl = 0#⊂0# (⊂-refl refl) ⊂-refl {Nsuc n} {1# ∷ xs} refl = b⊂1# (⊂-refl refl) ⊂-antisym : ∀ {n} → Antisymmetric _≡_ (_⊂_ {n}) ⊂-antisym []⊂[] []⊂[] = refl ⊂-antisym (0#⊂0# x⊂y) (0#⊂0# y⊂x) rewrite ⊂-antisym x⊂y y⊂x = refl ⊂-antisym (b⊂1# x⊂y) (b⊂1# y⊂x) rewrite ⊂-antisym x⊂y y⊂x = refl ⊂-trans : ∀ {n} → Transitive (_⊂_ {n}) ⊂-trans []⊂[] []⊂[] = []⊂[] ⊂-trans (0#⊂0# x⊂y) (0#⊂0# y⊂z) = 0#⊂0# (⊂-trans x⊂y y⊂z) ⊂-trans (0#⊂0# x⊂y) (b⊂1# y⊂z) = b⊂1# (⊂-trans x⊂y y⊂z) ⊂-trans (b⊂1# x⊂y) (b⊂1# y⊂z) = b⊂1# (⊂-trans x⊂y y⊂z) _⊂?_ : ∀ {n} → Decidable (_⊂_ {n}) [] ⊂? [] = yes []⊂[] (x ∷ xs) ⊂? (y ∷ ys) with xs ⊂? ys (0# ∷ xs) ⊂? (0# ∷ ys) | no xs≢ys = no helper where helper : ¬ 0# ∷ xs ⊂ 0# ∷ ys helper (0#⊂0# pf) = xs≢ys pf (x ∷ xs) ⊂? (1# ∷ ys) | no xs≢ys = no helper where helper : ¬ x ∷ xs ⊂ 1# ∷ ys helper (b⊂1# pf) = xs≢ys pf (1# ∷ xs) ⊂? (0# ∷ ys) | no xs≢ys = no (λ ()) (0# ∷ xs) ⊂? (0# ∷ ys) | yes xs≡ys = yes (0#⊂0# xs≡ys) (0# ∷ xs) ⊂? (1# ∷ ys) | yes xs≡ys = yes (b⊂1# xs≡ys) (1# ∷ xs) ⊂? (0# ∷ ys) | yes xs≡ys = no (λ ()) (1# ∷ xs) ⊂? (1# ∷ ys) | yes xs≡ys = yes (b⊂1# xs≡ys) decPoset : ∀ {n} → DecPoset _ _ _ decPoset {n} = record { Carrier = BitVector n ; _≈_ = _≡_ ; _≤_ = _⊂_ ; isDecPartialOrder = record { isPartialOrder = record { isPreorder = record { isEquivalence = isEquivalence ; reflexive = ⊂-refl ; trans = ⊂-trans } ; antisym = ⊂-antisym } ; _≟_ = _≟_ ; _≤?_ = _⊂?_ } }
algebraic-stack_agda0000_doc_5369
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties of sums (disjoint unions) ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Sum.Properties where open import Level open import Data.Sum.Base open import Function open import Relation.Binary using (Decidable) open import Relation.Binary.PropositionalEquality open import Relation.Nullary using (yes; no) open import Relation.Nullary.Decidable using (map′) private variable a b c d e f : Level A : Set a B : Set b C : Set c D : Set d E : Set e F : Set f inj₁-injective : ∀ {x y} → (A ⊎ B ∋ inj₁ x) ≡ inj₁ y → x ≡ y inj₁-injective refl = refl inj₂-injective : ∀ {x y} → (A ⊎ B ∋ inj₂ x) ≡ inj₂ y → x ≡ y inj₂-injective refl = refl module _ (dec₁ : Decidable {A = A} {B = A} _≡_) (dec₂ : Decidable {A = B} {B = B} _≡_) where ≡-dec : Decidable {A = A ⊎ B} _≡_ ≡-dec (inj₁ x) (inj₁ y) = map′ (cong inj₁) inj₁-injective (dec₁ x y) ≡-dec (inj₁ x) (inj₂ y) = no λ() ≡-dec (inj₂ x) (inj₁ y) = no λ() ≡-dec (inj₂ x) (inj₂ y) = map′ (cong inj₂) inj₂-injective (dec₂ x y) swap-involutive : swap {A = A} {B = B} ∘ swap ≗ id swap-involutive = [ (λ _ → refl) , (λ _ → refl) ] [,]-∘-distr : {f : A → B} {g : C → A} {h : D → A} → f ∘ [ g , h ] ≗ [ f ∘ g , f ∘ h ] [,]-∘-distr (inj₁ _) = refl [,]-∘-distr (inj₂ _) = refl [,]-map-commute : {f : A → B} {g : C → D} {f′ : B → E} {g′ : D → E} → [ f′ , g′ ] ∘ (map f g) ≗ [ f′ ∘ f , g′ ∘ g ] [,]-map-commute (inj₁ _) = refl [,]-map-commute (inj₂ _) = refl map-commute : {f : A → B} {g : C → D} {f′ : B → E} {g′ : D → F} → ((map f′ g′) ∘ (map f g)) ≗ map (f′ ∘ f) (g′ ∘ g) map-commute (inj₁ _) = refl map-commute (inj₂ _) = refl
algebraic-stack_agda0000_doc_5370
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Displayed.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.Univalence using (pathToEquiv) open import Cubical.Functions.FunExtEquiv open import Cubical.Data.Unit open import Cubical.Data.Nat open import Cubical.Data.Sigma open import Cubical.Relation.Binary open BinaryRelation open import Cubical.Displayed.Base private variable ℓ ℓA ℓA' ℓP ℓ≅A ℓ≅A' ℓB ℓB' ℓ≅B ℓ≅B' ℓC ℓ≅C : Level -- UARel on Σ-type module _ {A : Type ℓA} {ℓ≅A : Level} {𝒮-A : UARel A ℓ≅A} {B : A → Type ℓB} {ℓ≅B : Level} (𝒮ᴰ-B : DUARel 𝒮-A B ℓ≅B) where open UARel 𝒮-A open DUARel 𝒮ᴰ-B ∫ : UARel (Σ A B) (ℓ-max ℓ≅A ℓ≅B) UARel._≅_ ∫ (a , b) (a' , b') = Σ[ p ∈ a ≅ a' ] (b ≅ᴰ⟨ p ⟩ b') UARel.ua ∫ (a , b) (a' , b') = compEquiv (Σ-cong-equiv (ua a a') (λ p → uaᴰ b p b')) ΣPath≃PathΣ -- UARel on Π-type module _ {A : Type ℓA} (𝒮-A : UARel A ℓ≅A) {B : A → Type ℓB} (𝒮ᴰ-B : DUARel 𝒮-A B ℓ≅B) where open UARel 𝒮-A open DUARel 𝒮ᴰ-B 𝒮ᴰ→𝒮-Π : UARel ((a : A) → B a) (ℓ-max ℓA ℓ≅B) UARel._≅_ 𝒮ᴰ→𝒮-Π f f' = ∀ a → f a ≅ᴰ⟨ ρ a ⟩ f' a UARel.ua 𝒮ᴰ→𝒮-Π f f' = compEquiv (equivΠCod λ a → uaᴰρ (f a) (f' a)) funExtEquiv -- induction principles module _ {A : Type ℓA} {ℓ≅A : Level} (𝒮-A : UARel A ℓ≅A) where open UARel 𝒮-A 𝒮-J : {a : A} (P : (a' : A) → (p : a ≡ a') → Type ℓ) (d : P a refl) {a' : A} (p : a ≅ a') → P a' (≅→≡ p) 𝒮-J {a} P d {a'} p = J (λ y q → P y q) d (≅→≡ p) 𝒮-J-2 : {a : A} (P : (a' : A) → (p : a ≅ a') → Type ℓ) (d : P a (ρ a)) {a' : A} (p : a ≅ a') → P a' p 𝒮-J-2 {a = a} P d {a'} p = subst (λ r → P a' r) (Iso.leftInv (uaIso a a') p) g where g : P a' (≡→≅ (≅→≡ p)) g = J (λ y q → P y (≡→≅ q)) d (≅→≡ p) -- constructors module _ {A : Type ℓA} {𝒮-A : UARel A ℓ≅A} {B : A → Type ℓB} (_≅ᴰ⟨_⟩_ : {a a' : A} → B a → UARel._≅_ 𝒮-A a a' → B a' → Type ℓ≅B) where open UARel 𝒮-A -- constructor that reduces ua to the case where p = ρ a by induction on p private 𝒮ᴰ-make-aux : (uni : {a : A} (b b' : B a) → b ≅ᴰ⟨ ρ a ⟩ b' ≃ (b ≡ b')) → ({a a' : A} (b : B a) (p : a ≅ a') (b' : B a') → (b ≅ᴰ⟨ p ⟩ b') ≃ PathP (λ i → B (≅→≡ p i)) b b') 𝒮ᴰ-make-aux uni {a} {a'} b p = 𝒮-J-2 𝒮-A (λ y q → (b' : B y) → (b ≅ᴰ⟨ q ⟩ b') ≃ PathP (λ i → B (≅→≡ q i)) b b') (λ b' → uni' b') p where g : (b' : B a) → (b ≡ b') ≡ PathP (λ i → B (≅→≡ (ρ a) i)) b b' g b' = subst (λ r → (b ≡ b') ≡ PathP (λ i → B (r i)) b b') (sym (Iso.rightInv (uaIso a a) refl)) refl uni' : (b' : B a) → b ≅ᴰ⟨ ρ a ⟩ b' ≃ PathP (λ i → B (≅→≡ (ρ a) i)) b b' uni' b' = compEquiv (uni b b') (pathToEquiv (g b')) 𝒮ᴰ-make-1 : (uni : {a : A} (b b' : B a) → b ≅ᴰ⟨ ρ a ⟩ b' ≃ (b ≡ b')) → DUARel 𝒮-A B ℓ≅B DUARel._≅ᴰ⟨_⟩_ (𝒮ᴰ-make-1 uni) = _≅ᴰ⟨_⟩_ DUARel.uaᴰ (𝒮ᴰ-make-1 uni) = 𝒮ᴰ-make-aux uni -- constructor that reduces univalence further to contractibility of relational singletons 𝒮ᴰ-make-2 : (ρᴰ : {a : A} → isRefl _≅ᴰ⟨ ρ a ⟩_) (contrTotal : (a : A) → contrRelSingl _≅ᴰ⟨ UARel.ρ 𝒮-A a ⟩_) → DUARel 𝒮-A B ℓ≅B DUARel._≅ᴰ⟨_⟩_ (𝒮ᴰ-make-2 ρᴰ contrTotal) = _≅ᴰ⟨_⟩_ DUARel.uaᴰ (𝒮ᴰ-make-2 ρᴰ contrTotal) = 𝒮ᴰ-make-aux (contrRelSingl→isUnivalent _ ρᴰ (contrTotal _)) -- lifts module _ {A : Type ℓA} (𝒮-A : UARel A ℓ≅A) {B : A → Type ℓB} {ℓ≅B : Level} (𝒮ᴰ-B : DUARel 𝒮-A B ℓ≅B) {C : A → Type ℓC} (𝒮ᴰ-C : DUARel 𝒮-A C ℓ≅C) where open DUARel 𝒮ᴰ-B Lift-𝒮ᴰ : DUARel (∫ 𝒮ᴰ-C) (λ (a , _) → B a) ℓ≅B DUARel._≅ᴰ⟨_⟩_ Lift-𝒮ᴰ b p b' = b ≅ᴰ⟨ p .fst ⟩ b' DUARel.uaᴰ Lift-𝒮ᴰ b p b' = uaᴰ b (p .fst) b' -- associativity module _ {A : Type ℓA} (𝒮-A : UARel A ℓ≅A) {B : A → Type ℓB} {ℓ≅B : Level} (𝒮ᴰ-B : DUARel 𝒮-A B ℓ≅B) {C : Σ A B → Type ℓC} {ℓ≅C : Level} (𝒮ᴰ-C : DUARel (∫ 𝒮ᴰ-B) C ℓ≅C) where open UARel 𝒮-A open DUARel 𝒮ᴰ-B renaming (_≅ᴰ⟨_⟩_ to _≅B⟨_⟩_ ; uaᴰ to uaB) open DUARel 𝒮ᴰ-C renaming (_≅ᴰ⟨_⟩_ to _≅C⟨_⟩_ ; uaᴰ to uaC) splitTotal-𝒮ᴰ : DUARel 𝒮-A (λ a → Σ[ b ∈ B a ] C (a , b)) (ℓ-max ℓ≅B ℓ≅C) DUARel._≅ᴰ⟨_⟩_ splitTotal-𝒮ᴰ (b , c) p (b' , c') = Σ[ q ∈ b ≅B⟨ p ⟩ b' ] (c ≅C⟨ p , q ⟩ c') DUARel.uaᴰ splitTotal-𝒮ᴰ (b , c) p (b' , c') = compEquiv (Σ-cong-equiv (uaB b p b') (λ q → uaC c (p , q) c')) ΣPath≃PathΣ -- combination module _ {A : Type ℓA} {𝒮-A : UARel A ℓ≅A} {B : A → Type ℓB} {ℓ≅B : Level} (𝒮ᴰ-B : DUARel 𝒮-A B ℓ≅B) {C : A → Type ℓC} {ℓ≅C : Level} (𝒮ᴰ-C : DUARel 𝒮-A C ℓ≅C) where _×𝒮ᴰ_ : DUARel 𝒮-A (λ a → B a × C a) (ℓ-max ℓ≅B ℓ≅C) _×𝒮ᴰ_ = splitTotal-𝒮ᴰ 𝒮-A 𝒮ᴰ-B (Lift-𝒮ᴰ 𝒮-A 𝒮ᴰ-C 𝒮ᴰ-B) -- constant displayed structure module _ {A : Type ℓA} (𝒮-A : UARel A ℓ≅A) {B : Type ℓB} (𝒮-B : UARel B ℓ≅B) where open UARel 𝒮-B open DUARel 𝒮ᴰ-const : DUARel 𝒮-A (λ _ → B) ℓ≅B 𝒮ᴰ-const ._≅ᴰ⟨_⟩_ b _ b' = b ≅ b' 𝒮ᴰ-const .uaᴰ b p b' = ua b b' -- UARel product _×𝒮_ : UARel (A × B) (ℓ-max ℓ≅A ℓ≅B) _×𝒮_ = ∫ 𝒮ᴰ-const -- relational isomorphisms 𝒮-iso→iso : {A : Type ℓA} (𝒮-A : UARel A ℓ≅A) {B : Type ℓB} (𝒮-B : UARel B ℓ≅B) (F : RelIso (UARel._≅_ 𝒮-A) (UARel._≅_ 𝒮-B)) → Iso A B 𝒮-iso→iso 𝒮-A 𝒮-B F = RelIso→Iso (UARel._≅_ 𝒮-A) (UARel._≅_ 𝒮-B) (UARel.≅→≡ 𝒮-A) (UARel.≅→≡ 𝒮-B) F -- fiberwise relational isomorphisms module _ {A : Type ℓA} {𝒮-A : UARel A ℓ≅A} {A' : Type ℓA'} {𝒮-A' : UARel A' ℓ≅A'} (F : Iso A A') {B : A → Type ℓB} (𝒮ᴰ-B : DUARel 𝒮-A B ℓ≅B) {B' : A' → Type ℓB'} (𝒮ᴰ-B' : DUARel 𝒮-A' B' ℓ≅B') where open UARel 𝒮-A open DUARel 𝒮ᴰ-B renaming (_≅ᴰ⟨_⟩_ to _≅B⟨_⟩_ ; uaᴰ to uaB ; fiberRel to fiberRelB ; uaᴰρ to uaᴰρB) open DUARel 𝒮ᴰ-B' renaming (_≅ᴰ⟨_⟩_ to _≅B'⟨_⟩_ ; uaᴰ to uaB' ; fiberRel to fiberRelB' ; uaᴰρ to uaᴰρB') private f = Iso.fun F -- the following can of course be done slightly more generally -- for fiberwise binary relations F*fiberRelB' : (a : A) → Rel (B' (f a)) (B' (f a)) ℓ≅B' F*fiberRelB' a = fiberRelB' (f a) module _ (G : (a : A) → RelIso (fiberRelB a) (F*fiberRelB' a)) where private fiberIsoOver : (a : A) → Iso (B a) (B' (f a)) fiberIsoOver a = RelIso→Iso (fiberRelB a) (F*fiberRelB' a) (equivFun (uaᴰρB _ _)) (equivFun (uaᴰρB' _ _)) (G a) -- DUARelFiberIsoOver→TotalIso produces an isomorphism of total spaces -- from a relational isomorphism between B a and (F * B) a 𝒮ᴰ-fiberIsoOver→totalIso : Iso (Σ A B) (Σ A' B') 𝒮ᴰ-fiberIsoOver→totalIso = Σ-cong-iso F fiberIsoOver -- Special cases: -- Subtypes 𝒮-type : (A : Type ℓ) → UARel A ℓ UARel._≅_ (𝒮-type A) = _≡_ UARel.ua (𝒮-type A) a a' = idEquiv (a ≡ a') module _ {A : Type ℓA} (𝒮-A : UARel A ℓ≅A) where 𝒮ᴰ-subtype : (P : A → hProp ℓP) → DUARel 𝒮-A (λ a → P a .fst) ℓ-zero 𝒮ᴰ-subtype P = 𝒮ᴰ-make-2 (λ _ _ _ → Unit) (λ _ → tt) λ a p → isOfHLevelRespectEquiv 0 (invEquiv (Σ-contractSnd (λ _ → isContrUnit))) (inhProp→isContr p (P a .snd))
algebraic-stack_agda0000_doc_5371
{- This file contains: - the abelianization of groups as a coequalizer of sets as performed in https://1lab.dev/Algebra.Group.Ab.Free.html - the proof that this way of defining the abelianization of groups is equivalent to defining it as a HIT, more precisely that there is a unique isomorphism between the resulting abelian groups -} {-# OPTIONS --safe #-} module Cubical.Algebra.Group.Abelianization.AbelianizationAsCoeq where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Data.Sigma open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Group.Properties open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties using (isPropIsGroupHom; compGroupHom; idGroupHom; compGroupHomAssoc; invGroupIso; compGroupHomId; GroupIso≡; GroupIso→GroupHom) open import Cubical.Algebra.AbGroup.Base open import Cubical.HITs.SetCoequalizer open import Cubical.Algebra.Group.Abelianization.Base renaming (Abelianization to HITAbelianization; η to HITη; comm to HITcomm; isset to HITisset) open import Cubical.Algebra.Group.Abelianization.Properties hiding (elimProp; elimProp2; elimProp3; elimContr; elimContr2; rec; rec2) renaming (AbelianizationAbGroup to HITasAbelianGroup; AbelianizationHom to HITηAsGroupHom) open Cubical.Algebra.Group.Abelianization.Properties.UniversalProperty renaming (inducedHom to HITinducedHom; commutativity to HITcommutativity; uniqueness to HITuniqueness) private variable ℓ : Level G : Group ℓ module AbelianizationAsCoeq (G : Group ℓ) where open GroupStr {{...}} open GroupTheory G private instance _ = snd G G' = fst G {- The definition of the abelianization of a group as a coequalizer of sets. The generality of the coequalized functions will be needed to define the group structure on the abelianization. -} Abelianization : Type ℓ Abelianization = SetCoequalizer {A = G' × G' × G'} {B = G'} (λ (x , y , z) → x · y · z) (λ (x , y , z) → x · z · y) -- some convenient relabellings, so it looks more similar to the abelianization as a HIT. incAb : G' → Abelianization incAb = inc comm : (x y z : G') → incAb (x · (y · z)) ≡ incAb (x · (z · y)) comm = λ x y z → coeq (x , y , z) {- Definition of the group structure on the abelianization. Here the generality of the coequalized functions is used. -} _·Ab_ : Abelianization → Abelianization → Abelianization _·Ab_ = rec2 squash (λ x y → incAb (x · y)) (λ (a , b , c) d → incAb ((a · (b · c)) · d) ≡⟨ cong (λ x → incAb (x · d)) (assoc _ _ _) ⟩ incAb (((a · b) · c) · d) ≡⟨ cong incAb (sym (assoc (a · b) c d)) ⟩ incAb ((a · b) · (c · d)) ≡⟨ comm (a · b) c d ⟩ incAb ((a · b) · (d · c)) ≡⟨ cong incAb (sym (assoc _ _ _)) ⟩ incAb (a · (b · (d · c))) ≡⟨ cong (λ x → incAb (a · x)) (assoc _ _ _) ⟩ incAb (a · ((b · d) · c)) ≡⟨ comm a (b · d) c ⟩ incAb (a · (c · (b · d))) ≡⟨ cong (λ x → incAb (a · x)) (assoc _ _ _) ⟩ incAb (a · ((c · b) · d)) ≡⟨ cong incAb (assoc a (c · b) d) ⟩ incAb ((a · (c · b)) · d) ∎) (λ (b , c , d) a → incAb (a · (b · (c · d))) ≡⟨ cong incAb (assoc _ _ _) ⟩ incAb ((a · b) · (c · d)) ≡⟨ comm (a · b) c d ⟩ incAb ((a · b) · (d · c)) ≡⟨ cong incAb (sym (assoc _ _ _)) ⟩ incAb (a · (b · (d · c))) ∎) 1Ab : Abelianization 1Ab = incAb 1g invAb : Abelianization → Abelianization invAb = rec squash (λ x → incAb (inv x)) (λ (a , b , c) → incAb (inv (a · (b · c))) ≡⟨ cong incAb (invDistr a (b · c)) ⟩ incAb (inv (b · c) · inv a) ≡⟨ cong (λ x → incAb (x · inv a)) (invDistr b c) ⟩ incAb ((inv c · inv b) · inv a) ≡⟨ cong incAb (sym (lid ((inv c · inv b) · inv a))) ⟩ incAb (1g · ((inv c · inv b) · inv a)) ≡⟨ comm 1g (inv c · inv b) (inv a) ⟩ incAb (1g · (inv a · (inv c · inv b))) ≡⟨ cong incAb (lid (inv a · (inv c · inv b))) ⟩ incAb (inv a · (inv c · inv b)) ≡⟨ comm (inv a) (inv c) (inv b) ⟩ incAb (inv a · (inv b · inv c)) ≡⟨ cong incAb (sym (lid (inv a · (inv b · inv c)))) ⟩ incAb (1g · (inv a · (inv b · inv c))) ≡⟨ comm 1g (inv a) (inv b · inv c) ⟩ incAb (1g · ((inv b · inv c) · inv a)) ≡⟨ cong incAb (lid ((inv b · inv c) · inv a)) ⟩ incAb ((inv b · inv c) · inv a) ≡⟨ cong (λ x → incAb (x · inv a)) (sym (invDistr c b)) ⟩ incAb (inv (c · b) · inv a) ≡⟨ cong incAb (sym (invDistr a (c · b))) ⟩ incAb (inv (a · (c · b))) ∎) assocAb : (x y z : Abelianization) → x ·Ab (y ·Ab z) ≡ (x ·Ab y) ·Ab z assocAb = elimProp3 (λ x y z → squash (x ·Ab (y ·Ab z)) ((x ·Ab y) ·Ab z)) (λ x y z → cong incAb (assoc x y z)) ridAb : (x : Abelianization) → x ·Ab 1Ab ≡ x ridAb = elimProp (λ x → squash (x ·Ab 1Ab) x) (λ x → cong incAb (rid x)) rinvAb : (x : Abelianization) → x ·Ab (invAb x) ≡ 1Ab rinvAb = elimProp (λ x → squash (x ·Ab (invAb x)) 1Ab) (λ x → (incAb x) ·Ab (invAb (incAb x)) ≡⟨ refl ⟩ (incAb x) ·Ab (incAb (inv x)) ≡⟨ refl ⟩ incAb (x · (inv x)) ≡⟨ cong incAb (fst (inverse x)) ⟩ incAb 1g ≡⟨ refl ⟩ 1Ab ∎) commAb : (x y : Abelianization) → x ·Ab y ≡ y ·Ab x commAb = elimProp2 (λ x y → squash (x ·Ab y) (y ·Ab x)) (λ x y → (incAb x) ·Ab (incAb y) ≡⟨ refl ⟩ incAb (x · y) ≡⟨ cong incAb (sym (lid (x · y))) ⟩ incAb (1g · (x · y)) ≡⟨ comm 1g x y ⟩ incAb (1g · (y · x)) ≡⟨ cong incAb (lid (y · x)) ⟩ incAb (y · x) ≡⟨ refl ⟩ (incAb y) ·Ab (incAb x) ∎) -- The proof that the abelianization is in fact an abelian group. asAbelianGroup : AbGroup ℓ asAbelianGroup = makeAbGroup 1Ab _·Ab_ invAb squash assocAb ridAb rinvAb commAb -- The proof that incAb can be seen as a group homomorphism incAbAsGroupHom : GroupHom G (AbGroup→Group asAbelianGroup) incAbAsGroupHom = f , fIsHom where f = λ x → incAb x fIsHom : IsGroupHom (snd G) f (snd (AbGroup→Group asAbelianGroup)) IsGroupHom.pres· fIsHom = λ x y → refl IsGroupHom.pres1 fIsHom = refl IsGroupHom.presinv fIsHom = λ x → refl AbelianizationAbGroup : (G : Group ℓ) → AbGroup ℓ AbelianizationAbGroup G = AbelianizationAsCoeq.asAbelianGroup G AbelianizationHom : (G : Group ℓ) → GroupHom G (AbGroup→Group (AbelianizationAbGroup G)) AbelianizationHom G = AbelianizationAsCoeq.incAbAsGroupHom G module UniversalPropertyCoeq (G : Group ℓ) where open GroupStr {{...}} open GroupTheory G open AbelianizationAsCoeq G private instance _ = snd G G' = fst G abstract {- The proof of the universal property of the abelianization. G -incAb-> Abelianization \ . \ . f ∃! inducedHom \ . \ . H commuting diagram -} inducedHom : (H : AbGroup ℓ) → (f : GroupHom G (AbGroup→Group H)) → AbGroupHom asAbelianGroup H inducedHom H f = g , gIsHom where open IsGroupHom instance _ : GroupStr (fst H) _ = snd (AbGroup→Group H) f' : fst G → fst H f' = fst f g : Abelianization → fst H g = rec (isSetAbGroup H) (λ x → (f') x) (λ (a , b , c) → f' (a · b · c) ≡⟨ (snd f).pres· a (b · c) ⟩ (f' a) · (f' (b · c)) ≡⟨ cong (λ x → (f' a) · x) ((snd f).pres· b c) ⟩ (f' a) · (f' b) · (f' c) ≡⟨ cong (λ x → (f' a) · x) ((snd H).AbGroupStr.comm (f' b) (f' c)) ⟩ (f' a) · (f' c) · (f' b) ≡⟨ cong (λ x → (f' a) · x) (sym ((snd f).pres· c b)) ⟩ (f' a) · (f' (c · b)) ≡⟨ sym ((snd f).pres· a (c · b)) ⟩ f' (a · c · b) ∎) gIsHom : IsGroupHom (snd (AbGroup→Group asAbelianGroup)) g (snd (AbGroup→Group H)) pres· gIsHom = elimProp2 (λ x y → isSetAbGroup H _ _) ((snd f).pres·) pres1 gIsHom = (snd f).pres1 presinv gIsHom = elimProp (λ x → isSetAbGroup H _ _) ((snd f).presinv) commutativity : (H : AbGroup ℓ) → (f : GroupHom G (AbGroup→Group H)) → (compGroupHom incAbAsGroupHom (inducedHom H f) ≡ f) commutativity H f = Σ≡Prop (λ _ → isPropIsGroupHom _ _) (λ i x → q x i) where q : (x : fst G) → fst (compGroupHom incAbAsGroupHom (inducedHom H f)) x ≡ fst f x q = (λ x → refl) uniqueness : (H : AbGroup ℓ) → (f : GroupHom G (AbGroup→Group H)) → (g : AbGroupHom asAbelianGroup H) → (p : compGroupHom incAbAsGroupHom g ≡ f) → (g ≡ inducedHom H f) uniqueness H f g p = Σ≡Prop (λ _ → isPropIsGroupHom _ _) (λ i x → q x i) where q : (x : Abelianization) → fst g x ≡ fst (inducedHom H f) x q = elimProp (λ _ → isSetAbGroup H _ _) (λ x → fst g (incAb x) ≡⟨ cong (λ f → f x) (cong fst p) ⟩ (fst f) x ≡⟨ refl ⟩ fst (inducedHom H f) (incAb x)∎) module IsoCoeqHIT (G : Group ℓ) where open GroupStr {{...}} open GroupTheory G open AbelianizationAsCoeq G open UniversalPropertyCoeq G private instance _ = snd G G' = fst G {- The proof that defining the abelianization of groups as a coequalizer of sets is equivalent to defining it as a HIT, more precisely that there is an isomorphism between the resulting abelian groups unique with respect to commuting with the constructors η and inc. G -incAb-> abelianization as coequalizer \ . \ . η ∃! isomorphism \ . \ . abelianization as HIT commuting diagram -} isomorphism : AbGroupIso asAbelianGroup (HITasAbelianGroup G) isomorphism = h , hIsHomo where f = inducedHom (HITasAbelianGroup G) (HITηAsGroupHom G) g = HITinducedHom G asAbelianGroup incAbAsGroupHom HITgfcomm : compGroupHom (HITηAsGroupHom G) (compGroupHom g f) ≡ (HITηAsGroupHom G) HITgfcomm = compGroupHom (HITηAsGroupHom G) (compGroupHom g f) ≡⟨ sym (compGroupHomAssoc (HITηAsGroupHom G) g f) ⟩ compGroupHom (compGroupHom (HITηAsGroupHom G) g) f ≡⟨ cong (λ x → compGroupHom x f) (HITcommutativity G asAbelianGroup incAbAsGroupHom) ⟩ compGroupHom incAbAsGroupHom f ≡⟨ commutativity (HITasAbelianGroup G) (HITηAsGroupHom G) ⟩ (HITηAsGroupHom G) ∎ HITidcomm : compGroupHom (HITηAsGroupHom G) idGroupHom ≡ HITηAsGroupHom G HITidcomm = compGroupHomId (HITηAsGroupHom G) HITidIsInduced : HITinducedHom G (HITasAbelianGroup G) (HITηAsGroupHom G) ≡ idGroupHom HITidIsInduced = sym (HITuniqueness G (HITasAbelianGroup G) (HITηAsGroupHom G) idGroupHom HITidcomm) HITgfIsInduced : HITinducedHom G (HITasAbelianGroup G) (HITηAsGroupHom G) ≡ compGroupHom g f HITgfIsInduced = sym (HITuniqueness G (HITasAbelianGroup G) (HITηAsGroupHom G) (compGroupHom g f) HITgfcomm) i : idGroupHom ≡ compGroupHom g f i = idGroupHom ≡⟨ sym HITidIsInduced ⟩ HITinducedHom G (HITasAbelianGroup G) (HITηAsGroupHom G) ≡⟨ HITgfIsInduced ⟩ compGroupHom g f ∎ fgcomm : compGroupHom incAbAsGroupHom (compGroupHom f g) ≡ incAbAsGroupHom fgcomm = compGroupHom incAbAsGroupHom (compGroupHom f g) ≡⟨ sym (compGroupHomAssoc incAbAsGroupHom f g) ⟩ compGroupHom (compGroupHom incAbAsGroupHom f) g ≡⟨ cong (λ x → compGroupHom x g) (commutativity (HITasAbelianGroup G) (HITηAsGroupHom G)) ⟩ compGroupHom (HITηAsGroupHom G) g ≡⟨ (HITcommutativity G) asAbelianGroup incAbAsGroupHom ⟩ incAbAsGroupHom ∎ idcomm : compGroupHom incAbAsGroupHom idGroupHom ≡ incAbAsGroupHom idcomm = compGroupHomId incAbAsGroupHom idIsInduced : inducedHom asAbelianGroup incAbAsGroupHom ≡ idGroupHom idIsInduced = sym (uniqueness asAbelianGroup incAbAsGroupHom idGroupHom idcomm) fgIsInduced : inducedHom asAbelianGroup incAbAsGroupHom ≡ compGroupHom f g fgIsInduced = sym (uniqueness asAbelianGroup incAbAsGroupHom (compGroupHom f g) fgcomm) j : idGroupHom ≡ compGroupHom f g j = idGroupHom ≡⟨ sym idIsInduced ⟩ inducedHom asAbelianGroup incAbAsGroupHom ≡⟨ fgIsInduced ⟩ compGroupHom f g ∎ h = iso (fst f) (fst g) (λ b → cong (λ e → e b) (cong fst (sym i))) (λ a → cong (λ e → e a) (cong fst (sym j))) hIsHomo = snd f isomorphismCommutativity : compGroupHom incAbAsGroupHom (GroupIso→GroupHom isomorphism) ≡ (HITηAsGroupHom G) isomorphismCommutativity = commutativity (HITasAbelianGroup G) (HITηAsGroupHom G) isomorphismUniqueness : (h : AbGroupIso asAbelianGroup (HITasAbelianGroup G)) → (hcomm : compGroupHom incAbAsGroupHom (GroupIso→GroupHom h) ≡ (HITηAsGroupHom G)) → h ≡ isomorphism isomorphismUniqueness h hcomm = GroupIso≡ p where r : (x : fst asAbelianGroup) → fst (compGroupHom (GroupIso→GroupHom h) (GroupIso→GroupHom (invGroupIso h))) x ≡ x r = λ x → (h .fst .Iso.leftInv) x leftInvGroupHom : (compGroupHom (GroupIso→GroupHom h) (GroupIso→GroupHom (invGroupIso h))) ≡ idGroupHom leftInvGroupHom = Σ≡Prop (λ _ → isPropIsGroupHom _ _) (λ i x → r x i) q : (g : fst G) → fst (compGroupHom (HITηAsGroupHom G) (GroupIso→GroupHom (invGroupIso h))) g ≡ fst incAbAsGroupHom g q = λ g → fst (compGroupHom (HITηAsGroupHom G) (GroupIso→GroupHom (invGroupIso h))) g ≡⟨ cong (λ f → f g) (cong fst (cong (λ f → compGroupHom f (GroupIso→GroupHom (invGroupIso h))) (sym hcomm))) ⟩ fst (compGroupHom (compGroupHom incAbAsGroupHom (GroupIso→GroupHom h)) (GroupIso→GroupHom (invGroupIso h))) g ≡⟨ cong (λ f → f g) (cong fst (compGroupHomAssoc incAbAsGroupHom (GroupIso→GroupHom h) (GroupIso→GroupHom (invGroupIso h)))) ⟩ fst (compGroupHom incAbAsGroupHom (compGroupHom (GroupIso→GroupHom h) (GroupIso→GroupHom (invGroupIso h)))) g ≡⟨ cong (λ f → f g) (cong fst (cong (λ f → (compGroupHom incAbAsGroupHom f)) leftInvGroupHom)) ⟩ fst incAbAsGroupHom g ∎ isocomm : compGroupHom (HITηAsGroupHom G) (GroupIso→GroupHom (invGroupIso h)) ≡ incAbAsGroupHom isocomm = Σ≡Prop (λ _ → isPropIsGroupHom _ _) (λ i x → q x i) p : h .fst ≡ isomorphism .fst p = Iso≡Set (isSetAbGroup asAbelianGroup) (isSetAbGroup (HITasAbelianGroup G)) (h .fst) (isomorphism .fst) (λ x → cong (λ f → f x) (cong fst (uniqueness (HITasAbelianGroup G) (HITηAsGroupHom G) (GroupIso→GroupHom h) hcomm))) (λ x → cong (λ f → f x) (cong fst (HITuniqueness G asAbelianGroup incAbAsGroupHom (GroupIso→GroupHom (invGroupIso h)) isocomm))) AbelianizationComparisonIsomorphism : (G : Group ℓ) → AbGroupIso (AbelianizationAbGroup G) (HITasAbelianGroup G) AbelianizationComparisonIsomorphism G = IsoCoeqHIT.isomorphism G
algebraic-stack_agda0000_doc_5372
module list-to-string where open import list open import string 𝕃-to-string : ∀ {ℓ} {A : Set ℓ} → (f : A → string) → (separator : string) → 𝕃 A → string 𝕃-to-string f sep [] = "" 𝕃-to-string f sep (x1 :: (x2 :: xs)) = (f x1) ^ sep ^ (𝕃-to-string f sep (x2 :: xs)) 𝕃-to-string f sep (x1 :: []) = (f x1)
algebraic-stack_agda0000_doc_5373
module AbstractRationals where open import Algebra open import Data.Integer.Base using (+0) open import Data.Maybe.Base using (just; nothing; decToMaybe) open import Data.Rational.Base as ℚ public hiding (_+_; _*_; _-_) open import Data.Rational.Properties as ℚ public using (module ≤-Reasoning; <⇒≤) open import Relation.Binary open import Relation.Binary.PropositionalEquality open import Function.Base open import Data.Product using (_×_; _,_) open import Tactic.RingSolver.Core.AlmostCommutativeRing open import Tactic.RingSolver.NonReflective (fromCommutativeRing ℚ.+-*-commutativeRing (λ x → decToMaybe (0ℚ ℚ.≟ x))) open import RationalUtils as ℚ public using (2ℚ; 3ℚ) infixl 7 _*_ infixl 6 _+_ _-_ abstract _+_ : ℚ → ℚ → ℚ _+_ = ℚ._+_ _*_ : ℚ → ℚ → ℚ _*_ = ℚ._*_ _-_ : ℚ → ℚ → ℚ _-_ = ℚ._-_ +-eq : _+_ ≡ ℚ._+_ +-eq = refl *-eq : _*_ ≡ ℚ._*_ *-eq = refl neg-eq : _-_ ≡ ℚ._-_ neg-eq = refl p+q-p≡q : ∀ p q → p + q - p ≡ q p+q-p≡q = ℚ.p+q-p≡q p+q-q≡p : ∀ p q → p + q - q ≡ p p+q-q≡p = ℚ.p+q-q≡p p-q+q≡p : ∀ p q → p - q + q ≡ p p-q+q≡p = ℚ.p-q+q≡p p-[p+q]≡q : ∀ p q → p - (p + q) ≡ q p-[p+q]≡q = ℚ.p-[p+q]≡q ∣p-q∣≤∣p∣+∣q∣ : ∀ p q → ∣ p - q ∣ ≤ ∣ p ∣ + ∣ q ∣ ∣p-q∣≤∣p∣+∣q∣ = ℚ.∣p-q∣≤∣p∣+∣q∣ ∣p∣≤q⇒-q≤p≤q : ∀ p {q} → ∣ p ∣ ≤ q → - q ≤ p × p ≤ q ∣p∣≤q⇒-q≤p≤q p = ℚ.∣p∣≤q⇒-q≤p≤q p -p<q<p⇒∣q∣<p : ∀ {p q} → - p < q → q < p → ∣ q ∣ < p -p<q<p⇒∣q∣<p = ℚ.-p<q<p⇒∣q∣<p 2*p≡p+p : ∀ p → 2ℚ * p ≡ p + p 2*p≡p+p = ℚ.2*p≡p+p +-assoc : Associative _≡_ _+_ +-assoc = ℚ.+-assoc +-monoˡ-≤ : ∀ r → (_+ r) Preserves _≤_ ⟶ _≤_ +-monoˡ-≤ = ℚ.+-monoˡ-≤ +-monoʳ-≤ : ∀ r → (_+_ r) Preserves _≤_ ⟶ _≤_ +-monoʳ-≤ = ℚ.+-monoʳ-≤ +-mono-≤ : _+_ Preserves₂ _≤_ ⟶ _≤_ ⟶ _≤_ +-mono-≤ = ℚ.+-mono-≤ *-monoʳ-≤ : ∀ r → Positive r → (r *_) Preserves _≤_ ⟶ _≤_ *-monoʳ-≤ = ℚ.*-monoʳ-≤ ∣p+q∣≤∣p∣+∣q∣ : ∀ p q → ∣ p + q ∣ ≤ ∣ p ∣ + ∣ q ∣ ∣p+q∣≤∣p∣+∣q∣ = ℚ.∣p+q∣≤∣p∣+∣q∣ ∣p*q∣≡∣p∣*∣q∣ : ∀ p q → ∣ p * q ∣ ≡ ∣ p ∣ * ∣ q ∣ ∣p*q∣≡∣p∣*∣q∣ = ℚ.∣p*q∣≡∣p∣*∣q∣ p<r-q⇒p+q<r : ∀ p q r → p < r - q → p + q < r p<r-q⇒p+q<r = ℚ.p<r-q⇒p+q<r 2p+p≡3p : ∀ p → 2ℚ * p + p ≡ 3ℚ * p 2p+p≡3p p = begin-equality 2ℚ * p + p ≡⟨ cong (2ℚ * p +_) (sym (ℚ.*-identityˡ p)) ⟩ 2ℚ * p + 1ℚ * p ≡⟨ sym (ℚ.*-distribʳ-+ p 2ℚ 1ℚ) ⟩ (2ℚ + 1ℚ) * p ∎ where open ≤-Reasoning lem1 : ∀ a b c d e f g → a + (b + c) + d + (e + f + f - g) - (e + f + f - g) ≡ c + (a + f + (e + b + d + f)) - g - (f + f + (e - g)) lem1 = solve 7 (λ a b c d e f g → (a ⊕ (b ⊕ c) ⊕ d ⊕ (e ⊕ f ⊕ f ⊕ (⊝ g)) ⊕ (⊝ (e ⊕ f ⊕ f ⊕ (⊝ g))) , c ⊕ (a ⊕ f ⊕ (e ⊕ b ⊕ d ⊕ f)) ⊕ (⊝ g) ⊕ (⊝ (f ⊕ f ⊕ (e ⊕ (⊝ g)))))) refl
algebraic-stack_agda0000_doc_5374
module Issue461 where data D : Set where data D : Set where
algebraic-stack_agda0000_doc_5375
{-# OPTIONS --no-auto-inline #-} module Where where open import Haskell.Prelude hiding (_+_; _*_; _-_) open import Agda.Builtin.Nat postulate bool2nat : Bool → Nat -- no outer arguments ex1 : Nat ex1 = mult num + bool2nat true where num : Nat num = 42 mult : Nat → Nat mult = _* 100 -- nested where ex2 : Nat ex2 = mult num + bool2nat true where num : Nat num = 42 mult : Nat → Nat mult = _⊗ 100 where _⊗_ = _*_ -- with outer arguments ex3 : Nat → Bool → Nat ex3 n b = mult num + bool2nat b where num = 42 + bool2nat b mult : Nat → Nat mult = _* n -- nested where with outer arguments ex4 : Bool → Nat ex4 b = mult 42 where mult : Nat → Nat mult n = bump n (bool2nat b) where bump : Nat → Nat → Nat bump x y = x * y + (n - bool2nat b) ex4' : Bool → Nat ex4' b = mult (bool2nat b) where mult : Nat → Nat mult n = bump n (bool2nat b) where bump : Nat → Nat → Nat bump x y = go (x * y) (n - bool2nat b) where go : Nat → Nat → Nat go z w = z + x + w + y + n + bool2nat b -- with pattern matching and multiple clauses ex5 : List Nat → Nat ex5 [] = zro where zro : Nat zro = 0 ex5 (n ∷ ns) = mult num + 1 where num = 42 + ex5 ns mult : Nat → Nat mult = _* n -- mix of patterns + inner multiple clauses + nested where ex6 : List Nat → Bool → Nat ex6 [] b = zro where zro : Nat zro = 0 ex6 (n ∷ ns) b = mult (num ∷ 1 ∷ []) where mult : List Nat → Nat mult [] = bump 5 (bool2nat b) where bump : Nat → Nat → Nat bump x y = x * y + n mult (m ∷ ms) = bump n m where bump : Nat → Nat → Nat bump x y = x * y + (m - n) num = 42 + ex6 ns true ex7 : Nat → Nat ex7 n₀ = go₁ n₀ where go₁ : Nat → Nat go₁ n₁ = go₂ (n₀ + n₁) where go₂ : Nat → Nat go₂ n₂ = n₀ + n₁ + n₂ ex7' : Nat → Nat ex7' n₀ = go₁ n₀ where go₁ : Nat → Nat go₁ n₁ = go₂ (n₀ + n₁) where go₂ : Nat → Nat go₂ n₂ = go₃ (n₀ + n₁ + n₂) where go₃ : Nat → Nat go₃ n₃ = n₀ + n₁ + n₂ + n₃ ex8 : Nat ex8 = n₂ where n₁ : Nat n₁ = 1 n₂ = n₁ + 1 {-# COMPILE AGDA2HS bool2nat #-} {-# COMPILE AGDA2HS ex1 #-} {-# COMPILE AGDA2HS ex2 #-} {-# COMPILE AGDA2HS ex3 #-} {-# COMPILE AGDA2HS ex4 #-} {-# COMPILE AGDA2HS ex4' #-} {-# COMPILE AGDA2HS ex5 #-} {-# COMPILE AGDA2HS ex6 #-} {-# COMPILE AGDA2HS ex7 #-} {-# COMPILE AGDA2HS ex7' #-} {-# COMPILE AGDA2HS ex8 #-}
algebraic-stack_agda0000_doc_5296
open import System.IO using ( _>>_ ; putStr ; commit ) open import Data.Natural using ( show ) open import System.IO.Examples.Four using ( four ) module System.IO.Examples.HelloFour where main = putStr "Hello, " >> putStr (show four) >> putStr ".\n" >> commit
algebraic-stack_agda0000_doc_5297
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Monoids.Definition module Semirings.Definition where record Semiring {a : _} {A : Set a} (Zero One : A) (_+_ : A → A → A) (_*_ : A → A → A) : Set a where field monoid : Monoid Zero _+_ commutative : (a b : A) → a + b ≡ b + a multMonoid : Monoid One _*_ productZeroLeft : (a : A) → Zero * a ≡ Zero productZeroRight : (a : A) → a * Zero ≡ Zero +DistributesOver* : (a b c : A) → a * (b + c) ≡ (a * b) + (a * c) +DistributesOver*' : (a b c : A) → (a + b) * c ≡ (a * c) + (b * c) +Associative = Monoid.associative monoid *Associative = Monoid.associative multMonoid productOneLeft = Monoid.idLeft multMonoid productOneRight = Monoid.idRight multMonoid sumZeroLeft = Monoid.idLeft monoid sumZeroRight = Monoid.idRight monoid +WellDefined : {a b c d : A} → (a ≡ c) → (b ≡ d) → (a + b) ≡ (c + d) +WellDefined refl refl = refl -- (b+c)(a+a) == b(a+a) + c(a+a) == ba+ba+ca+ca == (ba+ca) + (ba+ca) -- (b+c)(a+a) ==? (b+c)a+(b+c)a
algebraic-stack_agda0000_doc_5298
{-# OPTIONS --type-in-type --rewriting #-} open import Agda.Builtin.Sigma open import Agda.Builtin.Equality coe : {A B : Set} → A ≡ B → A → B coe refl x = x {-# BUILTIN REWRITE _≡_ #-} Tel = Set U = Set variable Δ : Tel A B : Δ → U δ₀ δ₁ : Δ postulate IdTel : (Δ : Tel)(δ₀ δ₁ : Δ) → Tel Id : (A : Δ → U){δ₀ δ₁ : Δ}(δ₂ : IdTel Δ δ₀ δ₁) → A δ₀ → A δ₁ → U ap : {A : Δ → U}(a : (δ : Δ) → A δ) → {δ₀ δ₁ : Δ}(δ₂ : IdTel Δ δ₀ δ₁) → Id A δ₂ (a δ₀) (a δ₁) idTel-sigma : {a₀ : A δ₀}{a₁ : A δ₁} → IdTel (Σ Δ A) (δ₀ , a₀) (δ₁ , a₁) ≡ Σ (IdTel Δ δ₀ δ₁) (λ δ₂ → Id A δ₂ a₀ a₁) {-# REWRITE idTel-sigma #-} id-u : {A₀ A₁ : U}{δ₂ : IdTel Δ δ₀ δ₁} → Id {Δ = Δ}(λ _ → U) δ₂ A₀ A₁ ≡ (A₀ → A₁ → U) {-# REWRITE id-u #-} id-ap : {δ₂ : IdTel Δ δ₀ δ₁}{a₀ : A δ₀}{a₁ : A δ₁} → Id A δ₂ a₀ a₁ ≡ ap {A = λ _ → U} A δ₂ a₀ a₁ ap-sigma : {δ₂ : IdTel Δ δ₀ δ₁}{a₀ : A δ₀}{a₁ : A δ₁} {B : (δ : Δ) → A δ → U} {b₀ : B δ₀ a₀}{b₁ : B δ₁ a₁}→ ap {Δ = Δ}{A = λ _ → U} (λ δ → Σ (A δ) (B δ)) δ₂ (a₀ , b₀) (a₁ , b₁) ≡ Σ (Id A δ₂ a₀ a₁) λ a₂ → Id {Δ = Σ Δ A} (λ (δ , a) → B δ a) (δ₂ , a₂) b₀ b₁ {-# REWRITE ap-sigma #-} {-# REWRITE id-ap #-} ap-proj₁ : {δ₂ : IdTel Δ δ₀ δ₁} {B : (δ : Δ) → A δ → U} {ab : (δ : Δ) → Σ (A δ) (B δ)} → ap {Δ = Δ}{A = A}(λ δ → fst (ab δ)) δ₂ ≡ fst (ap ab δ₂)
algebraic-stack_agda0000_doc_5299
{-# OPTIONS --cubical-compatible --rewriting --confluence-check #-} module Issue1719.Spans where open import Issue1719.Common record Span : Set₁ where constructor span field A B C : Set f : C → A g : C → B open Span public
algebraic-stack_agda0000_doc_5300
------------------------------------------------------------------------ -- Products ------------------------------------------------------------------------ module Data.Product where open import Data.Function open import Relation.Nullary.Core infixr 4 _,_ infix 4 ,_ infixr 2 _×_ _-×-_ _-,-_ ------------------------------------------------------------------------ -- Definition data Σ (A : Set) (B : A → Set) : Set where _,_ : (x : A) (y : B x) → Σ A B ∃ : {A : Set} → (A → Set) → Set ∃ = Σ _ ∄ : {A : Set} → (A → Set) → Set ∄ P = ¬ ∃ P ∃₂ : {A : Set} {B : A → Set} (C : (x : A) → B x → Set) → Set ∃₂ C = ∃ λ a → ∃ λ b → C a b _×_ : (A B : Set) → Set A × B = Σ A (λ _ → B) ------------------------------------------------------------------------ -- Functions -- Sometimes the first component can be inferred. ,_ : ∀ {A} {B : A → Set} {x} → B x → ∃ B , y = _ , y proj₁ : ∀ {A B} → Σ A B → A proj₁ (x , y) = x proj₂ : ∀ {A B} → (p : Σ A B) → B (proj₁ p) proj₂ (x , y) = y <_,_> : ∀ {A} {B : A → Set} {C : ∀ {x} → B x → Set} (f : (x : A) → B x) → ((x : A) → C (f x)) → ((x : A) → Σ (B x) C) < f , g > x = (f x , g x) map : ∀ {A B P Q} → (f : A → B) → (∀ {x} → P x → Q (f x)) → Σ A P → Σ B Q map f g = < f ∘ proj₁ , g ∘ proj₂ > zip : ∀ {A B C P Q R} → (_∙_ : A → B → C) → (∀ {x y} → P x → Q y → R (x ∙ y)) → Σ A P → Σ B Q → Σ C R zip _∙_ _∘_ p₁ p₂ = (proj₁ p₁ ∙ proj₁ p₂ , proj₂ p₁ ∘ proj₂ p₂) swap : ∀ {A B} → A × B → B × A swap = < proj₂ , proj₁ > _-×-_ : ∀ {A B} → (A → B → Set) → (A → B → Set) → (A → B → Set) f -×- g = f -[ _×_ ]₁- g _-,-_ : ∀ {A B C D} → (A → B → C) → (A → B → D) → (A → B → C × D) f -,- g = f -[ _,_ ]- g curry : {A : Set} {B : A → Set} {C : Σ A B → Set} → ((p : Σ A B) → C p) → ((x : A) → (y : B x) → C (x , y)) curry f x y = f (x , y) uncurry : {A : Set} {B : A → Set} {C : Σ A B → Set} → ((x : A) → (y : B x) → C (x , y)) → ((p : Σ A B) → C p) uncurry f (p₁ , p₂) = f p₁ p₂
algebraic-stack_agda0000_doc_5301
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Foundations.Equiv.Base where open import Cubical.Foundations.Function open import Cubical.Foundations.Prelude open import Cubical.Core.Glue public using ( isEquiv ; equiv-proof ; _≃_ ; equivFun ; equivProof ) fiber : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (f : A → B) (y : B) → Type (ℓ-max ℓ ℓ') fiber {A = A} f y = Σ[ x ∈ A ] f x ≡ y -- The identity equivalence idIsEquiv : ∀ {ℓ} (A : Type ℓ) → isEquiv (idfun A) equiv-proof (idIsEquiv A) y = ((y , refl) , λ z i → z .snd (~ i) , λ j → z .snd (~ i ∨ j)) idEquiv : ∀ {ℓ} (A : Type ℓ) → A ≃ A idEquiv A .fst = idfun A idEquiv A .snd = idIsEquiv A
algebraic-stack_agda0000_doc_5302
module Prelude.List.Base where open import Prelude.Nat open import Prelude.Bool open import Prelude.Maybe open import Prelude.Product open import Prelude.Empty open import Prelude.Function open import Prelude.Functor open import Prelude.Applicative open import Prelude.Monad open import Prelude.Decidable open import Prelude.Equality open import Prelude.Ord open import Prelude.Semiring open import Prelude.Strict open import Prelude.Variables open import Agda.Builtin.List public infixr 5 _++_ pattern [_] x = x ∷ [] singleton : A → List A singleton x = x ∷ [] map : (A → B) → List A → List B map f [] = [] map f (x ∷ xs) = f x ∷ map f xs _++_ : List A → List A → List A [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ xs ++ ys length : List A → Nat length [] = 0 length (x ∷ xs) = 1 + length xs foldr : (A → B → B) → B → List A → B foldr f z [] = z foldr f z (x ∷ xs) = f x (foldr f z xs) foldl : (B → A → B) → B → List A → B foldl f z [] = z foldl f z (x ∷ xs) = foldl f (f z x) xs foldl! : (B → A → B) → B → List A → B foldl! f z [] = z foldl! f z (x ∷ xs) = force (f z x) λ z′ → foldl! f z′ xs reverse : List A → List A reverse xs = foldl (flip _∷_) [] xs concat : List (List A) → List A concat = foldr _++_ [] concatMap : (A → List B) → List A → List B concatMap f = concat ∘ map f filter : (A → Bool) → List A → List A filter p [] = [] filter p (x ∷ xs) = if p x then x ∷ filter p xs else filter p xs catMaybes : List (Maybe A) → List A catMaybes [] = [] catMaybes (x ∷ xs) = maybe (catMaybes xs) (_∷ catMaybes xs) x all? : (A → Bool) → List A → Bool all? p [] = true all? p (x ∷ xs) = p x && all? p xs any? : (A → Bool) → List A → Bool any? p [] = false any? p (x ∷ xs) = p x || any? p xs take : Nat → List A → List A take zero _ = [] take (suc n) [] = [] take (suc n) (x ∷ xs) = x ∷ take n xs drop : Nat → List A → List A drop zero xs = xs drop (suc n) [] = [] drop (suc n) (x ∷ xs) = drop n xs takeWhile : (A → Bool) → List A → List A takeWhile p [] = [] takeWhile p (x ∷ xs) = if p x then x ∷ takeWhile p xs else [] dropWhile : (A → Bool) → List A → List A dropWhile p [] = [] dropWhile p (x ∷ xs) = if p x then dropWhile p xs else x ∷ xs splitAt : Nat → List A → List A × List A splitAt zero xs = [] , xs splitAt (suc n) [] = [] , [] splitAt (suc n) (x ∷ xs) = first (x ∷_) (splitAt n xs) null : List A → Bool null [] = true null (_ ∷ _) = false elem : ⦃ Eq A ⦄ → A → List A → Bool elem x xs = not (null (filter (isYes ∘ _==_ x) xs)) lookup : ⦃ Eq A ⦄ → List (A × B) → A → Maybe B lookup [] _ = nothing lookup ((x₁ , v) ∷ xs) x = ifYes (x == x₁) then just v else lookup xs x nub : ⦃ Eq A ⦄ → List A → List A nub [] = [] nub (x ∷ xs) = x ∷ filter (isNo ∘ (x ==_)) (nub xs) index : List A → Nat → Maybe A index [] _ = nothing index (x ∷ xs) 0 = just x index (x ∷ xs) (suc i) = index xs i replicate : Nat → A → List A replicate zero x = [] replicate (suc n) x = x ∷ replicate n x zipWith : (A → B → C) → List A → List B → List C zipWith f [] _ = [] zipWith f _ [] = [] zipWith f (x ∷ xs) (y ∷ ys) = f x y ∷ zipWith f xs ys zip : List A → List B → List (A × B) zip = zipWith _,_ punctuate : A → List A → List A punctuate z [] = [] punctuate z [ x ] = [ x ] punctuate z (x ∷ xs) = x ∷ z ∷ punctuate z xs replicateA : ⦃ Applicative F ⦄ → Nat → F A → F (List A) replicateA zero _ = pure [] replicateA (suc n) x = pure _∷_ <*> x <*> replicateA n x module _ ⦃ _ : Semiring A ⦄ where sum : List A → A sum = foldl! _+_ zro product : List A → A product = foldl! _*_ one sumR : List A → A sumR = foldr _+_ zro productR : List A → A productR = foldr _*_ one module _ ⦃ _ : Ord A ⦄ where insert : A → List A → List A insert x [] = x ∷ [] insert x (y ∷ xs) = if x <? y then x ∷ y ∷ xs else y ∷ insert x xs sort : List A → List A sort [] = [] sort (x ∷ xs) = insert x (sort xs) infix 10 from_for_ from_to_ from_for_step_ from-to-step from_for_ : Nat → Nat → List Nat from 0 for 0 = [] -- make strict from a for 0 = [] from a for suc d = a ∷ from suc a for d from_for_step_ : Nat → Nat → Nat → List Nat from 0 for 0 step _ = [] -- make strict from a for 0 step _ = [] from a for suc c step d = a ∷ from a + d for c step d from_to_ : Nat → Nat → List Nat from a to b = from a for (suc b - a) syntax from-to-step d a b = from a to b step d from-to-step : (d : Nat) {{_ : NonZero d}} → Nat → Nat → List Nat from-to-step d a b = from a for 1 + (b - a) div d step d --- Equality --- cons-inj-tail : x ∷ xs ≡ y ∷ ys → xs ≡ ys cons-inj-tail refl = refl cons-inj-head : x ∷ xs ≡ y ∷ ys → x ≡ y cons-inj-head refl = refl private dec-∷ : Dec (x ≡ y) → Dec (xs ≡ ys) → Dec (x ∷ xs ≡ y ∷ ys) dec-∷ (yes refl) (yes refl) = yes refl dec-∷ _ (no neq) = no λ eq → neq (cons-inj-tail eq) dec-∷ (no neq) _ = no λ eq → neq (cons-inj-head eq) eqList : ⦃ Eq A ⦄ → (xs ys : List A) → Dec (xs ≡ ys) eqList [] [] = yes refl eqList [] (_ ∷ _) = no (λ ()) eqList (_ ∷ _) [] = no (λ ()) eqList (x ∷ xs) (y ∷ ys) = dec-∷ (x == y) (eqList xs ys) instance EqList : ⦃ Eq A ⦄ → Eq (List A) _==_ {{EqList}} = eqList --- Ord --- data LessList (_<_ : A → A → Set ℓ) : List A → List A → Set ℓ where nil<cons : LessList _<_ [] (x ∷ xs) head< : x < y → LessList _<_ (x ∷ xs) (y ∷ ys) tail< : LessList _<_ xs ys → LessList _<_ (x ∷ xs) (x ∷ ys) compareCons : ∀ {_<_ : A → A → Set ℓ} → Comparison _<_ x y → Comparison (LessList _<_) xs ys → Comparison (LessList _<_) (x ∷ xs) (y ∷ ys) compareCons (less lt) _ = less (head< lt) compareCons (greater gt) _ = greater (head< gt) compareCons (equal refl) (less lt) = less (tail< lt) compareCons (equal refl) (greater gt) = greater (tail< gt) compareCons (equal refl) (equal refl) = equal refl compareList : ∀ {_<_ : A → A → Set ℓ} (cmp : ∀ x y → Comparison _<_ x y) (xs ys : List A) → Comparison (LessList _<_) xs ys compareList cmp [] [] = equal refl compareList cmp [] (x ∷ ys) = less nil<cons compareList cmp (x ∷ xs) [] = greater nil<cons compareList cmp (x ∷ xs) (y ∷ ys) = compareCons (cmp x y) (compareList cmp xs ys) instance OrdList : ⦃ Ord A ⦄ → Ord (List A) OrdList = defaultOrd (compareList compare) OrdListLaws : ⦃ Ord/Laws A ⦄ → Ord/Laws (List A) Ord/Laws.super OrdListLaws = it less-antirefl {{OrdListLaws {A = A}}} (head< hd) = less-antirefl {A = A} hd less-antirefl {{OrdListLaws {A = A}}} (tail< tl) = less-antirefl {A = List A} tl less-trans {{OrdListLaws}} nil<cons (head< hd) = nil<cons less-trans {{OrdListLaws}} nil<cons (tail< tl) = nil<cons less-trans {{OrdListLaws {A = A}}} (head< hd) (head< hd₁) = head< (less-trans {A = A} hd hd₁) less-trans {{OrdListLaws {A = A}}} (head< hd) (tail< tl) = head< hd less-trans {{OrdListLaws {A = A}}} (tail< tl) (head< hd) = head< hd less-trans {{OrdListLaws {A = A}}} (tail< tl) (tail< tl₁) = tail< (less-trans {A = List A} tl tl₁) --- Functor --- instance FunctorList : Functor (List {ℓ}) fmap {{FunctorList}} = map FunctorList′ : Functor′ {ℓ₁} {ℓ₂} List fmap′ {{FunctorList′}} = map ApplicativeList : Applicative (List {ℓ}) pure {{ApplicativeList}} x = x ∷ [] _<*>_ {{ApplicativeList}} = monadAp (flip concatMap) ApplicativeList′ : Applicative′ {ℓ₁} {ℓ₂} List _<*>′_ {{ApplicativeList′}} = monadAp′ (flip concatMap) MonadList : Monad (List {ℓ}) _>>=_ {{MonadList}} xs f = concatMap f xs MonadList′ : Monad′ {ℓ₁} {ℓ₂} List _>>=′_ {{MonadList′}} xs f = concatMap f xs --- More functions --- IsPrefixOf : {A : Set ℓ} → List A → List A → Set ℓ IsPrefixOf xs ys = ∃ zs , ys ≡ xs ++ zs isPrefixOf : ⦃ Eq A ⦄ → (xs ys : List A) → Dec (IsPrefixOf xs ys) isPrefixOf [] ys = yes (ys , refl) isPrefixOf (x ∷ xs) [] = no λ where (zs , ()) isPrefixOf (x ∷ xs) (y ∷ ys) with y == x | isPrefixOf xs ys ... | yes y=x | yes (zs , xs⊑ys) = yes (zs , (_∷_ $≡ y=x *≡ xs⊑ys)) ... | _ | no noprefix = no λ where (zs , eq) → noprefix ((zs , cons-inj-tail eq)) ... | no y≠x | _ = no λ where (zs , eq) → y≠x (cons-inj-head eq) isPrefixOf? : ⦃ Eq A ⦄ → List A → List A → Bool isPrefixOf? xs ys = isYes (isPrefixOf xs ys) dropPrefix : ⦃ Eq A ⦄ → List A → List A → Maybe (List A) dropPrefix xs ys = case isPrefixOf xs ys of λ where (yes (tl , _)) → just tl (no _) → nothing commonPrefix : ⦃ Eq A ⦄ → (xs ys : List A) → ∃ zs , IsPrefixOf zs xs × IsPrefixOf zs ys commonPrefix [] ys = [] , (_ , refl) , (_ , refl) commonPrefix xs [] = [] , (_ , refl) , (_ , refl) commonPrefix (x ∷ xs) (y ∷ ys) with y == x | commonPrefix xs ys ... | yes y=x | zs , (xs₁ , eqx) , (ys₁ , eqy) = (x ∷ zs) , (xs₁ , (x ∷_ $≡ eqx)) , (ys₁ , (_∷_ $≡ y=x *≡ eqy)) ... | no _ | _ = [] , (_ , refl) , (_ , refl) commonPrefix! : ⦃ Eq A ⦄ → (xs ys : List A) → List A commonPrefix! xs ys = fst (commonPrefix xs ys) wordsBy : (A → Bool) → List A → List (List A) wordsBy {A = A} p = go in-word ∘ dropWhile p where data Mode : Set where in-word in-space : Mode cons : A → List (List A) → List (List A) cons x [] = [ x ] ∷ [] cons x (xs ∷ xss) = (x ∷ xs) ∷ xss go : Mode → List A → List (List A) go _ [] = [] go mode (x ∷ xs) with p x go mode (x ∷ xs) | false = cons x (go in-word xs) go in-word (x ∷ xs) | true = [] ∷ go in-space xs go in-space (x ∷ xs) | true = go in-space xs
algebraic-stack_agda0000_doc_5303
import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; sym; trans; cong; cong-app) open Eq.≡-Reasoning open import Data.Nat using (ℕ; zero; suc; _+_; _*_) open import Data.Product using (∃; _,_) +-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)) ≡⟨ cong suc (+-assoc m n p) ⟩ suc ((m + n) + p) ≡⟨⟩ (suc m + n) + p ∎ +-identity : ∀ (m : ℕ) → m + zero ≡ m +-identity zero = begin zero + zero ≡⟨⟩ zero ∎ +-identity (suc m) = begin suc m + zero ≡⟨⟩ suc (m + zero) ≡⟨ cong suc (+-identity m) ⟩ suc m ∎ +-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n) +-suc zero n = begin zero + suc n ≡⟨⟩ suc n ≡⟨⟩ suc (zero + n) ∎ +-suc (suc m) n = begin suc m + suc n ≡⟨⟩ suc (m + suc n) ≡⟨ cong suc (+-suc m n) ⟩ suc (suc (m + n)) ≡⟨⟩ suc (suc m + n) ∎ +-comm : ∀ (m n : ℕ) → m + n ≡ n + m +-comm 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 ∎ *-distrib-+ : ∀ (m n p : ℕ) → (m + n) * p ≡ m * p + n * p *-distrib-+ zero n p = begin (zero + n) * p ≡⟨⟩ n * p ≡⟨⟩ zero * p + n * p ∎ *-distrib-+ (suc m) n p = begin (suc m + n) * p ≡⟨⟩ p + (m + n) * p ≡⟨ cong (_+_ p) (*-distrib-+ m n p) ⟩ p + (m * p + n * p) ≡⟨ +-assoc p (m * p) (n * p) ⟩ (p + m * p) + n * p ≡⟨⟩ suc m * p + n * p ∎ data even : ℕ → Set where ev0 : even zero ev+2 : ∀ {n : ℕ} → even n → even (suc (suc n)) lemma : ∀ (m : ℕ) → 2 * suc m ≡ suc (suc (2 * m)) lemma m = begin 2 * suc m ≡⟨⟩ suc m + (suc m + zero) ≡⟨⟩ suc (m + (suc (m + zero))) ≡⟨ cong suc (+-suc m (m + zero)) ⟩ suc (suc (m + (m + zero))) ≡⟨⟩ suc (suc (2 * m)) ∎ ev-ex : ∀ {n : ℕ} → even n → ∃(λ (m : ℕ) → 2 * m ≡ n) ev-ex ev0 = (0 , refl) ev-ex (ev+2 ev) with ev-ex ev ... | (m , refl) = (suc m , lemma m) ex-ev : ∀ {n : ℕ} → ∃(λ (m : ℕ) → 2 * m ≡ n) → even n ex-ev (zero , refl) = ev0 ex-ev (suc m , refl) rewrite lemma m = ev+2 (ex-ev (m , refl)) -- I can't see how to avoid using rewrite in the second proof, -- or how to use rewrite in the first proof!
algebraic-stack_agda0000_doc_5304
module ExportTestAgda where open import Common.Prelude itWorksText : String itWorksText = "It works!" {-# COMPILED_EXPORT itWorksText itWorksText #-}
algebraic-stack_agda0000_doc_5305
-- There was a bug when unifying things of function type during pattern matching -- (the T argument to P is unified with D below) module Issue199 where data D (A : Set) : Set where data P {A : Set} : {T : Set → Set} → T A → Set where p : ∀ d → P {_} {D} d foo : ∀ {A} {l : D A} → P l → Set₁ foo (p _) = Set
algebraic-stack_agda0000_doc_5306
open import Type module Relator.Converse {ℓ₁ ℓ₂} {T : Type{ℓ₁}} (_▫_ : T → T → Type{ℓ₂}) where import Lvl open import Functional Converse : T → T → Type{ℓ₂} Converse = swap(_▫_)
algebraic-stack_agda0000_doc_5307
module Issue4954 where open import Issue4954.M Set
algebraic-stack_agda0000_doc_5308
module Relator.Ordering.Proofs where open import Data import Lvl open import Functional open import Lang.Instance open import Logic open import Logic.Classical open import Logic.Propositional open import Logic.Propositional.Theorems open import Type import Relator.Ordering open import Structure.Relator.Ordering import Structure.Relator.Names as Names open import Structure.Relator.Proofs open import Structure.Relator.Properties open import Structure.Relator.Properties.Proofs open import Structure.Relator open import Structure.Setoid open import Syntax.Implication open import Syntax.Transitivity private variable ℓ ℓ₁ ℓ₂ ℓ₃ ℓₗ ℓₑ ℓₗₑ ℓₗₜ : Lvl.Level private variable T : Type{ℓ} module From-[≤] (_≤_ : T → T → Stmt{ℓₗ}) where open Relator.Ordering.From-[≤] (_≤_) [≤][>]-not : ∀{a b} → (a ≤ b) → (a > b) → ⊥ [≤][>]-not = apply [≥][<]-not : ∀{a b} → (a ≥ b) → (a < b) → ⊥ [≥][<]-not = apply module _ ⦃ _ : Equiv{ℓₑ}(T) ⦄ ⦃ _ : Weak.TotalOrder(_≤_)(_≡_) ⦄ where [<]-to-[≤] : Names.Subrelation(_<_)(_≤_) [<]-to-[≤] {a} {b} nba with converseTotal(_≤_){a}{b} [<]-to-[≤] {a} {b} nba | [∨]-introₗ ab = ab [<]-to-[≤] {a} {b} nba | [∨]-introᵣ ba = [⊥]-elim(nba ba) instance [<][≤]-sub : (_<_) ⊆₂ (_≤_) _⊆₂_.proof [<][≤]-sub = [<]-to-[≤] [>]-to-[≥] : Names.Subrelation(_>_)(_≥_) [>]-to-[≥] = [<]-to-[≤] [>][≥]-sub : (_>_) ⊆₂ (_≥_) _⊆₂_.proof [>][≥]-sub = [>]-to-[≥] instance [<]-irreflexivity : Irreflexivity(_<_) Irreflexivity.proof [<]-irreflexivity = [¬¬]-intro(reflexivity(_≤_)) instance [<]-transitivity : Transitivity(_<_) Transitivity.proof [<]-transitivity {a} {b} {c} nba ncb ca = [≤][>]-not (transitivity(_≤_) ca ([<]-to-[≤] nba)) ncb instance [<]-asymmetry : Asymmetry(_<_) -- TODO: Proof of this property is independent of the model. Actually, many of them here are [<]-asymmetry = [irreflexivity,transitivity]-to-asymmetry [<]-strictOrder : Strict.PartialOrder(_<_) [<]-strictOrder = Strict.intro {- TODO: Maybe one must assume decidability of (_≡_)? instance [<]-total : ConverseTotal(_<_) ConverseTotal.proof [<]-total {x} {y} with converseTotal(_≤_) ... | [∨]-introₗ x₁ = {!!} ... | [∨]-introᵣ x₁ = {!!} -} instance [<][≤]-subtransitivityₗ : Subtransitivityₗ(_<_)(_≤_) Subtransitivityₗ.proof [<][≤]-subtransitivityₗ xy yz zx = yz(transitivity(_≤_) zx xy) instance [<][≤]-subtransitivityᵣ : Subtransitivityᵣ(_<_)(_≤_) Subtransitivityᵣ.proof [<][≤]-subtransitivityᵣ xy yz zx = xy(transitivity(_≤_) yz zx) [≤][≢]-to-[<] : ∀{a b} → (a ≤ b) → (a ≢ b) → (a < b) [≤][≢]-to-[<] le ne ba = ne(antisymmetry(_≤_)(_≡_) le ba) [≥][≢]-to-[>] : ∀{a b} → (a ≥ b) → (a ≢ b) → (a > b) [≥][≢]-to-[>] ge ne = [≤][≢]-to-[<] ge (ne ∘ symmetry(_≡_)) module _ ⦃ _ : (_≡_) ⊆₂ (_≤_) ⦄ where -- TODO: Consider including this in weak orders. Or just assume that (_≤_) is a relation and this will follow instance [≤][≡]-subtransitivityₗ : Subtransitivityₗ(_≤_)(_≡_) [≤][≡]-subtransitivityₗ = subrelation-transitivity-to-subtransitivityₗ instance [≤][≡]-subtransitivityᵣ : Subtransitivityᵣ(_≤_)(_≡_) [≤][≡]-subtransitivityᵣ = subrelation-transitivity-to-subtransitivityᵣ [≡]-to-[≥] : Names.Subrelation(_≡_)(_≥_) [≡]-to-[≥] = sub₂(_≡_)(_≤_) ∘ symmetry(_≡_) instance [≡][≥]-sub : (_≡_) ⊆₂ (_≥_) _⊆₂_.proof [≡][≥]-sub = [≡]-to-[≥] [≡][>]-not : ∀{a b} → (a ≡ b) → (a > b) → ⊥ [≡][>]-not eq gt = [≤][>]-not (sub₂(_≡_)(_≤_) eq) gt instance [≡][≯]-sub : (_≡_) ⊆₂ (_≯_) _⊆₂_.proof [≡][≯]-sub = [≡][>]-not instance [>][≢]-sub : (_>_) ⊆₂ (_≢_) _⊆₂_.proof [>][≢]-sub = swap [≡][>]-not [≡][<]-not : ∀{a b} → (a ≡ b) → (a < b) → ⊥ [≡][<]-not eq lt = [≤][>]-not ([≡]-to-[≥] eq) lt instance [≡][≮]-sub : (_≡_) ⊆₂ (_≮_) _⊆₂_.proof [≡][≮]-sub = [≡][<]-not instance [<][≢]-sub : (_<_) ⊆₂ (_≢_) _⊆₂_.proof [<][≢]-sub = swap [≡][<]-not instance [<][≡]-subtransitivityₗ : Subtransitivityₗ(_<_)(_≡_) Subtransitivityₗ.proof [<][≡]-subtransitivityₗ xy yz zx = [≡][>]-not xy (subtransitivityᵣ(_<_)(_≤_) yz zx) instance [<][≡]-subtransitivityᵣ : Subtransitivityᵣ(_<_)(_≡_) Subtransitivityᵣ.proof [<][≡]-subtransitivityᵣ xy yz zx = [≡][>]-not yz (subtransitivityₗ(_<_)(_≤_) zx xy) module _ ⦃ [≡]-classical : Classical₂(_≡_) ⦄ where [≤]-or-[>] : ∀{a b} → (a ≤ b) ∨ (a > b) [≤]-or-[>] {a} {b} with converseTotal(_≤_){a}{b} [≤]-or-[>] {a} {b} | [∨]-introₗ ab = [∨]-introₗ ab [≤]-or-[>] {a} {b} | [∨]-introᵣ ba with excluded-middle _ ⦃ [≡]-classical {a}{b} ⦄ [≤]-or-[>] {a} {b} | [∨]-introᵣ ba | [∨]-introₗ eqab = [∨]-introₗ (sub₂(_≡_)(_≤_) eqab) [≤]-or-[>] {a} {b} | [∨]-introᵣ ba | [∨]-introᵣ neqab = [∨]-introᵣ (ab ↦ neqab(antisymmetry(_≤_)(_≡_) ab ba)) instance [≤]-classical : Classical₂(_≤_) Classical.excluded-middle [≤]-classical = [≤]-or-[>] [≥]-or-[<] : ∀{a b} → (a ≥ b) ∨ (a < b) [≥]-or-[<] = [≤]-or-[>] [≥]-classical : Classical₂(_≥_) Classical.excluded-middle [≥]-classical = [≥]-or-[<] instance [<]-classical : Classical₂(_<_) Classical.excluded-middle ([<]-classical {a}{b}) with [≤]-or-[>] {b}{a} Classical.excluded-middle ([<]-classical {a}{b}) | [∨]-introₗ x = [∨]-introᵣ ([¬¬]-intro x) Classical.excluded-middle ([<]-classical {a}{b}) | [∨]-introᵣ x = [∨]-introₗ x [>]-classical : Classical₂(_>_) [>]-classical = [<]-classical [≤]-to-[<][≡] : ∀{a b} → (a ≤ b) → ((a < b) ∨ (a ≡ b)) [≤]-to-[<][≡] {a} {b} ab with excluded-middle _ ⦃ [≡]-classical {a}{b} ⦄ [≤]-to-[<][≡] {a} {b} ab | [∨]-introₗ eq = [∨]-introᵣ eq [≤]-to-[<][≡] {a} {b} ab | [∨]-introᵣ ne = [∨]-introₗ (ba ↦ ne(antisymmetry(_≤_)(_≡_) ab ba)) [≥]-to-[>][≡] : ∀{a b} → (a ≥ b) → ((a > b) ∨ (a ≡ b)) [≥]-to-[>][≡] ab = [∨]-elim2 id (symmetry(_≡_)) ([≤]-to-[<][≡] ab) module From-[≤][≢] {ℓ₁ ℓ₂ ℓ₃} {T : Type{ℓ₁}} (_≤_ : T → T → Stmt{ℓ₂}) (_≢_ : T → T → Stmt{ℓ₃}) where open Relator.Ordering.From-[≤][≢] (_≤_)(_≢_) -- postulate instance [<]-totalOrder : Strict.TotalOrder(_<_) instance [<][≤]-sub : (_<_) ⊆₂ (_≤_) _⊆₂_.proof [<][≤]-sub = [∧]-elimₗ instance [>][≥]-sub : (_>_) ⊆₂ (_≥_) _⊆₂_.proof [>][≥]-sub = sub₂(_<_)(_≤_) instance [<][≢]-sub : (_<_) ⊆₂ (_≢_) _⊆₂_.proof [<][≢]-sub = [∧]-elimᵣ [>][≢]-sub : ⦃ sym : Symmetry(_≢_) ⦄ → ((_>_) ⊆₂ (_≢_)) _⊆₂_.proof [>][≢]-sub = symmetry(_≢_) ∘ sub₂(_<_)(_≢_) -- [<]-transitivity : ⦃ [≤]-trans : Transitivity(_≤_) ⦄ → Transitivity(_<_) -- Transitivity.proof [<]-transitivity ([∧]-intro xy neq-xy) ([∧]-intro yz neq-yz) = [∧]-intro (transitivity(_≤_) xy yz) {!!} xy {- instance [<][≤]-subtransitivityₗ : Subtransitivityₗ(_<_)(_≤_) left (Subtransitivityₗ.proof [<][≤]-subtransitivityₗ xy ([∧]-intro yz nyz)) = transitivity(_≤_) xy yz Tuple.right (Subtransitivityₗ.proof [<][≤]-subtransitivityₗ xy yz) xz = {!!} postulate instance [<][≤]-subtransitivityᵣ : Subtransitivityᵣ(_<_)(_≤_) postulate instance [≤][≡]-subtransitivityₗ : Subtransitivityₗ(_≤_)(_≡_) postulate instance [≤][≡]-subtransitivityᵣ : Subtransitivityᵣ(_≤_)(_≡_) -} module From-[≤][<] ⦃ equiv : Equiv{ℓₑ}(T) ⦄ (_≤_ : T → T → Stmt{ℓₗₑ}) ⦃ [≤]-relator : BinaryRelator(_≤_) ⦄ (_<_ : T → T → Stmt{ℓₗₜ}) ⦃ [<]-relator : BinaryRelator(_<_) ⦄ where open Relator.Ordering.From-[≤][<] (_≤_)(_<_) private variable a b : T [≤]-def-[<][≡]ₗ-[<]-def-[≤][≢]ᵣ : ((∀{a b} → (a ≤ b) ← ((a < b) ∨ (a ≡ b))) ∧ Irreflexivity(_<_)) ↔ ((∀{a b} → (a < b) → ((a ≤ b) ∧ (a ≢ b))) ∧ Reflexivity(_≤_)) [≤]-def-[<][≡]ₗ-[<]-def-[≤][≢]ᵣ = [↔]-intro (\([∧]-intro p q) → l p ⦃ q ⦄) (\([∧]-intro p q) → r p ⦃ q ⦄) where l : (∀{a b} → (a < b) → ((a ≤ b) ∧ (a ≢ b))) → ⦃ refl : Reflexivity(_≤_) ⦄ → ((∀{a b} → (a ≤ b) ← ((a < b) ∨ (a ≡ b))) ∧ Irreflexivity(_<_)) l [<]-def-[≤][≢]ᵣ = [∧]-intro ([∨]-elim (lt ↦ [∧]-elimₗ ([<]-def-[≤][≢]ᵣ lt)) (sub₂(_≡_)(_≤_) ⦃ reflexive-binaryRelator-sub ⦄)) (intro(xx ↦ [∧]-elimᵣ ([<]-def-[≤][≢]ᵣ xx) (reflexivity(_≡_)))) r : (∀{a b} → (a ≤ b) ← ((a < b) ∨ (a ≡ b))) → ⦃ irrefl : Irreflexivity(_<_) ⦄ → ((∀{a b} → (a < b) → ((a ≤ b) ∧ (a ≢ b))) ∧ Reflexivity(_≤_)) r [≤]-def-[<][≡]ᵣ = [∧]-intro (lt ↦ [∧]-intro ([≤]-def-[<][≡]ᵣ ([∨]-introₗ lt)) (eq ↦ empty(irreflexivity(_<_) (substitute₂ₗ(_<_) eq lt)))) (intro ([≤]-def-[<][≡]ᵣ ([∨]-introᵣ (reflexivity(_≡_))))) module By-[≤] ([<]-def-[≤][≢] : ∀{a b} → (a < b) ↔ ((a ≤ b) ∧ (a ≢ b))) where instance [<][≤]-sub : (_<_) ⊆₂ (_≤_) _⊆₂_.proof [<][≤]-sub = [∧]-elimₗ ∘ [↔]-to-[→] [<]-def-[≤][≢] instance [<][≢]-sub : (_<_) ⊆₂ (_≢_) _⊆₂_.proof [<][≢]-sub = [∧]-elimᵣ ∘ [↔]-to-[→] [<]-def-[≤][≢] module _ ⦃ [≡]-classical : ∀{a b : T} → Classical(a ≡ b) ⦄ where [≤]-def-[<][≡]ᵣ-by-classical : (a ≤ b) → ((a < b) ∨ (a ≡ b)) [≤]-def-[<][≡]ᵣ-by-classical {a}{b} le with excluded-middle(a ≡ b) ... | [∨]-introₗ eq = [∨]-introᵣ eq ... | [∨]-introᵣ ne = [∨]-introₗ ([↔]-to-[←] [<]-def-[≤][≢] ([∧]-intro le ne)) module _ ⦃ [<]-tri : ConverseTrichotomy(_<_)(_≡_) ⦄ ⦃ [≤]-antisym : Antisymmetry(_≤_)(_≡_) ⦄ where [≤]-def-[<][≡]ᵣ-by-tri-antisym : (a ≤ b) → ((a < b) ∨ (a ≡ b)) [≤]-def-[<][≡]ᵣ-by-tri-antisym {a}{b} le with trichotomy(_<_)(_≡_) {a}{b} ... | [∨]-introₗ ([∨]-introₗ lt) = [∨]-introₗ lt ... | [∨]-introₗ ([∨]-introᵣ eq) = [∨]-introᵣ eq ... | [∨]-introᵣ gt = [∨]-introᵣ (antisymmetry(_≤_)(_≡_) le ([∧]-elimₗ ([↔]-to-[→] [<]-def-[≤][≢] gt))) [<]-asymmetry-by-antisym : ⦃ antisym : Antisymmetry(_≤_)(_≡_) ⦄ → Asymmetry(_<_) Asymmetry.proof [<]-asymmetry-by-antisym xy yx = let [∧]-intro xy-le nxy = [↔]-to-[→] [<]-def-[≤][≢] xy [∧]-intro yx-le nyx = [↔]-to-[→] [<]-def-[≤][≢] yx in nxy(antisymmetry(_≤_)(_≡_) xy-le yx-le) instance [<]-irreflexivity : Irreflexivity(_<_) Irreflexivity.proof [<]-irreflexivity xx = [∧]-elimᵣ ([↔]-to-[→] [<]-def-[≤][≢] xx) (reflexivity(_≡_)) [<]-transitivity-by-asym-trans : ⦃ antisym : Asymmetry(_<_) ⦄ → ⦃ trans : Transitivity(_≤_) ⦄ → Transitivity(_<_) Transitivity.proof [<]-transitivity-by-asym-trans xy yz = let [∧]-intro xy-le nxy = [↔]-to-[→] [<]-def-[≤][≢] xy [∧]-intro yz-le nyz = [↔]-to-[→] [<]-def-[≤][≢] yz in [↔]-to-[←] [<]-def-[≤][≢] ([∧]-intro (transitivity(_≤_) xy-le yz-le) (xz ↦ asymmetry(_<_) (substitute₂ₗ(_<_) xz xy) yz)) module By-[<] ([≤]-def-[<][≡] : ∀{a b} → (a ≤ b) ↔ ((a < b) ∨ (a ≡ b))) where instance [<][≤]-sub : (_<_) ⊆₂ (_≤_) _⊆₂_.proof [<][≤]-sub = [↔]-to-[←] [≤]-def-[<][≡] ∘ [∨]-introₗ instance [≡][≤]-sub : (_≡_) ⊆₂ (_≤_) _⊆₂_.proof [≡][≤]-sub = [↔]-to-[←] [≤]-def-[<][≡] ∘ [∨]-introᵣ instance [≰][≮]-sub : (_≰_) ⊆₂ (_≮_) _⊆₂_.proof [≰][≮]-sub = contrapositiveᵣ(sub₂(_<_)(_≤_)) instance [≰][≢]-sub : (_≰_) ⊆₂ (_≢_) _⊆₂_.proof [≰][≢]-sub = contrapositiveᵣ(sub₂(_≡_)(_≤_)) instance [>][≥]-sub : (_>_) ⊆₂ (_≥_) _⊆₂_.proof [>][≥]-sub = sub₂(_<_)(_≤_) instance [≡][≥]-sub : (_≡_) ⊆₂ (_≥_) _⊆₂_.proof [≡][≥]-sub = sub₂(_≡_)(_≤_) ∘ symmetry(_≡_) instance [≱][≯]-sub : (_≱_) ⊆₂ (_≯_) _⊆₂_.proof [≱][≯]-sub = sub₂(_≰_)(_≮_) instance [≱][≢]-sub : (_≱_) ⊆₂ (_≢_) _⊆₂_.proof [≱][≢]-sub = (_∘ symmetry(_≡_)) ∘ sub₂(_≰_)(_≢_) [<]-def-[≤][≢]ₗ : (a < b) ← ((a ≤ b) ∧ (a ≢ b)) [<]-def-[≤][≢]ₗ([∧]-intro le ne) = [∨]-elim id ([⊥]-elim ∘ ne) ([↔]-to-[→] [≤]-def-[<][≡] le) instance [≤]-reflexivity : Reflexivity(_≤_) Reflexivity.proof [≤]-reflexivity = [↔]-to-[←] [≤]-def-[<][≡] ([∨]-introᵣ (reflexivity(_≡_))) [≤]-transitivity-by-trans : ⦃ [<]-trans : Transitivity(_<_) ⦄ → Transitivity(_≤_) Transitivity.proof [≤]-transitivity-by-trans xy yz with [↔]-to-[→] [≤]-def-[<][≡] xy | [↔]-to-[→] [≤]-def-[<][≡] yz ... | [∨]-introₗ xy-lt | [∨]-introₗ yz-lt = [↔]-to-[←] [≤]-def-[<][≡] ([∨]-introₗ (transitivity(_<_) xy-lt yz-lt)) ... | [∨]-introₗ xy-lt | [∨]-introᵣ yz-eq = [↔]-to-[←] [≤]-def-[<][≡] ([∨]-introₗ (substitute₂ᵣ(_<_) yz-eq xy-lt)) ... | [∨]-introᵣ xy-eq | [∨]-introₗ yz-lt = [↔]-to-[←] [≤]-def-[<][≡] ([∨]-introₗ (substitute₂ₗ(_<_) (symmetry(_≡_) xy-eq) yz-lt)) ... | [∨]-introᵣ xy-eq | [∨]-introᵣ yz-eq = [↔]-to-[←] [≤]-def-[<][≡] ([∨]-introᵣ (transitivity(_≡_) xy-eq yz-eq)) module _ ⦃ asym : Asymmetry(_<_) ⦄ where [≤]-antisymmetry-by-asym : Antisymmetry(_≤_)(_≡_) Antisymmetry.proof [≤]-antisymmetry-by-asym le ge with [↔]-to-[→] [≤]-def-[<][≡] le | [↔]-to-[→] [≤]-def-[<][≡] ge ... | [∨]-introₗ lt | [∨]-introₗ gt with () ← asymmetry(_<_) lt gt ... | [∨]-introₗ lt | [∨]-introᵣ eq = symmetry(_≡_) eq ... | [∨]-introᵣ eq | [∨]-introₗ gt = eq ... | [∨]-introᵣ eq₁ | [∨]-introᵣ eq₂ = eq₁ [<]-transitivity-by-asym-trans : ⦃ trans : Transitivity(_≤_) ⦄ → Transitivity(_<_) Transitivity.proof [<]-transitivity-by-asym-trans {x}{y}{z} xy yz = • ( • (xy ⇒ (x < y) ⇒-[ [↔]-to-[←] [≤]-def-[<][≡] ∘ [∨]-introₗ ] (x ≤ y) ⇒-end ) • (yz ⇒ (y < z) ⇒-[ [↔]-to-[←] [≤]-def-[<][≡] ∘ [∨]-introₗ ] (y ≤ z) ⇒-end ) ⇒₂-[ transitivity(_≤_) ] (x ≤ z) ⇒-[ [↔]-to-[→] [≤]-def-[<][≡] ] (x < z) ∨ (x ≡ z) ⇒-end ) • ( (\xz → • (xz ⇒ (x ≡ z) ⇒-[ apply xy ∘ substitute₂ₗ(_<_) ] (z < y) ⇒-end ) • (yz ⇒ (y < z) ⇒-end ) ⇒₂-[ asymmetry(_<_) ] ⊥ ⇒-end ) ⇒ (x ≢ z) ⇒-end ) ⇒₂-[ [∨]-not-right ] (x < z) ⇒-end [<][≱]-sub-by-asym : ((_<_) ⊆₂ (_≱_)) _⊆₂_.proof [<][≱]-sub-by-asym lt-xy ge-xy = [∨]-elim (lt-yx ↦ asymmetry(_<_) lt-xy lt-yx) (eq-yx ↦ irreflexivity(_<_) ⦃ [asymmetry]-to-irreflexivity ⦄ (substitute₂ᵣ(_<_) eq-yx lt-xy)) ([↔]-to-[→] [≤]-def-[<][≡] ge-xy) [>][≰]-sub-by-asym : ((_>_) ⊆₂ (_≰_)) _⊆₂_.proof [>][≰]-sub-by-asym gt le = [∨]-elim (asymmetry(_<_) gt) (eq ↦ irreflexivity(_<_) ⦃ [asymmetry]-to-irreflexivity ⦄ (substitute₂ᵣ(_<_) eq gt)) ([↔]-to-[→] [≤]-def-[<][≡] le) module _ ⦃ [<]-classical : Classical₂(_<_) ⦄ ⦃ [≡]-classical : Classical₂(_≡_) ⦄ where [≤]-classical-by-classical : Classical₂(_≤_) Classical.excluded-middle ([≤]-classical-by-classical {x}{y}) with excluded-middle(x < y) | excluded-middle(x ≡ y) ... | [∨]-introₗ lt | _ = [∨]-introₗ (sub₂(_<_)(_≤_) lt) ... | [∨]-introᵣ nlt | [∨]-introₗ eq = [∨]-introₗ (sub₂(_≡_)(_≤_) eq) ... | [∨]-introᵣ nlt | [∨]-introᵣ ne = [∨]-introᵣ (le ↦ nlt ([<]-def-[≤][≢]ₗ ([∧]-intro le ne))) module _ ⦃ [<]-asym : Asymmetry(_<_) ⦄ ⦃ [<]-total : ConverseTrichotomy(_<_)(_≡_) ⦄ where [≤]-classical-by-asym-tri : Classical₂(_≤_) Classical.excluded-middle ([≤]-classical-by-asym-tri {x} {y}) with trichotomy(_<_)(_≡_) {x}{y} ... | [∨]-introₗ([∨]-introₗ lt) = [∨]-introₗ (sub₂(_<_)(_≤_) lt) ... | [∨]-introₗ([∨]-introᵣ eq) = [∨]-introₗ (sub₂(_≡_)(_≤_) eq) ... | [∨]-introᵣ gt = let [<]-def-[≤][≢]ᵣ = [∧]-elimₗ ([↔]-to-[→] [≤]-def-[<][≡]ₗ-[<]-def-[≤][≢]ᵣ ([∧]-intro ([↔]-to-[←] [≤]-def-[<][≡]) [asymmetry]-to-irreflexivity)) [∧]-intro ge ne = [<]-def-[≤][≢]ᵣ gt in [∨]-introᵣ (ne ∘ antisymmetry(_≤_)(_≡_) ⦃ [≤]-antisymmetry-by-asym ⦄ ge) -- TODO: Move to Structure.Relator.Properties.Proofs module _ ⦃ [<]-asym : Asymmetry(_<_) ⦄ ⦃ [<]-total : ConverseTrichotomy(_<_)(_≡_) ⦄ where [<]-classical-by-asym-tri : Classical₂(_<_) Classical.excluded-middle ([<]-classical-by-asym-tri {x} {y}) with trichotomy(_<_)(_≡_) {x}{y} ... | [∨]-introₗ([∨]-introₗ lt) = [∨]-introₗ lt ... | [∨]-introₗ([∨]-introᵣ eq) = [∨]-introᵣ (lt ↦ irreflexivity(_<_) ⦃ [asymmetry]-to-irreflexivity ⦄ (substitute₂ₗ(_<_) eq lt)) ... | [∨]-introᵣ gt = [∨]-introᵣ (lt ↦ asymmetry(_<_) lt gt) module ByReflTriSub ⦃ [≤]-refl : Reflexivity(_≤_) ⦄ ⦃ [<]-total : ConverseTrichotomy(_<_)(_≡_) ⦄ ⦃ [<][≤]-sub : (_<_) ⊆₂ (_≤_) ⦄ where [≰][≯]-not : (a ≰ b) → (a ≯ b) → ⊥ [≰][≯]-not {a}{b} nle ngt with trichotomy(_<_)(_≡_) {a}{b} ... | [∨]-introₗ([∨]-introₗ lt) = nle (sub₂(_<_)(_≤_) lt) ... | [∨]-introₗ([∨]-introᵣ eq) = substitute₂ₗ(_≰_) ⦃ [¬]-binaryRelator ⦄ eq nle (reflexivity(_≤_)) ... | [∨]-introᵣ gt = ngt gt [≮][≱]-not : (a ≮ b) → (a ≱ b) → ⊥ [≮][≱]-not = swap [≰][≯]-not module _ ⦃ [<]-classical : Classical₂(_<_) ⦄ where [≰][>]-sub : (_≰_) ⊆₂ (_>_) _⊆₂_.proof [≰][>]-sub = [¬¬]-elim ∘ [≰][≯]-not [≱][<]-sub : (_≱_) ⊆₂ (_<_) _⊆₂_.proof [≱][<]-sub = _⊆₂_.proof [≰][>]-sub module _ ⦃ [≤]-classical : Classical₂(_≤_) ⦄ where [≯][≤]-sub : (_≯_) ⊆₂ (_≤_) _⊆₂_.proof [≯][≤]-sub = [¬¬]-elim ∘ swap [≰][≯]-not [≮][≥]-sub : (_≮_) ⊆₂ (_≥_) _⊆₂_.proof [≮][≥]-sub = _⊆₂_.proof [≯][≤]-sub module _ ⦃ [≤]-classical : Classical₂(_≤_) ⦄ ⦃ [<]-classical : Classical₂(_<_) ⦄ where [≤]-or-[>] : (a ≤ b) ∨ (a > b) [≤]-or-[>] {a}{b} with excluded-middle(a ≤ b) ... | [∨]-introₗ a≤b = [∨]-introₗ a≤b ... | [∨]-introᵣ a≰b = [∨]-introᵣ (sub₂(_≰_)(_>_) ⦃ [≰][>]-sub ⦄ a≰b) [≥]-or-[<] : (a ≥ b) ∨ (a < b) [≥]-or-[<] {a}{b} with excluded-middle(a ≥ b) ... | [∨]-introₗ a≥b = [∨]-introₗ a≥b ... | [∨]-introᵣ a≱b = [∨]-introᵣ (sub₂(_≱_)(_<_) ⦃ [≱][<]-sub ⦄ a≱b) module ByStrictPartialOrder ([≤]-def-[<][≡] : ∀{a b} → (a ≤ b) ↔ ((a < b) ∨ (a ≡ b))) ⦃ ord : Strict.PartialOrder(_<_) ⦄ where open By-[<] [≤]-def-[<][≡] open By-[<] [≤]-def-[<][≡] public using ( [<][≤]-sub ; [≡][≤]-sub ; [≰][≮]-sub ; [≰][≢]-sub ; [>][≥]-sub ; [≡][≥]-sub ; [≱][≯]-sub ; [≱][≢]-sub ; [<]-def-[≤][≢]ₗ ; [≤]-reflexivity ) instance [≤]-transitivity : Transitivity(_≤_) [≤]-transitivity = [≤]-transitivity-by-trans instance [≤]-antisymmetry : Antisymmetry(_≤_)(_≡_) [≤]-antisymmetry = [≤]-antisymmetry-by-asym instance [≤]-weakPartialorder : Weak.PartialOrder(_≤_)(_≡_) [≤]-weakPartialorder = record{} instance [<][≱]-sub : ((_<_) ⊆₂ (_≱_)) [<][≱]-sub = [<][≱]-sub-by-asym instance [>][≰]-sub : ((_>_) ⊆₂ (_≰_)) [>][≰]-sub = [>][≰]-sub-by-asym module ByStrictTotalOrder ([≤]-def-[<][≡] : ∀{a b} → (a ≤ b) ↔ ((a < b) ∨ (a ≡ b))) ⦃ ord : Strict.TotalOrder(_<_)(_≡_) ⦄ where open By-[<] [≤]-def-[<][≡] open ByStrictPartialOrder [≤]-def-[<][≡] public instance [<]-classical : Classical₂(_<_) [<]-classical = [<]-classical-by-asym-tri instance [≤]-classical : Classical₂(_≤_) [≤]-classical = [≤]-classical-by-asym-tri [≰][≯]-not : (a ≰ b) → (a ≯ b) → ⊥ [≰][≯]-not = ByReflTriSub.[≰][≯]-not [≮][≱]-not : (a ≮ b) → (a ≱ b) → ⊥ [≮][≱]-not = ByReflTriSub.[≮][≱]-not instance [≰][>]-sub : (_≰_) ⊆₂ (_>_) [≰][>]-sub = ByReflTriSub.[≰][>]-sub instance [≱][<]-sub : (_≱_) ⊆₂ (_<_) [≱][<]-sub = ByReflTriSub.[≱][<]-sub instance [≯][≤]-sub : (_≯_) ⊆₂ (_≤_) [≯][≤]-sub = ByReflTriSub.[≯][≤]-sub instance [≮][≥]-sub : (_≮_) ⊆₂ (_≥_) [≮][≥]-sub = ByReflTriSub.[≮][≥]-sub [≤]-or-[>] : (a ≤ b) ∨ (a > b) [≤]-or-[>] = ByReflTriSub.[≤]-or-[>] [≥]-or-[<] : (a ≥ b) ∨ (a < b) [≥]-or-[<] = ByReflTriSub.[≥]-or-[<]
algebraic-stack_agda0000_doc_5309
module HasSatisfaction where open import OscarPrelude open import Interpretation record HasSatisfaction (A : Set) : Set₁ where field _⊨_ : Interpretation → A → Set _⊭_ : Interpretation → A → Set _⊭_ I = ¬_ ∘ I ⊨_ open HasSatisfaction ⦃ … ⦄ public {-# DISPLAY HasSatisfaction._⊨_ _ = _⊨_ #-} {-# DISPLAY HasSatisfaction._⊭_ _ = _⊭_ #-} instance HasSatisfactionList : {A : Set} ⦃ _ : HasSatisfaction A ⦄ → HasSatisfaction $ List A HasSatisfaction._⊨_ HasSatisfactionList I [] = ⊤ HasSatisfaction._⊨_ HasSatisfactionList I (x ∷ xs) = I ⊨ x × I ⊨ xs module _ {A} ⦃ _ : HasSatisfaction A ⦄ where ⊨_ : A → Set ⊨ x = (I : Interpretation) → I ⊨ x ⊭_ : A → Set ⊭_ = ¬_ ∘ ⊨_ record HasDecidableValidation (A : Set) ⦃ _ : HasSatisfaction A ⦄ : Set₁ where field ⊨?_ : (x : A) → Dec $ ⊨ x open HasDecidableValidation ⦃ … ⦄ public {-# DISPLAY HasDecidableValidation.⊨?_ _ = ⊨?_ #-} record HasDecidableSatisfaction (A : Set) ⦃ _ : HasSatisfaction A ⦄ : Set₁ where field _⊨?_ : (I : Interpretation) → (x : A) → Dec (I ⊨ x) open HasDecidableSatisfaction ⦃ … ⦄ public {-# DISPLAY HasDecidableSatisfaction._⊨?_ _ = _⊨?_ #-}
algebraic-stack_agda0000_doc_5310
{-# OPTIONS --without-K --safe #-} open import Algebra open import Relation.Unary open import Relation.Binary hiding (Decidable) module Data.FingerTree.Split.Intermediate {r m} (ℳ : Monoid r m) {s} {ℙ : Pred (Monoid.Carrier ℳ) s} (ℙ-resp : ℙ Respects (Monoid._≈_ ℳ)) (ℙ? : Decidable ℙ) where open import Relation.Nullary using (¬_; yes; no; Dec) open import Level using (_⊔_) open import Data.Product open import Function open import Data.List as List using (List; _∷_; []) open import Data.FingerTree.Measures ℳ open import Data.FingerTree.Structures ℳ open import Data.FingerTree.Reasoning ℳ open import Data.FingerTree.View ℳ using (deepₗ; deepᵣ) open import Data.FingerTree.Cons ℳ using (listToTree) open import Relation.Nullary using (Dec; yes; no) open import Relation.Nullary.Decidable using (True; toWitness; False; toWitnessFalse) open σ ⦃ ... ⦄ open Monoid ℳ renaming (Carrier to 𝓡) open import Data.FingerTree.Relation.Binary.Reasoning.FasterInference.Setoid setoid open import Data.FingerTree.Split.Point ℳ ℙ-resp ℙ? open import Data.FingerTree.Split.StoredPredicate ℳ ℙ-resp ℙ? open import Data.Empty.Irrelevant using (⊥-elim) record Split′ (i : 𝓡) {a b} (Σ : Set a) (A : Set b) ⦃ _ : σ Σ ⦄ ⦃ _ : σ A ⦄ : Set (a ⊔ b ⊔ s) where constructor _∷⟨_⟩∷_[_] field left′ : Σ focus′ : A right′ : Σ .proof′ : i ∙ μ left′ ∣ μ focus′ open Split′ public instance σ-Split′ : ∀ {a b} {Σ : Set a} {A : Set b} ⦃ _ : σ Σ ⦄ ⦃ _ : σ A ⦄ {i : 𝓡} → σ (Split′ i Σ A) μ ⦃ σ-Split′ {i = i} ⦄ (l ∷⟨ x ⟩∷ r [ _ ]) = i ∙ (μ l ∙ (μ x ∙ μ r)) infixl 2 _i≈[_] _i≈[_] : ∀ {a b} {Σ : Set a} {A : Set b} ⦃ _ : σ Σ ⦄ ⦃ _ : σ A ⦄ → ∀ {i xs} → μ⟨ Split′ i Σ A ⟩≈ (i ∙ xs) → ∀ {j} → i ≈ j → μ⟨ Split′ j Σ A ⟩≈ (j ∙ xs) xs ∷⟨ x ⟩∷ ys [ p₁ ] ⇑[ p₂ ] i≈[ i≈ ] = xs ∷⟨ x ⟩∷ ys [ p₁ ≈◄⟅ ≪∙ i≈ ⟆ ] ⇑[ ≪∙ sym i≈ ⍮ p₂ ⍮ ≪∙ i≈ ] {-# INLINE _i≈[_] #-}
algebraic-stack_agda0000_doc_5311
{-# OPTIONS --safe #-} module Cubical.Algebra.AbGroup.Instances.Unit where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Unit renaming (Unit* to UnitType) open import Cubical.Algebra.AbGroup open import Cubical.Algebra.Group.Instances.Unit using (UnitGroup) open import Cubical.Algebra.Group.Base using (GroupStr) private variable ℓ : Level open AbGroupStr open IsAbGroup UnitAbGroup : AbGroup ℓ fst UnitAbGroup = UnitType 0g (snd UnitAbGroup) = tt* _+_ (snd UnitAbGroup) = λ _ _ → tt* - snd UnitAbGroup = λ _ → tt* isGroup (isAbGroup (snd UnitAbGroup)) = GroupStr.isGroup (snd UnitGroup) +Comm (isAbGroup (snd UnitAbGroup)) = λ _ _ → refl
algebraic-stack_agda0000_doc_5248
{-# OPTIONS --universe-polymorphism #-} module Categories.Profunctor where open import Level hiding (lift) open import Categories.Category open import Categories.Agda open import Categories.Bifunctor using (Functor; Bifunctor; _∘_) open import Categories.Functor.Hom open import Categories.Lan open import Categories.Yoneda Profunctor : ∀ {o ℓ e} {o′ ℓ′ e′} → Category o ℓ e → Category o′ ℓ′ e′ → Set _ Profunctor {ℓ = ℓ} {e} {ℓ′ = ℓ′} {e′} C D = Bifunctor (Category.op D) C (ISetoids (ℓ ⊔ ℓ′) (e ⊔ e′)) id : ∀ {o ℓ e} → {C : Category o ℓ e} → Profunctor C C id {C = C} = Hom[ C ][-,-] {- _∘_ : ∀ {o ℓ e} {o′ ℓ′ e′} {o′′ ℓ′′ e′′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {E : Category o′′ ℓ′′ e′′} → Profunctor D E → Profunctor C D → Profunctor C E F ∘ G = {!!} -}
algebraic-stack_agda0000_doc_5249
{-# OPTIONS --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Properties.Reduction {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.RedSteps open import Definition.Typed.Weakening open import Definition.LogicalRelation open import Definition.LogicalRelation.Properties.Reflexivity open import Definition.LogicalRelation.Properties.Transitivity open import Definition.LogicalRelation.Properties.Symmetry open import Definition.LogicalRelation.Properties.Escape open import Definition.LogicalRelation.Properties.Conversion open import Tools.Product open import Tools.Empty import Tools.PropositionalEquality as PE import Data.Fin as Fin import Data.Nat as Nat -- Weak head expansion of reducible types. redSubst* : ∀ {A B r l Γ} → Γ ⊢ A ⇒* B ^ r → Γ ⊩⟨ l ⟩ B ^ r → ∃ λ ([A] : Γ ⊩⟨ l ⟩ A ^ r) → Γ ⊩⟨ l ⟩ A ≡ B ^ r / [A] redSubst* {A = A} D (Uᵣ′ B .(next l′) rU l′ l< PE.refl [[ ⊢A , ⊢B , D' ]]) = let ⊢A = redFirst* D in Uᵣ′ A (next l′) rU l′ l< PE.refl [[ ⊢A , ⊢B , D ⇨* D' ]] , D' redSubst* D (ℕᵣ [[ ⊢B , ⊢ℕ , D′ ]]) = let ⊢A = redFirst* D in ℕᵣ ([[ ⊢A , ⊢ℕ , D ⇨* D′ ]]) , D′ redSubst* D (Emptyᵣ [[ ⊢B , ⊢Empty , D′ ]]) = let ⊢A = redFirst* D in Emptyᵣ ([[ ⊢A , ⊢Empty , D ⇨* D′ ]]) , D′ redSubst* D (ne′ K [[ ⊢B , ⊢K , D′ ]] neK K≡K) = let ⊢A = redFirst* D in (ne′ K [[ ⊢A , ⊢K , D ⇨* D′ ]] neK K≡K) , (ne₌ _ [[ ⊢B , ⊢K , D′ ]] neK K≡K) redSubst* D (Πᵣ′ rF lF lG lF≤ lG≤ F G [[ ⊢B , ⊢ΠFG , D′ ]] ⊢F ⊢G A≡A [F] [G] G-ext) = let ⊢A = redFirst* D in (Πᵣ′ rF lF lG lF≤ lG≤ F G [[ ⊢A , ⊢ΠFG , D ⇨* D′ ]] ⊢F ⊢G A≡A [F] [G] G-ext) , (Π₌ _ _ D′ A≡A (λ ρ ⊢Δ → reflEq ([F] ρ ⊢Δ)) (λ ρ ⊢Δ [a] → reflEq ([G] ρ ⊢Δ [a]))) redSubst* D (∃ᵣ′ F G [[ ⊢B , ⊢ΠFG , D′ ]] ⊢F ⊢G A≡A [F] [G] G-ext) = let ⊢A = redFirst* D in (∃ᵣ′ F G [[ ⊢A , ⊢ΠFG , D ⇨* D′ ]] ⊢F ⊢G A≡A [F] [G] G-ext) , (∃₌ _ _ D′ A≡A (λ ρ ⊢Δ → reflEq ([F] ρ ⊢Δ)) (λ ρ ⊢Δ [a] → reflEq ([G] ρ ⊢Δ [a]))) redSubst* {l = ι ¹} D (emb l< X) with redSubst* D X redSubst* {l = ι ¹} D (emb l< X) | y , y₁ = emb l< y , y₁ redSubst* {l = ∞} D (emb l< X) with redSubst* D X redSubst* {l = ∞} D (emb ∞< X) | y , y₁ = emb {l′ = ι ¹} ∞< y , y₁ redSubst*Term⁰ : ∀ {A t u ll Γ} → let l = ι ⁰ in Γ ⊢ t ⇒* u ∷ A ^ ll → ([A] : Γ ⊩⟨ l ⟩ A ^ [ ! , ll ]) → Γ ⊩⟨ l ⟩ u ∷ A ^ [ ! , ll ] / [A] → Γ ⊩⟨ l ⟩ t ∷ A ^ [ ! , ll ] / [A] × Γ ⊩⟨ l ⟩ t ≡ u ∷ A ^ [ ! , ll ] / [A] redSubst*Term⁰ t⇒u (ℕᵣ D) (ℕₜ n [[ ⊢u , ⊢n , d ]] n≡n prop) = let A≡ℕ = subset* (red D) ⊢t = conv (redFirst*Term t⇒u) A≡ℕ t⇒u′ = conv* t⇒u A≡ℕ in ℕₜ n [[ ⊢t , ⊢n , t⇒u′ ⇨∷* d ]] n≡n prop , ℕₜ₌ n n [[ ⊢t , ⊢n , t⇒u′ ⇨∷* d ]] [[ ⊢u , ⊢n , d ]] n≡n (reflNatural-prop prop) redSubst*Term⁰ t⇒u (ne′ K D neK K≡K) (neₜ k [[ ⊢t , ⊢u , d ]] (neNfₜ neK₁ ⊢k k≡k)) = let A≡K = subset* (red D) [d] = [[ ⊢t , ⊢u , d ]] [d′] = [[ conv (redFirst*Term t⇒u) A≡K , ⊢u , conv* t⇒u A≡K ⇨∷* d ]] in neₜ k [d′] (neNfₜ neK₁ ⊢k k≡k) , neₜ₌ k k [d′] [d] (neNfₜ₌ neK₁ neK₁ k≡k) redSubst*Term⁰ {A} {t} {u} {l} {Γ} t⇒u (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πₜ f [[ ⊢t , ⊢u , d ]] funcF f≡f [f] [f]₁) = let A≡ΠFG = subset* (red D) t⇒u′ = conv* t⇒u A≡ΠFG [d] = [[ ⊢t , ⊢u , d ]] [d′] = [[ conv (redFirst*Term t⇒u) A≡ΠFG , ⊢u , conv* t⇒u A≡ΠFG ⇨∷* d ]] in Πₜ f [d′] funcF f≡f [f] [f]₁ , Πₜ₌ f f [d′] [d] funcF funcF f≡f (Πₜ f [d′] funcF f≡f [f] [f]₁) (Πₜ f [d] funcF f≡f [f] [f]₁) (λ [ρ] ⊢Δ [a] → reflEqTerm ([G] [ρ] ⊢Δ [a]) ([f]₁ [ρ] ⊢Δ [a])) -- Weak head expansion of reducible terms. redSubst*Term : ∀ {A t u l ll Γ} → Γ ⊢ t ⇒* u ∷ A ^ ll → ([A] : Γ ⊩⟨ l ⟩ A ^ [ ! , ll ]) → Γ ⊩⟨ l ⟩ u ∷ A ^ [ ! , ll ] / [A] → Γ ⊩⟨ l ⟩ t ∷ A ^ [ ! , ll ] / [A] × Γ ⊩⟨ l ⟩ t ≡ u ∷ A ^ [ ! , ll ] / [A] redSubst*Term {t = t} {l = ι ¹} {Γ = Γ} t⇒u (Uᵣ′ A .(next ⁰) rU ⁰ l< PE.refl D) (Uₜ K [[ ⊢u , ⊢K , d ]] typeA A≡A [u]) = let A≡U = subset* (red D) ⊢t = conv (redFirst*Term t⇒u) A≡U t⇒u′ = conv* t⇒u A≡U [t] = λ {ρ} {Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) ⊢Δ → proj₁ (redSubst* {l = ι ⁰} (wkRed* [ρ] ⊢Δ (univ* t⇒u′)) ([u] [ρ] ⊢Δ)) [t≡u] = λ {ρ} {Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) ⊢Δ → proj₂ (redSubst* {l = ι ⁰} (wkRed* [ρ] ⊢Δ (univ* t⇒u′)) ([u] [ρ] ⊢Δ)) [[t]] = Uₜ K [[ ⊢t , ⊢K , t⇒u′ ⇨∷* d ]] typeA A≡A [t] in ([[t]] , Uₜ₌ [[t]] (Uₜ K [[ ⊢u , ⊢K , d ]] typeA A≡A [u]) A≡A [t≡u]) redSubst*Term {t = t} {l = ∞} {Γ = Γ} t⇒u (Uᵣ′ A .(next ¹) rU ¹ l< PE.refl D) (Uₜ K [[ ⊢u , ⊢K , d ]] typeA A≡A [u]) = let A≡U = subset* (red D) ⊢t = conv (redFirst*Term t⇒u) A≡U t⇒u′ = conv* t⇒u A≡U [t] = λ {ρ} {Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) ⊢Δ → proj₁ (redSubst* {l = ι ¹} (wkRed* [ρ] ⊢Δ (univ* t⇒u′)) ([u] [ρ] ⊢Δ)) [t≡u] = λ {ρ} {Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) ⊢Δ → proj₂ (redSubst* {l = ι ¹} (wkRed* [ρ] ⊢Δ (univ* t⇒u′)) ([u] [ρ] ⊢Δ)) [[t]] = Uₜ K [[ ⊢t , ⊢K , t⇒u′ ⇨∷* d ]] typeA A≡A [t] in ([[t]] , Uₜ₌ [[t]] (Uₜ K [[ ⊢u , ⊢K , d ]] typeA A≡A [u]) A≡A [t≡u]) redSubst*Term t⇒u (ℕᵣ D) (ℕₜ n [[ ⊢u , ⊢n , d ]] n≡n prop) = let A≡ℕ = subset* (red D) ⊢t = conv (redFirst*Term t⇒u) A≡ℕ t⇒u′ = conv* t⇒u A≡ℕ in ℕₜ n [[ ⊢t , ⊢n , t⇒u′ ⇨∷* d ]] n≡n prop , ℕₜ₌ n n [[ ⊢t , ⊢n , t⇒u′ ⇨∷* d ]] [[ ⊢u , ⊢n , d ]] n≡n (reflNatural-prop prop) redSubst*Term t⇒u (ne′ K D neK K≡K) (neₜ k [[ ⊢t , ⊢u , d ]] (neNfₜ neK₁ ⊢k k≡k)) = let A≡K = subset* (red D) [d] = [[ ⊢t , ⊢u , d ]] [d′] = [[ conv (redFirst*Term t⇒u) A≡K , ⊢u , conv* t⇒u A≡K ⇨∷* d ]] in neₜ k [d′] (neNfₜ neK₁ ⊢k k≡k) , neₜ₌ k k [d′] [d] (neNfₜ₌ neK₁ neK₁ k≡k) redSubst*Term {A} {t} {u} {l} {Γ} t⇒u (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πₜ f [[ ⊢t , ⊢u , d ]] funcF f≡f [f] [f]₁) = let A≡ΠFG = subset* (red D) t⇒u′ = conv* t⇒u A≡ΠFG [d] = [[ ⊢t , ⊢u , d ]] [d′] = [[ conv (redFirst*Term t⇒u) A≡ΠFG , ⊢u , conv* t⇒u A≡ΠFG ⇨∷* d ]] in Πₜ f [d′] funcF f≡f [f] [f]₁ , Πₜ₌ f f [d′] [d] funcF funcF f≡f (Πₜ f [d′] funcF f≡f [f] [f]₁) (Πₜ f [d] funcF f≡f [f] [f]₁) (λ [ρ] ⊢Δ [a] → reflEqTerm ([G] [ρ] ⊢Δ [a]) ([f]₁ [ρ] ⊢Δ [a])) redSubst*Term {l = ι ¹} D (emb l< X) [u] = redSubst*Term D X [u] redSubst*Term {l = ∞} D (emb l< X) [u] = redSubst*Term D X [u] -- Weak head expansion of reducible types with single reduction step. redSubst : ∀ {A B r l Γ} → Γ ⊢ A ⇒ B ^ r → Γ ⊩⟨ l ⟩ B ^ r → ∃ λ ([A] : Γ ⊩⟨ l ⟩ A ^ r) → Γ ⊩⟨ l ⟩ A ≡ B ^ r / [A] redSubst A⇒B [B] = redSubst* (A⇒B ⇨ id (escape [B])) [B] -- Weak head expansion of reducible terms with single reduction step. redSubstTerm : ∀ {A t u l ll Γ} → Γ ⊢ t ⇒ u ∷ A ^ ll → ([A] : Γ ⊩⟨ l ⟩ A ^ [ ! , ll ]) → Γ ⊩⟨ l ⟩ u ∷ A ^ [ ! , ll ] / [A] → Γ ⊩⟨ l ⟩ t ∷ A ^ [ ! , ll ] / [A] × Γ ⊩⟨ l ⟩ t ≡ u ∷ A ^ [ ! , ll ] / [A] redSubstTerm t⇒u [A] [u] = redSubst*Term (t⇒u ⇨ id (escapeTerm [A] [u])) [A] [u] -- Equalities redSubst*EqTerm : ∀ {A B t t′ u u′ l ll Γ} → Γ ⊢ t ⇒* t′ ∷ A ^ ll → Γ ⊢ u ⇒* u′ ∷ B ^ ll → ([A] : Γ ⊩⟨ l ⟩ A ^ [ ! , ll ]) → ([B] : Γ ⊩⟨ l ⟩ B ^ [ ! , ll ]) → Γ ⊩⟨ l ⟩ A ≡ B ^ [ ! , ll ] / [A] → Γ ⊩⟨ l ⟩ t′ ∷ A ^ [ ! , ll ] / [A] → Γ ⊩⟨ l ⟩ u′ ∷ B ^ [ ! , ll ] / [B] → Γ ⊩⟨ l ⟩ t′ ≡ u′ ∷ A ^ [ ! , ll ] / [A] → Γ ⊩⟨ l ⟩ t ≡ u ∷ A ^ [ ! , ll ] / [A] redSubst*EqTerm D D′ [A] [B] [A≡B] [t′] [u′] [t′≡u′] = let [t≡t′] = proj₂ (redSubst*Term D [A] [t′]) [u≡u′:B] = proj₂ (redSubst*Term D′ [B] [u′]) [u≡u′] = convEqTerm₂ [A] [B] [A≡B] [u≡u′:B] in transEqTerm [A] [t≡t′] (transEqTerm [A] [t′≡u′] (symEqTerm [A] [u≡u′]))
algebraic-stack_agda0000_doc_5250
open import Data.String using ( String ) open import Data.List.Primitive using ( #List ) open import Data.Maybe.Primitive using ( #Maybe ) open import Web.URI.Port.Primitive using ( Port? ) open import Web.URI.Scheme.Primitive using ( Scheme? ) module Web.URI.Primitive where {-# IMPORT Data.Maybe #-} {-# IMPORT Web.URI.AgdaFFI #-} data #URI : Set where #abs : Scheme? → String → Port? → (#List String) → (#Maybe String) → #URI #rel : (#List String) → (#Maybe String) → #URI {-# COMPILED_DATA #URI Web.URI.AgdaFFI.URI Web.URI.AgdaFFI.Abs Web.URI.AgdaFFI.Rel #-} postulate #toString : #URI → String {-# COMPILED #toString Web.URI.AgdaFFI.toString #-} postulate #fromString : String → (#Maybe #URI) {-# COMPILED #fromString Web.URI.AgdaFFI.fromString #-}
algebraic-stack_agda0000_doc_5251
open import Oscar.Prelude open import Oscar.Class.IsPrefunctor open import Oscar.Class.Smap open import Oscar.Class.Surjection open import Oscar.Class.Transitivity module Oscar.Class.Prefunctor where record Prefunctor 𝔬₁ 𝔯₁ ℓ₁ 𝔬₂ 𝔯₂ ℓ₂ : Ø ↑̂ (𝔬₁ ∙̂ 𝔯₁ ∙̂ ℓ₁ ∙̂ 𝔬₂ ∙̂ 𝔯₂ ∙̂ ℓ₂) where constructor ∁ field {𝔒₁} : Ø 𝔬₁ _∼₁_ : 𝔒₁ → 𝔒₁ → Ø 𝔯₁ _∼̇₁_ : ∀ {x y} → x ∼₁ y → x ∼₁ y → Ø ℓ₁ _↦₁_ : Transitivity.type _∼₁_ {𝔒₂} : Ø 𝔬₂ _∼₂_ : 𝔒₂ → 𝔒₂ → Ø 𝔯₂ _∼̇₂_ : ∀ {x y} → x ∼₂ y → x ∼₂ y → Ø ℓ₂ _↦₂_ : Transitivity.type _∼₂_ {μ} : Surjection.type 𝔒₁ 𝔒₂ prefunctor-smap : Smap.type _∼₁_ _∼₂_ μ μ ⦃ `IsPrefunctor ⦄ : IsPrefunctor _∼₁_ _∼̇₁_ _↦₁_ _∼₂_ _∼̇₂_ _↦₂_ prefunctor-smap
algebraic-stack_agda0000_doc_5252
module Negative5 where data Funny (A : Set) : Set where funny : A -> Funny (Funny A -> A) -> Funny A
algebraic-stack_agda0000_doc_5253
module _ where -- Check that previous clauses reduce in later ones open import Agda.Builtin.Nat hiding (_==_) record Σ (A : Set) (B : A → Set) : Set where field fst : A snd : B fst open Σ postulate T : Nat → Set mkT : ∀ n → T n t5 : Σ Nat T fst t5 = 5 snd t5 = mkT 5 -- Also with instance projections -- open import Agda.Builtin.Bool open import Agda.Builtin.Equality record Eq (A : Set) : Set where field _==_ : A → A → Bool reflexive : ∀ x → true ≡ (x == x) open Eq {{...}} instance EqNat : Eq Nat _==_ {{EqNat}} zero zero = true _==_ {{EqNat}} zero (suc y) = false _==_ {{EqNat}} (suc x) zero = false _==_ {{EqNat}} (suc x) (suc y) = x == y reflexive {{EqNat}} zero = refl reflexive {{EqNat}} (suc x) rewrite reflexive x = refl
algebraic-stack_agda0000_doc_5254
------------------------------------------------------------------------ -- The Agda standard library -- -- Natural numbers represented in binary. ------------------------------------------------------------------------ -- This module aims to create an alternative formulation of ℕ that is -- still reasonably computationally efficient without having to call out -- to Haskell. {-# OPTIONS --without-K --safe #-} module Data.Nat.Binary.Base where open import Algebra.Core using (Op₂) open import Data.Nat.Base as ℕ using (ℕ) open import Data.Sum.Base using (_⊎_) open import Function using (_on_) open import Level using (0ℓ) open import Relation.Binary using (Rel) open import Relation.Binary.PropositionalEquality using (_≡_) open import Relation.Nullary using (¬_) ------------------------------------------------------------------------ -- Definition data ℕᵇ : Set where zero : ℕᵇ 2[1+_] : ℕᵇ → ℕᵇ -- n → 2*(1+n) = nonzero even numbers 1+[2_] : ℕᵇ → ℕᵇ -- n → 1 + 2*n = odd numbers ------------------------------------------------------------------------ -- Ordering relations infix 4 _<_ _>_ _≤_ _≮_ _≯_ _≰_ _≱_ data _<_ : Rel ℕᵇ 0ℓ where 0<even : ∀ {x} → zero < 2[1+ x ] 0<odd : ∀ {x} → zero < 1+[2 x ] even<even : ∀ {x y} → x < y → 2[1+ x ] < 2[1+ y ] even<odd : ∀ {x y} → x < y → 2[1+ x ] < 1+[2 y ] odd<even : ∀ {x y} → x < y ⊎ x ≡ y → 1+[2 x ] < 2[1+ y ] odd<odd : ∀ {x y} → x < y → 1+[2 x ] < 1+[2 y ] -- In these constructors "even" stands for nonzero even. _>_ : Rel ℕᵇ 0ℓ x > y = y < x _≤_ : Rel ℕᵇ 0ℓ x ≤ y = x < y ⊎ x ≡ y _≥_ : Rel ℕᵇ 0ℓ x ≥ y = y ≤ x _≮_ : Rel ℕᵇ 0ℓ x ≮ y = ¬ (x < y) _≯_ : Rel ℕᵇ 0ℓ x ≯ y = ¬ (x > y) _≰_ : Rel ℕᵇ 0ℓ x ≰ y = ¬ (x ≤ y) _≱_ : Rel ℕᵇ 0ℓ x ≱ y = ¬ (x ≥ y) ------------------------------------------------------------------------ -- Basic operations double : ℕᵇ → ℕᵇ double zero = zero double 2[1+ x ] = 2[1+ 1+[2 x ] ] double 1+[2 x ] = 2[1+ (double x) ] suc : ℕᵇ → ℕᵇ suc zero = 1+[2 zero ] suc 2[1+ x ] = 1+[2 (suc x) ] suc 1+[2 x ] = 2[1+ x ] pred : ℕᵇ → ℕᵇ pred zero = zero pred 2[1+ x ] = 1+[2 x ] pred 1+[2 x ] = double x ------------------------------------------------------------------------ -- Addition, multiplication and certain related functions infixl 6 _+_ infixl 7 _*_ _+_ : Op₂ ℕᵇ zero + y = y x + zero = x 2[1+ x ] + 2[1+ y ] = 2[1+ suc (x + y) ] 2[1+ x ] + 1+[2 y ] = suc 2[1+ (x + y) ] 1+[2 x ] + 2[1+ y ] = suc 2[1+ (x + y) ] 1+[2 x ] + 1+[2 y ] = suc 1+[2 (x + y) ] _*_ : Op₂ ℕᵇ zero * _ = zero _ * zero = zero 2[1+ x ] * 2[1+ y ] = double 2[1+ x + (y + x * y) ] 2[1+ x ] * 1+[2 y ] = 2[1+ x + y * 2[1+ x ] ] 1+[2 x ] * 2[1+ y ] = 2[1+ y + x * 2[1+ y ] ] 1+[2 x ] * 1+[2 y ] = 1+[2 x + y * 1+[2 x ] ] ------------------------------------------------------------------------ -- Conversion between ℕᵇ and ℕ toℕ : ℕᵇ → ℕ toℕ zero = 0 toℕ 2[1+ x ] = 2 ℕ.* (ℕ.suc (toℕ x)) toℕ 1+[2 x ] = ℕ.suc (2 ℕ.* (toℕ x)) -- Costs O(n), could be improved using `_/_` and `_%_` fromℕ : ℕ → ℕᵇ fromℕ 0 = zero fromℕ (ℕ.suc n) = suc (fromℕ n) -- An alternative ordering lifted from ℕ infix 4 _<ℕ_ _<ℕ_ : Rel ℕᵇ 0ℓ _<ℕ_ = ℕ._<_ on toℕ ------------------------------------------------------------------------ -- Other functions -- Useful in some termination proofs. size : ℕᵇ → ℕ size zero = 0 size 2[1+ x ] = ℕ.suc (size x) size 1+[2 x ] = ℕ.suc (size x) ------------------------------------------------------------------------ -- Constants 0ᵇ = zero 1ᵇ = suc 0ᵇ 2ᵇ = suc 1ᵇ 3ᵇ = suc 2ᵇ 4ᵇ = suc 3ᵇ 5ᵇ = suc 4ᵇ 6ᵇ = suc 5ᵇ 7ᵇ = suc 6ᵇ 8ᵇ = suc 7ᵇ 9ᵇ = suc 8ᵇ
algebraic-stack_agda0000_doc_5255
------------------------------------------------------------------------ -- The Agda standard library -- -- Convenient syntax for reasoning with a setoid ------------------------------------------------------------------------ -- Example use: -- n*0≡0 : ∀ n → n * 0 ≡ 0 -- n*0≡0 zero = refl -- n*0≡0 (suc n) = begin -- suc n * 0 ≈⟨ refl ⟩ -- n * 0 + 0 ≈⟨ ... ⟩ -- n * 0 ≈⟨ n*0≡0 n ⟩ -- 0 ∎ -- Module `≡-Reasoning` in `Relation.Binary.PropositionalEquality` -- is recommended for equational reasoning when the underlying equality is -- `_≡_`. {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Relation.Binary.Reasoning.Setoid {s₁ s₂} (S : Setoid s₁ s₂) where open Setoid S ------------------------------------------------------------------------ -- Publicly re-export base contents open import Relation.Binary.Reasoning.Base.Single _≈_ refl trans public renaming (_∼⟨_⟩_ to _≈⟨_⟩_) infixr 2 _≈˘⟨_⟩_ _≈˘⟨_⟩_ : ∀ x {y z} → y ≈ x → y IsRelatedTo z → x IsRelatedTo z x ≈˘⟨ x≈y ⟩ y∼z = x ≈⟨ sym x≈y ⟩ y∼z