Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Holes are checked but not filled #2

Open
sofia-snow opened this issue Aug 26, 2022 · 1 comment
Open

Holes are checked but not filled #2

sofia-snow opened this issue Aug 26, 2022 · 1 comment

Comments

@sofia-snow
Copy link

When checking the implementation of evilDup against its type signature, the SMT solver decides the hole can be filled with .2, which is correct. However, it does not fill the hole in the type signature, so later code, such as illegal can infer the hole can be filled with .1.

Manually filling the hole with .2 checks evilDup (and isn't so evil), and correctly fails to check illegal. Filling with .1 obviously fails to check against evilDup's implementation.

evilDup : (a : (.0, .3) Type 0) -> (x : (_, .0) a) -> <a * a>                                                   
evilDup = \a -> \x -> <x, x>

illegal : (a : (.0, .3) Type 0) -> (x : (.1, .0) a) -> <a * a>
illegal = evilDup
INFO: Pretty CST:
      evilDup : (a : (.0, .3) Type 0) -> (x : (_, .0) a) -> <a * a>
      evilDup = \ a -> \ x -> <x, x>
      illegal : (a : (.0, .3) Type 0) -> (x : (.1, .0) a) -> <a * a>
      illegal = evilDup
INFO: Pretty AST:
      evilDup`0 : (a`1 : (.0, .3) Type 0) -> (x`2 : (_`3, .0) a`1) -> <a`1 * a`1>
      evilDup`0 = \ (a`6 : (_`8, _`9) _`7) -> \ (x`10 : (_`12, _`13) _`11) -> <x`10, x`10>
      illegal`14 : (a`15 : (.0, .3) Type 0) -> (x`16 : (.1, .0) a`15) -> <a`15 * a`15>
      illegal`14 = evilDup`0
