Agda Environment
Demo
Interaction should follow Jupyter Agda Kernel rules, e.g Tab for symbol expansion or hole filling, Shift+Tab to inspect goal summary.
module HelloAgda wheredata ℕ : Set where zero : ℕ suc : ℕ → ℕ_+_ : ℕ → ℕ → ℕzero + b = bsuc a + b = suc (a + b)import Relation.Binary.PropositionalEquality as Eqopen Eq using (_≡_; refl; cong; sym)open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎)_ : 1 + 1 ≡ 2_ = begin 1 + 1 ≡⟨⟩ (suc 0) + 1 ≡⟨⟩ suc (0 + 1) ≡⟨⟩ suc 1 ≡⟨⟩ 2 ∎Setup
Agda Install
Get dependencies and the Cabal package manager.
apt-get -qq updateDEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends \ zlib1g-dev libncurses5-dev libicu-dev \ ghc cabal-install alex happyapt-get cleanrm -r /var/lib/apt/lists/* # Clear package list so it isn't staleInstall Agda via Cabal.
cabal updatecabal install --jobs=16 Agda-2.6.1.2Install Agda Standard Library
And require it by default. See the installation instructions for more informations.
mkdir -p /opt/agdawget -O /opt/agda/agda-stdlib.tar https://github.com/agda/agda-stdlib/archive/v1.4.tar.gzcd /opt/agdatar -zxvf agda-stdlib.tarcd /opt/agda/agda-stdlib-1.4cabal installmkdir -p ~/.agdaecho "/opt/agda/agda-stdlib-1.4/standard-library.agda-lib" > ~/.agda/librariesecho "standard-library" > ~/.agda/defaultsInstall Jupyter and Agda Jupyter Kernel from nextjournal fork (better support for completions, e.g. give + case split).
agda --versionIntall Jupyter Kernel
previous kernel at 5486b2b9f277aa3434f889e6064cff4a8061d614. (Environment timestamp: 2020-07-09 09:31:15).
conda install jupyterpip install --upgrade jupyter_client jupyter_corepip install \ git+https://github.com/nextjournal/agda-kernel.git@9139338a08e4c14c305fe6f16602fcc8a4a03150python -m agda_kernel.installCheck.
du -hsx /agda -Vjupyter kernelspec listStdlib Warmup
This is a warmup of stdlib imports for faster import at "runtime".
module StdLibWarmup whereimport Relation.Binary.PropositionalEquality as Eqopen Eqopen Eq.≡-Reasoningopen import Data.Natopen import Data.Nat.Propertiesopen import Data.Finopen import Data.Fin.Propertiesopen import Levelopen import Functionopen import Function.Inverseopen import Function.LeftInverseopen import Data.Emptyopen import Data.Sumopen import Data.Productopen import Data.Unitopen import Data.Boolopen import Data.Vecopen import Data.Vec.Propertiesopen import Data.Listopen import Data.List.Propertiesopen import Data.Fin.Subsetopen import Data.Fin.Subset.Propertiesopen import Data.Sumopen import Data.Productopen import Relation.Nullaryopen import Relation.Nullary.Negationopen import Relation.Nullary.Decidableopen import Relation.Unaryopen import Relation.Binaryopen import AlgebraPLFA Environment
Agda with on top the book installed as library
cd /opt/agdaif [ -d "plfa.github.io" ]; then rm -rf plfa.github.iofigit clone https://github.com/plfa/plfa.github.iocat opt/agda/plfa.github.io/plfa.agda-libecho "/opt/agda/plfa.github.io/plfa.agda-lib" >> ~/.agda/librariescat ~/.agda/librariesecho "plfa" >> ~/.agda/defaultscat ~/.agda/defaultsTest PLFA Imports
module plfa.part1.Connectives whereimport Relation.Binary.PropositionalEquality as Eqopen Eq using (_≡_; refl)open Eq.≡-Reasoningopen import Data.Nat using (ℕ)open import Function using (_∘_)open import plfa.part1.Isomorphism using (_≃_; _≲_; extensionality)open plfa.part1.Isomorphism.≃-ReasoningexportBuild Agda 2.6.1.2
This is our "official" default Agda v2.6.1.2 environment ships with standard library and the cubical library. This will be used when adding an agda cell via ```agda or insert-menu.
wget -O /opt/agda/cubical-v0.2.tar \ https://github.com/agda/cubical/archive/v0.2.tar.gzcd /opt/agdatar -zxvf cubical-v0.2.tarecho "/opt/agda/cubical-0.2/cubical.agda-lib" >> ~/.agda/librariesecho "cubical" >> ~/.agda/defaultsmodule CubiTest {ℓ} whereopen import Cubical.Core.Primitives hiding (_≡_)_ : I_ = i0_ = i1postulate ℐ : I → Set ℓ a₀ : (ℐ i0) a₁ : (ℐ i1)-- PathP : (ℐ : I → Set ℓ) → (ℐ i0) → (ℐ i1) → Set ℓ-- intro and elimPathP⁺ : (f : (i : I) → (ℐ i)) → PathP ℐ (f i0) (f i1)PathP⁺ f = λ i → f iPathP⁻ : (p : PathP ℐ a₀ a₁) → (r : I) → (ℐ r)PathP⁻ p r = p r-- equality_≡_ : {A : Set ℓ} → A → A → Set ℓ_≡_ {A} = PathP (λ _ → A)funExt : {A : Set ℓ} → {B : A → Set ℓ} → {f g : (x : A) → B x} → (p : (x : A) → f x ≡ g x) → f ≡ gfunExt p = λ i x → (p x) i