question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tycker tries to solve implicit argument in Pi types even when not needed

See original GitHub issue

Commit: 1707136

open data Unit : Set | unit

def foo : Pi {x : Unit} -> Unit => \{x} => x

def foo' : Pi {x : Unit} -> Unit => foo

Update:

@re-xyr The real use case is much more complex and the return type does depend on the implicit argument:

-- *** Prelude

prim I
prim left
prim right
prim arcoe
struct Path (A : I -> Type) (a : A left) (b : A right) : ooType
 | at (i : I) : A i {
   | left => a
   | right => b
 }
def path {A : I -> Type} (p : Pi (i : I) -> A i)
  => new Path A (p left) (p right) { | at i => p i }
def `=` Eq {A : Type} (a b : A) : ooType => Path (\ i => A) a b
def idp {A : Type} (a : A) : a = a => path (\ i => a)
def coe {a b : Type} (eq : a = b) (x : a) (i : I) : eq.at i
  => arcoe eq.at x i

bind = looser application

open data Unit : Set 0 | unit


-- *** Types

struct EventT : Set 1
  | agentT : Set 0

def getAgentT (t : EventT) : Set 0 => t.agentT
def setAgentT (x : Set 0) (t : EventT) : EventT
  => new EventT { | agentT => x }
def agentT-inv (t : EventT) (u : Set 0) : u = getAgentT (setAgentT u t)
  => idp u


struct Event (t : EventT) : Set 2
  | agent : t.agentT

def getAgent (t : EventT) (e : Event t) : t.agentT => e.agent


def Theta (setT : Set 0 -> EventT -> EventT) : ooType 4
  => Pi {u : Set 0} {t : EventT}
  -> ((u -> ooType 3) -> ooType 3)
  -> ((Event (setT u t) -> ooType 3) -> ooType 3)
  -> (Event (setT u t) -> ooType 3) -> ooType 3

def mkTheta
  (getT : EventT -> Set 0)
  (get : Pi (t : EventT) -> Event t -> getT t)
  (setT : Set 0 -> EventT -> EventT)
  (invariant : Pi (t : EventT) (u : Set 0) -> u = getT (setT u t))
  : Theta setT
  => \{u} {t} => \q p => \f =>
    q (\x => p (\e =>
      Sig (get (setT u t) e = coe (invariant t u) x right) ** (f e)))

def agent : Theta setAgentT
  => mkTheta getAgentT getAgent setAgentT agentT-inv

I had to change agent into \{u} {t} => mkTheta getAgentT getAgent setAgentT agentT-inv {u} {t} to make it type check.

I simplified it too much, sorry.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:21 (21 by maintainers)

github_iconTop GitHub Comments

1reaction
ice1000commented, Nov 7, 2021

I’ve managed to DRASTICALLY enhance the error messages!!!

If we have

def agent : Theta setAgentT
  => \{u} {v} => mkTheta getAgentT getAgent setAgentT agentT-inv {_} {_}

You’ll see

In file test.aya:51:70 ->

  49 | 
  50 | def agent : Theta setAgentT
  51 |   => \{u} {v} => mkTheta getAgentT getAgent setAgentT agentT-inv {_} {_}
                                                                             ^^

Error: Unsolved meta _7
       in `mkTheta getAgentT getAgent setAgentT agentT-inv {u} {_7}`
       in `λ {v} ⇒ mkTheta getAgentT getAgent setAgentT agentT-inv {u} {_7}`
       in `λ {u} {v} ⇒ mkTheta getAgentT getAgent setAgentT agentT-inv {u} {_7}`

1 error(s), 0 warning(s).
🔨

It’s MUCH BETTER than the freaking monstrosity in, e.g. https://github.com/aya-prover/aya-dev/issues/9#issuecomment-961337175!!!

Drink, drink, raise your glass, raise your glass high🥂!

1reaction
ice1000commented, Nov 6, 2021
-- #5 in public repo
prim I
prim left
prim right
prim arcoe
struct Path (A : I -> Type) (a : A left) (b : A right) : Type
 | at (i : I) : A i {
   | left => a
   | right => b
 }
def path {A : I -> Type} (p : Pi (i : I) -> A i)
  => new Path A (p left) (p right) { | at i => p i }
def infix = {A : Type} (a b : A) : Type => Path (\ i => A) a b
def idp {A : Type} {a : A} : a = a => path (\ i => a)

open data Unit | unit

-- *** Types

struct EventT : Type 1
  | agentT : Type 0

def getAgentT (t : EventT) : Type 0 => t.agentT
def setAgentT (x : Type 0) (t : EventT) : EventT
  => new EventT { | agentT => x }
def agentT-inv (t : EventT) (u : Type 0) : u = getAgentT (setAgentT u t)
  => idp
struct Event (t : EventT) : Type 2
  | agent : t.agentT

def getAgent (t : EventT) (e : Event t) : t.agentT => e.agent
def Theta (setT : Type 0 -> EventT -> EventT) : Type 4
  => Pi {u : Type 0} {t : EventT}
  -> ((u -> Type 3) -> Type 3)
  -> ((Event (setT u t) -> Type 3) -> Type 3)
  -> (Event (setT u t) -> Type 3) -> Type 3

def coe {a b : Type} (eq : a = b) (x : a) (i : I) : eq.at i
  => arcoe eq.at x i
def mkTheta
  (getT : EventT -> Type 0)
  (get : Pi (t : EventT) -> Event t -> getT t)
  (setT : Type 0 -> EventT -> EventT)
  (invariant : Pi (t : EventT) (u : Type 0) -> u = getT (setT u t))
  : Theta setT
  => \{u} {t} => \q p => \f =>
    q (\x => p (\e =>
      Sig (get (setT u t) e = coe (invariant t u) x right) ** (f e)))

def agent : Theta setAgentT
  => mkTheta getAgentT getAgent setAgentT agentT-inv

Full, working example

Read more comments on GitHub >

github_iconTop Results From Across the Web

[PDF] Conditions on Argument Drop - ResearchGate
PDF | This article pursues the idea that null arguments are derived without any statement or parameter, instead following naturally from 3rd factor....
Read more >
grommunio Administrator Documentation
Create the corresponding DNS records with a sane configuration (A, MX, TXT and CNAME records). • Configure the grommunio appliance by running ...
Read more >
Quasi-definites in Swedish: Elative superlatives and emphatic ...
We argue that the article and the suffix do not encode different aspects of definiteness, as Julien (2005) proposes; rather, both are markers...
Read more >
Untitled
El clasico barca real, Jogador mais feio do mundo, Notaris van hoestenberghe ... with methods of evaluating arguments for, Images not loading on...
Read more >
ED112893.pdf - ERIC - Department of Education
ABSTRACT. To test some aspects of Skinnerian programed instruction, a 241-frate program on Swedish grammar was presented to students 10 to 12 years...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found