Last active
August 29, 2015 14:10
-
-
Save dima-starosud/7100947b0e243ea6a034 to your computer and use it in GitHub Desktop.
I'm not sure if there should be a case for the constructor ..., because I get stuck when trying to solve the following unification problems
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open import Function | |
open import Relation.Binary.PropositionalEquality | |
open import Data.Product | |
open import Data.String | |
open import Data.Bool | |
open import Data.Unit | |
record Level : Set where | |
constructor level | |
field | |
vars : Bool | |
lams : Bool | |
lets : Bool | |
infixl 6 _⊔_ | |
_⊔_ : Level → Level → Level | |
level v₁ lm₁ lt₁ ⊔ level v₂ lm₂ lt₂ = level (v₁ ∨ v₂) (lm₁ ∨ lm₂) (lt₁ ∨ lt₂) | |
pattern Core = level false false false | |
data Term : Level -> Set where | |
S : Term Core | |
K : Term Core | |
I : Term Core | |
_$$_ : ∀ {a b} → Term a → Term b → Term (a ⊔ b) | |
Var : String → Term (record Core {vars = true}) | |
Lam : ∀ {a} → String → Term a → Term (record a {lams = true}) | |
Let : ∀ {a b} → String → Term a → Term b → Term (record (a ⊔ b) {lets = true}) | |
infixr 1 _$$_ | |
infixr 1 _$[_][_]$_ | |
pattern _$[_][_]$_ A a b B = _$$_ {a = a} {b = b} A B | |
infixr 1 _$₀_ | |
pattern _$₀_ a b = _$$_ {a = Core} {b = Core} a b | |
reduce₁ : Term Core → Term Core | |
reduce₁ (I $₀ x) = _ | |
reduce₁ (K $₀ x $₀ _) = _ | |
reduce₁ (S $₀ x $₀ y $₀ z) = _ | |
reduce₁ (f $₀ x) = _ | |
reduce₁ t = _ | |
{- | |
Level.lets a ∨ Level.lets b != false of type Bool | |
when checking that the pattern | |
_$$_ {a = level false false false} {b = level false false false} I | |
x | |
has type Term (level false false false) | |
-} | |
reduce₂ : ∀ {l} → Term l → l ≡ Core → Term Core | |
reduce₂ (I $$ x) = _ | |
reduce₂ (K $$ x $$ _) = _ | |
reduce₂ (S $$ x $$ y $$ z) = _ | |
reduce₂ (f $$ x) = _ | |
reduce₂ t = _ | |
reduce₃ : ∀ {l} → Term l → l ≡ Core → Term Core | |
reduce₃ (I $[ .Core ][ Core ]$ x) = _ | |
reduce₃ (K $[ .Core ][ .Core ]$ x $[ Core ][ Core ]$ _) = _ | |
reduce₃ (S $[ .Core ][ .Core ]$ x $[ Core ][ .Core ]$ y $[ Core ][ Core ]$ z) = _ | |
reduce₃ (f $[ Core ][ Core ]$ x) = _ | |
reduce₃ t = _ | |
{- | |
I'm not sure if there should be a case for the constructor _$$_, | |
because I get stuck when trying to solve the following unification | |
problems (inferred index ≟ expected index): | |
a ⊔ b ≟ level true lams lets | |
when checking the definition of reduce₃ | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The problem is that you are indexing your family Term by non-patterns in some of the constructor cases. Then Agda can sometimes not solve the unification constraints involved in dependent pattern matching, and gives up or produces error messages. The solution is to use explicit proofs of equality in your constructors instead.
Here is a cut-down version of your plight: