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

Builtin: Capture stage #1334

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Builtin: Capture stage #1334

wants to merge 5 commits into from

Conversation

chriseth
Copy link
Member

@chriseth chriseth commented Apr 30, 2024

Implements part of #424

@chriseth chriseth changed the base branch from main to constr_is_enum April 30, 2024 18:28
self.extract_new_constraints()
.into_iter()
.map(|id| {
(match id.kind {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should maybe move to a helper

Base automatically changed from constr_is_enum to main May 1, 2024 10:57
@chriseth chriseth force-pushed the capture_stage branch 3 times, most recently from 948b310 to b3b9546 Compare May 23, 2024 11:02
@chriseth chriseth marked this pull request as ready for review May 23, 2024 15:30
std::prover::capture_stage(f);
"#;
analyze_string::<GoldilocksField>(input);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what these do? Not sure I fully get it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that you call capture_stage to capture a full stage. This means that before the call to capture_stage, there cannot be any constraints or witness columns in the environment. Since capture_stage increments the stage, they would have a different stage index than those after the call to capture_stage.

I would also prefer to do this differently so that we don't need this and assign the correct stage automatically, but I don't know how to do this currently, and I also don't think that this would occur often.

pub fn capture_stage_non_fresh_inter() {
let input = r#"
namespace std::prover;
let capture_stage: (-> int) -> Constr[] = 9;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why =9? Do we need a constraint here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This defines a builtin. Since the builtin is "overridden" during execution and type checking, I always like to assign a value that will create an error both at type checking and during runtime when the value is used instead of being overridden.

Now that we have the prelude mechanism, we could use a fixed identifier like "std::prelude::builtin" (which is a builtin itself that always fails or something).

// Just use the second constraint.
std::prover::capture_stage(f)[1];
let w;
w = 10;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd expect this to fail since there are other columns and constraints besides the call to capture_stage. Why doesn't it fail?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this is a bit weird. In the end, you want to process the constraints that are returned by the call to capture_stage. Processing the constraints involves adding new constraints and witness column (but at a higher stage).

My current way to deal with it is that it's not OK to have witness columns or constraints above the call to capture_stage, but it is OK to have them below. The reason is that we only know the stage of witness columns once we return from capture_stage. Another way would be to retroactively change the stage of all witness columns that are already present in the condenser when we call capture_stage. This might indeed be a bit more uniform.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yea this "above" and "below" separation is kinda weird. Why not have a function that receives the results of capture_stage as argument and then adds constraints on top of that?

pil-analyzer/src/condenser.rs Outdated Show resolved Hide resolved
pil-analyzer/src/condenser.rs Show resolved Hide resolved
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

Successfully merging this pull request may close these issues.

None yet

2 participants