Comments (5)
Here is a version without std-lib and without abstract
:
{-# OPTIONS --rewriting #-}
open import Agda.Builtin.Equality using (_≡_; refl)
open import Agda.Builtin.List using (List; _∷_)
data Ty : Set where
arr : Ty → Ty → Ty
Ctx : Set
Ctx = List Ty
data Idx : Ctx → Ty → Set where
zero : {Γ : Ctx} {τ : Ty} → Idx (τ ∷ Γ) τ
suc : {Γ : Ctx} {τ₁ τ₂ : Ty} → Idx Γ τ₂ → Idx (τ₁ ∷ Γ) τ₂
data Expr (Γ : Ctx) : Ty → Set where
var : {τ : Ty} → Idx Γ τ → Expr Γ τ
abstraction : {τ₁ τ₂ : Ty} → Expr (τ₁ ∷ Γ) τ₂ → Expr Γ (Ty.arr τ₁ τ₂)
module Rename where
Rename : Ctx → Ctx → Set
Rename Γ Γ' = {τ : Ty} → Idx Γ τ → Idx Γ' τ
cons : {Γ Γ' : Ctx} {τ : Ty} → Idx Γ' τ → Rename Γ Γ' → Rename (τ ∷ Γ) Γ'
cons idx ρ Idx.zero = idx
cons idx ρ (Idx.suc idx') = ρ idx'
ext : {Γ Γ' : Ctx} {τ : Ty} → Rename Γ Γ' → Rename (τ ∷ Γ) (τ ∷ Γ')
ext ρ = cons Idx.zero (λ x → Idx.suc (ρ x))
rename : {Γ Γ' : Ctx} {τ : Ty} → Rename Γ Γ' → Expr Γ τ → Expr Γ' τ
rename ρ (Expr.var idx) = Expr.var (ρ idx)
rename ρ (Expr.abstraction e) = Expr.abstraction (rename (ext ρ) e)
open Rename using (Rename)
Subst : Ctx → Ctx → Set
Subst Γ Γ' = {τ : Ty} → Idx Γ τ → Expr Γ' τ
infixr 6 _•_
_•_ : {Γ Γ' : Ctx} {τ : Ty} → Expr Γ' τ → Subst Γ Γ' → Subst (τ ∷ Γ) Γ'
_•_ e σ Idx.zero = e
_•_ e σ (Idx.suc idx) = σ idx
⟰ : {Γ Γ' : Ctx} {τ : Ty} → Subst Γ Γ' → Subst Γ (τ ∷ Γ')
⟰ σ idx = Rename.rename Idx.suc (σ idx)
ext : {Γ Γ' : Ctx} {τ : Ty} → Subst Γ Γ' → Subst (τ ∷ Γ) (τ ∷ Γ')
ext σ = Expr.var Idx.zero • ⟰ σ
subst : {Γ Γ' : Ctx} {τ : Ty} (σ : Subst Γ Γ') → Expr Γ τ → Expr Γ' τ
subst σ (Expr.var idx) = σ idx
subst σ (Expr.abstraction e) = Expr.abstraction (subst (ext σ) e)
ren : {Γ Γ' : Ctx} → Rename Γ Γ' → Subst Γ Γ'
ren ρ x = Expr.var (ρ x)
postulate
_;_ : {Γ Γ' Γ'' : Ctx} → Subst Γ Γ' → Subst Γ' Γ'' → Subst Γ Γ''
-- (σ ; σ') x = subst σ' (σ x)
seq-def : {Γ Γ' Γ'' : Ctx} {τ : Ty} (σ : Subst Γ Γ') (σ' : Subst Γ' Γ'') (idx : Idx Γ τ) → (σ ; σ') idx ≡ subst σ' (σ idx)
-- seq-def σ σ' idx = refl
{-# BUILTIN REWRITE _≡_ #-}
{-# REWRITE seq-def #-}
subst-ren : {Γ Γ' Γ'' : Ctx} {τ : Ty} (ρ : Rename Γ' Γ'') (σ : Subst Γ Γ') (e : Expr Γ τ) → subst (ren ρ) (subst σ e) ≡ subst (σ ; (ren ρ)) e
subst-ren ρ σ (Expr.var idx) = refl
subst-ren ρ σ (Expr.abstraction e) with subst-ren (Rename.ext ρ) (ext σ) e
... | x = {!!}
This works as expected in Agda 2.5 and starts failing in 2.6.0.
from agda.
Bisection points to commit 031c69d @jespercockx
Date: Thu May 31 10:46:49 2018 +0200
[ rewriting ] Make non-linear matching more type-directed
The code has evolved quite a bit, but there is a fishy bit that is still here from the original commit: 031c69d#r141318594
agda/src/full/Agda/TypeChecking/Rewriting/NonLinMatch.hs
Lines 349 to 353 in c7541af
k
here is the context of variables bound by lambdas in the higher-order pattern. It is represented as a telescope. This feels unusual and is maybe wrong. Telescopes are extended on the left (B --> Sigma A B
) while context are extended on the right (A --> Sigma A B
). When going under a binder, we need to extend on the right, so telescopes seem wrong, and contexts would be right for the bound variables, if I am not mistaken.
The symptom is:
{-# OPTIONS -v rewriting:60 #-}
...
rewrote comp σ (ren ρ) idx
to subst (λ {τ} z → var (ρ τ)) (σ τ)
This is ill-typed, correct would be subst (λ z {τ} → var (ρ z)) (σ idx)
, so it seems that the lambdas are assembled in the wrong order.
from agda.
telescopes seem wrong, and contexts would be right for the bound variables
PR incoming that implements this, fixing the issue...
from agda.
Is there a workaround available for this other than reverting to 2.5?
from agda.
Not sure what exactly you are intending to do, but you could try opaque/unfolding
instead of abstract/REWRITE
(if you want to control the unfolding of substitution composition).
from agda.
Related Issues (20)
- Proof of ⊥ using HIT-indexed type HOT 6
- Literate programming Org/LaTeX feature request
- `--save-metas` causes internal error in `lookupMetaInstantiation` HOT 3
- Consider using `Set` instead of `nub`
- Mimer options `-l` and `-s` not covered by testsuite HOT 2
- The specification of `--safe` misses the pragmas
- MAlonzo bug: `unreachable code reached` HOT 9
- Our error messages do not follow the GNU standard HOT 4
- Agda 2.7.0-rc1 crashes when run twice, probably serialization issue HOT 3
- .cabal description "...: It ..." HOT 4
- Is pattern `AnnP` unused? (added in Oct 2020 as "not usable yet") HOT 2
- Pattern matching unifier does not preserve instances HOT 1
- `__IMPOSSIBLE__` error in `SSet` but not in `Set` HOT 2
- Cabal 3.12.1.0 install failure for `lib:Agda` - dist/build/agda/agda does not exist HOT 5
- Mimer internal error in hole with constraint HOT 1
- Wanted: reproducer for error "The type is non-fibrant or its sort depends on an interval variable" HOT 1
- Trigger failure of `checkModalityArgs` HOT 4
- Reproduce errors in createMissingHCompClause HOT 2
- `cabal install Agda` fails -- missing files in multiple pacakges HOT 2
- Erasure and irrelevance forbid deeper absurd patterns HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from agda.