Comments (3)
This turns out to have been a mysterious scoping bug which only arose when type checking things with lambdas in their type that happened to have the same name as something whose scope had previously been resolved. Now fixed.
from idris-dev.
I am afraid this could be an instance of the same problem, though in a slightly more involved situation. The following code type checks
> module TestBound
> soFalseElim : so False -> a
> soFalseElim x = FalseElim (believe_me x)
> X : Set
> X = (n : Nat ** so (n < 3))
> (==) : X -> X -> Bool
> (==) x x' = (getWitness x == getWitness x')
> data Move = L | R
> adm : X -> Move -> Bool
> adm (n ** _) L = n <= 1
> adm (n ** _) R = n >= 1
> Y : X -> Set
> Y x = (a : Move ** so (adm x a))
> step : (x : X) -> Y x -> X
> step (O ** _) (L ** _) = (2 ** oh)
> step ((S n) ** _) (L ** _) = (n ** believe_me oh) -- trivial
> step (n ** _) (R ** _) =
> if n == 2 then (O ** oh) else (S n ** believe_me oh)
> pred : X -> X -> Bool
> pred x x' = (adm x L && x' == step x (L ** believe_me oh)) ||
> (adm x R && x' == step x (R ** believe_me oh))
> succs : X -> (n : Nat ** Vect X n)
> succs x = filter (pred x) [(0 ** oh),(1 ** oh),(2 ** oh)]
> preds : X -> (n : Nat ** Vect X n)
> preds x' = filter ((flip pred) x') [(0 ** oh),(1 ** oh),(2 ** oh)]
> emptyC : (n : Nat ** Vect X n) -> Bool
> emptyC (_ ** Nil) = True
> emptyC (_ ** (x :: xs)) = False
> inC : X -> (n : Nat ** Vect X n) -> Bool
> inC _ (_ ** Nil) = False
> inC x (_ ** (x' :: xs')) = x == x' || inC x (_ ** xs')
> someC : (X -> Bool) -> (n : Nat ** Vect X n) -> Bool
> someC _ (_ ** Nil) = False
> someC p (_ ** (x :: xs)) = p x || someC p (_ ** xs)
> lemmaC2 : (xs : (n : Nat ** Vect X n)) ->
> so (not (emptyC xs)) ->
> (x : X ** so (x `inC` xs))
> lemmaC2 (_ ** Nil) soF = soFalseElim soF
> lemmaC2 (_ ** (x :: xs)) _ = (x ** believe_me oh)
> lemmaC3 : (x : X) ->
> (p : X -> Bool) ->
> (xs : (n : Nat ** Vect X n)) ->
> so (p x) ->
> so (inC x xs) ->
> so (someC p xs)
> lemmaC3 _ _ (_ ** Nil) _ soF = soFalseElim soF
> lemmaC3 _ _ (_ ** (x :: xs)) _ _ = ?lemmaC3_2
> succsTh : (x : X) -> so (not (emptyC (succs x)))
> succsTh x = ?lala
> reachable : (m : Nat) -> X -> Bool
> reachable O _ = True
> reachable (S m) x' = someC (reachable m) (preds x')
> viable : (n : Nat) -> X -> Bool
> viable O _ = True
> viable (S n) x = someC (viable n) (succs x)
> viableTh : (n : Nat) -> (x : X) -> so (viable n x)
> viableTh O _ = oh
> viableTh (S n) k = step2 where
> step0 : so (not (emptyC (succs k)))
> step0 = succsTh k
> step1 : (x' : X ** so (x' `inC` (succs k)))
> step1 = lemmaC2 (succs k) step0
> step2 : so (someC (viable n) (succs k))
> step2 = lemmaC3 x' (viable n) (succs k) vnx' x'inCsuccsx where
> x' : X
> x' = getWitness step1
> vnx' : so (viable n x')
> vnx' = viableTh n x' -- induction step
> x'inCsuccsx : so (x' `inC` (succs k))
> x'inCsuccsx = getProof step1
But replacing |k| with |x| in the second pattern of the definition of |viableTh| yields
test_bound.lidr:81:Can't unify (x' ** so (inC x' ...)) with (x ** so (inC x ...))
Maybe re-open the issue ?
from idris-dev.
There was a rendering error in the above message (I used |pre| instead of |````| to mark code) which made the code unusable. It should type check, now.
from idris-dev.
Related Issues (20)
- Types appear to match but fail HOT 4
- Totality checker thinks simple function is total when it's not HOT 1
- Broken sections of custom operators starting with pipe '|', "expecting function name"
- in interfaces.rst, replace "brackets" by "parentheses" HOT 3
- Totality check fails on simple structural recursion when it is not tail recusive
- Dependent constructor reproted as not strictly positive when in mutual block HOT 1
- Installation from hackage fails with ghc 8.10.2 in cabal configuration step HOT 1
- Is there a color scheme for IntelliJ?
- Idris not located in terminal.
- Please update dependency upperbounds HOT 2
- `pkg010` test output depends on version of optparse-applicative library used
- Lambda in place of Type HOT 1
- Data.Primitives.Views.divides behaves odd with negative dividend
- idris-1.3.3 fails with haskeline-0.8 HOT 2
- Type checker confused by overloaded `fst` (or just a strange error message)
- Test ffi008 fails with "multiple definition of `mystruct'"
- Cannot define recursive bound on associated type of an interface
- Incorrect behaviour when resolving associated type of an interface
- List available operators
- Dead download link for idris-1.3.3-win64.exe HOT 1
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 idris-dev.