Coder Social home page Coder Social logo

Comments (5)

nikomatsakis avatar nikomatsakis commented on June 25, 2024

Evaluating the "cannot prove" rule on the various examples shows that it works well, modulo the imprecision around not and forall binders I mentioned:

Example 1. In the first case (forall<T> { T: Foo }), trying to unify T: Foo against the impl would yield CannotProve, which would lead to an overall CannotProve result. Negating CannotProve again yields CannotProve. This successfully indicates that the goal may be provable for some instantiations (but not all).

Example 2. Negation and binders. We would yield CannotProve for both; to do better requires a different fulfillment context desugaring.

Example 3. Unifying the T: Iterator<Item = i32> goal with the impl would yield CannotProve, and hence we would drop that rule in favor of T: Iterator<Item = i32> from the environment.

from chalk.

nikomatsakis avatar nikomatsakis commented on June 25, 2024

After #45, this might be basically done -- the only thing left might be changing how we handle negative reasoning, if we decide we want more precise results. That could also be a separate bug.

from chalk.

aturon avatar aturon commented on June 25, 2024

Definite: The goal will definitely work. (Does this mean something closer to Unique?)

That's not quite right. The reading is rather: if this goal is to ever work, the existentials must take the given values.

from chalk.

nikomatsakis avatar nikomatsakis commented on June 25, 2024

@aturon updated

from chalk.

nikomatsakis avatar nikomatsakis commented on June 25, 2024

So I resolved this in #60. The first key observation is that free universally quantified variables (i.e., ForAll) cannot be considered ground and require some special treatment (this is why for<A, B> { not { A = B } } was giving us such trouble). The second is that the behavior of existentials in that case is exactly what we want. So essentially was #60 does is to say that, to solve a query like not { !1 = !2 }, we will check whether ?1 = ?2 has any answers. In other words, convert the universally quantified variables into existential ones. This allows us to drop "cannot prove" entirely.

Revisiting my examples:

Example 1.

trait Foo {}
struct i32 {}
impl Foo for i32 {}

forall<T> { T: Foo } // false
forall<T> { not { T: Foo } } // false -- ?T: Foo has an answer

Example 2.

not { forall<T, U> { T = U } } // true
forall<T, U> { not { T = U } } // false, ?T = ?U has an answer

Example 3.

T: Iterator<Item = i32> from environment is the only choice.

from chalk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.