DEBUG: LENGTH 4
DEBUG: FUN EQN INFERENCE: finding signature for evilDup`0
DEBUG: FUN EQN INFERENCE: found sig: (a`1 : (.0, .3) Type 0) -> (x`2 : (_`3, .0) a`1) -> <a`1 * a`1>
DEBUG: checkExpr: checking expression '\ (a`6 : (_`8, _`9) _`7) -> \ (x`10 : (_`12, _`13) _`11) -> <x`10, x`10>' against type '(a`1 : (.0, .3) Type 0) -> (x`2 : (_`3, .0) a`1) -> <a`1 * a`1>' with input context []
DEBUG: > ensureEqualTypes: Checking that expected type '_`7' is equal to actual type 'Type 0'
DEBUG: > ensureEqualTypes: Equal with type: 'Type 0'
DEBUG: > checkExpr: inferring a type for expression 'Type 0' with input context []
DEBUG: > checkExpr: inferred a type 'Type 1' for expression 'Type 0' with output context subject grades [] and subject type grades []
DEBUG: > Adding grade vector equality: [] = []
DEBUG: > checkExpr: checking expression '\ (x`0 : (_`12, _`13) _`11) -> <x`0, x`0>' against type '(x`2 : (_`3, .0) a`1) -> <a`1 * a`1>' with input context [(a`1, [])]
DEBUG: >> ensureEqualTypes: Checking that expected type '_`11' is equal to actual type 'a`1'
DEBUG: >> ensureEqualTypes: Equal with type: 'a`1'
DEBUG: >> checkExpr: inferring a type for expression 'a`1' with input context [(a`1, [])]
DEBUG: >>> Infer for var a`1 in context [(a`1, [])]
DEBUG: >>> Infer for var (type) []
DEBUG: >>> checkExpr: inferring a type for expression 'Type 0' with input context []
DEBUG: >>> checkExpr: inferred a type 'Type 1' for expression 'Type 0' with output context subject grades [] and subject type grades []
DEBUG: >>> Adding grade vector equality: [] = []
DEBUG: >>> Context grade eq var a`1 with [] and []
DEBUG: >> checkExpr: inferred a type 'Type 0' for expression 'a`1' with output context subject grades [(a`1, .1)] and subject type grades [(a`1, .0)]
DEBUG: >> Adding grade vector equality: [(a`1, .0)] = [(a`1, .0)]
DEBUG: >> Adding smt equality: .0 = .0
DEBUG: >> checkExpr: checking expression '<x`2, x`2>' against type '<a`1 * a`1>' with input context [(a`1, []), (x`2, [(a`1, .1)])]
DEBUG: >>> checkExpr: inferring a type for expression 'x`2' with input context [(a`1, []), (x`2, [(a`1, .1)])]
DEBUG: >>>> Infer for var x`2 in context [(a`1, []), (x`2, [(a`1, .1)])]
DEBUG: >>>> Infer for var (type) [(a`1, [])]
DEBUG: >>>> checkExpr: inferring a type for expression 'a`1' with input context [(a`1, [])]
DEBUG: >>>>> Infer for var a`1 in context [(a`1, [])]
DEBUG: >>>>> Infer for var (type) []
DEBUG: >>>>> checkExpr: inferring a type for expression 'Type 0' with input context []
DEBUG: >>>>> checkExpr: inferred a type 'Type 1' for expression 'Type 0' with output context subject grades [] and subject type grades []
DEBUG: >>>>> Adding grade vector equality: [] = []
DEBUG: >>>>> Context grade eq var a`1 with [] and []
DEBUG: >>>> checkExpr: inferred a type 'Type 0' for expression 'a`1' with output context subject grades [(a`1, .1)] and subject type grades [(a`1, .0)]
DEBUG: >>>> Adding grade vector equality: [(a`1, .0)] = [(a`1, .0)]
DEBUG: >>>> Adding smt equality: .0 = .0
DEBUG: >>>> Context grade eq var x`2 with [(a`1, .1)] and [(a`1, .1)]
DEBUG: >>>> Adding smt equality: .1 = .1
DEBUG: >>> checkExpr: inferred a type 'a`1' for expression 'x`2' with output context subject grades [(a`1, .0), (x`2, .1)] and subject type grades [(a`1, .1), (x`2, .0)]
DEBUG: >>> ensureEqualTypes: Checking that expected type 'a`1' is equal to actual type 'a`1'
DEBUG: >>> ensureEqualTypes: Equal with type: 'a`1'
DEBUG: >>> checkExpr: inferring a type for expression 'x`2' with input context [(a`1, []), (x`2, [(a`1, .1)])]
DEBUG: >>>> Infer for var x`2 in context [(a`1, []), (x`2, [(a`1, .1)])]
DEBUG: >>>> Infer for var (type) [(a`1, [])]
DEBUG: >>>> checkExpr: inferring a type for expression 'a`1' with input context [(a`1, [])]
DEBUG: >>>>> Infer for var a`1 in context [(a`1, [])]
DEBUG: >>>>> Infer for var (type) []
DEBUG: >>>>> checkExpr: inferring a type for expression 'Type 0' with input context []
DEBUG: >>>>> checkExpr: inferred a type 'Type 1' for expression 'Type 0' with output context subject grades [] and subject type grades []
DEBUG: >>>>> Adding grade vector equality: [] = []
DEBUG: >>>>> Context grade eq var a`1 with [] and []
DEBUG: >>>> checkExpr: inferred a type 'Type 0' for expression 'a`1' with output context subject grades [(a`1, .1)] and subject type grades [(a`1, .0)]
DEBUG: >>>> Adding grade vector equality: [(a`1, .0)] = [(a`1, .0)]
DEBUG: >>>> Adding smt equality: .0 = .0
DEBUG: >>>> Context grade eq var x`2 with [(a`1, .1)] and [(a`1, .1)]
DEBUG: >>>> Adding smt equality: .1 = .1
DEBUG: >>> checkExpr: inferred a type 'a`1' for expression 'x`2' with output context subject grades [(a`1, .0), (x`2, .1)] and subject type grades [(a`1, .1), (x`2, .0)]
DEBUG: >>> ensureEqualTypes: Checking that expected type 'a`1' is equal to actual type 'a`1'
DEBUG: >>> ensureEqualTypes: Equal with type: 'a`1'
DEBUG: >>> checkExpr: inferring a type for expression 'a`1' with input context [(a`1, []), (x`2, [(a`1, .1)]), (_`4, [(a`1, .1), (x`2, .0)])]
DEBUG: >>>> Infer for var a`1 in context [(a`1, []), (x`2, [(a`1, .1)]), (_`4, [(a`1, .1), (x`2, .0)])]
DEBUG: >>>> Infer for var (type) []
DEBUG: >>>> checkExpr: inferring a type for expression 'Type 0' with input context []
DEBUG: >>>> checkExpr: inferred a type 'Type 1' for expression 'Type 0' with output context subject grades [] and subject type grades []
DEBUG: >>>> Adding grade vector equality: [] = []
DEBUG: >>>> Context grade eq var a`1 with [] and []
DEBUG: >>> checkExpr: inferred a type 'Type 0' for expression 'a`1' with output context subject grades [(a`1, .1), (x`2, .0), (_`4, .0)] and subject type grades [(a`1, .0), (x`2, .0), (_`4, .0)]
DEBUG: >>> Adding grade vector equality: [(a`1, .0), (x`2, .0), (_`4, .0)] = [(a`1, .0), (x`2, .0), (_`4, .0)]
DEBUG: >>> Adding smt equality: .0 = .0
DEBUG: >>> Adding smt equality: .0 = .0
DEBUG: >>> Adding smt equality: .0 = .0
DEBUG: >>> Adding grade vector equality: [(a`1, .1), (x`2, .0)] = [(a`1, .1), (x`2, .0)]
DEBUG: >>> Adding smt equality: .1 = .1
DEBUG: >>> Adding smt equality: .0 = .0
DEBUG: >>> Adding smt equality: .0 = .0
DEBUG: >> checkExpr: checked OK for '<x`2, x`2>' with output context subject grades [(a`1, .0), (x`2, .2)] and subject type grades [(a`1, .2), (x`2, .0)]
DEBUG: >> existentially binding (grade): '?{12}'
DEBUG: >> no grade type specified, defaulting to Extended ExactUsage
DEBUG: >> Adding smt constraint: (_`12 = .2)
DEBUG: >> Adding smt constraint: (.0 = .0)
DEBUG: > checkExpr: checked OK for '\ (x`0 : (_`12, _`13) _`11) -> <x`0, x`0>' with output context subject grades [(a`1, .0)] and subject type grades [(a`1, .3)]
DEBUG: > Adding smt constraint: (.0 = .0)
DEBUG: > Adding smt constraint: (.3 = .3)
DEBUG: checkExpr: checked OK for '\ (a`6 : (_`8, _`9) _`7) -> \ (x`10 : (_`12, _`13) _`11) -> <x`10, x`10>' with output context subject grades [] and subject type grades []
DEBUG: Asking SMT solver if the following is valid:
        ∃ _`12 : Ext Nat .
        (.3 = .3) ∧
        (.0 = .0) ∧
        (.0 = .0) ∧
        (_`12 = .2) ∧
        (.0 = .0) ∧
        (.0 = .0) ∧
        (.1 = .1) ∧
        (.0 = .0) ∧
        (.0 = .0) ∧
        (.0 = .0) ∧
        (.1 = .1) ∧
        (.0 = .0) ∧
        (.1 = .1) ∧
        (.0 = .0)
DEBUG: FUN EQN INFERENCE: finding signature for illegal`14
DEBUG: FUN EQN INFERENCE: found sig: (a`15 : (.0, .3) Type 0) -> (x`16 : (.1, .0) a`15) -> <a`15 * a`15>
DEBUG: checkExpr: checking expression 'evilDup`0' against type '(a`15 : (.0, .3) Type 0) -> (x`16 : (.1, .0) a`15) -> <a`15 * a`15>' with input context []
DEBUG: > Check fall through for evilDup`0
DEBUG: > checkExpr: inferring a type for expression 'evilDup`0' with input context []
DEBUG: > checkExpr: inferred a type '(a`1 : (.0, .3) Type 0) -> (x`2 : (_`12, .0) a`1) -> <a`1 * a`1>' for expression 'evilDup`0' with output context subject grades [] and subject type grades []
DEBUG: > ensureEqualTypes: Checking that expected type '(a`15 : (.0, .3) Type 0) -> (x`16 : (.1, .0) a`15) -> <a`15 * a`15>' is equal to actual type '(a`1 : (.0, .3) Type 0) -> (x`2 : (_`12, .0) a`1) -> <a`1 * a`1>'
DEBUG: >> Adding smt equality: .0 = .0
DEBUG: >> Adding smt equality: .3 = .3
DEBUG: >> existentially binding (grade): '?{12}'
DEBUG: >> no grade type specified, defaulting to Extended ExactUsage
DEBUG: >> Adding smt equality: _`12 = .1
DEBUG: >> Adding smt equality: .0 = .0
DEBUG: >> existentially binding (grade): '?{18}'
DEBUG: >> no grade type specified, defaulting to Extended ExactUsage
DEBUG: >> Adding smt equality: .0 = _`18
DEBUG: >> Adding smt equality: .0 = .0
DEBUG: > ensureEqualTypes: Equal with type: '(a`1 : (.0, .3) Type 0) -> (x`2 : (_`12, .0) a`1) -> <a`1 * a`1>'
DEBUG: checkExpr: checked OK for 'evilDup`0' with output context subject grades [] and subject type grades []
DEBUG: Asking SMT solver if the following is valid:
        ∃ _`18 : Ext Nat .
        ∃ _`12 : Ext Nat .
        (.0 = .0) ∧ (.0 = _`18) ∧ (.0 = .0) ∧ (_`12 = .1) ∧ (.3 = .3) ∧ (.0 = .0)
Well typed.
@dorchard
Copy link
Member

Thanks so much! I am in a very busy period but hope to get to this soon (early-mid October).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants