Search is not available for this dataset
text
string
meta
dict
------------------------------------------------------------------------ -- The lenses fst and snd ------------------------------------------------------------------------ -- This module uses univalence without tracking such uses in the types -- of functions, and it is not parametrised by a notion of equality, -- it uses path equality. {-# OPTIONS --guardedness #-} module README.Fst-snd where open import Equality.Path open import Equality.Path.Univalence open import Prelude open import Equivalence.Erased.Cubical equality-with-paths as EEq using (_≃ᴱ_) import Lens.Non-dependent.Higher.Coinductive.Small.Erased equality-with-paths as S import Lens.Non-dependent.Higher.Erased equality-with-paths as E private variable a : Level A B : Type a -- A static variant of one consequence of S.Lens≃ᴱLensᴱ. Applications -- of static functions are normalised by (at least) the GHC backend. Lens→Lens : E.Lens A B → S.Lens univ A B Lens→Lens = _≃ᴱ_.from (S.Lens≃ᴱLensᴱ ⊠ univ) {-# STATIC Lens→Lens #-} -- A lens for the first projection. fst : S.Lens univ (A × B) A fst = Lens→Lens E.fst -- A lens for the second projection. -- -- With the implementation that this lens had at the time of writing -- (dependencies may later have changed) it turned out that when the -- lens was compiled using the non-strict GHC backend of a certain -- development version of Agda and GHC 9.0.1, then GHC's flag -- -ddump-simpl suggested that you ended up with code that could lead -- to a space leak: the code for the setter was something like -- -- \p y -> Pair (case p of { Pair x _ -> x }) y -- -- (where names have been changed, and code related to coercions and -- casts has been removed). -- -- Note that, unlike the lens snd^C discussed in "Compiling Programs -- with Erased Univalence", this one (as well as the one below) takes -- two universe level arguments. snd-with-space-leak : S.Lens univ (A × B) B snd-with-space-leak = Lens→Lens E.snd -- A lens for the second projection. -- -- This variant did not seem to have the problem exhibited by -- snd-with-space-leak: the code for the setter was something like -- -- \p y -> case p of { Pair x _ -> Pair x y }. snd : S.Lens univ (A × B) B snd = S.with-other-setter (Lens→Lens E.snd) (λ { (x , _) y → (x , y) }) ((λ (x , _) y → (x , y)) ≡⟨⟩ E.Lens.set E.snd ≡⟨ sym $ proj₂ $ proj₂ (S.Lens≃ᴱLensᴱ-preserves-getters-and-setters ⊠ univ univ) E.snd ⟩∎ S.Lens.set (Lens→Lens E.snd) ∎)
{ "alphanum_fraction": 0.6467761314, "avg_line_length": 32.0128205128, "ext": "agda", "hexsha": "4293482d4706902c8b5bde28d788631bce502bc5", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-07-01T14:33:26.000Z", "max_forks_repo_forks_event_min_datetime": "2020-07-01T14:33:26.000Z", "max_forks_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/dependent-lenses", "max_forks_repo_path": "README/Fst-snd.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/dependent-lenses", "max_issues_repo_path": "README/Fst-snd.agda", "max_line_length": 124, "max_stars_count": 3, "max_stars_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/dependent-lenses", "max_stars_repo_path": "README/Fst-snd.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:55:52.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T12:10:46.000Z", "num_tokens": 708, "size": 2497 }
module Bughunting where data Nat : Set where zero : Nat suc : Nat -> Nat plus : Nat -> Nat -> Nat {-# BUILTIN NATURAL Nat #-} plus m n = {! !} data List2 (A : Set) : Nat -> Set where empty2 : List2 A 0 cons2 : {n : Nat} -> A -> List2 A n -> List2 A (plus 1 n)
{ "alphanum_fraction": 0.5049180328, "avg_line_length": 19.0625, "ext": "agda", "hexsha": "66493bff887ec6ea0aff26a4db8c1554cd3d2ca9", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-01-31T08:40:41.000Z", "max_forks_repo_forks_event_min_datetime": "2019-01-31T08:40:41.000Z", "max_forks_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "omega12345/RefactorAgda", "max_forks_repo_path": "RefactorAgdaEngine/Test/Tests/input/Bughunting.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_issues_repo_issues_event_max_datetime": "2019-02-05T12:53:36.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-31T08:03:07.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "omega12345/RefactorAgda", "max_issues_repo_path": "RefactorAgdaEngine/Test/Tests/input/Bughunting.agda", "max_line_length": 63, "max_stars_count": 5, "max_stars_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "omega12345/RefactorAgda", "max_stars_repo_path": "RefactorAgdaEngine/Test/Tests/input/Bughunting.agda", "max_stars_repo_stars_event_max_datetime": "2019-05-03T10:03:36.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-31T14:10:18.000Z", "num_tokens": 100, "size": 305 }
{-# OPTIONS --without-K #-} open import Library open import Basic -------------------------------------------------------------------------------- -- Universes for a Functor -------------------------------------------------------------------------------- record FntrLevel : Set where field C : CatLevel D : CatLevel module C = CatLevel C module D = CatLevel D Fntr : Level Fntr = ℓ-max C.Cat D.Cat -------------------------------------------------------------------------------- -- Definition of a Functor -------------------------------------------------------------------------------- module _ {ℓ : FntrLevel} (let module ℓ = FntrLevel ℓ) (C : Category ℓ.C) (let module C = Category C) (open C using () renaming (_⇒_ to _⇒ᶜ_ ; _∘_ to _∘ᶜ_)) (D : Category ℓ.D) (let module D = Category D) (open D using () renaming (_⇒_ to _⇒ᵈ_ ; _∘_ to _∘ᵈ_)) where record Functor : Set ℓ.Fntr where field map : C.Obj → D.Obj fmap : ∀{X Y} → X ⇒ᶜ Y → (map X) ⇒ᵈ (map Y) field id : ∀{X} → fmap (C.id X) ≡ D.id (map X) comp : ∀{X Y Z}{f : X ⇒ᶜ Y}{g : Y ⇒ᶜ Z} → fmap (g ∘ᶜ f) ≡ (fmap g) ∘ᵈ (fmap f) -------------------------------------------------------------------------------- -- Definition of a Natural Transformation and a Natural Isomorphism -------------------------------------------------------------------------------- module _ {ℓ : FntrLevel} (let module ℓ = FntrLevel ℓ) {C : Category ℓ.C} (let module C = Category C) (open C using () renaming (_⇒_ to _⇒ᶜ_ ; _∘_ to _∘ᶜ_)) {D : Category ℓ.D} (let module D = Category D) (open D using () renaming (_⇒_ to _⇒ᵈ_ ; _∘_ to _∘ᵈ_)) (F G : Functor C D) (let module F = Functor F) (let module G = Functor G) where record NaturalTrans : Set ℓ.Fntr where field map : (X : C.Obj) → (F.map X) ⇒ᵈ (G.map X) nat-sq : {X Y : C.Obj}{f : X ⇒ᶜ Y} → (G.fmap f) ∘ᵈ (map X) ≡ (map Y) ∘ᵈ (F.fmap f) is-natrual-isomorphism : Set (ℓ-max ℓ.C.Obj ℓ.D.Hom) is-natrual-isomorphism = ∀(X : C.Obj) → D.is-isomorphism (map X) NaturalIso : Set ℓ.Fntr NaturalIso = Σ NaturalTrans NaturalTrans.is-natrual-isomorphism -------------------------------------------------------------------------------- -- Category of Functors -------------------------------------------------------------------------------- module _ {ℓ : FntrLevel} (let module ℓ = FntrLevel ℓ) (C : Category ℓ.C) (let module C = Category C) (open C using () renaming (_⇒_ to _⇒ᶜ_ ; _∘_ to _∘ᶜ_)) (D : Category ℓ.D) (let module D = Category D) (open D using () renaming (_⇒_ to _⇒ᵈ_ ; _∘_ to _∘ᵈ_)) where FntrCat : Category (record { Obj = ℓ.Fntr ; Hom = ℓ.Fntr }) FntrCat = record { Obj = Functor C D ; _⇒_ = NaturalTrans ; id = natural-trans-id ; _∘_ = vertical-comp ; idl = {!!} ; idr = {!!} ; assoc = {!!} } where natural-trans-id : (F : Functor C D) → NaturalTrans F F natural-trans-id F = record { map = λ (X : C.Obj) → D.id (F.map X) ; nat-sq = λ {X Y : C.Obj} {f : X ⇒ᶜ Y} → ≡-proof (F.fmap f) ∘ᵈ D.id (F.map X) ≡⟨ D.idr ⟩ F.fmap f ≡⟨ ≡-sym D.idl ⟩ D.id (F.map Y) ∘ᵈ (F.fmap f) ≡-qed } where module F = Functor F vertical-comp : {F G H : Functor C D} → NaturalTrans G H → NaturalTrans F G → NaturalTrans F H vertical-comp {F} {G} {H} β α = record { map = λ (X : C.Obj) → (β.map X) ∘ᵈ (α.map X) ; nat-sq = λ {X Y : C.Obj} {f : X ⇒ᶜ Y} → ≡-proof H.fmap f ∘ᵈ (β.map X ∘ᵈ α.map X) ≡⟨ ≡-sym D.assoc ⟩ (H.fmap f ∘ᵈ β.map X) ∘ᵈ α.map X ≡⟨ {!!} ⟩ (β.map Y ∘ᵈ G.fmap f) ∘ᵈ α.map X ≡⟨ D.assoc ⟩ β.map Y ∘ᵈ (G.fmap f ∘ᵈ α.map X) ≡⟨ {!!} ⟩ β.map Y ∘ᵈ (α.map Y ∘ᵈ F.fmap f) ≡⟨ ≡-sym D.assoc ⟩ (β.map Y ∘ᵈ α.map Y) ∘ᵈ F.fmap f ≡-qed } where module F = Functor F module G = Functor G module H = Functor H module α = NaturalTrans α module β = NaturalTrans β -------------------------------------------------------------------------------- -- Definition of Presheaf -------------------------------------------------------------------------------- -- module _ {C : CatLevel} (open CatLevel C) -- (C : Category C) (let module C = Category C) where -- Presheaf : Category (record { Obj = ℓ-suc Obj ; Hom = ℓ-suc Hom }) -- Presheaf C = record { Obj = Functor C.op (Type Hom) -- ; _⇒_ = NaturalTrans -- ; id = NaturalTrans-id -- ; __}
{ "alphanum_fraction": 0.3956607495, "avg_line_length": 42.25, "ext": "agda", "hexsha": "775b2202ee27b8f4cffafcabcc61bdd39c6cc472", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "045f2ab8a40c1b87f578ef12c0d1e10d131b7da3", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "gunpinyo/agda-cat", "max_forks_repo_path": "src/Naturality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "045f2ab8a40c1b87f578ef12c0d1e10d131b7da3", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "gunpinyo/agda-cat", "max_issues_repo_path": "src/Naturality.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "045f2ab8a40c1b87f578ef12c0d1e10d131b7da3", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "gunpinyo/agda-cat", "max_stars_repo_path": "src/Naturality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1571, "size": 5070 }
{-# OPTIONS --safe --cubical-compatible #-} module Erased-cubical.Without-K where data D : Set where c : D
{ "alphanum_fraction": 0.6756756757, "avg_line_length": 15.8571428571, "ext": "agda", "hexsha": "d4eb298790e4a4151b1e55d2843173b374840367", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Succeed/Erased-cubical/Without-K.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Succeed/Erased-cubical/Without-K.agda", "max_line_length": 43, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Succeed/Erased-cubical/Without-K.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 32, "size": 111 }
{-# OPTIONS --without-K #-} open import lib.Basics open import lib.NConnected open import lib.types.Nat open import lib.types.TLevel open import lib.types.Empty open import lib.types.Group open import lib.types.Pi open import lib.types.Pointed open import lib.types.Paths open import lib.types.Sigma open import lib.types.Truncation open import lib.cubical.Square module lib.types.LoopSpace where module _ {i} where ⊙Ω : Ptd i → Ptd i ⊙Ω (A , a) = ⊙[ (a == a) , idp ] Ω : Ptd i → Type i Ω = fst ∘ ⊙Ω ⊙Ω^ : (n : ℕ) → Ptd i → Ptd i ⊙Ω^ O X = X ⊙Ω^ (S n) X = ⊙Ω (⊙Ω^ n X) Ω^ : (n : ℕ) → Ptd i → Type i Ω^ n X = fst (⊙Ω^ n X) idp^ : ∀ {i} (n : ℕ) {X : Ptd i} → Ω^ n X idp^ n {X} = snd (⊙Ω^ n X) {- for n ≥ 1, we have a group structure on the loop space -} module _ {i} (n : ℕ) {X : Ptd i} where !^S : Ω^ (S n) X → Ω^ (S n) X !^S = ! conc^S : Ω^ (S n) X → Ω^ (S n) X → Ω^ (S n) X conc^S = _∙_ {- pointed versions of functions on paths -} private pt-lemma : ∀ {i} {A : Type i} {x y : A} (p : x == y) → ! p ∙ (idp ∙' p) == idp pt-lemma idp = idp ⊙conc : ∀ {i} {X : Ptd i} → fst (⊙Ω X ⊙× ⊙Ω X ⊙→ ⊙Ω X) ⊙conc = (uncurry _∙_ , idp) ⊙ap : ∀ {i j} {X : Ptd i} {Y : Ptd j} → fst (X ⊙→ Y) → fst (⊙Ω X ⊙→ ⊙Ω Y) ⊙ap (f , fpt) = ((λ p → ! fpt ∙ ap f p ∙' fpt) , pt-lemma fpt) ⊙ap2 : ∀ {i j k} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} → fst (X ⊙× Y ⊙→ Z) → fst (⊙Ω X ⊙× ⊙Ω Y ⊙→ ⊙Ω Z) ⊙ap2 (f , fpt) = ((λ {(p , q) → ! fpt ∙ ap2 (curry f) p q ∙' fpt}) , pt-lemma fpt) ⊙ap-∘ : ∀ {i j k} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} (g : fst (Y ⊙→ Z)) (f : fst (X ⊙→ Y)) → ⊙ap (g ⊙∘ f) == ⊙ap g ⊙∘ ⊙ap f ⊙ap-∘ (g , idp) (f , idp) = ⊙λ= (λ p → ap-∘ g f p) idp ⊙ap-idf : ∀ {i} {X : Ptd i} → ⊙ap (⊙idf X) == ⊙idf _ ⊙ap-idf = ⊙λ= ap-idf idp ⊙ap2-fst : ∀ {i j} {X : Ptd i} {Y : Ptd j} → ⊙ap2 {X = X} {Y = Y} ⊙fst == ⊙fst ⊙ap2-fst = ⊙λ= (uncurry ap2-fst) idp ⊙ap2-snd : ∀ {i j} {X : Ptd i} {Y : Ptd j} → ⊙ap2 {X = X} {Y = Y} ⊙snd == ⊙snd ⊙ap2-snd = ⊙λ= (uncurry ap2-snd) idp ⊙ap-ap2 : ∀ {i j k l} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} {W : Ptd l} (G : fst (Z ⊙→ W)) (F : fst (X ⊙× Y ⊙→ Z)) → ⊙ap G ⊙∘ ⊙ap2 F == ⊙ap2 (G ⊙∘ F) ⊙ap-ap2 (g , idp) (f , idp) = ⊙λ= (uncurry (ap-ap2 g (curry f))) idp ⊙ap2-ap : ∀ {i j k l m} {X : Ptd i} {Y : Ptd j} {U : Ptd k} {V : Ptd l} {Z : Ptd m} (G : fst ((U ⊙× V) ⊙→ Z)) (F₁ : fst (X ⊙→ U)) (F₂ : fst (Y ⊙→ V)) → ⊙ap2 G ⊙∘ pair⊙→ (⊙ap F₁) (⊙ap F₂) == ⊙ap2 (G ⊙∘ pair⊙→ F₁ F₂) ⊙ap2-ap (g , idp) (f₁ , idp) (f₂ , idp) = ⊙λ= (λ {(p , q) → ap2-ap-l (curry g) f₁ p (ap f₂ q) ∙ ap2-ap-r (λ x v → g (f₁ x , v)) f₂ p q}) idp ⊙ap2-diag : ∀ {i j} {X : Ptd i} {Y : Ptd j} (F : fst (X ⊙× X ⊙→ Y)) → ⊙ap2 F ⊙∘ ⊙diag == ⊙ap (F ⊙∘ ⊙diag) ⊙ap2-diag (f , idp) = ⊙λ= (ap2-diag (curry f)) idp {- ap and ap2 for higher loop spaces -} ap^ : ∀ {i j} (n : ℕ) {X : Ptd i} {Y : Ptd j} → fst (X ⊙→ Y) → fst (⊙Ω^ n X ⊙→ ⊙Ω^ n Y) ap^ O F = F ap^ (S n) F = ⊙ap (ap^ n F) ap2^ : ∀ {i j k} (n : ℕ) {X : Ptd i} {Y : Ptd j} {Z : Ptd k} → fst ((X ⊙× Y) ⊙→ Z) → fst ((⊙Ω^ n X ⊙× ⊙Ω^ n Y) ⊙→ ⊙Ω^ n Z) ap2^ O F = F ap2^ (S n) F = ⊙ap2 (ap2^ n F) ap^-idf : ∀ {i} (n : ℕ) {X : Ptd i} → ap^ n (⊙idf X) == ⊙idf _ ap^-idf O = idp ap^-idf (S n) = ap ⊙ap (ap^-idf n) ∙ ⊙ap-idf ap^-ap2^ : ∀ {i j k l} (n : ℕ) {X : Ptd i} {Y : Ptd j} {Z : Ptd k} {W : Ptd l} (G : fst (Z ⊙→ W)) (F : fst ((X ⊙× Y) ⊙→ Z)) → ap^ n G ⊙∘ ap2^ n F == ap2^ n (G ⊙∘ F) ap^-ap2^ O G F = idp ap^-ap2^ (S n) G F = ⊙ap-ap2 (ap^ n G) (ap2^ n F) ∙ ap ⊙ap2 (ap^-ap2^ n G F) ap2^-fst : ∀ {i j} (n : ℕ) {X : Ptd i} {Y : Ptd j} → ap2^ n {X} {Y} ⊙fst == ⊙fst ap2^-fst O = idp ap2^-fst (S n) = ap ⊙ap2 (ap2^-fst n) ∙ ⊙ap2-fst ap2^-snd : ∀ {i j} (n : ℕ) {X : Ptd i} {Y : Ptd j} → ap2^ n {X} {Y} ⊙snd == ⊙snd ap2^-snd O = idp ap2^-snd (S n) = ap ⊙ap2 (ap2^-snd n) ∙ ⊙ap2-snd ap2^-ap^ : ∀ {i j k l m} (n : ℕ) {X : Ptd i} {Y : Ptd j} {U : Ptd k} {V : Ptd l} {Z : Ptd m} (G : fst ((U ⊙× V) ⊙→ Z)) (F₁ : fst (X ⊙→ U)) (F₂ : fst (Y ⊙→ V)) → ap2^ n G ⊙∘ pair⊙→ (ap^ n F₁) (ap^ n F₂) == ap2^ n (G ⊙∘ pair⊙→ F₁ F₂) ap2^-ap^ O G F₁ F₂ = idp ap2^-ap^ (S n) G F₁ F₂ = ⊙ap2-ap (ap2^ n G) (ap^ n F₁) (ap^ n F₂) ∙ ap ⊙ap2 (ap2^-ap^ n G F₁ F₂) ap2^-diag : ∀ {i j} (n : ℕ) {X : Ptd i} {Y : Ptd j} (F : fst (X ⊙× X ⊙→ Y)) → ap2^ n F ⊙∘ ⊙diag == ap^ n (F ⊙∘ ⊙diag) ap2^-diag O F = idp ap2^-diag (S n) F = ⊙ap2-diag (ap2^ n F) ∙ ap ⊙ap (ap2^-diag n F) module _ {i} {X : Ptd i} (n : ℕ) where {- Prove these as lemmas now - so we don't have to deal with the n = O case later -} conc^S-unit-l : (q : Ω^ (S n) X) → (conc^S n (idp^ (S n)) q) == q conc^S-unit-l _ = idp conc^S-unit-r : (q : Ω^ (S n) X) → (conc^S n q (idp^ (S n))) == q conc^S-unit-r = ∙-unit-r conc^S-assoc : (p q r : Ω^ (S n) X) → conc^S n (conc^S n p q) r == conc^S n p (conc^S n q r) conc^S-assoc = ∙-assoc !^S-inv-l : (p : Ω^ (S n) X) → conc^S n (!^S n p) p == idp^ (S n) !^S-inv-l = !-inv-l !^S-inv-r : (p : Ω^ (S n) X) → conc^S n p (!^S n p) == idp^ (S n) !^S-inv-r = !-inv-r abstract ap^S-conc^S : ∀ {i j} (n : ℕ) {X : Ptd i} {Y : Ptd j} (F : fst (X ⊙→ Y)) (p q : Ω^ (S n) X) → fst (ap^ (S n) F) (conc^S n p q) == conc^S n (fst (ap^ (S n) F) p) (fst (ap^ (S n) F) q) ap^S-conc^S n {X = X} {Y = Y} F p q = ! gpt ∙ ap g (p ∙ q) ∙' gpt =⟨ ap-∙ g p q |in-ctx (λ w → ! gpt ∙ w ∙' gpt) ⟩ ! gpt ∙ (ap g p ∙ ap g q) ∙' gpt =⟨ lemma (ap g p) (ap g q) gpt ⟩ (! gpt ∙ ap g p ∙' gpt) ∙ (! gpt ∙ ap g q ∙' gpt) ∎ where g : Ω^ n X → Ω^ n Y g = fst (ap^ n F) gpt : g (idp^ n) == idp^ n gpt = snd (ap^ n F) lemma : ∀ {i} {A : Type i} {x y : A} → (p q : x == x) (r : x == y) → ! r ∙ (p ∙ q) ∙' r == (! r ∙ p ∙' r) ∙ (! r ∙ q ∙' r) lemma p q idp = idp {- ap^ preserves (pointed) equivalences -} module _ {i j} {X : Ptd i} {Y : Ptd j} where is-equiv-ap^ : (n : ℕ) (F : fst (X ⊙→ Y)) (e : is-equiv (fst F)) → is-equiv (fst (ap^ n F)) is-equiv-ap^ O F e = e is-equiv-ap^ (S n) F e = pre∙-is-equiv (! (snd (ap^ n F))) ∘ise post∙'-is-equiv (snd (ap^ n F)) ∘ise snd (equiv-ap (_ , is-equiv-ap^ n F e) _ _) equiv-ap^ : (n : ℕ) (F : fst (X ⊙→ Y)) (e : is-equiv (fst F)) → Ω^ n X ≃ Ω^ n Y equiv-ap^ n F e = (fst (ap^ n F) , is-equiv-ap^ n F e) Ω^-level-in : ∀ {i} (m : ℕ₋₂) (n : ℕ) (X : Ptd i) → (has-level (⟨ n ⟩₋₂ +2+ m) (fst X) → has-level m (Ω^ n X)) Ω^-level-in m O X pX = pX Ω^-level-in m (S n) X pX = Ω^-level-in (S m) n X (transport (λ k → has-level k (fst X)) (! (+2+-βr ⟨ n ⟩₋₂ m)) pX) (idp^ n) (idp^ n) Ω^-conn-in : ∀ {i} (m : ℕ₋₂) (n : ℕ) (X : Ptd i) → (is-connected (⟨ n ⟩₋₂ +2+ m) (fst X)) → is-connected m (Ω^ n X) Ω^-conn-in m O X pX = pX Ω^-conn-in m (S n) X pX = path-conn $ Ω^-conn-in (S m) n X $ transport (λ k → is-connected k (fst X)) (! (+2+-βr ⟨ n ⟩₋₂ m)) pX {- Eckmann-Hilton argument -} module _ {i} {X : Ptd i} where ap2-conc-is-conc^S : (α β : Ω^ 2 X) → ap2 _∙_ α β == conc^S 1 α β ap2-conc-is-conc^S α β = ap2-out _∙_ α β ∙ ap2 _∙_ (lemma α) (ap-idf β) where lemma : ∀ {i} {A : Type i} {x y : A} {p q : x == y} (α : p == q) → ap (λ r → r ∙ idp) α == ∙-unit-r p ∙ α ∙' ! (∙-unit-r q) lemma {p = idp} idp = idp ⊙ap2-conc-is-conc : ⊙ap2 (⊙conc {X = X}) == ⊙conc ⊙ap2-conc-is-conc = ⊙λ= (uncurry ap2-conc-is-conc^S) idp conc^2-comm : (α β : Ω^ 2 X) → conc^S 1 α β == conc^S 1 β α conc^2-comm α β = ! (⋆2=conc^ α β) ∙ ⋆2=⋆'2 α β ∙ ⋆'2=conc^ α β where ⋆2=conc^ : (α β : Ω^ 2 X) → α ⋆2 β == conc^S 1 α β ⋆2=conc^ α β = ap (λ π → π ∙ β) (∙-unit-r α) ⋆'2=conc^ : (α β : Ω^ 2 X) → α ⋆'2 β == conc^S 1 β α ⋆'2=conc^ α β = ap (λ π → β ∙ π) (∙-unit-r α) {- Pushing truncation through loop space -} module _ {i} where Trunc-Ω^ : (m : ℕ₋₂) (n : ℕ) (X : Ptd i) → ⊙Trunc m (⊙Ω^ n X) == ⊙Ω^ n (⊙Trunc (⟨ n ⟩₋₂ +2+ m) X) Trunc-Ω^ m O X = idp Trunc-Ω^ m (S n) X = ⊙Trunc m (⊙Ω^ (S n) X) =⟨ ! (pair= (Trunc=-path [ _ ] [ _ ]) (↓-idf-ua-in _ idp)) ⟩ ⊙Ω (⊙Trunc (S m) (⊙Ω^ n X)) =⟨ ap ⊙Ω (Trunc-Ω^ (S m) n X) ⟩ ⊙Ω^ (S n) (⊙Trunc (⟨ n ⟩₋₂ +2+ S m) X) =⟨ +2+-βr ⟨ n ⟩₋₂ m |in-ctx (λ k → ⊙Ω^ (S n) (⊙Trunc k X)) ⟩ ⊙Ω^ (S n) (⊙Trunc (S ⟨ n ⟩₋₂ +2+ m) X) ∎ Ω-Trunc-equiv : (m : ℕ₋₂) (X : Ptd i) → Ω (⊙Trunc (S m) X) ≃ Trunc m (Ω X) Ω-Trunc-equiv m X = Trunc=-equiv [ snd X ] [ snd X ] {- A loop space is a pregroup, and a group if it has the right level -} module _ {i} (n : ℕ) (X : Ptd i) where Ω^S-group-structure : GroupStructure (Ω^ (S n) X) Ω^S-group-structure = record { ident = idp^ (S n); inv = !^S n; comp = conc^S n; unitl = conc^S-unit-l n; unitr = conc^S-unit-r n; assoc = conc^S-assoc n; invr = !^S-inv-r n; invl = !^S-inv-l n } Ω^S-group : has-level ⟨ S n ⟩ (fst X) → Group i Ω^S-group pX = group (Ω^ (S n) X) (Ω^-level-in 0 (S n) X $ transport (λ t → has-level t (fst X)) (+2+-comm 0 ⟨ S n ⟩₋₂) pX) Ω^S-group-structure {- Our definition of Ω^ builds up loops on the outside, - but this is equivalent to building up on the inside -} module _ {i} where ⊙Ω^-inner-path : (n : ℕ) (X : Ptd i) → ⊙Ω^ (S n) X == ⊙Ω^ n (⊙Ω X) ⊙Ω^-inner-path O X = idp ⊙Ω^-inner-path (S n) X = ap ⊙Ω (⊙Ω^-inner-path n X) ⊙Ω^-inner-out : (n : ℕ) (X : Ptd i) → fst (⊙Ω^ (S n) X ⊙→ ⊙Ω^ n (⊙Ω X)) ⊙Ω^-inner-out O _ = (idf _ , idp) ⊙Ω^-inner-out (S n) X = ap^ 1 (⊙Ω^-inner-out n X) Ω^-inner-out : (n : ℕ) (X : Ptd i) → (Ω^ (S n) X → Ω^ n (⊙Ω X)) Ω^-inner-out n X = fst (⊙Ω^-inner-out n X) Ω^S-inner-out-conc^S : (n : ℕ) (X : Ptd i) (p q : Ω^ (S (S n)) X) → Ω^-inner-out (S n) X (conc^S (S n) p q) == conc^S n (Ω^-inner-out (S n) X p) (Ω^-inner-out (S n) X q) Ω^S-inner-out-conc^S n X p q = ap^S-conc^S 0 (⊙Ω^-inner-out n X) p q Ω^-inner-is-equiv : (n : ℕ) (X : Ptd i) → is-equiv (fst (⊙Ω^-inner-out n X)) Ω^-inner-is-equiv O X = is-eq (idf _) (idf _) (λ _ → idp) (λ _ → idp) Ω^-inner-is-equiv (S n) X = is-equiv-ap^ 1 (⊙Ω^-inner-out n X) (Ω^-inner-is-equiv n X) Ω^-inner-equiv : (n : ℕ) (X : Ptd i) → Ω^ (S n) X ≃ Ω^ n (⊙Ω X) Ω^-inner-equiv n X = _ , Ω^-inner-is-equiv n X
{ "alphanum_fraction": 0.4527543619, "avg_line_length": 32.0817610063, "ext": "agda", "hexsha": "e469608d4ebc776e9081dd868702e5b4b1d26b78", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_path": "core/lib/types/LoopSpace.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_path": "core/lib/types/LoopSpace.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_path": "core/lib/types/LoopSpace.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5455, "size": 10202 }
{-# OPTIONS --safe #-} module Cubical.Data.Fin.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels import Cubical.Data.Empty as ⊥ open import Cubical.Data.Nat using (ℕ ; zero ; suc ; _+_ ; znots) open import Cubical.Data.Nat.Order open import Cubical.Data.Nat.Order.Recursive using () renaming (_≤_ to _≤′_) open import Cubical.Data.Sigma open import Cubical.Data.Sum using (_⊎_; _⊎?_; inl; inr) open import Cubical.Relation.Nullary -- Finite types. -- -- Currently it is most convenient to define these as a subtype of the -- natural numbers, because indexed inductive definitions don't behave -- well with cubical Agda. This definition also has some more general -- attractive properties, of course, such as easy conversion back to -- ℕ. Fin : ℕ → Type₀ Fin n = Σ[ k ∈ ℕ ] k < n private variable ℓ : Level k : ℕ fzero : Fin (suc k) fzero = (0 , suc-≤-suc zero-≤) fone : Fin (suc (suc k)) fone = (1 , suc-≤-suc (suc-≤-suc zero-≤)) fzero≠fone : ¬ fzero {k = suc k} ≡ fone fzero≠fone p = znots (cong fst p) -- It is easy, using this representation, to take the successor of a -- number as a number in the next largest finite type. fsuc : Fin k → Fin (suc k) fsuc (k , l) = (suc k , suc-≤-suc l) -- Conversion back to ℕ is trivial... toℕ : Fin k → ℕ toℕ = fst -- ... and injective. toℕ-injective : ∀{fj fk : Fin k} → toℕ fj ≡ toℕ fk → fj ≡ fk toℕ-injective {fj = fj} {fk} = Σ≡Prop (λ _ → m≤n-isProp) -- Conversion from ℕ with a recursive definition of ≤ fromℕ≤ : (m n : ℕ) → m ≤′ n → Fin (suc n) fromℕ≤ zero _ _ = fzero fromℕ≤ (suc m) (suc n) m≤n = fsuc (fromℕ≤ m n m≤n) -- A case analysis helper for induction. fsplit : ∀(fj : Fin (suc k)) → (fzero ≡ fj) ⊎ (Σ[ fk ∈ Fin k ] fsuc fk ≡ fj) fsplit (0 , k<sn) = inl (toℕ-injective refl) fsplit (suc k , k<sn) = inr ((k , pred-≤-pred k<sn) , toℕ-injective refl) inject< : ∀ {m n} (m<n : m < n) → Fin m → Fin n inject< m<n (k , k<m) = k , <-trans k<m m<n flast : Fin (suc k) flast {k = k} = k , suc-≤-suc ≤-refl -- Fin 0 is empty ¬Fin0 : ¬ Fin 0 ¬Fin0 (k , k<0) = ¬-<-zero k<0 -- The full inductive family eliminator for finite types. elim : ∀(P : ∀{k} → Fin k → Type ℓ) → (∀{k} → P {suc k} fzero) → (∀{k} {fn : Fin k} → P fn → P (fsuc fn)) → {k : ℕ} → (fn : Fin k) → P fn elim P fz fs {zero} = ⊥.rec ∘ ¬Fin0 elim P fz fs {suc k} fj = case fsplit fj return (λ _ → P fj) of λ { (inl p) → subst P p fz ; (inr (fk , p)) → subst P p (fs (elim P fz fs fk)) } any? : ∀ {n} {P : Fin n → Type ℓ} → (∀ i → Dec (P i)) → Dec (Σ (Fin n) P) any? {n = zero} {P = _} P? = no (λ (x , _) → ¬Fin0 x) any? {n = suc n} {P = P} P? = mapDec (λ { (inl P0) → fzero , P0 ; (inr (x , Px)) → fsuc x , Px } ) (λ n h → n (helper h)) (P? fzero ⊎? any? (P? ∘ fsuc)) where helper : Σ (Fin (suc n)) P → P fzero ⊎ Σ (Fin n) λ z → P (fsuc z) helper (x , Px) with fsplit x ... | inl x≡0 = inl (subst P (sym x≡0) Px) ... | inr (k , x≡sk) = inr (k , subst P (sym x≡sk) Px) FinPathℕ : {n : ℕ} (x : Fin n) (y : ℕ) → fst x ≡ y → Σ[ p ∈ _ ] (x ≡ (y , p)) FinPathℕ {n = n} x y p = ((fst (snd x)) , (cong (λ y → fst (snd x) + y) (cong suc (sym p)) ∙ snd (snd x))) , (Σ≡Prop (λ _ → m≤n-isProp) p)
{ "alphanum_fraction": 0.5729008791, "avg_line_length": 29.4553571429, "ext": "agda", "hexsha": "491f4e0537d62197c97a5b35f5c4bc2d1590e50c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_path": "Cubical/Data/Fin/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_path": "Cubical/Data/Fin/Base.agda", "max_line_length": 85, "max_stars_count": null, "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_path": "Cubical/Data/Fin/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1355, "size": 3299 }
{-# OPTIONS --safe #-} module Cubical.Algebra.Monoid.Instances.Nat where open import Cubical.Foundations.Prelude open import Cubical.Data.Nat open import Cubical.Algebra.Monoid NatMonoid : Monoid ℓ-zero fst NatMonoid = ℕ MonoidStr.ε (snd NatMonoid) = 0 MonoidStr._·_ (snd NatMonoid) = _+_ MonoidStr.isMonoid (snd NatMonoid) = makeIsMonoid isSetℕ +-assoc +-zero (λ _ → refl)
{ "alphanum_fraction": 0.7546174142, "avg_line_length": 23.6875, "ext": "agda", "hexsha": "2d0eb95aab9907544e11b940ad1e9d8e65636061", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Algebra/Monoid/Instances/Nat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Algebra/Monoid/Instances/Nat.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/Monoid/Instances/Nat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 124, "size": 379 }
-- Andreas, 2016-12-03, issue 2307 -- preserve record (vs. constructor) in internal syntax open import Common.Equality postulate A : Set a : A record R : Set where constructor c field f : A open R postulate r : R g h : R → R fail1 : g (c a) ≡ h (record{ f = a }) fail1 = refl -- ERROR: g (c a) != h (c a) -- Expected: g (c a) != h (record{ f = a })
{ "alphanum_fraction": 0.5833333333, "avg_line_length": 15.5, "ext": "agda", "hexsha": "4403b33ce52e87f396ea660ce41df76e694d93db", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Issue2307.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Issue2307.agda", "max_line_length": 55, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue2307.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 138, "size": 372 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Functions.Definition open import Numbers.Naturals.Definition open import Sets.FinSet.Definition open import Setoids.Setoids module Setoids.Cardinality.Finite.Definition where record FiniteSetoid {a b : _} {A : Set a} (S : Setoid {a} {b} A) : Set (a ⊔ b) where field size : ℕ mapping : FinSet size → A bij : SetoidBijection (reflSetoid (FinSet size)) S mapping
{ "alphanum_fraction": 0.716, "avg_line_length": 29.4117647059, "ext": "agda", "hexsha": "c8c871b89c94680cf1f683702da969fb024e5ad5", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Setoids/Cardinality/Finite/Definition.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Setoids/Cardinality/Finite/Definition.agda", "max_line_length": 84, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Setoids/Cardinality/Finite/Definition.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 152, "size": 500 }
{-# OPTIONS --without-K --safe #-} module Categories.Functor.Representable where -- A Presheaf (into Setoids) is representation if it is naturally isomorphic to a Hom functor -- over a particular object A of the base category. open import Level open import Categories.Category using (Category) open import Categories.Category.Instance.Setoids open import Categories.Functor using (Functor) open import Categories.Functor.Hom open import Categories.Functor.Presheaf open import Categories.NaturalTransformation.NaturalIsomorphism record Representable {o ℓ e} {C : Category o ℓ e} (F : Presheaf C (Setoids ℓ e)) : Set (o ⊔ suc ℓ ⊔ suc e ) where open Category C open Hom C field A : Obj Iso : NaturalIsomorphism F Hom[-, A ]
{ "alphanum_fraction": 0.7581081081, "avg_line_length": 35.2380952381, "ext": "agda", "hexsha": "56f3630c38ec838d02f31100b9ead771c8ecacd4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Functor/Representable.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Functor/Representable.agda", "max_line_length": 113, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Functor/Representable.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 195, "size": 740 }
module _ where open import Agda.Primitive.Cubical hiding (PathP) postulate PathP : ∀ {ℓ} (A : I → Set ℓ) → A i0 → A i1 → Set ℓ {-# BUILTIN PATHP PathP #-}
{ "alphanum_fraction": 0.5906432749, "avg_line_length": 19, "ext": "agda", "hexsha": "e8f883bfb628aef14524f8404ed6d3f937c16905", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Fail/Issue2788c.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Fail/Issue2788c.agda", "max_line_length": 53, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Fail/Issue2788c.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 62, "size": 171 }
module Numeral.Integer.Relation.Divisibility.Proofs where open import Functional open import Logic.Propositional import Numeral.Natural.Relation.Divisibility as ℕ import Numeral.Natural.Relation.Divisibility.Proofs as ℕ open import Numeral.Natural using (ℕ) import Numeral.Natural.Oper as ℕ open import Numeral.Integer.Oper open import Numeral.Integer.Proofs open import Numeral.Integer.Relation.Divisibility open import Numeral.Integer open import Relator.Equals open import Relator.Equals.Proofs.Equiv open import Structure.Function.Multi open import Structure.Operator.Properties open import Structure.Relator open import Structure.Relator.Properties open import Type instance [∣][−𝐒ₙ]-sub : ((_∣_) on₂ (−𝐒ₙ_)) ⊆₂ ((ℕ._∣_) on₂ ℕ.𝐒) [∣][−𝐒ₙ]-sub = intro id instance [∣][+ₙ]-sub : ((_∣_) on₂ (+ₙ_)) ⊆₂ (ℕ._∣_) [∣][+ₙ]-sub = intro id instance [∣][−ₙ]-sub : ((_∣_) on₂ (−ₙ_)) ⊆₂ (ℕ._∣_) _⊆₂_.proof [∣][−ₙ]-sub {ℕ.𝟎} {ℕ.𝟎} p = p _⊆₂_.proof [∣][−ₙ]-sub {ℕ.𝟎} {ℕ.𝐒 y} p = p _⊆₂_.proof [∣][−ₙ]-sub {ℕ.𝐒 x} {ℕ.𝟎} p = p _⊆₂_.proof [∣][−ₙ]-sub {ℕ.𝐒 x} {ℕ.𝐒 y} p = p instance [∣][−𝐒ₙ]-super : ((_∣_) on₂ (−𝐒ₙ_)) ⊇₂ ((ℕ._∣_) on₂ ℕ.𝐒) [∣][−𝐒ₙ]-super = intro id instance [∣][+ₙ]-super : ((_∣_) on₂ (+ₙ_)) ⊇₂ (ℕ._∣_) [∣][+ₙ]-super = intro id instance [∣][−ₙ]-super : ((_∣_) on₂ (−ₙ_)) ⊇₂ (ℕ._∣_) _⊆₂_.proof [∣][−ₙ]-super {ℕ.𝟎} {ℕ.𝟎} p = p _⊆₂_.proof [∣][−ₙ]-super {ℕ.𝟎} {ℕ.𝐒 y} p = p _⊆₂_.proof [∣][−ₙ]-super {ℕ.𝐒 x} {ℕ.𝟎} p = p _⊆₂_.proof [∣][−ₙ]-super {ℕ.𝐒 x} {ℕ.𝐒 y} p = p divides-with-[−ₙ] : ∀{a b c} → ((absₙ a) ℕ.∣ b) → ((absₙ a) ℕ.∣ c) → (a ∣ (b −ₙ c)) divides-with-[−ₙ] {a} ℕ.Div𝟎 ℕ.Div𝟎 = ℕ.Div𝟎 divides-with-[−ₙ] {a} (ℕ.Div𝐒 ab) ℕ.Div𝟎 = ℕ.Div𝐒 ab divides-with-[−ₙ] {a} ℕ.Div𝟎 (ℕ.Div𝐒 {x = x} ac) with p ← ℕ.divides-with-[+] (reflexivity(ℕ._∣_)) ((super₂((_∣_) on₂ (−ₙ_))(ℕ._∣_) ac)) rewrite absₙ-of-[−ₙ] {x} rewrite absₙ-of-[−ₙ] {absₙ a} rewrite [−ₙ]-antiidentityₗ {absₙ a ℕ.+ x} rewrite absₙ-of-[−ₙ] {absₙ(a) ℕ.+ x} = p divides-with-[−ₙ] {a} (ℕ.Div𝐒 {x = x} ab) (ℕ.Div𝐒 {x = y} ac) rewrite [−ₙ]-on-[+]ₗ-redundancy{absₙ a}{x}{y} = divides-with-[−ₙ] {a} ab ac divides-with-[+] : ∀{a b c} → (a ∣ b) → (a ∣ c) → (a ∣ (b + c)) divides-with-[+] {+ₙ a} {+ₙ b} {+ₙ c} ab ac = ℕ.divides-with-[+] ab ac divides-with-[+] {+ₙ a} {+ₙ b} {−𝐒ₙ c} ab ac = divides-with-[−ₙ] {+ₙ a} ab ac divides-with-[+] {+ₙ a} {−𝐒ₙ b} {+ₙ c} ab ac = divides-with-[−ₙ] {+ₙ a} ac ab divides-with-[+] {+ₙ a} {−𝐒ₙ b} {−𝐒ₙ c} ab ac = ℕ.divides-with-[+] ab ac divides-with-[+] {−𝐒ₙ a} {+ₙ b} {+ₙ c} ab ac = ℕ.divides-with-[+] ab ac divides-with-[+] {−𝐒ₙ a} {+ₙ b} {−𝐒ₙ c} ab ac = divides-with-[−ₙ] {−𝐒ₙ a} ab ac divides-with-[+] {−𝐒ₙ a} {−𝐒ₙ b} {+ₙ c} ab ac = divides-with-[−ₙ] {−𝐒ₙ a} ac ab divides-with-[+] {−𝐒ₙ a} {−𝐒ₙ b} {−𝐒ₙ c} ab ac = ℕ.divides-with-[+] ab ac divides-with-[⋅] : ∀{a b c} → ((a ∣ b) ∨ (a ∣ c)) → (a ∣ (b ⋅ c)) divides-with-[⋅] {a} {b} {c} p = substitute₂ᵣ(ℕ._∣_) {absₙ a} (symmetry(_≡_) (preserving₂(absₙ)(_⋅_)(ℕ._⋅_) {b}{c})) (ℕ.divides-with-[⋅] {absₙ a}{absₙ b}{absₙ c} p)
{ "alphanum_fraction": 0.5639686684, "avg_line_length": 39.2820512821, "ext": "agda", "hexsha": "edc9f943c6972d4a3da8b60f600f3166a8eb900c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Numeral/Integer/Relation/Divisibility/Proofs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Numeral/Integer/Relation/Divisibility/Proofs.agda", "max_line_length": 164, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Numeral/Integer/Relation/Divisibility/Proofs.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 1647, "size": 3064 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.NType2 open import lib.types.Nat open import lib.types.Subtype module lib.types.Fin where Fin : ℕ → Type₀ Fin n = Σ ℕ (_< n) instance Fin-reader : ∀ {n} → FromNat (Fin n) FromNat.in-range (Fin-reader {n}) m = m < n FromNat.read (Fin-reader {n}) m ⦃ m<n ⦄ = m , m<n Fin-S : ∀ {n} → Fin n → Fin (S n) Fin-S (n , lt) = n , ltSR lt Fin-S^ : ∀ {n} → (m : ℕ) → Fin n → Fin (m + n) Fin-S^ O <n = <n Fin-S^ (S m) <n = Fin-S (Fin-S^ m <n) Fin-S^' : ∀ {n} → (m : ℕ) → Fin n → Fin (ℕ-S^' m n) Fin-S^' O <n = <n Fin-S^' (S m) <n = Fin-S^' m (Fin-S <n) Fin-to-≠ : ∀ {n} (<n : Fin n) → fst <n ≠ n Fin-to-≠ <n = <-to-≠ (snd <n) Fin-prop : ℕ → SubtypeProp ℕ lzero Fin-prop n = ((_< n) , λ _ → <-is-prop) abstract Fin-is-set : {n : ℕ} → is-set (Fin n) Fin-is-set {n} = Subtype-level (Fin-prop n) Fin-has-dec-eq : {n : ℕ} → has-dec-eq (Fin n) Fin-has-dec-eq {n} = Subtype-has-dec-eq (Fin-prop n) ℕ-has-dec-eq private Fin-pred=-type : {n : ℕ} → Fin n → Fin n → Type₀ Fin-pred=-type (_ , ltSR _) (_ , ltS) = ⊤ Fin-pred=-type (_ , ltS) (_ , ltSR _) = ⊤ Fin-pred=-type (m , ltS) (n , ltS) = m == n :> ℕ Fin-pred=-type {S n} (m , ltSR m<n) (o , ltSR o<n) = (m , m<n) == (o , o<n) :> Fin n Fin-pred= : {n : ℕ} {x y : Fin n} → x == y → Fin-pred=-type x y Fin-pred= {x = (_ , ltS)} idp = idp Fin-pred= {x = (_ , ltSR _)} idp = idp abstract ltSR≠ltS : ∀ {m} (<m : Fin m) → Fin-S <m ≠ (m , ltS) ltSR≠ltS <m = Fin-to-≠ <m ∘ ap fst ltS≠ltSR : ∀ {m} (<m : Fin m) → (m , ltS) ≠ Fin-S <m ltS≠ltSR <m = Fin-to-≠ <m ∘ ! ∘ ap fst abstract Fin-S-is-inj : ∀ {n} → is-inj (Fin-S {n = n}) Fin-S-is-inj _ _ = Fin-pred= Fin-S-≠ : ∀ {n} {<n₀ <n₁ : Fin n} (p : <n₀ ≠ <n₁) → Fin-S <n₀ ≠ Fin-S <n₁ Fin-S-≠ {<n₀ = <n₀} {<n₁} p = p ∘ Fin-S-is-inj <n₀ <n₁ Fin-S^-≠ : ∀ {n} m {<n₀ <n₁ : Fin n} (p : <n₀ ≠ <n₁) → Fin-S^ m <n₀ ≠ Fin-S^ m <n₁ Fin-S^-≠ O p = p Fin-S^-≠ (S n) p = Fin-S-≠ (Fin-S^-≠ n p) Fin-S^'-≠ : ∀ {n} m {<n₀ <n₁ : Fin n} (p : <n₀ ≠ <n₁) → Fin-S^' m <n₀ ≠ Fin-S^' m <n₁ Fin-S^'-≠ O p = p Fin-S^'-≠ (S n) p = Fin-S^'-≠ n (Fin-S-≠ p) Fin-equiv-Empty : Fin 0 ≃ Empty Fin-equiv-Empty = equiv to from to-from from-to where to : Fin 0 → Empty to (_ , ()) from : Empty → Fin 0 from () abstract to-from : ∀ x → to (from x) == x to-from () from-to : ∀ x → from (to x) == x from-to (_ , ()) Fin-equiv-Coprod : {n : ℕ} → Fin (S n) ≃ Fin n ⊔ Unit Fin-equiv-Coprod {n} = equiv to from to-from from-to where to : Fin (S n) → Fin n ⊔ Unit to (m , ltS) = inr unit to (m , ltSR lt) = inl (m , lt) from : Fin n ⊔ Unit → Fin (S n) from (inr _) = n , ltS from (inl fin) = Fin-S fin abstract to-from : ∀ x → to (from x) == x to-from (inr _) = idp to-from (inl _) = idp from-to : ∀ x → from (to x) == x from-to (_ , ltS) = idp from-to (_ , ltSR _) = idp
{ "alphanum_fraction": 0.492991453, "avg_line_length": 27.0833333333, "ext": "agda", "hexsha": "9d2beb38d8cfc72620fb092eee1d97d59afe8e83", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "core/lib/types/Fin.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "core/lib/types/Fin.agda", "max_line_length": 87, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "core/lib/types/Fin.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 1342, "size": 2925 }
module Logic.Names where open import Functional import Lvl open import Logic open import Logic.Predicate open import Logic.Propositional module _ {ℓ} where ExcludedMiddleOn : Stmt{ℓ} → Stmt ExcludedMiddleOn(X) = (X ∨ (¬ X)) ExcludedMiddle = ∀ₗ(ExcludedMiddleOn) WeakExcludedMiddleOn = ExcludedMiddleOn ∘ (¬_) WeakExcludedMiddle = ∀ₗ(WeakExcludedMiddleOn) NonContradictionOn : Stmt{ℓ} → Stmt NonContradictionOn(X) = ¬(X ∧ (¬ X)) NonContradiction = ∀ₗ(NonContradictionOn) DoubleNegationOn : Stmt{ℓ} → Stmt DoubleNegationOn(X) = (¬(¬ X)) → X DoubleNegation = ∀ₗ(DoubleNegationOn) module _ where private variable ℓ₁ ℓ₂ : Lvl.Level TopOrBottom : (Stmt{ℓ₁} → Stmt{Lvl.𝟎} → Stmt{ℓ₂}) → Stmt{ℓ₁} → Stmt TopOrBottom(_≡_)(P) = (P ≡ ⊤) ∨ (P ≡ ⊥) module _ {ℓ₁ ℓ₂} where CallCCOn : Stmt{ℓ₁} → Stmt{ℓ₂} → Stmt CallCCOn(X)(Y) = (((X → Y) → X) → X) CallCC = ∀²(CallCCOn) ContrapositiveOn : Stmt{ℓ₁} → Stmt{ℓ₂} → Stmt ContrapositiveOn(X)(Y) = (X → Y) → ((¬ Y) → (¬ X)) Contrapositive = ∀²(ContrapositiveOn) DisjunctiveSyllogismₗOn : Stmt{ℓ₁} → Stmt{ℓ₂} → Stmt DisjunctiveSyllogismₗOn(X)(Y) = ((X ∨ Y) ∧ (¬ Y)) → X DisjunctiveSyllogismₗ = ∀²(DisjunctiveSyllogismₗOn) DisjunctiveSyllogismᵣOn : Stmt{ℓ₁} → Stmt{ℓ₂} → Stmt DisjunctiveSyllogismᵣOn(X)(Y) = ((X ∨ Y) ∧ (¬ X)) → Y DisjunctiveSyllogismᵣ = ∀²(DisjunctiveSyllogismᵣOn) MaterialImplicationOn : Stmt{ℓ₁} → Stmt{ℓ₂} → Stmt MaterialImplicationOn(X)(Y) = (X → Y) ↔ ((¬ X) ∨ Y) MaterialImplication = ∀²(MaterialImplicationOn) module _ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} where ConstructiveDilemmaOn : Stmt{ℓ₁} → Stmt{ℓ₂} → Stmt{ℓ₃} → Stmt{ℓ₄} → Stmt ConstructiveDilemmaOn(X₁)(X₂)(Y₁)(Y₂) = ((X₁ → X₂) ∧ (Y₁ → Y₂) ∧ (X₁ ∨ Y₁)) → (X₂ ∨ Y₂) ConstructiveDilemma = ∀⁴(ConstructiveDilemmaOn) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Classical names module _ {ℓ₁ ℓ₂} where ModusTollensOn : Stmt{ℓ₁} → Stmt{ℓ₂} → Stmt ModusTollensOn(X)(Y) = ((X → Y) ∧ (¬ Y)) → (¬ X) ModusTollens = ∀²(ModusTollensOn) ModusPonensOn : Stmt{ℓ₁} → Stmt{ℓ₂} → Stmt ModusPonensOn(X)(Y) = ((X → Y) ∧ X) → Y ModusPonens = ∀²(ModusPonensOn) ReductioAdAbsurdumOn : Stmt{ℓ₁} → Stmt{ℓ₂} → Stmt ReductioAdAbsurdumOn(X)(Y) = ((X → Y) ∧ (X → (¬ Y))) → (¬ X) ReductioAdAbsurdum = ∀²(ReductioAdAbsurdumOn) ReductioAdAbsurdumNegatedOn : Stmt{ℓ₁} → Stmt{ℓ₂} → Stmt ReductioAdAbsurdumNegatedOn(X)(Y) = (((¬ X) → Y) ∧ ((¬ X) → (¬ Y))) → (¬ X) ReductioAdAbsurdumNegated = ∀²(ReductioAdAbsurdumNegatedOn)
{ "alphanum_fraction": 0.6381182147, "avg_line_length": 32.7236842105, "ext": "agda", "hexsha": "966c2d0caefb1251411bc57137d450b88a9cd591", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Logic/Names.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Logic/Names.agda", "max_line_length": 89, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Logic/Names.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 1110, "size": 2487 }
module Web.URI.Everything where import Web.URI import Web.URI.Examples.HelloWorld import Web.URI.Primitive import Web.URI.Port import Web.URI.Port.Primitive import Web.URI.Scheme import Web.URI.Scheme.Primitive
{ "alphanum_fraction": 0.8262910798, "avg_line_length": 19.3636363636, "ext": "agda", "hexsha": "c5683e68c56b1b8e31015934255ac870f48f10db", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:37:59.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:37:59.000Z", "max_forks_repo_head_hexsha": "8ced22124dbe12fa820699bb362247a96d592c03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-web-uri", "max_forks_repo_path": "src/Web/URI/Everything.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8ced22124dbe12fa820699bb362247a96d592c03", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-web-uri", "max_issues_repo_path": "src/Web/URI/Everything.agda", "max_line_length": 34, "max_stars_count": 1, "max_stars_repo_head_hexsha": "8ced22124dbe12fa820699bb362247a96d592c03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-web-uri", "max_stars_repo_path": "src/Web/URI/Everything.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-23T04:56:25.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-23T04:56:25.000Z", "num_tokens": 51, "size": 213 }
------------------------------------------------------------------------------ -- Example of a partial function ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- From (Bove, A. and Capretta, V. (2001)). module FOT.FOTC.Program.Min.Min where open import Data.Nat renaming ( suc to succ ) open import Relation.Binary.PropositionalEquality ------------------------------------------------------------------------------ -- Note: Although the function is partial the problem is that it is -- rejected by Agda's termination checker. {-# NON_TERMINATING #-} min : (ℕ → ℕ) → ℕ min f with f 0 ... | 0 = 0 ... | succ x = succ (min (λ n → f (succ n))) ------------------------------------------------------------------------------ -- References -- -- Bove, A. and Capretta, V. (2001). Nested General Recursion and -- Partiality in Type Theory. In: Theorem Proving in Higher Order -- Logics (TPHOLs 2001). Ed. by Boulton, R. J. and Jackson, -- P. B. Vol. 2152. LNCS. Springer, pp. 121–135.
{ "alphanum_fraction": 0.4631490787, "avg_line_length": 35.1176470588, "ext": "agda", "hexsha": "1dbdd8a4d6360858ff393c9639482c0f12657c9e", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Program/Min/Min.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Program/Min/Min.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Program/Min/Min.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 264, "size": 1194 }
module Integer10 where open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; refl) -- 整数の素朴な定義 --(succ (succ (pred zero))などが有効、という弱点がある) data ℤ : Set where zero : ℤ succ : ℤ → ℤ pred : ℤ → ℤ -- 加法 _+_ : ℤ → ℤ → ℤ zero + y = y succ x + zero = succ x succ x + succ y = succ (succ x + y) succ x + pred y = x + y pred x + zero = pred x pred x + succ y = x + y pred x + pred y = pred (pred x + y) -- 反数 opposite : ℤ → ℤ opposite zero = zero opposite (succ x) = pred (opposite x) opposite (pred x) = succ (opposite x) -- 乗法 _*_ : ℤ → ℤ → ℤ x * zero = zero x * succ y = (x * y) + x x * pred y = (x * y) + (opposite x) infixl 40 _+_ infixl 60 _*_ -- (-1) * (-1) = (+1) theorem : pred zero * pred zero ≡ succ zero theorem = refl
{ "alphanum_fraction": 0.5586380832, "avg_line_length": 19.3414634146, "ext": "agda", "hexsha": "f2eae749895f76e107941230082fc97703135e5c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "righ1113/Agda", "max_forks_repo_path": "Integer10.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "righ1113/Agda", "max_issues_repo_path": "Integer10.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "9117b6bec9880d8c0a5d6ee4399fd841c3544d84", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "righ1113/Agda", "max_stars_repo_path": "Integer10.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 321, "size": 793 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Some examples showing how the Function.Reasoning module -- can be used to perform "functional reasoning" similar to what is being -- described in: https://stackoverflow.com/q/22676703/3168666 ------------------------------------------------------------------------ {-# OPTIONS --with-K #-} module README.Function.Reasoning where -- Function.Reasoning exports a flipped application (_|>_) combinator -- as well as a type annotation (_∶_) combinator. open import Function.Reasoning ------------------------------------------------------------------------ -- A simple example module _ {A B C : Set} {A→B : A → B} {B→C : B → C} where -- Using the combinators we can, starting from a value, chain various -- functions whilst tracking the types of the intermediate results. A→C : A → C A→C a = a ∶ A |> A→B ∶ B |> B→C ∶ C ------------------------------------------------------------------------ -- A more concrete example open import Data.Nat open import Data.List.Base open import Data.Char.Base open import Data.String using (String; toList; fromList; _==_) open import Function open import Data.Bool hiding (_≤?_) open import Data.Product as P using (_×_; <_,_>; uncurry; proj₁) open import Agda.Builtin.Equality -- This can give us for instance this decomposition of a function -- collecting all of the substrings of the input which happen to be -- palindromes: subpalindromes : String → List String subpalindromes str = let Chars = List Char in str ∶ String -- first generate the substrings |> toList ∶ Chars |> inits ∶ List Chars |> concatMap tails ∶ List Chars -- then only keeps the ones which are not singletons |> filter (λ cs → 2 ≤? length cs) ∶ List Chars -- only keep the ones that are palindromes |> map < fromList , fromList ∘ reverse > ∶ List (String × String) |> boolFilter (uncurry _==_) ∶ List (String × String) |> map proj₁ ∶ List String -- Test cases _ : subpalindromes "doctoresreverse" ≡ "eve" ∷ "rever" ∷ "srevers" ∷ "esreverse" ∷ [] _ = refl _ : subpalindromes "elle-meme" ≡ "ll" ∷ "elle" ∷ "mem" ∷ "eme" ∷ [] _ = refl
{ "alphanum_fraction": 0.5538720539, "avg_line_length": 34.4347826087, "ext": "agda", "hexsha": "15472fa6299397741d635d94de14df9eacc45a12", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/README/Function/Reasoning.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/README/Function/Reasoning.agda", "max_line_length": 85, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/README/Function/Reasoning.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 594, "size": 2376 }
------------------------------------------------------------------------ -- Safe modules that use --without-K ------------------------------------------------------------------------ {-# OPTIONS --safe --without-K #-} module README.Safe.Without-K where -- Definitions of some basic types and some related functions. import Prelude -- Logical equivalences. import Logical-equivalence -- Some definitions related to Dec. import Dec -- Two logically equivalent axiomatisations of equality. Many of the -- modules below are parametrised by a definition of equality that -- satisfies these axioms. -- -- The reason for this parametrisation was that I thought that I might -- later want to use a definition of equality where the application -- elim P r (refl x) did not compute to r x, unlike the equality in -- Equality.Propositional. Now, with the advent of cubical type theory -- and paths, there is such an equality (see Equality.Path). -- -- (Note that Equality.Tactic contains a definition of equality which, -- roughly speaking, computes like the one in Equality.Propositional.) import Equality -- One model of the axioms: propositional equality. import Equality.Propositional -- A simple tactic for proving equality of equality proofs. import Equality.Tactic -- Injections. import Injection -- Split surjections. import Surjection -- Some definitions related to and properties of natural numbers. import Nat -- H-levels, along with some general properties. import H-level -- Types with decidable equality have unique identity proofs, and -- related results. import Equality.Decidable-UIP -- Some decision procedures for equality. import Equality.Decision-procedures -- Bijections. import Bijection -- Integers. import Integer.Basics -- Groupoids. import Groupoid -- Closure properties for h-levels. import H-level.Closure -- Excluded middle. import Excluded-middle -- Equivalence relations import Equivalence-relation -- Preimages. import Preimage -- Is-equivalence, defined in terms of contractible fibres. import Equivalence.Contractible-preimages -- Half adjoint equivalences. import Equivalence.Half-adjoint -- Equivalences. import Equivalence -- A type for values that should be erased at run-time. import Erased.Basics -- Equivalences with erased "proofs". import Equivalence.Erased.Basics -- Embeddings. import Embedding -- A universe which includes several kinds of functions (ordinary -- functions, logical equivalences, injections, embeddings, -- surjections, bijections and equivalences). import Function-universe -- Some alternative definitions of the concept of being an -- equivalence. import Equivalence.Path-split -- Results relating different instances of certain axioms related to -- equality. import Equality.Instances-related -- A parametrised specification of "natrec", along with a proof that -- the specification is propositional (assuming extensionality). import Nat.Eliminator -- A solver for certain natural number equalities. import Nat.Solver -- Some definitions related to the binary sum type former. import Sum -- Some definitions related to and properties of booleans. import Bool -- Raw monads. import Monad.Raw -- Monads. import Monad -- The reader monad transformer. import Monad.Reader -- The state monad transformer. import Monad.State -- The double-negation monad. import Double-negation -- Lists. import List -- Pullbacks. import Pullback -- The univalence axiom. import Univalence-axiom -- Pointed types and loop spaces. import Pointed-type -- Equalities can be turned into groupoids which are sometimes -- commutative. import Equality.Groupoid -- Groups. import Group -- Integers. import Integer -- Some definitions related to and properties of finite sets. import Fin -- Some definitions related to and properties of the Maybe type. import Maybe -- Vectors, defined using a recursive function. import Vec -- Vectors, defined using an inductive family. import Vec.Data -- Vectors, defined as functions from finite sets. import Vec.Function -- Some properties related to the const function. import Const -- Support for reflection. import TC-monad -- Tactics for proving instances of Σ-cong (and Surjection.Σ-cong) -- with "better" computational behaviour. import Tactic.Sigma-cong -- Code used to construct tactics aimed at making equational reasoning -- proofs more readable. import Tactic.By -- A tactic aimed at making equational reasoning proofs more readable -- in modules that are parametrised by an implementation of equality. import Tactic.By.Parametrised import Tactic.By.Parametrised.Tests -- Some tactics aimed at making equational reasoning proofs more -- readable for propositional equality. import Tactic.By.Propositional -- A type for values that should be erased at run-time. import Erased.Level-1 -- Equivalences with erased "proofs", defined in terms of partly -- erased contractible fibres. import Equivalence.Erased.Contractible-preimages -- Equivalences with erased "proofs". import Equivalence.Erased -- Embeddings with erased "proofs". import Embedding.Erased -- A type for values that should be erased at run-time. import Erased.Level-2 -- Some results related to the For-iterated-equality predicate -- transformer. import For-iterated-equality -- Properties related to stability for Erased. import Erased.Stability -- Some properties that hold for Erased do not hold for every -- topological modality. import Erased.Counterexamples -- Truncation, defined using a kind of Church encoding. import H-level.Truncation.Church -- Some omniscience principles. import Omniscience -- Bag equivalence for lists. import Bag-equivalence -- The All predicate, defined using _∈_. import List.All -- The All predicate, defined recursively. import List.All.Recursive -- Quotients, defined as families of equivalence classes. import Quotient.Families-of-equivalence-classes -- A type for values that should be erased at run-time. import Erased import Erased.Without-box-cong -- A wrapper that turns a representation of natural numbers (with a -- unique representative for every number) into a representation that -- computes roughly like the unary natural numbers (at least for some -- operations). import Nat.Wrapper -- A binary representation of natural numbers. import Nat.Binary -- Specifications of output-restricted deques (single-ended queues -- with cons). import Queue -- Simple queues, implemented in the usual way using two lists -- (following Hood and Melville). import Queue.Simple -- Queue instances for the queues in Queue.Simple. import Queue.Simple.Instances -- Banker's queues (following Okasaki). import Queue.Bankers -- Queue instances for the queues in Queue.Bankers. import Queue.Bankers.Instances -- Isomorphism of monoids on sets coincides with equality (assuming -- univalence). import Univalence-axiom.Isomorphism-is-equality.Monoid -- In fact, several large classes of algebraic structures satisfy the -- property that isomorphism coincides with equality (assuming -- univalence). import Univalence-axiom.Isomorphism-is-equality.Simple import Univalence-axiom.Isomorphism-is-equality.Simple.Variant import Univalence-axiom.Isomorphism-is-equality.More import Univalence-axiom.Isomorphism-is-equality.More.Examples -- A class of structures that satisfies the property that isomorphic -- instances of a structure are equal (assuming univalence). This code -- is superseded by the code above, but preserved because it is -- mentioned in a blog post. import Univalence-axiom.Isomorphism-implies-equality -- 1-categories. import Category import Functor import Adjunction -- Aczel's structure identity principle (for 1-categories). import Structure-identity-principle -- The structure identity principle can be used to establish that -- isomorphism coincides with equality (assuming univalence). import Univalence-axiom.Isomorphism-is-equality.Structure-identity-principle -- Bi-invertibility. import Bi-invertibility import Bi-invertibility.Erased -- Binary trees. import Tree -- Implementations of tree sort. One only establishes that the -- algorithm permutes its input, the other one also establishes -- sortedness. import Tree-sort.Partial import Tree-sort.Full import Tree-sort.Examples -- Containers, including a definition of bag equivalence. import Container -- An implementation of tree sort which uses containers to represent -- trees and lists. -- -- In the module Tree-sort.Full indexed types are used to enforce -- sortedness, but Containers contains a definition of non-indexed -- containers, so sortedness is not enforced in this development. -- -- The implementation using containers has the advantage of uniform -- definitions of Any/membership/bag equivalence, but the other -- implementations use more direct definitions and are perhaps a bit -- "leaner". import Container.List import Container.Tree import Container.Tree-sort import Container.Tree-sort.Example -- The stream container. import Container.Stream -- Indexed containers. import Container.Indexed -- Another definition of indexed containers. import Container.Indexed.Variant -- M-types for indexed containers, defined using functions. import Container.Indexed.M.Function -- Record types with manifest fields and "with". import Records-with-with -- Overview of code related to some papers. import README.Bag-equivalence import README.Isomorphism-is-equality import README.Weak-J
{ "alphanum_fraction": 0.768220962, "avg_line_length": 21.2071269488, "ext": "agda", "hexsha": "6d1d48194ca076b357a960deed870efad1a5cb1e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "README/Safe/Without-K.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "README/Safe/Without-K.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "README/Safe/Without-K.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 2037, "size": 9522 }
-- An implementation of terminating parsers due to Conor McBride and -- James McKinna, as presented in the talk Seeing and Doing at the -- Workshop on Termination and Type Theory, Hindås, Sweden, 2002. {-# OPTIONS --type-in-type #-} module SeeingAndDoing where open import Data.Unit open import Data.Bool open import Data.List open import Data.Maybe as Maybe open import Data.String renaming (_==_ to _=S=_) open import Category.Monad open RawMonadPlus Maybe.monadPlus open import Data.Function using (_∘_; const) open import Relation.Binary.PropositionalEquality data Token : Set where V : (s : String) → Token IF : Token THEN : Token ELSE : Token TRUE : Token FALSE : Token _==_ : Token → Token → Bool V s₁ == V s₂ = s₁ =S= s₂ IF == IF = true THEN == THEN = true ELSE == ELSE = true TRUE == TRUE = true FALSE == FALSE = true _ == _ = false data Pos : Set where L : Pos R : Pos Memo : (Pos → Set) → Pos → Set Memo P L = ⊤ Memo P R = P L PosOrder : ∀ j P → (∀ i → Memo P i → P i) → P j PosOrder L P p = p L _ PosOrder R P p = p R (p L _) module Combinators (Rec : Set) where infixl 25 _∙_ _!_ infixl 15 _+_ data _⟨_⟩_ : Pos → Set → Pos → Set where rec : R ⟨ Rec ⟩ R η : ∀ {i X} (x : Maybe X) → i ⟨ X ⟩ i tok : ∀ {i} (u : Token) → i ⟨ ⊤ ⟩ R vart : ∀ {i} → i ⟨ String ⟩ R _+_ : ∀ {i j X} (x y : i ⟨ X ⟩ j) → i ⟨ X ⟩ j _∙_ : ∀ {j i k S T} (f : i ⟨ (S → T) ⟩ j) (s : j ⟨ S ⟩ k) → i ⟨ T ⟩ k for : ∀ {i X} → X → i ⟨ X ⟩ i for = η ∘ just fail : ∀ {i X} → i ⟨ X ⟩ i fail = η nothing _!_ : ∀ {i j k S T} → i ⟨ S ⟩ j → j ⟨ T ⟩ k → i ⟨ S ⟩ k s ! t = for const ∙ s ∙ t Grammar : Set → Set Grammar Rec = L ⟨ Rec ⟩ R where open Combinators Rec module Parser {Rec : Set} (grammar : Grammar Rec) where open Combinators Rec ⇓ : ∀ {i j X} → i ⟨ X ⟩ j → Maybe X ⇓ (η x) = x ⇓ (x + y) = ⇓ x ∣ ⇓ y ⇓ (f ∙ s) = ⇓ f ⊛ ⇓ s ⇓ _ = nothing eat : ∀ {i X} → i ⟨ X ⟩ R → Token → R ⟨ X ⟩ R eat {i} x t = PosOrder i P eat′ x t where P = λ i → ∀ {X} → i ⟨ X ⟩ R → Token → R ⟨ X ⟩ R eat′ : ∀ i → Memo P i → P i eat′ _ _ (tok u) t with u == t eat′ _ _ (tok u) t | true = for _ eat′ _ _ (tok u) t | false = fail eat′ _ _ vart (V x) = for x eat′ _ eat (x + y) t = eat′ _ eat x t + eat′ _ eat y t eat′ L _ (_∙_ {L} f s) t = η (⇓ f) ∙ eat′ L _ s t eat′ L _ (_∙_ {R} f s) t = eat′ L _ f t ∙ s eat′ R eatL (_∙_ {R} f s) t = η (⇓ f) ∙ eat′ R eatL s t + eat′ R eatL f t ∙ s eat′ R eatL rec t = eatL grammar t eat′ _ _ _ _ = fail parse : List Token → Maybe Rec parse is = ⇓ (foldr (λ t x → eat x t) rec (reverse is)) data CE : Set where var : (s : String) → CE val : (b : Bool) → CE if : (i t e : CE) → CE grammar : Grammar CE grammar = for var ∙ vart + for (val true) ! tok TRUE + for (val false) ! tok FALSE + for (λ i → if i (val true) (val true)) ! tok IF ∙ rec + for if ! tok IF ∙ rec ! tok THEN ∙ rec ! tok ELSE ∙ rec where open Combinators CE test₁ : let open Parser grammar in parse (IF ∷ V "x" ∷ THEN ∷ TRUE ∷ ELSE ∷ FALSE ∷ []) ≡ just (if (var "x") (val true) (val false)) test₁ = refl -- Takes ages to type check: -- test₂ : let open Parser grammar in -- parse (IF ∷ V "x" ∷ -- THEN ∷ IF ∷ V "y" ∷ THEN ∷ V "z" ∷ ELSE ∷ V "x" ∷ -- ELSE ∷ FALSE ∷ []) ≡ -- just (if (var "x") (if (var "y") (var "z") (var "x")) -- (val false)) -- test₂ = refl
{ "alphanum_fraction": 0.4800422945, "avg_line_length": 28.0222222222, "ext": "agda", "hexsha": "c81043de68ece30e9cdad657ad961c80154a9b83", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "misc/SeeingAndDoing.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": "2018-01-24T16:39:37.000Z", "max_issues_repo_issues_event_min_datetime": "2018-01-22T22:21:41.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "misc/SeeingAndDoing.agda", "max_line_length": 72, "max_stars_count": 7, "max_stars_repo_head_hexsha": "b396d35cc2cb7e8aea50b982429ee385f001aa88", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yurrriq/parser-combinators", "max_stars_repo_path": "misc/SeeingAndDoing.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-22T05:35:31.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-13T05:23:14.000Z", "num_tokens": 1435, "size": 3783 }
module IrrelevantLambda where postulate A : Set P : A -> Set f : _ -> Set f = λ .x -> P x -- fails because irrelevant lambda may not introduce relevant function type
{ "alphanum_fraction": 0.6900584795, "avg_line_length": 19, "ext": "agda", "hexsha": "4508097cc8e952e68541a70c58808dbf3448780b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/IrrelevantLambda.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/IrrelevantLambda.agda", "max_line_length": 75, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/fail/IrrelevantLambda.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 47, "size": 171 }
module NonLinearConstraint where import Common.Level open import Common.Equality test : let X : Set -> Set -> Set X = _ in (A : Set) -> X A A ≡ A test A = refl -- should not be solved, solution not uniquely determined
{ "alphanum_fraction": 0.6512605042, "avg_line_length": 21.6363636364, "ext": "agda", "hexsha": "712b640666a588e45e898e027fb2c89d23e4c25b", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/NonLinearConstraint.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/NonLinearConstraint.agda", "max_line_length": 57, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/NonLinearConstraint.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 62, "size": 238 }
{-# OPTIONS --universe-polymorphism #-} open import Categories.Category module Categories.Object.BinaryProducts {o ℓ e} (C : Category o ℓ e) where open Category C open Equiv open import Level import Categories.Object.Product as Product import Categories.Object.Product.Morphisms as ProductMorphisms open import Categories.Morphisms C open Product C open ProductMorphisms C record BinaryProducts : Set (o ⊔ ℓ ⊔ e) where infixr 2 _×_ infix 10 _⁂_ field product : ∀ {A B} → Product A B _×_ : Obj → Obj → Obj A × B = Product.A×B (product {A} {B}) ×-comm : ∀ {A B} → _≅_ (A × B) (B × A) ×-comm = Commutative product product ×-assoc : ∀ {X Y Z} → _≅_ (X × (Y × Z)) ((X × Y) × Z) ×-assoc = Associative product product product product -- Convenience! π₁ : {A B : Obj} → ((A × B) ⇒ A) π₁ = Product.π₁ product π₂ : {A B : Obj} → ((A × B) ⇒ B) π₂ = Product.π₂ product ⟨_,_⟩ : ∀ {A B Q} → (Q ⇒ A) → (Q ⇒ B) → (Q ⇒ (A × B)) ⟨_,_⟩ = Product.⟨_,_⟩ product .commute₁ : ∀ {A B C} {f : C ⇒ A} {g : C ⇒ B} → π₁ ∘ ⟨ f , g ⟩ ≡ f commute₁ = Product.commute₁ product .commute₂ : ∀ {A B C} {f : C ⇒ A} {g : C ⇒ B} → π₂ ∘ ⟨ f , g ⟩ ≡ g commute₂ = Product.commute₂ product .universal : ∀ {A B C} {f : C ⇒ A} {g : C ⇒ B} {i : C ⇒ (A × B)} → π₁ ∘ i ≡ f → π₂ ∘ i ≡ g → ⟨ f , g ⟩ ≡ i universal = Product.universal product assocˡ : ∀ {A B C} → (((A × B) × C) ⇒ (A × (B × C))) assocˡ = _≅_.g ×-assoc assocʳ : ∀ {A B C} → ((A × (B × C)) ⇒ ((A × B) × C)) assocʳ = _≅_.f ×-assoc .assocʳ∘assocˡ : ∀ {A B C} → assocʳ {A}{B}{C} ∘ assocˡ {A}{B}{C} ≡ id assocʳ∘assocˡ = Iso.isoʳ (_≅_.iso ×-assoc) .assocˡ∘assocʳ : ∀ {A B C} → assocˡ {A}{B}{C} ∘ assocʳ {A}{B}{C} ≡ id assocˡ∘assocʳ = Iso.isoˡ (_≅_.iso ×-assoc) .g-η : ∀ {A B C} {f : C ⇒ (A × B)} → ⟨ π₁ ∘ f , π₂ ∘ f ⟩ ≡ f g-η = Product.g-η product .η : ∀ {A B} → ⟨ π₁ , π₂ ⟩ ≡ id {A × B} η = Product.η product .⟨⟩-cong₂ : ∀ {A B C} → {f f′ : C ⇒ A} {g g′ : C ⇒ B} → f ≡ f′ → g ≡ g′ → ⟨ f , g ⟩ ≡ ⟨ f′ , g′ ⟩ ⟨⟩-cong₂ = Product.⟨⟩-cong₂ product .⟨⟩-congˡ : ∀ {A B C} → {f f′ : C ⇒ A} {g : C ⇒ B} → f ≡ f′ → ⟨ f , g ⟩ ≡ ⟨ f′ , g ⟩ ⟨⟩-congˡ pf = ⟨⟩-cong₂ pf refl .⟨⟩-congʳ : ∀ {A B C} → {f : C ⇒ A} {g g′ : C ⇒ B} → g ≡ g′ → ⟨ f , g ⟩ ≡ ⟨ f , g′ ⟩ ⟨⟩-congʳ pf = ⟨⟩-cong₂ refl pf _⁂_ : ∀ {A B C D} → (A ⇒ B) → (C ⇒ D) → ((A × C) ⇒ (B × D)) f ⁂ g = [ product ⇒ product ] f ⁂ g swap : ∀ {A B} → ((A × B) ⇒ (B × A)) swap = ⟨ π₂ , π₁ ⟩ -- TODO: this is probably harder to use than necessary because of this definition. Maybe make a version -- that doesn't have an explicit id in it, too? first : ∀ {A B C} → (A ⇒ B) → ((A × C) ⇒ (B × C)) first f = f ⁂ id second : ∀ {A C D} → (C ⇒ D) → ((A × C) ⇒ (A × D)) second g = id ⁂ g -- Just to make this more obvious .π₁∘⁂ : ∀ {A B C D} → {f : A ⇒ B} → {g : C ⇒ D} → π₁ ∘ (f ⁂ g) ≡ f ∘ π₁ π₁∘⁂ {f = f} {g} = commute₁ .π₂∘⁂ : ∀ {A B C D} → {f : A ⇒ B} → {g : C ⇒ D} → π₂ ∘ (f ⁂ g) ≡ g ∘ π₂ π₂∘⁂ {f = f} {g} = commute₂ .⁂-cong₂ : ∀ {A B C D}{f g : A ⇒ B}{h i : C ⇒ D} → f ≡ g → h ≡ i → f ⁂ h ≡ g ⁂ i ⁂-cong₂ = [ product ⇒ product ]⁂-cong₂ .⁂∘⟨⟩ : ∀ {A B C D E} → {f : B ⇒ C} {f′ : A ⇒ B} {g : D ⇒ E} {g′ : A ⇒ D} → (f ⁂ g) ∘ ⟨ f′ , g′ ⟩ ≡ ⟨ f ∘ f′ , g ∘ g′ ⟩ ⁂∘⟨⟩ = [ product ⇒ product ]⁂∘⟨⟩ .first∘⟨⟩ : ∀ {A B C D} → {f : B ⇒ C} {f′ : A ⇒ B} {g′ : A ⇒ D} → first f ∘ ⟨ f′ , g′ ⟩ ≡ ⟨ f ∘ f′ , g′ ⟩ first∘⟨⟩ = [ product ⇒ product ]first∘⟨⟩ .second∘⟨⟩ : ∀ {A B D E} → {f′ : A ⇒ B} {g : D ⇒ E} {g′ : A ⇒ D} → second g ∘ ⟨ f′ , g′ ⟩ ≡ ⟨ f′ , g ∘ g′ ⟩ second∘⟨⟩ = [ product ⇒ product ]second∘⟨⟩ .⁂∘⁂ : ∀ {A B C D E F} → {f : B ⇒ C} → {f′ : A ⇒ B} {g : E ⇒ F} {g′ : D ⇒ E} → (f ⁂ g) ∘ (f′ ⁂ g′) ≡ (f ∘ f′) ⁂ (g ∘ g′) ⁂∘⁂ = [ product ⇒ product ⇒ product ]⁂∘⁂ .⟨⟩∘ : ∀ {A B C D} {f : A ⇒ B} {g : A ⇒ C} {q : D ⇒ A} → ⟨ f , g ⟩ ∘ q ≡ ⟨ f ∘ q , g ∘ q ⟩ ⟨⟩∘ = sym (universal (trans (sym assoc) (∘-resp-≡ˡ commute₁)) (trans (sym assoc) (∘-resp-≡ˡ commute₂))) .first∘first : ∀ {A B C D}{f : B ⇒ C} {g : A ⇒ B} → first f ∘ first g ≡ first {C = D} (f ∘ g) first∘first = [ product ⇒ product ⇒ product ]first∘first .second∘second : ∀ {A B C D}{f : B ⇒ C} {g : A ⇒ B} → second f ∘ second g ≡ second {A = D} (f ∘ g) second∘second = [ product ⇒ product ⇒ product ]second∘second .first↔second : ∀ {A B C D}{f : A ⇒ B}{g : C ⇒ D} → first f ∘ second g ≡ second g ∘ first f first↔second = [ product ⇒ product , product ⇒ product ]first↔second .swap∘⟨⟩ : ∀ {A B C} {f : A ⇒ B} {g : A ⇒ C} → swap ∘ ⟨ f , g ⟩ ≡ ⟨ g , f ⟩ swap∘⟨⟩ {A}{B}{C}{f}{g} = begin ⟨ π₂ , π₁ ⟩ ∘ ⟨ f , g ⟩ ↓⟨ ⟨⟩∘ ⟩ ⟨ π₂ ∘ ⟨ f , g ⟩ , π₁ ∘ ⟨ f , g ⟩ ⟩ ↓⟨ ⟨⟩-cong₂ commute₂ commute₁ ⟩ ⟨ g , f ⟩ ∎ where open HomReasoning .swap∘⁂ : ∀ {A B C D} {f : A ⇒ B} {g : C ⇒ D} → swap ∘ (f ⁂ g) ≡ (g ⁂ f) ∘ swap swap∘⁂ {f = f}{g} = begin swap ∘ (f ⁂ g) ↓⟨ swap∘⟨⟩ ⟩ ⟨ g ∘ π₂ , f ∘ π₁ ⟩ ↑⟨ ⁂∘⟨⟩ ⟩ (g ⁂ f) ∘ swap ∎ where open HomReasoning .swap∘swap : ∀ {A B} → (swap {A}{B}) ∘ (swap {B}{A}) ≡ id swap∘swap = trans swap∘⟨⟩ η .assocʳ∘⟨⟩ : ∀ {A B C D} {f : A ⇒ B} {g : A ⇒ C} {h : A ⇒ D} → assocʳ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ≡ ⟨ ⟨ f , g ⟩ , h ⟩ assocʳ∘⟨⟩ {f = f}{g}{h} = begin assocʳ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ↓⟨ ⟨⟩∘ ⟩ ⟨ ⟨ π₁ , π₁ ∘ π₂ ⟩ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ , (π₂ ∘ π₂) ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ⟩ ↓⟨ ⟨⟩-cong₂ ⟨⟩∘ assoc ⟩ ⟨ ⟨ π₁ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ , (π₁ ∘ π₂) ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ⟩ , π₂ ∘ π₂ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ⟩ ↓⟨ ⟨⟩-cong₂ (⟨⟩-cong₂ commute₁ assoc ) (∘-resp-≡ʳ commute₂) ⟩ ⟨ ⟨ f , π₁ ∘ π₂ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ⟩ , π₂ ∘ ⟨ g , h ⟩ ⟩ ↓⟨ ⟨⟩-cong₂ (⟨⟩-congʳ (∘-resp-≡ʳ commute₂)) commute₂ ⟩ ⟨ ⟨ f , π₁ ∘ ⟨ g , h ⟩ ⟩ , h ⟩ ↓⟨ ⟨⟩-congˡ (⟨⟩-congʳ commute₁) ⟩ ⟨ ⟨ f , g ⟩ , h ⟩ ∎ where open HomReasoning .assocˡ∘⟨⟩ : ∀ {A B C D} {f : A ⇒ B} {g : A ⇒ C} {h : A ⇒ D} → assocˡ ∘ ⟨ ⟨ f , g ⟩ , h ⟩ ≡ ⟨ f , ⟨ g , h ⟩ ⟩ assocˡ∘⟨⟩ {f = f}{g}{h} = begin assocˡ ∘ ⟨ ⟨ f , g ⟩ , h ⟩ ↑⟨ refl ⟩∘⟨ assocʳ∘⟨⟩ ⟩ assocˡ ∘ assocʳ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ↑⟨ assoc ⟩ (assocˡ ∘ assocʳ) ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ↓⟨ assocˡ∘assocʳ ⟩∘⟨ refl ⟩ id ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ↓⟨ identityˡ ⟩ ⟨ f , ⟨ g , h ⟩ ⟩ ∎ where open HomReasoning .assocʳ∘⁂ : ∀ {A₁ A₂ B₁ B₂ C₁ C₂} {f : A₁ ⇒ A₂} {g : B₁ ⇒ B₂} {h : C₁ ⇒ C₂} → assocʳ ∘ (f ⁂ (g ⁂ h)) ≡ ((f ⁂ g) ⁂ h) ∘ assocʳ assocʳ∘⁂ {f = f}{g}{h} = begin assocʳ ∘ (f ⁂ (g ⁂ h)) ↓⟨ refl ⟩∘⟨ ⟨⟩-congʳ ⟨⟩∘ ⟩ assocʳ ∘ ⟨ f ∘ π₁ , ⟨ (g ∘ π₁) ∘ π₂ , (h ∘ π₂) ∘ π₂ ⟩ ⟩ ↓⟨ assocʳ∘⟨⟩ ⟩ ⟨ ⟨ f ∘ π₁ , (g ∘ π₁) ∘ π₂ ⟩ , (h ∘ π₂) ∘ π₂ ⟩ ↓⟨ ⟨⟩-cong₂ (⟨⟩-congʳ assoc) assoc ⟩ ⟨ ⟨ f ∘ π₁ , g ∘ π₁ ∘ π₂ ⟩ , h ∘ π₂ ∘ π₂ ⟩ ↑⟨ ⟨⟩-congˡ ⁂∘⟨⟩ ⟩ ⟨ (f ⁂ g) ∘ ⟨ π₁ , π₁ ∘ π₂ ⟩ , h ∘ π₂ ∘ π₂ ⟩ ↑⟨ ⁂∘⟨⟩ ⟩ ((f ⁂ g) ⁂ h) ∘ assocʳ ∎ where open HomReasoning .assocˡ∘⁂ : ∀ {A₁ A₂ B₁ B₂ C₁ C₂} {f : A₁ ⇒ A₂} {g : B₁ ⇒ B₂} {h : C₁ ⇒ C₂} → assocˡ ∘ ((f ⁂ g) ⁂ h) ≡ (f ⁂ (g ⁂ h)) ∘ assocˡ assocˡ∘⁂ {f = f}{g}{h} = begin assocˡ ∘ ((f ⁂ g) ⁂ h) ↓⟨ refl ⟩∘⟨ ⟨⟩-congˡ ⟨⟩∘ ⟩ assocˡ ∘ ⟨ ⟨ (f ∘ π₁) ∘ π₁ , (g ∘ π₂) ∘ π₁ ⟩ , h ∘ π₂ ⟩ ↓⟨ assocˡ∘⟨⟩ ⟩ ⟨ (f ∘ π₁) ∘ π₁ , ⟨ (g ∘ π₂) ∘ π₁ , h ∘ π₂ ⟩ ⟩ ↓⟨ ⟨⟩-cong₂ assoc (⟨⟩-congˡ assoc) ⟩ ⟨ f ∘ π₁ ∘ π₁ , ⟨ g ∘ π₂ ∘ π₁ , h ∘ π₂ ⟩ ⟩ ↑⟨ ⟨⟩-congʳ ⁂∘⟨⟩ ⟩ ⟨ f ∘ π₁ ∘ π₁ , (g ⁂ h) ∘ ⟨ π₂ ∘ π₁ , π₂ ⟩ ⟩ ↑⟨ ⁂∘⟨⟩ ⟩ (f ⁂ (g ⁂ h)) ∘ assocˡ ∎ where open HomReasoning
{ "alphanum_fraction": 0.4021610225, "avg_line_length": 32.5708154506, "ext": "agda", "hexsha": "53ac0a72f14e298016e884206ec70fad5b82a0f0", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Object/BinaryProducts.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Object/BinaryProducts.agda", "max_line_length": 122, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Object/BinaryProducts.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 4047, "size": 7589 }
open import Relation.Binary.Core module InsertSort.Impl1.Correctness.Permutation.Base {A : Set} (_≤_ : A → A → Set) (tot≤ : Total _≤_) where open import Data.List open import Data.Sum open import InsertSort.Impl1 _≤_ tot≤ open import List.Permutation.Base A lemma-insert∼/ : (x : A)(xs : List A) → (insert x xs) / x ⟶ xs lemma-insert∼/ x [] = /head lemma-insert∼/ x (y ∷ ys) with tot≤ x y ... | inj₁ _ = /head ... | inj₂ _ = /tail (lemma-insert∼/ x ys) lemma-insert∼ : {xs ys : List A}(x : A) → xs ∼ ys → (x ∷ xs) ∼ insert x ys lemma-insert∼ {xs} {ys} x xs∼ys = ∼x /head (lemma-insert∼/ x ys) xs∼ys theorem-insertSort∼ : (xs : List A) → xs ∼ insertSort xs theorem-insertSort∼ [] = ∼[] theorem-insertSort∼ (x ∷ xs) = lemma-insert∼ x (theorem-insertSort∼ xs)
{ "alphanum_fraction": 0.605721393, "avg_line_length": 32.16, "ext": "agda", "hexsha": "166d4cacf7a690b0eca36c84d8de1cf11e974478", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/InsertSort/Impl1/Correctness/Permutation/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/InsertSort/Impl1/Correctness/Permutation/Base.agda", "max_line_length": 74, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/InsertSort/Impl1/Correctness/Permutation/Base.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 294, "size": 804 }
-- Lifting of substitutions, and instance of strength for δ module SOAS.Coalgebraic.Lift {T : Set} where open import SOAS.Common open import SOAS.Context {T} open import SOAS.Variable open import SOAS.Families.Core {T} import SOAS.Families.Delta {T} as δ; open δ.Sorted open import SOAS.Abstract.Hom {T} import SOAS.Abstract.Box {T} as □ ; open □.Sorted import SOAS.Abstract.Coalgebra {T} as →□ ; open →□.Sorted open import SOAS.Coalgebraic.Map open import SOAS.Coalgebraic.Strength private variable Γ Δ Θ : Ctx α : T module _ {𝒫 : Familyₛ} (𝒫ᴮ : Coalgₚ 𝒫) where open Coalgₚ 𝒫ᴮ -- General lifting over an arbitrary context lift : (Ξ : Ctx) → Γ ~[ 𝒫 ]↝ Δ → (Ξ ∔ Γ) ~[ 𝒫 ]↝ (Ξ ∔ Δ) lift ∅ σ v = σ v lift (τ ∙ Ξ) σ new = η new lift (τ ∙ Ξ) σ (old v) = r (lift Ξ σ v) old -- Single-variable lifting lift₁ : {τ : T} → Γ ~[ 𝒫 ]↝ Δ → (τ ∙ Γ) ~[ 𝒫 ]↝ (τ ∙ Δ) lift₁ {τ = τ} = lift ⌈ τ ⌋ -- General lifting of renaming rlift : (Ξ : Ctx) → Γ ↝ Δ → (Ξ ∔ Γ) ↝ (Ξ ∔ Δ) rlift Ξ = lift ℐᴮ Ξ -- Strength for context extension δ:Strength : (Ξ : Ctx) → Strength (δF Ξ) δ:Strength Ξ = record { str = λ 𝒫ᴮ 𝒳 h σ → h (lift 𝒫ᴮ Ξ σ) ; str-nat₁ = λ fᴮ⇒ h σ → cong h (dext (str-nat₁ Ξ fᴮ⇒ σ)) ; str-nat₂ = λ f h σ → refl ; str-unit = λ 𝒳 h → cong h (dext (str-unit Ξ 𝒳)) ; str-assoc = λ 𝒳 fᶜ h σ ς → cong h (dext (str-assoc Ξ 𝒳 fᶜ σ ς)) } where open ≡-Reasoning open Coalgₚ open Coalgₚ⇒ str-nat₁ : (Ξ : Ctx){𝒫 𝒬 : Familyₛ} {𝒫ᴮ : Coalgₚ 𝒫} {𝒬ᴮ : Coalgₚ 𝒬} {f : 𝒬 ⇾̣ 𝒫} → Coalgₚ⇒ 𝒬ᴮ 𝒫ᴮ f → (σ : Γ ~[ 𝒬 ]↝ Δ)(v : ℐ α (Ξ ∔ Γ)) → lift 𝒫ᴮ Ξ (f ∘ σ) v ≡ f (lift 𝒬ᴮ Ξ σ v) str-nat₁ ∅ fᴮ⇒ σ v = refl str-nat₁ (α ∙ Ξ) {𝒫ᴮ = 𝒫ᴮ} fᴮ⇒ σ new = sym (Coalgₚ⇒.⟨η⟩ fᴮ⇒) str-nat₁ (α ∙ Ξ) {𝒫ᴮ = 𝒫ᴮ} {𝒬ᴮ}{f}fᴮ⇒ σ (old v) = begin lift 𝒫ᴮ (α ∙ Ξ) (f ∘ σ) (old v) ≡⟨ congr (str-nat₁ Ξ fᴮ⇒ σ v) (λ - → r 𝒫ᴮ - old) ⟩ r 𝒫ᴮ (f (lift 𝒬ᴮ Ξ σ v)) old ≡˘⟨ ⟨r⟩ fᴮ⇒ ⟩ f (lift 𝒬ᴮ (α ∙ Ξ) σ (old v)) ∎ str-unit : (Ξ : Ctx) (𝒳 : Familyₛ) (v : ℐ α (Ξ ∔ Γ)) → lift ℐᴮ Ξ id v ≡ v str-unit ∅ 𝒳 v = refl str-unit (α ∙ Ξ) 𝒳 new = refl str-unit (α ∙ Ξ) 𝒳 (old v) = cong old (str-unit Ξ 𝒳 v) str-assoc : (Ξ : Ctx) (𝒳 : Familyₛ) {𝒫 𝒬 ℛ : Familyₛ} {𝒫ᴮ : Coalgₚ 𝒫} {𝒬ᴮ : Coalgₚ 𝒬} {ℛᴮ : Coalgₚ ℛ} {f : 𝒫 ⇾̣ 〖 𝒬 , ℛ 〗} (fᶜ : Coalgebraic 𝒫ᴮ 𝒬ᴮ ℛᴮ f) (open Coalgebraic fᶜ) (σ : Γ ~[ 𝒫 ]↝ Δ) (ς : Δ ~[ 𝒬 ]↝ Θ)(v : ℐ α (Ξ ∔ Γ)) → lift ℛᴮ Ξ (λ u → f (σ u) ς) v ≡ lift 〖𝒫,𝒴〗ᴮ Ξ (f ∘ σ) v (lift 𝒬ᴮ Ξ ς) str-assoc ∅ 𝒳 fᶜ σ ς v = refl str-assoc (β ∙ Ξ) 𝒳 {𝒫ᴮ = 𝒫ᴮ}{𝒬ᴮ}{ℛᴮ} {f} fᶜ σ ς new = begin η ℛᴮ new ≡˘⟨ f∘η ⟩ f (η 𝒫ᴮ new) (η 𝒬ᴮ) ≡⟨ eq-at-new refl ⟩ f (η 𝒫ᴮ new) (lift 𝒬ᴮ (β ∙ Ξ) ς) ∎ where open Coalgebraic fᶜ str-assoc {Γ = Γ} (β ∙ Ξ) 𝒳 {𝒫 = 𝒫}{𝒬}{𝒫ᴮ = 𝒫ᴮ}{𝒬ᴮ}{ℛᴮ}{f} fᶜ σ ς (old v) = begin r ℛᴮ (lift ℛᴮ Ξ (λ u → f (σ u) ς) v) old ≡⟨ congr (str-assoc Ξ 𝒳 fᶜ σ ς v) (λ - → r ℛᴮ - old) ⟩ r ℛᴮ ( lift 〖𝒫,𝒴〗ᴮ Ξ (f ∘ σ) v (lift 𝒬ᴮ Ξ ς)) old ≡⟨ congr (str-nat₁ Ξ fᴮ⇒ (σ) v) (λ - → r ℛᴮ (- (lift 𝒬ᴮ Ξ ς)) old) ⟩ r ℛᴮ (f (lift 𝒫ᴮ Ξ σ v) (lift 𝒬ᴮ Ξ ς)) old ≡⟨ r∘f ⟩ f (lift 𝒫ᴮ Ξ σ v) (λ u → r 𝒬ᴮ (lift 𝒬ᴮ Ξ ς u) old) ≡˘⟨ congr (str-nat₁ Ξ fᴮ⇒ σ v) (λ - → - (λ u → r 𝒬ᴮ (lift 𝒬ᴮ Ξ ς u) old)) ⟩ lift 〖𝒫,𝒴〗ᴮ Ξ (f ∘ σ) v (λ u → r 𝒬ᴮ (lift 𝒬ᴮ Ξ ς u) old) ∎ where open Coalgebraic fᶜ renaming (ᴮ⇒ to fᴮ⇒) module δ:Str Θ = Strength (δ:Strength Θ) -- Derived lifting properties rlift-id : (𝒳 : Familyₛ)(Ξ : Ctx)(b : δ Ξ (□ 𝒳) α Γ) → b (rlift Ξ id) ≡ b id rlift-id 𝒳 Ξ = Strength.str-unit (δ:Strength Ξ) 𝒳 lift-comp : {𝒫 𝒬 : Familyₛ}{𝒫ᴮ : Coalgₚ 𝒫}{𝒬ᴮ : Coalgₚ 𝒬} (𝒳 : Familyₛ)(Ξ : Ctx){f : 𝒬 ⇾̣ 𝒫} (fᴮ⇒ : Coalgₚ⇒ 𝒬ᴮ 𝒫ᴮ f) (h : δ Ξ 〖 𝒫 , 𝒳 〗 α Γ) (σ : Γ ~[ 𝒬 ]↝ Δ) → h (lift 𝒫ᴮ Ξ (f ∘ σ)) ≡ h (f ∘ lift 𝒬ᴮ Ξ σ) lift-comp 𝒳 Ξ fᴮ⇒ h σ = Strength.str-nat₁ (δ:Strength Ξ) {𝒳 = 𝒳} fᴮ⇒ h σ lift-assoc : {𝒫 𝒬 ℛ : Familyₛ} {𝒫ᴮ : Coalgₚ 𝒫} {𝒬ᴮ : Coalgₚ 𝒬} {ℛᴮ : Coalgₚ ℛ} (𝒳 : Familyₛ)(Ξ : Ctx) {f : 𝒫 ⇾̣ 〖 𝒬 , ℛ 〗} (fᶜ : Coalgebraic 𝒫ᴮ 𝒬ᴮ ℛᴮ f) (open Coalgebraic fᶜ) (h : δ Ξ 〖 ℛ , 𝒳 〗 α Γ) (σ : Γ ~[ 𝒫 ]↝ Δ) (ς : Δ ~[ 𝒬 ]↝ Θ) → h (lift ℛᴮ Ξ (λ v → f (σ v) ς)) ≡ h (λ v → lift 〖𝒫,𝒴〗ᴮ Ξ (f ∘ σ) v (lift 𝒬ᴮ Ξ ς)) lift-assoc 𝒳 Ξ fᶜ h σ ς = Strength.str-assoc (δ:Strength Ξ) 𝒳 fᶜ h σ ς lift-dist : {𝒫 𝒬 ℛ : Familyₛ}{𝒫ᴮ : Coalgₚ 𝒫}{𝒬ᴮ : Coalgₚ 𝒬}{ℛᴮ : Coalgₚ ℛ} (𝒳 : Familyₛ){Ξ : Ctx}{f : 𝒫 ⇾̣ 〖 𝒬 , ℛ 〗} (fᶜ : Coalgebraic 𝒫ᴮ 𝒬ᴮ ℛᴮ f) (h : δ Ξ 〖 ℛ , 𝒳 〗 α Γ) (σ : Γ ~[ 𝒫 ]↝ Δ) (ς : Δ ~[ 𝒬 ]↝ Θ) → h (lift ℛᴮ Ξ (λ v → f (σ v) ς)) ≡ h (λ v → f (lift 𝒫ᴮ Ξ σ v) (lift 𝒬ᴮ Ξ ς)) lift-dist 𝒳 {Ξ} = Strength.str-dist (δ:Strength Ξ) 𝒳
{ "alphanum_fraction": 0.483391074, "avg_line_length": 35.3021582734, "ext": "agda", "hexsha": "558eedd836bcce9a1fc23ee93afed502f9e3580e", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "SOAS/Coalgebraic/Lift.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "SOAS/Coalgebraic/Lift.agda", "max_line_length": 80, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "SOAS/Coalgebraic/Lift.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 2986, "size": 4907 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary using (Rel; Setoid; Substitutive; Symmetric; Total) module Algebra.FunctionProperties.Consequences {a ℓ} (S : Setoid a ℓ) where {-# WARNING_ON_IMPORT "Algebra.FunctionProperties.Consequences was deprecated in v1.3. Use Algebra.Consequences.Setoid instead." #-} open import Algebra.Consequences.Setoid S public
{ "alphanum_fraction": 0.5697278912, "avg_line_length": 29.4, "ext": "agda", "hexsha": "9337494c39f2344e86a35047d06f93a6d4344433", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Algebra/FunctionProperties/Consequences.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Algebra/FunctionProperties/Consequences.agda", "max_line_length": 79, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Algebra/FunctionProperties/Consequences.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 112, "size": 588 }
module Issue453 where postulate A : Set fails : {x : _} → A
{ "alphanum_fraction": 0.5714285714, "avg_line_length": 10, "ext": "agda", "hexsha": "ae57318d382bd8270c14fd4cd80eae0ca3a22d3b", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/Issue453.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/Issue453.agda", "max_line_length": 21, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue453.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 26, "size": 70 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.ZCohomology.Groups.Unit where open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.Properties open import Cubical.HITs.Sn open import Cubical.Foundations.HLevels open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.HITs.Susp open import Cubical.HITs.SetTruncation renaming (rec to sRec ; elim to sElim ; elim2 to sElim2) open import Cubical.HITs.PropositionalTruncation renaming (rec to pRec ; elim to pElim ; elim2 to pElim2 ; ∥_∥ to ∥_∥₋₁ ; ∣_∣ to ∣_∣₋₁) open import Cubical.HITs.Nullification open import Cubical.Data.Int hiding (_+_ ; +-comm) open import Cubical.Data.Nat open import Cubical.HITs.Truncation open import Cubical.Homotopy.Connected open import Cubical.Data.Unit open import Cubical.Algebra.Group -- H⁰(Unit) open GroupHom open GroupIso H⁰-Unit≅ℤ : GroupIso (coHomGr 0 Unit) intGroup fun (GroupIso.map H⁰-Unit≅ℤ) = sRec isSetInt (λ f → f tt) isHom (GroupIso.map H⁰-Unit≅ℤ) = sElim2 (λ _ _ → isOfHLevelPath 2 isSetInt _ _) λ a b → addLemma (a tt) (b tt) inv H⁰-Unit≅ℤ a = ∣ (λ _ → a) ∣₂ rightInv H⁰-Unit≅ℤ _ = refl leftInv H⁰-Unit≅ℤ = sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ a → refl {- Hⁿ(Unit) for n ≥ 1 -} isContrHⁿ-Unit : (n : ℕ) → isContr (coHom (suc n) Unit) isContrHⁿ-Unit n = subst isContr (λ i → ∥ UnitToTypePath (coHomK (suc n)) (~ i) ∥₂) (helper' n) where helper' : (n : ℕ) → isContr (∥ coHomK (suc n) ∥₂) helper' n = subst isContr ((isoToPath (truncOfTruncIso {A = S₊ (1 + n)} 2 (1 + n))) ∙∙ sym propTrunc≡Trunc2 ∙∙ λ i → ∥ hLevelTrunc (suc (+-comm n 2 i)) (S₊ (1 + n)) ∥₂) (isConnectedSubtr 2 (helper2 n .fst) (subst (λ x → isConnected x (S₊ (suc n))) (sym (helper2 n .snd)) (sphereConnected (suc n))) ) where helper2 : (n : ℕ) → Σ[ m ∈ ℕ ] m + 2 ≡ 2 + n helper2 zero = 0 , refl helper2 (suc n) = (suc n) , λ i → suc (+-comm n 2 i) Hⁿ-Unit≅0 : (n : ℕ) → GroupIso (coHomGr (suc n) Unit) trivialGroup GroupHom.fun (GroupIso.map (Hⁿ-Unit≅0 n)) _ = _ GroupHom.isHom (GroupIso.map (Hⁿ-Unit≅0 n)) _ _ = refl GroupIso.inv (Hⁿ-Unit≅0 n) _ = 0ₕ (suc n) GroupIso.rightInv (Hⁿ-Unit≅0 n) _ = refl GroupIso.leftInv (Hⁿ-Unit≅0 n) _ = isOfHLevelSuc 0 (isContrHⁿ-Unit n) _ _ {- Hⁿ for arbitrary contractible types -} private Hⁿ-contrTypeIso : ∀ {ℓ} {A : Type ℓ} (n : ℕ) → isContr A → Iso (coHom (suc n) A) (coHom (suc n) Unit) Hⁿ-contrTypeIso n contr = compIso (setTruncIso (isContr→Iso2 contr)) (setTruncIso (invIso (isContr→Iso2 isContrUnit))) Hⁿ-contrType≅0 : ∀ {ℓ} {A : Type ℓ} (n : ℕ) → isContr A → GroupIso (coHomGr (suc n) A) trivialGroup fun (GroupIso.map (Hⁿ-contrType≅0 _ _)) _ = _ isHom (GroupIso.map (Hⁿ-contrType≅0 _ _)) _ _ = refl inv (Hⁿ-contrType≅0 n _) _ = 0ₕ (suc n) rightInv (Hⁿ-contrType≅0 _ _) _ = refl leftInv (Hⁿ-contrType≅0 {A = A} n contr) _ = isOfHLevelSuc 0 helper _ _ where helper : isContr (coHom (suc n) A) helper = (Iso.inv (Hⁿ-contrTypeIso n contr) (0ₕ (suc n))) , λ y → cong (Iso.inv (Hⁿ-contrTypeIso n contr)) (isOfHLevelSuc 0 (isContrHⁿ-Unit n) (0ₕ (suc n)) (Iso.fun (Hⁿ-contrTypeIso n contr) y)) ∙ Iso.leftInv (Hⁿ-contrTypeIso n contr) y
{ "alphanum_fraction": 0.6470940683, "avg_line_length": 43.3506493506, "ext": "agda", "hexsha": "62530cf7d7fa9d9ca6d9f14ff0a241a25730cdae", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ayberkt/cubical", "max_forks_repo_path": "Cubical/ZCohomology/Groups/Unit.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "ayberkt/cubical", "max_issues_repo_path": "Cubical/ZCohomology/Groups/Unit.agda", "max_line_length": 135, "max_stars_count": null, "max_stars_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ayberkt/cubical", "max_stars_repo_path": "Cubical/ZCohomology/Groups/Unit.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1340, "size": 3338 }
{-# OPTIONS --cubical --no-import-sorts --allow-unsolved-metas #-} module Number.Operations.Details where open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Relation.Nullary.Base -- ¬_ open import Cubical.Data.Unit.Base -- Unit open import Cubical.Data.Sigma.Base renaming (_×_ to infixr 4 _×_) open import Cubical.Data.Empty renaming (elim to ⊥-elim) -- `⊥` and `elim` open import Function.Base using (_$_) open import Cubical.Data.Nat.Properties open import Cubical.Data.Nat.Order renaming (zero-≤ to z≤n; suc-≤-suc to s≤s) open import MoreNatProperties renaming (0≤x to 0≤xⁿ) open import Number.Postulates open import Number.Structures open import Number.Bundles open import Number.Inclusions open import Number.Base open import Number.Coercions open ℕⁿ open ℤᶻ open ℚᶠ open ℝʳ open ℂᶜ infix 9 _⁻¹ infix 8 -_ open import Number.Operations.Specification open PatternsProp _⁻¹ : ∀{l p} → (x : Number (l , p)) → ⁻¹-Types x _⁻¹ {isNat } {⁇x⁇} (x ,, q) {{h}} = let r = Isℕ↪ℚ.preserves-#0 ℕ↪ℚinc _ h in _⁻¹ᶠ (ℕ↪ℚ x) {{r}} ,, ℚ.⁻¹-preserves-#0 _ r _⁻¹ {isNat } {x#0} (x ,, q) {{h}} = let r = Isℕ↪ℚ.preserves-#0 ℕ↪ℚinc _ q in _⁻¹ᶠ (ℕ↪ℚ x) {{r}} ,, ℚ.⁻¹-preserves-#0 _ r _⁻¹ {isNat } {0≤x} (x ,, q) {{h}} = let p = Isℕ↪ℚ.preserves-0< ℕ↪ℚinc _ (ℕ.≤-#-implies-< _ _ q (ℕ.#-sym _ _ h)) r = Isℕ↪ℚ.preserves-#0 ℕ↪ℚinc _ h in _⁻¹ᶠ (ℕ↪ℚ x) {{r}} ,, ℚ.⁻¹-preserves-0< _ p r _⁻¹ {isNat } {0<x} (x ,, q) {{h}} = let p = Isℕ↪ℚ.preserves-0< ℕ↪ℚinc _ q r = Isℕ↪ℚ.preserves-#0 ℕ↪ℚinc _ (ℕ.#-sym _ _ (ℕ.<-implies-# _ _ q)) in _⁻¹ᶠ (ℕ↪ℚ x) {{r}} ,, ℚ.⁻¹-preserves-0< _ p r _⁻¹ {isNat } {x≤0} (x ,, q) {{h}} = let p = Isℕ↪ℚ.preserves-<0 ℕ↪ℚinc _ (ℕ.≤-#-implies-< _ _ q h) r = Isℕ↪ℚ.preserves-#0 ℕ↪ℚinc _ h in _⁻¹ᶠ (ℕ↪ℚ x) {{r}} ,, ℚ.⁻¹-preserves-<0 _ p r _⁻¹ {isInt } {⁇x⁇} (x ,, q) {{h}} = let r = Isℤ↪ℚ.preserves-#0 ℤ↪ℚinc _ h in _⁻¹ᶠ (ℤ↪ℚ x) {{r}} ,, ℚ.⁻¹-preserves-#0 _ r _⁻¹ {isInt } {x#0} (x ,, q) {{h}} = let r = Isℤ↪ℚ.preserves-#0 ℤ↪ℚinc _ q in _⁻¹ᶠ (ℤ↪ℚ x) {{r}} ,, ℚ.⁻¹-preserves-#0 _ r _⁻¹ {isInt } {0≤x} (x ,, q) {{h}} = let p = Isℤ↪ℚ.preserves-0< ℤ↪ℚinc _ (ℤ.≤-#-implies-< _ _ q (ℤ.#-sym _ _ h)) r = Isℤ↪ℚ.preserves-#0 ℤ↪ℚinc _ h in _⁻¹ᶠ (ℤ↪ℚ x) {{r}} ,, ℚ.⁻¹-preserves-0< _ p r _⁻¹ {isInt } {0<x} (x ,, q) {{h}} = let p = Isℤ↪ℚ.preserves-0< ℤ↪ℚinc _ q r = Isℤ↪ℚ.preserves-#0 ℤ↪ℚinc _ (ℤ.#-sym _ _ (ℤ.<-implies-# _ _ q)) in _⁻¹ᶠ (ℤ↪ℚ x) {{r}} ,, ℚ.⁻¹-preserves-0< _ p r _⁻¹ {isInt } {x<0} (x ,, q) {{h}} = let p = Isℤ↪ℚ.preserves-<0 ℤ↪ℚinc _ q r = Isℤ↪ℚ.preserves-#0 ℤ↪ℚinc _ (ℤ.<-implies-# _ _ q) in _⁻¹ᶠ (ℤ↪ℚ x) {{r}} ,, ℚ.⁻¹-preserves-<0 _ p r _⁻¹ {isInt } {x≤0} (x ,, q) {{h}} = let p = Isℤ↪ℚ.preserves-<0 ℤ↪ℚinc _ (ℤ.≤-#-implies-< _ _ q h) r = Isℤ↪ℚ.preserves-#0 ℤ↪ℚinc _ h in _⁻¹ᶠ (ℤ↪ℚ x) {{r}} ,, ℚ.⁻¹-preserves-<0 _ p r _⁻¹ {isRat } {⁇x⁇} (x ,, q) {{h}} = _⁻¹ᶠ x {{h}} ,, ℚ.⁻¹-preserves-#0 x h _⁻¹ {isRat } {x#0} (x ,, q) {{h}} = _⁻¹ᶠ x {{q}} ,, ℚ.⁻¹-preserves-#0 x q _⁻¹ {isRat } {0≤x} (x ,, q) {{h}} = _⁻¹ᶠ x {{h}} ,, ℚ.⁻¹-preserves-0< x (ℚ.≤-#-implies-< _ _ q (ℚ.#-sym _ _ h)) h _⁻¹ {isRat } {0<x} (x ,, q) {{h}} = let r = ℚ.#-sym _ _ (ℚ.<-implies-# _ _ q) in _⁻¹ᶠ x {{r}} ,, ℚ.⁻¹-preserves-0< _ q r _⁻¹ {isRat } {x<0} (x ,, q) {{h}} = let r = ℚ.<-implies-# _ _ q in _⁻¹ᶠ x {{r}} ,, ℚ.⁻¹-preserves-<0 _ q r _⁻¹ {isRat } {x≤0} (x ,, q) {{h}} = _⁻¹ᶠ x {{h}} ,, ℚ.⁻¹-preserves-<0 x (ℚ.≤-#-implies-< _ _ q h) h _⁻¹ {isReal } {⁇x⁇} (x ,, q) {{h}} = _⁻¹ʳ x {{h}} ,, ℝ.⁻¹-preserves-#0 x h _⁻¹ {isReal } {x#0} (x ,, q) {{h}} = _⁻¹ʳ x {{q}} ,, ℝ.⁻¹-preserves-#0 x q _⁻¹ {isReal } {0≤x} (x ,, q) {{h}} = _⁻¹ʳ x {{h}} ,, ℝ.⁻¹-preserves-0< x (ℝ.≤-#-implies-< _ _ q (ℝ.#-sym _ _ h)) h _⁻¹ {isReal } {0<x} (x ,, q) {{h}} = let r = ℝ.#-sym _ _ (ℝ.<-implies-# _ _ q) in _⁻¹ʳ x {{r}} ,, ℝ.⁻¹-preserves-0< _ q r _⁻¹ {isReal } {x<0} (x ,, q) {{h}} = let r = ℝ.<-implies-# _ _ q in _⁻¹ʳ x {{r}} ,, ℝ.⁻¹-preserves-<0 _ q r _⁻¹ {isReal } {x≤0} (x ,, q) {{h}} = _⁻¹ʳ x {{h}} ,, ℝ.⁻¹-preserves-<0 x (ℝ.≤-#-implies-< _ _ q h) h _⁻¹ {isComplex} {⁇x⁇} (x ,, q) {{h}} = _⁻¹ᶜ x {{h}} ,, ℂ.⁻¹-preserves-#0 x h _⁻¹ {isComplex} {x#0} (x ,, q) {{h}} = _⁻¹ᶜ x {{q}} ,, ℂ.⁻¹-preserves-#0 x q -_ : ∀{l p} → (x : Number (l , p)) → -Types x -_ {isNat } {⁇x⁇} (x ,, p) = (-ᶻ (ℕ↪ℤ x)) ,, (ℤ.-flips-0≤ _ $ Isℕ↪ℤ.preserves-0≤ ℕ↪ℤinc _ (0≤xⁿ x)) -_ {isNat } {x#0} (x ,, p) = (-ᶻ (ℕ↪ℤ x)) ,, (ℤ.-preserves-#0 _ $ Isℕ↪ℤ.preserves-#0 ℕ↪ℤinc _ p) -_ {isNat } {0≤x} (x ,, p) = (-ᶻ (ℕ↪ℤ x)) ,, (ℤ.-flips-0≤ _ $ Isℕ↪ℤ.preserves-0≤ ℕ↪ℤinc _ p) -_ {isNat } {0<x} (x ,, p) = (-ᶻ (ℕ↪ℤ x)) ,, (ℤ.-flips-0< _ $ Isℕ↪ℤ.preserves-0< ℕ↪ℤinc _ p) -_ {isNat } {x≤0} (x ,, p) = (-ᶻ (ℕ↪ℤ x)) ,, (ℤ.-flips-≤0 _ $ Isℕ↪ℤ.preserves-≤0 ℕ↪ℤinc _ p) -_ {isInt } {⁇x⁇} (x ,, p) = (-ᶻ x ) ,, lift tt -_ {isInt } {x#0} (x ,, p) = (-ᶻ x ) ,, ℤ.-preserves-#0 _ p -_ {isInt } {0≤x} (x ,, p) = (-ᶻ x ) ,, ℤ.-flips-0≤ _ p -_ {isInt } {0<x} (x ,, p) = (-ᶻ x ) ,, ℤ.-flips-0< _ p -_ {isInt } {x<0} (x ,, p) = (-ᶻ x ) ,, ℤ.-flips-<0 _ p -_ {isInt } {x≤0} (x ,, p) = (-ᶻ x ) ,, ℤ.-flips-≤0 _ p -_ {isRat } {⁇x⁇} (x ,, p) = (-ᶠ x ) ,, lift tt -_ {isRat } {x#0} (x ,, p) = (-ᶠ x ) ,, ℚ.-preserves-#0 _ p -_ {isRat } {0≤x} (x ,, p) = (-ᶠ x ) ,, ℚ.-flips-0≤ _ p -_ {isRat } {0<x} (x ,, p) = (-ᶠ x ) ,, ℚ.-flips-0< _ p -_ {isRat } {x<0} (x ,, p) = (-ᶠ x ) ,, ℚ.-flips-<0 _ p -_ {isRat } {x≤0} (x ,, p) = (-ᶠ x ) ,, ℚ.-flips-≤0 _ p -_ {isReal } {⁇x⁇} (x ,, p) = (-ʳ x ) ,, lift tt -_ {isReal } {x#0} (x ,, p) = (-ʳ x ) ,, ℝ.-preserves-#0 _ p -_ {isReal } {0≤x} (x ,, p) = (-ʳ x ) ,, ℝ.-flips-0≤ _ p -_ {isReal } {0<x} (x ,, p) = (-ʳ x ) ,, ℝ.-flips-0< _ p -_ {isReal } {x<0} (x ,, p) = (-ʳ x ) ,, ℝ.-flips-<0 _ p -_ {isReal } {x≤0} (x ,, p) = (-ʳ x ) ,, ℝ.-flips-≤0 _ p -_ {isComplex} {⁇x⁇} (x ,, p) = (-ᶜ x ) ,, lift tt -_ {isComplex} {x#0} (x ,, p) = (-ᶜ x ) ,, ℂ.-preserves-#0 _ p _+ʰⁿ_ : ∀{p q} → (x : Number (isNat , p)) → (y : Number (isNat , q)) → PositivityKindInterpretation isNat (+-Positivityʰ isNat p q) (num x +ⁿ num y) _+ʰⁿ_ {⁇x⁇} {⁇x⁇} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {⁇x⁇} {x#0} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {⁇x⁇} {0≤x} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {⁇x⁇} {0<x} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {⁇x⁇} {x≤0} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {x#0} {⁇x⁇} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {x#0} {x#0} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {x#0} {0≤x} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {x#0} {0<x} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {x#0} {x≤0} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {0≤x} {⁇x⁇} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {0≤x} {x#0} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {0≤x} {0≤x} (a ,, pa) (b ,, pb) = ℕ.+-0≤-0≤-implies-0≤ a b pa pb -- 0 ≤ a → 0 ≤ b → 0 ≤ a + b _+ʰⁿ_ {0≤x} {0<x} (a ,, pa) (b ,, pb) = ℕ.+-0≤-0<-implies-0< a b pa pb -- 0 ≤ a → 0 < b → 0 < a + b _+ʰⁿ_ {0≤x} {x≤0} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {0<x} {⁇x⁇} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {0<x} {x#0} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {0<x} {0≤x} (a ,, pa) (b ,, pb) = ℕ.+-0<-0≤-implies-0< a b pa pb -- 0 < a → 0 ≤ b → 0 < a + b _+ʰⁿ_ {0<x} {0<x} (a ,, pa) (b ,, pb) = ℕ.+-0<-0<-implies-0< a b pa pb -- 0 < a → 0 < b → 0 < a + b _+ʰⁿ_ {0<x} {x≤0} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {x≤0} {⁇x⁇} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {x≤0} {x#0} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {x≤0} {0≤x} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {x≤0} {0<x} (a ,, pa) (b ,, pb) = tt _+ʰⁿ_ {x≤0} {x≤0} (a ,, pa) (b ,, pb) = ℕ.+-≤0-≤0-implies-≤0 a b pa pb -- a ≤ 0 → b ≤ 0 → (a + b) ≤ 0 _+ʰᶻ_ : ∀{p q} → (x : Number (isInt , p)) → (y : Number (isInt , q)) → PositivityKindInterpretation isInt (+-Positivityʰ isInt p q) (num x +ᶻ num y) _+ʰᶻ_ {⁇x⁇} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {⁇x⁇} {x#0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {⁇x⁇} {0≤x} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {⁇x⁇} {0<x} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {⁇x⁇} {x<0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {⁇x⁇} {x≤0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {x#0} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {x#0} {x#0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {x#0} {0≤x} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {x#0} {0<x} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {x#0} {x<0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {x#0} {x≤0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {0≤x} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {0≤x} {x#0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {0≤x} {0≤x} (a ,, pa) (b ,, pb) = ℤ.+-0≤-0≤-implies-0≤ a b pa pb -- 0 ≤ a → 0 ≤ b → 0 ≤ a + b _+ʰᶻ_ {0≤x} {0<x} (a ,, pa) (b ,, pb) = ℤ.+-0≤-0<-implies-0< a b pa pb -- 0 ≤ a → 0 < b → 0 < a + b _+ʰᶻ_ {0≤x} {x<0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {0≤x} {x≤0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {0<x} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {0<x} {x#0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {0<x} {0≤x} (a ,, pa) (b ,, pb) = ℤ.+-0<-0≤-implies-0< a b pa pb -- 0 < a → 0 ≤ b → 0 < a + b _+ʰᶻ_ {0<x} {0<x} (a ,, pa) (b ,, pb) = ℤ.+-0<-0<-implies-0< a b pa pb -- 0 < a → 0 < b → 0 < a + b _+ʰᶻ_ {0<x} {x<0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {0<x} {x≤0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {x<0} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {x<0} {x#0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {x<0} {0≤x} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {x<0} {0<x} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {x<0} {x<0} (a ,, pa) (b ,, pb) = ℤ.+-<0-<0-implies-<0 a b pa pb -- a < 0 → b < 0 → (a + b) < 0 _+ʰᶻ_ {x<0} {x≤0} (a ,, pa) (b ,, pb) = ℤ.+-<0-≤0-implies-<0 a b pa pb -- a < 0 → b ≤ 0 → (a + b) < 0 _+ʰᶻ_ {x≤0} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {x≤0} {x#0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {x≤0} {0≤x} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {x≤0} {0<x} (a ,, pa) (b ,, pb) = lift tt _+ʰᶻ_ {x≤0} {x<0} (a ,, pa) (b ,, pb) = ℤ.+-≤0-<0-implies-<0 a b pa pb -- a ≤ 0 → b < 0 → (a + b) < 0 _+ʰᶻ_ {x≤0} {x≤0} (a ,, pa) (b ,, pb) = ℤ.+-≤0-≤0-implies-≤0 a b pa pb -- a ≤ 0 → b ≤ 0 → (a + b) ≤ 0 _+ʰᶠ_ : ∀{p q} → (x : Number (isRat , p)) → (y : Number (isRat , q)) → PositivityKindInterpretation isRat (+-Positivityʰ isRat p q) (num x +ᶠ num y) _+ʰᶠ_ {⁇x⁇} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {⁇x⁇} {x#0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {⁇x⁇} {0≤x} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {⁇x⁇} {0<x} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {⁇x⁇} {x<0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {⁇x⁇} {x≤0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {x#0} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {x#0} {x#0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {x#0} {0≤x} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {x#0} {0<x} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {x#0} {x<0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {x#0} {x≤0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {0≤x} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {0≤x} {x#0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {0≤x} {0≤x} (a ,, pa) (b ,, pb) = ℚ.+-0≤-0≤-implies-0≤ a b pa pb -- 0 ≤ a → 0 ≤ b → 0 ≤ a + b _+ʰᶠ_ {0≤x} {0<x} (a ,, pa) (b ,, pb) = ℚ.+-0≤-0<-implies-0< a b pa pb -- 0 ≤ a → 0 < b → 0 < a + b _+ʰᶠ_ {0≤x} {x<0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {0≤x} {x≤0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {0<x} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {0<x} {x#0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {0<x} {0≤x} (a ,, pa) (b ,, pb) = ℚ.+-0<-0≤-implies-0< a b pa pb -- 0 < a → 0 ≤ b → 0 < a + b _+ʰᶠ_ {0<x} {0<x} (a ,, pa) (b ,, pb) = ℚ.+-0<-0<-implies-0< a b pa pb -- 0 < a → 0 < b → 0 < a + b _+ʰᶠ_ {0<x} {x<0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {0<x} {x≤0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {x<0} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {x<0} {x#0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {x<0} {0≤x} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {x<0} {0<x} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {x<0} {x<0} (a ,, pa) (b ,, pb) = ℚ.+-<0-<0-implies-<0 a b pa pb -- a < 0 → b < 0 → (a + b) < 0 _+ʰᶠ_ {x<0} {x≤0} (a ,, pa) (b ,, pb) = ℚ.+-<0-≤0-implies-<0 a b pa pb -- a < 0 → b ≤ 0 → (a + b) < 0 _+ʰᶠ_ {x≤0} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {x≤0} {x#0} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {x≤0} {0≤x} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {x≤0} {0<x} (a ,, pa) (b ,, pb) = lift tt _+ʰᶠ_ {x≤0} {x<0} (a ,, pa) (b ,, pb) = ℚ.+-≤0-<0-implies-<0 a b pa pb -- a ≤ 0 → b < 0 → (a + b) < 0 _+ʰᶠ_ {x≤0} {x≤0} (a ,, pa) (b ,, pb) = ℚ.+-≤0-≤0-implies-≤0 a b pa pb -- a ≤ 0 → b ≤ 0 → (a + b) ≤ 0 _+ʰʳ_ : ∀{p q} → (x : Number (isReal , p)) → (y : Number (isReal , q)) → PositivityKindInterpretation isReal (+-Positivityʰ isReal p q) (num x +ʳ num y) _+ʰʳ_ {⁇x⁇} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {⁇x⁇} {x#0} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {⁇x⁇} {0≤x} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {⁇x⁇} {0<x} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {⁇x⁇} {x<0} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {⁇x⁇} {x≤0} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {x#0} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {x#0} {x#0} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {x#0} {0≤x} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {x#0} {0<x} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {x#0} {x<0} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {x#0} {x≤0} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {0≤x} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {0≤x} {x#0} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {0≤x} {0≤x} (a ,, pa) (b ,, pb) = ℝ.+-0≤-0≤-implies-0≤ a b pa pb -- 0 ≤ a → 0 ≤ b → 0 ≤ a + b _+ʰʳ_ {0≤x} {0<x} (a ,, pa) (b ,, pb) = ℝ.+-0≤-0<-implies-0< a b pa pb -- 0 ≤ a → 0 < b → 0 < a + b _+ʰʳ_ {0≤x} {x<0} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {0≤x} {x≤0} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {0<x} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {0<x} {x#0} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {0<x} {0≤x} (a ,, pa) (b ,, pb) = ℝ.+-0<-0≤-implies-0< a b pa pb -- 0 < a → 0 ≤ b → 0 < a + b _+ʰʳ_ {0<x} {0<x} (a ,, pa) (b ,, pb) = ℝ.+-0<-0<-implies-0< a b pa pb -- 0 < a → 0 < b → 0 < a + b _+ʰʳ_ {0<x} {x<0} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {0<x} {x≤0} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {x<0} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {x<0} {x#0} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {x<0} {0≤x} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {x<0} {0<x} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {x<0} {x<0} (a ,, pa) (b ,, pb) = ℝ.+-<0-<0-implies-<0 a b pa pb -- a < 0 → b < 0 → (a + b) < 0 _+ʰʳ_ {x<0} {x≤0} (a ,, pa) (b ,, pb) = ℝ.+-<0-≤0-implies-<0 a b pa pb -- a < 0 → b ≤ 0 → (a + b) < 0 _+ʰʳ_ {x≤0} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {x≤0} {x#0} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {x≤0} {0≤x} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {x≤0} {0<x} (a ,, pa) (b ,, pb) = lift tt _+ʰʳ_ {x≤0} {x<0} (a ,, pa) (b ,, pb) = ℝ.+-≤0-<0-implies-<0 a b pa pb -- a ≤ 0 → b < 0 → (a + b) < 0 _+ʰʳ_ {x≤0} {x≤0} (a ,, pa) (b ,, pb) = ℝ.+-≤0-≤0-implies-≤0 a b pa pb -- a ≤ 0 → b ≤ 0 → (a + b) ≤ 0 _+ʰᶜ_ : ∀{p q} → (x : Number (isComplex , p)) → (y : Number (isComplex , q)) → PositivityKindInterpretation isComplex (+-Positivityʰ isComplex p q) (num x +ᶜ num y) _+ʰᶜ_ x y = lift tt _·ʰⁿ_ : ∀{p q} → (x : Number (isNat , p)) → (y : Number (isNat , q)) → PositivityKindInterpretation isNat (·-Positivityʰ isNat p q) (num x ·ⁿ num y) _·ʰⁿ_ {⁇x⁇} {⁇x⁇} (a ,, pa) (b ,, pb) = tt _·ʰⁿ_ {⁇x⁇} {x#0} (a ,, pa) (b ,, pb) = tt _·ʰⁿ_ {⁇x⁇} {0≤x} (a ,, pa) (b ,, pb) = tt _·ʰⁿ_ {⁇x⁇} {0<x} (a ,, pa) (b ,, pb) = tt _·ʰⁿ_ {⁇x⁇} {x≤0} (a ,, pa) (b ,, pb) = tt _·ʰⁿ_ {x#0} {⁇x⁇} (a ,, pa) (b ,, pb) = tt _·ʰⁿ_ {x#0} {x#0} (a ,, pa) (b ,, pb) = ℕ.·-#0-#0-implies-#0 a b pa pb -- a # 0 → b # 0 → (a · b) # 0 _·ʰⁿ_ {x#0} {0≤x} (a ,, pa) (b ,, pb) = tt _·ʰⁿ_ {x#0} {0<x} (a ,, pa) (b ,, pb) = ℕ.·-#0-0<-implies-#0 a b pa pb -- a # 0 → 0 < b → (a · b) # 0 _·ʰⁿ_ {x#0} {x≤0} (a ,, pa) (b ,, pb) = tt _·ʰⁿ_ {0≤x} {⁇x⁇} (a ,, pa) (b ,, pb) = tt _·ʰⁿ_ {0≤x} {x#0} (a ,, pa) (b ,, pb) = tt _·ʰⁿ_ {0≤x} {0≤x} (a ,, pa) (b ,, pb) = ℕ.·-0≤-0≤-implies-0≤ a b pa pb -- 0 ≤ a → 0 ≤ b → 0 ≤ (a · b) _·ʰⁿ_ {0≤x} {0<x} (a ,, pa) (b ,, pb) = ℕ.·-0≤-0<-implies-0≤ a b pa pb -- 0 ≤ a → 0 < b → 0 ≤ (a · b) _·ʰⁿ_ {0≤x} {x≤0} (a ,, pa) (b ,, pb) = ℕ.·-0≤-≤0-implies-≤0 a b pa pb -- 0 ≤ a → b ≤ 0 → (a · b) ≤ 0 _·ʰⁿ_ {0<x} {⁇x⁇} (a ,, pa) (b ,, pb) = tt _·ʰⁿ_ {0<x} {x#0} (a ,, pa) (b ,, pb) = ℕ.·-0<-#0-implies-#0 a b pa pb -- 0 < a → b # 0 → (a · b) # 0 _·ʰⁿ_ {0<x} {0≤x} (a ,, pa) (b ,, pb) = ℕ.·-0<-0≤-implies-0≤ a b pa pb -- 0 < a → 0 ≤ b → 0 ≤ (a · b) _·ʰⁿ_ {0<x} {0<x} (a ,, pa) (b ,, pb) = ℕ.·-0<-0<-implies-0< a b pa pb -- 0 < a → 0 < b → 0 < (a · b) _·ʰⁿ_ {0<x} {x≤0} (a ,, pa) (b ,, pb) = ℕ.·-0<-≤0-implies-≤0 a b pa pb -- 0 < a → b ≤ 0 → (a · b) ≤ 0 _·ʰⁿ_ {x≤0} {⁇x⁇} (a ,, pa) (b ,, pb) = tt _·ʰⁿ_ {x≤0} {x#0} (a ,, pa) (b ,, pb) = tt _·ʰⁿ_ {x≤0} {0≤x} (a ,, pa) (b ,, pb) = ℕ.·-≤0-0≤-implies-≤0 a b pa pb -- a ≤ 0 → 0 ≤ b → (a · b) ≤ 0 _·ʰⁿ_ {x≤0} {0<x} (a ,, pa) (b ,, pb) = ℕ.·-≤0-0<-implies-≤0 a b pa pb -- a ≤ 0 → 0 < b → (a · b) ≤ 0 _·ʰⁿ_ {x≤0} {x≤0} (a ,, pa) (b ,, pb) = ℕ.·-≤0-≤0-implies-0≤ a b pa pb -- a ≤ 0 → b ≤ 0 → 0 ≤ (a · b) _·ʰᶻ_ : ∀{p q} → (x : Number (isInt , p)) → (y : Number (isInt , q)) → PositivityKindInterpretation isInt (·-Positivityʰ isInt p q) (num x ·ᶻ num y) _·ʰᶻ_ {⁇x⁇} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰᶻ_ {⁇x⁇} {x#0} (a ,, pa) (b ,, pb) = lift tt _·ʰᶻ_ {⁇x⁇} {0≤x} (a ,, pa) (b ,, pb) = lift tt _·ʰᶻ_ {⁇x⁇} {0<x} (a ,, pa) (b ,, pb) = lift tt _·ʰᶻ_ {⁇x⁇} {x<0} (a ,, pa) (b ,, pb) = lift tt _·ʰᶻ_ {⁇x⁇} {x≤0} (a ,, pa) (b ,, pb) = lift tt _·ʰᶻ_ {x#0} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰᶻ_ {x#0} {x#0} (a ,, pa) (b ,, pb) = ℤ.·-#0-#0-implies-#0 a b pa pb -- a # 0 → b # 0 → (a · b) # 0 _·ʰᶻ_ {x#0} {0≤x} (a ,, pa) (b ,, pb) = lift tt _·ʰᶻ_ {x#0} {0<x} (a ,, pa) (b ,, pb) = ℤ.·-#0-0<-implies-#0 a b pa pb -- a # 0 → 0 < b → (a · b) # 0 _·ʰᶻ_ {x#0} {x<0} (a ,, pa) (b ,, pb) = ℤ.·-#0-<0-implies-#0 a b pa pb -- a # 0 → b < 0 → (a · b) # 0 _·ʰᶻ_ {x#0} {x≤0} (a ,, pa) (b ,, pb) = lift tt _·ʰᶻ_ {0≤x} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰᶻ_ {0≤x} {x#0} (a ,, pa) (b ,, pb) = lift tt _·ʰᶻ_ {0≤x} {0≤x} (a ,, pa) (b ,, pb) = ℤ.·-0≤-0≤-implies-0≤ a b pa pb -- 0 ≤ a → 0 ≤ b → 0 ≤ (a · b) _·ʰᶻ_ {0≤x} {0<x} (a ,, pa) (b ,, pb) = ℤ.·-0≤-0<-implies-0≤ a b pa pb -- 0 ≤ a → 0 < b → 0 ≤ (a · b) _·ʰᶻ_ {0≤x} {x<0} (a ,, pa) (b ,, pb) = ℤ.·-0≤-<0-implies-≤0 a b pa pb -- 0 ≤ a → b < 0 → (a · b) ≤ 0 _·ʰᶻ_ {0≤x} {x≤0} (a ,, pa) (b ,, pb) = ℤ.·-0≤-≤0-implies-≤0 a b pa pb -- 0 ≤ a → b ≤ 0 → (a · b) ≤ 0 _·ʰᶻ_ {0<x} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰᶻ_ {0<x} {x#0} (a ,, pa) (b ,, pb) = ℤ.·-0<-#0-implies-#0 a b pa pb -- 0 < a → b # 0 → (a · b) # 0 _·ʰᶻ_ {0<x} {0≤x} (a ,, pa) (b ,, pb) = ℤ.·-0<-0≤-implies-0≤ a b pa pb -- 0 < a → 0 ≤ b → 0 ≤ (a · b) _·ʰᶻ_ {0<x} {0<x} (a ,, pa) (b ,, pb) = ℤ.·-0<-0<-implies-0< a b pa pb -- 0 < a → 0 < b → 0 < (a · b) _·ʰᶻ_ {0<x} {x<0} (a ,, pa) (b ,, pb) = ℤ.·-0<-<0-implies-<0 a b pa pb -- 0 < a → b < 0 → (a · b) < 0 _·ʰᶻ_ {0<x} {x≤0} (a ,, pa) (b ,, pb) = ℤ.·-0<-≤0-implies-≤0 a b pa pb -- 0 < a → b ≤ 0 → (a · b) ≤ 0 _·ʰᶻ_ {x<0} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰᶻ_ {x<0} {x#0} (a ,, pa) (b ,, pb) = ℤ.·-<0-#0-implies-#0 a b pa pb -- a < 0 → b # 0 → (a · b) # 0 _·ʰᶻ_ {x<0} {0≤x} (a ,, pa) (b ,, pb) = ℤ.·-<0-0≤-implies-≤0 a b pa pb -- a < 0 → 0 ≤ b → (a · b) ≤ 0 _·ʰᶻ_ {x<0} {0<x} (a ,, pa) (b ,, pb) = ℤ.·-<0-0<-implies-<0 a b pa pb -- a < 0 → 0 < b → (a · b) < 0 _·ʰᶻ_ {x<0} {x<0} (a ,, pa) (b ,, pb) = ℤ.·-<0-<0-implies-0< a b pa pb -- a < 0 → b < 0 → 0 < (a · b) _·ʰᶻ_ {x<0} {x≤0} (a ,, pa) (b ,, pb) = ℤ.·-<0-≤0-implies-0≤ a b pa pb -- a < 0 → b ≤ 0 → 0 ≤ (a · b) _·ʰᶻ_ {x≤0} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰᶻ_ {x≤0} {x#0} (a ,, pa) (b ,, pb) = lift tt _·ʰᶻ_ {x≤0} {0≤x} (a ,, pa) (b ,, pb) = ℤ.·-≤0-0≤-implies-≤0 a b pa pb -- a ≤ 0 → 0 ≤ b → (a · b) ≤ 0 _·ʰᶻ_ {x≤0} {0<x} (a ,, pa) (b ,, pb) = ℤ.·-≤0-0<-implies-≤0 a b pa pb -- a ≤ 0 → 0 < b → (a · b) ≤ 0 _·ʰᶻ_ {x≤0} {x<0} (a ,, pa) (b ,, pb) = ℤ.·-≤0-<0-implies-0≤ a b pa pb -- a ≤ 0 → b < 0 → 0 ≤ (a · b) _·ʰᶻ_ {x≤0} {x≤0} (a ,, pa) (b ,, pb) = ℤ.·-≤0-≤0-implies-0≤ a b pa pb -- a ≤ 0 → b ≤ 0 → 0 ≤ (a · b) _·ʰᶠ_ : ∀{p q} → (x : Number (isRat , p)) → (y : Number (isRat , q)) → PositivityKindInterpretation isRat (·-Positivityʰ isRat p q) (num x ·ᶠ num y) _·ʰᶠ_ {⁇x⁇} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰᶠ_ {⁇x⁇} {x#0} (a ,, pa) (b ,, pb) = lift tt _·ʰᶠ_ {⁇x⁇} {0≤x} (a ,, pa) (b ,, pb) = lift tt _·ʰᶠ_ {⁇x⁇} {0<x} (a ,, pa) (b ,, pb) = lift tt _·ʰᶠ_ {⁇x⁇} {x<0} (a ,, pa) (b ,, pb) = lift tt _·ʰᶠ_ {⁇x⁇} {x≤0} (a ,, pa) (b ,, pb) = lift tt _·ʰᶠ_ {x#0} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰᶠ_ {x#0} {x#0} (a ,, pa) (b ,, pb) = ℚ.·-#0-#0-implies-#0 a b pa pb -- a # 0 → b # 0 → (a · b) # 0 _·ʰᶠ_ {x#0} {0≤x} (a ,, pa) (b ,, pb) = lift tt _·ʰᶠ_ {x#0} {0<x} (a ,, pa) (b ,, pb) = ℚ.·-#0-0<-implies-#0 a b pa pb -- a # 0 → 0 < b → (a · b) # 0 _·ʰᶠ_ {x#0} {x<0} (a ,, pa) (b ,, pb) = ℚ.·-#0-<0-implies-#0 a b pa pb -- a # 0 → b < 0 → (a · b) # 0 _·ʰᶠ_ {x#0} {x≤0} (a ,, pa) (b ,, pb) = lift tt _·ʰᶠ_ {0≤x} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰᶠ_ {0≤x} {x#0} (a ,, pa) (b ,, pb) = lift tt _·ʰᶠ_ {0≤x} {0≤x} (a ,, pa) (b ,, pb) = ℚ.·-0≤-0≤-implies-0≤ a b pa pb -- 0 ≤ a → 0 ≤ b → 0 ≤ (a · b) _·ʰᶠ_ {0≤x} {0<x} (a ,, pa) (b ,, pb) = ℚ.·-0≤-0<-implies-0≤ a b pa pb -- 0 ≤ a → 0 < b → 0 ≤ (a · b) _·ʰᶠ_ {0≤x} {x<0} (a ,, pa) (b ,, pb) = ℚ.·-0≤-<0-implies-≤0 a b pa pb -- 0 ≤ a → b < 0 → (a · b) ≤ 0 _·ʰᶠ_ {0≤x} {x≤0} (a ,, pa) (b ,, pb) = ℚ.·-0≤-≤0-implies-≤0 a b pa pb -- 0 ≤ a → b ≤ 0 → (a · b) ≤ 0 _·ʰᶠ_ {0<x} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰᶠ_ {0<x} {x#0} (a ,, pa) (b ,, pb) = ℚ.·-0<-#0-implies-#0 a b pa pb -- 0 < a → b # 0 → (a · b) # 0 _·ʰᶠ_ {0<x} {0≤x} (a ,, pa) (b ,, pb) = ℚ.·-0<-0≤-implies-0≤ a b pa pb -- 0 < a → 0 ≤ b → 0 ≤ (a · b) _·ʰᶠ_ {0<x} {0<x} (a ,, pa) (b ,, pb) = ℚ.·-0<-0<-implies-0< a b pa pb -- 0 < a → 0 < b → 0 < (a · b) _·ʰᶠ_ {0<x} {x<0} (a ,, pa) (b ,, pb) = ℚ.·-0<-<0-implies-<0 a b pa pb -- 0 < a → b < 0 → (a · b) < 0 _·ʰᶠ_ {0<x} {x≤0} (a ,, pa) (b ,, pb) = ℚ.·-0<-≤0-implies-≤0 a b pa pb -- 0 < a → b ≤ 0 → (a · b) ≤ 0 _·ʰᶠ_ {x<0} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰᶠ_ {x<0} {x#0} (a ,, pa) (b ,, pb) = ℚ.·-<0-#0-implies-#0 a b pa pb -- a < 0 → b # 0 → (a · b) # 0 _·ʰᶠ_ {x<0} {0≤x} (a ,, pa) (b ,, pb) = ℚ.·-<0-0≤-implies-≤0 a b pa pb -- a < 0 → 0 ≤ b → (a · b) ≤ 0 _·ʰᶠ_ {x<0} {0<x} (a ,, pa) (b ,, pb) = ℚ.·-<0-0<-implies-<0 a b pa pb -- a < 0 → 0 < b → (a · b) < 0 _·ʰᶠ_ {x<0} {x<0} (a ,, pa) (b ,, pb) = ℚ.·-<0-<0-implies-0< a b pa pb -- a < 0 → b < 0 → 0 < (a · b) _·ʰᶠ_ {x<0} {x≤0} (a ,, pa) (b ,, pb) = ℚ.·-<0-≤0-implies-0≤ a b pa pb -- a < 0 → b ≤ 0 → 0 ≤ (a · b) _·ʰᶠ_ {x≤0} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰᶠ_ {x≤0} {x#0} (a ,, pa) (b ,, pb) = lift tt _·ʰᶠ_ {x≤0} {0≤x} (a ,, pa) (b ,, pb) = ℚ.·-≤0-0≤-implies-≤0 a b pa pb -- a ≤ 0 → 0 ≤ b → (a · b) ≤ 0 _·ʰᶠ_ {x≤0} {0<x} (a ,, pa) (b ,, pb) = ℚ.·-≤0-0<-implies-≤0 a b pa pb -- a ≤ 0 → 0 < b → (a · b) ≤ 0 _·ʰᶠ_ {x≤0} {x<0} (a ,, pa) (b ,, pb) = ℚ.·-≤0-<0-implies-0≤ a b pa pb -- a ≤ 0 → b < 0 → 0 ≤ (a · b) _·ʰᶠ_ {x≤0} {x≤0} (a ,, pa) (b ,, pb) = ℚ.·-≤0-≤0-implies-0≤ a b pa pb -- a ≤ 0 → b ≤ 0 → 0 ≤ (a · b) _·ʰʳ_ : ∀{p q} → (x : Number (isReal , p)) → (y : Number (isReal , q)) → PositivityKindInterpretation isReal (·-Positivityʰ isReal p q) (num x ·ʳ num y) _·ʰʳ_ {⁇x⁇} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰʳ_ {⁇x⁇} {x#0} (a ,, pa) (b ,, pb) = lift tt _·ʰʳ_ {⁇x⁇} {0≤x} (a ,, pa) (b ,, pb) = lift tt _·ʰʳ_ {⁇x⁇} {0<x} (a ,, pa) (b ,, pb) = lift tt _·ʰʳ_ {⁇x⁇} {x<0} (a ,, pa) (b ,, pb) = lift tt _·ʰʳ_ {⁇x⁇} {x≤0} (a ,, pa) (b ,, pb) = lift tt _·ʰʳ_ {x#0} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰʳ_ {x#0} {x#0} (a ,, pa) (b ,, pb) = ℝ.·-#0-#0-implies-#0 a b pa pb -- a # 0 → b # 0 → (a · b) # 0 _·ʰʳ_ {x#0} {0≤x} (a ,, pa) (b ,, pb) = lift tt _·ʰʳ_ {x#0} {0<x} (a ,, pa) (b ,, pb) = ℝ.·-#0-0<-implies-#0 a b pa pb -- a # 0 → 0 < b → (a · b) # 0 _·ʰʳ_ {x#0} {x<0} (a ,, pa) (b ,, pb) = ℝ.·-#0-<0-implies-#0 a b pa pb -- a # 0 → b < 0 → (a · b) # 0 _·ʰʳ_ {x#0} {x≤0} (a ,, pa) (b ,, pb) = lift tt _·ʰʳ_ {0≤x} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰʳ_ {0≤x} {x#0} (a ,, pa) (b ,, pb) = lift tt _·ʰʳ_ {0≤x} {0≤x} (a ,, pa) (b ,, pb) = ℝ.·-0≤-0≤-implies-0≤ a b pa pb -- 0 ≤ a → 0 ≤ b → 0 ≤ (a · b) _·ʰʳ_ {0≤x} {0<x} (a ,, pa) (b ,, pb) = ℝ.·-0≤-0<-implies-0≤ a b pa pb -- 0 ≤ a → 0 < b → 0 ≤ (a · b) _·ʰʳ_ {0≤x} {x<0} (a ,, pa) (b ,, pb) = ℝ.·-0≤-<0-implies-≤0 a b pa pb -- 0 ≤ a → b < 0 → (a · b) ≤ 0 _·ʰʳ_ {0≤x} {x≤0} (a ,, pa) (b ,, pb) = ℝ.·-0≤-≤0-implies-≤0 a b pa pb -- 0 ≤ a → b ≤ 0 → (a · b) ≤ 0 _·ʰʳ_ {0<x} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰʳ_ {0<x} {x#0} (a ,, pa) (b ,, pb) = ℝ.·-0<-#0-implies-#0 a b pa pb -- 0 < a → b # 0 → (a · b) # 0 _·ʰʳ_ {0<x} {0≤x} (a ,, pa) (b ,, pb) = ℝ.·-0<-0≤-implies-0≤ a b pa pb -- 0 < a → 0 ≤ b → 0 ≤ (a · b) _·ʰʳ_ {0<x} {0<x} (a ,, pa) (b ,, pb) = ℝ.·-0<-0<-implies-0< a b pa pb -- 0 < a → 0 < b → 0 < (a · b) _·ʰʳ_ {0<x} {x<0} (a ,, pa) (b ,, pb) = ℝ.·-0<-<0-implies-<0 a b pa pb -- 0 < a → b < 0 → (a · b) < 0 _·ʰʳ_ {0<x} {x≤0} (a ,, pa) (b ,, pb) = ℝ.·-0<-≤0-implies-≤0 a b pa pb -- 0 < a → b ≤ 0 → (a · b) ≤ 0 _·ʰʳ_ {x<0} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰʳ_ {x<0} {x#0} (a ,, pa) (b ,, pb) = ℝ.·-<0-#0-implies-#0 a b pa pb -- a < 0 → b # 0 → (a · b) # 0 _·ʰʳ_ {x<0} {0≤x} (a ,, pa) (b ,, pb) = ℝ.·-<0-0≤-implies-≤0 a b pa pb -- a < 0 → 0 ≤ b → (a · b) ≤ 0 _·ʰʳ_ {x<0} {0<x} (a ,, pa) (b ,, pb) = ℝ.·-<0-0<-implies-<0 a b pa pb -- a < 0 → 0 < b → (a · b) < 0 _·ʰʳ_ {x<0} {x<0} (a ,, pa) (b ,, pb) = ℝ.·-<0-<0-implies-0< a b pa pb -- a < 0 → b < 0 → 0 < (a · b) _·ʰʳ_ {x<0} {x≤0} (a ,, pa) (b ,, pb) = ℝ.·-<0-≤0-implies-0≤ a b pa pb -- a < 0 → b ≤ 0 → 0 ≤ (a · b) _·ʰʳ_ {x≤0} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰʳ_ {x≤0} {x#0} (a ,, pa) (b ,, pb) = lift tt _·ʰʳ_ {x≤0} {0≤x} (a ,, pa) (b ,, pb) = ℝ.·-≤0-0≤-implies-≤0 a b pa pb -- a ≤ 0 → 0 ≤ b → (a · b) ≤ 0 _·ʰʳ_ {x≤0} {0<x} (a ,, pa) (b ,, pb) = ℝ.·-≤0-0<-implies-≤0 a b pa pb -- a ≤ 0 → 0 < b → (a · b) ≤ 0 _·ʰʳ_ {x≤0} {x<0} (a ,, pa) (b ,, pb) = ℝ.·-≤0-<0-implies-0≤ a b pa pb -- a ≤ 0 → b < 0 → 0 ≤ (a · b) _·ʰʳ_ {x≤0} {x≤0} (a ,, pa) (b ,, pb) = ℝ.·-≤0-≤0-implies-0≤ a b pa pb -- a ≤ 0 → b ≤ 0 → 0 ≤ (a · b) _·ʰᶜ_ : ∀{p q} → (x : Number (isComplex , p)) → (y : Number (isComplex , q)) → PositivityKindInterpretation isComplex (·-Positivityʰ isComplex p q) (num x ·ᶜ num y) _·ʰᶜ_ {⁇x⁇} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰᶜ_ {⁇x⁇} {x#0} (a ,, pa) (b ,, pb) = lift tt _·ʰᶜ_ {x#0} {⁇x⁇} (a ,, pa) (b ,, pb) = lift tt _·ʰᶜ_ {x#0} {x#0} (a ,, pa) (b ,, pb) = ℂ.·-#0-#0-implies-#0 a b pa pb -- a # 0 → b # 0 → (a · b) # 0 open PatternsType -- abs x = max x (- x) abs : ∀{l p} → (x : Number (l , p)) → abs-Types x abs {isNat } {X } (x ,, p) = (absⁿ x ,, 0≤xⁿ x) abs {isNat } {X⁺⁻} (x ,, p) = (absⁿ x ,, ℕ.0≤-#0-implies-0< x (0≤xⁿ x) p) abs {isNat } {X₀⁺} (x ,, p) = (absⁿ x ,, p) abs {isNat } {X⁺ } (x ,, p) = (absⁿ x ,, p) abs {isNat } {X₀⁻} (x ,, p) = (absⁿ x ,, (0ⁿ , (sym $ ≤0→≡0 p))) abs {isInt } {X } (x ,, p) = (absᶻ x ,, {!!}) -- ∀ x → 0 ≤ abs x abs {isInt } {X⁺⁻} (x ,, p) = (absᶻ x ,, {!!}) -- ∀ x → x # 0 → 0 < abs x abs {isInt } {X₀⁺} (x ,, p) = (absᶻ x ,, {!!}) -- ∀ x → 0 ≤ abs x abs {isInt } {X⁺ } (x ,, p) = (absᶻ x ,, {!!}) -- ∀ x → 0 < x → 0 < abs x abs {isInt } {X⁻ } (x ,, p) = (absᶻ x ,, {!!}) -- ∀ x → x < 0 → 0 < abs x abs {isInt } {X₀⁻} (x ,, p) = (absᶻ x ,, {!!}) -- ∀ x → 0 ≤ abs x abs {isRat } {X } (x ,, p) = (absᶠ x ,, {!!}) -- ∀ x → 0 ≤ abs x abs {isRat } {X⁺⁻} (x ,, p) = (absᶠ x ,, {!!}) -- ∀ x → x # 0 → 0 < abs x abs {isRat } {X₀⁺} (x ,, p) = (absᶠ x ,, {!!}) -- ∀ x → 0 ≤ abs x abs {isRat } {X⁺ } (x ,, p) = (absᶠ x ,, {!!}) -- ∀ x → 0 < x → 0 < abs x abs {isRat } {X⁻ } (x ,, p) = (absᶠ x ,, {!!}) -- ∀ x → x < 0 → 0 < abs x abs {isRat } {X₀⁻} (x ,, p) = (absᶠ x ,, {!!}) -- ∀ x → 0 ≤ abs x abs {isReal } {X } (x ,, p) = (absʳ x ,, {!!}) -- ∀ x → 0 ≤ abs x abs {isReal } {X⁺⁻} (x ,, p) = (absʳ x ,, {!!}) -- ∀ x → x # 0 → 0 < abs x abs {isReal } {X₀⁺} (x ,, p) = (absʳ x ,, {!!}) -- ∀ x → 0 ≤ abs x abs {isReal } {X⁺ } (x ,, p) = (absʳ x ,, {!!}) -- ∀ x → 0 < x → 0 < abs x abs {isReal } {X⁻ } (x ,, p) = (absʳ x ,, {!!}) -- ∀ x → x < 0 → 0 < abs x abs {isReal } {X₀⁻} (x ,, p) = (absʳ x ,, {!!}) -- ∀ x → 0 ≤ abs x abs {isComplex} {X } (x ,, p) = (absᶜ x ,, 0≤abs x) abs {isComplex} {X⁺⁻} (x ,, p) = (absᶜ x ,, γ) where pʳ = ℂ.0≤abs x γ : 0ʳ <ʳ absᶜ x γ = ℝ.0≤-#0-implies-0< (absᶜ x) pʳ (ℂ.abs-preserves-#0 x p) -- a < b → ¬(b ≤ a) = ¬¬(a < b) -- 0≤abs : ∀ x → 0ʳ ≤ʳ abs x -- abs-preserves-0 : ∀ x → x ≡ 0f → abs x ≡ 0ʳ -- abs-reflects-0 : ∀ x → abs x ≡ 0ʳ → x ≡ 0f -- abs-preserves-· : ∀ x y → abs (x · y) ≡ (abs x) ·ʳ (abs y) -- #-tight : ∀ x y → ¬(x # y) → x ≡ y -- a ≤ b = ¬(b < a)
{ "alphanum_fraction": 0.4077801298, "avg_line_length": 64.7573033708, "ext": "agda", "hexsha": "7173b518c780c16d4b3367c94e0d904e8afc6c07", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "agda/Number/Operations/Details.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mchristianl/synthetic-reals", "max_issues_repo_path": "agda/Number/Operations/Details.agda", "max_line_length": 164, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "agda/Number/Operations/Details.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 17964, "size": 28817 }
{-# OPTIONS --rewriting #-} {-# OPTIONS --show-implicit #-} module NaturalDeduction-PatternLambdaBug where record ⊤ : Set where data ⊥ : Set where foo : ⦃ _ : ⊤ ⦄ → ⊥ → Set foo = λ {x → {!x!}} {- C-c C-c above generates invalid syntax: foo = λ { } Found an implicit lambda where an explicit lambda was expected when checking that the expression λ {} has type ⊥ → Set Better would have been foo = λ {()} -} -- module DelayMishMash where -- open import Level --public -- using (Level) renaming (zero to lzero; suc to lsuc) -- open import Size public -- open import Prelude.Monad renaming (Monad to RawMonad) -- --open import Category.Monad public -- -- using (RawMonad; module RawMonad) -- open import Data.Empty --public -- using (⊥; ⊥-elim) -- open import Data.List --public -- using (List; []; _∷_; map) -- open import Data.Maybe --public -- using (Maybe; just; nothing) renaming (map to fmap) -- open import Data.Product public -- using (∃; _×_; _,_) renaming (proj₁ to fst; proj₂ to snd) -- --infixr 1 _,_ -- open import Data.Sum --public -- using (_⊎_; [_,_]′) renaming (inj₁ to inl; inj₂ to inr) -- open import Data.Unit --public -- using (⊤) -- open import Function --public -- using (_∘_; case_of_) -- open import Relation.Nullary --public -- using (Dec; yes; no) -- open import Relation.Binary --public -- using (Setoid; module Setoid) -- import Relation.Binary.PreorderReasoning -- module Pre = Relation.Binary.PreorderReasoning -- open import Relation.Binary.PropositionalEquality --public -- using (_≡_; refl; sym; trans; cong; cong₂; subst; module ≡-Reasoning) -- --open ≡-Reasoning renaming (begin_ to proof_) public -- open import Relation.Binary.HeterogeneousEquality --public -- using (_≅_; refl; ≡-to-≅; module ≅-Reasoning) -- renaming (sym to hsym; trans to htrans; cong to hcong; -- cong₂ to hcong₂; subst to hsubst) -- hcong₃ : {A : Set}{B : A → Set}{C : ∀ a → B a → Set}{D : ∀ a b → C a b → Set} -- (f : ∀ a b c → D a b c) -- {a a′ : A} → a ≅ a′ → -- {b : B a}{b′ : B a′} → b ≅ b′ → -- {c : C a b}{c′ : C a′ b′} → c ≅ c′ → -- f a b c ≅ f a′ b′ c′ -- hcong₃ f refl refl refl = refl -- ≅-to-≡ : ∀ {a} {A : Set a} {x y : A} → x ≅ y → x ≡ y -- ≅-to-≡ refl = refl -- mutual -- data Delay (i : Size) (A : Set) : Set where -- now : A → Delay i A -- later : ∞Delay i A → Delay i A -- record ∞Delay (i : Size) (A : Set) : Set where -- coinductive -- field -- force : {j : Size< i} → Delay j A -- open ∞Delay public -- never : ∀{i A} → ∞Delay i A -- force (never {i}) {j} = later (never {j}) -- module Bind where -- mutual -- bindDelay : ∀ {i A B} → Delay i A → (A → Delay i B) → Delay i B -- bindDelay (now a) f = f a -- bindDelay (later a∞) f = later (bind∞Delay a∞ f) -- bind∞Delay : ∀ {i A B} → ∞Delay i A → (A → Delay i B) → ∞Delay i B -- force (bind∞Delay a∞ f) = bindDelay (force a∞) f -- _d>>=_ : ∀ {i A B} → Delay i A → (A → Delay i B) → Delay i B -- _d>>=_ {i} = Bind.bindDelay {i} -- {- -- open import Prelude.Applicative using (Applicative) -- instance delayApplicative : ∀ {i} → Applicative (Delay i) -- Applicative.pure (delayApplicative {i}) x = now x -- Applicative._<*>_ (delayApplicative {i}) (now f) x = x d>>= (now ∘ f) -- Applicative._<*>_ (delayApplicative {i}) (later f) x = {!force f {i}!} -- {- -- Applicative._<*>_ (delayApplicative {i}) f (now x) = {!x!} -- Bind.bindDelay x (λ x₁ → {!!}) -- Applicative._<*>_ (delayApplicative {i}) (now f) (later x) = {!!} -- Bind.bindDelay x (λ x₁ → {!!}) -- Applicative._<*>_ (delayApplicative {i}) (later f) (later x) = {!!} -- Bind.bindDelay x (λ x₁ → {!!}) -- -} -- Applicative.super (delayApplicative {i}) = {!!} -- -} -- {- -- instance delayMonad : ∀ {i} → RawMonad (Delay i) -- delayMonad {i} = record -- { {-return = now -- ; -}_>>=_ = bindDelay {i} -- } where open Bind -- -} -- {- -- module _ {i : Size} where -- open module DelayMonad = RawMonad (delayMonad {i = i}) -- public -- renaming (_⊛_ to _<*>_) -- -} -- open Bind public using () renaming (bind∞Delay to _∞>>=_) -- -- Map for Delay -- dreturn : {i : Size} → {A : Set} → A → Delay i A -- dreturn {i} = Delay.now {i} -- _d<$>_ : ∀ {i A B} (f : A → B) (a : Delay i A) → Delay i B -- f d<$> a = a d>>= λ a → dreturn (f a) -- -- Map for ∞Delay -- _∞<$>_ : ∀ {i A B} (f : A → B) (∞a : ∞Delay i A) → ∞Delay i B -- f ∞<$> ∞a = ∞a ∞>>= λ a → dreturn (f a) -- -- force (f ∞<$> ∞a) = f <$> force ∞a -- -- Double bind -- _=<<2_,_ : ∀ {i A B C} → (A → B → Delay i C) → Delay i A → Delay i B → Delay i C -- f =<<2 x , y = x d>>= λ a → y d>>= λ b → f a b -- mutual -- data _∼_ {i : Size} {A : Set} : (a? b? : Delay ∞ A) → Set where -- ∼now : ∀ a → now a ∼ now a -- ∼later : ∀ {a∞ b∞} (eq : a∞ ∞∼⟨ i ⟩∼ b∞) → later a∞ ∼ later b∞ -- _∼⟨_⟩∼_ = λ {A} a? i b? → _∼_ {i}{A} a? b? -- record _∞∼⟨_⟩∼_ {A} (a∞ : ∞Delay ∞ A) i (b∞ : ∞Delay ∞ A) : Set where -- coinductive -- field -- ∼force : {j : Size< i} → force a∞ ∼⟨ j ⟩∼ force b∞ -- _∞∼_ = λ {i} {A} a∞ b∞ → _∞∼⟨_⟩∼_ {A} a∞ i b∞ -- open _∞∼⟨_⟩∼_ public -- ∼never : ∀{i A} → (never {A = A}) ∞∼⟨ i ⟩∼ never -- ∼force ∼never = ∼later ∼never -- ∼refl : ∀{i A} (a? : Delay ∞ A) → a? ∼⟨ i ⟩∼ a? -- ∞∼refl : ∀{i A} (a∞ : ∞Delay ∞ A) → a∞ ∞∼⟨ i ⟩∼ a∞ -- ∼sym : ∀{i A}{a? b? : Delay ∞ A } → a? ∼⟨ i ⟩∼ b? → b? ∼⟨ i ⟩∼ a? -- ∞∼sym : ∀{i A}{a∞ b∞ : ∞Delay ∞ A} → a∞ ∞∼⟨ i ⟩∼ b∞ → b∞ ∞∼⟨ i ⟩∼ a∞ -- ∼trans : ∀{i A}{a? b? c? : Delay ∞ A} → -- a? ∼⟨ i ⟩∼ b? → b? ∼⟨ i ⟩∼ c? → a? ∼⟨ i ⟩∼ c? -- ∞∼trans : ∀{i A}{a∞ b∞ c∞ : ∞Delay ∞ A} → -- a∞ ∞∼⟨ i ⟩∼ b∞ → b∞ ∞∼⟨ i ⟩∼ c∞ → a∞ ∞∼⟨ i ⟩∼ c∞ -- ∼refl (now a) = ∼now a -- ∼refl (later a∞) = ∼later (∞∼refl a∞) -- ∼force (∞∼refl a∞) = ∼refl (force a∞) -- ∼sym (∼now a) = ∼now a -- ∼sym (∼later eq) = ∼later (∞∼sym eq) -- ∼force (∞∼sym eq) = ∼sym (∼force eq) -- ∼trans (∼now a) (∼now .a) = ∼now a -- ∼trans (∼later eq) (∼later eq′) = ∼later (∞∼trans eq eq′) -- ∼force (∞∼trans eq eq′) = ∼trans (∼force eq) (∼force eq′) -- -- Equality reasoning -- ∼setoid : (i : Size) (A : Set) → Setoid lzero lzero -- ∼setoid i A = record -- { Carrier = Delay ∞ A -- ; _≈_ = _∼_ {i} -- ; isEquivalence = record -- { refl = λ {a?} → ∼refl a? -- ; sym = ∼sym -- ; trans = ∼trans -- } -- } -- ∞∼setoid : (i : Size) (A : Set) → Setoid lzero lzero -- ∞∼setoid i A = record -- { Carrier = ∞Delay ∞ A -- ; _≈_ = _∞∼_ {i} -- ; isEquivalence = record -- { refl = λ {a?} → ∞∼refl a? -- ; sym = ∞∼sym -- ; trans = ∞∼trans -- } -- } -- module ∼-Reasoning {i : Size} {A : Set} where -- open Pre (Setoid.preorder (∼setoid i A)) public -- -- using (begin_; _∎) (_≈⟨⟩_ to _∼⟨⟩_; _≈⟨_⟩_ to _∼⟨_⟩_) -- renaming (_≈⟨⟩_ to _≡⟨⟩_; _≈⟨_⟩_ to _≡⟨_⟩_; _∼⟨_⟩_ to _∼⟨_⟩_; begin_ to proof_) -- module ∞∼-Reasoning {i : Size} {A : Set} where -- open Pre (Setoid.preorder (∞∼setoid i A)) public -- -- using (begin_; _∎) (_≈⟨⟩_ to _∼⟨⟩_; _≈⟨_⟩_ to _∼⟨_⟩_) -- renaming (_≈⟨⟩_ to _≡⟨⟩_; _≈⟨_⟩_ to _≡⟨_⟩_; _∼⟨_⟩_ to _∞∼⟨_⟩_; begin_ to proof_) -- mutual -- bind-assoc : ∀{i A B C} (m : Delay ∞ A) -- {k : A → Delay ∞ B} {l : B → Delay ∞ C} → -- ((m d>>= k) d>>= l) ∼⟨ i ⟩∼ (m d>>= λ a → (k a d>>= l)) -- bind-assoc (now a) = ∼refl _ -- bind-assoc (later a∞) = ∼later (∞bind-assoc a∞) -- ∞bind-assoc : ∀{i A B C} (a∞ : ∞Delay ∞ A) -- {k : A → Delay ∞ B} {l : B → Delay ∞ C} → -- ((a∞ ∞>>= k) ∞>>= l) ∞∼⟨ i ⟩∼ (a∞ ∞>>= λ a → (k a d>>= l)) -- ∼force (∞bind-assoc a∞) = bind-assoc (force a∞) -- bind-cong-l : ∀{i A B}{a? b? : Delay ∞ A} → a? ∼⟨ i ⟩∼ b? → -- (k : A → Delay ∞ B) → (a? d>>= k) ∼⟨ i ⟩∼ (b? d>>= k) -- ∞bind-cong-l : ∀{i A B}{a∞ b∞ : ∞Delay ∞ A} → a∞ ∞∼⟨ i ⟩∼ b∞ → -- (k : A → Delay ∞ B) → (a∞ ∞>>= k) ∞∼⟨ i ⟩∼ (b∞ ∞>>= k) -- bind-cong-r : ∀{i A B}(a? : Delay ∞ A){k l : A → Delay ∞ B} → -- (∀ a → (k a) ∼⟨ i ⟩∼ (l a)) → (a? d>>= k) ∼⟨ i ⟩∼ (a? d>>= l) -- ∞bind-cong-r : ∀{i A B}(a∞ : ∞Delay ∞ A){k l : A → Delay ∞ B} → -- (∀ a → (k a) ∼⟨ i ⟩∼ (l a)) → (a∞ ∞>>= k) ∞∼⟨ i ⟩∼ (a∞ ∞>>= l) -- bind-cong-l (∼now a) k = ∼refl _ -- bind-cong-l (∼later eq) k = ∼later (∞bind-cong-l eq k) -- ∼force (∞bind-cong-l eq k) = bind-cong-l (∼force eq) k -- bind-cong-r (now a) h = h a -- bind-cong-r (later a∞) h = ∼later (∞bind-cong-r a∞ h) -- ∼force (∞bind-cong-r a∞ h) = bind-cong-r (force a∞) h -- open import Prelude.Functor using (Functor; _<$>_) -- {- -- instance FunctorDelay : {i : Size} → Functor (Delay i) -- Functor.fmap (FunctorDelay {i}) {A} {B} f (now x) = {!!} -- Functor.fmap (FunctorDelay {i}) {A} {B} f (later x) = {!!} -- -} -- open import Prelude.Function using (_∘′_) -- map-compose : ∀{i A B C} (a? : Delay ∞ A) {f : A → B} {g : B → C} → -- (g d<$> (f d<$> a?)) ∼⟨ i ⟩∼ ((g ∘ f) d<$> a?) -- map-compose a? = bind-assoc a? -- map-cong : ∀{i A B}{a? b? : Delay ∞ A} (f : A → B) → -- a? ∼⟨ i ⟩∼ b? → (f d<$> a?) ∼⟨ i ⟩∼ (f d<$> b?) -- map-cong f eq = bind-cong-l eq (now ∘ f) -- data _⇓_ {A : Set} : (a? : Delay ∞ A) (a : A) → Set where -- now⇓ : ∀{a} → now a ⇓ a -- later⇓ : ∀{a} {a∞ : ∞Delay ∞ A} → force a∞ ⇓ a → later a∞ ⇓ a -- _⇓ : {A : Set} (x : Delay ∞ A) → Set -- x ⇓ = ∃ λ a → x ⇓ a -- map⇓ : ∀{A B}{a : A}{a? : Delay ∞ A}(f : A → B) → a? ⇓ a → (f d<$> a?) ⇓ f a -- subst∼⇓ : ∀{A}{a? a?′ : Delay ∞ A}{a : A} → a? ⇓ a → a? ∼ a?′ → a?′ ⇓ a -- bind⇓ : ∀{A B}(f : A → Delay ∞ B){?a : Delay ∞ A}{a : A}{b : B} → -- ?a ⇓ a → f a ⇓ b → (?a d>>= f) ⇓ b -- map⇓ f now⇓ = now⇓ -- map⇓ f (later⇓ a⇓) = later⇓ (map⇓ f a⇓) -- subst∼⇓ now⇓ (∼now a) = now⇓ -- subst∼⇓ (later⇓ p) (∼later eq) = later⇓ (subst∼⇓ p (∼force eq)) -- bind⇓ f now⇓ q = q -- bind⇓ f (later⇓ p) q = later⇓ (bind⇓ f p q) -- --infixr 6 _⇒_ -- --infixl 1 _,_ -- module CustomPrelude where -- open import Prelude public -- renaming (_==_ to _≟_) -- TODO ask Agda to rename Eq._==_ to Eq._≟_ -- hiding (force) -- needed by ∞Delay -- {-# BUILTIN REWRITE _≡_ #-} -- --{-# DISPLAY Eq._==_ _ = _≟_ #-} -- open import Container.List renaming (_∈_ to _∈C_; lookup∈ to lookup∈C) public -- _∈C?_ : ∀ {ℓ} {A : Set ℓ} ⦃ _ : Eq A ⦄ (a : A) → (xs : List A) → Dec (a ∈C xs) -- a ∈C? [] = no λ () -- a ∈C? (x ∷ xs) with a ≟ x -- … | yes a≡x rewrite a≡x = yes (zero refl) -- … | no a≢x with a ∈C? xs -- … | yes a∈xs = yes (suc a∈xs) -- … | no a∉xs = no (λ {(zero a≡x) → a≢x a≡x ; (suc a∈xs) → a∉xs a∈xs}) -- data _∈_ {ℓ} {A : Set ℓ} (a : A) : List A → Set ℓ -- where -- here : (as : List A) → a ∈ (a ∷ as) -- there : (x : A) {as : List A} → a ∈ as → a ∈ (x ∷ as) -- _∉_ : ∀ {ℓ} {A : Set ℓ} ⦃ _ : Eq A ⦄ (a : A) → (xs : List A) → Set ℓ -- a ∉ xs = ¬ (a ∈ xs) -- _∈?_ : ∀ {ℓ} {A : Set ℓ} ⦃ _ : Eq A ⦄ (a : A) → (xs : List A) → Dec (a ∈ xs) -- a ∈? [] = no λ () -- a ∈? (x ∷ xs) with a ≟ x -- … | yes a≡x rewrite a≡x = yes (here xs) -- … | no a≢x with a ∈? xs -- … | yes a∈xs = yes (there x a∈xs) -- … | no a∉xs = no (λ {(here _) → a≢x refl ; (there _ a∈xs) → a∉xs a∈xs}) -- _⊆_ : ∀ {ℓ} {A : Set ℓ} → List A → List A → Set ℓ -- R ⊆ S = ∀ {x} → x ∈ R → x ∈ S -- _≢_ : ∀ {ℓ} {A : Set ℓ} → A → A → Set ℓ -- x ≢ y = ¬ (x ≡ y) -- infix 0 _↔_ -- _↔_ : {ℓ¹ : Level} → Set ℓ¹ → {ℓ² : Level} → Set ℓ² → Set (ℓ¹ ⊔ ℓ²) -- P ↔ Q = (P → Q) × (Q → P) -- ∃ : ∀ {ℓᴬ ℓᴮ} {A : Set ℓᴬ} (B : A → Set ℓᴮ) → Set (ℓᴬ ⊔ ℓᴮ) -- ∃ = Σ _ -- ∄ : ∀ {ℓᴬ ℓᴮ} {A : Set ℓᴬ} (B : A → Set ℓᴮ) → Set (ℓᴬ ⊔ ℓᴮ) -- ∄ = ¬_ ∘ ∃ -- infixl 4 _⊎_ -- _⊎_ = Either -- --open import Agda.Builtin.Size public -- open import Size public -- open import Control.Monad.State public -- open import Control.Monad.Identity public -- open import Container.Traversable public -- sequence : ∀ {a b} {A : Set a} {F : Set a → Set b} ⦃ _ : Applicative F ⦄ → List (F A) → F ⊤′ -- sequence [] = pure tt -- sequence (x ∷ xs) = x *> sequence xs -- open import Tactic.Nat public -- open import Tactic.Deriving.Eq public -- mutual -- data Delay (i : Size) (A : Set) : Set where -- now : A → Delay i A -- later : ∞Delay i A → Delay i A -- record ∞Delay (i : Size) (A : Set) : Set where -- coinductive -- field -- force : {j : Size< i} → Delay j A -- open ∞Delay public -- module BindDelay -- where -- mutual -- bindDelay : ∀ {i A B} → Delay i A → (A → Delay i B) → Delay i B -- bindDelay (now a) f = f a -- bindDelay (later ∞a) f = later (bind∞Delay ∞a f) -- bind∞Delay : ∀ {i A B} → ∞Delay i A → (A → Delay i B) → ∞Delay i B -- force (bind∞Delay ∞a f) = bindDelay (force ∞a) f -- module _ -- where -- open BindDelay -- open BindDelay public using () renaming (bind∞Delay to _∞>>=_) -- instance FunctorDelay : {i : Size} → Functor (Delay i) -- Functor.fmap FunctorDelay f x = bindDelay x $ now ∘ f -- instance ApplicativeDelay : {i : Size} → Applicative (Delay i) -- Applicative.pure ApplicativeDelay x = now x -- Applicative._<*>_ ApplicativeDelay (now f) x = f <$> x -- Applicative._<*>_ ApplicativeDelay (later ∞f) x = later ∘ bind∞Delay ∞f $ flip fmap x -- Applicative.super ApplicativeDelay = FunctorDelay -- instance MonadDelay : {i : Size} → Monad (Delay i) -- Monad._>>=_ MonadDelay = bindDelay -- Monad.super MonadDelay = ApplicativeDelay -- mutual -- data _∼_ {i : Size} {A : Set} : (a? b? : Delay ∞ A) → Set where -- ∼now : ∀ a → now a ∼ now a -- ∼later : ∀ {a∞ b∞} (eq : a∞ ∞∼⟨ i ⟩∼ b∞) → later a∞ ∼ later b∞ -- _∼⟨_⟩∼_ = λ {A} a? i b? → _∼_ {i}{A} a? b? -- record _∞∼⟨_⟩∼_ {A} (a∞ : ∞Delay ∞ A) i (b∞ : ∞Delay ∞ A) : Set where -- coinductive -- field -- ∼force : {j : Size< i} → force a∞ ∼⟨ j ⟩∼ force b∞ -- open _∞∼⟨_⟩∼_ public -- _∞∼_ = λ {i} {A} a∞ b∞ → _∞∼⟨_⟩∼_ {A} a∞ i b∞ -- mutual -- ∼refl : ∀{i A} (a? : Delay ∞ A) → a? ∼⟨ i ⟩∼ a? -- ∼refl (now a) = ∼now a -- ∼refl (later a∞) = ∼later (∞∼refl a∞) -- ∞∼refl : ∀{i A} (a∞ : ∞Delay ∞ A) → a∞ ∞∼⟨ i ⟩∼ a∞ -- ∼force (∞∼refl a∞) = ∼refl (force a∞) -- mutual -- ∼sym : ∀{i A}{a? b? : Delay ∞ A } → a? ∼⟨ i ⟩∼ b? → b? ∼⟨ i ⟩∼ a? -- ∼sym (∼now a) = ∼now a -- ∼sym (∼later eq) = ∼later (∞∼sym eq) -- ∞∼sym : ∀{i A}{a∞ b∞ : ∞Delay ∞ A} → a∞ ∞∼⟨ i ⟩∼ b∞ → b∞ ∞∼⟨ i ⟩∼ a∞ -- ∼force (∞∼sym eq) = ∼sym (∼force eq) -- mutual -- ∼trans : ∀{i A}{a? b? c? : Delay ∞ A} → -- a? ∼⟨ i ⟩∼ b? → b? ∼⟨ i ⟩∼ c? → a? ∼⟨ i ⟩∼ c? -- ∼trans (∼now a) (∼now .a) = ∼now a -- ∼trans (∼later eq) (∼later eq′) = ∼later (∞∼trans eq eq′) -- ∞∼trans : ∀{i A}{a∞ b∞ c∞ : ∞Delay ∞ A} → -- a∞ ∞∼⟨ i ⟩∼ b∞ → b∞ ∞∼⟨ i ⟩∼ c∞ → a∞ ∞∼⟨ i ⟩∼ c∞ -- ∼force (∞∼trans eq eq′) = ∼trans (∼force eq) (∼force eq′) -- --∼setoid : (i : Size) (A : Set) → Setoid lzero lzero -- --∞∼setoid : (i : Size) (A : Set) → Setoid lzero lzero -- mutual -- bind-assoc : ∀{i A B C} (m : Delay ∞ A) -- {k : A → Delay ∞ B} {l : B → Delay ∞ C} → -- ((m >>= k) >>= l) ∼⟨ i ⟩∼ (m >>= λ a → (k a >>= l)) -- bind-assoc (now a) = ∼refl _ -- bind-assoc (later a∞) = ∼later (∞bind-assoc a∞) -- ∞bind-assoc : ∀{i A B C} (a∞ : ∞Delay ∞ A) -- {k : A → Delay ∞ B} {l : B → Delay ∞ C} → -- ((a∞ ∞>>= k) ∞>>= l) ∞∼⟨ i ⟩∼ (a∞ ∞>>= λ a → (k a >>= l)) -- ∼force (∞bind-assoc a∞) = bind-assoc (force a∞) -- mutual -- bind-cong-l : ∀{i A B}{a? b? : Delay ∞ A} → a? ∼⟨ i ⟩∼ b? → -- (k : A → Delay ∞ B) → (a? >>= k) ∼⟨ i ⟩∼ (b? >>= k) -- bind-cong-l (∼now a) k = ∼refl _ -- bind-cong-l (∼later eq) k = ∼later (∞bind-cong-l eq k) -- ∞bind-cong-l : ∀{i A B}{a∞ b∞ : ∞Delay ∞ A} → a∞ ∞∼⟨ i ⟩∼ b∞ → -- (k : A → Delay ∞ B) → (a∞ ∞>>= k) ∞∼⟨ i ⟩∼ (b∞ ∞>>= k) -- ∼force (∞bind-cong-l eq k) = bind-cong-l (∼force eq) k -- mutual -- bind-cong-r : ∀{i A B}(a? : Delay ∞ A){k l : A → Delay ∞ B} → -- (∀ a → (k a) ∼⟨ i ⟩∼ (l a)) → (a? >>= k) ∼⟨ i ⟩∼ (a? >>= l) -- bind-cong-r (now a) h = h a -- bind-cong-r (later a∞) h = ∼later (∞bind-cong-r a∞ h) -- ∞bind-cong-r : ∀{i A B}(a∞ : ∞Delay ∞ A){k l : A → Delay ∞ B} → -- (∀ a → (k a) ∼⟨ i ⟩∼ (l a)) → (a∞ ∞>>= k) ∞∼⟨ i ⟩∼ (a∞ ∞>>= l) -- ∼force (∞bind-cong-r a∞ h) = bind-cong-r (force a∞) h -- map-compose : ∀{i A B C} (a? : Delay ∞ A) {f : A → B} {g : B → C} → -- (g <$> (f <$> a?)) ∼⟨ i ⟩∼ ((g ∘ f) <$> a?) -- map-compose a? = bind-assoc a? -- map-cong : ∀{i A B}{a? b? : Delay ∞ A} (f : A → B) → -- a? ∼⟨ i ⟩∼ b? → (f <$> a?) ∼⟨ i ⟩∼ (f <$> b?) -- map-cong f eq = bind-cong-l eq (now ∘ f) -- data _⇓_ {A : Set} : (a? : Delay ∞ A) (a : A) → Set where -- now⇓ : ∀{a} → now a ⇓ a -- later⇓ : ∀{a} {a∞ : ∞Delay ∞ A} → force a∞ ⇓ a → later a∞ ⇓ a -- _⇓ : {A : Set} (x : Delay ∞ A) → Set -- x ⇓ = ∃ λ a → x ⇓ a -- map⇓ : ∀{A B}{a : A}{a? : Delay ∞ A}(f : A → B) → a? ⇓ a → (f <$> a?) ⇓ f a -- map⇓ f now⇓ = now⇓ -- map⇓ f (later⇓ a⇓) = later⇓ (map⇓ f a⇓) -- bind⇓ : ∀{A B}(f : A → Delay ∞ B){?a : Delay ∞ A}{a : A}{b : B} → -- ?a ⇓ a → f a ⇓ b → (?a >>= f) ⇓ b -- bind⇓ f now⇓ q = q -- bind⇓ f (later⇓ p) q = later⇓ (bind⇓ f p q) -- infixl 4 _>>=⇓_ -- _>>=⇓_ : ∀{A B}{f : A → Delay ∞ B}{?a : Delay ∞ A}{a : A}{b : B} → -- ?a ⇓ a → f a ⇓ b → (?a >>= f) ⇓ b -- _>>=⇓_ = bind⇓ _ -- infixl 4 _⇓>>=⇓_ -- _⇓>>=⇓_ : ∀{A B}{f : A → Delay ∞ B}{?a : Delay ∞ A}{b : B} → -- (?a⇓ : ?a ⇓) → f (fst ?a⇓) ⇓ b → (?a >>= f) ⇓ b -- _⇓>>=⇓_ (_ , a⇓) = bind⇓ _ a⇓ -- _⇓Dec>>=⇓_else⇓_ : ∀{A B}{f-yes : A → Delay ∞ B}{f-no : ¬ A → Delay ∞ B}{?a : Delay ∞ (Dec A)}{b : B} → -- (?a⇓ : ?a ⇓) → -- ((a : A) → f-yes a ⇓ b) → -- ((¬a : ¬ A) → f-no ¬a ⇓ b) → -- ((?a >>= (λ { (yes y) → f-yes y ; (no n) → f-no n }))) ⇓ b -- (yes y , y⇓) ⇓Dec>>=⇓ fy⇓ else⇓ fn⇓ = y⇓ >>=⇓ fy⇓ y -- (no n , n⇓) ⇓Dec>>=⇓ fy⇓ else⇓ fn⇓ = n⇓ >>=⇓ fn⇓ n -- _⇓DecEq>>=⇓_else⇓_ : ∀{A : Set} {A₁ A₂ : A} {B}{f-yes : A₁ ≡ A₂ → Delay ∞ B}{f-no : A₁ ≢ A₂ → Delay ∞ B}{?a : Delay ∞ (Dec (A₁ ≡ A₂))}{b : B} → -- (?a⇓ : ?a ⇓) → -- ((eq : A₁ ≡ A₂) → f-yes eq ⇓ b) → -- ((¬eq : A₁ ≢ A₂) → f-no ¬eq ⇓ b) → -- ((?a >>= (λ { (yes refl) → f-yes refl ; (no n) → f-no n }))) ⇓ b -- (yes refl , y⇓) ⇓DecEq>>=⇓ fy⇓ else⇓ fn⇓ = y⇓ >>=⇓ fy⇓ refl -- (no n , n⇓) ⇓DecEq>>=⇓ fy⇓ else⇓ fn⇓ = n⇓ >>=⇓ fn⇓ n -- app⇓ : ∀{A}{B}{f? : Delay ∞ (A → B)}{f : A → B}{x? : Delay ∞ A}{x : A} → f? ⇓ f → x? ⇓ x → (f? <*> x?) ⇓ f x -- app⇓ now⇓ now⇓ = now⇓ -- app⇓ now⇓ (later⇓ x?) = later⇓ $ map⇓ _ x? -- app⇓ (later⇓ f?) now⇓ = later⇓ $ bind⇓ _ f? now⇓ -- app⇓ (later⇓ ⇓f) (later⇓ ⇓x) = later⇓ $ bind⇓ _ ⇓f $ later⇓ $ bind⇓ _ ⇓x now⇓ -- subst∼⇓ : ∀{A}{a? a?′ : Delay ∞ A}{a : A} → a? ⇓ a → a? ∼ a?′ → a?′ ⇓ a -- subst∼⇓ now⇓ (∼now a) = now⇓ -- subst∼⇓ (later⇓ p) (∼later eq) = later⇓ (subst∼⇓ p (∼force eq)) -- {- -- traverse⇓' : ∀{A}{B}{f? : A → Delay ∞ B}{T : Set → Set}⦃ _ : Traversable T ⦄{X : T A} → (∀ x → f? x ⇓) → ∀ (x : T A) → traverse f? x ⇓ -- traverse⇓' x₁ x₂ = {!!} , {!!} -- -} -- {- -- traverse⇓ : ∀{A}{B}{f : A → B}{T : Set → Set}⦃ _ : Traversable T ⦄{X : T A} → (∀ x → f? x ⇓) → ∀ (x : T A) → traverse f x ⇓ -- traverse⇓ x₁ x₂ = {!!} , {!!} -- -} -- traverse-list⇓ : ∀{A}{B} (f? : A → Delay ∞ B) → (∀ x → f? x ⇓) → (xs : List A) → traverse f? xs ⇓ -- traverse-list⇓ f? f?⇓ [] = [] , now⇓ -- traverse-list⇓ f? f?⇓ (x ∷ xs) -- with f?⇓ x | traverse-list⇓ f? f?⇓ xs -- … | y , y⇓ | ys , ys⇓ = y ∷ ys , app⇓ (map⇓ _ y⇓) ys⇓ -- {- -- traverse-vec⇓' : ∀{A}{B}{𝑎} (f? : A → Delay ∞ B) → (∀ x → f? x ⇓) → (xs : Vector A 𝑎) → traverse f? xs ⇓ -- traverse-vec⇓' f? f?⇓ [] = [] , now⇓ -- traverse-vec⇓' f? f?⇓ (x ∷ xs) -- with f?⇓ x | traverse-vec⇓' f? f?⇓ xs -- … | y , y⇓ | ys , ys⇓ = y ∷ ys , app⇓ (map⇓ _ y⇓) ys⇓ -- traverse-vec⇓ : ∀{A}{B}{𝑎} (f : A → B) → (xs : Vector (Delay ∞ A) 𝑎) → traverse {!f!} xs ⇓ -- traverse-vec⇓ = {!!} -- -} -- open CustomPrelude -- -- infix 15 _╱_ -- -- record Sequent (A : Set) ⦃ _ : BeFormula A ⦄ : Set -- -- where -- -- constructor _╱_ -- -- field -- -- statement : A -- -- suppositions : List A -- -- open Sequent -- -- foooo : {A : Set} ⦃ bf : BeFormula A ⦄ {-⦃ hs : HasNegation A ⦄-} {-(x : Sequent A)-} → -- -- (∃ λ (x : A) → x ∈ List.[]) → ⊥ -- -- {- -- -- Dec -- -- (-- Either -- -- (Σ A -- -- (λ x₁ → -- -- --Σ -- -- ({-BeFormula.formula bf -}x₁ ∈ -- -- {-map (BeFormula.formula bf)-} [] {-(suppositions x)-}) -- -- {- -- -- (λ _ → -- -- ⊤ -- -- --BeFormula.formula bf (HasNegation.~ hs x₁) ∈ -- -- --map (BeFormula.formula bf) (suppositions x) -- -- )-} -- -- )) -- -- {-(BeFormula.formula bf (statement x) ∈ -- -- map (BeFormula.formula bf) (suppositions x))-}) -- -- -} -- -- foooo = λ {x → {!x!}} -- -- {- -- -- foooo (statement₁ ╱ []) = λ {x → {!x!}} -- no (λ {x → {!x!}}) -- -- foooo (statement₁ ╱ (x ∷ suppositions₁)) = {!!} -- -- -} -- -- -- TruthValue = Bool -- -- -- -- reification of elements of the domain -- -- -- Element = Nat -- -- -- record VariableName : Set -- -- -- where -- -- -- constructor ⟨_⟩ -- -- -- field -- -- -- name : Nat -- -- -- open VariableName -- -- -- instance EqVariableName : Eq VariableName -- -- -- Eq._==_ EqVariableName _ = decEq₁ (cong name) ∘ (_≟_ on name $ _) -- -- -- record FunctionName : Set -- -- -- where -- -- -- constructor ⟨_⟩ -- -- -- field -- -- -- name : Nat -- -- -- open FunctionName -- -- -- instance EqFunctionName : Eq FunctionName -- -- -- Eq._==_ EqFunctionName _ = decEq₁ (cong name) ∘ (_≟_ on name $ _) -- -- -- record PredicateName : Set -- -- -- where -- -- -- constructor ⟨_⟩ -- -- -- field -- -- -- name : Nat -- -- -- open PredicateName -- -- -- instance EqPredicateName : Eq PredicateName -- -- -- Eq._==_ EqPredicateName _ = decEq₁ (cong name) ∘ (_≟_ on name $ _) -- -- -- record Arity : Set -- -- -- where -- -- -- constructor ⟨_⟩ -- -- -- field -- -- -- arity : Nat -- -- -- open Arity -- -- -- instance EqArity : Eq Arity -- -- -- Eq._==_ EqArity _ = decEq₁ (cong arity) ∘ (_≟_ on arity $ _) -- -- -- Vector : Set → Arity → Set -- -- -- Vector A = Vec A ∘ arity -- -- -- record Elements : Set -- -- -- where -- -- -- constructor ⟨_⟩ -- -- -- field -- -- -- {arity} : Arity -- -- -- elements : Vector Element arity -- -- -- open Elements -- -- -- 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} -- -- -- record Interpretation : Set -- -- -- where -- -- -- field -- -- -- μ⟦_⟧ : VariableName → Element -- -- -- 𝑓⟦_⟧ : FunctionName → Elements → Element -- -- -- 𝑃⟦_⟧ : PredicateName → Elements → TruthValue -- -- -- open Interpretation -- -- -- mutual -- -- -- data Term : Set -- -- -- where -- -- -- variable : VariableName → Term -- -- -- function : FunctionName → Terms → Term -- -- -- record Terms : Set -- -- -- where -- -- -- constructor ⟨_⟩ -- -- -- inductive -- -- -- field -- -- -- {arity} : Arity -- -- -- terms : Vector Term arity -- -- -- open Terms -- -- -- termVariable-inj : ∀ {𝑥₁ 𝑥₂} → Term.variable 𝑥₁ ≡ variable 𝑥₂ → 𝑥₁ ≡ 𝑥₂ -- -- -- termVariable-inj refl = refl -- -- -- termFunction-inj₁ : ∀ {𝑓₁ 𝑓₂ τ₁s τ₂s} → Term.function 𝑓₁ τ₁s ≡ function 𝑓₂ τ₂s → 𝑓₁ ≡ 𝑓₂ -- -- -- termFunction-inj₁ refl = refl -- -- -- termFunction-inj₂ : ∀ {𝑓₁ 𝑓₂ τ₁s τ₂s} → Term.function 𝑓₁ τ₁s ≡ function 𝑓₂ τ₂s → τ₁s ≡ τ₂s -- -- -- termFunction-inj₂ refl = refl -- -- -- foo : ∀ a → (ts1 ts2 : Vec Term (arity a)) → (τ₁≡τ₂ : Terms.⟨ ts1 ⟩ ≡ (⟨_⟩ {a} ts2)) → _≡_ {lzero} {Vec Term (arity a)} ts1 ts2 -- -- -- foo a ts1 .ts1 refl = refl -- -- -- mutual -- -- -- EqTerm⇑ : ∀ {i} → (x y : Term) → Delay i ∘ Dec $ x ≡ y -- -- -- EqTerm⇑ (variable _) (variable _) = now (decEq₁ termVariable-inj $ _≟_ _ _) -- -- -- EqTerm⇑ (function 𝑓₁ τ₁s) (function 𝑓₂ τ₂s) = EqTerms⇑ τ₁s τ₂s >>= λ τ₁s≟τ₂s → now $ decEq₂ termFunction-inj₁ termFunction-inj₂ (𝑓₁ ≟ 𝑓₂) τ₁s≟τ₂s -- -- -- EqTerm⇑ (variable _) (function _ _) = now $ no λ () -- -- -- EqTerm⇑ (function _ _) (variable _) = now $ no λ () -- -- -- EqTerms⇑ : ∀ {i} → (x y : Terms) → Delay i ∘ Dec $ x ≡ y -- -- -- EqTerms⇑ (⟨_⟩ {𝑎₁} τ₁s) (⟨_⟩ {𝑎₂} τ₂s) -- -- -- with 𝑎₁ ≟ 𝑎₂ -- -- -- … | no 𝑎₁≢𝑎₂ = now $ no λ {τ₁≡τ₂ → 𝑎₁≢𝑎₂ (cong arity τ₁≡τ₂)} -- -- -- … | yes refl = EqVecTerm⇑ τ₁s τ₂s >>= λ { (yes refl) → now $ yes refl ; (no τ₁s≢τ₂s) → now $ no (λ ⟨τ₁s⟩≡⟨τ₂s⟩ → τ₁s≢τ₂s (foo ⟨ arity 𝑎₁ ⟩ τ₁s τ₂s ⟨τ₁s⟩≡⟨τ₂s⟩)) } -- -- -- EqVecTerm⇑ : ∀ {i} {n} → (x y : Vec Term n) → Delay i ∘ Dec $ x ≡ y -- -- -- EqVecTerm⇑ [] [] = now (yes refl) -- -- -- EqVecTerm⇑ (τ₁ ∷ τ₁s) (τ₂ ∷ τ₂s) = -- -- -- EqTerm⇑ τ₁ τ₂ >>= λ -- -- -- { (yes refl) → EqVecTerm⇑ τ₁s τ₂s >>= λ -- -- -- { (yes refl) → now $ yes refl -- -- -- ; (no τ₁s≢τ₂s) → now $ no λ τ₁₁s≡τ₁₂s → τ₁s≢τ₂s $ vcons-inj-tail τ₁₁s≡τ₁₂s } -- -- -- ; (no τ₁≢τ₂) → now $ no λ τ₁₁s≡τ₂₂s → τ₁≢τ₂ $ vcons-inj-head τ₁₁s≡τ₂₂s } -- -- -- EqVecTerm⇓ : ∀ {n} → (x y : Vec Term n) → EqVecTerm⇑ x y ⇓ -- -- -- EqVecTerm⇓ [] [] = _ , now⇓ -- -- -- EqVecTerm⇓ (variable 𝑥₁ ∷ τ₁s) (variable 𝑥₂ ∷ τ₂s) -- -- -- with 𝑥₁ ≟ 𝑥₂ -- -- -- … | yes refl with EqVecTerm⇓ τ₁s τ₂s -- -- -- EqVecTerm⇓ (variable 𝑥₁ ∷ τ₁s) (variable .𝑥₁ ∷ .τ₁s) | yes refl | (yes refl , snd₁) = _ , snd₁ >>=⇓ now⇓ -- -- -- EqVecTerm⇓ (variable 𝑥₁ ∷ τ₁s) (variable .𝑥₁ ∷ τ₂s) | yes refl | (no x , snd₁) = _ , snd₁ >>=⇓ now⇓ -- -- -- EqVecTerm⇓ (variable 𝑥₁ ∷ τ₁s) (variable 𝑥₂ ∷ τ₂s) | no 𝑥₁≢𝑥₂ = _ , now⇓ -- -- -- EqVecTerm⇓ (variable x ∷ τ₁s) (function x₁ x₂ ∷ τ₂s) = _ , now⇓ -- -- -- EqVecTerm⇓ (function x x₁ ∷ τ₁s) (variable x₂ ∷ τ₂s) = _ , now⇓ -- -- -- EqVecTerm⇓ (function 𝑓₁ (⟨_⟩ {𝑎₁} τ₁s) ∷ τ₁₂s) (function 𝑓₂ (⟨_⟩ {𝑎₂} τ₂s) ∷ τ₂₂s) -- -- -- with 𝑎₁ ≟ 𝑎₂ | 𝑓₁ ≟ 𝑓₂ -- -- -- … | no 𝑎₁≢𝑎₂ | no 𝑓₁≢𝑓₂ = _ , now⇓ -- -- -- … | no 𝑎₁≢𝑎₂ | yes refl = _ , now⇓ -- -- -- … | yes refl | no 𝑓₁≢𝑓₂ -- -- -- with EqVecTerm⇓ τ₁s τ₂s -- -- -- … | (no τ₁s≢τ₂s , τ⇓) = _ , τ⇓ >>=⇓ now⇓ >>=⇓ now⇓ >>=⇓ now⇓ -- -- -- … | (yes refl , τ⇓) = _ , τ⇓ >>=⇓ now⇓ >>=⇓ now⇓ >>=⇓ now⇓ -- -- -- EqVecTerm⇓ (function 𝑓₁ (⟨_⟩ {𝑎₁} τ₁s) ∷ τ₁₂s) (function 𝑓₂ (⟨_⟩ {𝑎₂} τ₂s) ∷ τ₂₂s) | yes refl | yes refl -- -- -- with EqVecTerm⇓ τ₁s τ₂s | EqVecTerm⇓ τ₁₂s τ₂₂s -- -- -- … | (no τ₁s≢τ₂s , τ⇓) | (no τ₁₂s≢τ₂₂s , τs⇓) = _ , τ⇓ >>=⇓ now⇓ >>=⇓ now⇓ >>=⇓ now⇓ -- -- -- … | (yes refl , τ⇓) | (no τ₁₂s≢τ₂₂s , τs⇓) = _ , τ⇓ >>=⇓ now⇓ >>=⇓ now⇓ >>=⇓ (τs⇓ >>=⇓ now⇓) -- -- -- … | (no τ₁s≢τ₂s , τ⇓) | (yes refl , τs⇓) = _ , τ⇓ >>=⇓ now⇓ >>=⇓ now⇓ >>=⇓ now⇓ -- -- -- … | (yes refl , τ⇓) | (yes refl , τs⇓) = _ , τ⇓ >>=⇓ now⇓ >>=⇓ now⇓ >>=⇓ (τs⇓ >>=⇓ now⇓) -- -- -- EqTerms⇓ : (x y : Terms) → EqTerms⇑ x y ⇓ -- -- -- EqTerms⇓ (⟨_⟩ {𝑎₁} τ₁s) (⟨_⟩ {𝑎₂} τ₂s) -- -- -- with 𝑎₁ ≟ 𝑎₂ -- -- -- … | no 𝑎₁≢𝑎₂ = _ , now⇓ -- -- -- … | yes refl -- -- -- with EqVecTerm⇓ τ₁s τ₂s -- -- -- … | (yes refl , τ⇓) = _ , τ⇓ >>=⇓ now⇓ -- -- -- … | (no _ , τ⇓) = _ , τ⇓ >>=⇓ now⇓ -- -- -- EqTerm⇓ : (x y : Term) → EqTerm⇑ x y ⇓ -- -- -- EqTerm⇓ (variable x) (variable x₁) = _ , now⇓ -- -- -- EqTerm⇓ (function _ τ₁s) (function _ τ₂s) -- -- -- with EqTerms⇓ τ₁s τ₂s -- -- -- … | (_ , τ⇓) = _ , τ⇓ >>=⇓ now⇓ -- -- -- EqTerm⇓ (variable x) (function x₁ x₂) = _ , now⇓ -- -- -- EqTerm⇓ (function x x₁) (variable x₂) = _ , now⇓ -- -- -- instance EqTerm : Eq Term -- -- -- EqTerm = record { _==_ = λ x y → fst (EqTerm⇓ x y) } -- -- -- instance EqTerms : Eq Terms -- -- -- Eq._==_ EqTerms x y = fst (EqTerms⇓ x y) -- -- -- mutual -- -- -- τ⇑⟦_⟧ : Interpretation → {i : Size} → Term → Delay i Element -- -- -- τ⇑⟦ I ⟧ (variable 𝑥) = now $ μ⟦ I ⟧ 𝑥 -- -- -- τ⇑⟦ I ⟧ (function 𝑓 τs) = 𝑓⟦ I ⟧ 𝑓 ∘ ⟨_⟩ <$> τs⇑⟦ I ⟧ τs -- -- -- τs⇑⟦_⟧ : Interpretation → {i : Size} → (τs : Terms) → Delay i (Vector Element (arity τs)) -- -- -- τs⇑⟦ I ⟧ ⟨ [] ⟩ = now [] -- -- -- τs⇑⟦ I ⟧ ⟨ τ ∷ τs ⟩ = τ⇑⟦ I ⟧ τ >>= (λ t → τs⇑⟦ I ⟧ ⟨ τs ⟩ >>= λ ts → now (t ∷ ts)) -- -- -- τs⇓⟦_⟧ : (I : Interpretation) → (τs : Terms) → τs⇑⟦ I ⟧ τs ⇓ -- -- -- τs⇓⟦ I ⟧ ⟨ [] ⟩ = _ , now⇓ -- -- -- τs⇓⟦ I ⟧ ⟨ variable 𝑥 ∷ τs ⟩ = _ , τs⇓⟦ I ⟧ ⟨ τs ⟩ ⇓>>=⇓ now⇓ -- -- -- τs⇓⟦ I ⟧ ⟨ function 𝑓₁ τs₁ ∷ τs₂ ⟩ = -- -- -- _ , τs⇓⟦ I ⟧ τs₁ ⇓>>=⇓ now⇓ >>=⇓ (τs⇓⟦ I ⟧ ⟨ τs₂ ⟩ ⇓>>=⇓ now⇓) -- -- -- τ⇓⟦_⟧ : (I : Interpretation) → (τ : Term) → τ⇑⟦ I ⟧ τ ⇓ -- -- -- τ⇓⟦ I ⟧ (variable 𝑥) = _ , now⇓ -- -- -- τ⇓⟦ I ⟧ (function 𝑓 τs) = _ , τs⇓⟦ I ⟧ τs ⇓>>=⇓ now⇓ -- -- -- τ⟦_⟧ : (I : Interpretation) → {i : Size} → (τ : Term) → Element -- -- -- τ⟦ I ⟧ τ = fst (τ⇓⟦ I ⟧ τ) -- -- -- data Formula : Set -- -- -- where -- -- -- atomic : PredicateName → Terms → Formula -- -- -- logical : Formula → -- -- -- Formula → -- -- -- Formula -- -- -- quantified : VariableName → Formula → Formula -- -- -- formulaAtomic-inj₁ : ∀ {𝑃₁ τs₁ 𝑃₂ τs₂} → Formula.atomic 𝑃₁ τs₁ ≡ atomic 𝑃₂ τs₂ → 𝑃₁ ≡ 𝑃₂ -- -- -- formulaAtomic-inj₁ refl = refl -- -- -- formulaAtomic-inj₂ : ∀ {𝑃₁ τs₁ 𝑃₂ τs₂} → Formula.atomic 𝑃₁ τs₁ ≡ atomic 𝑃₂ τs₂ → τs₁ ≡ τs₂ -- -- -- formulaAtomic-inj₂ refl = refl -- -- -- formulaLogical-inj₁ : ∀ {φ₁₁ φ₁₂ φ₂₁ φ₂₂} → Formula.logical φ₁₁ φ₁₂ ≡ logical φ₂₁ φ₂₂ → φ₁₁ ≡ φ₂₁ -- -- -- formulaLogical-inj₁ refl = refl -- -- -- formulaLogical-inj₂ : ∀ {φ₁₁ φ₁₂ φ₂₁ φ₂₂} → Formula.logical φ₁₁ φ₁₂ ≡ logical φ₂₁ φ₂₂ → φ₁₂ ≡ φ₂₂ -- -- -- formulaLogical-inj₂ refl = refl -- -- -- formulaQuantified-inj₁ : ∀ {𝑥₁ φ₁ 𝑥₂ φ₂} → Formula.quantified 𝑥₁ φ₁ ≡ quantified 𝑥₂ φ₂ → 𝑥₁ ≡ 𝑥₂ -- -- -- formulaQuantified-inj₁ refl = refl -- -- -- formulaQuantified-inj₂ : ∀ {𝑥₁ φ₁ 𝑥₂ φ₂} → Formula.quantified 𝑥₁ φ₁ ≡ quantified 𝑥₂ φ₂ → φ₁ ≡ φ₂ -- -- -- formulaQuantified-inj₂ refl = refl -- -- -- instance EqFormula : Eq Formula -- -- -- Eq._==_ EqFormula (atomic 𝑃₁ τs₁) (atomic 𝑃₂ τs₂) = decEq₂ formulaAtomic-inj₁ formulaAtomic-inj₂ (𝑃₁ ≟ 𝑃₂) (τs₁ ≟ τs₂) -- -- -- Eq._==_ EqFormula (logical φ₁₁ φ₁₂) (logical φ₂₁ φ₂₂) = decEq₂ formulaLogical-inj₁ formulaLogical-inj₂ (φ₁₁ ≟ φ₂₁) (φ₁₂ ≟ φ₂₂) -- -- -- Eq._==_ EqFormula (quantified 𝑥₁ φ₁) (quantified 𝑥₂ φ₂) = decEq₂ formulaQuantified-inj₁ formulaQuantified-inj₂ (𝑥₁ ≟ 𝑥₂) (φ₁ ≟ φ₂) -- -- -- Eq._==_ EqFormula (atomic _ _) (logical _ _) = no λ () -- -- -- Eq._==_ EqFormula (atomic _ _) (quantified _ _) = no λ () -- -- -- Eq._==_ EqFormula (logical _ _) (atomic _ _) = no λ () -- -- -- Eq._==_ EqFormula (logical _ _) (quantified _ _) = no λ () -- -- -- Eq._==_ EqFormula (quantified _ _) (atomic _ _) = no λ () -- -- -- Eq._==_ EqFormula (quantified _ _) (logical _ _) = no λ () -- -- -- record HasNegation (A : Set) : Set -- -- -- where -- -- -- field -- -- -- ~ : A → A -- -- -- open HasNegation ⦃ … ⦄ -- -- -- record BeFormula (A : Set) : Set -- -- -- where -- -- -- constructor ⟨_⟩ -- -- -- field -- -- -- formula : A → Formula -- -- -- open BeFormula ⦃ … ⦄ -- -- -- record HasSatisfaction (A : Set) : Set₁ -- -- -- where -- -- -- field -- -- -- _⊨_ : Interpretation → A → Set -- -- -- _⊭_ : Interpretation → A → Set -- -- -- _⊭_ I = ¬_ ∘ I ⊨_ -- -- -- open HasSatisfaction ⦃ … ⦄ -- -- -- record HasDecidableSatisfaction (A : Set) ⦃ _ : HasSatisfaction A ⦄ : Set₁ -- -- -- where -- -- -- field -- -- -- _⊨?_ : (I : Interpretation) → (x : A) → Dec (I ⊨ x) -- -- -- open HasDecidableSatisfaction ⦃ … ⦄ -- -- -- infix 15 _╱_ -- -- -- record Sequent (A : Set) ⦃ _ : BeFormula A ⦄ : Set -- -- -- where -- -- -- constructor _╱_ -- -- -- field -- -- -- statement : A -- -- -- suppositions : List A -- -- -- open Sequent -- -- -- foooo : {A : Set} ⦃ bf : BeFormula A ⦄ {-⦃ hs : HasNegation A ⦄-} (x : Sequent A) → -- -- -- Dec -- -- -- (-- Either -- -- -- (Σ A -- -- -- (λ x₁ → -- -- -- --Σ -- -- -- ({-BeFormula.formula bf -}x₁ ∈ -- -- -- {-map (BeFormula.formula bf)-} (suppositions x)) -- -- -- {- -- -- -- (λ _ → -- -- -- ⊤ -- -- -- --BeFormula.formula bf (HasNegation.~ hs x₁) ∈ -- -- -- --map (BeFormula.formula bf) (suppositions x) -- -- -- )-} -- -- -- )) -- -- -- {-(BeFormula.formula bf (statement x) ∈ -- -- -- map (BeFormula.formula bf) (suppositions x))-}) -- -- -- foooo (statement₁ ╱ []) = no (λ {x → {!x!}}) -- -- -- foooo (statement₁ ╱ (x ∷ suppositions₁)) = {!!} -- -- -- -- record HasValidation (A : Set) : Set₁ -- -- -- -- where -- -- -- -- field -- -- -- -- ⊨_ : A → Set -- -- -- -- ⊭_ : A → Set -- -- -- -- ⊭_ = ¬_ ∘ ⊨_ -- -- -- -- open HasValidation ⦃ … ⦄ -- -- -- -- 𝑃[_♭_] : PredicateName → Terms → Formula -- -- -- -- 𝑃[_♭_] = atomic -- -- -- -- _⊗_ : Formula → Formula → Formula -- -- -- -- _⊗_ = logical -- -- -- -- instance -- -- -- -- HasNegationFormula : HasNegation Formula -- -- -- -- HasNegation.~ HasNegationFormula φ = φ ⊗ φ -- -- -- -- data IsLiteral : Formula → Set -- -- -- -- where -- -- -- -- atomic : (𝑃 : PredicateName) → (τs : Terms) → IsLiteral $ 𝑃[ 𝑃 ♭ τs ] -- -- -- -- logical : (𝑃 : PredicateName) → (τs : Terms) → IsLiteral ∘ ~ $ 𝑃[ 𝑃 ♭ τs ] -- -- -- -- eqIsLiteral : ∀ {φ} → (lf₁ lf₂ : IsLiteral φ) → lf₁ ≡ lf₂ -- -- -- -- eqIsLiteral (atomic 𝑃 τs) (atomic .𝑃 .τs) = refl -- -- -- -- eqIsLiteral (logical 𝑃 τs) (logical .𝑃 .τs) = refl -- -- -- -- instance EqIsLiteral : ∀ {φ} → Eq (IsLiteral φ) -- -- -- -- Eq._==_ EqIsLiteral lf₁ lf₂ = yes (eqIsLiteral lf₁ lf₂) -- -- -- -- record LiteralFormula : Set -- -- -- -- where -- -- -- -- constructor ⟨_⟩ -- -- -- -- field -- -- -- -- {formula} : Formula -- -- -- -- isLiteral : IsLiteral formula -- -- -- -- open LiteralFormula -- -- -- -- instance EqLiteralFormula : Eq LiteralFormula -- -- -- -- Eq._==_ EqLiteralFormula (⟨_⟩ {φ₁} lf₁) (⟨_⟩ {φ₂} lf₂) -- -- -- -- with φ₁ ≟ φ₂ -- -- -- -- … | no φ₁≢φ₂ = no (λ {refl → φ₁≢φ₂ refl}) -- -- -- -- Eq._==_ EqLiteralFormula (⟨_⟩ {φ₁} lf₁) (⟨_⟩ {φ₂} lf₂) | yes refl = case (eqIsLiteral lf₁ lf₂) of λ {refl → yes refl} -- -- -- -- infix 13 _¶_ -- -- -- -- record Problem (A : Set) ⦃ _ : BeFormula A ⦄ : Set -- -- -- -- where -- -- -- -- constructor _¶_ -- -- -- -- field -- -- -- -- inferences : List (Sequent A) -- -- -- -- interest : Sequent A -- -- -- -- open Problem -- -- -- -- record HasSubstantiveDischarge (+ : Set) (- : Set) : Set₁ -- -- -- -- where -- -- -- -- field -- -- -- -- _≽_ : + → - → Set -- -- -- -- open HasSubstantiveDischarge ⦃ … ⦄ -- -- -- -- record HasVacuousDischarge (+ : Set) : Set₁ -- -- -- -- where -- -- -- -- field -- -- -- -- ◁_ : + → Set -- -- -- -- open HasVacuousDischarge ⦃ … ⦄ -- -- -- -- record HasSalvation (A : Set) : Set₁ -- -- -- -- where -- -- -- -- field -- -- -- -- {isVacuouslyDischargable} : Set -- -- -- -- ⦃ hasVacuousDischarge ⦄ : HasVacuousDischarge isVacuouslyDischargable -- -- -- -- ▷_ : A → Set -- -- -- -- open HasSalvation ⦃ … ⦄ -- -- -- -- record HasDecidableSalvation (A : Set) : Set₁ -- -- -- -- where -- -- -- -- field -- -- -- -- ⦃ hasSalvation ⦄ : HasSalvation A -- -- -- -- ▷?_ : (x : A) → Dec $ ▷_ x -- -- -- -- open HasDecidableSalvation ⦃ … ⦄ -- -- -- -- ∀[_♭_] : VariableName → Formula → Formula -- -- -- -- ∀[_♭_] = quantified -- -- -- -- _∧_ : Formula → Formula → Formula -- -- -- -- φ₁ ∧ φ₂ = ~ φ₁ ⊗ ~ φ₂ -- -- -- -- _∨_ : Formula → Formula → Formula -- -- -- -- φ₁ ∨ φ₂ = ~ (φ₁ ⊗ φ₂) -- -- -- -- _⊃_ : Formula → Formula → Formula -- -- -- -- φ₁ ⊃ φ₂ = ~ φ₁ ∨ φ₂ -- -- -- -- _⟷_ : Formula → Formula → Formula -- -- -- -- φ₁ ⟷ φ₂ = (φ₁ ⊗ (φ₂ ⊗ φ₂)) ⊗ ((φ₁ ⊗ φ₁) ⊗ φ₂) -- TODO check that this is logically equivalent to the more verbose, (φ₁ ⊃ φ₂) ∧ (φ₂ ⊃ φ₁) -- -- -- -- record _≞_/_ (𝓘 : Interpretation) (I : Interpretation) (𝑥 : VariableName) : Set -- -- -- -- where -- -- -- -- field -- -- -- -- μEquality : {𝑥′ : VariableName} → 𝑥′ ≢ 𝑥 → μ⟦ 𝓘 ⟧ 𝑥 ≡ μ⟦ I ⟧ 𝑥′ -- -- -- -- 𝑓Equality : (𝑓 : FunctionName) (μs : Elements) → 𝑓⟦ 𝓘 ⟧ 𝑓 μs ≡ 𝑓⟦ I ⟧ 𝑓 μs -- -- -- -- 𝑃Equality : (𝑃 : PredicateName) → (μs : Elements) → 𝑃⟦ 𝓘 ⟧ 𝑃 μs ≡ 𝑃⟦ I ⟧ 𝑃 μs -- -- -- -- instance -- -- -- -- BeFormulaFormula : BeFormula Formula -- -- -- -- BeFormula.formula BeFormulaFormula = id -- -- -- -- BeFormulaLiteralFormula : BeFormula LiteralFormula -- -- -- -- BeFormula.formula BeFormulaLiteralFormula = formula -- -- -- -- instance -- -- -- -- HasNegationLiteralFormula : HasNegation LiteralFormula -- -- -- -- HasNegation.~ HasNegationLiteralFormula ⟨ atomic 𝑃 τs ⟩ = ⟨ logical 𝑃 τs ⟩ -- -- -- -- HasNegation.~ HasNegationLiteralFormula ⟨ logical 𝑃 τs ⟩ = ⟨ atomic 𝑃 τs ⟩ -- -- -- -- HasNegationSequent : {A : Set} ⦃ _ : HasNegation A ⦄ ⦃ _ : BeFormula A ⦄ → HasNegation $ Sequent A -- -- -- -- HasNegation.~ HasNegationSequent ( φᵗ ╱ φˢs ) = ~ φᵗ ╱ φˢs -- -- -- -- instance -- -- -- -- HasSatisfactionList : {A : Set} ⦃ _ : HasSatisfaction A ⦄ → HasSatisfaction $ List A -- -- -- -- HasSatisfaction._⊨_ HasSatisfactionList I [] = ⊤ -- -- -- -- HasSatisfaction._⊨_ HasSatisfactionList I (x ∷ xs) = I ⊨ x × I ⊨ xs -- -- -- -- HasSatisfactionBeFormula : {A : Set} → ⦃ _ : BeFormula A ⦄ → HasSatisfaction A -- -- -- -- HasSatisfaction._⊨_ (HasSatisfactionBeFormula ⦃ beFormula ⦄) = λ I φ → I ⊨φ formula beFormula φ -- -- -- -- where -- -- -- -- _⊨φ_ : Interpretation → Formula → Set -- -- -- -- I ⊨φ (atomic 𝑃 τs) = 𝑃⟦ I ⟧ 𝑃 ⟨ τ⟦ I ⟧ <$> terms τs ⟩ ≡ true -- -- -- -- I ⊨φ (logical φ₁ φ₂) = ¬ I ⊨φ φ₁ × ¬ I ⊨φ φ₂ -- -- -- -- I ⊨φ (quantified 𝑥 φ) = (𝓘 : Interpretation) → 𝓘 ≞ I / 𝑥 → 𝓘 ⊨φ φ -- -- -- -- HasSatisfactionSequent : {A : Set} ⦃ _ : BeFormula A ⦄ → HasSatisfaction $ Sequent A -- -- -- -- HasSatisfaction._⊨_ HasSatisfactionSequent I (φᵗ ╱ φˢs) = I ⊨ φˢs → I ⊨ φᵗ -- -- -- -- instance -- -- -- -- postulate -- -- -- -- HasDecidableSatisfactionFormula : HasDecidableSatisfaction Formula -- -- -- -- instance -- -- -- -- HasValidationBeFormula : {A : Set} ⦃ _ : BeFormula A ⦄ → HasValidation A -- -- -- -- HasValidation.⊨_ HasValidationBeFormula φ = (I : Interpretation) → I ⊨ φ -- -- -- -- HasValidationSequent : {A : Set} ⦃ _ : BeFormula A ⦄ → HasValidation $ Sequent A -- -- -- -- HasValidation.⊨_ HasValidationSequent Φ = (I : Interpretation) → I ⊨ Φ -- -- -- -- HasValidationProblem : {A : Set} ⦃ _ : BeFormula A ⦄ → HasValidation $ Problem A -- -- -- -- HasValidation.⊨_ HasValidationProblem (χs ¶ ι) = (I : Interpretation) → I ⊨ χs → I ⊨ ι -- -- -- -- instance -- -- -- -- HasSubstantiveDischargeBeFormulaBeFormula : {A : Set} ⦃ _ : BeFormula A ⦄ → HasSubstantiveDischarge A A -- -- -- -- HasSubstantiveDischarge._≽_ (HasSubstantiveDischargeBeFormulaBeFormula ⦃ ⟨ beFormula ⟩ ⦄) = _≡_ on beFormula -- _≡_ on (formula beFormula) -- _≡_ -- -- -- -- HasSubstantiveDischargeListBeFormulaBeFormula : {A : Set} ⦃ _ : BeFormula A ⦄ → HasSubstantiveDischarge (List A) A -- -- -- -- HasSubstantiveDischarge._≽_ (HasSubstantiveDischargeListBeFormulaBeFormula ⦃ ⟨ beFormula ⟩ ⦄) +s - = beFormula - ∈ (beFormula <$> +s) -- flip _∈_ -- -- -- -- HasSubstantiveDischargeListFormulaListFormula : {A : Set} ⦃ _ : BeFormula A ⦄ → HasSubstantiveDischarge (List A) (List A) -- -- -- -- HasSubstantiveDischarge._≽_ (HasSubstantiveDischargeListFormulaListFormula ⦃ ⟨ beFormula ⟩ ⦄) = flip $ _⊆_ on fmap beFormula -- flip _⊆_ -- -- -- -- HasSubstantiveDischargeSequentSequent : ∀ {A : Set} ⦃ _ : BeFormula A ⦄ → HasSubstantiveDischarge (Sequent A) (Sequent A) -- -- -- -- HasSubstantiveDischarge._≽_ HasSubstantiveDischargeSequentSequent (+ᵗ ╱ +ᵖs) (-ᵗ ╱ -ᵖs) = +ᵗ ≽ -ᵗ × +ᵖs ≽ -ᵖs -- -- -- -- HasSubstantiveDischargeListSequentSequent : ∀ {A : Set} ⦃ _ : BeFormula A ⦄ → HasSubstantiveDischarge (List $ Sequent A) (Sequent A) -- -- -- -- HasSubstantiveDischarge._≽_ HasSubstantiveDischargeListSequentSequent χs ι = ∃ λ c → (c ∈ χs) × c ≽ ι -- -- -- -- instance -- -- -- -- HasVacuousDischargeList : {A : Set} ⦃ _ : HasSubstantiveDischarge (List A) A ⦄ ⦃ _ : HasNegation A ⦄ → HasVacuousDischarge (List A) -- -- -- -- HasVacuousDischarge.◁_ (HasVacuousDischargeList {A}) xs = ∃ λ (x : A) → xs ≽ x × xs ≽ ~ x -- -- -- -- HasVacuousDischargeSequent : {A : Set} ⦃ _ : BeFormula A ⦄ ⦃ _ : HasNegation A ⦄ → HasVacuousDischarge (Sequent A) -- -- -- -- HasVacuousDischarge.◁_ HasVacuousDischargeSequent (_ ╱ φˢs) = ∃ λ s → (s ∈ φˢs) × (φˢs ≽ s) × (φˢs ≽ ~ s) -- -- -- -- instance -- -- -- -- HasSalvationSequent : {A : Set} ⦃ _ : BeFormula A ⦄ ⦃ _ : HasNegation A ⦄ {-⦃ _ : HasVacuousDischarge $ List A ⦄-} → HasSalvation $ Sequent A -- -- -- -- HasSalvation.isVacuouslyDischargable (HasSalvationSequent {A}) = List A -- -- -- -- HasSalvation.hasVacuousDischarge HasSalvationSequent = HasVacuousDischargeList -- -- -- -- HasSalvation.▷_ HasSalvationSequent (φᵗ ╱ φᵖs) = (◁ φᵖs) ⊎ (φᵖs ≽ φᵗ) -- -- -- -- HasDecidableSalvationSequent : {A : Set} ⦃ bf : BeFormula A ⦄ ⦃ hs : HasNegation A ⦄ -- -- -- -- → HasDecidableSalvation $ Sequent A -- -- -- -- HasDecidableSalvation.hasSalvation HasDecidableSalvationSequent = HasSalvationSequent -- -- -- -- --(HasDecidableSalvation.▷? HasDecidableSalvationSequent) (statement₁ ╱ []) = no (foo2 statement₁) -- -- -- -- HasDecidableSalvation.▷? HasDecidableSalvationSequent = {!!} -- -- -- -- --(HasDecidableSalvation.▷? HasDecidableSalvationSequent) (statement₁ ╱ []) = no (λ {x → {!!}}) -- -- -- -- --(HasDecidableSalvation.▷? HasDecidableSalvationSequent) (statement₁ ╱ (x₂ ∷ suppositions₁)) = {!!} -- -- -- -- -- foo1 : ∀ {A} → ⦃ b : BeFormula A ⦄ ⦃ _ : HasNegation A ⦄ (statement₁ : A) → Σ A -- -- -- -- -- (λ x → -- -- -- -- -- Σ (BeFormula.formula b x ∈ []) -- -- -- -- -- (λ _ → BeFormula.formula b (~ x) ∈ [])) -- -- -- -- -- ⊎ (BeFormula.formula b statement₁ ∈ []) → -- -- -- -- -- ⊥ -- -- -- -- -- foo1 statement₁ (left (fst₁ , () , snd₁)) -- -- -- -- -- foo1 statement₁ (right ()) -- -- -- -- -- foo2 : ∀ {A} → ⦃ b : BeFormula A ⦄ ⦃ _ : HasNegation A ⦄ (statement₁ : A) → ▷ (statement₁ ╱ []) → -- -- -- -- -- ⊥ -- -- -- -- -- foo2 statement₁ (left (fst₁ , () , snd₁)) -- -- -- -- -- foo2 statement₁ (right ())
{ "alphanum_fraction": 0.455495128, "avg_line_length": 38.4407665505, "ext": "agda", "hexsha": "4ae1b7190e6dc5aa22271fdc6c97c3f4f9911d56", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-1/NaturalDeduction-PatternLambdaBug.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-1/NaturalDeduction-PatternLambdaBug.agda", "max_line_length": 173, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-1/NaturalDeduction-PatternLambdaBug.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 19750, "size": 44130 }
------------------------------------------------------------------------ -- Split surjections ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality module Surjection {reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where open Derived-definitions-and-properties eq open import Logical-equivalence using (_⇔_; module _⇔_) renaming (_∘_ to _⊙_) open import Prelude as P hiding (id) renaming (_∘_ to _⊚_) ------------------------------------------------------------------------ -- Split surjections -- The property of being a split surjection. Split-surjective : ∀ {a b} {A : Type a} {B : Type b} → (A → B) → Type (a ⊔ b) Split-surjective f = ∀ y → ∃ λ x → f x ≡ y infix 0 _↠_ -- Split surjections. Note that in this development split surjections -- are often called simply "surjections". record _↠_ {f t} (From : Type f) (To : Type t) : Type (f ⊔ t) where field logical-equivalence : From ⇔ To open _⇔_ logical-equivalence field right-inverse-of : ∀ x → to (from x) ≡ x -- A lemma. from-to : ∀ {x y} → from x ≡ y → to y ≡ x from-to {x} {y} from-x≡y = to y ≡⟨ cong to $ sym from-x≡y ⟩ to (from x) ≡⟨ right-inverse-of x ⟩∎ x ∎ -- The to function is split surjective. split-surjective : Split-surjective to split-surjective = λ y → from y , right-inverse-of y -- Every left inverse of to is pointwise equal to from. left-inverse-unique : (f : To → From) → (∀ x → f (to x) ≡ x) → (∀ x → f x ≡ from x) left-inverse-unique f left x = f x ≡⟨ cong f $ sym $ right-inverse-of _ ⟩ f (to (from x)) ≡⟨ left _ ⟩∎ from x ∎ -- Every right inverse of from is pointwise equal to to. right-inverse-of-from-unique : (f : From → To) → (∀ x → from (f x) ≡ x) → (∀ x → f x ≡ to x) right-inverse-of-from-unique _ right x = sym $ from-to (right x) open _⇔_ logical-equivalence public ------------------------------------------------------------------------ -- Preorder -- _↠_ is a preorder. id : ∀ {a} {A : Type a} → A ↠ A id = record { logical-equivalence = Logical-equivalence.id ; right-inverse-of = refl } infixr 9 _∘_ _∘_ : ∀ {a b c} {A : Type a} {B : Type b} {C : Type c} → B ↠ C → A ↠ B → A ↠ C f ∘ g = record { logical-equivalence = logical-equivalence f ⊙ logical-equivalence g ; right-inverse-of = to∘from } where open _↠_ to∘from : ∀ x → to f (to g (from g (from f x))) ≡ x to∘from = λ x → to f (to g (from g (from f x))) ≡⟨ cong (to f) (right-inverse-of g (from f x)) ⟩ to f (from f x) ≡⟨ right-inverse-of f x ⟩∎ x ∎ -- "Equational" reasoning combinators. infix -1 finally-↠ infixr -2 step-↠ -- For an explanation of why step-↠ is defined in this way, see -- Equality.step-≡. step-↠ : ∀ {a b c} (A : Type a) {B : Type b} {C : Type c} → B ↠ C → A ↠ B → A ↠ C step-↠ _ = _∘_ syntax step-↠ A B↠C A↠B = A ↠⟨ A↠B ⟩ B↠C finally-↠ : ∀ {a b} (A : Type a) (B : Type b) → A ↠ B → A ↠ B finally-↠ _ _ A↠B = A↠B syntax finally-↠ A B A↠B = A ↠⟨ A↠B ⟩□ B □ ------------------------------------------------------------------------ -- Some preservation/respectfulness lemmas -- ∃ preserves surjections. ∃-cong : ∀ {a b₁ b₂} {A : Type a} {B₁ : A → Type b₁} {B₂ : A → Type b₂} → (∀ x → B₁ x ↠ B₂ x) → ∃ B₁ ↠ ∃ B₂ ∃-cong {B₁ = B₁} {B₂} B₁↠B₂ = record { logical-equivalence = record { to = to′ ; from = from′ } ; right-inverse-of = right-inverse-of′ } where open _↠_ to′ : ∃ B₁ → ∃ B₂ to′ = Σ-map P.id (to (B₁↠B₂ _)) from′ : ∃ B₂ → ∃ B₁ from′ = Σ-map P.id (from (B₁↠B₂ _)) right-inverse-of′ : ∀ p → to′ (from′ p) ≡ p right-inverse-of′ = λ p → cong (_,_ (proj₁ p)) (right-inverse-of (B₁↠B₂ (proj₁ p)) _) -- A preservation lemma involving Σ, _↠_ and _⇔_. Σ-cong-⇔ : ∀ {a₁ a₂ b₁ b₂} {A₁ : Type a₁} {A₂ : Type a₂} {B₁ : A₁ → Type b₁} {B₂ : A₂ → Type b₂} (A₁↠A₂ : A₁ ↠ A₂) → (∀ x → B₁ x ⇔ B₂ (_↠_.to A₁↠A₂ x)) → Σ A₁ B₁ ⇔ Σ A₂ B₂ Σ-cong-⇔ {B₂ = B₂} A₁↠A₂ B₁⇔B₂ = record { to = Σ-map (_↠_.to A₁↠A₂) (_⇔_.to (B₁⇔B₂ _)) ; from = Σ-map (_↠_.from A₁↠A₂) (λ {x} y → _⇔_.from (B₁⇔B₂ (_↠_.from A₁↠A₂ x)) (subst B₂ (sym (_↠_.right-inverse-of A₁↠A₂ x)) y)) } -- A generalisation of ∃-cong. Σ-cong : ∀ {a₁ a₂ b₁ b₂} {A₁ : Type a₁} {A₂ : Type a₂} {B₁ : A₁ → Type b₁} {B₂ : A₂ → Type b₂} (A₁↠A₂ : A₁ ↠ A₂) → (∀ x → B₁ x ↠ B₂ (_↠_.to A₁↠A₂ x)) → Σ A₁ B₁ ↠ Σ A₂ B₂ Σ-cong {A₁ = A₁} {A₂} {B₁} {B₂} A₁↠A₂ B₁↠B₂ = record { logical-equivalence = logical-equivalence′ ; right-inverse-of = right-inverse-of′ } where open _↠_ logical-equivalence′ : Σ A₁ B₁ ⇔ Σ A₂ B₂ logical-equivalence′ = Σ-cong-⇔ A₁↠A₂ (logical-equivalence ⊚ B₁↠B₂) abstract right-inverse-of′ : ∀ p → _⇔_.to logical-equivalence′ (_⇔_.from logical-equivalence′ p) ≡ p right-inverse-of′ = λ p → Σ-≡,≡→≡ (_↠_.right-inverse-of A₁↠A₂ (proj₁ p)) (subst B₂ (_↠_.right-inverse-of A₁↠A₂ (proj₁ p)) (to (B₁↠B₂ _) (from (B₁↠B₂ _) (subst B₂ (sym (_↠_.right-inverse-of A₁↠A₂ (proj₁ p))) (proj₂ p)))) ≡⟨ cong (subst B₂ _) $ right-inverse-of (B₁↠B₂ _) _ ⟩ subst B₂ (_↠_.right-inverse-of A₁↠A₂ (proj₁ p)) (subst B₂ (sym (_↠_.right-inverse-of A₁↠A₂ (proj₁ p))) (proj₂ p)) ≡⟨ subst-subst-sym B₂ _ _ ⟩∎ proj₂ p ∎) -- Π A preserves surjections (assuming extensionality). ∀-cong : ∀ {a b₁ b₂} → Extensionality a (b₁ ⊔ b₂) → {A : Type a} {B₁ : A → Type b₁} {B₂ : A → Type b₂} → (∀ x → B₁ x ↠ B₂ x) → ((x : A) → B₁ x) ↠ ((x : A) → B₂ x) ∀-cong {b₁ = b₁} ext B₁↠B₂ = record { logical-equivalence = equiv ; right-inverse-of = right-inverse-of } where equiv = record { to = (_↠_.to ⊚ B₁↠B₂) _ ⊚_ ; from = (_↠_.from ⊚ B₁↠B₂) _ ⊚_ } abstract right-inverse-of : ∀ f → _⇔_.to equiv (_⇔_.from equiv f) ≡ f right-inverse-of = λ f → apply-ext (lower-extensionality lzero b₁ ext) λ x → _↠_.to (B₁↠B₂ x) (_↠_.from (B₁↠B₂ x) (f x)) ≡⟨ _↠_.right-inverse-of (B₁↠B₂ x) (f x) ⟩∎ f x ∎ -- A lemma relating surjections and equality. ↠-≡ : ∀ {a b} {A : Type a} {B : Type b} (A↠B : A ↠ B) {x y : B} → (_↠_.from A↠B x ≡ _↠_.from A↠B y) ↠ (x ≡ y) ↠-≡ A↠B {x} {y} = record { logical-equivalence = record { from = cong from ; to = to′ } ; right-inverse-of = right-inverse-of′ } where open _↠_ A↠B to′ : from x ≡ from y → x ≡ y to′ = λ from-x≡from-y → x ≡⟨ sym $ right-inverse-of _ ⟩ to (from x) ≡⟨ cong to from-x≡from-y ⟩ to (from y) ≡⟨ right-inverse-of _ ⟩∎ y ∎ abstract right-inverse-of′ : ∀ p → to′ (cong from p) ≡ p right-inverse-of′ = elim (λ {x y} x≡y → trans (sym (right-inverse-of x)) ( trans (cong to (cong from x≡y)) ( right-inverse-of y)) ≡ x≡y) (λ x → trans (sym (right-inverse-of x)) ( trans (cong to (cong from (refl x))) ( right-inverse-of x)) ≡⟨ cong (λ p → trans (sym (right-inverse-of x)) (trans (cong to p) (right-inverse-of x))) (cong-refl from) ⟩ trans (sym (right-inverse-of x)) ( trans (cong to (refl (from x))) ( right-inverse-of x)) ≡⟨ cong (λ p → trans (sym (right-inverse-of x)) (trans p (right-inverse-of x))) (cong-refl to) ⟩ trans (sym (right-inverse-of x)) ( trans (refl (to (from x))) ( right-inverse-of x)) ≡⟨ cong (trans (sym _)) (trans-reflˡ _) ⟩ trans (sym (right-inverse-of x)) (right-inverse-of x) ≡⟨ trans-symˡ _ ⟩∎ refl x ∎) -- A "computation rule" for ↠-≡. to-↠-≡-refl : ∀ {a b} {A : Type a} {B : Type b} (A↠B : A ↠ B) {x : B} → _↠_.to (↠-≡ A↠B) (refl (_↠_.from A↠B x)) ≡ refl x to-↠-≡-refl A↠B {x = x} = trans (sym $ _↠_.right-inverse-of A↠B x) (trans (cong (_↠_.to A↠B) (refl (_↠_.from A↠B x))) (_↠_.right-inverse-of A↠B x)) ≡⟨ cong (λ p → trans _ (trans p _)) $ cong-refl _ ⟩ trans (sym $ _↠_.right-inverse-of A↠B x) (trans (refl (_↠_.to A↠B (_↠_.from A↠B x))) (_↠_.right-inverse-of A↠B x)) ≡⟨ cong (trans _) $ trans-reflˡ _ ⟩ trans (sym $ _↠_.right-inverse-of A↠B x) (_↠_.right-inverse-of A↠B x) ≡⟨ trans-symˡ _ ⟩∎ refl x ∎ -- Decidable-equality respects surjections. Decidable-equality-respects : ∀ {a b} {A : Type a} {B : Type b} → A ↠ B → Decidable-equality A → Decidable-equality B Decidable-equality-respects A↠B _≟A_ x y = ⊎-map (to (↠-≡ A↠B)) (λ from-x≢from-y → from-x≢from-y ⊚ from (↠-≡ A↠B)) (from A↠B x ≟A from A↠B y) where open _↠_
{ "alphanum_fraction": 0.4689532201, "avg_line_length": 32.2094594595, "ext": "agda", "hexsha": "5ddbec5f07e10a909bb5876d9133fb8cc147de0f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Surjection.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Surjection.agda", "max_line_length": 130, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Surjection.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 3584, "size": 9534 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Homotopy.Whitehead where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.Pointed open import Cubical.Foundations.GroupoidLaws open import Cubical.Data.Nat open import Cubical.Data.Sigma open import Cubical.Data.Unit open import Cubical.HITs.Susp renaming (toSusp to σ) open import Cubical.HITs.Pushout open import Cubical.HITs.Sn open import Cubical.HITs.Join open import Cubical.HITs.Wedge open import Cubical.HITs.SetTruncation open import Cubical.Homotopy.Group.Base open Iso open 3x3-span joinTo⋁ : ∀ {ℓ ℓ'} {A : Pointed ℓ} {B : Pointed ℓ'} → join (typ A) (typ B) → (Susp (typ A) , north) ⋁ (Susp (typ B) , north) joinTo⋁ (inl x) = inr north joinTo⋁ (inr x) = inl north joinTo⋁ {A = A} {B = B} (push a b i) = ((λ i → inr (σ B b i)) ∙∙ sym (push tt) ∙∙ λ i → inl (σ A a i)) i -- Whitehead product (main definition) [_∣_] : ∀ {ℓ} {X : Pointed ℓ} {n m : ℕ} → (S₊∙ (suc n) →∙ X) → (S₊∙ (suc m) →∙ X) → S₊∙ (suc (n + m)) →∙ X fst ([_∣_] {X = X} {n = n} {m = m} f g) x = _∨→_ (f ∘∙ (inv (IsoSucSphereSusp n) , IsoSucSphereSusp∙ n)) (g ∘∙ (inv (IsoSucSphereSusp m) , IsoSucSphereSusp∙ m)) (joinTo⋁ {A = S₊∙ n} {B = S₊∙ m} (inv (IsoSphereJoin n m) x)) snd ([_∣_] {n = n} {m = m} f g) = cong (_∨→_ (f ∘∙ (inv (IsoSucSphereSusp n) , IsoSucSphereSusp∙ n)) (g ∘∙ (inv (IsoSucSphereSusp m) , IsoSucSphereSusp∙ m))) (cong (joinTo⋁ {A = S₊∙ n} {B = S₊∙ m}) (IsoSphereJoin⁻Pres∙ n m)) ∙ cong (fst g) (IsoSucSphereSusp∙ m) ∙ snd g -- For Sⁿ, Sᵐ with n, m ≥ 2, we can avoid some bureaucracy. We make -- a separate definition and prove it equivalent. [_∣_]-pre : ∀ {ℓ} {X : Pointed ℓ} {n m : ℕ} → (S₊∙ (suc (suc n)) →∙ X) → (S₊∙ (suc (suc m)) →∙ X) → join (typ (S₊∙ (suc n))) (typ (S₊∙ (suc m))) → fst X [_∣_]-pre {n = n} {m = m} f g x = _∨→_ f g (joinTo⋁ {A = S₊∙ (suc n)} {B = S₊∙ (suc m)} x) [_∣_]₂ : ∀ {ℓ} {X : Pointed ℓ} {n m : ℕ} → (S₊∙ (suc (suc n)) →∙ X) → (S₊∙ (suc (suc m)) →∙ X) → S₊∙ (suc ((suc n) + (suc m))) →∙ X fst ([_∣_]₂ {n = n} {m = m} f g) x = [ f ∣ g ]-pre (inv (IsoSphereJoin (suc n) (suc m)) x) snd ([_∣_]₂ {n = n} {m = m} f g) = cong ([ f ∣ g ]-pre) (IsoSphereJoin⁻Pres∙ (suc n) (suc m)) ∙ snd g []≡[]₂ : ∀ {ℓ} {X : Pointed ℓ} {n m : ℕ} → (f : (S₊∙ (suc (suc n)) →∙ X)) → (g : (S₊∙ (suc (suc m)) →∙ X)) → [ f ∣ g ] ≡ [ f ∣ g ]₂ []≡[]₂ {n = n} {m = m} f g = ΣPathP ( (λ i x → _∨→_ (∘∙-idˡ f i) (∘∙-idˡ g i) (joinTo⋁ {A = S₊∙ (suc n)} {B = S₊∙ (suc m)} (inv (IsoSphereJoin (suc n) (suc m)) x))) , (cong (cong (_∨→_ (f ∘∙ idfun∙ _) (g ∘∙ idfun∙ _)) (cong (joinTo⋁ {A = S₊∙ (suc n)} {B = S₊∙ (suc m)}) (IsoSphereJoin⁻Pres∙ (suc n) (suc m))) ∙_) (sym (lUnit (snd g))) ◁ λ j → (λ i → _∨→_ (∘∙-idˡ f j) (∘∙-idˡ g j) ( joinTo⋁ {A = S₊∙ (suc n)} {B = S₊∙ (suc m)} ((IsoSphereJoin⁻Pres∙ (suc n) (suc m)) i))) ∙ snd g)) -- Homotopy group version [_∣_]π' : ∀ {ℓ} {X : Pointed ℓ} {n m : ℕ} → π' (suc n) X → π' (suc m) X → π' (suc (n + m)) X [_∣_]π' = elim2 (λ _ _ → squash₂) λ f g → ∣ [ f ∣ g ] ∣₂ -- We prove that the function joinTo⋁ used in the definition of the whitehead -- product gives an equivalence between (Susp A × Susp B) and the -- appropriate cofibre of joinTo⋁ (last two theorems in the following -- module). module _ (A B : Type) (a₀ : A) (b₀ : B) where private W = joinTo⋁ {A = (A , a₀)} {B = (B , b₀)} A∨B = (Susp A , north) ⋁ (Susp B , north) σB = σ (B , b₀) σA = σ (A , a₀) cofibW = Pushout W λ _ → tt whitehead3x3 : 3x3-span A00 whitehead3x3 = Susp A A02 whitehead3x3 = B A04 whitehead3x3 = Unit A20 whitehead3x3 = B A22 whitehead3x3 = A × B A24 whitehead3x3 = A A40 whitehead3x3 = B A42 whitehead3x3 = B A44 whitehead3x3 = Unit f10 whitehead3x3 _ = south f12 whitehead3x3 = snd f14 whitehead3x3 _ = tt f30 whitehead3x3 = idfun B f32 whitehead3x3 = snd f34 whitehead3x3 _ = tt f01 whitehead3x3 _ = north f21 whitehead3x3 = snd f41 whitehead3x3 = idfun B f03 whitehead3x3 _ = tt f23 whitehead3x3 = fst f43 whitehead3x3 _ = tt H11 whitehead3x3 x = merid (fst x) H13 whitehead3x3 _ = refl H31 whitehead3x3 _ = refl H33 whitehead3x3 _ = refl A0□→A∨B : A0□ whitehead3x3 → A∨B A0□→A∨B (inl x) = inl x A0□→A∨B (inr x) = inr north A0□→A∨B (push a i) = (push tt ∙ λ i → inr (σB a (~ i))) i A∨B→A0□ : A∨B → A0□ whitehead3x3 A∨B→A0□ (inl x) = inl x A∨B→A0□ (inr north) = inl north A∨B→A0□ (inr south) = inl north A∨B→A0□ (inr (merid b i)) = (push b₀ ∙ sym (push b)) i A∨B→A0□ (push a i) = inl north Iso-A0□-⋁ : Iso (A0□ whitehead3x3) A∨B fun Iso-A0□-⋁ = A0□→A∨B inv Iso-A0□-⋁ = A∨B→A0□ rightInv Iso-A0□-⋁ (inl x) = refl rightInv Iso-A0□-⋁ (inr north) = push tt rightInv Iso-A0□-⋁ (inr south) = push tt ∙ λ i → inr (merid b₀ i) rightInv Iso-A0□-⋁ (inr (merid a i)) j = lem j i where lem : PathP (λ i → push tt i ≡ (push tt ∙ (λ i → inr (merid b₀ i))) i) (cong A0□→A∨B (cong A∨B→A0□ λ i → inr (merid a i))) (λ i → inr (merid a i)) lem = (cong-∙ A0□→A∨B (push b₀) (sym (push a)) ∙ cong₂ _∙_ (cong (push tt ∙_) (λ j i → inr (rCancel (merid b₀) j (~ i))) ∙ sym (rUnit (push tt))) (symDistr (push tt) (λ i → inr (σB a (~ i))))) ◁ λ i j → hcomp (λ k → λ { (i = i0) → compPath-filler' (push tt) (compPath-filler (λ i → inr (σB a i)) (sym (push tt)) k) k j ; (i = i1) → inr (merid a j) ; (j = i0) → push tt (i ∨ ~ k) ; (j = i1) → compPath-filler' (push tt) (λ i → inr (merid b₀ i)) k i}) (inr (compPath-filler (merid a) (sym (merid b₀)) (~ i) j)) rightInv Iso-A0□-⋁ (push a i) j = push tt (i ∧ j) leftInv Iso-A0□-⋁ (inl x) = refl leftInv Iso-A0□-⋁ (inr tt) = push b₀ leftInv Iso-A0□-⋁ (push b i) j = help j i where help : PathP (λ i → inl north ≡ push b₀ i) (cong A∨B→A0□ (cong A0□→A∨B (push b))) (push b) help = (cong-∙ A∨B→A0□ (push tt) (λ i → inr (σB b (~ i))) ∙ (λ i → lUnit (sym (cong-∙ (A∨B→A0□ ∘ inr) (merid b) (sym (merid b₀)) i)) (~ i)) ∙ cong sym (cong ((push b₀ ∙ sym (push b)) ∙_) (cong sym (rCancel (push b₀)))) ∙ cong sym (sym (rUnit (push b₀ ∙ sym (push b))))) ◁ λ i j → compPath-filler' (push b₀) (sym (push b)) (~ i) (~ j) Iso-A2□-join : Iso (A2□ whitehead3x3) (join A B) fun Iso-A2□-join (inl x) = inr x fun Iso-A2□-join (inr x) = inl x fun Iso-A2□-join (push (a , b) i) = push a b (~ i) inv Iso-A2□-join (inl x) = inr x inv Iso-A2□-join (inr x) = inl x inv Iso-A2□-join (push a b i) = push (a , b) (~ i) rightInv Iso-A2□-join (inl x) = refl rightInv Iso-A2□-join (inr x) = refl rightInv Iso-A2□-join (push a b i) = refl leftInv Iso-A2□-join (inl x) = refl leftInv Iso-A2□-join (inr x) = refl leftInv Iso-A2□-join (push a i) = refl isContrA4□ : isContr (A4□ whitehead3x3) fst isContrA4□ = inr tt snd isContrA4□ (inl x) = sym (push x) snd isContrA4□ (inr x) = refl snd isContrA4□ (push a i) j = push a (i ∨ ~ j) A4□≃Unit : A4□ whitehead3x3 ≃ Unit A4□≃Unit = isContr→≃Unit isContrA4□ Iso-A□0-Susp : Iso (A□0 whitehead3x3) (Susp A) fun Iso-A□0-Susp (inl x) = x fun Iso-A□0-Susp (inr x) = north fun Iso-A□0-Susp (push a i) = merid a₀ (~ i) inv Iso-A□0-Susp x = inl x rightInv Iso-A□0-Susp x = refl leftInv Iso-A□0-Susp (inl x) = refl leftInv Iso-A□0-Susp (inr x) = (λ i → inl (merid a₀ i)) ∙ push x leftInv Iso-A□0-Susp (push a i) j = hcomp (λ k → λ { (i = i0) → inl (merid a₀ (k ∨ j)) ; (i = i1) → compPath-filler (λ i₁ → inl (merid a₀ i₁)) (push (idfun B a)) k j ; (j = i0) → inl (merid a₀ (~ i ∧ k)) ; (j = i1) → push a (i ∧ k)}) (inl (merid a₀ j)) Iso-A□2-Susp× : Iso (A□2 whitehead3x3) (Susp A × B) fun Iso-A□2-Susp× (inl x) = north , x fun Iso-A□2-Susp× (inr x) = south , x fun Iso-A□2-Susp× (push a i) = merid (fst a) i , (snd a) inv Iso-A□2-Susp× (north , y) = inl y inv Iso-A□2-Susp× (south , y) = inr y inv Iso-A□2-Susp× (merid a i , y) = push (a , y) i rightInv Iso-A□2-Susp× (north , snd₁) = refl rightInv Iso-A□2-Susp× (south , snd₁) = refl rightInv Iso-A□2-Susp× (merid a i , snd₁) = refl leftInv Iso-A□2-Susp× (inl x) = refl leftInv Iso-A□2-Susp× (inr x) = refl leftInv Iso-A□2-Susp× (push a i) = refl Iso-A□4-Susp : Iso (A□4 whitehead3x3) (Susp A) fun Iso-A□4-Susp (inl x) = north fun Iso-A□4-Susp (inr x) = south fun Iso-A□4-Susp (push a i) = merid a i inv Iso-A□4-Susp north = inl tt inv Iso-A□4-Susp south = inr tt inv Iso-A□4-Susp (merid a i) = push a i rightInv Iso-A□4-Susp north = refl rightInv Iso-A□4-Susp south = refl rightInv Iso-A□4-Susp (merid a i) = refl leftInv Iso-A□4-Susp (inl x) = refl leftInv Iso-A□4-Susp (inr x) = refl leftInv Iso-A□4-Susp (push a i) = refl Iso-PushSusp×-Susp×Susp : Iso (Pushout {A = Susp A × B} fst fst) (Susp A × Susp B) Iso-PushSusp×-Susp×Susp = theIso where F : Pushout {A = Susp A × B} fst fst → Susp A × Susp B F (inl x) = x , north F (inr x) = x , north F (push (x , b) i) = x , σB b i G : Susp A × Susp B → Pushout {A = Susp A × B} fst fst G (a , north) = inl a G (a , south) = inr a G (a , merid b i) = push (a , b) i retr : retract F G retr (inl x) = refl retr (inr x) = push (x , b₀) retr (push (a , b) i) j = help j i where help : PathP (λ i → Path (Pushout fst fst) (inl a) (push (a , b₀) i)) (cong G (λ i → a , σB b i)) (push (a , b)) help = cong-∙ (λ x → G (a , x)) (merid b) (sym (merid b₀)) ◁ λ i j → compPath-filler (push (a , b)) (sym (push (a , b₀))) (~ i) j theIso : Iso (Pushout fst fst) (Susp A × Susp B) fun theIso = F inv theIso = G rightInv theIso (a , north) = refl rightInv theIso (a , south) = ΣPathP (refl , merid b₀) rightInv theIso (a , merid b i) j = a , compPath-filler (merid b) (sym (merid b₀)) (~ j) i leftInv theIso = retr Iso-A□○-PushSusp× : Iso (A□○ whitehead3x3) (Pushout {A = Susp A × B} fst fst) Iso-A□○-PushSusp× = pushoutIso _ _ fst fst (isoToEquiv Iso-A□2-Susp×) (isoToEquiv Iso-A□0-Susp) (isoToEquiv Iso-A□4-Susp) (funExt (λ { (inl x) → refl ; (inr x) → merid a₀ ; (push a i) j → help₁ a j i})) (funExt λ { (inl x) → refl ; (inr x) → refl ; (push a i) j → fun Iso-A□4-Susp (rUnit (push (fst a)) (~ j) i)}) where help₁ : (a : A × B) → PathP (λ i → north ≡ merid a₀ i) (cong (fun Iso-A□0-Susp) (cong (f□1 whitehead3x3) (push a))) (merid (fst a)) help₁ a = (cong-∙∙ (fun Iso-A□0-Susp) (λ i → inl (merid (fst a) i)) (push (snd a)) refl) ◁ (λ i j → hcomp (λ k → λ {(i = i1) → merid (fst a) (j ∨ ~ k) ; (j = i0) → merid (fst a) (~ k) ; (j = i1) → merid a₀ i}) (merid a₀ (i ∨ ~ j))) Iso-A□○-Susp×Susp : Iso (A□○ whitehead3x3) (Susp A × Susp B) Iso-A□○-Susp×Susp = compIso Iso-A□○-PushSusp× Iso-PushSusp×-Susp×Susp Iso-A○□-cofibW : Iso (A○□ whitehead3x3) cofibW Iso-A○□-cofibW = pushoutIso _ _ W (λ _ → tt) (isoToEquiv Iso-A2□-join) (isoToEquiv Iso-A0□-⋁) A4□≃Unit (funExt lem) λ _ _ → tt where lem : (x : A2□ whitehead3x3) → A0□→A∨B (f1□ whitehead3x3 x) ≡ W (fun Iso-A2□-join x) lem (inl x) = (λ i → inl (merid a₀ (~ i))) lem (inr x) = refl lem (push (a , b) i) j = help j i where help : PathP (λ i → Path (Pushout (λ _ → north) (λ _ → north)) ((inl (merid a₀ (~ i)))) (inr north)) (cong A0□→A∨B (cong (f1□ whitehead3x3) (push (a , b)))) (cong W (cong (fun Iso-A2□-join) (push (a , b)))) help = (cong-∙∙ A0□→A∨B (λ i → inl (merid a (~ i))) (push b) refl ∙ λ j → (λ i₂ → inl (merid a (~ i₂))) ∙∙ compPath-filler (push tt) (λ i → inr (σB b (~ i))) (~ j) ∙∙ λ i → inr (σB b (~ i ∧ j))) ◁ (λ j → (λ i → inl (sym (compPath-filler (merid a) (sym (merid a₀)) j) i)) ∙∙ push tt ∙∙ λ i → inr (σB b (~ i))) Iso₁-Susp×Susp-cofibW : Iso (Susp A × Susp B) cofibW Iso₁-Susp×Susp-cofibW = compIso (invIso Iso-A□○-Susp×Susp) (compIso (3x3-Iso whitehead3x3) Iso-A○□-cofibW) -- Main iso Iso-Susp×Susp-cofibJoinTo⋁ : Iso (Susp A × Susp B) cofibW Iso-Susp×Susp-cofibJoinTo⋁ = compIso (Σ-cong-iso-snd (λ _ → invSuspIso)) Iso₁-Susp×Susp-cofibW -- The induced function A ∨ B → Susp A × Susp B satisfies -- the following identity Susp×Susp→cofibW≡ : Path (A∨B → Susp A × Susp B) (Iso.inv Iso-Susp×Susp-cofibJoinTo⋁ ∘ inl) ⋁↪ Susp×Susp→cofibW≡ = funExt λ { (inl x) → ΣPathP (refl , (sym (merid b₀))) ; (inr north) → ΣPathP (refl , (sym (merid b₀))) ; (inr south) → refl ; (inr (merid a i)) j → lem₂ a j i ; (push a i) j → north , (merid b₀ (~ j))} where f₁ = fun Iso-PushSusp×-Susp×Susp f₂ = fun Iso-A□○-PushSusp× f₃ = backward-l whitehead3x3 f₄ = fun (Σ-cong-iso-snd (λ _ → invSuspIso)) lem : (b : B) → cong (f₁ ∘ f₂ ∘ f₃) (push b) ≡ (λ i → north , σB b i) lem b = cong (cong f₁) (sym (rUnit (push (north , b)))) lem₂ : (a : B) → PathP (λ i → (north , merid b₀ (~ i)) ≡ (north , south)) (cong (f₄ ∘ f₁ ∘ f₂ ∘ f₃ ∘ A∨B→A0□ ∘ inr) (merid a)) λ i → north , merid a i lem₂ a = cong (cong f₄) (cong-∙ (f₁ ∘ f₂ ∘ f₃) (push b₀) (sym (push a)) ∙∙ cong₂ _∙_ (lem b₀ ∙ (λ j i → north , rCancel (merid b₀) j i)) (cong sym (lem a)) ∙∙ sym (lUnit (λ i₁ → north , σB a (~ i₁)))) ∙ (λ i j → north , cong-∙ invSusp (merid a) (sym (merid b₀)) i (~ j) ) ◁ λ i j → north , compPath-filler (sym (merid a)) (merid b₀) (~ i) (~ j)
{ "alphanum_fraction": 0.4915209675, "avg_line_length": 37.0170316302, "ext": "agda", "hexsha": "2198fdee3bb9b94e757ce7e62f9a346e1236e69e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Homotopy/Whitehead.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Homotopy/Whitehead.agda", "max_line_length": 80, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Homotopy/Whitehead.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 6546, "size": 15214 }
------------------------------------------------------------------------------ -- Data and postulates ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- Are the FOTC natural numbers defined by data and postulates the -- same? module DataPostulate where ------------------------------------------------------------------------------ postulate D : Set zero : D succ : D → D -- The FOTC natural numbers using data. data N : D → Set where zN : N zero sN : ∀ {n} → N n → N (succ n) N-ind : (P : D → Set) → P zero → (∀ {n} → N n → P n → P (succ n)) → ∀ {n} → N n → P n N-ind P P0 h zN = P0 N-ind P P0 h (sN Nn) = h Nn (N-ind P P0 h Nn) -- The FOTC natural numbers using postulates (we chose 'M' by 'Model'). postulate M : D → Set zM : M zero sM : ∀ {n} → M n → M (succ n) M-ind : (P : D → Set) → P zero → (∀ {n} → M n → P n → P (succ n)) → ∀ {n} → M n → P n ------------------------------------------------------------------------------ -- The predicates -- From the data predicate to the postulated one: Using the induction -- principle. nat-D2P : ∀ {n} → N n → M n nat-D2P = N-ind M zM (λ _ Mn → sM Mn) -- From the data predicate to the postulated one: Using pattern -- matching. nat-D2P' : ∀ {n} → N n → M n nat-D2P' zN = zM nat-D2P' (sN Nn) = sM (nat-D2P' Nn) -- From the postulated predicate to the data one. nat-P2D : ∀ {n} → M n → N n nat-P2D = M-ind N zN (λ _ Nn → sN Nn) ------------------------------------------------------------------------------ -- The induction principles -- The postulated inductive principle from the data one. D2P-ind : (P : D → Set) → P zero → (∀ {n} → M n → P n → P (succ n)) → ∀ {n} → M n → P n D2P-ind P P0 ih Mn = N-ind P P0 (λ {_} Nn → ih (nat-D2P Nn)) (nat-P2D Mn) -- The data inductive principle from the postulated one. P2D-ind : (P : D → Set) → P zero → (∀ {n} → N n → P n → P (succ n)) → ∀ {n} → N n → P n P2D-ind P P0 ih Nn = M-ind P P0 (λ {_} Mn → ih (nat-P2D Mn)) (nat-D2P Nn)
{ "alphanum_fraction": 0.430324277, "avg_line_length": 30.4266666667, "ext": "agda", "hexsha": "d4a576932de3da699f1921e2c2cd8505c61b26ec", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/DataPostulate.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/DataPostulate.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/DataPostulate.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 709, "size": 2282 }
import Common.Reflect data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x data Bool : Set where true false : Bool data True : Set where true : True -- Should print names as "quote Bool.true" (making sure to disambiguate) -- and "quote false" rather than "Issue619.Bool.true/false" in error message. not-true : quote Bool.true ≡ quote Bool.false not-true = refl
{ "alphanum_fraction": 0.6835106383, "avg_line_length": 22.1176470588, "ext": "agda", "hexsha": "342e26ece44e074c961cc0fa467b4e010798d648", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_path": "test/fail/Issue619.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_path": "test/fail/Issue619.agda", "max_line_length": 77, "max_stars_count": null, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/fail/Issue619.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 115, "size": 376 }
-- It seems as if our fix for singleton records was not good enough; -- the following code was accepted by Agda 2.2.6. -- Fixed now. module Issue245 where record ⊤ : Set where postulate A : Set x : A record R₁ (P : A → Set) : Set where field f : P x record R₂ : Set₁ where field F : A → Set f : R₁ F record R₃ (R : R₂) : Set where field f : A R : R₂ R = record { F = λ (x : A) → ⊤ ; f = record {} } foo : R₃ R → A foo = R₃.f {_} -- No unsolved metas at the following locations: -- /home/nad/research/dtp/lib/Bug.agda:32,13-14
{ "alphanum_fraction": 0.5933098592, "avg_line_length": 15.7777777778, "ext": "agda", "hexsha": "7b703e070f95077b0b5d7651bc2684ea3d570880", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/agda-kanso", "max_forks_repo_path": "test/succeed/Issue245.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/agda-kanso", "max_issues_repo_path": "test/succeed/Issue245.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/Issue245.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 211, "size": 568 }
open import Agda.Builtin.IO open import Agda.Builtin.Reflection open import Agda.Builtin.Strict open import Agda.Builtin.String open import Agda.Builtin.Unit postulate putStr : String → IO ⊤ {-# FOREIGN GHC import qualified Data.Text.IO #-} {-# COMPILE GHC putStr = Data.Text.IO.putStr #-} {-# COMPILE JS putStr = function (x) { return function(cb) { process.stdout.write(x); cb(0); }; } #-} main : IO ⊤ main = primForce commitTC λ _ → putStr "Success\n"
{ "alphanum_fraction": 0.6861924686, "avg_line_length": 25.1578947368, "ext": "agda", "hexsha": "50c04bf572495e68077782ba7124ec60a6676b95", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Compiler/simple/Issue5421.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Compiler/simple/Issue5421.agda", "max_line_length": 50, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Compiler/simple/Issue5421.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 128, "size": 478 }
{-# OPTIONS --sized-types #-} module SizedTypesFunctionFromSuccSize where open import Common.Size data Nat : {size : Size} → Set where zero : {size : Size} → Nat {↑ size} suc : {size : Size} → Nat {size} → Nat {↑ size} bad : {i : Size} → Nat {↑ i} → Set bad zero = bad zero bad (suc x) = Nat
{ "alphanum_fraction": 0.6032786885, "avg_line_length": 20.3333333333, "ext": "agda", "hexsha": "ddade568ad78cb163f0616341629b0cd0b294b39", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/SizedTypesFunctionFromSuccSize.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/SizedTypesFunctionFromSuccSize.agda", "max_line_length": 50, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/SizedTypesFunctionFromSuccSize.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 100, "size": 305 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties of operations on strings ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.String.Properties where open import Data.Bool.Base using (Bool) import Data.Char.Properties as Charₚ import Data.List.Properties as Listₚ import Data.List.Relation.Binary.Pointwise as Pointwise import Data.List.Relation.Binary.Lex.Strict as StrictLex open import Data.String.Base open import Function open import Relation.Nullary using (yes; no) open import Relation.Nullary.Decidable using (map′; isYes) open import Relation.Binary open import Relation.Binary.PropositionalEquality.Core import Relation.Binary.Construct.On as On import Relation.Binary.PropositionalEquality as PropEq ------------------------------------------------------------------------ -- Primitive properties open import Agda.Builtin.String.Properties public renaming ( primStringToListInjective to toList-injective) ------------------------------------------------------------------------ -- Properties of _≈_ ≈⇒≡ : _≈_ ⇒ _≡_ ≈⇒≡ = toList-injective _ _ ∘ Pointwise.Pointwise-≡⇒≡ ∘ Pointwise.map Charₚ.≈⇒≡ ≈-reflexive : _≡_ ⇒ _≈_ ≈-reflexive = Pointwise.map Charₚ.≈-reflexive ∘ Pointwise.≡⇒Pointwise-≡ ∘ cong toList ≈-refl : Reflexive _≈_ ≈-refl {x} = ≈-reflexive {x} {x} refl ≈-sym : Symmetric _≈_ ≈-sym = Pointwise.symmetric (λ {i j} → Charₚ.≈-sym {i} {j}) ≈-trans : Transitive _≈_ ≈-trans = Pointwise.transitive (λ {i j k} → Charₚ.≈-trans {i} {j} {k}) ≈-subst : ∀ {ℓ} → Substitutive _≈_ ℓ ≈-subst P x≈y p = subst P (≈⇒≡ x≈y) p infix 4 _≈?_ _≈?_ : Decidable _≈_ x ≈? y = Pointwise.decidable Charₚ._≈?_ (toList x) (toList y) ≈-isEquivalence : IsEquivalence _≈_ ≈-isEquivalence = record { refl = λ {i} → ≈-refl {i} ; sym = λ {i j} → ≈-sym {i} {j} ; trans = λ {i j k} → ≈-trans {i} {j} {k} } ≈-setoid : Setoid _ _ ≈-setoid = record { isEquivalence = ≈-isEquivalence } ≈-isDecEquivalence : IsDecEquivalence _≈_ ≈-isDecEquivalence = record { isEquivalence = ≈-isEquivalence ; _≟_ = _≈?_ } ≈-decSetoid : DecSetoid _ _ ≈-decSetoid = record { isDecEquivalence = ≈-isDecEquivalence } ----------------------------------------------------------------------- -- Properties of _≡_ infix 4 _≟_ _≟_ : Decidable _≡_ x ≟ y = map′ ≈⇒≡ ≈-reflexive $ x ≈? y ≡-setoid : Setoid _ _ ≡-setoid = PropEq.setoid String ≡-decSetoid : DecSetoid _ _ ≡-decSetoid = PropEq.decSetoid _≟_ ------------------------------------------------------------------------ -- Properties of _<_ infix 4 _<?_ _<?_ : Decidable _<_ x <? y = StrictLex.<-decidable Charₚ._≈?_ Charₚ._<?_ (toList x) (toList y) <-isStrictPartialOrder-≈ : IsStrictPartialOrder _≈_ _<_ <-isStrictPartialOrder-≈ = On.isStrictPartialOrder toList (StrictLex.<-isStrictPartialOrder Charₚ.<-isStrictPartialOrder-≈) <-isStrictTotalOrder-≈ : IsStrictTotalOrder _≈_ _<_ <-isStrictTotalOrder-≈ = On.isStrictTotalOrder toList (StrictLex.<-isStrictTotalOrder Charₚ.<-isStrictTotalOrder-≈) <-strictPartialOrder-≈ : StrictPartialOrder _ _ _ <-strictPartialOrder-≈ = On.strictPartialOrder (StrictLex.<-strictPartialOrder Charₚ.<-strictPartialOrder-≈) toList <-strictTotalOrder-≈ : StrictTotalOrder _ _ _ <-strictTotalOrder-≈ = On.strictTotalOrder (StrictLex.<-strictTotalOrder Charₚ.<-strictTotalOrder-≈) toList ------------------------------------------------------------------------ -- Alternative Boolean equality test. -- -- Why is the definition _==_ = primStringEquality not used? One -- reason is that the present definition can sometimes improve type -- inference, at least with the version of Agda that is current at the -- time of writing: see unit-test below. infix 4 _==_ _==_ : String → String → Bool s₁ == s₂ = isYes (s₁ ≟ s₂) private -- The following unit test does not type-check (at the time of -- writing) if _==_ is replaced by primStringEquality. data P : (String → Bool) → Set where p : (c : String) → P (_==_ c) unit-test : P (_==_ "") unit-test = p _ -- Version 1.1 setoid = ≡-setoid {-# WARNING_ON_USAGE setoid "Warning: setoid was deprecated in v1.1. Please use ≡-setoid instead." #-} decSetoid = ≡-decSetoid {-# WARNING_ON_USAGE decSetoid "Warning: decSetoid was deprecated in v1.1. Please use ≡-decSetoid instead." #-} strictTotalOrder = <-strictTotalOrder-≈ {-# WARNING_ON_USAGE strictTotalOrder "Warning: strictTotalOrder was deprecated in v1.1. Please use <-strictTotalOrder-≈ instead." #-}
{ "alphanum_fraction": 0.6163969795, "avg_line_length": 27.2647058824, "ext": "agda", "hexsha": "e7947bb79bf5911e9326815c0d9dde7b559687bd", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/String/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/String/Properties.agda", "max_line_length": 74, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/String/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 1461, "size": 4635 }
-- {-# OPTIONS --show-implicit #-} -- {-# OPTIONS -v tc.with.top:25 #-} -- {-# OPTIONS -v tc.with:40 -v tc.interaction:20 -v interaction.give:20 -v tc:10 #-} open import Common.Equality data Unit : Set where unit : Unit id : (A : Set) → A → A id A a = a module Works where dx : (x : Unit) → Unit → Unit dx x unit = x g : (x : Unit) → ∀ u → x ≡ dx x u g x with x g x | unit = id ((u : Unit) → unit ≡ dx unit u) ? -- Now if we make (x : Unit) a module parameter -- then we turn all applications (dx _) into just dx, -- which actually means (dx x), i.e., dx applied to -- the module free variables. -- This leads to an incomprehendable rejection -- of the following code (culprit is the first argument to id). module M (x : Unit) where dx : Unit → Unit dx unit = x g : ∀ u → x ≡ dx u g with x g | unit = id ((u : Unit) → unit ≡ dx u) ? -- Now, `with x` is a plain error. -- Also in harmless cases like the one below: module CollateralDamage (x : Unit) where x′ = x bla : x ≡ x′ bla with x bla | unit = id (unit ≡ unit) refl
{ "alphanum_fraction": 0.5934579439, "avg_line_length": 20.9803921569, "ext": "agda", "hexsha": "ad55d2e15966bb2e23dc184372bb7667296ec66d", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/Issue1342a.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/Issue1342a.agda", "max_line_length": 85, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue1342a.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 357, "size": 1070 }
{-# OPTIONS --cubical --no-import-sorts #-} open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero) module Number.Bundles where private variable ℓ ℓ' : Level open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Relation.Binary.Base -- Rel open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_) open import Cubical.Data.Sigma.Base renaming (_×_ to infixr 4 _×_) open import MoreAlgebra open import Number.Structures -- ℕ ℤ ℚ ℝ ℂ and ℚ₀⁺ ℝ₀⁺ ... -- ring without additive inverse record RCommSemiring : Type (ℓ-suc (ℓ-max ℓ ℓ')) where field Carrier : Type ℓ _#_ : Rel Carrier Carrier ℓ' -- RCommSemiring 0f 1f : Carrier _+_ _·_ : Carrier → Carrier → Carrier isRCommSemiring : IsRCommSemiring _#_ 0f 1f _+_ _·_ open IsRCommSemiring isRCommSemiring public -- ℤ ℚ ℝ ℂ record RCommRing : Type (ℓ-suc (ℓ-max ℓ ℓ')) where field Carrier : Type ℓ _#_ : Rel Carrier Carrier ℓ' -- RCommSemiring 0f 1f : Carrier _+_ _·_ : Carrier → Carrier → Carrier -- RCommRing -_ : Carrier → Carrier isRCommRing : IsRCommRing _#_ 0f 1f _+_ _·_ -_ open IsRCommRing isRCommRing public -- ℚ ℝ ℂ record RField : Type (ℓ-suc (ℓ-max ℓ ℓ')) where field Carrier : Type ℓ _#_ : Rel Carrier Carrier ℓ' -- RCommSemiring 0f 1f : Carrier _+_ _·_ : Carrier → Carrier → Carrier -- RCommRing -_ : Carrier → Carrier -- RField _⁻¹ : (x : Carrier) → {{ x # 0f }} → Carrier isRField : IsRField _#_ 0f 1f _+_ _·_ -_ _⁻¹ -- Finₖ ℕ ℤ ℚ ℚ₀⁺ ℚ⁺ ℝ ℝ₀⁺ ℝ⁺ record RLattice : Type (ℓ-suc (ℓ-max ℓ ℓ')) where constructor rlattice field Carrier : Type ℓ _<_ _≤_ _#_ : Rel Carrier Carrier ℓ' min max : Carrier → Carrier → Carrier isRLattice : IsRLattice _<_ _≤_ _#_ min max open IsRLattice isRLattice public infixl 4 _<_ infixl 4 _≤_ infixl 4 _#_ -- ℕ ℤ ℚ ℚ₀⁺ ℚ⁺ ℝ ℝ₀⁺ ℝ⁺ -- ring without additive inverse record ROrderedCommSemiring : Type (ℓ-suc (ℓ-max ℓ ℓ')) where field -- RLattice Carrier : Type ℓ _<_ _≤_ _#_ : Rel Carrier Carrier ℓ' min max : Carrier → Carrier → Carrier -- ROrderedCommSemiring 0f 1f : Carrier _+_ _·_ : Carrier → Carrier → Carrier -- _-_ : (x y : Carrier) → (y ≤ x) → Carrier -- is that a good idea? isROrderedCommSemiring : IsROrderedCommSemiring _<_ _≤_ _#_ min max 0f 1f _+_ _·_ open IsROrderedCommSemiring isROrderedCommSemiring public -- ℤ ℚ ℝ record ROrderedCommRing : Type (ℓ-suc (ℓ-max ℓ ℓ')) where field -- RLattice Carrier : Type ℓ _<_ _≤_ _#_ : Rel Carrier Carrier ℓ' min max : Carrier → Carrier → Carrier -- ROrderedCommSemiring 0f 1f : Carrier _+_ _·_ : Carrier → Carrier → Carrier -- ROrderedCommRing -_ : Carrier → Carrier isROrderedCommRing : IsROrderedCommRing _<_ _≤_ _#_ min max 0f 1f _+_ _·_ -_ open IsROrderedCommRing isROrderedCommRing public abs : Carrier → Carrier abs x = max x (- x) field isAbsOrderedCommRing : IsAbsOrderedCommRing _<_ _≤_ _#_ min max 0f 1f _+_ _·_ -_ abs open IsAbsOrderedCommRing isAbsOrderedCommRing public -- ℚ ℝ record ROrderedField : Type (ℓ-suc (ℓ-max ℓ ℓ')) where field -- RLattice Carrier : Type ℓ _<_ _≤_ _#_ : Rel Carrier Carrier ℓ' min max : Carrier → Carrier → Carrier -- ROrderedCommSemiring 0f 1f : Carrier _+_ _·_ : Carrier → Carrier → Carrier -- ROrderedCommRing -_ : Carrier → Carrier -- ROrderedField _⁻¹ : (x : Carrier) → {{ x # 0f }} → Carrier isROrderedField : IsROrderedField _<_ _≤_ _#_ min max 0f 1f _+_ _·_ -_ _⁻¹ open IsROrderedField isROrderedField public abs : Carrier → Carrier abs x = max x (- x) field isAbsOrderedCommRing : IsAbsOrderedCommRing _<_ _≤_ _#_ min max 0f 1f _+_ _·_ -_ abs open IsAbsOrderedCommRing isAbsOrderedCommRing public {- -- ℚ₀⁺ ℝ₀⁺ record ROrderedSemifield : Type (ℓ-suc (ℓ-max ℓ ℓ')) where field -- RLattice Carrier : Type ℓ _<_ _≤_ _#_ : Rel Carrier Carrier ℓ' min max : Carrier → Carrier → Carrier -- ROrderedCommSemiring 0f 1f : Carrier _+_ _·_ : Carrier → Carrier → Carrier -- ROrderedSemifield _-_ : (x y : Carrier) → (y ≤ x) → Carrier -- is that a good idea? _⁻¹ : (x : Carrier) → {{ 0f < x }} → Carrier -- ℚ⁺ ℝ⁺ record ROrderedSemifieldWithoutZero : Type (ℓ-suc (ℓ-max ℓ ℓ')) where field -- RLattice Carrier : Type ℓ _<_ _≤_ _#_ : Rel Carrier Carrier ℓ' min max : Carrier → Carrier → Carrier -- ROrderedSemifieldWithoutZero 1f : Carrier _+_ _·_ : Carrier → Carrier → Carrier _-_ : (x y : Carrier) → (y < x) → Carrier -- is that a good idea? _⁻¹ : Carrier → Carrier -}
{ "alphanum_fraction": 0.6120810757, "avg_line_length": 28.9709302326, "ext": "agda", "hexsha": "e7321321efe964235dbbfc82bde4d47ff44e5db8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "agda/Number/Bundles.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mchristianl/synthetic-reals", "max_issues_repo_path": "agda/Number/Bundles.agda", "max_line_length": 88, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "agda/Number/Bundles.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 1816, "size": 4983 }
module Lvl where open import Type open import Agda.Primitive public using (Level; _⊔_) renaming (lzero to 𝟎; lsuc to 𝐒) -- Wraps a lower level set in a higher level wrapper set. record Up {ℓ₁ ℓ₂} (T : Type{ℓ₂}) : Type{ℓ₁ ⊔ ℓ₂} where constructor up field obj : T of : ∀{ℓ} → Type{ℓ} → Level of {ℓ} _ = ℓ {-# INLINE of #-} ofType : ∀{ℓ} → Type{𝐒(ℓ)} → Level ofType {ℓ} _ = ℓ {-# INLINE ofType #-}
{ "alphanum_fraction": 0.6225490196, "avg_line_length": 19.4285714286, "ext": "agda", "hexsha": "a4db4ea94ed3ea6061088fbc234e0db3a475d70d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Lvl.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Lvl.agda", "max_line_length": 57, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Lvl.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 168, "size": 408 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.Polynomials.UnivariateFun.Polyn-nPoly where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Data.Nat renaming (_+_ to _+n_; _·_ to _·n_) open import Cubical.Data.Sigma open import Cubical.Algebra.Ring open import Cubical.Algebra.GradedRing.DirectSumFun open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.Instances.Polynomials.UnivariatePolyHIT open import Cubical.Algebra.CommRing.Instances.Polynomials.UnivariatePolyFun open import Cubical.Algebra.CommRing.Instances.Polynomials.MultivariatePoly open import Cubical.Algebra.Polynomials.Multivariate.EquivCarac.Poly0-A open import Cubical.Algebra.Polynomials.Multivariate.EquivCarac.An[Am[X]]-Anm[X] open import Cubical.Algebra.Polynomials.Multivariate.EquivCarac.AB-An[X]Bn[X] open import Cubical.Algebra.Polynomials.UnivariateHIT.Polyn-nPoly open CommRingEquivs renaming (compCommRingEquiv to _∘-ecr_ ; invCommRingEquiv to inv-ecr) private variable ℓ : Level ----------------------------------------------------------------------------- -- Definition Equiv1 : (A' : CommRing ℓ) → CommRingEquiv (nUnivariatePolyHIT A' 1) (nUnivariatePolyFun A' 1) Equiv1 A' = CommRingEquiv-DirectSumGradedRing _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Equiv-Polyn-nPolyFun : (A' : CommRing ℓ) → (n : ℕ) → CommRingEquiv (PolyCommRing A' n) (nUnivariatePolyFun A' n) Equiv-Polyn-nPolyFun A' zero = CRE-Poly0-A A' Equiv-Polyn-nPolyFun A' (suc n) = inv-ecr _ _ (CRE-PolyN∘M-PolyN+M A' 1 n) ∘-ecr (lift-equiv-poly _ _ 1 (Equiv-Polyn-nPolyFun A' n) ∘-ecr (Equiv-Polyn-nPolyHIT (nUnivariatePolyFun A' n) 1 ∘-ecr Equiv1 (nUnivariatePolyFun A' n)))
{ "alphanum_fraction": 0.7090611354, "avg_line_length": 45.8, "ext": "agda", "hexsha": "17fb2dcf8aa0252171f353370d779c0722327a37", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Algebra/Polynomials/UnivariateFun/Polyn-nPoly.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Algebra/Polynomials/UnivariateFun/Polyn-nPoly.agda", "max_line_length": 112, "max_stars_count": null, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/Polynomials/UnivariateFun/Polyn-nPoly.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 558, "size": 1832 }
-- Make the type checker loop. How can we ensure that the record is not -- recursive? module RecursiveRecord where data Nat : Set where zero : Nat suc : Nat -> Nat F : Set -> Set F _ = R where record R : Set where field x : F Nat r : F Nat r = _
{ "alphanum_fraction": 0.6278195489, "avg_line_length": 15.6470588235, "ext": "agda", "hexsha": "0875849fed22c4063d51eaf4e3aa5f7b8a0d7c80", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/bugs/RecursiveRecord.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/bugs/RecursiveRecord.agda", "max_line_length": 71, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/bugs/RecursiveRecord.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 80, "size": 266 }
module examplesPaperJFP.WxGraphicsLib where open import SizedIO.Base open import StateSizedIO.GUI.BaseStateDependent open import Size open import Data.Bool.Base open import Data.List.Base open import Function open import NativeIO open import StateSizedIO.GUI.WxBindingsFFI open import StateSizedIO.GUI.VariableList data GuiLev1Command : Set where makeFrame : GuiLev1Command makeButton : Frame → GuiLev1Command addButton : Frame → Button → GuiLev1Command drawBitmap : DC → Bitmap → Point → Bool → GuiLev1Command repaint : Frame → GuiLev1Command GuiLev1Response : GuiLev1Command → Set GuiLev1Response makeFrame = Frame GuiLev1Response (makeButton _) = Button GuiLev1Response _ = Unit GuiLev1Interface : IOInterface Command GuiLev1Interface = GuiLev1Command Response GuiLev1Interface = GuiLev1Response GuiLev2State : Set₁ GuiLev2State = VarList data GuiLev2Command (s : GuiLev2State) : Set₁ where level1C : GuiLev1Command → GuiLev2Command s createVar : {A : Set} → A → GuiLev2Command s setButtonHandler : Button → List (prod s → IO GuiLev1Interface ∞ (prod s)) → GuiLev2Command s setOnPaint : Frame → List (prod s → DC → Rect → IO GuiLev1Interface ∞ (prod s)) → GuiLev2Command s GuiLev2Response : (s : GuiLev2State) → GuiLev2Command s → Set GuiLev2Response _ (level1C c) = GuiLev1Response c GuiLev2Response _ (createVar {A} a) = Var A GuiLev2Response _ _ = Unit GuiLev2Next : (s : GuiLev2State) → (c : GuiLev2Command s) → GuiLev2Response s c → GuiLev2State GuiLev2Next s (createVar {A} a) var = addVar A var s GuiLev2Next s _ _ = s GuiLev2Interface : IOInterfaceˢ Stateˢ GuiLev2Interface = GuiLev2State Commandˢ GuiLev2Interface = GuiLev2Command Responseˢ GuiLev2Interface = GuiLev2Response nextˢ GuiLev2Interface = GuiLev2Next translateLev1Local : (c : GuiLev1Command) → NativeIO (GuiLev1Response c) translateLev1Local makeFrame = nativeNewFrame "dummy title" translateLev1Local (makeButton fra) = nativeMakeButton fra "dummy button label" translateLev1Local (addButton fra bt) = nativeAddButton fra bt translateLev1Local (drawBitmap dc bm p b) = nativeDrawBitmap dc bm p b translateLev1Local (repaint fra) = nativeRepaint fra translateLev1 : {A : Set} → IO GuiLev1Interface ∞ A → NativeIO A translateLev1 = translateIO translateLev1Local translateLev1List : {A : Set} → List (IO GuiLev1Interface ∞ A) → List (NativeIO A) translateLev1List l = map translateLev1 l translateLev2Local : (s : GuiLev2State) → (c : GuiLev2Command s) → NativeIO (GuiLev2Response s c) translateLev2Local s (level1C c) = translateLev1Local c translateLev2Local s (createVar {A} a) = nativeNewVar {A} a translateLev2Local s (setButtonHandler bt proglist) = nativeSetButtonHandler bt (dispatchList s (map (λ prog → translateLev1 ∘ prog) proglist)) translateLev2Local s (setOnPaint fra proglist) = nativeSetOnPaint fra (λ dc rect → dispatchList s (map (λ prog aa → translateLev1 (prog aa dc rect)) proglist)) translateLev2 : ∀ {A s} → IOˢ GuiLev2Interface ∞ (λ _ → A) s → NativeIO A translateLev2 = translateIOˢ translateLev2Local
{ "alphanum_fraction": 0.6847731869, "avg_line_length": 34.9595959596, "ext": "agda", "hexsha": "7ba24d93d3576aaffa806dd86cfda4607e0d2461", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "examples/examplesPaperJFP/WxGraphicsLib.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "examples/examplesPaperJFP/WxGraphicsLib.agda", "max_line_length": 87, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "examples/examplesPaperJFP/WxGraphicsLib.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 1116, "size": 3461 }
{-# OPTIONS --safe --cubical #-} open import Container module Container.Membership {s p} (𝒞 : Container s p) where open import Prelude open import HLevels infixr 5 _∈_ _∈!_ _∈_ : A → ⟦ 𝒞 ⟧ A → Type _ x ∈ xs = fiber (snd xs) x _∈!_ : A → ⟦ 𝒞 ⟧ A → Type _ x ∈! xs = isContr (x ∈ xs)
{ "alphanum_fraction": 0.6048951049, "avg_line_length": 17.875, "ext": "agda", "hexsha": "1cfcb4b0130f4a3317e75793d09c9fc2eab5a0f1", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Container/Membership.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Container/Membership.agda", "max_line_length": 59, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Container/Membership.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 115, "size": 286 }
{-# OPTIONS --copatterns #-} -- {-# OPTIONS -v tc.lhs.split:50 -v tc.cover:20 -v tc.cc:15 -v tc.lhs.top:10 #-} -- {-# OPTIONS -v term:20 #-} -- {-# OPTIONS --no-positivity-check #-} -- {-# OPTIONS -v tc.def.fun:50 #-} -- {-# OPTIONS -v 100 #-} module CoPatStream where import Common.Level open import Common.Prelude hiding (map) open import Common.Equality record Stream (A : Set) : Set where coinductive constructor cons field head : A tail : Stream A module S = Stream record _≈_ {A : Set}(s t : Stream A) : Set where coinductive field head : S.head s ≡ S.head t tail : S.tail s ≈ S.tail t module B = _≈_ repeat : {A : Set}(a : A) → Stream A -- repeat a = cons a (repeat a) S.head (repeat a) = a S.tail (repeat a) = repeat a module Cycle where cycle : Nat -> Stream Nat cycle n = cycle' n where cycle' : Nat -> Stream Nat S.head (cycle' n) = n S.tail (cycle' zero ) = cycle n S.tail (cycle' (suc n')) = cycle' n' module CoPat where map : {A B : Set} → (A → B) → Stream A → Stream B S.head (map f s) = f (S.head s) S.tail (map f s) = map f (S.tail s) map_id : {A : Set}(s : Stream A) → map (λ x → x) s ≈ s B.head (map_id s) = refl B.tail (map_id s) = map_id (S.tail s) module HandTranslated where {-# NON_TERMINATING #-} map : {A B : Set} → (A → B) → Stream A → Stream B map f s = record { head = f (S.head s) ; tail = map f (S.tail s) } {- rejected because map is not unfolded {-# NON_TERMINATING #-} map_id : {A : Set}(s : Stream A) → map (λ x → x) s ≈ s map_id s = record { head = refl ; tail = map_id (S.tail s) } -} module DeepCoPat where repeat₂ : {A : Set}(a₁ a₂ : A) → Stream A ( (S.head (repeat₂ a₁ a₂))) = a₁ (S.head (S.tail (repeat₂ a₁ a₂))) = a₂ (S.tail (S.tail (repeat₂ a₁ a₂))) = repeat₂ a₁ a₂ repeat≈repeat₂ : {A : Set}(a : A) → repeat a ≈ repeat₂ a a ( (B.head (repeat≈repeat₂ a))) = refl (B.head (B.tail (repeat≈repeat₂ a))) = refl (B.tail (B.tail (repeat≈repeat₂ a))) = repeat≈repeat₂ a module ProjectionRHS where repeat′ : {A : Set}(a : A) → Stream A ( (S.head (repeat′ a))) = a (S.head (S.tail (repeat′ a))) = a (S.tail (S.tail (repeat′ a))) = S.tail (repeat′ a) -- -- Type error: -- repeat≈repeat′ : {A : Set}(a : A) → repeat a ≈ repeat′ a -- ( (B.head (repeat≈repeat′ a))) = refl -- (B.head (B.tail (repeat≈repeat′ a))) = refl -- (B.tail (B.tail (repeat≈repeat′ a))) = repeat≈repeat′ a
{ "alphanum_fraction": 0.5657418577, "avg_line_length": 26.1789473684, "ext": "agda", "hexsha": "e2e8454b862ca51cc029f50891a27fbbf564223e", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/CoPatStream.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Succeed/CoPatStream.agda", "max_line_length": 81, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/CoPatStream.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 903, "size": 2487 }
{- Definition of and facts about Smith normal form -} {-# OPTIONS --safe #-} module Cubical.Algebra.IntegerMatrix.Smith.NormalForm where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Nat hiding (_·_) renaming (_+_ to _+ℕ_ ; +-assoc to +Assocℕ) open import Cubical.Data.Int hiding (_+_ ; _·_ ; _-_ ; -_ ; addEq) open import Cubical.Data.Int.Divisibility open import Cubical.Data.FinData open import Cubical.Data.Empty as Empty open import Cubical.Data.Unit as Unit open import Cubical.Data.Sigma open import Cubical.Data.List open import Cubical.Relation.Nullary open import Cubical.Algebra.Matrix.CommRingCoefficient open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.Instances.Int renaming (ℤ to ℤRing) private variable m n k : ℕ open Coefficient ℤRing -- Sequence of consecutively divisible integers _∣all_ : ℤ → List ℤ → Type n ∣all [] = ¬ n ≡ 0 n ∣all (x ∷ ys) = n ∣ x × n ∣all ys isProp∣all : {n : ℤ}{xs : List ℤ} → isProp (n ∣all xs) isProp∣all {xs = []}= isPropΠ (λ _ → isProp⊥) isProp∣all {xs = x ∷ xs} = isProp× isProp∣ isProp∣all isConsDivs : List ℤ → Type isConsDivs [] = Unit isConsDivs (x ∷ xs) = x ∣all xs × isConsDivs xs isPropIsConsDivs : (xs : List ℤ) → isProp (isConsDivs xs) isPropIsConsDivs [] = isPropUnit isPropIsConsDivs (x ∷ xs) = isProp× isProp∣all (isPropIsConsDivs xs) ConsDivs : Type ConsDivs = Σ[ xs ∈ List ℤ ] isConsDivs xs cons : (n : ℤ)(xs : ConsDivs) → n ∣all xs .fst → ConsDivs cons n (xs , _) _ .fst = n ∷ xs cons n ([] , _) p .snd = p , tt cons n (x ∷ xs , q) p .snd = p , q -- Smith normal matrix _+length_ : ConsDivs → ℕ → ℕ xs +length n = length (xs .fst) +ℕ n smithMat : (xs : List ℤ)(m n : ℕ) → Mat (length xs +ℕ m) (length xs +ℕ n) smithMat [] _ _ = 𝟘 smithMat (x ∷ xs) _ _ = x ⊕ smithMat xs _ _ smithMat∣ : (a : ℤ)(xs : ConsDivs){m n : ℕ} → ¬ a ≡ 0 → ((i : Fin (xs +length m))(j : Fin (xs +length n)) → a ∣ smithMat (xs .fst) m n i j) → a ∣all xs .fst smithMat∣ _ ([] , _) q _ = q smithMat∣ a (x ∷ xs , p) q h = h zero zero , smithMat∣ a (xs , p .snd) q (λ i j → h (suc i) (suc j)) smithMat⊕ : (a : ℤ)(xs : ConsDivs){m n : ℕ} → (div : a ∣all xs .fst) → a ⊕ smithMat (xs .fst) m n ≡ smithMat (cons a xs div .fst) m n smithMat⊕ _ _ _ = refl -- Matrix with smith normality record isSmithNormal (M : Mat m n) : Type where field divs : ConsDivs rowNull : ℕ colNull : ℕ rowEq : divs +length rowNull ≡ m colEq : divs +length colNull ≡ n matEq : PathP (λ t → Mat (rowEq t) (colEq t)) (smithMat (divs .fst) rowNull colNull) M open isSmithNormal row col : {M : Mat m n} → isSmithNormal M → ℕ row isNorm = isNorm .divs +length isNorm .rowNull col isNorm = isNorm .divs +length isNorm .colNull smith∣ : (a : ℤ){M : Mat m n}(isNorm : isSmithNormal M) → ¬ a ≡ 0 → ((i : Fin m)(j : Fin n) → a ∣ M i j) → a ∣all isNorm . divs .fst smith∣ a isNorm p h = let a∣smith = λ { i j → subst (a ∣_) (λ t → isNorm .matEq (~ t) (subst-filler Fin (isNorm .rowEq) i (~ t)) (subst-filler Fin (isNorm .colEq) j (~ t))) (h _ _) } in smithMat∣ _ (isNorm .divs) p a∣smith -- Similarity to a normal form open Sim record Smith (M : Mat m n) : Type where field sim : Sim M isnormal : isSmithNormal (sim .result) open Smith simSmith : {M : Mat m n}(sim : Sim M) → Smith (sim .result) → Smith M simSmith simM smith .sim = compSim simM (smith .sim) simSmith _ smith .isnormal = smith .isnormal -- Simple special cases of normal matrices isSmithNormal𝟘 : isSmithNormal (𝟘 {m = m} {n = n}) isSmithNormal𝟘 .divs = [] , tt isSmithNormal𝟘 {m = m} .rowNull = m isSmithNormal𝟘 {n = n} .colNull = n isSmithNormal𝟘 .rowEq = refl isSmithNormal𝟘 .colEq = refl isSmithNormal𝟘 .matEq = refl isSmithNormalEmpty : (M : Mat 0 n) → isSmithNormal M isSmithNormalEmpty _ .divs = [] , tt isSmithNormalEmpty _ .rowNull = 0 isSmithNormalEmpty {n = n} _ .colNull = n isSmithNormalEmpty _ .rowEq = refl isSmithNormalEmpty _ .colEq = refl isSmithNormalEmpty _ .matEq = isContr→isProp isContrEmpty _ _ isSmithNormalEmptyᵗ : (M : Mat m 0) → isSmithNormal M isSmithNormalEmptyᵗ _ .divs = [] , tt isSmithNormalEmptyᵗ {m = m} _ .rowNull = m isSmithNormalEmptyᵗ _ .colNull = 0 isSmithNormalEmptyᵗ _ .rowEq = refl isSmithNormalEmptyᵗ _ .colEq = refl isSmithNormalEmptyᵗ _ .matEq = isContr→isProp isContrEmptyᵗ _ _ smith𝟘 : Smith (𝟘 {m = m} {n = n}) smith𝟘 .sim = idSim _ smith𝟘 .isnormal = isSmithNormal𝟘 smithEmpty : (M : Mat 0 n) → Smith M smithEmpty _ .sim = idSim _ smithEmpty M .isnormal = isSmithNormalEmpty M smithEmptyᵗ : (M : Mat m 0) → Smith M smithEmptyᵗ _ .sim = idSim _ smithEmptyᵗ M .isnormal = isSmithNormalEmptyᵗ M
{ "alphanum_fraction": 0.6525831416, "avg_line_length": 27.4770114943, "ext": "agda", "hexsha": "0a42763c9476983099e6ba2d3186df7737d82079", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_path": "Cubical/Algebra/IntegerMatrix/Smith/NormalForm.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_path": "Cubical/Algebra/IntegerMatrix/Smith/NormalForm.agda", "max_line_length": 100, "max_stars_count": null, "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_path": "Cubical/Algebra/IntegerMatrix/Smith/NormalForm.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1814, "size": 4781 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Solver for equations in commutative monoids -- -- Adapted from Algebra.Solver.Monoid ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Algebra module Algebra.Solver.CommutativeMonoid {m₁ m₂} (M : CommutativeMonoid m₁ m₂) where open import Data.Fin using (Fin; zero; suc) open import Data.Maybe as Maybe using (Maybe; decToMaybe; From-just; from-just) open import Data.Nat as ℕ using (ℕ; zero; suc; _+_) open import Data.Nat.GeneralisedArithmetic using (fold) open import Data.Product using (_×_; uncurry) open import Data.Vec using (Vec; []; _∷_; lookup; replicate) open import Function using (_∘_) import Relation.Binary.Reasoning.Setoid as EqReasoning import Relation.Binary.Reflection as Reflection import Relation.Nullary.Decidable as Dec import Data.Vec.Relation.Binary.Pointwise.Inductive as Pointwise open import Relation.Binary.PropositionalEquality as P using (_≡_; decSetoid) open import Relation.Nullary using (Dec) open CommutativeMonoid M open EqReasoning setoid ------------------------------------------------------------------------ -- Monoid expressions -- There is one constructor for every operation, plus one for -- variables; there may be at most n variables. infixr 5 _⊕_ infixr 10 _•_ data Expr (n : ℕ) : Set where var : Fin n → Expr n id : Expr n _⊕_ : Expr n → Expr n → Expr n -- An environment contains one value for every variable. Env : ℕ → Set _ Env n = Vec Carrier n -- The semantics of an expression is a function from an environment to -- a value. ⟦_⟧ : ∀ {n} → Expr n → Env n → Carrier ⟦ var x ⟧ ρ = lookup ρ x ⟦ id ⟧ ρ = ε ⟦ e₁ ⊕ e₂ ⟧ ρ = ⟦ e₁ ⟧ ρ ∙ ⟦ e₂ ⟧ ρ ------------------------------------------------------------------------ -- Normal forms -- A normal form is a vector of multiplicities (a bag). Normal : ℕ → Set Normal n = Vec ℕ n -- The semantics of a normal form. ⟦_⟧⇓ : ∀ {n} → Normal n → Env n → Carrier ⟦ [] ⟧⇓ _ = ε ⟦ n ∷ v ⟧⇓ (a ∷ ρ) = fold (⟦ v ⟧⇓ ρ) (λ b → a ∙ b) n ------------------------------------------------------------------------ -- Constructions on normal forms -- The empty bag. empty : ∀{n} → Normal n empty = replicate 0 -- A singleton bag. sg : ∀{n} (i : Fin n) → Normal n sg zero = 1 ∷ empty sg (suc i) = 0 ∷ sg i -- The composition of normal forms. _•_ : ∀{n} (v w : Normal n) → Normal n [] • [] = [] (l ∷ v) • (m ∷ w) = l + m ∷ v • w ------------------------------------------------------------------------ -- Correctness of the constructions on normal forms -- The empty bag stands for the unit ε. empty-correct : ∀{n} (ρ : Env n) → ⟦ empty ⟧⇓ ρ ≈ ε empty-correct [] = refl empty-correct (a ∷ ρ) = empty-correct ρ -- The singleton bag stands for a single variable. sg-correct : ∀{n} (x : Fin n) (ρ : Env n) → ⟦ sg x ⟧⇓ ρ ≈ lookup ρ x sg-correct zero (x ∷ ρ) = begin x ∙ ⟦ empty ⟧⇓ ρ ≈⟨ ∙-congˡ (empty-correct ρ) ⟩ x ∙ ε ≈⟨ identityʳ _ ⟩ x ∎ sg-correct (suc x) (m ∷ ρ) = sg-correct x ρ -- Normal form composition corresponds to the composition of the monoid. comp-correct : ∀ {n} (v w : Normal n) (ρ : Env n) → ⟦ v • w ⟧⇓ ρ ≈ (⟦ v ⟧⇓ ρ ∙ ⟦ w ⟧⇓ ρ) comp-correct [] [] ρ = sym (identityˡ _) comp-correct (l ∷ v) (m ∷ w) (a ∷ ρ) = lemma l m (comp-correct v w ρ) where flip12 : ∀ a b c → a ∙ (b ∙ c) ≈ b ∙ (a ∙ c) flip12 a b c = begin a ∙ (b ∙ c) ≈⟨ sym (assoc _ _ _) ⟩ (a ∙ b) ∙ c ≈⟨ ∙-congʳ (comm _ _) ⟩ (b ∙ a) ∙ c ≈⟨ assoc _ _ _ ⟩ b ∙ (a ∙ c) ∎ lemma : ∀ l m {d b c} (p : d ≈ b ∙ c) → fold d (a ∙_) (l + m) ≈ fold b (a ∙_) l ∙ fold c (a ∙_) m lemma zero zero p = p lemma zero (suc m) p = trans (∙-congˡ (lemma zero m p)) (flip12 _ _ _) lemma (suc l) m p = trans (∙-congˡ (lemma l m p)) (sym (assoc a _ _)) ------------------------------------------------------------------------ -- Normalization -- A normaliser. normalise : ∀ {n} → Expr n → Normal n normalise (var x) = sg x normalise id = empty normalise (e₁ ⊕ e₂) = normalise e₁ • normalise e₂ -- The normaliser preserves the semantics of the expression. normalise-correct : ∀ {n} (e : Expr n) (ρ : Env n) → ⟦ normalise e ⟧⇓ ρ ≈ ⟦ e ⟧ ρ normalise-correct (var x) ρ = sg-correct x ρ normalise-correct id ρ = empty-correct ρ normalise-correct (e₁ ⊕ e₂) ρ = begin ⟦ normalise e₁ • normalise e₂ ⟧⇓ ρ ≈⟨ comp-correct (normalise e₁) (normalise e₂) ρ ⟩ ⟦ normalise e₁ ⟧⇓ ρ ∙ ⟦ normalise e₂ ⟧⇓ ρ ≈⟨ ∙-cong (normalise-correct e₁ ρ) (normalise-correct e₂ ρ) ⟩ ⟦ e₁ ⟧ ρ ∙ ⟦ e₂ ⟧ ρ ∎ ------------------------------------------------------------------------ -- "Tactics" open module R = Reflection setoid var ⟦_⟧ (⟦_⟧⇓ ∘ normalise) normalise-correct public using (solve; _⊜_) -- We can decide if two normal forms are /syntactically/ equal. infix 5 _≟_ _≟_ : ∀ {n} (nf₁ nf₂ : Normal n) → Dec (nf₁ ≡ nf₂) nf₁ ≟ nf₂ = Dec.map Pointwise-≡↔≡ (decidable ℕ._≟_ nf₁ nf₂) where open Pointwise -- We can also give a sound, but not necessarily complete, procedure -- for determining if two expressions have the same semantics. prove′ : ∀ {n} (e₁ e₂ : Expr n) → Maybe (∀ ρ → ⟦ e₁ ⟧ ρ ≈ ⟦ e₂ ⟧ ρ) prove′ e₁ e₂ = Maybe.map lemma (decToMaybe (normalise e₁ ≟ normalise e₂)) where lemma : normalise e₁ ≡ normalise e₂ → ∀ ρ → ⟦ e₁ ⟧ ρ ≈ ⟦ e₂ ⟧ ρ lemma eq ρ = R.prove ρ e₁ e₂ (begin ⟦ normalise e₁ ⟧⇓ ρ ≡⟨ P.cong (λ e → ⟦ e ⟧⇓ ρ) eq ⟩ ⟦ normalise e₂ ⟧⇓ ρ ∎) -- This procedure can be combined with from-just. prove : ∀ n (e₁ e₂ : Expr n) → From-just (prove′ e₁ e₂) prove _ e₁ e₂ = from-just (prove′ e₁ e₂) -- prove : ∀ n (es : Expr n × Expr n) → -- From-just (uncurry prove′ es) -- prove _ = from-just ∘ uncurry prove′
{ "alphanum_fraction": 0.541447703, "avg_line_length": 29.6432160804, "ext": "agda", "hexsha": "8268d100f368fdaa6d503ad0c12282850bc61d73", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Solver/CommutativeMonoid.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Solver/CommutativeMonoid.agda", "max_line_length": 83, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Solver/CommutativeMonoid.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2096, "size": 5899 }
open import Data.List hiding ([_]) renaming (_∷_ to _∷ₗ_) open import Data.Maybe open import Data.Product open import AEff open import EffectAnnotations open import Renamings open import Substitutions renaming (⟨_,_⟩ to ⟨_,,_⟩) open import Types open import Relation.Binary.PropositionalEquality hiding ([_]) open import Relation.Nullary module Preservation where -- BINDING CONTEXTS BCtx = List VType -- WELL-TYPED EVALUATION CONTEXTS data _⊢E[_]⦂_ (Γ : Ctx) : (Δ : BCtx) → CType → Set where [-] : {C : CType} → ------------- Γ ⊢E[ [] ]⦂ C let=_`in_ : {Δ : BCtx} {X Y : VType} {o : O} {i : I} → Γ ⊢E[ Δ ]⦂ X ! (o , i) → Γ ∷ X ⊢C⦂ Y ! (o , i) → ------------------------ Γ ⊢E[ Δ ]⦂ Y ! (o , i) ↑ : {Δ : BCtx} {X : VType} {o : O} {i : I} → (op : Σₛ) → op ∈ₒ o → Γ ⊢V⦂ proj₁ (payload op) → Γ ⊢E[ Δ ]⦂ X ! (o , i) → -------------------------- Γ ⊢E[ Δ ]⦂ X ! (o , i) ↓ : {Δ : BCtx} {X : VType} {o : O} {i : I} (op : Σₛ) → Γ ⊢V⦂ proj₁ (payload op) → Γ ⊢E[ Δ ]⦂ X ! (o , i) → --------------------------- Γ ⊢E[ Δ ]⦂ X ! op ↓ₑ (o , i) promise_∣_↦_`in_ : {Δ : BCtx} {X Y : VType} {o o' : O} {i i' : I} → (op : Σₛ) → (o' , i') ⊑ lkpᵢ op i → Γ ∷ proj₁ (payload op) ∷ (𝟙 ⇒ (⟨ X ⟩ ! (∅ₒ , ∅ᵢ [ op ↦ just (o' , i') ]ᵢ))) ⊢C⦂ ⟨ X ⟩ ! (o' , i') → Γ ∷ ⟨ X ⟩ ⊢E[ Δ ]⦂ Y ! (o , i) → ---------------------------------------------- Γ ⊢E[ X ∷ₗ Δ ]⦂ Y ! (o , i) spawn : {Δ : BCtx} {C D : CType} → Γ ■ ⊢C⦂ C → Γ ⊢E[ Δ ]⦂ D → --------------- Γ ⊢E[ Δ ]⦂ D coerce : {Δ : BCtx} {X : VType} {o o' : O} {i i' : I} → o ⊑ₒ o' → i ⊑ᵢ i' → Γ ⊢E[ Δ ]⦂ X ! (o , i) → ------------------------ Γ ⊢E[ Δ ]⦂ X ! (o' , i') -- MERGING AN ORDINARY CONTEXT AND A BINDING CONTEXT infix 30 _⋈_ _⋈_ : Ctx → BCtx → Ctx Γ ⋈ [] = Γ Γ ⋈ (X ∷ₗ Δ) = (Γ ∷ ⟨ X ⟩) ⋈ Δ -- FINDING THE TYPE OF THE HOLE OF A WELL-TYPED EVALUATION CONTEXT hole-ty-e : {Γ : Ctx} {Δ : BCtx} {C : CType} → Γ ⊢E[ Δ ]⦂ C → CType hole-ty-e {_} {_} {C} [-] = C hole-ty-e (let= E `in M) = hole-ty-e E hole-ty-e (↑ op p V E) = hole-ty-e E hole-ty-e (↓ op V E) = hole-ty-e E hole-ty-e (promise op ∣ p ↦ M `in E) = hole-ty-e E hole-ty-e (spawn M E) = hole-ty-e E hole-ty-e (coerce p q E) = hole-ty-e E -- FILLING A WELL-TYPED EVALUATION CONTEXT infix 30 _[_] _[_] : {Γ : Ctx} {Δ : BCtx} {C : CType} → (E : Γ ⊢E[ Δ ]⦂ C) → Γ ⋈ Δ ⊢C⦂ (hole-ty-e E) → Γ ⊢C⦂ C [-] [ M ] = M (let= E `in N) [ M ] = let= (E [ M ]) `in N (↑ op p V E) [ M ] = ↑ op p V (E [ M ]) (↓ op V E) [ M ] = ↓ op V (E [ M ]) (promise op ∣ p ↦ N `in E) [ M ] = promise op ∣ p ↦ N `in (E [ M ]) (spawn N E) [ M ] = spawn N (E [ M ]) (coerce p q E) [ M ] = coerce p q (E [ M ]) -- STRENGTHENING OF GROUND VALUES WRT BOUND PROMISES strengthen-var : {Γ : Ctx} → (Δ : BCtx) → {X : VType} → mobile X → X ∈ Γ ⋈ Δ → -------------------------------------- X ∈ Γ strengthen-var [] p x = x strengthen-var (y ∷ₗ Δ) p x with strengthen-var Δ p x ... | Tl-v z = z strengthen-■-var : {Γ : Ctx} → (Γ' : Ctx) → (Δ : BCtx) → {X : VType} → X ∈ (Γ ⋈ Δ) ■ ++ₖ Γ' → -------------------------- X ∈ Γ ■ ++ₖ Γ' strengthen-■-var Γ' [] x = x strengthen-■-var [] (y ∷ₗ Δ) x with strengthen-■-var [] Δ x ... | Tl-■ p (Tl-v z) = Tl-■ p z strengthen-■-var (Γ' ∷ Z) (y ∷ₗ Δ) Hd = Hd strengthen-■-var (Γ' ∷ Z) (y ∷ₗ Δ) (Tl-v x) with strengthen-■-var Γ' (y ∷ₗ Δ) x ... | q = Tl-v q strengthen-■-var (Γ' ■) (y ∷ₗ Δ) (Tl-■ p x) with strengthen-■-var Γ' (y ∷ₗ Δ) x ... | q = Tl-■ p q mutual strengthen-■-v : {Γ Γ' : Ctx} {Δ : BCtx} {X : VType} → (Γ ⋈ Δ) ■ ++ₖ Γ' ⊢V⦂ X → ------------------------------------- Γ ■ ++ₖ Γ' ⊢V⦂ X strengthen-■-v {_} {Γ'} {Δ} (` x) = ` strengthen-■-var Γ' Δ x strengthen-■-v (´ c) = ´ c strengthen-■-v ⋆ = ⋆ strengthen-■-v {Γ} {Γ'} {Δ} (ƛ M) = ƛ (strengthen-■-c {Γ} {Γ' ∷ _} {Δ} M) strengthen-■-v {Γ} {Γ'} {Δ} ⟨ V ⟩ = ⟨ strengthen-■-v {Γ} {Γ'} {Δ} V ⟩ strengthen-■-v {Γ} {Γ'} {Δ} (□ V) = □ (strengthen-■-v {Γ' = _ ■} {Δ = Δ} V) strengthen-■-c : {Γ Γ' : Ctx} {Δ : BCtx} {C : CType} → (Γ ⋈ Δ) ■ ++ₖ Γ' ⊢C⦂ C → ------------------------------------- Γ ■ ++ₖ Γ' ⊢C⦂ C strengthen-■-c {Γ} {Γ'} {Δ} (return V) = return (strengthen-■-v {Γ} {Γ'} {Δ} V) strengthen-■-c {Γ} {Γ'} {Δ} (let= M `in N) = let= (strengthen-■-c {Γ} {Γ'} {Δ} M) `in (strengthen-■-c {Γ} {Γ' ∷ _} {Δ} N) strengthen-■-c {Γ} {Γ'} {Δ} (V · W) = (strengthen-■-v {Γ} {Γ'} {Δ} V) · (strengthen-■-v {Γ} {Γ'} {Δ} W) strengthen-■-c {Γ} {Γ'} {Δ} (↑ op p V M) = ↑ op p (strengthen-■-v {Γ} {Γ'} {Δ} V) (strengthen-■-c {Γ} {Γ'} {Δ} M) strengthen-■-c {Γ} {Γ'} {Δ} (↓ op V M) = ↓ op (strengthen-■-v {Γ} {Γ'} {Δ} V) (strengthen-■-c {Γ} {Γ'} {Δ} M) strengthen-■-c {Γ} {Γ'} {Δ} (promise op ∣ p ↦ M `in N) = promise op ∣ p ↦ (strengthen-■-c {Γ} {Γ' ∷ proj₁ (payload op) ∷ _} {Δ} M) `in (strengthen-■-c {Γ} {Γ' ∷ ⟨ _ ⟩} {Δ} N) strengthen-■-c {Γ} {Γ'} {Δ} (await V until N) = await (strengthen-■-v {Γ} {Γ'} {Δ} V) until (strengthen-■-c {Γ} {Γ' ∷ _} {Δ} N) strengthen-■-c {Γ} {Γ'} {Δ} (unbox V `in N) = unbox (strengthen-■-v {Γ} {Γ'} {Δ} V) `in (strengthen-■-c {Γ} {Γ' ∷ _} {Δ} N) strengthen-■-c {Γ} {Γ'} {Δ} (spawn M N) = spawn (strengthen-■-c {Γ' = _ ■} {Δ = Δ} M) (strengthen-■-c {Δ = Δ} N) strengthen-■-c {Γ} {Γ'} {Δ} (coerce p q M) = coerce p q (strengthen-■-c {Γ} {Γ'} {Δ} M) strengthen-val : {Γ : Ctx} {Δ : BCtx} {X : VType} → mobile X → Γ ⋈ Δ ⊢V⦂ X → ---------------------------------- Γ ⊢V⦂ X strengthen-val {_} {Δ} p (` x) = ` strengthen-var Δ p x strengthen-val p (´ c) = ´ c strengthen-val p ⋆ = ⋆ strengthen-val {Γ} {Δ} p (□ V) = □ (strengthen-■-v {Γ} {[]} {Δ} V) -- SMALL-STEP OPERATIONAL SEMANTICS FOR WELL-TYPED COMPUTATIONS -- (ADDITIONALLY SERVES AS THE PRESERVATION THEOREM) infix 10 _↝_ data _↝_ {Γ : Ctx} : {C : CType} → Γ ⊢C⦂ C → Γ ⊢C⦂ C → Set where -- COMPUTATIONAL RULES apply : {X : VType} {C : CType} → (M : Γ ∷ X ⊢C⦂ C) → (V : Γ ⊢V⦂ X) → ---------------------- (ƛ M) · V ↝ M [ sub-id [ V ]s ]c let-return : {X Y : VType} {o : O} {i : I} → (V : Γ ⊢V⦂ X) → (N : Γ ∷ X ⊢C⦂ Y ! (o , i)) → ----------------------------- let= (return V) `in N ↝ N [ sub-id [ V ]s ]c let-↑ : {X Y : VType} {o : O} {i : I} {op : Σₛ} → (p : op ∈ₒ o) → (V : Γ ⊢V⦂ proj₁ (payload op)) → (M : Γ ⊢C⦂ X ! (o , i)) → (N : Γ ∷ X ⊢C⦂ Y ! (o , i)) → ----------------------------- let= (↑ op p V M) `in N ↝ ↑ op p V (let= M `in N) let-promise : {X Y Z : VType} {o o' : O} {i i' : I} {op : Σₛ} → (p : (o' , i') ⊑ lkpᵢ op i) → (M₁ : Γ ∷ proj₁ (payload op) ∷ (𝟙 ⇒ (⟨ X ⟩ ! (∅ₒ , ∅ᵢ [ op ↦ just (o' , i') ]ᵢ))) ⊢C⦂ ⟨ X ⟩ ! (o' , i')) → (M₂ : Γ ∷ ⟨ X ⟩ ⊢C⦂ Y ! (o , i)) → (N : Γ ∷ Y ⊢C⦂ Z ! (o , i)) → ---------------------------------------------------------------------------------------------------------- let= (promise op ∣ p ↦ M₁ `in M₂) `in N ↝ (promise op ∣ p ↦ M₁ `in (let= M₂ `in (C-rename (ren-cong ren-wk) N))) let-await : {X Y Z : VType} {o : O} {i : I} → (V : Γ ⊢V⦂ ⟨ X ⟩) → (M : Γ ∷ X ⊢C⦂ Y ! (o , i)) → (N : Γ ∷ Y ⊢C⦂ Z ! (o , i)) → ------------------------------------------------------- let= (await V until M) `in N ↝ await V until (let= M `in C-rename (ren-cong ren-wk) N) let-spawn : {X Y : VType} {C : CType} {o : O} {i : I} → (M : Γ ■ ⊢C⦂ C) → (N : Γ ⊢C⦂ X ! (o , i)) → (K : Γ ∷ X ⊢C⦂ Y ! (o , i)) → --------------------------------------- let= (spawn M N) `in K ↝ spawn M (let= N `in K) promise-↑ : {X Y : VType} {o o' : O} {i i' : I} {op op' : Σₛ} → (p : (o' , i') ⊑ lkpᵢ op i) → (q : op' ∈ₒ o) → (V : Γ ∷ ⟨ X ⟩ ⊢V⦂ proj₁ (payload op')) → (M : Γ ∷ proj₁ (payload op) ∷ (𝟙 ⇒ (⟨ X ⟩ ! (∅ₒ , ∅ᵢ [ op ↦ just (o' , i') ]ᵢ))) ⊢C⦂ ⟨ X ⟩ ! (o' , i')) → (N : Γ ∷ ⟨ X ⟩ ⊢C⦂ Y ! (o , i)) → ----------------------------------------------------------------------------------------- (promise op ∣ p ↦ M `in (↑ op' q V N)) ↝ ↑ op' q (strengthen-val {Δ = X ∷ₗ []} (proj₂ (payload op')) V) (promise op ∣ p ↦ M `in N) promise-spawn : {X Y : VType} {C : CType} {o o' : O} {i i' : I} {op : Σₛ} → (p : (o' , i') ⊑ lkpᵢ op i) → (M : Γ ∷ proj₁ (payload op) ∷ (𝟙 ⇒ (⟨ X ⟩ ! (∅ₒ , ∅ᵢ [ op ↦ just (o' , i') ]ᵢ))) ⊢C⦂ ⟨ X ⟩ ! (o' , i')) → (N : Γ ∷ ⟨ X ⟩ ■ ⊢C⦂ C) → (K : Γ ∷ ⟨ X ⟩ ⊢C⦂ Y ! (o , i)) → --------------------------------------------------------------------------- (promise op ∣ p ↦ M `in (spawn N K)) ↝ spawn (strengthen-■-c {Γ' = []} {Δ = X ∷ₗ []} N) (promise op ∣ p ↦ M `in K) ↓-return : {X : VType} {o : O} {i : I} {op : Σₛ} → (V : Γ ⊢V⦂ proj₁ (payload op)) → (W : Γ ⊢V⦂ X) → ---------------------------------------------------------------- ↓ {o = o} {i = i} op V (return W) ↝ return {o = proj₁ (op ↓ₑ (o , i))} {i = proj₂ (op ↓ₑ (o , i))} W ↓-↑ : {X : VType} {o : O} {i : I} {op : Σₛ} {op' : Σₛ} → (p : op' ∈ₒ o) → (V : Γ ⊢V⦂ proj₁ (payload op)) → (W : Γ ⊢V⦂ proj₁ (payload op')) → (M : Γ ⊢C⦂ X ! (o , i)) → -------------------------------- ↓ op V (↑ op' p W M) ↝ ↑ op' (↓ₑ-⊑ₒ op' p) W (↓ op V M) ↓-promise-op : {X Y : VType} {o o' : O} {i i' : I} {op : Σₛ} → (p : (o' , i') ⊑ lkpᵢ op i) → (V : Γ ⊢V⦂ proj₁ (payload op)) → (M : Γ ∷ proj₁ (payload op) ∷ (𝟙 ⇒ (⟨ X ⟩ ! (∅ₒ , ∅ᵢ [ op ↦ just (o' , i') ]ᵢ))) ⊢C⦂ ⟨ X ⟩ ! (o' , i')) → (N : Γ ∷ ⟨ X ⟩ ⊢C⦂ Y ! (o , i)) → -------------------------------------------------------------------------------------------------------------------------------------------------------- ↓ op V (promise op ∣ p ↦ M `in N ) ↝ (let= (coerce (⊑ₒ-trans (proj₁ (⊑-proj p (proj₂ (proj₂ (⊑-just p))))) (↓ₑ-⊑ₒ-o' {o = o} (proj₂ (proj₂ (⊑-just p))))) (⊑ᵢ-trans (proj₂ (⊑-proj p (proj₂ (proj₂ (⊑-just p))))) (↓ₑ-⊑ₒ-i' {o = o} (proj₂ (proj₂ (⊑-just p))))) (M [ (sub-id [ V ]s) [ ƛ (promise op ∣ subst (λ oi → (o' , i') ⊑ oi) (sym ite-≡) ⊑-refl ↦ C-rename (ren-cong (ren-cong ren-wk)) M `in return (` Hd)) ]s ]c)) `in (↓ op (V-rename ren-wk V) N)) ↓-promise-op' : {X Y : VType} {o o' : O} {i i' : I} {op op' : Σₛ} → (p : ¬ op ≡ op') → (q : (o' , i') ⊑ lkpᵢ op' i) → (V : Γ ⊢V⦂ proj₁ (payload op)) → (M : Γ ∷ proj₁ (payload op') ∷ (𝟙 ⇒ (⟨ X ⟩ ! (∅ₒ , ∅ᵢ [ op' ↦ just (o' , i') ]ᵢ))) ⊢C⦂ ⟨ X ⟩ ! (o' , i')) → (N : Γ ∷ ⟨ X ⟩ ⊢C⦂ Y ! (o , i)) → ---------------------------------------------------------------------------------------------------------- ↓ op V (promise op' ∣ q ↦ M `in N ) ↝ promise op' ∣ (lkpᵢ-↓ₑ-neq-⊑ {o = o} {i = i} p q) ↦ M `in ↓ op (V-rename ren-wk V) N ↓-await : {X Y : VType} {o : O} {i : I} {op : Σₛ} → (V : Γ ⊢V⦂ proj₁ (payload op)) → (W : Γ ⊢V⦂ ⟨ X ⟩) → (M : Γ ∷ X ⊢C⦂ Y ! (o , i)) → ------------------------------------------ ↓ op V (await W until M) ↝ await W until (↓ op (V-rename ren-wk V) M) ↓-spawn : {X : VType} {C : CType} {o : O} {i : I} {op : Σₛ} → (V : Γ ⊢V⦂ proj₁ (payload op)) → (M : Γ ■ ⊢C⦂ C) → (N : Γ ⊢C⦂ X ! (o , i)) → -------------------------------- ↓ op V (spawn M N) ↝ spawn M (↓ op V N) await-promise : {X : VType} {C : CType} → (V : Γ ⊢V⦂ X) → (M : Γ ∷ X ⊢C⦂ C) → -------------------- await ⟨ V ⟩ until M ↝ M [ sub-id [ V ]s ]c box-unbox : {X : VType} {C : CType} → (V : Γ ■ ⊢V⦂ X) → (M : Γ ∷ X ⊢C⦂ C) → ------------------- unbox (□ V) `in M ↝ M [ ⟨ sub-id ,, ■-str-v {Γ' = []} V ⟩ ]c -- EVALUATION CONTEXT RULE context : {Δ : BCtx} {C : CType} → (E : Γ ⊢E[ Δ ]⦂ C) → {M N : Γ ⋈ Δ ⊢C⦂ (hole-ty-e E)} → M ↝ N → ------------------------------- E [ M ] ↝ E [ N ] -- COERCION RULES -- (THE RESULT OF WORKING WITH WELL-TYPED SYNTAX AND MAKING SUBSUMPTION INTO AN EXPLICIT COERCION) coerce-return : {X : VType} {o o' : O} {i i' : I} {p : o ⊑ₒ o'} {q : i ⊑ᵢ i'} → (V : Γ ⊢V⦂ X) → -------------------------------- coerce p q (return V) ↝ return V coerce-↑ : {X : VType} {o o' : O} {i i' : I} {p : o ⊑ₒ o'} {q : i ⊑ᵢ i'} {op : Σₛ} → (r : op ∈ₒ o) → (V : Γ ⊢V⦂ proj₁ (payload op)) → (M : Γ ⊢C⦂ X ! (o , i)) → -------------------------------- coerce p q (↑ op r V M) ↝ ↑ op (p op r) V (coerce p q M) coerce-promise : {X Y : VType} {o o' o'' : O} {i i' i'' : I} {p : o ⊑ₒ o'} {q : i ⊑ᵢ i'} {op : Σₛ} → (r : (o'' , i'') ⊑ lkpᵢ op i) (M : Γ ∷ proj₁ (payload op) ∷ (𝟙 ⇒ (⟨ X ⟩ ! (∅ₒ , ∅ᵢ [ op ↦ just (o'' , i'') ]ᵢ))) ⊢C⦂ ⟨ X ⟩ ! (o'' , i'')) → (N : Γ ∷ ⟨ X ⟩ ⊢C⦂ Y ! (o , i)) → ------------------------------------------------------------------------------------------------------------- coerce p q (promise op ∣ r ↦ M `in N) ↝ promise_∣_↦_`in_ op (subst (λ oi → (o'' , i'') ⊑ oi) (sym (lkpᵢ-next-eq q (proj₂ (proj₂ (⊑-just r))))) (⊑-trans r (proj₂ (proj₂ (⊑-just r))) ( (lkpᵢ-next-⊑ₒ q (proj₂ (proj₂ (⊑-just r)))) , (lkpᵢ-next-⊑ᵢ q (proj₂ (proj₂ (⊑-just r))))))) M (coerce p q N) coerce-await : {X Y : VType} {o o' : O} {i i' : I} {p : o ⊑ₒ o'} {q : i ⊑ᵢ i'} → (V : Γ ⊢V⦂ ⟨ X ⟩) → (M : Γ ∷ X ⊢C⦂ Y ! (o , i)) → ----------------------------- coerce p q (await V until M) ↝ await V until (coerce p q M) coerce-spawn : {X : VType} {C : CType} {o o' : O} {i i' : I} {p : o ⊑ₒ o'} {q : i ⊑ᵢ i'} → (M : Γ ■ ⊢C⦂ C) → (N : Γ ⊢C⦂ X ! (o , i)) → ------------------------- coerce p q (spawn M N) ↝ spawn M (coerce p q N)
{ "alphanum_fraction": 0.2629817497, "avg_line_length": 37.0600775194, "ext": "agda", "hexsha": "e8d34b584b1a6b54e120ac8705b22e900034c4ab", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b41df71f4456666aab4bd14e13d285c31af80ff6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "danelahman/modal-aeff-agda", "max_forks_repo_path": "Preservation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b41df71f4456666aab4bd14e13d285c31af80ff6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "danelahman/modal-aeff-agda", "max_issues_repo_path": "Preservation.agda", "max_line_length": 172, "max_stars_count": 2, "max_stars_repo_head_hexsha": "b41df71f4456666aab4bd14e13d285c31af80ff6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "danelahman/higher-order-aeff-agda", "max_stars_repo_path": "Preservation.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T18:50:26.000Z", "max_stars_repo_stars_event_min_datetime": "2021-08-17T15:00:34.000Z", "num_tokens": 6678, "size": 19123 }
{-# OPTIONS --sized-types #-} module FormalLanguage.Proofs {ℓ} where import Lvl open import Data open import Data.Boolean open import Data.Boolean.Proofs open import Data.Boolean.Operators open Data.Boolean.Operators.Programming open import Data.Boolean.Stmt open import Data.Boolean.Stmt.Proofs import Data.Tuple as Tuple open import FormalLanguage open import FormalLanguage.Equals open import Functional using (id) open import Sized.Data.List renaming (∅ to []) open import Lang.Size open import Logic.Predicate open import Logic.Propositional open import Logic.Propositional.Theorems open import Relator.Equals using ([≡]-intro) renaming (_≡_ to _≡ₑ_) open import Relator.Equals.Proofs import Function.Names as Names open import Structure.Setoid open import Structure.Operator.Monoid import Structure.Operator.Names as Names open import Structure.Operator.Proofs open import Structure.Operator.Properties -- open import Structure.Operator.SetAlgebra open import Structure.Operator open import Structure.Function.Domain open import Structure.Relator open import Structure.Relator.Properties open import Syntax.Transitivity open import Type -- TODO: Prove all these -- TODO: http://www.cse.chalmers.se/~abela/jlamp17.pdf private variable s s₁ s₂ s₃ : Size {- module _ {Σ : Alphabet{ℓ}} where open Oper{ℓ}{Σ} open Language renaming (accepts-ε to accepts ; suffix-lang to suffix) instance [∪]-associativity : Associativity ⦃ [≅]-equiv {s = s} ⦄ (_∪_) Associativity.proof([∪]-associativity {s = s}) = [∪]-associativity-raw {s = s} where [∪]-associativity-raw : ∀{s} → Names.Associativity ⦃ [≅]-equiv {s = s} ⦄ (_∪_) _≅[_]≅_.accepts-ε ([∪]-associativity-raw {x = A}) = associativity(_||_) {Language.accepts-ε A} _≅[_]≅_.suffix-lang ([∪]-associativity-raw {x = A}) {c} = [∪]-associativity-raw {x = Language.suffix-lang A c} instance [∪]-commutativity : Commutativity ⦃ [≅]-equiv {s = s} ⦄ (_∪_) Commutativity.proof([∪]-commutativity {s = s}) = [∪]-commutativity-raw {s = s} where [∪]-commutativity-raw : ∀{s} → Names.Commutativity ⦃ [≅]-equiv {s = s} ⦄ (_∪_) _≅[_]≅_.accepts-ε ([∪]-commutativity-raw {x = A}) = commutativity(_||_) {Language.accepts-ε A} _≅[_]≅_.suffix-lang ([∪]-commutativity-raw {x = A}) {c} = [∪]-commutativity-raw {x = Language.suffix-lang A c} instance [∪]-identityₗ : Identityₗ ⦃ [≅]-equiv {s = s} ⦄ (_∪_)(∅) Identityₗ.proof([∪]-identityₗ {s = s}) = [∪]-identityₗ-raw {s = s} where [∪]-identityₗ-raw : ∀{s} → Names.Identityₗ ⦃ [≅]-equiv {s = s} ⦄ (_∪_)(∅) _≅[_]≅_.accepts-ε ([∪]-identityₗ-raw {x = A}) = [≡]-intro _≅[_]≅_.suffix-lang ([∪]-identityₗ-raw {x = A}) {c} = [∪]-identityₗ-raw {x = Language.suffix-lang A c} instance [∪]-identityᵣ : Identityᵣ ⦃ [≅]-equiv {s = s} ⦄ (_∪_)(∅) Identityᵣ.proof([∪]-identityᵣ {s = s}) = [∪]-identityᵣ-raw {s = s} where [∪]-identityᵣ-raw : ∀{s} → Names.Identityᵣ ⦃ [≅]-equiv {s = s} ⦄ (_∪_)(∅) _≅[_]≅_.accepts-ε ([∪]-identityᵣ-raw {x = A}) = [≡]-intro _≅[_]≅_.suffix-lang ([∪]-identityᵣ-raw {x = A}) {c} = [∪]-identityᵣ-raw {x = Language.suffix-lang A c} instance [∪]-identity : Identity ⦃ [≅]-equiv {s = s} ⦄ (_∪_)(∅) [∪]-identity = intro instance [∪]-absorberₗ : Absorberₗ ⦃ [≅]-equiv {s = s} ⦄ (_∪_)(𝐔) Absorberₗ.proof([∪]-absorberₗ {s = s}) = [∪]-absorberₗ-raw {s = s} where [∪]-absorberₗ-raw : ∀{s} → Names.Absorberₗ ⦃ [≅]-equiv {s = s} ⦄ (_∪_)(𝐔) _≅[_]≅_.accepts-ε ([∪]-absorberₗ-raw {x = A}) = [≡]-intro _≅[_]≅_.suffix-lang ([∪]-absorberₗ-raw {x = A}) {c} = [∪]-absorberₗ-raw {x = Language.suffix-lang A c} instance [∪]-absorberᵣ : Absorberᵣ ⦃ [≅]-equiv {s = s} ⦄ (_∪_)(𝐔) Absorberᵣ.proof([∪]-absorberᵣ {s = s}) = [∪]-absorberᵣ-raw {s = s} where [∪]-absorberᵣ-raw : ∀{s} → Names.Absorberᵣ ⦃ [≅]-equiv {s = s} ⦄ (_∪_)(𝐔) _≅[_]≅_.accepts-ε ([∪]-absorberᵣ-raw {x = A}) = [≡]-intro _≅[_]≅_.suffix-lang ([∪]-absorberᵣ-raw {x = A}) {c} = [∪]-absorberᵣ-raw {x = Language.suffix-lang A c} instance [∪]-absorber : Absorber ⦃ [≅]-equiv {s = s} ⦄ (_∪_)(𝐔) [∪]-absorber = intro instance [∪]-binary-operator : BinaryOperator ⦃ [≅]-equiv {s = s} ⦄ ⦃ [≅]-equiv {s = s} ⦄ ⦃ [≅]-equiv {s = s} ⦄ (_∪_) BinaryOperator.congruence([∪]-binary-operator {s = s}) = [∪]-binary-operator-raw {s = s} where [∪]-binary-operator-raw : ∀{s} → Names.Congruence₂ ⦃ [≅]-equiv {s = s} ⦄ ⦃ [≅]-equiv {s = s} ⦄ ⦃ [≅]-equiv {s = s} ⦄ (_∪_) _≅[_]≅_.accepts-ε ([∪]-binary-operator-raw aeq beq) = [≡]-with-op(_||_) (_≅[_]≅_.accepts-ε aeq) (_≅[_]≅_.accepts-ε beq) _≅[_]≅_.suffix-lang ([∪]-binary-operator-raw aeq beq) = [∪]-binary-operator-raw (_≅[_]≅_.suffix-lang aeq) (_≅[_]≅_.suffix-lang beq) instance [∪]-monoid : Monoid ⦃ [≅]-equiv {s = s} ⦄ (_∪_) Monoid.identity-existence [∪]-monoid = [∃]-intro(∅) instance [∩]-associativity : Associativity ⦃ [≅]-equiv {s = s} ⦄ (_∩_) Associativity.proof([∩]-associativity {s = s}) = [∩]-associativity-raw {s = s} where [∩]-associativity-raw : ∀{s} → Names.Associativity ⦃ [≅]-equiv {s = s} ⦄ (_∩_) _≅[_]≅_.accepts-ε ([∩]-associativity-raw {x = A}) = associativity(_&&_) {Language.accepts-ε A} _≅[_]≅_.suffix-lang ([∩]-associativity-raw {x = A}) {c} = [∩]-associativity-raw {x = Language.suffix-lang A c} instance [∩]-commutativity : Commutativity ⦃ [≅]-equiv {s = s} ⦄ (_∩_) Commutativity.proof([∩]-commutativity {s = s}) = [∩]-commutativity-raw {s = s} where [∩]-commutativity-raw : ∀{s} → Names.Commutativity ⦃ [≅]-equiv {s = s} ⦄ (_∩_) _≅[_]≅_.accepts-ε ([∩]-commutativity-raw {x = A}) = commutativity(_&&_) {Language.accepts-ε A} _≅[_]≅_.suffix-lang ([∩]-commutativity-raw {x = A}) {c} = [∩]-commutativity-raw {x = Language.suffix-lang A c} instance [∩]-identityₗ : Identityₗ ⦃ [≅]-equiv {s = s} ⦄ (_∩_)(𝐔) Identityₗ.proof([∩]-identityₗ {s = s}) = [∩]-identityₗ-raw {s = s} where [∩]-identityₗ-raw : ∀{s} → Names.Identityₗ ⦃ [≅]-equiv {s = s} ⦄ (_∩_)(𝐔) _≅[_]≅_.accepts-ε ([∩]-identityₗ-raw {x = A}) = [≡]-intro _≅[_]≅_.suffix-lang ([∩]-identityₗ-raw {x = A}) {c} = [∩]-identityₗ-raw {x = Language.suffix-lang A c} instance [∩]-identityᵣ : Identityᵣ ⦃ [≅]-equiv {s = s} ⦄ (_∩_)(𝐔) Identityᵣ.proof([∩]-identityᵣ {s = s}) = [∩]-identityᵣ-raw {s = s} where [∩]-identityᵣ-raw : ∀{s} → Names.Identityᵣ ⦃ [≅]-equiv {s = s} ⦄ (_∩_)(𝐔) _≅[_]≅_.accepts-ε ([∩]-identityᵣ-raw {x = A}) = [≡]-intro _≅[_]≅_.suffix-lang ([∩]-identityᵣ-raw {x = A}) {c} = [∩]-identityᵣ-raw {x = Language.suffix-lang A c} instance [∩]-identity : Identity ⦃ [≅]-equiv {s = s} ⦄ (_∩_)(𝐔) [∩]-identity = intro instance [∩]-absorberₗ : Absorberₗ ⦃ [≅]-equiv {s = s} ⦄ (_∩_)(∅) Absorberₗ.proof([∩]-absorberₗ {s = s}) = [∩]-absorberₗ-raw {s = s} where [∩]-absorberₗ-raw : ∀{s} → Names.Absorberₗ ⦃ [≅]-equiv {s = s} ⦄ (_∩_)(∅) _≅[_]≅_.accepts-ε ([∩]-absorberₗ-raw {x = A}) = [≡]-intro _≅[_]≅_.suffix-lang ([∩]-absorberₗ-raw {x = A}) {c} = [∩]-absorberₗ-raw {x = Language.suffix-lang A c} instance [∩]-absorberᵣ : Absorberᵣ ⦃ [≅]-equiv {s = s} ⦄ (_∩_)(∅) Absorberᵣ.proof([∩]-absorberᵣ {s = s}) = [∩]-absorberᵣ-raw {s = s} where [∩]-absorberᵣ-raw : ∀{s} → Names.Absorberᵣ ⦃ [≅]-equiv {s = s} ⦄ (_∩_)(∅) _≅[_]≅_.accepts-ε ([∩]-absorberᵣ-raw {x = A}) = [≡]-intro _≅[_]≅_.suffix-lang ([∩]-absorberᵣ-raw {x = A}) {c} = [∩]-absorberᵣ-raw {x = Language.suffix-lang A c} instance [∩]-absorber : Absorber ⦃ [≅]-equiv {s = s} ⦄ (_∩_)(∅) [∩]-absorber = intro instance [∩]-binary-operator : BinaryOperator ⦃ [≅]-equiv {s = s} ⦄ ⦃ [≅]-equiv {s = s} ⦄ ⦃ [≅]-equiv {s = s} ⦄ (_∩_) BinaryOperator.congruence([∩]-binary-operator {s = s}) = [∩]-binary-operator-raw {s = s} where [∩]-binary-operator-raw : ∀{s} → Names.Congruence₂ ⦃ [≅]-equiv {s = s} ⦄ ⦃ [≅]-equiv {s = s} ⦄ ⦃ [≅]-equiv {s = s} ⦄(_∩_) _≅[_]≅_.accepts-ε ([∩]-binary-operator-raw aeq beq) = [≡]-with-op(_&&_) (_≅[_]≅_.accepts-ε aeq) (_≅[_]≅_.accepts-ε beq) _≅[_]≅_.suffix-lang ([∩]-binary-operator-raw aeq beq) = [∩]-binary-operator-raw (_≅[_]≅_.suffix-lang aeq) (_≅[_]≅_.suffix-lang beq) instance [∩]-monoid : Monoid ⦃ [≅]-equiv {s = s} ⦄ (_∩_) Monoid.identity-existence [∩]-monoid = [∃]-intro(𝐔) instance [∪][∩]-distributivityₗ : Distributivityₗ ⦃ [≅]-equiv {s = s} ⦄ (_∪_)(_∩_) Distributivityₗ.proof([∪][∩]-distributivityₗ {s = s}) = [∪][∩]-distributivityₗ-raw {s = s} where [∪][∩]-distributivityₗ-raw : ∀{s} → Names.Distributivityₗ ⦃ [≅]-equiv {s = s} ⦄ (_∪_)(_∩_) _≅[_]≅_.accepts-ε ([∪][∩]-distributivityₗ-raw {x = A}) = distributivityₗ(_||_)(_&&_) {x = Language.accepts-ε A} _≅[_]≅_.suffix-lang ([∪][∩]-distributivityₗ-raw {x = A}) {c} = [∪][∩]-distributivityₗ-raw {x = Language.suffix-lang A c} instance [∩][∪]-distributivityₗ : Distributivityₗ ⦃ [≅]-equiv {s = s} ⦄ (_∩_)(_∪_) Distributivityₗ.proof([∩][∪]-distributivityₗ {s = s}) = [∩][∪]-distributivityₗ-raw {s = s} where [∩][∪]-distributivityₗ-raw : ∀{s} → Names.Distributivityₗ ⦃ [≅]-equiv {s = s} ⦄ (_∩_)(_∪_) _≅[_]≅_.accepts-ε ([∩][∪]-distributivityₗ-raw {x = A}) = distributivityₗ(_&&_)(_||_) {x = Language.accepts-ε A} _≅[_]≅_.suffix-lang ([∩][∪]-distributivityₗ-raw {x = A}) {c} = [∩][∪]-distributivityₗ-raw {x = Language.suffix-lang A c} instance [𝁼][∪]-distributivityₗ : Distributivityₗ ⦃ [≅]-equiv {s = s} ⦄ (_𝁼_)(_∪_) Distributivityₗ.proof ([𝁼][∪]-distributivityₗ {s = s}) = [𝁼][∪]-distributivityₗ-raw {s = s} where [𝁼][∪]-distributivityₗ-raw : ∀{s} → Names.Distributivityₗ ⦃ [≅]-equiv {s = s} ⦄ (_𝁼_)(_∪_) _≅[_]≅_.accepts-ε ([𝁼][∪]-distributivityₗ-raw {x = x}) with accepts x ... | 𝑇 = [≡]-intro ... | 𝐹 = [≡]-intro _≅[_]≅_.suffix-lang ([𝁼][∪]-distributivityₗ-raw {x = x}{y}{z}) {c} with accepts x ... | 𝑇 = ((suffix x c) 𝁼 (y ∪ z)) ∪ ((suffix y c) ∪ (suffix z c)) 🝖[ _≅_ ]-[ congruence₂ₗ(_∪_) _ [𝁼][∪]-distributivityₗ-raw ] (((suffix x c) 𝁼 y) ∪ ((suffix x c) 𝁼 z)) ∪ ((suffix y c) ∪ (suffix z c)) 🝖[ _≅_ ]-[ One.associate-commute4 (commutativity(_∪_)) ] (((suffix x c) 𝁼 y) ∪ (suffix y c)) ∪ (((suffix x c) 𝁼 z) ∪ (suffix z c)) 🝖[ _≅_ ]-end ... | 𝐹 = [𝁼][∪]-distributivityₗ-raw {-TODO idempotence-by-dist-id-abs-idemp x ∪ x (x ∩ x) ∪ (x ∩ x) (x ∪ x) ∩ x (x ∪ x) ∩ (x ∪ ∅) x ∪ (x ∩ ∅) x ∪ ∅ x idempotence-by-dist-inv-id x ∪ x (x ∪ x) ∩ 𝐔 (x ∪ x) ∩ (x ∪ (∁ x)) x ∪ (x ∩ (∁ x)) x ∪ ∅ x -} instance [𝁼][∪]-distributivityᵣ : Distributivityᵣ ⦃ [≅]-equiv {s = s} ⦄ (_𝁼_)(_∪_) Distributivityᵣ.proof ([𝁼][∪]-distributivityᵣ {s}) = [𝁼][∪]-distributivityᵣ-raw where [𝁼][∪]-distributivityᵣ-raw : ∀{s} → Names.Distributivityᵣ ⦃ [≅]-equiv {s = s} ⦄ (_𝁼_)(_∪_) _≅[_]≅_.accepts-ε ([𝁼][∪]-distributivityᵣ-raw {x = x}{y}{z}) with accepts z ... | 𝑇 = [≡]-intro ... | 𝐹 = [≡]-intro _≅[_]≅_.suffix-lang ([𝁼][∪]-distributivityᵣ-raw {x = x}{y}{z}) {c} with accepts x | accepts y ... | 𝑇 | 𝑇 = (((suffix x c) ∪ (suffix y c)) 𝁼 z) ∪ (suffix z c) 🝖[ _≅_ ]-[ congruence₂ₗ(_∪_) _ [𝁼][∪]-distributivityᵣ-raw ] (((suffix x c) 𝁼 z) ∪ ((suffix y c) 𝁼 z)) ∪ (suffix z c) 🝖[ _≅_ ]-[ congruence₂ᵣ(_∪_) _ {!!} ]-sym (((suffix x c) 𝁼 z) ∪ ((suffix y c) 𝁼 z)) ∪ ((suffix z c) ∪ (suffix z c)) 🝖[ _≅_ ]-[ One.associate-commute4 (commutativity(_∪_)) ] (((suffix x c) 𝁼 z) ∪ (suffix z c)) ∪ (((suffix y c) 𝁼 z) ∪ (suffix z c)) 🝖[ _≅_ ]-end ... | 𝑇 | 𝐹 = {!!} ... | 𝐹 | 𝑇 = {!!} ... | 𝐹 | 𝐹 = {!!} instance [𝁼]-associativity : Associativity ⦃ [≅]-equiv {s = s} ⦄ (_𝁼_) Associativity.proof ([𝁼]-associativity {s = s}) = [𝁼]-associativity-raw {s = s} where [𝁼]-associativity-raw : ∀{s} → Names.Associativity ⦃ [≅]-equiv {s = s} ⦄ (_𝁼_) _≅[_]≅_.accepts-ε ([𝁼]-associativity-raw {s = s} {x} {y} {z} ) with Language.accepts-ε(x) ... | 𝑇 = [≡]-intro ... | 𝐹 = [≡]-intro _≅[_]≅_.suffix-lang ([𝁼]-associativity-raw {s = s} {x} {y} {z}) {c} {sₛ} with [𝁼]-associativity-raw {s = sₛ} {suffix x c}{y}{z} | accepts(x) | accepts(y) ... | p | 𝑇 | 𝑇 = ((((suffix x c) 𝁼 y) ∪ (suffix y c)) 𝁼 z) ∪ (suffix z c) 🝖[ _≅_ ]-[ congruence₂ₗ(_∪_) _ (distributivityᵣ(_𝁼_)(_∪_)) ] ((((suffix x c) 𝁼 y) 𝁼 z) ∪ ((suffix y c) 𝁼 z)) ∪ (suffix z c) 🝖[ _≅_ ]-[ congruence₂ₗ(_∪_) _ (congruence₂ₗ(_∪_) _ p) ] (((suffix x c) 𝁼 (y 𝁼 z)) ∪ ((suffix y c) 𝁼 z)) ∪ (suffix z c) 🝖[ _≅_ ]-[ associativity(_∪_) ] ((suffix x c) 𝁼 (y 𝁼 z)) ∪ (((suffix y c) 𝁼 z) ∪ (suffix z c)) 🝖[ _≅_ ]-end ... | p | 𝑇 | 𝐹 = (((suffix x c) 𝁼 y) ∪ (suffix y c)) 𝁼 z 🝖[ _≅_ ]-[ distributivityᵣ(_𝁼_)(_∪_) ] (((suffix x c) 𝁼 y) 𝁼 z) ∪ ((suffix y c) 𝁼 z) 🝖[ _≅_ ]-[ congruence₂ₗ(_∪_) _ p ] ((suffix x c) 𝁼 (y 𝁼 z)) ∪ ((suffix y c) 𝁼 z) 🝖[ _≅_ ]-end ... | p | 𝐹 | _ = p {- TODO: Is it possible to describe concatenation using an algebraic property? Maybe something about that it behaves like (_⨯_) (combining every element with each other in some way)? Probably a "Kleene algebra". postulate [𝁼]-identityₗ : Identityₗ(_𝁼_)(ε) -- Identityₗ.proof([𝁼]-identityₗ) {x} = postulate [𝁼]-identityᵣ : Identityᵣ(_𝁼_)(ε) postulate [𝁼]-absorberₗ : Absorberₗ(_𝁼_)(∅) postulate [𝁼]-absorberᵣ : Absorberᵣ(_𝁼_)(∅) -- postulate [*]-fixpoint-[ε] : FixPoint(_*)(ε) postulate [*]-on-[∅] : (∅ * ≡ ε) postulate [*]-on-[*] : ∀{L} → ((L *)* ≡ L *) postulate [𝁼]-commutativity-with-[*] : ∀{L} → ((L *) 𝁼 L ≡ L 𝁼 (L *)) -- postulate [𝁼]-set-algebra : SetAlgebra -- TODO: Complement is missing -} -} module _ {Σ : Alphabet{ℓ}} where open Oper{ℓ}{Σ} open Language renaming (accepts-ε to accepts ; suffix-lang to suffix) open import Logic.IntroInstances open import Structure.Sets.Operator hiding (_∪_ ; _∩_ ; ∁ ; ∅ ; 𝐔) open import Structure.Sets.Relator hiding (_≡_ ; _⊆_) instance [≅]-set-equality : SetEqualityRelation([ s ]_∈_)([ s ]_∈_)(_≅[ s ]≅_) SetEqualityRelation.membership [≅]-set-equality {A}{B} = [↔]-intro (l{A = A}{B = B}) (r{A = A}{B = B}) where l : ∀{A B : Language(Σ)} → (A ≅[ s ]≅ B) ← (∀{w} → ([ s ] w ∈ A) ↔ ([ s ] w ∈ B)) _≅[_]≅_.accepts-ε (l {A = A} {B = B} p) with accepts A | accepts B | p{[]} ... | 𝑇 | 𝑇 | _ = [≡]-intro ... | 𝑇 | 𝐹 | q with () ← [↔]-to-[→] q <> ... | 𝐹 | 𝑇 | q with () ← [↔]-to-[←] q <> ... | 𝐹 | 𝐹 | _ = [≡]-intro _≅[_]≅_.suffix-lang (l {A = A} {B = B} p) {c} = l {A = suffix A c}{B = suffix B c} (\{w} → p{c ⊰ w}) r : ∀{A B : Language(Σ)} → (A ≅[ s ]≅ B) → (∀{w} → ([ s ] w ∈ A) ↔ ([ s ] w ∈ B)) Tuple.left (r ab {[]}) wB = substitute₁ₗ(IsTrue) (_≅[_]≅_.accepts-ε ab) wB Tuple.right (r ab {[]}) wA = substitute₁ᵣ(IsTrue) (_≅[_]≅_.accepts-ε ab) wA Tuple.left (r {s = s} {A} {B} ab {_⊰_ {sₛ} x w}) wB = [↔]-to-[←] (r {s = sₛ} (_≅[_]≅_.suffix-lang {s = s} ab {sₛ = sₛ}) {w}) wB Tuple.right (r {s = s} {A} {B} ab {_⊰_ {sₛ} x w}) wA = [↔]-to-[→] (r {s = sₛ} (_≅[_]≅_.suffix-lang {s = s} ab {sₛ = sₛ}) {w}) wA instance [∪]-operator : UnionOperator([ s ]_∈_)([ s ]_∈_)([ s ]_∈_)(_∪_) UnionOperator.membership [∪]-operator {A}{B}{w} = [↔]-intro (l{w = w}{A}{B}) (r{w = w}{A}{B}) where l : ∀{w}{A B} → ([ s ] w ∈ (A ∪ B)) ← (([ s ] w ∈ A) ∨ ([ s ] w ∈ B)) l {w = []} = [↔]-to-[←] IsTrue.preserves-[||][∨] l {w = c ⊰ w} = l {w = w} r : ∀{w}{A B} → ([ s ] w ∈ (A ∪ B)) → (([ s ] w ∈ A) ∨ ([ s ] w ∈ B)) r {w = []} = [↔]-to-[→] IsTrue.preserves-[||][∨] r {w = c ⊰ w} = r {w = w} instance [∩]-operator : IntersectionOperator([ s ]_∈_)([ s ]_∈_)([ s ]_∈_)(_∩_) IntersectionOperator.membership [∩]-operator {A}{B}{w} = [↔]-intro (l{w = w}{A}{B}) (r{w = w}{A}{B}) where l : ∀{w}{A B} → ([ s ] w ∈ (A ∩ B)) ← (([ s ] w ∈ A) ∧ ([ s ] w ∈ B)) l {w = []} = [↔]-to-[←] IsTrue.preserves-[&&][∧] l {w = c ⊰ w} = l {w = w} r : ∀{w}{A B} → ([ s ] w ∈ (A ∩ B)) → (([ s ] w ∈ A) ∧ ([ s ] w ∈ B)) r {w = []} = [↔]-to-[→] IsTrue.preserves-[&&][∧] r {w = c ⊰ w} = r {w = w} instance [∁]-operator : ComplementOperator([ s ]_∈_)([ s ]_∈_)(∁_) ComplementOperator.membership [∁]-operator {A}{w} = [↔]-intro (l{w = w}{A}) (r{w = w}{A}) where l : ∀{w}{A} → ([ s ] w ∈ (∁ A)) ← ¬([ s ] w ∈ A) l {w = []} = [↔]-to-[←] IsTrue.preserves-[!][¬] l {w = c ⊰ w} = l {w = w} r : ∀{w}{A} → ([ s ] w ∈ (∁ A)) → ¬([ s ] w ∈ A) r {w = []} = [↔]-to-[→] IsTrue.preserves-[!][¬] r {w = c ⊰ w} = r {w = w} instance [∅]-set : EmptySet([ s ]_∈_)(∅) EmptySet.membership [∅]-set {x = w} = p{w = w} where p : ∀{w} → ¬([ s ] w ∈ ∅) p {w = []} () p {w = x ⊰ w} = p {w = w} instance [𝐔]-set : UniversalSet([ s ]_∈_)(𝐔) UniversalSet.membership [𝐔]-set {x = w} = p{w = w} where p : ∀{w} → ([ s ] w ∈ 𝐔) p {w = []} = [⊤]-intro p {w = c ⊰ w} = p {w = w} [ε]-set : ∀{x} → (x ∈ ε) ↔ (x ≡ []) [ε]-set {x} = [↔]-intro (l{x}) (r{x}) where l : ∀{x} → (x ∈ ε) ← (x ≡ []) l {[]} [≡]-intro = [⊤]-intro r : ∀{x} → (x ∈ ε) → (x ≡ []) r {[]} _ = [≡]-intro r {a ⊰ l} proof with () ← [∅]-membership {x = l} proof {-open import Structure.Container.SetLike hiding (_∪_ ; _∩_ ; ∁ ; ∅ ; 𝐔) -- TODO: Copy-pasted from the previous code that only used coinduction instance [𝁼][∪]-distributivityₗ : Distributivityₗ ⦃ [≅]-equiv {s = s} ⦄ (_𝁼_)(_∪_) Distributivityₗ.proof ([𝁼][∪]-distributivityₗ {s = s}) = [𝁼][∪]-distributivityₗ-raw {s = s} where [𝁼][∪]-distributivityₗ-raw : ∀{s} → Names.Distributivityₗ ⦃ [≅]-equiv {s = s} ⦄ (_𝁼_)(_∪_) _≅[_]≅_.accepts-ε ([𝁼][∪]-distributivityₗ-raw {x = x}) with accepts x ... | 𝑇 = [≡]-intro ... | 𝐹 = [≡]-intro _≅[_]≅_.suffix-lang ([𝁼][∪]-distributivityₗ-raw {s = s} {x = x}{y}{z}) {c} with accepts x ... | 𝑇 = ((suffix x c) 𝁼 (y ∪ z)) ∪ ((suffix y c) ∪ (suffix z c)) 🝖[ _≅[ s ]≅_ ]-[ congruence₂ₗ(_∪_) _ [𝁼][∪]-distributivityₗ-raw ] (((suffix x c) 𝁼 y) ∪ ((suffix x c) 𝁼 z)) ∪ ((suffix y c) ∪ (suffix z c)) 🝖[ _≅[ s ]≅_ ]-[ One.associate-commute4 (commutativity(_∪_)) ] (((suffix x c) 𝁼 y) ∪ (suffix y c)) ∪ (((suffix x c) 𝁼 z) ∪ (suffix z c)) 🝖[ _≅[ s ]≅_ ]-end ... | 𝐹 = [𝁼][∪]-distributivityₗ-raw -} {- -- TODO: Sizes and (_++_) [𝁼]-membershipₗ : ∀{x y}{A B : Language(Σ)} → ([ s ] x ∈ A) → ([ s ] y ∈ B) → ([ s ] (x ++ y) ∈ (A 𝁼 B)) [𝁼]-membershipₗ {x = []} {[]} {A}{B} xA yB with accepts A | accepts B ... | 𝑇 | 𝑇 = <> [𝁼]-membershipₗ {x = []} {c ⊰ y}{A}{B} xA yB with accepts A ... | 𝑇 = [↔]-to-[←] (Union.membership {a = suffix A c 𝁼 B} {b = suffix B c} {x = y}) ([∨]-introᵣ yB) [𝁼]-membershipₗ {x = c ⊰ x}{y}{A}{B} xA yB with accepts A ... | 𝑇 = {!!} ... | 𝐹 = [𝁼]-membershipₗ {x = x}{y}{suffix A c}{B} {!xA!} {!!} -} -- [𝁼]-membershipₗ {[]}{y}{suffix } -- [↔]-to-[←] (Union.membership {a = {!!}}{b = {!!}}{x = {!!}}) ([∨]-introᵣ yB) {- single-containment : ⦃ _ : ComputablyDecidable(_≡_) ⦄ → ∀{x}{a} → (x ∈ single(a)) ↔ (x ≡ singleton(a)) single-containment ⦃ dec ⦄ = [↔]-intro l r where postulate l : ∀{x}{a} → (x ∈ single(a)) ← (x ≡ singleton(a)) {-l {c ⊰ w} [≡]-intro with ComputablyDecidable.decide(_≡_) ⦃ dec ⦄ c c ... | 𝑇 = {!!} ... | 𝐹 = {!!}-} postulate r : ∀{x}{a} → (x ∈ single(a)) → (x ≡ singleton(a)) --r {c ⊰ w} p = {![↔]-to-[←] (ComputablyDecidable.proof-istrue(_≡_) {x = ?}) ?!} Language-list-suffix : Language(Σ) → List(Σ) → Language(Σ) Language-list-suffix A [] = A Language-list-suffix A (x ⊰ l) = Language.suffix-lang(A)(x) postulate suffix-concat-step : ∀{A : Language(Σ)}{l₁ l₂} → ((l₁ ++ l₂) ∈ A) → (l₂ ∈ Language-list-suffix(A)(l₁)) -- suffix-concat-step {A}{[]} p = p -- suffix-concat-step {A}{x ⊰ l₁}{l₂} p = {!!} postulate [𝁼]-containmentₗ : ∀{x y}{A B : Language(Σ)} → (x ∈ A) → (y ∈ B) → ((x ++ y) ∈ (A 𝁼 B)) -- [𝁼]-containmentₗ {x} {y} {A} {B} xa xb with Language.accepts-ε(A) | y Oper.∈? B {-[𝁼]-containmentₗ {LongOper.empty} {LongOper.empty} {A} {B} xa xb with Language.accepts-ε(A) | Language.accepts-ε(B) [𝁼]-containmentₗ {LongOper.empty} {LongOper.empty} {A} {B} xa xb | 𝑇 | 𝑇 = [⊤]-intro [𝁼]-containmentₗ {LongOper.empty} {LongOper.prepend x y} {A} {B} xa xb = {![⊤]-intro!} where test : ∀{A B : Language(Σ)}{a} → ([] ∈ A) → (a ∈ B) → (a ∈ (A 𝁼 B)) test {A}{B}{LongOper.empty} p q with Language.accepts-ε(A) | Language.accepts-ε(B) test {A}{B}{LongOper.empty} p q | 𝑇 | 𝑇 = [⊤]-intro test {A}{B}{LongOper.prepend x a} p q = {!test {A}{B}{a} p !} -- test {LongOper.prepend x a} p q with test {a} p (Language.suffix-lang q) -- ... | test = ? [𝁼]-containmentₗ {LongOper.prepend x x₁} {LongOper.empty} {A} {B} xa xb = {!!} [𝁼]-containmentₗ {LongOper.prepend x x₁} {LongOper.prepend x₂ y} {A} {B} xa xb = {!!} -} -- [𝁼]-containment : ∀{x}{A B : Language(Σ)} → (x ∈ (A 𝁼 B)) ↔ ∃(a ↦ ∃ b ↦ (a ++ b ≡ x)∧(a ∈ A)∧(b ∈ B)) -- [𝁼]-containment {x} = [↔]-intro (l{x}) (r{x}) where -- TODO: Set properties -- TODO: Connection with logic (from sets) in relations -}
{ "alphanum_fraction": 0.5112946887, "avg_line_length": 50.0607476636, "ext": "agda", "hexsha": "eafbec6774d16517c840503cdf31f06be1f8de7a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "FormalLanguage/Proofs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "FormalLanguage/Proofs.agda", "max_line_length": 213, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "FormalLanguage/Proofs.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 9975, "size": 21426 }
module comb where infixr 50 _⟶_ data Ty : Set where ι : Ty _⟶_ : Ty -> Ty -> Ty data Tm : Ty -> Set where K : {σ τ : Ty} -> Tm (σ ⟶ τ ⟶ σ) S : {σ τ ρ : Ty} -> Tm ((σ ⟶ τ ⟶ ρ) ⟶ (σ ⟶ τ) ⟶ σ ⟶ ρ) _$_ : {σ τ : Ty} -> Tm (σ ⟶ τ) -> Tm σ -> Tm τ data Nf : Ty -> Set where Kⁿ : {σ τ : Ty} -> Nf (σ ⟶ τ ⟶ σ) Kⁿ¹ : {σ τ : Ty} -> Nf σ -> Nf (τ ⟶ σ) Sⁿ : {σ τ ρ : Ty} -> Nf ((σ ⟶ τ ⟶ ρ) ⟶ (σ ⟶ τ) ⟶ σ ⟶ ρ) Sⁿ¹ : {σ τ ρ : Ty} -> Nf (σ ⟶ τ ⟶ ρ) -> Nf ((σ ⟶ τ) ⟶ σ ⟶ ρ) Sⁿ² : {σ τ ρ : Ty} -> Nf (σ ⟶ τ ⟶ ρ) -> Nf (σ ⟶ τ) -> Nf (σ ⟶ ρ) _$$_ : {σ τ : Ty} -> Nf (σ ⟶ τ) -> Nf σ -> Nf τ Kⁿ $$ x = Kⁿ¹ x Kⁿ¹ x $$ y = x Sⁿ $$ x = Sⁿ¹ x Sⁿ¹ x $$ y = Sⁿ² x y Sⁿ² x y $$ z = (x $$ z) $$ (y $$ z) nf : {σ : Ty} -> Tm σ -> Nf σ nf K = Kⁿ nf S = Sⁿ nf (t $ u) = nf t $$ nf u data _$ⁿ_⇓_ : {σ τ : Ty} -> Nf (σ ⟶ τ) -> Nf σ -> Nf τ -> Set where rKⁿ : {σ τ : Ty} -> {x : Nf σ} -> Kⁿ {σ} {τ} $ⁿ x ⇓ Kⁿ¹ x rKⁿ¹ : {σ τ : Ty} -> {x : Nf σ} -> {y : Nf τ} -> Kⁿ¹ x $ⁿ y ⇓ x rSⁿ : {σ τ ρ : Ty} -> {x : Nf (σ ⟶ τ ⟶ ρ)} -> Sⁿ $ⁿ x ⇓ Sⁿ¹ x rSⁿ¹ : {σ τ ρ : Ty} -> {x : Nf (σ ⟶ τ ⟶ ρ)} -> {y : Nf (σ ⟶ τ)} -> Sⁿ¹ x $ⁿ y ⇓ Sⁿ² x y rSⁿ² : {σ τ ρ : Ty} -> {x : Nf (σ ⟶ τ ⟶ ρ)} -> {y : Nf (σ ⟶ τ)} -> {z : Nf σ} -> {u : Nf (τ ⟶ ρ)} -> x $ⁿ z ⇓ u -> {v : Nf τ} -> y $ⁿ z ⇓ v -> {w : Nf ρ} -> u $ⁿ v ⇓ w -> Sⁿ² x y $ⁿ z ⇓ w data _⇓_ : {σ : Ty} -> Tm σ -> Nf σ -> Set where rK : {σ τ : Ty} -> K {σ} {τ} ⇓ Kⁿ rS : {σ τ ρ : Ty} -> S {σ} {τ} {ρ} ⇓ Sⁿ r$ : {σ τ : Ty} -> {t : Tm (σ ⟶ τ)} -> {f : Nf (σ ⟶ τ)} -> t ⇓ f -> {u : Tm σ} -> {a : Nf σ} -> u ⇓ a -> {v : Nf τ} -> f $ⁿ a ⇓ v -> t $ u ⇓ v data _==_ {A : Set}(a : A) : {B : Set} -> (b : B) -> Set where refl : a == a data Σ {A : Set}(B : A -> Set) : Set where sig : (a : A) -> (b : B a) -> Σ B σ₀ : {A : Set} -> {B : A -> Set} -> Σ B -> A σ₀ (sig x _) = x σ₁ : {A : Set} -> {B : A -> Set} -> (s : Σ B) -> B (σ₀ s) σ₁ (sig _ y) = y _$$⁼_&_ : {σ τ : Ty} -> (f : Nf (σ ⟶ τ)) -> (a : Nf σ) -> {n : Nf τ} -> f $ⁿ a ⇓ n -> Σ \(n' : Nf τ) -> n' == n Kⁿ $$⁼ x & rKⁿ = sig (Kⁿ¹ x) refl Kⁿ¹ x $$⁼ y & rKⁿ¹ = sig x refl Sⁿ $$⁼ x & rSⁿ = sig (Sⁿ¹ x) refl Sⁿ¹ x $$⁼ y & rSⁿ¹ = sig (Sⁿ² x y) refl Sⁿ² x y $$⁼ z & (rSⁿ² p q r) with x $$⁼ z & p | y $$⁼ z & q Sⁿ² x y $$⁼ z & (rSⁿ² p q r) | sig u refl | sig v refl with u $$⁼ v & r Sⁿ² x y $$⁼ z & (rSⁿ² p q r) | sig u refl | sig v refl | sig w refl = sig w refl nf⁼ : {σ : Ty} -> (t : Tm σ) -> {n : Nf σ} -> t ⇓ n -> Σ \(n' : Nf σ) -> n' == n nf⁼ K rK = sig Kⁿ refl nf⁼ S rS = sig Sⁿ refl nf⁼ (t $ u) (r$ p q r) with nf⁼ t p | nf⁼ u q nf⁼ (t $ u) (r$ p q r) | sig f refl | sig a refl with f $$⁼ a & r nf⁼ (t $ u) (r$ p q r) | sig f refl | sig a refl | sig v refl = sig v refl proof : {σ : Ty} -> (t : Tm σ) -> Σ \(n : Nf σ) -> t ⇓ n proof = {! !} nf⇓ : {σ : Ty} -> Tm σ -> Nf σ nf⇓ t = σ₀ (nf⁼ t (σ₁ (proof t)))
{ "alphanum_fraction": 0.3696927856, "avg_line_length": 32.5505617978, "ext": "agda", "hexsha": "d08b4abb76e3ba1061ba10698fbda63be2a97dbd", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/Termination/comb.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/Termination/comb.agda", "max_line_length": 76, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "examples/outdated-and-incorrect/Termination/comb.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 1678, "size": 2897 }
{- Constant structure: _ ↦ A -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Structures.Relational.Constant where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Structure open import Cubical.Foundations.RelationalStructure open import Cubical.Structures.Constant private variable ℓ ℓ' : Level -- Structured relations module _ (A : hSet ℓ') where preservesSetsConstant : preservesSets {ℓ = ℓ} (ConstantStructure (A .fst)) preservesSetsConstant _ = A .snd ConstantRelStr : StrRel {ℓ = ℓ} (ConstantStructure (A .fst)) ℓ' ConstantRelStr _ a₀ a₁ = a₀ ≡ a₁ open SuitableStrRel constantSuitableRel : SuitableStrRel {ℓ = ℓ} (ConstantStructure (A .fst)) ConstantRelStr constantSuitableRel .quo _ _ _ = isContrSingl _ constantSuitableRel .symmetric _ = sym constantSuitableRel .transitive _ _ = _∙_ constantSuitableRel .prop _ = A .snd constantRelMatchesEquiv : StrRelMatchesEquiv {ℓ = ℓ} ConstantRelStr (ConstantEquivStr (A .fst)) constantRelMatchesEquiv _ _ _ = idEquiv _
{ "alphanum_fraction": 0.7584070796, "avg_line_length": 27.5609756098, "ext": "agda", "hexsha": "e2f5bbe5f61a157b686de8a06bc02036be75e44a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "RobertHarper/cubical", "max_forks_repo_path": "Cubical/Structures/Relational/Constant.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "RobertHarper/cubical", "max_issues_repo_path": "Cubical/Structures/Relational/Constant.agda", "max_line_length": 97, "max_stars_count": null, "max_stars_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "RobertHarper/cubical", "max_stars_repo_path": "Cubical/Structures/Relational/Constant.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 336, "size": 1130 }
module SystemF.BigStep.Extrinsic.Terms where open import Prelude open import SystemF.BigStep.Types open import Data.List open import Data.Fin.Substitution -- erased (type-free) System F syntax data Term : Set where unit : Term ƛ : Term → Term Λ : Term → Term _·_ : Term → Term → Term _[-] : Term → Term var : ℕ → Term
{ "alphanum_fraction": 0.6987951807, "avg_line_length": 20.75, "ext": "agda", "hexsha": "d432946dcc3ffc6a360ab49c9bcba8638e4afd02", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/SystemF/BigStep/Extrinsic/Terms.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/SystemF/BigStep/Extrinsic/Terms.agda", "max_line_length": 44, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/SystemF/BigStep/Extrinsic/Terms.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 102, "size": 332 }
-- There was a bug with module applications in let. module Issue34 where module A (X : Set) where postulate A : Set T : (X : Set) -> let open A X in A -> Set T X _ = X record B (X : Set) : Set where open A X field f : A postulate foo : (X : Set)(b : B X) -> let open A X open B b in A -> Set
{ "alphanum_fraction": 0.5481927711, "avg_line_length": 17.4736842105, "ext": "agda", "hexsha": "4151289fda91fdd9e2129faee26c2c3a99a36092", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue34.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue34.agda", "max_line_length": 51, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue34.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 111, "size": 332 }
-- Andreas, 2019-11-11, issue #4189, reported by nad. -- Record constructors living in the record module are problematic -- as the record module is parameterized over the record value, -- but the constructor not. -- Thus, a record constructor does not live in the record module -- any more. -- {-# OPTIONS -v tc.mod.apply:100 #-} record ⊤ : Set where constructor tt module Unit = ⊤ renaming (tt to unit) -- WAS: internal error -- NOW: warning about tt not being in scope tt′ : ⊤ tt′ = ⊤.tt -- WAS: success -- NOW: Not in scope: ⊤.tt
{ "alphanum_fraction": 0.6775956284, "avg_line_length": 23.8695652174, "ext": "agda", "hexsha": "c114401602fe8261139309d2904819a407731890", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/Issue4189.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/Issue4189.agda", "max_line_length": 66, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue4189.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 154, "size": 549 }
{-# OPTIONS --instance-search-depth=10 #-} open import Agda.Primitive it : ∀ {a} {A : Set a} {{x : A}} -> A it {{x}} = x infixr 5 _,_ postulate Pair : ∀ {a} (A : Set a) {b} (B : Set b) -> Set (a ⊔ b) _,_ : ∀ {a} {A : Set a} {b} {B : Set b} -> A -> B -> Pair A B data Constraint {a} {A : Set a} (x : A) : Set where mkConstraint : Constraint x record Inner {l a} {A : Set a} (x : A) (_ : Constraint x) (C : Set l) : Set l where field value : C Class : ∀ {l a} {A : Set a} (x : A) (C : Set l) -> Set l Class x C = Inner x mkConstraint C FunctionClass = λ {a} (A : Set a) -> Class A (A -> A) DiagonalClass = λ {i} {I : Set i} {r} (R : I -> I -> Set r) x -> Class (R , x) (R x x) DiagonalFunctionClass = λ {i} {I : Set i} {r} (R : I -> I -> Set r) x -> Class (R , x) (R x x -> R x x) postulate toDiagonalFunctionClass : ∀ {i} {I : Set i} {r} {R : I -> I -> Set r} {{iD : ∀ {x} -> DiagonalClass R x}} -> ∀ {x} -> DiagonalFunctionClass R x DiagonalPropertyType = λ {i r p} {I : Set i} (R : I -> I -> Set r) (P : ∀ x -> R x x -> Set p) -> ∀ x (d : R x x) -> P _ d DiagonalPropertyClass = λ {i r p} {I : Set i} (R : I -> I -> Set r) (P : ∀ x -> R x x -> Set p) (C : FunctionClass I) -> Class (R , P , C) (DiagonalPropertyType R P) diagonalProperty : ∀ {i r p} {I : Set i} {R : I -> I -> Set r} {P : ∀ x -> R x x -> Set p} {{C : FunctionClass I}} {{iDP : DiagonalPropertyClass R P C}} -> DiagonalPropertyType R P diagonalProperty {{iDP = iDP}} = Inner.value iDP -- works-1 works-2 fails : ∀ {r p} {I : Set} {R : I -> I -> Set r} {P : ∀ x -> R x x -> Set p} (C : FunctionClass I) {{iDP : DiagonalPropertyClass R P C}} -> DiagonalPropertyType R P -- works-1 C x d = -- let instance iC = C -- in diagonalProperty _ d -- works-2 C x d = -- let instance iC = C -- iDF = toDiagonalFunctionClass -- in diagonalProperty {{it}} _ d fails C x d = let instance iC = C iDF = toDiagonalFunctionClass in diagonalProperty _ d -- Instance search depth exhausted
{ "alphanum_fraction": 0.5203446625, "avg_line_length": 22.956043956, "ext": "agda", "hexsha": "52d85cc3c75d37e000c452cb324bffa98fc5f3cf", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue2713.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue2713.agda", "max_line_length": 83, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue2713.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 805, "size": 2089 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.CommRing.RadicalIdeal where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Function open import Cubical.Foundations.Powerset using (⊆-isProp) open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.Data.Sum hiding (map) open import Cubical.Data.FinData hiding (elim) open import Cubical.Data.Nat renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_ ; +-comm to +ℕ-comm ; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm ; _choose_ to _ℕchoose_ ; snotz to ℕsnotz) open import Cubical.Data.Nat.Order open import Cubical.HITs.PropositionalTruncation as PT open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.Ideal open import Cubical.Algebra.CommRing.FGIdeal open import Cubical.Algebra.CommRing.BinomialThm open import Cubical.Algebra.Ring.Properties open import Cubical.Algebra.Ring.BigOps open import Cubical.Algebra.RingSolver.ReflectionSolving private variable ℓ : Level module RadicalIdeal (R' : CommRing ℓ) where private R = fst R' open CommRingStr (snd R') open RingTheory (CommRing→Ring R') open Sum (CommRing→Ring R') open CommRingTheory R' open Exponentiation R' open BinomialThm R' open CommIdeal R' open isCommIdeal √ : CommIdeal → CommIdeal fst (√ I) x = (∃[ n ∈ ℕ ] x ^ n ∈ I) , isPropPropTrunc +Closed (snd (√ I)) {x = x} {y = y} = map2 +ClosedΣ where +ClosedΣ : Σ[ n ∈ ℕ ] x ^ n ∈ I → Σ[ n ∈ ℕ ] y ^ n ∈ I → Σ[ n ∈ ℕ ] (x + y) ^ n ∈ I +ClosedΣ (n , xⁿ∈I) (m , yᵐ∈I) = (n +ℕ m) , subst-∈ I (sym (BinomialThm (n +ℕ m) _ _)) ∑Binomial∈I where binomialCoeff∈I : ∀ i → ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ∈ I binomialCoeff∈I i with ≤-+-split n m (toℕ i) (pred-≤-pred (toℕ<n i)) ... | inl n≤i = subst-∈ I (sym path) (·Closed (I .snd) _ xⁿ∈I) where useSolver : ∀ a b c d → a · (b · c) · d ≡ a · b · d · c useSolver = solve R' path : ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ≡ ((n +ℕ m) choose toℕ i) · x ^ (toℕ i ∸ n) · y ^ (n +ℕ m ∸ toℕ i) · x ^ n path = ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ≡⟨ cong (λ k → ((n +ℕ m) choose toℕ i) · x ^ k · y ^ (n +ℕ m ∸ toℕ i)) (sym (≤-∸-+-cancel n≤i)) ⟩ ((n +ℕ m) choose toℕ i) · x ^ ((toℕ i ∸ n) +ℕ n) · y ^ (n +ℕ m ∸ toℕ i) ≡⟨ cong (λ z → ((n +ℕ m) choose toℕ i) · z · y ^ (n +ℕ m ∸ toℕ i)) (sym (·-of-^-is-^-of-+ x (toℕ i ∸ n) n)) ⟩ ((n +ℕ m) choose toℕ i) · (x ^ (toℕ i ∸ n) · x ^ n) · y ^ (n +ℕ m ∸ toℕ i) ≡⟨ useSolver _ _ _ _ ⟩ ((n +ℕ m) choose toℕ i) · x ^ (toℕ i ∸ n) · y ^ (n +ℕ m ∸ toℕ i) · x ^ n ∎ ... | inr m≤n+m-i = subst-∈ I (sym path) (·Closed (I .snd) _ yᵐ∈I) where path : ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ≡ ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ ((n +ℕ m ∸ toℕ i) ∸ m) · y ^ m path = ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ≡⟨ cong (λ k → ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ k) (sym (≤-∸-+-cancel m≤n+m-i)) ⟩ ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (((n +ℕ m ∸ toℕ i) ∸ m) +ℕ m) ≡⟨ cong (((n +ℕ m) choose toℕ i) · x ^ toℕ i ·_) (sym (·-of-^-is-^-of-+ y ((n +ℕ m ∸ toℕ i) ∸ m) m)) ⟩ ((n +ℕ m) choose toℕ i) · x ^ toℕ i · (y ^ ((n +ℕ m ∸ toℕ i) ∸ m) · y ^ m) ≡⟨ ·Assoc _ _ _ ⟩ ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ ((n +ℕ m ∸ toℕ i) ∸ m) · y ^ m ∎ ∑Binomial∈I : ∑ (BinomialVec (n +ℕ m) x y) ∈ I ∑Binomial∈I = ∑Closed I (BinomialVec (n +ℕ m) _ _) binomialCoeff∈I contains0 (snd (√ I)) = ∣ 1 , subst-∈ I (sym (0LeftAnnihilates 1r)) ((I .snd) .contains0) ∣ ·Closed (snd (√ I)) r = map λ { (n , xⁿ∈I) → n , subst-∈ I (sym (^-ldist-· r _ n)) ((I .snd) .·Closed (r ^ n) xⁿ∈I) } ^∈√→∈√ : ∀ (I : CommIdeal) (x : R) (n : ℕ) → x ^ n ∈ √ I → x ∈ √ I ^∈√→∈√ I x n = map (λ { (m , [xⁿ]ᵐ∈I) → (n ·ℕ m) , subst-∈ I (sym (^-rdist-·ℕ x n m)) [xⁿ]ᵐ∈I }) ∈→∈√ : ∀ (I : CommIdeal) (x : R) → x ∈ I → x ∈ √ I ∈→∈√ I _ x∈I = ∣ 1 , subst-∈ I (sym (·Rid _)) x∈I ∣ -- important lemma for characterization of the Zariski lattice open KroneckerDelta (CommRing→Ring R') √FGIdealCharLImpl : {n : ℕ} (V : FinVec R n) (I : CommIdeal) → √ ⟨ V ⟩[ R' ] ⊆ √ I → (∀ i → V i ∈ √ I) √FGIdealCharLImpl V I √⟨V⟩⊆√I i = √⟨V⟩⊆√I _ (∈→∈√ ⟨ V ⟩[ R' ] (V i) ∣ (λ j → δ i j) , sym (∑Mul1r _ _ i) ∣) √FGIdealCharRImpl : {n : ℕ} (V : FinVec R n) (I : CommIdeal) → (∀ i → V i ∈ √ I) → √ ⟨ V ⟩[ R' ] ⊆ √ I √FGIdealCharRImpl V I ∀i→Vi∈√I x = PT.elim (λ _ → √ I .fst x .snd) λ { (n , xⁿ∈⟨V⟩) → ^∈√→∈√ I x n (elimHelper _ xⁿ∈⟨V⟩) } where elimHelper : ∀ (y : R) → y ∈ ⟨ V ⟩[ R' ] → y ∈ √ I elimHelper y = PT.elim (λ _ → √ I .fst y .snd) λ { (α , y≡∑αV) → subst-∈ (√ I) (sym y≡∑αV) (∑Closed (√ I) (λ i → α i · V i) (λ i → √ I .snd .·Closed (α i) (∀i→Vi∈√I i))) } √FGIdealChar : {n : ℕ} (V : FinVec R n) (I : CommIdeal) → √ ⟨ V ⟩[ R' ] ⊆ √ I ≃ (∀ i → V i ∈ √ I) √FGIdealChar V I = propBiimpl→Equiv (⊆-isProp (√ ⟨ V ⟩[ R' ] .fst) (√ I .fst)) (isPropΠ (λ _ → √ I .fst _ .snd)) (√FGIdealCharLImpl V I) (√FGIdealCharRImpl V I) √+RContrLIncl : (I J : CommIdeal) → √ (I +i √ J) ⊆ √ (I +i J) √+RContrLIncl I J x = PT.elim (λ _ → isPropPropTrunc) (uncurry (λ n → PT.elim (λ _ → isPropPropTrunc) (uncurry3 (curriedIncl1 n)))) where curriedIncl1 : (n : ℕ) (y : R × R) → (y .fst ∈ I) → (y . snd ∈ √ J) → (x ^ n ≡ y .fst + y .snd) → x ∈ √ (I +i J) curriedIncl1 n (y , z) y∈I = PT.elim (λ _ → isPropΠ λ _ → isPropPropTrunc) Σhelper where yVec : (m : ℕ) → FinVec R m yVec m = (BinomialVec m y z) ∘ suc ∑yVec∈I : ∀ m → ∑ (yVec m) ∈ I ∑yVec∈I zero = I .snd .contains0 ∑yVec∈I (suc m) = ∑Closed I (yVec (suc m)) λ _ → subst-∈ I (useSolver _ _ _ _) (I .snd .·Closed _ y∈I) where useSolver : (bc y y^i z^m-i : R) → (bc · y^i · z^m-i) · y ≡ bc · (y · y^i) · z^m-i useSolver = solve R' path : (m : ℕ) → x ^ n ≡ y + z → x ^ (n ·ℕ m) ≡ ∑ (yVec m) + z ^ m path m p = x ^ (n ·ℕ m) ≡⟨ ^-rdist-·ℕ x n m ⟩ (x ^ n) ^ m ≡⟨ cong (_^ m) p ⟩ (y + z) ^ m ≡⟨ BinomialThm m y z ⟩ ∑ (BinomialVec m y z) ≡⟨ useSolver _ _ ⟩ ∑ (yVec m) + z ^ m ∎ where useSolver : (zm ∑yVec : R) → 1r · 1r · zm + ∑yVec ≡ ∑yVec + zm useSolver = solve R' Σhelper : Σ[ m ∈ ℕ ] (z ^ m ∈ J) → x ^ n ≡ y + z → x ∈ √ (I +i J) Σhelper (m , z^m∈J) x^n≡y+z = ∣ n ·ℕ m , ∣ (∑ (yVec m) , z ^ m) , ∑yVec∈I m , z^m∈J , path m x^n≡y+z ∣ ∣ √+RContrRIncl : (I J : CommIdeal) → √ (I +i J) ⊆ √ (I +i √ J) √+RContrRIncl I J x = PT.elim (λ _ → isPropPropTrunc) (uncurry curriedIncl2) where curriedIncl2 : (n : ℕ) → (x ^ n ∈ (I +i J)) → x ∈ √ ((I +i √ J)) curriedIncl2 n = map λ ((y , z) , y∈I , z∈J , x≡y+z) → n , ∣ (y , z) , y∈I , ∈→∈√ J z z∈J , x≡y+z ∣ √+RContr : (I J : CommIdeal) → √ (I +i √ J) ≡ √ (I +i J) √+RContr I J = CommIdeal≡Char (√+RContrLIncl I J) (√+RContrRIncl I J) √+LContr : (I J : CommIdeal) → √ (√ I +i J) ≡ √ (I +i J) √+LContr I J = cong √ (+iComm (√ I) J) ∙∙ √+RContr J I ∙∙ cong √ (+iComm J I) √·RContrLIncl : (I J : CommIdeal) → √ (I ·i √ J) ⊆ √ (I ·i J) √·RContrLIncl I J x = PT.elim (λ _ → isPropPropTrunc) (uncurry (λ n → PT.elim (λ _ → isPropPropTrunc) (uncurry4 (curriedIncl1 n)))) where curriedIncl1 : (n m : ℕ) (α : FinVec R m × FinVec R m) → (∀ i → α .fst i ∈ I) → (∀ i → α .snd i ∈ √ J) → (x ^ n ≡ linearCombination R' (α .fst) (α .snd)) → x ∈ √ (I ·i J) curriedIncl1 n m (α , β) α∈I β∈√J xⁿ≡∑αβ = ^∈√→∈√ (I ·i J) x n (subst-∈ (√ (I ·i J)) (sym xⁿ≡∑αβ) (∑Closed (√ (I ·i J)) (λ i → α i · β i) λ i → prodHelper i (β∈√J i))) where curriedHelper : ∀ x y → x ∈ I → ∀ l → y ^ l ∈ J → (x · y) ∈ √ (I ·i J) curriedHelper x y x∈I zero 1∈J = subst (λ K → (x · y) ∈ √ K) (sym (·iRContains1id I J 1∈J)) --1∈J → √J ≡ √ ⊃ I (∈→∈√ I _ (·RClosed (I .snd) y x∈I)) curriedHelper x y x∈I (suc l) y^l+1∈J = -- (xy)^l+1 ≡ x^l · x (∈I) · y^l+1 (∈J) ∣ suc l , subst-∈ (I ·i J) (sym (^-ldist-· _ _ (suc l))) (prodInProd I J _ _ (subst-∈ I (·-comm _ _) (I .snd .·Closed (x ^ l) x∈I)) y^l+1∈J) ∣ prodHelper : ∀ i → β i ∈ √ J → α i · β i ∈ √ (I ·i J) prodHelper i = PT.elim (λ _ → isPropPropTrunc) (uncurry (curriedHelper (α i) (β i) (α∈I i))) √·RContrRIncl : (I J : CommIdeal) → √ (I ·i J) ⊆ √ (I ·i √ J) √·RContrRIncl I J x = PT.elim (λ _ → isPropPropTrunc) (uncurry curriedIncl2) where curriedIncl2 : (n : ℕ) → x ^ n ∈ (I ·i J) → x ∈ √ (I ·i √ J) curriedIncl2 n = map λ (m , (α , β) , α∈I , β∈J , xⁿ≡∑αβ) → n , ∣ m , (α , β) , α∈I , (λ i → ∈→∈√ J (β i) (β∈J i)) , xⁿ≡∑αβ ∣ √·RContr : (I J : CommIdeal) → √ (I ·i √ J) ≡ √ (I ·i J) √·RContr I J = CommIdeal≡Char (√·RContrLIncl I J) (√·RContrRIncl I J) √·LContr : (I J : CommIdeal) → √ (√ I ·i J) ≡ √ (I ·i J) √·LContr I J = cong √ (·iComm (√ I) J) ∙∙ √·RContr J I ∙∙ cong √ (·iComm J I) √·IdemLIncl : ∀ (I : CommIdeal) → √ (I ·i I) ⊆ √ I √·IdemLIncl I x = map λ (n , x^n∈II) → (n , ·iLincl I I _ x^n∈II) √·IdemRIncl : ∀ (I : CommIdeal) → √ I ⊆ √ (I ·i I) √·IdemRIncl I x = map λ (n , x^n∈I) → (n +ℕ n , subst-∈ (I ·i I) (·-of-^-is-^-of-+ x n n) -- x²ⁿ≡xⁿ (∈I) · xⁿ (∈I) (prodInProd I I _ _ x^n∈I x^n∈I)) √·Idem : ∀ (I : CommIdeal) → √ (I ·i I) ≡ √ I √·Idem I = CommIdeal≡Char (√·IdemLIncl I) (√·IdemRIncl I) √·Absorb+LIncl : ∀ (I J : CommIdeal) → √ (I ·i (I +i J)) ⊆ √ I √·Absorb+LIncl I J x = map λ (n , x^n∈I[I+J]) → (n , ·iLincl I (I +i J) _ x^n∈I[I+J]) √·Absorb+RIncl : ∀ (I J : CommIdeal) → √ I ⊆ √ (I ·i (I +i J)) √·Absorb+RIncl I J x = map λ (n , x^n∈I) → (n +ℕ n , subst-∈ (I ·i (I +i J)) (·-of-^-is-^-of-+ x n n) -- x²ⁿ≡xⁿ (∈I) · xⁿ (∈I⊆I+J) (prodInProd I (I +i J) _ _ x^n∈I (+iLincl I J _ x^n∈I))) √·Absorb+ : ∀ (I J : CommIdeal) → √ (I ·i (I +i J)) ≡ √ I √·Absorb+ I J = CommIdeal≡Char (√·Absorb+LIncl I J) (√·Absorb+RIncl I J)
{ "alphanum_fraction": 0.4514181153, "avg_line_length": 46.313559322, "ext": "agda", "hexsha": "2e4d95f1d41b3e2db52b7d9808710a916de34645", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dolio/cubical", "max_forks_repo_path": "Cubical/Algebra/CommRing/RadicalIdeal.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dolio/cubical", "max_issues_repo_path": "Cubical/Algebra/CommRing/RadicalIdeal.agda", "max_line_length": 96, "max_stars_count": null, "max_stars_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dolio/cubical", "max_stars_repo_path": "Cubical/Algebra/CommRing/RadicalIdeal.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5112, "size": 10930 }
module sum-thms where open import eq open import sum open import list open import product open import negation inj₁-inj : ∀{ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'}{x : A}{x'} → inj₁{ℓ}{ℓ'}{A}{B} x ≡ inj₁ x' → x ≡ x' inj₁-inj refl = refl ¬∨ : ∀ {A B : Set} → ¬ A ∧ ¬ B → ¬ (A ∨ B) ¬∨ (u , u') (inj₁ x) = u x ¬∨ (u , u') (inj₂ y) = u' y ¬Σ : ∀{A : Set}{B : A → Set} → (∀(x : A) → ¬ B x) → ¬ Σ A B ¬Σ p (a , b) = p a b ¬∧1 : ∀ {A B : Set} → ¬ A → ¬ (A ∧ B) ¬∧1 f (a , b) = f a ¬∧2 : ∀ {A B : Set} → ¬ B → ¬ (A ∧ B) ¬∧2 f (a , b) = f b ¬∀ : ∀{A : Set}{B : A → Set} → Σ A (λ x → ¬ B x) → ¬ ∀(x : A) → B x ¬∀ (a , b) f = b (f a)
{ "alphanum_fraction": 0.4048387097, "avg_line_length": 22.962962963, "ext": "agda", "hexsha": "e2f5fe0ad2ca2d9fbae49e0df99e34db9ce4de4c", "lang": "Agda", "max_forks_count": 17, "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rfindler/ial", "max_forks_repo_path": "sum-thms.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rfindler/ial", "max_issues_repo_path": "sum-thms.agda", "max_line_length": 93, "max_stars_count": 29, "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rfindler/ial", "max_stars_repo_path": "sum-thms.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "num_tokens": 337, "size": 620 }
{-# OPTIONS --safe --without-K #-} -- Proof relevant separation algebras module Relation.Ternary.Separation where open import Function open import Level open import Data.Unit using (tt; ⊤) open import Data.Product hiding (map) open import Data.List.Relation.Ternary.Interleaving.Propositional hiding (map) open import Data.List.Relation.Binary.Equality.Propositional open import Relation.Unary hiding (Empty) open import Relation.Unary.PredicateTransformer using (Pt) open import Relation.Binary hiding (_⇒_) open import Relation.Binary.PropositionalEquality as P using (_≡_) open import Algebra open import Algebra.Structures using (IsMonoid) open import Algebra.FunctionProperties.Core ∥_∥ : ∀ {ℓ a} {A : Set a} {P : Pred A ℓ} {Φ} → P Φ → A ∥_∥ {Φ = Φ} _ = Φ Exactly : ∀ {a} {A : Set a} → A → Pred A a Exactly x y = y ≡ x module _ where open import Data.List Just : ∀ {a} {A : Set a} → A → Pred (List A) _ Just t = Exactly [ t ] record RawSep {a} (Carrier : Set a) : Set (suc a) where SPred : (ℓ : Level) → Set _ SPred ℓ = Pred Carrier ℓ field _⊎_≣_ : (Φ₁ Φ₂ : Carrier) → SPred a -- we can see the three point relation as a predicate on the carrier _⊎_ = _⊎_≣_ -- buy one, get a preorder for free _≤_ : Rel Carrier _ Φ₁ ≤ Φ = ∃ λ Φ₂ → Φ₁ ⊎ Φ₂ ≣ Φ -- remainder rem : ∀ {x y} → x ≤ y → Carrier rem (z , _) = z -- separating conjunction infixr 10 _×⟨_⟩_ record Conj {p q} (P : SPred p) (Q : ∀ {Φ} → P Φ → SPred q) Φ : Set (p ⊔ q ⊔ a) where inductive constructor _×⟨_⟩_ field {Φₗ Φᵣ} : Carrier px : P Φₗ sep : Φₗ ⊎ Φᵣ ≣ Φ qx : Q px Φᵣ infixr 9 ∃[_]✴_ ∃[_]✴_ = Conj infixr 9 _✴_ _✴_ : ∀ {p q} → SPred p → SPred q → SPred (p ⊔ q ⊔ a) P ✴ Q = ∃[ P ]✴ const Q -- | Separating implication / magic is what you wand infixr 8 _─✴[_]_ record _─✴[_]_ {b p q} {A : Set b} (P : Pred A p) (j : A → Carrier) (Q : SPred q) (Φᵢ : Carrier) : Set (p ⊔ q ⊔ a ⊔ b) where constructor wand field app : ∀ {Φₚ} → P Φₚ → ∀ {Φ} → Φᵢ ⊎ j Φₚ ≣ Φ → Q Φ open _─✴[_]_ public infixr 8 _─✴_ _─✴_ : ∀ {p q} (P : SPred p) (Q : SPred q) → SPred (p ⊔ q ⊔ a) _─✴_ = _─✴[ id ]_ _$⟨_⟩_ : ∀ {p q Φ₁ Φ₂ Φ} {P : SPred p} {Q : SPred q} → (P ─✴ Q) Φ₁ → Φ₁ ⊎ Φ₂ ≣ Φ → P Φ₂ → Q Φ f $⟨ σ ⟩ px = app f px σ -- | The update modality -- the naked version, which doesn't coop well with inference: ⤇' : ∀ {p} (P : SPred p) → SPred (a ⊔ p) ⤇' P Φᵢ = ∀ {Φⱼ Φₖ} → Φᵢ ⊎ Φⱼ ≣ Φₖ → ∃₂ λ Φₗ Φ → Φₗ ⊎ Φⱼ ≣ Φ × P Φₗ -- Φᵢ is what we own, Φⱼ is an arbitrary frame. -- We may update Φᵢ as long as we do not disturb the framing -- wrapped record ⤇ {p} (P : SPred p) Φᵢ : Set (a ⊔ p) where constructor local field update : ⤇' P Φᵢ open ⤇ public infixr 8 _==✴_ _==✴_ : ∀ {p q} → (P : SPred p) (Q : SPred q) → SPred (p ⊔ q ⊔ a) P ==✴ Q = P ─✴ (⤇ Q) record IsSep {ℓ₁} {A} (s : RawSep {ℓ₁} A) : Set ℓ₁ where open RawSep s field ⊎-comm : ∀ {Φ₁ Φ₂} → ∀[ Φ₁ ⊎ Φ₂ ⇒ Φ₂ ⊎ Φ₁ ] ⊎-assoc : ∀ {a b ab c abc} → a ⊎ b ≣ ab → ab ⊎ c ≣ abc → ∃ λ bc → a ⊎ bc ≣ abc × b ⊎ c ≣ bc ⊎-unassoc : ∀ {b c bc a abc} → a ⊎ bc ≣ abc → b ⊎ c ≣ bc → ∃ λ ab → a ⊎ b ≣ ab × ab ⊎ c ≣ abc ⊎-unassoc σ₁ σ₂ = let _ , σ₃ , σ₄ = ⊎-assoc (⊎-comm σ₂) (⊎-comm σ₁) in -, ⊎-comm σ₄ , ⊎-comm σ₃ variable Φ₁ Φ₂ Φ₃ Φ : A module _ where resplit : ∀ {a b c d ab cd abcd} → a ⊎ b ≣ ab → c ⊎ d ≣ cd → ab ⊎ cd ≣ abcd → ∃₂ λ ac bd → a ⊎ c ≣ ac × b ⊎ d ≣ bd × ac ⊎ bd ≣ abcd resplit σ₁ σ₂ σ with ⊎-assoc σ₁ σ ... | bcd , σ₃ , σ₄ with ⊎-unassoc σ₄ (⊎-comm σ₂) ... | bd , σ₅ , σ₆ with ⊎-unassoc σ₃ σ₆ ... | abd , σ₇ , σ₈ with ⊎-unassoc (⊎-comm σ₈) σ₇ ... | ac , τ , τ' = -, -, ⊎-comm τ , σ₅ , τ' -- pairs commute module _ {p q} {P : SPred p} {Q : SPred q} where ✴-swap : ∀[ (P ✴ Q) ⇒ (Q ✴ P) ] ✴-swap (px ×⟨ σ ⟩ qx) = qx ×⟨ ⊎-comm σ ⟩ px -- pairs rotate and reassociate module _ {p q r} {P : SPred p} {Q : SPred q} {R : SPred r} where ✴-assocₗ : ∀[ P ✴ (Q ✴ R) ⇒ (P ✴ Q) ✴ R ] ✴-assocₗ (p ×⟨ σ₁ ⟩ (q ×⟨ σ₂ ⟩ r)) = let _ , σ₃ , σ₄ = ⊎-assoc (⊎-comm σ₂) (⊎-comm σ₁) in (p ×⟨ ⊎-comm σ₄ ⟩ q) ×⟨ ⊎-comm σ₃ ⟩ r ✴-assocᵣ : ∀[ (P ✴ Q) ✴ R ⇒ P ✴ (Q ✴ R) ] ✴-assocᵣ ((p ×⟨ σ₁ ⟩ q) ×⟨ σ₂ ⟩ r) = let _ , σ₃ , σ₄ = ⊎-assoc σ₁ σ₂ in p ×⟨ σ₃ ⟩ q ×⟨ σ₄ ⟩ r ✴-rotateᵣ : ∀[ P ✴ (Q ✴ R) ⇒ R ✴ P ✴ Q ] ✴-rotateᵣ (p ×⟨ σ₁ ⟩ (q ×⟨ σ₂ ⟩ r)) = let _ , σ₃ , σ₄ = ⊎-assoc (⊎-comm σ₂) (⊎-comm σ₁) in r ×⟨ σ₃ ⟩ p ×⟨ ⊎-comm σ₄ ⟩ q ✴-rotateₗ : ∀[ P ✴ (Q ✴ R) ⇒ Q ✴ R ✴ P ] ✴-rotateₗ (p ×⟨ σ₁ ⟩ (q ×⟨ σ₂ ⟩ r)) = let _ , σ₃ , σ₄ = ⊎-assoc σ₂ (⊎-comm σ₁) in q ×⟨ σ₃ ⟩ r ×⟨ σ₄ ⟩ p module _ {p q} {P : SPred p} {Q : SPred q} where apply : ∀[ (P ─✴ Q) ✴ P ⇒ Q ] apply (px ×⟨ sep ⟩ qx) = app px qx sep -- mapping module _ {p q p' q'} {P : SPred p} {Q : SPred q} {P' : SPred p'} {Q' : SPred q'} where ⟨_⟨✴⟩_⟩ : ∀[ P ⇒ P' ] → ∀[ Q ⇒ Q' ] → ∀[ P ✴ Q ⇒ P' ✴ Q' ] ⟨_⟨✴⟩_⟩ f g (px ×⟨ sep ⟩ qx) = (f px) ×⟨ sep ⟩ (g qx) both : ∀[ (P ─✴ P') ✴ (Q ─✴ Q') ⇒ P ✴ Q ─✴ P' ✴ Q' ] app (both (f ×⟨ σ₁ ⟩ g)) (px ×⟨ σ₂ ⟩ qx) σ₃ with resplit σ₁ σ₂ σ₃ ... | _ , _ , σ₄ , σ₅ , σ₆ = apply (f ×⟨ σ₄ ⟩ px) ×⟨ σ₆ ⟩ apply (g ×⟨ σ₅ ⟩ qx) module _ {p q r} {P : SPred p} {Q : SPred q} {R : SPred r} where ✴-curry : ∀[ (P ─✴ (Q ─✴ R)) ⇒ (P ✴ Q) ─✴ R ] app (✴-curry f) (p ×⟨ σ₁ ⟩ q) σ₂ = let _ , σ₃ , σ₄ = ⊎-unassoc σ₂ σ₁ in app (app f p σ₃) q σ₄ intro : ∀[ (P ✴ Q) ⇒ R ] → ∀[ P ⇒ (Q ─✴ R) ] app (intro f px) qx s = f (px ×⟨ s ⟩ qx) com : ∀[ (P ─✴ Q) ✴ (Q ─✴ R) ⇒ (P ─✴ R) ] app (com (f ×⟨ s ⟩ g)) px s' = let _ , eq₁ , eq₂ = ⊎-assoc (⊎-comm s) s' in app g (app f px eq₂) eq₁ ✴-uncurry : ∀[ (P ✴ Q ─✴ R) ⇒ P ─✴ (Q ─✴ R) ] app (app (✴-uncurry f) p σ₁) q σ₂ = let _ , σ₃ , σ₄ = ⊎-assoc σ₁ σ₂ in app f (p ×⟨ σ₄ ⟩ q) σ₃ module _ where ≤-trans : Φ₁ ≤ Φ₂ → Φ₂ ≤ Φ₃ → Φ₁ ≤ Φ₃ ≤-trans (τ₁ , Φ₁⊎τ₁=Φ₂) (τ₂ , Φ₂⊎τ₂=Φ₃) = let τ₃ , p , q = ⊎-assoc Φ₁⊎τ₁=Φ₂ Φ₂⊎τ₂=Φ₃ in τ₃ , p module _ where -- disjointness _◆_ : _ → _ → SPred _ Φₗ ◆ Φᵣ = Exactly Φₗ ✴ Exactly Φᵣ record IsUnitalSep {c} {C : Set c} (sep : RawSep C) un : Set (suc c) where field overlap {{ isSep }} : IsSep sep open RawSep sep ε = un field ⊎-idˡ : ∀ {Φ} → ε ⊎ Φ ≣ Φ ⊎-id⁻ˡ : ∀ {Φ₁ Φ₂} → ε ⊎ Φ₁ ≣ Φ₂ → Φ₁ ≡ Φ₂ open IsSep isSep ⊎-idʳ : ∀ {Φ} → Φ ⊎ ε ≣ Φ ⊎-idʳ = ⊎-comm ⊎-idˡ ⊎-id⁻ʳ : ∀ {Φ} → ∀[ (Φ ⊎ ε) ⇒ (Φ ≡_) ] ⊎-id⁻ʳ = ⊎-id⁻ˡ ∘ ⊎-comm infix 10 ε[_] ε[_] : ∀ {ℓ} → Pred C ℓ → Set ℓ ε[ P ] = P ε {- Emptyness -} module _ where data Empty {p} (P : Set p) : SPred (c ⊔ p) where emp : P → Empty P ε pattern empty = emp tt Emp : SPred c Emp = Empty ⊤ module _ where ε⊎ε : ∀[ ε ⊎ ε ⇒ Emp ] ε⊎ε p with ⊎-id⁻ˡ p ... | (P.refl) = empty ✴-idʳ : ∀ {p} {P : SPred p} → ∀[ P ⇒ P ✴ Emp ] ✴-idʳ px = px ×⟨ ⊎-idʳ ⟩ empty -- a resource-polymorphic function is a pure wand wandit : ∀ {p q} {P : SPred p} {Q : SPred q} → ∀[ P ⇒ Q ] → ε[ P ─✴ Q ] app (wandit f) p σ rewrite ⊎-id⁻ˡ σ = f p _⟨✴⟩_ : ∀ {p q} {P : SPred p} {Q : SPred q} → ε[ P ─✴ Q ] → ∀[ P ⇒ Q ] w ⟨✴⟩ p = app w p ⊎-idˡ {- A free preorder -} module _ where ≤-reflexive : Φ₁ ≡ Φ₂ → Φ₁ ≤ Φ₂ ≤-reflexive P.refl = ε , ⊎-idʳ ≤-isPreorder : IsPreorder _≡_ _≤_ ≤-isPreorder = record { isEquivalence = P.isEquivalence ; reflexive = ≤-reflexive ; trans = ≤-trans } ≤-preorder : Preorder _ _ _ ≤-preorder = record { isPreorder = ≤-isPreorder } ε-minimal : ∀ {Φ} → ε ≤ Φ ε-minimal {Φ} = Φ , ⊎-idˡ {- Framing where we forget the actual resource owned -} module ↑-Frames where infixl 1000 _↑ _↑ : ∀ {ℓ} → SPred ℓ → SPred _ P ↑ = P ✴ U pattern _⇑_ p sep = p ×⟨ sep ⟩ tt module _ {ℓ} {P : SPred ℓ} where return : ∀[ P ⇒ P ↑ ] return p = p ×⟨ ⊎-idʳ ⟩ tt join : ∀[ (P ↑) ↑ ⇒ P ↑ ] join ((p ×⟨ σ₁ ⟩ tt) ×⟨ σ₂ ⟩ tt) = let _ , σ₃ = ≤-trans (-, σ₁) (-, σ₂) in p ×⟨ σ₃ ⟩ tt module _ {ℓ₁ ℓ₂} {P : SPred ℓ₁} {Q : SPred ℓ₂} where map : ∀[ P ⇒ Q ] → ∀[ P ↑ ⇒ Q ↑ ] map f (px ⇑ sep) = f px ⇑ sep module _ {ℓ₁ ℓ₂} {P : SPred ℓ₁} {Q : SPred ℓ₂} where ↑-bind : ∀[ P ⇒ Q ↑ ] → ∀[ P ↑ ⇒ Q ↑ ] ↑-bind f px = join (map f px) {- Projections out of separating conjunction using framing -} module _ where π₁ : ∀ {p q} {P : SPred p} {Q : SPred q} → ∀[ (P ✴ Q) ⇒ P ↑ ] π₁ (px ×⟨ sep ⟩ _) = px ⇑ sep π₂ : ∀ {p q} {P : SPred p} {Q : SPred q} → ∀[ (P ✴ Q) ⇒ Q ↑ ] π₂ (_ ×⟨ sep ⟩ qx) = qx ⇑ ⊎-comm sep record IsConcattative {c} {C : Set c} (sep : RawSep C) : Set (suc c) where open RawSep sep field overlap {{ isSep }} : IsSep sep _∙_ : C → C → C ⊎-∙ₗ : ∀ {Φ₁ Φ₂ Φ Φₑ} → Φ₁ ⊎ Φ₂ ≣ Φ → (Φₑ ∙ Φ₁) ⊎ Φ₂ ≣ (Φₑ ∙ Φ) open IsSep isSep ⊎-∙ᵣ : ∀ {Φ₁ Φ₂ Φ Φₑ} → Φ₁ ⊎ Φ₂ ≣ Φ → Φ₁ ⊎ (Φₑ ∙ Φ₂) ≣ (Φₑ ∙ Φ) ⊎-∙ᵣ s = ⊎-comm (⊎-∙ₗ (⊎-comm s)) record IsPositive {c} {C : Set c} (sep : RawSep C) : Set (suc c) where open RawSep sep field {ε} : _ overlap {{ isUnitalSep }} : IsUnitalSep sep ε overlap {{ isSep }} : IsSep sep open IsUnitalSep isUnitalSep using (⊎-id⁻ˡ) field ⊎-εˡ : ∀ {Φ₁ Φ₂} → Φ₁ ⊎ Φ₂ ≣ ε → Φ₁ ≡ ε ⊎-ε : ∀ {Φ₁ Φ₂} → Φ₁ ⊎ Φ₂ ≣ ε → Φ₁ ≡ ε × Φ₂ ≡ ε ⊎-ε σ with ⊎-εˡ σ ... | P.refl with ⊎-id⁻ˡ σ ... | P.refl = P.refl , P.refl record Separation c : Set (suc c) where field Carrier : Set c overlap {{ raw }} : RawSep Carrier overlap {{ isSep }} : IsSep raw record UnitalSep c : Set (suc c) where field Carrier : Set c ε : _ overlap {{ sep }} : RawSep Carrier overlap {{ isUnitalSep }} : IsUnitalSep sep ε record MonoidalSep c : Set (suc c) where field Carrier : Set c ε : _ overlap {{ sep }} : RawSep Carrier overlap {{ isSep }} : IsSep sep overlap {{ isUnitalSep }} : IsUnitalSep sep ε overlap {{ isConcat }} : IsConcattative sep open RawSep sep open IsSep isSep open IsConcattative isConcat open IsUnitalSep isUnitalSep hiding (ε) field overlap {{ monoid }} : IsMonoid {A = Carrier} _≡_ _∙_ ε open IsMonoid monoid ⊎-∙ : ∀ {Φₗ Φᵣ : Carrier} → Φₗ ⊎ Φᵣ ≣ (Φₗ ∙ Φᵣ) ⊎-∙ {Φₗ} {Φᵣ} = P.subst (λ φ → φ ⊎ Φᵣ ≣ (Φₗ ∙ Φᵣ)) (identityʳ Φₗ) (⊎-∙ₗ {Φₑ = Φₗ} (⊎-idˡ {Φᵣ})) instance unital : UnitalSep _ unital = record { ε = ε } module _ {c} {C : Set c} where εOf : ∀ (r : RawSep C) {u} {{ _ : IsUnitalSep r u }} → C εOf _ {{ un }}= IsUnitalSep.ε un open RawSep ⦃...⦄ public open IsConcattative ⦃...⦄ public open IsUnitalSep ⦃...⦄ public open IsPositive ⦃...⦄ hiding (ε) public open UnitalSep ⦃...⦄ public hiding (Carrier; ε) open IsSep ⦃...⦄ public open MonoidalSep ⦃...⦄ public hiding (Carrier; ε)
{ "alphanum_fraction": 0.484414643, "avg_line_length": 27.8686868687, "ext": "agda", "hexsha": "b14d5a421fd2999b0e720e8636d83ee1ef0e04ce", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2020-05-23T00:34:36.000Z", "max_forks_repo_forks_event_min_datetime": "2020-01-30T14:15:14.000Z", "max_forks_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "laMudri/linear.agda", "max_forks_repo_path": "src/Relation/Ternary/Separation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "laMudri/linear.agda", "max_issues_repo_path": "src/Relation/Ternary/Separation.agda", "max_line_length": 126, "max_stars_count": 34, "max_stars_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "laMudri/linear.agda", "max_stars_repo_path": "src/Relation/Ternary/Separation.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-03T15:22:33.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-20T13:57:50.000Z", "num_tokens": 5417, "size": 11036 }
{-# OPTIONS --without-K #-} open import HoTT open import cohomology.Theory {- Useful lemmas concerning the functorial action of C -} module cohomology.Functor {i} (CT : CohomologyTheory i) where open CohomologyTheory CT CF-inverse : (n : ℤ) {X Y : Ptd i} (f : fst (X ⊙→ Y)) (g : fst (Y ⊙→ X)) → g ⊙∘ f == ⊙idf _ → (CF-hom n f) ∘ᴳ (CF-hom n g) == idhom _ CF-inverse n f g p = ! (CF-comp n g f) ∙ ap (CF-hom n) p ∙ CF-ident n
{ "alphanum_fraction": 0.6111111111, "avg_line_length": 28.8, "ext": "agda", "hexsha": "3e307028982706143be3b1fa614b8dc7b8798267", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "danbornside/HoTT-Agda", "max_forks_repo_path": "cohomology/Functor.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "danbornside/HoTT-Agda", "max_issues_repo_path": "cohomology/Functor.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "danbornside/HoTT-Agda", "max_stars_repo_path": "cohomology/Functor.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 169, "size": 432 }
{-# OPTIONS --copatterns #-} module LecStr where open import CS410-Prelude open import CS410-Nat open import CS410-Functor record Stream (X : Set) : Set where coinductive field head : X tail : Stream X open Stream count : Nat -> Stream Nat head (count n) = n tail (count n) = count (suc n) nats : Stream Nat nats = count zero poke : Nat poke = head (tail (tail (tail nats))) repeat : {X : Set} -> X -> Stream X head (repeat x) = x tail (repeat x) = repeat x strApp : {S T : Set} -> Stream (S -> T) -> Stream S -> Stream T head (strApp fs ss) = (head fs) (head ss) tail (strApp fs ss) = strApp (tail fs) (tail ss) strMap : {S T : Set} -> (S -> T) -> Stream S -> Stream T strMap f ss = strApp (repeat f) ss diagonal : {X : Set} -> Stream (Stream X) -> Stream X head (diagonal xss) = head (head xss) tail (diagonal xss) = diagonal (strMap tail (tail xss)) {- productivity checker rejects fibo : Stream Nat head fibo = 1 head (tail fibo) = 1 tail (tail fibo) = strApp (strApp (repeat _+N_) (tail fibo)) fibo -} data CoList' (X : Set) : Set record CoList (X : Set) : Set where coinductive constructor thunk field force : CoList' X data CoList' X where [] : CoList' X _::_ : X -> CoList X -> CoList' X module CoListExamples where open CoList short : CoList Nat short = thunk (0 :: thunk (1 :: thunk (2 :: thunk []))) long : forall {X} -> Stream X -> CoList X force (long s) = head s :: long (tail s) _++_ : forall {X} -> CoList X -> CoList X -> CoList X force (xs ++ ys) with force xs force (xs ++ ys) | [] = force ys force (xs ++ ys) | x :: xs' = x :: (xs' ++ ys) {- concat : forall {X} -> CoList (CoList X) -> CoList X force (concat xss) with force xss force (concat xss) | [] = [] force (concat xss) | xs :: xss' with force xs force (concat xss) | xs :: xss' | [] = ? -- oops force (concat xss') force (concat xss) | xs :: xss' | x :: xs' = x :: concat (thunk (xs' :: xss')) -} -- nonempty CoLists -- tails for Streams -- " n.e. CoLists
{ "alphanum_fraction": 0.6035856574, "avg_line_length": 23.9047619048, "ext": "agda", "hexsha": "ce3a7d1a3832d31d167c2b72cf5584437ecec8ee", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "clarkdm/CS410", "max_forks_repo_path": "LecStr.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "clarkdm/CS410", "max_issues_repo_path": "LecStr.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "clarkdm/CS410", "max_stars_repo_path": "LecStr.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 699, "size": 2008 }
--{-# OPTIONS -v tc.data:100 #-} module Issue830 where _⟶_ : Set₁ → Set → Set₁ A ⟶ B = A → B data ⟨Set⟩ : Set where [_] : Set ⟶ ⟨Set⟩ -- should fail
{ "alphanum_fraction": 0.5519480519, "avg_line_length": 14, "ext": "agda", "hexsha": "4f902727be61878b78da4b980d7d1bf8e43cc528", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Issue830.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Issue830.agda", "max_line_length": 32, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue830.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 60, "size": 154 }
module x where {- ------------------------------------------------------------------------------ Abstract Relational program derivation technique : - stepwise refining a relational spec to a program by algebraic rules. - program obtained is correct by construction Dependent type theory rich enough to express correctness properties verified by type checker. Library, Algebra of Programming in Agda (AoPA) - http://www.iis.sinica.edu.tw/~scm/2008/aopa/ - encodes relational derivations - A program is coupled with an algebraic derivation whose correctness is guaranteed by type system ------------------------------------------------------------------------------ 1 Introduction relational program derivation - specs are input-output relations that are stepwise refined by an algebra of programs. paper show how program derivation can be encoded in a type and its proof term. - case study using Curry-Howard isomorphism - modelled a many concepts that occur in relational program derivation including relational folds, relational division, and converse-of-a-function. - e.g., Minimum, is defined using division and intersection - e.g., greedy theorem proved using the universal property of minimum. - the theorem can be used to deal with a number of optimisation problems specified as folds. • to ensure termination with unfolds and hylomorphisms, enable programmer to model an unfold as the relational converse of a fold, but demand a proof of accessibility before it is refined to a functional unfold. ------------------------------------------------------------------------------ 2 Overview of Relational Program Derivation Merit of functional programming : programs can be manipulated by equational reasoning. Program derivation in Bird-Meertens style 1989b) typically start with a specification, as a function, that is obviously correct but not efficient. Algebraic identities are then applied, in successive steps, to show that the specification equals another functional program that is more efficient. Typical example : Maximum Segment Sum (Gries, 1989; Bird, 1989a), specification : max · map sum · segs where - segs produces all consecutive segments of the input list of numbers - map sum computes their summation - maximum is picked by max Specification can be shown, after transformation, to be equal a version using foldr (linear). In 90’s there was a trend in the program derivation community to move from functions to relations. - spec given in terms of an input/output relation - relation is refined to smaller, more deterministic relations in each step, - until obtaining a function Relational derivation advantages: - spec often more concise than corresponding functional specification - optimisation problems can be specified using relations generating all possible solutions - easier to talk about program inversion The catch: *must reason in terms of inequalities rather than equalities* denoted by R : B ← A - relation R from A to B - subset of set of pairs B × A - A function f is seen as a special case where (b, a) ∈ f and (b' , a) ∈ f implies b = b' converse R˘ : A ← B of R : B ← A - defined by (a, b) ∈ R ˘ if (b, a) ∈ R composition of two relations R : C ← B and S : B ← A - defined by: (c, a) ∈ R ◦ S if ∃b : (c, b) ∈ R ∧ (b, a) ∈ S power transpose ΛR of R : B ← A - is a function from A to P B (subsets of B) - ΛR a = { b | (b, a) ∈ R }. relation ∈ : A ← P A - maps a set to one of its arbitrary members - converse: ∋ : P A ← A product of two relations, R × S - defined by ((c, d), (a, b)) ∈ R × S if (c, a) ∈ R and (d, b) ∈ S -- step fun base input output foldr : (A → B → B) → B → List A → B generalisation to a relation, denote foldR input step relation base cases foldR R : B ← List A ← (B ← (A×B)) (set s : PB) -- relation mapping a list to one of its arbitrary subsequences subseq = foldR (cons ∪ outr) {[ ]} where cons (x, xs) = x :: xs -- cons keeps the current element outr (x, xs) = xs -- outr drops the current element Relational fold defined in terms of functional fold: foldR R s = ∈ ◦ foldr Λ(R ◦ (id " ∈)) s of type List A → P B that collects all the results in a set. step function Λ(R ◦ (id " ∈)) : has type (A × P B) → P B (id " ∈) : (A × B) ← (A × P B) : pairs current element with one of the results from previous step before passing the pair to R foldR R s satisfies the universal property: foldR R s = S ⇔ R ◦ (id " S) = S ◦ cons ∧ s = ΛS [ ] -- induction rule -- states that foldR R s is the unique fixed-point of the monotonic function λ X → (R ◦ (id " X) ◦ cons ˘) ∪ {(b, [ ]) | b ∈ s} -- computation rule -- foldR R s is also the least prefix-point, therefore foldR R s ⊆ S ⇐ R ◦ (id " S) ⊆ S ◦ cons ∧ s ⊆ ΛS [ ], R ◦ (id " foldR R s) ⊆ foldR R s ◦ cons ∧ s ⊆ Λ(foldR R s) [ ]. If an optimisation problem can be specified by generating all possible solutions using foldR or converse of foldR before picking the best one, Bird and de Moor (1997) gave a number of conditions under which the specification can be refined to a greedy algorithm, a dynamic programming algorithm, or something in-between. ------------------------------------------------------------------------------ 3 A Crash Course in Agda -} -- Fig. 2. Some examples of datatype definitions. data List (A : Set) : Set where [] : List A _∷_ : A → List A → List A data ℕ : Set where zero : ℕ suc : ℕ → ℕ data _≤_ : ℕ → ℕ → Set where ≤-refl : {n : ℕ} → n ≤ n ≤-step : {m n : ℕ} → m ≤ n → m ≤ suc n _<_ : ℕ → ℕ → Set m < n = suc m ≤ n -- Fig. 3. An encoding of first-order intuitionistic logic in Agda. -- Truth : has one unique term — a record with no fields record ⊤ : Set where -- Falsity : type with no constructors therefore no inhabitants data ⊥ : Set where -- Disjunction : proof deduced either from a proof of P or a proof of Q data _⨄_ (A B : Set) : Set where inj1 : A → A ⨄ B inj2 : B → A ⨄ B -- Dependent Pair : type of 2nd may depend on the first component data Σ (A : Set)(B : A → Set) : Set where _,_ : (x : A) → (y : B x) → Σ A B proj₁ : ∀ {A B} → Σ A B → A proj₁ (x , y) = x proj₂ : ∀ {A B} → (p : Σ A B) → B (proj₁ p) proj₂ (x , y) = y -- Conjunction _×_ : (A B : Set) → Set A × B = Σ A (λ _ → B) -- Existential Quantification -- to prove the proposition ∃ P, where P is a predicate on terms of type A -- provide, in a pair, a witness w : A and a proof of P w. ∃ : {A : Set} (P : A → Set) → Set ∃ = Σ _ -- Universal Quantification -- of predicate P on type A is encoded as a dependent function type -- whose elements, given any x : A, must produce a proof of P x. -- Agda provides a short hand ∀ x → P x in place of (x : A) → P x when A can be inferred. -- Implication -- P → Q is represented as a function taking a proof of P to a proof of Q -- no new notation for it -- Predicates -- on type A are represented by A → Set. -- e.g., (λ n → zero < n) : N → Set -- is a predicate stating that a natural number is positive. {- 3.2 Identity Type term of type x ≡ y is proof x and y are equal -} data _≡_ {A : Set}(x : A) : A → Set where ≡-refl : x ≡ x -- REFLEXIVE : by definition -- SYMMETRIC ≡-sym : {A : Set}{x y : A} → x ≡ y → y ≡ x ≡-sym {A}{x}{.x} ≡-refl = ≡-refl -- TRANSITIVE ≡-trans : {A : Set}{x y z : A} → x ≡ y → y ≡ z → x ≡ z ≡-trans {A}{x}{.x}{z} ≡-refl x≡z = x≡z -- could replace x≡z with ≡-refl -- SUBSTITUTIVE — if x ≡ y, they are interchangeable in all contexts ≡-subst : {A : Set}(P : A → Set){x y : A} → x ≡ y → P x → P y ≡-subst P ≡-refl Px = Px ≡-cong : {A B : Set}(f : A → B){x y : A} → x ≡ y → f x ≡ f y ≡-cong f ≡-refl = ≡-refl {- ≡ NOT EXTENSIONAL Qquality of terms is checked by expanding them to normal forms. Problem comparing higher-order values: e.g., sum·map sum and sum · concat while defining the same function summing up a list of lists of numbers, are not “equal” under ≡ . Can define extensional equality for (non-dependent) functions on first-order values: -} _≐_ : {A B : Set} → (A → B) → (A → B) → Set f ≐ g = ∀ x → f x ≡ g x {- ≐ NOT SUBSTITUTIVE : congruence of ≐ has to be proved for each context. Refinement in preorder reasoning usually involves replacing terms in provably monotonic contexts. This is a significant overhead; but given that this overhead is incurred anyway, not having extensional equality is no extra trouble. 3.3 Preorder Reasoning To prove e1 ≡ e2 is to construct a term having that type. For any binary relation ∼ that is reflexive and transitive - for which one can construct terms ∼-refl and ∼-trans having the types described in above can derive a set of combinators, shown in Fig. 4, which enables one to construct a term of type e₁ ∼ en in algebraic style. -- Fig. 4. Combinators for preorder reasoning. infixr 2 _∼⟨_⟩_ infix 2 _∼∎ _∼⟨_⟩_ : {A : Set}(x : A){y z : A} → x ∼ y → y ∼ z → x ∼ z x ∼⟨ x∼y ⟩ y∼z = ∼-trans x∼y y∼z _∼∎ : {A : Set}(x : A) → x ∼ x x ∼∎ = ∼-refl implication as a relation: -} _⇒_ : Set → Set → Set P ⇒ Q = P → Q _⇐_ : Set → Set → Set P ⇐ Q = Q ⇒ P {- Reflexivity and transitivity of ⇐ , for example, can be simply given by ⇐-refl = id and ⇐-trans = · , where · is function composition. Therefore, they induce a pair of operators _⇐⟨_⟩_ and ⇐∎ for logical reasoning. Hierarchy of universes - Set, the type of small types, is in sort Set1 When instantiating ∼ in Fig. 4 to ⇐ : Set → Set → Set - notice that the type A : Set itself cannot be instantiated to Set, which is in Set1 We resolve this by using different module generators for different universes. More on this in Sect. 4.1. 3.4 Functional Derivation Since _≐_ is reflexive and transitive (not shown), it induces its preorder reasoning operators. Fig. 5 shows a proof of the universal property of foldr. The steps using ≡-refl are equivalences Agda proves by expanding definitions. The inductive hypothesis is established by a recursive call to foldr-universal. -} infix 3 _≡∎ infixr 2 _≡⟨⟩_ _≡⟨_⟩_ infix 1 begin_ begin_ : {A : Set} {x y : A} → x ≡ y → x ≡ y begin_ x≡y = x≡y _≡⟨⟩_ : {A : Set} (x {y} : A) → x ≡ y → x ≡ y _ ≡⟨⟩ x≡y = x≡y _≡⟨_⟩_ : {A : Set} (x {y z} : A) → x ≡ y → y ≡ z → x ≡ z _ ≡⟨ x≡y ⟩ y≡z = ≡-trans x≡y y≡z _≡∎ : {A : Set} (x : A) → x ≡ x _≡∎ _ = ≡-refl {- Fig. 5. Proving the universal property for foldr -} foldr : {A B : Set} → (A → B → B) → B → List A → B foldr f e [] = e foldr f e (x ∷ xs) = f x (foldr f e xs) {- https://www.cs.nott.ac.uk/~pszgmh/fold.pdf For finite lists, the universal property of fold can be stated as the following equivalence between two definitions for a function g that processes lists: g [] = v ⇔ g = fold f v g (x ∷ xs) = f x (g xs) right-to-left : substituting g = fold f v into the two equations for g gives recursive fold def left-to-right : two equations for g are the assumptions required to show that g = fold f v using a simple proof by induction on finite lists (Bird, 1998) universal property states that for finite lists the function fold f v is not just a solution to its defining equations, but the unique solution. Utility of universal property : makes explicit the two assumptions required for a certain pattern of inductive proof. For specific cases, by verifying the two assumptions (typically done without need for induction) can then appeal to the universal property to complete the inductive proof that g = fold f v. universal PROPERTY of fold : encapsulates a pattern of inductive proof concerning lists just as the fold OPERATOR : encapsulates a pattern of recursion for processing lists -} foldr-universal : ∀ {A B} (h : List A → B) f e → (h [] ≡ e) → (∀ x xs → h (x ∷ xs) ≡ f x (h xs)) → h ≐ foldr f e foldr-universal h f e base step [] = base foldr-universal h f e base step (x ∷ xs) = begin h (x ∷ xs) ≡⟨ step x xs ⟩ f x (h xs) ≡⟨ ≡-cong (f x) (foldr-universal h f e base step xs) ⟩ f x (foldr f e xs) ≡⟨ ≡-refl ⟩ foldr f e (x ∷ xs) ≡∎ {- -- Can use the universal property to prove the foldr-fusion theorem: _·_ : {A : Set} {B : A → Set} {C : (x : A) → B x → Set} → (f : {x : A} (y : B x) → C x y) → (g : (x : A) → B x) → (x : A) → C x (g x) (f · g) x = f (g x) -- TODO compile problems foldr-fusion : ∀ {A B C} (h : B → C) {f : A → B → B} {g : A → C → C} → {e : B} → (∀ x y → h (f x y) ≡ g x (h y)) → (h · foldr f e) ≐ (foldr g (h e)) foldr-fusion h {f} {g} e fuse = foldr-universal (h · foldr f e) g (h e) ≡-refl (λ x xs → fuse x (foldr f e xs)) -}
{ "alphanum_fraction": 0.6350999131, "avg_line_length": 34.2189189189, "ext": "agda", "hexsha": "43f2470d19aec492fe80589ed4ceeff8eb0c919d", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/paper/2009-09-Algebra_of_programming_in_Agda/x.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/paper/2009-09-Algebra_of_programming_in_Agda/x.agda", "max_line_length": 98, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/paper/2009-09-Algebra_of_programming_in_Agda/x.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "num_tokens": 3961, "size": 12661 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.PtdAdjoint open import homotopy.SuspAdjointLoop open import cohomology.WithCoefficients module cohomology.SuspAdjointLoopIso where module SuspAdjointLoopIso {i} where private hadj : HomAdjoint {i} {i} Σ⊣Ω.SuspFunctor Σ⊣Ω.LoopFunctor hadj = counit-unit-to-hom Σ⊣Ω.adj module A = HomAdjoint hadj module _ (X Y : Ptd i) where abstract pres-comp : (h₁ h₂ : ⊙Susp X ⊙→ ⊙Ω Y) → –> (A.eq X (⊙Ω Y)) (⊙Ω-∙ ⊙∘ ⊙fanout h₁ h₂) == ⊙Ω-∙ ⊙∘ ⊙fanout (–> (A.eq X (⊙Ω Y)) h₁) (–> (A.eq X (⊙Ω Y)) h₂) pres-comp h₁ h₂ = B.nat-cod h₁ h₂ ⊙Ω-∙ ∙ ap (_⊙∘ ⊙fanout (–> (A.eq X (⊙Ω Y)) h₁) (–> (A.eq X (⊙Ω Y)) h₂)) arr2-lemma where module A× = RightAdjoint× hadj module B = RightAdjointBinary hadj ap2-lemma : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (f : A × B → C) {r s : A × B} (p : r == s) → ap f p == ap2 (curry f) (ap fst p) (ap snd p) ap2-lemma f idp = idp ⊙ap2-lemma : ∀ {i j k} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} (f : X ⊙× Y ⊙→ Z) → ⊙Ω-fmap f == ⊙Ω-fmap2 f ⊙∘ ⊙fanout (⊙Ω-fmap ⊙fst) (⊙Ω-fmap ⊙snd) ⊙ap2-lemma (f , idp) = ⊙λ= (ap2-lemma f) idp arr2-lemma : B.arr2 ⊙Ω-∙ == ⊙Ω-∙ arr2-lemma = ⊙Ω-fmap ⊙Ω-∙ ⊙∘ A×.⊙out _ _ =⟨ ⊙ap2-lemma ⊙Ω-∙ |in-ctx _⊙∘ A×.⊙out _ _ ⟩ (⊙Ω-fmap2 ⊙Ω-∙ ⊙∘ A×.⊙into _ _) ⊙∘ A×.⊙out _ _ =⟨ ⊙∘-assoc (⊙Ω-fmap2 ⊙Ω-∙) (A×.⊙into _ _) (A×.⊙out _ _) ⟩ ⊙Ω-fmap2 ⊙Ω-∙ ⊙∘ (A×.⊙into _ _ ⊙∘ A×.⊙out _ _) =⟨ A×.⊙into-out _ _ |in-ctx ⊙Ω-fmap2 ⊙Ω-∙ ⊙∘_ ⟩ ⊙Ω-fmap2 ⊙Ω-∙ =⟨ ⊙Ω-fmap2-∙ ⟩ ⊙Ω-∙ ∎ iso : Trunc-⊙→Ω-group (⊙Susp X) Y ≃ᴳ Trunc-⊙→Ω-group X (⊙Ω Y) iso = Trunc-group-emap (≃-to-≃ᴳˢ (A.eq X (⊙Ω Y)) pres-comp) abstract nat-dom : {X Y : Ptd i} (f : X ⊙→ Y) (Z : Ptd i) → fst (iso X Z) ∘ᴳ Trunc-⊙→Ω-group-fmap-dom (⊙Susp-fmap f) Z == Trunc-⊙→Ω-group-fmap-dom f (⊙Ω Z) ∘ᴳ fst (iso Y Z) nat-dom f Z = group-hom= $ λ= $ Trunc-elim (λ _ → =-preserves-level Trunc-level) (λ g → ap [_] (! (A.nat-dom f (⊙Ω Z) g)))
{ "alphanum_fraction": 0.4751455441, "avg_line_length": 34.890625, "ext": "agda", "hexsha": "e4569cc867ec0a8568e9b7100d61a8dec48d1dc6", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "theorems/cohomology/SuspAdjointLoopIso.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "theorems/cohomology/SuspAdjointLoopIso.agda", "max_line_length": 77, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "theorems/cohomology/SuspAdjointLoopIso.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1149, "size": 2233 }
{-# OPTIONS --cubical --safe #-} module Cubical.Induction.Everything where open import Cubical.Induction.WellFounded public
{ "alphanum_fraction": 0.784, "avg_line_length": 25, "ext": "agda", "hexsha": "b189b82cdb05835b21ee294e05313d14cc110a21", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "borsiemir/cubical", "max_forks_repo_path": "Cubical/Induction/Everything.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "borsiemir/cubical", "max_issues_repo_path": "Cubical/Induction/Everything.agda", "max_line_length": 48, "max_stars_count": null, "max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "borsiemir/cubical", "max_stars_repo_path": "Cubical/Induction/Everything.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 32, "size": 125 }
module Examples.PingPong where open import ActorMonad public open import Prelude -- An example including three actors: spawner, pinger, ponger -- -- Spawner is the actor that starts it all. -- Spawner spawns both pinger and ponger. -- Then spawner send the reference of ponger to pinger, -- and the reference of pinger to ponger. -- -- Pinger is an actor that can receive Bool messages. -- Pinger counts the number of 'false' messages it receives, until it receives a 'true' -- -- Ponger is an actor that can receive Nat messages. -- Ponger keeps sending 'false' until it receives a message containing 10. Spawnbox : InboxShape Spawnbox = [] mutual PingValues = [ Bool ]ˡ PongValues = [ ℕ ]ˡ PingRefs : TypingContext PingRefs = [ ⊠-of-values PongValues ]ˡ PongRefs : TypingContext PongRefs = [ ⊠-of-values PingValues ]ˡ PongReferenceMessage : MessageType PongReferenceMessage = [ ReferenceType (⊠-of-values PongValues) ]ˡ BoolMessage : MessageType BoolMessage = [ ValueType Bool ]ˡ Pingbox : InboxShape Pingbox = BoolMessage ∷ [ PongReferenceMessage ]ˡ PingReferenceMessage : MessageType PingReferenceMessage = [ ReferenceType (⊠-of-values PingValues) ]ˡ NatMessage : MessageType NatMessage = [ ValueType ℕ ]ˡ Pongbox : InboxShape Pongbox = NatMessage ∷ [ PingReferenceMessage ]ˡ constPingrefs : {A : Set₁} → (A → TypingContext) constPingrefs _ = PingRefs pingMainActor : (i : Size) (A : Set₁) → Set₂ pingMainActor i A = ∞ActorM i Pingbox A PingRefs constPingrefs mutual pingReceive : ∀ {i} (msg : Message Pingbox) → ∞ActorM i Pingbox (Lift (lsuc lzero) Bool) (add-references PingRefs msg) constPingrefs pingReceive (Msg Z (b ∷ [])) = return b pingReceive (Msg (S Z) _) = strengthen [ S Z ]ᵐ >> loopTillPingValue pingReceive (Msg (S (S ())) x₁) loopTillPingValue : ∀ {i} → pingMainActor i (Lift (lsuc lzero) Bool) loopTillPingValue .force = receive ∞>>= pingReceive pinger : ∀ {i} → ∞ActorM (↑ i) Pingbox ⊤₁ [] constPingrefs pinger .force = loopTillPong ∞>> pingMain 0 where loopTillPong : ∀ {i} → ∞ActorM i Pingbox ⊤₁ [] constPingrefs loopTillPong .force = receive ∞>>= ((λ { (Msg Z x₁) → loopTillPong ; (Msg (S Z) x₁) → return _ ; (Msg (S (S ())) x₁) })) pingMain : ∀ {i} → ℕ → pingMainActor i ⊤₁ pingMain n .force = loopTillPingValue ∞>>= λ { (lift false) → (Z ![t: Z ] ( [ lift n ]ᵃ)) >> pingMain (suc n) ; (lift true) → return _} constPongrefs : {A : Set₁} → (A → TypingContext) constPongrefs _ = PongRefs pongMainActor : (i : Size) (A : Set₁) → Set₂ pongMainActor i A = ∞ActorM i Pongbox A PongRefs constPongrefs mutual pongReceive : ∀ {i} (msg : Message Pongbox) → ∞ActorM i Pongbox (Lift (lsuc lzero) ℕ) (add-references PongRefs msg) constPongrefs pongReceive (Msg Z (n ∷ [])) = return n pongReceive (Msg (S Z) _) = strengthen [ S Z ]ᵐ >> loopTillPongValue pongReceive (Msg (S (S ())) _) loopTillPongValue : ∀ {i} → pongMainActor i (Lift (lsuc lzero) ℕ) loopTillPongValue .force = receive ∞>>= pongReceive ponger : ∀ {i} → ∞ActorM (↑ i) Pongbox ⊤₁ [] constPongrefs ponger .force = loopTillPing ∞>> ((Z ![t: Z ] ([ lift false ]ᵃ)) >> pongMain) where loopTillPing : ∀ {i} → ∞ActorM i Pongbox ⊤₁ [] constPongrefs loopTillPing .force = receive ∞>>= λ { (Msg Z _) → loopTillPing ; (Msg (S Z) _) → return _ ; (Msg (S (S ())) _) } pongMain : ∀ {i} → pongMainActor i ⊤₁ pongMain .force = loopTillPongValue ∞>>= λ { (lift 10) → Z ![t: Z ] [ lift true ]ᵃ ; (lift n) → Z ![t: Z ] [ lift false ]ᵃ >> pongMain } spawner : ∀ {i} → ∞ActorM i Spawnbox ⊤₁ [] (λ _ → Pingbox ∷ [ Pongbox ]ˡ) spawner = do spawn∞ ponger spawn∞ pinger Z ![t: S Z ] [ [ S Z ]>: [ Z ]ᵐ ]ᵃ S Z ![t: S Z ] [ [ Z ]>: [ Z ]ᵐ ]ᵃ
{ "alphanum_fraction": 0.6460363445, "avg_line_length": 33.3070175439, "ext": "agda", "hexsha": "33e79e5ce8140aa8a5ee099f41113dbff941a868", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Zalastax/singly-typed-actors", "max_forks_repo_path": "src/Examples/PingPong.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Zalastax/singly-typed-actors", "max_issues_repo_path": "src/Examples/PingPong.agda", "max_line_length": 134, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Zalastax/thesis", "max_stars_repo_path": "src/Examples/PingPong.agda", "max_stars_repo_stars_event_max_datetime": "2018-02-02T16:44:43.000Z", "max_stars_repo_stars_event_min_datetime": "2018-02-02T16:44:43.000Z", "num_tokens": 1359, "size": 3797 }
module Issue1252 where data Bool : Set where true false : Bool {-# COMPILE GHC Bool = data Bool (True | False) #-} foo : Bool → Bool foo true = false foo false = true {-# COMPILE GHC foo as foohs #-}
{ "alphanum_fraction": 0.652173913, "avg_line_length": 15.9230769231, "ext": "agda", "hexsha": "afa6d3ea38540a47bcddb879ddbd806a34898c85", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Compiler/simple/Issue1252.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Compiler/simple/Issue1252.agda", "max_line_length": 51, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Compiler/simple/Issue1252.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 59, "size": 207 }
{-# OPTIONS --without-K --safe #-} -- https://www.cs.bham.ac.uk/~mhe/papers/omniscient-journal-revised.pdf module Constructive.OmniscienceAlt where open import Level renaming (zero to lzero; suc to lsuc) import Data.Bool as 𝔹 using (_≤_) open import Data.Bool as 𝔹 using (Bool; true; false; T; f≤t; b≤b; _∧_; not; _∨_) import Data.Bool.Properties as 𝔹ₚ open import Data.Empty open import Data.Unit using (tt) open import Data.Nat open import Data.Nat.Properties open import Data.Product as Prod open import Data.Sum as Sum open import Function.Base open import Relation.Binary as B open import Relation.Binary.PropositionalEquality open import Relation.Nullary open import Relation.Nullary.Decidable import Relation.Unary as U -- agda-misc open import Constructive.Axiom open import Constructive.Axiom.Properties open import Constructive.Axiom.Properties.Base.Lemma open import Constructive.Common open import Constructive.Combinators ℕ∞ : Set ℕ∞ = Σ (ℕ → Bool) λ x → ∀ i → T (x i) → T (x (suc i)) fromℕ-C : ℕ → ℕ → Bool fromℕ-C zero zero = false fromℕ-C zero (suc n) = true fromℕ-C (suc m) zero = false fromℕ-C (suc m) (suc n) = fromℕ-C m n fromℕ-convergent : ∀ n i → T (fromℕ-C n i) → T (fromℕ-C n (suc i)) fromℕ-convergent zero (suc i) t = tt fromℕ-convergent (suc n) (suc i) t = fromℕ-convergent n i t fromℕ : ℕ → ℕ∞ fromℕ n = fromℕ-C n , fromℕ-convergent n ∞ : ℕ∞ ∞ = (λ _ → false) , (λ i x → x) _≈_ : Rel (ℕ → Bool) lzero α ≈ β = ∀ i → α i ≡ β i _≉_ : Rel (ℕ → Bool) lzero α ≉ β = ¬ (α ≈ β) _#_ : Rel (ℕ → Bool) lzero α # β = ∃ λ i → α i ≢ β i #⇒≉ : {α β : ℕ → Bool} → α # β → α ≉ β #⇒≉ {α} {β} (i , αi≢βi) α≈β = αi≢βi (α≈β i) ≈-refl : {α : ℕ → Bool} → α ≈ α ≈-refl _ = refl ≈-sym : {α β : ℕ → Bool} → α ≈ β → β ≈ α ≈-sym α≈β i = sym (α≈β i) ≈-trans : {α β γ : ℕ → Bool} → α ≈ β → β ≈ γ → α ≈ γ ≈-trans α≈β β≈γ i = trans (α≈β i) (β≈γ i) _≈∞_ : Rel ℕ∞ lzero x ≈∞ y = proj₁ x ≈ proj₁ y _≉∞_ : Rel ℕ∞ lzero x ≉∞ y = proj₁ x ≉ proj₁ y _#∞_ : Rel ℕ∞ lzero x #∞ y = proj₁ x # proj₁ y -- Proposition 3.1 -- r = ≤-any ≤-any : (ℕ → Bool) → (ℕ → Bool) ≤-any α zero = α 0 ≤-any α (suc n) = α (suc n) ∨ ≤-any α n ≤-any-idem : ∀ α → ≤-any (≤-any α) ≈ ≤-any α ≤-any-idem α zero = refl ≤-any-idem α (suc n) = begin (α (suc n) ∨ ≤-any α n) ∨ ≤-any (≤-any α) n ≡⟨ cong ((α (suc n) ∨ ≤-any α n) ∨_) $ ≤-any-idem α n ⟩ (α (suc n) ∨ ≤-any α n) ∨ ≤-any α n ≡⟨ 𝔹ₚ.∨-assoc (α (suc n)) (≤-any α n) (≤-any α n) ⟩ α (suc n) ∨ (≤-any α n ∨ ≤-any α n) ≡⟨ cong (α (suc n) ∨_) $ 𝔹ₚ.∨-idem (≤-any α n) ⟩ α (suc n) ∨ ≤-any α n ∎ where open ≡-Reasoning private T-∧-× : ∀ {x y} → T (x ∧ y) → (T x × T y) T-∧-× {true} {true} t = tt , tt T-×-∧ : ∀ {x y} → (T x × T y) → T (x ∧ y) T-×-∧ {true} {true} (tt , tt) = tt T-∨-introʳ : ∀ {x y} → T y → T (x ∨ y) T-∨-introʳ {true} {true} t = tt T-∨-introʳ {false} {true} t = tt T-∨-introˡ : ∀ {x y} → T x → T (x ∨ y) T-∨-introˡ {true} {true} t = tt T-∨-introˡ {true} {false} t = tt ≤-any-convergent : ∀ α i → T (≤-any α i) → T (≤-any α (suc i)) ≤-any-convergent α n t = T-∨-introʳ t ≤-any-ℕ∞ : (ℕ → Bool) → ℕ∞ ≤-any-ℕ∞ α = ≤-any α , ≤-any-convergent α ≤-any-construct : ∀ α n → T (α n) → T (≤-any α n) ≤-any-construct α zero t = t ≤-any-construct α (suc n) t = T-∨-introˡ t private not-injective : ∀ {x y} → not x ≡ not y → x ≡ y not-injective {false} {false} refl = refl not-injective {true} {true} refl = refl x≢y⇒not[x]≡y : ∀ {x y} → x ≢ y → not x ≡ y x≢y⇒not[x]≡y {false} {false} x≢y = contradiction refl x≢y x≢y⇒not[x]≡y {false} {true} x≢y = refl x≢y⇒not[x]≡y {true} {false} x≢y = refl x≢y⇒not[x]≡y {true} {true} x≢y = contradiction refl x≢y x≢y⇒x≡not[y] : ∀ {x y} → x ≢ y → x ≡ not y x≢y⇒x≡not[y] {x} {y} x≢y = subst (_≡ not y) (𝔹ₚ.not-involutive x) $ x≢y⇒not[x]≡y {not x} {not y} (x≢y ∘′ not-injective) x≡y⇒not[x]≢y : ∀ {x y} → x ≡ y → not x ≢ y x≡y⇒not[x]≢y {false} {false} p () x≡y⇒not[x]≢y {false} {true} () q x≡y⇒not[x]≢y {true} {false} () q x≡y⇒not[x]≢y {true} {true} p () not[x]≡true→x≢true : ∀ {x} → not x ≡ true → x ≢ true not[x]≡true→x≢true {false} refl () not[x]≡true→x≢true {true} () p false≢true : false ≢ true false≢true () lpo-Bool⇒∀x→x#∞⊎x≈∞ : LPO-Bool ℕ → ∀ x → (x #∞ ∞) ⊎ (x ≈∞ ∞) lpo-Bool⇒∀x→x#∞⊎x≈∞ lpo-Bool (α , con) with lpo-Bool α ... | inj₁ (x , αx≡true) = inj₁ (x , λ αx≡false → false≢true (trans (sym αx≡false) αx≡true)) ... | inj₂ ¬∃x→αx≡true = inj₂ λ i → x≢y⇒x≡not[y] $′ ¬∃P→∀¬P ¬∃x→αx≡true i T-to-≡ : ∀ {x} → T x → x ≡ true T-to-≡ {true} tx = refl ≡-to-T : ∀ {x} → x ≡ true → T x ≡-to-T {true} x≡true = tt private T-¬-not : ∀ {x} → ¬ (T x) → T (not x) T-¬-not {false} n = tt T-¬-not {true} n = n tt T-not-¬ : ∀ {x} → T (not x) → ¬ (T x) T-not-¬ {false} tt () T-not-¬ {true} () y ¬T-≤-any : ∀ α x → ¬ T (≤-any α x) → ∃ λ y → ¬ T (α y) ¬T-≤-any α zero ¬T with α 0 | inspect α 0 ... | true | [ α0≡true ] = contradiction tt ¬T ... | false | [ α0≡false ] = zero , (λ T[α0] → subst T α0≡false T[α0]) ¬T-≤-any α (suc x) ¬T with α (suc x) | inspect α (suc x) ... | true | [ αsn≡true ] = ¬T-≤-any α x ¬T ... | false | [ αsn≡false ] = (suc x) , (λ T[αsn] → subst T αsn≡false T[αsn]) {- ¬T-≤-any′ : ∀ α x → ¬ T (≤-any (not ∘′ α) x) → ∃ λ y → T (α y) ¬T-≤-any′ α x ¬T = Prod.map₂ (λ nt → subst T (𝔹ₚ.not-involutive _) (T-¬-not nt)) $′ ¬T-≤-any (not ∘ α) x ¬T ∀x→x#∞⊎x≈∞⇒lpo-Bool : (∀ x → (x #∞ ∞) ⊎ (x ≈∞ ∞)) → LPO-Bool ℕ ∀x→x#∞⊎x≈∞⇒lpo-Bool ≈∞? P with ≈∞? (≤-any-ℕ∞ (λ n → not (P n))) ... | inj₁ (x , ≤-any[not∘P,x]≢true) = inj₁ (Prod.map₂ T-to-≡ (¬T-≤-any′ P x (contraposition T-to-≡ ≤-any[not∘P,x]≢true))) ... | inj₂ ∀i→≤-any[not∘P,i]≡true = inj₂ (∀¬P→¬∃P λ i → not[x]≡true→x≢true (T-to-≡ $ ≤-any-extract (not ∘ P) i $ ≡-to-T (∀i→≤-any[not∘P,i]≡true i))) -- ≤-any (λ n → not (P n)) x ≡ true → ⊥ -- ≤-any (not ∘ P) x ≡ false -- -- --------------------------- -- T (≤-any P x) -}
{ "alphanum_fraction": 0.5173459077, "avg_line_length": 29.69, "ext": "agda", "hexsha": "c0f917cecdde401ad898fca8076c68c1275de268", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_path": "Constructive/OmniscienceAlt.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_path": "Constructive/OmniscienceAlt.agda", "max_line_length": 114, "max_stars_count": 3, "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_path": "Constructive/OmniscienceAlt.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "num_tokens": 3106, "size": 5938 }
module UnSizedIO.Object where open import Data.Product record Interface : Set₁ where field Method : Set Result : (m : Method) → Set open Interface public -- A simple object just returns for a method the response -- and the object itself record Object (i : Interface) : Set where coinductive field objectMethod : (m : Method i) → Result i m × Object i open Object public
{ "alphanum_fraction": 0.7088607595, "avg_line_length": 19.75, "ext": "agda", "hexsha": "c5a990787903226158e3bd418c5c6bbf3ed1e544", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "src/UnSizedIO/Object.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "src/UnSizedIO/Object.agda", "max_line_length": 57, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "src/UnSizedIO/Object.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 104, "size": 395 }
module Equality where data Nat : Set where zero : Nat suc : Nat -> Nat _+_ : Nat -> Nat -> Nat zero + m = m suc n + m = suc (n + m) data Vec (A : Set) : Nat -> Set where [] : Vec A zero _::_ : {n : Nat} -> A -> Vec A n -> Vec A (suc n) -- so that we know to parse infixr 40 _::_ -- some hacks 'cuz we don't do pragmas one : Nat one = suc zero two : Nat two = suc (suc zero) three : Nat three = suc (suc (suc zero)) 3things : Vec Nat three 3things = zero :: one :: zero :: [] 3things' : Vec Nat (one + two) 3things' = 3things -- getting boring aint it? 3things'' : Vec Nat (two + one) 3things'' = 3things'
{ "alphanum_fraction": 0.5821371611, "avg_line_length": 16.9459459459, "ext": "agda", "hexsha": "5143e33aa559df2d9e2621345362799660ce5de1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_path": "tests/covered/Equality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejtokarcik/agda-semantics", "max_issues_repo_path": "tests/covered/Equality.agda", "max_line_length": 51, "max_stars_count": 3, "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_path": "tests/covered/Equality.agda", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "num_tokens": 222, "size": 627 }
{-# OPTIONS --show-implicit #-} {-# OPTIONS -v tc.interaction:20 #-} ------------------------------------------------------------------------ -- Library id : ∀ {X : Set} → X → X id x = x infixr 9 _∘_ _∘_ : ∀ {a b c} {A : Set a} {B : A → Set b} {C : {x : A} → B x → Set c} → (∀ {x} (y : B x) → C y) → (g : (x : A) → B x) → ((x : A) → C (g x)) f ∘ g = λ x → f (g x) record Σ (X : Set) (Y : X → Set) : Set where constructor _,_ field proj₁ : X proj₂ : Y proj₁ open Σ public syntax Σ X (λ x → Y) = Σ[ x ∈ X ] Y data _≡_ {X : Set} (x : X) : X → Set where refl : x ≡ x subst : ∀ {A} (P : A → Set) {x y} → x ≡ y → P x → P y subst P refl p = p record _▷_ (I O : Set) : Set₁ where constructor _◃_/_ field Parameter : (o : O) → Set Arity : ∀ {o} (p : Parameter o) → Set input : ∀ {o} (p : Parameter o) (a : Arity p) → I open _▷_ public Pow : Set → Set₁ Pow X = X → Set infix 4 _⊆_ _⊆_ : ∀ {X} → Pow X → Pow X → Set P ⊆ Q = ∀ {x} → P x → Q x ⟦_⟧ : ∀ {I O} → I ▷ O → (Pow I → Pow O) ⟦ P ◃ A / s ⟧ X o = Σ[ p ∈ P o ] ((a : A p) → X (s p a)) Alg : ∀ {O} → O ▷ O → Pow O → Set Alg Σ X = ⟦ Σ ⟧ X ⊆ X module _ {I₁ I₂ O₁ O₂} where record ContainerMorphism (C₁ : I₁ ▷ O₁) (C₂ : I₂ ▷ O₂) (f : I₁ → I₂) (g : O₁ → O₂) (_∼_ : I₂ → I₂ → Set) (_≈_ : Set → Set → Set) (_·_ : ∀ {A B} → A ≈ B → A → B) : Set where field parameter : Parameter C₁ ⊆ Parameter C₂ ∘ g arity : ∀ {o} {p₁ : Parameter C₁ o} → Arity C₂ (parameter p₁) ≈ Arity C₁ p₁ coherent : ∀ {o} {p₁ : Parameter C₁ o} {a₂ : Arity C₂ (parameter p₁)} → f (input C₁ p₁ (arity · a₂)) ∼ input C₂ (parameter p₁) a₂ open ContainerMorphism public _⇒[_/_]_ : I₁ ▷ O₁ → (I₁ → I₂) → (O₁ → O₂) → I₂ ▷ O₂ → Set C₁ ⇒[ f / g ] C₂ = ContainerMorphism C₁ C₂ f g _≡_ (λ R₂ R₁ → R₂ → R₁) (λ f x → f x) ⟪_⟫ : ∀ {I} {C₁ C₂ : I ▷ I} → C₁ ⇒[ id / id ] C₂ → (X : Pow I) → ⟦ C₁ ⟧ X ⊆ ⟦ C₂ ⟧ X ⟪ m ⟫ X (c , k) = parameter m c , λ a₂ → subst X (coherent m) (k (arity m a₂)) ------------------------------------------------------------------------ -- Example weaken : ∀ {I} {Ω : I ▷ I} {Ψ : I ▷ I} {X : Pow I} → Alg Ψ X → Ω ⇒[ id / id ] Ψ → Alg Ω X weaken {I}{Ω}{Ψ}{X = X} φ m {i} (p , k) = φ {x = i} (⟪ m ⟫ {!X!} (p , k)) weaken2 : ∀ {I} {Ω : I ▷ I} {Ψ : I ▷ I} {X : Pow I} → Alg Ψ X → Ω ⇒[ id / id ] Ψ → Alg Ω X weaken2 {I}{Ω}{Ψ}{X = X} φ m {i} (p , k) = φ {i} (⟪ m ⟫ X (p , k))
{ "alphanum_fraction": 0.3940563489, "avg_line_length": 27.5638297872, "ext": "agda", "hexsha": "29859de970e59b793aefa26560a53ca0e2056297", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue1353.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue1353.agda", "max_line_length": 79, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue1353.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 1143, "size": 2591 }
{-# OPTIONS -v impossible:10 #-} -- Andreas, 2021-05-12, issue #5379 module ImpossibleVerboseReduceM where -- Note: keep ReduceM as first word after IMPOSSIBLE! {-# IMPOSSIBLE ReduceM should also print this debug message. #-} -- Should print the text after IMPOSSIBLE and then raise an internal error.
{ "alphanum_fraction": 0.75, "avg_line_length": 33.7777777778, "ext": "agda", "hexsha": "ea584aa77f0abdc8d70347a488ecd0e49657e7d3", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Fail/ImpossibleVerboseReduceM.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Fail/ImpossibleVerboseReduceM.agda", "max_line_length": 75, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Fail/ImpossibleVerboseReduceM.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 78, "size": 304 }
-- Andreas, 2014-03-27 fixed issue {-# OPTIONS --copatterns --sized-types #-} open import Common.Size mutual data D (i : Size) : Set where inn : R i → D i record R (i : Size) : Set where -- Note: not coinductive field force : (j : Size< i) → D j open R inh : (i : Size) → R i force (inh i) j = inn (inh j) -- inh should be rejected by termination checker data ⊥ : Set where elim : D ∞ → ⊥ elim (inn r) = elim (force r ∞) absurd : ⊥ absurd = elim (inn (inh ∞))
{ "alphanum_fraction": 0.5833333333, "avg_line_length": 16.4, "ext": "agda", "hexsha": "29ef33bb54609d5d2c152ffd8a05e95e2940e7d6", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/Issue1015.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/Issue1015.agda", "max_line_length": 48, "max_stars_count": 1, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/fail/Issue1015.agda", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "num_tokens": 172, "size": 492 }
module Issue276 where boo : {S T : Set}(f : S -> T)(x y : S) -> ((P : S -> Set) -> P x -> P y) -> (P : T -> Set) -> P (f x) -> P (f y) boo = \ f x y q P -> q (\ s -> P (f s)) record Pack (S : Set) : Set where constructor pack field unpack : S open Pack unpack' : {S : Set} -> Pack S -> S unpack' (pack s) = s foo : {S : Set}(x : Pack S)(P : Pack S -> Set) -> P (pack (unpack x)) -> P x foo = \ x P p -> p goo : {S : Set}(x : Pack S)(P : S -> Set) -> P (unpack x) -> P (unpack' x) goo = \ x -> boo unpack' (pack (unpack x)) x (foo x) {- normal form of goo is \ x P p -> p -} goo' : {S : Set}(x : Pack S)(P : S -> Set) -> P (unpack x) -> P (unpack' x) goo' = \ x P p -> p {- /Users/conor/Desktop/fooling/RecConBug.agda:27,19-20 unpack x != unpack' x of type .S when checking that the expression p has type P (unpack' x) -}
{ "alphanum_fraction": 0.5035294118, "avg_line_length": 25.7575757576, "ext": "agda", "hexsha": "66cd17a5fc82a0008638d43b11b971b7d6c374e9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_path": "test/succeed/Issue276.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_path": "test/succeed/Issue276.agda", "max_line_length": 76, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/Issue276.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 323, "size": 850 }
module Reduction where open import Prelude open import Lambda open import Subst open import Trans infix 10 _⟶β_ data _⟶β_ : forall {Γ τ} -> (t u : Term Γ τ) -> Set where β : forall {Γ σ τ}{t : Term (Γ , σ) τ} Δ {u : Term (Γ ++ Δ) σ} -> (ƛ t) ↑ Δ • u ⟶β t ↑ Δ / [ Δ ⟵ u ] wk⟶ : forall {Γ σ τ}{t₁ t₂ : Term Γ τ} -> t₁ ⟶β t₂ -> wk {σ = σ} t₁ ⟶β wk t₂ •⟶L : forall {Γ σ τ}{t₁ t₂ : Term Γ (σ ⟶ τ)}{u : Term Γ σ} -> t₁ ⟶β t₂ -> t₁ • u ⟶β t₂ • u •⟶R : forall {Γ σ τ}{t : Term Γ (σ ⟶ τ)}{u₁ u₂ : Term Γ σ} -> u₁ ⟶β u₂ -> t • u₁ ⟶β t • u₂ ƛ⟶ : forall {Γ σ τ}{t₁ t₂ : Term (Γ , σ) τ} -> t₁ ⟶β t₂ -> ƛ t₁ ⟶β ƛ t₂ _⟶β*_ : {Γ : Ctx}{τ : Type}(x y : Term Γ τ) -> Set x ⟶β* y = [ _⟶β_ ]* x y ↑⟶β : {Γ : Ctx}(Δ : Ctx){τ : Type}{t u : Term Γ τ} -> t ⟶β u -> t ↑ Δ ⟶β u ↑ Δ ↑⟶β ε r = r ↑⟶β (Δ , σ) r = wk⟶ (↑⟶β Δ r)
{ "alphanum_fraction": 0.439862543, "avg_line_length": 29.1, "ext": "agda", "hexsha": "b27b9808881270ac2ee779a2ad39bd52e9f52d56", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/tait/Reduction.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/tait/Reduction.agda", "max_line_length": 69, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "examples/outdated-and-incorrect/tait/Reduction.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 451, "size": 873 }
------------------------------------------------------------------------------ -- Distributive laws on a binary operation: Task B ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module DistributiveLaws.TaskB-HalvedStepsATP where open import DistributiveLaws.Base open import Common.FOL.Relation.Binary.EqReasoning ------------------------------------------------------------------------------ -- We prove the half of the proof steps (skipping the even ones) of -- DistributiveLaws.TaskB-I using the ATPs. prop₂ : ∀ u x y z → (x · y · (z · u)) · ((x · y · (z · u)) · (x · z · (y · u))) ≡ x · z · (y · u) prop₂ u x y z = -- The numbering of the proof step justifications are associated with -- the numbers used in DistributiveLaws.TaskB-I. xy·zu · (xy·zu · xz·yu) ≡⟨ j₁₋₃ ⟩ xy·zu · (x·zu · xz·yu · (y·zu · xz·yu)) ≡⟨ j₃₋₅ ⟩ xy·zu · (xz · xu·yu · (y·zu · xz·yu)) ≡⟨ j₅₋₇ ⟩ xy·zu · (xz · xyu · (yz·yu · xz·yu)) ≡⟨ j₇₋₉ ⟩ xy·zu · (xz · xyu · (yxz · yu)) ≡⟨ j₉₋₁₁ ⟩ xy·zu · (xz · xyu · (y·xu · z·yu)) ≡⟨ j₁₁₋₁₃ ⟩ xz·yz · xyu · (xz · xyu · (y·xu · z·yu)) ≡⟨ j₁₃₋₁₅ ⟩ xz · xyu · (yz · xyu · (y·xu · z·yu)) ≡⟨ j₁₅₋₁₇ ⟩ xz · xyu · (y · xu·yu · (z · xu·yu) · (y·xu · z·yu)) ≡⟨ j₁₇₋₁₉ ⟩ xz · xyu · (y·xu · y·yu · (y·xu · z·yu) · (z · xu·yu · (y·xu · z·yu))) ≡⟨ j₁₉₋₂₁ ⟩ xz · xyu · (y·xu · yz·yu · (z · xu·yu · (y·xu · z·yu))) ≡⟨ j₂₁₋₂₃ ⟩ xz · xyu · (y · xu·zu · (z · xu·yu · (y·xu · z·yu))) ≡⟨ j₂₃₋₂₅ ⟩ (xz · xyu) · (y · xu·zu · (z·xu · y·xu · z·yu)) ≡⟨ j₂₅₋₂₇ ⟩ xz · xyu · (y · xu·zu · (zy·xu · zy·zu)) ≡⟨ j₂₇₋₂₉ ⟩ xz · xyu · (y·zy · xu·zu) ≡⟨ j₂₉₋₃₁ ⟩ xz·xy · xzu · (y·zy · xzu) ≡⟨ j₃₁₋₃₃ ⟩ x·zy · y·zy · xzu ≡⟨ j₃₃₋₃₅ ⟩ xzy · xzu ≡⟨ j₃₅ ⟩ xz·yu ∎ where -- Two variables abbreviations xz = x · z yu = y · u yz = y · z zy = z · y {-# ATP definitions xz yu yz zy #-} -- Three variables abbreviations xyu = x · y · u xzu = x · z · u xzy = x · z · y yxz = y · x · z {-# ATP definitions xyu xzu xzy yxz #-} x·zu = x · (z · u) x·zy = x · (z · y) {-# ATP definitions x·zu x·zy #-} y·xu = y · (x · u) y·yu = y · (y · u) y·zu = y · (z · u) y·zy = y · (z · y) {-# ATP definitions y·xu y·yu y·zu y·zy #-} z·xu = z · (x · u) z·yu = z · (y · u) {-# ATP definitions z·xu z·yu #-} -- Four variables abbreviations xu·yu = x · u · (y · u) xu·zu = x · u · (z · u) {-# ATP definitions xu·yu xu·zu #-} xy·zu = x · y · (z · u) {-# ATP definition xy·zu #-} xz·xy = x · z · (x · y) xz·yu = x · z · (y · u) xz·yz = x · z · (y · z) {-# ATP definitions xz·xy xz·yu xz·yz #-} yz·yu = y · z · (y · u) {-# ATP definition yz·yu #-} zy·xu = z · y · (x · u) zy·zu = z · y · (z · u) {-# ATP definitions zy·xu zy·zu #-} -- Steps justifications postulate j₁₋₃ : xy·zu · (xy·zu · xz·yu) ≡ xy·zu · (x·zu · xz·yu · (y·zu · xz·yu)) {-# ATP prove j₁₋₃ #-} postulate j₃₋₅ : xy·zu · (x·zu · xz·yu · (y·zu · xz·yu)) ≡ xy·zu · (xz · xu·yu · (y·zu · xz·yu)) {-# ATP prove j₃₋₅ #-} postulate j₅₋₇ : xy·zu · (xz · xu·yu · (y·zu · xz·yu)) ≡ xy·zu · (xz · xyu · (yz·yu · xz·yu)) {-# ATP prove j₅₋₇ #-} postulate j₇₋₉ : xy·zu · (xz · xyu · (yz·yu · xz·yu)) ≡ xy·zu · (xz · xyu · (yxz · yu)) {-# ATP prove j₇₋₉ #-} postulate j₉₋₁₁ : xy·zu · (xz · xyu · (yxz · yu)) ≡ xy·zu · (xz · xyu · (y·xu · z·yu)) {-# ATP prove j₉₋₁₁ #-} postulate j₁₁₋₁₃ : xy·zu · (xz · xyu · (y·xu · z·yu)) ≡ xz·yz · xyu · (xz · xyu · (y·xu · z·yu)) {-# ATP prove j₁₁₋₁₃ #-} postulate j₁₃₋₁₅ : xz·yz · xyu · (xz · xyu · (y·xu · z·yu)) ≡ xz · xyu · (yz · xyu · (y·xu · z·yu)) {-# ATP prove j₁₃₋₁₅ #-} postulate j₁₅₋₁₇ : xz · xyu · (yz · xyu · (y·xu · z·yu)) ≡ xz · xyu · (y · xu·yu · (z · xu·yu) · (y·xu · z·yu)) {-# ATP prove j₁₅₋₁₇ #-} postulate j₁₇₋₁₉ : xz · xyu · (y · xu·yu · (z · xu·yu) · (y·xu · z·yu)) ≡ xz · xyu · (y·xu · y·yu · (y·xu · z·yu) · (z · xu·yu · (y·xu · z·yu))) {-# ATP prove j₁₇₋₁₉ #-} postulate j₁₉₋₂₁ : xz · xyu · (y·xu · y·yu · (y·xu · z·yu) · (z · xu·yu · (y·xu · z·yu))) ≡ xz · xyu · (y·xu · yz·yu · (z · xu·yu · (y·xu · z·yu))) {-# ATP prove j₁₉₋₂₁ #-} postulate j₂₁₋₂₃ : xz · xyu · (y·xu · yz·yu · (z · xu·yu · (y·xu · z·yu))) ≡ xz · xyu · (y · xu·zu · (z · xu·yu · (y·xu · z·yu))) {-# ATP prove j₂₁₋₂₃ #-} postulate j₂₃₋₂₅ : xz · xyu · (y · xu·zu · (z · xu·yu · (y·xu · z·yu))) ≡ (xz · xyu) · (y · xu·zu · (z·xu · y·xu · z·yu)) {-# ATP prove j₂₃₋₂₅ #-} postulate j₂₅₋₂₇ : (xz · xyu) · (y · xu·zu · (z·xu · y·xu · z·yu)) ≡ xz · xyu · (y · xu·zu · (zy·xu · zy·zu)) {-# ATP prove j₂₅₋₂₇ #-} postulate j₂₇₋₂₉ : xz · xyu · (y · xu·zu · (zy·xu · zy·zu)) ≡ xz · xyu · (y·zy · xu·zu) {-# ATP prove j₂₇₋₂₉ #-} postulate j₂₉₋₃₁ : xz · xyu · (y·zy · xu·zu) ≡ xz·xy · xzu · (y·zy · xzu) {-# ATP prove j₂₉₋₃₁ #-} postulate j₃₁₋₃₃ : xz·xy · xzu · (y·zy · xzu) ≡ x·zy · y·zy · xzu {-# ATP prove j₃₁₋₃₃ #-} postulate j₃₃₋₃₅ : x·zy · y·zy · xzu ≡ xzy · xzu {-# ATP prove j₃₃₋₃₅ #-} postulate j₃₅ : xzy · xzu ≡ xz·yu {-# ATP prove j₃₅ #-}
{ "alphanum_fraction": 0.3896403827, "avg_line_length": 34.4431818182, "ext": "agda", "hexsha": "8a395bedb22ec5936a6b2ae8466e9755ef747663", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/DistributiveLaws/TaskB-HalvedStepsATP.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/DistributiveLaws/TaskB-HalvedStepsATP.agda", "max_line_length": 79, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/DistributiveLaws/TaskB-HalvedStepsATP.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 2738, "size": 6062 }
-- Two out-of-scope variables are given the same name #3678 open import Agda.Builtin.Sigma open import Agda.Builtin.Equality postulate A : Set B : A → Set a : A Pi : (A → Set) → Set Pi B = {x : A} → B x foo : Pi \ y → Σ (B y) \ _ → Pi \ z → Σ (y ≡ a → B z) \ _ → B y → B z → A foo = {!!} , (\ { refl → {!!} }) , {!!} -- Expected: -- ... -- ?2 : B x₁ → B x₂ → A (not the same name for these variables)
{ "alphanum_fraction": 0.5169082126, "avg_line_length": 20.7, "ext": "agda", "hexsha": "26c996ae310ff1adb4f09d07114acfd31426f570", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue3678.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue3678.agda", "max_line_length": 74, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue3678.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 161, "size": 414 }
-- Long version, the final version is Nat.agda module NatTry where data ℕ : Set where zero : ℕ suc : ℕ → ℕ one two three four : ℕ one = suc zero two = suc one three = suc two four = suc three _+_ : ℕ → ℕ → ℕ zero + b = b suc a + b = suc (a + b) data Bool : Set where true : Bool false : Bool _≟_ : ℕ → ℕ → Bool zero ≟ zero = true suc a ≟ suc b = a ≟ b _ ≟ _ = false infix 4 _≟_ assocProp : ℕ → ℕ → ℕ → Bool assocProp a b c = (a + b) + c ≟ a + (b + c) reflProp : ℕ → Bool reflProp n = n ≟ n module isTrue-direct where data isTrue : Bool → Set where ok : isTrue true unitTest : isTrue (assocProp one one two) unitTest = ok refl-True : (n : ℕ) → isTrue (reflProp n) refl-True zero = ok refl-True (suc n) = refl-True n assocProp-zero-True : (n m : ℕ) → isTrue (assocProp zero n m) assocProp-zero-True n m = refl-True (n + m) assocProp-True : (n m k : ℕ) → isTrue (assocProp n m k) assocProp-True zero m k = assocProp-zero-True m k assocProp-True (suc n) m k = assocProp-True n m k -------- switch to _≡_ module ≡-Bool where -- propositional equalitiy on Bool data _≡_ : Bool → Bool → Set where refl : {a : Bool} → a ≡ a -- the Bool paramter is hidden infix 4 _≡_ isTrue : Bool → Set isTrue x = x ≡ true -- generic propositional equality data _≡_ {A : Set} : A → A → Set where refl : {a : A} → a ≡ a infix 4 _≡_ -- This is the type of the refl constructor -- The parameters are hidden refl′ : {A : Set} {a : A} → a ≡ a refl′ = refl isTrue : Bool → Set isTrue x = x ≡ true refl-True : (n : ℕ) → isTrue (reflProp n) refl-True zero = refl refl-True (suc n) = refl-True n unitTest : isTrue (assocProp one one two) unitTest = refl assocProp-zero-True : (n m : ℕ) → isTrue (assocProp zero n m) assocProp-zero-True n m = refl-True (n + m) assocProp-True : (n m k : ℕ) → isTrue (assocProp n m k) assocProp-True zero m k = assocProp-zero-True m k assocProp-True (suc n) m k = assocProp-True n m k ---- switch from _≟_ cong : {A B : Set} {a b : A} (f : A → B) → a ≡ b → f a ≡ f b cong f refl = refl cong-suc : {a b : ℕ} → a ≡ b → suc a ≡ suc b cong-suc = cong suc ≡-to-≟ : {a b : ℕ} → a ≡ b → isTrue (a ≟ b) ≡-to-≟ {a} refl = refl-True a ≟-to-≡ : (a b : ℕ) → isTrue (a ≟ b) → a ≡ b ≟-to-≡ zero zero i = refl ≟-to-≡ zero (suc b) () ≟-to-≡ (suc a) zero () ≟-to-≡ (suc a) (suc b) i = cong-suc (≟-to-≡ a b i) -- the rest is in Nat.agda
{ "alphanum_fraction": 0.5841910251, "avg_line_length": 21.1217391304, "ext": "agda", "hexsha": "e0a8f0faf74055e8e02b03784c2555bd7bb2f5a8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a8902e36ed2037de9008e061d54517d4d7d99f0f", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "divipp/agda-intro-prezi", "max_forks_repo_path": "NatTry.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a8902e36ed2037de9008e061d54517d4d7d99f0f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "divipp/agda-intro-prezi", "max_issues_repo_path": "NatTry.agda", "max_line_length": 63, "max_stars_count": 2, "max_stars_repo_head_hexsha": "a8902e36ed2037de9008e061d54517d4d7d99f0f", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "divipp/agda-intro-prezi", "max_stars_repo_path": "NatTry.agda", "max_stars_repo_stars_event_max_datetime": "2020-01-21T14:53:25.000Z", "max_stars_repo_stars_event_min_datetime": "2018-11-27T02:50:48.000Z", "num_tokens": 985, "size": 2429 }
------------------------------------------------------------------------ -- η-expansion of simply-kinded types in Fω with interval kinds ------------------------------------------------------------------------ {-# OPTIONS --safe --without-K #-} module FOmegaInt.Kinding.Simple.EtaExpansion where open import Data.Fin using (Fin; zero; suc; raise; lift) open import Data.Fin.Substitution open import Data.Fin.Substitution.Lemmas open import Data.Fin.Substitution.ExtraLemmas open import Data.List using ([]; _∷_; _∷ʳ_) open import Data.Maybe using (Maybe) open import Data.Nat using (zero; suc) open import Data.Product as Prod using (_,_) open import Data.Vec as Vec using ([]) open import Function using (_∘_) open import Relation.Binary.PropositionalEquality open import FOmegaInt.Syntax open import FOmegaInt.Syntax.SingleVariableSubstitution open import FOmegaInt.Syntax.HereditarySubstitution open import FOmegaInt.Syntax.Normalization open import FOmegaInt.Syntax.WeakEquality open import FOmegaInt.Kinding.Simple ------------------------------------------------------------------------ -- η-expansion of simply kinded types. -- -- TODO: explain the point of this and how "simple" kinding differs -- from "canonical" kinding. open Syntax open SimpleCtx open Substitution hiding (_↑; _↑⋆_; sub; subst) open SimpHSubstLemmas open RenamingCommutes open WeakHereditarySubstitutionEquality open WeakEqEtaExpansion open KindedRenaming open KindedHereditarySubstitution open Kinding module TrackSimpleKindsKindedEtaExp where private module V = VarSubst module TK = TrackSimpleKindsEtaExp -- NOTE. The definition of the functions η-exp-Var∈ and η-exp-Ne∈ -- below are structurally recursive in the *shape* parameter k, but -- *not* in the kind j because we need to weaken the domain j₁ of -- the dependent kind (j = Π j₁ j₂) in the arrow case. The -- additional hypothesis ⌊ j ⌋≡ k ensures that k is indeed the shape -- of the kind j. mutual -- η-expansion preserves simple kinding of neutral types. η-exp-Var∈ : ∀ {n} {Γ : Ctx n} {x j k} (hyp : ⌊ j ⌋≡ k) → Γ ⊢ j kds → Γ ⊢Var x ∈ k → Γ ⊢Nf TK.η-exp j hyp (var∙ x) ∈ k η-exp-Var∈ hyp j-kd x∈k = η-exp-Ne∈ hyp j-kd (∈-∙ x∈k ∈-[]) η-exp-Ne∈ : ∀ {n} {Γ : Ctx n} {a j k} (hyp : ⌊ j ⌋≡ k) → Γ ⊢ j kds → Γ ⊢Ne a ∈ k → Γ ⊢Nf TK.η-exp j hyp a ∈ k η-exp-Ne∈ is-★ (kds-⋯ b∈* c∈*) a∈★ = ∈-ne a∈★ η-exp-Ne∈ (is-⇒ ⌊j₁⌋≡k₁ ⌊j₂⌋≡k₂) (kds-Π j₁-kds j₂-kds) (∈-∙ {x} {_} {_} {as} x∈l l∋as∈k₁⇒k₂) = subst (λ j → _ ⊢Nf η-x∙as ∈ j ⇒ _) (⌊⌋≡⇒⌊⌋-≡ ⌊j₁⌋≡k₁) (∈-Π-i j₁-kds (η-exp-Ne∈ ⌊j₂⌋≡k₂ j₂-kds x∙as·z∈k₂)) where η-x∙as = TK.η-exp _ (is-⇒ ⌊j₁⌋≡k₁ ⌊j₂⌋≡k₂) (var x ∙ as) z∈k₁ = η-exp-Var∈ (⌊⌋≡-weaken ⌊j₁⌋≡k₁) (kds-weaken j₁-kds) (∈-var zero (cong kd (⌊⌋≡⇒⌊⌋-≡ ⌊j₁⌋≡k₁))) x∙as·z∈k₂ = Ne∈-Π-e (Ne∈-weaken (∈-∙ x∈l l∋as∈k₁⇒k₂)) z∈k₁ mutual -- η-expansion of neutrals followed by hereditary substitution -- vanishes if the substitution hits the head of the neutral. η-exp-var-Hit-/⟨⟩ : ∀ {k m n Γ Δ} {x a j} (hyp : ⌊ j ⌋≡ k) {σ : SVSub m n} → Hit σ x a → Γ ⊢ j kds → Γ ⊢Var x ∈ k → Δ ⊢/⟨ k ⟩ σ ∈ Γ → TK.η-exp j hyp (var∙ x) /⟨ k ⟩ σ ≈ var∙ x /⟨ k ⟩ σ η-exp-var-Hit-/⟨⟩ hyp hitP j-kds x∈k σ∈Γ = η-exp-ne-Hit-/⟨⟩ hyp hitP j-kds (∈-∙ x∈k ∈-[]) σ∈Γ η-exp-ne-Hit-/⟨⟩ : ∀ {k l m n Γ Δ} {x a as j} (hyp : ⌊ j ⌋≡ k) {σ : SVSub m n} → Hit σ x a → Γ ⊢ j kds → Γ ⊢Ne var x ∙ as ∈ k → Δ ⊢/⟨ l ⟩ σ ∈ Γ → TK.η-exp j hyp (var x ∙ as) /⟨ l ⟩ σ ≈ var x ∙ as /⟨ l ⟩ σ η-exp-ne-Hit-/⟨⟩ is-★ hitP j-kds a∈k σ∈Γ = ≈-refl _ η-exp-ne-Hit-/⟨⟩ (is-⇒ ⌊j₁⌋≡k₁ ⌊j₂⌋≡k₂) hitP (kds-Π j₁-kds j₂-kds) (∈-∙ {as = as} x∈l l∋as∈k₁⇒k₂) σ∈Γ with lookup-/⟨⟩∈-Hit σ∈Γ x∈l hitP η-exp-ne-Hit-/⟨⟩ {l = l} {Γ = Γ} {a = a} (is-⇒ {j₁} {j₂} {k₁} {k₂} ⌊j₁⌋≡k₁ ⌊j₂⌋≡k₂) {σ} hitP (kds-Π j₁-kds j₂-kds) (∈-∙ {as = as} (∈-var {l} x Γ[x]≡kd-l) l∋as∈k₁⇒k₂) σ∈Γ | a∈l , refl = let hitP-σ↑ = hitP ↑ ηz = TK.η-exp (weakenKind′ j₁) (⌊⌋≡-weaken ⌊j₁⌋≡k₁) (var∙ zero) as′ = weakenSpine as ηz∈k₁ = η-exp-Var∈ (⌊⌋≡-weaken ⌊j₁⌋≡k₁) (kds-weaken j₁-kds) (∈-var zero refl) kd-l∷Γ[x+1]≡kd-l = trans (lookup-suc (kd l) Γ x) Γ[x]≡kd-l x+1∈l = ∈-var (suc x) kd-l∷Γ[x+1]≡kd-l l∋as∈k₁⇒k₂′ = Sp∈-weaken l∋as∈k₁⇒k₂ σ↑∈k₁∷Γ = ∈-H↑ σ∈Γ l∋as//σ∈k₁⇒k₂ = Sp∈-/⟨⟩ l∋as∈k₁⇒k₂ σ∈Γ a∙as/σ∈k₁⇒k₂ = Nf∈-∙∙ a∈l l∋as//σ∈k₁⇒k₂ j′ , a′ , j′-kds , a′∈k₁⇒k₂ , rest = Nf∈-⇒-inv a∙as/σ∈k₁⇒k₂ ⌊j′⌋≡k₁ , a∙as/σ≡Λj′a′ = rest ⌊j₁/σ⌋≡⌊j′⌋ = let open ≡-Reasoning in begin ⌊ j₁ Kind/⟨ l ⟩ σ ⌋ ≡⟨ ⌊⌋-Kind/⟨⟩ j₁ ⟩ ⌊ j₁ ⌋ ≡⟨ ⌊⌋≡⇒⌊⌋-≡ ⌊j₁⌋≡k₁ ⟩ k₁ ≡⟨ sym ⌊j′⌋≡k₁ ⟩ ⌊ j′ ⌋ ∎ open ≈-Reasoning in begin TK.η-exp (Π j₁ j₂) (is-⇒ ⌊j₁⌋≡k₁ ⌊j₂⌋≡k₂) (var x ∙ as) /⟨ l ⟩ σ ≈⟨ ≈-Λ∙ ⌊j₁/σ⌋≡⌊j′⌋ (begin TK.η-exp j₂ ⌊j₂⌋≡k₂ (weakenElim (var x ∙ as) ⌜·⌝ ηz) /⟨ l ⟩ σ ↑ ≡⟨ cong (λ y → TK.η-exp _ ⌊j₂⌋≡k₂ (var y ∙ as′ ⌜·⌝ ηz) /⟨ l ⟩ σ ↑) (VarLemmas.lookup-wk x) ⟩ TK.η-exp j₂ ⌊j₂⌋≡k₂ (var (suc x) ∙ as′ ⌜·⌝ ηz) /⟨ l ⟩ σ ↑ ≈⟨ η-exp-ne-Hit-/⟨⟩ ⌊j₂⌋≡k₂ hitP-σ↑ (subst (λ k → kd k ∷ _ ⊢ _ kds) (⌊⌋≡⇒⌊⌋-≡ ⌊j₁⌋≡k₁) j₂-kds) (∈-∙ x+1∈l (∈-∷ʳ l∋as∈k₁⇒k₂′ ηz∈k₁)) σ↑∈k₁∷Γ ⟩ var (suc x) ∙ as′ ⌜·⌝ ηz /⟨ l ⟩ σ ↑ ≡⟨ cong (_?∙∙⟨ l ⟩ ((as′ ∷ʳ ηz) //⟨ l ⟩ σ ↑)) (lookup-Hit hitP-σ↑) ⟩ weakenElim a ∙∙⟨ l ⟩ ((as′ ∷ʳ ηz) //⟨ l ⟩ σ ↑) ≡⟨ cong (_ ∙∙⟨ l ⟩_) (++-//⟨⟩ (as′) (_ ∷ [])) ⟩ weakenElim a ∙∙⟨ l ⟩ (as′ //⟨ l ⟩ σ ↑ ∷ʳ ηz /⟨ l ⟩ σ ↑) ≡⟨ Nf∈-++-∙∙⟨⟩ (Nf∈-weaken a∈l) (Sp∈-/⟨⟩ l∋as∈k₁⇒k₂′ σ↑∈k₁∷Γ) (∈-∷ (Nf∈-/⟨⟩ ηz∈k₁ σ↑∈k₁∷Γ) ∈-[]) ⟩ weakenElim a ∙∙⟨ l ⟩ (as′ //⟨ l ⟩ σ ↑) ⌜·⌝⟨ k₁ ⇒ k₂ ⟩ (ηz /⟨ l ⟩ σ ↑) ≡⟨ cong (λ bs → weakenElim a ∙∙⟨ l ⟩ bs ⌜·⌝⟨ k₁ ⇒ k₂ ⟩ (ηz /⟨ l ⟩ σ ↑)) (wk-//⟨⟩-↑⋆ 0 as) ⟩ weakenElim a ∙∙⟨ l ⟩ weakenSpine (as //⟨ l ⟩ σ) ⌜·⌝⟨ k₁ ⇒ k₂ ⟩ (ηz /⟨ l ⟩ σ ↑) ≡˘⟨ cong (_⌜·⌝⟨ k₁ ⇒ k₂ ⟩ (ηz /⟨ l ⟩ σ ↑)) (∙∙⟨⟩-/Var a l (as //⟨ l ⟩ σ)) ⟩ weakenElim (a ∙∙⟨ l ⟩ (as //⟨ l ⟩ σ)) ⌜·⌝⟨ k₁ ⇒ k₂ ⟩ (ηz /⟨ l ⟩ σ ↑) ≡⟨ cong ((_⌜·⌝⟨ k₁ ⇒ k₂ ⟩ _) ∘ weakenElim) a∙as/σ≡Λj′a′ ⟩ weakenElim (Λ∙ j′ a′) ⌜·⌝⟨ k₁ ⇒ k₂ ⟩ (ηz /⟨ l ⟩ σ ↑) ≡⟨ cong (weakenElim (Λ∙ j′ a′) ⌜·⌝⟨ k₁ ⇒ k₂ ⟩_) (TK.η-exp-ne-Miss-/⟨⟩ zero zero (⌊⌋≡-weaken ⌊j₁⌋≡k₁) under) ⟩ weakenElim (Λ∙ j′ a′) ⌜·⌝⟨ k₁ ⇒ k₂ ⟩ TK.η-exp (weakenKind′ j₁ Kind/⟨ l ⟩ σ ↑) (⌊⌋≡-/⟨⟩ (⌊⌋≡-weaken ⌊j₁⌋≡k₁)) (var∙ zero) ≈⟨ Nf∈-[]-η-var [] (⌊⌋≡-/⟨⟩ (⌊⌋≡-weaken ⌊j₁⌋≡k₁)) (kds-/⟨⟩ (kds-weaken j₁-kds) σ↑∈k₁∷Γ) a′∈k₁⇒k₂ ⟩ a′ ∎) ⟩ Λ∙ j′ a′ ≡⟨ sym a∙as/σ≡Λj′a′ ⟩ a ∙∙⟨ l ⟩ (as //⟨ l ⟩ σ) ≡˘⟨ cong (_?∙∙⟨ l ⟩ (as //⟨ l ⟩ σ)) (lookup-Hit hitP) ⟩ var x ∙ as /⟨ l ⟩ σ ∎ -- Hereditary substitutions of a variable by its η-expansion vanish. -- -- NOTE. Both the statement and the proof of this lemma are -- complicated by the use of de Bruijn notation in combination -- with single-variable (hereditary) substitution. When -- formulated using the usual, human-readable variable notation, -- the lemma simply says that -- -- e [ηⱼ(x)/ʲx] = e -- -- where "e [a/ʲx]" denotes hereditary substitution of a for x in -- expression e at kind j, and "ηⱼ(x)" denotes the η-expansion of -- x at kind j. Using de Bruijn notation, this substitution only -- makes sense if there are actually _two_ copies of the variable -- x in e on the LHS (say x and x′): one to be replaced (x) and a -- second one (x′) to be η-expanded and substituted for x. To -- make the equation well-scoped, we therefore weaken e to -- introduce a new variable x′ = (suc x) just after x, which after -- substitution for x will correspond precisely to the de Bruijn -- index of x itself. The stated form of the lemma is obtained by -- letting x be the n-th variable in a context with (n + m) free -- variables, i.e. we fix x = (raise n zero) in e. -- -- Note also that the proof of this lemma is currently the only -- place in the development where the Eq? predicate from the -- FOmegaInt.Syntax.SingleVariableSubstitution module is used. -- It's probably possible to reformulate the proof without using -- this predicate, but that will likely render the proof even -- harder to follow than it already is. kds-[]-η-var : ∀ {k m n} (Γ₂ : CtxExt (suc m) n) {Γ₁ j l} (hyp : ⌊ j ⌋≡ k) → kd k ∷ Γ₁ ⊢ j kds → Γ₂ ++ kd k ∷ Γ₁ ⊢ l kds → let l′ = l Kind′/Var (V.wk V.↑) V.↑⋆ n in l′ Kind/⟨ k ⟩ sub (TK.η-exp j hyp (var∙ zero)) ↑⋆ n ≋ l kds-[]-η-var Γ₂ hyp j-kds (kds-⋯ a∈★ b∈★) = ≋-⋯ (Nf∈-[]-η-var Γ₂ hyp j-kds a∈★) (Nf∈-[]-η-var Γ₂ hyp j-kds b∈★) kds-[]-η-var Γ₂ hyp j-kds (kds-Π k-kds l-kds) = ≋-Π (kds-[]-η-var Γ₂ hyp j-kds k-kds) (kds-[]-η-var (_ ∷ Γ₂) hyp j-kds l-kds) Nf∈-[]-η-var : ∀ {k m n} (Γ₂ : CtxExt (suc m) n) {Γ₁ a j l} (hyp : ⌊ j ⌋≡ k) → kd k ∷ Γ₁ ⊢ j kds → Γ₂ ++ kd k ∷ Γ₁ ⊢Nf a ∈ l → let a′ = a Elim/Var (V.wk V.↑) V.↑⋆ n in a′ /⟨ k ⟩ sub (TK.η-exp j hyp (var∙ zero)) ↑⋆ n ≈ a Nf∈-[]-η-var Γ₂ hyp j-kds ∈-⊥-f = ≈-refl ⊥∙ Nf∈-[]-η-var Γ₂ hyp j-kds ∈-⊤-f = ≈-refl ⊤∙ Nf∈-[]-η-var Γ₂ hyp j-kds (∈-∀-f k-kds a∈★) = ≈-∀∙ (kds-[]-η-var Γ₂ hyp j-kds k-kds) (Nf∈-[]-η-var (_ ∷ Γ₂) hyp j-kds a∈★) Nf∈-[]-η-var Γ₂ hyp j-kds (∈-→-f a∈★ b∈★) = ≈-⇒∙ (Nf∈-[]-η-var Γ₂ hyp j-kds a∈★) (Nf∈-[]-η-var Γ₂ hyp j-kds b∈★) Nf∈-[]-η-var {k} {_} {n} Γ₂ hyp j-kds (∈-Π-i {l} l-kds a∈k) = let open ≡-Reasoning ρ = (V.wk V.↑) V.↑⋆ n σ = sub (TK.η-exp _ hyp (var∙ zero)) ↑⋆ n in ≈-Λ∙ (begin ⌊ l Kind′/Var ρ Kind/⟨ k ⟩ σ ⌋ ≡⟨ ⌊⌋-Kind/⟨⟩ (l Kind′/Var ρ) ⟩ ⌊ l Kind′/Var ρ ⌋ ≡⟨ ⌊⌋-Kind′/Var l ⟩ ⌊ l ⌋ ∎) (Nf∈-[]-η-var (_ ∷ Γ₂) hyp j-kds a∈k) Nf∈-[]-η-var {_} {_} {n} Γ₂ hyp j-kds (∈-ne (∈-∙ (∈-var x _) k∋as∈★)) with compare n x Nf∈-[]-η-var {k} {_} {n} Γ₂ {Γ₁} {_} {j} hyp j-kds (∈-ne (∈-∙ {as = as} (∈-var ._ Γ[x]≡kd-k′) k′∋as∈★)) | yes refl = begin lookupSV σ (x V./ (V.wk V.↑) V.↑⋆ n) ?∙∙⟨ k ⟩ (as′ //⟨ k ⟩ σ) ≡⟨ cong (λ z → lookupSV σ z ?∙∙⟨ k ⟩ (as′ //⟨ k ⟩ σ)) (lookup-raise-↑⋆ n zero refl) ⟩ lookupSV σ (raise n zero) ?∙∙⟨ k ⟩ (as′ //⟨ k ⟩ σ) ≡⟨ cong (_?∙∙⟨ k ⟩ (as′ //⟨ k ⟩ σ)) (lookup-Hit hitP) ⟩ weakenElim⋆ n ηz ∙∙⟨ k ⟩ (as′ //⟨ k ⟩ σ) ≡˘⟨ cong (_∙∙⟨ k ⟩ (as′ //⟨ k ⟩ σ)) (EL./Var-wk⋆ n) ⟩ (ηz Elim/Var V.wk⋆ n) ∙∙⟨ k ⟩ (as′ //⟨ k ⟩ σ) ≈⟨ ≈-∙∙⟨⟩ k (≈-refl _) (Sp∈-[]-η-var Γ₂ hyp j-kds k∋as∈★) ⟩ (ηz Elim/Var V.wk⋆ n) ∙∙⟨ k ⟩ as ≡⟨ cong (_∙∙⟨ k ⟩ as) (TK.η-exp-/Var hyp (var∙ zero)) ⟩ TK.η-exp (j Kind′/Var V.wk⋆ n) (⌊⌋≡-/Var hyp) (var∙ zero Elim/Var V.wk⋆ n) ∙∙⟨ k ⟩ as ≡⟨ cong (λ y → TK.η-exp (j Kind′/Var V.wk⋆ n) (⌊⌋≡-/Var hyp) (var∙ y) ∙∙⟨ k ⟩ as) (lookup-wk⋆ zero n) ⟩ TK.η-exp (j Kind′/Var V.wk⋆ n) (⌊⌋≡-/Var hyp) (var∙ x) ∙∙⟨ k ⟩ as ≈⟨ η-exp-ne-∙∙ (⌊⌋≡-/Var hyp) (subst (_ ⊢_kds) (sym (KL./Var-wk⋆ n)) (kds-weaken⋆ Γ₂ j-kds)) (∈-∙ (∈-var x Γ[x]≡kd-k) ∈-[]) k∋as∈★ ⟩ var x ∙ as ∎ where x = raise n zero Γ = Γ₂ ++ kd k ∷ Γ₁ Γ[x]≡kd-k = begin lookup Γ (raise n zero) ≡⟨ lookup-weaken⋆ n Γ₂ _ zero ⟩ weakenSAsc⋆ n (kd k) ≡⟨ weakenSAsc⋆-id n ⟩ kd k ∎ where open ≡-Reasoning ηz = TK.η-exp j hyp (var∙ zero) σ = sub ηz ↑⋆ n as′ = as //Var (V.wk V.↑) V.↑⋆ n hitP = Hit-sub-↑⋆ n k′≡k = kd-inj′ (trans (sym Γ[x]≡kd-k′) Γ[x]≡kd-k) k∋as∈★ = subst (_ ⊢_∋∙ _ ∈ _) k′≡k k′∋as∈★ open ≈-Reasoning open ExtLemmas₁ VarLemmas.lemmas₁ using (lookup-wk⋆; lookup-raise-↑⋆) module EL = TermLikeLemmas termLikeLemmasElim module KL = TermLikeLemmas termLikeLemmasKind′ Nf∈-[]-η-var {k} {_} {n} Γ₂ {_} {_} {j} hyp j-kds (∈-ne (∈-∙ {as = as} (∈-var ._ Γ[x]≡kd-k′) k′∋as∈★)) | no y refl = begin lookupSV σ (x V./ (V.wk V.↑) V.↑⋆ n) ?∙∙⟨ k ⟩ (as′ //⟨ k ⟩ σ) ≡⟨ cong (λ z → lookupSV σ z ?∙∙⟨ k ⟩ (as′ //⟨ k ⟩ σ)) eq ⟩ lookupSV σ (lift n suc x) ?∙∙⟨ k ⟩ (as′ //⟨ k ⟩ σ) ≡⟨ cong (_?∙∙⟨ k ⟩ (as′ //⟨ k ⟩ σ)) (lookup-Miss (Miss-sub-↑⋆ n x)) ⟩ var x ∙ (as′ //⟨ k ⟩ σ) ≈⟨ ≈-∙ (≈-var x) (Sp∈-[]-η-var Γ₂ hyp j-kds k′∋as∈★) ⟩ var x ∙ as ∎ where x = lift n suc y ηz = TK.η-exp j hyp (var∙ zero) σ = sub ηz ↑⋆ n as′ = as //Var (V.wk V.↑) V.↑⋆ n eq = begin x V./ (V.wk V.↑) V.↑⋆ n ≡⟨ VarLemmas.lookup-wk-↑⋆-↑⋆ 1 n x ⟩ lift n (lift 1 suc) x ≡⟨⟩ lift n (lift 1 suc) (lift n suc y) ≡⟨ sym (lift-commutes 0 n y) ⟩ lift n suc (lift n suc y) ≡⟨⟩ lift n suc x ∎ where open ≡-Reasoning open ≈-Reasoning Sp∈-[]-η-var : ∀ {k m n} (Γ₂ : CtxExt (suc m) n) {Γ₁ as j l₁ l₂} (hyp : ⌊ j ⌋≡ k) → kd k ∷ Γ₁ ⊢ j kds → Γ₂ ++ kd k ∷ Γ₁ ⊢ l₁ ∋∙ as ∈ l₂ → let as′ = as //Var (V.wk V.↑) V.↑⋆ n in as′ //⟨ k ⟩ sub (TK.η-exp j hyp (var∙ zero)) ↑⋆ n ≈Sp as Sp∈-[]-η-var Γ₂ hyp j-kds ∈-[] = ≈-[] Sp∈-[]-η-var Γ₂ hyp j-kds (∈-∷ a∈l₁ l₂∋as∈l₃) = ≈-∷ (Nf∈-[]-η-var Γ₂ hyp j-kds a∈l₁) (Sp∈-[]-η-var Γ₂ hyp j-kds l₂∋as∈l₃) -- Reducing applications cancel out η-expansion of neutrals. η-exp-ne-∙∙ : ∀ {n} {Γ : Ctx n} {a bs j k} (hyp : ⌊ j ⌋≡ k) → Γ ⊢ j kds → Γ ⊢Ne a ∈ k → Γ ⊢ k ∋∙ bs ∈ ★ → TK.η-exp j hyp a ∙∙⟨ k ⟩ bs ≈ a ∙∙ bs η-exp-ne-∙∙ is-★ j-kds a∈k ∈-[] = subst (_ ≈_) (sym (∙∙-[] _)) (≈-refl _) η-exp-ne-∙∙ {a = a} (is-⇒ {j₁} {j₂} {k₁} {k₂} ⌊j₁⌋≡k₁ ⌊j₂⌋≡k₂) (kds-Π j₁-kds j₂-kds) a∈k₁⇒k₂ (∈-∷ {b} {bs} b∈k₁ k₂∋bs∈★) = begin TK.η-exp (Π j₁ j₂) (is-⇒ ⌊j₁⌋≡k₁ ⌊j₂⌋≡k₂) a ⌜·⌝⟨ k₁ ⇒ k₂ ⟩ b ∙∙⟨ k₂ ⟩ bs ≈⟨ ≈-∙∙⟨⟩ k₂ (η-exp-ne-⌜·⌝ ⌊j₁⌋≡k₁ ⌊j₂⌋≡k₂ j₁-kds a∈k₁⇒k₂ b∈k₁) (≈Sp-refl bs) ⟩ TK.η-exp (j₂ Kind[ b ∈ k₁ ]) (⌊⌋≡-/⟨⟩ ⌊j₂⌋≡k₂) (a ⌜·⌝ b) ∙∙⟨ k₂ ⟩ bs ≈⟨ η-exp-ne-∙∙ (⌊⌋≡-/⟨⟩ ⌊j₂⌋≡k₂) j₂[b]-kds (Ne∈-Π-e a∈k₁⇒k₂ b∈k₁) k₂∋bs∈★ ⟩ (a ⌜·⌝ b) ∙∙ bs ≡⟨ ∙∙-++ a (b ∷ []) bs ⟩ a ∙∙ (b ∷ bs) ∎ where open ≈-Reasoning j₂[b]-kds = kds-/⟨⟩ (subst (λ k → kd k ∷ _ ⊢ j₂ kds) (⌊⌋≡⇒⌊⌋-≡ ⌊j₁⌋≡k₁) j₂-kds) (∈-hsub b∈k₁) η-exp-ne-⌜·⌝ : ∀ {n} {Γ : Ctx n} {a b j₁ j₂ k₁ k₂} (hyp₁ : ⌊ j₁ ⌋≡ k₁) (hyp₂ : ⌊ j₂ ⌋≡ k₂) → Γ ⊢ j₁ kds → Γ ⊢Ne a ∈ k₁ ⇒ k₂ → Γ ⊢Nf b ∈ k₁ → TK.η-exp (Π j₁ j₂) (is-⇒ hyp₁ hyp₂) a ⌜·⌝⟨ k₁ ⇒ k₂ ⟩ b ≈ TK.η-exp (j₂ Kind[ b ∈ k₁ ]) (⌊⌋≡-/⟨⟩ hyp₂) (a ⌜·⌝ b) η-exp-ne-⌜·⌝ {b = b} {j₁} {j₂} {k₁} ⌊j₁⌋≡k₁ ⌊j₂⌋≡k₂ j₁-kds (∈-∙ {x} {_} {_} {as} x∈l l∋as∈k₁⇒k₂) b∈k₁ = let ηz = TK.η-exp (weakenKind′ j₁) (⌊⌋≡-weaken ⌊j₁⌋≡k₁) (var∙ zero) in begin TK.η-exp j₂ ⌊j₂⌋≡k₂ (weakenElim (var∙ x) ∙∙ weakenSpine as ⌜·⌝ ηz) /⟨ k₁ ⟩ sub b ≡⟨ cong (λ y → TK.η-exp _ ⌊j₂⌋≡k₂ (var y ∙ weakenSpine as ⌜·⌝ ηz) /⟨ k₁ ⟩ _) (VarLemmas.lookup-wk x) ⟩ TK.η-exp j₂ ⌊j₂⌋≡k₂ (var (suc x) ∙ weakenSpine as ⌜·⌝ ηz) /⟨ k₁ ⟩ sub b ≡⟨ TK.η-exp-ne-Miss-/⟨⟩ (suc x) x ⌊j₂⌋≡k₂ over ⟩ TK.η-exp (j₂ Kind[ b ∈ k₁ ]) (⌊⌋≡-/⟨⟩ ⌊j₂⌋≡k₂) (var x ∙ ((weakenSpine as ∷ʳ ηz) //⟨ k₁ ⟩ sub b)) ≡⟨ cong (λ bs → TK.η-exp _ (⌊⌋≡-/⟨⟩ ⌊j₂⌋≡k₂) (var x ∙ bs)) (++-//⟨⟩ (weakenSpine as) _) ⟩ TK.η-exp (j₂ Kind[ b ∈ k₁ ]) (⌊⌋≡-/⟨⟩ ⌊j₂⌋≡k₂) (var x ∙ (weakenSpine as //⟨ k₁ ⟩ sub b) ⌜·⌝ (ηz /⟨ k₁ ⟩ sub b)) ≡⟨ cong (λ bs → TK.η-exp _ (⌊⌋≡-/⟨⟩ ⌊j₂⌋≡k₂) (var x ∙ bs ⌜·⌝ _)) (//Var-wk-↑⋆-hsub-vanishes 0 as) ⟩ TK.η-exp (j₂ Kind[ b ∈ k₁ ]) (⌊⌋≡-/⟨⟩ ⌊j₂⌋≡k₂) (var x ∙ as ⌜·⌝ (ηz /⟨ k₁ ⟩ sub b)) ≈⟨ ≈-η-exp′ (⌊⌋≡-/⟨⟩ ⌊j₂⌋≡k₂) (⌊⌋≡-/⟨⟩ ⌊j₂⌋≡k₂) (≈-⌜·⌝ (≈-refl (var x ∙ as)) (η-exp-var-Hit-/⟨⟩ (⌊⌋≡-weaken ⌊j₁⌋≡k₁) (Hit-sub-↑⋆ 0) (kds-weaken j₁-kds) (∈-var zero refl) (∈-hsub b∈k₁))) ⟩ TK.η-exp (j₂ Kind[ b ∈ k₁ ]) (⌊⌋≡-/⟨⟩ ⌊j₂⌋≡k₂) (var x ∙ as ⌜·⌝ (var∙ zero /⟨ k₁ ⟩ sub b)) ≡⟨⟩ TK.η-exp (j₂ Kind[ b ∈ k₁ ]) (⌊⌋≡-/⟨⟩ ⌊j₂⌋≡k₂) (var x ∙ as ⌜·⌝ b) ∎ where open ≈-Reasoning private module TK = TrackSimpleKindsKindedEtaExp -- η-expansion preserves simple kinding of neutral types. η-exp-Var∈ : ∀ {n} {Γ : Ctx n} {x k} → Γ ⊢ k kds → Γ ⊢Var x ∈ ⌊ k ⌋ → Γ ⊢Nf η-exp k (var∙ x) ∈ ⌊ k ⌋ η-exp-Var∈ k-kd x∈⌊k⌋ = TK.η-exp-Var∈ (⌊⌋-⌊⌋≡ _) k-kd x∈⌊k⌋ η-exp-Ne∈ : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢ k kds → Γ ⊢Ne a ∈ ⌊ k ⌋ → Γ ⊢Nf η-exp k a ∈ ⌊ k ⌋ η-exp-Ne∈ k-kd a∈⌊k⌋ = TK.η-exp-Ne∈ (⌊⌋-⌊⌋≡ _) k-kd a∈⌊k⌋ -- η-expansion of neutrals followed by hereditary substitution -- vanish if the substitution hits the head of the neutral. η-exp-ne-Hit-/⟨⟩ : ∀ {k m n Γ Δ} {x a as j} {σ : SVSub m n} → Hit σ x a → Γ ⊢ j kds → Γ ⊢Ne var x ∙ as ∈ ⌊ j ⌋ → Δ ⊢/⟨ k ⟩ σ ∈ Γ → η-exp j (var x ∙ as) /⟨ k ⟩ σ ≈ var x ∙ as /⟨ k ⟩ σ η-exp-ne-Hit-/⟨⟩ hitP j-kds x∙as∈k σ∈Γ = TK.η-exp-ne-Hit-/⟨⟩ (⌊⌋-⌊⌋≡ _) hitP j-kds x∙as∈k σ∈Γ η-exp-var-Hit-/⟨⟩ : ∀ {k m n Γ Δ} {x a j} {σ : SVSub m n} → Hit σ x a → Γ ⊢ j kds → Γ ⊢Var x ∈ ⌊ j ⌋ → Δ ⊢/⟨ k ⟩ σ ∈ Γ → η-exp j (var∙ x) /⟨ k ⟩ σ ≈ var∙ x /⟨ k ⟩ σ η-exp-var-Hit-/⟨⟩ hitP j-kds x∈k σ∈Γ = η-exp-ne-Hit-/⟨⟩ hitP j-kds (∈-∙ x∈k ∈-[]) σ∈Γ -- Hereditary substitutions of a variable by its η-expansion vanish. kds-[]-η-var : ∀ {m n} (Γ₂ : CtxExt (suc m) n) {Γ₁ j k} → Γ₁ ⊢ j kds → Γ₂ ++ kd ⌊ j ⌋ ∷ Γ₁ ⊢ k kds → let j′ = weakenKind′ j k′ = k Kind′/Var (VarSubst.wk VarSubst.↑) VarSubst.↑⋆ n in k′ Kind/⟨ ⌊ j′ ⌋ ⟩ sub (η-exp j′ (var∙ zero)) ↑⋆ n ≋ k kds-[]-η-var Γ₂ {Γ₁} {j} j-kds k-kds = TK.kds-[]-η-var Γ₂ (⌊⌋-⌊⌋≡ _) (kds-weaken j-kds) (subst (λ l → Γ₂ ++ kd l ∷ Γ₁ ⊢ _ kds) (sym (⌊⌋-Kind′/Var j)) k-kds) Nf∈-[]-η-var : ∀ {m n} (Γ₂ : CtxExt (suc m) n) {Γ₁ a j k} → Γ₁ ⊢ j kds → Γ₂ ++ kd ⌊ j ⌋ ∷ Γ₁ ⊢Nf a ∈ k → let j′ = weakenKind′ j a′ = a Elim/Var (VarSubst.wk VarSubst.↑) VarSubst.↑⋆ n in a′ /⟨ ⌊ j′ ⌋ ⟩ sub (η-exp j′ (var∙ zero)) ↑⋆ n ≈ a Nf∈-[]-η-var Γ₂ {Γ₁} {a} {j} j-kds a∈k = TK.Nf∈-[]-η-var Γ₂ (⌊⌋-⌊⌋≡ _) (kds-weaken j-kds) (subst (λ l → Γ₂ ++ kd l ∷ Γ₁ ⊢Nf _ ∈ _) (sym (⌊⌋-Kind′/Var j)) a∈k)
{ "alphanum_fraction": 0.4274466813, "avg_line_length": 46.8878504673, "ext": "agda", "hexsha": "9d3eb44e14c785517910fa529e051b4359252052", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-05-14T10:25:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-05-13T22:29:48.000Z", "max_forks_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Blaisorblade/f-omega-int-agda", "max_forks_repo_path": "src/FOmegaInt/Kinding/Simple/EtaExpansion.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_issues_repo_issues_event_max_datetime": "2021-05-14T08:54:39.000Z", "max_issues_repo_issues_event_min_datetime": "2021-05-14T08:09:40.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Blaisorblade/f-omega-int-agda", "max_issues_repo_path": "src/FOmegaInt/Kinding/Simple/EtaExpansion.agda", "max_line_length": 83, "max_stars_count": 12, "max_stars_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Blaisorblade/f-omega-int-agda", "max_stars_repo_path": "src/FOmegaInt/Kinding/Simple/EtaExpansion.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-27T05:53:06.000Z", "max_stars_repo_stars_event_min_datetime": "2017-06-13T16:05:35.000Z", "num_tokens": 10288, "size": 20068 }
------------------------------------------------------------------------ -- Some examples related to Nat.Wrapper, defined in Cubical Agda ------------------------------------------------------------------------ {-# OPTIONS --cubical --safe #-} open import Equality.Path as P open import Prelude hiding (zero; suc; _+_) open import Bijection equality-with-J using (_↔_) module Nat.Wrapper.Cubical -- The underlying representation of natural numbers. (Nat′ : Type) -- A bijection between this representation and the unary natural -- numbers. (Nat′↔ℕ : Nat′ ↔ ℕ) where open import Equality.Path.Univalence open import Logical-equivalence using (_⇔_) import Equivalence equality-with-J as Eq open import Erased.Cubical equality-with-paths open import Function-universe equality-with-J as F hiding (_∘_) open import H-level equality-with-J open import H-level.Closure equality-with-J open import H-level.Truncation.Propositional equality-with-paths as Trunc import Nat equality-with-J as Nat import Univalence-axiom equality-with-J as U open import Nat.Wrapper equality-with-J Nat′ Nat′↔ℕ as NW open NW.[]-cong instance-of-[]-cong-axiomatisation private variable A : Type m n : A ------------------------------------------------------------------------ -- Could Nat have been defined using the propositional truncation -- instead of Erased? -- Could Nat have been defined using ∥_∥ instead of Erased? Let us -- try. -- Given a truncated natural number we can kind of apply Nat-[_] to -- it, because Nat-[_] is a family of contractible types. (The code -- uses univalence.) Nat-[]′ : ∥ ℕ ∥ → ∃ λ (A : Type) → Contractible A Nat-[]′ = Trunc.rec (U.∃-H-level-H-level-1+ ext univ 0) (λ n → Nat-[ n ] , propositional⇒inhabited⇒contractible Nat-[]-propositional ( _↔_.from Nat′↔ℕ n , [ _↔_.right-inverse-of Nat′↔ℕ n ] )) Nat-[_]′ : ∥ ℕ ∥ → Type Nat-[ n ]′ = proj₁ (Nat-[]′ n) -- Thus we can form a variant of Nat. Nat-with-∥∥ : Type Nat-with-∥∥ = Σ ∥ ℕ ∥ Nat-[_]′ -- However, this variant is isomorphic to the unit type. Nat-with-∥∥↔⊤ : Nat-with-∥∥ ↔ ⊤ Nat-with-∥∥↔⊤ = _⇔_.to contractible⇔↔⊤ $ Σ-closure 0 (propositional⇒inhabited⇒contractible truncation-is-proposition ∣ 0 ∣) (proj₂ ∘ Nat-[]′) -- And thus it is not isomorphic to the natural numbers. ¬-Nat-with-∥∥↔ℕ : ¬ (Nat-with-∥∥ ↔ ℕ) ¬-Nat-with-∥∥↔ℕ = Nat-with-∥∥ ↔ ℕ ↝⟨ F._∘ inverse Nat-with-∥∥↔⊤ ⟩ ⊤ ↔ ℕ ↝⟨ (λ hyp → _↔_.injective (inverse hyp) refl) ⟩ 0 ≡ 1 ↝⟨ Nat.0≢+ ⟩□ ⊥ □ ------------------------------------------------------------------------ -- Addition of "wrapped" numbers is commutative and associative module _ (o : Operations) where open Operations-for-Nat o open Operations-for-Nat-correct o private -- A lemma used several times below. from[to+to]≡+ : ∀ m → _↔_.from Nat↔ℕ (_↔_.to Nat↔ℕ m Prelude.+ _↔_.to Nat↔ℕ n) ≡ m + n from[to+to]≡+ {n = n} m = _↔_.from Nat↔ℕ (_↔_.to Nat↔ℕ m Prelude.+ _↔_.to Nat↔ℕ n) ≡⟨ cong (_↔_.from Nat↔ℕ) $ sym $ to-ℕ-+ m n ⟩ _↔_.from Nat↔ℕ (_↔_.to Nat↔ℕ (m + n)) ≡⟨ _↔_.left-inverse-of Nat↔ℕ _ ⟩∎ m + n ∎ -- First two "traditional" proofs. -- Addition is commutative. +-comm-traditional : ∀ m {n} → m + n ≡ n + m +-comm-traditional m {n = n} = m + n ≡⟨ sym $ from[to+to]≡+ m ⟩ _↔_.from Nat↔ℕ (_↔_.to Nat↔ℕ m Prelude.+ _↔_.to Nat↔ℕ n) ≡⟨ cong (_↔_.from Nat↔ℕ) $ Nat.+-comm (_↔_.to Nat↔ℕ m) ⟩ _↔_.from Nat↔ℕ (_↔_.to Nat↔ℕ n Prelude.+ _↔_.to Nat↔ℕ m) ≡⟨ from[to+to]≡+ n ⟩∎ n + m ∎ -- Addition is associative. +-assoc-traditional : ∀ m {n o} → m + (n + o) ≡ (m + n) + o +-assoc-traditional m {n = n} {o = o} = m + (n + o) ≡⟨ cong (m +_) $ sym $ from[to+to]≡+ n ⟩ m + (_↔_.from Nat↔ℕ (_↔_.to Nat↔ℕ n Prelude.+ _↔_.to Nat↔ℕ o)) ≡⟨ sym $ from[to+to]≡+ m ⟩ _↔_.from Nat↔ℕ (_↔_.to Nat↔ℕ m Prelude.+ _↔_.to Nat↔ℕ (_↔_.from Nat↔ℕ (_↔_.to Nat↔ℕ n Prelude.+ _↔_.to Nat↔ℕ o))) ≡⟨ cong (λ n → _↔_.from Nat↔ℕ (_↔_.to Nat↔ℕ m Prelude.+ n)) $ _↔_.right-inverse-of Nat↔ℕ _ ⟩ _↔_.from Nat↔ℕ (_↔_.to Nat↔ℕ m Prelude.+ (_↔_.to Nat↔ℕ n Prelude.+ _↔_.to Nat↔ℕ o)) ≡⟨ cong (_↔_.from Nat↔ℕ) $ Nat.+-assoc (_↔_.to Nat↔ℕ m) ⟩ _↔_.from Nat↔ℕ ((_↔_.to Nat↔ℕ m Prelude.+ _↔_.to Nat↔ℕ n) Prelude.+ _↔_.to Nat↔ℕ o) ≡⟨ cong (λ n → _↔_.from Nat↔ℕ (n Prelude.+ _↔_.to Nat↔ℕ o)) $ sym $ _↔_.right-inverse-of Nat↔ℕ _ ⟩ _↔_.from Nat↔ℕ (_↔_.to Nat↔ℕ (_↔_.from Nat↔ℕ (_↔_.to Nat↔ℕ m Prelude.+ _↔_.to Nat↔ℕ n)) Prelude.+ _↔_.to Nat↔ℕ o) ≡⟨ from[to+to]≡+ (_↔_.from Nat↔ℕ (_↔_.to Nat↔ℕ m Prelude.+ _↔_.to Nat↔ℕ n)) ⟩ (_↔_.from Nat↔ℕ (_↔_.to Nat↔ℕ m Prelude.+ _↔_.to Nat↔ℕ n)) + o ≡⟨ cong (_+ o) $ from[to+to]≡+ {n = n} m ⟩∎ (m + n) + o ∎ -- The following proofs are instead based on a technique used by -- Vezzosi, Mörtberg and Abel in "Cubical Agda: A Dependently Typed -- Programming Language with Univalence and Higher Inductive Types". -- The type of unary natural numbers is equal to the type of wrapped -- natural numbers. ℕ≡Nat : ℕ ≡ Nat ℕ≡Nat = sym (≃⇒≡ (Eq.↔⇒≃ Nat↔ℕ)) -- Addition of unary natural numbers is, in a certain sense, equal -- to addition of wrapped natural numbers. +≡+ : P.[ (λ i → ℕ≡Nat i → ℕ≡Nat i → ℕ≡Nat i) ] Prelude._+_ ≡ _+_ +≡+ = Prelude._+_ ≡⟨ (λ i → transport (λ j → ℕ≡Nat (min i j) → ℕ≡Nat (min i j) → ℕ≡Nat (min i j)) (- i) Prelude._+_) ⟩h transport (λ i → ℕ≡Nat i → ℕ≡Nat i → ℕ≡Nat i) 0̲ Prelude._+_ ≡⟨⟩ (λ m n → _↔_.from Nat↔ℕ (_↔_.to Nat↔ℕ m Prelude.+ _↔_.to Nat↔ℕ n)) ≡⟨ (⟨ext⟩ λ m → ⟨ext⟩ λ _ → from[to+to]≡+ m) ⟩∎ _+_ ∎ -- Addition is commutative. +-comm-cubical : ∀ m {n} → m + n ≡ n + m +-comm-cubical = transport (λ i → (m {n} : ℕ≡Nat i) → +≡+ i m n ≡ +≡+ i n m) 0̲ Nat.+-comm -- Addition is associative. +-assoc-cubical : ∀ m {n o} → m + (n + o) ≡ (m + n) + o +-assoc-cubical = transport (λ i → (m {n o} : ℕ≡Nat i) → +≡+ i m (+≡+ i n o) ≡ +≡+ i (+≡+ i m n) o) 0̲ Nat.+-assoc -- This proof technique seems to scale better than the one used -- above, at least for examples of the kind used here.
{ "alphanum_fraction": 0.4810939026, "avg_line_length": 36.5663265306, "ext": "agda", "hexsha": "6b5915d943aa81d45f6ec1d979c9c4cb67d203a0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Nat/Wrapper/Cubical.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Nat/Wrapper/Cubical.agda", "max_line_length": 145, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Nat/Wrapper/Cubical.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 2568, "size": 7167 }
------------------------------------------------------------------------ -- The Agda standard library -- -- A bunch of properties about natural number operations ------------------------------------------------------------------------ module Data.Nat.Properties.Simple where open import Data.Nat as Nat open import Function open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; _≢_; refl; sym; cong; cong₂) open PropEq.≡-Reasoning open import Data.Product open import Data.Sum ------------------------------------------------------------------------ +-assoc : ∀ m n o → (m + n) + o ≡ m + (n + o) +-assoc zero _ _ = refl +-assoc (suc m) n o = cong suc $ +-assoc m n o +-right-identity : ∀ n → n + 0 ≡ n +-right-identity zero = refl +-right-identity (suc n) = cong suc $ +-right-identity n +-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 zero n = sym $ +-right-identity n +-comm (suc m) n = begin suc m + n ≡⟨ refl ⟩ suc (m + n) ≡⟨ cong suc (+-comm m n) ⟩ suc (n + m) ≡⟨ sym (+-suc n m) ⟩ n + suc m ∎ +-*-suc : ∀ m n → m * suc n ≡ m + m * n +-*-suc zero n = refl +-*-suc (suc m) n = begin suc m * suc n ≡⟨ refl ⟩ suc n + m * suc n ≡⟨ cong (λ x → suc n + x) (+-*-suc m n) ⟩ suc n + (m + m * n) ≡⟨ refl ⟩ suc (n + (m + m * n)) ≡⟨ cong suc (sym $ +-assoc n m (m * n)) ⟩ suc (n + m + m * n) ≡⟨ cong (λ x → suc (x + m * n)) (+-comm n m) ⟩ suc (m + n + m * n) ≡⟨ cong suc (+-assoc m n (m * n)) ⟩ suc (m + (n + m * n)) ≡⟨ refl ⟩ suc m + suc m * n ∎ *-right-zero : ∀ n → n * 0 ≡ 0 *-right-zero zero = refl *-right-zero (suc n) = *-right-zero n *-comm : ∀ m n → m * n ≡ n * m *-comm zero n = sym $ *-right-zero n *-comm (suc m) n = begin suc m * n ≡⟨ refl ⟩ n + m * n ≡⟨ cong (λ x → n + x) (*-comm m n) ⟩ n + n * m ≡⟨ sym (+-*-suc n m) ⟩ n * suc m ∎ distribʳ-*-+ : ∀ m n o → (n + o) * m ≡ n * m + o * m distribʳ-*-+ m zero o = refl distribʳ-*-+ m (suc n) o = begin (suc n + o) * m ≡⟨ refl ⟩ m + (n + o) * m ≡⟨ cong (_+_ m) $ distribʳ-*-+ m n o ⟩ m + (n * m + o * m) ≡⟨ sym $ +-assoc m (n * m) (o * m) ⟩ m + n * m + o * m ≡⟨ refl ⟩ suc n * m + o * m ∎ *-assoc : ∀ m n o → (m * n) * o ≡ m * (n * o) *-assoc zero n o = refl *-assoc (suc m) n o = begin (suc m * n) * o ≡⟨ refl ⟩ (n + m * n) * o ≡⟨ distribʳ-*-+ o n (m * n) ⟩ n * o + (m * n) * o ≡⟨ cong (λ x → n * o + x) $ *-assoc m n o ⟩ n * o + m * (n * o) ≡⟨ refl ⟩ suc m * (n * o) ∎
{ "alphanum_fraction": 0.4182509506, "avg_line_length": 23.6936936937, "ext": "agda", "hexsha": "6c5cb93c5abd78775059fbbb22d5917b66fe6ce7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Nat/Properties/Simple.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Nat/Properties/Simple.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Nat/Properties/Simple.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 1112, "size": 2630 }
{-# OPTIONS --safe #-} module Definition.Conversion.Lift where open import Definition.Untyped open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Weakening open import Definition.Typed.Properties open import Definition.Typed.EqRelInstance open import Definition.Conversion open import Definition.Conversion.Whnf open import Definition.Conversion.Soundness open import Definition.Conversion.Reduction open import Definition.Conversion.Weakening open import Definition.LogicalRelation open import Definition.LogicalRelation.Properties open import Definition.LogicalRelation.Fundamental.Reducibility open import Definition.Typed.Consequences.Syntactic open import Definition.Typed.Consequences.Reduction open import Definition.Typed.Consequences.Equality open import Tools.Product import Tools.PropositionalEquality as PE -- Lifting of algorithmic equality of types from WHNF to generic types. liftConv : ∀ {A B rA Γ} → Γ ⊢ A [conv↓] B ^ rA → Γ ⊢ A [conv↑] B ^ rA liftConv A<>B = let ⊢A , ⊢B = syntacticEq (soundnessConv↓ A<>B) whnfA , whnfB = whnfConv↓ A<>B in [↑] _ _ (id ⊢A) (id ⊢B) whnfA whnfB A<>B -- Lifting of algorithmic equality of terms from WHNF to generic terms. liftConvTerm : ∀ {t u A Γ l} → Γ ⊢ t [conv↓] u ∷ A ^ l → Γ ⊢ t [conv↑] u ∷ A ^ l liftConvTerm t<>u = let ⊢A , ⊢t , ⊢u = syntacticEqTerm (soundnessConv↓Term t<>u) whnfA , whnfT , whnfU = whnfConv↓Term t<>u in [↑]ₜ _ _ _ (id ⊢A) (id ⊢t) (id ⊢u) whnfA whnfT whnfU t<>u mutual -- Helper function for lifting from neutrals to generic terms in WHNF. lift~toConv↓!′ : ∀ {t u A A′ Γ l lA } → Γ ⊩⟨ l ⟩ A′ ^ [ ! , lA ] → Γ ⊢ A′ ⇒* A ^ [ ! , lA ] → Γ ⊢ t ~ u ↓! A ^ lA → Γ ⊢ t [conv↓] u ∷ A ^ lA lift~toConv↓!′ (Uᵣ′ _ l r l' l< PE.refl d) D ([~] A D₁ whnfB k~l) rewrite U≡A-whnf (trans (sym (subset* (red d))) (subset* D)) whnfB = ne ([~] A D₁ Uₙ k~l) lift~toConv↓!′ (ℕᵣ D) D₁ ([~] A D₂ whnfB k~l) rewrite PE.sym (whrDet* (red D , ℕₙ) (D₁ , whnfB)) = ℕ-ins ([~] A D₂ ℕₙ k~l) lift~toConv↓!′ (ne′ K D neK K≡K) D₁ ([~] A D₂ whnfB k~l) rewrite PE.sym (whrDet* (red D , ne neK) (D₁ , whnfB)) = let _ , ⊢t , ⊢u = syntacticEqTerm (soundness~↑! k~l) A≡K = subset* D₂ in ne-ins (conv ⊢t A≡K) (conv ⊢u A≡K) neK ([~] A D₂ (ne neK) k~l) lift~toConv↓!′ (Πᵣ′ rF lF lG l< l<' F G D ⊢F ⊢G A≡A [F] [G] G-ext) D₁ ([~] A D₂ whnfB k~l) with PE.sym (whrDet* (red D , Πₙ) (D₁ , whnfB)) lift~toConv↓!′ (Πᵣ′ ! lF lG l< l<' F G D ⊢F ⊢G A≡A [F] [G] G-ext) D₁ ([~] A D₂ whnfB k~l) | PE.refl = let ⊢ΠFG , ⊢t , ⊢u = syntacticEqTerm (soundness~↓! ([~] A D₂ Πₙ k~l)) neT , neU = ne~↑! k~l ⊢Γ = wf ⊢F var0 = neuTerm ([F] (step id) (⊢Γ ∙ ⊢F)) (var 0) (var (⊢Γ ∙ ⊢F) here) (genRefl (var (⊢Γ ∙ ⊢F) here)) 0≡0 = lift~toConv↑′ ([F] (step id) (⊢Γ ∙ ⊢F)) (var-refl′ (var (⊢Γ ∙ ⊢F) here)) k∘0≡l∘0 = lift~toConv↑′ ([G] (step id) (⊢Γ ∙ ⊢F) var0) (~↑! (app-cong (wk~↓! (step id) (⊢Γ ∙ ⊢F) ([~] A D₂ Πₙ k~l)) 0≡0)) in η-eq l< l<' ⊢F ⊢t ⊢u (ne neT) (ne neU) (PE.subst (λ x → _ ⊢ _ [conv↑] _ ∷ x ^ _) (wkSingleSubstId _) k∘0≡l∘0) lift~toConv↓!′ (Πᵣ′ % lF lG l< l<' F G D ⊢F ⊢G A≡A [F] [G] G-ext) D₁ ([~] A D₂ whnfB k~l) | PE.refl = let ⊢ΠFG , ⊢t , ⊢u = syntacticEqTerm (soundness~↓! ([~] A D₂ Πₙ k~l)) neT , neU = ne~↑! k~l ⊢Γ = wf ⊢F var0 = neuTerm ([F] (step id) (⊢Γ ∙ ⊢F)) (var 0) (var (⊢Γ ∙ ⊢F) here) (genRefl (var (⊢Γ ∙ ⊢F) here)) k∘0≡l∘0 = lift~toConv↑′ ([G] (step id) (⊢Γ ∙ ⊢F) var0) (~↑! (app-cong (wk~↓! (step id) (⊢Γ ∙ ⊢F) ([~] A D₂ Πₙ k~l)) (%~↑ (var (⊢Γ ∙ ⊢F) here) (var (⊢Γ ∙ ⊢F) here)))) in η-eq l< l<' ⊢F ⊢t ⊢u (ne neT) (ne neU) (PE.subst (λ x → _ ⊢ _ [conv↑] _ ∷ x ^ _) (wkSingleSubstId _) k∘0≡l∘0) lift~toConv↓!′ (emb emb< [A]) D t~u = lift~toConv↓!′ [A] D t~u lift~toConv↓!′ (emb ∞< [A]) D t~u = lift~toConv↓!′ [A] D t~u -- Helper function for lifting from neutrals to generic terms. lift~toConv↑!′ : ∀ {t u A Γ l lA} → Γ ⊩⟨ l ⟩ A ^ [ ! , lA ] → Γ ⊢ t ~ u ↑! A ^ lA → Γ ⊢ t [conv↑] u ∷ A ^ lA lift~toConv↑!′ [A] t~u = let B , whnfB , D = whNorm′ [A] t~u↓ = [~] _ (red D) whnfB t~u neT , neU = ne~↑! t~u _ , ⊢t , ⊢u = syntacticEqTerm (soundness~↓! t~u↓) in [↑]ₜ _ _ _ (red D) (id ⊢t) (id ⊢u) whnfB (ne neT) (ne neU) (lift~toConv↓!′ [A] (red D) t~u↓) lift~toConv↑′ : ∀ {t u A Γ l lA} → Γ ⊩⟨ l ⟩ A ^ [ ! , lA ] → Γ ⊢ t ~ u ↑ A ^ [ ! , lA ] → Γ ⊢ t [conv↑] u ∷ A ^ lA lift~toConv↑′ [A] (~↑! x) = lift~toConv↑!′ [A] x -- Lifting of algorithmic equality of terms from neutrals to generic terms in WHNF. lift~toConv↓! : ∀ {t u A Γ lA} → Γ ⊢ t ~ u ↓! A ^ lA → Γ ⊢ t [conv↓] u ∷ A ^ lA lift~toConv↓! ([~] A D whnfB k~l) = lift~toConv↓!′ (reducible (proj₁ (syntacticRed D))) D ([~] A D whnfB k~l) lift~toConv↓ : ∀ {t u A Γ lA} → Γ ⊢ t ~ u ↓! A ^ lA → Γ ⊢ t [conv↓] u ∷ A ^ lA lift~toConv↓ x = lift~toConv↓! x -- Lifting of algorithmic equality of terms from neutrals to generic terms. lift~toConv↑! : ∀ {t u A Γ lA} → Γ ⊢ t ~ u ↑! A ^ lA → Γ ⊢ t [conv↑] u ∷ A ^ lA lift~toConv↑! t~u = lift~toConv↑!′ (reducible (proj₁ (syntacticEqTerm (soundness~↑! t~u)))) t~u lift~toConv↑ : ∀ {t u A Γ lA} → Γ ⊢ t ~ u ↑ A ^ [ ! , lA ] → Γ ⊢ t [conv↑] u ∷ A ^ lA lift~toConv↑ (~↑! t~u) = lift~toConv↑! t~u
{ "alphanum_fraction": 0.5033978933, "avg_line_length": 43.2794117647, "ext": "agda", "hexsha": "bd14ccf63be06e783f93ea8607259d26f4535ef3", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/Conversion/Lift.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/Conversion/Lift.agda", "max_line_length": 143, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/Conversion/Lift.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z", "max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z", "num_tokens": 2533, "size": 5886 }
module Data.Fin.Extra where open import Data.Nat renaming (suc to S; zero to Z; _+_ to _ℕ+_; _*_ to _ℕ*_) open import Data.Fin open import Function open import Relation.Nullary.Negation open import Relation.Binary.PropositionalEquality inject-1 : ∀ {n} → (i : Fin (S n)) → toℕ i ≢ n → Fin n inject-1 {Z} zero p = contradiction refl p inject-1 {Z} (suc i) p = i inject-1 {S n} zero p = zero inject-1 {S n} (suc i) p = suc (inject-1 i (p ∘ cong S))
{ "alphanum_fraction": 0.6573275862, "avg_line_length": 29, "ext": "agda", "hexsha": "8edc61d10fc62799ffb86b6292fae10c16325484", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_path": "Data/Fin/Extra.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_path": "Data/Fin/Extra.agda", "max_line_length": 60, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_path": "Data/Fin/Extra.agda", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "num_tokens": 170, "size": 464 }
module Extensions.List where open import Prelude open import Data.List open import Data.Fin using (fromℕ≤; zero; suc) open import Data.List.All hiding (lookup; map) open import Data.Maybe hiding (All; map) open import Relation.Nullary open import Relation.Nullary.Decidable using (map′) open import Relation.Binary.Core using (REL; Reflexive; Transitive) open import Relation.Binary.List.Pointwise hiding (refl; map) data _[_]=_ {a} {A : Set a} : List A → ℕ → A → Set where here : ∀ {x xs} → (x ∷ xs) [ 0 ]= x there : ∀ {x y xs n} → xs [ n ]= x → (y ∷ xs) [ suc n ]= x []=-functional : ∀ {a} {A : Set a} → (l : List A) → (i : ℕ) → ∀ {x y : A} → l [ i ]= x → l [ i ]= y → x ≡ y []=-functional .(_ ∷ _) .0 here here = refl []=-functional .(_ ∷ _) .(suc _) (there p) (there q) = []=-functional _ _ p q []=-map : ∀ {a b}{A : Set a}{B : Set b}{l : List A}{i x}{f : A → B} → l [ i ]= x → (map f l) [ i ]= (f x) []=-map here = here []=-map (there p) = there ([]=-map p) maybe-lookup : ∀ {a}{A : Set a} → ℕ → List A → Maybe A maybe-lookup n [] = nothing maybe-lookup zero (x ∷ μ) = just x maybe-lookup (suc n) (x ∷ μ) = maybe-lookup n μ maybe-lookup-safe : ∀ {a}{A : Set a}{l : List A} {i x} → l [ i ]= x → maybe-lookup i l ≡ just x maybe-lookup-safe here = refl maybe-lookup-safe (there p) = maybe-lookup-safe p lookup : ∀ {a} {A : Set a} → (l : List A) → Fin (length l) → A lookup [] () lookup (x ∷ l) zero = x lookup (x ∷ l) (suc p) = lookup l p dec-lookup : ∀ {a} {A : Set a} → (i : ℕ) → (l : List A) → Dec (∃ λ x → l [ i ]= x) dec-lookup _ [] = no (λ{ (_ , ())}) dec-lookup zero (x ∷ l) = yes (x , here) dec-lookup (suc i) (_ ∷ l) = map′ (λ{ (x , p) → x , there p}) (λ{ (x , there p) → x , p}) (dec-lookup i l) all-lookup : ∀ {a} {A : Set a} {l : List A} {i x p P} → l [ i ]= x → All {p = p} P l → P x all-lookup here (px ∷ l) = px all-lookup (there i) (px ∷ l) = all-lookup i l infixl 10 _[_]≔_ _[_]≔_ : ∀ {a} {A : Set a} → (l : List A) → Fin (length l) → A → List A [] [ () ]≔ x (x ∷ xs) [ zero ]≔ x' = x' ∷ xs (x ∷ xs) [ suc i ]≔ y = xs [ i ]≔ y module _ where open import Data.List.Any open Membership-≡ _[_]≔'_ : ∀ {a} {A : Set a}{x} → (l : List A) → x ∈ l → A → List A [] [ () ]≔' y (x ∷ l) [ here px ]≔' y = y ∷ l (x ∷ l) [ there px ]≔' y = x ∷ (l [ px ]≔' y) ≔'-[]= : ∀ {a} {A : Set a}{x}{l : List A} (p : x ∈ l) → ∀ {y} → y ∈ (l [ p ]≔' y) ≔'-[]= (here px) = here refl ≔'-[]= (there p) = there (≔'-[]= p) -- proof matters; update a particular witness of a property _All[_]≔_ : ∀ {a p} {A : Set a} {P : A → Set p} {xs : List A} {i x} → All P xs → xs [ i ]= x → P x → All P xs [] All[ () ]≔ px (px ∷ xs) All[ here ]≔ px' = px' ∷ xs (px ∷ xs) All[ there i ]≔ px' = px ∷ (xs All[ i ]≔ px') -- prefix predicate for lists infix 4 _⊑_ data _⊑_ {a} {A : Set a} : List A → List A → Set where [] : ∀ {ys} → [] ⊑ ys _∷_ : ∀ x {xs ys} → xs ⊑ ys → x ∷ xs ⊑ x ∷ ys ⊑-refl : ∀ {a} {A : Set a} → Reflexive (_⊑_ {A = A}) ⊑-refl {x = []} = [] ⊑-refl {x = x ∷ xs} = x ∷ ⊑-refl ⊑-trans : ∀ {a} {A : Set a} → Transitive (_⊑_ {A = A}) ⊑-trans [] _ = [] ⊑-trans (x ∷ p) (.x ∷ q) = x ∷ ⊑-trans p q -- list extensions; reverse prefix relation infix 4 _⊒_ _⊒_ : ∀ {a} {A : Set a} → List A → List A → Set xs ⊒ ys = ys ⊑ xs -- appending to a list gives a list extension; -- or, appending to a list makes the original a prefix ∷ʳ-⊒ : ∀ {a} {A : Set a} (x : A) xs → xs ∷ʳ x ⊒ xs ∷ʳ-⊒ x [] = [] ∷ʳ-⊒ x (x₁ ∷ Σ₁) = x₁ ∷ (∷ʳ-⊒ x Σ₁) -- indexes into a prefix point to the same element in extensions xs⊒ys[i] : ∀ {a} {A : Set a} {xs : List A} {ys : List A} {i y} → xs [ i ]= y → (p : ys ⊒ xs) → ys [ i ]= y xs⊒ys[i] here (x ∷ q) = here xs⊒ys[i] (there p) (x ∷ q) = there (xs⊒ys[i] p q) -- prefix is preserved by map ⊑-map : ∀ {a b} {A : Set a} {B : Set b} {xs ys : List A} {f : A → B} → xs ⊑ ys → map f xs ⊑ map f ys ⊑-map [] = [] ⊑-map {f = f} (x ∷ p) = f x ∷ (⊑-map p) module Pointwise where pointwise-length : ∀ {a b ℓ A B P l m} → Rel {a} {b} {ℓ} {A} {B} P l m → length l ≡ length m pointwise-length [] = refl pointwise-length (x∼y ∷ p) = cong suc (pointwise-length p) []=-length : ∀ {a} {A : Set a} {L : List A} {i x} → L [ i ]= x → i < length L []=-length here = s≤s z≤n []=-length (there p) = s≤s ([]=-length p) ∷ʳ[length] : ∀ {a} {A : Set a} (l : List A) x → (l ∷ʳ x) [ length l ]= x ∷ʳ[length] [] y = here ∷ʳ[length] (x ∷ Σ) y = there (∷ʳ[length] Σ y) all-∷ʳ : ∀ {a p} {A : Set a} {l : List A} {x} {P : A → Set p} → All P l → P x → All P (l ∷ʳ x) all-∷ʳ [] q = q ∷ [] all-∷ʳ (px ∷ p) q = px ∷ (all-∷ʳ p q) pointwise-∷ʳ : ∀ {a b ℓ A B P l m x y} → Rel {a} {b} {ℓ} {A} {B} P l m → P x y → Rel {a} {b} {ℓ} {A} {B} P (l ∷ʳ x) (m ∷ʳ y) pointwise-∷ʳ [] q = q ∷ [] pointwise-∷ʳ (x∼y ∷ p) q = x∼y ∷ (pointwise-∷ʳ p q) pointwise-lookup : ∀ {a b ℓ A B P l m i x} → Rel {a} {b} {ℓ} {A} {B} P l m → l [ i ]= x → ∃ λ y → P x y pointwise-lookup (x∼y ∷ r) here = , x∼y pointwise-lookup (x∼y ∷ r) (there p) = pointwise-lookup r p pointwise-maybe-lookup : ∀ {a b ℓ A B P l m i x} → Rel {a} {b} {ℓ} {A} {B} P l m → l [ i ]= x → ∃ λ y → maybe-lookup i m ≡ just y × P x y pointwise-maybe-lookup [] () pointwise-maybe-lookup (x∼y ∷ r) here = , refl , x∼y pointwise-maybe-lookup (x∼y ∷ r) (there p) = pointwise-maybe-lookup r p postulate pointwise-[]≔ : ∀ {a b ℓ A B P l m i x y} → Rel {a} {b} {ℓ} {A} {B} P l m → (p : l [ i ]= x) → (q : i < length m) → P x y → Rel {a} {b} {ℓ} {A} {B} P l (m [ fromℕ≤ q ]≔ y) {-} pointwise-[]≔ [] () r pointwise-[]≔ (x∼y ∷ r) here (s≤s z≤n) z = z ∷ r pointwise-[]≔ (x∼y ∷ r) (there p) (s≤s q) z = subst (λ x → Rel _ _ x) {!!} (x∼y ∷ pointwise-[]≔ r p q z) -} open Pointwise public
{ "alphanum_fraction": 0.4815636736, "avg_line_length": 36.3850931677, "ext": "agda", "hexsha": "c5aaea1a9a142a73766ad5b5d0d72c03564f899b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Extensions/List.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Extensions/List.agda", "max_line_length": 107, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Extensions/List.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2692, "size": 5858 }
-- Andreas 2016-01-06 -- {-# OPTIONS -v error.checkclause:60 #-} data D : Set where c : D test : (x y z : D) → Set test _ c _ with D test x y z | _ = D -- Expected output: clause should be printed as is in error message, -- including underscore patterns.
{ "alphanum_fraction": 0.6436781609, "avg_line_length": 18.6428571429, "ext": "agda", "hexsha": "78ccc5e5ba0579d78ea40db40f5d8bdc91c6a3f9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Fail/PrintClauseUnderscorePattern.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "test/Fail/PrintClauseUnderscorePattern.agda", "max_line_length": 68, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Fail/PrintClauseUnderscorePattern.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 80, "size": 261 }
module n2o.Network.Socket where open import proto.IO open import proto.Base data SocketType : Set where NoSocketType : SocketType Stream : SocketType Datagram : SocketType Raw : SocketType RDM : SocketType SeqPacket : SocketType {-# COMPILE GHC SocketType = data Network.Socket.SocketType ( NoSocketType | Stream | Datagram | Raw | RDM | SeqPacket ) #-} data SockFamily : Set where AF_UNSPEC : SockFamily AF_UNIX : SockFamily AF_INET : SockFamily AF_INET6 : SockFamily AF_IMPLINK : SockFamily AF_PUP : SockFamily AF_CHAOS : SockFamily AF_NS : SockFamily AF_NBS : SockFamily AF_ECMA : SockFamily AF_DATAKIT : SockFamily AF_CCITT : SockFamily AF_SNA : SockFamily AF_DECnet : SockFamily AF_DLI : SockFamily AF_LAT : SockFamily AF_HYLINK : SockFamily AF_APPLETALK : SockFamily AF_ROUTE : SockFamily AF_NETBIOS : SockFamily AF_NIT : SockFamily AF_EIE : SockFamily AF_ISO : SockFamily AF_OSI : SockFamily AF_NETMAN : SockFamily AF_X25 : SockFamily AF_AX25 : SockFamily AF_OSINET : SockFamily AF_GOSSIP : SockFamily AF_IPX : SockFamily Pseudo_AF_XTP : SockFamily AF_CTF : SockFamily AF_WAN : SockFamily AF_SDL : SockFamily AF_NETWARE : SockFamily AF_NDD : SockFamily AF_INTF : SockFamily AF_COIP : SockFamily AF_CNT : SockFamily Pseudo_AF_RTIP : SockFamily Pseudo_AF_PIP : SockFamily AF_SIP : SockFamily AF_ISDN : SockFamily Pseudo_AF_KEY : SockFamily AF_NATM : SockFamily AF_ARP : SockFamily Pseudo_AF_HDRCMPLT : SockFamily AF_ENCAP : SockFamily AF_LINK : SockFamily AF_RAW : SockFamily AF_RIF : SockFamily AF_NETROM : SockFamily AF_BRIDGE : SockFamily AF_ATMPVC : SockFamily AF_ROSE : SockFamily AF_NETBEUI : SockFamily AF_SECURITY : SockFamily AF_PACKET : SockFamily AF_ASH : SockFamily AF_ECONET : SockFamily AF_ATMSVC : SockFamily AF_IRDA : SockFamily AF_PPPOX : SockFamily AF_WANPIPE : SockFamily AF_BLUETOOTH : SockFamily AF_CAN : SockFamily {-# COMPILE GHC SockFamily = data Network.Socket.Family ( AF_UNSPEC | AF_UNIX | AF_INET | AF_INET6 | AF_IMPLINK | AF_PUP | AF_CHAOS | AF_NS | AF_NBS | AF_ECMA | AF_DATAKIT | AF_CCITT | AF_SNA | AF_DECnet | AF_DLI | AF_LAT | AF_HYLINK | AF_APPLETALK | AF_ROUTE | AF_NETBIOS | AF_NIT | AF_802 | AF_ISO | AF_OSI | AF_NETMAN | AF_X25 | AF_AX25 | AF_OSINET | AF_GOSSIP | AF_IPX | Pseudo_AF_XTP | AF_CTF | AF_WAN | AF_SDL | AF_NETWARE | AF_NDD | AF_INTF | AF_COIP | AF_CNT | Pseudo_AF_RTIP | Pseudo_AF_PIP | AF_SIP | AF_ISDN | Pseudo_AF_KEY | AF_NATM | AF_ARP | Pseudo_AF_HDRCMPLT | AF_ENCAP | AF_LINK | AF_RAW | AF_RIF | AF_NETROM | AF_BRIDGE | AF_ATMPVC | AF_ROSE | AF_NETBEUI | AF_SECURITY | AF_PACKET | AF_ASH | AF_ECONET | AF_ATMSVC | AF_IRDA | AF_PPPOX | AF_WANPIPE | AF_BLUETOOTH | AF_CAN ) #-} data SocketOption : Set where Debug : SocketOption ReuseAddr : SocketOption Type : SocketOption SoError : SocketOption DontRoute : SocketOption Broadcast : SocketOption SendBuffer : SocketOption RecvBuffer : SocketOption KeepAlive : SocketOption OOBInline : SocketOption TimeToLive : SocketOption MaxSegment : SocketOption NoDelay : SocketOption Cork : SocketOption Linger : SocketOption ReusePort : SocketOption RecvLowWater : SocketOption SendLowWater : SocketOption RecvTimeOut : SocketOption SendTimeOut : SocketOption UseLoopBack : SocketOption UserTimeout : SocketOption IPv6Only : SocketOption CustomSockOpt : ℤ × ℤ → SocketOption {- {-# COMPILE GHC SocketOption = data Network.Socket.SocketOption ( Debug | ReuseAddr | Type | SoError | DontRoute | Broadcast | SendBuffer | RecvBuffer | KeepAlive | OOBInline | TimeToLive | MaxSegment | NoDelay | Cork | Linger | ReusePort | RecvLowWater | SendLowWater | RecvTimeOut | SendTimeOut | UseLoopBack | UserTimeout | IPv6Only | CustomSockOpt ) #-} -} postulate Family : Set Socket : Set {-# COMPILE GHC Family = type Network.Socket.Family #-} {-# COMPILE GHC Socket = type Network.Socket.Socket #-} ProtocolNumber : Set ProtocolNumber = ℤ data SocketStatus : Set where NotConnected : SocketStatus Bound : SocketStatus Listening : SocketStatus Connected : SocketStatus ConvertedToHandle : SocketStatus Closed : SocketStatus {-# COMPILE GHC SocketStatus = data Network.Socket.SocketStatus ( NotConnected | Bound | Listening | Connected | ConvertedToHandle | Closed ) #-} -- data SockAddr where -- SockAddrInet : PortNumber → HostAddress → SockAddr -- SockAddrInet6 : PortNumber → FlowInfo → HostAddress6 → ScopeID → SockAddr -- SockAddrUnix : String → SockAddr -- SockAddrCan : ℤ → SockAddr -- record Socket : Set where -- constructor MkSocket -- field -- sock : ℤ -- family : Family -- type : SocketType -- protonum : ProtocolNumber -- status : MVar SocketStatus -- open Socket -- {-# COMPILE GHC Socket = #-} {-# FOREIGN GHC import Unsafe.Coerce import Foreign.C.Types import Network.Socket coeCInt :: Integer -> Foreign.C.Types.CInt coeCInt n = Unsafe.Coerce.unsafeCoerce (n :: Integer) :: Foreign.C.Types.CInt #-} postulate socket : SockFamily → SocketType → ProtocolNumber → IO Socket -- setSocketOption : Socket → SocketOption → ℤ → IO ⊤ -- bind : Socket → SockAddr → IO ⊤ -- listen : Socket → ℤ → IO ⊤ -- accept : Socket → IO (Socket × SockAddr) {-# COMPILE GHC socket = \ f t n -> Network.Socket.socket f t (coeCInt n) #-}
{ "alphanum_fraction": 0.4164107994, "avg_line_length": 34.4708029197, "ext": "agda", "hexsha": "e714010915b160e5960bcc836c184619784d1770", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "d7903dfffcd66ae174eed9347afe008f892b2491", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "o4/n2o", "max_forks_repo_path": "n2o/Network/Socket.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d7903dfffcd66ae174eed9347afe008f892b2491", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "o4/n2o", "max_issues_repo_path": "n2o/Network/Socket.agda", "max_line_length": 80, "max_stars_count": 3, "max_stars_repo_head_hexsha": "d7903dfffcd66ae174eed9347afe008f892b2491", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "o4/n2o", "max_stars_repo_path": "n2o/Network/Socket.agda", "max_stars_repo_stars_event_max_datetime": "2019-01-02T06:37:47.000Z", "max_stars_repo_stars_event_min_datetime": "2018-11-30T11:37:10.000Z", "num_tokens": 2043, "size": 9445 }
------------------------------------------------------------------------------ -- Testing the η-expansion ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module Eta4 where infix 7 _≡_ infixl 10 _*_ postulate D : Set zero : D _≡_ : D → D → Set _+_ : D → D → D lam : (D → D) → D rec : D → D → D → D *-helper₂ : D → D → D -- We don't η-expand the definition of _*_ before the translation, -- because we cannot translate the λ-abstraction generated from -- *-helper₂ n to FOL terms. _*_ : D → D → D m * n = rec m zero (lam (*-helper₂ n)) {-# ATP definition _*_ #-} postulate foo : ∀ n → n * n ≡ n * n {-# ATP prove foo #-}
{ "alphanum_fraction": 0.4246885617, "avg_line_length": 25.2285714286, "ext": "agda", "hexsha": "5cfad90c52960ce739dfa3eb2d4f2d108a630ce5", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z", "max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/apia", "max_forks_repo_path": "test/Succeed/fol-theorems/Eta4.agda", "max_issues_count": 121, "max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/apia", "max_issues_repo_path": "test/Succeed/fol-theorems/Eta4.agda", "max_line_length": 78, "max_stars_count": 10, "max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/apia", "max_stars_repo_path": "test/Succeed/fol-theorems/Eta4.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z", "num_tokens": 234, "size": 883 }
------------------------------------------------------------------------ -- Instantiation of Contractive for streams ------------------------------------------------------------------------ -- Taken from the paper. -- The definition of Eq has been changed slightly, as compared to the -- paper. The paper uses -- Eq = λ n xs ys → take n xs ≡ take n ys. -- The reason for the change is that with the definition above -- coherence does not say anything about the first element in limU s. -- With the definition in the paper head (s 0), which is the first -- element in limU s, does not have to be related to head (s n) for -- any other n, and this makes it impossible to prove isLimitU. -- (Unless I have missed something.) module Contractive.Stream {A : Set} where open import Codata.Musical.Notation open import Codata.Musical.Stream open import Contractive open import Data.Nat open import Data.Nat.Induction open import Data.Nat.Properties import Data.Vec as Vec open Vec using (_∷_; []) open import Function open import Relation.Unary open import Relation.Binary.PropositionalEquality <′-isWellFoundedOrder : IsWellFoundedOrder _<′_ <′-isWellFoundedOrder = record { trans = λ {i} {j} {k} i+1≤j j+1≤k → ≤⇒≤′ (begin suc i ≤⟨ ≤′⇒≤ (≤′-step i+1≤j) ⟩ suc j ≤⟨ ≤′⇒≤ j+1≤k ⟩ k ∎) ; isWellFounded = <′-wellFounded } where open ≤-Reasoning ofe : OFE ofe = record { Carrier = ℕ ; Domain = Stream A ; _<_ = _<′_ ; isWellFoundedOrder = <′-isWellFoundedOrder ; Eq = λ n xs ys → take (suc n) xs ≡ take (suc n) ys ; isEquivalence = λ _ → record { refl = refl ; sym = sym ; trans = trans } } open OFE ofe private limU : (ℕ → Stream A) → Stream A limU s = head (s 0) ∷ ♯ limU (tail ∘ s ∘ suc) η : ∀ {n} {xs : Stream A} → Eq n xs (head xs ∷ ♯ tail xs) η {xs = x ∷ xs} = refl step : ∀ s → IsCoherent {U} (lift s) → IsCoherent {U} (lift (tail ∘ s ∘ suc)) step s coh {m} {n} _ _ m<n = begin take (suc m) (tail (s (suc m))) ≡⟨ lem (s (suc m)) ⟩ Vec.tail (take (2 + m) (s (1 + m))) ≡⟨ cong Vec.tail $ coh {1 + m} {1 + n} _ _ (s≤′s m<n) ⟩ Vec.tail (take (2 + m) (s (1 + n))) ≡⟨ sym $ lem (s (suc n)) ⟩ take (suc m) (tail (s (suc n))) ∎ where open ≡-Reasoning lem : ∀ {n} (xs : Stream A) → take n (tail xs) ≡ Vec.tail (take (1 + n) xs) lem (x ∷ xs) = refl isLimitU : ∀ s → IsCoherent {U} (lift s) → IsLimit {U} (lift s) (limU s) isLimitU s coh {zero} _ = begin take 1 (s 0) ≡⟨ η ⟩ head (s 0) ∷ [] ∎ where open ≡-Reasoning isLimitU s coh {suc n} _ = begin take (2 + n) (s (1 + n)) ≡⟨ η ⟩ head (s (1 + n)) ∷ take (1 + n) ((tail ∘ s ∘ suc) n) ≡⟨ cong₂ _∷_ lem₁ (isLimitU (tail ∘ s ∘ suc) (step s coh) {n} _) ⟩ head (s 0) ∷ take (1 + n) (limU (tail ∘ s ∘ suc)) ∎ where open ≡-Reasoning lem₂ : ∀ {n} (xs ys : Stream A) → Eq n xs ys → head xs ≡ head ys lem₂ (x ∷ xs) (y ∷ ys) = cong Vec.head lem₁ : head (s (1 + n)) ≡ head (s 0) lem₁ = lem₂ _ _ $ sym $ coh {0} {suc n} _ _ (s≤′s z≤′n) lim↓ : A → ∀ n → (∀ n' → n' <′ n → Stream A) → Stream A lim↓ x zero s = repeat x lim↓ x (suc n) s = s n ≤′-refl isLimit↓ : ∀ x n (s : Family (↓ n)) → IsCoherent s → IsLimit s (lim↓ x n s) isLimit↓ x zero s coh () isLimit↓ x (suc n) s coh ≤′-refl = refl isLimit↓ x (suc n) s coh (≤′-step m<n) = coh (≤′-step m<n) ≤′-refl m<n -- The paper implicitly assumes that A is non-empty. cofe : A → COFE cofe x = record { ofe = ofe ; limU = limU ; isLimitU = isLimitU _ ; lim↓ = lim↓ x ; isLimit↓ = λ n {s} → isLimit↓ x n s }
{ "alphanum_fraction": 0.4969681657, "avg_line_length": 32.1788617886, "ext": "agda", "hexsha": "0de8ee77de8da7081c6a00af08ca5dd845a79472", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/codata", "max_forks_repo_path": "Contractive/Stream.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/codata", "max_issues_repo_path": "Contractive/Stream.agda", "max_line_length": 110, "max_stars_count": 1, "max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/codata", "max_stars_repo_path": "Contractive/Stream.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z", "num_tokens": 1436, "size": 3958 }
{-# OPTIONS --cubical --no-import-sorts --allow-unsolved-metas #-} module MorePropAlgebra.Consequences where open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero) private variable ℓ ℓ' ℓ'' : Level open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Relation.Nullary.Base renaming (¬_ to ¬ᵗ_)-- ¬ᵗ_ open import Cubical.Relation.Binary.Base open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_) open import Cubical.Data.Sigma renaming (_×_ to infixr 4 _×_) open import Cubical.Data.Empty renaming (elim to ⊥-elim; ⊥ to ⊥⊥) -- `⊥` and `elim` open import Function.Base using (_∋_; _$_) open import Cubical.Foundations.Logic renaming ( inl to inlᵖ ; inr to inrᵖ ; _⇒_ to infixr 0 _⇒_ -- shifting by -6 ; _⇔_ to infixr -2 _⇔_ -- ; ∃[]-syntax to infix -4 ∃[]-syntax -- ; ∃[∶]-syntax to infix -4 ∃[∶]-syntax -- ; ∀[∶]-syntax to infix -4 ∀[∶]-syntax -- ; ∀[]-syntax to infix -4 ∀[]-syntax -- ) open import Cubical.HITs.PropositionalTruncation.Base -- ∣_∣ open import Cubical.HITs.PropositionalTruncation.Properties using (propTruncIsProp) renaming (elim to ∣∣-elim) open import Utils open import MoreLogic.Reasoning open import MoreLogic.Definitions renaming ( _ᵗ⇒_ to infixr 0 _ᵗ⇒_ ; ∀ᵖ[∶]-syntax to infix -4 ∀ᵖ[∶]-syntax ; ∀ᵖ〚∶〛-syntax to infix -4 ∀ᵖ〚∶〛-syntax ; ∀ᵖ!〚∶〛-syntax to infix -4 ∀ᵖ!〚∶〛-syntax ; ∀〚∶〛-syntax to infix -4 ∀〚∶〛-syntax ) open import MoreLogic.Properties open import MorePropAlgebra.Definitions -- NOTE: hProps need to be explicit arguments (that is not a necessity, but we need to give them completely and not just their witnesses) -- NOTE: I think one can make all `isProp` implementations `abstract` to save some compilation time -- because we have `isPropIsProp` anyways -- but for the logic part, it depends on how coslty -- ⊔-elim, ⊥-elim, ⇒∶_⇐∶_, isoToPath, hProp≡, etc. -- are and whether they could actually reduce some terms module _ {ℓ ℓ' : Level} {A : Type ℓ} (R : hPropRel A A ℓ') (let _<_ = R) (let _≤_ = R) (let _#_ = R) where -- abstract irrefl+trans⇒asym : [ isIrrefl R ] → [ isTrans R ] → [ isAsym R ] irrefl+trans⇒asym' : [ isIrrefl R ] → [ isTrans R ] → [ isAsym' R ] <-cotrans⇒≤-trans : [ isCotrans _<_ ] → [ isTrans (λ x y → ¬(y < x)) ] connex⇒refl : [ isConnex _≤_ ] → [ isRefl _≤_ ] isIrrefl⇔isIrrefl' : [ isIrrefl _<_ ⇔ isIrrefl' _<_ ] isIrrefl'⇔isIrrefl'' : (<-asym : [ isAsym _<_ ]) → [ isIrrefl' _<_ ⇔ isIrrefl'' _<_ ] isAsym⇔isAsym' : [ isAsym R ⇔ isAsym' R ] isTight⇔isTight' : [ isTight R ⇔ isTight' R ] isTight'⇔isTight'' : [ isTight' R ⇔ isTight'' R ] isTight'⇔isTight''' : [ isTight' _<_ ⇔ isTight''' (λ x y → (x < y) ⊔ (y < x)) ] isTight''⇔isTight''' : (<-asym : [ isAsym _<_ ]) → [ isTight'' _<_ ⇔ isTight''' (λ x y → [ <-asym x y ] (x < y) ⊎ᵖ (y < x)) ] isTight⇔isAntisym : [ isTight _<_ ⇔ isAntisym (λ x y → ¬ (y < x)) ] strictlinearorder⇒strictpartialorder : [ isStrictLinearOrder _<_ ⇒ isStrictPartialOrder _<_ ] linearorder⇒partialorder : [ isLinearOrder _≤_ ⇒ isPartialOrder _≤_ ] irrefl+trans⇒asym isIrrefl isTrans a b a<b b<a = isIrrefl _ (isTrans _ _ _ a<b b<a) irrefl+trans⇒asym' isIrrefl isTrans a b (a<b , b<a) = isIrrefl _ (isTrans _ _ _ a<b b<a) <-cotrans⇒≤-trans <-cotrans a b c ¬b<a ¬c<b c<a = ⊔-elim (c < b) (b < a) (λ _ → ⊥) (λ c<b → ¬c<b c<b) (λ b<a → ¬b<a b<a) (<-cotrans _ _ c<a b) connex⇒refl is-connex a = case is-connex a a as a ≤ a ⊔ a ≤ a ⇒ a ≤ a of λ{ (inl p) → p ; (inr p) → p } isIrrefl⇔isIrrefl' .fst <-irrefl a b a<b⊔b<a a≡b = substₚ (λ b → a < b ⊔ b < a ⇒ ⊥) a≡b (λ p → case p as R a a ⊔ R a a ⇒ ⊥ of λ{ (inl p) → <-irrefl _ p ; (inr p) → <-irrefl _ p }) a<b⊔b<a isIrrefl⇔isIrrefl' .snd <-irrefl' x x<x = <-irrefl' x x (inlᵖ x<x) ∣ refl ∣ isIrrefl'⇔isIrrefl'' <-asym .fst <-irrefl' a b (inl a<b) = <-irrefl' a b (inlᵖ a<b) isIrrefl'⇔isIrrefl'' <-asym .fst <-irrefl' a b (inr b<a) = <-irrefl' a b (inrᵖ b<a) isIrrefl'⇔isIrrefl'' <-asym .snd <-irrefl'' a b a<b⊎b<a = case a<b⊎b<a as a < b ⊔ b < a ⇒ ¬ a ≡ₚ b of λ { (inl a<b) → <-irrefl'' a b (inl a<b) ; (inr b<a) → <-irrefl'' a b (inr b<a) } isAsym⇔isAsym' .fst <-asym a b (a<b , b<a) = <-asym a b a<b b<a isAsym⇔isAsym' .snd <-asym a b = fst (¬-⊓-distrib (a < b) (b < a) (<-asym a b)) isTight⇔isTight' .fst <-tightᵖ a b ¬ᵗ[a<b⊔b<a] = let (¬ᵗ[a<b] , ¬ᵗ[b<a]) = deMorgan₂ (a < b) (b < a) ¬ᵗ[a<b⊔b<a] in <-tightᵖ a b ¬ᵗ[a<b] ¬ᵗ[b<a] isTight⇔isTight' .snd <-tightᵖ' a b ¬ᵗ[a<b] ¬ᵗ[b<a] = <-tightᵖ' a b (deMorgan₂-back (a < b) (b < a) (¬ᵗ[a<b] , ¬ᵗ[b<a])) isTight'⇔isTight'' .fst <-tightᵖ' a b ¬ᵗ[a<b⊎b<a] = <-tightᵖ' a b (pathTo⇒ (∥¬A∥≡¬∥A∥ _) ∣ ¬ᵗ[a<b⊎b<a] ∣) isTight'⇔isTight'' .snd <-tightᵖ'' a b ¬ᵗ[a<b⊔b<a] = <-tightᵖ'' a b (λ [a<b⊎b<a] → ¬ᵗ[a<b⊔b<a] (⊎⇒⊔ (a < b) (b < a) [a<b⊎b<a])) isTight'⇔isTight''' .fst x = x isTight'⇔isTight''' .snd x = x isTight''⇔isTight''' <-asym .fst x = x isTight''⇔isTight''' <-asym .snd x = x isTight⇔isAntisym .fst <-tight a b a≤b b≤a = <-tight a b b≤a a≤b isTight⇔isAntisym .snd ≤-antisym a b b≤a a≤b = ≤-antisym a b a≤b b≤a strictlinearorder⇒strictpartialorder is-StrictLinearOrder = isstrictpartialorder is-irrefl is-trans is-cotrans where is-irrefl = IsStrictLinearOrder.is-irrefl is-StrictLinearOrder is-trans = IsStrictLinearOrder.is-trans is-StrictLinearOrder is-tricho = IsStrictLinearOrder.is-tricho is-StrictLinearOrder is-asym = irrefl+trans⇒asym is-irrefl is-trans is-cotrans : [ isCotrans _<_ ] is-cotrans a b a<b x with is-tricho a x | is-tricho x b ... | inl (inl a<x) | q = inlᵖ a<x ... | inl (inr x<a) | inl (inl x<b) = inrᵖ x<b ... | inl (inr x<a) | inl (inr b<x) = ⊥-elim $ is-irrefl x (is-trans x b x (is-trans x a b x<a a<b) b<x) ... | inl (inr x<a) | inr x≡b = ⊥-elim $ is-asym a b a<b (substₚ (λ p → p < a) x≡b x<a) ... | inr a≡x | inl (inl x<b) = inrᵖ x<b ... | inr a≡x | inl (inr b<x) = ⊥-elim $ is-asym b x b<x (substₚ (λ p → p < b) a≡x a<b) ... | inr a≡x | inr x≡b = ⊥-elim $ is-irrefl b (substₚ (λ p → p < b) x≡b $ substₚ (λ p → p < b) a≡x a<b) linearorder⇒partialorder is-LinearOrder = let (islinearorder is-connex is-antisym is-trans) = is-LinearOrder in ispartialorder (connex⇒refl is-connex) is-antisym is-trans -- consequences on sets module _ (is-set : isSet A) where -- abstract isIrreflˢ''⇔isIrrefl'' : (is-asym : [ isAsym R ]) → [ isIrreflˢ'' R is-set ⇔ isIrrefl'' R ] isAntisymˢ⇔isAntisym : [ isAntisymˢ R is-set ⇔ isAntisym R ] isAntisymˢ'⇔isAntisym' : [ isAntisymˢ' R is-set ⇔ isAntisym' R ] isTightˢ⇔isTight : [ isTightˢ R is-set ⇔ isTight R ] isTightˢ'⇔isTight' : [ isTightˢ' R is-set ⇔ isTight' R ] isTightˢ''⇔isTight'' : [ isTightˢ'' R is-set ⇔ isTight'' R ] isTightˢ'''⇔isTight''' : [ isTightˢ''' R is-set ⇔ isTight''' R ] isTightˢ'''⇔isAntisymˢ : (is-asym : [ isAsym R ]) → [ isTightˢ''' (λ x y → [ is-asym x y ] (x < y) ⊎ᵖ (y < x)) is-set ⇔ isAntisymˢ (λ x y → ¬ (y < x) ) is-set ] isTrichotomousˢ⇔isTrichotomous : (is-irrefl : [ isIrrefl'' R ]) → (is-irreflˢ : [ isIrreflˢ'' R is-set ]) → (is-asym : [ isAsym R ]) → [ isTrichotomousˢ R is-set is-irreflˢ is-asym ⇔ isTrichotomous R is-irrefl is-asym ] -- tricho⇒cotrans : (is-irrefl : [ isIrrefl'' R ]) → (is-asym : [ isAsym R ]) -- → [ isTrichotomous _<_ is-irrefl is-asym ⇒ isCotrans _<_ ] isIrreflˢ''⇔isIrrefl'' <-asym .fst <-irreflˢ'' a b a<b a≡b = <-irreflˢ'' a b a<b (∣∣-elim (λ c → is-set a b) (λ x → x) a≡b) isIrreflˢ''⇔isIrrefl'' <-asym .snd <-irrefl'' a b a<b a≡b = <-irrefl'' a b a<b ∣ a≡b ∣ isAntisymˢ⇔isAntisym .fst ≤-antisymˢ a b a≤b b≤a = ∣ ≤-antisymˢ a b a≤b b≤a ∣ isAntisymˢ⇔isAntisym .snd ≤-antisym a b a≤b b≤a = ∣∣-elim (λ c → is-set a b) (λ x → x) (≤-antisym a b a≤b b≤a) isAntisymˢ'⇔isAntisym' .fst ≤-antisymˢ' a b a≤b ¬ᵗa≡b = ≤-antisymˢ' a b a≤b (λ z → ¬ᵗa≡b ∣ z ∣) isAntisymˢ'⇔isAntisym' .snd ≤-antisym' a b a≤b ¬ᵗa≡b = ≤-antisym' a b a≤b (λ ∣z∣ → ∣∣-elim {P = λ _ → ⊥⊥} (λ _ → isProp⊥) ¬ᵗa≡b ∣z∣) isTightˢ⇔isTight .fst <-tightˢ a b a<b b<a = ∣ <-tightˢ a b a<b b<a ∣ isTightˢ⇔isTight .snd <-tightᵖ a b a<b b<a = ∣∣-elim (λ c → is-set a b) (λ x → x) (<-tightᵖ a b a<b b<a) isTightˢ'⇔isTight' .fst <-tightˢ' a b ¬ᵗ[a<b⊔b<a] = ∣ <-tightˢ' a b ¬ᵗ[a<b⊔b<a] ∣ isTightˢ'⇔isTight' .snd <-tightᵖ' a b ¬ᵗ[a<b⊔b<a] = ∣∣-elim (λ c → is-set a b) (λ x → x) (<-tightᵖ' a b ¬ᵗ[a<b⊔b<a]) isTightˢ''⇔isTight'' .fst <-tightˢ'' a b ¬ᵗ[a<b⊎b<a] = ∣ <-tightˢ'' a b ¬ᵗ[a<b⊎b<a] ∣ isTightˢ''⇔isTight'' .snd <-tightᵖ'' a b ¬ᵗ[a<b⊎b<a] = ∣∣-elim (λ c → is-set a b) (λ x → x) (<-tightᵖ'' a b ¬ᵗ[a<b⊎b<a]) isTightˢ'''⇔isTight''' .fst #-tightˢ''' a b ¬ᵗ[a#b] = ∣ #-tightˢ''' a b ¬ᵗ[a#b] ∣ isTightˢ'''⇔isTight''' .snd #-tightᵖ''' a b ¬ᵗ[a#b] = ∣∣-elim (λ c → is-set a b) (λ x → x) (#-tightᵖ''' a b ¬ᵗ[a#b]) isTightˢ'''⇔isAntisymˢ <-asym .fst #-tight a b a≤b b≤a = #-tight a b (deMorgan₂-back' (b≤a , a≤b)) isTightˢ'''⇔isAntisymˢ <-asym .snd ≤-antisym a b ¬ᵗa#b = let (b≤a , a≤b) = deMorgan₂' ¬ᵗa#b in ≤-antisym a b a≤b b≤a isTrichotomousˢ⇔isTrichotomous <-irreflˢ <-irrefl <-asym .fst <-trichoˢ a b with <-trichoˢ a b ... | inl a<b⊎b<a = inl a<b⊎b<a ... | inr a≡b = inr ∣ a≡b ∣ isTrichotomousˢ⇔isTrichotomous <-irreflˢ <-irrefl <-asym .snd <-tricho a b with <-tricho a b ... | inl a<b⊎b<a = inl a<b⊎b<a ... | inr a≡b = inr (∣∣-elim (λ c → is-set a b) (λ x → x) a≡b) -- for these pathes, `A` and `hProp.fst` need to be in the same universe to omit ugly lifting into `ℓ-max ℓ ℓ'` -- although this would be possible to have (with lifting) module _ {ℓ : Level} {A : Type ℓ} (_≤_ : hPropRel A A ℓ) (let R = _≤_) (let _<_ = R) -- different semantics (let _≤_ = R) -- (let _#_ = R) -- where -- equivalence of "not apart" and "equal" [¬ᵗ#]⇔[≡] : hProp ℓ [¬ᵗ#]⇔[≡] = ∀[ a ] ∀[ b ] ¬ (a # b) ⇔ a ≡ₚ b [¬ᵗ#]⇔[≡]ᵗ : Type (ℓ-suc ℓ) [¬ᵗ#]⇔[≡]ᵗ = ∀ a b → (¬ᵗ [ a # b ]) ≡ (a ≡ b) -- double negation elimination over _≡_ dne-over-≡ᵗ : Type (ℓ-suc ℓ) dne-over-≡ᵗ = ∀(a b : A) → (¬ᵗ ¬ᵗ (a ≡ b)) ≡ (a ≡ b) abstract irrefl+tight⇒[¬ᵗ#]⇔[≡] : [ isIrrefl _#_ ] → [ isTight''' _#_ ] → [ [¬ᵗ#]⇔[≡] ] irrefl+tight⇒[¬ᵗ#]⇔[≡] #-irrefl #-tight a b .fst ¬ᵗ[a#b] = #-tight a b ¬ᵗ[a#b] irrefl+tight⇒[¬ᵗ#]⇔[≡] #-irrefl #-tight a b .snd a≡b a#b = #-irrefl b (substₚ (λ x → x # b) a≡b a#b) [¬ᵗ#]≡[≡]⇒dne-over-≡ : [¬ᵗ#]⇔[≡]ᵗ → dne-over-≡ᵗ [¬ᵗ#]≡[≡]⇒dne-over-≡ [¬ᵗ#]≡[≡] a b = ( ¬ᵗ ¬ᵗ ( a ≡ b ) ≡⟨ (λ i → ¬ᵗ ¬ᵗ [¬ᵗ#]≡[≡] a b (~ i)) ⟩ ¬ᵗ ¬ᵗ ¬ᵗ [ a # b ] ≡⟨ ¬¬-involutiveᵗ [ a # b ] ⟩ ¬ᵗ [ a # b ] ≡⟨ [¬ᵗ#]≡[≡] a b ⟩ a ≡ b ∎) -- consequences on sets module _ (is-set : isSet A) where -- equivalence of "not apart" and "equal" on sets [¬ᵗ#]⇔[≡ˢ] = ∀[ a ] ∀[ b ] ¬ (a # b) ⇔ [ is-set ] a ≡ˢ b -- double negation elimination over _≡_ on sets dne-over-≡ˢ = ∀[ a ] ∀[ b ] ¬ ¬ ([ is-set ] a ≡ˢ b) ⇔ [ is-set ] a ≡ˢ b irrefl+tight⇒[¬ᵗ#]⇔[≡ˢ] : [ isIrrefl _#_ ] → [ isTightˢ''' _#_ is-set ] → [ [¬ᵗ#]⇔[≡ˢ] ] [¬ᵗ#]⇔[≡ˢ]⇒dne-over-≡ˢ : [ [¬ᵗ#]⇔[≡ˢ] ] → [ dne-over-≡ˢ ] irrefl+tight⇒dne-over-≡ˢ : [ isIrrefl _#_ ] → [ isTightˢ''' _#_ is-set ] → [ dne-over-≡ˢ ] irrefl+tight⇒[¬ᵗ#]≡[≡ˢ] : [ isIrrefl _#_ ] → [ isTightˢ''' _#_ is-set ] → ∀ a b → (¬ᵗ [ a # b ]) ≡ (a ≡ b) irrefl+tight⇒dne-over-≡ˢᵗ : [ isIrrefl _#_ ] → [ isTightˢ''' _#_ is-set ] → ∀(a b : A) → (¬ᵗ ¬ᵗ (a ≡ b)) ≡ (a ≡ b) -- x ≤ y ≡ ¬(y < x) -- x <' y ≡ ¬(y ≤ x) ≡ ¬¬(x < y) -- ¬¬(x < y) ⇔ (x < y) ?? -- x ≤ y ⇔ ∀[ ε ] (y < ε) ⇒ (x < ε) -- https://en.wikipedia.org/wiki/Total_order -- We can work the other way and start by choosing < as a transitive trichotomous binary relation; then a total order ≤ can be defined in two equivalent ways: -- https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings -- IsStrictLinearOrder _<_ ⇒ IsLinearOrder _≤_ irrefl+tight⇒[¬ᵗ#]⇔[≡ˢ] #-irrefl #-tight a b .fst ¬ᵗ[a#b] = #-tight a b ¬ᵗ[a#b] irrefl+tight⇒[¬ᵗ#]⇔[≡ˢ] #-irrefl #-tight a b .snd a≡b a#b = #-irrefl b (subst (λ x → [ x # b ]) a≡b a#b) irrefl+tight⇒[¬ᵗ#]≡[≡ˢ] #-irrefl #-tight a b = isoToPath γ where γ : Iso _ _ γ .Iso.fun ¬ᵗ[a#b] = #-tight a b ¬ᵗ[a#b] γ .Iso.inv a≡b a#b = #-irrefl b (subst (λ x → [ x # b ]) a≡b a#b) γ .Iso.rightInv f = is-set a b _ f γ .Iso.leftInv g = isProp[] (¬ (a # b)) _ g [¬ᵗ#]⇔[≡ˢ]⇒dne-over-≡ˢ [¬ᵗ#]⇔[≡ˢ] a b = snd ( -- this first proof works better with `_≡⟨_⟩_` -- ( ¬ ¬ ([ is-set ] a ≡ˢ b)) ⇔⟨ (map-× (subst (λ p → fst p → snd p) (cong₂ _,_ {! ¬¬-introᵗ (a ≡ b) !} {! !})) {! !} $ swap $ [¬ᵗ#]⇔[≡ˢ] a b) ⟩ ( ¬ ¬ ([ is-set ] a ≡ˢ b)) ⇔⟨ (map-× (λ z z₁ z₂ → z₂ (λ z₃ → z₁ (λ z₄ → z z₄ z₃))) (λ z z₁ z₂ → z₂ (z (λ z₃ → z₁ (λ z₄ → z₄ z₃)))) $ swap $ [¬ᵗ#]⇔[≡ˢ] a b) ⟩ -- how did Agsy find this out?? ( ¬ ¬ ¬ (a # b)) ⇔⟨ ¬¬-involutive (a # b) ⟩ ( ¬ (a # b)) ⇔⟨ [¬ᵗ#]⇔[≡ˢ] a b ⟩ ( [ is-set ] a ≡ˢ b ) ∎ᵖ) irrefl+tight⇒dne-over-≡ˢ #-irrefl #-tight = [¬ᵗ#]⇔[≡ˢ]⇒dne-over-≡ˢ (irrefl+tight⇒[¬ᵗ#]⇔[≡ˢ] #-irrefl #-tight) irrefl+tight⇒dne-over-≡ˢᵗ #-irrefl #-tight = [¬ᵗ#]≡[≡]⇒dne-over-≡ (irrefl+tight⇒[¬ᵗ#]≡[≡ˢ] #-irrefl #-tight) module _ {ℓ : Level} {A : Type ℓ} (is-set : isSet A) where nzinvˢ''+comm⇒invnzˢ : (0f 1f : A) (_·_ : A → A → A) → ∀{ℓ'} → (_#_ : hPropRel A A ℓ') → [ isNonzeroInverseˢ'' is-set 0f 1f _·_ _#_ ⊓ isCommutativeˢ _·_ is-set ⇒ isInverseNonzeroˢ is-set 0f 1f _·_ _#_ ] nzinvˢ''+comm⇒invnzˢ 0f 1f _·_ _#_ (is-nzinv , ·-comm) x y x·y≡1 .fst = fst (is-nzinv x) ∣ y , x·y≡1 ∣ nzinvˢ''+comm⇒invnzˢ 0f 1f _·_ _#_ (is-nzinv , ·-comm) x y x·y≡1 .snd = fst (is-nzinv y) ∣ x , ·-comm y x ∙ x·y≡1 ∣ module _ {ℓ ℓ'} {X : Type ℓ} {_<_ : hPropRel X X ℓ'} (<-SPO : [ isStrictPartialOrder _<_ ]) (let _#'_ : hPropRel X X ℓ' x #' y = (x < y) ⊔ (y < x) _≤'_ : hPropRel X X ℓ' x ≤' y = ¬ (y < x) (isstrictpartialorder <-irrefl <-trans <-cotrans) = <-SPO ) where abstract -- Lemma 4.1.7. -- Given a strict partial order < on a set X: -- 1. we have an apartness relation defined by -- x # y := (x < y) ∨ (y < x), and #'-isApartnessRel : [ isApartnessRel _#'_ ] #'-isApartnessRel .IsApartnessRel.is-irrefl a a#a = case a#a as a < a ⊔ a < a ⇒ ⊥ of λ where (inl a<a) → <-irrefl _ a<a (inr a<a) → <-irrefl _ a<a #'-isApartnessRel .IsApartnessRel.is-sym a b p = pathTo⇒ (⊔-comm (a < b) (b < a)) p #'-isApartnessRel .IsApartnessRel.is-cotrans a b p = case p as a < b ⊔ b < a ⇒ ∀[ x ] (a #' x) ⊔ (x #' b) of λ where (inl a<b) x → case (<-cotrans _ _ a<b x) as a < x ⊔ x < b ⇒ (a #' x) ⊔ (x #' b) of λ where (inl a<x) → inlᵖ (inlᵖ a<x) (inr x<b) → inrᵖ (inlᵖ x<b) (inr b<a) x → case (<-cotrans _ _ b<a x) as b < x ⊔ x < a ⇒ (a #' x) ⊔ (x #' b) of λ where (inl b<x) → inrᵖ (inrᵖ b<x) (inr x<a) → inlᵖ (inrᵖ x<a) -- 2. we have a preorder defined by -- x ≤ y := ¬ᵗ(y < x). ≤'-isPreorder : [ isPreorder _≤'_ ] ≤'-isPreorder .IsPreorder.is-refl = <-irrefl ≤'-isPreorder .IsPreorder.is-trans a b c ¬ᵗb<a ¬ᵗc<b c<a = ⊔-elim (c < b) (b < a) (λ _ → ⊥) (λ c<b → ¬ᵗc<b c<b) (λ b<a → ¬ᵗb<a b<a) (<-cotrans _ _ c<a b) module _ {ℓ ℓ'} {X : Type ℓ} {_<_ : hPropRel X X ℓ'} (<-SPO : [ isStrictPartialOrder _<_ ]) (<-asym : [ isAsym _<_ ]) (let _#''_ : hPropRel X X ℓ' x #'' y = [ <-asym x y ] (x < y) ⊎ᵖ (y < x) _≤'_ : hPropRel X X ℓ' x ≤' y = ¬ (y < x) (isstrictpartialorder <-irrefl <-trans <-cotrans) = <-SPO ) where abstract #''-isApartnessRel : [ isApartnessRel _#''_ ] #''-isApartnessRel .IsApartnessRel.is-irrefl a (inl a<a) = <-irrefl _ a<a #''-isApartnessRel .IsApartnessRel.is-irrefl a (inr a<a) = <-irrefl _ a<a #''-isApartnessRel .IsApartnessRel.is-sym a b p = ⊎-swap p #''-isApartnessRel .IsApartnessRel.is-cotrans a b (inl a<b) x = case (<-cotrans _ _ a<b x) as a < x ⊔ x < b ⇒ (a #'' x) ⊔ (x #'' b) of λ where (inl a<x) → inlᵖ (inl a<x) (inr x<b) → inrᵖ (inl x<b) #''-isApartnessRel .IsApartnessRel.is-cotrans a b (inr b<a) x = case (<-cotrans _ _ b<a x) as b < x ⊔ x < a ⇒ (a #'' x) ⊔ (x #'' b) of λ where (inl b<x) → inrᵖ (inr b<x) (inr x<a) → inlᵖ (inr x<a) module _ {ℓ ℓ'} {X : Type ℓ} {_<_ : hPropRel X X ℓ'} (<-SLO : [ isStrictLinearOrder _<_ ]) (let _≤'_ : hPropRel X X ℓ' x ≤' y = ¬ (y < x) (isstrictlinearorder <-irrefl <-trans <-tricho) = <-SLO ) where private <-cotrans : [ isCotrans _<_ ] <-cotrans = IsStrictPartialOrder.is-cotrans (strictlinearorder⇒strictpartialorder _<_ <-SLO) abstract ≤'-isLinearOrder : [ isLinearOrder _≤'_ ] IsLinearOrder.is-connex ≤'-isLinearOrder a b with <-tricho a b ... | inl (inl a<b) = inlᵖ λ b<a → <-irrefl a $ <-trans a b a a<b b<a ... | inl (inr b<a) = inrᵖ λ a<b → <-irrefl a $ <-trans a b a a<b b<a ... | inr a≡b = inlᵖ λ b<a → <-irrefl b (substₚ (λ p → b < p) a≡b b<a) IsLinearOrder.is-antisym ≤'-isLinearOrder a b a≤b b≤a with <-tricho a b ... | inl (inl a<b) = ⊥-elim (b≤a a<b) ... | inl (inr b<a) = ⊥-elim (a≤b b<a) ... | inr a≡b = a≡b IsLinearOrder.is-trans ≤'-isLinearOrder a b c a≤b b≤c c<a = let γ : [ ¬ (b < a ⊔ c < b) ] γ = deMorgan₂-back (b < a) (c < b) (a≤b , b≤c) κ : [ b < a ⊔ c < b ] κ = pathTo⇐ (⊔-comm (b < a) (c < b)) $ <-cotrans c a c<a b in γ κ
{ "alphanum_fraction": 0.4985297206, "avg_line_length": 53.7966101695, "ext": "agda", "hexsha": "a443338d7720c32a9452c283931a559cbbe1f8c0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "agda/MorePropAlgebra/Consequences.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mchristianl/synthetic-reals", "max_issues_repo_path": "agda/MorePropAlgebra/Consequences.agda", "max_line_length": 223, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "agda/MorePropAlgebra/Consequences.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 9056, "size": 19044 }
{-# OPTIONS --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Properties.Reflexivity {{eqrel : EqRelSet}} where open import Definition.Untyped open import Definition.Typed open import Definition.LogicalRelation open import Tools.Product open import Tools.Empty import Tools.PropositionalEquality as PE import Data.Fin as Fin import Data.Nat as Nat -- Reflexivity of reducible types. reflEq : ∀ {l Γ A r} ([A] : Γ ⊩⟨ l ⟩ A ^ r) → Γ ⊩⟨ l ⟩ A ≡ A ^ r / [A] reflEq (Uᵣ′ _ _ _ _ l< PE.refl D) = red D reflEq (ℕᵣ D) = red D reflEq (Emptyᵣ D) = red D reflEq (ne′ K [[ ⊢A , ⊢B , D ]] neK K≡K) = ne₌ _ [[ ⊢A , ⊢B , D ]] neK K≡K reflEq (Πᵣ′ rF lF lG _ _ F G [[ ⊢A , ⊢B , D ]] ⊢F ⊢G A≡A [F] [G] G-ext) = Π₌ _ _ D A≡A (λ ρ ⊢Δ → reflEq ([F] ρ ⊢Δ)) (λ ρ ⊢Δ [a] → reflEq ([G] ρ ⊢Δ [a])) reflEq (∃ᵣ′ F G [[ ⊢A , ⊢B , D ]] ⊢F ⊢G A≡A [F] [G] G-ext) = ∃₌ _ _ D A≡A (λ ρ ⊢Δ → reflEq ([F] ρ ⊢Δ)) (λ ρ ⊢Δ [a] → reflEq ([G] ρ ⊢Δ [a])) reflEq {ι ¹} (emb X [A]) = reflEq [A] reflEq {∞} (emb X [A]) = reflEq [A] reflNatural-prop : ∀ {Γ n} → Natural-prop Γ n → [Natural]-prop Γ n n reflNatural-prop (sucᵣ (ℕₜ n d t≡t prop)) = sucᵣ (ℕₜ₌ n n d d t≡t (reflNatural-prop prop)) reflNatural-prop zeroᵣ = zeroᵣ reflNatural-prop (ne (neNfₜ neK ⊢k k≡k)) = ne (neNfₜ₌ neK neK k≡k) reflEmpty-prop : ∀ {Γ n l} → Empty-prop Γ n l → [Empty]-prop Γ n n l reflEmpty-prop (ne x) = ne x x -- Reflexivity of reducible terms. -- We proceed in a layered way because Agda does not understand our -- recursions are well founded reflEqTerm⁰ : ∀ {Γ A t r} ([A] : Γ ⊩⟨ ι ⁰ ⟩ A ^ r) → Γ ⊩⟨ ι ⁰ ⟩ t ∷ A ^ r / [A] → Γ ⊩⟨ ι ⁰ ⟩ t ≡ t ∷ A ^ r / [A] reflEqTerm⁰ (ℕᵣ D) (ℕₜ n [[ ⊢t , ⊢u , d ]] t≡t prop) = ℕₜ₌ n n [[ ⊢t , ⊢u , d ]] [[ ⊢t , ⊢u , d ]] t≡t (reflNatural-prop prop) reflEqTerm⁰ (Emptyᵣ D) (Emptyₜ (ne x)) = Emptyₜ₌ (ne x x) reflEqTerm⁰ {r = [ ! , l ]} (ne′ K D neK K≡K) (neₜ k d (neNfₜ neK₁ ⊢k k≡k)) = neₜ₌ k k d d (neNfₜ₌ neK₁ neK₁ k≡k) reflEqTerm⁰ {r = [ % , l ]} (ne′ K D neK K≡K) (neₜ d) = neₜ₌ d d reflEqTerm⁰ {r = [ ! , l ]} (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πₜ 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] → [f] ρ ⊢Δ [a] [a] (reflEqTerm⁰ ([F] ρ ⊢Δ) [a])) reflEqTerm⁰ {r = [ % , l ]} (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) X = X , X reflEqTerm⁰ (∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) X = X , X reflEqTerm¹ : ∀ {Γ A t r} ([A] : Γ ⊩⟨ ι ¹ ⟩ A ^ r) → Γ ⊩⟨ ι ¹ ⟩ t ∷ A ^ r / [A] → Γ ⊩⟨ ι ¹ ⟩ t ≡ t ∷ A ^ r / [A] reflEqTerm¹ (Uᵣ (Uᵣ r ⁰ X PE.refl D)) (Uₜ A d typeA A≡A [A]) = Uₜ₌ (Uₜ A d typeA A≡A [A]) (Uₜ A d typeA A≡A [A]) A≡A (λ [ρ] ⊢Δ → reflEq ([A] [ρ] ⊢Δ)) reflEqTerm¹ (Uᵣ (Uᵣ r ¹ () PE.refl D)) (Uₜ A d typeA A≡A [A]) reflEqTerm¹ (ℕᵣ D) (ℕₜ n [[ ⊢t , ⊢u , d ]] t≡t prop) = ℕₜ₌ n n [[ ⊢t , ⊢u , d ]] [[ ⊢t , ⊢u , d ]] t≡t (reflNatural-prop prop) reflEqTerm¹ (Emptyᵣ D) (Emptyₜ (ne x)) = Emptyₜ₌ (ne x x) reflEqTerm¹ {r = [ ! , l ]} (ne′ K D neK K≡K) (neₜ k d (neNfₜ neK₁ ⊢k k≡k)) = neₜ₌ k k d d (neNfₜ₌ neK₁ neK₁ k≡k) reflEqTerm¹ {r = [ % , l ]} (ne′ K D neK K≡K) (neₜ d) = neₜ₌ d d reflEqTerm¹ {r = [ ! , l ]} (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πₜ 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] → [f] ρ ⊢Δ [a] [a] (reflEqTerm¹ ([F] ρ ⊢Δ) [a])) reflEqTerm¹ {r = [ % , l ]} (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) X = X , X reflEqTerm¹ (∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) X = X , X reflEqTerm¹ (emb X [A]) = reflEqTerm⁰ [A] reflEqTerm∞ : ∀ {Γ A t r} ([A] : Γ ⊩⟨ ∞ ⟩ A ^ r) → Γ ⊩⟨ ∞ ⟩ t ∷ A ^ r / [A] → Γ ⊩⟨ ∞ ⟩ t ≡ t ∷ A ^ r / [A] reflEqTerm∞ (Uᵣ (Uᵣ r ⁰ X eq D)) (Uₜ A d typeA A≡A [A]) = Uₜ₌ (Uₜ A d typeA A≡A [A]) (Uₜ A d typeA A≡A [A]) A≡A (λ [ρ] ⊢Δ → reflEq ([A] [ρ] ⊢Δ)) reflEqTerm∞ (Uᵣ (Uᵣ r ¹ X eq D)) (Uₜ A d typeA A≡A [A]) = Uₜ₌ (Uₜ A d typeA A≡A [A]) (Uₜ A d typeA A≡A [A]) A≡A (λ [ρ] ⊢Δ → reflEq ([A] [ρ] ⊢Δ)) reflEqTerm∞ (ℕᵣ D) (ℕₜ n [[ ⊢t , ⊢u , d ]] t≡t prop) = ℕₜ₌ n n [[ ⊢t , ⊢u , d ]] [[ ⊢t , ⊢u , d ]] t≡t (reflNatural-prop prop) reflEqTerm∞ (Emptyᵣ D) (Emptyₜ (ne x)) = Emptyₜ₌ (ne x x) reflEqTerm∞ {r = [ ! , l ]} (ne′ K D neK K≡K) (neₜ k d (neNfₜ neK₁ ⊢k k≡k)) = neₜ₌ k k d d (neNfₜ₌ neK₁ neK₁ k≡k) reflEqTerm∞ {r = [ % , l ]} (ne′ K D neK K≡K) (neₜ d) = neₜ₌ d d reflEqTerm∞ {r = [ ! , l ]} (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πₜ 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] → [f] ρ ⊢Δ [a] [a] (reflEqTerm∞ ([F] ρ ⊢Δ) [a])) reflEqTerm∞ {r = [ % , l ]} (Πᵣ′ rF lF lG F G _ _ D ⊢F ⊢G A≡A [F] [G] G-ext) X = X , X reflEqTerm∞ (∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) X = X , X reflEqTerm∞ (emb X [A]) = reflEqTerm¹ [A] reflEqTerm : ∀ {l Γ A t r} ([A] : Γ ⊩⟨ l ⟩ A ^ r) → Γ ⊩⟨ l ⟩ t ∷ A ^ r / [A] → Γ ⊩⟨ l ⟩ t ≡ t ∷ A ^ r / [A] reflEqTerm {l = ι ⁰} [A] [t] = reflEqTerm⁰ [A] [t] reflEqTerm {l = ι ¹} [A] [t] = reflEqTerm¹ [A] [t] reflEqTerm {l = ∞} [A] [t] = reflEqTerm∞ [A] [t]
{ "alphanum_fraction": 0.4882753404, "avg_line_length": 42.304, "ext": "agda", "hexsha": "a3c08d0470b30a5fe208c9e87611c53eda0e1102", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Properties/Reflexivity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Properties/Reflexivity.agda", "max_line_length": 106, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Properties/Reflexivity.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z", "max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z", "num_tokens": 3051, "size": 5288 }
{-# OPTIONS --without-K --safe #-} module Categories.Diagram.Limit.Ran where open import Level open import Data.Product using (Σ) open import Categories.Category open import Categories.Category.Complete import Categories.Category.Construction.Cones as ConesCat open import Categories.Category.Construction.Comma open import Categories.Category.Construction.Properties.Comma open import Categories.Category.Instance.One using (One) open import Categories.Diagram.Cone using (Cone; Cone⇒) open import Categories.Diagram.Cone.Properties open import Categories.Diagram.Limit open import Categories.Diagram.Limit.Properties open import Categories.Functor open import Categories.Functor.Properties open import Categories.Functor.Construction.Constant open import Categories.Kan open import Categories.NaturalTransformation open import Categories.NaturalTransformation.Equivalence using () renaming (_≃_ to _≊_) open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism; _≃_; module ≃; _ⓘˡ_) open import Categories.Object.Terminal using (Terminal) import Categories.Morphism as Mor import Categories.Morphism.Reasoning as MR -- construct a Ran from a limit module _ {o ℓ e o′ ℓ′ e′ o″ ℓ″ e″} {C : Category o′ ℓ′ e′} {D : Category o ℓ e} {E : Category o″ ℓ″ e″} (F : Functor C D) (X : Functor C E) (Com : Complete (o′ ⊔ ℓ) (ℓ′ ⊔ e) e′ E) where private module C = Category C module D = Category D module E = Category E module F = Functor F module X = Functor X open Limit using (limit; proj; apex; module terminal) open Cone using () renaming (commute to K-commute) open ConesCat.Cone⇒ using (arr) renaming (commute to ⇒-commute) open Mor E using (_≅_) G : (d : D.Obj) → Functor (d ↙ F) E G d = X ∘F Cod {A = One} {B = C} {C = D} (const! d) F ⊤Gd : (d : D.Obj) → Limit (G d) ⊤Gd d = Com (G d) module ⊤Gd d = Limit (⊤Gd d) using (proj; limit; rep; rep-cone; apex; module terminal) f↙F : {Y Z : D.Obj} (f : Y D.⇒ Z) → Functor (Z ↙ F) (Y ↙ F) f↙F = along-natˡ′ F Gf≃ : {Y Z : D.Obj} (f : Y D.⇒ Z) → G Z ≃ G Y ∘F f↙F f Gf≃ f = record { F⇒G = record { η = λ z/F → let j = CommaObj.β z/F in X.₁ {j} C.id -- help inference a bit ; commute = λ _ → [ X ]-resp-square id-comm-sym ; sym-commute = λ _ → [ X ]-resp-square id-comm } ; F⇐G = record { η = λ _ → X.₁ C.id ; commute = λ _ → [ X ]-resp-square id-comm-sym ; sym-commute = λ _ → [ X ]-resp-square id-comm } ; iso = λ _ → record { isoˡ = [ X ]-resp-∘ C.identity² ○ X.identity ; isoʳ = [ X ]-resp-∘ C.identity² ○ X.identity } } where open MR C using (id-comm-sym; id-comm) open E.HomReasoning using (_○_) Compl : {Y Z : D.Obj} (f : Y D.⇒ Z) → Limit (G Y ∘F f↙F f) Compl {Y} f = Com (G Y ∘F f↙F f) limY⇒limZ∘ : {Y Z : D.Obj} (f : Y D.⇒ Z) → ConesCat.Cones (G Y ∘F f↙F f) [ F-map-Coneʳ (f↙F f) (limit (Com (G Y))) , limit (Compl f) ] limY⇒limZ∘ {Y} f = F⇒arr Com (f↙F f) (G Y) limZ∘≅limZ : {Y Z : D.Obj} (f : Y D.⇒ Z) → ⊤Gd.apex Z ≅ apex (Compl f) limZ∘≅limZ {Y} {Z} f = ≃⇒lim≅ (Gf≃ f) (⊤Gd Z) (Compl f) limit-is-ran : Ran F X limit-is-ran = record { R = R ; ε = ε ; δ = δ ; δ-unique = λ {M γ} δ′ eq → δ-unique {M} {γ} δ′ eq ; commutes = commutes } where open MR E open E.HomReasoning module DH = D.HomReasoning R₀ : D.Obj → E.Obj R₀ = ⊤Gd.apex R₁ : ∀ {A B} → D [ A , B ] → E [ R₀ A , R₀ B ] R₁ {A} f = _≅_.to (limZ∘≅limZ f) E.∘ arr (limY⇒limZ∘ f) ↙⇒ : {Y Z : D.Obj} (K : CommaObj {A = One} {C} {D} (const Z) F) (f : Y D.⇒ Z) → CommaObj {A = One} {C} {D} (const Y) F ↙⇒ K f = record { β = CommaObj.β K; f = D.id D.∘ CommaObj.f K D.∘ f } proj-red : {Y Z : D.Obj} (K : CommaObj (const Z) F) (f : Y D.⇒ Z) → ⊤Gd.proj Z K E.∘ R₁ f E.≈ ⊤Gd.proj Y (↙⇒ K f) proj-red {Y} {Z} K f = begin ⊤Gd.proj Z K E.∘ R₁ f ≈⟨ pullˡ (⇒-commute (≃⇒Cone⇒ (≃.sym (Gf≃ f)) (Compl f) (⊤Gd Z))) ⟩ (X.₁ C.id E.∘ proj (Compl f) K) E.∘ arr (limY⇒limZ∘ f) ≈⟨ pullʳ (⇒-commute (limY⇒limZ∘ f)) ⟩ X.₁ C.id E.∘ ⊤Gd.proj Y f/K ≈⟨ elimˡ X.identity ⟩ ⊤Gd.proj Y f/K ∎ where f/K : CommaObj {A = One} {C} {D} (const Y) F f/K = ↙⇒ K f commaF : {d : D.Obj} {c : C.Obj} (f : d D.⇒ F.₀ c) → CommaObj {A = One} {C} {D} (const d) F commaF f = record { f = f } proj≈ : {d : D.Obj} {b : C.Obj} {f g : d D.⇒ F.₀ b} → f D.≈ g → ⊤Gd.proj d (commaF f) E.≈ ⊤Gd.proj d (commaF g) proj≈ {d} {b} {f} {g} eq = begin ⊤Gd.proj d (commaF f) ≈⟨ introˡ X.identity ⟩ X.₁ C.id E.∘ ⊤Gd.proj d (commaF f) ≈⟨ K-commute (⊤Gd.limit d) C⇒ ⟩ ⊤Gd.proj d (commaF g) ∎ where C⇒ : Comma⇒ (commaF f) (commaF g) C⇒ = record { h = C.id ; commute = DH.begin F.₁ C.id D.∘ f DH.≈⟨ D.∘-resp-≈ F.identity eq ⟩ D.id D.∘ g DH.≈⟨ MR.id-comm-sym D ⟩ g D.∘ D.id DH.∎ } ConesGd : {d : D.Obj} → Functor (Comma {A = One} (const d) F) E ConesGd {d} = X ∘F Cod {A = One} {B = C} {C = D} (const d) F R-identity : {d : D.Obj} → R₁ {d} D.id E.≈ E.id R-identity {d} = G.terminal.⊤-id ConeArr where open E module G = Limit (Com (G d)) ConeArr : Cone⇒ (ConesGd {d}) G.limit G.limit ConeArr = record { arr = R₁ D.id ; commute = λ {Z} → begin G.proj Z ∘ R₁ D.id ≈⟨ proj-red Z D.id ⟩ G.proj (↙⇒ Z D.id) ≈⟨ proj≈ (D.Equiv.trans D.identityˡ D.identityʳ) ⟩ G.proj Z ∎ } R-hom : {Y Z W : D.Obj} {f : D [ Y , Z ]} {g : D [ Z , W ]} → E [ R₁ (D [ g ∘ f ]) ≈ E [ R₁ g ∘ R₁ f ] ] R-hom {Y} {Z} {W} {f} {g} = terminal.!-unique₂ (⊤Gd W) {A = cc} {f = f⇒} {g = g⇒} where module ⊤GY = Cone (⊤Gd.limit Y) module H = Functor (f↙F (g D.∘ f)) using (₀; ₁) open E cc : Cone (X ∘F Cod (const W) F) cc = record { N = ⊤GY.N; apex = record { ψ = λ K → ⊤GY.ψ (H.₀ K) ; commute = λ h → ⊤GY.commute (H.₁ h) } } f⇒ : Cone⇒ (ConesGd {W}) cc (⊤Gd.terminal.⊤ W) f⇒ = record { arr = R₁ (g D.∘ f) ; commute = λ {K} → proj-red K (g D.∘ f) } g⇒ : Cone⇒ (ConesGd {W}) cc (⊤Gd.terminal.⊤ W) g⇒ = record { arr = R₁ g ∘ R₁ f ; commute = λ {K} → begin ⊤Gd.proj W K ∘ R₁ g ∘ R₁ f ≈⟨ pullˡ (proj-red K g) ⟩ ⊤Gd.proj Z (↙⇒ K g) ∘ R₁ f ≈⟨ proj-red (↙⇒ K g) f ⟩ ⊤Gd.proj Y (↙⇒ (↙⇒ K g) f) ≈⟨ proj≈ (D.Equiv.trans D.identityˡ (MR.assoc²' D)) ⟩ ⊤Gd.proj Y (↙⇒ K (g D.∘ f)) ∎ } R-resp-≈ : {Y Z : D.Obj} {f g : D [ Y , Z ]} → D [ f ≈ g ] → E [ R₁ f ≈ R₁ g ] R-resp-≈ {Y} {Z} {f} {g} f≈g = terminal.!-unique₂ (⊤Gd Z) {A = cc} {f = fc} {g = gc} where open E module ⊤GY = Cone (⊤Gd.limit Y) module H = Functor (f↙F f) cc : Cone (X ∘F Cod (const Z) F) cc = record { apex = record { ψ = λ K → ⊤GY.ψ (H.F₀ K) ; commute = λ h → ⊤GY.commute (H.F₁ h) } } F-resp-≈-commute : ∀ {Y Z} {K : Category.Obj (Z ↙ F)} {f g : Y D.⇒ Z} → f D.≈ g → ⊤Gd.proj Z K ∘ R₁ f ≈ ⊤Gd.proj Y (↙⇒ K g) F-resp-≈-commute {Y} {Z} {K} {f} {g} eq = begin ⊤Gd.proj Z K ∘ R₁ f ≈⟨ proj-red K f ⟩ ⊤Gd.proj Y (↙⇒ K f) ≈⟨ proj≈ (D.∘-resp-≈ʳ (D.∘-resp-≈ʳ eq)) ⟩ ⊤Gd.proj Y (↙⇒ K g) ∎ fc : Cone⇒ (ConesGd {Z}) cc (⊤Gd.terminal.⊤ Z) fc = record { arr = R₁ f ; commute = λ {X} → F-resp-≈-commute {Y} {Z} {X} {f} {f} D.Equiv.refl } gc : Cone⇒ (ConesGd {Z}) cc (⊤Gd.terminal.⊤ Z) gc = record { arr = R₁ g ; commute = λ {X} → F-resp-≈-commute {Y} {Z} {X} {g} {f} (D.Equiv.sym f≈g) } R : Functor D E R = record { F₀ = R₀ ; F₁ = R₁ ; identity = λ {d} → R-identity {d} ; homomorphism = λ {A B C} {f g} → R-hom {A} {B} {C} {f} {g} ; F-resp-≈ = λ {A B} {f g} → R-resp-≈ {A} {B} {f} {g} } ,Fc : (c : C.Obj) → CommaObj {A = One} {B = C} {C = D} (const (F.₀ c)) F ,Fc c = record { β = c ; f = D.id } ε : NaturalTransformation (R ∘F F) X ε = ntHelper record { η = λ c → ⊤Gd.proj (F.F₀ c) record { f = D.id } ; commute = λ {Y Z} f → begin ⊤Gd.proj (F.F₀ Z) _ ∘ Functor.F₁ (R ∘F F) f ≈⟨ proj-red _ (F.F₁ f) ⟩ ⊤Gd.proj (F.F₀ Y) _ ≈˘⟨ K-commute {C = E} (⊤Gd.limit (F.F₀ Y)) record { h = f ; commute = D.Equiv.sym (D.Equiv.trans (D.∘-resp-≈ˡ D.identityˡ) (D.∘-resp-≈ˡ D.identityˡ)) } ⟩ X.F₁ f ∘ ⊤Gd.proj (F.F₀ Y) _ ∎ } where open E {- ε : NaturalTransformation (R ∘F F) X ε = ntHelper record { η = λ c → ⊤Gd.proj (F.₀ c) (,Fc c) ; commute = λ {Y Z} f → let module G = Limit (Com (G (F.₀ Y))) in begin ⊤Gd.proj (F.₀ Z) (,Fc Z) E.∘ Functor.F₁ (R ∘F F) f ≈⟨ proj-red (,Fc Z) (F.₁ f) ⟩ G.proj (↙⇒ (,Fc Z) (F.₁ f)) ≈˘⟨ K-commute {C = E} {J = Comma (const (F.₀ Y)) F} {F = ConesGd {F.₀ Y}} G.limit (,⇒ f) ⟩ X.₁ f E.∘ G.proj (,Fc Y) ∎ } where ,⇒ : {Y Z : C.Obj} (f : Y C.⇒ Z) → Comma⇒ (,Fc Y) (↙⇒ (,Fc Z) (F.₁ f)) ,⇒ f = record { g = _ ; h = f ; commute = DH.begin F.₁ f D.∘ D.id DH.≈˘⟨ D.identityˡ DH.⟩∘⟨refl ⟩ ((D.id D.∘ F.₁ f) D.∘ D.id) DH.≈˘⟨ D.identityˡ DH.⟩∘⟨refl ⟩ (D.id D.∘ D.id D.∘ F.₁ f) D.∘ D.id DH.∎ } -} δ-Cone : ∀ d (M : Functor D E) → NaturalTransformation (M ∘F F) X → Cone (G d) δ-Cone d M γ = record { apex = record { ψ = λ K → γ.η (β K) E.∘ M.₁ (f K) ; commute = λ {Y Z} g → begin X.₁ (h g) E.∘ γ.η (β Y) E.∘ M.₁ (f Y) ≈˘⟨ pushˡ (γ.commute (h g)) ⟩ (γ.η (β Z) E.∘ M.₁ (F.₁ (h g))) E.∘ M.₁ (f Y) ≈⟨ pullʳ ([ M ]-resp-∘ (D.Equiv.trans (commute g) D.identityʳ)) ⟩ γ.η (β Z) E.∘ M.₁ (f Z) ∎ } } where module M = Functor M module γ = NaturalTransformation γ open CommaObj open Comma⇒ δ : (M : Functor D E) → NaturalTransformation (M ∘F F) X → NaturalTransformation M R δ M γ = record { η = λ d → ⊤Gd.rep d (δ-Cone d M γ) ; commute = λ {Y Z} f → terminal.!-unique₂ (⊤Gd Z) {cc f} {q⇒ f} {w⇒ f} ; sym-commute = λ {Y Z} f → terminal.!-unique₂ (⊤Gd Z) {cc f} {w⇒ f} {q⇒ f} } where module M = Functor M module γ = NaturalTransformation γ module δ-Cone d = Cone (δ-Cone d M γ) open CommaObj cc : {Y Z : D.Obj} → Y D.⇒ Z → Cone (X ∘F Cod (const Z) F) cc {_} {Z} f = record { apex = record { ψ = λ W → δ-Cone.ψ Z W E.∘ M.F₁ f ; commute = λ g → pullˡ (δ-Cone.commute Z g) } } q⇒ : {Y Z : D.Obj} → (f : Y D.⇒ Z) → Cone⇒ (ConesGd {Z}) (cc f) (⊤Gd.terminal.⊤ Z) q⇒ {Y} {Z} f = record { arr = ⊤Gd.rep Z (δ-Cone Z M γ) E.∘ M.F₁ f ; commute = pullˡ (⇒-commute (⊤Gd.rep-cone Z (δ-Cone Z M γ))) } w⇒ : {Y Z : D.Obj} → (g : Y D.⇒ Z) → Cone⇒ (ConesGd {Z}) (cc g) (⊤Gd.terminal.⊤ Z) w⇒ {Y} {Z} g = record { arr = R₁ g E.∘ ⊤Gd.rep Y (δ-Cone Y M γ) ; commute = λ {W} → begin ⊤Gd.proj Z W E.∘ R₁ g E.∘ ⊤Gd.rep Y (δ-Cone Y M γ) ≈⟨ pullˡ (proj-red W g) ⟩ ⊤Gd.proj Y (↙⇒ W g) E.∘ ⊤Gd.rep Y (δ-Cone Y M γ) ≈⟨ ⇒-commute (⊤Gd.rep-cone Y (δ-Cone Y M γ)) ⟩ γ.η (β W) E.∘ M.F₁ (D.id D.∘ f W D.∘ g) ≈˘⟨ refl⟩∘⟨ [ M ]-resp-∘ ( D.Equiv.sym D.identityˡ ) ⟩ γ.η (β W) E.∘ M.F₁ (f W) E.∘ M.F₁ g ≈⟨ E.sym-assoc ⟩ (γ.η (β W) E.∘ M.F₁ (f W)) E.∘ M.F₁ g ∎ } δ-unique : ∀ {M : Functor D E} {γ : NaturalTransformation (M ∘F F) X} (δ′ : NaturalTransformation M R) → γ ≊ ε ∘ᵥ δ′ ∘ʳ F → δ′ ≊ δ M γ δ-unique {M} {γ} δ′ eq {d} = ⟺ (⊤Gd.terminal.!-unique d C⇒) where module M = Functor M using (₁) module γ = NaturalTransformation γ using (η) module δ = NaturalTransformation δ′ using (η; commute) open CommaObj C⇒ : Cone⇒ (X ∘F Cod (const d) F) (δ-Cone d M γ) (terminal.⊤ (⊤Gd d)) C⇒ = record { arr = δ.η d ; commute = λ {W} → begin ⊤Gd.proj d W E.∘ δ.η d ≈˘⟨ proj≈ (D.Equiv.trans D.identityˡ D.identityˡ) ⟩∘⟨refl ⟩ ⊤Gd.proj d (↙⇒ (commaF D.id) (f W)) E.∘ δ.η d ≈˘⟨ pullˡ (proj-red (commaF D.id) (f W)) ⟩ ⊤Gd.proj (F.₀ (β W)) (commaF D.id) E.∘ R₁ (f W) E.∘ δ.η d ≈˘⟨ pullʳ (δ.commute (f W)) ⟩ (⊤Gd.proj (F.₀ (β W)) (commaF D.id) E.∘ δ.η (F.₀ (β W))) E.∘ M.₁ (f W) ≈˘⟨ eq ⟩∘⟨refl ⟩ γ.η (β W) E.∘ M.₁ (f W) ∎ } commutes : (M : Functor D E) (γ : NaturalTransformation (M ∘F F) X) → γ ≊ ε ∘ᵥ δ M γ ∘ʳ F commutes M γ {c} = begin η γ c ≈˘⟨ elimʳ M.identity ⟩ η γ c E.∘ M.₁ D.id ≈˘⟨ ⇒-commute (⊤Gd.rep-cone (F.₀ c) (δ-Cone (F.₀ c) M γ)) {,Fc c} ⟩ η (ε ∘ᵥ δ M γ ∘ʳ F) c ∎ where open NaturalTransformation module M = Functor M using (₁; identity)
{ "alphanum_fraction": 0.4503566334, "avg_line_length": 43.2716049383, "ext": "agda", "hexsha": "799c7a758bc8f841891ca6ee3e74fe022880cf29", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Diagram/Limit/Ran.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Diagram/Limit/Ran.agda", "max_line_length": 205, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Diagram/Limit/Ran.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 5993, "size": 14020 }
------------------------------------------------------------------------------ -- Test case due to Agda new unifier ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module Agda.NewUnifier where infixl 7 _·_ infixr 5 _∷_ infix 4 _≡_ -- The universe of discourse/universal domain. postulate D : Set -- The identity type on the universe of discourse. data _≡_ (x : D) : D → Set where refl : x ≡ x postulate _·_ : D → D → D -- FOTC application. -- List constants. postulate [] cons head tail null : D -- FOTC partial lists. -- Definitions abstract _∷_ : D → D → D x ∷ xs = cons · x · xs -- The FOTC lists type (inductive predicate for total lists). data List : D → Set where lnil : List [] lcons : ∀ x {xs} → List xs → List (x ∷ xs) {-# ATP axioms lnil lcons #-} postulate _++_ : D → D → D ++-[] : ∀ ys → [] ++ ys ≡ ys ++-∷ : ∀ x xs ys → (x ∷ xs) ++ ys ≡ x ∷ (xs ++ ys) {-# ATP axioms ++-[] ++-∷ #-} ++-List : ∀ {xs ys} → List xs → List ys → List (xs ++ ys) ++-List {ys = ys} lnil Lys = prf where postulate prf : List ([] ++ ys) {-# ATP prove prf #-} ++-List {ys = ys} (lcons x {xs} Lxs) Lys = prf (++-List Lxs Lys) where postulate prf : List (xs ++ ys) → List ((x ∷ xs) ++ ys) {-# ATP prove prf #-}
{ "alphanum_fraction": 0.4792092706, "avg_line_length": 27.1666666667, "ext": "agda", "hexsha": "ce67277a14f6189d02d7df46c774090c3935f2d9", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z", "max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/apia", "max_forks_repo_path": "test/Succeed/fol-theorems/Agda/NewUnifier.agda", "max_issues_count": 121, "max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/apia", "max_issues_repo_path": "test/Succeed/fol-theorems/Agda/NewUnifier.agda", "max_line_length": 78, "max_stars_count": 10, "max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/apia", "max_stars_repo_path": "test/Succeed/fol-theorems/Agda/NewUnifier.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z", "num_tokens": 455, "size": 1467 }
{-# OPTIONS --without-K --safe #-} module Categories.Monad.Relative where open import Level open import Categories.Category using (Category) open import Categories.Functor using (Functor; Endofunctor; _∘F_) renaming (id to idF) import Categories.Morphism.Reasoning as MR open import Categories.NaturalTransformation renaming (id to idN) open import Categories.NaturalTransformation.NaturalIsomorphism hiding (_≃_) open import Categories.NaturalTransformation.Equivalence open NaturalIsomorphism private variable o ℓ e o′ ℓ′ e′ : Level C : Category o ℓ e D : Category o′ ℓ′ e′ record Monad {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (J : Functor C D) : Set (o ⊔ o′ ⊔ ℓ′ ⊔ e′) where private module C = Category C module D = Category D module J = Functor J open D using (_⇒_; _∘_; _≈_) field F₀ : C.Obj → D.Obj unit : {c : C.Obj} → J.₀ c ⇒ F₀ c extend : {x y : C.Obj} → (J.₀ x ⇒ F₀ y) → F₀ x ⇒ F₀ y identityʳ : {x y : C.Obj} { k : J.₀ x ⇒ F₀ y} → extend k ∘ unit ≈ k identityˡ : {x : C.Obj} → extend {x} unit ≈ D.id assoc : {x y z : C.Obj} {k : J.₀ x ⇒ F₀ y} {l : J.₀ y ⇒ F₀ z} → extend (extend l ∘ k) ≈ extend l ∘ extend k extend-≈ : {x y : C.Obj} {k h : J.₀ x ⇒ F₀ y} → k ≈ h → extend k ≈ extend h -- From a Relative Monad, we can extract a functor RMonad⇒Functor : {J : Functor C D} → Monad J → Functor C D RMonad⇒Functor {C = C} {D = D} {J = J} r = record { F₀ = F₀ ; F₁ = λ f → extend (unit ∘ J.₁ f) ; identity = identity′ ; homomorphism = hom′ ; F-resp-≈ = λ f≈g → extend-≈ (∘-resp-≈ʳ (J.F-resp-≈ f≈g)) } where open Monad r module C = Category C module D = Category D module J = Functor J open Category D hiding (identityˡ; identityʳ; assoc) open HomReasoning open MR D identity′ : {c : C.Obj} → extend {c} (unit ∘ J.₁ C.id) ≈ id identity′ = begin extend (unit ∘ J.₁ C.id) ≈⟨ extend-≈ (elimʳ J.identity) ⟩ extend unit ≈⟨ identityˡ ⟩ id ∎ hom′ : {X Y Z : C.Obj} {f : X C.⇒ Y} {g : Y C.⇒ Z} → extend (unit ∘ J.₁ (g C.∘ f)) ≈ extend (unit ∘ J.₁ g) ∘ extend (unit ∘ J.F₁ f) hom′ {f = f} {g} = begin extend (unit ∘ J.₁ (g C.∘ f)) ≈⟨ extend-≈ (pushʳ J.homomorphism) ⟩ extend ((unit ∘ J.₁ g) ∘ J.₁ f) ≈⟨ extend-≈ (pushˡ (⟺ identityʳ)) ⟩ extend (extend (unit ∘ J.₁ g) ∘ (unit ∘ J.F₁ f)) ≈⟨ assoc ⟩ extend (unit ∘ J.₁ g) ∘ extend (unit ∘ J.F₁ f) ∎
{ "alphanum_fraction": 0.5717188135, "avg_line_length": 38.453125, "ext": "agda", "hexsha": "e795584112881390fced385e81f869aea2f6e08f", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Monad/Relative.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Monad/Relative.agda", "max_line_length": 111, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Monad/Relative.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 969, "size": 2461 }
{-# OPTIONS --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Substitution.Introductions.Sigma {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped as U hiding (wk) open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Weakening using (_∷_⊆_ ; _•ₜ_) open import Definition.Typed.Properties open import Definition.LogicalRelation open import Definition.LogicalRelation.ShapeView open import Definition.LogicalRelation.Weakening open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.Properties open import Definition.LogicalRelation.Substitution open import Definition.LogicalRelation.Substitution.Weakening open import Definition.LogicalRelation.Substitution.Properties open import Definition.LogicalRelation.Substitution.MaybeEmbed import Definition.LogicalRelation.Substitution.Irrelevance as S open import Definition.LogicalRelation.Substitution.Introductions.Universe open import Definition.LogicalRelation.Substitution.Introductions.Pi open import Tools.Nat open import Tools.Product import Tools.PropositionalEquality as PE open import Tools.Empty using (⊥; ⊥-elim) -- Validity of ∃. ∃ᵛ : ∀ {F G Γ l∃ l} ([Γ] : ⊩ᵛ Γ) ([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ % , ι l∃ ] / [Γ]) → Γ ∙ F ^ [ % , ι l∃ ] ⊩ᵛ⟨ l ⟩ G ^ [ % , ι l∃ ] / [Γ] ∙ [F] → Γ ⊩ᵛ⟨ l ⟩ ∃ F ▹ G ^ [ % , ι l∃ ] / [Γ] ∃ᵛ {F} {G} {Γ} {l∃} {l} [Γ] [F] [G] {Δ = Δ} {σ = σ} ⊢Δ [σ] = let [F]σ {σ′} [σ′] = [F] {σ = σ′} ⊢Δ [σ′] [σF] = proj₁ ([F]σ [σ]) ⊢F {σ′} [σ′] = escape (proj₁ ([F]σ {σ′} [σ′])) ⊢F≡F = escapeEq [σF] (reflEq [σF]) [G]σ {σ′} [σ′] = [G] {σ = liftSubst σ′} (⊢Δ ∙ ⊢F [σ′]) (liftSubstS {F = F} [Γ] ⊢Δ [F] [σ′]) ⊢G {σ′} [σ′] = escape (proj₁ ([G]σ {σ′} [σ′])) ⊢G≡G = escapeEq (proj₁ ([G]σ [σ])) (reflEq (proj₁ ([G]σ [σ]))) ⊢∃F▹G = ∃ⱼ un-univ (⊢F [σ]) ▹ un-univ (⊢G [σ]) in ∃ᵣ′ (subst σ F) (subst (liftSubst σ) G) (idRed:*: (univ ⊢∃F▹G)) (⊢F [σ]) (⊢G [σ]) (≅-univ (≅ₜ-∃-cong (⊢F [σ]) (≅-un-univ ⊢F≡F) (≅-un-univ ⊢G≡G))) (λ ρ ⊢Δ₁ → wk ρ ⊢Δ₁ [σF]) (λ {ρ} {Δ₁} {a} [ρ] ⊢Δ₁ [a] → let [a]′ = irrelevanceTerm′ (wk-subst F) PE.refl PE.refl (wk [ρ] ⊢Δ₁ [σF]) (proj₁ ([F] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ]))) [a] in Gapp {F = F} {G = G} {σ = σ} [Γ] [F] [G] ⊢Δ [σ] a [ρ] ⊢Δ₁ [a]′) (λ {ρ} {Δ₁} {a} {b} [ρ] ⊢Δ₁ [a] [b] [a≡b] → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] [a]′ = irrelevanceTerm′ (wk-subst F) PE.refl PE.refl (wk [ρ] ⊢Δ₁ [σF]) (proj₁ ([F] ⊢Δ₁ [ρσ])) [a] [b]′ = irrelevanceTerm′ (wk-subst F) PE.refl PE.refl (wk [ρ] ⊢Δ₁ [σF]) (proj₁ ([F] ⊢Δ₁ [ρσ])) [b] [a≡b]′ = irrelevanceEqTerm′ (wk-subst F) PE.refl PE.refl (wk [ρ] ⊢Δ₁ [σF]) (proj₁ ([F] ⊢Δ₁ [ρσ])) [a≡b] in irrelevanceEq″ (PE.sym (singleSubstWkComp a σ G)) (PE.sym (singleSubstWkComp b σ G)) PE.refl PE.refl (proj₁ (GappGen {F = F} {G = G} {σ = σ} [Γ] [F] [G] ⊢Δ [σ] a [ρ] ⊢Δ₁ [a]′)) (Gapp {F = F} {G = G} {σ = σ} [Γ] [F] [G] ⊢Δ [σ] a [ρ] ⊢Δ₁ [a]′) (proj₂ (GappGen {F = F} {G = G} {σ = σ} [Γ] [F] [G] ⊢Δ [σ] a [ρ] ⊢Δ₁ [a]′) ([ρσ] , [b]′) (reflSubst [Γ] ⊢Δ₁ [ρσ] , [a≡b]′))) , λ {σ′} [σ′] [σ≡σ′] → let var0 = var (⊢Δ ∙ ⊢F [σ]) (PE.subst (λ x → 0 ∷ x ^ [ % , ι l∃ ] ∈ (Δ ∙ subst σ F ^ [ % , ι l∃ ])) (wk-subst F) here) [wk1σ] = wk1SubstS [Γ] ⊢Δ (⊢F [σ]) [σ] [wk1σ′] = wk1SubstS [Γ] ⊢Δ (⊢F [σ]) [σ′] [wk1σ≡wk1σ′] = wk1SubstSEq [Γ] ⊢Δ (⊢F [σ]) [σ] [σ≡σ′] [F][wk1σ] = proj₁ ([F] (⊢Δ ∙ ⊢F [σ]) [wk1σ]) [F][wk1σ′] = proj₁ ([F] (⊢Δ ∙ ⊢F [σ]) [wk1σ′]) var0′ = conv var0 (≅-eq (escapeEq [F][wk1σ] (proj₂ ([F] (⊢Δ ∙ ⊢F [σ]) [wk1σ]) [wk1σ′] [wk1σ≡wk1σ′]))) in ∃₌ _ _ (id (univ (∃ⱼ un-univ (⊢F [σ′]) ▹ un-univ (⊢G [σ′])))) (≅-univ (≅ₜ-∃-cong (⊢F [σ]) (≅-un-univ (escapeEq (proj₁ ([F] ⊢Δ [σ])) (proj₂ ([F] ⊢Δ [σ]) [σ′] [σ≡σ′]))) (≅-un-univ (escapeEq (proj₁ ([G]σ [σ])) (proj₂ ([G]σ [σ]) ([wk1σ′] , neuTerm [F][wk1σ′] (var 0) var0′ (~-var var0′)) ([wk1σ≡wk1σ′] , neuEqTerm [F][wk1σ] (var 0) (var 0) var0 var0 (~-var var0))))))) (λ ρ ⊢Δ₁ → wkEq ρ ⊢Δ₁ [σF] (proj₂ ([F] ⊢Δ [σ]) [σ′] [σ≡σ′])) (λ {ρ} {Δ₁} {a} [ρ] ⊢Δ₁ [a] → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] [ρσ′] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ′] [a]′ = irrelevanceTerm′ (wk-subst F) PE.refl PE.refl (wk [ρ] ⊢Δ₁ [σF]) (proj₁ ([F] ⊢Δ₁ [ρσ])) [a] [a]″ = convTerm₁ (proj₁ ([F] ⊢Δ₁ [ρσ])) (proj₁ ([F] ⊢Δ₁ [ρσ′])) (proj₂ ([F] ⊢Δ₁ [ρσ]) [ρσ′] (wkSubstSEq [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] [σ≡σ′])) [a]′ [ρσa≡ρσ′a] = consSubstSEq {t = a} {A = F} [Γ] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ]) (wkSubstSEq [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] [σ≡σ′]) [F] [a]′ in irrelevanceEq″ (PE.sym (singleSubstWkComp a σ G)) (PE.sym (singleSubstWkComp a σ′ G)) PE.refl PE.refl (proj₁ (GappGen {F = F} {G = G} {σ = σ} [Γ] [F] [G] ⊢Δ [σ] a [ρ] ⊢Δ₁ [a]′)) (Gapp {F = F} {G = G} {σ = σ} [Γ] [F] [G] ⊢Δ [σ] a [ρ] ⊢Δ₁ [a]′) (proj₂ (GappGen {F = F} {G = G} {σ = σ} [Γ] [F] [G] ⊢Δ [σ] a [ρ] ⊢Δ₁ [a]′) (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ′] , [a]″) [ρσa≡ρσ′a])) -- Validity of ∃-congurence. ∃-congᵛ : ∀ {F G H E Γ l∃ l} ([Γ] : ⊩ᵛ Γ) ([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ % , ι l∃ ] / [Γ]) ([G] : Γ ∙ F ^ [ % , ι l∃ ] ⊩ᵛ⟨ l ⟩ G ^ [ % , ι l∃ ] / [Γ] ∙ [F]) ([H] : Γ ⊩ᵛ⟨ l ⟩ H ^ [ % , ι l∃ ] / [Γ]) ([E] : Γ ∙ H ^ [ % , ι l∃ ] ⊩ᵛ⟨ l ⟩ E ^ [ % , ι l∃ ] / [Γ] ∙ [H]) ([F≡H] : Γ ⊩ᵛ⟨ l ⟩ F ≡ H ^ [ % , ι l∃ ] / [Γ] / [F]) ([G≡E] : Γ ∙ F ^ [ % , ι l∃ ] ⊩ᵛ⟨ l ⟩ G ≡ E ^ [ % , ι l∃ ] / [Γ] ∙ [F] / [G]) → Γ ⊩ᵛ⟨ l ⟩ ∃ F ▹ G ≡ ∃ H ▹ E ^ [ % , ι l∃ ] / [Γ] / ∃ᵛ {F} {G} [Γ] [F] [G] ∃-congᵛ {F} {G} {H} {E} [Γ] [F] [G] [H] [E] [F≡H] [G≡E] {σ = σ} ⊢Δ [σ] = let [∃FG] = ∃ᵛ {F} {G} [Γ] [F] [G] [σ∃FG] = proj₁ ([∃FG] ⊢Δ [σ]) _ , ∃ᵣ F′ G′ D′ ⊢F′ ⊢G′ A≡A′ [F]′ [G]′ G-ext′ = extractMaybeEmb (∃-elim [σ∃FG]) [σF] = proj₁ ([F] ⊢Δ [σ]) ⊢σF = escape [σF] [σG] = proj₁ ([G] (⊢Δ ∙ ⊢σF) (liftSubstS {F = F} [Γ] ⊢Δ [F] [σ])) ⊢σH = escape (proj₁ ([H] ⊢Δ [σ])) ⊢σE = escape (proj₁ ([E] (⊢Δ ∙ ⊢σH) (liftSubstS {F = H} [Γ] ⊢Δ [H] [σ]))) ⊢σF≡σH = escapeEq [σF] ([F≡H] ⊢Δ [σ]) ⊢σG≡σE = escapeEq [σG] ([G≡E] (⊢Δ ∙ ⊢σF) (liftSubstS {F = F} [Γ] ⊢Δ [F] [σ])) in ∃₌ (subst σ H) (subst (liftSubst σ) E) (id (univ (∃ⱼ (un-univ ⊢σH) ▹ (un-univ ⊢σE)))) (≅-univ (≅ₜ-∃-cong ⊢σF (≅-un-univ ⊢σF≡σH) (≅-un-univ ⊢σG≡σE))) (λ ρ ⊢Δ₁ → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ ρ [σ] in irrelevanceEq″ (PE.sym (wk-subst F)) (PE.sym (wk-subst H)) PE.refl PE.refl (proj₁ ([F] ⊢Δ₁ [ρσ])) ([F]′ ρ ⊢Δ₁) ([F≡H] ⊢Δ₁ [ρσ])) (λ {ρ} {Δ} {a} [ρ] ⊢Δ₁ [a] → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] [a]′ = irrelevanceTerm′ (wk-subst F) PE.refl PE.refl ([F]′ [ρ] ⊢Δ₁) (proj₁ ([F] ⊢Δ₁ [ρσ])) [a] [aρσ] = consSubstS {t = a} {A = F} [Γ] ⊢Δ₁ [ρσ] [F] [a]′ in irrelevanceEq″ (PE.sym (singleSubstWkComp a σ G)) (PE.sym (singleSubstWkComp a σ E)) PE.refl PE.refl (proj₁ ([G] ⊢Δ₁ [aρσ])) ([G]′ [ρ] ⊢Δ₁ [a]) ([G≡E] ⊢Δ₁ [aρσ]) ) -- Validity of ∃ as a term. ∃ᵗᵛ₁ : ∀ {F G l∃ Γ} ([Γ] : ⊩ᵛ Γ)→ let l = ∞ [UF] = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) [U∃] = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) in ([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ % , ι l∃ ] / [Γ]) ([UG] : Γ ∙ F ^ [ % , ι l∃ ] ⊩ᵛ⟨ l ⟩ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] ∙ [F]) → Γ ⊩ᵛ⟨ l ⟩ F ∷ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] / [UF] → Γ ∙ F ^ [ % , ι l∃ ] ⊩ᵛ⟨ l ⟩ G ∷ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] ∙ [F] / (λ {Δ} {σ} → [UG] {Δ} {σ}) → ∀ {Δ σ} (⊢Δ : ⊢ Δ) ([σ] : Δ ⊩ˢ σ ∷ Γ / [Γ] / ⊢Δ) → Δ ⊩⟨ l ⟩ subst σ (∃ F ▹ G) ∷ subst σ (Univ % l∃) ^ [ ! , next l∃ ] / proj₁ ([U∃] ⊢Δ [σ]) ∃ᵗᵛ₁ {F} {G} {l∃ = ¹} {Γ} [Γ] [F] [UG] [Fₜ] [Gₜ] {Δ = Δ} {σ = σ} ⊢Δ [σ] = let l = ∞ l∃ = ¹ l∃≤ = ≡is≤ PE.refl [UF] = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) [U∃] = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) ⊢F = escape (proj₁ ([F] ⊢Δ [σ])) [liftσ] = liftSubstS {F = F} [Γ] ⊢Δ [F] [σ] univΔ = proj₁ ([UF] ⊢Δ [σ]) [Fₜ]σ {σ′} [σ′] = [Fₜ] {σ = σ′} ⊢Δ [σ′] [σF] = proj₁ ([Fₜ]σ [σ]) ⊢Fₜ = escapeTerm univΔ (proj₁ ([Fₜ] ⊢Δ [σ])) ⊢F≡Fₜ = escapeTermEq univΔ (reflEqTerm univΔ (proj₁ ([Fₜ] ⊢Δ [σ]))) [UG]σ = proj₁ ([UG] {σ = liftSubst σ} (⊢Δ ∙ ⊢F) [liftσ]) [Gₜ]σ = proj₁ ([Gₜ] (⊢Δ ∙ ⊢F) [liftσ]) ⊢Gₜ = escapeTerm [UG]σ [Gₜ]σ ⊢G≡Gₜ = escapeTermEq [UG]σ (reflEqTerm [UG]σ [Gₜ]σ) [F]₀ = univᵛ {F} [Γ] l∃≤ [UF] [Fₜ] [UG]′ = S.irrelevance {A = Univ % l∃} {r = [ ! , next l∃ ]} (_∙_ {A = F} [Γ] [F]) (_∙_ {A = F} [Γ] [F]₀) (λ {Δ} {σ} → [UG] {Δ} {σ}) [Gₜ]′ = S.irrelevanceTerm {l′ = ∞} {A = Univ % l∃} {t = G} (_∙_ {A = F} [Γ] [F]) (_∙_ {A = F} [Γ] [F]₀) (λ {Δ} {σ} → [UG] {Δ} {σ}) (λ {Δ} {σ} → [UG]′ {Δ} {σ}) [Gₜ] [G]₀ = univᵛ {G} (_∙_ {A = F} [Γ] [F]₀) l∃≤ (λ {Δ} {σ} → [UG]′ {Δ} {σ}) (λ {Δ} {σ} → [Gₜ]′ {Δ} {σ}) [Guniv] = univᵛ {A = G} (_∙_ {A = F} [Γ] [F]₀) l∃≤ (λ {Δ} {σ} → [UG]′ {Δ} {σ}) [Gₜ]′ in Uₜ (∃ subst σ F ▹ subst (liftSubst σ) G) (idRedTerm:*: (∃ⱼ ⊢Fₜ ▹ ⊢Gₜ)) ∃ₙ (≅ₜ-∃-cong ⊢F ⊢F≡Fₜ ⊢G≡Gₜ) (λ {ρ} {Δ₁} [ρ] ⊢Δ₁ → let ⊢Fₜ' = Definition.Typed.Weakening.wkTerm [ρ] ⊢Δ₁ ⊢Fₜ ⊢Gₜ' = Definition.Typed.Weakening.wkTerm (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') ⊢Gₜ [wkFₜ] = wkTerm [ρ] ⊢Δ₁ univΔ (proj₁ ([Fₜ] ⊢Δ [σ])) [wkGₜ] = wkTerm (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') (proj₁ ([UG] {σ = liftSubst σ} (⊢Δ ∙ ⊢F) [liftσ])) (proj₁ ([Gₜ] (⊢Δ ∙ ⊢F) [liftσ])) [⊢weakF≡Fₜ] = escapeTermEq (wk [ρ] ⊢Δ₁ univΔ) (reflEqTerm (wk [ρ] ⊢Δ₁ univΔ) [wkFₜ]) [⊢weakG≡Gₜ] = escapeTermEq (wk (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ]))) (reflEqTerm (wk (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ]))) (wkTerm (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ])) (proj₁ ([Gₜ] (⊢Δ ∙ ⊢F) [liftσ])))) [wkFₜ]Type : ∀ {ρ₁ Δ₂} [ρ₁] ⊢Δ₂ → Δ₂ ⊩⟨ ι ¹ ⟩ U.wk ρ₁ (U.wk ρ (subst σ F)) ^ [ % , ι l∃ ] [wkFₜ]Type = λ {ρ₁} {Δ₂} [ρ₁] ⊢Δ₂ → let [wkFₜ]Type = univEq (wk [ρ₁] ⊢Δ₂ (wk [ρ] ⊢Δ₁ univΔ)) (wkTerm [ρ₁] ⊢Δ₂ (wk [ρ] ⊢Δ₁ univΔ) [wkFₜ]) in maybeEmb′ l∃≤ [wkFₜ]Type in ∃ᵣ′ (U.wk ρ (subst σ F)) (U.wk (lift ρ) (subst (liftSubst σ) G)) (idRed:*: (univ (∃ⱼ ⊢Fₜ' ▹ ⊢Gₜ'))) (univ ⊢Fₜ') (univ ⊢Gₜ') (≅-univ (≅ₜ-∃-cong (univ ⊢Fₜ') [⊢weakF≡Fₜ] [⊢weakG≡Gₜ])) [wkFₜ]Type (λ {ρ₁} {Δ₂} {a} [ρ₁] ⊢Δ₂ [a] → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₂ ([ρ₁] •ₜ [ρ]) [σ] [a]′ = irrelevanceTerm′ (wk-subst2 {ρ} {ρ₁} {σ} F) PE.refl PE.refl ([wkFₜ]Type [ρ₁] ⊢Δ₂) (proj₁ ([F]₀ ⊢Δ₂ [ρσ])) [a] [Gapp] = Gapp {F = F} {G = G} {σ = σ} [Γ] [F]₀ [Guniv] ⊢Δ [σ] a ([ρ₁] •ₜ [ρ]) ⊢Δ₂ [a]′ in PE.subst (λ X → _ ⊩⟨ ι ¹ ⟩ X ^ _) (wk-comp-subst _ _ (subst (liftSubst σ) G)) [Gapp]) (λ {ρ₁} {Δ₂} {a} {b} [ρ₁] ⊢Δ₂ [a] [b] [a≡b] → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₂ ([ρ₁] •ₜ [ρ]) [σ] [a]′ = irrelevanceTerm′ (wk-subst2 {ρ} {ρ₁} {σ} F) PE.refl PE.refl ([wkFₜ]Type [ρ₁] ⊢Δ₂) (proj₁ ([F]₀ ⊢Δ₂ [ρσ])) [a] [b]′ = irrelevanceTerm′ (wk-subst2 {ρ} {ρ₁} {σ} F) PE.refl PE.refl ([wkFₜ]Type [ρ₁] ⊢Δ₂) (proj₁ ([F]₀ ⊢Δ₂ [ρσ])) [b] [a≡b]′ = irrelevanceEqTerm′ (wk-subst2 {ρ} {ρ₁} {σ} F) PE.refl PE.refl ([wkFₜ]Type [ρ₁] ⊢Δ₂) (proj₁ ([F]₀ ⊢Δ₂ [ρσ])) [a≡b] [Gapp] = Gapp {F = F} {G = G} {σ = σ} [Γ] [F]₀ [Guniv] ⊢Δ [σ] a ([ρ₁] •ₜ [ρ]) ⊢Δ₂ [a]′ in irrelevanceEq″ (PE.trans (PE.sym (singleSubstWkComp a σ G)) (wk-comp-subst {a} ρ₁ ρ (subst (liftSubst σ) G))) (PE.trans (PE.sym (singleSubstWkComp b σ G)) (wk-comp-subst {b} ρ₁ ρ (subst (liftSubst σ) G))) PE.refl PE.refl (proj₁ (GappGen {F = F} {G = G} {σ = σ} [Γ] [F]₀ [Guniv] ⊢Δ [σ] a ([ρ₁] •ₜ [ρ]) ⊢Δ₂ [a]′ )) (PE.subst (λ X → _ ⊩⟨ ι ¹ ⟩ X ^ _) (wk-comp-subst _ _ (subst (liftSubst σ) G)) [Gapp]) (proj₂ (GappGen {F = F} {G = G} {σ = σ} [Γ] [F]₀ [Guniv] ⊢Δ [σ] a ([ρ₁] •ₜ [ρ]) ⊢Δ₂ [a]′ ) ([ρσ] , [b]′) (reflSubst [Γ] ⊢Δ₂ [ρσ] , [a≡b]′)))) ∃ᵗᵛ₁ {F} {G} {l∃ = ⁰} {Γ} [Γ] [F] [UG] [Fₜ] [Gₜ] {Δ = Δ} {σ = σ} ⊢Δ [σ] = let l = ∞ l∃ = ⁰ l∃≤ = ≡is≤ PE.refl [UF] = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) [U∃] = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) ⊢F = escape (proj₁ ([F] ⊢Δ [σ])) [liftσ] = liftSubstS {F = F} [Γ] ⊢Δ [F] [σ] univΔ = proj₁ ([UF] ⊢Δ [σ]) [Fₜ]σ {σ′} [σ′] = [Fₜ] {σ = σ′} ⊢Δ [σ′] [σF] = proj₁ ([Fₜ]σ [σ]) ⊢Fₜ = escapeTerm univΔ (proj₁ ([Fₜ] ⊢Δ [σ])) ⊢F≡Fₜ = escapeTermEq univΔ (reflEqTerm univΔ (proj₁ ([Fₜ] ⊢Δ [σ]))) [UG]σ = proj₁ ([UG] {σ = liftSubst σ} (⊢Δ ∙ ⊢F) [liftσ]) [Gₜ]σ = proj₁ ([Gₜ] (⊢Δ ∙ ⊢F) [liftσ]) ⊢Gₜ = escapeTerm [UG]σ [Gₜ]σ ⊢G≡Gₜ = escapeTermEq [UG]σ (reflEqTerm [UG]σ [Gₜ]σ) [F]₀ = univᵛ {F} [Γ] l∃≤ [UF] [Fₜ] [UG]′ = S.irrelevance {A = Univ % l∃} {r = [ ! , next l∃ ]} (_∙_ {A = F} [Γ] [F]) (_∙_ {A = F} [Γ] [F]₀) (λ {Δ} {σ} → [UG] {Δ} {σ}) [Gₜ]′ = S.irrelevanceTerm {l′ = ∞} {A = Univ % l∃} {t = G} (_∙_ {A = F} [Γ] [F]) (_∙_ {A = F} [Γ] [F]₀) (λ {Δ} {σ} → [UG] {Δ} {σ}) (λ {Δ} {σ} → [UG]′ {Δ} {σ}) [Gₜ] [G]₀ = univᵛ {G} (_∙_ {A = F} [Γ] [F]₀) l∃≤ (λ {Δ} {σ} → [UG]′ {Δ} {σ}) (λ {Δ} {σ} → [Gₜ]′ {Δ} {σ}) [Guniv] = univᵛ {A = G} (_∙_ {A = F} [Γ] [F]₀) l∃≤ (λ {Δ} {σ} → [UG]′ {Δ} {σ}) [Gₜ]′ in Uₜ (∃ subst σ F ▹ subst (liftSubst σ) G) (idRedTerm:*: (∃ⱼ ⊢Fₜ ▹ ⊢Gₜ)) ∃ₙ (≅ₜ-∃-cong ⊢F ⊢F≡Fₜ ⊢G≡Gₜ) (λ {ρ} {Δ₁} [ρ] ⊢Δ₁ → let ⊢Fₜ' = Definition.Typed.Weakening.wkTerm [ρ] ⊢Δ₁ ⊢Fₜ ⊢Gₜ' = Definition.Typed.Weakening.wkTerm (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') ⊢Gₜ [wkFₜ] = wkTerm [ρ] ⊢Δ₁ univΔ (proj₁ ([Fₜ] ⊢Δ [σ])) [wkGₜ] = wkTerm (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') (proj₁ ([UG] {σ = liftSubst σ} (⊢Δ ∙ ⊢F) [liftσ])) (proj₁ ([Gₜ] (⊢Δ ∙ ⊢F) [liftσ])) [⊢weakF≡Fₜ] = escapeTermEq (wk [ρ] ⊢Δ₁ univΔ) (reflEqTerm (wk [ρ] ⊢Δ₁ univΔ) [wkFₜ]) [⊢weakG≡Gₜ] = escapeTermEq (wk (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ]))) (reflEqTerm (wk (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ]))) (wkTerm (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ])) (proj₁ ([Gₜ] (⊢Δ ∙ ⊢F) [liftσ])))) [wkFₜ]Type : ∀ {ρ₁ Δ₂} [ρ₁] ⊢Δ₂ → Δ₂ ⊩⟨ ι ⁰ ⟩ U.wk ρ₁ (U.wk ρ (subst σ F)) ^ [ % , ι l∃ ] [wkFₜ]Type = λ {ρ₁} {Δ₂} [ρ₁] ⊢Δ₂ → let [wkFₜ]Type = univEq (wk [ρ₁] ⊢Δ₂ (wk [ρ] ⊢Δ₁ univΔ)) (wkTerm [ρ₁] ⊢Δ₂ (wk [ρ] ⊢Δ₁ univΔ) [wkFₜ]) in maybeEmb′ l∃≤ [wkFₜ]Type in ∃ᵣ′ (U.wk ρ (subst σ F)) (U.wk (lift ρ) (subst (liftSubst σ) G)) (idRed:*: (univ (∃ⱼ ⊢Fₜ' ▹ ⊢Gₜ'))) (univ ⊢Fₜ') (univ ⊢Gₜ') (≅-univ (≅ₜ-∃-cong (univ ⊢Fₜ') [⊢weakF≡Fₜ] [⊢weakG≡Gₜ])) [wkFₜ]Type (λ {ρ₁} {Δ₂} {a} [ρ₁] ⊢Δ₂ [a] → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₂ ([ρ₁] •ₜ [ρ]) [σ] [a]′ = irrelevanceTerm′ (wk-subst2 {ρ} {ρ₁} {σ} F) PE.refl PE.refl ([wkFₜ]Type [ρ₁] ⊢Δ₂) (proj₁ ([F]₀ ⊢Δ₂ [ρσ])) [a] [Gapp] = Gapp {F = F} {G = G} {σ = σ} [Γ] [F]₀ [Guniv] ⊢Δ [σ] a ([ρ₁] •ₜ [ρ]) ⊢Δ₂ [a]′ in PE.subst (λ X → _ ⊩⟨ ι ⁰ ⟩ X ^ _) (wk-comp-subst _ _ (subst (liftSubst σ) G)) [Gapp]) (λ {ρ₁} {Δ₂} {a} {b} [ρ₁] ⊢Δ₂ [a] [b] [a≡b] → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₂ ([ρ₁] •ₜ [ρ]) [σ] [a]′ = irrelevanceTerm′ (wk-subst2 {ρ} {ρ₁} {σ} F) PE.refl PE.refl ([wkFₜ]Type [ρ₁] ⊢Δ₂) (proj₁ ([F]₀ ⊢Δ₂ [ρσ])) [a] [b]′ = irrelevanceTerm′ (wk-subst2 {ρ} {ρ₁} {σ} F) PE.refl PE.refl ([wkFₜ]Type [ρ₁] ⊢Δ₂) (proj₁ ([F]₀ ⊢Δ₂ [ρσ])) [b] [a≡b]′ = irrelevanceEqTerm′ (wk-subst2 {ρ} {ρ₁} {σ} F) PE.refl PE.refl ([wkFₜ]Type [ρ₁] ⊢Δ₂) (proj₁ ([F]₀ ⊢Δ₂ [ρσ])) [a≡b] [Gapp] = Gapp {F = F} {G = G} {σ = σ} [Γ] [F]₀ [Guniv] ⊢Δ [σ] a ([ρ₁] •ₜ [ρ]) ⊢Δ₂ [a]′ in irrelevanceEq″ (PE.trans (PE.sym (singleSubstWkComp a σ G)) (wk-comp-subst {a} ρ₁ ρ (subst (liftSubst σ) G))) (PE.trans (PE.sym (singleSubstWkComp b σ G)) (wk-comp-subst {b} ρ₁ ρ (subst (liftSubst σ) G))) PE.refl PE.refl (proj₁ (GappGen {F = F} {G = G} {σ = σ} [Γ] [F]₀ [Guniv] ⊢Δ [σ] a ([ρ₁] •ₜ [ρ]) ⊢Δ₂ [a]′ )) (PE.subst (λ X → _ ⊩⟨ ι ⁰ ⟩ X ^ _) (wk-comp-subst _ _ (subst (liftSubst σ) G)) [Gapp]) (proj₂ (GappGen {F = F} {G = G} {σ = σ} [Γ] [F]₀ [Guniv] ⊢Δ [σ] a ([ρ₁] •ₜ [ρ]) ⊢Δ₂ [a]′ ) ([ρσ] , [b]′) (reflSubst [Γ] ⊢Δ₂ [ρσ] , [a≡b]′)))) ∃ᵗᵛ : ∀ {F G l∃ Γ} ([Γ] : ⊩ᵛ Γ)→ let l = ∞ [UF] = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) [U∃] = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) in ([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ % , ι l∃ ] / [Γ]) ([UG] : Γ ∙ F ^ [ % , ι l∃ ] ⊩ᵛ⟨ l ⟩ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] ∙ [F]) → Γ ⊩ᵛ⟨ l ⟩ F ∷ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] / [UF] → Γ ∙ F ^ [ % , ι l∃ ] ⊩ᵛ⟨ l ⟩ G ∷ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] ∙ [F] / (λ {Δ} {σ} → [UG] {Δ} {σ}) → Γ ⊩ᵛ⟨ l ⟩ ∃ F ▹ G ∷ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] / [U∃] ∃ᵗᵛ {F} {G} {l∃ = ¹} {Γ} [Γ] [F] [UG] [Fₜ] [Gₜ] {Δ = Δ} {σ = σ} ⊢Δ [σ] = let l = ∞ l∃ = ¹ l∃≤ = ≡is≤ PE.refl [UF] = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) in ∃ᵗᵛ₁ {F} {G} {¹} {Γ} [Γ] [F] (λ {Δ} {σ} → [UG] {Δ} {σ}) [Fₜ] [Gₜ] {Δ = Δ} {σ = σ} ⊢Δ [σ] , (λ {σ′} [σ′] [σ≡σ′] → let ⊢F = escape (proj₁ ([F] ⊢Δ [σ])) [liftσ] = liftSubstS {F = F} [Γ] ⊢Δ [F] [σ] univΔ = proj₁ ([UF] ⊢Δ [σ]) [Fₜ]σ {σ′} [σ′] = [Fₜ] {σ = σ′} ⊢Δ [σ′] [σF] = proj₁ ([Fₜ]σ [σ]) ⊢Fₜ = escapeTerm univΔ (proj₁ ([Fₜ] ⊢Δ [σ])) ⊢F≡Fₜ = escapeTermEq univΔ (reflEqTerm univΔ (proj₁ ([Fₜ] ⊢Δ [σ]))) [liftσ′] = liftSubstS {F = F} [Γ] ⊢Δ [F] [σ′] [wk1σ] = wk1SubstS [Γ] ⊢Δ ⊢F [σ] [wk1σ′] = wk1SubstS [Γ] ⊢Δ ⊢F [σ′] var0 = conv (var (⊢Δ ∙ ⊢F) (PE.subst (λ x → 0 ∷ x ^ [ % , ι l∃ ] ∈ (Δ ∙ subst σ F ^ [ % , ι l∃ ])) (wk-subst F) here)) (≅-eq (escapeEq (proj₁ ([F] (⊢Δ ∙ ⊢F) [wk1σ])) (proj₂ ([F] (⊢Δ ∙ ⊢F) [wk1σ]) [wk1σ′] (wk1SubstSEq [Γ] ⊢Δ ⊢F [σ] [σ≡σ′])))) [liftσ′]′ = [wk1σ′] , neuTerm (proj₁ ([F] (⊢Δ ∙ ⊢F) [wk1σ′])) (var 0) var0 (~-var var0) ⊢F′ = escape (proj₁ ([F] ⊢Δ [σ′])) univΔ = proj₁ ([UF] ⊢Δ [σ]) univΔ′ = proj₁ ([UF] ⊢Δ [σ′]) [Fₜ]σ {σ′} [σ′] = [Fₜ] {σ = σ′} ⊢Δ [σ′] [σF] = proj₁ ([Fₜ]σ [σ]) ⊢Fₜ′ = escapeTerm univΔ′ (proj₁ ([Fₜ] ⊢Δ [σ′])) ⊢Gₜ′ = escapeTerm (proj₁ ([UG] {σ = liftSubst σ′} (⊢Δ ∙ ⊢F′) [liftσ′])) (proj₁ ([Gₜ] (⊢Δ ∙ ⊢F′) [liftσ′])) ⊢F≡F′ = escapeTermEq univΔ (proj₂ ([Fₜ] ⊢Δ [σ]) [σ′] [σ≡σ′]) ⊢G≡G′ = escapeTermEq (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ])) (proj₂ ([Gₜ] (⊢Δ ∙ ⊢F) [liftσ]) [liftσ′]′ (liftSubstSEq {F = F} [Γ] ⊢Δ [F] [σ] [σ≡σ′])) [F]₀ = univᵛ {F} [Γ] l∃≤ [UF] [Fₜ] [UG]′ = S.irrelevance {A = Univ % l∃} {r = [ ! , next l∃ ]} (_∙_ {A = F} [Γ] [F]) (_∙_ {A = F} [Γ] [F]₀) (λ {Δ} {σ} → [UG] {Δ} {σ}) [Gₜ]′ = S.irrelevanceTerm {l′ = ∞} {A = Univ % l∃} {t = G} (_∙_ {A = F} [Γ] [F]) (_∙_ {A = F} [Γ] [F]₀) (λ {Δ} {σ} → [UG] {Δ} {σ}) (λ {Δ} {σ} → [UG]′ {Δ} {σ}) [Gₜ] [G]₀ = univᵛ {G} (_∙_ {A = F} [Γ] [F]₀) l∃≤ (λ {Δ} {σ} → [UG]′ {Δ} {σ}) (λ {Δ} {σ} → [Gₜ]′ {Δ} {σ}) [∃FG-cong] = ∃-congᵛ {F} {G} {F} {G} [Γ] [F]₀ [G]₀ [F]₀ [G]₀ (λ ⊢Δ₁ [σ]₁ → proj₂ ([F]₀ ⊢Δ₁ [σ]₁) [σ]₁ (reflSubst [Γ] ⊢Δ₁ [σ]₁)) (λ {Δ₁} {σ₁} ⊢Δ₁ [σ]₁ → proj₂ ([G]₀ ⊢Δ₁ [σ]₁) [σ]₁ (reflSubst {σ₁} ((_∙_ {A = F} [Γ] [F]₀)) ⊢Δ₁ [σ]₁)) [∃FG]ᵗ = ∃ᵗᵛ₁ {F} {G} {l∃ = ¹} {Γ} [Γ] [F] (λ {Δ} {σ} → [UG] {Δ} {σ}) [Fₜ] [Gₜ] {Δ = Δ} {σ = σ} ⊢Δ [σ] [∃FG]ᵗ′ = ∃ᵗᵛ₁ {F} {G} {l∃ = ¹} {Γ} [Γ] [F] (λ {Δ} {σ} → [UG] {Δ} {σ}) [Fₜ] [Gₜ] {Δ = Δ} {σ = σ′} ⊢Δ [σ′] [∃FG] = ∃ᵛ {F} {G} {Γ} {l∃ = ¹} [Γ] [F]₀ [G]₀ in Uₜ₌ [∃FG]ᵗ [∃FG]ᵗ′ (≅ₜ-∃-cong ⊢F ⊢F≡F′ ⊢G≡G′) (λ {ρ} {Δ₁} [ρ] ⊢Δ₁ → let [∃FG-cong]′ = [∃FG-cong] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ]) X = irrelevanceEq″ (PE.sym (wk-subst (∃ F ▹ G))) (PE.sym (wk-subst (∃ F ▹ G))) PE.refl PE.refl (proj₁ ([∃FG] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ]))) (LogRel._⊩¹U_∷_^_/_.[t] [∃FG]ᵗ [ρ] ⊢Δ₁) [∃FG-cong]′ [σ∃FG] = proj₁ ([∃FG] ⊢Δ [σ]) _ , ∃ᵣ F′ G′ D′ ⊢F′ ⊢G′ A≡A′ [F]′ [G]′ G-ext′ = extractMaybeEmb (∃-elim [σ∃FG]) [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] [σF]₀ = proj₁ ([F]₀ ⊢Δ₁ [ρσ]) ⊢σF₀ = escape [σF]₀ [σG]₀ = proj₁ ([G]₀ (⊢Δ₁ ∙ ⊢σF₀) (liftSubstS {F = F} [Γ] ⊢Δ₁ [F]₀ [ρσ])) [ρσ′] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ′] [σF′]₀ = proj₁ ([F]₀ ⊢Δ₁ [ρσ′]) ⊢σH = escape (proj₁ ([F]₀ ⊢Δ₁ [ρσ′])) ⊢σE = escape (proj₁ ([G]₀ (⊢Δ₁ ∙ ⊢σH) (liftSubstS {F = F} [Γ] ⊢Δ₁ [F]₀ [ρσ′]))) univΔ₁ = proj₁ ([UF] ⊢Δ₁ [ρσ]) [ρσ≡ρσ′] = wkSubstSEq [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] [σ≡σ′] [σF≡σH] = univEqEq univΔ₁ [σF]₀ (proj₂ ([Fₜ] ⊢Δ₁ [ρσ]) [ρσ′] [ρσ≡ρσ′]) ⊢σF≡σH = escapeEq [σF]₀ [σF≡σH] [σF] = proj₁ ([F] ⊢Δ₁ [ρσ]) ⊢σF = escape [σF] liftσ = liftSubstS {F = F} [Γ] ⊢Δ₁ [F] [ρσ] [wk1σ] = wk1SubstS [Γ] ⊢Δ₁ ⊢σF [ρσ] [wk1σ′] = wk1SubstS [Γ] ⊢Δ₁ ⊢σF [ρσ′] var0 = conv (var (⊢Δ₁ ∙ ⊢σF) (PE.subst (λ x → 0 ∷ x ^ [ % , ι l∃ ] ∈ (Δ₁ ∙ subst (ρ •ₛ σ) F ^ [ % , ι l∃ ])) (wk-subst F) here)) (≅-eq (escapeEq (proj₁ ([F] (⊢Δ₁ ∙ ⊢σF) [wk1σ])) (proj₂ ([F] (⊢Δ₁ ∙ ⊢σF) [wk1σ]) [wk1σ′] (wk1SubstSEq [Γ] ⊢Δ₁ ⊢σF [ρσ] [ρσ≡ρσ′])))) [liftσ′]′ : (Δ₁ ∙ subst (ρ •ₛ σ) F ^ [ % , ι l∃ ]) ⊩ˢ liftSubst (ρ •ₛ σ′) ∷ Γ ∙ F ^ [ % , ι l∃ ] / [Γ] ∙ [F] / (⊢Δ₁ ∙ escape (proj₁ ([F] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ])))) [liftσ′]′ = [wk1σ′] , neuTerm (proj₁ ([F] (⊢Δ₁ ∙ ⊢σF) [wk1σ′])) (var 0) var0 (~-var var0) liftσ′ = liftSubstS {F = F} [Γ] ⊢Δ₁ [F] [ρσ′] univΔ₁G = proj₁ ([UG] (⊢Δ₁ ∙ ⊢σF) liftσ) [σG≡σE] = univEqEq univΔ₁G [σG]₀ (proj₂ ([Gₜ] {σ = liftSubst (ρ •ₛ σ)} (⊢Δ₁ ∙ ⊢σF) liftσ) [liftσ′]′ (liftSubstSEq {F = F} [Γ] ⊢Δ₁ [F] [ρσ] [ρσ≡ρσ′])) ⊢σG≡σE = escapeEq [σG]₀ [σG≡σE] X = ∃₌ (subst (ρ •ₛ σ′) F) (subst (liftSubst (ρ •ₛ σ′)) G) (id (univ (∃ⱼ (un-univ ⊢σH) ▹ (un-univ ⊢σE)))) ((≅-univ (≅ₜ-∃-cong ⊢σF (≅-un-univ ⊢σF≡σH) (≅-un-univ ⊢σG≡σE)))) (λ {ρ₂} {Δ₂} [ρ₂] ⊢Δ₂ → let [ρσ₂] = wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ₂F]₀ = proj₁ ([F]₀ ⊢Δ₂ [ρσ₂]) [σ∃FG] = proj₁ ([∃FG] ⊢Δ₁ [ρσ]) _ , ∃ᵣ F′ G′ D′ ⊢F′ ⊢G′ A≡A′ [F]′ [G]′ G-ext′ = extractMaybeEmb (∃-elim [σ∃FG]) ⊢ρσ₂F = escape [ρσ₂F]₀ [ρσ₂′] = wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ′] ⊢σH = escape (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂′])) univΔ₂ = proj₁ ([UF] ⊢Δ₂ [ρσ₂]) [σF≡σH] = univEqEq univΔ₂ [ρσ₂F]₀ (proj₂ ([Fₜ] ⊢Δ₂ [ρσ₂]) [ρσ₂′] (wkSubstSEq [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ≡ρσ′])) in irrelevanceEq″ (PE.sym (wk-subst F)) (PE.sym (wk-subst F)) PE.refl PE.refl [ρσ₂F]₀ ([F]′ [ρ₂] ⊢Δ₂) [σF≡σH]) (λ {ρ₂} {Δ₂} {a} [ρ₂] ⊢Δ₂ [a] → let [ρσ₂] = wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ₂F]₀ = proj₁ ([F]₀ ⊢Δ₂ [ρσ₂]) [σ∃FG] = proj₁ ([∃FG] ⊢Δ₁ [ρσ]) _ , ∃ᵣ F′ G′ D′ ⊢F′ ⊢G′ A≡A′ [F]′ [G]′ G-ext′ = extractMaybeEmb (∃-elim [σ∃FG]) ⊢ρσ₂F = escape [ρσ₂F]₀ [ρσ₂′] = wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ′] ⊢σH = escape (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂′])) univΔ₂ = proj₁ ([UF] ⊢Δ₂ [ρσ₂]) [a]′ = irrelevanceTerm′ (wk-subst F) PE.refl PE.refl (wk [ρ₂] ⊢Δ₂ [σF]₀) (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂])) [a] [a]″ = convTerm₁ (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂])) (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂′])) (proj₂ ([F]₀ ⊢Δ₂ [ρσ₂]) [ρσ₂′] (wkSubstSEq [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ≡ρσ′])) [a]′ [ρσa≡ρσ′a] = consSubstSEq {t = a} {A = F} [Γ] ⊢Δ₂ (wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ]) (wkSubstSEq [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ≡ρσ′]) [F]₀ [a]′ in irrelevanceEq″ (PE.sym (singleSubstWkComp a (ρ •ₛ σ) G)) (PE.sym (singleSubstWkComp a (ρ •ₛ σ′) G)) PE.refl PE.refl (proj₁ (GappGen {F = F} {G = G} {σ = _} [Γ] [F]₀ [G]₀ ⊢Δ₁ [ρσ] a [ρ₂] ⊢Δ₂ [a]′)) (Gapp {F = F} {G = G} {σ = _} [Γ] [F]₀ [G]₀ ⊢Δ₁ [ρσ] a [ρ₂] ⊢Δ₂ [a]′) (proj₂ (GappGen {F = F} {G = G} {σ = _} [Γ] [F]₀ [G]₀ ⊢Δ₁ [ρσ] a [ρ₂] ⊢Δ₂ [a]′) ([ρσ₂′] , [a]″) [ρσa≡ρσ′a] )) in irrelevanceEq″ (PE.sym (wk-subst (∃ F ▹ G))) (PE.sym (wk-subst (∃ F ▹ G))) PE.refl PE.refl (proj₁ ([∃FG] ⊢Δ₁ [ρσ])) (LogRel._⊩¹U_∷_^_/_.[t] [∃FG]ᵗ [ρ] ⊢Δ₁) X)) ∃ᵗᵛ {F} {G} {l∃ = ⁰} {Γ} [Γ] [F] [UG] [Fₜ] [Gₜ] {Δ = Δ} {σ = σ} ⊢Δ [σ] = let l = ∞ l∃ = ⁰ l∃≤ = ≡is≤ PE.refl [UF] = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) in ∃ᵗᵛ₁ {F} {G} {⁰} {Γ} [Γ] [F] (λ {Δ} {σ} → [UG] {Δ} {σ}) [Fₜ] [Gₜ] {Δ = Δ} {σ = σ} ⊢Δ [σ] , (λ {σ′} [σ′] [σ≡σ′] → let ⊢F = escape (proj₁ ([F] ⊢Δ [σ])) [liftσ] = liftSubstS {F = F} [Γ] ⊢Δ [F] [σ] univΔ = proj₁ ([UF] ⊢Δ [σ]) [Fₜ]σ {σ′} [σ′] = [Fₜ] {σ = σ′} ⊢Δ [σ′] [σF] = proj₁ ([Fₜ]σ [σ]) ⊢Fₜ = escapeTerm univΔ (proj₁ ([Fₜ] ⊢Δ [σ])) ⊢F≡Fₜ = escapeTermEq univΔ (reflEqTerm univΔ (proj₁ ([Fₜ] ⊢Δ [σ]))) [liftσ′] = liftSubstS {F = F} [Γ] ⊢Δ [F] [σ′] [wk1σ] = wk1SubstS [Γ] ⊢Δ ⊢F [σ] [wk1σ′] = wk1SubstS [Γ] ⊢Δ ⊢F [σ′] var0 = conv (var (⊢Δ ∙ ⊢F) (PE.subst (λ x → 0 ∷ x ^ [ % , ι l∃ ] ∈ (Δ ∙ subst σ F ^ [ % , ι l∃ ])) (wk-subst F) here)) (≅-eq (escapeEq (proj₁ ([F] (⊢Δ ∙ ⊢F) [wk1σ])) (proj₂ ([F] (⊢Δ ∙ ⊢F) [wk1σ]) [wk1σ′] (wk1SubstSEq [Γ] ⊢Δ ⊢F [σ] [σ≡σ′])))) [liftσ′]′ = [wk1σ′] , neuTerm (proj₁ ([F] (⊢Δ ∙ ⊢F) [wk1σ′])) (var 0) var0 (~-var var0) ⊢F′ = escape (proj₁ ([F] ⊢Δ [σ′])) univΔ = proj₁ ([UF] ⊢Δ [σ]) univΔ′ = proj₁ ([UF] ⊢Δ [σ′]) [Fₜ]σ {σ′} [σ′] = [Fₜ] {σ = σ′} ⊢Δ [σ′] [σF] = proj₁ ([Fₜ]σ [σ]) ⊢Fₜ′ = escapeTerm univΔ′ (proj₁ ([Fₜ] ⊢Δ [σ′])) ⊢Gₜ′ = escapeTerm (proj₁ ([UG] {σ = liftSubst σ′} (⊢Δ ∙ ⊢F′) [liftσ′])) (proj₁ ([Gₜ] (⊢Δ ∙ ⊢F′) [liftσ′])) ⊢F≡F′ = escapeTermEq univΔ (proj₂ ([Fₜ] ⊢Δ [σ]) [σ′] [σ≡σ′]) ⊢G≡G′ = escapeTermEq (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ])) (proj₂ ([Gₜ] (⊢Δ ∙ ⊢F) [liftσ]) [liftσ′]′ (liftSubstSEq {F = F} [Γ] ⊢Δ [F] [σ] [σ≡σ′])) [F]₀ = univᵛ {F} [Γ] (≡is≤ PE.refl) [UF] [Fₜ] [UG]′ = S.irrelevance {A = Univ % l∃} {r = [ ! , next l∃ ]} (_∙_ {A = F} [Γ] [F]) (_∙_ {A = F} [Γ] [F]₀) (λ {Δ} {σ} → [UG] {Δ} {σ}) [Gₜ]′ = S.irrelevanceTerm {l′ = ∞} {A = Univ % l∃} {t = G} (_∙_ {A = F} [Γ] [F]) (_∙_ {A = F} [Γ] [F]₀) (λ {Δ} {σ} → [UG] {Δ} {σ}) (λ {Δ} {σ} → [UG]′ {Δ} {σ}) [Gₜ] [G]₀ = univᵛ {G} (_∙_ {A = F} [Γ] [F]₀) l∃≤ (λ {Δ} {σ} → [UG]′ {Δ} {σ}) (λ {Δ} {σ} → [Gₜ]′ {Δ} {σ}) [∃FG-cong] = ∃-congᵛ {F} {G} {F} {G} [Γ] [F]₀ [G]₀ [F]₀ [G]₀ (λ ⊢Δ₁ [σ]₁ → proj₂ ([F]₀ ⊢Δ₁ [σ]₁) [σ]₁ (reflSubst [Γ] ⊢Δ₁ [σ]₁)) (λ {Δ₁} {σ₁} ⊢Δ₁ [σ]₁ → proj₂ ([G]₀ ⊢Δ₁ [σ]₁) [σ]₁ (reflSubst {σ₁} ((_∙_ {A = F} [Γ] [F]₀)) ⊢Δ₁ [σ]₁)) [∃FG]ᵗ = ∃ᵗᵛ₁ {F} {G} {l∃ = ⁰} {Γ} [Γ] [F] (λ {Δ} {σ} → [UG] {Δ} {σ}) [Fₜ] [Gₜ] {Δ = Δ} {σ = σ} ⊢Δ [σ] [∃FG]ᵗ′ = ∃ᵗᵛ₁ {F} {G} {l∃ = ⁰} {Γ} [Γ] [F] (λ {Δ} {σ} → [UG] {Δ} {σ}) [Fₜ] [Gₜ] {Δ = Δ} {σ = σ′} ⊢Δ [σ′] [∃FG] = ∃ᵛ {F} {G} {Γ} {l∃ = ⁰} [Γ] [F]₀ [G]₀ in Uₜ₌ [∃FG]ᵗ [∃FG]ᵗ′ (≅ₜ-∃-cong ⊢F ⊢F≡F′ ⊢G≡G′) (λ {ρ} {Δ₁} [ρ] ⊢Δ₁ → let [∃FG-cong]′ = [∃FG-cong] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ]) X = irrelevanceEq″ (PE.sym (wk-subst (∃ F ▹ G))) (PE.sym (wk-subst (∃ F ▹ G))) PE.refl PE.refl (proj₁ ([∃FG] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ]))) (LogRel._⊩¹U_∷_^_/_.[t] [∃FG]ᵗ [ρ] ⊢Δ₁) [∃FG-cong]′ [σ∃FG] = proj₁ ([∃FG] ⊢Δ [σ]) _ , ∃ᵣ F′ G′ D′ ⊢F′ ⊢G′ A≡A′ [F]′ [G]′ G-ext′ = extractMaybeEmb (∃-elim [σ∃FG]) [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] [σF]₀ = proj₁ ([F]₀ ⊢Δ₁ [ρσ]) ⊢σF₀ = escape [σF]₀ [σG]₀ = proj₁ ([G]₀ (⊢Δ₁ ∙ ⊢σF₀) (liftSubstS {F = F} [Γ] ⊢Δ₁ [F]₀ [ρσ])) [ρσ′] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ′] [σF′]₀ = proj₁ ([F]₀ ⊢Δ₁ [ρσ′]) ⊢σH = escape (proj₁ ([F]₀ ⊢Δ₁ [ρσ′])) ⊢σE = escape (proj₁ ([G]₀ (⊢Δ₁ ∙ ⊢σH) (liftSubstS {F = F} [Γ] ⊢Δ₁ [F]₀ [ρσ′]))) univΔ₁ = proj₁ ([UF] ⊢Δ₁ [ρσ]) [ρσ≡ρσ′] = wkSubstSEq [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] [σ≡σ′] [σF≡σH] = univEqEq univΔ₁ [σF]₀ (proj₂ ([Fₜ] ⊢Δ₁ [ρσ]) [ρσ′] [ρσ≡ρσ′]) ⊢σF≡σH = escapeEq [σF]₀ [σF≡σH] [σF] = proj₁ ([F] ⊢Δ₁ [ρσ]) ⊢σF = escape [σF] liftσ = liftSubstS {F = F} [Γ] ⊢Δ₁ [F] [ρσ] [wk1σ] = wk1SubstS [Γ] ⊢Δ₁ ⊢σF [ρσ] [wk1σ′] = wk1SubstS [Γ] ⊢Δ₁ ⊢σF [ρσ′] var0 = conv (var (⊢Δ₁ ∙ ⊢σF) (PE.subst (λ x → 0 ∷ x ^ [ % , ι l∃ ] ∈ (Δ₁ ∙ subst (ρ •ₛ σ) F ^ [ % , ι l∃ ])) (wk-subst F) here)) (≅-eq (escapeEq (proj₁ ([F] (⊢Δ₁ ∙ ⊢σF) [wk1σ])) (proj₂ ([F] (⊢Δ₁ ∙ ⊢σF) [wk1σ]) [wk1σ′] (wk1SubstSEq [Γ] ⊢Δ₁ ⊢σF [ρσ] [ρσ≡ρσ′])))) [liftσ′]′ : (Δ₁ ∙ subst (ρ •ₛ σ) F ^ [ % , ι l∃ ]) ⊩ˢ liftSubst (ρ •ₛ σ′) ∷ Γ ∙ F ^ [ % , ι l∃ ] / [Γ] ∙ [F] / (⊢Δ₁ ∙ escape (proj₁ ([F] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ])))) [liftσ′]′ = [wk1σ′] , neuTerm (proj₁ ([F] (⊢Δ₁ ∙ ⊢σF) [wk1σ′])) (var 0) var0 (~-var var0) liftσ′ = liftSubstS {F = F} [Γ] ⊢Δ₁ [F] [ρσ′] univΔ₁G = proj₁ ([UG] (⊢Δ₁ ∙ ⊢σF) liftσ) [σG≡σE] = univEqEq univΔ₁G [σG]₀ (proj₂ ([Gₜ] {σ = liftSubst (ρ •ₛ σ)} (⊢Δ₁ ∙ ⊢σF) liftσ) [liftσ′]′ (liftSubstSEq {F = F} [Γ] ⊢Δ₁ [F] [ρσ] [ρσ≡ρσ′])) ⊢σG≡σE = escapeEq [σG]₀ [σG≡σE] X = ∃₌ (subst (ρ •ₛ σ′) F) (subst (liftSubst (ρ •ₛ σ′)) G) (id (univ (∃ⱼ (un-univ ⊢σH) ▹ (un-univ ⊢σE)))) ((≅-univ (≅ₜ-∃-cong ⊢σF (≅-un-univ ⊢σF≡σH) (≅-un-univ ⊢σG≡σE)))) (λ {ρ₂} {Δ₂} [ρ₂] ⊢Δ₂ → let [ρσ₂] = wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ₂F]₀ = proj₁ ([F]₀ ⊢Δ₂ [ρσ₂]) [σ∃FG] = proj₁ ([∃FG] ⊢Δ₁ [ρσ]) _ , ∃ᵣ F′ G′ D′ ⊢F′ ⊢G′ A≡A′ [F]′ [G]′ G-ext′ = extractMaybeEmb (∃-elim [σ∃FG]) ⊢ρσ₂F = escape [ρσ₂F]₀ [ρσ₂′] = wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ′] ⊢σH = escape (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂′])) univΔ₂ = proj₁ ([UF] ⊢Δ₂ [ρσ₂]) [σF≡σH] = univEqEq univΔ₂ [ρσ₂F]₀ (proj₂ ([Fₜ] ⊢Δ₂ [ρσ₂]) [ρσ₂′] (wkSubstSEq [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ≡ρσ′])) in irrelevanceEq″ (PE.sym (wk-subst F)) (PE.sym (wk-subst F)) PE.refl PE.refl [ρσ₂F]₀ ([F]′ [ρ₂] ⊢Δ₂) [σF≡σH]) (λ {ρ₂} {Δ₂} {a} [ρ₂] ⊢Δ₂ [a] → let [ρσ₂] = wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ₂F]₀ = proj₁ ([F]₀ ⊢Δ₂ [ρσ₂]) [σ∃FG] = proj₁ ([∃FG] ⊢Δ₁ [ρσ]) _ , ∃ᵣ F′ G′ D′ ⊢F′ ⊢G′ A≡A′ [F]′ [G]′ G-ext′ = extractMaybeEmb (∃-elim [σ∃FG]) ⊢ρσ₂F = escape [ρσ₂F]₀ [ρσ₂′] = wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ′] ⊢σH = escape (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂′])) univΔ₂ = proj₁ ([UF] ⊢Δ₂ [ρσ₂]) [a]′ = irrelevanceTerm′ (wk-subst F) PE.refl PE.refl (wk [ρ₂] ⊢Δ₂ [σF]₀) (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂])) [a] [a]″ = convTerm₁ (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂])) (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂′])) (proj₂ ([F]₀ ⊢Δ₂ [ρσ₂]) [ρσ₂′] (wkSubstSEq [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ≡ρσ′])) [a]′ [ρσa≡ρσ′a] = consSubstSEq {t = a} {A = F} [Γ] ⊢Δ₂ (wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ]) (wkSubstSEq [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ≡ρσ′]) [F]₀ [a]′ in irrelevanceEq″ (PE.sym (singleSubstWkComp a (ρ •ₛ σ) G)) (PE.sym (singleSubstWkComp a (ρ •ₛ σ′) G)) PE.refl PE.refl (proj₁ (GappGen {F = F} {G = G} {σ = _} [Γ] [F]₀ [G]₀ ⊢Δ₁ [ρσ] a [ρ₂] ⊢Δ₂ [a]′)) (Gapp {F = F} {G = G} {σ = _} [Γ] [F]₀ [G]₀ ⊢Δ₁ [ρσ] a [ρ₂] ⊢Δ₂ [a]′) (proj₂ (GappGen {F = F} {G = G} {σ = _} [Γ] [F]₀ [G]₀ ⊢Δ₁ [ρσ] a [ρ₂] ⊢Δ₂ [a]′) ([ρσ₂′] , [a]″) [ρσa≡ρσ′a] )) in irrelevanceEq″ (PE.sym (wk-subst (∃ F ▹ G))) (PE.sym (wk-subst (∃ F ▹ G))) PE.refl PE.refl (proj₁ ([∃FG] ⊢Δ₁ [ρσ])) (LogRel._⊩¹U_∷_^_/_.[t] [∃FG]ᵗ [ρ] ⊢Δ₁) X)) -- Validity of ∃-congurence as a term equality. ∃-congᵗᵛ : ∀ {F G H E l∃ Γ} ([Γ] : ⊩ᵛ Γ) → let l = ∞ [UF] = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) [U∃] = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) in ([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ % , ι l∃ ] / [Γ]) ([H] : Γ ⊩ᵛ⟨ l ⟩ H ^ [ % , ι l∃ ] / [Γ]) ([UG] : Γ ∙ F ^ [ % , ι l∃ ] ⊩ᵛ⟨ l ⟩ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] ∙ [F]) ([UE] : Γ ∙ H ^ [ % , ι l∃ ] ⊩ᵛ⟨ l ⟩ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] ∙ [H]) ([F]ₜ : Γ ⊩ᵛ⟨ l ⟩ F ∷ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] / [UF]) ([G]ₜ : Γ ∙ F ^ [ % , ι l∃ ] ⊩ᵛ⟨ l ⟩ G ∷ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] ∙ [F] / (λ {Δ} {σ} → [UG] {Δ} {σ})) ([H]ₜ : Γ ⊩ᵛ⟨ l ⟩ H ∷ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] / [UF]) ([E]ₜ : Γ ∙ H ^ [ % , ι l∃ ] ⊩ᵛ⟨ l ⟩ E ∷ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] ∙ [H] / (λ {Δ} {σ} → [UE] {Δ} {σ})) ([F≡H]ₜ : Γ ⊩ᵛ⟨ l ⟩ F ≡ H ∷ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] / [UF]) ([G≡E]ₜ : Γ ∙ F ^ [ % , ι l∃ ] ⊩ᵛ⟨ l ⟩ G ≡ E ∷ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] ∙ [F] / (λ {Δ} {σ} → [UG] {Δ} {σ})) → Γ ⊩ᵛ⟨ l ⟩ ∃ F ▹ G ≡ ∃ H ▹ E ∷ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] / [U∃] ∃-congᵗᵛ {F} {G} {H} {E} {l∃ = ¹} {Γ} [Γ] [F] [H] [UG] [UE] [F]ₜ [G]ₜ [H]ₜ [E]ₜ [F≡H]ₜ [G≡E]ₜ {Δ} {σ} ⊢Δ [σ] = let l = ∞ l∃ = ¹ l∃≤ = ≡is≤ PE.refl [UF] = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) [∃FG]ᵗ = ∃ᵗᵛ₁ {F} {G} {l∃ = ¹} {Γ} [Γ] [F] (λ {Δ} {σ} → [UG] {Δ} {σ}) [F]ₜ [G]ₜ {Δ = Δ} {σ = σ} ⊢Δ [σ] [∃HE]ᵗ = ∃ᵗᵛ₁ {H} {E} {l∃ = ¹} {Γ} [Γ] [H] (λ {Δ} {σ} → [UE] {Δ} {σ}) [H]ₜ [E]ₜ {Δ = Δ} {σ = σ} ⊢Δ [σ] ⊢F = escape (proj₁ ([F] ⊢Δ [σ])) [liftσ] = liftSubstS {F = F} [Γ] ⊢Δ [F] [σ] univΔ = proj₁ ([UF] ⊢Δ [σ]) [G] = maybeEmbᵛ {A = G} (_∙_ {A = F} [Γ] [F]) (univᵛ {G} (_∙_ {A = F} [Γ] [F]) l∃≤ (λ {Δ} {σ} → [UG] {Δ} {σ}) [G]ₜ) [E] = maybeEmbᵛ {A = E} (_∙_ {A = H} [Γ] [H]) (univᵛ {E} (_∙_ {A = H} [Γ] [H]) l∃≤ (λ {Δ} {σ} → [UE] {Δ} {σ}) [E]ₜ) [F≡H] = univEqᵛ {F} {H} [Γ] [UF] [F] [F≡H]ₜ [G≡E] = univEqᵛ {G} {E} (_∙_ {A = F} [Γ] [F]) (λ {Δ} {σ} → [UG] {Δ} {σ}) [G] [G≡E]ₜ in Uₜ₌ [∃FG]ᵗ [∃HE]ᵗ (≅ₜ-∃-cong ⊢F (escapeTermEq univΔ ([F≡H]ₜ ⊢Δ [σ])) (escapeTermEq (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ])) ([G≡E]ₜ (⊢Δ ∙ ⊢F) [liftσ]))) λ {ρ} {Δ₁} [ρ] ⊢Δ₁ → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] X = ∃-congᵛ {F} {G} {H} {E} {Γ} {¹} [Γ] [F] [G] [H] [E] [F≡H] [G≡E] ⊢Δ₁ [ρσ] in irrelevanceEq″ (PE.sym (wk-subst (∃ F ▹ G))) (PE.sym (wk-subst (∃ H ▹ E))) PE.refl PE.refl (proj₁ (∃ᵛ {F} {G} [Γ] [F] [G] ⊢Δ₁ [ρσ])) (LogRel._⊩¹U_∷_^_/_.[t] [∃FG]ᵗ [ρ] ⊢Δ₁) X ∃-congᵗᵛ {F} {G} {H} {E} {l∃ = ⁰} {Γ} [Γ] [F] [H] [UG] [UE] [F]ₜ [G]ₜ [H]ₜ [E]ₜ [F≡H]ₜ [G≡E]ₜ {Δ} {σ} ⊢Δ [σ] = let l = ∞ l∃ = ⁰ l∃≤ = ≡is≤ PE.refl [UF] = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) [∃FG]ᵗ = ∃ᵗᵛ₁ {F} {G} {l∃ = ⁰} {Γ} [Γ] [F] (λ {Δ} {σ} → [UG] {Δ} {σ}) [F]ₜ [G]ₜ {Δ = Δ} {σ = σ} ⊢Δ [σ] [∃HE]ᵗ = ∃ᵗᵛ₁ {H} {E} {l∃ = ⁰} {Γ} [Γ] [H] (λ {Δ} {σ} → [UE] {Δ} {σ}) [H]ₜ [E]ₜ {Δ = Δ} {σ = σ} ⊢Δ [σ] ⊢F = escape (proj₁ ([F] ⊢Δ [σ])) [liftσ] = liftSubstS {F = F} [Γ] ⊢Δ [F] [σ] univΔ = proj₁ ([UF] ⊢Δ [σ]) [Fₜ]σ {σ′} [σ′] = [F]ₜ {σ = σ′} ⊢Δ [σ′] [σF] = proj₁ ([Fₜ]σ [σ]) [G] = maybeEmbᵛ {A = G} (_∙_ {A = F} [Γ] [F]) (univᵛ {G} (_∙_ {A = F} [Γ] [F]) l∃≤ (λ {Δ} {σ} → [UG] {Δ} {σ}) [G]ₜ) [E] = maybeEmbᵛ {A = E} (_∙_ {A = H} [Γ] [H]) (univᵛ {E} (_∙_ {A = H} [Γ] [H]) l∃≤ (λ {Δ} {σ} → [UE] {Δ} {σ}) [E]ₜ) [F≡H] = univEqᵛ {F} {H} [Γ] [UF] [F] [F≡H]ₜ [G≡E] = univEqᵛ {G} {E} (_∙_ {A = F} [Γ] [F]) (λ {Δ} {σ} → [UG] {Δ} {σ}) [G] [G≡E]ₜ in Uₜ₌ [∃FG]ᵗ [∃HE]ᵗ (≅ₜ-∃-cong ⊢F (escapeTermEq univΔ ([F≡H]ₜ ⊢Δ [σ])) (escapeTermEq (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ])) ([G≡E]ₜ (⊢Δ ∙ ⊢F) [liftσ]))) λ {ρ} {Δ₁} [ρ] ⊢Δ₁ → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] X = ∃-congᵛ {F} {G} {H} {E} {Γ} {⁰} [Γ] [F] [G] [H] [E] [F≡H] [G≡E] ⊢Δ₁ [ρσ] in irrelevanceEq″ (PE.sym (wk-subst (∃ F ▹ G))) (PE.sym (wk-subst (∃ H ▹ E))) PE.refl PE.refl (proj₁ (∃ᵛ {F} {G} [Γ] [F] [G] ⊢Δ₁ [ρσ])) (LogRel._⊩¹U_∷_^_/_.[t] [∃FG]ᵗ [ρ] ⊢Δ₁) X -- Validity of non-dependent sum types. ××ᵛ : ∀ {F G l∃ Γ l} ([Γ] : ⊩ᵛ Γ) ([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ % , ι l∃ ] / [Γ]) → Γ ⊩ᵛ⟨ l ⟩ G ^ [ % , ι l∃ ] / [Γ] → Γ ⊩ᵛ⟨ l ⟩ F ×× G ^ [ % , ι l∃ ] / [Γ] ××ᵛ {F} {G} [Γ] [F] [G] = ∃ᵛ {F} {wk1 G} [Γ] [F] (wk1ᵛ {G} {F} [Γ] [F] [G]) -- Validity of non-dependent sum type congurence. ××-congᵛ : ∀ {F F′ G G′ l∃ Γ l} ([Γ] : ⊩ᵛ Γ) ([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ % , ι l∃ ] / [Γ]) ([F′] : Γ ⊩ᵛ⟨ l ⟩ F′ ^ [ % , ι l∃ ] / [Γ]) ([F≡F′] : Γ ⊩ᵛ⟨ l ⟩ F ≡ F′ ^ [ % , ι l∃ ] / [Γ] / [F]) ([G] : Γ ⊩ᵛ⟨ l ⟩ G ^ [ % , ι l∃ ] / [Γ]) ([G′] : Γ ⊩ᵛ⟨ l ⟩ G′ ^ [ % , ι l∃ ] / [Γ]) ([G≡G′] : Γ ⊩ᵛ⟨ l ⟩ G ≡ G′ ^ [ % , ι l∃ ] / [Γ] / [G]) → Γ ⊩ᵛ⟨ l ⟩ F ×× G ≡ F′ ×× G′ ^ [ % , ι l∃ ] / [Γ] / ××ᵛ {F} {G} [Γ] [F] [G] ××-congᵛ {F} {F′} {G} {G′} [Γ] [F] [F′] [F≡F′] [G] [G′] [G≡G′] = ∃-congᵛ {F} {wk1 G} {F′} {wk1 G′} [Γ] [F] (wk1ᵛ {G} {F} [Γ] [F] [G]) [F′] (wk1ᵛ {G′} {F′} [Γ] [F′] [G′]) [F≡F′] (wk1Eqᵛ {G} {G′} {F} [Γ] [F] [G] [G≡G′]) ××ᵗᵛ : ∀ {F G l∃ Γ} ([Γ] : ⊩ᵛ Γ)→ let l = ∞ [U] = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) in ([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ % , ι l∃ ] / [Γ]) → Γ ⊩ᵛ⟨ l ⟩ F ∷ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] / [U] → Γ ⊩ᵛ⟨ l ⟩ G ∷ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] / (λ {Δ} {σ} → [U] {Δ} {σ}) → Γ ⊩ᵛ⟨ l ⟩ F ×× G ∷ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] / [U] ××ᵗᵛ {F} {G} {l∃} [Γ] [F] [Fₜ] [Gₜ] = let l = ∞ [U] = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) [Gₜ]′ = wk1ᵗᵛ {F} {G} {[ % , ι l∃ ]} {%} {l∃} [Γ] [F] [Gₜ] [wU] = maybeEmbᵛ {A = Univ % _} (_∙_ {A = F} [Γ] [F]) (λ {Δ} {σ} → Uᵛ (proj₂ (levelBounded l∃)) (_∙_ {A = F} [Γ] [F]) {Δ} {σ}) [wU]′ = wk1ᵛ {Univ _ _ } {F} [Γ] [F] [U] in ∃ᵗᵛ {F} {wk1 G} [Γ] [F] (λ {Δ} {σ} → [wU]′ {Δ} {σ}) [Fₜ] (S.irrelevanceTerm {A = Univ _ _} {t = wk1 G} (_∙_ {A = F} [Γ] [F]) (_∙_ {A = F} [Γ] [F]) (λ {Δ} {σ} → [wU] {Δ} {σ}) (λ {Δ} {σ} → [wU]′ {Δ} {σ}) [Gₜ]′)
{ "alphanum_fraction": 0.2869458128, "avg_line_length": 73.7196261682, "ext": "agda", "hexsha": "fb852e6594492522f654757ce237c74aca6f7a52", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Sigma.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Sigma.agda", "max_line_length": 186, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Sigma.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z", "max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z", "num_tokens": 23786, "size": 55216 }
module ElaborateGive where open import Agda.Builtin.List open import Agda.Builtin.Nat open import Agda.Builtin.Reflection open import Agda.Builtin.String open import Agda.Builtin.Unit five : Nat five = {!!} five' : Nat five' = {!!} five'' : Nat five'' = {!!} macro addUnknown : Term → TC ⊤ addUnknown goal = unify goal (def (quote _+_) (arg (arg-info visible relevant) unknown ∷ arg (arg-info visible relevant) unknown ∷ [])) unknownPlus : Nat unknownPlus = {!!} + {!!} macro literalNat : Nat → Term → TC ⊤ literalNat n hole = unify hole (lit (nat n)) macro literalString : String → Term → TC ⊤ literalString s hole = unify hole (lit (string s)) seven : Nat seven = {!!} seven' : Nat seven' = {!!} hello : String hello = {!!} hello' : String hello' = {!!} hi : String hi = {!!}
{ "alphanum_fraction": 0.5891647856, "avg_line_length": 17.3725490196, "ext": "agda", "hexsha": "722d4b86cca08db0ab7e34dec6863982733886fb", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/ElaborateGive.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/ElaborateGive.agda", "max_line_length": 74, "max_stars_count": 2, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/ElaborateGive.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 243, "size": 886 }
module main where {- unsized Versions omitted in talk -} import interactiveProgramsAgdaUnsized import objectsInAgdaUnsized {- end unsized Versions omitted in talk -} import interactiveProgramsAgda import objectsInAgda {- Probably omit because of time -} import interfaceExtensionAndDelegation {- End Probably omit because of time -} {- Omit later parts about proofs -} import stateDependentObjects {- End Omit later parts about proofs -} import stateDependentIO import drawingProgram import objectOrientedGui import spaceShipSimpleVar import spaceShipCell import spaceShipAdvanced
{ "alphanum_fraction": 0.8151260504, "avg_line_length": 18.0303030303, "ext": "agda", "hexsha": "5758da81a50989bcd18048f8ad90c4e1808e530d", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/main.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/main.agda", "max_line_length": 42, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/main.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 137, "size": 595 }
{- The subset "goodness" of can w.r.t. other ρθ-reductions. For each of the 7 non-merge ρθ-reductions, there are two corresponding Can subset lemmas. The lemmas for shared variables and sequential variables are merged together, using term-raise and term-nothing to capture the relevant esterel Terms (see Base for their definitions): canₛ-raise : ∀ {E any/shr any/var r r' p} θ → term-raise any/shr any/var r' p → r ≐ E ⟦ r' ⟧e → ∀ S → Signal.unwrap S ∈ Canₛ (E ⟦ ρ (Θ SigMap.empty any/shr any/var) · p ⟧e) θ → Signal.unwrap S ∈ Canₛ r θ canₛ-term-nothin : ∀ {r' E r} θ θ' → Env.sig θ ≡ Env.sig θ' → term-nothin r' → r ≐ E ⟦ r' ⟧e → ∀ S → Signal.unwrap S ∈ Canₛ (E ⟦ nothin ⟧e) θ' → Signal.unwrap S ∈ Canₛ r θ -} module Esterel.Lang.CanFunction.NonMergePotentialRules where open import utility open import Esterel.Lang open import Esterel.Lang.CanFunction open import Esterel.Lang.CanFunction.Base open import Esterel.Lang.CanFunction.CanThetaContinuation open import Esterel.Lang.CanFunction.SetSigMonotonic open import Esterel.Lang.CanFunction.Plug open import Esterel.Context open import Esterel.Context.Properties open import Esterel.Environment as Env using (Env ; Θ ; _←_ ; Dom ; module SigMap ; module ShrMap ; module VarMap) open import Esterel.CompletionCode as Code using () renaming (CompletionCode to Code) open import Esterel.Variable.Signal as Signal using (Signal ; _ₛ) renaming (unwrap to _ˢ) open import Esterel.Variable.Shared as SharedVar using (SharedVar ; _ₛₕ) renaming (unwrap to _ˢʰ) open import Esterel.Variable.Sequential as SeqVar using (SeqVar ; _ᵥ) renaming (unwrap to _ᵛ) open import Data.Bool using (Bool ; true ; false ; if_then_else_) open import Data.Empty using (⊥ ; ⊥-elim) open import Data.List using (List ; [] ; _∷_ ; _++_ ; map) open import Data.List.Properties using (map-id ; map-compose ; map-cong) open import Data.List.Any using (Any ; any ; here ; there) open import Data.List.Any.Properties using (++⁻) renaming (++⁺ˡ to ++ˡ ; ++⁺ʳ to ++ʳ) open import Data.Nat using (ℕ ; zero ; suc ; _≟_ ; _+_ ; _∸_ ; _<_ ; _≤_ ; _<′_ ; _≤′_) open import Data.Nat.Properties.Simple using (+-comm ; +-assoc) open import Data.Nat.Properties -- using (n∸n≡0 ; +-∸-assoc ; m≢1+m+n ; z≤′n) open import Data.Maybe using (Maybe ; just ; nothing) open import Data.Product using (Σ ; Σ-syntax ; proj₁ ; proj₂ ; ∃ ; _,_ ; _,′_ ; _×_) open import Data.Sum using (_⊎_ ; inj₁ ; inj₂) open import Function using (_∘_ ; id ; _∋_) open import Relation.Nullary using (¬_ ; Dec ; yes ; no) open import Relation.Nullary.Decidable using (⌊_⌋) open import Relation.Binary.PropositionalEquality using (_≡_ ; _≢_ ; refl ; trans ; sym ; cong ; subst ; inspect ; [_] ; Reveal_·_is_ ; module ≡-Reasoning) open ListSet Data.Nat._≟_ using (set-subtract ; set-subtract-[] ; set-subtract-merge ; set-subtract-split ; set-remove ; set-remove-removed ; set-remove-mono-∈ ; set-remove-not-removed ; set-subtract-[a]≡set-remove) module LCode = ListSet Code._≟_ open _≤′_ open _≤_ open ≡-Reasoning using (begin_ ; _≡⟨_⟩_ ; _∎) open import Data.OrderedListMap Signal Signal.unwrap Signal.Status as SigM open import Data.OrderedListMap SharedVar SharedVar.unwrap (Σ SharedVar.Status (λ _ → ℕ)) as ShrM open import Data.OrderedListMap SeqVar SeqVar.unwrap ℕ as SeqM can-is-unknown-lemma : ∀ q θ S → ¬ (Env.isSig∈ S θ) → Can q θ ≡ Can q (θ ← [ S ↦ Signal.unknown ]) canθ'-is-unknown-lemma : ∀ sigs' S' q θ S → S ∉ proj₁ (Dom θ) → S ∉ map (_+_ S') (SigMap.keys sigs') → Canθ' sigs' S' (Can q) θ ≡ Canθ' sigs' S' (Can q ∘ (_← [ (S ₛ) ↦ Signal.unknown ])) θ canθ-is-unknown-lemma : ∀ sigs' S' q θ S → ¬ (Env.isSig∈ S θ) → Signal.unwrap S ∉ map (_+_ S') (SigMap.keys sigs') → Canθ sigs' S' q θ ≡ Canθ sigs' S' q (θ ← [ S ↦ Signal.unknown ]) canθ-is-unknown-lemma sigs' S' q θ S S∉Domθ S∉map-+-S'-sigs' rewrite unfold sigs' S' q θ | unfold sigs' S' q (θ ← [S]-env S) | canθ'-search-acc sigs' S' (Can q) θ (Signal.unwrap S) Signal.unknown S∉map-+-S'-sigs' = canθ'-is-unknown-lemma sigs' S' q θ (Signal.unwrap S) S∉Domθ S∉map-+-S'-sigs' can-is-unknown-lemma nothin θ S S∉Domθ = refl can-is-unknown-lemma pause θ S S∉Domθ = refl can-is-unknown-lemma (signl S' q) θ S S∉Domθ with Env.Sig∈ S ([S]-env S') ... | yes S∈Domθ' rewrite canθ-shadowing-irr (Env.sig ([S]-env S')) 0 q S Signal.unknown θ (subst (Signal.unwrap S ∈_) (sym (map-id (proj₁ (Dom ([S]-env S'))))) S∈Domθ') = refl ... | no S∉Domθ' rewrite canθ-is-unknown-lemma (Env.sig ([S]-env S')) 0 q θ S S∉Domθ (subst (Signal.unwrap S ∉_) (sym (map-id (proj₁ (Dom ([S]-env S'))))) S∉Domθ') = refl can-is-unknown-lemma (present S' ∣⇒ p ∣⇒ q) θ S S∉Domθ with S' Signal.≟ S can-is-unknown-lemma (present S' ∣⇒ p ∣⇒ q) θ S S∉Domθ | yes refl with Env.Sig∈ S' θ | Env.Sig∈ S' (θ ← [ S ↦ Signal.unknown ]) ... | no S'∉Domθ | yes S'∈Domθ←[S] rewrite Env.sig-stats-1map-right-← S Signal.unknown θ S'∈Domθ←[S] | can-is-unknown-lemma p θ S S∉Domθ | can-is-unknown-lemma q θ S S∉Domθ = refl ... | S'∈?Domθ | no S'∉Domθ←[S] = ⊥-elim (S'∉Domθ←[S] (Env.sig-∈-single-right-← S Signal.unknown θ)) ... | yes S'∈Domθ | S'∈?Domθ←[S] = ⊥-elim (S∉Domθ S'∈Domθ) can-is-unknown-lemma (present S' ∣⇒ p ∣⇒ q) θ S S∉Domθ | no S'≠S with Env.Sig∈ S' θ | Env.Sig∈ S' (θ ← [ S ↦ Signal.unknown ]) ... | no S'∉Domθ | yes S'∈Domθ←[S] = ⊥-elim (Data.Sum.[ S'∉Domθ , Env.sig-∉-single S' S Signal.unknown S'≠S ] (Env.sig-←⁻ {θ} {[ S ↦ Signal.unknown ]} S' S'∈Domθ←[S])) ... | yes S'∈Domθ | no S'∉Domθ←[S] = ⊥-elim (S'∉Domθ←[S] (Env.sig-←-monoˡ S' θ [ S ↦ Signal.unknown ] S'∈Domθ)) ... | no S'∉Domθ | no S'∉Domθ←[S] rewrite can-is-unknown-lemma p θ S S∉Domθ | can-is-unknown-lemma q θ S S∉Domθ = refl ... | yes S'∈Domθ | yes S'∈Domθ←[S] rewrite sym (Env.sig-←-∉-irr-stats' S' θ [ S ↦ Signal.unknown ] S'∈Domθ (Env.sig-∉-single S' S Signal.unknown S'≠S) S'∈Domθ←[S]) with Env.sig-stats {S'} θ S'∈Domθ ... | Signal.present rewrite can-is-unknown-lemma p θ S S∉Domθ = refl ... | Signal.absent rewrite can-is-unknown-lemma q θ S S∉Domθ = refl ... | Signal.unknown rewrite can-is-unknown-lemma p θ S S∉Domθ | can-is-unknown-lemma q θ S S∉Domθ = refl can-is-unknown-lemma (emit S') θ S S∉Domθ = refl can-is-unknown-lemma (p ∥ q) θ S S∉Domθ rewrite can-is-unknown-lemma p θ S S∉Domθ | can-is-unknown-lemma q θ S S∉Domθ = refl can-is-unknown-lemma (loop q) θ S S∉Domθ = can-is-unknown-lemma q θ S S∉Domθ can-is-unknown-lemma (loopˢ p q) θ S S∉Domθ = can-is-unknown-lemma p θ S S∉Domθ can-is-unknown-lemma (p >> q) θ S S∉Domθ with any (Code._≟_ Code.nothin) (Canₖ p θ) | any (Code._≟_ Code.nothin) (Canₖ p (θ ← [ S ↦ Signal.unknown ])) ... | yes nothin∈can-p-θ | yes nothin∈can-p-θ←[S] rewrite can-is-unknown-lemma p θ S S∉Domθ | can-is-unknown-lemma q θ S S∉Domθ = refl ... | no nothin∉can-p-θ | no nothin∉can-p-θ←[S] rewrite can-is-unknown-lemma p θ S S∉Domθ = refl ... | yes nothin∈can-p-θ | no nothin∉can-p-θ←[S] rewrite can-is-unknown-lemma p θ S S∉Domθ = ⊥-elim (nothin∉can-p-θ←[S] nothin∈can-p-θ) ... | no nothin∉can-p-θ | yes nothin∈can-p-θ←[S] rewrite can-is-unknown-lemma p θ S S∉Domθ = ⊥-elim (nothin∉can-p-θ nothin∈can-p-θ←[S]) can-is-unknown-lemma (suspend q S') θ S S∉Domθ = can-is-unknown-lemma q θ S S∉Domθ can-is-unknown-lemma (trap q) θ S S∉Domθ rewrite can-is-unknown-lemma q θ S S∉Domθ = refl can-is-unknown-lemma (exit n) θ S S∉Domθ = refl can-is-unknown-lemma (shared s ≔ e in: q) θ S S∉Domθ rewrite can-is-unknown-lemma q θ S S∉Domθ = refl can-is-unknown-lemma (s ⇐ e) θ S S∉Domθ = refl can-is-unknown-lemma (var x ≔ e in: q) θ S S∉Domθ rewrite can-is-unknown-lemma q θ S S∉Domθ = refl can-is-unknown-lemma (x ≔ e) θ S S∉Domθ = refl can-is-unknown-lemma (if x ∣⇒ p ∣⇒ q) θ S S∉Domθ rewrite can-is-unknown-lemma p θ S S∉Domθ | can-is-unknown-lemma q θ S S∉Domθ = refl can-is-unknown-lemma (ρ⟨ θ' , A ⟩· q) θ S S∉Domθ with Env.Sig∈ S θ' ... | yes S∈Domθ' rewrite canθ-shadowing-irr (Env.sig θ') 0 q S Signal.unknown θ (subst (Signal.unwrap S ∈_) (sym (map-id (proj₁ (Dom θ')))) S∈Domθ') = refl ... | no S∉Domθ' rewrite canθ-is-unknown-lemma (Env.sig θ') 0 q θ S S∉Domθ (subst (Signal.unwrap S ∉_) (sym (map-id (proj₁ (Dom θ')))) S∉Domθ') = refl canθ'-is-unknown-lemma [] S' q θ S S∉Domθ S∉map-+-S'-sigs' = can-is-unknown-lemma q θ (S ₛ) S∉Domθ canθ'-is-unknown-lemma (nothing ∷ sigs') S' q θ S S∉Domθ S∉map-+-S'-sigs' rewrite map-+-compose-suc S' (SigMap.keys sigs') = canθ'-is-unknown-lemma sigs' (suc S') q θ S S∉Domθ S∉map-+-S'-sigs' canθ'-is-unknown-lemma (just Signal.present ∷ sigs') S' q θ S S∉Domθ S∉map-+-S'-sigs' rewrite +-comm S' 0 | map-+-compose-suc S' (SigMap.keys sigs') = canθ'-is-unknown-lemma sigs' (suc S') q (θ ← [S]-env-present (S' ₛ)) S (Env.sig-↚⁻ {θ} {[S]-env-present (S' ₛ)} (S ₛ) S∉Domθ (Env.sig-∉-single (S ₛ) (S' ₛ) Signal.present (S∉map-+-S'-sigs' ∘ here ∘ cong Signal.unwrap))) (S∉map-+-S'-sigs' ∘ there) canθ'-is-unknown-lemma (just Signal.absent ∷ sigs') S' q θ S S∉Domθ S∉map-+-S'-sigs' rewrite +-comm S' 0 | map-+-compose-suc S' (SigMap.keys sigs') = canθ'-is-unknown-lemma sigs' (suc S') q (θ ← [S]-env-absent (S' ₛ)) S (Env.sig-↚⁻ {θ} {[S]-env-absent (S' ₛ)} (S ₛ) S∉Domθ (Env.sig-∉-single (S ₛ) (S' ₛ) Signal.absent (S∉map-+-S'-sigs' ∘ here ∘ cong Signal.unwrap))) (S∉map-+-S'-sigs' ∘ there) canθ'-is-unknown-lemma (just Signal.unknown ∷ sigs') S' q θ S S∉Domθ S∉map-+-S'-sigs' with any (_≟_ S') (proj₁ (Canθ' sigs' (suc S') (Can q) (θ ← [S]-env (S' ₛ)))) | any (_≟_ S') (proj₁ (Canθ' sigs' (suc S') (Can q ∘ (_← [ (S ₛ) ↦ Signal.unknown ])) (θ ← [S]-env (S' ₛ)))) ... | yes S∈canθ'-sigs'-can-q-θ←[S'] | yes S∈canθ'-sigs'-can-q←[S]-θ←[S'] rewrite +-comm S' 0 | map-+-compose-suc S' (SigMap.keys sigs') = canθ'-is-unknown-lemma sigs' (suc S') q (θ ← [S]-env (S' ₛ)) S (Env.sig-↚⁻ {θ} {[S]-env (S' ₛ)} (S ₛ) S∉Domθ (Env.sig-∉-single (S ₛ) (S' ₛ) Signal.unknown (S∉map-+-S'-sigs' ∘ here ∘ cong Signal.unwrap))) (S∉map-+-S'-sigs' ∘ there) ... | no S∉canθ'-sigs'-can-q-θ←[S'] | no S∉canθ'-sigs'-can-q←[S]-θ←[S'] rewrite +-comm S' 0 | map-+-compose-suc S' (SigMap.keys sigs') = canθ'-is-unknown-lemma sigs' (suc S') q (θ ← [S]-env-absent (S' ₛ)) S (Env.sig-↚⁻ {θ} {[S]-env-absent (S' ₛ)} (S ₛ) S∉Domθ (Env.sig-∉-single (S ₛ) (S' ₛ) Signal.absent (S∉map-+-S'-sigs' ∘ here ∘ cong Signal.unwrap))) (S∉map-+-S'-sigs' ∘ there) ... | yes S∈canθ'-sigs'-can-q-θ←[S'] | no S∉canθ'-sigs'-can-q←[S]-θ←[S'] rewrite +-comm S' 0 | map-+-compose-suc S' (SigMap.keys sigs') | canθ'-is-unknown-lemma sigs' (suc S') q (θ ← [S]-env (S' ₛ)) S (Env.sig-↚⁻ {θ} {[S]-env (S' ₛ)} (S ₛ) S∉Domθ (Env.sig-∉-single (S ₛ) (S' ₛ) Signal.unknown (S∉map-+-S'-sigs' ∘ here ∘ cong Signal.unwrap))) (S∉map-+-S'-sigs' ∘ there) = ⊥-elim (S∉canθ'-sigs'-can-q←[S]-θ←[S'] S∈canθ'-sigs'-can-q-θ←[S']) ... | no S∉canθ'-sigs'-can-q-θ←[S'] | yes S∈canθ'-sigs'-can-q←[S]-θ←[S'] rewrite +-comm S' 0 | map-+-compose-suc S' (SigMap.keys sigs') | canθ'-is-unknown-lemma sigs' (suc S') q (θ ← [S]-env (S' ₛ)) S (Env.sig-↚⁻ {θ} {[S]-env (S' ₛ)} (S ₛ) S∉Domθ (Env.sig-∉-single (S ₛ) (S' ₛ) Signal.unknown (S∉map-+-S'-sigs' ∘ here ∘ cong Signal.unwrap))) (S∉map-+-S'-sigs' ∘ there) = ⊥-elim (S∉canθ'-sigs'-can-q-θ←[S'] S∈canθ'-sigs'-can-q←[S]-θ←[S']) can-is-present-lemma : ∀ p q S θ S∈ E → Env.sig-stats {S} θ S∈ ≡ Signal.present → Can (E ⟦ present S ∣⇒ p ∣⇒ q ⟧e) θ ≡ Can (E ⟦ p ⟧e) θ can-is-present-lemma p q S θ S∈ [] θS≡present with Env.Sig∈ S θ ... | no S∉ = ⊥-elim (S∉ S∈) ... | yes S∈' rewrite Env.sig-stats-∈-irr {S} {θ} S∈ S∈' with Signal.present Signal.≟ₛₜ Env.sig-stats {S} θ S∈' ... | no θS≢present = ⊥-elim (θS≢present (sym θS≡present)) ... | yes θS≡present' = refl can-is-present-lemma p q S θ S∈ (epar₁ _ ∷ E) θS≡present rewrite can-is-present-lemma p q S θ S∈ E θS≡present = refl can-is-present-lemma p q S θ S∈ (epar₂ _ ∷ E) θS≡present rewrite can-is-present-lemma p q S θ S∈ E θS≡present = refl can-is-present-lemma p q S θ S∈ (eloopˢ _ ∷ E) θS≡present = can-is-present-lemma p q S θ S∈ E θS≡present can-is-present-lemma p q S θ S∈ (eseq _ ∷ E) θS≡present with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ present S ∣⇒ p ∣⇒ q ⟧e) θ) | any (Code._≟_ Code.nothin) (Canₖ (E ⟦ p ⟧e) θ) | can-is-present-lemma p q S θ S∈ E θS≡present ... | yes nothin∈can-E⟦present⟧ | yes nothin∈can-E⟦p⟧ | eq rewrite eq = refl ... | yes nothin∈can-E⟦present⟧ | no nothin∉can-E⟦p⟧ | eq rewrite eq = ⊥-elim (nothin∉can-E⟦p⟧ nothin∈can-E⟦present⟧) ... | no nothin∉can-E⟦present⟧ | yes nothin∈can-E⟦p⟧ | eq rewrite eq = ⊥-elim (nothin∉can-E⟦present⟧ nothin∈can-E⟦p⟧) ... | no nothin∉can-E⟦present⟧ | no nothin∉can-E⟦p⟧ | eq rewrite eq = refl can-is-present-lemma p q S θ S∈ (esuspend S' ∷ E) θS≡present rewrite can-is-present-lemma p q S θ S∈ E θS≡present = refl can-is-present-lemma p q S θ S∈ (etrap ∷ E) θS≡present rewrite can-is-present-lemma p q S θ S∈ E θS≡present = refl can-is-absent-lemma : ∀ p q S θ S∈ E → Env.sig-stats {S} θ S∈ ≡ Signal.absent → Can (E ⟦ present S ∣⇒ p ∣⇒ q ⟧e) θ ≡ Can (E ⟦ q ⟧e) θ can-is-absent-lemma p q S θ S∈ [] θS≡absent with Env.Sig∈ S θ ... | no S∉ = ⊥-elim (S∉ S∈) ... | yes S∈' rewrite Env.sig-stats-∈-irr {S} {θ} S∈ S∈' with Signal.present Signal.≟ₛₜ Env.sig-stats {S} θ S∈' ... | yes present≡θS = ((Signal.present ≡ Signal.absent → _) ∋ λ ()) (trans present≡θS θS≡absent) ... | no present≢θS with Signal.absent Signal.≟ₛₜ Env.sig-stats {S} θ S∈' ... | no absent≢θS = ⊥-elim (absent≢θS (sym θS≡absent)) ... | yes absent≡θS = refl can-is-absent-lemma p q S θ S∈ (epar₁ _ ∷ E) θS≡absent rewrite can-is-absent-lemma p q S θ S∈ E θS≡absent = refl can-is-absent-lemma p q S θ S∈ (epar₂ _ ∷ E) θS≡absent rewrite can-is-absent-lemma p q S θ S∈ E θS≡absent = refl can-is-absent-lemma p q S θ S∈ (eloopˢ _ ∷ E) θS≡absent = can-is-absent-lemma p q S θ S∈ E θS≡absent can-is-absent-lemma p q S θ S∈ (eseq _ ∷ E) θS≡absent with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ present S ∣⇒ p ∣⇒ q ⟧e) θ) | any (Code._≟_ Code.nothin) (Canₖ (E ⟦ q ⟧e) θ) | can-is-absent-lemma p q S θ S∈ E θS≡absent ... | yes nothin∈can-E⟦present⟧ | yes nothin∈can-E⟦p⟧ | eq rewrite eq = refl ... | yes nothin∈can-E⟦present⟧ | no nothin∉can-E⟦p⟧ | eq rewrite eq = ⊥-elim (nothin∉can-E⟦p⟧ nothin∈can-E⟦present⟧) ... | no nothin∉can-E⟦present⟧ | yes nothin∈can-E⟦p⟧ | eq rewrite eq = ⊥-elim (nothin∉can-E⟦present⟧ nothin∈can-E⟦p⟧) ... | no nothin∉can-E⟦present⟧ | no nothin∉can-E⟦p⟧ | eq rewrite eq = refl can-is-absent-lemma p q S θ S∈ (esuspend S' ∷ E) θS≡absent rewrite can-is-absent-lemma p q S θ S∈ E θS≡absent = refl can-is-absent-lemma p q S θ S∈ (etrap ∷ E) θS≡absent rewrite can-is-absent-lemma p q S θ S∈ E θS≡absent = refl can-is-present : ∀ {r p q S E} θ S∈ → r ≐ E ⟦ present S ∣⇒ p ∣⇒ q ⟧e → Env.sig-stats {S} θ S∈ ≡ Signal.present → Can r θ ≡ Can (E ⟦ p ⟧e) θ can-is-present {_} {p} {q} {S} {E} θ S∈ r≐E⟦present⟧ rewrite sym (unplug r≐E⟦present⟧) = can-is-present-lemma p q S θ S∈ E canθ-is-present-lemma : ∀ {r p q E} sigs S'' S θ → r ≐ E ⟦ present (S ₛ) ∣⇒ p ∣⇒ q ⟧e → (Σ[ S''≤S ∈ S'' ≤′ S ] ∃ λ S-S''∈sigs → SigMap.lookup {_} {(S ∸ S'')ₛ} sigs S-S''∈sigs ≡ Signal.present) ⊎ (Σ[ S<S'' ∈ S <′ S'' ] ∃ λ S∈Domθ → Env.sig-stats {S ₛ} θ S∈Domθ ≡ Signal.present) → Canθ sigs S'' r θ ≡ Canθ sigs S'' (E ⟦ p ⟧e) θ canθ-is-present-lemma [] S'' S θ r≐E⟦present⟧ (inj₁ (S''≤S , () , sigs⟨S-S''⟩≡present)) canθ-is-present-lemma [] S'' S θ r≐E⟦present⟧ (inj₂ (S<S'' , S∈Domθ , θS≡present)) = can-is-present θ S∈Domθ r≐E⟦present⟧ θS≡present canθ-is-present-lemma (nothing ∷ sigs) S'' .S'' θ r≐E⟦present⟧ (inj₁ (≤′-refl , S-S''∈sigs , sigs⟨S-S''⟩≡present)) rewrite n∸n≡0 S'' = ⊥-elim (n∉map-suc-n-+ 0 (SigMap.keys sigs) S-S''∈sigs) canθ-is-present-lemma (just Signal.present ∷ sigs) S'' .S'' θ r≐E⟦present⟧ (inj₁ (≤′-refl , S-S''∈sigs , sigs⟨S-S''⟩≡present)) = canθ-is-present-lemma sigs (suc S'') S'' (θ ← [S]-env-present (S'' ₛ)) r≐E⟦present⟧ (inj₂ (≤′-refl , S''∈Domθ←[S''] , trans (Env.sig-stats-←-right-irr' (S'' ₛ) θ ([S]-env-present (S'' ₛ)) S''∈[S''] S''∈Domθ←[S'']) (Env.sig-stats-1map' (S'' ₛ) Signal.present S''∈[S'']))) where S''∈[S''] = Env.sig-∈-single (S'' ₛ) Signal.present S''∈Domθ←[S''] = Env.sig-←-monoʳ (S'' ₛ) ([S]-env-present (S'' ₛ)) θ S''∈[S''] canθ-is-present-lemma (just Signal.absent ∷ sigs) S'' .S'' θ r≐E⟦present⟧(inj₁ (≤′-refl , S-S''∈sigs , sigs⟨S-S''⟩≡present)) rewrite n∸n≡0 S'' with sigs⟨S-S''⟩≡present ... | () canθ-is-present-lemma (just Signal.unknown ∷ sigs) S'' .S'' θ r≐E⟦present⟧ (inj₁ (≤′-refl , S-S''∈sigs , sigs⟨S-S''⟩≡present)) rewrite n∸n≡0 S'' with sigs⟨S-S''⟩≡present ... | () canθ-is-present-lemma (nothing ∷ sigs) S'' (suc S) θ r≐E⟦present⟧ (inj₁ (≤′-step S''≤S , S-S''∈sigs , sigs⟨S-S''⟩≡present)) rewrite +-∸-assoc 1 (≤′⇒≤ S''≤S) = canθ-is-present-lemma sigs (suc S'') (suc S) θ r≐E⟦present⟧ (inj₁ (s≤′s S''≤S , SigM.n∈S {S ∸ S''} {nothing} {sigs} S-S''∈sigs , sigs⟨S-S''⟩≡present)) canθ-is-present-lemma (just Signal.present ∷ sigs) S'' (suc S) θ r≐E⟦present⟧ (inj₁ (≤′-step S''≤S , S-S''∈sigs , sigs⟨S-S''⟩≡present)) rewrite +-∸-assoc 1 (≤′⇒≤ S''≤S) = canθ-is-present-lemma sigs (suc S'') (suc S) (θ ← ([S]-env-present (S'' ₛ))) r≐E⟦present⟧ (inj₁ (s≤′s S''≤S , SigM.n∈S {S ∸ S''} {just Signal.present} {sigs} S-S''∈sigs , sigs⟨S-S''⟩≡present)) canθ-is-present-lemma (just Signal.absent ∷ sigs) S'' (suc S) θ r≐E⟦present⟧ (inj₁ (≤′-step S''≤S , S-S''∈sigs , sigs⟨S-S''⟩≡present)) rewrite +-∸-assoc 1 (≤′⇒≤ S''≤S) = canθ-is-present-lemma sigs (suc S'') (suc S) (θ ← ([S]-env-absent (S'' ₛ))) r≐E⟦present⟧ (inj₁ (s≤′s S''≤S , SigM.n∈S {S ∸ S''} {just Signal.absent} {sigs} S-S''∈sigs , sigs⟨S-S''⟩≡present)) canθ-is-present-lemma {r = r} {p} {E = E} (just Signal.unknown ∷ sigs) S'' (suc S) θ r≐E⟦present⟧ (inj₁ (≤′-step S''≤S , S-S''∈sigs , sigs⟨S-S''⟩≡present)) with any (_≟_ S'') (Canθₛ sigs (suc S'') (E ⟦ p ⟧e) (θ ← [S]-env (S'' ₛ))) | any (_≟_ S'') (Canθₛ sigs (suc S'') r (θ ← [S]-env (S'' ₛ))) ... | yes S''∈canθ-sig-E⟦p⟧-θ←[S''] | yes S''∈canθ-sig-r-θ←[S''] rewrite +-∸-assoc 1 (≤′⇒≤ S''≤S) = canθ-is-present-lemma sigs (suc S'') (suc S) (θ ← ([S]-env (S'' ₛ))) r≐E⟦present⟧ (inj₁ (s≤′s S''≤S , SigM.n∈S {S ∸ S''} {just Signal.unknown} {sigs} S-S''∈sigs , sigs⟨S-S''⟩≡present)) ... | no S''∉canθ-sig-E⟦p⟧-θ←[S''] | no S''∉canθ-sig-r-θ←[S''] rewrite +-∸-assoc 1 (≤′⇒≤ S''≤S) = canθ-is-present-lemma sigs (suc S'') (suc S) (θ ← ([S]-env-absent (S'' ₛ))) r≐E⟦present⟧ (inj₁ (s≤′s S''≤S , SigM.n∈S {S ∸ S''} {just Signal.unknown} {sigs} S-S''∈sigs , sigs⟨S-S''⟩≡present)) ... | yes S''∈canθ-sig-E⟦p⟧-θ←[S''] | no S''∉canθ-sig-r-θ←[S''] rewrite +-∸-assoc 1 (≤′⇒≤ S''≤S) | canθ-is-present-lemma sigs (suc S'') (suc S) (θ ← ([S]-env (S'' ₛ))) r≐E⟦present⟧ (inj₁ (s≤′s S''≤S , SigM.n∈S {S ∸ S''} {just Signal.unknown} {sigs} S-S''∈sigs , sigs⟨S-S''⟩≡present)) = ⊥-elim (S''∉canθ-sig-r-θ←[S''] S''∈canθ-sig-E⟦p⟧-θ←[S'']) ... | no S''∉canθ-sig-E⟦p⟧-θ←[S''] | yes S''∈canθ-sig-r-θ←[S''] rewrite +-∸-assoc 1 (≤′⇒≤ S''≤S) | canθ-is-present-lemma sigs (suc S'') (suc S) (θ ← ([S]-env (S'' ₛ))) r≐E⟦present⟧ (inj₁ (s≤′s S''≤S , SigM.n∈S {S ∸ S''} {just Signal.unknown} {sigs} S-S''∈sigs , sigs⟨S-S''⟩≡present)) = ⊥-elim (S''∉canθ-sig-E⟦p⟧-θ←[S''] S''∈canθ-sig-r-θ←[S'']) canθ-is-present-lemma (nothing ∷ sigs) S'' S θ r≐E⟦present⟧ (inj₂ (S<S'' , S∈Domθ , θS≡present)) = canθ-is-present-lemma sigs (suc S'') S θ r≐E⟦present⟧ (inj₂ (≤′-step S<S'' , S∈Domθ , θS≡present)) canθ-is-present-lemma (just Signal.present ∷ sigs) S'' S θ r≐E⟦present⟧ (inj₂ (S<S'' , S∈Domθ , θS≡present)) = canθ-is-present-lemma sigs (suc S'') S (θ ← [S]-env-present (S'' ₛ)) r≐E⟦present⟧ (inj₂ (≤′-step S<S'' , S∈Domθ←[S''] , trans (sym θS≡⟨θ←[S'']⟩S) θS≡present)) where S∈Domθ←[S''] = Env.sig-←-monoˡ (S ₛ) θ ([S]-env-present (S'' ₛ)) S∈Domθ θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' (S ₛ) θ ([S]-env-present (S'' ₛ)) S∈Domθ (Env.sig-∉-single (S ₛ) (S'' ₛ) Signal.present (<⇒≢ (≤′⇒≤ S<S'') ∘ cong Signal.unwrap)) S∈Domθ←[S''] canθ-is-present-lemma (just Signal.absent ∷ sigs) S'' S θ r≐E⟦present⟧ (inj₂ (S<S'' , S∈Domθ , θS≡present)) = canθ-is-present-lemma sigs (suc S'') S (θ ← [S]-env-absent (S'' ₛ)) r≐E⟦present⟧ (inj₂ (≤′-step S<S'' , S∈Domθ←[S''] , trans (sym θS≡⟨θ←[S'']⟩S) θS≡present)) where S∈Domθ←[S''] = Env.sig-←-monoˡ (S ₛ) θ ([S]-env-absent (S'' ₛ)) S∈Domθ θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' (S ₛ) θ ([S]-env-absent (S'' ₛ)) S∈Domθ (Env.sig-∉-single (S ₛ) (S'' ₛ) Signal.absent (<⇒≢ (≤′⇒≤ S<S'') ∘ cong Signal.unwrap)) S∈Domθ←[S''] canθ-is-present-lemma {r = r} {p} {E = E} (just Signal.unknown ∷ sigs) S'' S θ r≐E⟦present⟧ (inj₂ (S<S'' , S∈Domθ , θS≡present)) with any (_≟_ S'') (Canθₛ sigs (suc S'') (E ⟦ p ⟧e) (θ ← [S]-env (S'' ₛ))) | any (_≟_ S'') (Canθₛ sigs (suc S'') r (θ ← [S]-env (S'' ₛ))) ... | yes S''∈canθ-sig-E⟦p⟧-θ←[S''] | yes S''∈canθ-sig-r-θ←[S''] = canθ-is-present-lemma sigs (suc S'') S (θ ← [S]-env (S'' ₛ)) r≐E⟦present⟧ (inj₂ (≤′-step S<S'' , S∈Domθ←[S''] , trans (sym θS≡⟨θ←[S'']⟩S) θS≡present)) where S∈Domθ←[S''] = Env.sig-←-monoˡ (S ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' (S ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ (Env.sig-∉-single (S ₛ) (S'' ₛ) Signal.unknown (<⇒≢ (≤′⇒≤ S<S'') ∘ cong Signal.unwrap)) S∈Domθ←[S''] ... | no S''∉canθ-sig-E⟦p⟧-θ←[S''] | no S''∉canθ-sig-r-θ←[S''] = canθ-is-present-lemma sigs (suc S'') S (θ ← [S]-env-absent (S'' ₛ)) r≐E⟦present⟧ (inj₂ (≤′-step S<S'' , S∈Domθ←[S''] , trans (sym θS≡⟨θ←[S'']⟩S) θS≡present)) where S∈Domθ←[S''] = Env.sig-←-monoˡ (S ₛ) θ ([S]-env-absent (S'' ₛ)) S∈Domθ θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' (S ₛ) θ ([S]-env-absent (S'' ₛ)) S∈Domθ (Env.sig-∉-single (S ₛ) (S'' ₛ) Signal.absent (<⇒≢ (≤′⇒≤ S<S'') ∘ cong Signal.unwrap)) S∈Domθ←[S''] ... | yes S''∈canθ-sig-E⟦p⟧-θ←[S''] | no S''∉canθ-sig-r-θ←[S''] rewrite canθ-is-present-lemma sigs (suc S'') S (θ ← [S]-env (S'' ₛ)) r≐E⟦present⟧ (inj₂ (≤′-step S<S'' , Env.sig-←-monoˡ (S ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ , (trans (sym (Env.sig-←-∉-irr-stats' (S ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ (Env.sig-∉-single (S ₛ) (S'' ₛ) Signal.unknown (<⇒≢ (≤′⇒≤ S<S'') ∘ cong Signal.unwrap)) (Env.sig-←-monoˡ (S ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ))) θS≡present))) = ⊥-elim (S''∉canθ-sig-r-θ←[S''] S''∈canθ-sig-E⟦p⟧-θ←[S'']) ... | no S''∉canθ-sig-E⟦p⟧-θ←[S''] | yes S''∈canθ-sig-r-θ←[S''] rewrite canθ-is-present-lemma sigs (suc S'') S (θ ← [S]-env (S'' ₛ)) r≐E⟦present⟧ (inj₂ (≤′-step S<S'' , Env.sig-←-monoˡ (S ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ , (trans (sym (Env.sig-←-∉-irr-stats' (S ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ (Env.sig-∉-single (S ₛ) (S'' ₛ) Signal.unknown (<⇒≢ (≤′⇒≤ S<S'') ∘ cong Signal.unwrap)) (Env.sig-←-monoˡ (S ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ))) θS≡present))) = ⊥-elim (S''∉canθ-sig-E⟦p⟧-θ←[S''] S''∈canθ-sig-r-θ←[S'']) canθ-is-present : ∀ {S r p q E} sigs S∈ θ → -- perhaps θ is not needed at all r ≐ E ⟦ present S ∣⇒ p ∣⇒ q ⟧e → SigMap.lookup {_} {S} sigs S∈ ≡ Signal.present → Canθ sigs 0 r θ ≡ Canθ sigs 0 (E ⟦ p ⟧e) θ canθ-is-present {S ₛ} sigs S∈ θ r≐E⟦present⟧ sigs-S≡present = canθ-is-present-lemma sigs 0 S θ r≐E⟦present⟧ (inj₁ (z≤′n , S∈ , sigs-S≡present)) can-is-absent : ∀ {r p q S E} θ S∈ → r ≐ E ⟦ present S ∣⇒ p ∣⇒ q ⟧e → Env.sig-stats {S} θ S∈ ≡ Signal.absent → Can r θ ≡ Can (E ⟦ q ⟧e) θ can-is-absent {_} {p} {q} {S} {E} θ S∈ r≐E⟦present⟧ rewrite sym (unplug r≐E⟦present⟧) = can-is-absent-lemma p q S θ S∈ E canθ-is-absent-lemma : ∀ {r p q E} sigs S'' S θ → r ≐ E ⟦ present (S ₛ) ∣⇒ q ∣⇒ p ⟧e → (Σ[ S''≤S ∈ S'' ≤′ S ] ∃ λ S-S''∈sigs → SigMap.lookup {_} {(S ∸ S'')ₛ} sigs S-S''∈sigs ≡ Signal.absent) ⊎ (Σ[ S<S'' ∈ S <′ S'' ] ∃ λ S∈Domθ → Env.sig-stats {S ₛ} θ S∈Domθ ≡ Signal.absent) → Canθ sigs S'' r θ ≡ Canθ sigs S'' (E ⟦ p ⟧e) θ canθ-is-absent-lemma [] S'' S θ r≐E⟦present⟧ (inj₁ (S''≤S , () , sigs⟨S-S''⟩≡absent)) canθ-is-absent-lemma [] S'' S θ r≐E⟦present⟧ (inj₂ (S<S'' , S∈Domθ , θS≡absent)) = can-is-absent θ S∈Domθ r≐E⟦present⟧ θS≡absent canθ-is-absent-lemma (nothing ∷ sigs) S'' .S'' θ r≐E⟦present⟧ (inj₁ (≤′-refl , S-S''∈sigs , sigs⟨S-S''⟩≡absent)) rewrite n∸n≡0 S'' = ⊥-elim (n∉map-suc-n-+ 0 (SigMap.keys sigs) S-S''∈sigs) canθ-is-absent-lemma (just Signal.present ∷ sigs) S'' .S'' θ r≐E⟦present⟧(inj₁ (≤′-refl , S-S''∈sigs , sigs⟨S-S''⟩≡absent)) rewrite n∸n≡0 S'' with sigs⟨S-S''⟩≡absent ... | () canθ-is-absent-lemma (just Signal.absent ∷ sigs) S'' .S'' θ r≐E⟦present⟧ (inj₁ (≤′-refl , S-S''∈sigs , sigs⟨S-S''⟩≡absent)) = canθ-is-absent-lemma sigs (suc S'') S'' (θ ← [S]-env-absent (S'' ₛ)) r≐E⟦present⟧ (inj₂ (≤′-refl , S''∈Domθ←[S''] , trans (Env.sig-stats-←-right-irr' (S'' ₛ) θ ([S]-env-absent (S'' ₛ)) S''∈[S''] S''∈Domθ←[S'']) (Env.sig-stats-1map' (S'' ₛ) Signal.absent S''∈[S'']))) where S''∈[S''] = Env.sig-∈-single (S'' ₛ) Signal.absent S''∈Domθ←[S''] = Env.sig-←-monoʳ (S'' ₛ) ([S]-env-absent (S'' ₛ)) θ S''∈[S''] canθ-is-absent-lemma (just Signal.unknown ∷ sigs) S'' .S'' θ r≐E⟦present⟧ (inj₁ (≤′-refl , S-S''∈sigs , sigs⟨S-S''⟩≡absent)) rewrite n∸n≡0 S'' with sigs⟨S-S''⟩≡absent ... | () canθ-is-absent-lemma (nothing ∷ sigs) S'' (suc S) θ r≐E⟦present⟧ (inj₁ (≤′-step S''≤S , S-S''∈sigs , sigs⟨S-S''⟩≡absent)) rewrite +-∸-assoc 1 (≤′⇒≤ S''≤S) = canθ-is-absent-lemma sigs (suc S'') (suc S) θ r≐E⟦present⟧ (inj₁ (s≤′s S''≤S , SigM.n∈S {S ∸ S''} {nothing} {sigs} S-S''∈sigs , sigs⟨S-S''⟩≡absent)) canθ-is-absent-lemma (just Signal.present ∷ sigs) S'' (suc S) θ r≐E⟦present⟧ (inj₁ (≤′-step S''≤S , S-S''∈sigs , sigs⟨S-S''⟩≡absent)) rewrite +-∸-assoc 1 (≤′⇒≤ S''≤S) = canθ-is-absent-lemma sigs (suc S'') (suc S) (θ ← ([S]-env-present (S'' ₛ))) r≐E⟦present⟧ (inj₁ (s≤′s S''≤S , SigM.n∈S {S ∸ S''} {just Signal.present} {sigs} S-S''∈sigs , sigs⟨S-S''⟩≡absent)) canθ-is-absent-lemma (just Signal.absent ∷ sigs) S'' (suc S) θ r≐E⟦present⟧ (inj₁ (≤′-step S''≤S , S-S''∈sigs , sigs⟨S-S''⟩≡absent)) rewrite +-∸-assoc 1 (≤′⇒≤ S''≤S) = canθ-is-absent-lemma sigs (suc S'') (suc S) (θ ← ([S]-env-absent (S'' ₛ))) r≐E⟦present⟧ (inj₁ (s≤′s S''≤S , SigM.n∈S {S ∸ S''} {just Signal.absent} {sigs} S-S''∈sigs , sigs⟨S-S''⟩≡absent)) canθ-is-absent-lemma {r = r} {p} {E = E} (just Signal.unknown ∷ sigs) S'' (suc S) θ r≐E⟦present⟧ (inj₁ (≤′-step S''≤S , S-S''∈sigs , sigs⟨S-S''⟩≡absent)) with any (_≟_ S'') (Canθₛ sigs (suc S'') (E ⟦ p ⟧e) (θ ← [S]-env (S'' ₛ))) | any (_≟_ S'') (Canθₛ sigs (suc S'') r (θ ← [S]-env (S'' ₛ))) ... | yes S''∈canθ-sig-E⟦p⟧-θ←[S''] | yes S''∈canθ-sig-r-θ←[S''] rewrite +-∸-assoc 1 (≤′⇒≤ S''≤S) = canθ-is-absent-lemma sigs (suc S'') (suc S) (θ ← ([S]-env (S'' ₛ))) r≐E⟦present⟧ (inj₁ (s≤′s S''≤S , SigM.n∈S {S ∸ S''} {just Signal.unknown} {sigs} S-S''∈sigs , sigs⟨S-S''⟩≡absent)) ... | no S''∉canθ-sig-E⟦p⟧-θ←[S''] | no S''∉canθ-sig-r-θ←[S''] rewrite +-∸-assoc 1 (≤′⇒≤ S''≤S) = canθ-is-absent-lemma sigs (suc S'') (suc S) (θ ← ([S]-env-absent (S'' ₛ))) r≐E⟦present⟧ (inj₁ (s≤′s S''≤S , SigM.n∈S {S ∸ S''} {just Signal.unknown} {sigs} S-S''∈sigs , sigs⟨S-S''⟩≡absent)) ... | yes S''∈canθ-sig-E⟦p⟧-θ←[S''] | no S''∉canθ-sig-r-θ←[S''] rewrite +-∸-assoc 1 (≤′⇒≤ S''≤S) | canθ-is-absent-lemma sigs (suc S'') (suc S) (θ ← ([S]-env (S'' ₛ))) r≐E⟦present⟧ (inj₁ (s≤′s S''≤S , SigM.n∈S {S ∸ S''} {just Signal.unknown} {sigs} S-S''∈sigs , sigs⟨S-S''⟩≡absent)) = ⊥-elim (S''∉canθ-sig-r-θ←[S''] S''∈canθ-sig-E⟦p⟧-θ←[S'']) ... | no S''∉canθ-sig-E⟦p⟧-θ←[S''] | yes S''∈canθ-sig-r-θ←[S''] rewrite +-∸-assoc 1 (≤′⇒≤ S''≤S) | canθ-is-absent-lemma sigs (suc S'') (suc S) (θ ← ([S]-env (S'' ₛ))) r≐E⟦present⟧ (inj₁ (s≤′s S''≤S , SigM.n∈S {S ∸ S''} {just Signal.unknown} {sigs} S-S''∈sigs , sigs⟨S-S''⟩≡absent)) = ⊥-elim (S''∉canθ-sig-E⟦p⟧-θ←[S''] S''∈canθ-sig-r-θ←[S'']) canθ-is-absent-lemma (nothing ∷ sigs) S'' S θ r≐E⟦present⟧ (inj₂ (S<S'' , S∈Domθ , θS≡absent)) = canθ-is-absent-lemma sigs (suc S'') S θ r≐E⟦present⟧ (inj₂ (≤′-step S<S'' , S∈Domθ , θS≡absent)) canθ-is-absent-lemma (just Signal.present ∷ sigs) S'' S θ r≐E⟦present⟧ (inj₂ (S<S'' , S∈Domθ , θS≡absent)) = canθ-is-absent-lemma sigs (suc S'') S (θ ← [S]-env-present (S'' ₛ)) r≐E⟦present⟧ (inj₂ (≤′-step S<S'' , S∈Domθ←[S''] , trans (sym θS≡⟨θ←[S'']⟩S) θS≡absent)) where S∈Domθ←[S''] = Env.sig-←-monoˡ (S ₛ) θ ([S]-env-present (S'' ₛ)) S∈Domθ θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' (S ₛ) θ ([S]-env-present (S'' ₛ)) S∈Domθ (Env.sig-∉-single (S ₛ) (S'' ₛ) Signal.present (<⇒≢ (≤′⇒≤ S<S'') ∘ cong Signal.unwrap)) S∈Domθ←[S''] canθ-is-absent-lemma (just Signal.absent ∷ sigs) S'' S θ r≐E⟦present⟧ (inj₂ (S<S'' , S∈Domθ , θS≡absent)) = canθ-is-absent-lemma sigs (suc S'') S (θ ← [S]-env-absent (S'' ₛ)) r≐E⟦present⟧ (inj₂ (≤′-step S<S'' , S∈Domθ←[S''] , trans (sym θS≡⟨θ←[S'']⟩S) θS≡absent)) where S∈Domθ←[S''] = Env.sig-←-monoˡ (S ₛ) θ ([S]-env-absent (S'' ₛ)) S∈Domθ θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' (S ₛ) θ ([S]-env-absent (S'' ₛ)) S∈Domθ (Env.sig-∉-single (S ₛ) (S'' ₛ) Signal.absent (<⇒≢ (≤′⇒≤ S<S'') ∘ cong Signal.unwrap)) S∈Domθ←[S''] canθ-is-absent-lemma {r = r} {p} {E = E} (just Signal.unknown ∷ sigs) S'' S θ r≐E⟦present⟧ (inj₂ (S<S'' , S∈Domθ , θS≡absent)) with any (_≟_ S'') (Canθₛ sigs (suc S'') (E ⟦ p ⟧e) (θ ← [S]-env (S'' ₛ))) | any (_≟_ S'') (Canθₛ sigs (suc S'') r (θ ← [S]-env (S'' ₛ))) ... | yes S''∈canθ-sig-E⟦p⟧-θ←[S''] | yes S''∈canθ-sig-r-θ←[S''] = canθ-is-absent-lemma sigs (suc S'') S (θ ← [S]-env (S'' ₛ)) r≐E⟦present⟧ (inj₂ (≤′-step S<S'' , S∈Domθ←[S''] , trans (sym θS≡⟨θ←[S'']⟩S) θS≡absent)) where S∈Domθ←[S''] = Env.sig-←-monoˡ (S ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' (S ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ (Env.sig-∉-single (S ₛ) (S'' ₛ) Signal.unknown (<⇒≢ (≤′⇒≤ S<S'') ∘ cong Signal.unwrap)) S∈Domθ←[S''] ... | no S''∉canθ-sig-E⟦p⟧-θ←[S''] | no S''∉canθ-sig-r-θ←[S''] = canθ-is-absent-lemma sigs (suc S'') S (θ ← [S]-env-absent (S'' ₛ)) r≐E⟦present⟧ (inj₂ (≤′-step S<S'' , S∈Domθ←[S''] , trans (sym θS≡⟨θ←[S'']⟩S) θS≡absent)) where S∈Domθ←[S''] = Env.sig-←-monoˡ (S ₛ) θ ([S]-env-absent (S'' ₛ)) S∈Domθ θS≡⟨θ←[S'']⟩S = Env.sig-←-∉-irr-stats' (S ₛ) θ ([S]-env-absent (S'' ₛ)) S∈Domθ (Env.sig-∉-single (S ₛ) (S'' ₛ) Signal.absent (<⇒≢ (≤′⇒≤ S<S'') ∘ cong Signal.unwrap)) S∈Domθ←[S''] ... | yes S''∈canθ-sig-E⟦p⟧-θ←[S''] | no S''∉canθ-sig-r-θ←[S''] rewrite canθ-is-absent-lemma sigs (suc S'') S (θ ← [S]-env (S'' ₛ)) r≐E⟦present⟧ (inj₂ (≤′-step S<S'' , Env.sig-←-monoˡ (S ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ , (trans (sym (Env.sig-←-∉-irr-stats' (S ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ (Env.sig-∉-single (S ₛ) (S'' ₛ) Signal.unknown (<⇒≢ (≤′⇒≤ S<S'') ∘ cong Signal.unwrap)) (Env.sig-←-monoˡ (S ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ))) θS≡absent))) = ⊥-elim (S''∉canθ-sig-r-θ←[S''] S''∈canθ-sig-E⟦p⟧-θ←[S'']) ... | no S''∉canθ-sig-E⟦p⟧-θ←[S''] | yes S''∈canθ-sig-r-θ←[S''] rewrite canθ-is-absent-lemma sigs (suc S'') S (θ ← [S]-env (S'' ₛ)) r≐E⟦present⟧ (inj₂ (≤′-step S<S'' , Env.sig-←-monoˡ (S ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ , (trans (sym (Env.sig-←-∉-irr-stats' (S ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ (Env.sig-∉-single (S ₛ) (S'' ₛ) Signal.unknown (<⇒≢ (≤′⇒≤ S<S'') ∘ cong Signal.unwrap)) (Env.sig-←-monoˡ (S ₛ) θ ([S]-env (S'' ₛ)) S∈Domθ))) θS≡absent))) = ⊥-elim (S''∉canθ-sig-E⟦p⟧-θ←[S''] S''∈canθ-sig-r-θ←[S'']) canθ-is-absent : ∀ {S r p q E} sigs S∈ θ → r ≐ E ⟦ present S ∣⇒ q ∣⇒ p ⟧e → SigMap.lookup {_} {S} sigs S∈ ≡ Signal.absent → Canθ sigs 0 r θ ≡ Canθ sigs 0 (E ⟦ p ⟧e) θ canθ-is-absent {S ₛ} sigs S∈ θ r≐E⟦present⟧ sigs-S≡absent = canθ-is-absent-lemma sigs 0 S θ r≐E⟦present⟧ (inj₁ (z≤′n , S∈ , sigs-S≡absent)) canₛₕ-emit-lemma : ∀ S θ E → ∀ s → s ∈ Canₛₕ (E ⟦ nothin ⟧e) θ → s ∈ Canₛₕ (E ⟦ emit S ⟧e) θ canₛₕ-emit-lemma S θ [] s s∈can-E⟦nothin⟧ = s∈can-E⟦nothin⟧ canₛₕ-emit-lemma S θ (epar₁ q ∷ E) s s∈can-E∥q⟦nothin⟧ with ++⁻ (Canₛₕ (E ⟦ nothin ⟧e) θ) s∈can-E∥q⟦nothin⟧ ... | inj₁ s∈can-E⟦nothin⟧ = ++ˡ (canₛₕ-emit-lemma S θ E s s∈can-E⟦nothin⟧) ... | inj₂ s∈can-q = ++ʳ (Canₛₕ (E ⟦ emit S ⟧e) θ) s∈can-q canₛₕ-emit-lemma S θ (epar₂ p ∷ E) s s∈can-p∥E⟦nothin⟧ with ++⁻ (Canₛₕ p θ) s∈can-p∥E⟦nothin⟧ ... | inj₁ s∈can-p = ++ˡ s∈can-p ... | inj₂ s∈can-E⟦nothin⟧ = ++ʳ (Canₛₕ p θ) (canₛₕ-emit-lemma S θ E s s∈can-E⟦nothin⟧) canₛₕ-emit-lemma S θ (eloopˢ q ∷ E) s s∈can-E⟦nothin⟧ = canₛₕ-emit-lemma S θ E s s∈can-E⟦nothin⟧ canₛₕ-emit-lemma S θ (eseq q ∷ E) s s∈can-E⟦nothin⟧ with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ emit S ⟧e) θ) | any (Code._≟_ Code.nothin) (Canₖ (E ⟦ nothin ⟧e) θ) ... | yes nothin∈can-E⟦emit⟧ | no nothin∉can-E⟦nothin⟧ = ⊥-elim (nothin∉can-E⟦nothin⟧ (canₖ-term-nothin-lemma θ E (temit S) tnothin Code.nothin nothin∈can-E⟦emit⟧)) ... | no nothin∉can-E⟦emit⟧ | yes nothin∈can-E⟦nothin⟧ = ⊥-elim (nothin∉can-E⟦emit⟧ (canₖ-term-nothin-lemma θ E tnothin (temit S) Code.nothin nothin∈can-E⟦nothin⟧)) ... | no nothin∉can-E⟦emit⟧ | no nothin∉can-E⟦nothin⟧ = canₛₕ-emit-lemma S θ E s s∈can-E⟦nothin⟧ ... | yes nothin∈can-E⟦emit⟧ | yes nothin∈can-E⟦nothin⟧ with ++⁻ (Canₛₕ (E ⟦ nothin ⟧e) θ) s∈can-E⟦nothin⟧ ... | inj₁ s∈can-E⟦nothin⟧-θ = ++ˡ (canₛₕ-emit-lemma S θ E s s∈can-E⟦nothin⟧-θ) ... | inj₂ s∈can-q-θ = ++ʳ (Canₛₕ (E ⟦ emit S ⟧e) θ) s∈can-q-θ canₛₕ-emit-lemma S θ (esuspend S' ∷ E) s s∈can-E⟦nothin⟧ = canₛₕ-emit-lemma S θ E s s∈can-E⟦nothin⟧ canₛₕ-emit-lemma S θ (etrap ∷ E) s s∈can-E⟦nothin⟧ = canₛₕ-emit-lemma S θ E s s∈can-E⟦nothin⟧ canₛₕ-emit : ∀ {S r E} θ S∈ → r ≐ E ⟦ emit S ⟧e → ¬ (Env.sig-stats {S} θ S∈ ≡ Signal.absent) → ∀ s → SharedVar.unwrap s ∈ Canₛₕ (E ⟦ nothin ⟧e) (Env.set-sig {S} θ S∈ Signal.present) → SharedVar.unwrap s ∈ Canₛₕ r θ canₛₕ-emit {S} {r} {E} θ S∈ r≐E⟦emitS⟧ θS≢absent s s∈can-E⟦nothin⟧-θ' rewrite sym (unplug r≐E⟦emitS⟧) with Env.sig-stats {S} θ S∈ | inspect (Env.sig-stats {S} θ) S∈ ... | Signal.present | [ θS≡present ] rewrite (sym θS≡present) | sym (SigMap.getput-m S (Env.sig θ) S∈) = canₛₕ-emit-lemma S θ E (SharedVar.unwrap s) s∈can-E⟦nothin⟧-θ' ... | Signal.absent | [ θS≡absent ] = ⊥-elim (θS≢absent refl) ... | Signal.unknown | [ θS≡unknown ] = canₛₕ-emit-lemma S θ E (SharedVar.unwrap s) (canₛₕ-set-sig-monotonic (E ⟦ nothin ⟧e) S θ S∈ Signal.present θS≡unknown (SharedVar.unwrap s) s∈can-E⟦nothin⟧-θ') canₛ-emit-lemma : ∀ S θ E → ∀ S'' → S'' ∈ Canₛ (E ⟦ nothin ⟧e) θ → S'' ∈ Canₛ (E ⟦ emit S ⟧e) θ canₛ-emit-lemma S θ [] S'' () canₛ-emit-lemma S θ (epar₁ q ∷ E) S'' S''∈can-E∥q⟦nothin⟧ with ++⁻ (Canₛ (E ⟦ nothin ⟧e) θ) S''∈can-E∥q⟦nothin⟧ ... | inj₁ S''∈can-E⟦nothin⟧ = ++ˡ (canₛ-emit-lemma S θ E S'' S''∈can-E⟦nothin⟧) ... | inj₂ S''∈can-q = ++ʳ (Canₛ (E ⟦ emit S ⟧e) θ) S''∈can-q canₛ-emit-lemma S θ (epar₂ p ∷ E) S'' S''∈can-p∥E⟦nothin⟧ with ++⁻ (Canₛ p θ) S''∈can-p∥E⟦nothin⟧ ... | inj₁ S''∈can-p = ++ˡ S''∈can-p ... | inj₂ S''∈can-E⟦nothin⟧ = ++ʳ (Canₛ p θ) (canₛ-emit-lemma S θ E S'' S''∈can-E⟦nothin⟧) canₛ-emit-lemma S θ (eloopˢ q ∷ E) S'' S''∈can-E⟦nothin⟧ = canₛ-emit-lemma S θ E S'' S''∈can-E⟦nothin⟧ canₛ-emit-lemma S θ (eseq q ∷ E) S'' S''∈can-E⟦nothin⟧ with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ emit S ⟧e) θ) | any (Code._≟_ Code.nothin) (Canₖ (E ⟦ nothin ⟧e) θ) ... | yes nothin∈can-E⟦emit⟧ | no nothin∉can-E⟦nothin⟧ = ⊥-elim (nothin∉can-E⟦nothin⟧ (canₖ-term-nothin-lemma θ E (temit S) tnothin Code.nothin nothin∈can-E⟦emit⟧)) ... | no nothin∉can-E⟦emit⟧ | yes nothin∈can-E⟦nothin⟧ = ⊥-elim (nothin∉can-E⟦emit⟧ (canₖ-term-nothin-lemma θ E tnothin (temit S) Code.nothin nothin∈can-E⟦nothin⟧)) ... | no nothin∉can-E⟦emit⟧ | no nothin∉can-E⟦nothin⟧ = canₛ-emit-lemma S θ E S'' S''∈can-E⟦nothin⟧ ... | yes nothin∈can-E⟦emit⟧ | yes nothin∈can-E⟦nothin⟧ with ++⁻ (Canₛ (E ⟦ nothin ⟧e) θ) S''∈can-E⟦nothin⟧ ... | inj₁ S''∈can-E⟦nothin⟧-θ = ++ˡ (canₛ-emit-lemma S θ E S'' S''∈can-E⟦nothin⟧-θ) ... | inj₂ S''∈can-q-θ = ++ʳ (Canₛ (E ⟦ emit S ⟧e) θ) S''∈can-q-θ canₛ-emit-lemma S θ (esuspend S' ∷ E) S'' S''∈can-E⟦nothin⟧ = canₛ-emit-lemma S θ E S'' S''∈can-E⟦nothin⟧ canₛ-emit-lemma S θ (etrap ∷ E) S'' S''∈can-E⟦nothin⟧ = canₛ-emit-lemma S θ E S'' S''∈can-E⟦nothin⟧ canₛ-emit : ∀ {S r E} θ S∈ → r ≐ E ⟦ emit S ⟧e → ¬ (Env.sig-stats {S} θ S∈ ≡ Signal.absent) → ∀ S'' → Signal.unwrap S'' ∈ Canₛ (E ⟦ nothin ⟧e) (Env.set-sig {S} θ S∈ Signal.present) → Signal.unwrap S'' ∈ Canₛ r θ canₛ-emit {S} {r} {E} θ S∈ r≐E⟦emitS⟧ θS≢absent S'' S''∈can-E⟦nothin⟧-θ' rewrite sym (unplug r≐E⟦emitS⟧) with Env.sig-stats {S} θ S∈ | inspect (Env.sig-stats {S} θ) S∈ ... | Signal.present | [ θS≡present ] rewrite (sym θS≡present) | sym (SigMap.getput-m S (Env.sig θ) S∈) = canₛ-emit-lemma S θ E (Signal.unwrap S'') S''∈can-E⟦nothin⟧-θ' ... | Signal.absent | [ θS≡absent ] = ⊥-elim (θS≢absent refl) ... | Signal.unknown | [ θS≡unknown ] = canₛ-emit-lemma S θ E (Signal.unwrap S'') (canₛ-set-sig-monotonic (E ⟦ nothin ⟧e) S θ S∈ Signal.present θS≡unknown (Signal.unwrap S'') S''∈can-E⟦nothin⟧-θ') canθₛ-emit-lemma : ∀ sigs S'' p θ S S∈ → (S'' + S) ∈ Canθₛ sigs S'' p θ → SigMap.lookup {_} {S ₛ} sigs S∈ ≡ Signal.unknown → ∀ S' → S' ∈ Canθₛ (SigMap.update sigs (S ₛ) Signal.present) S'' p θ → S' ∈ Canθₛ sigs S'' p θ canθₖ-emit-lemma : ∀ sigs S'' p θ S S∈ → (S'' + S) ∈ Canθₛ sigs S'' p θ → SigMap.lookup {_} {S ₛ} sigs S∈ ≡ Signal.unknown → ∀ k → k ∈ Canθₖ (SigMap.update sigs (S ₛ) Signal.present) S'' p θ → k ∈ Canθₖ sigs S'' p θ canθₖ-emit-lemma [] S'' p θ S () S''+S∈canθ-sigs-p-θ lk==u k k∈ canθₖ-emit-lemma (nothing ∷ sigs) S'' p θ zero S∈ S''+S∈canθ-sigs-p-θ lk==u k k∈ = ⊥-elim (SigM.0∈S S∈) canθₖ-emit-lemma (just Signal.present ∷ sigs) S'' p θ zero S∈ S''+S∈canθ-sigs-p-θ () k k∈ canθₖ-emit-lemma (just Signal.absent ∷ sigs) S'' p θ zero S∈ S''+S∈canθ-sigs-p-θ () k k∈ canθₖ-emit-lemma (just Signal.unknown ∷ sigs) S'' p θ zero S∈ S''+S∈canθ-sigs-p-θ lk==u k k∈ with any (_≟_ S'') (Canθₛ sigs (suc S'') p (θ ← [S]-env (S'' ₛ))) ... | yes is∈ = canθₖ-add-sig-monotonic sigs (suc S'') p θ (S'' ₛ) Signal.present k k∈ ... | no ¬is∈ rewrite +-comm S'' 0 = ⊥-elim (¬is∈ (canθₛ-add-sig-monotonic sigs (suc S'') p θ (S'' ₛ) Signal.absent S'' S''+S∈canθ-sigs-p-θ)) canθₖ-emit-lemma (nothing ∷ sigs) S'' p θ (suc S) S∈ S''+S∈canθ-sigs-p-θ lk==u k k∈ rewrite +-comm S'' (suc S) | +-comm S S'' = canθₖ-emit-lemma sigs (suc S'') p θ S (SigM.n∈S {S} {nothing} {sigs} S∈) S''+S∈canθ-sigs-p-θ lk==u k k∈ canθₖ-emit-lemma (just Signal.present ∷ sigs) S'' p θ (suc S) S∈ S''+S∈canθ-sigs-p-θ lk==u k k∈ rewrite +-comm S'' (suc S) | +-comm S S'' = canθₖ-emit-lemma sigs (suc S'') p (θ ← [S]-env-present (S'' ₛ)) S (SigM.n∈S {S} {just Signal.present} {sigs} S∈) S''+S∈canθ-sigs-p-θ lk==u k k∈ canθₖ-emit-lemma (just Signal.absent ∷ sigs) S'' p θ (suc S) S∈ S''+S∈canθ-sigs-p-θ lk==u k k∈ rewrite +-comm S'' (suc S) | +-comm S S'' = canθₖ-emit-lemma sigs (suc S'') p (θ ← [S]-env-absent (S'' ₛ)) S (SigM.n∈S {S} {just Signal.absent} {sigs} S∈) S''+S∈canθ-sigs-p-θ lk==u k k∈ canθₖ-emit-lemma (just Signal.unknown ∷ sigs) S'' p θ (suc S) S∈ S''+S∈canθ-sigs-p-θ lk==u k k∈ with any (_≟_ S'') (Canθₛ sigs (suc S'') p (θ ← [S]-env (S'' ₛ))) | any (_≟_ S'') (Canθₛ (SigMap.update sigs (S ₛ) Signal.present) (suc S'') p (θ ← [S]-env (S'' ₛ))) ... | yes S''∈canθ-sigs-p-θ←[S''] | yes S''∈canθ-θ'-p-θ←[S''] rewrite +-comm S'' (suc S) | +-comm S S'' = canθₖ-emit-lemma sigs (suc S'') p (θ ← [S]-env (S'' ₛ)) S (SigM.n∈S {S} {just Signal.unknown} {sigs} S∈) S''+S∈canθ-sigs-p-θ lk==u k k∈ ... | no S''∉canθ-sigs-p-θ←[S''] | no S''∉canθ-θ'-p-θ←[S''] rewrite +-comm S'' (suc S) | +-comm S S'' = canθₖ-emit-lemma sigs (suc S'') p (θ ← [S]-env-absent (S'' ₛ)) S (SigM.n∈S {S} {just Signal.unknown} {sigs} S∈) S''+S∈canθ-sigs-p-θ lk==u k k∈ ... | no S''∉canθ-sigs-p-θ←[S''] | yes S''∈canθ-θ'-p-θ←[S''] rewrite +-comm S'' (suc S) | +-comm S S'' = ⊥-elim (S''∉canθ-sigs-p-θ←[S''] (canθₛ-emit-lemma sigs (suc S'') p (θ ← [S]-env (S'' ₛ)) S (SigM.n∈S {S} {just Signal.unknown} {sigs} S∈) (canθₛ-add-sig-monotonic sigs (suc S'') p θ (S'' ₛ) Signal.absent (suc (S'' + S)) S''+S∈canθ-sigs-p-θ) lk==u S'' S''∈canθ-θ'-p-θ←[S''])) ... | yes S''∈canθ-sigs-p-θ←[S''] | no S''∉canθ-θ'-p-θ←[S''] rewrite +-comm S'' (suc S) | +-comm S S'' = canθₖ-emit-lemma sigs (suc S'') p (θ ← [S]-env (S'' ₛ)) S (SigM.n∈S {S} {just Signal.unknown} {sigs} S∈) S''+S∈canθ-sigs-p-θ lk==u k (canθₖ-add-sig-monotonic (SigM.m-insert (just Signal.present) S sigs) (suc S'') p θ (S'' ₛ) Signal.absent k k∈) canθₛ-emit-lemma [] S'' p θ S () S''+S∈canθ-sigs-p-θ sigs-S≡unknown S' S'∈canθ-θ'-p canθₛ-emit-lemma (nothing ∷ sigs) S'' p θ zero S∈ S''+S∈canθ-sigs-p-θ sigs-S≡unknown S' S'∈canθ-θ'-p = ⊥-elim (SigM.0∈S S∈) canθₛ-emit-lemma (nothing ∷ sigs) S'' p θ (suc S) S∈ S''+S∈canθ-sigs-p-θ sigs-S≡unknown S' S'∈canθ-θ'-p rewrite +-comm S'' (suc S) | +-comm S S'' = canθₛ-emit-lemma sigs (suc S'') p θ S (SigM.n∈S {S} {nothing} {sigs} S∈) S''+S∈canθ-sigs-p-θ sigs-S≡unknown S' S'∈canθ-θ'-p canθₛ-emit-lemma (just Signal.present ∷ sigs) S'' p θ 0 S∈ S''+S∈canθ-sigs-p-θ sigs-S≡unknown S' S'∈canθ-θ'-p with sigs-S≡unknown ... | () canθₛ-emit-lemma (just Signal.absent ∷ sigs) S'' p θ 0 S∈ S''+S∈canθ-sigs-p-θ sigs-S≡unknown S' S'∈canθ-θ'-p with sigs-S≡unknown ... | () canθₛ-emit-lemma (just Signal.unknown ∷ sigs) S'' p θ 0 S∈ S''+S∈canθ-sigs-p-θ sigs-S≡unknown S' S'∈canθ-θ'-p with any (_≟_ S'') (Canθₛ sigs (suc S'') p (θ ← [S]-env (S'' ₛ))) ... | no S''∉canθ-sigs-θ←[S''] rewrite +-comm S'' 0 = ⊥-elim (S''∉canθ-sigs-θ←[S''] (canθₛ-add-sig-monotonic sigs (suc S'') p θ (S'' ₛ) Signal.absent S'' S''+S∈canθ-sigs-p-θ)) ... | yes S''∈canθ-sigs-θ↽[S''] = canθₛ-add-sig-monotonic sigs (suc S'') p θ (S'' ₛ) Signal.present S' S'∈canθ-θ'-p canθₛ-emit-lemma (just Signal.present ∷ sigs) S'' p θ (suc S) S∈ S''+S∈canθ-sigs-p-θ sigs-S≡unknown S' S'∈canθ-θ'-p rewrite +-comm S'' (suc S) | +-comm S S'' = canθₛ-emit-lemma sigs (suc S'') p (θ ← [S]-env-present (S'' ₛ)) S (SigM.n∈S {S} {just Signal.present} {sigs} S∈) S''+S∈canθ-sigs-p-θ sigs-S≡unknown S' S'∈canθ-θ'-p canθₛ-emit-lemma (just Signal.absent ∷ sigs) S'' p θ (suc S) S∈ S''+S∈canθ-sigs-p-θ sigs-S≡unknown S' S'∈canθ-θ'-p rewrite +-comm S'' (suc S) | +-comm S S'' = canθₛ-emit-lemma sigs (suc S'') p (θ ← [S]-env-absent (S'' ₛ)) S (SigM.n∈S {S} {just Signal.absent} {sigs} S∈) S''+S∈canθ-sigs-p-θ sigs-S≡unknown S' S'∈canθ-θ'-p canθₛ-emit-lemma (just Signal.unknown ∷ sigs) S'' p θ (suc S) S∈ S''+S∈canθ-sigs-p-θ sigs-S≡unknown S' S'∈canθ-θ'-p with any (_≟_ S'') (Canθₛ sigs (suc S'') p (θ ← [S]-env (S'' ₛ))) | any (_≟_ S'') (Canθₛ (SigMap.update sigs (S ₛ) Signal.present) (suc S'') p (θ ← [S]-env (S'' ₛ))) ... | yes S''∈canθ-sigs-p-θ←[S''] | yes S''∈canθ-θ'-p-θ←[S''] rewrite +-comm S'' (suc S) | +-comm S S'' = canθₛ-emit-lemma sigs (suc S'') p (θ ← [S]-env (S'' ₛ)) S (SigM.n∈S {S} {just Signal.unknown} {sigs} S∈) S''+S∈canθ-sigs-p-θ sigs-S≡unknown S' S'∈canθ-θ'-p ... | no S''∉canθ-sigs-p-θ←[S''] | no S''∉canθ-θ'-p-θ←[S''] rewrite +-comm S'' (suc S) | +-comm S S'' = canθₛ-emit-lemma sigs (suc S'') p (θ ← [S]-env-absent (S'' ₛ)) S (SigM.n∈S {S} {just Signal.unknown} {sigs} S∈) S''+S∈canθ-sigs-p-θ sigs-S≡unknown S' S'∈canθ-θ'-p ... | no S''∉canθ-sigs-p-θ←[S''] | yes S''∈canθ-θ'-p-θ←[S''] rewrite +-comm S'' (suc S) | +-comm S S'' = ⊥-elim (S''∉canθ-sigs-p-θ←[S''] (canθₛ-emit-lemma sigs (suc S'') p (θ ← [S]-env (S'' ₛ)) S (SigM.n∈S {S} {just Signal.unknown} {sigs} S∈) (canθₛ-add-sig-monotonic sigs (suc S'') p θ (S'' ₛ) Signal.absent (suc (S'' + S)) S''+S∈canθ-sigs-p-θ) sigs-S≡unknown S'' S''∈canθ-θ'-p-θ←[S''])) ... | yes S''∈canθ-sigs-p-θ←[S''] | no S''∉canθ-θ'-p-θ←[S''] rewrite +-comm S'' (suc S) | +-comm S S'' = canθₛ-emit-lemma sigs (suc S'') p (θ ← [S]-env (S'' ₛ)) S (SigM.n∈S {S} {just Signal.unknown} {sigs} S∈) S''+S∈canθ-sigs-p-θ sigs-S≡unknown S' (canθₛ-add-sig-monotonic (SigM.m-insert (just Signal.present) S sigs) (suc S'') p θ (S'' ₛ) Signal.absent S' S'∈canθ-θ'-p) canθₛ-emit : ∀ {S r E} θ S∈ θ' → r ≐ E ⟦ emit S ⟧e → ¬ (Env.sig-stats {S} θ S∈ ≡ Signal.absent) → Signal.unwrap S ∈ Canθₛ (Env.sig θ) 0 r θ' → ∀ S'' → Signal.unwrap S'' ∈ Canθₛ (Env.sig (Env.set-sig {S} θ S∈ Signal.present)) 0 (E ⟦ nothin ⟧e) θ' → Signal.unwrap S'' ∈ Canθₛ (Env.sig θ) 0 r θ' canθₛ-emit {S} {r} {E} θ S∈ θ' r≐E⟦emitS⟧ θS≢absent S∈canθ-r S'' S''∈canθ-E⟦nothin⟧ rewrite sym (unplug r≐E⟦emitS⟧) with Env.sig-stats {S} θ S∈ | inspect (Env.sig-stats {S} θ) S∈ ... | Signal.present | [ θS≡present ] rewrite (sym θS≡present) | sym (SigMap.getput-m S (Env.sig θ) S∈) = canθₛ-subset-lemma (Env.sig θ) 0 (E ⟦ nothin ⟧e) (E ⟦ emit S ⟧e) θ' (λ θ* S* → canₛ-emit-lemma S θ* E S*) (Signal.unwrap S'') S''∈canθ-E⟦nothin⟧ ... | Signal.absent | [ θS≡absent ] = ⊥-elim (θS≢absent refl) ... | Signal.unknown | [ θS≡unknown ] = canθₛ-emit-lemma (Env.sig θ) 0 (E ⟦ emit S ⟧e) θ' (Signal.unwrap S) S∈ S∈canθ-r θS≡unknown (Signal.unwrap S'') (canθₛ-subset-lemma (Env.sig (Env.set-sig {S} θ S∈ Signal.present)) 0 (E ⟦ nothin ⟧e) (E ⟦ emit S ⟧e) θ' (λ θ* S* → canₛ-emit-lemma S θ* E S*) (Signal.unwrap S'') S''∈canθ-E⟦nothin⟧) canθₖ-emit : ∀ {S r E} θ S∈ θ' → r ≐ E ⟦ emit S ⟧e → ¬ (Env.sig-stats {S} θ S∈ ≡ Signal.absent) → Signal.unwrap S ∈ Canθₛ (Env.sig θ) 0 r θ' → ∀ k → k ∈ Canθₖ (Env.sig (Env.set-sig {S} θ S∈ Signal.present)) 0 (E ⟦ nothin ⟧e) θ' → k ∈ Canθₖ (Env.sig θ) 0 r θ' canθₖ-emit {S} {r} {E} θ S∈ θ' r≐E⟦emitS⟧ θS≢absent S∈canθ-r k k∈canθ'-E⟦nothin⟧ rewrite sym (unplug r≐E⟦emitS⟧) with Env.sig-stats {S} θ S∈ | inspect (Env.sig-stats {S} θ) S∈ ... | Signal.present | [ θS≡present ] rewrite (sym θS≡present) | sym (SigMap.getput-m S (Env.sig θ) S∈) = canθₖ-subset-lemma (Env.sig θ) 0 (E ⟦ nothin ⟧e) (E ⟦ emit S ⟧e) θ' (λ θ* S* → canₛ-emit-lemma S θ* E S*) (λ θ* S* → canₖ-term-nothin-lemma θ* E tnothin (temit S) S*) k k∈canθ'-E⟦nothin⟧ ... | Signal.absent | [ θS≡absent ] = ⊥-elim (θS≢absent refl) ... | Signal.unknown | [ θS≡unknown ] = canθₖ-emit-lemma (Env.sig θ) 0 (E ⟦ emit S ⟧e) θ' (Signal.unwrap S) S∈ S∈canθ-r θS≡unknown k (canθₖ-subset-lemma (Env.sig (Env.set-sig {S} θ S∈ Signal.present)) 0 (E ⟦ nothin ⟧e) (E ⟦ emit S ⟧e) θ' (λ θ* S* → canₛ-emit-lemma S θ* E S*) (λ θ* S* → canₖ-term-nothin-lemma θ* E tnothin (temit S) S*) k k∈canθ'-E⟦nothin⟧) canθₛₕ-emit-lemma : ∀ sigs S'' p θ S S∈ → (S'' + S) ∈ Canθₛ sigs S'' p θ → SigMap.lookup {_} {S ₛ} sigs S∈ ≡ Signal.unknown → ∀ s → s ∈ Canθₛₕ (SigMap.update sigs (S ₛ) Signal.present) S'' p θ → s ∈ Canθₛₕ sigs S'' p θ canθₛₕ-emit-lemma [] S'' p θ S () S''+S∈canθ-sigs-p-θ sigs-S≡unknown s s∈canθ-θ'-p canθₛₕ-emit-lemma (nothing ∷ sigs) S'' p θ zero S∈ S''+S∈canθ-sigs-p-θ sigs-S≡unknown s s∈canθ-θ'-p = ⊥-elim (SigM.0∈S S∈) canθₛₕ-emit-lemma (nothing ∷ sigs) S'' p θ (suc S) S∈ S''+S∈canθ-sigs-p-θ sigs-S≡unknown s s∈canθ-θ'-p rewrite +-comm S'' (suc S) | +-comm S S'' = canθₛₕ-emit-lemma sigs (suc S'') p θ S (SigM.n∈S {S} {nothing} {sigs} S∈) S''+S∈canθ-sigs-p-θ sigs-S≡unknown s s∈canθ-θ'-p canθₛₕ-emit-lemma (just Signal.present ∷ sigs) S'' p θ 0 S∈ S''+S∈canθ-sigs-p-θ sigs-S≡unknown s s∈canθ-θ'-p with sigs-S≡unknown ... | () canθₛₕ-emit-lemma (just Signal.absent ∷ sigs) S'' p θ 0 S∈ S''+S∈canθ-sigs-p-θ sigs-S≡unknown s s∈canθ-θ'-p with sigs-S≡unknown ... | () canθₛₕ-emit-lemma (just Signal.unknown ∷ sigs) S'' p θ 0 S∈ S''+S∈canθ-sigs-p-θ sigs-S≡unknown s s∈canθ-θ'-p with any (_≟_ S'') (Canθₛ sigs (suc S'') p (θ ← [S]-env (S'' ₛ))) ... | no S''∉canθ-sigs-θ←[S''] rewrite +-comm S'' 0 = ⊥-elim (S''∉canθ-sigs-θ←[S''] (canθₛ-add-sig-monotonic sigs (suc S'') p θ (S'' ₛ) Signal.absent S'' S''+S∈canθ-sigs-p-θ)) ... | yes S''∈canθ-sigs-θ↽[S''] = canθₛₕ-add-sig-monotonic sigs (suc S'') p θ (S'' ₛ) Signal.present s s∈canθ-θ'-p canθₛₕ-emit-lemma (just Signal.present ∷ sigs) S'' p θ (suc S) S∈ S''+S∈canθ-sigs-p-θ sigs-S≡unknown s s∈canθ-θ'-p rewrite +-comm S'' (suc S) | +-comm S S'' = canθₛₕ-emit-lemma sigs (suc S'') p (θ ← [S]-env-present (S'' ₛ)) S (SigM.n∈S {S} {just Signal.present} {sigs} S∈) S''+S∈canθ-sigs-p-θ sigs-S≡unknown s s∈canθ-θ'-p canθₛₕ-emit-lemma (just Signal.absent ∷ sigs) S'' p θ (suc S) S∈ S''+S∈canθ-sigs-p-θ sigs-S≡unknown s s∈canθ-θ'-p rewrite +-comm S'' (suc S) | +-comm S S'' = canθₛₕ-emit-lemma sigs (suc S'') p (θ ← [S]-env-absent (S'' ₛ)) S (SigM.n∈S {S} {just Signal.absent} {sigs} S∈) S''+S∈canθ-sigs-p-θ sigs-S≡unknown s s∈canθ-θ'-p canθₛₕ-emit-lemma (just Signal.unknown ∷ sigs) S'' p θ (suc S) S∈ S''+S∈canθ-sigs-p-θ sigs-S≡unknown s s∈canθ-θ'-p with any (_≟_ S'') (Canθₛ sigs (suc S'') p (θ ← [S]-env (S'' ₛ))) | any (_≟_ S'') (Canθₛ (SigMap.update sigs (S ₛ) Signal.present) (suc S'') p (θ ← [S]-env (S'' ₛ))) ... | yes S''∈canθ-sigs-p-θ←[S''] | yes S''∈canθ-θ'-p-θ←[S''] rewrite +-comm S'' (suc S) | +-comm S S'' = canθₛₕ-emit-lemma sigs (suc S'') p (θ ← [S]-env (S'' ₛ)) S (SigM.n∈S {S} {just Signal.unknown} {sigs} S∈) S''+S∈canθ-sigs-p-θ sigs-S≡unknown s s∈canθ-θ'-p ... | no S''∉canθ-sigs-p-θ←[S''] | no S''∉canθ-θ'-p-θ←[S''] rewrite +-comm S'' (suc S) | +-comm S S'' = canθₛₕ-emit-lemma sigs (suc S'') p (θ ← [S]-env-absent (S'' ₛ)) S (SigM.n∈S {S} {just Signal.unknown} {sigs} S∈) S''+S∈canθ-sigs-p-θ sigs-S≡unknown s s∈canθ-θ'-p ... | no S''∉canθ-sigs-p-θ←[S''] | yes S''∈canθ-θ'-p-θ←[S''] rewrite +-comm S'' (suc S) | +-comm S S'' = ⊥-elim (S''∉canθ-sigs-p-θ←[S''] (canθₛ-emit-lemma sigs (suc S'') p (θ ← [S]-env (S'' ₛ)) S (SigM.n∈S {S} {just Signal.unknown} {sigs} S∈) (canθₛ-add-sig-monotonic sigs (suc S'') p θ (S'' ₛ) Signal.absent (suc (S'' + S)) S''+S∈canθ-sigs-p-θ) sigs-S≡unknown S'' S''∈canθ-θ'-p-θ←[S''])) ... | yes S''∈canθ-sigs-p-θ←[S''] | no S''∉canθ-θ'-p-θ←[S''] rewrite +-comm S'' (suc S) | +-comm S S'' = canθₛₕ-emit-lemma sigs (suc S'') p (θ ← [S]-env (S'' ₛ)) S (SigM.n∈S {S} {just Signal.unknown} {sigs} S∈) S''+S∈canθ-sigs-p-θ sigs-S≡unknown s (canθₛₕ-add-sig-monotonic (SigM.m-insert (just Signal.present) S sigs) (suc S'') p θ (S'' ₛ) Signal.absent s s∈canθ-θ'-p) canθₛₕ-emit : ∀ {S r E} θ S∈ θ' → r ≐ E ⟦ emit S ⟧e → ¬ (Env.sig-stats {S} θ S∈ ≡ Signal.absent) → Signal.unwrap S ∈ Canθₛ (Env.sig θ) 0 r θ' → ∀ s → SharedVar.unwrap s ∈ Canθₛₕ (Env.sig (Env.set-sig {S} θ S∈ Signal.present)) 0 (E ⟦ nothin ⟧e) θ' → SharedVar.unwrap s ∈ Canθₛₕ (Env.sig θ) 0 r θ' canθₛₕ-emit {S} {r} {E} θ S∈ θ' r≐E⟦emitS⟧ θS≢absent S∈canθ-r s s∈canθ'-E⟦nothin⟧ rewrite sym (unplug r≐E⟦emitS⟧) with Env.sig-stats {S} θ S∈ | inspect (Env.sig-stats {S} θ) S∈ ... | Signal.present | [ θS≡present ] rewrite (sym θS≡present) | sym (SigMap.getput-m S (Env.sig θ) S∈) = canθₛₕ-subset-lemma (Env.sig θ) 0 (E ⟦ nothin ⟧e) (E ⟦ emit S ⟧e) θ' (λ θ* S* → canₛ-emit-lemma S θ* E S*) (λ θ* s* → canₛₕ-emit-lemma S θ* E s*) (SharedVar.unwrap s) s∈canθ'-E⟦nothin⟧ ... | Signal.absent | [ θS≡absent ] = ⊥-elim (θS≢absent refl) ... | Signal.unknown | [ θS≡unknown ] = canθₛₕ-emit-lemma (Env.sig θ) 0 (E ⟦ emit S ⟧e) θ' (Signal.unwrap S) S∈ S∈canθ-r θS≡unknown (SharedVar.unwrap s) (canθₛₕ-subset-lemma (Env.sig (Env.set-sig {S} θ S∈ Signal.present)) 0 (E ⟦ nothin ⟧e) (E ⟦ emit S ⟧e) θ' (λ θ* S* → canₛ-emit-lemma S θ* E S*) (λ θ* s* → canₛₕ-emit-lemma S θ* E s*) (SharedVar.unwrap s) s∈canθ'-E⟦nothin⟧) canₖ-raise-lemma : ∀ {any/shr any/var r p A} θ E → term-raise any/shr any/var r p → Canₖ (E ⟦ r ⟧e) θ ≡ Canₖ (E ⟦ ρ⟨ (Θ SigMap.empty any/shr any/var) , A ⟩· p ⟧e) θ canₖ-raise-lemma {any/shr} {any/var} {r} {p} θ [] (tshared n s e .p) rewrite can-shr-var-irr p θ (θ ← Θ SigMap.empty any/shr any/var) (SigMap.union-comm {_} SigMap.empty (Env.sig θ) (λ _ ())) | set-subtract-[] (Canₛ p (θ ← Θ SigMap.empty any/shr any/var)) = refl canₖ-raise-lemma {any/shr} {any/var} {r} {p} θ [] (tvar n x e .p) rewrite can-shr-var-irr p θ (θ ← Θ SigMap.empty any/shr any/var) (SigMap.union-comm {_} SigMap.empty (Env.sig θ) (λ _ ())) | set-subtract-[] (Canₛ p (θ ← Θ SigMap.empty any/shr any/var)) = refl canₖ-raise-lemma θ (epar₁ q ∷ E) tr rewrite canₖ-raise-lemma θ E tr = refl canₖ-raise-lemma θ (epar₂ p ∷ E) tr rewrite canₖ-raise-lemma θ E tr = refl canₖ-raise-lemma {any/shr} {any/var} {r} {p} θ (eloopˢ q ∷ E) tr = canₖ-raise-lemma θ E tr canₖ-raise-lemma {any/shr} {any/var} {r} {p} {A} θ (eseq q ∷ E) tr with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ r ⟧e) θ) | any (Code._≟_ Code.nothin) (Canₖ (E ⟦ ρ⟨ (Θ SigMap.empty any/shr any/var) , A ⟩· p ⟧e) θ) ... | no nothin∉can-E⟦r⟧ | no nothin∉can-E⟦ρΘp⟧ = canₖ-raise-lemma θ E tr ... | yes nothin∈can-E⟦r⟧ | no nothin∉can-E⟦ρΘp⟧ rewrite canₖ-raise-lemma {any/shr} {any/var} {A = A} θ E tr = ⊥-elim (nothin∉can-E⟦ρΘp⟧ nothin∈can-E⟦r⟧) ... | no nothin∉can-E⟦r⟧ | yes nothin∈can-E⟦ρΘp⟧ rewrite canₖ-raise-lemma {any/shr} {any/var} {A = A} θ E tr = ⊥-elim (nothin∉can-E⟦r⟧ nothin∈can-E⟦ρΘp⟧) ... | yes nothin∈can-E⟦r⟧ | yes nothin∈can-E⟦ρΘp⟧ rewrite canₖ-raise-lemma θ E tr = refl canₖ-raise-lemma θ (esuspend S ∷ E) tr = canₖ-raise-lemma θ E tr canₖ-raise-lemma θ (etrap ∷ E) tr rewrite canₖ-raise-lemma θ E tr = refl canₛ-raise-lemma : ∀ {any/shr any/var r p A} θ E → term-raise any/shr any/var r p → Canₛ (E ⟦ ρ⟨ (Θ SigMap.empty any/shr any/var) , A ⟩· p ⟧e) θ ≡ Canₛ (E ⟦ r ⟧e) θ canₛ-raise-lemma {any/shr} {any/var} {r} {p} θ [] (tshared n s e .p) rewrite set-subtract-[] (Canₛ p θ) = refl canₛ-raise-lemma {any/shr} {any/var} {r} {p} θ [] (tvar n x e .p) rewrite set-subtract-[] (Canₛ p θ) = refl canₛ-raise-lemma {any/shr} {any/var} {r} {p} {A = A} θ (epar₁ q ∷ E) tr rewrite canₛ-raise-lemma {any/shr} {any/var} {r} {p} {A = A} θ E tr = refl canₛ-raise-lemma {A = A} θ (epar₂ p ∷ E) tr rewrite canₛ-raise-lemma {A = A} θ E tr = refl canₛ-raise-lemma {any/shr} {any/var} {r} {p} θ (eloopˢ q ∷ E) tr = canₛ-raise-lemma θ E tr canₛ-raise-lemma {any/shr} {any/var} {r} {p} {A} θ (eseq q ∷ E) tr with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ r ⟧e) θ) | any (Code._≟_ Code.nothin) (Canₖ (E ⟦ ρ⟨ (Θ SigMap.empty any/shr any/var) , A ⟩· p ⟧e) θ) ... | no nothin∉can-E⟦r⟧ | no nothin∉can-E⟦ρΘp⟧ = canₛ-raise-lemma θ E tr ... | yes nothin∈can-E⟦r⟧ | no nothin∉can-E⟦ρΘp⟧ rewrite canₖ-raise-lemma {any/shr} {any/var} {A = A} θ E tr = ⊥-elim (nothin∉can-E⟦ρΘp⟧ nothin∈can-E⟦r⟧) ... | no nothin∉can-E⟦r⟧ | yes nothin∈can-E⟦ρΘp⟧ rewrite canₖ-raise-lemma {any/shr} {any/var} {A = A} θ E tr = ⊥-elim (nothin∉can-E⟦r⟧ nothin∈can-E⟦ρΘp⟧) ... | yes nothin∈can-E⟦r⟧ | yes nothin∈can-E⟦ρΘp⟧ rewrite canₛ-raise-lemma {A = A} θ E tr = refl canₛ-raise-lemma θ (esuspend S' ∷ E) tr = canₛ-raise-lemma θ E tr canₛ-raise-lemma θ (etrap ∷ E) tr = canₛ-raise-lemma θ E tr canθₛ-raise-lemma : ∀ {any/shr any/var r p A} sigs S' θ E → term-raise any/shr any/var r p → Canθₛ sigs S' (E ⟦ r ⟧e) θ ≡ Canθₛ sigs S' (E ⟦ ρ⟨ (Θ SigMap.empty any/shr any/var) , A ⟩· p ⟧e) θ canθₛ-raise-lemma [] S' θ E tr = sym (canₛ-raise-lemma θ E tr) canθₛ-raise-lemma (nothing ∷ sigs) S' = canθₛ-raise-lemma sigs (suc S') canθₛ-raise-lemma (just Signal.present ∷ sigs) S' θ = canθₛ-raise-lemma sigs (suc S') (θ ← _) canθₛ-raise-lemma (just Signal.absent ∷ sigs) S' θ = canθₛ-raise-lemma sigs (suc S') (θ ← _) canθₛ-raise-lemma {any/shr} {any/var} {r} {p} {A} (just Signal.unknown ∷ sigs) S' θ E tr with any (_≟_ S') (Canθₛ sigs (suc S') (E ⟦ r ⟧e) (θ ← ([S]-env (S' ₛ)))) | any (_≟_ S') (Canθₛ sigs (suc S') (E ⟦ ρ⟨ (Θ SigMap.empty any/shr any/var) , A ⟩· p ⟧e) (θ ← ([S]-env (S' ₛ)))) ... | yes S'∈CanE⟦r⟧ | yes S'∈CanE⟦ρ⟧ = canθₛ-raise-lemma sigs (suc S') (θ ← _) E tr ... | no S'∉CanE⟦r⟧ | no S'∉CanE⟦ρ⟧ = canθₛ-raise-lemma sigs (suc S') (θ ← _) E tr ... | yes S'∈CanE⟦r⟧ | no S'∉CanE⟦ρ⟧ rewrite (canθₛ-raise-lemma {A = A} sigs (suc S') (θ ← ([S]-env (S' ₛ))) E tr) = ⊥-elim (S'∉CanE⟦ρ⟧ S'∈CanE⟦r⟧) canθₛ-raise-lemma {any/shr} {any/var} {r} {p} {A = A} (just Signal.unknown ∷ sigs) S' θ E tr | no S'∉CanE⟦r⟧ | yes S'∈CanE⟦ρ⟧ rewrite (canθₛ-raise-lemma {A = A} sigs (suc S') (θ ← ([S]-env (S' ₛ))) E tr) = ⊥-elim (S'∉CanE⟦r⟧ S'∈CanE⟦ρ⟧) canθₖ-raise-lemma : ∀ {any/shr any/var r p A} sigs S' θ E → term-raise any/shr any/var r p → Canθₖ sigs S' (E ⟦ r ⟧e) θ ≡ Canθₖ sigs S' (E ⟦ ρ⟨ (Θ SigMap.empty any/shr any/var) , A ⟩· p ⟧e) θ canθₖ-raise-lemma [] S' = canₖ-raise-lemma canθₖ-raise-lemma (nothing ∷ sigs) S' = canθₖ-raise-lemma sigs (suc S') canθₖ-raise-lemma (just Signal.present ∷ sigs) S' θ = canθₖ-raise-lemma sigs (suc S') (θ ← _) canθₖ-raise-lemma (just Signal.absent ∷ sigs) S' θ = canθₖ-raise-lemma sigs (suc S') (θ ← _) canθₖ-raise-lemma {any/shr} {any/var} {r} {p} {A} (just Signal.unknown ∷ sigs) S' θ E tr with any (_≟_ S') (Canθₛ sigs (suc S') (E ⟦ r ⟧e) (θ ← ([S]-env (S' ₛ)))) | any (_≟_ S') (Canθₛ sigs (suc S') (E ⟦ ρ⟨ (Θ SigMap.empty any/shr any/var) , A ⟩· p ⟧e) (θ ← ([S]-env (S' ₛ)))) ... | yes S'∈CanE⟦r⟧ | yes S'∈CanE⟦ρ⟧ = canθₖ-raise-lemma sigs (suc S') (θ ← _) E tr ... | no S'∉CanE⟦r⟧ | no S'∉CanE⟦ρ⟧ = canθₖ-raise-lemma sigs (suc S') (θ ← _) E tr ... | yes S'∈CanE⟦r⟧ | no S'∉CanE⟦ρ⟧ rewrite (canθₛ-raise-lemma {A = A} sigs (suc S') (θ ← ([S]-env (S' ₛ))) E tr) = ⊥-elim (S'∉CanE⟦ρ⟧ S'∈CanE⟦r⟧) canθₖ-raise-lemma {any/shr} {any/var} {r} {p} {A = A} (just Signal.unknown ∷ sigs) S' θ E tr | no S'∉CanE⟦r⟧ | yes S'∈CanE⟦ρ⟧ rewrite (canθₛ-raise-lemma {A = A} sigs (suc S') (θ ← ([S]-env (S' ₛ))) E tr) = ⊥-elim (S'∉CanE⟦r⟧ S'∈CanE⟦ρ⟧) canₛ-raise : ∀ {E any/shr any/var r r' p A} θ → term-raise any/shr any/var r' p → r ≐ E ⟦ r' ⟧e → ∀ S → Signal.unwrap S ∈ Canₛ (E ⟦ ρ⟨ (Θ SigMap.empty any/shr any/var) , A ⟩· p ⟧e) θ → Signal.unwrap S ∈ Canₛ r θ canₛ-raise {E} {A = A} θ tr r≐E⟦shared⟧ S S∈ rewrite sym (unplug r≐E⟦shared⟧) | canₛ-raise-lemma {A = A} θ E tr = S∈ canₛₕ-raise-lemma : ∀ {any/shr any/var r p A} θ E → term-raise any/shr any/var r p → ∀ s'' → s'' ∈ Canₛₕ (E ⟦ ρ⟨ (Θ SigMap.empty any/shr any/var) , A ⟩· p ⟧e) θ → s'' ∈ Canₛₕ (E ⟦ r ⟧e) θ canₛₕ-raise-lemma {any/shr} {any/var} {r} {p} θ [] (tshared n s e .p) s'' s''∈can-ρΘp-θ rewrite ShrMap.keys-1map s (SharedVar.old ,′ n) | set-subtract-[a]≡set-remove (Canₛₕ p θ) (SharedVar.unwrap s) = s''∈can-ρΘp-θ canₛₕ-raise-lemma {any/shr} {any/var} {r} {p} θ [] (tvar n x e .p) s'' s''∈can-ρΘp-θ rewrite set-subtract-[] (Canₛₕ p θ) = s''∈can-ρΘp-θ canₛₕ-raise-lemma {any/shr} {any/var} {r} {p} {A} θ (epar₁ q ∷ E) tr s'' s''∈can-E⟦ρΘp⟧∥q-θ with ++⁻ (Canₛₕ (E ⟦ ρ⟨ (Θ SigMap.empty any/shr any/var) , A ⟩· p ⟧e) θ) s''∈can-E⟦ρΘp⟧∥q-θ ... | inj₁ s''∈can-E⟦ρΘp⟧-θ = ++ˡ (canₛₕ-raise-lemma θ E tr s'' s''∈can-E⟦ρΘp⟧-θ) ... | inj₂ s''∈can-q-θ = ++ʳ (Canₛₕ (E ⟦ r ⟧e) θ) s''∈can-q-θ canₛₕ-raise-lemma θ (epar₂ p ∷ E) tr s'' s''∈can-p∥E⟦ρΘp⟧-θ with ++⁻ (Canₛₕ p θ) s''∈can-p∥E⟦ρΘp⟧-θ ... | inj₁ s''∈can-p-θ = ++ˡ s''∈can-p-θ ... | inj₂ s''∈can-E⟦ρΘp⟧-θ = ++ʳ (Canₛₕ p θ) (canₛₕ-raise-lemma θ E tr s'' s''∈can-E⟦ρΘp⟧-θ) canₛₕ-raise-lemma {any/shr} {any/var} {r} {p} θ (eloopˢ q ∷ E) tr s'' s''∈can-E⟦ρΘp⟧>>q-θ = canₛₕ-raise-lemma θ E tr s'' s''∈can-E⟦ρΘp⟧>>q-θ canₛₕ-raise-lemma {any/shr} {any/var} {r} {p} {A} θ (eseq q ∷ E) tr s'' s''∈can-E⟦ρΘp⟧>>q-θ with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ r ⟧e) θ) | any (Code._≟_ Code.nothin) (Canₖ (E ⟦ ρ⟨ (Θ SigMap.empty any/shr any/var) , A ⟩· p ⟧e) θ) ... | no nothin∉can-E⟦r⟧ | no nothin∉can-E⟦ρΘp⟧ = canₛₕ-raise-lemma θ E tr s'' s''∈can-E⟦ρΘp⟧>>q-θ ... | yes nothin∈can-E⟦r⟧ | no nothin∉can-E⟦ρΘp⟧ rewrite canₖ-raise-lemma {any/shr} {any/var} {A = A} θ E tr = ⊥-elim (nothin∉can-E⟦ρΘp⟧ nothin∈can-E⟦r⟧) ... | no nothin∉can-E⟦r⟧ | yes nothin∈can-E⟦ρΘp⟧ rewrite canₖ-raise-lemma {any/shr} {any/var} {A = A} θ E tr = ⊥-elim (nothin∉can-E⟦r⟧ nothin∈can-E⟦ρΘp⟧) ... | yes nothin∈can-E⟦r⟧ | yes nothin∈can-E⟦ρΘp⟧ with ++⁻ (Canₛₕ (E ⟦ ρ⟨ (Θ SigMap.empty any/shr any/var) , A ⟩· p ⟧e) θ) s''∈can-E⟦ρΘp⟧>>q-θ ... | inj₁ s''∈can-E⟦ρΘp⟧ = ++ˡ (canₛₕ-raise-lemma θ E tr s'' s''∈can-E⟦ρΘp⟧) ... | inj₂ s''∈can-q = ++ʳ (Canₛₕ (E ⟦ r ⟧e) θ) s''∈can-q canₛₕ-raise-lemma θ (esuspend S' ∷ E) tr s'' s''∈can-E⟦ρΘp⟧-θ = canₛₕ-raise-lemma θ E tr s'' s''∈can-E⟦ρΘp⟧-θ canₛₕ-raise-lemma θ (etrap ∷ E) tr s'' s''∈can-E⟦ρΘp⟧-θ = canₛₕ-raise-lemma θ E tr s'' s''∈can-E⟦ρΘp⟧-θ canₛₕ-raise : ∀ {E any/shr any/var r r' p A} θ → term-raise any/shr any/var r' p → r ≐ E ⟦ r' ⟧e → ∀ s'' → SharedVar.unwrap s'' ∈ Canₛₕ (E ⟦ ρ⟨ (Θ SigMap.empty any/shr any/var) , A ⟩· p ⟧e) θ → SharedVar.unwrap s'' ∈ Canₛₕ r θ canₛₕ-raise {E} θ tr r≐E⟦shared⟧ s'' s''∈ rewrite sym (unplug r≐E⟦shared⟧) = canₛₕ-raise-lemma θ E tr (SharedVar.unwrap s'') s''∈ canₛ-term-nothin-lemma : ∀ {r} θ E → term-nothin r → ∀ S → S ∈ Canₛ (E ⟦ nothin ⟧e) θ → S ∈ Canₛ (E ⟦ r ⟧e) θ canₛ-term-nothin-lemma θ [] tn S () canₛ-term-nothin-lemma {r} θ (epar₁ q ∷ E) tn S S∈can-E⟦nothin⟧∥q with ++⁻ (Canₛ (E ⟦ nothin ⟧e) θ) S∈can-E⟦nothin⟧∥q ... | inj₁ S∈can-E⟦nothin⟧ = ++ˡ (canₛ-term-nothin-lemma θ E tn S S∈can-E⟦nothin⟧) ... | inj₂ S∈can-q = ++ʳ (Canₛ (E ⟦ r ⟧e) θ) S∈can-q canₛ-term-nothin-lemma θ (epar₂ p ∷ E) tn S S∈can-p∥E⟦nothin⟧ with ++⁻ (Canₛ p θ) S∈can-p∥E⟦nothin⟧ ... | inj₁ S∈can-q = ++ˡ S∈can-q ... | inj₂ S∈can-E⟦nothin⟧ = ++ʳ (Canₛ p θ) (canₛ-term-nothin-lemma θ E tn S S∈can-E⟦nothin⟧) canₛ-term-nothin-lemma {r} θ (eloopˢ q ∷ E) tn S S∈can-E⟦nothin⟧>>q = canₛ-term-nothin-lemma θ E tn S S∈can-E⟦nothin⟧>>q canₛ-term-nothin-lemma {r} θ (eseq q ∷ E) tn S S∈can-E⟦nothin⟧>>q with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ nothin ⟧e) θ) | any (Code._≟_ Code.nothin) (Canₖ (E ⟦ r ⟧e) θ) ... | yes nothin∈can-E⟦nothin⟧ | no nothin∉can-E⟦r⟧ = ⊥-elim (nothin∉can-E⟦r⟧ (canₖ-term-nothin-lemma θ E tnothin tn Code.nothin nothin∈can-E⟦nothin⟧)) ... | no nothin∉can-E⟦nothin⟧ | yes nothin∈can-E⟦r⟧ = ⊥-elim (nothin∉can-E⟦nothin⟧ (canₖ-term-nothin-lemma θ E tn tnothin Code.nothin nothin∈can-E⟦r⟧)) ... | no nothin∉can-E⟦nothin⟧ | no nothin∉can-E⟦s'⇐e⟧ = canₛ-term-nothin-lemma θ E tn S S∈can-E⟦nothin⟧>>q ... | yes nothin∈can-E⟦nothin⟧ | yes nothin∈can-E⟦s'⇐e⟧ with ++⁻ (Canₛ (E ⟦ nothin ⟧e) θ) S∈can-E⟦nothin⟧>>q ... | inj₁ S∈can-E⟦nothin⟧ = ++ˡ (canₛ-term-nothin-lemma θ E tn S S∈can-E⟦nothin⟧) ... | inj₂ S∈can-q = ++ʳ (Canₛ (E ⟦ r ⟧e) θ) S∈can-q canₛ-term-nothin-lemma θ (esuspend S' ∷ E) tn S S∈can-E⟦nothin⟧ = canₛ-term-nothin-lemma θ E tn S S∈can-E⟦nothin⟧ canₛ-term-nothin-lemma θ (etrap ∷ E) tn S S∈can-E⟦nothin⟧ = canₛ-term-nothin-lemma θ E tn S S∈can-E⟦nothin⟧ canₛ-term-nothin : ∀ {r' E r} θ θ' → Env.sig θ ≡ Env.sig θ' → term-nothin r' → r ≐ E ⟦ r' ⟧e → ∀ S → Signal.unwrap S ∈ Canₛ (E ⟦ nothin ⟧e) θ' → Signal.unwrap S ∈ Canₛ r θ canₛ-term-nothin {r'} {E} {r} θ θ' θₛ≡θ'ₛ tn r≐E⟦r'⟧ S S∈can-E⟦nothin⟧-θ' rewrite can-shr-var-irr (E ⟦ nothin ⟧e) θ' θ (sym θₛ≡θ'ₛ) | sym (unplug r≐E⟦r'⟧) = canₛ-term-nothin-lemma θ E tn (Signal.unwrap S) S∈can-E⟦nothin⟧-θ' canₛₕ-term-nothin-lemma : ∀ {r} θ E → term-nothin r → ∀ S → S ∈ Canₛₕ (E ⟦ nothin ⟧e) θ → S ∈ Canₛₕ (E ⟦ r ⟧e) θ canₛₕ-term-nothin-lemma θ [] tn S () canₛₕ-term-nothin-lemma {r} θ (epar₁ q ∷ E) tn s'' s''∈can-E⟦nothin⟧∥q with ++⁻ (Canₛₕ (E ⟦ nothin ⟧e) θ) s''∈can-E⟦nothin⟧∥q ... | inj₁ s''∈can-E⟦nothin⟧ = ++ˡ (canₛₕ-term-nothin-lemma θ E tn s'' s''∈can-E⟦nothin⟧) ... | inj₂ s''∈can-q = ++ʳ (Canₛₕ (E ⟦ r ⟧e) θ) s''∈can-q canₛₕ-term-nothin-lemma θ (epar₂ p ∷ E) tn s'' s''∈can-p∥E⟦nothin⟧ with ++⁻ (Canₛₕ p θ) s''∈can-p∥E⟦nothin⟧ ... | inj₁ s''∈can-q = ++ˡ s''∈can-q ... | inj₂ s''∈can-E⟦nothin⟧ = ++ʳ (Canₛₕ p θ) (canₛₕ-term-nothin-lemma θ E tn s'' s''∈can-E⟦nothin⟧) canₛₕ-term-nothin-lemma {r} θ (eloopˢ q ∷ E) tn s'' s''∈can-E⟦nothin⟧>>q = canₛₕ-term-nothin-lemma θ E tn s'' s''∈can-E⟦nothin⟧>>q canₛₕ-term-nothin-lemma {r} θ (eseq q ∷ E) tn s'' s''∈can-E⟦nothin⟧>>q with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ nothin ⟧e) θ) | any (Code._≟_ Code.nothin) (Canₖ (E ⟦ r ⟧e) θ) ... | yes nothin∈can-E⟦nothin⟧ | no nothin∉can-E⟦r⟧ = ⊥-elim (nothin∉can-E⟦r⟧ (canₖ-term-nothin-lemma θ E tnothin tn Code.nothin nothin∈can-E⟦nothin⟧)) ... | no nothin∉can-E⟦nothin⟧ | yes nothin∈can-E⟦r⟧ = ⊥-elim (nothin∉can-E⟦nothin⟧ (canₖ-term-nothin-lemma θ E tn tnothin Code.nothin nothin∈can-E⟦r⟧)) ... | no nothin∉can-E⟦nothin⟧ | no nothin∉can-E⟦s'⇐e⟧ = canₛₕ-term-nothin-lemma {r} θ E tn s'' s''∈can-E⟦nothin⟧>>q ... | yes nothin∈can-E⟦nothin⟧ | yes nothin∈can-E⟦s'⇐e⟧ with ++⁻ (Canₛₕ (E ⟦ nothin ⟧e) θ) s''∈can-E⟦nothin⟧>>q ... | inj₁ s''∈can-E⟦nothin⟧ = ++ˡ (canₛₕ-term-nothin-lemma θ E tn s'' s''∈can-E⟦nothin⟧) ... | inj₂ s''∈can-q = ++ʳ (Canₛₕ (E ⟦ r ⟧e) θ) s''∈can-q canₛₕ-term-nothin-lemma θ (esuspend S' ∷ E) tn s'' s''∈can-E⟦nothin⟧ = canₛₕ-term-nothin-lemma θ E tn s'' s''∈can-E⟦nothin⟧ canₛₕ-term-nothin-lemma θ (etrap ∷ E) tn s'' s''∈can-E⟦nothin⟧ = canₛₕ-term-nothin-lemma θ E tn s'' s''∈can-E⟦nothin⟧ canₛₕ-term-nothin : ∀ {r' E r} θ θ' → Env.sig θ ≡ Env.sig θ' → term-nothin r' → r ≐ E ⟦ r' ⟧e → ∀ s'' → SharedVar.unwrap s'' ∈ Canₛₕ (E ⟦ nothin ⟧e) θ' → SharedVar.unwrap s'' ∈ Canₛₕ r θ canₛₕ-term-nothin {r'} {E} {r} θ θ' θₛ≡θ'ₛ tn r≐E⟦r'⟧ s'' s''∈can-E⟦nothin⟧-θ' rewrite can-shr-var-irr (E ⟦ nothin ⟧e) θ' θ (sym θₛ≡θ'ₛ) | sym (unplug r≐E⟦r'⟧) = canₛₕ-term-nothin-lemma θ E tn (SharedVar.unwrap s'') s''∈can-E⟦nothin⟧-θ' canₖ-if-true-lemma : ∀ x p q θ E → ∀ k → k ∈ Canₖ (E ⟦ p ⟧e) θ → k ∈ Canₖ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ canₖ-if-true-lemma x p q θ [] k k∈can-E⟦p⟧ = ++ˡ k∈can-E⟦p⟧ canₖ-if-true-lemma x p q θ (epar₁ q' ∷ E) k k∈can-E⟦p⟧∥q' = map-mono² {xs = Canₖ (E ⟦ p ⟧e) θ} Code._⊔_ (canₖ-if-true-lemma x p q θ E) (λ _ → id) k k∈can-E⟦p⟧∥q' canₖ-if-true-lemma x p q θ (epar₂ p' ∷ E) k k∈can-p'∥E⟦p⟧ = map-mono² {xs = Canₖ p' θ} Code._⊔_ (λ _ → id) (canₖ-if-true-lemma x p q θ E) k k∈can-p'∥E⟦p⟧ canₖ-if-true-lemma x p q θ (eloopˢ q' ∷ E) k k∈can-E⟦p⟧>>q' = canₖ-if-true-lemma x p q θ E k k∈can-E⟦p⟧>>q' canₖ-if-true-lemma x p q θ (eseq q' ∷ E) k k∈can-E⟦p⟧>>q' with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ p ⟧e) θ) | any (Code._≟_ Code.nothin) (Canₖ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ) canₖ-if-true-lemma x p q θ (eseq q' ∷ E) k k∈can-E⟦p⟧>>q' | yes nothin∈can-E⟦p⟧ | no nothin∉can-E⟦if⟧ = ⊥-elim (nothin∉can-E⟦if⟧ (canₖ-if-true-lemma x p q θ E Code.nothin nothin∈can-E⟦p⟧)) canₖ-if-true-lemma x p q θ (eseq q' ∷ E) k k∈can-E⟦p⟧>>q' | no nothin∉can-E⟦p⟧ | no nothin∉can-E⟦if⟧ = canₖ-if-true-lemma x p q θ E k k∈can-E⟦p⟧>>q' canₖ-if-true-lemma x p q θ (eseq q' ∷ E) k k∈can-E⟦p⟧>>q' | no nothin∉can-E⟦p⟧ | yes nothin∈can-E⟦if⟧ with Code.nothin Code.≟ k ... | yes refl = ⊥-elim (nothin∉can-E⟦p⟧ k∈can-E⟦p⟧>>q') ... | no nothin≢k = ++ˡ (CodeSet.set-remove-not-removed nothin≢k (canₖ-if-true-lemma x p q θ E k k∈can-E⟦p⟧>>q')) canₖ-if-true-lemma x p q θ (eseq q' ∷ E) k k∈can-E⟦p⟧>>q' | yes nothin∈can-E⟦p⟧ | yes nothin∈can-E⟦if⟧ with ++⁻ (CodeSet.set-remove (Canₖ (E ⟦ p ⟧e) θ) Code.nothin) k∈can-E⟦p⟧>>q' ... | inj₂ k∈can-q' = ++ʳ (CodeSet.set-remove (Canₖ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ) Code.nothin) k∈can-q' ... | inj₁ k∈can-E⟦p⟧-nothin with Code.nothin Code.≟ k ... | yes refl = ⊥-elim (CodeSet.set-remove-removed {Code.nothin} {Canₖ (E ⟦ p ⟧e) θ} k∈can-E⟦p⟧-nothin) ... | no nothin≢k = ++ˡ (CodeSet.set-remove-not-removed nothin≢k (canₖ-if-true-lemma x p q θ E k (CodeSet.set-remove-mono-∈ Code.nothin k∈can-E⟦p⟧-nothin))) canₖ-if-true-lemma x p q θ (esuspend S' ∷ E) k k∈can-E⟦p⟧ = canₖ-if-true-lemma x p q θ E k k∈can-E⟦p⟧ canₖ-if-true-lemma x p q θ (etrap ∷ E) k k∈can-E⟦p⟧ = map-mono Code.↓* (canₖ-if-true-lemma x p q θ E) k k∈can-E⟦p⟧ canₖ-if-false-lemma : ∀ x p q θ E → ∀ k → k ∈ Canₖ (E ⟦ q ⟧e) θ → k ∈ Canₖ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ canₖ-if-false-lemma x p q θ [] k k∈can-E⟦q⟧ = ++ʳ (Canₖ p θ) k∈can-E⟦q⟧ canₖ-if-false-lemma x p q θ (epar₁ q' ∷ E) k k∈can-E⟦q⟧∥q' = map-mono² {xs = Canₖ (E ⟦ q ⟧e) θ} Code._⊔_ (canₖ-if-false-lemma x p q θ E) (λ _ → id) k k∈can-E⟦q⟧∥q' canₖ-if-false-lemma x p q θ (epar₂ p' ∷ E) k k∈can-p'∥E⟦q⟧ = map-mono² {xs = Canₖ p' θ} Code._⊔_ (λ _ → id) (canₖ-if-false-lemma x p q θ E) k k∈can-p'∥E⟦q⟧ canₖ-if-false-lemma x p q θ (eloopˢ q' ∷ E) k k∈can-E⟦q⟧>>q' = canₖ-if-false-lemma x p q θ E k k∈can-E⟦q⟧>>q' canₖ-if-false-lemma x p q θ (eseq q' ∷ E) k k∈can-E⟦q⟧>>q' with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ q ⟧e) θ) | any (Code._≟_ Code.nothin) (Canₖ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ) canₖ-if-false-lemma x p q θ (eseq q' ∷ E) k k∈can-E⟦q⟧>>q' | yes nothin∈can-E⟦q⟧ | no nothin∉can-E⟦if⟧ = ⊥-elim (nothin∉can-E⟦if⟧ (canₖ-if-false-lemma x p q θ E Code.nothin nothin∈can-E⟦q⟧)) canₖ-if-false-lemma x p q θ (eseq q' ∷ E) k k∈can-E⟦q⟧>>q' | no nothin∉can-E⟦q⟧ | no nothin∉can-E⟦if⟧ = canₖ-if-false-lemma x p q θ E k k∈can-E⟦q⟧>>q' canₖ-if-false-lemma x p q θ (eseq q' ∷ E) k k∈can-E⟦q⟧>>q' | no nothin∉can-E⟦q⟧ | yes nothin∈can-E⟦if⟧ with Code.nothin Code.≟ k ... | yes refl = ⊥-elim (nothin∉can-E⟦q⟧ k∈can-E⟦q⟧>>q') ... | no nothin≢k = ++ˡ (CodeSet.set-remove-not-removed nothin≢k (canₖ-if-false-lemma x p q θ E k k∈can-E⟦q⟧>>q')) canₖ-if-false-lemma x p q θ (eseq q' ∷ E) k k∈can-E⟦q⟧>>q' | yes nothin∈can-E⟦q⟧ | yes nothin∈can-E⟦if⟧ with ++⁻ (CodeSet.set-remove (Canₖ (E ⟦ q ⟧e) θ) Code.nothin) k∈can-E⟦q⟧>>q' ... | inj₂ k∈can-q' = ++ʳ (CodeSet.set-remove (Canₖ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ) Code.nothin) k∈can-q' ... | inj₁ k∈can-E⟦q⟧-nothin with Code.nothin Code.≟ k ... | yes refl = ⊥-elim (CodeSet.set-remove-removed {Code.nothin} {Canₖ (E ⟦ q ⟧e) θ} k∈can-E⟦q⟧-nothin) ... | no nothin≢k = ++ˡ (CodeSet.set-remove-not-removed nothin≢k (canₖ-if-false-lemma x p q θ E k (CodeSet.set-remove-mono-∈ Code.nothin k∈can-E⟦q⟧-nothin))) canₖ-if-false-lemma x p q θ (esuspend S' ∷ E) k k∈can-E⟦q⟧ = canₖ-if-false-lemma x p q θ E k k∈can-E⟦q⟧ canₖ-if-false-lemma x p q θ (etrap ∷ E) k k∈can-E⟦q⟧ = map-mono Code.↓* (canₖ-if-false-lemma x p q θ E) k k∈can-E⟦q⟧ canθₖ-if-false-lemma : ∀ sig S → ∀ x p q θ E → ∀ k → k ∈ Canθₖ sig S (E ⟦ q ⟧e) θ → k ∈ Canθₖ sig S (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ canθₖ-if-false-lemma sig S x p q θ E = (canθₖ-plugE S sig E (if x ∣⇒ p ∣⇒ q) q (λ θ₁ k x₁ → ++ʳ (Canₖ p θ₁) x₁) ((λ θ₁ k x₁ → ++ʳ (Canₛ p θ₁) x₁)) θ) canθₖ-if-true-lemma : ∀ sig S → ∀ x p q θ E → ∀ k → k ∈ Canθₖ sig S (E ⟦ p ⟧e) θ → k ∈ Canθₖ sig S (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ canθₖ-if-true-lemma sig S x p q θ E = (canθₖ-plugE S sig E (if x ∣⇒ p ∣⇒ q) p (λ θ₁ k x₁ → ++ˡ x₁) ((λ θ₁ k x₁ → ++ˡ x₁)) θ) canθₛ-if-false-lemma : ∀ sig S → ∀ x p q θ E → ∀ S' → S' ∈ Canθₛ sig S (E ⟦ q ⟧e) θ → S' ∈ Canθₛ sig S (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ canθₛ-if-false-lemma sig S x p q θ E = (canθₛ-plugE S sig E (if x ∣⇒ p ∣⇒ q) q (λ θ₁ k x₁ → ++ʳ (Canₛ p θ₁) x₁) ((λ θ₁ k x₁ → ++ʳ (Canₖ p θ₁) x₁)) θ) canθₛ-if-true-lemma : ∀ sig S → ∀ x p q θ E → ∀ S' → S' ∈ Canθₛ sig S (E ⟦ p ⟧e) θ → S' ∈ Canθₛ sig S (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ canθₛ-if-true-lemma sig S x p q θ E = (canθₛ-plugE S sig E (if x ∣⇒ p ∣⇒ q) p (λ θ₁ k x₁ → ++ˡ x₁) ((λ θ₁ k x₁ → ++ˡ x₁)) θ) canθₛₕ-if-true-lemma : ∀ sigs S → ∀ x p q θ E → ∀ s → s ∈ Canθₛₕ sigs S (E ⟦ p ⟧e) θ → s ∈ Canθₛₕ sigs S (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ canθₛₕ-if-true-lemma sig S x p q θ E = (canθₛₕ-plugE S sig E (if x ∣⇒ p ∣⇒ q) p (λ θ₁ k x₁ → ++ˡ x₁) ((λ θ₁ k x₁ → ++ˡ x₁)) ((λ θ₁ k x₁ → ++ˡ x₁)) θ) canθₛₕ-if-false-lemma : ∀ sigs S → ∀ x p q θ E → ∀ s → s ∈ Canθₛₕ sigs S (E ⟦ q ⟧e) θ → s ∈ Canθₛₕ sigs S (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ canθₛₕ-if-false-lemma sig S x p q θ E = (canθₛₕ-plugE S sig E (if x ∣⇒ p ∣⇒ q) q (λ θ₁ k x₁ → ++ʳ (Canₛₕ p θ₁) x₁) ((λ θ₁ k x₁ → ++ʳ ((Canₖ p θ₁)) x₁)) ((λ θ₁ k x₁ → ++ʳ ((Canₛ p θ₁)) x₁)) θ) canₛ-if-true-lemma : ∀ x p q θ E → ∀ S → S ∈ Canₛ (E ⟦ p ⟧e) θ → S ∈ Canₛ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ canₛ-if-true-lemma x p q θ [] S S∈can-E⟦p⟧ = ++ˡ S∈can-E⟦p⟧ canₛ-if-true-lemma x p q θ (epar₁ q' ∷ E) S S∈can-E⟦p⟧∥q' with ++⁻ (Canₛ (E ⟦ p ⟧e) θ) S∈can-E⟦p⟧∥q' ... | inj₁ S∈can-E⟦p⟧ = ++ˡ (canₛ-if-true-lemma x p q θ E S S∈can-E⟦p⟧) ... | inj₂ S∈can-q' = ++ʳ (Canₛ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ) S∈can-q' canₛ-if-true-lemma x p q θ (epar₂ p' ∷ E) S S∈can-p'∥E⟦p⟧ with ++⁻ (Canₛ p' θ) S∈can-p'∥E⟦p⟧ ... | inj₁ S∈can-p' = ++ˡ S∈can-p' ... | inj₂ S∈can-E⟦p⟧ = ++ʳ (Canₛ p' θ) (canₛ-if-true-lemma x p q θ E S S∈can-E⟦p⟧) canₛ-if-true-lemma x p q θ (eloopˢ q' ∷ E) S S∈can-E⟦p⟧>>q' = canₛ-if-true-lemma x p q θ E S S∈can-E⟦p⟧>>q' canₛ-if-true-lemma x p q θ (eseq q' ∷ E) S S∈can-E⟦p⟧>>q' with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ p ⟧e) θ) | any (Code._≟_ Code.nothin) (Canₖ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ) ... | yes nothin∈can-E⟦p⟧ | no nothin∉can-E⟦if⟧ = ⊥-elim (nothin∉can-E⟦if⟧ (canₖ-if-true-lemma x p q θ E Code.nothin nothin∈can-E⟦p⟧)) ... | no nothin∉can-E⟦p⟧ | yes nothin∈can-E⟦if⟧ = ++ˡ (canₛ-if-true-lemma x p q θ E S S∈can-E⟦p⟧>>q') ... | no nothin∉can-E⟦p⟧ | no nothin∉can-E⟦if⟧ = canₛ-if-true-lemma x p q θ E S S∈can-E⟦p⟧>>q' ... | yes nothin∈can-E⟦p⟧ | yes nothin∈can-E⟦if⟧ with ++⁻ (Canₛ (E ⟦ p ⟧e) θ) S∈can-E⟦p⟧>>q' ... | inj₁ S∈can-E⟦p⟧ = ++ˡ (canₛ-if-true-lemma x p q θ E S S∈can-E⟦p⟧) ... | inj₂ S∈can-q' = ++ʳ (Canₛ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ) S∈can-q' canₛ-if-true-lemma x p q θ (esuspend S' ∷ E) S S∈can-E⟦p⟧ = canₛ-if-true-lemma x p q θ E S S∈can-E⟦p⟧ canₛ-if-true-lemma x p q θ (etrap ∷ E) S S∈can-E⟦p⟧ = canₛ-if-true-lemma x p q θ E S S∈can-E⟦p⟧ canₛ-if-true : ∀ {x p q E r} θ → r ≐ E ⟦ if x ∣⇒ p ∣⇒ q ⟧e → ∀ S → Signal.unwrap S ∈ Canₛ (E ⟦ p ⟧e) θ → Signal.unwrap S ∈ Canₛ r θ canₛ-if-true {x} {p} {q} {E} θ r≐E⟦if⟧ S S∈can-E⟦p⟧ rewrite sym (unplug r≐E⟦if⟧) = canₛ-if-true-lemma x p q θ E (Signal.unwrap S) S∈can-E⟦p⟧ canₛ-if-false-lemma : ∀ x p q θ E → ∀ S → S ∈ Canₛ (E ⟦ q ⟧e) θ → S ∈ Canₛ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ canₛ-if-false-lemma x p q θ [] S S∈can-E⟦q⟧ = ++ʳ (Canₛ p θ) S∈can-E⟦q⟧ canₛ-if-false-lemma x p q θ (epar₁ q' ∷ E) S S∈can-E⟦q⟧∥q' with ++⁻ (Canₛ (E ⟦ q ⟧e) θ) S∈can-E⟦q⟧∥q' ... | inj₁ S∈can-E⟦q⟧ = ++ˡ (canₛ-if-false-lemma x p q θ E S S∈can-E⟦q⟧) ... | inj₂ S∈can-q' = ++ʳ (Canₛ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ) S∈can-q' canₛ-if-false-lemma x p q θ (epar₂ p' ∷ E) S S∈can-p'∥E⟦q⟧ with ++⁻ (Canₛ p' θ) S∈can-p'∥E⟦q⟧ ... | inj₁ S∈can-p' = ++ˡ S∈can-p' ... | inj₂ S∈can-E⟦q⟧ = ++ʳ (Canₛ p' θ) (canₛ-if-false-lemma x p q θ E S S∈can-E⟦q⟧) canₛ-if-false-lemma x p q θ (eloopˢ q' ∷ E) S S∈can-E⟦q⟧>>q' = canₛ-if-false-lemma x p q θ E S S∈can-E⟦q⟧>>q' canₛ-if-false-lemma x p q θ (eseq q' ∷ E) S S∈can-E⟦q⟧>>q' with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ q ⟧e) θ) | any (Code._≟_ Code.nothin) (Canₖ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ) ... | yes nothin∈can-E⟦q⟧ | no nothin∉can-E⟦if⟧ = ⊥-elim (nothin∉can-E⟦if⟧ (canₖ-if-false-lemma x p q θ E Code.nothin nothin∈can-E⟦q⟧)) ... | no nothin∉can-E⟦q⟧ | yes nothin∈can-E⟦if⟧ = ++ˡ (canₛ-if-false-lemma x p q θ E S S∈can-E⟦q⟧>>q') ... | no nothin∉can-E⟦q⟧ | no nothin∉can-E⟦if⟧ = canₛ-if-false-lemma x p q θ E S S∈can-E⟦q⟧>>q' ... | yes nothin∈can-E⟦q⟧ | yes nothin∈can-E⟦if⟧ with ++⁻ (Canₛ (E ⟦ q ⟧e) θ) S∈can-E⟦q⟧>>q' ... | inj₁ S∈can-E⟦q⟧ = ++ˡ (canₛ-if-false-lemma x p q θ E S S∈can-E⟦q⟧) ... | inj₂ S∈can-q' = ++ʳ (Canₛ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ) S∈can-q' canₛ-if-false-lemma x p q θ (esuspend S' ∷ E) S S∈can-E⟦q⟧ = canₛ-if-false-lemma x p q θ E S S∈can-E⟦q⟧ canₛ-if-false-lemma x p q θ (etrap ∷ E) S S∈can-E⟦q⟧ = canₛ-if-false-lemma x p q θ E S S∈can-E⟦q⟧ canₛ-if-false : ∀ {x p q E r} θ → r ≐ E ⟦ if x ∣⇒ p ∣⇒ q ⟧e → ∀ S → Signal.unwrap S ∈ Canₛ (E ⟦ q ⟧e) θ → Signal.unwrap S ∈ Canₛ r θ canₛ-if-false {x} {p} {q} {E} θ r≐E⟦if⟧ S S∈can-E⟦q⟧ rewrite sym (unplug r≐E⟦if⟧) = canₛ-if-false-lemma x p q θ E (Signal.unwrap S) S∈can-E⟦q⟧ canₛₕ-if-true-lemma : ∀ x p q θ E → ∀ S → S ∈ Canₛₕ (E ⟦ p ⟧e) θ → S ∈ Canₛₕ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ canₛₕ-if-true-lemma x p q θ [] s s∈can-E⟦p⟧ = ++ˡ s∈can-E⟦p⟧ canₛₕ-if-true-lemma x p q θ (epar₁ q' ∷ E) s s∈can-E⟦p⟧∥q' with ++⁻ (Canₛₕ (E ⟦ p ⟧e) θ) s∈can-E⟦p⟧∥q' ... | inj₁ s∈can-E⟦p⟧ = ++ˡ (canₛₕ-if-true-lemma x p q θ E s s∈can-E⟦p⟧) ... | inj₂ s∈can-q' = ++ʳ (Canₛₕ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ) s∈can-q' canₛₕ-if-true-lemma x p q θ (epar₂ p' ∷ E) s s∈can-p'∥E⟦p⟧ with ++⁻ (Canₛₕ p' θ) s∈can-p'∥E⟦p⟧ ... | inj₁ s∈can-p' = ++ˡ s∈can-p' ... | inj₂ s∈can-E⟦p⟧ = ++ʳ (Canₛₕ p' θ) (canₛₕ-if-true-lemma x p q θ E s s∈can-E⟦p⟧) canₛₕ-if-true-lemma x p q θ (eloopˢ q' ∷ E) s s∈can-E⟦p⟧>>q' = canₛₕ-if-true-lemma x p q θ E s s∈can-E⟦p⟧>>q' canₛₕ-if-true-lemma x p q θ (eseq q' ∷ E) s s∈can-E⟦p⟧>>q' with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ p ⟧e) θ) | any (Code._≟_ Code.nothin) (Canₖ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ) ... | yes nothin∈can-E⟦p⟧ | no nothin∉can-E⟦if⟧ = ⊥-elim (nothin∉can-E⟦if⟧ (canₖ-if-true-lemma x p q θ E Code.nothin nothin∈can-E⟦p⟧)) ... | no nothin∉can-E⟦p⟧ | yes nothin∈can-E⟦if⟧ = ++ˡ (canₛₕ-if-true-lemma x p q θ E s s∈can-E⟦p⟧>>q') ... | no nothin∉can-E⟦p⟧ | no nothin∉can-E⟦if⟧ = canₛₕ-if-true-lemma x p q θ E s s∈can-E⟦p⟧>>q' ... | yes nothin∈can-E⟦p⟧ | yes nothin∈can-E⟦if⟧ with ++⁻ (Canₛₕ (E ⟦ p ⟧e) θ) s∈can-E⟦p⟧>>q' ... | inj₁ s∈can-E⟦p⟧ = ++ˡ (canₛₕ-if-true-lemma x p q θ E s s∈can-E⟦p⟧) ... | inj₂ s∈can-q' = ++ʳ (Canₛₕ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ) s∈can-q' canₛₕ-if-true-lemma x p q θ (esuspend S' ∷ E) s s∈can-E⟦p⟧ = canₛₕ-if-true-lemma x p q θ E s s∈can-E⟦p⟧ canₛₕ-if-true-lemma x p q θ (etrap ∷ E) s s∈can-E⟦p⟧ = canₛₕ-if-true-lemma x p q θ E s s∈can-E⟦p⟧ canₛₕ-if-true : ∀ {x p q E r} θ → r ≐ E ⟦ if x ∣⇒ p ∣⇒ q ⟧e → ∀ s → SharedVar.unwrap s ∈ Canₛₕ (E ⟦ p ⟧e) θ → SharedVar.unwrap s ∈ Canₛₕ r θ canₛₕ-if-true {x} {p} {q} {E} θ r≐E⟦if⟧ s s∈can-E⟦p⟧ rewrite sym (unplug r≐E⟦if⟧) = canₛₕ-if-true-lemma x p q θ E (SharedVar.unwrap s) s∈can-E⟦p⟧ canₛₕ-if-false-lemma : ∀ x p q θ E → ∀ S → S ∈ Canₛₕ (E ⟦ q ⟧e) θ → S ∈ Canₛₕ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ canₛₕ-if-false-lemma x p q θ [] s s∈can-E⟦q⟧ = ++ʳ (Canₛₕ p θ) s∈can-E⟦q⟧ canₛₕ-if-false-lemma x p q θ (epar₁ q' ∷ E) s s∈can-E⟦q⟧∥q' with ++⁻ (Canₛₕ (E ⟦ q ⟧e) θ) s∈can-E⟦q⟧∥q' ... | inj₁ s∈can-E⟦q⟧ = ++ˡ (canₛₕ-if-false-lemma x p q θ E s s∈can-E⟦q⟧) ... | inj₂ s∈can-q' = ++ʳ (Canₛₕ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ) s∈can-q' canₛₕ-if-false-lemma x p q θ (epar₂ p' ∷ E) s s∈can-p'∥E⟦q⟧ with ++⁻ (Canₛₕ p' θ) s∈can-p'∥E⟦q⟧ ... | inj₁ s∈can-p' = ++ˡ s∈can-p' ... | inj₂ s∈can-E⟦q⟧ = ++ʳ (Canₛₕ p' θ) (canₛₕ-if-false-lemma x p q θ E s s∈can-E⟦q⟧) canₛₕ-if-false-lemma x p q θ (eloopˢ q' ∷ E) s s∈can-E⟦q⟧>>q' = canₛₕ-if-false-lemma x p q θ E s s∈can-E⟦q⟧>>q' canₛₕ-if-false-lemma x p q θ (eseq q' ∷ E) s s∈can-E⟦q⟧>>q' with any (Code._≟_ Code.nothin) (Canₖ (E ⟦ q ⟧e) θ) | any (Code._≟_ Code.nothin) (Canₖ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ) ... | yes nothin∈can-E⟦q⟧ | no nothin∉can-E⟦if⟧ = ⊥-elim (nothin∉can-E⟦if⟧ (canₖ-if-false-lemma x p q θ E Code.nothin nothin∈can-E⟦q⟧)) ... | no nothin∉can-E⟦q⟧ | yes nothin∈can-E⟦if⟧ = ++ˡ (canₛₕ-if-false-lemma x p q θ E s s∈can-E⟦q⟧>>q') ... | no nothin∉can-E⟦q⟧ | no nothin∉can-E⟦if⟧ = canₛₕ-if-false-lemma x p q θ E s s∈can-E⟦q⟧>>q' ... | yes nothin∈can-E⟦q⟧ | yes nothin∈can-E⟦if⟧ with ++⁻ (Canₛₕ (E ⟦ q ⟧e) θ) s∈can-E⟦q⟧>>q' ... | inj₁ s∈can-E⟦q⟧ = ++ˡ (canₛₕ-if-false-lemma x p q θ E s s∈can-E⟦q⟧) ... | inj₂ s∈can-q' = ++ʳ (Canₛₕ (E ⟦ if x ∣⇒ p ∣⇒ q ⟧e) θ) s∈can-q' canₛₕ-if-false-lemma x p q θ (esuspend S' ∷ E) s s∈can-E⟦q⟧ = canₛₕ-if-false-lemma x p q θ E s s∈can-E⟦q⟧ canₛₕ-if-false-lemma x p q θ (etrap ∷ E) s s∈can-E⟦q⟧ = canₛₕ-if-false-lemma x p q θ E s s∈can-E⟦q⟧ canₛₕ-if-false : ∀ {x p q E r} θ → r ≐ E ⟦ if x ∣⇒ p ∣⇒ q ⟧e → ∀ s → SharedVar.unwrap s ∈ Canₛₕ (E ⟦ q ⟧e) θ → SharedVar.unwrap s ∈ Canₛₕ r θ canₛₕ-if-false {x} {p} {q} {E} θ r≐E⟦if⟧ s s∈can-E⟦q⟧ rewrite sym (unplug r≐E⟦if⟧) = canₛₕ-if-false-lemma x p q θ E (SharedVar.unwrap s) s∈can-E⟦q⟧ canθₛ-set-sig-monotonic-absence-lemma : ∀ sigs S'' → ∀ p S θ S∈ → SigMap.lookup{_}{S} sigs S∈ ≡ Signal.unknown → ∀ S' → S' ∈ Canθₛ (SigMap.update{_} sigs S Signal.absent) S'' p θ → S' ∈ Canθₛ sigs S'' p θ canθₛ-set-sig-monotonic-absence-lemma [] S'' p (S ₛ) θ () status eq canθₛ-set-sig-monotonic-absence-lemma (nothing ∷ sigs) S'' p (zero ₛ) θ S∈ eq = ⊥-elim (SigM.0∈S S∈) canθₛ-set-sig-monotonic-absence-lemma (just Signal.present ∷ sigs) S'' p (zero ₛ) θ S∈ () canθₛ-set-sig-monotonic-absence-lemma (just Signal.absent ∷ sigs) S'' p (zero ₛ) θ S∈ () canθₛ-set-sig-monotonic-absence-lemma (just Signal.unknown ∷ sigs) S'' p (zero ₛ) θ S∈ eq with any (_≟_ S'') (Canθₛ sigs (suc S'') p (θ ← ([S]-env (S'' ₛ)))) ... | no S∉Cansigs = λ k z → z ... | yes S∈Cansigs with canθₛ-set-sig-monotonic sigs (suc S'') p (S'' ₛ) (θ ← [S]-env (S'' ₛ)) (Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ) Signal.absent (Env.sig-stats-1map-right-← (S'' ₛ) Signal.unknown θ ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ))) (n∉map-suc-n-+ S'' (SigM.Dom' sigs)) ... | r rewrite (begin (Env.set-sig{(S'' ₛ)} (θ ← [S]-env (S'' ₛ)) ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ)) Signal.absent) ≡⟨ sym (Env.sig-switch-right (S'' ₛ) Signal.absent θ ([S]-env (S'' ₛ)) ((Env.sig-∈-single (S'' ₛ) Signal.unknown)) ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ))) ⟩ (θ ← (Env.set-sig{(S'' ₛ)} ([S]-env (S'' ₛ)) ((Env.sig-∈-single (S'' ₛ) Signal.unknown)) Signal.absent)) ≡⟨ cong (_←_ θ) (Env.sig-put-1map-overwrite' (S'' ₛ) Signal.unknown Signal.absent ((Env.sig-∈-single (S'' ₛ) Signal.unknown))) ⟩ (θ ← [S]-env-absent (S'' ₛ)) ∎) = r canθₛ-set-sig-monotonic-absence-lemma (nothing ∷ sigs) S'' p (suc S ₛ) θ S∈ eq = canθₛ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) θ ((SigM.n∈S{S}{nothing}{sigs} S∈)) eq canθₛ-set-sig-monotonic-absence-lemma (just Signal.present ∷ sigs) S'' p (suc S ₛ) θ S∈ eq = canθₛ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) (θ ← _) ((SigM.n∈S{S}{just Signal.present}{sigs} S∈)) eq canθₛ-set-sig-monotonic-absence-lemma (just Signal.absent ∷ sigs) S'' p (suc S ₛ) θ S∈ eq = canθₛ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) (θ ← _) ((SigM.n∈S{S}{just Signal.absent}{sigs} S∈)) eq canθₛ-set-sig-monotonic-absence-lemma (just Signal.unknown ∷ sigs) S'' p (suc S ₛ) θ S∈ eq with any (_≟_ S'') (Canθₛ sigs (suc S'') p (θ ← ([S]-env (S'' ₛ)))) | any (_≟_ S'') (Canθₛ (SigMap.update{_} sigs (S ₛ) Signal.absent) (suc S'') p (θ ← ([S]-env (S'' ₛ)))) ... | yes S∈Cansigs | yes S∈Cansigs←a = canθₛ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) (θ ← [S]-env (S'' ₛ)) ((SigM.n∈S{S}{just Signal.unknown}{sigs} S∈)) eq ... | no S∉Cansigs | no S∉Cansigs←a = canθₛ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) (θ ← [S]-env-absent (S'' ₛ)) ((SigM.n∈S{S}{just Signal.unknown}{sigs} S∈)) eq ... | no S∉Cansigs | yes S∈Cansigs←a = ⊥-elim (S∉Cansigs (canθₛ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) (θ ← [S]-env (S'' ₛ)) ((SigM.n∈S{S}{just Signal.unknown}{sigs} S∈)) eq S'' S∈Cansigs←a)) ... | yes S∈Cansigs | no S∉Cansigs←a with (canθₛ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) (θ ← [S]-env-absent (S'' ₛ)) ((SigM.n∈S{S}{just Signal.unknown}{sigs} S∈)) eq) ... | r rewrite sym (begin (Env.set-sig{(S'' ₛ)} (θ ← [S]-env (S'' ₛ)) ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ)) Signal.absent) ≡⟨ sym (Env.sig-switch-right (S'' ₛ) Signal.absent θ ([S]-env (S'' ₛ)) ((Env.sig-∈-single (S'' ₛ) Signal.unknown)) ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ))) ⟩ (θ ← (Env.set-sig{(S'' ₛ)} ([S]-env (S'' ₛ)) ((Env.sig-∈-single (S'' ₛ) Signal.unknown)) Signal.absent)) ≡⟨ cong (_←_ θ) (Env.sig-put-1map-overwrite' (S'' ₛ) Signal.unknown Signal.absent ((Env.sig-∈-single (S'' ₛ) Signal.unknown))) ⟩ (θ ← [S]-env-absent (S'' ₛ)) ∎) = λ k k∈ → canθₛ-set-sig-monotonic sigs (suc S'') p (S'' ₛ) (θ ← [S]-env (S'' ₛ)) ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ)) Signal.absent ((Env.sig-stats-1map-right-← (S'' ₛ) Signal.unknown θ ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ)))) (n∉map-suc-n-+ S'' (SigM.Dom' sigs)) k (r k k∈) canθₖ-set-sig-monotonic-absence-lemma : ∀ sigs S'' → ∀ p S θ S∈ → SigMap.lookup{_}{S} sigs S∈ ≡ Signal.unknown → ∀ k → k ∈ Canθₖ (SigMap.update{_} sigs S Signal.absent) S'' p θ → k ∈ Canθₖ sigs S'' p θ canθₖ-set-sig-monotonic-absence-lemma [] S'' p (x ₛ) θ () eq canθₖ-set-sig-monotonic-absence-lemma (nothing ∷ sigs) S'' p (zero ₛ) θ S∈ status eq = ⊥-elim (SigM.0∈S S∈) canθₖ-set-sig-monotonic-absence-lemma (just Signal.present ∷ sigs) S'' p (zero ₛ) θ S∈ () canθₖ-set-sig-monotonic-absence-lemma (just Signal.absent ∷ sigs) S'' p (zero ₛ) θ S∈ () canθₖ-set-sig-monotonic-absence-lemma (just Signal.unknown ∷ sigs) S'' p (zero ₛ) θ S∈ eq with any (_≟_ S'') (Canθₛ sigs (suc S'') p (θ ← ([S]-env (S'' ₛ)))) ... | no S∉Cansigs = λ k z → z ... | yes S∈Cansigs with canθₖ-set-sig-monotonic sigs (suc S'') p (S'' ₛ) (θ ← [S]-env (S'' ₛ)) (Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ) Signal.absent (Env.sig-stats-1map-right-← (S'' ₛ) Signal.unknown θ ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ))) (n∉map-suc-n-+ S'' (SigM.Dom' sigs)) ... | r rewrite (begin (Env.set-sig{(S'' ₛ)} (θ ← [S]-env (S'' ₛ)) ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ)) Signal.absent) ≡⟨ sym (Env.sig-switch-right (S'' ₛ) Signal.absent θ ([S]-env (S'' ₛ)) ((Env.sig-∈-single (S'' ₛ) Signal.unknown)) ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ))) ⟩ (θ ← (Env.set-sig{(S'' ₛ)} ([S]-env (S'' ₛ)) ((Env.sig-∈-single (S'' ₛ) Signal.unknown)) Signal.absent)) ≡⟨ cong (_←_ θ) (Env.sig-put-1map-overwrite' (S'' ₛ) Signal.unknown Signal.absent ((Env.sig-∈-single (S'' ₛ) Signal.unknown))) ⟩ (θ ← [S]-env-absent (S'' ₛ)) ∎) = r canθₖ-set-sig-monotonic-absence-lemma (nothing ∷ sigs) S'' p (suc S ₛ) θ S∈ eq = canθₖ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) θ ((SigM.n∈S{S}{nothing}{sigs} S∈)) eq canθₖ-set-sig-monotonic-absence-lemma (just Signal.present ∷ sigs) S'' p (suc S ₛ) θ S∈ eq = canθₖ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) (θ ← _) ((SigM.n∈S{S}{just Signal.present}{sigs} S∈)) eq canθₖ-set-sig-monotonic-absence-lemma (just Signal.absent ∷ sigs) S'' p (suc S ₛ) θ S∈ eq = canθₖ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) (θ ← _) ((SigM.n∈S{S}{just Signal.absent}{sigs} S∈)) eq canθₖ-set-sig-monotonic-absence-lemma (just Signal.unknown ∷ sigs) S'' p (suc S ₛ) θ S∈ eq with any (_≟_ S'') (Canθₛ sigs (suc S'') p (θ ← ([S]-env (S'' ₛ)))) | any (_≟_ S'') (Canθₛ (SigMap.update{_} sigs (S ₛ) Signal.absent) (suc S'') p (θ ← ([S]-env (S'' ₛ)))) ... | yes S∈Cansigs | yes S∈Cansigs←a = canθₖ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) (θ ← [S]-env (S'' ₛ)) ((SigM.n∈S{S}{just Signal.unknown}{sigs} S∈)) eq ... | no S∉Cansigs | no S∉Cansigs←a = canθₖ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) (θ ← [S]-env-absent (S'' ₛ)) ((SigM.n∈S{S}{just Signal.unknown}{sigs} S∈)) eq ... | no S∉Cansigs | yes S∈Cansigs←a = ⊥-elim (S∉Cansigs (canθₛ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) (θ ← [S]-env (S'' ₛ)) ((SigM.n∈S{S}{just Signal.unknown}{sigs} S∈)) eq S'' S∈Cansigs←a)) ... | yes S∈Cansigs | no S∉Cansigs←a with (canθₖ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) (θ ← [S]-env-absent (S'' ₛ)) ((SigM.n∈S{S}{just Signal.unknown}{sigs} S∈)) eq) ... | r rewrite sym (begin (Env.set-sig{(S'' ₛ)} (θ ← [S]-env (S'' ₛ)) ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ)) Signal.absent) ≡⟨ sym (Env.sig-switch-right (S'' ₛ) Signal.absent θ ([S]-env (S'' ₛ)) ((Env.sig-∈-single (S'' ₛ) Signal.unknown)) ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ))) ⟩ (θ ← (Env.set-sig{(S'' ₛ)} ([S]-env (S'' ₛ)) ((Env.sig-∈-single (S'' ₛ) Signal.unknown)) Signal.absent)) ≡⟨ cong (_←_ θ) (Env.sig-put-1map-overwrite' (S'' ₛ) Signal.unknown Signal.absent ((Env.sig-∈-single (S'' ₛ) Signal.unknown))) ⟩ (θ ← [S]-env-absent (S'' ₛ)) ∎) = λ k k∈ → canθₖ-set-sig-monotonic sigs (suc S'') p (S'' ₛ) (θ ← [S]-env (S'' ₛ)) ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ)) Signal.absent ((Env.sig-stats-1map-right-← (S'' ₛ) Signal.unknown θ ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ)))) (n∉map-suc-n-+ S'' (SigM.Dom' sigs)) k (r k k∈) canθₛₕ-set-sig-monotonic-absence-lemma : ∀ sigs S'' → ∀ p S θ S∈ → SigMap.lookup{_}{S} sigs S∈ ≡ Signal.unknown → ∀ s → s ∈ Canθₛₕ (SigMap.update{_} sigs S Signal.absent) S'' p θ → s ∈ Canθₛₕ sigs S'' p θ canθₛₕ-set-sig-monotonic-absence-lemma [] S'' p (x ₛ) θ () eq canθₛₕ-set-sig-monotonic-absence-lemma (nothing ∷ sigs) S'' p (zero ₛ) θ S∈ status eq = ⊥-elim (SigM.0∈S S∈) canθₛₕ-set-sig-monotonic-absence-lemma (just Signal.present ∷ sigs) S'' p (zero ₛ) θ S∈ () canθₛₕ-set-sig-monotonic-absence-lemma (just Signal.absent ∷ sigs) S'' p (zero ₛ) θ S∈ () canθₛₕ-set-sig-monotonic-absence-lemma (just Signal.unknown ∷ sigs) S'' p (zero ₛ) θ S∈ eq with any (_≟_ S'') (Canθₛ sigs (suc S'') p (θ ← ([S]-env (S'' ₛ)))) ... | no S∉Cansigs = λ k z → z ... | yes S∈Cansigs with canθₛₕ-set-sig-monotonic sigs (suc S'') p (S'' ₛ) (θ ← [S]-env (S'' ₛ)) (Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ) Signal.absent (Env.sig-stats-1map-right-← (S'' ₛ) Signal.unknown θ ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ))) (n∉map-suc-n-+ S'' (SigM.Dom' sigs)) ... | r rewrite (begin (Env.set-sig{(S'' ₛ)} (θ ← [S]-env (S'' ₛ)) ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ)) Signal.absent) ≡⟨ sym (Env.sig-switch-right (S'' ₛ) Signal.absent θ ([S]-env (S'' ₛ)) ((Env.sig-∈-single (S'' ₛ) Signal.unknown)) ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ))) ⟩ (θ ← (Env.set-sig{(S'' ₛ)} ([S]-env (S'' ₛ)) ((Env.sig-∈-single (S'' ₛ) Signal.unknown)) Signal.absent)) ≡⟨ cong (_←_ θ) (Env.sig-put-1map-overwrite' (S'' ₛ) Signal.unknown Signal.absent ((Env.sig-∈-single (S'' ₛ) Signal.unknown))) ⟩ (θ ← [S]-env-absent (S'' ₛ)) ∎) = r canθₛₕ-set-sig-monotonic-absence-lemma (nothing ∷ sigs) S'' p (suc S ₛ) θ S∈ eq = canθₛₕ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) θ ((SigM.n∈S{S}{nothing}{sigs} S∈)) eq canθₛₕ-set-sig-monotonic-absence-lemma (just Signal.present ∷ sigs) S'' p (suc S ₛ) θ S∈ eq = canθₛₕ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) (θ ← _) ((SigM.n∈S{S}{just Signal.present}{sigs} S∈)) eq canθₛₕ-set-sig-monotonic-absence-lemma (just Signal.absent ∷ sigs) S'' p (suc S ₛ) θ S∈ eq = canθₛₕ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) (θ ← _) ((SigM.n∈S{S}{just Signal.absent}{sigs} S∈)) eq canθₛₕ-set-sig-monotonic-absence-lemma (just Signal.unknown ∷ sigs) S'' p (suc S ₛ) θ S∈ eq with any (_≟_ S'') (Canθₛ sigs (suc S'') p (θ ← ([S]-env (S'' ₛ)))) | any (_≟_ S'') (Canθₛ (SigMap.update{_} sigs (S ₛ) Signal.absent) (suc S'') p (θ ← ([S]-env (S'' ₛ)))) ... | yes S∈Cansigs | yes S∈Cansigs←a = canθₛₕ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) (θ ← [S]-env (S'' ₛ)) ((SigM.n∈S{S}{just Signal.unknown}{sigs} S∈)) eq ... | no S∉Cansigs | no S∉Cansigs←a = canθₛₕ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) (θ ← [S]-env-absent (S'' ₛ)) ((SigM.n∈S{S}{just Signal.unknown}{sigs} S∈)) eq ... | no S∉Cansigs | yes S∈Cansigs←a = ⊥-elim (S∉Cansigs (canθₛ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) (θ ← [S]-env (S'' ₛ)) ((SigM.n∈S{S}{just Signal.unknown}{sigs} S∈)) eq S'' S∈Cansigs←a)) ... | yes S∈Cansigs | no S∉Cansigs←a with (canθₛₕ-set-sig-monotonic-absence-lemma sigs (suc S'') p (S ₛ) (θ ← [S]-env-absent (S'' ₛ)) ((SigM.n∈S{S}{just Signal.unknown}{sigs} S∈)) eq) ... | r rewrite sym (begin (Env.set-sig{(S'' ₛ)} (θ ← [S]-env (S'' ₛ)) ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ)) Signal.absent) ≡⟨ sym (Env.sig-switch-right (S'' ₛ) Signal.absent θ ([S]-env (S'' ₛ)) ((Env.sig-∈-single (S'' ₛ) Signal.unknown)) ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ))) ⟩ (θ ← (Env.set-sig{(S'' ₛ)} ([S]-env (S'' ₛ)) ((Env.sig-∈-single (S'' ₛ) Signal.unknown)) Signal.absent)) ≡⟨ cong (_←_ θ) (Env.sig-put-1map-overwrite' (S'' ₛ) Signal.unknown Signal.absent ((Env.sig-∈-single (S'' ₛ) Signal.unknown))) ⟩ (θ ← [S]-env-absent (S'' ₛ)) ∎) = λ k k∈ → canθₛₕ-set-sig-monotonic sigs (suc S'') p (S'' ₛ) (θ ← [S]-env (S'' ₛ)) ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ)) Signal.absent ((Env.sig-stats-1map-right-← (S'' ₛ) Signal.unknown θ ((Env.sig-∈-single-right-← (S'' ₛ) Signal.unknown θ)))) (n∉map-suc-n-+ S'' (SigM.Dom' sigs)) k (r k k∈) canθₖ-term-nothin-lemma : ∀ sigs S' → ∀ {r} θ E → term-nothin r → ∀ k → k ∈ Canθₖ sigs S' (E ⟦ nothin ⟧e) θ → k ∈ Canθₖ sigs S' (E ⟦ r ⟧e) θ canθₖ-term-nothin-lemma sigs S' {r} θ E tr = canθₖ-subset-lemma sigs S' (E ⟦ nothin ⟧e) (E ⟦ r ⟧e) θ (λ θ' S x → canₛ-term-nothin-lemma θ' E tr S x) (λ θ → canₖ-term-nothin-lemma θ E tnothin tr) canθₛ-term-nothin-lemma : ∀ sigs S' → ∀ {r} θ E → term-nothin r → ∀ S → S ∈ Canθₛ sigs S' (E ⟦ nothin ⟧e) θ → S ∈ Canθₛ sigs S' (E ⟦ r ⟧e) θ canθₛ-term-nothin-lemma sigs S' {r} θ E tr = canθₛ-subset-lemma sigs S' (E ⟦ nothin ⟧e) (E ⟦ r ⟧e) θ (λ θ' S x → canₛ-term-nothin-lemma θ' E tr S x)
{ "alphanum_fraction": 0.5409799236, "avg_line_length": 48.3346495558, "ext": "agda", "hexsha": "fdac92bf3823b2be1d33c17bfa2447cd98e8b642", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_path": "agda/Esterel/Lang/CanFunction/NonMergePotentialRules.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "florence/esterel-calculus", "max_issues_repo_path": "agda/Esterel/Lang/CanFunction/NonMergePotentialRules.agda", "max_line_length": 184, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_path": "agda/Esterel/Lang/CanFunction/NonMergePotentialRules.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "num_tokens": 50568, "size": 97926 }
open import Oscar.Prelude open import Oscar.Class open import Oscar.Class.HasEquivalence open import Oscar.Class.Quadricity open import Oscar.Class.Injectivity open import Oscar.Class.Congruity open import Oscar.Class.Leftstar open import Oscar.Class.Properthing open import Oscar.Class.Smap open import Oscar.Class.Symmetry open import Oscar.Data.Fin open import Oscar.Data.Substitunction open import Oscar.Data.Term open import Oscar.Data.Surjcollation open import Oscar.Data.Surjextenscollation open import Oscar.Data.Proposequality open import Oscar.Property.Setoid.Proposequality open import Oscar.Property.Setoid.Proposextensequality open import Oscar.Property.Functor.SubstitunctionExtensionTerm open import Oscar.Property.Thickandthin.FinTermProposequalityMaybeProposequality import Oscar.Class.Congruity.Proposequality import Oscar.Class.Congruity.Proposextensequality import Oscar.Class.Surjection.⋆ open import Oscar.Property.Setoid.ṖropertyEquivalence import Oscar.Class.Properthing.Ṗroperty open import Oscar.Data.ProductIndexEquivalence import Oscar.Data.ExtensionṖroperty open import Oscar.Data.ProperlyExtensionNothing import Oscar.Class.Properthing.ExtensionṖroperty import Oscar.Class.Smap.TransitiveExtensionLeftṖroperty import Oscar.Class.Smap.ExtensionṖroperty import Oscar.Class.[ExtensibleType].Proposequality import Oscar.Class.HasEquivalence.ExtensionṖroperty import Oscar.Class.HasEquivalence.Ṗroperty import Oscar.Class.HasEquivalence.Substitunction open import Oscar.Class.Reflexivity open import Oscar.Class.Similarity open import Oscar.Class.Quadricity open import Oscar.Class.Surjection open import Oscar.Class.Leftunit module Oscar.Property.Propergroup.Substitunction where module _ {𝔭} {𝔓 : Ø 𝔭} {ℓ : Ł} where open Substitunction 𝔓 instance 𝓢urjectextenscongruityArrowṖropertySubstitunction : Similarity,smaphomarrow!.class Substitunction (LeftṖroperty ℓ Substitunction) _≈_ 𝓢urjectextenscongruityArrowṖropertySubstitunction .⋆ _ (∁ P⇔Q) .π₀ = P⇔Q 𝓢urjectextenscongruityArrowExtensionṖropertySubstitunction : Similarity,smaphomarrow!.class Substitunction (LeftExtensionṖroperty ℓ Substitunction _≈_) _≈_ 𝓢urjectextenscongruityArrowExtensionṖropertySubstitunction .⋆ _ (∁ (∁ P⇔Q)) .π₀ = ∁ P⇔Q -- P⇔Q module _ {𝔭} {𝔓 : Ø 𝔭} where open Term 𝔓 module S = Surjcollation (Arrow Fin Term) _≡_ module Ṡ = Surjextenscollation (Arrow Fin Term) _≡̇_ instance 𝒫roperfact1UnifiesSubstitunctionFork : ∀ {n} → Properfact1.class S._⟹_ (_fork_ {n = n}) 𝒫roperfact1UnifiesSubstitunctionFork .⋆ _ _ _ _ .π₀ = (λ s≡t → injectivity₂,₀,₁ s≡t , injectivity₂,₀,₂ s≡t) , uncurry (congruity₂ _fork_) 𝒫roperfact1ExtensionalUnifiesSubstitunctionFork : ∀ {n} → Properfact1.class Ṡ._⟹_ (_fork_ {n = n}) 𝒫roperfact1ExtensionalUnifiesSubstitunctionFork .⋆ _ _ _ _ .π₀ .π₀ = (λ s≡t → injectivity₂,₀,₁ s≡t , injectivity₂,₀,₂ s≡t) , uncurry (congruity₂ _fork_) instance 𝓕actsurj3Regular : ∀ {ℓ} → Leftunit,equivalence,smaphomarrow!.class (Arrow Fin Term) (LeftṖroperty ℓ (Arrow Fin Term)) 𝓕actsurj3Regular .⋆ .π₀ = ¡ , ¡ 𝓕actsurj3Extension : ∀ {ℓ} → Leftunit,smaphomarrow.class (Arrow Fin Term) (LeftExtensionṖroperty ℓ (Arrow Fin Term) (Pointwise Proposequality)) ε surjection smaparrow _≈_ 𝓕actsurj3Extension .⋆ .π₀ .π₀ = ¡ , ¡ open Substitunction 𝔓 instance 𝓕actsurj4Regular : ∀ {ℓ} → Leftstar,smaphomarrow!.class (LeftṖroperty ℓ (Arrow Fin Term)) (Arrow Fin Term) Nothing 𝓕actsurj4Regular .⋆ _ (∁ nop) .π₀ = nop 𝓕actsurj4Extension : ∀ {ℓ} → Leftstar,smaphomarrow!.class (LeftExtensionṖroperty ℓ Substitunction (Pointwise Proposequality)) (Arrow Fin Term) Nothing 𝓕actsurj4Extension .⋆ _ (∁ nop) .π₀ = nop instance 𝓕actsurj6Extension : ∀ {ℓ} → Similarity,cosmaphomarrow!.class Substitunction (ArrowExtensionṖroperty ℓ Fin Term Proposequality) _≈_ _≈_ 𝓕actsurj6Extension .⋆ P f≐g .π₀ .π₀ {f = h} = π₁ P (congruity (smap h) ∘ f≐g) , π₁ P (symmetry (congruity (smap h) ∘ f≐g)) -- FIXME replacing symmetry with Sym.[] fails
{ "alphanum_fraction": 0.7787893701, "avg_line_length": 41.8969072165, "ext": "agda", "hexsha": "b822128926ba04e47489945e6aa813f0d966ab46", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Oscar/Property/Propergroup/Substitunction.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Oscar/Property/Propergroup/Substitunction.agda", "max_line_length": 175, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Oscar/Property/Propergroup/Substitunction.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1380, "size": 4064 }
-- Andreas, 2014-06-27 -- {-# OPTIONS -v tc.lhs:40 #-} {-# OPTIONS --copatterns #-} record Coind : Set where coinductive field ind : Coind open Coind loop : Set -> Coind ind A (loop B) = ind (loop A) -- WAS: Internal error. -- NOW: Proper error. -- Cannot eliminate type Coind with pattern ind A (did you supply too many arguments?) -- when checking that the clause ind A (loop B) = ind (loop A) has -- type Set → Coind
{ "alphanum_fraction": 0.6573426573, "avg_line_length": 21.45, "ext": "agda", "hexsha": "37e496d5e9e3f219fd062bb1799b8a860ec1daef", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Issue1216a.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Issue1216a.agda", "max_line_length": 86, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue1216a.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 129, "size": 429 }
open import Agda.Builtin.String open import Agda.Builtin.Equality test : String → String → String test "x" b = "left" test a "x" = "right" test a b = "nowhere" _ : test "a" "x" ≡ "right" _ = refl
{ "alphanum_fraction": 0.648241206, "avg_line_length": 16.5833333333, "ext": "agda", "hexsha": "8cd8eca645214666cff7e89d6e2677b16930cfad", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue2954.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue2954.agda", "max_line_length": 33, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue2954.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 70, "size": 199 }