qsharp-community / qram

Library for Q# implementing various qRAM proposals
MIT License
52 stars 17 forks source link

Track down off-by-one (?) error in memory query #7

Closed glassnotes closed 4 years ago

glassnotes commented 4 years ago

When testing the qRAM query with the following:

//Generates binary representation of [5,4,1]=>[3,2,1]
    function GenerateMemoryData() : (Bool[],Bool[])[] {
        let fiveGivesThree = (IntAsBoolArray(5,3),IntAsBoolArray(3,2));
        let fourGivesTwo = (IntAsBoolArray(4,3),IntAsBoolArray(2,2));
        let oneGivesOne = (IntAsBoolArray(1,3),IntAsBoolArray(1,2));
        return [fiveGivesThree, fourGivesTwo, oneGivesOne];
    }
}

Addresses 5 and 4 produce the correct results, however querying 1 produces a 0 when it should produce a 1. All other tests seem to pass...

crazy4pi314 commented 4 years ago

So this should be fixed with #8, the issue was basically that it was not clear how ControlOnBitString was behaving when the control value was smaller than the register it needed to control on. Will follow-up with an issue on the Q# libraries repo to request documentation for what happens in that case. It turned out that it was just controlling on 1 for bits that were in the control register but not in the control bit string.

crazy4pi314 commented 4 years ago

Follow-up on official repos here: https://github.com/microsoft/QuantumLibraries/issues/262