Coder Social home page Coder Social logo

Comments (4)

rachitnigam avatar rachitnigam commented on August 15, 2024

How to encode coverage constraints for Filament's linearity check?

For example:

bundle a{#K+1};
a{0} = 20
for #i in 0..#K-1 {
  a{#i+1} = 30
}
a{#K} = 10

The following asks whether there is any point that is not any of these indices:

exists #p. 
  #p \in [0, K] /\                   -- (1)
  (
    !(#p == 0) \/                    -- (2)
    !(#p >= 1 /\ #p < K) \/          -- (3)
    !(#p == #K)                      -- (4)
  )

Constraints are:

  1. #p is a valid index into the bundle
  2. #p is not {0} which is written to in the first write
  3. #p is not in the range implied by [0, K-1) incremented by 1 because of the #i+1 expression
    1. It's not clear how to support a{2*#i} or other expressions which don't generate continuous sets.
  4. Same as (1)

Since p is implicitly existentially quantified, we can just ask the solver to provide a model and there is a model, then we've found an index that is not assigned to.

from filament.

rachitnigam avatar rachitnigam commented on August 15, 2024

Another approach is using forall (😭 ):

exists #p. 
  #p \in [0, K] /\                         -- (1)
  (
    #p != 0) \/                            -- (2)
    (forall #i. 
	    #i >= 0 /\ #i < K-1 /\ #p != #i+1) -- (3)
	\/          
    #p != #K                               -- (4)
  )

While annoying, this does get around the problem of dealing with complex indexing expressions like 2*#i. The final approach is making this a best effort check and leave it to monomorphization to track if all locations in a bundle are assigned to.

from filament.

rachitnigam avatar rachitnigam commented on August 15, 2024

Subsumes #46

from filament.

rachitnigam avatar rachitnigam commented on August 15, 2024

Much like #85, this is not strictly required for Filament's type soundness guarantees. The type soundness guarantee only holds if all the ports are linearly assigned. However, I think it makes sense to keep this around if not for parametric modules then at least as a elaboration check

from filament.

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.