mit-plv / koika

A core language for rule-based hardware design 🦑
GNU General Public License v3.0
139 stars 9 forks source link

Multiplier correctness example #17

Open vaishnavi08 opened 3 years ago

vaishnavi08 commented 3 years ago

Hi, I'm new to coq and I am facing a few issues with understanding the code MultiplierCorrectness.v. I could understand till the lemma mul_to_partial_mul. I don't understand what the rest of the code does. @math-fehr It would be really helpful if I could get what are we trying to prove in lemmas enq_preserves_invariant, deq_preserves_invariant, step_preserves_result_invariant, step_preserves_result_finished_invariant. It would be really helpful for beginners like me if a few comments could be added giving the description of the lemma.

I am currently working on proving correctness of different modules of a processor based on riscv architecture. I would also like to start a discussion (if interested) as to how can we prove the functionality and timing correctness of different modules. For instance, I currently wrote a koika code for alu module of the processor. I was thinking how could the functionality correctness of this module could be proved with the help of coq (ie, what lemmas would be good to prove since its not a mathematical problem).

Any sort of idea or suggestion would be really helpful. Thank you :)

math-fehr commented 3 years ago

Hi! Sorry for the delay. I'm currently a bit busy, so here is the main idea.

We want to show that our multiplier state satisfy some invariants at each cycle:

Then, the lemmas you mentionned are used to prove that the invariants will hold for each cycle. For example, enq_preserves_invariant proves that after a enq rule, if the invariants held, then the invariants will still hold. However, we need to be careful and make sure that the variables used inside the multiplier module were not previously written, otherwise the rule would not trigger.

For proving functional and timing correctness of modules, maybe @cpitclaudel or @threonorm would have some ideas. I haven't worked with koika for the last year, so I don't know what kind of progress has been made!